aboutsummaryrefslogtreecommitdiff
path: root/gcc/lto/lto-lang.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/lto/lto-lang.c')
-rw-r--r--gcc/lto/lto-lang.c82
1 files changed, 61 insertions, 21 deletions
diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c
index c2ba3dc..89702a4 100644
--- a/gcc/lto/lto-lang.c
+++ b/gcc/lto/lto-lang.c
@@ -57,46 +57,82 @@ static tree handle_format_attribute (tree *, tree, tree, int, bool *);
static tree handle_fnspec_attribute (tree *, tree, tree, int, bool *);
static tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
+/* Helper to define attribute exclusions. */
+#define ATTR_EXCL(name, function, type, variable) \
+ { name, function, type, variable }
+
+/* Define attributes that are mutually exclusive with one another. */
+static const struct attribute_spec::exclusions attr_noreturn_exclusions[] =
+{
+ ATTR_EXCL ("noreturn", true, true, true),
+ ATTR_EXCL ("alloc_align", true, true, true),
+ ATTR_EXCL ("alloc_size", true, true, true),
+ ATTR_EXCL ("const", true, true, true),
+ ATTR_EXCL ("malloc", true, true, true),
+ ATTR_EXCL ("pure", true, true, true),
+ ATTR_EXCL ("returns_twice", true, true, true),
+ ATTR_EXCL ("warn_unused_result", true, true, true),
+ ATTR_EXCL (NULL, false, false, false),
+};
+
+static const struct attribute_spec::exclusions attr_returns_twice_exclusions[] =
+{
+ ATTR_EXCL ("noreturn", true, true, true),
+ ATTR_EXCL (NULL, false, false, false),
+};
+
+static const struct attribute_spec::exclusions attr_const_pure_exclusions[] =
+{
+ ATTR_EXCL ("const", true, true, true),
+ ATTR_EXCL ("noreturn", true, true, true),
+ ATTR_EXCL ("pure", true, true, true),
+ ATTR_EXCL (NULL, false, false, false)
+};
+
/* Table of machine-independent attributes supported in GIMPLE. */
const struct attribute_spec lto_attribute_table[] =
{
/* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
- do_diagnostic } */
+ do_diagnostic, exclusions } */
{ "noreturn", 0, 0, true, false, false,
- handle_noreturn_attribute, false },
+ handle_noreturn_attribute, false,
+ attr_noreturn_exclusions },
{ "leaf", 0, 0, true, false, false,
- handle_leaf_attribute, false },
+ handle_leaf_attribute, false, NULL },
/* The same comments as for noreturn attributes apply to const ones. */
{ "const", 0, 0, true, false, false,
- handle_const_attribute, false },
+ handle_const_attribute, false,
+ attr_const_pure_exclusions },
{ "malloc", 0, 0, true, false, false,
- handle_malloc_attribute, false },
+ handle_malloc_attribute, false, NULL },
{ "pure", 0, 0, true, false, false,
- handle_pure_attribute, false },
+ handle_pure_attribute, false,
+ attr_const_pure_exclusions },
{ "no vops", 0, 0, true, false, false,
- handle_novops_attribute, false },
+ handle_novops_attribute, false, NULL },
{ "nonnull", 0, -1, false, true, true,
- handle_nonnull_attribute, false },
+ handle_nonnull_attribute, false, NULL },
{ "nothrow", 0, 0, true, false, false,
- handle_nothrow_attribute, false },
+ handle_nothrow_attribute, false, NULL },
{ "patchable_function_entry", 1, 2, true, false, false,
handle_patchable_function_entry_attribute,
- false },
+ false, NULL },
{ "returns_twice", 0, 0, true, false, false,
- handle_returns_twice_attribute, false },
+ handle_returns_twice_attribute, false,
+ attr_returns_twice_exclusions },
{ "sentinel", 0, 1, false, true, true,
- handle_sentinel_attribute, false },
+ handle_sentinel_attribute, false, NULL },
{ "type generic", 0, 0, false, true, true,
- handle_type_generic_attribute, false },
+ handle_type_generic_attribute, false, NULL },
{ "fn spec", 1, 1, false, true, true,
- handle_fnspec_attribute, false },
+ handle_fnspec_attribute, false, NULL },
{ "transaction_pure", 0, 0, false, true, true,
- handle_transaction_pure_attribute, false },
+ handle_transaction_pure_attribute, false, NULL },
/* For internal use only. The leading '*' both prevents its usage in
source code and signals that it may be overridden by machine tables. */
{ "*tm regparm", 0, 0, false, true, true,
- ignore_attribute, false },
- { NULL, 0, 0, false, false, false, NULL, false }
+ ignore_attribute, false, NULL },
+ { NULL, 0, 0, false, false, false, NULL, false, NULL }
};
/* Give the specifications for the format attributes, used by C and all
@@ -105,12 +141,12 @@ const struct attribute_spec lto_attribute_table[] =
const struct attribute_spec lto_format_attribute_table[] =
{
/* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
- affects_type_identity } */
+ affects_type_identity, exclusions } */
{ "format", 3, 3, false, true, true,
- handle_format_attribute, false },
+ handle_format_attribute, false, NULL },
{ "format_arg", 1, 1, false, true, true,
- handle_format_arg_attribute, false },
- { NULL, 0, 0, false, false, false, NULL, false }
+ handle_format_arg_attribute, false, NULL },
+ { NULL, 0, 0, false, false, false, NULL, false, NULL }
};
enum built_in_attribute
@@ -264,6 +300,10 @@ handle_const_attribute (tree *node, tree ARG_UNUSED (name),
tree ARG_UNUSED (args), int ARG_UNUSED (flags),
bool * ARG_UNUSED (no_add_attrs))
{
+ if (TREE_CODE (*node) != FUNCTION_DECL
+ || !DECL_BUILT_IN (*node))
+ inform (UNKNOWN_LOCATION, "%s:%s: %E: %E", __FILE__, __func__, *node, name);
+
tree type = TREE_TYPE (*node);
/* See FIXME comment on noreturn in c_common_attribute_table. */