From patchwork Tue Oct 26 13:05:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 69246 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 60461B70D2 for ; Wed, 27 Oct 2010 00:06:01 +1100 (EST) Received: (qmail 18684 invoked by alias); 26 Oct 2010 13:05:57 -0000 Received: (qmail 18670 invoked by uid 22791); 26 Oct 2010 13:05:56 -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) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 26 Oct 2010 13:05:42 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 8E29ECB02FA; Tue, 26 Oct 2010 15:05:40 +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 XRLzeGB6zUao; Tue, 26 Oct 2010 15:05:40 +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 77EE9CB02F2; Tue, 26 Oct 2010 15:05:40 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 52A34D9BB4; Tue, 26 Oct 2010 15:05:40 +0200 (CEST) Date: Tue, 26 Oct 2010 15:05:40 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [Ada] Fix regression in imported C++ type that cover interface primitives Message-ID: <20101026130540.GA5004@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 This patch fixes a regression of the compiler in the management of imported C++ types that cover interfaces. The following test now compiles without errors. package Animals is type Carnivore is limited interface; function Number_Of_Teeth (X : Carnivore) return Natural is abstract; pragma Convention (CPP, Number_Of_Teeth); type Animal is tagged limited null record; pragma Import (CPP, Animal); type Dog is new Animal and Carnivore with null record; pragma Import (CPP, Dog); function Number_Of_Teeth (A : Dog) return Natural; pragma Import (CPP, Number_Of_Teeth); end Animals; Command: gcc -c -gnat05 animals.ads -gnatws Tested on x86_64-pc-linux-gnu, committed on trunk 2010-10-26 Javier Miranda * sem_prag.adb (Process_Import_Or_Interface): Skip primitives of interface types when processing all the entities in the homonym chain that are declared in the same declarative part. Index: sem_prag.adb =================================================================== --- sem_prag.adb (revision 165941) +++ sem_prag.adb (working copy) @@ -3928,6 +3928,14 @@ package body Sem_Prag is then null; + -- The pragma does not apply to primitives of interfaces + + elsif Is_Dispatching_Operation (Def_Id) + and then Present (Find_Dispatching_Type (Def_Id)) + and then Is_Interface (Find_Dispatching_Type (Def_Id)) + then + null; + -- Verify that the homonym is in the same declarative part (not -- just the same scope). @@ -4047,10 +4055,10 @@ package body Sem_Prag is and then C = Convention_CPP then -- Types treated as CPP classes are treated as limited, but we - -- don't require them to be declared this way. A warning is - -- issued to encourage the user to declare them as limited. - -- This is not an error, for compatibility reasons, because - -- these types have been supported this way for some time. + -- don't require them to be declared this way. A warning is issued + -- to encourage the user to declare them as limited. This is not + -- an error, for compatibility reasons, because these types have + -- been supported this way for some time. if not Is_Limited_Type (Def_Id) then Error_Msg_N