From patchwork Fri Sep 10 10:02:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 64366 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 3C3A2B7116 for ; Fri, 10 Sep 2010 20:02:18 +1000 (EST) Received: (qmail 23096 invoked by alias); 10 Sep 2010 10:02:13 -0000 Received: (qmail 23086 invoked by uid 22791); 10 Sep 2010 10:02:12 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 10 Sep 2010 10:02:07 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 01619CB0315; Fri, 10 Sep 2010 12:02:05 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nbQcfS+Qk9oV; Fri, 10 Sep 2010 12:02:04 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id E3F94CB01E0; Fri, 10 Sep 2010 12:02:04 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id C7C23D9BB4; Fri, 10 Sep 2010 12:02:04 +0200 (CEST) Date: Fri, 10 Sep 2010 12:02:04 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Interface operations that are renamings Message-ID: <20100910100204.GA28635@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes 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 If the parent subprogram in a type derivation is an explicit renaming of an interface primitive, it is a regular primitive operation, and the presence of its alias is not relevant: it has to be derived like any other primitive. The following must compile quietly: gcc -c -gnat05 p2.ads --- package P1 is type I1 is limited interface; procedure P (Self : not null access I1) is abstract; procedure H (Self : not null access I1) renames P; end P1; --- with P1; package P2 is type T1 is limited new P1.I1 with private; private type T1 is limited new P1.I1 with null record; overriding procedure P (Self : not null access T1) is null; overriding procedure H (Self : not null access T1) is null; end P2; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-09-10 Ed Schonberg * sem_ch3.adb (Derive_Subprograms): An interface primitive operation that is a renaming must be derived like any other primitive operation, the renamed operation is not relevant to the derivation. Index: sem_ch3.adb =================================================================== --- sem_ch3.adb (revision 164154) +++ sem_ch3.adb (working copy) @@ -12966,8 +12966,16 @@ package body Sem_Ch3 is -- were not covered by the parent type. We exclude here null -- interface primitives because they do not need special -- management. + -- We also exclude interface operations that are renamings. + -- If the subprogram is an explicit renaming of an interface + -- primitive, it is a regular primitive operation, and the + -- presence of its alias is not relevant: it has to be derived + -- like any other primitive. elsif Present (Alias (Subp)) + and then + Nkind (Unit_Declaration_Node (Subp)) + /= N_Subprogram_Renaming_Declaration and then Is_Interface (Find_Dispatching_Type (Alias_Subp)) and then not (Nkind (Parent (Alias_Subp)) = N_Procedure_Specification