From patchwork Mon Oct 22 08:41:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 193115 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 C09482C008C for ; Mon, 22 Oct 2012 19:43:39 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1351500220; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=58WLWpMnWJ1Z0HwsP0K+OvCp+fU=; b=NAanaSKEOK1YzDF NukXOzUsi+AHuVnaUJA27mKTPI3wmm/ciPFK0kW1dA3PGG5U8X19pkVgXgDqIzFr 9/gy2dxSs679M4aN8ens9RQ5U0NJZ+QpIscJOEAU1OZ81AlyEEdsx9aTAZs7tl1c D4pExBTkzARyNV8F3Yh4cqLSC1a4= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:Content-Transfer-Encoding:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=cKU/XB64w/Mx+uhCAF8HuE6AwhYTDInUm8HoLp1zeQDpbsQQmkrWixY2txaRdN ObHRMYq2xa87b1uXXXOHQVPodJzLYY07P1SdTScvbiItiGSKHRKTny2hHh2VKY5N YxYCH4EZx/HGnoo9qoKn6iLCtV8SbAwFHevhbbrXVhxhM=; Received: (qmail 31792 invoked by alias); 22 Oct 2012 08:43:33 -0000 Received: (qmail 31784 invoked by uid 22791); 22 Oct 2012 08:43:32 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 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; Mon, 22 Oct 2012 08:43:26 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id CAD18290B1D for ; Mon, 22 Oct 2012 10:43:24 +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 byl6HOAnJgrg for ; Mon, 22 Oct 2012 10:43:24 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 97AD9290B10 for ; Mon, 22 Oct 2012 10:43:24 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix ICE on new limited_with use in Ada 2012 Date: Mon, 22 Oct 2012 10:41:51 +0200 Message-ID: <5518368.6RpW6G0Ynz@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.16-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 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 Ada 2012 has extended the use of limited_with and incomplete types coming from a limited context may now appear in parameter and result profiles. This of course introduces more circularities, especially in -gnatct mode. Tested on x86_64-suse-linux, applied on the mainline. 2012-10-22 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity) : In type annotation mode, break circularities introduced by AI05-0151. 2012-10-22 Eric Botcazou * gnat.dg/specs/limited_with4.ads: New test. * gnat.dg/specs/limited_with4_pkg.ads: New helper. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 192667) +++ gcc-interface/decl.c (working copy) @@ -4142,7 +4142,18 @@ gnat_to_gnu_entity (Entity_Id gnat_entit gnu_return_type = void_type_node; else { - gnu_return_type = gnat_to_gnu_type (gnat_return_type); + /* Ada 2012 (AI05-0151): Incomplete types coming from a limited + context may now appear in parameter and result profiles. If + we are only annotating types, break circularities here. */ + if (type_annotate_only + && IN (Ekind (gnat_return_type), Incomplete_Kind) + && From_With_Type (gnat_return_type) + && In_Extended_Main_Code_Unit + (Non_Limited_View (gnat_return_type)) + && !present_gnu_tree (Non_Limited_View (gnat_return_type))) + gnu_return_type = ptr_void_type_node; + else + gnu_return_type = gnat_to_gnu_type (gnat_return_type); /* If this function returns by reference, make the actual return type the pointer type and make a note of that. */ @@ -4238,11 +4249,30 @@ gnat_to_gnu_entity (Entity_Id gnat_entit Present (gnat_param); gnat_param = Next_Formal_With_Extras (gnat_param), parmnum++) { + Entity_Id gnat_param_type = Etype (gnat_param); tree gnu_param_name = get_entity_name (gnat_param); - tree gnu_param_type = gnat_to_gnu_type (Etype (gnat_param)); - tree gnu_param, gnu_field; - bool copy_in_copy_out = false; + tree gnu_param_type, gnu_param, gnu_field; Mechanism_Type mech = Mechanism (gnat_param); + bool copy_in_copy_out = false, fake_param_type; + + /* Ada 2012 (AI05-0151): Incomplete types coming from a limited + context may now appear in parameter and result profiles. If + we are only annotating types, break circularities here. */ + if (type_annotate_only + && IN (Ekind (gnat_param_type), Incomplete_Kind) + && From_With_Type (Etype (gnat_param_type)) + && In_Extended_Main_Code_Unit + (Non_Limited_View (gnat_param_type)) + && !present_gnu_tree (Non_Limited_View (gnat_param_type))) + { + gnu_param_type = ptr_void_type_node; + fake_param_type = true; + } + else + { + gnu_param_type = gnat_to_gnu_type (gnat_param_type); + fake_param_type = false; + } /* Builtins are expanded inline and there is no real call sequence involved. So the type expected by the underlying expander is @@ -4280,10 +4310,28 @@ gnat_to_gnu_entity (Entity_Id gnat_entit mech = Default; } - gnu_param - = gnat_to_gnu_param (gnat_param, mech, gnat_entity, - Has_Foreign_Convention (gnat_entity), - ©_in_copy_out); + /* Do not call gnat_to_gnu_param for a fake parameter type since + it will try to use the real type again. */ + if (fake_param_type) + { + if (Ekind (gnat_param) == E_Out_Parameter) + gnu_param = NULL_TREE; + else + { + gnu_param + = create_param_decl (gnu_param_name, gnu_param_type, + false); + Set_Mechanism (gnat_param, + mech == Default ? By_Copy : mech); + if (Ekind (gnat_param) == E_In_Out_Parameter) + copy_in_copy_out = true; + } + } + else + gnu_param + = gnat_to_gnu_param (gnat_param, mech, gnat_entity, + Has_Foreign_Convention (gnat_entity), + ©_in_copy_out); /* We are returned either a PARM_DECL or a type if no parameter needs to be passed; in either case, adjust the type. */