diff options
author | Joseph Myers <jsm28@cam.ac.uk> | 2001-06-11 12:50:29 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2001-06-11 12:50:29 +0100 |
commit | f18b70f587310c161b81a159523cf13262b393c3 (patch) | |
tree | f31c4c85770575b6701e3a1a5db7bbfed83e24dd /gcc/c-decl.c | |
parent | 89cc6be35070f5aa20e0b6189daa6788726ea220 (diff) | |
download | gcc-f18b70f587310c161b81a159523cf13262b393c3.zip gcc-f18b70f587310c161b81a159523cf13262b393c3.tar.gz gcc-f18b70f587310c161b81a159523cf13262b393c3.tar.bz2 |
c-decl.c (xref_tag): Don't return previous tags of wrong type.
* c-decl.c (xref_tag): Don't return previous tags of wrong type.
testsuite:
* gcc.dg/c99-tag-1.c: Add more tests.
From-SVN: r43179
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 78c852e..b68f772 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -5226,11 +5226,18 @@ xref_tag (code, name) already defined for this tag and return it. */ register tree ref = lookup_tag (code, name, current_binding_level, 0); - /* Even if this is the wrong type of tag, return what we found. - There will be an error message anyway, from pending_xref_error. - If we create an empty xref just for an invalid use of the type, - the main result is to create lots of superfluous error messages. */ - if (ref) + /* If this is the right type of tag, return what we found. + (This reference will be shadowed by shadow_tag later if appropriate.) + If this is the wrong type of tag, do not return it. If it was the + wrong type in the same binding level, we will have had an error + message already; if in a different binding level and declaring + a name, pending_xref_error will give an error message; but if in a + different binding level and not declaring a name, this tag should + shadow the previous declaration of a different type of tag, and + this would not work properly if we return the reference found. + (For example, with "struct foo" in an outer scope, "union foo;" + must shadow that tag with a new one of union type.) */ + if (ref && TREE_CODE (ref) == code) return ref; /* If no such tag is yet defined, create a forward-reference node |