From patchwork Thu Jun 17 13:00:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 56039 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 11EF3B7D61 for ; Thu, 17 Jun 2010 23:00:48 +1000 (EST) Received: (qmail 19312 invoked by alias); 17 Jun 2010 13:00:45 -0000 Received: (qmail 19297 invoked by uid 22791); 17 Jun 2010 13:00:43 -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 13:00:39 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 75EF5CB0276; Thu, 17 Jun 2010 15:00:45 +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 Kn1WyZeE59Pt; Thu, 17 Jun 2010 15:00:45 +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 63901CB020E; Thu, 17 Jun 2010 15:00:45 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 5497DD9AB0; Thu, 17 Jun 2010 15:00:54 +0200 (CEST) Date: Thu, 17 Jun 2010 15:00:54 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Pragma Eliminated applied to internal protected subprograms Message-ID: <20100617130054.GA28080@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 If a protected operation has been eliminated, an internal call to it from another protected operation (that is itself eliminated) must not be expanded, because the corresponding body has not been constructed. 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 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; --- file elim.out: -- 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:12"); Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-17 Ed Schonberg * exp_ch6.adb (Expand_Call): Do not expand a call to an internal protected operation if the subprogram has been eliminated. Index: exp_ch6.adb =================================================================== --- exp_ch6.adb (revision 160905) +++ exp_ch6.adb (working copy) @@ -3095,12 +3095,14 @@ package body Exp_Ch6 is -- In Ada 2005, this may be an indirect call to an access parameter that -- is an access_to_subprogram. In that case the anonymous type has a -- scope that is a protected operation, but the call is a regular one. + -- In either case do not expand call if subprogram is eliminated. Scop := Scope (Subp); if Nkind (N) /= N_Entry_Call_Statement and then Is_Protected_Type (Scop) and then Ekind (Subp) /= E_Subprogram_Type + and then not Is_Eliminated (Subp) then -- If the call is an internal one, it is rewritten as a call to the -- corresponding unprotected subprogram.