[cfe-commits] r123449 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/CXX/temp/temp.decls/temp.variadic/p4.cpp
Douglas Gregor
dgregor at apple.com
Fri Jan 14 09:12:22 PST 2011
Author: dgregor
Date: Fri Jan 14 11:12:22 2011
New Revision: 123449
URL: http://llvm.org/viewvc/llvm-project?rev=123449&view=rev
Log:
When we're instantiating a direct variable initializer that has a pack
expansion in it, we may end up instantiating to an empty
expression-list. In this case, the variable is uninitialized; tweak
the instantiation logic to handle this case. Fixes PR8977.
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=123449&r1=123448&r2=123449&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Fri Jan 14 11:12:22 2011
@@ -314,19 +314,19 @@
ASTOwningVector<Expr*> InitArgs(SemaRef);
if (!InstantiateInitializer(SemaRef, D->getInit(), TemplateArgs, LParenLoc,
InitArgs, RParenLoc)) {
- // Attach the initializer to the declaration.
- if (D->hasCXXDirectInitializer()) {
+ // Attach the initializer to the declaration, if we have one.
+ if (InitArgs.size() == 0)
+ SemaRef.ActOnUninitializedDecl(Var, false);
+ else if (D->hasCXXDirectInitializer()) {
// Add the direct initializer to the declaration.
SemaRef.AddCXXDirectInitializerToDecl(Var,
LParenLoc,
move_arg(InitArgs),
RParenLoc);
- } else if (InitArgs.size() == 1) {
+ } else {
+ assert(InitArgs.size() == 1);
Expr *Init = InitArgs.take()[0];
SemaRef.AddInitializerToDecl(Var, Init, false);
- } else {
- assert(InitArgs.size() == 0);
- SemaRef.ActOnUninitializedDecl(Var, false);
}
} else {
// FIXME: Not too happy about invalidating the declaration
Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p4.cpp?rev=123449&r1=123448&r2=123449&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p4.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p4.cpp Fri Jan 14 11:12:22 2011
@@ -34,6 +34,15 @@
template void initializer_list_expansion<1, 2, 3, 4, 5>();
template void initializer_list_expansion<1, 2, 3, 4, 5, 6>(); // expected-note{{in instantiation of function template specialization 'initializer_list_expansion<1, 2, 3, 4, 5, 6>' requested here}}
+namespace PR8977 {
+ struct A { };
+ template<typename T, typename... Args> void f(Args... args) {
+ T t(args...);
+ };
+
+ template void f<A>();
+}
+
// In a base-specifier-list (Clause 10); the pattern is a base-specifier.
template<typename ...Mixins>
struct HasMixins : public Mixins... {
More information about the cfe-commits
mailing list