From patchwork Mon Nov 21 11:26:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 126746 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]) by ozlabs.org (Postfix) with SMTP id 4F71AB6FD1 for ; Mon, 21 Nov 2011 22:26:48 +1100 (EST) Received: (qmail 9006 invoked by alias); 21 Nov 2011 11:26:45 -0000 Received: (qmail 8987 invoked by uid 22791); 21 Nov 2011 11:26:44 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 Nov 2011 11:26:24 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id E27822BB123; Mon, 21 Nov 2011 06:26:23 -0500 (EST) 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 bXI7rVosAsPp; Mon, 21 Nov 2011 06:26:23 -0500 (EST) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id C85522BB0FE; Mon, 21 Nov 2011 06:26:23 -0500 (EST) Received: by kwai.gnat.com (Postfix, from userid 4192) id C7F873FEE8; Mon, 21 Nov 2011 06:26:23 -0500 (EST) Date: Mon, 21 Nov 2011 06:26:23 -0500 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Conformance checks on partially parametrized formal packages Message-ID: <20111121112623.GA9600@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 A formal subprogram of the formal package can be specified with a box default, or can be covered by an others association with a box initialization. In either case there is no need to check its conformance with the actual subprogram that appears in the instantiation of the formal package. This patch covers the case of an others association, whose representation is different from that of an explicit box initialization for the formal subprogram. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-11-21 Ed Schonberg * sem_ch12.adb (Check_Formal_Package_Instance): If a formal subprogram of the formal package is covered by an others association with a box initialization, no check is needed against the actual in the instantiation of the formal package. Index: sem_ch12.adb =================================================================== --- sem_ch12.adb (revision 181556) +++ sem_ch12.adb (working copy) @@ -5076,6 +5076,18 @@ then null; + -- If the formal package has an "others" box association that + -- covers this formal, there is no need for a check either. + + elsif Nkind (Unit_Declaration_Node (E2)) in + N_Formal_Subprogram_Declaration + and then Box_Present (Unit_Declaration_Node (E2)) + then + null; + + -- Otherwise the actual in the formal and the actual in the + -- instantiation of the formal must match, up to renamings. + else Check_Mismatch (Ekind (E2) /= Ekind (E1) or else (Alias (E1)) /= Alias (E2)); @@ -12383,9 +12395,11 @@ procedure Reset_Entity (N : Node_Id) is procedure Set_Global_Type (N : Node_Id; N2 : Node_Id); - -- If the type of N2 is global to the generic unit. Save the type in - -- the generic node. - -- What does this comment mean??? + -- If the type of N2 is global to the generic unit, save the type in + -- the generic node. Just as we perform name capture for explicit + -- references within the generic, we must capture the global types + -- of local entities because they may participate in resolution in + -- the instance. function Top_Ancestor (E : Entity_Id) return Entity_Id; -- Find the ultimate ancestor of the current unit. If it is not a