diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-01-19 16:50:08 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-01-19 16:50:08 +0000 |
commit | 92c3a04f3ec683f279814b0eb6d6271b3fd3a219 (patch) | |
tree | 8aa282a17c24cd6659392c07d93b76226de96dae /test/SemaCXX/warn-assignment-condition.cpp | |
parent | 9ea416e598fa3cb09d67d514c4519c99abb81321 (diff) |
Warn about the use of unparenthesized |= in conditionals (which may be
a typo for !=). Fixes PR9001, from Hans Wennborg!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123836 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/warn-assignment-condition.cpp')
-rw-r--r-- | test/SemaCXX/warn-assignment-condition.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/SemaCXX/warn-assignment-condition.cpp b/test/SemaCXX/warn-assignment-condition.cpp index e5a3425804..9dcffbfe84 100644 --- a/test/SemaCXX/warn-assignment-condition.cpp +++ b/test/SemaCXX/warn-assignment-condition.cpp @@ -3,6 +3,7 @@ struct A { int foo(); friend A operator+(const A&, const A&); + A operator|=(const A&); operator bool(); }; @@ -95,4 +96,13 @@ void test() { // expected-note{{use '==' to turn this assignment into an equality comparison}} \ // expected-note{{place parentheses around the assignment to silence this warning}} for (; (a = b + b); ) {} + + // Compound assignments. + if (x |= 2) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \ + // expected-note{{use '!=' to turn this compound assignment into an inequality comparison}} \ + // expected-note{{place parentheses around the assignment to silence this warning}} + + if (a |= b) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \ + // expected-note{{use '!=' to turn this compound assignment into an inequality comparison}} \ + // expected-note{{place parentheses around the assignment to silence this warning}} } |