[cfe-commits] r167918 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaTemplate/instantiate-overload-candidates.cpp

Richard Smith richard-llvm at metafoo.co.uk
Tue Nov 13 23:06:31 PST 2012


Author: rsmith
Date: Wed Nov 14 01:06:31 2012
New Revision: 167918

URL: http://llvm.org/viewvc/llvm-project?rev=167918&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaTemplate/instantiate-overload-candidates.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=167918&r1=167917&r2=167918&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Nov 14 01:06:31 2012
@@ -11529,6 +11529,7 @@
                                         TemplateArgs,
                                         type, valueKind, OK_Ordinary);
     ME->setHadMultipleCandidates(true);
+    MarkMemberReferenced(ME);
     return ME;
   }
 

Modified: cfe/trunk/test/SemaTemplate/instantiate-overload-candidates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-overload-candidates.cpp?rev=167918&r1=167917&r2=167918&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-overload-candidates.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-overload-candidates.cpp Wed Nov 14 01:06:31 2012
@@ -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}}





More information about the cfe-commits mailing list