]> granicus.if.org Git - clang/commitdiff
Place 'equality comparison with extraneous parentheses...' into a subgroup of -Wparen...
authorTed Kremenek <kremenek@apple.com>
Tue, 6 Sep 2011 20:58:32 +0000 (20:58 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 6 Sep 2011 20:58:32 +0000 (20:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139180 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
test/SemaCXX/warn-assignment-condition.cpp

index 35ff035aa05ef8affc14e7d754ac03e616941226..7ce4696db2d2e172d86be7f7d52482952e9f4e8b 100644 (file)
@@ -209,9 +209,11 @@ def DuplicateArgDecl : DiagGroup<"duplicate-method-arg">;
 // missing parentheses;  it is off by default.  We do not include it
 // in -Wparentheses because most users who use -Wparentheses explicitly
 // do not want these warnings.
+def ParenthesesOnEquality : DiagGroup<"parentheses-equality">;
 def Parentheses : DiagGroup<"parentheses",
                             [LogicalOpParentheses,
-                             BitwiseOpParentheses]>;
+                             BitwiseOpParentheses,
+                             ParenthesesOnEquality]>;
 
 // -Wconversion has its own warnings, but we split a few out for
 // legacy reasons:
index f0c7a5cad478df160d0d876c63411f44e39f28d7..4143fef781d51d2afcb4f085fb38683285a3707a 100644 (file)
@@ -3668,7 +3668,7 @@ def note_condition_assign_silence : Note<
   "place parentheses around the assignment to silence this warning">;
 
 def warn_equality_with_extra_parens : Warning<"equality comparison with "
-  "extraneous parentheses">, InGroup<Parentheses>;
+  "extraneous parentheses">, InGroup<ParenthesesOnEquality>;
 def note_equality_comparison_to_assign : Note<
   "use '=' to turn this equality comparison into an assignment">;
 def note_equality_comparison_silence : Note<
index c0ef35b252d85d5fc3160955f82a01276b07956c..04f2e79525475b39e0b0fa8fc2832eb762a4e9af 100644 (file)
@@ -109,6 +109,12 @@ void test() {
   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}}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wparentheses-equality"
+  if ((x == 5)) {} // no-warning
+#pragma clang diagnostic pop
+
   if ((5 == x)) {}
 
 #define EQ(x,y) ((x) == (y))