From patchwork Tue Jan 7 12:53:37 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: 104240 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 88EB33851C02 for ; Tue, 7 Jan 2025 13:06:24 +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 3D386385627A for ; Tue, 7 Jan 2025 12:54:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3D386385627A 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 3D386385627A 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=1736254464; cv=none; b=MbiOGCOsC8KUuPgIYqIs4FTwdeQ02g4EXYJ1x/h4A7674HwV4ntnrXn/0fwyfNpX5yJLY3wM+hqzrj2uwaGoQgM+sWKulH1+8snmWpYwrHOtGnmb03FH/zrpiLiRRqEInomO8YVtZQGI1qjveB1l+McT3DUBCHor65ujFQNmQb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736254464; c=relaxed/simple; bh=AMpN4wak//f7JoQhggZSGXS3uKCgzr+LduxRLEUF04g=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=dGx6yEUwUvOwrlRDXaYnbKSP9pnaK2KuvZGeaxT9RtXq6zinbPd9GuOAWmxBwUSXOLAo7Fx/kRUGBGkjND5sT/ISiIWQ+qy87PmLo/1REAr5X5rr5AJOXlgAJUsSbAVQOVDSdVj44CZmDZh02b6JLFtbqNkj5dz98DeqkylDQIs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D386385627A 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=GN3u9Dvh Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4361b0ec57aso154042145e9.0 for ; Tue, 07 Jan 2025 04:54:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1736254463; x=1736859263; 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=oZuEOqRwTYRFjkIB+i35+SaEPknx/FPUNDv0n2T14uc=; b=GN3u9DvhvJe4MDOeYlAAExUj9Q4D0LyvSc+KAwpvUZs13xfAwrAVp7jzjfvycFqctx EidjENxYZ8/Wp96uLUgvVSu6YyXZqDGfZB5J7K/dSDEBsYqcWusDkQCIOROJXbCR5T7K ajnn3S40LX2obFs3xaxd/Ix4IM+PG9uQcj8CZCMmx78LBQPDT3OxwL5YQm+fNFIh55xW tY2S+vHmH3rHvOLnSlrh/1MbhIfeUDG3YJcffMfjLI+4q/CyXwMfkwZ5N52+wSoW/Iw7 wlvLO86VII6rmfO3Osxpldvy0r7KVc4ZuLNj9QSf6+gWPbv0P2AIsWzY9gKAhMnzQKuG aE9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736254463; x=1736859263; 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=oZuEOqRwTYRFjkIB+i35+SaEPknx/FPUNDv0n2T14uc=; b=CZQeTw9gOfGv4ZsDpN4m8wKI4dandS7ffA0XHbq7YA2RjIgKclBT6D6EHZoX6O4qLf 8DfA/3Y/oTBDxqlYHFKJRYsATHFytOlxhnXJ9cmvZLms6PBoaGOplNMnSUk4dY/fFpz8 vdyOYyDcBxffNO2OsR2CQA3mRIAmtzvuhesdOguquLU6Whzf3eHbcOAjKqH5QHXj6Mbb elci55HXdNy8zzPnxnPJzF25IHIWtn1x8pP6gB12MIDfuCh7eqrZtbVrFc/srXYCFS24 rCQiUz2TYx5ZX/9Z6Vf0cgDdOwdTBHEV1qOIOCw1xtu6///H8AeP2WZgdhBsHTzyzRo1 XQ3Q== X-Gm-Message-State: AOJu0YwxEyUmMsbPivUK3Np+EhwntKkJQl7llWSrIEenOO5KCbnA+Vcd lgXP9WhbPswMm0w/68fWezzouOKnYhieuvHBKSS59dlMbUfIoaAW5zGnuFA9t+w1gBq2konqksk = X-Gm-Gg: ASbGncth+BsJb/rwdQ51ajzkwvlpFsVrvExXnnMdvTSo6QBJ4uZviX5FS48MUOEbKRs SYa//t8u1o1wT3ZJxAwNEnI1JUwt9oWS8ZoddkJC6IVbk8dc1+4/xjQ6bsuPcHW+HG0yO4wQS8t HVTr3VidWaoeFmzYWRQUUQGTfpkVHZttfJ+G3XC2SN7CSDo/nMTc9oljcQDdDWsKEdBEv3I3kPU j0dsSzBLd1kyFr+1XyPMJNiMA6PRJESGKrcYrE9XP80d1bXX2wxz7DUDXfL9k1arDwSIcu64eHw wCpj8kC+UCgNjs3guvNvZs0XoIkOUbUZbqyH83cl93MbhH3TImII6hTDoPbCNGdqoknQVWOC X-Google-Smtp-Source: AGHT+IG1MpGOe+k9E4Bia/2Y8DoIdCRLDQSOB0POkFpW9Y4se/DjjkRz52n4AmdnVW4DTy6BO9M/FQ== X-Received: by 2002:a05:600c:1c8f:b0:431:93d8:e1a1 with SMTP id 5b1f17b1804b1-43668b61b5bmr497920025e9.27.1736254462897; Tue, 07 Jan 2025 04:54:22 -0800 (PST) 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 5b1f17b1804b1-43656af6c42sm631014805e9.9.2025.01.07.04.54.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 04:54:22 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED 19/31] ada: Improved checking of uses of package renamings Date: Tue, 7 Jan 2025 13:53:37 +0100 Message-ID: <20250107125350.619654-19-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250107125350.619654-1-poulhies@adacore.com> References: <20250107125350.619654-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~patchwork=sourceware.org@gcc.gnu.org From: Steve Baird In some cases, the RM 8.5.1(3.1) legality rule about uses of renamings of limited views of packages was implemented incorrectly, resulting in rejecting legal uses. gcc/ada/ChangeLog: * gen_il-fields.ads: add new Renames_Limited_View field. * gen_il-gen-gen_entities.adb: add Renames_Limited_View flag for packages. * einfo.ads: add comment documenting Renames_Limited_View flag. * sem_ch8.adb (Analyze_Package_Renaming): Set new Renames_Limited_View flag. Test new Renames_Limited_View flag instead of calling Has_Limited_With. If Has_Limited_With is True, that just means that somebody, sometime during this compilation needed to reference the limited view of the package; so that function returns True too often to be used here. (Find_Expanded_Name): Test new Renames_Limited_View flag instead of calling Has_Limited_With. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/einfo.ads | 9 +++++++++ gcc/ada/gen_il-fields.ads | 1 + gcc/ada/gen_il-gen-gen_entities.adb | 1 + gcc/ada/sem_ch8.adb | 7 ++++--- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index 1946e68b3c7..a7c0584d8da 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -4247,6 +4247,15 @@ package Einfo is -- within an accept statement. For all remaining cases (discriminants, -- loop parameters) the field is Empty. +-- Renames_Limited_View +-- Defined in package entities. True for a package renaming if either +-- a) the renamed package is not itself a renaming, and the renaming +-- denotes a limited view of the renamed package (as seen at the +-- point of the renaming declaration, as opposed to later on when +-- the renaming is referenced); or +-- b) the renamed package is itself a renaming and the +-- Renames_Limited_View flag is True for the renamed package. + -- Requires_Overriding -- Defined in all subprograms and entries. Set for subprograms that -- require overriding as defined by RM-2005-3.9.3(6/2). Note that this diff --git a/gcc/ada/gen_il-fields.ads b/gcc/ada/gen_il-fields.ads index c778f00856d..fe2da80c548 100644 --- a/gcc/ada/gen_il-fields.ads +++ b/gcc/ada/gen_il-fields.ads @@ -879,6 +879,7 @@ package Gen_IL.Fields is Relative_Deadline_Variable, Renamed_In_Spec, Renamed_Or_Alias, -- Shared among Alias, Renamed_Entity, Renamed_Object + Renames_Limited_View, Requires_Overriding, Return_Applies_To, Return_Present, diff --git a/gcc/ada/gen_il-gen-gen_entities.adb b/gcc/ada/gen_il-gen-gen_entities.adb index 8cf66b2611d..3df1f8e7284 100644 --- a/gcc/ada/gen_il-gen-gen_entities.adb +++ b/gcc/ada/gen_il-gen-gen_entities.adb @@ -1281,6 +1281,7 @@ begin -- Gen_IL.Gen.Gen_Entities Sm (Related_Instance, Node_Id), Sm (Renamed_In_Spec, Flag), Sm (Renamed_Or_Alias, Node_Id), + Sm (Renames_Limited_View, Flag), Sm (Scope_Depth_Value, Unat), Sm (SPARK_Aux_Pragma, Node_Id), Sm (SPARK_Aux_Pragma_Inherited, Flag), diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index 533b62aef32..c6b8f6c5d7c 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -1665,8 +1665,7 @@ package body Sem_Ch8 is Set_Etype (New_P, Standard_Void_Type); elsif Present (Renamed_Entity (Old_P)) - and then (From_Limited_With (Renamed_Entity (Old_P)) - or else Has_Limited_View (Renamed_Entity (Old_P))) + and then Renames_Limited_View (Old_P) and then not Unit_Is_Visible (Cunit (Get_Source_Unit (Renamed_Entity (Old_P)))) then @@ -1691,8 +1690,10 @@ package body Sem_Ch8 is if Present (Renamed_Entity (Old_P)) then Set_Renamed_Entity (New_P, Renamed_Entity (Old_P)); + Set_Renames_Limited_View (New_P, Renames_Limited_View (Old_P)); else Set_Renamed_Entity (New_P, Old_P); + Set_Renames_Limited_View (New_P, From_Limited_With (Old_P)); end if; -- The package renaming declaration may become Ghost if it renames a @@ -7077,7 +7078,7 @@ package body Sem_Ch8 is ("renaming of limited view of package & not usable in this" & " context (RM 8.5.3(3.1/2))", Prefix (N), P_Name); - elsif Has_Limited_View (P_Name) + elsif Renames_Limited_View (Entity (Prefix (N))) and then not Unit_Is_Visible (Cunit (Get_Source_Unit (P_Name))) and then not Is_Visible_Through_Renamings (P_Name) then