aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
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 d6e8ac3..206c7718 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])