summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/condition.cpp
Commit message (Collapse)AuthorAgeFilesLines
* PR28373: fix crash-on-invalid if the condition of an if-statement fails ↵Richard Smith2016-06-301-0/+4
| | | | | | typo-correction. llvm-svn: 274260
* Unify diagnostics for type defintitions in bad contextsReid Kleckner2015-12-111-4/+4
| | | | | | | The message for a type definition in an "if" condition was different from the other three for no particular reason. llvm-svn: 255372
* Don't treat a non-deduced 'auto' type as being type-dependent. Instead, thereRichard Smith2013-04-301-5/+3
| | | | | | | | are now two distinct canonical 'AutoType's: one is the undeduced 'auto' placeholder type, and the other is a deduced-but-dependent type. All deduced-to-a-non-dependent-type cases are still non-canonical. llvm-svn: 180789
* Fixed an assertion failure triggered by invalid code.Enea Zaffanella2013-01-111-1/+10
| | | | | | | | Set invalid type of declarator after emitting error diagnostics, so that it won't be later considered when instantiating the template. Added test5_inst in test/SemaCXX/condition.cpp for non-regression. llvm-svn: 172201
* Improvements to vexing-parse warnings. Make the no-parameters case moreRichard Smith2012-07-301-1/+1
| | | | | | | | | | | | | 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
* Generalize -Wempty-body: warn when statement body is empty (closes: PR11329)Dmitri Gribenko2012-02-141-1/+2
| | | | | | | | | | | | | | * if, switch, range-based for: warn if semicolon is on the same line. * for, while: warn if semicolon is on the same line and either next statement is compound statement or next statement has more indentation. Replacing the semicolon with {} or moving the semicolon to the next line will always silence the warning. Tests from SemaCXX/if-empty-body.cpp merged into SemaCXX/warn-empty-body.cpp. llvm-svn: 150515
* Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:Richard Smith2012-01-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | - 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
* David Blaikie and Chandler would like us to diagnoseRichard Smith2012-01-061-1/+1
| | | | | | | | int f(); in function scopes under -Wvexing-parse, so now we do. llvm-svn: 147649
* Add notes for suppressing and (if it's a zero-arg function returning bool) ↵David Blaikie2011-12-091-1/+2
| | | | | | fixing the function-to-bool conversion warning. llvm-svn: 146280
* Switch a cast to a dyn_cast and check the pointer before using. Fixes a crashRichard Trieu2011-12-061-0/+4
| | | | | | | | | | in the following code: void test4(bool (&x)(void)) { while (x); } llvm-svn: 145918
* Add a warning for implicit conversion from function literals (and staticLang Hames2011-12-051-1/+1
| | | | | | | | | | | | | methods) to bool. E.g. void foo() {} if (f) { ... // <- Warns here. } Only applies to non-weak functions, and does not apply if the function address is taken explicitly with the addr-of operator. llvm-svn: 145849
* Remove the call to GetTypeForDeclarator in Sema::ActOnCXXConditionDeclaration.Argyrios Kyrtzidis2011-06-281-0/+1
| | | | | | No functionality change. llvm-svn: 133984
* Cut down a few of the excess errors in the test.Argyrios Kyrtzidis2011-06-281-2/+2
| | | | llvm-svn: 133983
* When deciding whether to complain about the type of a boolean condition, useJohn McCall2010-12-041-0/+9
| | | | | | the type of the expression *after* array/function decay. llvm-svn: 120895
* Pretty-print anonymous types using their kind and presumed location.John McCall2010-03-191-1/+1
| | | | | | Fixes PR6643. Patch by Mike M! llvm-svn: 98946
* For -Wswitch-enum warnings, be sure to look through typedefs of enumDouglas Gregor2010-02-171-1/+2
| | | | | | types. Fixes <rdar://problem/7643909>. llvm-svn: 96531
* Improve the reporting of non-viable overload candidates by noting the reasonJohn McCall2010-01-131-2/+2
| | | | | | | | why the candidate is non-viable. There's a lot we can do to improve this, but it's a good start. Further improvements should probably be integrated with the bad-initialization reporting routines. llvm-svn: 93277
* Improve the diagnostics used to report implicitly-generated class membersJohn McCall2010-01-061-2/+2
| | | | | | | | | as parts of overload sets. Also, refer to constructors as 'constructors' rather than functions. Adjust a lot of tests. llvm-svn: 92832
* Initialization improvements: addition of string initialization and a fewEli Friedman2009-12-191-2/+2
| | | | | | | | small bug fixes in SemaInit, switch over SemaDecl to use it more often, and change a bunch of diagnostics which are different with the new initialization code. llvm-svn: 91767
* Switch more of Sema::CheckInitializerTypes over toDouglas Gregor2009-12-191-2/+2
| | | | | | | | | | InitializationSequence. Specially, switch initialization of a C++ class type (either copy- or direct-initialization). Also, make sure that we create an elidable copy-construction when performing copy initialization of a C++ class variable. Fixes PR5826. llvm-svn: 91750
* 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
* Eliminate CXXConditionDeclExpr with extreme prejudice.Douglas Gregor2009-11-251-0/+8
| | | | | | | | | | | | | | | | | All statements that involve conditions can now hold on to a separate condition declaration (a VarDecl), and will use a DeclRefExpr referring to that VarDecl for the condition expression. ForStmts now have such a VarDecl (I'd missed those in previous commits). Also, since this change reworks the Action interface for if/while/switch/for, use FullExprArg for the full expressions in those expressions, to ensure that we're emitting Note that we are (still) not generating the right cleanups for condition variables in for statements. That will be a follow-on commit. llvm-svn: 89817
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Make one expected-diag directive match exactly one actual diagnostic.Sebastian Redl2009-02-071-1/+1
| | | | | | This uncovers some bugs, so several test cases now fail. llvm-svn: 64025
* Introduce support for C++0x explicit conversion operators (N2437)Douglas Gregor2009-01-141-6/+6
| | | | | | | | | | Small cleanup in the handling of user-defined conversions. Also, implement an optimization when constructing a call. We avoid recomputing implicit conversion sequences and instead use those conversion sequences that we computed as part of overload resolution. llvm-svn: 62231
* Correct the order in which we cope with end-of-class-definitionDouglas Gregor2008-12-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | semantics and improve our handling of default arguments. Specifically, we follow this order: - As soon as the see the '}' in the class definition, the class is complete and we add any implicit declarations (default constructor, copy constructor, etc.) to the class. - If there are any default function arguments, parse them - If there were any inline member function definitions, parse them As part of this change, we now keep track of the the fact that we've seen unparsed default function arguments within the AST. See the new ParmVarDecl::hasUnparsedDefaultArg member. This allows us to properly cope with calls inside default function arguments to other functions where we're making use of the default arguments. Made some C++ error messages regarding failed initializations more specific. llvm-svn: 61406
* Make all the 'redefinition' diagnostics more consistent, and make the Chris Lattner2008-11-231-20/+20
| | | | | | "previously defined here" diagnostics all notes. llvm-svn: 59920
* Fix test cases broken by quote normalization in diagnostics.Sebastian Redl2008-11-221-1/+1
| | | | llvm-svn: 59888
* Implement semantic checking of static_cast and dynamic_cast.Sebastian Redl2008-10-311-1/+1
| | | | llvm-svn: 58509
* Do implicit conversion to bool for the condition in a do-while statement.Argyrios Kyrtzidis2008-09-111-0/+2
| | | | llvm-svn: 56096
* In the 'condition.cpp' test case, make sure that condition declarations are ↵Argyrios Kyrtzidis2008-09-101-3/+3
| | | | | | local to the statement. llvm-svn: 56077
* Implement Sema support for the 'condition' part of C++ selection-statements ↵Argyrios Kyrtzidis2008-09-101-0/+33
and iteration-statements (if/switch/while/for). llvm-svn: 56044
OpenPOWER on IntegriCloud