]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/c/ChangeLog
Expand C2x attribute parsing support and factor out from TM attributes.
authorJoseph Myers <joseph@codesourcery.com>
Thu, 7 Nov 2019 23:54:49 +0000 (23:54 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Thu, 7 Nov 2019 23:54:49 +0000 (23:54 +0000)
commitc01bd174ef751a2766df122011124e15c1340086
treeeb428d933f655e452a70a3c5262045ec3df4e32c
parentdc4b579686d1cd4cfff2b8c6397e07d6eea2ff45
Expand C2x attribute parsing support and factor out from TM attributes.

There is one place in the C parser that already handles a subset of
the C2x [[]] attribute syntax: c_parser_transaction_attributes.

This patch factors C2x attribute parsing out of there, extending it to
cover the full C2x attribute syntax (although currently only called
from that one place in the parser - so this is another piece of
preparation for supporting C2x attributes in the places where C2x says
they are valid, not the patch that actually enables such support).
The new C2X attribute parsing code uses the same representation for
scoped attributes as C++ does, so requiring parse_tm_stmt_attr to
handle the scoped attributes representation (C++ currently
special-cases TM attributes "to avoid the pedwarn in C++98 mode"; in C
I'm using an argument to c_parser_std_attribute_specifier to disable
the pedwarn_c11 call in the TM case).

Parsing of arguments to known attributes is shared by GNU and C2x
attributes.  C2x specifies that unknown attributes are ignored (GCC
practice in such a case is to warn along with ignoring the attribute)
and gives a very general balanced-token-sequence syntax for arguments
to unknown attributes (known ones each have their own syntax which is
a subset of balanced-token-sequence), so support is added for parsing
and ignoring such balanced-token-sequences as arguments of unknown
attributes.

Some limited tests are added of different attribute usages in the TM
attribute case.  The cases that become valid in the TM case include
extra commas inside [[]], and an explicit "gnu" namespace, as the
extra commas have no semantic effect for C2x attributes, while
accepting the "gnu" namespace seems appropriate because the attribute
in question is accepted inside __attribute__ (()), which is considered
equivalent to the "gnu" namespace inside [[]].

Bootstrapped with no regressions on x86_64-pc-linux-gnu.

gcc/c:
* c-parser.c (c_parser_attribute_arguments): New function.
Factored out of c_parser_gnu_attribute.
(c_parser_gnu_attribute): Use c_parser_attribute_arguments.
(c_parser_balanced_token_sequence, c_parser_std_attribute)
(c_parser_std_attribute_specifier): New functions.
(c_parser_transaction_attributes): Use
c_parser_std_attribute_specifier.

gcc/c-family:
* c-attribs.c (parse_tm_stmt_attr): Handle scoped attributes.

gcc/testsuite:
* gcc.dg/tm/attrs-1.c: New test.
* gcc.dg/tm/props-5.c: New test.  Based on props-4.c.

From-SVN: r277935
gcc/c-family/ChangeLog
gcc/c-family/c-attribs.c
gcc/c/ChangeLog
gcc/c/c-parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tm/attrs-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tm/props-5.c [new file with mode: 0644]