[cfe-commits] r83511 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
Douglas Gregor
dgregor at apple.com
Wed Oct 7 17:14:38 PDT 2009
Author: dgregor
Date: Wed Oct 7 19:14:38 2009
New Revision: 83511
URL: http://llvm.org/viewvc/llvm-project?rev=83511&view=rev
Log:
Only perform an implicit instantiation of a function if its template
specialization kind is TSK_ImplicitInstantiation. Previously, we would
end up implicitly instantiating functions that had explicit
specialization declarations or explicit instantiation declarations
(with no corresponding definitions).
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=83511&r1=83510&r2=83511&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Oct 7 19:14:38 2009
@@ -6198,15 +6198,9 @@
if (FunctionDecl *Function = dyn_cast<FunctionDecl>(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);
Modified: cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp?rev=83511&r1=83510&r2=83511&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp Wed Oct 7 19:14:38 2009
@@ -98,6 +98,12 @@
namespace N0 {
template<> void X0<volatile void>::f1(void *) { } // expected-error{{no function template matches}}
+
+ template<> void X0<const volatile void*>::f1(const volatile void*);
+}
+
+void test_x0_cvvoid(N0::X0<const volatile void*> x0, const volatile void *cvp) {
+ x0.f1(cvp); // okay: we've explicitly specialized
}
#if 0
More information about the cfe-commits
mailing list