From patchwork Thu Jun 17 15:24:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 56060 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 694B91007D2 for ; Fri, 18 Jun 2010 01:24:24 +1000 (EST) Received: (qmail 27988 invoked by alias); 17 Jun 2010 15:24:21 -0000 Received: (qmail 27965 invoked by uid 22791); 17 Jun 2010 15:24:20 -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; Thu, 17 Jun 2010 15:24:15 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 8A940CB0202; Thu, 17 Jun 2010 17:24:21 +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 rDV7Fm631bMZ; Thu, 17 Jun 2010 17:24:21 +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 780AECB01EA; Thu, 17 Jun 2010 17:24:21 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 82476D9AB0; Thu, 17 Jun 2010 17:24:31 +0200 (CEST) Date: Thu, 17 Jun 2010 17:24:31 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Eliminated protected operations Message-ID: <20100617152431.GA14142@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 The enclosing dynamic scope of a construct is the subprogram body that executes the construct. If the source construct appears within a protected operation, the enclosing dynamic scope is the protected subprogram body built for it. However, this body is not constructed if the protected operation has been eliminated. In that case the enclosing dynamic scope is the source subprogram, and is used only for semantic checks. The following must compile quietly: gnatmake -f -gnatec=elim.out test_it.adb --: procedure Test_It is Var : Integer := 1; protected Obj is procedure Used; procedure Unused; private end Obj; protected body Obj is procedure Hidden is begin declare I : Integer := 1; procedure Hidden1 is begin Var := Var + I; end Hidden1; begin Hidden1; end; Var := Var + 1; end Hidden; procedure Used is begin Var := Var + 1; end; procedure Unused is begin Hidden; end; end Obj; begin Obj.Used; end Test_It; --- contents of file elim.out (output of gnatelim) -- List of unused entities to be placed in gnat.adc. -- pragma Eliminate (Test_It, Unused, Source_Location => "test_it.adb:7"); pragma Eliminate (Test_It, Hidden, Source_Location => "test_it.adb:14"); pragma Eliminate (Test_It, Hidden1, Source_Location => "test_it.adb:18"); Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-17 Ed Schonberg * sem_util.adb (Enclosing_Subprogram): If the called subprogram is protected, use the protected_subprogram_body only if the original subprogram has not been eliminated. Index: sem_util.adb =================================================================== --- sem_util.adb (revision 160908) +++ sem_util.adb (working copy) @@ -2549,7 +2549,12 @@ package body Sem_Util is elsif Ekind (Dynamic_Scope) = E_Task_Type then return Get_Task_Body_Procedure (Dynamic_Scope); - elsif Convention (Dynamic_Scope) = Convention_Protected then + -- No body is generated if the protected operation is eliminated + + elsif Convention (Dynamic_Scope) = Convention_Protected + and then not Is_Eliminated (Dynamic_Scope) + and then Present (Protected_Body_Subprogram (Dynamic_Scope)) + then return Protected_Body_Subprogram (Dynamic_Scope); else