result = 201907;
else if (is_attribute_p ("assume", attr_name))
result = 202207;
+ else if (is_attribute_p ("init_priority", attr_name))
+ {
+ /* The (non-standard) init_priority attribute is always
+ included in the attribute table, but we don't want to
+ advertise the attribute unless the target actually
+ supports init priorities. */
+ result = SUPPORTS_INIT_PRIORITY ? 1 : 0;
+ attr_name = NULL_TREE;
+ }
}
else
{
{
/* { name, min_len, max_len, decl_req, type_req, fn_type_req,
affects_type_identity, handler, exclude } */
-#if SUPPORTS_INIT_PRIORITY
{ "init_priority", 1, 1, true, false, false, false,
handle_init_priority_attribute, NULL },
-#endif
{ "abi_tag", 1, -1, false, false, false, true,
handle_abi_tag_attribute, NULL },
{ NULL, 0, 0, false, false, false, false, NULL, NULL }
/* Handle an "init_priority" attribute; arguments as in
struct attribute_spec.handler. */
-ATTRIBUTE_UNUSED static tree
+static tree
handle_init_priority_attribute (tree* node,
tree name,
tree args,
int /*flags*/,
bool* no_add_attrs)
{
+ if (!SUPPORTS_INIT_PRIORITY)
+ /* Treat init_priority as an unrecognized attribute (mirroring
+ __has_attribute) if the target doesn't support init priorities. */
+ return error_mark_node;
+
tree initp_expr = TREE_VALUE (args);
tree decl = *node;
tree type = TREE_TYPE (decl);
pri);
}
- gcc_assert (SUPPORTS_INIT_PRIORITY);
SET_DECL_INIT_PRIORITY (decl, pri);
DECL_HAS_INIT_PRIORITY_P (decl) = 1;
return NULL_TREE;