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 47c4331..549fa8f 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -11529,6 +11529,7 @@
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 5b7e60d..5c892aa 100644
--- a/test/SemaTemplate/instantiate-overload-candidates.cpp
+++ b/test/SemaTemplate/instantiate-overload-candidates.cpp
@@ -19,3 +19,11 @@
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<typename T> struct X {
+ static T f() { T::error; } // expected-error {{has no members}}
+ static T f(bool);
+};
+void (*p)() = &X<void>().f; // expected-note {{instantiation of}}