Skip to content

Commit 73d5d3e

Browse files
committed
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.
1 parent b26bbd1 commit 73d5d3e

1 file changed

Lines changed: 33 additions & 37 deletions

File tree

gcc/ada/gcc-interface/utils.cc

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,32 @@ static const struct attribute_spec::exclusions attr_stack_protect_exclusions[] =
131131
{ NULL, false, false, false },
132132
};
133133

134+
static const struct attribute_spec::exclusions attr_always_inline_exclusions[] =
135+
{
136+
{ "noinline", true, true, true },
137+
{ "target_clones", true, true, true },
138+
{ NULL, false, false, false },
139+
};
140+
141+
static const struct attribute_spec::exclusions attr_noinline_exclusions[] =
142+
{
143+
{ "always_inline", true, true, true },
144+
{ NULL, false, false, false },
145+
};
146+
147+
static const struct attribute_spec::exclusions attr_target_exclusions[] =
148+
{
149+
{ "target_clones", true, true, true },
150+
{ NULL, false, false, false },
151+
};
152+
153+
static const struct attribute_spec::exclusions attr_target_clones_exclusions[] =
154+
{
155+
{ "always_inline", true, true, true },
156+
{ "target", true, true, true },
157+
{ NULL, false, false, false },
158+
};
159+
134160
/* Fake handler for attributes we don't properly support, typically because
135161
they'd require dragging a lot of the common-c front-end circuitry. */
136162
static tree fake_attribute_handler (tree *, tree, tree, int, bool *);
@@ -166,7 +192,7 @@ static const attribute_spec gnat_internal_attributes[] =
166192
{ "strub", 0, 1, false, true, false, true,
167193
handle_strub_attribute, NULL },
168194
{ "noinline", 0, 0, true, false, false, false,
169-
handle_noinline_attribute, NULL },
195+
handle_noinline_attribute, attr_noinline_exclusions },
170196
{ "noclone", 0, 0, true, false, false, false,
171197
handle_noclone_attribute, NULL },
172198
{ "no_icf", 0, 0, true, false, false, false,
@@ -176,7 +202,7 @@ static const attribute_spec gnat_internal_attributes[] =
176202
{ "leaf", 0, 0, true, false, false, false,
177203
handle_leaf_attribute, NULL },
178204
{ "always_inline",0, 0, true, false, false, false,
179-
handle_always_inline_attribute, NULL },
205+
handle_always_inline_attribute, attr_always_inline_exclusions },
180206
{ "malloc", 0, 0, true, false, false, false,
181207
handle_malloc_attribute, NULL },
182208
{ "type generic", 0, 0, false, true, true, false,
@@ -193,9 +219,9 @@ static const attribute_spec gnat_internal_attributes[] =
193219
{ "simd", 0, 1, true, false, false, false,
194220
handle_simd_attribute, NULL },
195221
{ "target", 1, -1, true, false, false, false,
196-
handle_target_attribute, NULL },
222+
handle_target_attribute, attr_target_exclusions },
197223
{ "target_clones",1, -1, true, false, false, false,
198-
handle_target_clones_attribute, NULL },
224+
handle_target_clones_attribute, attr_target_clones_exclusions },
199225

200226
{ "vector_size", 1, 1, false, true, false, false,
201227
handle_vector_size_attribute, NULL },
@@ -6826,16 +6852,7 @@ handle_noinline_attribute (tree *node, tree name,
68266852
int ARG_UNUSED (flags), bool *no_add_attrs)
68276853
{
68286854
if (TREE_CODE (*node) == FUNCTION_DECL)
6829-
{
6830-
if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node)))
6831-
{
6832-
warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
6833-
"with attribute %qs", name, "always_inline");
6834-
*no_add_attrs = true;
6835-
}
6836-
else
6837-
DECL_UNINLINABLE (*node) = 1;
6838-
}
6855+
DECL_UNINLINABLE (*node) = 1;
68396856
else
68406857
{
68416858
warning (OPT_Wattributes, "%qE attribute ignored", name);
@@ -7134,12 +7151,6 @@ handle_target_attribute (tree *node, tree name, tree args, int flags,
71347151
warning (OPT_Wattributes, "%qE attribute ignored", name);
71357152
*no_add_attrs = true;
71367153
}
7137-
else if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (*node)))
7138-
{
7139-
warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
7140-
"with %qs attribute", name, "target_clones");
7141-
*no_add_attrs = true;
7142-
}
71437154
else if (!targetm.target_option.valid_attribute_p (*node, name, args, flags))
71447155
*no_add_attrs = true;
71457156

@@ -7167,23 +7178,8 @@ handle_target_clones_attribute (tree *node, tree name, tree ARG_UNUSED (args),
71677178
{
71687179
/* Ensure we have a function type. */
71697180
if (TREE_CODE (*node) == FUNCTION_DECL)
7170-
{
7171-
if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node)))
7172-
{
7173-
warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
7174-
"with %qs attribute", name, "always_inline");
7175-
*no_add_attrs = true;
7176-
}
7177-
else if (lookup_attribute ("target", DECL_ATTRIBUTES (*node)))
7178-
{
7179-
warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
7180-
"with %qs attribute", name, "target");
7181-
*no_add_attrs = true;
7182-
}
7183-
else
7184-
/* Do not inline functions with multiple clone targets. */
7185-
DECL_UNINLINABLE (*node) = 1;
7186-
}
7181+
/* Do not inline functions with multiple clone targets. */
7182+
DECL_UNINLINABLE (*node) = 1;
71877183
else
71887184
{
71897185
warning (OPT_Wattributes, "%qE attribute ignored", name);

0 commit comments

Comments
 (0)