]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Appertain standard attributes after array closing square bracket to array type...
authorJakub Jelinek <jakub@redhat.com>
Tue, 20 Aug 2024 20:17:41 +0000 (22:17 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 20 Aug 2024 20:17:41 +0000 (22:17 +0200)
commitd05949558ef1c8eeeb07399174a64f968f70e3ee
tree97a138af95260ac004e051322bf84e91451e57a8
parent1db5ca04da365ac57f7d788a85055edcf13da708
c++: Appertain standard attributes after array closing square bracket to array type rather than declarator [PR110345]

For C++ 26 P2552R3 I went through all the spots (except modules) where
attribute-specifier-seq appears in the grammar and tried to construct
a testcase in all those spots, for now for [[deprecated]] attribute.

This is the second issue I found.  The comment already correctly says that
attributes after closing ] appertain to the array type, but we were
appending them to returned_attrs, so effectively applying them to the
declarator (as if they appeared right after declarator-id).

2024-08-20  Jakub Jelinek  <jakub@redhat.com>

PR c++/110345
* decl.cc (grokdeclarator): Apply declarator->std_attributes
for cdk_array to type, rather than chaining it to returned_attrs.

* g++.dg/cpp0x/gen-attrs-82.C: New test.
* g++.dg/gomp/attrs-3.C (foo): Expect different diagnostics for
omp::directive attribute after closing square bracket of an automatic
declaration and add a test with the attribute after array's
declarator-id.
gcc/cp/decl.cc
gcc/testsuite/g++.dg/cpp0x/gen-attrs-82.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/attrs-3.C