From patchwork Thu Jan 6 17:13:13 2022 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: 1576213 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=tkagQ8nl; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVD5f6yB8z9sXM for ; Fri, 7 Jan 2022 04:35:33 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B4A623858416 for ; Thu, 6 Jan 2022 17:35:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4A623858416 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641490530; bh=tKUA2K3AMxiWAVJN87siFf/EIrHHf+hY6lJ2LqfF4cg=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=tkagQ8nlSgBjhsZCDmTGpDP5KEssOwcpKQI77vlCYQYScB5Fhii/uQLcc6V1ZVNp5 UrBWT01ccTIqlfU1UHB3+ypr26CuUtDAxmWUyvf4YHgUi9mpWnxb2mREirkkU5LBll EVXykcOzCvhXLPdZHFSik2XKKKPUQQcNmFIcUNag= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 6F01D3858421 for ; Thu, 6 Jan 2022 17:13:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6F01D3858421 Received: by mail-wr1-x436.google.com with SMTP id k18so6070181wrg.11 for ; Thu, 06 Jan 2022 09:13:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=tKUA2K3AMxiWAVJN87siFf/EIrHHf+hY6lJ2LqfF4cg=; b=4H7mwqluO6g4Ym/uy+ABJ9GSAiqx8/TAwWt7dsqiyKKb4ZBMthNalInPBZGDV0E7HX fB98Ps9QNS5mAu8ynAa+1bYIGMz7ttPVwSbDnaHd1QS37kRq4yvy5iZVdRzkqNHTPU9C 12qyjWlgkFKcBKH2eiWW5blpao8WXtUZ3badBeBabXaSkhCYcevotQRvg5HA2eP6L1OK di1NXrYC6/CokZBuH3qZii9HXnEeHkVh4+2LrN+kzkTEIvDAdGu5AcpJD8w2y4l4uTzI vCZmUH6aWGSdZElNykK/3t0YOtnBSM/ox4juJgv8WiAAD9rLDKHsXGzc1g2zZYZ1MyS7 wTJQ== X-Gm-Message-State: AOAM530G5aUVoKQ/rN4WIJ1ni3oIC6euDQ4W+fKZWR7aT9/tL1mcTn5a nLNCSblQrHAAaeocItubtU5rShEQyp1LOg== X-Google-Smtp-Source: ABdhPJw4Tg4QcqK9w0PmdyjuB6yZpPiMIi31VL0lEVBIBPrwY8PcJa5QW7QaROxonsLt/KmcRMMkYg== X-Received: by 2002:adf:d1ef:: with SMTP id g15mr53244206wrd.198.1641489194477; Thu, 06 Jan 2022 09:13:14 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id z22sm6724782wmp.40.2022.01.06.09.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 09:13:13 -0800 (PST) Date: Thu, 6 Jan 2022 17:13:13 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Move messages on division by zero to the right operand Message-ID: <20220106171313.GA2921774@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Piotr Trojanek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" All compile-time messages about division by zero are now located at the right operand. Previously some of them were located at the division operator, which was inconsistent. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_eval.adb (Eval_Arithmetic_Op): Add Loc parameter to all calls to Apply_Compile_Time_Constraint_Error related to division by zero. diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb --- a/gcc/ada/sem_eval.adb +++ b/gcc/ada/sem_eval.adb @@ -2117,6 +2117,7 @@ package body Sem_Eval is Apply_Compile_Time_Constraint_Error (N, "division by zero", CE_Divide_By_Zero, + Loc => Sloc (Right), Warn => not Stat or SPARK_Mode = On); return; @@ -2139,6 +2140,7 @@ package body Sem_Eval is Apply_Compile_Time_Constraint_Error (N, "mod with zero divisor", CE_Divide_By_Zero, + Loc => Sloc (Right), Warn => not Stat or SPARK_Mode = On); return; @@ -2159,6 +2161,7 @@ package body Sem_Eval is Apply_Compile_Time_Constraint_Error (N, "rem with zero divisor", CE_Divide_By_Zero, + Loc => Sloc (Right), Warn => not Stat or SPARK_Mode = On); return; @@ -2218,7 +2221,8 @@ package body Sem_Eval is else pragma Assert (Nkind (N) = N_Op_Divide); if UR_Is_Zero (Right_Real) then Apply_Compile_Time_Constraint_Error - (N, "division by zero", CE_Divide_By_Zero); + (N, "division by zero", CE_Divide_By_Zero, + Loc => Sloc (Right)); return; end if;