decl.c (add_binding): Don't complain about a redeclaration of a semantically identica...
authorMark Mitchell <mark@codesourcery.com>
Fri, 28 May 1999 02:37:13 +0000 (02:37 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 28 May 1999 02:37:13 +0000 (02:37 +0000)
* decl.c (add_binding): Don't complain about a redeclaration of a
semantically identical typedef in a local scope.

From-SVN: r27213

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.old-deja/g++.other/typedef7.C [new file with mode: 0644]

index f6496eca372fefd7d209abec935151cbeb4d111b..5307cb2d3d3ab15ad71af34d429ec01b2a918800 100644 (file)
@@ -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
index ea6acd738903dd38befdd153eda379fd72215044..edcd60832687e0436bcc61c120a15b5426c18c82 100644 (file)
@@ -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 (file)
index 0000000..d0e9dab
--- /dev/null
@@ -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;
+};
+