summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/warn-assignment-condition.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Unrevert r166268, reverted in r166272, with a fix for the issue which NickRichard Smith2012-10-211-3/+3
| | | | | | | | | | | | | | | | | | | | | found: if an overloaded operator& is present before a template definition, the expression &T::foo is represented as a CXXOperatorCallExpr, not as a UnaryOperator, so we didn't notice that it's permitted to reference a non-static data member of an unrelated class. While investigating this, I discovered another problem in this area: we are treating template default arguments as unevaluated contexts during substitution, resulting in performing incorrect checks for uses of non-static data members in C++11. That is not fixed by this patch (I'll look into this soon; it's related to the failure to correctly instantiate constexpr function templates), but was resulting in this bug not firing in C++11 mode (except with -Wc++98-compat). Original message: PR14124: When performing template instantiation of a qualified-id outside of a class, diagnose if the qualified-id instantiates to a non-static class member. llvm-svn: 166385
* Revert r166268, this fix for a crash-on-invalid introduced a rejects-valid.Nick Lewycky2012-10-191-3/+3
| | | | | | Richard has an unreduced testcase to work with. llvm-svn: 166272
* PR14124: When performing template instantiation of a qualified-id outside of aRichard Smith2012-10-191-3/+3
| | | | | | class, diagnose if the qualified-id instantiates to a non-static class member. llvm-svn: 166268
* Place 'equality comparison with extraneous parentheses...' into a subgroup ↵Ted Kremenek2011-09-061-0/+6
| | | | | | of -Wparentheses called -Wparentheses-equality. llvm-svn: 139180
* Don't do the checks of Sema::DiagnoseEqualityWithExtraParens() on ↵Argyrios Kyrtzidis2011-03-281-0/+13
| | | | | | type-dependent expressions. Fixes rdar://9027658. llvm-svn: 128437
* Remove redundant check to not warn for warn_equality_with_extra_parens if we ↵Ted Kremenek2011-02-021-9/+0
| | | | | | are in a macro. This is checked twice. llvm-svn: 124714
* Don't warn about extraneous '()' around a comparison if it occurs within a ↵Ted Kremenek2011-02-011-0/+10
| | | | | | | | | macro. Macros frequently contain extra '()' to make instantiation less error prone. This warning was flagging a ton of times on postgresql because of its use of macros. llvm-svn: 124695
* Don't warn for "if ((a == b))" if the parens came from a macro. Thanks to ↵Argyrios Kyrtzidis2011-02-011-0/+4
| | | | | | Fariborz for the hint! llvm-svn: 124689
* For "if ((a == b))" only warn if 'a' is a modifiable l-value. Caught by John!Argyrios Kyrtzidis2011-02-011-0/+10
| | | | llvm-svn: 124675
* Warn for "if ((a == b))" where the equality expression is needlessly wrapped ↵Argyrios Kyrtzidis2011-02-011-0/+4
| | | | | | | | | | inside parentheses. It's highly likely that the user intended an assignment used as condition. Addresses rdar://8848646. llvm-svn: 124668
* Warn about the use of unparenthesized |= in conditionals (which may beDouglas Gregor2011-01-191-0/+10
| | | | | | a typo for !=). Fixes PR9001, from Hans Wennborg! llvm-svn: 123836
* When diagnosing suspicious precedence or assignments, move the fix-itDouglas Gregor2010-04-141-16/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | that adds parentheses from the main diagnostic down to a new note. This way, when the fix-it represents a choice between two options, each of the options is associted with a note. There is no default option in such cases. For example: /Users/dgregor/t.c:2:9: warning: & has lower precedence than ==; == will be evaluated first [-Wparentheses] if (x & y == 0) { ^~~~~~~~ /Users/dgregor/t.c:2:9: note: place parentheses around the & expression to evaluate it first if (x & y == 0) { ^ ( ) /Users/dgregor/t.c:2:9: note: place parentheses around the == expression to silence this warning if (x & y == 0) { ^ ( ) llvm-svn: 101249
* Improve the fix-its for -Wparentheses to ensure that the fix-itDouglas Gregor2010-01-081-16/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | suggestions follow recovery. Additionally, add a note to these diagnostics which suggests a fix-it for changing the behavior to what the user probably meant. Examples: t.cpp:2:9: warning: & has lower precedence than ==; == will be evaluated first [-Wparentheses] if (i & j == k) { ^~~~~~~~ ( ) t.cpp:2:9: note: place parentheses around the & expression to evaluate it first if (i & j == k) { ^ ( ) t.cpp:14:9: warning: using the result of an assignment as a condition without parentheses [-Wparentheses] if (i = f()) { ~~^~~~~ ( ) t.cpp:14:9: note: use '==' to turn this assignment into an equality comparison if (i = f()) { ^ == llvm-svn: 92975
* 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
* Implement -Wparentheses: warn about using assignments in contexts that requireJohn McCall2009-10-121-0/+65
conditions. Add a fixit to insert the parentheses. Also fix a very minor possible memory leak in 'for' conditions. Fixes PR 4876 and rdar://problem/7289172 llvm-svn: 83907
OpenPOWER on IntegriCloud