From: Richard Smith Date: Wed, 14 Nov 2012 07:06:31 +0000 (+0000) Subject: When we have a MemberExpr referring to an overloaded static member function, X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a030228d1bfa0cab89114a18d6b50b44eb3a1a8;p=clang When we have a MemberExpr referring to an overloaded static member function, and we resolve it to a specific function based on the type which it's used as, don't forget to mark it as referenced. Fixes a regression introduced in r167514. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167918 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 47c433192c..549fa8fc9a 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -11529,6 +11529,7 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found, TemplateArgs, type, valueKind, OK_Ordinary); ME->setHadMultipleCandidates(true); + MarkMemberReferenced(ME); return ME; } diff --git a/test/SemaTemplate/instantiate-overload-candidates.cpp b/test/SemaTemplate/instantiate-overload-candidates.cpp index 5b7e60dccf..5c892aab37 100644 --- a/test/SemaTemplate/instantiate-overload-candidates.cpp +++ b/test/SemaTemplate/instantiate-overload-candidates.cpp @@ -19,3 +19,11 @@ template S_::type f(T*, NoDefinition*); // expected-n void test(int x) { f(&x, 0); } + +// Ensure that we instantiate an overloaded function if it's selected by +// overload resolution when initializing a function pointer. +template struct X { + static T f() { T::error; } // expected-error {{has no members}} + static T f(bool); +}; +void (*p)() = &X().f; // expected-note {{instantiation of}}