(cp_parser_constructor_declarator_p): Add FLAGS parameter. Pass it to
cp_parser_type_specifier.
+ PR c++/89686 - mixing init-capture and simple-capture in lambda.
+ * parser.c (cp_parser_lambda_introducer): Give error when combining
+ init-capture and simple-capture.
+
2019-03-11 Jason Merrill <jason@redhat.com>
PR c++/86521 - wrong overload resolution with ref-qualifiers.
}
bool init_pack_expansion = false;
+ location_t ellipsis_loc = UNKNOWN_LOCATION;
if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS))
{
- location_t loc = cp_lexer_peek_token (parser->lexer)->location;
+ ellipsis_loc = cp_lexer_peek_token (parser->lexer)->location;
if (cxx_dialect < cxx2a)
- pedwarn (loc, 0, "pack init-capture only available with "
- "%<-std=c++2a%> or %<-std=gnu++2a%>");
+ pedwarn (ellipsis_loc, 0, "pack init-capture only available with "
+ "%<-std=c++2a%> or %<-std=gnu++2a%>");
cp_lexer_consume_token (parser->lexer);
init_pack_expansion = true;
}
if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS))
{
+ location_t loc = cp_lexer_peek_token (parser->lexer)->location;
cp_lexer_consume_token (parser->lexer);
capture_init_expr = make_pack_expansion (capture_init_expr);
+ if (init_pack_expansion)
+ {
+ /* If what follows is an initializer, the second '...' is
+ invalid. But for cases like [...xs...], the first one
+ is invalid. */
+ if (cp_lexer_next_token_is (parser->lexer, CPP_EQ)
+ || cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN)
+ || cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
+ ellipsis_loc = loc;
+ error_at (ellipsis_loc, "too many %<...%> in lambda capture");
+ continue;
+ }
}
}
--- /dev/null
+// PR c++/89686
+// { dg-do compile { target c++2a } }
+
+template <typename... Ts>
+void foo(Ts... xs)
+{
+ int i = 10;
+ [...xs...]{}(); // { dg-error "4:too many ..... in lambda capture" }
+ [...xs...=xs]{}(); // { dg-error "9:too many ..... in lambda capture|expected" }
+ [xs...]{}();
+ [...xs=xs]{}();
+
+ [i, ...xs...]{}(); // { dg-error "7:too many ..... in lambda capture" }
+ [i, ...xs...=xs]{}(); // { dg-error "12:too many ..... in lambda capture|expected" }
+ [i, xs...]{}();
+ [i, ...xs=xs]{}();
+}
+
+int main()
+{
+ foo(0, 1, 2);
+}