From patchwork Tue May 23 08:09:22 2023 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: 1784957 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=ig4ThqT+; dkim-atps=neutral Received: from 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QQRtt48Gbz2020 for ; Tue, 23 May 2023 18:14:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8946C389942A for ; Tue, 23 May 2023 08:14:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8946C389942A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684829684; bh=EPXx/HkrT47h4RvZXol44NRtaONwVkPlOX32EEXaVcU=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ig4ThqT+7a0cryExiaJUKjrCDxjaTMgyjKstrIQtoKvsCFmroDbwEH0UOcwwWGChO DvqZ0aRkwzaUFJ/EGFkZYQTq2VDVvTQmmBFg/DHzN8poSN/kFa9KCcjSG1uxtXaxC7 PHAcLRTndLiXIuwmg1MQanzyfHr2+CR01odFVcuE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 136E43856DD5 for ; Tue, 23 May 2023 08:09:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 136E43856DD5 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3078cc99232so6727078f8f.3 for ; Tue, 23 May 2023 01:09:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684829364; x=1687421364; 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=EPXx/HkrT47h4RvZXol44NRtaONwVkPlOX32EEXaVcU=; b=E1gtX4SHAW5exVPqEe9tUaSUce0407hhCCdQC7zpm/VHs8XCrZPUaggirRdt7tSsKc 8l+kLlh9rN/OI7TBz8MhLPzqhYlopT9YXcQU4/VOq8e92ZZmQYTnI6DQIYw3dRkeIKux uMDmv7YLfB+RBIYrBLlDnyQs+jRzmyuWRKchUYP0dsFv5xTk1V+yHWF+kuj41CqobpHR q+jBw2Dmv4mVNPP/yV/JNCWFdHRKsyp7Y/wLLjnQ/3Mf9q9D8CnKTAw/s6l6qPa0nfA/ XoOqSE2S2DyssPQzc9Dlykx5lN/hC/eGtNtRrizranKnT/xoGSkP4EdWW8lZ/B1Nw6QL 5/Wg== X-Gm-Message-State: AC+VfDwksmGgnk9rwesP1TzEYoPeu8ufdDGwICQvhCCDZ4rME8gLK/pb KCP47pkRJc1VSF/9skwU5IGVjJAU1fn2qyLy6lrzbA== X-Google-Smtp-Source: ACHHUZ4BkOt1N2bPM4LkD/1QgJJ9Qa4wYh90iErBNrd4vpPfeKP7fKoBOemhDfWlQ3+1JLHJ/mJ+Vw== X-Received: by 2002:a5d:4f8e:0:b0:307:cb94:85de with SMTP id d14-20020a5d4f8e000000b00307cb9485demr10402013wru.11.1684829363865; Tue, 23 May 2023 01:09:23 -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 s3-20020a5d4243000000b002cea9d931e6sm10170399wrr.78.2023.05.23.01.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 01:09:23 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes Subject: [COMMITTED] ada: ICE on BIP call in class-wide function return within instance Date: Tue, 23 May 2023 10:09:22 +0200 Message-Id: <20230523080922.1874982-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.6 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, T_SCC_BODY_TEXT_LINE 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" From: Gary Dismukes The compiler blows up (such as with a Storage_Error or Assert_Failure) on a call to a limited build-in-place function occurring in the return for a function with a limited class-wide result. Such a function should include extra formals for a task master and activation chain (because it's possible for a limited class-wide type to have values with task parts), but when the enclosing function occurs within an instantiation and the result subtype comes from a formal type, the extra formals were missing for the enclosing function. As a result, the attempt to retrieve the task master formal for passing along to a BIP call in the return failed when calling Build_In_Place_Formal to loop through the formals. When determining the need for the formals in Create_Extra_Formals, Needs_BIP_Actual_Task_Actuals was returning False, because Might_Have_Tasks incorrectly returned False due to the test of Is_Limited_Record flag on the class-wide generic actual subtype's Etype being False. Is_Limited_Record was not being properly inherited by the class-wide type in the case of private extensions, because Make_Class_Wide_Type was called in Analyze_Private_Extension_Declaration before certain flags (such as Is_Limited_Record and Is_Controlled_Active) are inherited later in Build_Derived_Record_Type (which will also call Make_Class_Wide_Type). This is corrected by removing the early call to Make_Class_Wide_Type. gcc/ada/ * exp_ch6.adb (Might_Have_Tasks): Remove unneeded Etype call from call to Is_Limited_Record, since that flag is now properly inherited by class-wide types. * sem_ch3.adb (Analyze_Private_Extension_Declaration): Remove call to Make_Class_Wide_Type, which is done too early, and will later be done in Build_Derived_Record_Type after flags such as Is_Limited_Record and Is_Controlled_Active have been set on the derived type. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch6.adb | 2 +- gcc/ada/sem_ch3.adb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 28b746ba2c4..fce10d5e946 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -9326,7 +9326,7 @@ package body Exp_Ch6 is and then not No_Run_Time_Mode and then (Has_Task (Typ) or else (Is_Class_Wide_Type (Typ) - and then Is_Limited_Record (Etype (Typ)) + and then Is_Limited_Record (Typ) and then not Has_Aspect (Etype (Typ), Aspect_No_Task_Parts))); end Might_Have_Tasks; diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 50ccb390363..a0783195b8b 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -5376,7 +5376,6 @@ package body Sem_Ch3 is Set_Convention (T, Convention (Parent_Type)); Set_First_Rep_Item (T, First_Rep_Item (Parent_Type)); Set_Is_First_Subtype (T); - Make_Class_Wide_Type (T); -- Set the SPARK mode from the current context