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
This commit is contained in:
Argyrios Kyrtzidis 2011-03-28 23:52:04 +00:00
Родитель 14086764e3
Коммит 170a6a229b
2 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -9839,6 +9839,9 @@ void Sema::DiagnoseEqualityWithExtraParens(ParenExpr *parenE) {
SourceLocation parenLoc = parenE->getLocStart(); SourceLocation parenLoc = parenE->getLocStart();
if (parenLoc.isInvalid() || parenLoc.isMacroID()) if (parenLoc.isInvalid() || parenLoc.isMacroID())
return; return;
// Don't warn for dependent expressions.
if (parenE->isTypeDependent())
return;
Expr *E = parenE->IgnoreParens(); Expr *E = parenE->IgnoreParens();

Просмотреть файл

@ -125,3 +125,16 @@ void test2() {
if ((test2 == fn)) {} 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}}
}
}