From patchwork Thu Sep 11 09:18:48 2025 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: 120044 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D40E33858287 for ; Thu, 11 Sep 2025 09:32:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id B2F463858D37 for ; Thu, 11 Sep 2025 09:19:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B2F463858D37 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 B2F463858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582370; cv=none; b=tqi8E/F6SZ028XMDuvCGfoRzv54NvFpRWpUvWNRqKjs0qhY3n+zGAsGYs4aGrMolcAEWbTArm8hTIc4KuKeYZo/LyjuD6fMdTGeSIlQuXyGTKgm37zcD3Tovzd70qEcaQLQjLKWWq1J2UzPjDSYy2xh91MDCioEch9MG2okJ5t0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582370; c=relaxed/simple; bh=yRSsNTOkC1F8uEYm3OmgMIrM9FsNyUYJKiRIjk9iHFA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hI1+Xqgoa35vxeZDHYjE/Xby8HX/VAt1IG/s9DE68LPuc99cUa3Xd7sAvSuSp4b8ljHM1VTLbFpKKgR40WSb6cqfWci1RUpJK+TWcfgEnvnjouo6zzOix+707+ikR567ktWXNBt8ZOUiK919XTF+gXgxrTshUO1RE83rQg/CpPA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2F463858D37 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=jhV0UWCp Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-45df656889cso3138675e9.1 for ; Thu, 11 Sep 2025 02:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582368; x=1758187168; 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=EO+6sTPBE01S7b/qX+Valr9sS/Ok3MAInysDNUEhMTM=; b=jhV0UWCph70pSyh6gIAOHPHNMaGoaftRNj/mCNCMihT6MV6q3ZDZeg5zoFo0nzTku/ SXc772SSaRrrkj5OM6QHy/Ck7KHXsvSwTWZWKGncr/79hXRk14kNhViKw82vtadkK9tn N2+hNbRGz1a+W1KU51T+RfNqzt/I0cfuWm/KdA9gzG65quYAHAiPi2oMKt6HjtVEMaYT NebVWXgb2flohi0VEW5ufo3NzVBsEWG+pPM0RRL4IpMGhb+rtqbrBnB0mILXYtw65HTv QP0wT3rFIMv68hYvfWFjoX1LbAGRlKU5G36qrD3Jx9oIYs5q90BOwSoYtcImiAqQzRt+ +wNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582368; x=1758187168; 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=EO+6sTPBE01S7b/qX+Valr9sS/Ok3MAInysDNUEhMTM=; b=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MZOhUW4sdaCD4Tu8QaQ== X-Received: by 2002:a05:600c:4fc1:b0:45d:d5df:ab39 with SMTP id 5b1f17b1804b1-45ddded614bmr161301815e9.26.1757582368318; Thu, 11 Sep 2025 02:19:28 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:27 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED 16/31] ada: Fix visibility bug related to target name Date: Thu, 11 Sep 2025 11:18:48 +0200 Message-ID: <20250911091904.1505690-16-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-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~patchwork=sourceware.org@gcc.gnu.org From: Bob Duff This patch fixes the following bug: If the right-hand side of an expression contains a target name (i.e. "@"), and also contains a reference to a user-defined operator that is directly visible because of a "use type" clause on a renaming of the package where the operator is declared, the compiler gives an incorrect error saying that the renamed package is not visible. It turns out that setting Entity of resolved nodes is unnecessary and wrong; the fix is to simply remove that code. gcc/ada/ChangeLog: * exp_ch5.adb (Expand_Assign_With_Target_Names.Replace_Target): Remove code setting Entity to Empty. * sinfo.ads (Has_Target_Names): Improve comment: add "@" to clarify what "target name" means, and remove the content-free phrase "and must be expanded accordingly." Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch5.adb | 17 ++--------------- gcc/ada/sinfo.ads | 2 +- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index d78df5c8315a..0949d5864bb5 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -2254,7 +2254,8 @@ package body Exp_Ch5 is function Replace_Target (N : Node_Id) return Traverse_Result; -- Replace occurrences of the target name by the proper entity: either -- the entity of the LHS in simple cases, or the formal of the - -- constructed procedure otherwise. + -- constructed procedure otherwise. Mark all nodes as Analyzed=False + -- so reanalysis will occur. -------------------- -- Replace_Target -- @@ -2264,20 +2265,6 @@ package body Exp_Ch5 is begin if Nkind (N) = N_Target_Name then Rewrite (N, New_Occurrence_Of (Ent, Sloc (N))); - - -- The expression will be reanalyzed when the enclosing assignment - -- is reanalyzed, so reset the entity, which may be a temporary - -- created during analysis, e.g. a loop variable for an iterated - -- component association. However, if entity is callable then - -- resolution has established its proper identity (including in - -- rewritten prefixed calls) so we must preserve it. - - elsif Is_Entity_Name (N) then - if Present (Entity (N)) - and then not Is_Overloadable (Entity (N)) - then - Set_Entity (N, Empty); - end if; end if; Set_Analyzed (N, False); diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index eb9529f52cec..bde67a05b6e6 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -1476,7 +1476,7 @@ package Sinfo is -- Has_Target_Names -- Present in assignment statements. Indicates that the RHS contains - -- target names (see AI12-0125-3) and must be expanded accordingly. + -- target names ("@" -- see AI12-0125-3). -- Has_Wide_Character -- Present in string literals, set if any wide character (i.e. character