diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-01-14 17:12:22 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-01-14 17:12:22 +0000 |
commit | 07a77b4b1d1fa95930129541eff8b79558f5d80d (patch) | |
tree | 9ff8a2cde1d6d3d5c7dfba57258e0acec0b7da1a /lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | cded4f649cd4b7ba7d461c25c6482ef52b8d3a2a (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123449 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 6b5713a2fa..bd431a1138 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -314,19 +314,19 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) { 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 |