This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Fix parser ICE with [[...]] and [[unused,...]] (PR c++/77637)
- From: Jason Merrill <jason at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 20 Sep 2016 11:03:42 -0400
- Subject: Re: [C++ PATCH] Fix parser ICE with [[...]] and [[unused,...]] (PR c++/77637)
- Authentication-results: sourceware.org; auth=none
- References: <20160919215008.GP7282@tucnak.redhat.com>
OK.
On Mon, Sep 19, 2016 at 5:50 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> As the testcase shows, while the grammar has
> attribute-list:
> attribute[opt]
> attribute-list , attribute[opt]
> attribute ...
> attribute-list , attribute ...
> we are actually parsing it as if the last 2 lines were
> attribute[opt] ...
> attribute-list , attribute[opt] ...
> and ICEing when there is no attribute.
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk/6.3?
>
> 2016-09-19 Jakub Jelinek <jakub@redhat.com>
>
> PR c++/77637
> * parser.c (cp_parser_std_attribute_list): Reject ... without
> preceding attribute.
>
> * g++.dg/cpp0x/gen-attrs-62.C: New test.
>
> --- gcc/cp/parser.c.jj 2016-09-16 22:19:39.000000000 +0200
> +++ gcc/cp/parser.c 2016-09-19 10:33:51.481904739 +0200
> @@ -24220,8 +24220,12 @@ cp_parser_std_attribute_list (cp_parser
> if (token->type == CPP_ELLIPSIS)
> {
> cp_lexer_consume_token (parser->lexer);
> - TREE_VALUE (attribute)
> - = make_pack_expansion (TREE_VALUE (attribute));
> + if (attribute == NULL_TREE)
> + error_at (token->location,
> + "expected attribute before %<...%>");
> + else
> + TREE_VALUE (attribute)
> + = make_pack_expansion (TREE_VALUE (attribute));
> token = cp_lexer_peek_token (parser->lexer);
> }
> if (token->type != CPP_COMMA)
> --- gcc/testsuite/g++.dg/cpp0x/gen-attrs-62.C.jj 2016-09-19 10:37:59.414772726 +0200
> +++ gcc/testsuite/g++.dg/cpp0x/gen-attrs-62.C 2016-09-19 10:37:28.000000000 +0200
> @@ -0,0 +1,5 @@
> +// PR c++/77637
> +// { dg-do compile { target c++11 } }
> +
> +int [[...]] a; // { dg-error "expected attribute before '...'" }
> +int [[,,...]] b; // { dg-error "expected attribute before '...'" }
>
> Jakub