summaryrefslogtreecommitdiff
path: root/gcc/attribs.c
diff options
context:
space:
mode:
authorira <ira@138bc75d-0d04-0410-961f-82ee72b054a4>2002-01-10 18:51:24 +0000
committerira <ira@138bc75d-0d04-0410-961f-82ee72b054a4>2002-01-10 18:51:24 +0000
commit88da234dc7be67523c21ab558bd6e8b04aff7842 (patch)
treeea5ad261c8b70074c9c7c1c74de2f56e14b206cd /gcc/attribs.c
parentb3a976d8079392f6be31f4fe1ed477f34d9fe315 (diff)
downloadgcc-88da234dc7be67523c21ab558bd6e8b04aff7842.tar.gz
Added __attribute__((deprecated)) patches.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48743 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/attribs.c')
-rw-r--r--gcc/attribs.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/gcc/attribs.c b/gcc/attribs.c
index 19e99ad3055..f342cd16bf3 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -82,6 +82,8 @@ static tree handle_no_limit_stack_attribute PARAMS ((tree *, tree, tree, int,
bool *));
static tree handle_pure_attribute PARAMS ((tree *, tree, tree, int,
bool *));
+static tree handle_deprecated_attribute PARAMS ((tree *, tree, tree, int,
+ bool *));
static tree handle_vector_size_attribute PARAMS ((tree *, tree, tree, int,
bool *));
static tree vector_size_helper PARAMS ((tree, tree));
@@ -138,6 +140,8 @@ static const struct attribute_spec c_common_attribute_table[] =
handle_no_limit_stack_attribute },
{ "pure", 0, 0, true, false, false,
handle_pure_attribute },
+ { "deprecated", 0, 0, false, false, false,
+ handle_deprecated_attribute },
{ "vector_size", 1, 1, false, true, false,
handle_vector_size_attribute },
{ NULL, 0, 0, false, false, false, NULL }
@@ -1131,6 +1135,67 @@ handle_pure_attribute (node, name, args, flags, no_add_attrs)
return NULL_TREE;
}
+/* Handle a "deprecated" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_deprecated_attribute (node, name, args, flags, no_add_attrs)
+ tree *node;
+ tree name;
+ tree args ATTRIBUTE_UNUSED;
+ int flags;
+ bool *no_add_attrs;
+{
+ tree type = NULL_TREE;
+ int warn = 0;
+ char *what = NULL;
+
+ if (DECL_P (*node))
+ {
+ tree decl = *node;
+ type = TREE_TYPE (decl);
+
+ if (TREE_CODE (decl) == TYPE_DECL
+ || TREE_CODE (decl) == PARM_DECL
+ || TREE_CODE (decl) == VAR_DECL
+ || TREE_CODE (decl) == FUNCTION_DECL
+ || TREE_CODE (decl) == FIELD_DECL)
+ TREE_DEPRECATED (decl) = 1;
+ else
+ warn = 1;
+ }
+ else if (TYPE_P (*node))
+ {
+ if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
+ *node = build_type_copy (*node);
+ TREE_DEPRECATED (*node) = 1;
+ type = *node;
+ }
+ else
+ warn = 1;
+
+ if (warn)
+ {
+ *no_add_attrs = true;
+ if (type && TYPE_NAME (type))
+ {
+ if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
+ what = IDENTIFIER_POINTER (TYPE_NAME (*node));
+ else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
+ && DECL_NAME (TYPE_NAME (type)))
+ what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
+ }
+ if (what)
+ warning ("`%s' attribute ignored for `%s'",
+ IDENTIFIER_POINTER (name), what);
+ else
+ warning ("`%s' attribute ignored",
+ IDENTIFIER_POINTER (name));
+ }
+
+ return NULL_TREE;
+}
+
/* Handle a "vector_size" attribute; arguments as in
struct attribute_spec.handler. */