[cfe-commits] r172859 - in /cfe/trunk: include/clang/Sema/Template.h lib/Sema/SemaTemplateDeduction.cpp test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp
Douglas Gregor
dgregor at apple.com
Fri Jan 18 14:27:10 PST 2013
Author: dgregor
Date: Fri Jan 18 16:27:09 2013
New Revision: 172859
URL: http://llvm.org/viewvc/llvm-project?rev=172859&view=rev
Log:
Once we've collected the template arguments for a
partially-substituted parameter pack in a template, forget about the
partially-substituted parameter pack: it is now completed. Fixes
<rdar://problem/12176336>.
Modified:
cfe/trunk/include/clang/Sema/Template.h
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp
Modified: cfe/trunk/include/clang/Sema/Template.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Template.h?rev=172859&r1=172858&r2=172859&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Template.h (original)
+++ cfe/trunk/include/clang/Sema/Template.h Fri Jan 18 16:27:09 2013
@@ -345,7 +345,16 @@
void SetPartiallySubstitutedPack(NamedDecl *Pack,
const TemplateArgument *ExplicitArgs,
unsigned NumExplicitArgs);
-
+
+ /// \brief Reset the partially-substituted pack when it is no longer of
+ /// interest.
+ void ResetPartiallySubstitutedPack() {
+ assert(PartiallySubstitutedPack && "No partially-substituted pack");
+ PartiallySubstitutedPack = 0;
+ ArgsInPartiallySubstitutedPack = 0;
+ NumArgsInPartiallySubstitutedPack = 0;
+ }
+
/// \brief Retrieve the partially-substitued template parameter pack.
///
/// If there is no partially-substituted parameter pack, returns NULL.
Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=172859&r1=172858&r2=172859&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Fri Jan 18 16:27:09 2013
@@ -2647,11 +2647,15 @@
if (CurrentInstantiationScope &&
CurrentInstantiationScope->getPartiallySubstitutedPack(&ExplicitArgs,
&NumExplicitArgs)
- == Param)
+ == Param) {
Builder.push_back(TemplateArgument(ExplicitArgs, NumExplicitArgs));
- else
- Builder.push_back(TemplateArgument::getEmptyPack());
+ // Forget the partially-substituted pack; it's substitution is now
+ // complete.
+ CurrentInstantiationScope->ResetPartiallySubstitutedPack();
+ } else {
+ Builder.push_back(TemplateArgument::getEmptyPack());
+ }
continue;
}
Modified: cfe/trunk/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp?rev=172859&r1=172858&r2=172859&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp Fri Jan 18 16:27:09 2013
@@ -26,3 +26,24 @@
unsigned_c<2> uc2 = f<float, double>();
}
}
+
+namespace rdar12176336 {
+ typedef void (*vararg_func)(...);
+
+ struct method {
+ vararg_func implementation;
+
+ method(vararg_func implementation) : implementation(implementation) {}
+
+ template<typename TReturnType, typename... TArguments, typename TFunctionType = TReturnType (*)(TArguments...)>
+ auto getImplementation() const -> TFunctionType
+ {
+ return reinterpret_cast<TFunctionType>(implementation);
+ }
+ };
+
+ void f() {
+ method m(nullptr);
+ auto imp = m.getImplementation<int, int, int>();
+ }
+}
More information about the cfe-commits
mailing list