aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-12-18 12:00:13 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2024-12-18 12:00:13 +0100
commit7eb2acb7221b5a219ece1a693d9ac594f229a61a (patch)
treee8b8643885ab5736a6af60347e992654f5c6d016 /gcc/c-family
parent190d9a2b384e626bcd0554e01513939af1ed5339 (diff)
downloadgcc-7eb2acb7221b5a219ece1a693d9ac594f229a61a.zip
gcc-7eb2acb7221b5a219ece1a693d9ac594f229a61a.tar.gz
gcc-7eb2acb7221b5a219ece1a693d9ac594f229a61a.tar.bz2
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.
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/c-attribs.cc5
-rw-r--r--gcc/c-family/c-common.h2
2 files changed, 4 insertions, 3 deletions
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index eb76a9e..3bb2cb5 100644
--- a/gcc/c-family/c-attribs.cc
+++ b/gcc/c-family/c-attribs.cc
@@ -101,7 +101,6 @@ static tree handle_destructor_attribute (tree *, tree, tree, int, bool *);
static tree handle_mode_attribute (tree *, tree, tree, int, bool *);
static tree handle_section_attribute (tree *, tree, tree, int, bool *);
static tree handle_special_var_sec_attribute (tree *, tree, tree, int, bool *);
-static tree handle_aligned_attribute (tree *, tree, tree, int, bool *);
static tree handle_warn_if_not_aligned_attribute (tree *, tree, tree,
int, bool *);
static tree handle_strict_flex_array_attribute (tree *, tree, tree,
@@ -195,7 +194,7 @@ static tree handle_null_terminated_string_arg_attribute (tree *, tree, tree, int
{ name, function, type, variable }
/* Define attributes that are mutually exclusive with one another. */
-static const struct attribute_spec::exclusions attr_aligned_exclusions[] =
+extern const struct attribute_spec::exclusions attr_aligned_exclusions[] =
{
/* Attribute name exclusion applies to:
function, type, variable */
@@ -2816,7 +2815,7 @@ common_handle_aligned_attribute (tree *node, tree name, tree args, int flags,
/* Handle a "aligned" attribute; arguments as in
struct attribute_spec.handler. */
-static tree
+tree
handle_aligned_attribute (tree *node, tree name, tree args,
int flags, bool *no_add_attrs)
{
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index ac574e9..13406e2 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -1666,8 +1666,10 @@ extern int parse_tm_stmt_attr (tree, int);
extern int tm_attr_to_mask (tree);
extern tree tm_mask_to_attr (int);
extern tree find_tm_attribute (tree);
+extern const struct attribute_spec::exclusions attr_aligned_exclusions[];
extern const struct attribute_spec::exclusions attr_cold_hot_exclusions[];
extern const struct attribute_spec::exclusions attr_noreturn_exclusions[];
+extern tree handle_aligned_attribute (tree *, tree, tree, int, bool *);
extern tree handle_noreturn_attribute (tree *, tree, tree, int, bool *);
extern tree handle_musttail_attribute (tree *, tree, tree, int, bool *);
extern bool has_attribute (location_t, tree, tree, tree (*)(tree));