aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>1999-05-28 02:37:13 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-05-28 02:37:13 +0000
commit263505afafc29e3c1ee3b9b93db70b597ff7227b (patch)
treece1b3050537428a4cbeec7650e785c4ffb634429
parent6c123729de158957c1a7c2d3ddb66e3fb27d1f75 (diff)
downloadgcc-263505afafc29e3c1ee3b9b93db70b597ff7227b.zip
gcc-263505afafc29e3c1ee3b9b93db70b597ff7227b.tar.gz
gcc-263505afafc29e3c1ee3b9b93db70b597ff7227b.tar.bz2
decl.c (add_binding): Don't complain about a redeclaration of a semantically identical typedef in a...
* decl.c (add_binding): Don't complain about a redeclaration of a semantically identical typedef in a local scope. From-SVN: r27213
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c14
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/typedef7.C17
3 files changed, 36 insertions, 0 deletions
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 <mark@codesourcery.com>
+
+ * decl.c (add_binding): Don't complain about a redeclaration of a
+ semantically identical typedef in a local scope.
+
1999-05-28 Nathan Sidwell <nathan@acm.org>
* 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 <mark@codesourcery.com>
+
+typedef int I;
+typedef int I;
+
+struct A {
+ typedef int I;
+ typedef int I;
+};
+
+template <class T>
+struct S {
+ typedef int I;
+ typedef int I;
+};
+