From 108ebf88b21935d2e28ffe205b2126b49acf9e12 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Fri, 10 Sep 2004 11:54:25 +0100 Subject: [PATCH] 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 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/deprecated-2.c | 7 +++++++ gcc/toplev.c | 17 ++++++++++------- 4 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/deprecated-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 72d1e46fbaf..74815048c0c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-09-10 Joseph S. Myers + + * toplev.c (warn_deprecated_use): Correct logic for saying "type" + in diagnostic. Don't dereference NULL TYPE_NAME. + 2004-09-10 Kazu Hirata * c-common.c, c-pch.c, defaults.h, lambda-code.c, passes.c, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1dbc50a01d5..c33d260b5b3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-09-10 Joseph S. Myers + + * gcc.dg/deprecated-2.c: New test. + 2004-09-09 James E Wilson * gcc.dg/init-vec-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/deprecated-2.c b/gcc/testsuite/gcc.dg/deprecated-2.c new file mode 100644 index 00000000000..c4ca8a272d0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/deprecated-2.c @@ -0,0 +1,7 @@ +/* Test __attribute__((deprecated)). Test types without names. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +struct { int a; } __attribute__((deprecated)) x; /* { dg-warning "type is deprecated" } */ +typeof(x) y; /* { dg-warning "type is deprecated" } */ diff --git a/gcc/toplev.c b/gcc/toplev.c index c3cae64b296..79094e2e039 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -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"); } } } -- 2.30.2