]> granicus.if.org Git - clang/commitdiff
Don't do the checks of Sema::DiagnoseEqualityWithExtraParens() on type-dependent...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 28 Mar 2011 23:52:04 +0000 (23:52 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 28 Mar 2011 23:52:04 +0000 (23:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128437 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaCXX/warn-assignment-condition.cpp

index 8b7324e9661fe9aeebad12643afb004bcfaecec0..22b0f03a52d69586140046154f37d4a396cb2dad 100644 (file)
@@ -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();
 
index 27eedb9128d7ee04e2103a62d7d4609d1da8503d..c0ef35b252d85d5fc3160955f82a01276b07956c 100644 (file)
@@ -125,3 +125,16 @@ void test2() {
     if ((test2 == fn)) {}
 }
 
+namespace rdar9027658 {
+template <typename T>
+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<S>(); // expected-note {{in instantiation}}
+}
+}