From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x42c.google.com with SMTP id b16so10072943wru.7 for ; Mon, 05 Sep 2022 00:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date; bh=8GE5IonBnIpftEgLnF0O/zrdj/cpBqOB5VhmCNd5Au4=; b=DbuScvzi2He8pPhvlmEB/i9osATKWcnPco8sp58DwLhYed6gyfQGIfSVQDYa9yvG55 lU1qL/rohMSG6rc3j1/mqZ6iUto54NfQ+VMQl8LHPUPyEIpBQ+IaRiGRc2nR+AGhlTJM x7KbMD4/qTyshPlKb4oc9Irg4qwS8T5PLiuDmuBEIij1pTXytJ2u9JcFgOM+KDWIF8o2 m/x+mVElQTP+sjkJ+eoD+ihQW/Sq64zjHJkb7/J6KQzK0ixOXcx6bTwmlkIfZRQThMkQ 2gDgrXcRXbUB7cSi87cRfTaVf374Bm4LVZ+mIl3jAeshUmFb33QL9BMDyV2PdmqWxn38 Vs+A== 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-Google-Smtp-Source: AA6agR7ZzPlv2zbALw8Re/QPZAaBV0hmzRMVn7nWbEw/nuG3gppktx+BBxFUd9Xx4Z5GWZV+1KC8kg== 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 From: Marc =?iso-8859-1?Q?Poulhi=E8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [Ada] Fix insertion of a runtime check for null array aggregate Message-ID: <20220905072616.GA1174873@poulhies-Precision-5550> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="KsGdsel6WgEHnImy" 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 List-Id: --KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --KsGdsel6WgEHnImy Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" 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); --KsGdsel6WgEHnImy--