From patchwork Mon Sep 5 07:26:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 987 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp59874wrt; Mon, 5 Sep 2022 00:41:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR6xAwn80rQfcgJGMnC0oM4n9tTU2CPvWjfkCndUNd95z4qQExfprxQN9TaZ/DqfVuq5khjD X-Received: by 2002:a05:6402:1d84:b0:44e:8158:84 with SMTP id dk4-20020a0564021d8400b0044e81580084mr3213363edb.80.1662363664660; Mon, 05 Sep 2022 00:41:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662363664; cv=none; d=google.com; s=arc-20160816; b=N2BfCfyRvQvBraUaMe1TvEw4O8lkzhs8mz3fxJI8vCeVp6z9CAZTFRzqVkPn2YzD0U OnRKEPEAI45pd/9Mba7B6kRQvT4oYz2BKgOMX4r0iLi1HMd8BL2fbBpBCnw/2qvnGFxg eWYwpOqC5jY3q9rkZll8Th2Cab61DYmJ/yr+V1raD4QGWQyhIfIH8NI3VulkAri3VJS3 wrWJM4u4g/dl5HZMXlY1dj5dckbejXn252CBgUBhSpAQrorvjfPhfxrleTrssvqDckp1 UN4VFok2WsKYimwklKrp/Erm4FL/foUwXpKvlKIHQRoY0uFp4nQPCo61vVTh88DqUeta W0uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=8GE5IonBnIpftEgLnF0O/zrdj/cpBqOB5VhmCNd5Au4=; b=ba0dYbUXb2icdr0MPTj/uoJQh9MZiDrbBX9WeAljep8yqJaR4VheUpaWasUTjtPPdX qf8vq4XQJtTfcj9F61/gwc3M8Zcrwt6+ELqg3qU8RGPPTBav55FhygCMwJSR7pq0ydrN d+k0J4kfW3moq9ck+LQsjxBk8e1eIHZapDYByLC/RSxUGQtST6iOIrZuYUbCQf7Z6LZr F0GRpLmZpijzcZ6jfWl0cqi/+vaCjd3lfbJDShqr4DgUi4GxrrXy3/zQIcbtR3R3ZS6v XNB1/moXB9AuRQ4Rbt2u+f2cETlAF72L+SkhaZNe2advJZOdrBmtzck+gqvzZdSVeGvh 3/+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=IW54uezS; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id bx20-20020a170906a1d400b007305f9cf344si6223890ejb.853.2022.09.05.00.41.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:41:04 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=IW54uezS; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D329A3835DFF for ; Mon, 5 Sep 2022 07:35:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D329A3835DFF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662363338; bh=8GE5IonBnIpftEgLnF0O/zrdj/cpBqOB5VhmCNd5Au4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=IW54uezSi4nGpnERnOnC4jNYN7OZxDpHJcdFsGG1yT2U57QNqo+AYTaVpUKf6nc17 VJWRkFFWMO8cNdyW0NX+6g26NGXiN10bO4wdrAo8d3IDblIXI/p8k9qx9J7ljebYA0 eJk4ZbW5pv4B8BvbrZe7ufcgeyRCsJaSNVt5H+Bw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id A87B63853830 for ; Mon, 5 Sep 2022 07:26:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A87B63853830 Received: by mail-wr1-x42c.google.com with SMTP id b16so10072943wru.7 for ; Mon, 05 Sep 2022 00:26:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=8GE5IonBnIpftEgLnF0O/zrdj/cpBqOB5VhmCNd5Au4=; b=rdRN/33K6OIo8PYDLH5D0zEcWIMkqHjnhtOubgNKJ7/dNfcqLrvVXL5G4ZlojqYyvZ wF59aRqaf8wXrC/i22hZ7CpQJjqVpDwR1Z5NscJn693JJPrnsHklxZJ9yClb/aTriJx9 5HZCOQ/0XA2t48hF/bnJ6vi8k7eL/3l6vIakfUTyrTatAerW+KZ92IiMQoPf7hdibakK jVlVYxyhh3W0P6TAXelbZ7tqhxykbdoOLqCnh10QhUanCO8JIoPsc31g98dwgKmC5uSF Pu8X939dLOk6L/X7jstxvisEjVy6mOD9u8ZJHs6cvZFv2Gk/cl0gVaonmIQ89P8+so7Z 71Pw== X-Gm-Message-State: ACgBeo0ulCg1UiL0ptBWETPtYPJ1aWCie5Wq4nv3iLKYdW/ObLY4A8bb a6/HAG5990fQuOZmS1gLb3MyET11vayppg== X-Received: by 2002:a5d:67ca:0:b0:228:7ad5:768f with SMTP id n10-20020a5d67ca000000b002287ad5768fmr2333940wrw.163.1662362777536; Mon, 05 Sep 2022 00:26:17 -0700 (PDT) Received: from poulhies-Precision-5550 (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id o12-20020a05600c378c00b003a5f4fccd4asm15756057wmr.35.2022.09.05.00.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:26:17 -0700 (PDT) Date: Mon, 5 Sep 2022 09:26:16 +0200 To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix insertion of a runtime check for null array aggregate Message-ID: <20220905072616.GA1174873@poulhies-Precision-5550> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-12.9 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: Marc =?iso-8859-1?q?Poulhi=E8s?= Cc: Piotr Trojanek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743114642230636125?= X-GMAIL-MSGID: =?utf-8?q?1743114642230636125?= A null array aggregate of Ada 2022 requires a conditional runtime check that was inserted as an if-statement. While gigi can handle statements inserted into a list of declarations, in GNATprove such a statement will cause a crash. It is better to insert a conditional raise node, which is properly handled by both gigi and GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aggr.adb (Resolve_Null_Array_Aggregate): Insert check as a Raise_Constraint_Error node and not an If_Statement. diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -4113,12 +4113,10 @@ package body Sem_Aggr is -- including modular). Check := - Make_If_Statement (Loc, + Make_Raise_Constraint_Error (Loc, Condition => Make_Op_Le (Loc, New_Copy_Tree (Lo), New_Copy_Tree (Hi)), - Then_Statements => - New_List (Make_Raise_Constraint_Error - (Loc, Reason => CE_Range_Check_Failed))); + Reason => CE_Range_Check_Failed); Insert_Action (N, Check);