From patchwork Mon Jun 10 09:07:23 2024 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: 1945770 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=kSsqJ2eU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VyQx76HJDz20Tk for ; Mon, 10 Jun 2024 19:09:47 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2290C385DDD0 for ; Mon, 10 Jun 2024 09:09:46 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 83657385842C for ; Mon, 10 Jun 2024 09:08:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83657385842C Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 83657385842C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::430 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718010496; cv=none; b=T5uY7cqmebza6orfVlRjlFV4Vv0Z5vrdZJINDEfyLMJ9Z6SsBB4PGPe1pIEfzTnANLV3Rz1emqUjZOU3OQsuD7NLe2Ff8P2psDV5OOZ2PCWi9SqeVjQoymTs+46wQo77i2eXZO/TuxUT0k7k05Vh+kSCuT+Mj6tyio1ZYycstq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718010496; c=relaxed/simple; bh=EJjubhE85s9bT3Lp+dG2CgIGwve/JtR1QGYWU6fpLG0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=mXxESf7XgFKIvL4mlhGvtY9c+tn8U9sDIMIOcnLcKBs497r/VONLjqVCdcpg0P3pzDkOZ9OJI38GD1O0T0J8PioRNKiQqQL3AIVY03qF2P2nG0ZYgOPZNR/AM6kYwyqcalZtMbWt8BeJqSUqRRHeUo7NrATxkj4r+EBTwdLtu9o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-35f24fabb81so563119f8f.3 for ; Mon, 10 Jun 2024 02:08:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718010487; x=1718615287; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aeMHvyBJphPiBM4K9fIUbiKc9rjhEQEhSyMtNG7OBgw=; b=kSsqJ2eUVOmRmi5NxzGEAm3UK4tp3t623eX8uo9AI4Vkn55XZvVbunqA7HBj5SsExk b6E6IpWp3nZY9exSsb+UwVwB24i2Iu0MT1UJHAh+JE0XnmO2RkNngQ7gHwvTwQQiwa+N pO89WS/NYcgyVxrbQRNw1zmRO5v/pWO3t5jFAeJO38zvmdAdT4GKLowtZf7dQBLI5WHS 88QACDLp8OOehnmR7QalRZK4CZz3HeJrkvpFU/yupMK2obgGJVgVUi+T24cEzialPHkD LReTfxFVwVSJw/KPRbHlzLlDQWopLDjGwwAjcUu5rKuB1M+VgxExDyOcCouEHPMZqnDj HhqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718010487; x=1718615287; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aeMHvyBJphPiBM4K9fIUbiKc9rjhEQEhSyMtNG7OBgw=; b=vvtTRO/oGyU+HXH3GUpj/zMc5gzDQuH7wNM2ExAqFbPLlqbVTuUuiuEBbMzeu4PVtc cHyo4qWcMkfFDbiIrx3vdHxiHLoHR+oq99NkXeUsvgMMB1AZ5708J7BUMAYdn2iQWvZE MJk9vOnI8Y19fLVj4p/RyMzHHnH7CsYDOi45Eljx4U5EStQ9RwV8CwbC3++hc937vTJl 1YDGB4PWtxfl/gnICoQ/2BmbJqnyVRTDBRECcf3W4aKmX9Nc+DLUf11akOT4Oa3qMm5I Qq1y0yrNIXk1l6QGU4SoT5R8Di0lPcG8x6WwOJHOXT5Tr50qiN+7R2AYnjagLHbInUXJ WNBg== X-Gm-Message-State: AOJu0Yyd6/ftEV31lhI4EoEWrhyd7e6tteGF5ExdH8r2obQPMaYm77wy 2RMFrr8RPy3GaCG1ay/HWCzOQ17Qx1ieTDXyMK9R6+qRe45zhOwytkbHSrRroj31pZEUabq7UFE = X-Google-Smtp-Source: AGHT+IF+6S0Ik7pF1rzirEgfuNRGhyI1xl7mw9NNl3CWpiVeD9ezOV5FDH2d/aiFj84qG5BhFJnKQA== X-Received: by 2002:a5d:6587:0:b0:357:4c8f:ef8 with SMTP id ffacd0b85a97d-35efee3c533mr5829451f8f.70.1718010487280; Mon, 10 Jun 2024 02:08:07 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35f0f551c20sm6454970f8f.69.2024.06.10.02.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 02:08:06 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED 07/30] ada: Add switch to disable expansion of assertions in CodePeer mode Date: Mon, 10 Jun 2024 11:07:23 +0200 Message-ID: <20240610090747.1557638-7-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240610090747.1557638-1-poulhies@adacore.com> References: <20240610090747.1557638-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org From: Piotr Trojanek A new debug switch -gnatd_k is added, which has only effect in CodePeer mode. When enabled, assertion expressions are no longer expanded (which is the default in the CodePeer mode); instead, their expansion needs to be explicitly enabled by pragma Assertion_Policy. gcc/ada/ * debug.adb (d_k): Use first available debug switch. * gnat1drv.adb (Adjust_Global_Switches): If new debug switch is active then don't expand assertion expressions by default. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/debug.adb | 7 ++++++- gcc/ada/gnat1drv.adb | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb index 18b4a5480b6..540db2a9942 100644 --- a/gcc/ada/debug.adb +++ b/gcc/ada/debug.adb @@ -148,7 +148,7 @@ package body Debug is -- d_h Disable the use of (perfect) hash functions for enumeration Value -- d_i Ignore activations and calls to instances for elaboration -- d_j Read JSON files and populate Repinfo tables (opposite of -gnatRjs) - -- d_k + -- d_k In CodePeer mode disable expansion of assertion checks -- d_l -- d_m -- d_n @@ -990,6 +990,11 @@ package body Debug is -- compilation session if -gnatRjs was passed, in order to populate -- the internal tables of the Repinfo unit from them. + -- d_k In CodePeer mode assertion expressions are expanded by default + -- (regardless of the -gnata compiler switch); when this switch is + -- enabled, expansion of assertion expressions is controlled by + -- pragma Assertion_Policy. + -- d_p The compiler ignores calls to subprograms which verify the run-time -- semantics of invariants and postconditions in both the static and -- dynamic elaboration models. diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb index 55b5d565536..081d9435f4a 100644 --- a/gcc/ada/gnat1drv.adb +++ b/gcc/ada/gnat1drv.adb @@ -357,9 +357,13 @@ procedure Gnat1drv is Generate_SCIL := True; - -- Enable assertions, since they give CodePeer valuable extra info + -- Enable assertions, since they give CodePeer valuable extra info; + -- however, when switch -gnatd_k is active, then keep assertions + -- disabled by default and only enable them when explicitly + -- requested by pragma Assertion_Policy, just like in ordinary + -- compilation. - Assertions_Enabled := True; + Assertions_Enabled := not Debug_Flag_Underscore_K; -- Set normal RM validity checking and checking of copies (to catch -- e.g. wrong values used in unchecked conversions).