]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Use cplus_decl_attributes rather than decl_attributes in grokdecl [PR118773]
authorJakub Jelinek <jakub@redhat.com>
Fri, 7 Feb 2025 13:28:57 +0000 (14:28 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 7 Feb 2025 13:28:57 +0000 (14:28 +0100)
commit801fb71f83624f0bf6d6bd27121d4a332103f7be
tree3c1f57271e806e2d2e0d752177ee15c276a232f1
parent6c8e6d6febaed3c167ca9534935c2cb18045528e
c++: Use cplus_decl_attributes rather than decl_attributes in grokdecl [PR118773]

My r15-3046 change regressed the first half of the following testcase.
When it calls decl_attributes, it doesn't handle attributes with
dependent arguments correctly and so is now rejected that N is not
a constant integer during template parsing.

I've actually followed the pointer/reference case which did that
too and that one has been failing for a couple of years on the
second part of the testcase.

Note, there is also
          if (decl_context != PARM && decl_context != TYPENAME)
            /* Assume that any attributes that get applied late to
               templates will DTRT when applied to the declaration
               as a whole.  */
            late_attrs = splice_template_attributes (&attrs, type);
          returned_attrs = decl_attributes (&type,
                                            attr_chainon (returned_attrs,
                                                          attrs),
                                            attr_flags);
          returned_attrs = attr_chainon (late_attrs, returned_attrs);
call directly to decl_attributes in grokdeclarator, but this one handles
the splicing manually, so maybe it is ok as is (and I don't have a testcase
of anything misbehaving for that).

2025-02-07  Jakub Jelinek  <jakub@redhat.com>

PR c++/118773
* decl.cc (grokdeclarator): Use cplus_decl_attributes rather than
decl_attributes for std_attributes on pointer and array types.

* g++.dg/cpp0x/gen-attrs-87.C: New test.
* g++.dg/gomp/attrs-3.C: Adjust expected diagnostics.
gcc/cp/decl.cc
gcc/testsuite/g++.dg/cpp0x/gen-attrs-87.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/attrs-3.C