From patchwork Fri Oct 10 14:43:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 398648 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id CADCE1400BE for ; Sat, 11 Oct 2014 01:43:23 +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=wyFZCI6Z8/PQUpZAUHbafa4MwCARo2hVGpiTf/Oy7ivvUtpAuA bThWOig66PP3SHODfzBUlV1Kdc2QDzImGZJaYnsWjFOYAmwJG8L2mpsgm5YO0Lhw Ylv2647COKHzF1kSjDyyePHca1/I5TfUlMxUY8WvpZlAdmRRctYl0FCvA= 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=JKs4tKFAr2OrylP3BUIMPBabWjI=; b=KJfxwgJ0Mft2QWstfSTC ohWbU8oc9ZIhQ8/zxSnQ+HnaEq0m22B7dN9mvQJ+Kt/v9FpmniNcmDbyvfhk+AvM 9krXBw6xqJR1ELiZ9QgOmqtT6yDWGXcpmh3haiO9uJLsGsnrzFGjBeDhMvBcqOaj z0A9NegMCI3glN1HZwP4TtY= Received: (qmail 21426 invoked by alias); 10 Oct 2014 14:43:08 -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 21339 invoked by uid 89); 10 Oct 2014 14:43:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, 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; Fri, 10 Oct 2014 14:43:06 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id E3427116358; Fri, 10 Oct 2014 10:43:04 -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 ia0B87VlPrR2; Fri, 10 Oct 2014 10:43:04 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 86568116353; Fri, 10 Oct 2014 10:43:04 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 7E70791A7D; Fri, 10 Oct 2014 10:43:04 -0400 (EDT) Date: Fri, 10 Oct 2014 10:43:04 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Ada2012 freeze rules for subprogram profiles Message-ID: <20141010144304.GA1703@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Ada05-019 specifies that freezing a subprogram does not automatically freeze the profile, i.e. the types of the formals and the return type. In particular an attribute reference 'Access and its relatives do not freeze the profile. Compiling bd.ads must yield: bd.ads:15:34: incorrect expression for "READ" attribute --- with Ada.Streams; package BD is type My_Big_Int is range 0 .. 10000; type Write_Ptr is access procedure (Stream : not null access Ada.Streams.Root_Stream_Type'Class; A : in My_Big_Int'Base); procedure Good_Write6 (Stream : not null access Ada.Streams.Root_Stream_Type'Class; A : in My_Big_Int'Base); WPtr : Write_Ptr := Good_Write6'Access; -- Does not freeze My_Big_Int (AI05-0019-1). for My_Big_Int'Read use WPtr.all; -- ERROR: private type My_Priv (D : Integer) is null record; end BD; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-10-10 Ed Schonberg * freeze.adb (Freeze_Entity): Freezing a subprogram does not always freeze its profile. In particular, an attribute reference that takes the access type does not freeze the types of the formals. Index: freeze.adb =================================================================== --- freeze.adb (revision 216089) +++ freeze.adb (working copy) @@ -4004,7 +4004,17 @@ -- any extra formal parameters are created since we now know -- whether the subprogram will use a foreign convention. - if not Is_Internal (E) then + -- In Ada 2012, freezing a subprogram does not always freeze + -- the corresponding profile (see AI05-019). An attribute + -- reference is not a freezing point of the profile. + -- Other constructs that should not freeze ??? + + if Ada_Version > Ada_2005 + and then Nkind (N) = N_Attribute_Reference + then + null; + + elsif not Is_Internal (E) then declare F_Type : Entity_Id; R_Type : Entity_Id;