From patchwork Fri May 26 07:35:59 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: 70120 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 B2CE93887F58 for ; Fri, 26 May 2023 07:37:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2CE93887F58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685086663; bh=rilRdZJoDL8eG0bQKsdWHcxSrctd9IX08PeTNvSQVJ8=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=n2wfFfgg7zq7of/BoYaqORqLw8ebRKkk2mHHa1JoyN6XWkQPdbDOZjTrZTytfTxvF sYBalBuEtpAn2KrnIcIYSHjYuB/B1hFRvO3VHqL185Jp7ZS6nePuNxl+rllhcy/88V 7sz/4SUO94syedeDSvRIhzR8CVAr4z8arkjxA0EA= 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 89724385E011 for ; Fri, 26 May 2023 07:36:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 89724385E011 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-30abe551605so383155f8f.0 for ; Fri, 26 May 2023 00:36:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685086561; x=1687678561; 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=rilRdZJoDL8eG0bQKsdWHcxSrctd9IX08PeTNvSQVJ8=; b=az3pLGI5cwYXS0byO+49XSqYi08El+Jf+ZlUL7dGe6hoMEzGP/xxd0PeU8lqiuPrjf PbQN6Ykw3XAAaDpMHEuQJBLDk4oa/GJvXCZdTJKtAiux4WZ/RuqxkqbzalyPOEner+1H qDvSHs2WX6OVQF+Zntm12PbV/2mADYZNu0yDJu17GV0HHsfa4rj9CW9gRhGXgGkTzgjY SrB7PJTm5tICyzbknxzpw1havIp562lIYlkb01+7fnsX2Q7GHutKgOzRTfEdevIC2ObP r1wmuF7OHTRK8/Fmn0mBuTuTcSzPm9aR6YoqIKZVmKStyMjcv8YjGpFfo1ulmiWYvw+q RYjw== X-Gm-Message-State: AC+VfDze35UNz8A4vRwIyhqMr5YmsaFq+YeEztw6T3qkI2SjEh4GKj7X AKOZT8vSxLZSM/avDDi9JOciT6VVK6YGnH7mMY7qIg== X-Google-Smtp-Source: ACHHUZ6XyW9UE/FsbRLooiQ7ZeP4yOGVsfOL2kRDPlA0c03kFk+aTGHHiXkN4LvHsB9K8QYn/t9FcA== X-Received: by 2002:a5d:60d0:0:b0:307:7be5:90d7 with SMTP id x16-20020a5d60d0000000b003077be590d7mr575097wrt.10.1685086561361; Fri, 26 May 2023 00:36:01 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:777b:eef4:6f79:f26f]) by smtp.gmail.com with ESMTPSA id y15-20020a5d4acf000000b00306299be5a2sm4157857wrs.72.2023.05.26.00.36.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 00:36:00 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Ghjuvan Lacambre Subject: [COMMITTED] ada: Handle new Controlling_Tag format when converting to SCIL Date: Fri, 26 May 2023 09:35:59 +0200 Message-Id: <20230526073559.2068284-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: Ghjuvan Lacambre This commit fixes two CodePeer crashes that were introduced when the format of the controlling tag changed. gcc/ada/ * exp_disp.adb (Expand_Dispatching_Call): Handle new Controlling_Tag. * sem_scil.adb (Check_SCIL_Node): Treat N_Object_Renaming_Declaration as N_Object_Declaration. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_disp.adb | 34 ++++++++++++++++++++++++++-------- gcc/ada/sem_scil.adb | 5 +++-- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb index e7cae38d553..494ead7c144 100644 --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -1133,18 +1133,36 @@ package body Exp_Disp is Set_SCIL_Controlling_Tag (SCIL_Node, Parent (Entity (Prefix (Controlling_Tag)))); - -- For a direct reference of the tag of the type the SCIL node - -- references the internal object declaration containing the tag - -- of the type. + -- Depending on whether a dereference is involved, the SCIL node + -- references the corresponding object/parameter declaration or + -- the internal object declaration containing the tag of the type. elsif Nkind (Controlling_Tag) = N_Attribute_Reference and then Attribute_Name (Controlling_Tag) = Name_Tag then - Set_SCIL_Controlling_Tag (SCIL_Node, - Parent - (Node - (First_Elmt - (Access_Disp_Table (Entity (Prefix (Controlling_Tag))))))); + declare + Prefix_Node : constant Node_Id := Prefix (Controlling_Tag); + Ent : constant Entity_Id := Entity + (if Nkind (Prefix_Node) = N_Explicit_Dereference then + Prefix (Prefix_Node) + else + Prefix_Node); + + begin + if Ekind (Ent) in E_Record_Type + | E_Record_Subtype + | E_Record_Type_With_Private + then + Set_SCIL_Controlling_Tag (SCIL_Node, + Parent + (Node + (First_Elmt + (Access_Disp_Table (Ent))))); + + else + Set_SCIL_Controlling_Tag (SCIL_Node, Parent (Ent)); + end if; + end; -- Interfaces are not supported. For now we leave the SCIL node -- decorated with the Controlling_Tag. More work needed here??? diff --git a/gcc/ada/sem_scil.adb b/gcc/ada/sem_scil.adb index 7c75c9d66bc..da8fab69a97 100644 --- a/gcc/ada/sem_scil.adb +++ b/gcc/ada/sem_scil.adb @@ -88,8 +88,9 @@ package body Sem_SCIL is -- object or parameter declaration. Interface types are still -- unsupported. - elsif Nkind (Ctrl_Tag) in - N_Object_Declaration | N_Parameter_Specification + elsif Nkind (Ctrl_Tag) in N_Object_Renaming_Declaration + | N_Object_Declaration + | N_Parameter_Specification then Ctrl_Typ := Etype (Defining_Identifier (Ctrl_Tag));