From patchwork Mon Jun 9 17:08:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 357573 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 52728140081 for ; Tue, 10 Jun 2014 03:12:19 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=uLaSQBr9EOQecvNqVE2HJLvc8JWUg8UR4FRUjpsWacI lnxw+nHlwav4yE0xSBci16+G/4z1u9q/qXkK8NrkwOaEZOIp2V19jdTYpN/b2Ctb Jx0kZvZOkYZlYuCiVIxMVvROg0wI/KOkRWVhIgayi4fb7xfyyvLQmde4Owh9Dirw = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=u9kpqWLLx7eC8G1QUmrbeoC2/HQ=; b=Ah4ssU1y6Wc7djxtK dZz6jf6fkyLxZY+izowvOZqhLJGpBxJpNmaiPKK+YjW8wBrF6fvcj2oyV7Lfd8HI vkzkyT3wd6NtbNlrilGCokbdBBg0PSlkoHp+SUF77EUwpXBvzZtvhmWO5lnRQ0/7 rM4tdN4QB6fIFYIYP30cD96reg= Received: (qmail 25427 invoked by alias); 9 Jun 2014 17:12:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 25415 invoked by uid 89); 9 Jun 2014 17:12:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 09 Jun 2014 17:12:10 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s59HC7nl020125 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 9 Jun 2014 17:12:08 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s59HC6Ax005169 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 9 Jun 2014 17:12:07 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id s59HC51u025142; Mon, 9 Jun 2014 17:12:05 GMT Received: from [192.168.1.4] (/80.181.50.126) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Jun 2014 10:12:04 -0700 Message-ID: <5395EA2A.4000408@oracle.com> Date: Mon, 09 Jun 2014 19:08:58 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 22556 X-IsSubscribed: yes 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 PR c++/22556 * name-lookup.c (pushdecl_maybe_friend_1): Use comptypes. /testsuite 2014-06-09 Paolo Carlini 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 +}