From: Paolo Carlini Date: Tue, 25 Nov 2014 13:48:49 +0000 (+0000) Subject: re PR c++/63786 (crash on argument pack in switch case) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a959b33fc4a5b4dffc55d5c7f105dc1096a75b42;p=gcc.git re PR c++/63786 (crash on argument pack in switch case) /cp 2014-11-25 Paolo Carlini 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 PR c++/63786 * g++.dg/cpp0x/variadic163.C: New. From-SVN: r218043 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7f17929c20a..f1ef2e0b3f1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-11-25 Paolo Carlini + + PR c++/63786 + * parser.c (cp_parser_label_for_labeled_statement): Check the case + with check_for_bare_parameter_packs. + 2014-11-24 Jonathan Wakely Paolo Carlini diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index b106f3b03cd..b8e182af5d7 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -9820,14 +9820,17 @@ cp_parser_label_for_labeled_statement (cp_parser* parser, tree attributes) 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) { /* 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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d8a82d66bda..b577824093b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-11-25 Paolo Carlini + + PR c++/63786 + * g++.dg/cpp0x/variadic163.C: New. + 2014-11-25 Ilya Enkovich PR target/64056 diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic163.C b/gcc/testsuite/g++.dg/cpp0x/variadic163.C new file mode 100644 index 00000000000..1f3d90956d7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic163.C @@ -0,0 +1,21 @@ +// PR c++/63786 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +template +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); +}