Hi,

I believe this very old issue simply boils down to using comptypes with COMPARE_REDECLARATION instead of same_type_p (comp_array_types is careful with TYPE_DOMAINs).

Tested x86_64-linux.

Thanks,
Paolo.

////////////////////
/cp
2014-06-09  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/22556
        * name-lookup.c (pushdecl_maybe_friend_1): Use comptypes.

/testsuite
2014-06-09  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/22556
        * g++.dg/other/redecl3.C: New.
Index: cp/name-lookup.c
===================================================================
--- cp/name-lookup.c    (revision 211370)
+++ cp/name-lookup.c    (working copy)
@@ -974,7 +974,8 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend)
              && (DECL_EXTERNAL (decl) || TREE_PUBLIC (decl))
              /* If different sort of thing, we already gave an error.  */
              && TREE_CODE (decl) == TREE_CODE (x)
-             && !same_type_p (TREE_TYPE (x), TREE_TYPE (decl)))
+             && !comptypes (TREE_TYPE (x), TREE_TYPE (decl),
+                            COMPARE_REDECLARATION))
            {
              if (permerror (input_location, "type mismatch with previous "
                             "external decl of %q#D", x))
Index: testsuite/g++.dg/other/redecl3.C
===================================================================
--- testsuite/g++.dg/other/redecl3.C    (revision 0)
+++ testsuite/g++.dg/other/redecl3.C    (working copy)
@@ -0,0 +1,9 @@
+// PR c++/22556
+
+extern int foo[]; // OK
+int foo[] = {1,2,3};
+extern int foo[]; // OK
+
+void bar(){
+  extern int foo[]; // g++: ERROR -- SHOULD BE OK
+}

Reply via email to