From patchwork Tue Sep 6 13:07:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 113551 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 28367B6F76 for ; Tue, 6 Sep 2011 23:07:41 +1000 (EST) Received: (qmail 5669 invoked by alias); 6 Sep 2011 13:07:39 -0000 Received: (qmail 5659 invoked by uid 22791); 6 Sep 2011 13:07:38 -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; Tue, 06 Sep 2011 13:07:21 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id F2E6F2BB299; Tue, 6 Sep 2011 09:07:20 -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 j4W3IRm7GTnB; Tue, 6 Sep 2011 09:07:20 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id DA0162BB294; Tue, 6 Sep 2011 09:07:20 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id CC47692A55; Tue, 6 Sep 2011 09:07:20 -0400 (EDT) Date: Tue, 6 Sep 2011 09:07:20 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Freezing and Ada2012 expression functions Message-ID: <20110906130720.GA5130@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 The body that is a rewriting of an expression function does not freeze previous entities. The following must compile quietly in Ada2012 mode: --- package Ada12 is type T is tagged null record; function Template (Self : T) return String is ("foo.thtml"); type T2 is new T with null record; overriding function Template (Self : T2) return String is ("bar.thtml"); end Ada12; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-09-06 Ed Schonberg * sem_ch6.adb (Analyze_Subprogram_Body_Helper): The body that is a rewriting of an expression function does not freeze previous entities. Index: sem_ch6.adb =================================================================== --- sem_ch6.adb (revision 178567) +++ sem_ch6.adb (working copy) @@ -2346,7 +2346,12 @@ -- expansion has generated an equivalent type that is used when -- elaborating the body. - if No (Spec_Id) then + -- An exception in the case of Ada2012, AI05-177: The bodies + -- created for expression functions do not freeze. + + if No (Spec_Id) + and then Nkind (Original_Node (N)) /= N_Expression_Function + then Freeze_Before (N, Body_Id); elsif Nkind (Parent (N)) = N_Compilation_Unit then