From patchwork Mon Nov 21 10:14:31 2022 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: 60917 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 D0D883955608 for ; Mon, 21 Nov 2022 10:18:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D0D883955608 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669025927; bh=W5NGJ+zjVRqWaEdVu/+PiWzIAWU8HIOkomRWQhEf5uc=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=TLUCkz5+6zwTx4CyOejaVymLfI+v5RJfK4Bzw8416WUeNR2p9BL8rllfyvmTae1y2 AycLuQYS4TNxNb20PJZWBx81aqvNH6DoIArpBlk09Folq5o1lwK5H2JD7+RZyNBVwK KmAL0T+5QWFOba7B+spsjwRbxwsCP2rB1LBj1B4g= 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 E5C61382E524 for ; Mon, 21 Nov 2022 10:14:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E5C61382E524 Received: by mail-wm1-x329.google.com with SMTP id 5so8103390wmo.1 for ; Mon, 21 Nov 2022 02:14:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=W5NGJ+zjVRqWaEdVu/+PiWzIAWU8HIOkomRWQhEf5uc=; b=IabU/Pf2yONQB2YQ6mwJJwKD1TJHqY5Se03qzI9vaaXNR1JhVJAyWDBBTqd6UqUqNz 0pMBx+H66wpb+Xe1MB5x0ygWawF8s1D29SQVhNNf2qhd13Yg+lrsminRSOL+BkwYOPP7 9QpHkejS4T+muqCBho7aygLcFrURIlIlSdXO7SeTjjLGm2l5LGe7Ap9wXpIO1RO2gRxE 2PsKh0Nr6jTCW1l79T06cnGjV7k9KMMRCvL08EALjmvYkS9Q5z2tM/rs8lsg9iTv9JNq DpxP/WVdnmaSa9lCMWSDrvOuTXosTid7fvFIw25bWrbYssiaLX9rtCRIuEHrKOEupifQ nT1A== X-Gm-Message-State: ANoB5pmUq6STG5t1idRyKRtoRnq652xDoKRdqOEVmdyAsEPPrMmYu2l5 TqVBZ0jTIOX0/I6hPtLlPt4JB86bdpF1Mw== X-Google-Smtp-Source: AA0mqf7eUMD6leplz7YhXvOL+yGC80aKldgG3WFbp9uiT+6PnY+zYwvHo/YOS8GVjI52R+c/OH2UdQ== X-Received: by 2002:a05:600c:4e47:b0:3cf:5657:4717 with SMTP id e7-20020a05600c4e4700b003cf56574717mr15492755wmq.87.1669025673698; Mon, 21 Nov 2022 02:14:33 -0800 (PST) Received: from localhost.localdomain (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id b3-20020a5d4d83000000b00236576c8eddsm10815364wru.12.2022.11.21.02.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 02:14:33 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED] ada: Internal compiler error for Sequential Partition_Elaboration_Policy Date: Mon, 21 Nov 2022 11:14:31 +0100 Message-Id: <20221121101431.259470-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Steve Baird In some cases, compilation of a function with a limited class-wide result type could fail with an internal error if a Sequential Partition_Elaboration_Policy is specified. To prevent this, we want specifying a Sequential Partition_Elaboration_Policy to have the side effect of imposing a No_Task_Hierarchy restriction. But doing that in a straightforward way leads to problems with incorrectly accepting violations of H.6(6). So a new restriction, No_Task_Hierarchy_Implicit, is introduced. gcc/ada/ * libgnat/s-rident.ads: Define a new restriction, No_Task_Hierarchy_Implicit. This is like the No_Task_Hierarchy restriction, but with the difference that setting this restriction does not mean the H.6(6) post-compilation check is satisified. * exp_ch6.adb (Add_Task_Actuals_To_Build_In_Place_Call): If it is known that the function result cannot have tasks, then pass in a null literal for the activation chain actual parameter. This avoids generating a reference to an entity that Build_Activation_Chain_Entity may have chosen not to generate a declaration for. * gnatbind.adb (List_Applicable_Restrictions): Do not list the No_Task_Hierarchy_Implicit restriction. * restrict.adb: Special treatment for the No_Task_Hierarchy_Implicit restriction in functions Get_Restriction_Id and Restriction_Active. The former is needed to disallow the (unlikely) case that a user tries to explicitly reference the No_Task_Hierarchy_Implicit restriction. * sem_prag.adb (Analyze_Pragma): If a Sequential Partition_Elaboration_Policy is specified (and the No_Task_Hierarchy restriction is not already enabled), then enable the No_Task_Hierarchy_Implicit restriction. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch6.adb | 5 ++++- gcc/ada/gnatbind.adb | 3 +++ gcc/ada/libgnat/s-rident.ads | 5 +++-- gcc/ada/restrict.adb | 12 ++++++++++-- gcc/ada/sem_prag.adb | 19 +++++++++++++++++++ 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 4cdd98649c8..a5dee38c55f 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -662,7 +662,10 @@ package body Exp_Ch6 is -- Create the actual which is a pointer to the current activation chain - if No (Chain) then + if Restriction_Active (No_Task_Hierarchy) then + Chain_Actual := Make_Null (Loc); + + elsif No (Chain) then Chain_Actual := Make_Attribute_Reference (Loc, Prefix => Make_Identifier (Loc, Name_uChain), diff --git a/gcc/ada/gnatbind.adb b/gcc/ada/gnatbind.adb index 475702a755e..509b4d368a8 100644 --- a/gcc/ada/gnatbind.adb +++ b/gcc/ada/gnatbind.adb @@ -215,6 +215,9 @@ procedure Gnatbind is No_Specification_Of_Aspect => False, -- Requires a parameter value, not a count + No_Task_Hierarchy_Implicit => False, + -- A compiler implementation artifact, not a documented restriction + No_Use_Of_Attribute => False, -- Requires a parameter value, not a count diff --git a/gcc/ada/libgnat/s-rident.ads b/gcc/ada/libgnat/s-rident.ads index 9d652a4cc3e..1c6f2e7156e 100644 --- a/gcc/ada/libgnat/s-rident.ads +++ b/gcc/ada/libgnat/s-rident.ads @@ -107,7 +107,7 @@ package System.Rident is No_Dispatching_Calls, -- GNAT No_Dynamic_Accessibility_Checks, -- GNAT No_Dynamic_Attachment, -- Ada 2012 (RM E.7(10/3)) - No_Dynamic_CPU_Assignment, -- Ada 202x (RM D.7(10/3)) + No_Dynamic_CPU_Assignment, -- Ada 2022 (RM D.7(10/3)) No_Dynamic_Priorities, -- (RM D.9(9)) No_Enumeration_Maps, -- GNAT No_Entry_Calls_In_Elaboration_Code, -- GNAT @@ -152,8 +152,9 @@ package System.Rident is No_Task_Attributes_Package, -- GNAT No_Task_At_Interrupt_Priority, -- GNAT No_Task_Hierarchy, -- (RM D.7(3), H.4(3)) + No_Task_Hierarchy_Implicit, -- GNAT No_Task_Termination, -- Ada 2005 (D.7(15.1/2)) - No_Tasks_Unassigned_To_CPU, -- Ada 202x (D.7(10.10/4)) + No_Tasks_Unassigned_To_CPU, -- Ada 2022 (D.7(10.10/4)) No_Tasking, -- GNAT No_Terminate_Alternatives, -- (RM D.7(6)) No_Unchecked_Access, -- (RM H.4(18)) diff --git a/gcc/ada/restrict.adb b/gcc/ada/restrict.adb index 9ef923b186c..9965321c75e 100644 --- a/gcc/ada/restrict.adb +++ b/gcc/ada/restrict.adb @@ -897,7 +897,10 @@ package body Restrict is declare S : constant String := Restriction_Id'Image (J); begin - if S = Name_Buffer (1 .. Name_Len) then + if S = Name_Buffer (1 .. Name_Len) + -- users cannot name the N_T_H_Implicit restriction + and then J /= No_Task_Hierarchy_Implicit + then return J; end if; end; @@ -1104,7 +1107,12 @@ package body Restrict is function Restriction_Active (R : All_Restrictions) return Boolean is begin - return Restrictions.Set (R) and then not Restriction_Warnings (R); + if Restrictions.Set (R) and then not Restriction_Warnings (R) then + return True; + else + return R = No_Task_Hierarchy + and then Restriction_Active (No_Task_Hierarchy_Implicit); + end if; end Restriction_Active; -------------------------------- diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 72ad0cd9d81..f2c1a3f0e6e 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -21097,6 +21097,25 @@ package body Sem_Prag is if Partition_Elaboration_Policy_Sloc /= System_Location then Partition_Elaboration_Policy_Sloc := Loc; end if; + + if PEP_Val = Name_Sequential + and then not Restriction_Active (No_Task_Hierarchy) + then + -- RM H.6(6) guarantees that No_Task_Hierarchy will be + -- set eventually, so take advantage of that knowledge now. + -- But we have to do this in a tricky way. If we simply + -- set the No_Task_Hierarchy restriction here, then the + -- assumption that the restriction will be set eventually + -- becomes a self-fulfilling prophecy; the binder can + -- then mistakenly conclude that the H.6(6) rule is + -- satisified in cases where the post-compilation check + -- should fail. So we invent a new restriction, + -- No_Task_Hierarchy_Implicit, which is treated specially + -- in the function Restriction_Active. + + Set_Restriction (No_Task_Hierarchy_Implicit, N); + pragma Assert (Restriction_Active (No_Task_Hierarchy)); + end if; end if; end PEP;