re PR c++/63786 (crash on argument pack in switch case)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 25 Nov 2014 13:48:49 +0000 (13:48 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 25 Nov 2014 13:48:49 +0000 (13:48 +0000)
/cp
2014-11-25  Paolo Carlini  <paolo.carlini@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.carlini@oracle.com>

PR c++/63786
* g++.dg/cpp0x/variadic163.C: New.

From-SVN: r218043

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/variadic163.C [new file with mode: 0644]

index 7f17929c20a77ca555e3a31703f3a920c83f4af0..f1ef2e0b3f131cd81a70340fd6de2ef5552fec52 100644 (file)
@@ -1,3 +1,9 @@
+2014-11-25  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       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  <jwakely@redhat.com>
            Paolo Carlini  <paolo.carlini@oracle.com>
 
index b106f3b03cdf64d1a0762bee740a121bfa38083a..b8e182af5d765985ffe0ac002dbae255611a492e 100644 (file)
@@ -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.  */
index d8a82d66bda5b03d1bb9cca287f7a659893d3fd1..b577824093ba3c4ebf6116b30d9537d5c3396a9e 100644 (file)
@@ -1,3 +1,8 @@
+2014-11-25  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/63786
+       * g++.dg/cpp0x/variadic163.C: New.
+
 2014-11-25  Ilya Enkovich  <ilya.enkovich@intel.com>
 
        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 (file)
index 0000000..1f3d909
--- /dev/null
@@ -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);
+}