diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-12-16 01:31:22 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-12-16 01:31:22 +0000 |
commit | a31040f16604849b3b1dc36015056c81bae68ad1 (patch) | |
tree | 7ba4ebf887f2c72419dc8f379eea4b9c4ff4e915 /lib/Sema/SemaDeclCXX.cpp | |
parent | 6ccab97c17c17f38eb92c7fe02c766508875bd97 (diff) |
Check for unexpanded parameter packs within variable initializers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121938 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 0cf5f99b64..30e8b1e28e 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -5517,11 +5517,21 @@ void Sema::AddCXXDirectInitializerToDecl(Decl *RealDecl, return; } + bool IsDependent = false; + for (unsigned I = 0, N = Exprs.size(); I != N; ++I) { + if (DiagnoseUnexpandedParameterPack(Exprs.get()[I], UPPC_Expression)) { + VDecl->setInvalidDecl(); + return; + } + + if (Exprs.get()[I]->isTypeDependent()) + IsDependent = true; + } + // If either the declaration has a dependent type or if any of the // expressions is type-dependent, we represent the initialization // via a ParenListExpr for later use during template instantiation. - if (VDecl->getType()->isDependentType() || - Expr::hasAnyTypeDependentArguments((Expr **)Exprs.get(), Exprs.size())) { + if (VDecl->getType()->isDependentType() || IsDependent) { // Let clients know that initialization was done with a direct initializer. VDecl->setCXXDirectInitializer(true); |