From patchwork Mon Aug 12 09:02:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1145561 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-506655-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="vt07q/Xb"; dkim-atps=neutral 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 466VVl2H4zz9sNF for ; Mon, 12 Aug 2019 19:12:47 +1000 (AEST) 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=DxhHvLLSncmdDYRsi0QDJbdAU7WVkBuUDl1R2TuuAXNGbwS8fi k0OQT8ORv7pebJkLbBPkbHZERwH8miyjD2o418TIliqko8yt3IFhIvYJPq1IpVGf fhU0M4JvayR5GQnfBNHF8VKj0Jh9nePJ0Izrvc7CfJX3P6e1lhXaI2aB4= 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=N/DKLk1KYEt9waHZz4UAlWAHtZo=; b=vt07q/Xbzw7v6qLKKY0I 3b+2BRUTHeMkCxrTjXlR3uWAptA8UJ0Rw+FrDsv6arMtIt1/KW9mHQJCSxX7ebSS jZTdnFqlMtwn19MBs/czT99pY/WRZ54MNu+9qKfooxJod1iVfAcV0JsMQStHOLhi R4K3rxI4emIT2H7+YwiwS8Y= Received: (qmail 111783 invoked by alias); 12 Aug 2019 09:10:06 -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 48805 invoked by uid 89); 12 Aug 2019 09:02:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= 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 ESMTP; Mon, 12 Aug 2019 09:02:50 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id A145C1164B1; Mon, 12 Aug 2019 05:02:48 -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 B8b2GCXo7D-U; Mon, 12 Aug 2019 05:02:48 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 8FC2011647A; Mon, 12 Aug 2019 05:02:48 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 8A9D76AF; Mon, 12 Aug 2019 05:02:48 -0400 (EDT) Date: Mon, 12 Aug 2019 05:02:48 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Fix incorrect Do_Range_Check on type conversion Message-ID: <20190812090248.GA22475@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes This gets rid of another leak of the Do_Range_Check flag to the back-end which is specific to expression functions. No functional changes. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-12 Eric Botcazou gcc/ada/ * checks.adb (Activate_Range_Check): Remove redundant argument. (Generate_Range_Check): Likewise. (Apply_Float_Conversion_Check): Reset the Do_Range_Check flag on entry and remove redundant condition. --- gcc/ada/checks.adb +++ gcc/ada/checks.adb @@ -445,7 +445,7 @@ package body Checks is procedure Activate_Range_Check (N : Node_Id) is begin - Set_Do_Range_Check (N, True); + Set_Do_Range_Check (N); Possible_Local_Raise (N, Standard_Constraint_Error); end Activate_Range_Check; @@ -2031,6 +2031,12 @@ package body Checks is return; end if; + -- Here we will generate an explicit range check, so we don't want to + -- set the Do_Range check flag, since the range check is taken care of + -- by the code we will generate. + + Set_Do_Range_Check (Ck_Node, False); + if not Compile_Time_Known_Value (LB) or not Compile_Time_Known_Value (HB) then @@ -2079,7 +2085,6 @@ package body Checks is if Nkind (Ck_Node) = N_Real_Literal and then Etype (Ck_Node) = Universal_Real and then Is_Integer_Type (Target_Typ) - and then Nkind (Parent (Ck_Node)) = N_Type_Conversion then declare Int_Val : constant Uint := UR_To_Uint (Realval (Ck_Node)); @@ -6936,7 +6941,7 @@ package body Checks is -- flag set, we do not want to generate the explicit range check code. if GNATprove_Mode or else not Expander_Active then - Set_Do_Range_Check (N, True); + Set_Do_Range_Check (N); return; end if;