diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-07-30 17:44:38 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-07-30 17:44:38 +0200 |
commit | 0ba2003cf306aa98b6ec91c9d849ab9bafcf17c2 (patch) | |
tree | 41ff2dc33aad41fbda41722670e552777510dd80 /gcc/cp/decl.c | |
parent | 59ffdb9849be033540ad680836cd4cc592098ca4 (diff) | |
download | gcc-0ba2003cf306aa98b6ec91c9d849ab9bafcf17c2.zip gcc-0ba2003cf306aa98b6ec91c9d849ab9bafcf17c2.tar.gz gcc-0ba2003cf306aa98b6ec91c9d849ab9bafcf17c2.tar.bz2 |
c++: Fix up attribute rollbacks in cp_parser_statement
During the OpenMP directives using C++ attribute syntax work, I've noticed
that cp_parser_statement when parsing various block declarations that do
not allow attribute-specifier-seq at the start rolls back the attributes
only if std_attrs is non-NULL (i.e. some attributes have been parsed),
but doesn't roll back if some tokens were parsed as attribute-specifier-seq,
but didn't yield any attributes (e.g. [[]][[]][[]][[]]), which means
we accept those empty attributes even in places where they don't appear
in the grammar.
The following patch fixes that by instead checking if there are any
tokens to roll back. This makes the parsing handle the first
function the same as the second one (where some attribute appears).
The testcase contains two xfails, using namespace ... apparently
allows attributes at the start and the attributes shall appeartain to
using in that case. To be fixed incrementally.
2021-07-30 Jakub Jelinek <jakub@redhat.com>
* parser.c (cp_parser_statement): Rollback attributes not just
when std_attrs is non-NULL, but whenever
cp_parser_std_attribute_spec_seq parsed any tokens.
* g++.dg/cpp0x/gen-attrs-76.C: New test.
Diffstat (limited to 'gcc/cp/decl.c')
0 files changed, 0 insertions, 0 deletions