Commit 108ebf88 by Joseph Myers Committed by Joseph Myers

toplev.c (warn_deprecated_use): Correct logic for saying "type" in diagnostic.

	* toplev.c (warn_deprecated_use): Correct logic for saying "type"
	in diagnostic.  Don't dereference NULL TYPE_NAME.

testsuite:
	* gcc.dg/deprecated-2.c: New test.

From-SVN: r87289
parent 6cb38cd4
2004-09-10 Joseph S. Myers <jsm@polyomino.org.uk>
* toplev.c (warn_deprecated_use): Correct logic for saying "type"
in diagnostic. Don't dereference NULL TYPE_NAME.
2004-09-10 Kazu Hirata <kazu@cs.umass.edu> 2004-09-10 Kazu Hirata <kazu@cs.umass.edu>
* c-common.c, c-pch.c, defaults.h, lambda-code.c, passes.c, * c-common.c, c-pch.c, defaults.h, lambda-code.c, passes.c,
......
2004-09-10 Joseph S. Myers <jsm@polyomino.org.uk>
* gcc.dg/deprecated-2.c: New test.
2004-09-09 James E Wilson <wilson@specifixinc.com> 2004-09-09 James E Wilson <wilson@specifixinc.com>
* gcc.dg/init-vec-1.c: New test. * gcc.dg/init-vec-1.c: New test.
......
/* Test __attribute__((deprecated)). Test types without names. */
/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
/* { dg-do compile } */
/* { dg-options "" } */
struct { int a; } __attribute__((deprecated)) x; /* { dg-warning "type is deprecated" } */
typeof(x) y; /* { dg-warning "type is deprecated" } */
...@@ -900,11 +900,14 @@ warn_deprecated_use (tree node) ...@@ -900,11 +900,14 @@ warn_deprecated_use (tree node)
const char *what = NULL; const char *what = NULL;
tree decl = TYPE_STUB_DECL (node); tree decl = TYPE_STUB_DECL (node);
if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE) if (TYPE_NAME (node))
what = IDENTIFIER_POINTER (TYPE_NAME (node)); {
else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
&& DECL_NAME (TYPE_NAME (node))) what = IDENTIFIER_POINTER (TYPE_NAME (node));
what = IDENTIFIER_POINTER (DECL_NAME (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 (decl) if (decl)
{ {
...@@ -920,9 +923,9 @@ warn_deprecated_use (tree node) ...@@ -920,9 +923,9 @@ warn_deprecated_use (tree node)
else else
{ {
if (what) if (what)
warning ("type is deprecated");
else
warning ("`%s' is deprecated", what); warning ("`%s' is deprecated", what);
else
warning ("type is deprecated");
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment