From patchwork Fri May 26 07:36:37 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: 70139 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 F284B38A814E for ; Fri, 26 May 2023 07:42:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F284B38A814E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685086976; bh=O6/8SpGAHGYr4VUKKJVqjo1zpDFbhGWWpnTvA/lAtkg=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=xlNmX5Fu5VbkL4noswowycUeLRfYduOlj3WGBFsKDe23Xb/Ya9yoWACJld5WyCJzq wRx6DsgspBNRQ2H2m0jQ1BsPMEFh6fxv4lrvg3WVasiApewvmk97BSmOW7XA7VS8ip 4W0rVWU7szfQr4pOTNi/IGmNDG1CBor8hhHr2fBo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id E95983857703 for ; Fri, 26 May 2023 07:36:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E95983857703 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3094910b150so341526f8f.0 for ; Fri, 26 May 2023 00:36:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685086599; x=1687678599; 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=O6/8SpGAHGYr4VUKKJVqjo1zpDFbhGWWpnTvA/lAtkg=; b=KaerDAEoGMzeRoz/TX1sw5LN0PLNIJn49i50l3Ug8VmHMmIxczV9wlyakP189toQts b2ezjxFXUxHSYVpeaDGeS864ih0nxzwpIQVend97og3xK0asDwK6ho7K0eqmSd2kMQ8N dj6QnZ1kU1bY7pXFfSbviikqbNHbOl03WiC6811f1uWSDqElkKKA/tSOhAqyipA5ZDr0 VxQtuBA3vYUMcBXSEkXdtQqk1HsL6gb2BRxcfD37xgpUkPDXEgIcS/DltyQ9vKnMOgjZ mvwCJQpBOkcgi+u1IIUiTIhvM5Cb7ZAQM98pBKnIiNQMPvv88JrECei33saqAqFIbisZ fijQ== X-Gm-Message-State: AC+VfDyghgk3M/oJeT/F2e7bL1CiMSCWT1/jpJGCGcrVczeVIbRwChwD SGe/61NKMU/StB5MZRqQI6qZrfd2tZArCAOBOzoe3w== X-Google-Smtp-Source: ACHHUZ4aElh/JCJt8dtLZloJskdM2u9YUHpVhHI9z6D0hZBYOo8MM0b4OZ2s03muk2vIOCr8qlCjFA== X-Received: by 2002:a5d:63ca:0:b0:307:a77c:c16a with SMTP id c10-20020a5d63ca000000b00307a77cc16amr645999wrw.29.1685086598830; Fri, 26 May 2023 00:36:38 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:777b:eef4:6f79:f26f]) by smtp.gmail.com with ESMTPSA id n5-20020a5d51c5000000b003064088a94fsm4144601wrv.16.2023.05.26.00.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 00:36:38 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix internal error on Big_Integer conversion ghost instance Date: Fri, 26 May 2023 09:36:37 +0200 Message-Id: <20230526073637.2069474-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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Eric Botcazou The problem is that the ghost mode of the instance is used to analyze the parent of the generic body, whose own ghost mode has nothing to do with it. gcc/ada/ * sem_ch12.adb (Instantiate_Package_Body): Set the ghost mode to that of the instance only after loading the generic's parent. (Instantiate_Subprogram_Body): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch12.adb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 4fefcc8fb46..a9a3e322917 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -11911,12 +11911,6 @@ package body Sem_Ch12 is return; end if; - -- The package being instantiated may be subject to pragma Ghost. Set - -- the mode now to ensure that any nodes generated during instantiation - -- are properly marked as Ghost. - - Set_Ghost_Mode (Act_Decl_Id); - Expander_Mode_Save_And_Set (Body_Info.Expander_Status); -- Re-establish the state of information on which checks are suppressed. @@ -12029,6 +12023,12 @@ package body Sem_Ch12 is Instantiation_Node := Inst_Node; end if; + -- The package being instantiated may be subject to pragma Ghost. Set + -- the mode now to ensure that any nodes generated during instantiation + -- are properly marked as Ghost. + + Set_Ghost_Mode (Act_Decl_Id); + if Present (Gen_Body_Id) then Save_Env (Gen_Unit, Act_Decl_Id); Style_Check := False; @@ -12468,12 +12468,6 @@ package body Sem_Ch12 is return; end if; - -- The subprogram being instantiated may be subject to pragma Ghost. Set - -- the mode now to ensure that any nodes generated during instantiation - -- are properly marked as Ghost. - - Set_Ghost_Mode (Act_Decl_Id); - Expander_Mode_Save_And_Set (Body_Info.Expander_Status); -- Re-establish the state of information on which checks are suppressed. @@ -12511,6 +12505,12 @@ package body Sem_Ch12 is Instantiation_Node := Inst_Node; + -- The subprogram being instantiated may be subject to pragma Ghost. Set + -- the mode now to ensure that any nodes generated during instantiation + -- are properly marked as Ghost. + + Set_Ghost_Mode (Act_Decl_Id); + if Present (Gen_Body_Id) then Gen_Body := Unit_Declaration_Node (Gen_Body_Id);