Hi,
we are crashing on this kind of invalid code because we don't early
check the case with check_for_bare_parameter_packs. Tested x86_64-linux.
Thanks,
Paolo.
//////////////////////
/cp
2014-11-25 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/63786
* parser.c (cp_parser_label_for_labeled_statement): Check the case
with check_for_bare_parameter_packs.
/testsuite
2014-11-25 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/63786
* g++.dg/cpp0x/variadic163.C: New.
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 218039)
+++ cp/parser.c (working copy)
@@ -9820,6 +9820,8 @@ cp_parser_label_for_labeled_statement (cp_parser*
cp_lexer_consume_token (parser->lexer);
/* Parse the constant-expression. */
expr = cp_parser_constant_expression (parser);
+ if (check_for_bare_parameter_packs (expr))
+ expr = error_mark_node;
ellipsis = cp_lexer_peek_token (parser->lexer);
if (ellipsis->type == CPP_ELLIPSIS)
@@ -9826,8 +9828,9 @@ cp_parser_label_for_labeled_statement (cp_parser*
{
/* Consume the `...' token. */
cp_lexer_consume_token (parser->lexer);
- expr_hi =
- cp_parser_constant_expression (parser);
+ expr_hi = cp_parser_constant_expression (parser);
+ if (check_for_bare_parameter_packs (expr_hi))
+ expr_hi = error_mark_node;
/* We don't need to emit warnings here, as the common code
will do this for us. */
Index: testsuite/g++.dg/cpp0x/variadic163.C
===================================================================
--- testsuite/g++.dg/cpp0x/variadic163.C (revision 0)
+++ testsuite/g++.dg/cpp0x/variadic163.C (working copy)
@@ -0,0 +1,21 @@
+// PR c++/63786
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+template <int... Is>
+int f(int i) {
+ switch (i) {
+ case Is: // { dg-error "not expanded" }
+ return 0;
+ }
+
+ switch (i) {
+ case 0 ...Is: // { dg-error "not expanded" }
+ return 0;
+ }
+ return 0;
+}
+
+int main() {
+ f<1,2,3>(1);
+}