Created attachment 40791 [details] test-case Adopted from clang: $ g++ /home/marxin/BIG/Programming/llvm-project/llvm/tools/clang/test/SemaCXX/attr-cxx0x.cpp /home/marxin/BIG/Programming/llvm-project/llvm/tools/clang/test/SemaCXX/attr-cxx0x.cpp:3:28: error: requested alignment is not a positive power of 2 int align_illegal alignas(3); //expected-error {{requested alignment is not a power of 2}} ^ /home/marxin/BIG/Programming/llvm-project/llvm/tools/clang/test/SemaCXX/attr-cxx0x.cpp:11:25: error: function definition does not declare parameters int bitfield alignas(1) : 1; // expected-error {{}} ^ /home/marxin/BIG/Programming/llvm-project/llvm/tools/clang/test/SemaCXX/attr-cxx0x.cpp:14:24: error: alignment may not be specified for ‘c’ void f(alignas(1) char c) { // expected-error {{'alignas' attribute cannot be applied to a function parameter}} ^ /home/marxin/BIG/Programming/llvm-project/llvm/tools/clang/test/SemaCXX/attr-cxx0x.cpp:26:19: error: expansion pattern ‘#‘tree_list’ not supported by dump_expr#<expression error>’ contains no argument packs struct alignas(int...) alignas_expansion_no_packs {}; // expected-error {{pack expansion does not contain any unexpanded parameter packs}} ^~~ /home/marxin/BIG/Programming/llvm-project/llvm/tools/clang/test/SemaCXX/attr-cxx0x.cpp:26:24: internal compiler error: tree check: expected tree_list, have error_mark in cp_check_const_attributes, at cp/decl2.c:1351 struct alignas(int...) alignas_expansion_no_packs {}; // expected-error {{pack expansion does not contain any unexpanded parameter packs}} ^~~~~~~~~~~~~~~~~~~~~~~~~~ 0x15410ca tree_check_failed(tree_node const*, char const*, int, char const*, ...) ../../gcc/tree.c:9815 0x80d4d6 tree_check(tree_node*, char const*, int, char const*, tree_code) ../../gcc/tree.h:3064 0x95cfd7 cp_check_const_attributes ../../gcc/cp/decl2.c:1351 0x95d5ce cplus_decl_attributes(tree_node**, tree_node*, int) ../../gcc/cp/decl2.c:1423 0x9b04ca cp_parser_class_head ../../gcc/cp/parser.c:22805 0x9ae06f cp_parser_class_specifier_1 ../../gcc/cp/parser.c:22055 0x9af194 cp_parser_class_specifier ../../gcc/cp/parser.c:22368 0x9a2ec6 cp_parser_type_specifier ../../gcc/cp/parser.c:16441 0x99dd17 cp_parser_decl_specifier_seq ../../gcc/cp/parser.c:13352 0x99c73a cp_parser_simple_declaration ../../gcc/cp/parser.c:12676 0x99c6c2 cp_parser_block_declaration ../../gcc/cp/parser.c:12621 0x99c444 cp_parser_declaration ../../gcc/cp/parser.c:12518 0x99bf9d cp_parser_declaration_seq_opt ../../gcc/cp/parser.c:12394 0x98a935 cp_parser_translation_unit ../../gcc/cp/parser.c:4366 0x9dbd52 c_parse_file() ../../gcc/cp/parser.c:38430 0xb8e93c c_common_parse_file() ../../gcc/c-family/c-opts.c:1107
Started with r222902.
I'm not sure if I should reduce the testcase or just gcc-ify it. Maybe it's worth it to do the latter.
Well, this is enough to provoke the ICE: struct alignas(int...) {}
cp_check_const_attributes should check ARG before accessing its TREE_VALUE.
I came up with another testcase that triggers a similar ICE: template <typename... T> struct A { alignas(int...) char c; }; A<int, double> a; q.cc:2:23: error: expansion pattern ‘#‘tree_list’ not supported by dump_expr#<expression error>’ contains no argument packs struct A { alignas(int...) char c; }; ^~~ q.cc:2:33: internal compiler error: tree check: expected tree_list, have error_mark in is_late_template_attribute, at cp/decl2.c:1119 struct A { alignas(int...) char c; }; ^ 0x14b8fcc tree_check_failed(tree_node const*, char const*, int, char const*, ...) /home/marek/src/gcc/gcc/tree.c:9815 0x7911d6 tree_check(tree_node*, char const*, int, char const*, tree_code) /home/marek/src/gcc/gcc/tree.h:3064 0x8e008a is_late_template_attribute /home/marek/src/gcc/gcc/cp/decl2.c:1119 0x8e02c0 splice_template_attributes /home/marek/src/gcc/gcc/cp/decl2.c:1179 0x8e040e save_template_attributes /home/marek/src/gcc/gcc/cp/decl2.c:1205 0x8e13f4 cplus_decl_attributes(tree_node**, tree_node*, int) /home/marek/src/gcc/gcc/cp/decl2.c:1420 0x8df76d grokfield(cp_declarator const*, cp_decl_specifier_seq*, tree_node*, bool, tree_node*, tree_node*) /home/marek/src/gcc/gcc/cp/decl2.c:951 0x9353d7 cp_parser_member_declaration /home/marek/src/gcc/gcc/cp/parser.c:23414 0x9346d3 cp_parser_member_specification_opt /home/marek/src/gcc/gcc/cp/parser.c:22963 0x932255 cp_parser_class_specifier_1 /home/marek/src/gcc/gcc/cp/parser.c:22116 0x933010 cp_parser_class_specifier /home/marek/src/gcc/gcc/cp/parser.c:22368 0x926d42 cp_parser_type_specifier /home/marek/src/gcc/gcc/cp/parser.c:16441 0x921b93 cp_parser_decl_specifier_seq /home/marek/src/gcc/gcc/cp/parser.c:13352 0x93b331 cp_parser_single_declaration /home/marek/src/gcc/gcc/cp/parser.c:26646 0x93a5f5 cp_parser_template_declaration_after_parameters /home/marek/src/gcc/gcc/cp/parser.c:26337 0x93b1c9 cp_parser_explicit_template_declaration /home/marek/src/gcc/gcc/cp/parser.c:26573 0x93b223 cp_parser_template_declaration_after_export /home/marek/src/gcc/gcc/cp/parser.c:26591 0x923dbb cp_parser_template_declaration /home/marek/src/gcc/gcc/cp/parser.c:14693 0x9200b0 cp_parser_declaration /home/marek/src/gcc/gcc/cp/parser.c:12467 0x91fe19 cp_parser_declaration_seq_opt /home/marek/src/gcc/gcc/cp/parser.c:12394 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.
I have a fix for that.
Author: mpolacek Date: Wed Feb 22 19:31:49 2017 New Revision: 245657 URL: https://gcc.gnu.org/viewcvs?rev=245657&root=gcc&view=rev Log: PR c++/79653 * parser.c (cp_parser_std_attribute_spec): Don't build the attribute if the alignas expression is erroneous. * pt.c (tsubst_attribute): If tsubst_pack_expansion fails, return error_mark_node. * g++.dg/cpp0x/alignas10.C: New test. * g++.dg/cpp0x/alignas9.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp0x/alignas10.C trunk/gcc/testsuite/g++.dg/cpp0x/alignas9.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/parser.c trunk/gcc/cp/pt.c trunk/gcc/testsuite/ChangeLog
Fixed for GCC 7.