From patchwork Thu Oct 10 11:03:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 282208 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 355462C00B8 for ; Thu, 10 Oct 2013 22:03:41 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=hz/JvFwuhenW1NufuzXj6JTX7fnICG/KAw+2N6HDoi2aJeM8RI Ct8q+cGGS4g/GvaOmIA4OUt1mkS5UmloBcIgybtgfqrk4gUV5F6cE5wZvvYKLHka PQSchTuSw7p+8JTLF6Vv22fZUTRQu9t2bGe6y0zNM5HSPC90HUYBL5KDk= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=A5qX2BfIQ3f5c+U4C80FEKB1ys8=; b=dn7cjZGpzXZyCQvKuTOy fO/0T5z1KPJo3wH3A0U0QmHGduTZY3OEBPtc/js3HIDun3xBJ+AFx8MOBX8vwpMK stDS98kmxdJ+FpOjl40BoEwKoon1+PZepB8fKUTYTOwnA3dKHeHGem0AyWG42r5c 7ALx//napn0eJhnoR2Tw9dk= Received: (qmail 16210 invoked by alias); 10 Oct 2013 11:03:35 -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 16201 invoked by uid 89); 10 Oct 2013 11:03:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 10 Oct 2013 11:03:34 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 615EE11672B; Thu, 10 Oct 2013 07:03:53 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 3j5I7cxKqk8x; Thu, 10 Oct 2013 07:03:53 -0400 (EDT) Received: from kwai.gnat.com (unknown [IPv6:2620:20:4000:0:a6ba:dbff:fe26:1f63]) by rock.gnat.com (Postfix) with ESMTP id 51F741166B6; Thu, 10 Oct 2013 07:03:53 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 2D8933FB31; Thu, 10 Oct 2013 07:03:32 -0400 (EDT) Date: Thu, 10 Oct 2013 07:03:32 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Improper visibility with child instance that is siblling of current unit Message-ID: <20131010110332.GA14984@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) This patch fixes a visibility hole in the instantiation of child units. Before this patch, a declaration in the private part of a non-generic common ancestor was made visible by an instantiation of a child unit in another descendant of that ancestor. Compiling p-c.ads must be rejected with: p-c.ads:8:19: "Private_Integer" is not visible p-c.ads:8:19: non-visible (private) declaration at p.ads:5 --- package P is private Private_Integer : Integer := 1; end P; --- generic package P.G is end P.G; --- with P.G; package P.C is package NG is new P.G; -- This instantiation causes the visibility problem. Y : Integer := Private_Integer; -- ERROR: Private_Integer not visible here end P.C; Tested on x86_64-pc-linux-gnu, committed on trunk 2013-10-10 Ed Schonberg * sem_ch7.adb (Install_Parent_Private_Declarations): When instantiating a child unit, do not install private declaration of a non-generic ancestor of the generic that is also an ancestor of the current unit: its private part will be installed when private part of ancestor itself is analyzed. Index: sem_ch7.adb =================================================================== --- sem_ch7.adb (revision 203342) +++ sem_ch7.adb (working copy) @@ -1167,17 +1167,31 @@ -- then finish off by looping through the nongeneric parents -- and installing their private declarations. + -- If one of the non-generic parents is itself on the scope + -- stack, do not install its private declarations: they are + -- installed in due time when the private part of that parent + -- is analyzed. + else while Present (Inst_Par) and then Inst_Par /= Standard_Standard and then (not In_Open_Scopes (Inst_Par) or else not In_Private_Part (Inst_Par)) loop - Install_Private_Declarations (Inst_Par); - Set_Use (Private_Declarations - (Specification - (Unit_Declaration_Node (Inst_Par)))); - Inst_Par := Scope (Inst_Par); + if Nkind (Inst_Node) = N_Formal_Package_Declaration + or else + not Is_Ancestor_Package + (Inst_Par, Cunit_Entity (Current_Sem_Unit)) + then + Install_Private_Declarations (Inst_Par); + Set_Use (Private_Declarations + (Specification + (Unit_Declaration_Node (Inst_Par)))); + Inst_Par := Scope (Inst_Par); + + else + exit; + end if; end loop; exit;