aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/warn-assignment-condition.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-02-01 18:24:22 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-02-01 18:24:22 +0000
commit0e2dc3a1159806c8303b0979be1ce1526cc64ed3 (patch)
treeaf7b32e291a316e1c5e7fae41b03e46fece42813 /test/SemaCXX/warn-assignment-condition.cpp
parent63b54104700873dc4a5b95b3108052580b5370e7 (diff)
Warn for "if ((a == b))" where the equality expression is needlessly wrapped inside parentheses.
It's highly likely that the user intended an assignment used as condition. Addresses rdar://8848646. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124668 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/warn-assignment-condition.cpp')
-rw-r--r--test/SemaCXX/warn-assignment-condition.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/SemaCXX/warn-assignment-condition.cpp b/test/SemaCXX/warn-assignment-condition.cpp
index 9dcffbfe84..48cc137dac 100644
--- a/test/SemaCXX/warn-assignment-condition.cpp
+++ b/test/SemaCXX/warn-assignment-condition.cpp
@@ -105,4 +105,8 @@ void test() {
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}}
+
+ if ((x == 5)) {} // expected-warning {{equality comparison with extraneous parentheses}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}} \
+ // expected-note {{remove extraneous parentheses around the comparison to silence this warning}}
}