summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/decl-expr-ambiguity.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Try to recognise hidden tag type names in potential declarations, in ObjC ↵Argyrios Kyrtzidis2013-05-071-0/+1
| | | | | | | | code as well. rdar://13829073 llvm-svn: 181345
* Implement GCC's -Wint-to-pointer-cast.David Blaikie2012-10-161-1/+1
| | | | | | | | | | | | This implementation doesn't warn on anything that GCC doesn't warn on with the exception of templates specializations (GCC doesn't warn, Clang does). The specific skipped cases (boolean, constant expressions, enums) are open for debate/adjustment if anyone wants to demonstrate that GCC is being overly conservative here. The only really obvious false positive I found was in the Clang regression suite's MPI test - apparently MPI uses specific flag values in pointer constants. (eg: #define FOO (void*)~0) llvm-svn: 166039
* Extend the ',' versus ';' diagnostic for -Wvexing-parse to cover the ↵Richard Smith2012-07-301-0/+5
| | | | | | with-arguments case as well as the no-arguments case. llvm-svn: 160999
* Improvements to vexing-parse warnings. Make the no-parameters case moreRichard Smith2012-07-301-4/+4
| | | | | | | | | | | | | accurate by asking the parser whether there was an ambiguity rather than trying to reverse-engineer it from the DeclSpec. Make the with-parameters case have better diagnostics by using semantic information to drive the warning, improving the diagnostics and adding a fixit. Patch by Nikola Smiljanic. Some minor changes by me to suppress diagnostics for declarations of the form 'T (*x)(...)', which seem to have a very high false positive rate, and to reduce indentation in 'warnAboutAmbiguousFunction'. llvm-svn: 160998
* Try harder to recognize hidden tag type names in potential declarations insteadKaelyn Uhrain2012-05-021-0/+20
| | | | | | of giving unhelpful errors about undeclared identifers and missing semicolons. llvm-svn: 155965
* Don't crash while trying to diagnose a function declared at block scope with anRichard Smith2012-01-131-0/+4
| | | | | | incomplete return type. llvm-svn: 148088
* Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:Richard Smith2012-01-121-3/+17
| | | | | | | | | | | | | | | | | | | | | | | - If the declarator is at the start of a line, and the previous line contained another declarator and ended with a comma, then that comma was probably a typo for a semicolon: int n = 0, m = 1, l = 2, // k = 5; myImportantFunctionCall(); // oops! - If removing the parentheses would correctly initialize the object, then produce a note suggesting that fix. - Otherwise, if there is a simple initializer we can suggest which performs value-initialization, then provide a note suggesting a correction to that initializer. Sema::Declarator now tracks the location of the comma prior to the declarator in the declaration, if there is one, to facilitate providing the note. The code to determine an appropriate initializer from the -Wuninitialized warning has been factored out to allow use in both that and -Wvexing-parse. llvm-svn: 148072
* Restore some parts of this test which were accidental reverted in r147649.Richard Smith2012-01-091-0/+6
| | | | | | Thanks to David Blaikie for pointing this out. llvm-svn: 147783
* David Blaikie and Chandler would like us to diagnoseRichard Smith2012-01-061-7/+3
| | | | | | | | int f(); in function scopes under -Wvexing-parse, so now we do. llvm-svn: 147649
* Tweak to r147599 for PR10828: Move the check from the parser into sema, and useRichard Smith2012-01-061-3/+7
| | | | | | | the Semantic Powers to only warn on class types (or dependent types), where the constructor or destructor could do something interesting. llvm-svn: 147642
* PR10828: Produce a warning when a no-arguments function is declared in blockRichard Smith2012-01-051-2/+7
| | | | | | | | | | | | | | | | | scope, when no other indication is provided that the user intended to declare a function rather than a variable. Remove some false positives from the existing 'parentheses disambiguated as a function' warning by suppressing it when the declaration is marked as 'typedef' or 'extern'. Add a new warning group -Wvexing-parse containing both of these warnings. The new warning is enabled by default; despite a number of false positives (and one bug) in clang's test-suite, I have only found genuine bugs with it when running it over a significant quantity of real C++ code. llvm-svn: 147599
* Although we currently have explicit lvalue-to-rvalue conversions, they'reJohn McCall2010-12-041-2/+2
| | | | | | | | | | | | | | | | | | | not actually frequently used, because ImpCastExprToType only creates a node if the types differ. So explicitly create an ICE in the lvalue-to-rvalue conversion code in DefaultFunctionArrayLvalueConversion() as well as several other new places, and consistently deal with the consequences throughout the compiler. In addition, introduce a new cast kind for loading an ObjCProperty l-value, and make sure we emit those nodes whenever an ObjCProperty l-value appears that's not on the LHS of an assignment operator. This breaks a couple of rewriter tests, which I've x-failed until future development occurs on the rewriter. Ted Kremenek kindly contributed the analyzer workarounds in this patch. llvm-svn: 120890
* Revert r114316, -Wunused-value enabled by default was intended.Argyrios Kyrtzidis2010-09-191-2/+2
| | | | llvm-svn: 114318
* Make -Wunused-value off by default, matching GCC. Fixes rdar://7126194.Argyrios Kyrtzidis2010-09-191-2/+2
| | | | llvm-svn: 114316
* Use the new-initialization code for initializing scalars with aDouglas Gregor2010-09-081-1/+1
| | | | | | | | function-style cast. Previously, we had a (redundant, incorrect) semantic-checking path for non-class types, which allowed value-initialization of a reference type and then crashed. llvm-svn: 113415
* Improve the unused-value check to look into comma expressions and filter outJohn McCall2010-03-121-1/+1
| | | | | | | | voids in sub-expressions. Patch by Mike M! Fixes PR4806. llvm-svn: 98335
* Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar2009-12-151-1/+1
| | | | | | | | | - This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it can be useful to redefine what gets run as 'clang -cc1' (for example, to set a default target). llvm-svn: 91446
* Ok, ok, I give in. Fix tests for unused result warning.Daniel Dunbar2009-08-011-1/+1
| | | | llvm-svn: 77780
* Implement C++ semantics for C-style and functional-style casts. This ↵Sebastian Redl2009-07-251-1/+1
| | | | | | | | regresses Clang extension conversions, like vectors, but allows conversions via constructors and conversion operators. Add custom conversions to static_cast. llvm-svn: 77076
* Use "()" instead of "(void)" when pretty-printing a parameter-less function ↵Argyrios Kyrtzidis2009-06-031-1/+1
| | | | | | type for C++. llvm-svn: 72747
* Make the RAII extension warning silencing for __extension__ a bit Eli Friedman2009-05-161-1/+1
| | | | | | | narrower, so it doesn't catch expresions that aren't sub-expressions of __extension__ operator. llvm-svn: 71967
* Emit keyword extension warning in all modes, not just C99 mode.Eli Friedman2009-04-281-2/+2
| | | | llvm-svn: 70283
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Initial implementation of argument dependent lookup (a.k.a. ADL,Douglas Gregor2009-02-041-2/+2
| | | | | | | | | | | | a.k.a. Koenig lookup) in C++. Most of the pieces are in place, but for two: - In an unqualified call g(x), even if the name does not refer to anything in the current scope, we can still find functions named "g" based on ADL. We don't yet have this ability. - ADL will need updating for friend functions and templates. llvm-svn: 63692
* Removed the warningDouglas Gregor2008-12-171-6/+6
| | | | | | | | | | warning: statement was disambiguated as declaration because it is currently firing in cases where the declaration would not actually parse as a statement. We'd love to bring this warning back if we can make it more accurate. llvm-svn: 61137
* Make all the 'redefinition' diagnostics more consistent, and make the Chris Lattner2008-11-231-1/+1
| | | | | | "previously defined here" diagnostics all notes. llvm-svn: 59920
* implement a fixme by making warnings for ++/-- on non-modifiable-lvalues better.Chris Lattner2008-11-181-2/+2
| | | | llvm-svn: 59484
* Initial step toward supporting qualification conversions (C++ 4.4).Douglas Gregor2008-10-211-1/+1
| | | | | | | | | | | | | | | | | | | | Changes: - Sema::IsQualificationConversion determines whether we have a qualification conversion. - Sema::CheckSingleAssignment constraints now follows the C++ rules in C++, performing an implicit conversion from the right-hand side to the type of the left-hand side rather than checking based on the C notion of "compatibility". We now rely on the implicit-conversion code to determine whether the conversion can happen or not. Sema::TryCopyInitialization has an ugly reference-related hack to cope with the initialization of references, for now. - When building DeclRefExprs, strip away the reference type, since there are no expressions whose type is a reference. We'll need to do this throughout Sema. - Expr::isLvalue now permits functions to be lvalues in C++ (but not in C). llvm-svn: 57935
* Tweak an expected-error to match the output. IMHO it is better to diagnose ↵Gabor Greif2008-10-211-1/+1
| | | | | | 'int (void)' because it has the same meaning in C and C++. llvm-svn: 57901
* Issue a warning when there's an ambiguous function declarator (that could be ↵Argyrios Kyrtzidis2008-10-151-1/+2
| | | | | | | | a direct initializer for a variable defition). Idea originated from here: http://thread.gmane.org/gmane.comp.gcc.devel/101524 llvm-svn: 57609
* Add some text from the C++ standard and additional ambiguity resolution tests.Argyrios Kyrtzidis2008-10-051-1/+16
| | | | | | No funcitonality change. llvm-svn: 57136
* Handle ambiguities between expressions and type-ids that occur inside ↵Argyrios Kyrtzidis2008-10-051-0/+2
| | | | | | | | | parentheses, e.g.: sizeof(int()) -> "int()" is type-id sizeof(int()+1) -> "int()+1" is expression. llvm-svn: 57131
* Found a subtle bug caused by an implicit enum-to-bool conversion (of the ↵Argyrios Kyrtzidis2008-10-051-0/+1
| | | | | | | | | | | | TentativeParsingResult enum). This was the motivation of the following changes: -'TentativeParsingResult' enum is replaced by a 'TPResult' class that basically encapsulates the enum. -TPR_true, TPR_false, TPR_ambiguous, and TPR_error enum constants are replaced by TPResult::True(), TPResult::False(), etc. calls that return a TPResult object. -Also fixed the subtle bug in Parser::isCXXFunctionDeclarator (caught by the above changes as a compilation error). llvm-svn: 57125
* Disambiguate between a declaration or an expression, in the ↵Argyrios Kyrtzidis2008-10-051-0/+1
| | | | | | 'for-init-statement' part of a 'for' statement. llvm-svn: 57112
* Fix Parser::isCXXConditionDeclaration to properly resolve declarations.Argyrios Kyrtzidis2008-10-051-0/+1
| | | | llvm-svn: 57111
* Disambiguate between a declaration or expression for the 'condition' part of ↵Argyrios Kyrtzidis2008-10-051-0/+1
| | | | | | a if/switch/while/for statement. llvm-svn: 57109
* Consider GNU attributes when doing ambiguity resolution.Argyrios Kyrtzidis2008-10-051-0/+1
| | | | llvm-svn: 57108
* Resolve ambiguous C++ statements (C++ 6.8p1).Argyrios Kyrtzidis2008-10-051-0/+20
'ParseTentative.cpp' implements the functionality needed to resolve ambiguous C++ statements, to either a declaration or an expression, by "tentatively parsing" them. llvm-svn: 57084
OpenPOWER on IntegriCloud