diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index e7b074b43c3a..3bd72d07d2e1 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -6198,15 +6198,9 @@ void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) { if (FunctionDecl *Function = dyn_cast(D)) { // Implicit instantiation of function templates and member functions of // class templates. - if (!Function->getBody()) { - // FIXME: distinguish between implicit instantiations of function - // templates and explicit specializations (the latter don't get - // instantiated, naturally). - if (Function->getInstantiatedFromMemberFunction() || - Function->getPrimaryTemplate()) - PendingImplicitInstantiations.push_back(std::make_pair(Function, Loc)); - } - + if (!Function->getBody() && + Function->getTemplateSpecializationKind() == TSK_ImplicitInstantiation) + PendingImplicitInstantiations.push_back(std::make_pair(Function, Loc)); // FIXME: keep track of references to static functions Function->setUsed(true); diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp index 553d62c9e5e8..413d0b949d8e 100644 --- a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp +++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp @@ -98,6 +98,12 @@ void test_spec(N0::X0 xvp, void *vp) { namespace N0 { template<> void X0::f1(void *) { } // expected-error{{no function template matches}} + + template<> void X0::f1(const volatile void*); +} + +void test_x0_cvvoid(N0::X0 x0, const volatile void *cvp) { + x0.f1(cvp); // okay: we've explicitly specialized } #if 0