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
This commit is contained in:
Joseph Myers 2004-09-10 11:54:25 +01:00 committed by Joseph Myers
parent 6cb38cd4ae
commit 108ebf88b2
4 changed files with 26 additions and 7 deletions

View File

@ -1,3 +1,8 @@
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>
* c-common.c, c-pch.c, defaults.h, lambda-code.c, passes.c,

View File

@ -1,3 +1,7 @@
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>
* gcc.dg/init-vec-1.c: New test.

View File

@ -0,0 +1,7 @@
/* 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" } */

View File

@ -900,11 +900,14 @@ warn_deprecated_use (tree 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 (TYPE_NAME (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 (decl)
{
@ -920,9 +923,9 @@ warn_deprecated_use (tree node)
else
{
if (what)
warning ("type is deprecated");
else
warning ("`%s' is deprecated", what);
else
warning ("type is deprecated");
}
}
}