@@ -21146,7 +21146,16 @@ cp_parser_enumerator_definition (cp_parser* parser, tree type)
/* If we are processing a template, make sure the initializer of the
enumerator doesn't contain any bare template parameter pack. */
- if (check_for_bare_parameter_packs (value))
+ if (current_lambda_expr ())
+ {
+ /* In a lambda it should work, but doesn't currently. */
+ if (uses_parameter_packs (value))
+ {
+ sorry ("unexpanded parameter pack in enumerator in lambda");
+ value = error_mark_node;
+ }
+ }
+ else if (check_for_bare_parameter_packs (value))
value = error_mark_node;
/* Create the enumerator. */
@@ -26624,6 +26633,14 @@ cp_parser_class_head (cp_parser* parser,
if (type)
{
+ if (current_lambda_expr ()
+ && uses_parameter_packs (attributes))
+ {
+ /* In a lambda this should work, but doesn't currently. */
+ sorry ("unexpanded parameter pack in local class in lambda");
+ attributes = NULL_TREE;
+ }
+
/* Apply attributes now, before any use of the class as a template
argument in its base list. */
cplus_decl_attributes (&type, attributes, (int)ATTR_FLAG_TYPE_IN_PLACE);
@@ -4273,10 +4273,27 @@ check_for_bare_parameter_packs (tree t, location_t loc /* = UNKNOWN_LOCATION */)
cp_walk_tree (&t, &find_parameter_packs_r, &ppd, ppd.visited);
delete ppd.visited;
+ if (!parameter_packs)
+ return false;
+
+ if (loc == UNKNOWN_LOCATION)
+ loc = cp_expr_loc_or_input_loc (t);
+
/* It's OK for a lambda to have an unexpanded parameter pack from the
containing context, but do complain about unexpanded capture packs. */
- if (current_class_type && LAMBDA_TYPE_P (current_class_type)
- && CLASSTYPE_TEMPLATE_INFO (current_class_type))
+ tree lam = current_lambda_expr ();
+ if (lam)
+ lam = TREE_TYPE (lam);
+
+ if (lam && lam != current_class_type)
+ {
+ /* We're in a lambda, but it isn't the innermost class.
+ This should work, but currently doesn't. */
+ sorry_at (loc, "unexpanded parameter pack in local class in lambda");
+ return true;
+ }
+
+ if (lam && CLASSTYPE_TEMPLATE_INFO (lam))
for (; parameter_packs;
parameter_packs = TREE_CHAIN (parameter_packs))
{
@@ -4287,8 +4304,6 @@ check_for_bare_parameter_packs (tree t, location_t loc /* = UNKNOWN_LOCATION */)
if (parameter_packs)
{
- if (loc == UNKNOWN_LOCATION)
- loc = cp_expr_loc_or_input_loc (t);
error_at (loc, "parameter packs not expanded with %<...%>:");
while (parameter_packs)
{
@@ -3,7 +3,7 @@
template <class... Ts>
void f() {
- [] { struct S : Ts { }; }; // { dg-error "not expanded" }
+ [] { struct S : Ts { }; }; // { dg-message "" }
}
int main() {
@@ -3,6 +3,6 @@
template <int... E>
void f() {
- [] { enum e { e = E }; }; // { dg-error "not expanded" }
+ [] { enum e { e = E }; }; // { dg-message "" }
}
template void f<>();
new file mode 100644
@@ -0,0 +1,9 @@
+// PR c++/100198
+// { dg-do compile { target c++11 } }
+
+template <int... E>
+void f() {
+ ([] { enum e { e = E }; }(), ...); // { dg-bogus "" "" { xfail *-*-* } }
+}
+
+template void f<0>();
new file mode 100644
@@ -0,0 +1,14 @@
+// PR c++/100030
+// { dg-do compile { target c++11 } }
+
+template <class... Ts>
+void sink(Ts...);
+
+template <class... Ts>
+void f(Ts...) {
+ sink([] { struct alignas(Ts) S {}; }...); // { dg-bogus "" "" { xfail *-*-* } }
+}
+
+int main() {
+ f(0);
+}
new file mode 100644
@@ -0,0 +1,13 @@
+// PR c++/100282
+// { dg-do compile { target c++11 } }
+
+template <typename... Ts>
+void
+local_class ()
+{
+ int { []{ struct ZZ : Ts {}; }... }; // { dg-bogus "" "" { xfail *-*-* } }
+}
+
+template // <>
+void
+local_class<int> ();