From: Eli Friedman Date: Mon, 8 Jul 2013 23:35:04 +0000 (+0000) Subject: Fix crash typo-correcting dependent member func. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d739c4ecf7d7f2222f6f1c8de9e234d1c8a0468c;p=clang Fix crash typo-correcting dependent member func. PR16561. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185887 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 3ddce77a88..e55e128dae 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -1187,7 +1187,7 @@ bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, // Attempt to call the member with no arguments - this will correctly handle // member templates with defaults/deduction of template arguments, overloads // with default arguments, etc. - if (IsMemExpr) { + if (IsMemExpr && !E.isTypeDependent()) { bool Suppress = getDiagnostics().getSuppressAllDiagnostics(); getDiagnostics().setSuppressAllDiagnostics(true); ExprResult R = BuildCallToMemberFunction(NULL, &E, SourceLocation(), None, diff --git a/test/SemaCXX/addr-of-overloaded-function.cpp b/test/SemaCXX/addr-of-overloaded-function.cpp index 3d007a9612..230a1eb994 100644 --- a/test/SemaCXX/addr-of-overloaded-function.cpp +++ b/test/SemaCXX/addr-of-overloaded-function.cpp @@ -235,3 +235,7 @@ namespace test1 { void (Qualifiers::*X)() = &Dummy::N; // expected-error{{cannot initialize a variable of type 'void (test1::Qualifiers::*)()' with an rvalue of type 'void (test1::Dummy::*)()': different classes ('test1::Qualifiers' vs 'test1::Dummy')}} } + +template class PR16561 { + virtual bool f() { if (f) {} return false; } // expected-error {{reference to non-static member function must be called}} +};