aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Carlotti <andrew.carlotti@arm.com>2023-11-06 16:20:47 +0000
committerAndrew Carlotti <andrew.carlotti@arm.com>2023-12-16 00:38:42 +0000
commit73d5d3e2b29a3ebd538b6e55f0c8d62621342317 (patch)
treea4ef8af823d30477668ad61f499914fe2e39f0b9
parentb26bbd1be31666c2cc83527e89dba6684d97735b (diff)
downloadgcc-73d5d3e2b29a3ebd538b6e55f0c8d62621342317.zip
gcc-73d5d3e2b29a3ebd538b6e55f0c8d62621342317.tar.gz
gcc-73d5d3e2b29a3ebd538b6e55f0c8d62621342317.tar.bz2
ada: Improve attribute exclusion handling
Change the handling of some attribute mutual exclusions to use the generic attribute exclusion lists, and fix some asymmetric exclusions by adding the exclusions for always_inline after noinline or target_clones. Aside from the new always_inline exclusions, the only change is functionality is the choice of warning message displayed. All warnings about attribute mutual exclusions now use the same message. gcc/ada/ChangeLog: * gcc-interface/utils.cc (attr_noinline_exclusions): New. (attr_always_inline_exclusions): Ditto. (attr_target_exclusions): Ditto. (attr_target_clones_exclusions): Ditto. (gnat_internal_attribute_table): Add new exclusion lists. (handle_noinline_attribute): Remove custom exclusion handling. (handle_target_attribute): Ditto. (handle_target_clones_attribute): Ditto.
-rw-r--r--gcc/ada/gcc-interface/utils.cc70
1 files changed, 33 insertions, 37 deletions
diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc
index 33904d8..3eabbec 100644
--- a/gcc/ada/gcc-interface/utils.cc
+++ b/gcc/ada/gcc-interface/utils.cc
@@ -131,6 +131,32 @@ static const struct attribute_spec::exclusions attr_stack_protect_exclusions[] =
{ NULL, false, false, false },
};
+static const struct attribute_spec::exclusions attr_always_inline_exclusions[] =
+{
+ { "noinline", true, true, true },
+ { "target_clones", true, true, true },
+ { NULL, false, false, false },
+};
+
+static const struct attribute_spec::exclusions attr_noinline_exclusions[] =
+{
+ { "always_inline", true, true, true },
+ { NULL, false, false, false },
+};
+
+static const struct attribute_spec::exclusions attr_target_exclusions[] =
+{
+ { "target_clones", true, true, true },
+ { NULL, false, false, false },
+};
+
+static const struct attribute_spec::exclusions attr_target_clones_exclusions[] =
+{
+ { "always_inline", true, true, true },
+ { "target", true, true, true },
+ { NULL, false, false, false },
+};
+
/* Fake handler for attributes we don't properly support, typically because
they'd require dragging a lot of the common-c front-end circuitry. */
static tree fake_attribute_handler (tree *, tree, tree, int, bool *);
@@ -166,7 +192,7 @@ static const attribute_spec gnat_internal_attributes[] =
{ "strub", 0, 1, false, true, false, true,
handle_strub_attribute, NULL },
{ "noinline", 0, 0, true, false, false, false,
- handle_noinline_attribute, NULL },
+ handle_noinline_attribute, attr_noinline_exclusions },
{ "noclone", 0, 0, true, false, false, false,
handle_noclone_attribute, NULL },
{ "no_icf", 0, 0, true, false, false, false,
@@ -176,7 +202,7 @@ static const attribute_spec gnat_internal_attributes[] =
{ "leaf", 0, 0, true, false, false, false,
handle_leaf_attribute, NULL },
{ "always_inline",0, 0, true, false, false, false,
- handle_always_inline_attribute, NULL },
+ handle_always_inline_attribute, attr_always_inline_exclusions },
{ "malloc", 0, 0, true, false, false, false,
handle_malloc_attribute, NULL },
{ "type generic", 0, 0, false, true, true, false,
@@ -193,9 +219,9 @@ static const attribute_spec gnat_internal_attributes[] =
{ "simd", 0, 1, true, false, false, false,
handle_simd_attribute, NULL },
{ "target", 1, -1, true, false, false, false,
- handle_target_attribute, NULL },
+ handle_target_attribute, attr_target_exclusions },
{ "target_clones",1, -1, true, false, false, false,
- handle_target_clones_attribute, NULL },
+ handle_target_clones_attribute, attr_target_clones_exclusions },
{ "vector_size", 1, 1, false, true, false, false,
handle_vector_size_attribute, NULL },
@@ -6826,16 +6852,7 @@ handle_noinline_attribute (tree *node, tree name,
int ARG_UNUSED (flags), bool *no_add_attrs)
{
if (TREE_CODE (*node) == FUNCTION_DECL)
- {
- if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node)))
- {
- warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
- "with attribute %qs", name, "always_inline");
- *no_add_attrs = true;
- }
- else
- DECL_UNINLINABLE (*node) = 1;
- }
+ DECL_UNINLINABLE (*node) = 1;
else
{
warning (OPT_Wattributes, "%qE attribute ignored", name);
@@ -7134,12 +7151,6 @@ handle_target_attribute (tree *node, tree name, tree args, int flags,
warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
- else if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (*node)))
- {
- warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
- "with %qs attribute", name, "target_clones");
- *no_add_attrs = true;
- }
else if (!targetm.target_option.valid_attribute_p (*node, name, args, flags))
*no_add_attrs = true;
@@ -7167,23 +7178,8 @@ handle_target_clones_attribute (tree *node, tree name, tree ARG_UNUSED (args),
{
/* Ensure we have a function type. */
if (TREE_CODE (*node) == FUNCTION_DECL)
- {
- if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node)))
- {
- warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
- "with %qs attribute", name, "always_inline");
- *no_add_attrs = true;
- }
- else if (lookup_attribute ("target", DECL_ATTRIBUTES (*node)))
- {
- warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
- "with %qs attribute", name, "target");
- *no_add_attrs = true;
- }
- else
- /* Do not inline functions with multiple clone targets. */
- DECL_UNINLINABLE (*node) = 1;
- }
+ /* Do not inline functions with multiple clone targets. */
+ DECL_UNINLINABLE (*node) = 1;
else
{
warning (OPT_Wattributes, "%qE attribute ignored", name);