From patchwork Wed Jul 7 16:25:44 2021 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: 1501895 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=adacore-com.20150623.gappssmtp.com header.i=@adacore-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=Qms7491k; dkim-atps=neutral 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 (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GKlYG5St9z9s5R for ; Thu, 8 Jul 2021 02:41:06 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A302396EC80 for ; Wed, 7 Jul 2021 16:41:03 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id D428D3969836 for ; Wed, 7 Jul 2021 16:25:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D428D3969836 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-lf1-x136.google.com with SMTP id c28so5229532lfp.11 for ; Wed, 07 Jul 2021 09:25:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=2U7jgqtjbLSe5PUdzqJlLCCeM/6laDW0vDqBh0GSCbg=; b=Qms7491kcy3HloLBKAqUFwz6HLz48sDF0GM6q9GlMfkMGoXPV8xBkL/3nauYphmKhD YdOmCS7JCp1Fbn0NCemYlB4z389AfV0WFK1/dxPR4uDSDAIRYMo/Nj0gRpbydn2EqBKd 1lpCRz/cPPyji94xwEoCKysmMjbbn3j2UeGK7NIv0IIzb2MPRl6hpFFs/n0GTBE1wudC wsNykHc96bLFILkB1RF4y3sH3aLxKYoZmFfeuJiBEOqhp1SdkUBEuFucyHhvGxXHPhTh 0pcLAm3b9962G1fHaZYTo9niVwSBMbZCm6XU4567C32BDlBKxIe4QcEGzRstsEQvxGjC lAow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=2U7jgqtjbLSe5PUdzqJlLCCeM/6laDW0vDqBh0GSCbg=; b=pKqJIBpLln0G2SIhOMxciz8OnbH4emXEVq13S2ncmGuTnjWlkVj9J6Hx4A5E1UQOn5 DDHgAu259qca4+KF+UTEhmLLOi1i924D3uROL4dbhc4wuaMwKC2DgnN0MzJzNe3Qk69a NazTikNoaYc0zhfml+ihOF2quruwoAnkN2VvwddEgXLqU62AaW6xrzEhmlw1sYIupKqi zlJJqNQIegIBC29I7VytAmtsQWITdtPnMzGQY64Ugpc9BKQDKLEdnXvD/wo04TfUWoQu iDA9OEnW0PfJy3sk/1hG4w3iuQZ9yaD7OR1wMzCZVZatgk9GaZZZvVLtIbtHmgQawikw hOlw== X-Gm-Message-State: AOAM531N10810UdpUJUn8SHr3wszZVKqXkPaJliWwxyVaoA/jDpabkYK VTadxCZCHwoMSfe2n31khWk+sQiCatgYjw== X-Google-Smtp-Source: ABdhPJw+t9kZZ7HgcMSC3eGQjtjaYJvGwHLIhfYH0RRzxCFCVDIsUu3UAhCM8zTWrLCDO90wOpr40w== X-Received: by 2002:a19:5f48:: with SMTP id a8mr5597309lfj.496.1625675146757; Wed, 07 Jul 2021 09:25:46 -0700 (PDT) Received: from adacore.com ([2a02:2ab8:224:2ce:72b5:e8ff:feef:ee60]) by smtp.gmail.com with ESMTPSA id s15sm286901lfp.216.2021.07.07.09.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 09:25:45 -0700 (PDT) Date: Wed, 7 Jul 2021 16:25:44 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Subject: [Ada] Stronger assertion about flag for checking static expressions Message-ID: <20210707162544.GA2543266@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, 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: , Cc: Piotr Trojanek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Ensure that Checking_For_Potentially_Static_Expression flag is manipulated in a stack-like manner (with stack depth 1 at the most). The previous assertion didn't prevent us from setting the flag to True or to False twice in a row. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_eval.adb (Set_Checking_Potentially_Static_Expression): Stronger assertion. 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 @@ -6481,11 +6481,10 @@ package body Sem_Eval is procedure Set_Checking_Potentially_Static_Expression (Value : Boolean) is begin - -- Verify that we're not currently checking for a potentially static - -- expression unless we're disabling such checking. + -- Verify that we only start/stop checking for a potentially static + -- expression and do not start or stop it twice in a row. - pragma Assert - (not Checking_For_Potentially_Static_Expression or else not Value); + pragma Assert (Checking_For_Potentially_Static_Expression /= Value); Checking_For_Potentially_Static_Expression := Value; end Set_Checking_Potentially_Static_Expression;