aboutsummaryrefslogtreecommitdiff
path: root/gcc/toplev.c
diff options
context:
space:
mode:
authorGabriel Dos Reis <gdr@integrable-solutions.net>2003-09-07 11:59:52 +0000
committerGabriel Dos Reis <gdr@gcc.gnu.org>2003-09-07 11:59:52 +0000
commit43f9ce025631eabe87889646e50d19c1d228c680 (patch)
treea13e6b35d663ef787e8ad6315376985896dbd63f /gcc/toplev.c
parentc57e159892e138cdb46977dc063d8a3a9aa91281 (diff)
downloadgcc-43f9ce025631eabe87889646e50d19c1d228c680.zip
gcc-43f9ce025631eabe87889646e50d19c1d228c680.tar.gz
gcc-43f9ce025631eabe87889646e50d19c1d228c680.tar.bz2
* diagnostic.c (warn_deprecated_use): Move to toplev.c
From-SVN: r71168
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r--gcc/toplev.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 92ef835..aa04138 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1702,6 +1702,44 @@ check_global_declarations (tree *vec, int len)
}
}
+/* Warn about a use of an identifier which was marked deprecated. */
+void
+warn_deprecated_use (tree node)
+{
+ if (node == 0 || !warn_deprecated_decl)
+ return;
+
+ if (DECL_P (node))
+ warning ("`%s' is deprecated (declared at %s:%d)",
+ IDENTIFIER_POINTER (DECL_NAME (node)),
+ DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node));
+ else if (TYPE_P (node))
+ {
+ const char *what = NULL;
+ tree decl = TYPE_STUB_DECL (node);
+
+ if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
+ what = IDENTIFIER_POINTER (TYPE_NAME (node));
+ else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
+ && DECL_NAME (TYPE_NAME (node)))
+ what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
+
+ if (what)
+ {
+ if (decl)
+ warning ("`%s' is deprecated (declared at %s:%d)", what,
+ DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
+ else
+ warning ("`%s' is deprecated", what);
+ }
+ else if (decl)
+ warning ("type is deprecated (declared at %s:%d)",
+ DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
+ else
+ warning ("type is deprecated");
+ }
+}
+
/* Save the current INPUT_LOCATION on the top entry in the
INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
INPUT_LOCATION accordingly. */