From patchwork Wed Jul 6 13:31:31 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: 1652996 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=RtY3IATx; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LdLCL1sjFz9s07 for ; Wed, 6 Jul 2022 23:35:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1E8AF38337B2 for ; Wed, 6 Jul 2022 13:35:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E8AF38337B2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1657114540; bh=+vSzMzgaWsQzOLzObMroePNgYTpXoNOuvhv0lCWdlXY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=RtY3IATxDJaGXD0Xo1by9EmVp6fhGmbCKEtXbUUAI13ZyKUNP51jVINu3ijbP9qUa UhRsIpYmdlwmw5BNViSwkUVHhO6diXh4Uj/SGTCzu1qeEymi3VOwwYqpSkIvfQmoM5 +avliV8Xqz+8y3TMx8P6jlZ28Z1Dv4SJgzMXZQIk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 381E3385357D for ; Wed, 6 Jul 2022 13:31:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 381E3385357D Received: by mail-wr1-x433.google.com with SMTP id b26so22120980wrc.2 for ; Wed, 06 Jul 2022 06:31:33 -0700 (PDT) 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=+vSzMzgaWsQzOLzObMroePNgYTpXoNOuvhv0lCWdlXY=; b=TT1hu4zzAMCu3TxjKr1RC073zDTrblnve4tMqxstMcm8/tDTCOZoljVT4aSNbj7BiA gUEInDPcbPB7ccUxCd0HWRvcmogr5sqVooup+2NfNl/1cHY4HVohCBrTmAq8kiaM5h5T YZLcIDFs2XkdEPk8AHUZQ2axdgKEJEfSlH2i4yh8jqDq+M4NRjrC6C8cT8nCKwUdq8Ju 3GB0tJv/XofbSBB6APW+2MsIWhp0KHsdZQgDIDkpoPkwSbra+UgoTc6E26IV3VWq+5sn +I4MuMg16eI2Er5q/guh1HQsMqvzk7iedL97wlp8VYqPOZ/WEO63MMR7RYLmYJE8oHKc 9nuA== X-Gm-Message-State: AJIora8/lQ0qMx2E/Tl6YUBidInc4A8QX8BZm8NqDI578u0aTeiwrzSQ Qb8cTRdgKDM7G+aSzH6AyG6C2eggbZKe5Q== X-Google-Smtp-Source: AGRyM1uYRq2mzIWWSvTme2/QhaebYc3P67JppUIvMLAAvLsmMIjbYPAjd7AX+VgwAEEc+F6EHdwCEw== X-Received: by 2002:adf:df89:0:b0:21d:7f20:7535 with SMTP id z9-20020adfdf89000000b0021d7f207535mr2382654wrl.714.1657114292792; Wed, 06 Jul 2022 06:31:32 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id x12-20020a5d650c000000b0021d7050ace4sm5353994wru.77.2022.07.06.06.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 06:31:32 -0700 (PDT) Date: Wed, 6 Jul 2022 13:31:31 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Deferred constant considered as not preelaborable Message-ID: <20220706133131.GA2206413@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.3 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: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Yannick Moy Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Fix detection of non-preelaborable constructs for checking SPARK elaboration rules, which was tagging deferred constant declarations as not preelaborable. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_util.adb (Is_Non_Preelaborable_Construct): Fix for deferred constants. diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -18952,8 +18952,9 @@ package body Sem_Util is if Has_Init_Expression (Nod) then Visit (Expression (Nod)); - elsif not Has_Preelaborable_Initialization - (Etype (Defining_Entity (Nod))) + elsif not Constant_Present (Nod) + and then not Has_Preelaborable_Initialization + (Etype (Defining_Entity (Nod))) then raise Non_Preelaborable; end if;