]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/80241 - ICE with alignas pack expansion.
authorMarek Polacek <polacek@redhat.com>
Sat, 24 Jun 2017 10:50:08 +0000 (10:50 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Sat, 24 Jun 2017 10:50:08 +0000 (10:50 +0000)
* error.c (dump_expr): Handle TREE_LIST.
* parser.c (cp_parser_std_attribute_list): Return error_mark if
make_pack_expansion returns an error.

* g++.dg/cpp0x/alignas11.C: New test.

From-SVN: r249621

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

index ba4751e80cef97cfae47bb57e15fa0f960f076f2..57db5ca858f91123b9ee4346cfe05624a6f18509 100644 (file)
@@ -1,3 +1,13 @@
+2017-06-24  Marek Polacek  <polacek@redhat.com>
+
+       Backported from mainline
+       2017-04-18  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/80241 - ICE with alignas pack expansion.
+       * error.c (dump_expr): Handle TREE_LIST.
+       * parser.c (cp_parser_std_attribute_list): Return error_mark if
+       make_pack_expansion returns an error.
+
 2017-06-22  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
index 17432f18a49e74d634515d6b145d1cae07b3444a..7a324981424813b6a94fed2b9e7359526b0453c5 100644 (file)
@@ -2766,6 +2766,10 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
       pp_string (pp, M_("*this"));
       break;
 
+    case TREE_LIST:
+      dump_expr_list (pp, t, flags);
+      break;
+
       /*  This list is incomplete, but should suffice for now.
          It is very important that `sorry' does not call
          `report_error_function'.  That could cause an infinite loop.  */
index ff7b18b3b8e2f2cecb358282adc85102b741a6b0..3a056e4135b1cb4615adaed3cf61d89cff66e70c 100644 (file)
@@ -24082,8 +24082,12 @@ cp_parser_std_attribute_list (cp_parser *parser)
            error_at (token->location,
                      "expected attribute before %<...%>");
          else
-           TREE_VALUE (attribute)
-             = make_pack_expansion (TREE_VALUE (attribute));
+           {
+             tree pack = make_pack_expansion (TREE_VALUE (attribute));
+             if (pack == error_mark_node)
+               return error_mark_node;
+             TREE_VALUE (attribute) = pack;
+           }
          token = cp_lexer_peek_token (parser->lexer);
        }
       if (token->type != CPP_COMMA)
index 6434d674e85eb5102cfc7f1e0f7d0125a7ebb4ea..337620c1ef094e9354ea83fbc88ef4e5491d9a7c 100644 (file)
@@ -1,3 +1,11 @@
+2017-06-24  Marek Polacek  <polacek@redhat.com>
+
+       Backported from mainline
+       2017-04-18  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/80241 - ICE with alignas pack expansion.
+       * g++.dg/cpp0x/alignas11.C: New test.
+
 2017-06-23  Thomas Preud'homme  <thomas.preudhomme@arm.com>
 
        Backport from mainline
diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas11.C b/gcc/testsuite/g++.dg/cpp0x/alignas11.C
new file mode 100644 (file)
index 0000000..73c54da
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/80241
+// { dg-do compile { target c++11 } }
+
+template <typename... T>
+struct A
+{
+  [[gnu::aligned (alignof(A))...]] char c; // { dg-error "expansion pattern" }
+};
+
+A<int> a;