[cfe-commits] r142758 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/CXX/temp/temp.decls/temp.variadic/p5.cpp

Peter Collingbourne peter at pcc.me.uk
Sun Oct 23 11:59:44 PDT 2011


Author: pcc
Date: Sun Oct 23 13:59:44 2011
New Revision: 142758

URL: http://llvm.org/viewvc/llvm-project?rev=142758&view=rev
Log:
Diagnose unexpanded parameter packs in member initialisers (including
in-class member initialisers).

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=142758&r1=142757&r2=142758&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Oct 23 13:59:44 2011
@@ -1635,6 +1635,12 @@
     return;
   }
 
+  if (DiagnoseUnexpandedParameterPack(InitExpr, UPPC_Initializer)) {
+    FD->setInvalidDecl();
+    FD->removeInClassInitializer();
+    return;
+  }
+
   ExprResult Init = InitExpr;
   if (!FD->getType()->isDependentType() && !InitExpr->isTypeDependent()) {
     // FIXME: if there is no EqualLoc, this is list-initialization.
@@ -2031,6 +2037,9 @@
   assert((DirectMember || IndirectMember) &&
          "Member must be a FieldDecl or IndirectFieldDecl");
 
+  if (Args.DiagnoseUnexpandedParameterPack(*this))
+    return true;
+
   if (Member->isInvalidDecl())
     return true;
 

Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp?rev=142758&r1=142757&r2=142758&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp Sun Oct 23 13:59:44 2011
@@ -189,6 +189,12 @@
     T list_init = { static_cast<Types>(0) }; // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
   }
 
+  T in_class_member_init = static_cast<Types>(0); // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
+  TestUnexpandedDecls() : 
+    Types(static_cast<Types>(0)), // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
+    Types(static_cast<Types>(0))...,
+    in_class_member_init(static_cast<Types>(0)) {} // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
+
   void default_function_args(T = static_cast<Types>(0)); // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
 
   template<typename = Types*> // expected-error{{default argument contains unexpanded parameter pack 'Types'}}





More information about the cfe-commits mailing list