]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix up pedantic handling of alignas [PR110345]
authorJakub Jelinek <jakub@redhat.com>
Wed, 18 Dec 2024 11:00:13 +0000 (12:00 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 18 Dec 2024 11:00:13 +0000 (12:00 +0100)
commit7eb2acb7221b5a219ece1a693d9ac594f229a61a
treee8b8643885ab5736a6af60347e992654f5c6d016
parent190d9a2b384e626bcd0554e01513939af1ed5339
c++: Fix up pedantic handling of alignas [PR110345]

The following patch on top of the PR110345 P2552R3 series
emits pedantic pedwarns for alignas appertaining to incorrect entities.
As the middle-end and attribute exclusions look for "aligned" attribute,
the patch transforms alignas into "internal "::aligned attribute (didn't
use [[aligned (x)]] so that people can't type it that way).

2024-12-18  Jakub Jelinek  <jakub@redhat.com>

PR c++/110345
gcc/c-family/
* c-common.h (attr_aligned_exclusions): Declare.
(handle_aligned_attribute): Likewise.
* c-attribs.cc (handle_aligned_attribute): No longer
static.
(attr_aligned_exclusions): Use extern instead of static.
gcc/cp/
* cp-tree.h (enum cp_tree_index): Add CPTI_INTERNAL_IDENTIFIER.
(internal_identifier): Define.
(internal_attribute_table): Declare.
* parser.cc (cp_parser_exception_declaration): Error on alignas
on exception declaration.
(cp_parser_std_attribute_spec): Turn alignas into internal
ns aligned attribute rather than gnu.
* decl.cc (initialize_predefined_identifiers): Initialize
internal_identifier.
* tree.cc (handle_alignas_attribute): New function.
(internal_attributes): New variable.
(internal_attribute_table): Likewise.
* cp-objcp-common.h (cp_objcp_attribute_table): Add
internal_attribute_table entry.
gcc/testsuite/
* g++.dg/cpp0x/alignas1.C: Add dg-options "".
* g++.dg/cpp0x/alignas2.C: Likewise.
* g++.dg/cpp0x/alignas7.C: Likewise.
* g++.dg/cpp0x/alignas21.C: New test.
* g++.dg/ext/bitfield9.C: Expect a warning.
* g++.dg/cpp2a/is-layout-compatible3.C: Add dg-options -pedantic.
Expect a warning.
13 files changed:
gcc/c-family/c-attribs.cc
gcc/c-family/c-common.h
gcc/cp/cp-objcp-common.h
gcc/cp/cp-tree.h
gcc/cp/decl.cc
gcc/cp/parser.cc
gcc/cp/tree.cc
gcc/testsuite/g++.dg/cpp0x/alignas1.C
gcc/testsuite/g++.dg/cpp0x/alignas2.C
gcc/testsuite/g++.dg/cpp0x/alignas21.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/alignas7.C
gcc/testsuite/g++.dg/cpp2a/is-layout-compatible3.C
gcc/testsuite/g++.dg/ext/bitfield9.C