From patchwork Fri Jun 21 08:57:57 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: 1950628 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=QATP5pj8; 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 4W5B9l39dPz20X4 for ; Fri, 21 Jun 2024 18:59:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9CA5338983A5 for ; Fri, 21 Jun 2024 08:59:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by sourceware.org (Postfix) with ESMTPS id 2EC833895FE3 for ; Fri, 21 Jun 2024 08:58:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2EC833895FE3 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 2EC833895FE3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960314; cv=none; b=iXWmoM4/I2Kou4SsIwOFLtPz06bjDv7i4LbXx5aXxPBtnORggouJyrDhhbJiaDn+gVrMhfyjF9iFFOXJiHIZjrewXSymi3YlIGz3ieeTK/Dcm25ESe//qyQoblpI94TtckpPWfxMHyTsclmn1RuUbX4KrNcquMtae58Jx052DSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960314; c=relaxed/simple; bh=RUNyYDmbBmyfe4va/tAnZWp3GVAeK2v6RqfTDsp1wzE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=esmhhRkKvFC2kMjTMG9ExpCwX/3/8LNsoI27rRAkiqrSnnk4Z39ahXZrpw0cL5S4t/gx3zZw665qQWSISqHDhwUrAQOIvHBuQ+O042nQoJQ4FV8ze5YVHU7rkc+Nc51aVGtC0OO/geMWBXrI+gETKtgT0px1vW+0+ku/utptDiA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-52c85a7f834so2238266e87.0 for ; Fri, 21 Jun 2024 01:58:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960311; x=1719565111; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JuCcj3j21BnFv528UjDbBglouLC6NehW2sJ28egtPto=; b=QATP5pj8D7aCB+5dV2wCccNpFvIMw8DF7BTo17isb5LyZAOdie4D+eT5zRt9ohw3II XWqtiKyTDzy4Smy74Jpt1WydXGC88RSxTgBKTfYohVz2Za+aH7ZuFcEwiYT2QETN1AUn 2H1nGsZ0ka1fBMYa+nLj1mhC/Abc0jhZR6tXkcRD4Yh1seuxutVq1RCMOHY+R4UafStf +kwsXvzWN24kqata0vXn+dNr9myMNC4SltzknK4QsBv+ByEST2GEnDH3rH2WupnODbf0 1orYIBp2GuiQ4Q6DOmL+r7da/0x74oTRbKV9Sz/AUNAeqJTBGqw+1WneteeiXtvJ6nkO ZS5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960311; x=1719565111; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JuCcj3j21BnFv528UjDbBglouLC6NehW2sJ28egtPto=; b=J1nOTpqviP40No8nuM/1x/dzf2jpUydP8XKte/IG/EJinkVIcYvamU75sAUd+jJKKz c8Jvhi+PBKv9LSyFVGwwvFygfsNiR72Cw1pxIN3Ia+McNnFNLVIryj/tzjITRB1wP3tP GlRI1xXhU/7wGvIOpu7dYv4TBNTeHBOxkvBaWp7DH/tcVnpC7o5sXYFb6EeuAYfO7Pxy 6KNBuEni3QVcCAHqYlrBYNNGiZHyN9uwextdkqirqVL+DEeaY9HD97k2w+RGhPp+Ig4c lvDwDcSir0vGs6dMjgpaW1SoxyRyY7wmB9KqWEIgAXQe7RAWC3FWz6vCrNH4v2U6L2Td i27Q== X-Gm-Message-State: AOJu0YxKpWVS+dli6AVxtTWDjAMmiirEPmLog4pu8HlUpeNTJ8rjj5+i BpvK6xchf56MrRdMcAm+BMO/MqGN7fbSlKcAkrxjuLrIauEfZBCvsKrdxn2ex5Cck1U2ZGf7Il4 = X-Google-Smtp-Source: AGHT+IHLoJh2iS+agxe/O6/qCrW/XDE872oS0rPhTW9la9MhEUsiHFPnkTQ2delALppL6SjmGsLe0g== X-Received: by 2002:a05:6512:b20:b0:52c:86eb:a2e6 with SMTP id 2adb3069b0e04-52ccaa56a21mr5792297e87.4.1718960310508; Fri, 21 Jun 2024 01:58:30 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:a589:2704:bfe1:5d92]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247d0c5485sm55322375e9.21.2024.06.21.01.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:30 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Justin Squirek Subject: [COMMITTED 01/22] ada: Spurious style error with mutiple square brackets Date: Fri, 21 Jun 2024 10:57:57 +0200 Message-ID: <20240621085819.2485987-1-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 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, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, 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: Justin Squirek This patch fixes a spurious error in the compiler when checking for style for token separation where two square brackets are next to each other. gcc/ada/ * csets.ads (Identifier_Char): New function - replacing table. * csets.adb (Identifier_Char): Rename and move table for static values. (Initialize): Remove dynamic calculations. (Identifier_Char): New function to calculate dynamic values. * opt.adb (Set_Config_Switches): Remove setting of Identifier_Char. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/csets.adb | 46 ++++++++++++++++++++++++++++++++++++---------- gcc/ada/csets.ads | 14 +++++++------- gcc/ada/opt.adb | 3 --- 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/gcc/ada/csets.adb b/gcc/ada/csets.adb index 7e5af3ffa17..54ebdb46b6c 100644 --- a/gcc/ada/csets.adb +++ b/gcc/ada/csets.adb @@ -29,6 +29,12 @@ with System.WCh_Con; use System.WCh_Con; package body Csets is + Identifier_Char_Table : Char_Array_Flags; + -- This table contains all statically known characters which can appear in + -- identifiers, but excludes characters which need to be known dynamically, + -- for example like those that depend on the current Ada version which may + -- change from file to file. + X_80 : constant Character := Character'Val (16#80#); X_81 : constant Character := Character'Val (16#81#); X_82 : constant Character := Character'Val (16#82#); @@ -1085,6 +1091,34 @@ package body Csets is others => ' '); + --------------------- + -- Identifier_Char -- + --------------------- + + function Identifier_Char (Item : Character) return Boolean is + begin + -- Handle explicit dynamic cases + + case Item is + + -- Add [ as an identifier character to deal with the brackets + -- notation for wide characters used in identifiers for versions up + -- to Ada 2012. + + -- Note that if we are not allowing wide characters in identifiers, + -- then any use of this notation will be flagged as an error in + -- Scan_Identifier. + + when '[' | ']' => + return Ada_Version < Ada_2022; + + -- Otherwise, this is a static case - use the table + + when others => + return Identifier_Char_Table (Item); + end case; + end Identifier_Char; + ---------------- -- Initialize -- ---------------- @@ -1144,24 +1178,16 @@ package body Csets is -- Build Identifier_Char table from used entries of Fold_Upper for J in Character loop - Identifier_Char (J) := (Fold_Upper (J) /= ' '); + Identifier_Char_Table (J) := (Fold_Upper (J) /= ' '); end loop; - -- Add [ as an identifier character to deal with the brackets notation - -- for wide characters used in identifiers for versions up to Ada 2012. - -- Note that if we are not allowing wide characters in identifiers, then - -- any use of this notation will be flagged as an error in - -- Scan_Identifier. - - Identifier_Char ('[') := Ada_Version < Ada_2022; - -- Add entry for ESC if wide characters in use with a wide character -- encoding method active that uses the ESC code for encoding. if Identifier_Character_Set = 'w' and then Wide_Character_Encoding_Method in WC_ESC_Encoding_Method then - Identifier_Char (ASCII.ESC) := True; + Identifier_Char_Table (ASCII.ESC) := True; end if; end Initialize; diff --git a/gcc/ada/csets.ads b/gcc/ada/csets.ads index 9dc78ba10e8..f0930df47db 100644 --- a/gcc/ada/csets.ads +++ b/gcc/ada/csets.ads @@ -80,12 +80,12 @@ package Csets is Fold_Lower : Translate_Table; -- Table to fold upper case identifier letters to lower case - Identifier_Char : Char_Array_Flags; - -- This table has True entries for all characters that can legally appear - -- in identifiers, including digits, the underline character, all letters - -- including upper and lower case and extended letters (as controlled by - -- the setting of Opt.Identifier_Character_Set), left bracket for brackets - -- notation wide characters and also ESC if wide characters are permitted - -- in identifiers using escape sequences starting with ESC. + function Identifier_Char (Item : Character) return Boolean; + -- Return True for all characters that can legally appear in identifiers, + -- including digits, the underline character, all letters including upper + -- and lower case and extended letters (as controlled by the setting of + -- Opt.Identifier_Character_Set), left bracket for brackets notation wide + -- characters and also ESC if wide characters are permitted in identifiers + -- using escape sequences starting with ESC. end Csets; diff --git a/gcc/ada/opt.adb b/gcc/ada/opt.adb index 5427a95a3b6..8598ce234cc 100644 --- a/gcc/ada/opt.adb +++ b/gcc/ada/opt.adb @@ -23,8 +23,6 @@ -- -- ------------------------------------------------------------------------------ -with Csets; use Csets; - package body Opt is -------------------- @@ -188,7 +186,6 @@ package body Opt is Prefix_Exception_Messages := True; Uneval_Old := 'E'; Use_VADS_Size := False; - Identifier_Char ('[') := False; -- Note: we do not need to worry about Warnings_As_Errors_Count since -- we do not expect to get any warnings from compiling such a unit.