From: Ted Kremenek Date: Tue, 6 Sep 2011 20:58:32 +0000 (+0000) Subject: Place 'equality comparison with extraneous parentheses...' into a subgroup of -Wparen... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f1bb0b049f7292336d3e2229a56e05003820b0f4;p=clang Place 'equality comparison with extraneous parentheses...' into a subgroup of -Wparentheses called -Wparentheses-equality. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139180 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index 35ff035aa0..7ce4696db2 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -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: diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index f0c7a5cad4..4143fef781 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -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; + "extraneous parentheses">, InGroup; def note_equality_comparison_to_assign : Note< "use '=' to turn this equality comparison into an assignment">; def note_equality_comparison_silence : Note< diff --git a/test/SemaCXX/warn-assignment-condition.cpp b/test/SemaCXX/warn-assignment-condition.cpp index c0ef35b252..04f2e79525 100644 --- a/test/SemaCXX/warn-assignment-condition.cpp +++ b/test/SemaCXX/warn-assignment-condition.cpp @@ -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))