From d6e3e8a54cfb57df98db48d728844231f24c0661 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Tue, 18 Apr 2017 09:38:55 +0000 Subject: [PATCH] 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. * g++.dg/cpp0x/alignas11.C: New test. From-SVN: r246963 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/error.c | 4 ++++ gcc/cp/parser.c | 8 ++++++-- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp0x/alignas11.C | 10 ++++++++++ 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas11.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3f87d715dd2..6eac0ba0ca0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 PR c++/80287 diff --git a/gcc/cp/error.c b/gcc/cp/error.c index f93e8b67841..40a7eab4b9e 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -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. */ diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e202ad9bf12..5255e713a32 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ca0717ec694..db98764c627 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 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 index 00000000000..73c54da00f6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alignas11.C @@ -0,0 +1,10 @@ +// PR c++/80241 +// { dg-do compile { target c++11 } } + +template +struct A +{ + [[gnu::aligned (alignof(A))...]] char c; // { dg-error "expansion pattern" } +}; + +A a; -- 2.30.2