From b18138e7efd754caa7c212dbe49007b33c087576 Mon Sep 17 00:00:00 2001 From: mmitchel Date: Fri, 28 May 1999 02:37:13 +0000 Subject: [PATCH] * decl.c (add_binding): Don't complain about a redeclaration of a semantically identical typedef in a local scope. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@27213 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 14 ++++++++++++++ gcc/testsuite/g++.old-deja/g++.other/typedef7.C | 17 +++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/typedef7.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f6496ec..5307cb2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +1999-05-28 Mark Mitchell + + * decl.c (add_binding): Don't complain about a redeclaration of a + semantically identical typedef in a local scope. + 1999-05-28 Nathan Sidwell * decl.c (complete_array_type): Allocate off same obstack. Fix diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index ea6acd7..edcd608 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1143,6 +1143,20 @@ add_binding (id, decl) BINDING_VALUE (binding) = decl; INHERITED_VALUE_BINDING_P (binding) = 0; } + else if (TREE_CODE (BINDING_VALUE (binding)) == TYPE_DECL + && TREE_CODE (decl) == TYPE_DECL + && DECL_NAME (decl) == DECL_NAME (BINDING_VALUE (binding)) + && same_type_p (TREE_TYPE (decl), + TREE_TYPE (BINDING_VALUE (binding)))) + /* We have two typedef-names, both naming the same type to have + the same name. This is OK because of: + + [dcl.typedef] + + In a given scope, a typedef specifier can be used to redefine + the name of any type declared in that scope to refer to the + type to which it already refers. */ + ok = 0; else { cp_error ("declaration of `%#D'", decl); diff --git a/gcc/testsuite/g++.old-deja/g++.other/typedef7.C b/gcc/testsuite/g++.old-deja/g++.other/typedef7.C new file mode 100644 index 0000000..d0e9dab --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/typedef7.C @@ -0,0 +1,17 @@ +// Build don't link: +// Origin: Mark Mitchell + +typedef int I; +typedef int I; + +struct A { + typedef int I; + typedef int I; +}; + +template +struct S { + typedef int I; + typedef int I; +}; + -- 2.7.4