From patchwork Fri Jun 18 10:20:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 56165 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 35B0FB7D85 for ; Fri, 18 Jun 2010 20:20:50 +1000 (EST) Received: (qmail 14969 invoked by alias); 18 Jun 2010 10:20:48 -0000 Received: (qmail 14943 invoked by uid 22791); 18 Jun 2010 10:20:45 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, TW_DR, 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; Fri, 18 Jun 2010 10:20:41 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 6C3D9CB025A; Fri, 18 Jun 2010 12:20:48 +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 9XmklSZRO0Of; Fri, 18 Jun 2010 12:20:48 +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 5918BCB0253; Fri, 18 Jun 2010 12:20:48 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 336DFD9B31; Fri, 18 Jun 2010 12:20:56 +0200 (CEST) Date: Fri, 18 Jun 2010 12:20:56 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] Better expansion of short-circuit, conditional expressions Message-ID: <20100618102056.GA15158@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 This patch enables use of the new N_Expression_With_Actions node by default when using the gcc back end. The following test program: procedure ExprActions (A, B, C : Natural; M, N : String) is begin if (A = 23 and then M (1 .. A) = N (1 .. B)) or else M (A .. B) = M (B .. C) then null; end if; end ExprActions; Now generates the following -gnatG output by default (previous to this patch, this output required the use of the -gnatd.X switch). procedure expractions (a : natural; b : natural; c : natural; m : string; n : string) is subtype expractions__S2b is string (n'first(1) .. n'last(1)); subtype expractions__S1b is string (m'first(1) .. m'last(1)); begin if (a = 23 and then do [constraint_error when a >= 1 and then (1 < m'first(1) or else integer(a) > m'last( 1)) "range check failed"] [subtype expractions__T3b is integer range 1 .. a] [subtype expractions__T4b is string (expractions__T3b)] reference expractions__T4b[constraint_error when b >= 1 and then (1 < n'first(1) or else integer(b) > n'last( 1)) "range check failed"] [subtype expractions__T5b is integer range 1 .. b] [subtype expractions__T6b is string (expractions__T5b)] reference expractions__T6b in m (1 .. a) = n (1 .. b) end ) or else do [constraint_error when b >= a and then (integer(a) < m'first(1) or else integer(b) > m'last(1)) "range check failed"] [subtype expractions__T7b is integer range a .. b] [subtype expractions__T8b is string (expractions__T7b)] reference expractions__T8b[constraint_error when c >= b and then (integer(b) < m'first(1) or else integer(c) > m'last(1)) "range check failed"] [subtype expractions__T9b is integer range b .. c] [subtype expractions__T10b is string (expractions__T9b)] reference expractions__T10b in m (a .. b) = m (b .. c) end then null; end if; return; end expractions; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-18 Robert Dewar * gnat1drv.adb (Adjust_Global_Switches): Set Use_Expression_With_Actions true for gcc. Index: gnat1drv.adb =================================================================== --- gnat1drv.adb (revision 160971) +++ gnat1drv.adb (working copy) @@ -353,11 +353,11 @@ procedure Gnat1drv is then Use_Expression_With_Actions := False; - -- Otherwise normal gcc back end, for now still turn usage off by - -- default. + -- Otherwise normal gcc back end, which does implement this feature + -- so by default we allow its use. else - Use_Expression_With_Actions := False; + Use_Expression_With_Actions := True; end if; -- Set switch indicating if back end can handle limited types, and