From patchwork Fri Aug 2 07:11:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 1968197 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=SHlkgO4d; 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 4WZxtB5pyzz1ydv for ; Fri, 2 Aug 2024 17:14:58 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E4B63386075A for ; Fri, 2 Aug 2024 07:14:56 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 15E783858289 for ; Fri, 2 Aug 2024 07:12:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 15E783858289 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 15E783858289 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::331 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722582756; cv=none; b=Gt8hfHmqx5bXyZP68wnFOw/uHBXcWriUWgLgDY+cUWXCBhrvhwNyv1fNcV95QcnOK70o2izdahrrJ2N6fi5R3HadR3m47Q5muO7jYr3kOGrxLjr08fsgeoh2wZGB++tmKRTSv10tS97LhOqaeb8ZT/V7qcTfL2fD7jNmOw9JdV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722582756; c=relaxed/simple; bh=3JLzemc5UpaO+ytfjN6pWoKntG61IsoI7pEs90GLlFA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ZWnzeQRx3FhOebNIAHYIXseMFlTwsmbJaKG/BPmbYiEyIg0Wonm96ZhEAIhjOynEh/BnpgF61kU12zLxIq+rzLuY1OTvhRu+ORdMLYDNwz58TdPbyT9zZTy5WKTR6s/TE85KDIubFFF88fJ1GtLSfziCbGBUcKLt3TKlnQb4r5I= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-428163f7635so50919125e9.2 for ; Fri, 02 Aug 2024 00:12:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1722582753; x=1723187553; 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=wC9ngaYuKMfA0zrRvwa8hompqPYenGh5Uqd79MIw9pk=; b=SHlkgO4deyLIsJ2rl1jYas6hNLl9d/DAcJMGV0/uJXwWFmOGkPilug1ncmTmaLq+Lv zIx8HWFX2+16T2j+lnGBW6bswaYjIkQEQ3cDZo64NXryRTF/uy4ThGK+NvucxeNHRwNX 2CjTIpb2aYrNDUzvNGCp4C/txE0YdVsUWn/l2YgvslCFQ+Z8PyVsZuHGd+7YvvLNuzrh YvEMDglyKaV0WukAwlO5cB5hhgSXO2pBcUfHkVgRPguxsJFmBRdkObZpClUAp6LQu6eQ c5oGq0Z9Lsoq3f1AYaHj1reCpgm6FJzchI63M3DLAskOqDuqqdFwRdMrujIGia9IHYnP t1ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722582753; x=1723187553; 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=wC9ngaYuKMfA0zrRvwa8hompqPYenGh5Uqd79MIw9pk=; b=v75AtXSPji9/mFDxfx3nRL3nIso79TDHZ9+Km0iDU4ZSqxX1mjQJ7fZ07RldY3hBqa z30tyq5js8+i3Wd/80gbRLDp12yi24c++oRP9hQO0TdcN6SVFkfiydITmFF0RqqwpLrw R5hpNaqan0tX7mSZI0B3tgFI23H3zY6DKkRGAdK0ptPX5yEQ89hJPBE+lJvSQXjUpfko 798JO42s3SsQxab3NHp5Hj/a6LCgR3h6okCjf9k69A4pdyRL6btqJT8uUPX9vav15yF0 K+B8Jy00JjhBbz56bMz7b6VcQjOauzjrFjDs1n1WefYQBhyb/Tl3SK7TYHGPdmkToV66 pQsQ== X-Gm-Message-State: AOJu0Yw6/Pplg/koIOlmRcUOGgN3lSCDX6AfR/Vy/e0Sd5eB/Cy/mXz0 yCY2fefqDcUmb4kcdj5af1TSaPFMmdxs12RGxEx3wEdn5mgTDFx3cqoW/1wKkADUxHPOE0IHL/P Dzg== X-Google-Smtp-Source: AGHT+IEPXhIgOgltapwHJXbc2/aKIh5IPflW2p0InBCw/jI09fHOA+6Tvw3NgRMa529diYtWvkPDYg== X-Received: by 2002:a05:600c:444f:b0:426:5b3a:96c with SMTP id 5b1f17b1804b1-428e6b78e3amr15747255e9.28.1722582752627; Fri, 02 Aug 2024 00:12:32 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b6aa:4751:9ea1:da1e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36bbd059932sm1195770f8f.69.2024.08.02.00.12.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 00:12:32 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Tonu Naks Subject: [COMMITTED 12/26] ada: Update doc of Style_Checks pragma Date: Fri, 2 Aug 2024 09:11:29 +0200 Message-ID: <20240802071210.413366-12-poulhies@adacore.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240802071210.413366-1-poulhies@adacore.com> References: <20240802071210.413366-1-poulhies@adacore.com> MIME-Version: 1.0 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, SCC_5_SHORT_WORD_LINES, SPF_HELO_NONE, SPF_PASS, TXREP 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: Tonu Naks gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst: Add examples. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate. Tested on x86_64-pc-linux-gnu, committed on master. --- .../implementation_defined_pragmas.rst | 79 +++++++++++++++++-- gcc/ada/gnat_rm.texi | 77 +++++++++++++++++- gcc/ada/gnat_ugn.texi | 2 +- 3 files changed, 150 insertions(+), 8 deletions(-) diff --git a/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst b/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst index 926c5f4e37b..7ff94c4c2b9 100644 --- a/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst +++ b/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst @@ -6328,21 +6328,91 @@ activated. These are additive, so they apply in addition to any previously set style check options. The codes for the options are the same as those used in the *-gnaty* switch to *gcc* or *gnatmake*. For example the following two methods can be used to enable -layout checking: +layout checking and to change the maximum nesting level value: * - :: + .. code-block:: ada + -- switch on layout checks pragma Style_Checks ("l"); - + -- set the number of maximum allowed nesting levels to 15 + pragma Style_Checks ("L15"); * :: - gcc -c -gnatyl ... + gcc -c -gnatyl -gnatyL15 ... + + +The string literal values can be cumulatively switched on and off by prefixing +the value with ``+`` or ``-``, where: + +* ``+`` is equivalent to no prefix. It applies the check referenced by the + literal value; +* ``-`` switches the referenced check off. + + +.. code-block:: ada + :linenos: + :emphasize-lines: 15 + + -- allow misaligned block by disabling layout check + pragma Style_Checks ("-l"); + declare + msg : constant String := "Hello"; + begin + Put_Line (msg); + end; + + -- enable the layout check again + pragma Style_Checks ("l"); + declare + msg : constant String := "Hello"; + begin + Put_Line (msg); + end; + +The code above contains two layout errors, however, only +the last line is picked up by the compiler. + +Similarly, the switches containing a numeric value can be applied in sequence. +In the example below, the permitted nesting level is reduced in in the middle +block and the compiler raises a warning on the highlighted line. +.. code-block:: ada + :linenos: + :emphasize-lines: 15 + + -- Permit 3 levels of nesting + pragma Style_Checks ("L3"); + + procedure Main is + begin + if True then + if True then + null; + end if; + end if; + -- Reduce permitted nesting levels to 2. + -- Note that "+L2" and "L2" are equivalent. + pragma Style_Checks ("+L2"); + if True then + if True then + null; + end if; + end if; + -- Disable checking permitted nesting levels. + -- Note that the number after "-L" is insignificant, + -- "-L", "-L3" and "-Lx" are all equivalent. + pragma Style_Checks ("-L3"); + if True then + if True then + null; + end if; + end if; + end Main; The form ``ALL_CHECKS`` activates all standard checks (its use is equivalent to the use of the :switch:`gnaty` switch with no options. @@ -6356,7 +6426,6 @@ The forms with ``Off`` and ``On`` can be used to temporarily disable style checks as shown in the following example: - .. code-block:: ada pragma Style_Checks ("k"); -- requires keywords in lower case diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index d5e8931e088..3a766ccc38d 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -7901,22 +7901,95 @@ activated. These are additive, so they apply in addition to any previously set style check options. The codes for the options are the same as those used in the `-gnaty' switch to `gcc' or `gnatmake'. For example the following two methods can be used to enable -layout checking: +layout checking and to change the maximum nesting level value: @itemize * @item @example +-- switch on layout checks pragma Style_Checks ("l"); +-- set the number of maximum allowed nesting levels to 15 +pragma Style_Checks ("L15"); @end example @item @example -gcc -c -gnatyl ... +gcc -c -gnatyl -gnatyL15 ... @end example @end itemize +The string literal values can be cumulatively switched on and off by prefixing +the value with @code{+} or @code{-}, where: + + +@itemize * + +@item +@code{+} is equivalent to no prefix. It applies the check referenced by the +literal value; + +@item +@code{-} switches the referenced check off. +@end itemize + +@example +-- allow misaligned block by disabling layout check +pragma Style_Checks ("-l"); +declare + msg : constant String := "Hello"; +begin + Put_Line (msg); + end; + +-- enable the layout check again +pragma Style_Checks ("l"); +declare + msg : constant String := "Hello"; +begin + Put_Line (msg); + end; +@end example + +The code above contains two layout errors, however, only +the last line is picked up by the compiler. + +Similarly, the switches containing a numeric value can be applied in sequence. +In the example below, the permitted nesting level is reduced in in the middle +block and the compiler raises a warning on the highlighted line. + +@example +-- Permit 3 levels of nesting +pragma Style_Checks ("L3"); + +procedure Main is +begin + if True then + if True then + null; + end if; + end if; + -- Reduce permitted nesting levels to 2. + -- Note that "+L2" and "L2" are equivalent. + pragma Style_Checks ("+L2"); + if True then + if True then + null; + end if; + end if; + -- Disable checking permitted nesting levels. + -- Note that the number after "-L" is insignificant, + -- "-L", "-L3" and "-Lx" are all equivalent. + pragma Style_Checks ("-L3"); + if True then + if True then + null; + end if; + end if; +end Main; +@end example + The form @code{ALL_CHECKS} activates all standard checks (its use is equivalent to the use of the @code{gnaty} switch with no options. See the @cite{GNAT User’s Guide} for details.) diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index ea1d2f9d71a..0e3ee935552 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -29670,8 +29670,8 @@ to permit their use in free software. @printindex ge -@anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{ } @anchor{d1}@w{ } +@anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{ } @c %**end of body @bye