summaryrefslogtreecommitdiff
path: root/gcc/c-decl.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/c-decl.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/c-decl.c')
-rw-r--r--gcc/c-decl.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index d6e8ac33469..206c7718ba1 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -439,6 +439,18 @@ int warn_multichar = 1;
#endif
int dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
+/* States indicating how grokdeclarator() should handle declspecs marked
+ with __attribute__((deprecated)). An object declared as
+ __attribute__((deprecated)) suppresses warnings of uses of other
+ deprecated items. */
+
+enum deprecated_states {
+ DEPRECATED_NORMAL,
+ DEPRECATED_SUPPRESS
+};
+
+static enum deprecated_states deprecated_state = DEPRECATED_NORMAL;
+
/* Decode the string P as a language-specific option for C.
Return the number of strings consumed. Should not complain
if it does not recognise the option. */
@@ -3420,9 +3432,18 @@ start_decl (declarator, declspecs, initialized, attributes)
int initialized;
tree attributes;
{
- tree decl = grokdeclarator (declarator, declspecs,
- NORMAL, initialized);
+ tree decl;
tree tem;
+
+ /* An object declared as __attribute__((deprecated)) suppresses
+ warnings of uses of other deprecated items. */
+ if (lookup_attribute ("deprecated", attributes))
+ deprecated_state = DEPRECATED_SUPPRESS;
+
+ decl = grokdeclarator (declarator, declspecs,
+ NORMAL, initialized);
+
+ deprecated_state = DEPRECATED_NORMAL;
if (warn_main > 0 && TREE_CODE (decl) != FUNCTION_DECL
&& MAIN_NAME_P (DECL_NAME (decl)))
@@ -4091,6 +4112,14 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
{
tree id = TREE_VALUE (spec);
+ /* If the entire declaration is itself tagged as deprecated then
+ suppress reports of deprecated items. */
+ if (id && TREE_DEPRECATED (id))
+ {
+ if (deprecated_state != DEPRECATED_SUPPRESS)
+ warn_deprecated_use (id);
+ }
+
if (id == ridpointers[(int) RID_INT])
explicit_int = 1;
if (id == ridpointers[(int) RID_CHAR])