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. From patchwork Fri Jun 21 08:57:58 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: 1950627 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=gIY3OOxC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4W5B9l3kmgz20X8 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 B602A38983AB 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-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 97C463894C27 for ; Fri, 21 Jun 2024 08:58:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 97C463894C27 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 97C463894C27 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=1718960314; cv=none; b=ju1LU8Azp26onwylXKZCrJrhzC+8uxE17Ea2jBBZb3cN7wRG5KKO+plRs92q3lHMj2PrL1FwFzkqE1dlVrOuVur4FEJCQTrOWWtqAeh1dFW1Ld0smtIoi16Ugc1TDvVYFDej+zggU+swRiuBI/isd/O2oTGBgH52XIzlpXO2vOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960314; c=relaxed/simple; bh=EdnFvkGZ67G0GyHpCk00DZ5EHWoRm+qj14NGf3aFy20=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=dGxkH8HwNDWSL0HQ0ysKfrUH+fo6SDg+g2mz8ohfwc9nQ6ax84zeOYT96BkzlJybTZ2vzWUP/dG2iBZZMjx56pyRiU85bHKo5RFIbT4MoyGP/Liva85YyCKMRwaFscZeVhXNtzBhiifiqUhXvU5F3OHHBpP3L2ykWu2+Uj8hjxo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4217dbeb4caso16003195e9.1 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:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uvAdpQMQ+Wt1zpYA7XMuTlpNM7uyJ5apLPu+mLlEsvU=; b=gIY3OOxCVEMCS2IXOEEnw5VS6O0UKz+f1FLAhSuJSoq2cNYWyItDSIHjgTT4RGvuTU k0CWCCVvSqhlvbo+A8z0Y+ZkWMjBBdqQ1o5jqCNvnLFJ6RBLXZApnTa7KqerE8TuiHJT yZonEJSgev2rjD2zJP2/IdYqFs2Eg5jugSKXfon4bdISHb7LJ1e6al7M4DU5AQK3Ejac cliLrnPBpCJf4bJvYFGPEsQOQLLFf1NlAysOKBab769+s+OhtKeKGRreumo93Z3UfkA7 vFeUSeV29fYj011TwiDtfE3DCEBp7touV/o0Rnarq/4XomRoOGQH0BJ17i5P81XC1JX7 fAbQ== 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: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=uvAdpQMQ+Wt1zpYA7XMuTlpNM7uyJ5apLPu+mLlEsvU=; b=iPYEGzl2ede+HIJ6NlCLORf7fKiM8Z0602D/VFuBWaygGolVbQuywZsFtZM6a3u6Js 7l3uK1hrGPJSN0BuDK0pGZu238a14fUmmoawYAOPjCVQR0CpwTCViReSSRGeMSUVmGa0 zMZxztFBFRrHqA7p2dv0p81q0vNe4YsRMDhct7jOo8pfsG3wQEjBv8E+20+yqV1n82yr 5VBnFKSepe3WiQ8cf8CZiX4VkrcwKi7HH8Y6kHXZTQkzv0B3S2hu5z60LPlLH1Ff0gee 2Za30euzDN1moTkicTW08Rl4yCGQSJD344olWT0k3P8XAXJa9XrCf70DCvK/D1YDDaWW +Z7g== X-Gm-Message-State: AOJu0YwVec/Csu7RTfURCfR7MY6wIIKDGKVi0umHE4c2otEeWxSLDog5 g6Ewp5jEBc/qLkFXi6VDR/BVmZ0Rp1jkJjimzZ0ZeRziXOteFm9dYx/YgyWT6sUcsKpSdH0VGxM = X-Google-Smtp-Source: AGHT+IEPSVUBuXYT3D58T3PtFtY3rU95J6ipqccZ0BUwGPaB9VPF6wJXQuMXl7Sj0OW8THHQf5tNsQ== X-Received: by 2002:a05:600c:3587:b0:422:6e65:a4cb with SMTP id 5b1f17b1804b1-4247507865fmr61340085e9.3.1718960311304; Fri, 21 Jun 2024 01:58:31 -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.30 (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: Piotr Trojanek Subject: [COMMITTED 02/22] ada: Fix for Default_Component_Value with declare expressions Date: Fri, 21 Jun 2024 10:57:58 +0200 Message-ID: <20240621085819.2485987-2-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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 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 When the expression of aspect Default_Component_Value includes a declare expression with current type instance, we attempted to recursively froze that type, which itself caused an infinite recursion, because we didn't properly manage the scope of declare expression. This patch fixes both the detection of the current type instance and analysis of the expression that caused recursive freezing. gcc/ada/ * sem_attr.adb (In_Aspect_Specification): Use the standard condition that works correctly with declare expressions. * sem_ch13.adb (Analyze_Aspects_At_Freeze_Point): Replace ordinary analysis with preanalysis of spec expressions. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_attr.adb | 4 +++- gcc/ada/sem_ch13.adb | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 72f5ab49175..d56c25a79cc 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -1843,7 +1843,9 @@ package body Sem_Attr is if Nkind (P) = N_Aspect_Specification then return P_Type = Entity (P); - elsif Nkind (P) in N_Declaration then + -- Prevent the search from going too far + + elsif Is_Body_Or_Package_Declaration (P) then return False; end if; diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 4012932a6f2..a86f774018a 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -1037,11 +1037,19 @@ package body Sem_Ch13 is Parent_Type : Entity_Id; + Save_In_Spec_Expression : constant Boolean := In_Spec_Expression; + begin -- Ensure Expr is analyzed so that e.g. all types are properly - -- resolved for Find_Type_Reference. + -- resolved for Find_Type_Reference. We preanalyze this expression + -- as a spec expression (to avoid recursive freezing), while skipping + -- resolution (to not fold type self-references, e.g. T'Last). - Analyze (Expr); + In_Spec_Expression := True; + + Preanalyze (Expr); + + In_Spec_Expression := Save_In_Spec_Expression; -- A self-referential aspect is illegal if it forces freezing the -- entity before the corresponding aspect has been analyzed. From patchwork Fri Jun 21 08:57:59 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: 1950634 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=O4rXC8te; 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 4W5BCf2SgNz20X8 for ; Fri, 21 Jun 2024 19:00:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 98FF53899072 for ; Fri, 21 Jun 2024 09:00:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 4525E3895FC2 for ; Fri, 21 Jun 2024 08:58:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4525E3895FC2 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 4525E3895FC2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::431 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960314; cv=none; b=hzu6MEI1sVyVpQj5frlnIqm23syF1NhkYhHdgJ38UOQznkNvTIVMGTvGBoICFqBwYdb1zPSsAH6evPlZiVnEfMtjy4LUj9zn+zodPk4obJwh78yFsTvp3b2GNgjRYVO09Ap0FfqtHhdpYQOn3ALuCzKMCBE2ckbsDDDIzxs8asY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960314; c=relaxed/simple; bh=m9Xwcm3Ngpf1oz6fC+/sRpFep0VxO8oN3V/ji4CybFA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=lypOtlJj/nGeGXOiilm4GpCGahwUqT8Gpagaa59w1rSWQdczGpiIXG6Q/ewAv4pkIl8XYymHit5BzMgnNMnCZgWIbiI0186aNRC5/2B5kIW6B38l+qeOuho7DjqykkpYvlAyVOWZP3H9A+DgT8oXj6T5joV/P4+iPXXa6S6pWkI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-362f62ae4c5so1014329f8f.1 for ; Fri, 21 Jun 2024 01:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960312; x=1719565112; 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=wWRlNC7tGLT0rGfeUFG/33Hzw4/SWlx37Br/PuCORSE=; b=O4rXC8temF9B4aaRr/134p37KfV6f7QPJl5fRRzNixoHfXZGsUCJkap22jbxi7BQeb 1Z5CfOmJ1vETttsX1rgjzNQnH3nUJPw7rSQ1XTK9pPR8+cwE7AYfulTSBol73EygJ1UB cYzrJj2dndrW3iEu8+eP0NphZN6bwiBADMuC2rj+1H+zl044gq19nufH68g2imkgMScu qGMpYlrzyUULS6uDUAdqYFZb6b9xHCU+l+0fzlgy4ynSqkCAfC46RIXTb5C4V1MJrV25 108xgFHNqPgMbyhhtHRpA5yql5/9lCGgZlS4ApwBizlJ70fmY3bP2hQXfxisOHq0DJWJ jyWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960312; x=1719565112; 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=wWRlNC7tGLT0rGfeUFG/33Hzw4/SWlx37Br/PuCORSE=; b=uLDIrFZ0OkPK8M1YjUD7YuQppHzOAyho9T15+svbQ7IYLY+ZbKET/n4A5Bje0IZroT 1CRSdFhsiUtTfXksMz927IGXDOMe1KbapN+pBU6oOwg3yoYq78yXdi09l9wbQLRmgPCm 4warUonNNavsY9QPB/YkK1u/EGgc8mgxvNufX2ycf/9mAlNyKfFm83lIoMVpSrb82NGv BZ4ViXZHDsQYvnzb47wi6XOcaiFuwORBTXXSbBxZXaHl0FG314PnfG8YPcamdsnoAyeh CGg6ffz/yOxkrJctax+wEUUfHruFWpBD2Y0iGsxPH2RqjOIAOi61Vcoa3E51OFL5VVfH Z81Q== X-Gm-Message-State: AOJu0YwKXESCrseH6uwWVVJG7iTSVoyjCjcUo4MdDcwhYi15v6+foqYa uX5oL5Ka7jgdpRFZrLk2xN2pmxEGprUs6uq4lTH1kgQuxn4hsHIs+C3aR9D2YMkJjsrm5gWecMc = X-Google-Smtp-Source: AGHT+IG8cxD1U0t1BS5dEiYAE1Wzh6T0ZQj4x8hBAQR5j9lf6GZjrszOXPkC6uimulosEckdLlT7zg== X-Received: by 2002:adf:f4d1:0:b0:362:1d6c:b867 with SMTP id ffacd0b85a97d-3621d6cb9c6mr10315911f8f.3.1718960312095; Fri, 21 Jun 2024 01:58:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:31 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 03/22] ada: Fix assertion failure on predicate involving access parameter Date: Fri, 21 Jun 2024 10:57:59 +0200 Message-ID: <20240621085819.2485987-3-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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 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: Eric Botcazou The assertion fails because the Original_Node of the expression has no Etype since its an unanalyzed identifier. gcc/ada/ * accessibility.adb (Accessibility_Level): Apply the processing to Expr when its Original_Node is an unanalyzed identifier. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/accessibility.adb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gcc/ada/accessibility.adb b/gcc/ada/accessibility.adb index da4d1d9ce2e..298103377a7 100644 --- a/gcc/ada/accessibility.adb +++ b/gcc/ada/accessibility.adb @@ -398,7 +398,7 @@ package body Accessibility is -- Local variables - E : Node_Id := Original_Node (Expr); + E : Node_Id; Pre : Node_Id; -- Start of processing for Accessibility_Level @@ -409,6 +409,17 @@ package body Accessibility is if Present (Param_Entity (Expr)) then E := Param_Entity (Expr); + + -- Use the original node unless it is an unanalyzed identifier, as we + -- don't want to reason on unanalyzed expressions from predicates. + + elsif Nkind (Original_Node (Expr)) /= N_Identifier + or else Analyzed (Original_Node (Expr)) + then + E := Original_Node (Expr); + + else + E := Expr; end if; -- Extract the entity From patchwork Fri Jun 21 08:58:00 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: 1950633 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=krYjwJBi; 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 4W5BCf1BKzz1ydW for ; Fri, 21 Jun 2024 19:00:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6DFF9389906C for ; Fri, 21 Jun 2024 09:00:44 +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 2834F3896C18 for ; Fri, 21 Jun 2024 08:58:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2834F3896C18 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 2834F3896C18 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=1718960318; cv=none; b=ah6ngQIf4UJXNKEhgjed9OuoDoUjDk7eySLE6nfWV6YCsjsKfv6yv5AWmGzTiArEvKKE9or0tNjjjXiwI9cLhD8af7BdABMjOTZBwxFZbAhYTRgEYitur7dv2/iQhZWyykz4spOkh1WL46TrdAohcf6xcVBBYNOPPbimuxuESRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960318; c=relaxed/simple; bh=5ds7vAtrE7gdFiw1FML7c/KbvgBGp6+kL+hKNtothsk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=CSD6ruzfXbwUKHAKalwguyevDM5cI2evurnnh+N2Adc8dJXTuOka9NRW2uQ8i3vF5xoYSxGjxjFUDNCP2vp/cyARnsplrV/N+EszV2T3VLdAEs1dF0ZE3C7F83DMwd5n1HERl/jt9zF5XPa564/HNnxzJIiTFqCzz1p6cRP31f8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-42172ed3487so13590995e9.0 for ; Fri, 21 Jun 2024 01:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960313; x=1719565113; 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=JmKJXlSrpvubjLst5uJ3EPpXBKLj4oy2RJ7jK+ukwG0=; b=krYjwJBibRuQ5WHkxV04ZECTWGT2VMXhVTR1mSuuBe4d7d/CREr6Af82Q8yKF/lDzj DCwWZwkfEECt3/kwfz3Ym4kHipezzO66qU0qR7z1oGadD0kv6VKo90i7BeACDmJqqP7+ 5E5s4+3SojQOqQb7bINaNq8xe+xUW9q5JDgRxJZPLuzRzUKYD1o477PJNQOg3fmArip2 3qRHX/Lo1R36vJAIYQFonHVhCdv5Vu2muRXd9qV6Bt/crvF0oGjmOeRZ1Xo7aevZZ4sr quPgHJFpgGPpGHlZT2oDk3JhW27pepnG9XY7s4zmySlKaHj67vbCtoUGOKXyvGHm0npx yY6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960313; x=1719565113; 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=JmKJXlSrpvubjLst5uJ3EPpXBKLj4oy2RJ7jK+ukwG0=; b=d+NhXVFsf+ONBKYfzO/TZuD+nh6ozGtUs9YtErLC9aKr8HdosPjfN3qG+ohkuTVf3H BhKv1sx6utoyj7AyCqwVDDw6vp1POMeg5XhuEheW4aCug6ArxaIjNt2qXnbiOf3Z7NKX vL5EGjAbPFz2vgjekUYH3+cuRaWrd521h6KqmMSNiglVymBoUYNZiujdnzSXqk0pJ+hZ EOliUAoiOVcCtoqBaL5pIW/Sn0JdshEh0kFh5TGK683jAN4LTxKnIyGuS29bmPNZNG+U y0v89kjqgsCMO+yLA7GkV07S1JAhKduoBgnqXA2IRb3A5TErJB+KCQgu1B+k1ID7RiTp GtZg== X-Gm-Message-State: AOJu0Yxbf3qnlyUt8CXSV/dukChYQevA8qi8TGMZ/QsD9mA2Z5cYVR3G oQbVFMPzHZlG7DUWeJhjMelsizkgxGxJYZh3MjXTvCRkDm6RnJakfP1sTv8efxHmW8xjjn1eSpc = X-Google-Smtp-Source: AGHT+IFFTkU0VjrWpLHtMy+N4Jbs7M09vHC+t2tdxhyGQpckmCmIOMmRKW5YTK9X3lcJX4eApSd3ng== X-Received: by 2002:a05:600c:4899:b0:422:648d:bdf1 with SMTP id 5b1f17b1804b1-4247529bc60mr52137475e9.34.1718960312918; Fri, 21 Jun 2024 01:58:32 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:32 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED 04/22] ada: Predefined arithmetic operators incorrectly treated as directly visible Date: Fri, 21 Jun 2024 10:58:00 +0200 Message-ID: <20240621085819.2485987-4-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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 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: Steve Baird In some cases, a predefined operator (e.g., the "+" operator for an integer type) is incorrectly treated as being directly visible when it is not. This can lead to both accepting operator uses that should be rejected and also to incorrectly rejecting legal constructs as ambiguous (for example, an expression "Foo + 1" where Foo is an overloaded function and the "+" operator is directly visible for the result type of only one of the possible callees). gcc/ada/ * sem_ch4.adb (Is_Effectively_Visible_Operator): A new function. (Check_Arithmetic_Pair): In paths where Add_One_Interp was previously called unconditionally, instead call only if Is_Effectively_Visible_Operator returns True. (Check_Boolean_Pair): Likewise. (Find_Unary_Types): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch4.adb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 1175a34df21..dfeff02a011 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -270,6 +270,18 @@ package body Sem_Ch4 is -- these aspects can be achieved without larger modifications to the -- two-pass resolution algorithm. + function Is_Effectively_Visible_Operator + (N : Node_Id; Typ : Entity_Id) return Boolean + is (Is_Visible_Operator (N => N, Typ => Typ) + or else + -- test for a rewritten Foo."+" call + (N /= Original_Node (N) + and then Is_Effectively_Visible_Operator + (N => Original_Node (N), Typ => Typ)) + or else not Comes_From_Source (N)); + -- Return True iff either Is_Visible_Operator returns True or if + -- there is a reason it is ok for Is_Visible_Operator to return False. + function Possible_Type_For_Conditional_Expression (T1, T2 : Entity_Id) return Entity_Id; -- Given two types T1 and T2 that are _not_ compatible, return a type that @@ -6641,6 +6653,8 @@ package body Sem_Ch4 is and then (Covers (T1 => T1, T2 => T2) or else Covers (T1 => T2, T2 => T1)) + and then Is_Effectively_Visible_Operator + (N, Specific_Type (T1, T2)) then Add_One_Interp (N, Op_Id, Specific_Type (T1, T2)); end if; @@ -6670,6 +6684,8 @@ package body Sem_Ch4 is and then (Covers (T1 => T1, T2 => T2) or else Covers (T1 => T2, T2 => T1)) + and then Is_Effectively_Visible_Operator + (N, Specific_Type (T1, T2)) then Add_One_Interp (N, Op_Id, Specific_Type (T1, T2)); @@ -6713,6 +6729,8 @@ package body Sem_Ch4 is and then (Covers (T1 => T1, T2 => T2) or else Covers (T1 => T2, T2 => T1)) + and then Is_Effectively_Visible_Operator + (N, Specific_Type (T1, T2)) then Add_One_Interp (N, Op_Id, Specific_Type (T1, T2)); end if; @@ -7086,6 +7104,7 @@ package body Sem_Ch4 is T := Any_Modular; end if; + -- test Is_Effectively_Visible_Operator here ??? Add_One_Interp (N, Op_Id, T); end if; end Check_Boolean_Pair; @@ -7615,7 +7634,8 @@ package body Sem_Ch4 is then null; - else + elsif Is_Effectively_Visible_Operator (N, Base_Type (It.Typ)) + then Add_One_Interp (N, Op_Id, Base_Type (It.Typ)); end if; end if; From patchwork Fri Jun 21 08:58:01 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: 1950629 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=AvmSev9o; 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 4W5BB61gC7z20X4 for ; Fri, 21 Jun 2024 18:59:26 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 720763896C34 for ; Fri, 21 Jun 2024 08:59:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id 6A79B3896C21 for ; Fri, 21 Jun 2024 08:58:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6A79B3896C21 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 6A79B3896C21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960318; cv=none; b=fLaA3vesDEmieArOYOOl6J1FSjtmjZbr9tZnxgTMIp0+dyEXLHZkRy0U0jJgBSY03mFYLRBJOk0V5QKq5ZXkOLB1GbBJpmLs8Cn7rh4i6Ox+V2zYB9sHzrCAStL8vdYz+v/oJEAdlx5aLYsswSjoScTz223ek8ai2oBlRs8O/wg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960318; c=relaxed/simple; bh=eZmh/sjLbcfowy1D83WAsBBt+YkpmkwnRO7SETLLCzM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=FgD3s/mb6A8N5BE7WalKOV37fk6wPMFQZh3Q18mnXpMbtVuH0yMfw5cNttTRMjKxHQhXPjtkltWPQpb4BXznKNo+LnkcVPpzUGxW85zuSchonrEPplt4p1TYi59nTUx8geUhP7SC82DtrB0NTfYY6uKS1mTxeUHxuWTfUMG/eIs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-52cd9f9505cso207585e87.0 for ; Fri, 21 Jun 2024 01:58:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960314; x=1719565114; 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=Bx3Y283PwkzPq/SyY7GuYpNPaqG5uiKb4QXI2dUyRgQ=; b=AvmSev9odgxrx2QTFd847dfkVluPcTl/vCBQG1gUIUx1qkjSykpQ21HzPDm+MKZ4cC pjAbqe3laGpZl2JU6OxGXYZqDhVDP5zxw2+F7iU1GoCeQzvyONmzAS8zI+eNghHKdeMN RYtkfzuL2k5vdeh3vZuHWy9y/dbUAz33WqQoHFRe0oDE3GJ9A2e9vY67lKKkbRYCCW5X nhgn26b+0Z2yJUgAomsmK5asnEGxLSksbF9T2B07wo8Vkgl0owDXe9ha0Nhz35IEDilR p4BrZ8TT0Cm/SB3O77aDdxOhBIY/WFD4D6HSYh6CR+jpsUAlIzL7edgrW/dZyMW8bkeU Fl0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960314; x=1719565114; 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=Bx3Y283PwkzPq/SyY7GuYpNPaqG5uiKb4QXI2dUyRgQ=; b=mbermDblgHgcqR1Oe3voMN5VN2P3mMZydsKloFJrALX8r9jYVKO4PHlU6/eWvi495q Uc2JWsy4cylhI2sjhPzRsmh/MBHEV4pzDm3fSsOwagVwfcCPApyo/1xWycJGq0t7OpTO 866bypfDllMTarw1hNWUVWadNEm/iuvSAMpGAJss4COCA3BD7aL4eiXofF7ATspF3XaJ Dsq9UwJh5MSExgwcnPntbcgLiiVURCIfiGoEwM0MfhdoilPFa5pPxhTgAORHsHnbU0PW 4c0yQ7Ps59VSHLsBtGuhHQOUURoSrS566nWE3tTpPq7Nfb5iCEiDSE/3rKj9eBMvlYjm qdWg== X-Gm-Message-State: AOJu0Yw3QgWsB+Atqz5fSwt5nnDVBJAvwb+4UlwHcXDk0Oz7lT+UkoHz tOz00rflzFDPcNgdKp/bLWhUnIA5B550L+ETYwivIANcuGqdoLAh53BCCsqZT38z3fwDc/JJbc8 = X-Google-Smtp-Source: AGHT+IFbLuAIz2qA44qvt48HTQnOHnZaeYMCsaCgsOnUgItN+SM4urVmrAU0mzFDSgXtTOZpKNsp6Q== X-Received: by 2002:ac2:44d3:0:b0:52b:839c:78dc with SMTP id 2adb3069b0e04-52ccaa61d65mr4478524e87.29.1718960313789; Fri, 21 Jun 2024 01:58:33 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:33 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED 05/22] ada: Fix gnatcheck violation reported after a recent cleanup Date: Fri, 21 Jun 2024 10:58:01 +0200 Message-ID: <20240621085819.2485987-5-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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 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 Code cleanup; semantics is unaffected. gcc/ada/ * sem_ch3.adb (Add_Interface_Tag_Components): Simplify with No. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch3.adb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index eebaedc216b..a1112d7b44a 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -1618,7 +1618,7 @@ package body Sem_Ch3 is Last_Tag := Empty; - if not Present (Component_List (Ext)) then + if No (Component_List (Ext)) then Set_Null_Present (Ext, False); L := New_List; Set_Component_List (Ext, From patchwork Fri Jun 21 08:58:02 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: 1950642 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=Aby/vz5P; 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 4W5BFP0X45z1ydW for ; Fri, 21 Jun 2024 19:02:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 355EC3899096 for ; Fri, 21 Jun 2024 09:02:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id EB6AB3896C23 for ; Fri, 21 Jun 2024 08:58:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EB6AB3896C23 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 EB6AB3896C23 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::334 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960320; cv=none; b=YPwQIubBLGhGtHDE721ungXFoBVvuW5LNN1QZTSooIIOZl0yowoY24Eo7uBacYT3Vg7TMfZMBPfcsqlZZ2QXvI3tZXQaU0tabNPwpQ2XphrahlgPggV75H/nBgwFg7hzaSnv0aI/oWwTz8NAj9lhUSOhEexaRjDppoInHxPD634= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960320; c=relaxed/simple; bh=gNgajLoU8VGmhJ/ExEaiVAan8oje/DUy+VkAZnHyf8U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XzxdX8ClgtvGQsigDQSVixh5O4Xg4dD9TltpU03Au7R8Bt1e0qItYT7Xu092Krvo0fcmWfhn2oNMBKJa0zTFejdO5WoY4+XBPkrMbbOwqphjEMtv2Xl8+yi87p+0n6hLYdHm+sNz656H12Baa651SjsoxVuaQrKiViBw1VZvuUU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-42172ed3597so10540845e9.0 for ; Fri, 21 Jun 2024 01:58:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960315; x=1719565115; 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=L/E8QanJK4eq/85xvkFY61yu0fTJ7Yq6PVPF3BntaU4=; b=Aby/vz5Pvpm7qMM92vwN9oCUQl+IB1SyEBn4VvyCO+vScctfwPRqnjSijfbW18tjpJ NOgNGGNIPy9mX0SpKzpFQpMkpFexat8E8BuyEPDdRp6pD08986hh8rMXcihkYT0sJBSW iHXYTnUwbBlwYRbAhNUNaxWo1cJyaeUH4jW9UFp2oLHrvBZVjYBgGWNcH/GT1aFvqw0R AE1suXYDGbfZUPwXu82ceOGXFOl2xiR0bDkOPazkWEFETwhWhBryojpuXqOl13GrOWEL 7Akee0xweXx5xRVpJoTcFcBcV7nxtADQardokug3Sr6eeCPbQXfcGL8OMzKVwrEKyT2e NcFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960315; x=1719565115; 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=L/E8QanJK4eq/85xvkFY61yu0fTJ7Yq6PVPF3BntaU4=; b=YV6XfehhWIa+nsc3S+TFNbAygduxAFA/J2Rm40Uxg4hEm0OxJ911TNczPBwFdPWERS 5IRusGTomkHPNQktDFCimkQZMm8KEoH5ptbnk0rrfb0E26Qo0m0GeKlA9PxNqwvBNBxk kZGN5/yWMg4QwhZ6KPAn3/NDhXAA0+j8FTwEmuJFS6u4QpL15AJhFNqDOQ0b7e/kTD4D riKJLzgnYM6L6dXRWpJ+2X6fc9XznUujmUxDRo9Hw3uoppxdY5QrzW8+UdrPPkAbeKb9 zP5ASzX2/FCQ8+QtvcJN8IE3IljeauMtNoTZF14sKQGecTGtkdh4V4wkQx7I+Hg+O/TE dw5Q== X-Gm-Message-State: AOJu0Yy8SBKEjkAXypzObHcxfyf+cyzavyzu1hhjbUkFy4gXyCuaylX2 eKomNoRq3ktnjmKDyW1fMUbMlLa16fdXUqULtoY9mJRrWyoYZ9WDz04eGElBSu2qoc7cf6YXl9U = X-Google-Smtp-Source: AGHT+IGcE2J+ajwe6qJyHE/+rPnDIdF+x07YIRJ5MPPeFgjPgd46//oKMWA6Limob+UcYEBkkgRWbg== X-Received: by 2002:a05:600c:4506:b0:422:291:6b3e with SMTP id 5b1f17b1804b1-4246f56d2b6mr102109525e9.1.1718960314690; Fri, 21 Jun 2024 01:58:34 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:34 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED 06/22] ada: Generic formal/actual matching -- misc cleanup Date: Fri, 21 Jun 2024 10:58:02 +0200 Message-ID: <20240621085819.2485987-6-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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, 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: Bob Duff The only substantive change is to remove Activation_Chain_Entity from N_Generic_Package_Declaration. The comment in sinfo.ads suggesting this change was written in 1993! Various pieces of missing documentation are added to Sinfo and Einfo. Also other minor cleanups. gcc/ada/ * gen_il-gen-gen_nodes.adb (N_Generic_Package_Declaration): Remove Activation_Chain_Entity. * sinfo.ads: Comment improvements. Add missing doc. Remove obsolete comment about Activation_Chain_Entity. * einfo.ads: Comment improvements. Add missing doc. * einfo-utils.adb (Base_Type): Add Assert (disabled for now). (Next_Index): Minor cleanup. * aspects.ads: Minor comment fix. * exp_ch6.adb: Likewise. * sem_ch3.adb: Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/aspects.ads | 2 +- gcc/ada/einfo-utils.adb | 29 ++++++++++++++++++++--------- gcc/ada/einfo.ads | 29 +++++++++++++++-------------- gcc/ada/exp_ch6.adb | 4 ++-- gcc/ada/gen_il-gen-gen_nodes.adb | 3 +-- gcc/ada/sem_ch3.adb | 4 ++-- gcc/ada/sinfo.ads | 32 ++++++++++++++++++-------------- 7 files changed, 59 insertions(+), 44 deletions(-) diff --git a/gcc/ada/aspects.ads b/gcc/ada/aspects.ads index 140fb7c8fe1..cf992a89038 100644 --- a/gcc/ada/aspects.ads +++ b/gcc/ada/aspects.ads @@ -1176,7 +1176,7 @@ package Aspects is Class_Present : Boolean := False; Or_Rep_Item : Boolean := False) return Node_Id; -- Find the aspect specification of aspect A (or A'Class if Class_Present) - -- associated with entity I. + -- associated with entity Id. -- If found, then return the aspect specification. -- If not found and Or_Rep_Item is true, then look for a representation -- item (as opposed to an N_Aspect_Specification node) which specifies diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb index 438868ac757..4c86ba1c3b1 100644 --- a/gcc/ada/einfo-utils.adb +++ b/gcc/ada/einfo-utils.adb @@ -664,12 +664,22 @@ package body Einfo.Utils is function Base_Type (Id : E) return E is begin - if Is_Base_Type (Id) then - return Id; - else - pragma Assert (Is_Type (Id)); - return Etype (Id); - end if; + return Result : E do + if Is_Base_Type (Id) then + Result := Id; + else + pragma Assert (Is_Type (Id)); + Result := Etype (Id); + if False then + pragma Assert (Is_Base_Type (Result)); + -- ???It seems like Base_Type should return a base type, + -- but this assertion is disabled because it is not always + -- true. Hence the need to say "Base_Type (Base_Type (...))" + -- in some cases; Base_Type is not idempotent as one might + -- expect. + end if; + end if; + end return; end Base_Type; ---------------------- @@ -2018,10 +2028,11 @@ package body Einfo.Utils is ---------------- function Next_Index (Id : N) return Node_Id is - begin pragma Assert (Nkind (Id) in N_Is_Index); - pragma Assert (No (Next (Id)) or else Nkind (Next (Id)) in N_Is_Index); - return Next (Id); + Result : constant Node_Id := Next (Id); + pragma Assert (No (Result) or else Nkind (Result) in N_Is_Index); + begin + return Result; end Next_Index; ------------------ diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index 8ee419b3e07..dd95ea051c1 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -1334,7 +1334,7 @@ package Einfo is -- First_Component (synthesized) -- Applies to incomplete, private, protected, record and task types. -- Returns the first component by following the chain of declared --- entities for the type a component is found (one with an Ekind of +-- entities for the type until a component is found (one with an Ekind of -- E_Component). The discriminants are skipped. If the record is null, -- then Empty is returned. @@ -1342,6 +1342,10 @@ package Einfo is -- Similar to First_Component, but discriminants are not skipped, so will -- find the first discriminant if discriminants are present. +-- First_Discriminant (synthesized) +-- Defined for types with discriminants or unknown discriminants. +-- Returns the first in the Next_Discriminant chain; see Sem_Aux. + -- First_Entity -- Defined in all entities that act as scopes to which a list of -- associated entities is attached, and also in all [sub]types. Some @@ -1375,12 +1379,11 @@ package Einfo is -- First_Index -- Defined in array types and subtypes. By introducing implicit subtypes -- for the index constraints, we have the same structure for constrained --- and unconstrained arrays, subtype marks and discrete ranges are --- both represented by a subtype. This function returns the tree node --- corresponding to an occurrence of the first index (NOT the entity for --- the type). Subsequent indices are obtained using Next_Index. Note that --- this field is defined for the case of string literal subtypes, but is --- always Empty. +-- and unconstrained arrays, subtype marks and discrete ranges are both +-- represented by a subtype. This function returns the N_Is_Index tree +-- node corresponding to the first index (not an entity). Subsequent +-- indices are obtained using Next_Index. Note that this field is defined +-- for the case of string literal subtypes, but is always Empty. -- First_Literal -- Defined in all enumeration types, including character and boolean @@ -3749,13 +3752,11 @@ package Einfo is -- all the extra formals (see description of Extra_Formal field) -- Next_Index (synthesized) --- Applies to array types and subtypes and to string types and --- subtypes. Yields the next index. The first index is obtained by --- using the First_Index attribute, and then subsequent indexes are --- obtained by applying Next_Index to the previous index. Empty is --- returned to indicate that there are no more indexes. Note that --- unlike most attributes in this package, Next_Index applies to --- nodes for the indexes, not to entities. +-- Applies to the N_Is_Index node returned by First_Index/Next_Index; +-- returns the next N_Is_Index node in the chain. Empty is returned to +-- indicate that there are no more indexes. Note that unlike most +-- attributes in this package, Next_Index applies to nodes for the +-- indexes, not to entities. -- Next_Inlined_Subprogram -- Defined in subprograms. Used to chain inlined subprograms used in diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index da19c031c3d..6d3d05fcf20 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -2939,8 +2939,8 @@ package body Exp_Ch6 is -- If the aspect is inherited, convert the pointer to the -- parent type that specifies the contract. -- If the original access_to_subprogram has defaults for - -- in_parameters, the call may include named associations, so - -- we create one for the pointer as well. + -- in-mode parameters, the call may include named associations, + -- so we create one for the pointer as well. if Is_Derived_Type (Ptr_Type) and then Ptr_Type /= Etype (Last_Formal (Wrapper)) diff --git a/gcc/ada/gen_il-gen-gen_nodes.adb b/gcc/ada/gen_il-gen-gen_nodes.adb index 580723666c5..b1ca6cf6c86 100644 --- a/gcc/ada/gen_il-gen-gen_nodes.adb +++ b/gcc/ada/gen_il-gen-gen_nodes.adb @@ -915,8 +915,7 @@ begin -- Gen_IL.Gen.Gen_Nodes Cc (N_Generic_Package_Declaration, N_Generic_Declaration, (Sy (Specification, Node_Id), Sy (Generic_Formal_Declarations, List_Id), - Sy (Aspect_Specifications, List_Id, Default_No_List), - Sm (Activation_Chain_Entity, Node_Id))); + Sy (Aspect_Specifications, List_Id, Default_No_List))); Cc (N_Generic_Subprogram_Declaration, N_Generic_Declaration, (Sy (Specification, Node_Id), diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index a1112d7b44a..fa13bd23ac7 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -1250,8 +1250,8 @@ package body Sem_Ch3 is -- to incomplete types declared in some enclosing scope, not to limited -- views from other packages. - -- Prior to Ada 2012, access to functions parameters must be of mode - -- 'in'. + -- Prior to Ada 2012, all parameters of an access-to-function type must + -- be of mode 'in'. if Present (Formals) then Formal := First_Formal (Desig_Type); diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index 599f4f63cce..3696ca4f7b4 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -2304,6 +2304,10 @@ package Sinfo is -- scope all use this field to reference the corresponding scope entity. -- See Einfo for further details. + -- Selector_Name + -- Present in N_Expanded_Name N_Selected_Component, + -- N_Generic_Association, and N_Parameter_Association nodes. + -- Shift_Count_OK -- A flag present in shift nodes to indicate that the shift count is -- known to be in range, i.e. is in the range from zero to word length @@ -7013,7 +7017,7 @@ package Sinfo is -- GENERIC_FORMAL_PART SUBPROGRAM_SPECIFICATION -- [ASPECT_SPECIFICATIONS]; - -- Note: Generic_Formal_Declarations can include pragmas + -- Note: Generic_Formal_Declarations can include pragmas and use clauses -- N_Generic_Subprogram_Declaration -- Sloc points to GENERIC @@ -7030,11 +7034,7 @@ package Sinfo is -- GENERIC_FORMAL_PART PACKAGE_SPECIFICATION -- [ASPECT_SPECIFICATIONS]; - -- Note: when we do generics right, the Activation_Chain_Entity entry - -- for this node can be removed (since the expander won't see generic - -- units any more)???. - - -- Note: Generic_Formal_Declarations can include pragmas + -- Note: Generic_Formal_Declarations can include pragmas and use clauses -- N_Generic_Package_Declaration -- Sloc points to GENERIC @@ -7042,7 +7042,6 @@ package Sinfo is -- Corresponding_Body -- Generic_Formal_Declarations from generic formal part -- Parent_Spec - -- Activation_Chain_Entity ------------------------------- -- 12.1 Generic Formal Part -- @@ -7143,16 +7142,19 @@ package Sinfo is -- Note: unlike the procedure call case, a generic association node -- is generated for every association, even if no formal parameter - -- selector name is present. In this case the parser will leave the - -- Selector_Name field set to Empty, to be filled in later by the - -- semantic pass. + -- selector name is present, in which case Selector_Name is Empty. -- In Ada 2005, a formal may be associated with a box, if the -- association is part of the list of actuals for a formal package. - -- If the association is given by OTHERS => <>, the association is + -- If the association is given by OTHERS => <>, the association is -- an N_Others_Choice (not an N_Generic_Association whose Selector_Name -- is an N_Others_Choice). + -- In source nodes, either Explicit_Generic_Actual_Parameter is present, + -- or Box_Present is True. However, Sem_Ch12 generates "dummy" nodes + -- with Explicit_Generic_Actual_Parameter = Empty and Box_Present = + -- False. + -- N_Generic_Association -- Sloc points to first token of generic association -- Selector_Name (set to Empty if no formal @@ -7382,13 +7384,15 @@ package Sinfo is -- Default_Name (set to Empty if no subprogram default) -- Box_Present -- Expression (set to Empty if no expression present) + -- If the default is "is null", then Null_Present is set + -- on the Specification of this node. -- Note: If no subprogram default is present, then Name is set -- to Empty, and Box_Present is False. - -- Note: The Expression field is only used for the GNAT extension - -- that allows a FORMAL_CONCRETE_SUBPROGRAM_DECLARATION to specify - -- an expression default for generic formal functions. + -- Note: The Expression field is for the GNAT extension that allows a + -- FORMAL_CONCRETE_SUBPROGRAM_DECLARATION to specify an expression + -- default for generic formal functions. -------------------------------------------------- -- 12.6 Formal Abstract Subprogram Declaration -- From patchwork Fri Jun 21 08:58:03 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: 1950630 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=UDgIIvrL; 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 4W5BBL6jWkz20X4 for ; Fri, 21 Jun 2024 18:59:38 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 365743896C2A for ; Fri, 21 Jun 2024 08:59:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id D40A13896C0E for ; Fri, 21 Jun 2024 08:58:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D40A13896C0E 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 D40A13896C0E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960320; cv=none; b=j1b4MerQ0GT9ZBK9zlXiDAq64DbWumaSfFk5RQc13kHOh7zpNd337ELDZrAvOBs33t2bPBwgRz+cSsLUt0jFIXWgHCeF1Sq/+rmK8Se7Z4v7XzjrPvaQn0eSqBLm9A3BHOzgR3NSdvV/b9mXm+A7ffbBv8dMKE/O96qlmaHwfJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960320; c=relaxed/simple; bh=EuRlYy5JbJsI5yR/gjHyEfa/o/tcmnBaOY8FX9gLM0Y=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pAxnE7vep9LbEbK7XQ8p0OEmLX/ExVMPBw1xWx9zcZ0DmUNGGUr65DQeFsKWGD3fbTHKkk3SdtW9efbDDAs/ZCDRUc3frgss+I8V8klpKnexB2fMaO8q8y5O5tqyxClaNcIvVAL5hWwK9mN4OHAVuEtMG05/+WCVr0nbhaMQ9PE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4230366ad7bso20478365e9.1 for ; Fri, 21 Jun 2024 01:58:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960315; x=1719565115; 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=sA+n/GYeD577+b1v92nCF1OssTbUx3nFVGYcHIQn2OA=; b=UDgIIvrL+Sd4CrXqpYv/3UGJlpT48rUx/iaIwvXHBnlW0vLv5JcNOr6YYvveFvlfOf nJF2VhN5owoGPv6CHwT6p5XklgJhx2mPPMAZiaKRCsQZnYQi61j96FQZ541Cs8a57guP yZs0XNuGzvp9hv06c6D0MXUlyr1aN3lFmiN+b/7jufJ7e6HW1fR3KIwJxSmX4w38i37m FGFSEQ2Wz4GTc8vPstkqbPDgLHWnqfDUTcz5KBrfdfaR0WeiP+Qgcwtw5fSW+BFgsk8H UoIBS4AC+CjajapDPJ9q8PQYG2M+mkWmQtO6aOkkgNsUM5uHlpYMVD34ojzkmlPi8OUj /y6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960315; x=1719565115; 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=sA+n/GYeD577+b1v92nCF1OssTbUx3nFVGYcHIQn2OA=; b=gcPGfgksjwa9tdMQ07cPSwD99jT6Usi+fv48l9bVfyFjojvYAOahojgWz26zn0GzzH 6NtSE6Ns8S84sOYJAOHtdV7AXeywT5K88MG2ZN9XIjG2h7un1++lkcq71VwuJHyYHT6A j4gPsPCvNnqlw8QbCQru/aBbxm8HXiKDouo15N+fEqxd60CnHYgoAjau1OZs2X0UavBK Ml7cevaeKh9DK/KgqrzytILDbsFlyW6WMhrlVG6hlbL4/ok1hkPdGGNqDKQ+yOthkSe7 PC8ihdmNsoNtqzu/TX4mqlWb+JxK8jZ3rJvAyCYdWHTJEPaqs6OSZrFNpsJ0rEAt9Ckj jKCQ== X-Gm-Message-State: AOJu0YxJOppGx4rl5p+f/y2BHSdvaqZxYl6bUV5d84e0Gn1KnYoE5npd 5IfNbhD0//cNLGqbfEe8bVNyvgrUl3wKTG9V9yj2ncsPyjvQwIPAPQiUC4Q+mCwb2IE8dYEi1Mk = X-Google-Smtp-Source: AGHT+IEun4t8nra//fagzzXvcgJAS3sM0/IuPo0FykK10iqCV11GL9jnFG7zpyplpgQiHDs3qym+jQ== X-Received: by 2002:a05:600c:19d2:b0:424:7e33:b9ef with SMTP id 5b1f17b1804b1-4247e33badbmr37482175e9.18.1718960315470; Fri, 21 Jun 2024 01:58:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:35 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 07/22] ada: Fix incorrect handling of packed array with aliased composite components Date: Fri, 21 Jun 2024 10:58:03 +0200 Message-ID: <20240621085819.2485987-7-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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 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: Eric Botcazou The problem is that the handling of the interaction between packing and aliased/atomic/independent components of an array type is tied to that of the interaction between a component clause and aliased/atomic/independent components, although the semantics are different: packing is a best effort thing, whereas a component clause must be honored or else an error be given. This decouples the two handlings, but retrofits the separate processing of independent components done in both cases into the common code and changes the error message from "minimum allowed is" to "minimum allowed value is" for the sake of consistency with the aliased/atomic processing. gcc/ada/ * freeze.adb (Freeze_Array_Type): Decouple the handling of the interaction between packing and aliased/atomic components from that of the interaction between a component clause and aliased/ atomic components, and retrofit the processing of the interaction between the two characteristics and independent components into the common processing. gcc/testsuite/ChangeLog: * gnat.dg/atomic10.adb: Adjust. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/freeze.adb | 190 ++++++++++++++--------------- gcc/testsuite/gnat.dg/atomic10.adb | 4 +- 2 files changed, 93 insertions(+), 101 deletions(-) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 1867880b314..29733a17a56 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -3634,7 +3634,9 @@ package body Freeze is procedure Freeze_Array_Type (Arr : Entity_Id) is FS : constant Entity_Id := First_Subtype (Arr); Ctyp : constant Entity_Id := Component_Type (Arr); - Clause : Entity_Id; + + Clause : Node_Id; + -- Set to Component_Size clause or Atomic pragma, if any Non_Standard_Enum : Boolean := False; -- Set true if any of the index types is an enumeration type with a @@ -3710,76 +3712,57 @@ package body Freeze is end; end if; - -- Check for Aliased or Atomic_Components or Full Access with - -- unsuitable packing or explicit component size clause given. - - if (Has_Aliased_Components (Arr) - or else Has_Atomic_Components (Arr) - or else Is_Full_Access (Ctyp)) - and then - (Has_Component_Size_Clause (Arr) or else Is_Packed (Arr)) - then - Alias_Atomic_Check : declare + -- Check for Aliased or Atomic or Full Access or Independent + -- components with an unsuitable component size clause given. + -- The main purpose is to give an error when bit packing would + -- be required to honor the component size, because bit packing + -- is incompatible with these aspects; when bit packing is not + -- required, the final validation of the component size may be + -- left to the back end. - procedure Complain_CS (T : String); - -- Outputs error messages for incorrect CS clause or pragma - -- Pack for aliased or full access components (T is either - -- "aliased" or "atomic" or "volatile full access"); + if Has_Component_Size_Clause (Arr) then + CS_Check : declare + procedure Complain_CS (T : String; Min : Boolean := False); + -- Output an error message for an unsuitable component size + -- clause for independent components (T is either "aliased" + -- or "atomic" or "volatile full access" or "independent"). ----------------- -- Complain_CS -- ----------------- - procedure Complain_CS (T : String) is + procedure Complain_CS (T : String; Min : Boolean := False) is begin - if Has_Component_Size_Clause (Arr) then - Clause := - Get_Attribute_Definition_Clause - (FS, Attribute_Component_Size); + Clause := + Get_Attribute_Definition_Clause + (FS, Attribute_Component_Size); - Error_Msg_N - ("incorrect component size for " - & T & " components", Clause); - Error_Msg_Uint_1 := Esize (Ctyp); - Error_Msg_N - ("\only allowed value is^", Clause); + Error_Msg_N + ("incorrect component size for " & T & " components", + Clause); + if Known_Static_Esize (Ctyp) then + Error_Msg_Uint_1 := Esize (Ctyp); + if Min then + Error_Msg_N ("\minimum allowed value is^", Clause); + else + Error_Msg_N ("\only allowed value is^", Clause); + end if; else Error_Msg_N - ("?cannot pack " & T & " components (RM 13.2(7))", - Get_Rep_Pragma (FS, Name_Pack)); - Set_Is_Packed (Arr, False); + ("\must be multiple of storage unit", Clause); end if; end Complain_CS; - -- Start of processing for Alias_Atomic_Check + -- Start of processing for CS_Check begin - -- If object size of component type isn't known, we cannot - -- be sure so we defer to the back end. + -- OK if the component size and object size are equal, or + -- if the component size is a multiple of the storage unit. - if not Known_Static_Esize (Ctyp) then - null; - - -- Case where component size has no effect. First check for - -- object size of component type multiple of the storage - -- unit size. - - elsif Esize (Ctyp) mod System_Storage_Unit = 0 - - -- OK in both packing case and component size case if RM - -- size is known and static and same as the object size. - - and then - ((Known_Static_RM_Size (Ctyp) - and then Esize (Ctyp) = RM_Size (Ctyp)) - - -- Or if we have an explicit component size clause and - -- the component size and object size are equal. - - or else - (Has_Component_Size_Clause (Arr) - and then Component_Size (Arr) = Esize (Ctyp))) + if (if Known_Static_Esize (Ctyp) + then Component_Size (Arr) = Esize (Ctyp) + else Component_Size (Arr) mod System_Storage_Unit = 0) then null; @@ -3793,67 +3776,76 @@ package body Freeze is elsif Is_Volatile_Full_Access (Ctyp) then Complain_CS ("volatile full access"); + + -- For Independent a larger size is permitted + + elsif (Has_Independent_Components (Arr) + or else Is_Independent (Ctyp)) + and then (not Known_Static_Esize (Ctyp) + or else Component_Size (Arr) < Esize (Ctyp)) + then + Complain_CS ("independent", Min => True); end if; - end Alias_Atomic_Check; - end if; + end CS_Check; - -- Check for Independent_Components/Independent with unsuitable - -- packing or explicit component size clause given. + -- Check for Aliased or Atomic or Full Access or Independent + -- components with an unsuitable aspect/pragma Pack given. + -- The main purpose is to prevent bit packing from occurring, + -- because bit packing is incompatible with these aspects; when + -- bit packing cannot occur, the final handling of the packing + -- may be left to the back end. - if (Has_Independent_Components (Arr) or else Is_Independent (Ctyp)) - and then - (Has_Component_Size_Clause (Arr) or else Is_Packed (Arr)) - then - begin - -- If object size of component type isn't known, we cannot - -- be sure so we defer to the back end. + elsif Is_Packed (Arr) and then Known_Static_RM_Size (Ctyp) then + Pack_Check : declare - if not Known_Static_Esize (Ctyp) then - null; + procedure Complain_Pack (T : String); + -- Output a warning message for an unsuitable aspect/pragma + -- Pack for independent components (T is either "aliased" or + -- "atomic" or "volatile full access" or "independent") and + -- reset the Is_Packed flag on the array type. - -- Case where component size has no effect. First check for - -- object size of component type multiple of the storage - -- unit size. + ------------------- + -- Complain_Pack -- + ------------------- - elsif Esize (Ctyp) mod System_Storage_Unit = 0 + procedure Complain_Pack (T : String) is + begin + Error_Msg_N + ("?cannot pack " & T & " components (RM 13.2(7))", + Get_Rep_Pragma (FS, Name_Pack)); - -- OK in both packing case and component size case if RM - -- size is known and multiple of the storage unit size. + Set_Is_Packed (Arr, False); + end Complain_Pack; - and then - ((Known_Static_RM_Size (Ctyp) - and then RM_Size (Ctyp) mod System_Storage_Unit = 0) + -- Start of processing for Pack_Check - -- Or if we have an explicit component size clause and - -- the component size is larger than the object size. + begin + -- OK if the component size and object size are equal, or + -- if the component size is a multiple of the storage unit. - or else - (Has_Component_Size_Clause (Arr) - and then Component_Size (Arr) >= Esize (Ctyp))) + if (if Known_Static_Esize (Ctyp) + then RM_Size (Ctyp) = Esize (Ctyp) + else RM_Size (Ctyp) mod System_Storage_Unit = 0) then null; - else - if Has_Component_Size_Clause (Arr) then - Clause := - Get_Attribute_Definition_Clause - (FS, Attribute_Component_Size); + elsif Has_Aliased_Components (Arr) then + Complain_Pack ("aliased"); - Error_Msg_N - ("incorrect component size for " - & "independent components", Clause); - Error_Msg_Uint_1 := Esize (Ctyp); - Error_Msg_N - ("\minimum allowed is^", Clause); + elsif Has_Atomic_Components (Arr) + or else Is_Atomic (Ctyp) + then + Complain_Pack ("atomic"); - else - Error_Msg_N - ("?cannot pack independent components (RM 13.2(7))", - Get_Rep_Pragma (FS, Name_Pack)); - Set_Is_Packed (Arr, False); - end if; + elsif Is_Volatile_Full_Access (Ctyp) then + Complain_Pack ("volatile full access"); + + elsif Has_Independent_Components (Arr) + or else Is_Independent (Ctyp) + then + Complain_Pack ("independent"); end if; - end; + end Pack_Check; end if; -- If packing was requested or if the component size was diff --git a/gcc/testsuite/gnat.dg/atomic10.adb b/gcc/testsuite/gnat.dg/atomic10.adb index 5f99ca66266..69685732f21 100644 --- a/gcc/testsuite/gnat.dg/atomic10.adb +++ b/gcc/testsuite/gnat.dg/atomic10.adb @@ -14,8 +14,8 @@ procedure Atomic10 is subtype Index_Type is Positive range 1 .. Max; - type Array_Type is array (Index_Type) of aliased Atomic_Unsigned; -- { dg-error "cannot be guaranteed" } - for Array_Type'Component_Size use Comp_Size; + type Array_Type is array (Index_Type) of aliased Atomic_Unsigned; + for Array_Type'Component_Size use Comp_Size; -- { dg-error "incorrect|only" } Slots : Array_Type; begin From patchwork Fri Jun 21 08:58:04 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: 1950643 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=fgVtbBtO; 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 4W5BFP2VFMz20X8 for ; Fri, 21 Jun 2024 19:02:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9C408389908A for ; Fri, 21 Jun 2024 09:02:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by sourceware.org (Postfix) with ESMTPS id D52533896C14 for ; Fri, 21 Jun 2024 08:58:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D52533896C14 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 D52533896C14 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960320; cv=none; b=L08K0a/VFv3xgkdl8b2nd1x07zSYcqerbd0Go9Y4JApLhK9HTPDLOzeynbcfMiPWrlq9ZertLrVjoW8e+r60zRHnwehrilrZmIddo6EWxZiWUDjqD0XD5g0JZylPEpthOME6uJFaulVSkNoodDp+IcIBZFJEbTC1ab6kjY21DM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960320; c=relaxed/simple; bh=9zGUHlDUGL/S3cHrovOojVxcSeXtLLZmCrB6WLtv4FA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=E1ALemuO4PVh6oyz5gYTdW7mlKv+lNdzu828Z2BCmwTcv5NhOj55XaD2yGRnRTq6g7ZNnHutar/JG5ZMk8m/B9dT8cChX5tBN9q6zz7D/+ioejU3FioU6A9BxGnAIIbUTsSC7mSe1M4fEwl0Oszmm2cn6eMAbu06ULDdzHRvvc4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-52cdb0d8107so65585e87.1 for ; Fri, 21 Jun 2024 01:58:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960316; x=1719565116; 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=fjvLWqD6WuQS/EXjxt0ketuhIBu5jhVMoQzkfr+7wis=; b=fgVtbBtOp+9wRzhV13Ft0nuN77UkOlJkiIiyW4WftBw9P9tZrorUTxsy2qdMu1xQgM O5pHzAYHl6squ30svkA8BY892SoH5efBHOK1lcXF0WpPF2BKgjK4RT69vuJSYALhvWpK z8i+w6qQvmdFCj47+ywhinb2AUD1iiOhRO7uryjdzR2Mqa9YWTqn1et4t5R3a0sj51hj wp9HFheq6jIwyrubTu6YpkAK81cx3WRgfjOh23bXzTBDlKgGSaKA+Z3+6DKDAkawU7Ho REa4VepuCHWmGSBUCiqUn+1d3IsenBSFv3iC2rEiBqe5YtwS9+waQ8Yo7D2i/7jHYl17 l35Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960316; x=1719565116; 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=fjvLWqD6WuQS/EXjxt0ketuhIBu5jhVMoQzkfr+7wis=; b=s1ZG+c/iFB+r8aoG/i8BfGFqRqA3u3+Z6OgbpjCqORRudWqjdev80WPp6LwZLVabvN FcUZcLWSvzMUXtWqhgIXsTXRfeaUSpWVuWFa9Z/KDXdXEgWZpwM8FWHdqKQhRO6OphX4 zxRO6KYQourvOTf3NdgQy72ahmfiF4OdDUovWJ7XFkgMzhK3Ipv9Tt21LxIcJx0P+6VT ic1R7VIVQWBYba1qqog64Fb2KQviUNU9fVz7Cl27l5ZOmeMHNhLgu5gLCBS3rB06zUbT q0EGTrRfy3j0YvHsbm9QVd+FlY1eozIiRma7LoT81OZwi7JJZ+60UpxMoAl8dR3TzLlw Vj0w== X-Gm-Message-State: AOJu0Yxx6P7ADAdQ46rJ2e+TaEG+8zOnmutqIBSdvYkPSDXvFc/q0AtF w7fz6UPKORe7LWeCA1XwUzf8VxB0UZ1iVx+pdPonAK4/6mq1023fEOvXUQuZeVl8qME098hvW8o = X-Google-Smtp-Source: AGHT+IFpBjTcQlWiwB1LLg5alWcn94vDSi0HuDUuOKtdiLT39n1YF6yLCzfJKfNJ6QWKoeui/X+/1g== X-Received: by 2002:a05:6512:281e:b0:52c:a016:5405 with SMTP id 2adb3069b0e04-52ccaa5867fmr5784281e87.8.1718960316251; Fri, 21 Jun 2024 01:58:36 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:35 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 08/22] ada: Fix internal error on case expression used as index of array component Date: Fri, 21 Jun 2024 10:58:04 +0200 Message-ID: <20240621085819.2485987-8-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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, 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: Eric Botcazou This occurs when the bounds of the array component depend on a discriminant and the component reference is not nested, that is to say the component is not (referenced as) a subcomponent of a larger record. In this case, Analyze_Selected_Component does not build the actual subtype for the component, but it turns out to be required for constructs generated during the analysis of the case expression. The change causes this actual subtype to be built, and also renames a local variable used to hold the prefix of the selected component. gcc/ada/ * sem_ch4.adb (Analyze_Selected_Component): Rename Name into Pref and use Sel local variable consistently. (Is_Simple_Indexed_Component): New predicate. Call Is_Simple_Indexed_Component to determine whether to build an actual subtype for the component. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch4.adb | 108 ++++++++++++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 35 deletions(-) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index dfeff02a011..4e1d1bc7ed7 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -4927,7 +4927,7 @@ package body Sem_Ch4 is -- the selector must denote a visible entry. procedure Analyze_Selected_Component (N : Node_Id) is - Name : constant Node_Id := Prefix (N); + Pref : constant Node_Id := Prefix (N); Sel : constant Node_Id := Selector_Name (N); Act_Decl : Node_Id; Comp : Entity_Id := Empty; @@ -4962,8 +4962,11 @@ package body Sem_Ch4 is -- indexed component rather than a function call. function Has_Dereference (Nod : Node_Id) return Boolean; - -- Check whether prefix includes a dereference, explicit or implicit, - -- at any recursive level. + -- Check whether Nod includes a dereference, explicit or implicit, at + -- any recursive level. + + function Is_Simple_Indexed_Component (Nod : Node_Id) return Boolean; + -- Check whether Nod is a simple indexed component in the context function Try_By_Protected_Procedure_Prefixed_View return Boolean; -- Return True if N is an access attribute whose prefix is a prefixed @@ -5107,6 +5110,40 @@ package body Sem_Ch4 is end if; end Has_Dereference; + --------------------------------- + -- Is_Simple_Indexed_Component -- + --------------------------------- + + function Is_Simple_Indexed_Component (Nod : Node_Id) return Boolean is + Expr : Node_Id; + + begin + -- Nod must be an indexed component + + if Nkind (Nod) /= N_Indexed_Component then + return False; + end if; + + -- The context must not be a nested selected component + + if Nkind (Pref) = N_Selected_Component then + return False; + end if; + + -- The expressions must not be case expressions + + Expr := First (Expressions (Nod)); + while Present (Expr) loop + if Nkind (Expr) = N_Case_Expression then + return False; + end if; + + Next (Expr); + end loop; + + return True; + end Is_Simple_Indexed_Component; + ---------------------------------------------- -- Try_By_Protected_Procedure_Prefixed_View -- ---------------------------------------------- @@ -5292,17 +5329,17 @@ package body Sem_Ch4 is begin Set_Etype (N, Any_Type); - if Is_Overloaded (Name) then + if Is_Overloaded (Pref) then Analyze_Overloaded_Selected_Component (N); return; - elsif Etype (Name) = Any_Type then + elsif Etype (Pref) = Any_Type then Set_Entity (Sel, Any_Id); Set_Etype (Sel, Any_Type); return; else - Prefix_Type := Etype (Name); + Prefix_Type := Etype (Pref); end if; if Is_Access_Type (Prefix_Type) then @@ -5345,8 +5382,8 @@ package body Sem_Ch4 is -- component prefixes because of the prefixed dispatching call case. -- Note that implicit dereferences are checked for this just above. - elsif Nkind (Name) = N_Explicit_Dereference - and then Is_Remote_Access_To_Class_Wide_Type (Etype (Prefix (Name))) + elsif Nkind (Pref) = N_Explicit_Dereference + and then Is_Remote_Access_To_Class_Wide_Type (Etype (Prefix (Pref))) and then Comes_From_Source (N) then if Try_Object_Operation (N) then @@ -5397,7 +5434,7 @@ package body Sem_Ch4 is Is_Concurrent_Type (Prefix_Type) and then Is_Internal_Name (Chars (Prefix_Type)) and then not Is_Derived_Type (Prefix_Type) - and then Is_Entity_Name (Name); + and then Is_Entity_Name (Pref); -- Avoid initializing Comp if that initialization is not needed -- (and, more importantly, if the call to First_Entity could fail). @@ -5425,8 +5462,8 @@ package body Sem_Ch4 is -- subsequent semantic checks might examine the original node. Set_Entity (Sel, Comp); - Rewrite (Selector_Name (N), New_Occurrence_Of (Comp, Sloc (N))); - Set_Original_Discriminant (Selector_Name (N), Comp); + Rewrite (Sel, New_Occurrence_Of (Comp, Sloc (N))); + Set_Original_Discriminant (Sel, Comp); Set_Etype (N, Etype (Comp)); Check_Implicit_Dereference (N, Etype (Comp)); @@ -5477,7 +5514,7 @@ package body Sem_Ch4 is -- to duplicate this prefix and duplication is only allowed -- on fully resolved expressions. - Resolve (Name); + Resolve (Pref); -- Ada 2005 (AI-50217): Check wrong use of incomplete types or -- subtypes in a package specification. @@ -5490,38 +5527,39 @@ package body Sem_Ch4 is -- N : Natural := X.all.Comp; -- ERROR, limited view -- end Pkg; -- Comp is not visible - if Nkind (Name) = N_Explicit_Dereference - and then From_Limited_With (Etype (Prefix (Name))) - and then not Is_Potentially_Use_Visible (Etype (Name)) + if Nkind (Pref) = N_Explicit_Dereference + and then From_Limited_With (Etype (Prefix (Pref))) + and then not Is_Potentially_Use_Visible (Etype (Pref)) and then Nkind (Parent (Cunit_Entity (Current_Sem_Unit))) = N_Package_Specification then Error_Msg_NE - ("premature usage of incomplete}", Prefix (Name), - Etype (Prefix (Name))); + ("premature usage of incomplete}", Prefix (Pref), + Etype (Prefix (Pref))); end if; - -- We never need an actual subtype for the case of a selection - -- for a indexed component of a non-packed array, since in - -- this case gigi generates all the checks and can find the - -- necessary bounds information. + -- We generally do not need an actual subtype for the case of + -- a selection for an indexed component of a non-packed array, + -- since, in this case, gigi can find all the necessary bound + -- information. However, when the prefix is itself a selected + -- component, for example a.b.c (i), gigi may regard a.b.c as + -- a dynamic-sized temporary, so we generate an actual subtype + -- for this case. Moreover, if the expressions are complex, + -- the actual subtype may be needed for constructs generated + -- by their analysis. -- We also do not need an actual subtype for the case of a -- first, last, length, or range attribute applied to a -- non-packed array, since gigi can again get the bounds in -- these cases (gigi cannot handle the packed case, since it -- has the bounds of the packed array type, not the original - -- bounds of the type). However, if the prefix is itself a - -- selected component, as in a.b.c (i), gigi may regard a.b.c - -- as a dynamic-sized temporary, so we do generate an actual - -- subtype for this case. + -- bounds of the type). Parent_N := Parent (N); if not Is_Packed (Etype (Comp)) and then - ((Nkind (Parent_N) = N_Indexed_Component - and then Nkind (Name) /= N_Selected_Component) + (Is_Simple_Indexed_Component (Parent_N) or else (Nkind (Parent_N) = N_Attribute_Reference and then @@ -5603,8 +5641,8 @@ package body Sem_Ch4 is -- Force the generation of a mutably tagged type conversion -- when we encounter a special class-wide equivalent type. - if Is_Mutably_Tagged_CW_Equivalent_Type (Etype (Name)) then - Make_Mutably_Tagged_Conversion (Name, Force => True); + if Is_Mutably_Tagged_CW_Equivalent_Type (Etype (Pref)) then + Make_Mutably_Tagged_Conversion (Pref, Force => True); end if; Check_Implicit_Dereference (N, Etype (N)); @@ -5616,7 +5654,7 @@ package body Sem_Ch4 is -- which can appear in expanded code in a tag check. if Ekind (Type_To_Use) = E_Record_Type_With_Private - and then Chars (Selector_Name (N)) /= Name_uTag + and then Chars (Sel) /= Name_uTag then exit when Comp = Last_Entity (Type_To_Use); end if; @@ -5786,7 +5824,7 @@ package body Sem_Ch4 is elsif Ekind (Comp) in E_Discriminant | E_Entry_Family or else (In_Scope and then not Is_Protected_Type (Prefix_Type) - and then Is_Entity_Name (Name)) + and then Is_Entity_Name (Pref)) then Set_Entity_With_Checks (Sel, Comp); Generate_Reference (Comp, Sel); @@ -5856,8 +5894,8 @@ package body Sem_Ch4 is -- and the selector is one of the task operations. if In_Scope - and then not Is_Entity_Name (Name) - and then not Has_Dereference (Name) + and then not Is_Entity_Name (Pref) + and then not Has_Dereference (Pref) then if Is_Task_Type (Prefix_Type) and then Present (Entity (Sel)) @@ -5974,7 +6012,7 @@ package body Sem_Ch4 is if Present (Comp) then if Is_Single_Concurrent_Object then - Error_Msg_Node_2 := Entity (Name); + Error_Msg_Node_2 := Entity (Pref); Error_Msg_NE ("invisible selector& for &", N, Sel); else @@ -6006,7 +6044,7 @@ package body Sem_Ch4 is if Etype (N) = Any_Type then if Is_Single_Concurrent_Object then - Error_Msg_Node_2 := Entity (Name); + Error_Msg_Node_2 := Entity (Pref); Error_Msg_NE ("no selector& for&", N, Sel); Check_Misspelled_Selector (Type_To_Use, Sel); From patchwork Fri Jun 21 08:58:05 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: 1950637 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=d/Gak9Fy; 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 4W5BD83BRGz1ydW for ; Fri, 21 Jun 2024 19:01:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9D1D738A1401 for ; Fri, 21 Jun 2024 09:01:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id 529103896C2A for ; Fri, 21 Jun 2024 08:58:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 529103896C2A 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 529103896C2A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::333 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960320; cv=none; b=sdPsbYYv2i1Y/j5srNcDAKaxk/EYpQXrdS7oxkdqzJIN6OVEXtQr8GlzSbvqIQZjOmTqsPk4RIL3pinR4NOSwCph9qfyhfKiyWW5sdxSkctmh8VSWWSiWyHokSGyJzl9iTJnhP4jZXRAUhkmi/I+p5b0y9DFo55C3nAhm9HMr9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960320; c=relaxed/simple; bh=/bdys62tjy7toEAnPoG3J+5PmC250JvytpXVnVayPTM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=uXs+WFgnNc7Ot65Ht7WU8DeX23AmKmsWP6EiXb0NlAsrFd5T9uNt3yr+ESProOqLLOio36PxbV20ZMcTaUkQdJV5FcZy2v706Are7FYmjzyvAPFnZjcb/BKoY0/juir0rOVshh4kDH0UoRVvQm0shtW3Lwb8chH7I34rrBTQn3k= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4247f36f689so11096515e9.1 for ; Fri, 21 Jun 2024 01:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960317; x=1719565117; 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=f90hCGMs9ILPG1jXtDqZk3iVkU+nxEh9POQAjMQYDEY=; b=d/Gak9FyZDoD1S4lu0233dG5ZwSQ7EGTZKq3ZhxiyAsIy7oARB/dXkuqRDlaWC6S2f 4zUUX9wN6Ius5Ec0xcIzPzrTD4W/lInPXNFsTJZcASDxdDYji34DOHe8rUUKbkW0FJPU RT1CsLu3y+MDOieqSvChsp8pj2rCWSICbPimUqnaoHzwFau7gKfSV0Fo59qf6xsMM4f+ BKWaar2uDU3J7mY3atWe7hA9jLS8h2MtwhWP+L3sFAZiAv+gFcocMKG4Hqx/PTS5Z69j WJhyvf0lGyYbY+B7o0+Vgb9kHMDYfLMe5MwbrwyQDV7lje0RN+14Zy5DM3BiKq2SvWLL A54w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960317; x=1719565117; 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=f90hCGMs9ILPG1jXtDqZk3iVkU+nxEh9POQAjMQYDEY=; b=Y0eizvc59uRg0E5vnZdkMF4s4VPG+eEljFkkmlc+YcBe5NOZrl0D15ChJtmzsX44xf yl+JXina4UX3EBM2jOlOP7ILblZou9pgXWkgnwnLIwuGfKXm9d/AkqFRRvagWFZcj1+Z SvUw9s/UO4c4HSDEFzU6M3NBzWsuvzMpS/4KyQZmC/o7PcCtCPlnlOVcdWqE9MZea9dp 7Ohl0pNEFnoAIlJnKweQC7MSWcQi+4ut+/p3i94sjadiVpG5Ek4hyKyV0kTNO9anH73u VvQqj5VmNgD8Wxu2SXPU825wbXkvIPVFviYk4uMlk2mw0vRzqv2SeisWOHJvSrR6ACt1 X5nw== X-Gm-Message-State: AOJu0YwiW3Q5caZ/kdvedp9RupKcwbOxqJz5OtXPnpAg99LGqFOXRn7F 1/a/Lm9DAPuJZiUTwSw5cJmYgZa6ty+Nu0dYKMojLl9xPNbGc1aGHLHXNfcmC+S7HDsGGlDPdgE = X-Google-Smtp-Source: AGHT+IEqb7zcoOBIZZFf5aReNfrY/8BQMAU1a45gryK5a4eoE8OThgSavoVK0fHvwFBKTbZx2VJhQg== X-Received: by 2002:a05:600c:491c:b0:422:2b9b:671d with SMTP id 5b1f17b1804b1-4247517dd8fmr62249635e9.19.1718960317078; Fri, 21 Jun 2024 01:58:37 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:36 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 09/22] ada: Fix missing index check with declare expression Date: Fri, 21 Jun 2024 10:58:05 +0200 Message-ID: <20240621085819.2485987-9-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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 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: Eric Botcazou The Do_Range_Check flag is properly set on the Expression of the EWA node built for the declare expression, so this instructs Generate_Index_Checks to look into this Expression. gcc/ada/ * checks.adb (Generate_Index_Checks): Add specific treatment for index expressions that are N_Expression_With_Actions nodes. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/checks.adb | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index bada3dffcbf..c8a0696be67 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -7248,7 +7248,8 @@ package body Checks is Loc : constant Source_Ptr := Sloc (N); A : constant Node_Id := Prefix (N); A_Ent : constant Entity_Id := Entity_Of_Prefix; - Sub : Node_Id; + + Expr : Node_Id; -- Start of processing for Generate_Index_Checks @@ -7294,13 +7295,13 @@ package body Checks is -- us to omit the check have already been taken into account in the -- setting of the Do_Range_Check flag earlier on. - Sub := First (Expressions (N)); + Expr := First (Expressions (N)); -- Handle string literals if Ekind (Etype (A)) = E_String_Literal_Subtype then - if Do_Range_Check (Sub) then - Set_Do_Range_Check (Sub, False); + if Do_Range_Check (Expr) then + Set_Do_Range_Check (Expr, False); -- For string literals we obtain the bounds of the string from the -- associated subtype. @@ -7310,8 +7311,8 @@ package body Checks is Condition => Make_Not_In (Loc, Left_Opnd => - Convert_To (Base_Type (Etype (Sub)), - Duplicate_Subexpr_Move_Checks (Sub)), + Convert_To (Base_Type (Etype (Expr)), + Duplicate_Subexpr_Move_Checks (Expr)), Right_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Etype (A), Loc), @@ -7330,11 +7331,19 @@ package body Checks is Ind : Pos; Num : List_Id; Range_N : Node_Id; + Stmt : Node_Id; + Sub : Node_Id; begin A_Idx := First_Index (Etype (A)); Ind := 1; - while Present (Sub) loop + while Present (Expr) loop + if Nkind (Expr) = N_Expression_With_Actions then + Sub := Expression (Expr); + else + Sub := Expr; + end if; + if Do_Range_Check (Sub) then Set_Do_Range_Check (Sub, False); @@ -7396,7 +7405,7 @@ package body Checks is Expressions => Num); end if; - Insert_Action (N, + Stmt := Make_Raise_Constraint_Error (Loc, Condition => Make_Not_In (Loc, @@ -7404,14 +7413,21 @@ package body Checks is Convert_To (Base_Type (Etype (Sub)), Duplicate_Subexpr_Move_Checks (Sub)), Right_Opnd => Range_N), - Reason => CE_Index_Check_Failed)); + Reason => CE_Index_Check_Failed); + + if Nkind (Expr) = N_Expression_With_Actions then + Append_To (Actions (Expr), Stmt); + Analyze (Stmt); + else + Insert_Action (Expr, Stmt); + end if; Checks_Generated.Elements (Ind) := True; end if; Next_Index (A_Idx); Ind := Ind + 1; - Next (Sub); + Next (Expr); end loop; end; end if; From patchwork Fri Jun 21 08:58:06 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: 1950636 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=Dw7jIfdQ; 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 4W5BCt4tVtz20X8 for ; Fri, 21 Jun 2024 19:00:58 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E293238A102D for ; Fri, 21 Jun 2024 09:00:56 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 07EB23896C0D for ; Fri, 21 Jun 2024 08:58:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 07EB23896C0D 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 07EB23896C0D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960321; cv=none; b=GUa1Fj+JYQ9hFK6qnEhDaJqDx2t7/jRmTAZtHcuedb63swwT5ghYfrV8BZtnMGHyQ1kmxRQuZFVFyJsSWqdm7VWcIh2wE6VGX3v7fDdRCnBqoYKAwg1um5pD5p0ay/E2NSZxDjAhYIIGFWg99X6oi0O6TMdsx/NuZETBejIRmZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960321; c=relaxed/simple; bh=dPMKyTKH0MNxgRxG7p5Gd+UZ0utsoc9lAL9gbz1Px+o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=e0kpViHJA6ARkzNyQ/VClVNysdJJmDdS1HgZPUHhvjyoD/vYBxWeT5ZUUCizkxslxCBtjZ87t7+pPqjrZf1yFSDHXynXYBjIvXN9x1WTPV08bMv+2mGGGvhPg693LvlvPzhPPMMD7eEurZuY2PH5Evab8vwtmm4UQHIMCRgOfPg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-421cd1e5f93so13279165e9.0 for ; Fri, 21 Jun 2024 01:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960318; x=1719565118; 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=QGytLC0gxjX2tyK69L3NkK3GNZIefgufoT979hYRleI=; b=Dw7jIfdQJBVLnrdDAcOat9UKVfeVTwuboxz7YadxbsJPiXbKw1M5RtVV52VlopmujM sdmjNCTk12G92/gZDrSzmybnHkoCLEvlgwlwDc9XWFOZt+28LWPF9T1rTnQc8IsKurL0 6iOqPzZ8ZsFQUS4U3cVGiybljmbqlqxRAqZX901ws2u0Ghpf4ZEjcCibFWHZO2POaCOF B9NfM3hcCbKTFR9BMKQCWudedsVl6bAchGSDBQ1XsOiTwJatkfDxrT5lCMt429tf4HZM s+ZdYumDKDeCoGI4hQfLNTZD/DncsAjSsOOs9EMcEI1BzgpH72ev6U2zK5PaHJIoiCWJ 2lUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960318; x=1719565118; 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=QGytLC0gxjX2tyK69L3NkK3GNZIefgufoT979hYRleI=; b=GLR86zvstbJ02Cu4yQXEB9wucRJciHvbNuubOVOy41m69eWqOXHcAuDYDmMAZc2KWu HqG+qAS/1ny3drbdRFiPX0i9P6V+RQNzJNWiP/oBiTWSyH02MyLqZLByhoGstld/TKCI GpiCq//wdpvDBjhsBxyVG1RexVjv4wIZFTV6LLYRgRRteva/bZ/2Gjh/6t2B0EMuw0ly hxxszDzLCoFzg4uoVUuCaWylR+Kz+Z5IYMljANjeNJlpK/QQSLIm+xzpTvXMHqaacF0F o4NCD+EqAL+qI2bTHcsyEsGmLdCWrgUmlUs99xvIcWqI3TIB8DcJMF1CGlA8C73pfYn4 vuXg== X-Gm-Message-State: AOJu0YxaWDdTEJv6zzG50zJeXeGLASDcpvTLxSq84XtyFQ+uC6CAmCv0 RUzK1BJHy7uzOSLEF0FWlAx7YWKBsiJMiXeFq02Oltw09gR9Zz+sROirtw2u69Qkiy4woENClSE = X-Google-Smtp-Source: AGHT+IEm7mwhZKV+BYEEb2lS2daDASPoEoUnsX/ljtvrWQd8NS4FLYsYqbIaCmxwJV5c2FYSVT3Wmw== X-Received: by 2002:a05:600c:893:b0:422:6755:17e3 with SMTP id 5b1f17b1804b1-42475298eeamr58601585e9.29.1718960317872; Fri, 21 Jun 2024 01:58:37 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:37 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED 10/22] ada: Cannot override inherited function with controlling result Date: Fri, 21 Jun 2024 10:58:06 +0200 Message-ID: <20240621085819.2485987-10-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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 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: Javier Miranda When a package has the declaration of a derived tagged type T with private null extension that inherits a public function F with controlling result, and a derivation of T is declared in the public part of another package, overriding function F may be rejected by the compiler. gcc/ada/ * sem_disp.adb (Find_Hidden_Overridden_Primitive): Check public dispatching primitives of ancestors; previously, only immediately-visible primitives were checked. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_disp.adb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_disp.adb b/gcc/ada/sem_disp.adb index 9c498ee9a3f..fe822290e45 100644 --- a/gcc/ada/sem_disp.adb +++ b/gcc/ada/sem_disp.adb @@ -89,7 +89,9 @@ package body Sem_Disp is -- to the found entity; otherwise return Empty. -- -- This routine does not search for non-hidden primitives since they are - -- covered by the normal Ada 2005 rules. + -- covered by the normal Ada 2005 rules. Its name was motivated by an + -- intermediate version of AI05-0125 where this term was proposed to + -- name these entities in the RM. function Is_Inherited_Public_Operation (Op : Entity_Id) return Boolean; -- Check whether a primitive operation is inherited from an operation @@ -2403,7 +2405,7 @@ package body Sem_Disp is Orig_Prim := Original_Corresponding_Operation (Prim); if Orig_Prim /= Prim - and then Is_Immediately_Visible (Orig_Prim) + and then not Is_Hidden (Orig_Prim) then Vis_Ancestor := First_Elmt (Vis_List); while Present (Vis_Ancestor) loop From patchwork Fri Jun 21 08:58:07 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: 1950646 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=LfKCFvyA; 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 4W5BFr2Zylz1ydW for ; Fri, 21 Jun 2024 19:02:40 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 95E96389909A for ; Fri, 21 Jun 2024 09:02:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 080073896C35 for ; Fri, 21 Jun 2024 08:58:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 080073896C35 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 080073896C35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::335 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960322; cv=none; b=cJA+wfI3uSrDXZejOOARQGfcawFYix3V0PkujFtiivQ619zANkS8n4wgjwuxjJxVAXLxhac+ZYxmw/3VP+/FHiqNT2NQUeZ3UcuJmyDz5KsHd2qeVg5THE/uRJpXXzorcjxmiMnhuw0zfhulIGRN01gI9S05YVI6tkgfe+jBwME= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960322; c=relaxed/simple; bh=yQmQ3XkG+AzA5Ws17rfhJ5Ce1oQZLO+goySpOnMCodc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ajR6AKcQUGrDjy+JJTM1anppxrBWpiA8Y8io5v5dGusEDEDvZQbF1zyUDIyhkeEAM8xZSIpuHOBJtVLlZYwkPYtLppu1jTMiwd3NnHE6LGK3uROqe5had3w6RuK+udqyv/lRqHSxwrzsiHd9bcUrB9+nJgBs/l2E5qT/TI+WaXs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4217dbeb4caso16003945e9.1 for ; Fri, 21 Jun 2024 01:58:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960319; x=1719565119; 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=KcQFEfvXi78Rkwx6S2Ys2IFbFECqHPxrWyI1OCKm7j8=; b=LfKCFvyAfKETQZN0pFB24HXeycUW/eu3PrIspbq/hExZ21iaYasbhJnvgjqMaDxdil OQ8dPwmQ4F4zCKls04LFN0TcYcUvMaaH2Leqavq3WCTz/hsqNA3D3xV0J8df9BJg04oF rWW26TvMmvbB3JqYvmueG8/Fmy9qzzYN9K6EkMuG27zTFAQNwIlpVF/Da0WbMcWzyvVu oeoNIimaKRcefQPIRt7ITiqLwxaqvdbB7l1hTlOu0RkhcbC0JT2nSNT3BeH9/SmWcTd7 9/rM15ec69aF8WUd9mxr23SbdWz3yIRewW4wVE2LMx3tTC03Vwb3Pb3Ffb01AQNoCUON ERFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960319; x=1719565119; 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=KcQFEfvXi78Rkwx6S2Ys2IFbFECqHPxrWyI1OCKm7j8=; b=sVpdOF6cpA4HRDdJj9BaGfOufpEhsiJTztTiQQzne6Pin8sJEiwuy49t3H58ILFnj0 AIxEnnsuH3YX3fw81yXCAcDApTPsbPGQZ2o4C9+3/mw9f3rMKMOx8gOMvK49CY6Vc4BK IhI4uh87EJPPIiw23e0AjTboxyTTRnnrX547TAQ+djaJ8H79/yUQoGECekpGMDdKOj7t 72/Z0XbGZzmChEI2k1P++hwC7If/drX0eLC/yt8emIle69mdDD31bBD8gL5orSTXHk6n HnoPBymH/y+t5jlZdLC5zpoigwYIUbk+b8LoelIfzqLKO+Pk08B3gXB06JWXtgHquoKz 603A== X-Gm-Message-State: AOJu0Yw+CnExFYAyUPFaCEgLiw6N/X6bNT39Cy91aYxFZNsOwFZJPmu5 C7efjNpwOLQUU6XNhabT5d7KtXwulvl4TCRBSrX/Sj+em5v9QlPyzJD4KokxVPp7I/Uwi8CrMMI = X-Google-Smtp-Source: AGHT+IEwu4Snf0ygf1FDvaERHQxIL+V4gUbAkSKBKPBRCU69mNbXfGrR6UM5zibaVWv/wlSn03dJCQ== X-Received: by 2002:a7b:cc0f:0:b0:424:7826:792 with SMTP id 5b1f17b1804b1-42478260d9fmr50055275e9.1.1718960318721; Fri, 21 Jun 2024 01:58:38 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:38 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Doug Rupp Subject: [COMMITTED 11/22] ada: Revert conditional installation of signal handlers on VxWorks Date: Fri, 21 Jun 2024 10:58:07 +0200 Message-ID: <20240621085819.2485987-11-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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 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: Doug Rupp The conditional installation resulted in a semantic change, and although it is likely what is ultimately wanted (since HW interrupts are being reworked on VxWorks). However it must be done in concert with other modifications for the new formulation of HW interrupts and not in isolation. gcc/ada/ * init.c [vxworks] (__gnat_install_handler): Revert to installing signal handlers without regard to interrupt_state. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/init.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/gcc/ada/init.c b/gcc/ada/init.c index acb8c7cc57e..93e73f53c64 100644 --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -2100,14 +2100,10 @@ __gnat_install_handler (void) /* For VxWorks, install all signal handlers, since pragma Interrupt_State applies to vectored hardware interrupts, not signals. */ - if (__gnat_get_interrupt_state (SIGFPE) != 's') - sigaction (SIGFPE, &act, NULL); - if (__gnat_get_interrupt_state (SIGILL) != 's') - sigaction (SIGILL, &act, NULL); - if (__gnat_get_interrupt_state (SIGSEGV) != 's') - sigaction (SIGSEGV, &act, NULL); - if (__gnat_get_interrupt_state (SIGBUS) != 's') - sigaction (SIGBUS, &act, NULL); + sigaction (SIGFPE, &act, NULL); + sigaction (SIGILL, &act, NULL); + sigaction (SIGSEGV, &act, NULL); + sigaction (SIGBUS, &act, NULL); #if defined(__leon__) && defined(_WRS_KERNEL) /* Specific to the LEON VxWorks kernel run-time library */ From patchwork Fri Jun 21 08:58:08 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: 1950648 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=iDFi0h3S; 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 4W5BGz6CGdz1ydW for ; Fri, 21 Jun 2024 19:03:39 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0FBED3896C36 for ; Fri, 21 Jun 2024 09:03:38 +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 3CAE93898384 for ; Fri, 21 Jun 2024 08:58:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3CAE93898384 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 3CAE93898384 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=1718960324; cv=none; b=g7+9Xpy36x7lHDQxSaZA/ZaFLMxo4MQFQUdMiJ1MPeL85qZotjnEvxIvWDlULZalxVzYLQA+wNmhs3zMJ5FahXxAKL6oTjMpB1J8U7S7qv7HcSB2B/4PurL8+ROTTtNaXTs0VmY1veaUXfYC+3+JcEvhFDA8J/5Br2i+8RAaIOU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960324; c=relaxed/simple; bh=LM72DJ4WePjpOrCjYamsR0aQw4zPfrJYGSX2cnsHzME=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=h7mfbVAhsRSoeou9Hex1MtEQOSWiwE7JcWciB95tLJk77RrusJ4nIz3GyckE5EHHlDvblY6Y+qnwYcuuptyutnqRirsf3YntXH8fj0FoszYMYVWLr7gbyQ7k7G0xs5tYE8Yaag/7CRrzatbhvS1QrUjam0GDIqhESSgg4pVaQzI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-52cd6784aa4so420189e87.3 for ; Fri, 21 Jun 2024 01:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960320; x=1719565120; 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=b5ML+0X0uT7iR64bHzEK9VgikLQDAWu+4zg4HA0tL8Y=; b=iDFi0h3SptL2EpsRdL6tn+9TnnxRFOIUJ03pgDfzsAuphU6Ja866hxV4Vlng+zxqFu wp82z1XLk0qNnatvhNMTDLJn06jLSzTdggYsIt55eKMNE9l0ESTzfRIYsoRffHElPYkc qDmcxh1j82irsgNciK13UG+Ii0ukmeTAUuReekF6vUrS3OIZBYbQHjzPlkhbmQQV9Xl1 /BcOxCCm+Ahqa10xkMyjc+qS4HHqEC1hJmjTjaSpzB/UjqKR2FZGOZxjOFnpZhQAn3lJ bXkhKBmcZJJzSmpK1RQxLH4CHtGFbWw7VfR0GtfnrtSboHmMfodEgjPzF2Kxh5FACf/J XCPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960320; x=1719565120; 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=b5ML+0X0uT7iR64bHzEK9VgikLQDAWu+4zg4HA0tL8Y=; b=SyTSb0OXcR8BBE+6cVfyiotSbDCDtaSpkXLVaEDHmWTqEJoCiSU7tIi7uhEd4eVDpY ts9DKsZvnIXAiTCyvb+yNZe8QD3VrzEiK+bkHYHyrSF5bn1+nDR51f8juR/wjX0b2NqS hssPIulXeH7y7Xd0pFmZTdB0ERt2TYg9HQFTZy5YGDQ3OgDG4Xahb7InuKOWDqQBHvFs 67tbRpz0MR4gg10YuBOp+3oaa+kjyeCvQrlNyqcTO2JhZ7yjPZyH9bSJX9n+/x6qCitO iP+Ay7pWhDO3qkoW5pRvUmPbbiVGToeSOg8rt1ZUK4uK4Bor4OBT5b0gYNZ81mU1zB5O 3Kmg== X-Gm-Message-State: AOJu0YxSG6CzJ6wGz/8uTq2CEFKyyvCsmB5yp38KRptdE+yLxeuwGcRt L01BFZTBvbKvEbUHUaWp9fLJ4NW1ZMBUx1uGlqCiDTBmOoSkmZlM4CoXvjMrGm6BJ3fhRCBFa4s = X-Google-Smtp-Source: AGHT+IFe2UqaY8HezcsEooQ3NUXMI/FnSpKNHQ+96d79c2WkO7rlu2Fi6hLyQaLbyXIpZrQ/fGwpIQ== X-Received: by 2002:ac2:5dd9:0:b0:52c:a23b:ef2b with SMTP id 2adb3069b0e04-52ccaa5a381mr3978813e87.66.1718960319546; Fri, 21 Jun 2024 01:58:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:39 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 12/22] ada: Small cleanup in processing of primitive operations Date: Fri, 21 Jun 2024 10:58:08 +0200 Message-ID: <20240621085819.2485987-12-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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 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: Eric Botcazou The processing of primitive operations is now always uniform for tagged and untagged types, but the code contains left-overs from the time where it was specific to tagged types, in particular for the handling of subtypes. gcc/ada/ * einfo.ads (Direct_Primitive_Operations): Mention concurrent types as well as GNAT extensions instead of implementation details. (Primitive_Operations): Document that Direct_Primitive_Operations is also used for concurrent types as a fallback. * einfo-utils.adb (Primitive_Operations): Tweak formatting. * exp_util.ads (Find_Prim_Op): Adjust description. * exp_util.adb (Make_Subtype_From_Expr): In the private case with unknown discriminants, always copy Direct_Primitive_Operations and do not overwrite the Class_Wide_Type of the expression's base type. * sem_ch3.adb (Analyze_Incomplete_Type_Decl): Tweak comment. (Analyze_Subtype_Declaration): Remove older and now dead calls to Set_Direct_Primitive_Operations. Tweak comment. (Build_Derived_Private_Type): Likewise. (Build_Derived_Record_Type): Likewise. (Build_Discriminated_Subtype): Set Direct_Primitive_Operations in all cases instead of just for tagged types. (Complete_Private_Subtype): Likewise. (Derived_Type_Declaration): Tweak comment. * sem_ch4.ads (Try_Object_Operation): Adjust description. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/einfo-utils.adb | 4 +-- gcc/ada/einfo.ads | 34 ++++++++++++----------- gcc/ada/exp_util.adb | 8 ++---- gcc/ada/exp_util.ads | 10 +++---- gcc/ada/sem_ch3.adb | 61 ++++++++++++++++++----------------------- gcc/ada/sem_ch4.ads | 5 ++-- 6 files changed, 55 insertions(+), 67 deletions(-) diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb index 4c86ba1c3b1..c0c79f92e13 100644 --- a/gcc/ada/einfo-utils.adb +++ b/gcc/ada/einfo-utils.adb @@ -2422,8 +2422,8 @@ package body Einfo.Utils is begin if Is_Concurrent_Type (Id) then if Present (Corresponding_Record_Type (Id)) then - return Direct_Primitive_Operations - (Corresponding_Record_Type (Id)); + return + Direct_Primitive_Operations (Corresponding_Record_Type (Id)); -- When expansion is disabled, the corresponding record type is -- absent, but if this is a tagged type with ancestors, or if the diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index dd95ea051c1..de175310ee9 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -932,18 +932,17 @@ package Einfo is -- subtypes. Contains the Digits value specified in the declaration. -- Direct_Primitive_Operations --- Defined in tagged types and subtypes (including synchronized types), --- in tagged private types, and in tagged incomplete types. Moreover, it --- is also defined for untagged types, both when Extensions_Allowed is --- True (-gnatX) to support the extension feature of prefixed calls for --- untagged types, and when Extensions_Allowed is False to get better --- error messages. This field is an element list of entities for --- primitive operations of the type. For incomplete types the list is --- always empty. In order to follow the C++ ABI, entities of primitives --- that come from source must be stored in this list in the order of --- their occurrence in the sources. When expansion is disabled, the --- corresponding record type of a synchronized type is not constructed. --- In that case, such types carry this attribute directly. +-- Defined in concurrent types, tagged record types and subtypes, tagged +-- private types, and tagged incomplete types. Moreover, it is also +-- defined in untagged types, both when GNAT extensions are allowed, to +-- support prefixed calls for untagged types, and when GNAT extensions +-- are not allowed, to give better error messages. Set to a list of +-- entities for primitive operations of the type. For incomplete types +-- the list is always empty. In order to follow the C++ ABI, entities of +-- primitives that come from source must be stored in this list in the +-- order of their occurrence in the sources. When expansion is disabled, +-- the corresponding record type of concurrent types is not constructed; +-- in this case, such types carry this attribute directly. -- Directly_Designated_Type -- Defined in access types. This field points to the type that is @@ -4066,10 +4065,13 @@ package Einfo is -- Primitive_Operations (synthesized) -- Defined in concurrent types, tagged record types and subtypes, tagged --- private types and tagged incomplete types. For concurrent types whose --- Corresponding_Record_Type (CRT) is available, returns the list of --- Direct_Primitive_Operations of its CRT; otherwise returns No_Elist. --- For all the other types returns the Direct_Primitive_Operations. +-- private types, and tagged incomplete types. Moreover, it is also +-- defined in untagged types, both when GNAT extensions are allowed, to +-- support prefixed calls for untagged types, and when GNAT extensions +-- are not allowed, to give better error messages. For concurrent types +-- whose Corresponding_Record_Type (CRT) is available, returns the list +-- of Direct_Primitive_Operations of this CRT. In all the other cases, +-- returns the list of Direct_Primitive_Operations. -- Prival -- Defined in private components of protected types. Refers to the entity diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 7a756af97ea..e86e7037d1f 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -10671,12 +10671,8 @@ package body Exp_Util is Set_Is_Itype (Priv_Subtyp); Set_Associated_Node_For_Itype (Priv_Subtyp, E); - if Is_Tagged_Type (Priv_Subtyp) then - Set_Class_Wide_Type - (Base_Type (Priv_Subtyp), Class_Wide_Type (Unc_Typ)); - Set_Direct_Primitive_Operations (Priv_Subtyp, - Direct_Primitive_Operations (Unc_Typ)); - end if; + Set_Direct_Primitive_Operations + (Priv_Subtyp, Direct_Primitive_Operations (Unc_Typ)); Set_Full_View (Priv_Subtyp, Full_Subtyp); diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads index 16d8e14976c..6460bf02c1b 100644 --- a/gcc/ada/exp_util.ads +++ b/gcc/ada/exp_util.ads @@ -578,11 +578,11 @@ package Exp_Util is -- Find the last initialization call related to object declaration Decl function Find_Prim_Op (T : Entity_Id; Name : Name_Id) return Entity_Id; - -- Find the first primitive operation of a tagged type T with name Name. - -- This function allows the use of a primitive operation which is not - -- directly visible. If T is a class-wide type, then the reference is to an - -- operation of the corresponding root type. It is an error if no primitive - -- operation with the given name is found. + -- Find the first primitive operation of type T with the specified Name, + -- disregarding any visibility considerations. If T is a class-wide type, + -- then examine the primitive operations of its corresponding root type. + -- Raise Program_Error if no primitive operation with the specified Name + -- is found. function Find_Prim_Op (T : Entity_Id; diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index fa13bd23ac7..391727a37f4 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -3554,8 +3554,7 @@ package body Sem_Ch3 is -- Initialize the list of primitive operations to an empty list, -- to cover tagged types as well as untagged types. For untagged -- types this is used either to analyze the call as legal when - -- Core_Extensions_Allowed is True, or to issue a better error message - -- otherwise. + -- GNAT extensions are allowed, or to give better error messages. Set_Direct_Primitive_Operations (T, New_Elmt_List); @@ -5864,8 +5863,6 @@ package body Sem_Ch3 is Set_No_Tagged_Streams_Pragma (Id, No_Tagged_Streams_Pragma (T)); Set_Is_Abstract_Type (Id, Is_Abstract_Type (T)); - Set_Direct_Primitive_Operations - (Id, Direct_Primitive_Operations (T)); Set_Class_Wide_Type (Id, Class_Wide_Type (T)); if Is_Interface (T) then @@ -5895,8 +5892,6 @@ package body Sem_Ch3 is No_Tagged_Streams_Pragma (T)); Set_Is_Abstract_Type (Id, Is_Abstract_Type (T)); Set_Class_Wide_Type (Id, Class_Wide_Type (T)); - Set_Direct_Primitive_Operations (Id, - Direct_Primitive_Operations (T)); end if; -- In general the attributes of the subtype of a private type @@ -6000,16 +5995,6 @@ package body Sem_Ch3 is (Id, No_Tagged_Streams_Pragma (T)); end if; - -- For tagged types, or when prefixed-call syntax is allowed - -- for untagged types, initialize the list of primitive - -- operations to an empty list. - - if Is_Tagged_Type (Id) - or else Core_Extensions_Allowed - then - Set_Direct_Primitive_Operations (Id, New_Elmt_List); - end if; - -- Ada 2005 (AI-412): Decorate an incomplete subtype of an -- incomplete type visible through a limited with clause. @@ -6050,7 +6035,8 @@ package body Sem_Ch3 is -- When prefixed calls are enabled for untagged types, the subtype -- shares the primitive operations of its base type. Do this even - -- when Extensions_Allowed is False to issue better error messages. + -- when GNAT extensions are not allowed, in order to give better + -- error messages. Set_Direct_Primitive_Operations (Id, Direct_Primitive_Operations (Base_Type (T))); @@ -8462,8 +8448,7 @@ package body Sem_Ch3 is -- Initialize the list of primitive operations to an empty list, -- to cover tagged types as well as untagged types. For untagged -- types this is used either to analyze the call as legal when - -- Extensions_Allowed is True, or to issue a better error message - -- otherwise. + -- GNAT extensions are allowed, or to give better error messages. Set_Direct_Primitive_Operations (Derived_Type, New_Elmt_List); @@ -9862,8 +9847,7 @@ package body Sem_Ch3 is -- Initialize the list of primitive operations to an empty list, -- to cover tagged types as well as untagged types. For untagged -- types this is used either to analyze the call as legal when - -- Extensions_Allowed is True, or to issue a better error message - -- otherwise. + -- GNAT extensions are allowed, or to give better error messages. Set_Direct_Primitive_Operations (Derived_Type, New_Elmt_List); @@ -10911,6 +10895,14 @@ package body Sem_Ch3 is Make_Class_Wide_Type (Def_Id); end if; + -- When prefixed calls are enabled for untagged types, the subtype + -- shares the primitive operations of its base type. Do this even + -- when GNAT extensions are not allowed, in order to give better + -- error messages. + + Set_Direct_Primitive_Operations + (Def_Id, Direct_Primitive_Operations (T)); + Set_Stored_Constraint (Def_Id, No_Elist); if Has_Discrs then @@ -10921,17 +10913,11 @@ package body Sem_Ch3 is if Is_Tagged_Type (T) then -- Ada 2005 (AI-251): In case of concurrent types we inherit the - -- concurrent record type (which has the list of primitive - -- operations). + -- concurrent record type. - if Ada_Version >= Ada_2005 - and then Is_Concurrent_Type (T) - then - Set_Corresponding_Record_Type (Def_Id, - Corresponding_Record_Type (T)); - else - Set_Direct_Primitive_Operations (Def_Id, - Direct_Primitive_Operations (T)); + if Ada_Version >= Ada_2005 and then Is_Concurrent_Type (T) then + Set_Corresponding_Record_Type + (Def_Id, Corresponding_Record_Type (T)); end if; Set_Is_Abstract_Type (Def_Id, Is_Abstract_Type (T)); @@ -13083,6 +13069,14 @@ package body Sem_Ch3 is Set_First_Rep_Item (Full, First_Rep_Item (Full_Base)); Set_Depends_On_Private (Full, Has_Private_Component (Full)); + -- When prefixed calls are enabled for untagged types, the subtype + -- shares the primitive operations of its base type. Do this even + -- when GNAT extensions are not allowed, in order to give better + -- error messages. + + Set_Direct_Primitive_Operations + (Full, Direct_Primitive_Operations (Full_Base)); + -- Freeze the private subtype entity if its parent is delayed, and not -- already frozen. We skip this processing if the type is an anonymous -- subtype of a record component, or is the corresponding record of a @@ -13189,8 +13183,6 @@ package body Sem_Ch3 is Set_Is_Tagged_Type (Full); Set_Is_Limited_Record (Full, Is_Limited_Record (Full_Base)); - Set_Direct_Primitive_Operations - (Full, Direct_Primitive_Operations (Full_Base)); Set_No_Tagged_Streams_Pragma (Full, No_Tagged_Streams_Pragma (Full_Base)); @@ -17469,8 +17461,7 @@ package body Sem_Ch3 is -- Initialize the list of primitive operations to an empty list, -- to cover tagged types as well as untagged types. For untagged -- types this is used either to analyze the call as legal when - -- Extensions_Allowed is True, or to issue a better error message - -- otherwise. + -- GNAT extensions are allowed, or to give better error messages. Set_Direct_Primitive_Operations (T, New_Elmt_List); diff --git a/gcc/ada/sem_ch4.ads b/gcc/ada/sem_ch4.ads index 7aae598b32a..dbe0f9a73da 100644 --- a/gcc/ada/sem_ch4.ads +++ b/gcc/ada/sem_ch4.ads @@ -84,9 +84,8 @@ package Sem_Ch4 is -- true then N is an N_Selected_Component node which is part of a call to -- an entry or procedure of a tagged concurrent type and this routine is -- invoked to search for class-wide subprograms conflicting with the target - -- entity. If Allow_Extensions is True, then a prefixed call of a primitive - -- of a non-tagged type is allowed as if Extensions_Allowed returned True. - -- This is used to issue better error messages. + -- entity. If Allow_Extensions is True, then a prefixed call to a primitive + -- of an untagged type is allowed (used to give better error messages). procedure Unresolved_Operator (N : Node_Id); -- Give an error for an unresolved operator From patchwork Fri Jun 21 08:58:09 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: 1950665 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=e79gP6Yf; 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 4W5BMV6KdJz20X8 for ; Fri, 21 Jun 2024 19:07:34 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 07F163896C3F for ; Fri, 21 Jun 2024 09:07:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id 6F5113896C0B for ; Fri, 21 Jun 2024 08:58:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F5113896C0B 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 6F5113896C0B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::336 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960333; cv=none; b=V5lgZRe6Nm9XagDBVtJE5sS+TNwvjVt7znMh72Turg6zvQ7XokzR81QIkUmSmZDVerI1kpJkkhUXqNAYxFMl0EFNp6oasb9K+0JIG3Xt3AZwQkUlhd+JWn2O40HgMGnxKeBFX8UMQLXLqgfWIO409ZaBWQoNjlKnjkEQMfszhnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960333; c=relaxed/simple; bh=CO0tVJusZNhFZV0eLPRkj/2xYCDzblriqxyaHLKN2W0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=p+t/XASobhAfJGKOMxLSt5UpL2XaFWxFLMH64EUncRQInXWryGa26Rk8/Y6mKDcqUYX+xM+Az/enDiaAqIH04r9gAenVSKrmY+bB+9ohrw2uNLO9gFJ9o1UyLp3GUTF/yy4FU57pSj8bzPlyW19HG1Q6DbaKF6IYPg7lkP2pdKw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42249a4f9e4so13149635e9.2 for ; Fri, 21 Jun 2024 01:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960320; x=1719565120; 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=i6JwoDIGKaodKnTJi3Zv70IzGWcXZpBaHy2MlqVp8wE=; b=e79gP6YfELCE5+usOKp9IcTnAW9M46rOgRAXzzjNonhAkp81M5PD8C9G+C6om6AvJM bwbkhF3LPmrAxfriJrRhw2pJuTFrHiH4OPZ68Q4MAjBHK1qA2ufpHPLvMiM5C1ffTNg3 Wvv47RJgcDtRppSgqVDYhm3yBE5jN032ZxzIJ8rSCMu+U+q0X/yMvHGyCLR6oZC8ByJA Lo1LVtScuv/aNSflZZdc2fucG9wfwSNafz1qChd96hox12o0CNvSMKwN1YJF0oNuzLsX rPCzTFmJLtq5HYVzXJu+OAhPKOEdLfKFG0TTIBUpI0ELA9dx1arBKx+RWaBs40JAOvtD ar3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960320; x=1719565120; 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=i6JwoDIGKaodKnTJi3Zv70IzGWcXZpBaHy2MlqVp8wE=; b=WA2fgtGtQDMcJdH08k/7/GY+eXwp0+bEjf1o1x7HLY2wNVhRKseqOBluX7fYJmiRoV DpVr7xo79DXo7l/acFtUi4kfjmO7wdJ2owlPriJTLChPeiokWOIauZpDsOFt0vUHxQ1w KF6V0So1w0uN7jOLxQ8SZisxsmi2LXSOfd37HtkfV0LaItIDhbusMT7NM28CiqT6yzhF wwGs0GL8+tDQ563TK1sPdvUUT/4K6gaGxmW0ZZmVG4CZN4OubwadspJbY9yr+wWf+KOL PbrhWjHcK9uwIeXlhCMkq97BjRQqgKCoP+BLzhlGsAELorUAK2koM3mHuIQR6WQmINzW wZiw== X-Gm-Message-State: AOJu0YziSR89fsxN0iaELUapaCbd/KIKvJ0ds6EdYJPuz5+7eQH4h5j0 rfunDa3Q3QUQAbgqrU31/ys9TqF0bntaQtw6m4CvleMU7tatV58uZy1zOvDQ6hjz46uBFha0K1I = X-Google-Smtp-Source: AGHT+IF9wJfJ9iHdGv0bnlpUq8SqXO3qVVl4bNkkt1LOhczXz6WzkB2PdE0lkZBffFtO/LaNC7qUwQ== X-Received: by 2002:a05:600c:4652:b0:422:615f:649e with SMTP id 5b1f17b1804b1-42475298ba0mr61838605e9.27.1718960320201; Fri, 21 Jun 2024 01:58:40 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:39 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: =?utf-8?q?Marc_Poulhi=C3=A8s?= Subject: [COMMITTED 13/22] ada: Change error message on invalid RTS path Date: Fri, 21 Jun 2024 10:58:09 +0200 Message-ID: <20240621085819.2485987-13-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 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 Include the invalid path in the error message. gcc/ada/ * make.adb (Scan_Make_Arg): Adjust error message. * gnatls.adb (Search_RTS): Likewise. * switch-b.adb (Scan_Debug_Switches): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gnatls.adb | 11 ++++++++--- gcc/ada/make.adb | 14 +++++++++----- gcc/ada/switch-b.adb | 15 ++++++++++----- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/gcc/ada/gnatls.adb b/gcc/ada/gnatls.adb index 2c26001743a..c52c1aea9c3 100644 --- a/gcc/ada/gnatls.adb +++ b/gcc/ada/gnatls.adb @@ -1673,9 +1673,13 @@ procedure Gnatls is end if; if Lib_Path /= null then - Osint.Fail ("RTS path not valid: missing adainclude directory"); + Osint.Fail + ("RTS path """ & Name + & """ not valid: missing adainclude directory"); elsif Src_Path /= null then - Osint.Fail ("RTS path not valid: missing adalib directory"); + Osint.Fail + ("RTS path """ & Name + & """ not valid: missing adalib directory"); end if; -- Try to find the RTS on the project path. First setup the project path @@ -1710,7 +1714,8 @@ procedure Gnatls is end if; Osint.Fail - ("RTS path not valid: missing adainclude and adalib directories"); + ("RTS path """ & Name + & """ not valid: missing adainclude and adalib directories"); end Search_RTS; ------------------- diff --git a/gcc/ada/make.adb b/gcc/ada/make.adb index 24b2d099bfe..cef24341135 100644 --- a/gcc/ada/make.adb +++ b/gcc/ada/make.adb @@ -4478,13 +4478,14 @@ package body Make is RTS_Switch := True; declare + RTS_Arg_Path : constant String := Argv (7 .. Argv'Last); Src_Path_Name : constant String_Ptr := Get_RTS_Search_Dir - (Argv (7 .. Argv'Last), Include); + (RTS_Arg_Path, Include); Lib_Path_Name : constant String_Ptr := Get_RTS_Search_Dir - (Argv (7 .. Argv'Last), Objects); + (RTS_Arg_Path, Objects); begin if Src_Path_Name /= null @@ -4501,16 +4502,19 @@ package body Make is and then Lib_Path_Name = null then Make_Failed - ("RTS path not valid: missing adainclude and adalib " + ("RTS path """ & RTS_Arg_Path + & """ not valid: missing adainclude and adalib " & "directories"); elsif Src_Path_Name = null then Make_Failed - ("RTS path not valid: missing adainclude directory"); + ("RTS path """ & RTS_Arg_Path + & """ not valid: missing adainclude directory"); else pragma Assert (Lib_Path_Name = null); Make_Failed - ("RTS path not valid: missing adalib directory"); + ("RTS path """ & RTS_Arg_Path + & """ not valid: missing adalib directory"); end if; end; end if; diff --git a/gcc/ada/switch-b.adb b/gcc/ada/switch-b.adb index 8d8dc58937c..2de516dba56 100644 --- a/gcc/ada/switch-b.adb +++ b/gcc/ada/switch-b.adb @@ -672,13 +672,15 @@ package body Switch.B is Opt.RTS_Switch := True; declare + RTS_Arg_Path : constant String := + Switch_Chars (Ptr + 1 .. Max); Src_Path_Name : constant String_Ptr := Get_RTS_Search_Dir - (Switch_Chars (Ptr + 1 .. Max), + (RTS_Arg_Path, Include); Lib_Path_Name : constant String_Ptr := Get_RTS_Search_Dir - (Switch_Chars (Ptr + 1 .. Max), + (RTS_Arg_Path, Objects); begin @@ -698,14 +700,17 @@ package body Switch.B is and then Lib_Path_Name = null then Osint.Fail - ("RTS path not valid: missing adainclude and " + ("RTS path """ & RTS_Arg_Path + & """ not valid: missing adainclude and " & "adalib directories"); elsif Src_Path_Name = null then Osint.Fail - ("RTS path not valid: missing adainclude directory"); + ("RTS path """ & RTS_Arg_Path + & """ not valid: missing adainclude directory"); else pragma Assert (Lib_Path_Name = null); Osint.Fail - ("RTS path not valid: missing adalib directory"); + ("RTS path """ & RTS_Arg_Path + & """ not valid: missing adalib directory"); end if; end; end if; From patchwork Fri Jun 21 08:58:10 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: 1950650 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=KqnlKrSG; 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 4W5BHQ0L7jz1ydW for ; Fri, 21 Jun 2024 19:04:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 589713896C2C for ; Fri, 21 Jun 2024 09:04:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id 3F0D23896C1F for ; Fri, 21 Jun 2024 08:58:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F0D23896C1F 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 3F0D23896C1F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960323; cv=none; b=sU26aqGSx5/nBkBKpKr8AIbyQVtvJkodBTMGGLeNHmfz3dXB5MEknfNsC3q1gz6FR7iZIp9TIyKk/pwzWffnADdn4AJD+skGlrF3kZxp3gsd8RgydxCuXO3gKClGIumPH13gXBkm2L5hvCW3APvlxRKq1HvEf4ozPSw4PYyhTrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960323; c=relaxed/simple; bh=o/JjLgJ934d58CeAq6Y+5JWkOYcPUE1P23YZ+WiRAFM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=L54hIW1hNntmCcYosp9B271OhLK6Hp9ExJJMmY1vMVG4yydaEfNeba5Bk1HrcEMLwlbD5Tbkqy2uEQBATk4YUoXvtJmsM1+kYdZpTO/mhk2oa4Yb4m9m5O3vTKJLmu9I+mIx06CHo0ss5aohnVRbA0+z7YnPPMptckC03k0nYRc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-42108856c33so17233665e9.1 for ; Fri, 21 Jun 2024 01:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960321; x=1719565121; 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=cZKPS+17C7kFnfadiScBJABtQ1xYPAikZmNk9Bbp9xo=; b=KqnlKrSGoFH4907nxTkfnkJM2LbDYBM9UroatWZfDH+3BKczeRSUhQ2DvtUYjNl2lO rBmJrzW79IUGizYQ5eRAXMj1sovUSjSYKJksF9czBQ21bx4bt+/6YprotY0kPe/Z2JIG p5FbnimPMismEQoaUDbuEp6+WZcoe0uJlAqgOY4yF300AzpUL3yoY7J1UbgbW2TFKpdW 62+Sm1NLSsxQvPO/eMgp9Va9zi7GK2UJ368SToY+JDGF7SsZoJP1FEMZpbc840p/7ejU CprpajkTX9W02tVFcHxnBEcOm789pvC9ngKWHBt5nV7r9ahyJrQ95fFAMt2SJ4JLYTpw c+GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960321; x=1719565121; 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=cZKPS+17C7kFnfadiScBJABtQ1xYPAikZmNk9Bbp9xo=; b=Ff2av6IijIGODZs9zmNzFx3HJg356Enj9lxCvb/lr2JLGaC19Lc2cLZdjGiua9AWuj q/MHkvzK9le7SGbVpCN/wDfsSKdF3MxHEOqIWKFpwP1y0KZ2UaVPswH3YisrJs+4vXL3 75dwj3dQLJcqoqiouZpNggp0ZATIgm8BUx7n/mb6XDGK4LKVLG4f2ojOzHRd80bfxEoj b1lGcKe5WlrRLlYW2e1NZYlEtjGKHXDkDUIuB0OaFN4Mu3huHxYXcT2ahLUp6+Tp4kxo evqUEilxasJa+4nfd4RjHwAKDP7aSWwmZqCnpZdvMCNKuHqoNwjC42GwgCrw4JaS3WKN nmUA== X-Gm-Message-State: AOJu0YwjpT6pkjWmpNCytJn6PUM2FDX1qdTfq8usFuv3lR0CpPuPRyuu TBCcn6cVne3uVN+9WhxNGHwkJHX0AqbzyvR0cdgZ/zEHjC+WuATQ+5X7ZU2i7mdy5ZVJtOHQ1rQ = X-Google-Smtp-Source: AGHT+IEafiixBNXSUlmRk86+uzEhIjdI+4gMJ6COm1RMyTANdptEgYS8n5467MWEVtEmqeTMVayL6g== X-Received: by 2002:a05:600c:364d:b0:424:84fb:9fd2 with SMTP id 5b1f17b1804b1-42484fba09amr1285455e9.19.1718960320961; Fri, 21 Jun 2024 01:58:40 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:40 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED 14/22] ada: Crash when using user defined string literals Date: Fri, 21 Jun 2024 10:58:10 +0200 Message-ID: <20240621085819.2485987-14-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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 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: Javier Miranda When a non-overridable aspect is explicitly specified for a non-tagged derived type, the compiler blows up processing an object declaration of an object of such type. gcc/ada/ * sem_ch13.adb (Analyze_One_Aspect): Fix code locating the entity of the parent type. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch13.adb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index a86f774018a..90376f818a3 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -4801,8 +4801,14 @@ package body Sem_Ch13 is and then Nkind (Type_Definition (N)) = N_Derived_Type_Definition and then not In_Instance_Body then + -- In order to locate the parent type we must go first to its + -- base type because the frontend introduces an implicit base + -- type even if there is no constraint attached to it, since + -- this is closer to the Ada semantics. + declare - Parent_Type : constant Entity_Id := Etype (E); + Parent_Type : constant Entity_Id := + Etype (Base_Type (E)); Inherited_Aspect : constant Node_Id := Find_Aspect (Parent_Type, A_Id); begin From patchwork Fri Jun 21 08:58:11 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: 1950654 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=d+PcvfeM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4W5BJM3GKTz1ydW for ; Fri, 21 Jun 2024 19:04:51 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B7F9E3896C2A for ; Fri, 21 Jun 2024 09:04:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by sourceware.org (Postfix) with ESMTPS id 56D423898392 for ; Fri, 21 Jun 2024 08:58:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 56D423898392 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 56D423898392 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960328; cv=none; b=YTLvrex0iN64akaFvpRXgXP+bYs8t13FQLobs//Q2gAFmQv2gWmyuB3VX5fymZVIoLFpyZjoQFNguGiMk0MzJ1xQJOL2o1M3JepZYj5+zWvXK/LFdpRmwgZcZUxtp2F4MrWOLN9iavPEdJqGrzY3/9TyHi5ix6GBvmyYzaOiEzU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960328; c=relaxed/simple; bh=5j0Ez1PZeh1u5wnybs/91Uf5YqShxf+7+35LXwD/5g4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=VKn3xCfeBLdVwAvYTbm+3xt0u2GJsZVpCxfDa/C7Hk+uR/2BjzAZoImdewkAQXobFiH9vH2UxMxJ1jUQuPrQ7EX0ARDTBlNd3l+Hw2qfob7Bnhkj/tLP1GYHqrNo5mFm4BcyxrPEtp38vTh+Giry+RbIqHHW+XmJCGlRgPYcsXg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-52ccc40e72eso1381061e87.3 for ; Fri, 21 Jun 2024 01:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960322; x=1719565122; 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=lQBZUcxBTMu4e5kytvnjvv9Jb3a0hcQNrk3RP7I+Vlc=; b=d+PcvfeMUM5tb9T36tK31yMzTJx7KnBDmlqEisz5m3aQ8Z2wPeMVoJLwpSfiZfmN2l Nlz71qvr66AbvTDGowH6u9f4dZHS8IKuGnjJGhBJNv1Kulxw+nG1yXYGRVxrz/V1hdgn ma1AcXrAtwCTldHIpRK/JNcRjFc/I/wK86HcrU8nROqXVZBI6FdYplZ61C9YwJIXcKiB 2E2XhcKtLoujp57mfmVGDlIkWXhHqzPA62YIlOVARWopdoCDXsv/+pFDPTtOz8A/tfzc 8CV7f4wIH6PyX4V1JpiPj1yHMF14XLjDMyresVmrrTn+AW/Q704hD2Kx4cr7ztiHrJLC 6jfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960322; x=1719565122; 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=lQBZUcxBTMu4e5kytvnjvv9Jb3a0hcQNrk3RP7I+Vlc=; b=SQYV0I+S8OAjYWtrdKno5BZ8e2BIL3w9CoHPbvZqHEw3Zn9oeE5CiwpYUQXpbxYdPq zWon5tHiWU5CbVOTxou8Y6hFao573fx6niGliW7+slYr/L9N705GUYv3tnFt47V2arVc LUiH3Fb7Vb8oALC47/dlZh45dSJyO9EgSukpAX4tu11VicTCnH3G6Vd8glzLOHNZnvIx Y9y5NyGDC0IYnLLa5CXi3ExLbqMFoerLIVGyiIrandO0qR95LxsvMEvrodAtUItAvhhZ 6hIMMwYb4mGTnJCuVMmw/7E09ZyHvzRJztwZYWuGtp078g9yWTtoos86nrh3BqBjShCR PX9g== X-Gm-Message-State: AOJu0Ywd40Rli2z5K82hAKouPY/xle5+cVWZSSvW5KdZGXWOajyMxQrQ pw9E5OaUIhPRVPF1+hGLjxxi4Va+5kQmDClhhaA7YxgZv5ApQCAk8IewTr/+a552nlIXlUimKKs = X-Google-Smtp-Source: AGHT+IEAiM7S+nnY3d9ZaliX9BH40mC8WdgnDNa3jgd4PDQoCAwONSitdUezQQHNRjLVWYxq+zXJFQ== X-Received: by 2002:a05:6512:3195:b0:52c:898b:a180 with SMTP id 2adb3069b0e04-52ccaa2c7c9mr7181413e87.12.1718960321743; Fri, 21 Jun 2024 01:58:41 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:41 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 15/22] ada: Fix crash in GNATbind during error reporting Date: Fri, 21 Jun 2024 10:58:11 +0200 Message-ID: <20240621085819.2485987-15-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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 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: Eric Botcazou This is the minimal fix to avoid the crash. gcc/ada/ * bcheck.adb (Check_Consistency_Of_Sdep): Guard against path to ALI file not found. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/bcheck.adb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gcc/ada/bcheck.adb b/gcc/ada/bcheck.adb index 56a417cc517..64a6734a330 100644 --- a/gcc/ada/bcheck.adb +++ b/gcc/ada/bcheck.adb @@ -162,10 +162,14 @@ package body Bcheck is end if; else - ALI_Path_Id := - Osint.Full_Lib_File_Name (A.Afile); + ALI_Path_Id := Osint.Full_Lib_File_Name (A.Afile); + + -- Guard against Find_File not finding (again) the file because + -- Primary_Directory has been clobbered in between. - if Osint.Is_Readonly_Library (ALI_Path_Id) then + if Present (ALI_Path_Id) + and then Osint.Is_Readonly_Library (ALI_Path_Id) + then if Tolerate_Consistency_Errors then Error_Msg ("?{ should be recompiled"); Error_Msg_File_1 := ALI_Path_Id; From patchwork Fri Jun 21 08:58:12 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: 1950649 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=WrNKFr+5; 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 4W5BH01jG7z20X8 for ; Fri, 21 Jun 2024 19:03:40 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 768A83898392 for ; Fri, 21 Jun 2024 09:03:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by sourceware.org (Postfix) with ESMTPS id 28280389838B for ; Fri, 21 Jun 2024 08:58:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 28280389838B 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 28280389838B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::133 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960329; cv=none; b=NaOSIUJbwl6DwO58t7cbPhW1m44PeuTTrr1/2Y3O+DpC2I6YycQPbnU0MBMZchc3lDxWALsg+WpVi2BV+GiajB88765ZRL+wLRH2xxxGWGnk6kbBYXwX2VlyZo6RzVW+2tKYZu+u7BIR3s3ENi3Xh9+gE0zH0LbnIgUj40E7wvU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960329; c=relaxed/simple; bh=Kkyrxm65xphH550b/XE/Bcqe05C9AZahpE/6kPrUL3o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ZPxV400zm3fPYL1J2eP7QacGqmsqt24XdHejRXClZ/uUnGseWGtfmSGMApVZ+L/fO0g9fh3LCYFNYQGyKuz/aW6TofIs4aDOO+Vo5LiXu/EyO1Dreb/eFfFsol92HmvExNCRkq586fwp44JTqPMEzLRR5jFAhZYQr1foNXjxnmU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-52c4b92c09bso2448383e87.1 for ; Fri, 21 Jun 2024 01:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960322; x=1719565122; 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=y2oRvDAM63phqTFFjP9A2JS01m99E8f3LMzNLJ7Eugg=; b=WrNKFr+5A7feIhH9msft45bm3RB/RNniO3v6X8QW8FHZkSUEuqIgR/sPwYIoCyw0wN 82ZSv5uEe/URoD+bpkcBndaMsWBz9/cnO27LvZ9H4WTct+YRc/QQ/puubPBlFODOG0V6 ytZXk2RkSDQfYG4P1rnhDy+EP8wfgb1hho/b+kmw16LkSlQR3DFoN9IpY2wXFlh35mJG rwf4H72SRRxhJRC1Z7vtvG5gS8mh1JjhE6ssLSl54m9XlXiCBJldUHcHk7A3gUAoFato ENeDBYbNW2B1PEdOCafgfv9R0Mhxe1r9w68blqTh7cRfiDqKWOx73UuwTp5FW8HKz7Y4 4bmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960322; x=1719565122; 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=y2oRvDAM63phqTFFjP9A2JS01m99E8f3LMzNLJ7Eugg=; b=YBz71bSTZuKucnarkSqGqGx3jbcoj6rjXIIyRU/c+XfG5JFlS2d9x9Z6Mgqui7lzYD 1TsqHwwPSULDzMFOWRIPnuZ2OQmwi4KAkYNqKfokzvqngq5H5FyYpibVxf+hVvnFcXoo ui8wHcgRkXL52scI86WSkyFa1/6s0tM+8BeRGHHKCvF7oM4jnPuHJaUZbdsS5nyHi4Lv MQ/Giz/YY0ZCWygqRGLVw1ozw9TujRgmX/ggmb3JWorOouSJNLu7V23bT+hOfzmJBdiE TJsfzf1DtlRrCEcL7jr+m1+20igsNcBjdmNw4GMvTdoedkoPUWMzp79IMuqBa5H/VXCB 77/w== X-Gm-Message-State: AOJu0YzpifairraNer1Mh+7f6SeoC9jFKCThnuJzmSt4m8EVZa5t7aLJ M+Hy8AhB8oNKQUTza3RuGgI07HZfjA5faQvquYNBecp7wJ0YB/C4sjsgIBHNqCxS8zxe5t9++yM = X-Google-Smtp-Source: AGHT+IGASUS/ssBzVQ17r5HRpzLBdOVVs0L4dhi2PPlgF4FNjeG0Jrq1YxEcyhIrqhm78DCC/mexog== X-Received: by 2002:a05:6512:3988:b0:52c:cb8d:6374 with SMTP id 2adb3069b0e04-52ccb8d6456mr6884408e87.11.1718960322623; Fri, 21 Jun 2024 01:58:42 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:42 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Ronan Desplanques Subject: [COMMITTED 16/22] ada: Apply fixes to Examine_Array_Bounds Date: Fri, 21 Jun 2024 10:58:12 +0200 Message-ID: <20240621085819.2485987-16-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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 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: Ronan Desplanques gcc/ada/ * sem_util.adb (Examine_Array_Bounds): Add missing return statements. Fix criterion for a string literal being empty. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 4cdac9443e6..4dde5f3964e 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -8157,13 +8157,15 @@ package body Sem_Util is if not Is_Constrained (Typ) then All_Static := False; Has_Empty := False; + return; -- A string literal has static bounds, and is not empty as long as it -- contains at least one character. elsif Ekind (Typ) = E_String_Literal_Subtype then All_Static := True; - Has_Empty := String_Literal_Length (Typ) > 0; + Has_Empty := String_Literal_Length (Typ) = 0; + return; end if; -- Assume that all bounds are static and not empty From patchwork Fri Jun 21 08:58:13 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: 1950661 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=AGQwiWp4; 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 4W5BKz2wmFz20X6 for ; Fri, 21 Jun 2024 19:06:15 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A4B593896C31 for ; Fri, 21 Jun 2024 09:06:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id B6D013896C3D for ; Fri, 21 Jun 2024 08:58:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B6D013896C3D 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 B6D013896C3D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::332 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960329; cv=none; b=XzAcCYkqgZ/mOrCdEW54OOU35Jc+rmCdQqBrQ6tMzVvF1ul2yJqnsPRWxd0gdiy7i76PRJBTy4j0orIurIemQKGCdjhsTc0lFt0l6UDIg35C/PIcmxeK1whFNRPqGubVfZdFLHsDWiUWUUIxbffwuEaTIhCGy53pRuIWA4us9Yk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960329; c=relaxed/simple; bh=9oXwfncaO7R/+b14lPMxOwbHF5oKwCtg+aBibYpDg1U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=RfGMf9kME6WuFgT4gcAKFpldlaT5G97GJtxhm+RSnOV/rU96HE6RfOQW2JbH0pSIy0oZRnDT4YvOpqVnA1SHHfADMk3O4NsGrW39Yg8YkGmhFGz3p5yxklEzROib6w6ttvkr4112jkZ5rL2GA9lvBHPryHkdU0WpXxGkwaVSW04= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-421cd1e5f93so13279615e9.0 for ; Fri, 21 Jun 2024 01:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960323; x=1719565123; 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=G5iZ81c100gFYwKW8ScbpeWRklkh6H+HPjOWMT94iM8=; b=AGQwiWp4g5mckbJw/cXnjjJ/fNoJ+hd4bzG9pofOQXQqyOa+Ii2VsezRWKsf4lmtfx yZDbJx8CYi4etCymR9waDhVAEvwp131OioHqtJiPpT7XPFW1oPdWijxwAEmryTWWFDaM sFijUzxHVmXHvAnw/zCz6ojqNrKLQTZ09ZJoaCm8ApL+8ERGz9O5ObVGOsgGDmscwxqZ XJe691x8kGe8fSEOAlJLGbfIVzZt+LlgqBt0jsb0dlfPZq9IniDqcgmggi7wALoXIU7O FsBDf+6D0R7/0VHJHyqCCZ2jLhV3SxgB6kbCev8jao2yNFBVJvLPNTesHnvCZCuE93b6 KJSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960323; x=1719565123; 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=G5iZ81c100gFYwKW8ScbpeWRklkh6H+HPjOWMT94iM8=; b=MQ54HLjQRu2EJrzG0lFIZmVfltjeVBH6sk0eEbiLTV3vc/YzrsjtmQXZzkSQ23pnGh us2MhtqE41p4j0olEHOIYfJUKe53oXKmeCQt3LWZkgM2wFrza/NY92a2d7UIoVLSvTa4 WJW+NzmKw77dlnBSVJwa2VmTyVw81bGjnD1OJ6YpKZCINX6FLfQQNFHFxMAVSNdU9EwI mNPhMk+ybTcdKER01Aorvk/HD9NOEAARlC/k8mHy8aZ4MpNk6ZU4nFQO0nLBk+i0OFtC U+malxvbxpLQK8jQbdxgkO07C1Kn3vuUNuOBCV6X/F4oAbQwcWiQNAC07TXUH/43mv1N Uw3A== X-Gm-Message-State: AOJu0YwIENw6KOO6vBfi7esK/NLfM9DFuXSH+BSoLfFJznnQBKgcaOpg CEsuq+MmvuTx1DfLNIUSbd5E3ovvR6LlHuINygE/sFWlZzoRONwjWabmepRTKpoR0VUMr67s9YE = X-Google-Smtp-Source: AGHT+IEZLghuXlzNlU6nGj0dkamBftID9Ab+q+L9cz6wK9jLiX+b2p5QHlPN3gJfuDCRI41IItqEug== X-Received: by 2002:a05:600c:1615:b0:420:2cbe:7efd with SMTP id 5b1f17b1804b1-42475298bd5mr63021345e9.31.1718960323496; Fri, 21 Jun 2024 01:58:43 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:43 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED 17/22] ada: Reject ambiguous function calls in interpolated string expressions Date: Fri, 21 Jun 2024 10:58:13 +0200 Message-ID: <20240621085819.2485987-17-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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 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: Javier Miranda When the interpolated expression is a call to an ambiguous call the frontend does not reject it; erroneously accepts the call and generates code that calls to one of them. gcc/ada/ * sem_ch2.adb (Analyze_Interpolated_String_Literal): Reject ambiguous function calls. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch2.adb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gcc/ada/sem_ch2.adb b/gcc/ada/sem_ch2.adb index aae9990eb4d..08cc75c9104 100644 --- a/gcc/ada/sem_ch2.adb +++ b/gcc/ada/sem_ch2.adb @@ -25,7 +25,9 @@ with Atree; use Atree; with Einfo; use Einfo; +with Einfo.Entities; use Einfo.Entities; with Einfo.Utils; use Einfo.Utils; +with Errout; use Errout; with Ghost; use Ghost; with Mutably_Tagged; use Mutably_Tagged; with Namet; use Namet; @@ -141,6 +143,14 @@ package body Sem_Ch2 is Str_Elem := First (Expressions (N)); while Present (Str_Elem) loop Analyze (Str_Elem); + + if Nkind (Str_Elem) = N_Identifier + and then Ekind (Entity (Str_Elem)) = E_Function + and then Is_Overloaded (Str_Elem) + then + Error_Msg_NE ("ambiguous call to&", Str_Elem, Entity (Str_Elem)); + end if; + Next (Str_Elem); end loop; end Analyze_Interpolated_String_Literal; From patchwork Fri Jun 21 08:58:14 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: 1950647 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=UFT9w1h3; 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 4W5BFs0y2bz1ydW for ; Fri, 21 Jun 2024 19:02:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 66CE13899426 for ; Fri, 21 Jun 2024 09:02:39 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 887D03896C15 for ; Fri, 21 Jun 2024 08:58:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 887D03896C15 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 887D03896C15 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::335 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960329; cv=none; b=tYdfHL9O6gBV6rjgpLHsXp/WHMV3Oyqx/6/o7KvOf0VN8Pe0tUgpvE9mNLPhoRtxGUZ4JiDj9hv8ODtZl4jT88vQw7LtHG2A6+gqgZIgJgS+diFdpcvBiP0qQqSQc+V/Nhl6MFdyEJTuUOh4qqyJ0ueuKM/AswLVXv9I50whh5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960329; c=relaxed/simple; bh=8NgXWi3SWLESARQ6BRBX9xcuCBs+ICWz5PKVzbr8FZQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=YliX4h/AinmzbNXvZiptaZI5KTcwcC0CDiPyXdSfTT02EIcW2JR1vOodzr05sve6CfjYhcpyqNK5VTQKkbF79Cow/LWKzZnqaI3E+BxMk2BpGFDLd4UZoEQqC4l3/6pxhHHhz0ATsvVLljx4NM4QUBe3UjVQhq6vu1ijEUZZ3Rc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-424720e73e1so15703885e9.1 for ; Fri, 21 Jun 2024 01:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960324; x=1719565124; 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=XAUslvpKlPGaKM0BOZd05zlQSCW3D+h/zuR91ePyiTY=; b=UFT9w1h3vzY7OEJKmxP3SxpEucA1Nvn9d56AQ9eSCOSyu3xuNG8PSxKuXekHmmQwzM MaiLfcP0BO5+gZGR45ekJr7PHvtqcSonrl7AVRvP5QRGiSsv7w3HCPexwlhO3JFuxH8/ erR3QR4So+wMxUxDtE5Y+FWnmoPd3o6UDW7BjgpPtsd8ztQyUD3Vb1brgQr6xmNPHxLi dhW5Z16osFVF5rah8BtDcQTUk63xChsHj9VXtB2eVQ4CgLFfdKRJ4XaxnKCyIuH6Kn7I OCVmtgVvV6t2PfhWbl7vWp2ZGw/QMvc86o2GjaNpahqCrjvHRZHYkoZgyWcHjyJ+rtHs +WsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960324; x=1719565124; 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=XAUslvpKlPGaKM0BOZd05zlQSCW3D+h/zuR91ePyiTY=; b=AsCcIDTUymVZP5BXFpYXBhxlfUECrIXDzlTvZmIJowQzPWbSSUDhdY4/r8vJZwtMUl t/CKPhnq+XRj0YiaQZqF57wAXz+jMq4nwk/RIk/LPOnTUqgigW99fGQVMFYwC17O26Kb ZOS6/K4oZLKJivVOVEe6DDt2fBBLpgkWom+F+L5kjL1xklwE8SeAecaeI72i8I6Qfz2P HYeqkkjbp7Hm1WVZkl/BzSH2FSMRRaob7rt2uX11urGN0d1YGt7cRH0K/KQsIRRxtJVK l6KNKlFa8L334YZvHptXeD1hivZoRr8LBGpnAm3LtvKvp+yI9KVRlzezVSy+nE1Qc5l7 XoHQ== X-Gm-Message-State: AOJu0YzM7aV5C62ebcy3rXcQV36/sWvbPV9tK2nrHvzkA5iyt8RN5FjM 2lHAdaOz6z1Jc/rcItV61b04TtnSVFUUD0M4xkmcarJ1oAxSmEhENdWsPkmiD7v8LiaQG+g/ofM = X-Google-Smtp-Source: AGHT+IHdGiko7EWG8k3U6gKQrEpBfKf9H/efRS19cHc8T/iLFxLqcZ6SDDK1bmEp2Vj9s/I61V5ZFQ== X-Received: by 2002:a05:600c:310a:b0:41a:b30e:42a3 with SMTP id 5b1f17b1804b1-4247529bd84mr54345515e9.37.1718960324309; Fri, 21 Jun 2024 01:58:44 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:43 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 18/22] ada: Implement fast modulo reduction for nonbinary modular multiplication Date: Fri, 21 Jun 2024 10:58:14 +0200 Message-ID: <20240621085819.2485987-18-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-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 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: Eric Botcazou This implements modulo reduction for nonbinary modular multiplication with small moduli by means of the standard division-free algorithm also used in the optimizer, but with fewer constraints and therefore better results. For the sake of consistency, it is also used for the 'Mod attribute of the same modular types and, more generally, for the Mod (and Rem) operators of unsigned types if the second operand is static and not a power of two. gcc/ada/ * gcc-interface/gigi.h (fast_modulo_reduction): Declare. * gcc-interface/trans.cc (gnat_to_gnu) : In the unsigned case, call fast_modulo_reduction for {FLOOR,TRUNC}_MOD_EXPR if the RHS is a constant and not a power of two, and the precision is not larger than the word size. * gcc-interface/utils2.cc: Include expmed.h. (fast_modulo_reduction): New function. (nonbinary_modular_operation): Call fast_modulo_reduction for the multiplication if the precision is not larger than the word size. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/gigi.h | 5 ++ gcc/ada/gcc-interface/trans.cc | 17 ++++++ gcc/ada/gcc-interface/utils2.cc | 102 +++++++++++++++++++++++++++++++- 3 files changed, 121 insertions(+), 3 deletions(-) diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index 6ed74d6879e..40f3f0d3d13 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -1040,6 +1040,11 @@ extern bool simple_constant_p (Entity_Id gnat_entity); /* Return the size of TYPE, which must be a positive power of 2. */ extern unsigned int resolve_atomic_size (tree type); +/* Try to compute the reduction of OP modulo MODULUS in PRECISION bits with a + division-free algorithm. Return NULL_TREE if this is not easily doable. */ +extern tree fast_modulo_reduction (tree op, tree modulus, + unsigned int precision); + #ifdef __cplusplus extern "C" { #endif diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index e68fb3fd776..7c5282602b2 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -7317,6 +7317,23 @@ gnat_to_gnu (Node_Id gnat_node) gnu_result = build_binary_op_trapv (code, gnu_type, gnu_lhs, gnu_rhs, gnat_node); + + /* For an unsigned modulo operation with nonbinary constant modulus, + we first try to do a reduction by means of a (multiplier, shifter) + pair in the needed precision up to the word size. But not when + optimizing for size, because it will be longer than a div+mul+sub + sequence. */ + else if (!optimize_size + && (code == FLOOR_MOD_EXPR || code == TRUNC_MOD_EXPR) + && TYPE_UNSIGNED (gnu_type) + && TYPE_PRECISION (gnu_type) <= BITS_PER_WORD + && TREE_CODE (gnu_rhs) == INTEGER_CST + && !integer_pow2p (gnu_rhs) + && (gnu_expr + = fast_modulo_reduction (gnu_lhs, gnu_rhs, + TYPE_PRECISION (gnu_type)))) + gnu_result = gnu_expr; + else { /* Some operations, e.g. comparisons of arrays, generate complex diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc index 70271cf2836..a37eccc4cfb 100644 --- a/gcc/ada/gcc-interface/utils2.cc +++ b/gcc/ada/gcc-interface/utils2.cc @@ -33,6 +33,7 @@ #include "tree.h" #include "inchash.h" #include "builtins.h" +#include "expmed.h" #include "fold-const.h" #include "stor-layout.h" #include "stringpool.h" @@ -534,6 +535,91 @@ compare_fat_pointers (location_t loc, tree result_type, tree p1, tree p2) p1_array_is_null, same_bounds)); } +/* Try to compute the reduction of OP modulo MODULUS in PRECISION bits with a + division-free algorithm. Return NULL_TREE if this is not easily doable. */ + +tree +fast_modulo_reduction (tree op, tree modulus, unsigned int precision) +{ + const tree type = TREE_TYPE (op); + const unsigned int type_precision = TYPE_PRECISION (type); + + /* The implementation is host-dependent for the time being. */ + if (type_precision <= HOST_BITS_PER_WIDE_INT) + { + const unsigned HOST_WIDE_INT d = tree_to_uhwi (modulus); + unsigned HOST_WIDE_INT ml, mh; + int pre_shift, post_shift; + tree t; + + /* The trick is to replace the division by d with a multiply-and-shift + sequence parameterized by a (multiplier, shifter) pair computed from + d, the precision of the type and the needed precision: + + op / d = (op * multiplier) >> shifter + + But choose_multiplier provides a slightly different interface: + + op / d = (op h* multiplier) >> reduced_shifter + + that makes things easier by using a high-part multiplication. */ + mh = choose_multiplier (d, type_precision, precision, &ml, &post_shift); + + /* If the suggested multiplier is more than TYPE_PRECISION bits, we can + do better for even divisors, using an initial right shift. */ + if (mh != 0 && (d & 1) == 0) + { + pre_shift = ctz_or_zero (d); + mh = choose_multiplier (d >> pre_shift, type_precision, + precision - pre_shift, &ml, &post_shift); + } + else + pre_shift = 0; + + /* If the suggested multiplier is still more than TYPE_PRECISION bits, + try again with a larger type up to the word size. */ + if (mh != 0) + { + if (type_precision < BITS_PER_WORD) + { + const scalar_int_mode m + = smallest_int_mode_for_size (type_precision + 1); + tree new_type = gnat_type_for_mode (m, 1); + op = fold_convert (new_type, op); + modulus = fold_convert (new_type, modulus); + t = fast_modulo_reduction (op, modulus, precision); + if (t) + return fold_convert (type, t); + } + + return NULL_TREE; + } + + /* This computes op - (op / modulus) * modulus with PRECISION bits. */ + op = gnat_protect_expr (op); + + /* t = op >> pre_shift + t = t h* ml + t = t >> post_shift + t = t * modulus */ + if (pre_shift) + t = fold_build2 (RSHIFT_EXPR, type, op, + build_int_cst (type, pre_shift)); + else + t = op; + t = fold_build2 (MULT_HIGHPART_EXPR, type, t, build_int_cst (type, ml)); + if (post_shift) + t = fold_build2 (RSHIFT_EXPR, type, t, + build_int_cst (type, post_shift)); + t = fold_build2 (MULT_EXPR, type, t, modulus); + + return fold_build2 (MINUS_EXPR, type, op, t); + } + + else + return NULL_TREE; +} + /* Compute the result of applying OP_CODE to LHS and RHS, where both are of TYPE. We know that TYPE is a modular type with a nonbinary modulus. */ @@ -543,7 +629,7 @@ nonbinary_modular_operation (enum tree_code op_code, tree type, tree lhs, { tree modulus = TYPE_MODULUS (type); unsigned precision = tree_floor_log2 (modulus) + 1; - tree op_type, result; + tree op_type, result, fmr; /* For the logical operations, we only need PRECISION bits. For addition and subtraction, we need one more, and for multiplication twice as many. */ @@ -576,9 +662,19 @@ nonbinary_modular_operation (enum tree_code op_code, tree type, tree lhs, if (op_code == MINUS_EXPR) result = fold_build2 (PLUS_EXPR, op_type, result, modulus); - /* For a multiplication, we have no choice but to use a modulo operation. */ + /* For a multiplication, we first try to do a modulo reduction by means of a + (multiplier, shifter) pair in the needed precision up to the word size, or + else we fall back to a standard modulo operation. But not when optimizing + for size, because it will be longer than a div+mul+sub sequence. */ if (op_code == MULT_EXPR) - result = fold_build2 (TRUNC_MOD_EXPR, op_type, result, modulus); + { + if (!optimize_size + && precision <= BITS_PER_WORD + && (fmr = fast_modulo_reduction (result, modulus, precision))) + result = fmr; + else + result = fold_build2 (TRUNC_MOD_EXPR, op_type, result, modulus); + } /* For the other operations, subtract the modulus if we are >= it. */ else From patchwork Fri Jun 21 08:58:15 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: 1950632 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=Vwt4REm7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4W5BCW4pSvz1ydW for ; Fri, 21 Jun 2024 19:00:39 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D304438983B1 for ; Fri, 21 Jun 2024 09:00:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id ACE4E3896C20 for ; Fri, 21 Jun 2024 08:58:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ACE4E3896C20 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 ACE4E3896C20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::336 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960330; cv=none; b=dyOIS+LJUvB2msQA5bu++mGT1wvc+O62VotlL1oLh6fev2JEJWemMHQhermoBOrfPo0IDdErd3deKY4CuWmWLADUdAV00m2lY6e8tHgkC5XonElJa/cSYfsifWs2r5Xqs3gkWm6wlTz8lLpCmm1IXtmw6ZzdxFIKaBupS1+E1j4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960330; c=relaxed/simple; bh=dVqfwhhuL6XGPigzeyrPD5M1Bd3Ql3Pnq32ISGTg1pY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=adnbIrbXJT+pyeSaLaYMuNuIgSr6mbZtI7BTkXeOP4w7aM8ghpc5co7WpZt4asYV7m7DB4mf/xmg1FRO6jX5OHWkdH+1XwHt+yD/tvVQGSRjDFUfYSM/wXnQsx4S6VV6o19wEQoZfaj/w5JE+6R/sN64TyIVrZsucHIPEbr66A8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-421757d217aso20410315e9.3 for ; Fri, 21 Jun 2024 01:58:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960325; x=1719565125; 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=dgOzZtQC2R7Hkd0xIooaZrCJq8rf+RNxYonvXJATOAE=; b=Vwt4REm7CcZGdPWpNJonujuBpGk7XnunIy/z4M3QHXaSYyBj6mLcqKlusZzvOGzIjT 361YxcD8+6tOuQzBBexFSWG+TBRdK9kesE9vSwewas+H9FHMr57ca/5QNjr1dhVjOFHU oY2auz0iMdVh1TfdSaX2M7PaMl4g2PKp3Z/HpdWYVRhS9PR/Hhnh7M7NiGxpB7HyXRZ6 TATHhzSXbzeaiaXZIODe41NEI/kpRZx4LoYeehoKZwDIdiHCHepF7aPeYjWUucgACfKG EuK4JaUhQLq3xABc4w+OVNfiYnFeFZ/wcs4+MC/sy0n63TXclZIEncPvcfVTNm6XNyoz OVQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960325; x=1719565125; 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=dgOzZtQC2R7Hkd0xIooaZrCJq8rf+RNxYonvXJATOAE=; b=rSvp5MD33rW/hnT/2KsijaftEeLF+z211vVWi4O62GSUoBUIuuLpixczexCon1NyQL z74CogKA4OPdJ2N2b6sBcPsVKVP7KF5PhPmr8V9/hvKePJMjTe8pPYGONI7DV5oNt8jN JNM32PtszIzBbWkUKiYYsYdXMCoLsbZPIUFPJ4wv5U7TBTjVmtv6ZVmDh+aJ9hyintfP SJKwY3YOZxTiWxquAJqtXu9DBO6pejKNK1vxgATubQlpdT1Tfw7jseFtqCxpryBvA55x xoGhWErD7NQiaeJ8ZwceM2+7z/5c4Yd+ZCPPsZoG3+cuVrkW8UJV16pxK3kUDm5lyHlA VXWw== X-Gm-Message-State: AOJu0YzgXfflJxT39Xwo0bSiLJXx/KOMPm8yuqm4mbZHYlk2zPNlLyBl Dlic576yTfpw1mEP84OIIlbvfOIE37J82pe0dwVhT6xD2dyArJukG3e5fNAwnEwJsDYfyodVI7c = X-Google-Smtp-Source: AGHT+IFlV0vuxuu4euJTfx93IX7/eRBzFroU7P5G+Ypdrn02xgEz8oCZ0StWo+h6ZP8GaFUoadkM5Q== X-Received: by 2002:a05:600c:5107:b0:424:760d:75b8 with SMTP id 5b1f17b1804b1-424760d766bmr77157845e9.8.1718960325113; Fri, 21 Jun 2024 01:58:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:44 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 19/22] ada: Implement fast modulo reduction for nonbinary modular multiplication Date: Fri, 21 Jun 2024 10:58:15 +0200 Message-ID: <20240621085819.2485987-19-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 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: Eric Botcazou This adds the missing guard to prevent the reduction from being used when the target does not provide or cannot synthesize a high-part multiply. gcc/ada/ * gcc-interface/trans.cc (gnat_to_gnu) : Fix formatting. * gcc-interface/utils2.cc: Include optabs-query.h. (fast_modulo_reduction): Call can_mult_highpart_p on the TYPE_MODE before generating a high-part multiply. Fix formatting. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/trans.cc | 2 +- gcc/ada/gcc-interface/utils2.cc | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index 7c5282602b2..83ed17bff84 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -7323,7 +7323,7 @@ gnat_to_gnu (Node_Id gnat_node) pair in the needed precision up to the word size. But not when optimizing for size, because it will be longer than a div+mul+sub sequence. */ - else if (!optimize_size + else if (!optimize_size && (code == FLOOR_MOD_EXPR || code == TRUNC_MOD_EXPR) && TYPE_UNSIGNED (gnu_type) && TYPE_PRECISION (gnu_type) <= BITS_PER_WORD diff --git a/gcc/ada/gcc-interface/utils2.cc b/gcc/ada/gcc-interface/utils2.cc index a37eccc4cfb..d101d7729bf 100644 --- a/gcc/ada/gcc-interface/utils2.cc +++ b/gcc/ada/gcc-interface/utils2.cc @@ -35,6 +35,7 @@ #include "builtins.h" #include "expmed.h" #include "fold-const.h" +#include "optabs-query.h" #include "stor-layout.h" #include "stringpool.h" #include "varasm.h" @@ -558,11 +559,11 @@ fast_modulo_reduction (tree op, tree modulus, unsigned int precision) op / d = (op * multiplier) >> shifter - But choose_multiplier provides a slightly different interface: + But choose_multiplier provides a slightly different interface: - op / d = (op h* multiplier) >> reduced_shifter + op / d = (op h* multiplier) >> reduced_shifter - that makes things easier by using a high-part multiplication. */ + that makes things easier by using a high-part multiplication. */ mh = choose_multiplier (d, type_precision, precision, &ml, &post_shift); /* If the suggested multiplier is more than TYPE_PRECISION bits, we can @@ -577,8 +578,9 @@ fast_modulo_reduction (tree op, tree modulus, unsigned int precision) pre_shift = 0; /* If the suggested multiplier is still more than TYPE_PRECISION bits, - try again with a larger type up to the word size. */ - if (mh != 0) + or the TYPE_MODE does not have a high-part multiply, try again with + a larger type up to the word size. */ + if (mh != 0 || !can_mult_highpart_p (TYPE_MODE (type), true)) { if (type_precision < BITS_PER_WORD) { From patchwork Fri Jun 21 08:58:16 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: 1950656 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=kxx5z83h; 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 4W5BJm3sRzz20X6 for ; Fri, 21 Jun 2024 19:05:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C643E38983A0 for ; Fri, 21 Jun 2024 09:05:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 319CE3896C09 for ; Fri, 21 Jun 2024 08:58:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 319CE3896C09 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 319CE3896C09 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960331; cv=none; b=icf5Y688I11SUM7wxaw1+UV4NTTJxjOMM04hQgeQS0snOZeJMQATyUA4dAqGBUPOcBSU7trvIHPYC84nRL9McSikX8e9/h24Oy2Q8ZJQY0d84CJQ38bbn6+pMl7h+0rlpqHjmVQgfBGqHMnRBjezKRf8SjtfTcpyCdN0lcccDO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960331; c=relaxed/simple; bh=/eVODcI7OMJ9Ozv0L8X45TyekjouRDwFv61MX83Xk7w=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=o5ltvIs+OE4+PgC71MWCH7AsEfvr/Zf32O6Zl7j9inzg0eTkiZbVMHk8yMX/n8emoGtj1NriTG9xttqc+6zTSBxwMO69YliHfRWOROq452a1TNR9fXPNaTHtDjLBSQ87RHboVxpJwfiv5w3v18PP7vqy9gGbqCaAv5oYEy3UGWQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-42249a4f9e4so13150095e9.2 for ; Fri, 21 Jun 2024 01:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960326; x=1719565126; 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=AsK+iyVmzDoqpnGL5y9ZQAav4vk60gAmSuJCCcK+Q90=; b=kxx5z83hwYGEy8frOsrPqo3TvUiholVv5Dp6SuLzDcvFDynwV1iM8zGwcQTv5S7lJ3 UeEIvbminplXDKzr7s4bPs0pKwJ5m3GR6VjadqhxQ5UviJ+2whYkVaJ1WJitMN3d/HYy iKOXfAIZ5KGp8/fW7S8b9R9R0K12zIfqVZuiRc9JI3DmMU9H/56XN344LK1UGKVaUZpd 3dsXElttjErVRwjm92ChIVJ850BtYKgb//R4nSkeT0cSQTG8fCBonPbyCbSlXDPU0OwV nadSHnGk7qdb32zRQy2A0GYFEuCPSmIjOhJZFa4/XTWz7HTKwLZzl2PE3yxyDdZr0yhe rC/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960326; x=1719565126; 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=AsK+iyVmzDoqpnGL5y9ZQAav4vk60gAmSuJCCcK+Q90=; b=rDLjyIgtqjwEzN4T+lRpK7kRBcu3KfNvX2B+NVcygZPtHKtQHVG8EdYKjDP1I2B/jT f0trCMGH7Z+XDXjhux/P2srdHUp2MvoSvkt1+AgDyrDaFgH1zj1ez2GEmg8tQ2uuZzrI cEyaqDxZwAJXo3XH27xAig3hX1w2UevmUWL+CKscfl7J1XMbF2NwVQOeZAj7+cQiPHXn JFniY2pp0YXSpKIv90R9eZ3z7z+g7e3+5ftWXKTVeA8Lbf8CLexvjLuNEBbobij5eTlk FB2Y3DJdP6wziCGk9bpyMSSu6n+wKXsPGVRxP8r7/LZei/bvHKxked1G5mjI4EyK0eLI 8+9A== X-Gm-Message-State: AOJu0YyagVDp6VLihpl1Dfn4YGqXTbV9jXMmkjI9t/kYCwJyogxAYFZN 64JTGREpUVj2f1kodXfaC1kI6Kp7q5HATDZdI/9NEvB+OSx/eEjHH2EI79SgJT0Fmjg8pINOgsU = X-Google-Smtp-Source: AGHT+IHKepJKuyxQ0KwKmvedSKI9OLZt4m5I42VC97pbWiJojh4AtdnhLx5wCJtgjRwH6VVvCSgIQQ== X-Received: by 2002:a05:600c:2d93:b0:421:182d:9232 with SMTP id 5b1f17b1804b1-42475185a23mr57072695e9.18.1718960325920; Fri, 21 Jun 2024 01:58:45 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:45 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 20/22] ada: Fix bogus Address Sanitizer stack-buffer-overflow on packed record equality Date: Fri, 21 Jun 2024 10:58:16 +0200 Message-ID: <20240621085819.2485987-20-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 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: Eric Botcazou We set DECL_BIT_FIELD optimistically during the translation of record types and clear it afterward if needed, but fail to clear other attributes in the latter case, which fools the logic of the Address Sanitizer. gcc/ada/ * gcc-interface/utils.cc (clear_decl_bit_field): New function. (finish_record_type): Call clear_decl_bit_field instead of clearing DECL_BIT_FIELD manually. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/utils.cc | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc index 771cb1a17ca..0eb9af8d4a2 100644 --- a/gcc/ada/gcc-interface/utils.cc +++ b/gcc/ada/gcc-interface/utils.cc @@ -2002,6 +2002,21 @@ finish_fat_pointer_type (tree record_type, tree field_list) TYPE_CONTAINS_PLACEHOLDER_INTERNAL (record_type) = 2; } +/* Clear DECL_BIT_FIELD flag and associated markers on FIELD, which is a field + of aggregate type TYPE. */ + +static void +clear_decl_bit_field (tree field, tree type) +{ + DECL_BIT_FIELD (field) = 0; + DECL_BIT_FIELD_TYPE (field) = NULL_TREE; + + /* DECL_BIT_FIELD_REPRESENTATIVE is not defined for QUAL_UNION_TYPE since + it uses the same slot as DECL_QUALIFIER. */ + if (TREE_CODE (type) != QUAL_UNION_TYPE) + DECL_BIT_FIELD_REPRESENTATIVE (field) = NULL_TREE; +} + /* Given a record type RECORD_TYPE and a list of FIELD_DECL nodes FIELD_LIST, finish constructing the record or union type. If REP_LEVEL is zero, this record has no representation clause and so will be entirely laid out here. @@ -2112,7 +2127,7 @@ finish_record_type (tree record_type, tree field_list, int rep_level, if (TYPE_ALIGN (record_type) >= align) { SET_DECL_ALIGN (field, MAX (DECL_ALIGN (field), align)); - DECL_BIT_FIELD (field) = 0; + clear_decl_bit_field (field, record_type); } else if (!had_align && rep_level == 0 @@ -2122,7 +2137,7 @@ finish_record_type (tree record_type, tree field_list, int rep_level, { SET_TYPE_ALIGN (record_type, align); SET_DECL_ALIGN (field, MAX (DECL_ALIGN (field), align)); - DECL_BIT_FIELD (field) = 0; + clear_decl_bit_field (field, record_type); } } @@ -2130,7 +2145,7 @@ finish_record_type (tree record_type, tree field_list, int rep_level, if (!STRICT_ALIGNMENT && DECL_BIT_FIELD (field) && value_factor_p (pos, BITS_PER_UNIT)) - DECL_BIT_FIELD (field) = 0; + clear_decl_bit_field (field, record_type); } /* Clear DECL_BIT_FIELD_TYPE for a variant part at offset 0, it's simply @@ -2453,10 +2468,7 @@ rest_of_record_type_compilation (tree record_type) avoid generating useless attributes for the field in DWARF. */ if (DECL_SIZE (old_field) == TYPE_SIZE (field_type) && value_factor_p (pos, BITS_PER_UNIT)) - { - DECL_BIT_FIELD (new_field) = 0; - DECL_BIT_FIELD_TYPE (new_field) = NULL_TREE; - } + clear_decl_bit_field (new_field, new_record_type); DECL_CHAIN (new_field) = TYPE_FIELDS (new_record_type); TYPE_FIELDS (new_record_type) = new_field; From patchwork Fri Jun 21 08:58:17 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: 1950651 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=EWrSEuN4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4W5BHR5QzHz1ydW for ; Fri, 21 Jun 2024 19:04:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 09FD53898396 for ; Fri, 21 Jun 2024 09:04:02 +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 329553896C22 for ; Fri, 21 Jun 2024 08:58:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 329553896C22 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 329553896C22 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=1718960331; cv=none; b=WvuBUyxTffA4J5teucYicFrrYomUVI9BKHNZxbAV7+W1rKNOolLlSYH0euXfDhbpqwmRPd9BeAF2CLwj82onLAsIdh4EI5MnrZi1ddmjvh35ikTnnxd0Is0iinKEwhq9gtsor5flEsysbq+WLAI28qFCF8yJvJqbRoJW1iQlwzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960331; c=relaxed/simple; bh=cXWqcKe6H4Otrv0eoyCqGlPpCoeBxJdvU7nlzlu/W50=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gyyfbNAKjKPvE/nPkoinRKU1OFbiyHacPgrY2hePzEcIaodxPCggxkGEhGSKuwar6NPS9HR8xGplZ16uqF6ytzyV461T7/Kq6071DOJE3wh+bwAWMRyb/ZQ2LEES7IgmDs8nTGO9yElLP9KPc2jIP/GoMb12Bf0exVVyVaiZvRE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-52cd87277d8so256912e87.2 for ; Fri, 21 Jun 2024 01:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960327; x=1719565127; 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=3YfZpNp8IZibN52Ox/Cf8I6AZ+WWw3j+TUrDU2g6VNg=; b=EWrSEuN48tFyczJCpFKFDgdTzSm5koDmImwec7CQlWqpCmOPyJOHPfSXf4fVEyGkwg P0rcBbbKvVXQTAj0Yws+JJeOgk8iSsjcBjJnNQlzXQ+54VVVTGP8n9pPuMFzfftcUtlA Q/lDSjrZhqUIotYUhxjY/GavYZP17EqTfVH9KnhyxibSXhnUA6jbh8BVpXOymI1xUYem beslmIos4qsNxWJTxIKnbds6Z3kKKEHzZGYtpm8gYJrUmgEVr0MMp9heXQaJsbqve2GE wLWU35t1JmxFZ7pAKCzvFm83baK6y786zosODyrw4SIZppxjwnpLnngiU/BNUA3BNaAL oaLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960327; x=1719565127; 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=3YfZpNp8IZibN52Ox/Cf8I6AZ+WWw3j+TUrDU2g6VNg=; b=UrQmlvv+sLx69Dp85cwr3AWfG/1I/wi95B7RRtqar1gi1+bZLnBk1NdZr2RagBsNkZ PibF9n9fOfoKyfqLsdzEQxtt8CRhyqKIWal9yZYyghK5cM/yRtcsyIHkeA4p8EREY6Xl oKRgey/mYE78BkNyh0vFbGX4bL5GnhlMIkUHO60bOdDcZv4niflHTj6YXJC4qvuA5Nm1 zb7NHXKUFSxXFKIWVgIjY4Ts6ly4HBRjDxTpOmphdOsVw3buejQzI8eDYFw5vGsVZVFw nPl0R/dS7O62Gv+cJJ07pT7/wIxTKtKw9qLkc8Ny61hRRiB3rV/uvx3F6gzCAd0r3eoc Q2Eg== X-Gm-Message-State: AOJu0YxJq8xkpADp8Tb4cMRCeuoocAmfAEP7CqVHkDPNb+sjq8prE1CH kU6L3JbP0EMThHwP4JDXgubXo3zzgPCQ0QDyCoYrw2BJQ65C0cUGHYqdLLUnc03xSAHI6SA6AQg = X-Google-Smtp-Source: AGHT+IEwOdjdhZzrsqwqBTBfYqil7FjNwoQsG8uiIEs3eBbblb4Lsx4WahDXVWQ8Y2yyRGjjL/kncA== X-Received: by 2002:a05:6512:39d1:b0:52c:8a3a:fe2c with SMTP id 2adb3069b0e04-52ccaa91d4dmr5815394e87.45.1718960326690; Fri, 21 Jun 2024 01:58:46 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:46 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 21/22] ada: Fix bogus Address Sanitizer stack-buffer-overflow on packed array copy Date: Fri, 21 Jun 2024 10:58:17 +0200 Message-ID: <20240621085819.2485987-21-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 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: Eric Botcazou The Address Sanitizer considers that the padding at the end of a justified modular type may be accessed through the object, but it is never accessed and therefore can always be reused. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) : Set the TYPE_JUSTIFIED_MODULAR_P flag earlier. * gcc-interface/misc.cc (gnat_unit_size_without_reusable_padding): New function. (LANG_HOOKS_UNIT_SIZE_WITHOUT_REUSABLE_PADDING): Redefine to above function. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/decl.cc | 2 +- gcc/ada/gcc-interface/misc.cc | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index aa31a888818..5b3a3b4961b 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -1976,6 +1976,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) gnu_type = make_node (RECORD_TYPE); TYPE_NAME (gnu_type) = create_concat_name (gnat_entity, "JM"); + TYPE_JUSTIFIED_MODULAR_P (gnu_type) = 1; TYPE_PACKED (gnu_type) = 1; TYPE_SIZE (gnu_type) = TYPE_SIZE (gnu_field_type); TYPE_SIZE_UNIT (gnu_type) = TYPE_SIZE_UNIT (gnu_field_type); @@ -2006,7 +2007,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) /* We will output additional debug info manually below. */ finish_record_type (gnu_type, gnu_field, 2, false); - TYPE_JUSTIFIED_MODULAR_P (gnu_type) = 1; /* Make the original array type a parallel/debug type. Note that gnat_get_array_descr_info needs a TYPE_IMPL_PACKED_ARRAY_P type diff --git a/gcc/ada/gcc-interface/misc.cc b/gcc/ada/gcc-interface/misc.cc index b703f00d3c0..4f6f6774fe7 100644 --- a/gcc/ada/gcc-interface/misc.cc +++ b/gcc/ada/gcc-interface/misc.cc @@ -760,6 +760,19 @@ gnat_type_max_size (const_tree gnu_type) return max_size_unit; } +/* Return the unit size of TYPE without reusable tail padding. */ + +static tree +gnat_unit_size_without_reusable_padding (tree type) +{ + /* The padding of justified modular types can always be reused. */ + if (TYPE_JUSTIFIED_MODULAR_P (type)) + return fold_convert (sizetype, + size_binop (CEIL_DIV_EXPR, + TYPE_ADA_SIZE (type), bitsize_unit_node)); + return TYPE_SIZE_UNIT (type); +} + static tree get_array_bit_stride (tree); /* Provide information in INFO for debug output about the TYPE array type. @@ -1407,6 +1420,8 @@ const struct scoped_attribute_specs *const gnat_attribute_table[] = #define LANG_HOOKS_TYPE_FOR_SIZE gnat_type_for_size #undef LANG_HOOKS_TYPES_COMPATIBLE_P #define LANG_HOOKS_TYPES_COMPATIBLE_P gnat_types_compatible_p +#undef LANG_HOOKS_UNIT_SIZE_WITHOUT_REUSABLE_PADDING +#define LANG_HOOKS_UNIT_SIZE_WITHOUT_REUSABLE_PADDING gnat_unit_size_without_reusable_padding #undef LANG_HOOKS_GET_ARRAY_DESCR_INFO #define LANG_HOOKS_GET_ARRAY_DESCR_INFO gnat_get_array_descr_info #undef LANG_HOOKS_GET_SUBRANGE_BOUNDS @@ -1433,7 +1448,7 @@ const struct scoped_attribute_specs *const gnat_attribute_table[] = #define LANG_HOOKS_DEEP_UNSHARING true #undef LANG_HOOKS_CUSTOM_FUNCTION_DESCRIPTORS #define LANG_HOOKS_CUSTOM_FUNCTION_DESCRIPTORS true -#undef LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE +#undef LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE #define LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE gnat_get_sarif_source_language struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; From patchwork Fri Jun 21 08:58:18 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: 1950663 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=fpIUft/z; 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 4W5BL80Zvwz20X6 for ; Fri, 21 Jun 2024 19:06:24 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 58BDB3896C3F for ; Fri, 21 Jun 2024 09:06:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id B8DDC3895FE3 for ; Fri, 21 Jun 2024 08:58:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B8DDC3895FE3 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 B8DDC3895FE3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::329 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960331; cv=none; b=woN52eBapMVU+CAkGKKRtQMMXMnVgSHWUgjPjnb7Qy0Efs2At9TuD+rr8tmCLxTJKqEw1TBBmENwWHy37k8icLlohOiZUqbzKVm1DtPkDGxGlSJQS2DHHEkoahTsN/Y9FutRme0W06xhLUigZcInFDMnRNTdLCpfvv/nBIL5ACI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718960331; c=relaxed/simple; bh=wLNjwS4nT6BG5xIaFGjLIXfB2m1kqRogAxeYXJRGRO0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hbef+nE+b6w0CjHQ0IPlYKjvMPe2V49vj5zf7x8zzZw0DTwXGnC7Hhk+djEQyygpEma0B8cda3GfSVs6O6Foy/n9HSk/Fw7y2RLuibjpXaqG9I4S3DtPoYCBqNCUvz0sokrpCgmDwZtzzU4nnpVXJr+lh47F5U8M7y0riveQao8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4218008c613so15927495e9.2 for ; Fri, 21 Jun 2024 01:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1718960327; x=1719565127; 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=e7r//xljxR/1Dv4Tt74QBDvIUnN6lzeiUihCNaKxVIQ=; b=fpIUft/z1GFrHp0UnUp5s5LVeFk96wufmig47Cm5onQGSM+hs/9qzvKiPHIpSF7QxT SrfLv7ayOTmYXBRM1vptXloT17hOD+k0AYyKq3x6UskxiOUwUvVHWts5f5IPogPAEIzw sI8+DnvuEqSHQ3FAuKeFd87/G+ZYk+LBAWonLi3YQV4NvkKUnkVeIINc8Wh3HZHpTKfQ 2sdMdtt81TUb/u6Qn45tFTKN6DkikdFT3E/P8XU6iw7BGk64Yx71DBYn6zziSEokE4W2 Gg12sMFuUVdL3UUo43E37IOMX0ggK1zuRxzcJXkoBkWMXB5pxJhg6zmX4gBWVUnfIfXQ kDFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718960327; x=1719565127; 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=e7r//xljxR/1Dv4Tt74QBDvIUnN6lzeiUihCNaKxVIQ=; b=Bf91EB+O7HJYQe8D5KEG1AtZkDM3Ynte5OUkLz1YiGH+Hp9g02buxGF1nQkLS0LjCs Hq3YuP47MZDVD1XnDSjJBN2L9xUh57yHeF0fkCA7NH1USYVUN32JzhUgofu1oNcmR8xf mVLXDXnPtkEtx0XxKvXWZNw5ZF3CO8imSbSmnE8/dAkVj4nBDDUH0rPBT++oZ+6YRrS3 yPWb9OivWZdkqfpzJVtHe8SVN95UEN1nERoYeRJ5CKvLe1QCqhDjFr7N4G5m01Z5+CzK uL5Of4dqzSV7MVYt2VUdAStNC6XV34AhM2qcR9u7DMoiX8Q510yjNPLZ8EbT96QRH0S0 dPqQ== X-Gm-Message-State: AOJu0YzLoFM8n7HdOUYEMC1hynn2PE06olHRlhWCRIFrBWpKEWKPrjpL t6QXRUULl3wFBWAe2gXWyR6CqPOCnOdi6gGddMUx5ZTqSSuGHx2mMu2JTZ0YdXLc9tv7M890Mjw = X-Google-Smtp-Source: AGHT+IH2TpNCCiOdA8FjvUL0QQviDmuSQzH53hBsMHhtOBuSvT8jkkHImyMSq4tDUGKAyeZajUAchQ== X-Received: by 2002:a05:600c:1792:b0:421:75e2:c090 with SMTP id 5b1f17b1804b1-42475176435mr62220585e9.11.1718960327515; Fri, 21 Jun 2024 01:58:47 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 01:58:47 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED 22/22] ada: Fix internal error on protected type with -gnatc -gnatR Date: Fri, 21 Jun 2024 10:58:18 +0200 Message-ID: <20240621085819.2485987-22-poulhies@adacore.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621085819.2485987-1-poulhies@adacore.com> References: <20240621085819.2485987-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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 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: Eric Botcazou It occurs when the body of a protected subprogram is processed, because the references to the components of the type have not been properly expanded. gcc/ada/ * gcc-interface/trans.cc (Subprogram_Body_to_gnu): Also return early for a protected subprogram in -gnatc mode. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/trans.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index 83ed17bff84..3f2eadd7b2b 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -3934,6 +3934,12 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) if (Is_Generic_Subprogram (gnat_subprog) || Is_Eliminated (gnat_subprog)) return; + /* Likewise if this is a protected subprogram and we are only annotating + types, as the required expansion of references did not take place. */ + if (Convention (gnat_subprog) == Convention_Protected + && type_annotate_only) + return; + /* If this subprogram acts as its own spec, define it. Otherwise, just get the already-elaborated tree node. However, if this subprogram had its elaboration deferred, we will already have made a tree node for it. So