From: Argyrios Kyrtzidis Date: Mon, 28 Mar 2011 23:52:04 +0000 (+0000) Subject: Don't do the checks of Sema::DiagnoseEqualityWithExtraParens() on type-dependent... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=170a6a229b6cb0c411be5edaa587a1b1436bd147;p=clang Don't do the checks of Sema::DiagnoseEqualityWithExtraParens() on type-dependent expressions. Fixes rdar://9027658. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128437 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 8b7324e966..22b0f03a52 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -9839,6 +9839,9 @@ void Sema::DiagnoseEqualityWithExtraParens(ParenExpr *parenE) { SourceLocation parenLoc = parenE->getLocStart(); if (parenLoc.isInvalid() || parenLoc.isMacroID()) return; + // Don't warn for dependent expressions. + if (parenE->isTypeDependent()) + return; Expr *E = parenE->IgnoreParens(); diff --git a/test/SemaCXX/warn-assignment-condition.cpp b/test/SemaCXX/warn-assignment-condition.cpp index 27eedb9128..c0ef35b252 100644 --- a/test/SemaCXX/warn-assignment-condition.cpp +++ b/test/SemaCXX/warn-assignment-condition.cpp @@ -125,3 +125,16 @@ void test2() { if ((test2 == fn)) {} } +namespace rdar9027658 { +template +void f() { + if ((T::g == 3)) { } // 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}} +} + +struct S { int g; }; +void test() { + f(); // expected-note {{in instantiation}} +} +}