re PR c++/79653 (ICE on invalid c++ code in cp_check_const_attributes in cp/decl2.c:1423)

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.

From-SVN: r245657
This commit is contained in:
Marek Polacek 2017-02-22 19:31:49 +00:00 committed by Marek Polacek
parent 3b2a007843
commit 78af14ae0e
6 changed files with 34 additions and 0 deletions

View File

@ -1,3 +1,11 @@
2017-02-22 Marek Polacek <polacek@redhat.com>
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.
2017-02-21 Jason Merrill <jason@redhat.com>
PR c++/50308 - wrong deprecated warning with ADL

View File

@ -24977,12 +24977,17 @@ cp_parser_std_attribute_spec (cp_parser *parser)
alignas_expr = cxx_alignas_expr (alignas_expr);
alignas_expr = build_tree_list (NULL_TREE, alignas_expr);
/* Handle alignas (pack...). */
if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS))
{
cp_lexer_consume_token (parser->lexer);
alignas_expr = make_pack_expansion (alignas_expr);
}
/* Something went wrong, so don't build the attribute. */
if (alignas_expr == error_mark_node)
return error_mark_node;
if (cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN) == NULL)
{
cp_parser_error (parser, "expected %<)%>");

View File

@ -10012,6 +10012,8 @@ tsubst_attribute (tree t, tree *decl_p, tree args,
/* An attribute pack expansion. */
tree purp = TREE_PURPOSE (t);
tree pack = tsubst_pack_expansion (val, args, complain, in_decl);
if (pack == error_mark_node)
return error_mark_node;
int len = TREE_VEC_LENGTH (pack);
tree list = NULL_TREE;
tree *q = &list;

View File

@ -1,3 +1,9 @@
2017-02-22 Marek Polacek <polacek@redhat.com>
PR c++/79653
* g++.dg/cpp0x/alignas10.C: New test.
* g++.dg/cpp0x/alignas9.C: New test.
2017-02-22 Jakub Jelinek <jakub@redhat.com>
PR target/70465

View File

@ -0,0 +1,7 @@
// PR c++/79653
// { dg-do compile { target c++11 } }
template <typename... A> struct outer {
template <typename... B> struct alignas(alignof(A) * alignof(B)...) inner {}; // { dg-error "mismatched argument pack lengths" }
};
outer<int>::inner<> mismatched_packs;

View File

@ -0,0 +1,6 @@
// PR c++/79653
// { dg-do compile { target c++11 } }
template <typename... T>
struct A { alignas(int...) char c; }; // { dg-error "no argument packs|expected" }
A<int, double> a;