PR c++/80241 - ICE with alignas pack expansion.
authorMarek Polacek <polacek@redhat.com>
Tue, 18 Apr 2017 09:38:55 +0000 (09:38 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 18 Apr 2017 09:38:55 +0000 (09:38 +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: r246963

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 3f87d715dd27c6ae2c2dc089b9f49588277f56c2..6eac0ba0ca095450297a31a740151388a321142c 100644 (file)
@@ -3,6 +3,11 @@
        PR c++/80244 - ICE with attribute in template alias.
        * tree.c (strip_typedefs): Handle UNDERLYING_TYPE.
 
+       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-04-17  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        PR c++/80287
index f93e8b67841c9e020b9db88bfe1c6a253693c8ed..40a7eab4b9e0bc78201cb11f83b0ac6799e8bb7f 100644 (file)
@@ -2822,6 +2822,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 e202ad9bf120cf6f36c5f34d69be7c10919c7031..5255e713a32495249985b3be94e6649964e722c5 100644 (file)
@@ -24846,8 +24846,12 @@ cp_parser_std_attribute_list (cp_parser *parser, tree attr_ns)
            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 ca0717ec69429f5dd968192ef07c3afb5f09615f..db98764c62772cd8721f415985609fd45c164a1b 100644 (file)
@@ -3,6 +3,9 @@
        PR c++/80244 - ICE with attribute in template alias.
        * g++.dg/cpp0x/alias-decl-59.C: New test.
 
+       PR c++/80241 - ICE with alignas pack expansion.
+       * g++.dg/cpp0x/alignas11.C: New test.
+
 2017-04-17  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        PR c++/80287
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;