diff mbox

[C++] PR 22556

Message ID 5395EA2A.4000408@oracle.com
State New
Headers show

Commit Message

Paolo Carlini June 9, 2014, 5:08 p.m. UTC
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.carlini@oracle.com>

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

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

	PR c++/22556
	* g++.dg/other/redecl3.C: New.

Comments

Jason Merrill June 9, 2014, 6:48 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

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
+}