From patchwork Tue Jul 18 13:13:35 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: 122019 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1739679vqt; Tue, 18 Jul 2023 06:18:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlFeuxEKqnev10AR1anyhuqekZLK6SDgOaHSckGFfJ7Wq6NdTzBlaIDw6YkAmQ2TFxvWBJ23 X-Received: by 2002:a05:6402:12d4:b0:51d:a308:74f9 with SMTP id k20-20020a05640212d400b0051da30874f9mr14268034edx.29.1689686336969; Tue, 18 Jul 2023 06:18:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689686336; cv=none; d=google.com; s=arc-20160816; b=eDFqID+zhjCitDgcsqmQufqXdscnXJibzZPNpWBX7cAE8JvFoZ3F7gTuPOfQte+lww YQzS56/6GZiNvDNbZT7ez7qFxd/iJKhZEYrCTs1T15+KF6rDRrbvI81ZsyGzqhZ5m3Vo f3J0EFEWrrA2ziurVJrIMixAjxDxzfPPJc18C4FPoTRx+CUCNLiM+41txYBJc3CP2IXG WpTpnS5388PTSzqDbnkD+Vci5RedmhecaY6nNSiDshEBfMOg7hz4sdbVLqov6fSiLIAv vUkqZX5xipx6metjGD35NhaZzA8wp28SF41Z776jgdyVhDAFFX0UKJWxc523OVE4EOGS SFVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=JFZ2nOOQI6F6Xv+KQx5Tp9/mfvQGSfS+0dKsIe6Lv10=; fh=mgcp2dPS/EOrPrvlUBKTekhhXYvk0GhGvlUG1Y0idUc=; b=XCnjODQ6w7wzo8oZktoG3lAsjwADI2aMvn+Pid+e+8jiFHMTszOWJVpZ+6JeQOOdSu 2IdVkW/OAJAddvn3ytP65h5Vlnc4DNf0oODrEh4OAJ4Xp4joMO1ayFT4uPLUWBXdpvJW TPE16s8nvEJh0qiCOefFnvHZPrctDSuGCZyxYfZw4lo6nR2AKn2d/lfW/prNyNXuaG+c SFbvIi4GLagkqBrPPTAA6uuzlRMYGSbX9PaQJAqUIQLkG7iDDIdM/4aWqVyNMsVa4gBh 3WKfSHZABX0zxgMdsAbVkbCfZgp+zXEUXdi2OketW7TDiOLDf8rqLqdwJ+fV5Ikx1uAh vBPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=CuuGpdj4; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i12-20020aa7c70c000000b00521937ee981si1204866edq.402.2023.07.18.06.18.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 06:18:56 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=CuuGpdj4; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9FE833829BC9 for ; Tue, 18 Jul 2023 13:15:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9FE833829BC9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689686138; bh=JFZ2nOOQI6F6Xv+KQx5Tp9/mfvQGSfS+0dKsIe6Lv10=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=CuuGpdj44Q5Ikr7/koOSUewrbBJcVvgUpJPG3OySDs9M6GBc0HOxSfIJt5ctug1bb eX4VfWO3TIoQiTbwyQutYsOopfUdmMsJe/aVfL6PtSILnd6E8vO+P6xO8h/+fcvecM YlVqjYokre4RlGIJG8UsFbkE0emtBcLX+ZSXaS5o= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id 645F6385AF96 for ; Tue, 18 Jul 2023 13:13:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 645F6385AF96 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3fbc63c2e84so56623315e9.3 for ; Tue, 18 Jul 2023 06:13:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689686016; x=1690290816; 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=JFZ2nOOQI6F6Xv+KQx5Tp9/mfvQGSfS+0dKsIe6Lv10=; b=XMOW58BE6nSd9CS68lwnQcSjElOO9z59tFxmW9hUbpcc9CrfjFUrmDd7jiW+RX8544 Nt33mBlxUJ31oq9suwIZTvsFmRCkDV/tgSJNkpdoXMO4yCDJYBLW1nJBYSywRsR7Rmh6 JGU2ToJCBp9FhSs5X+yaNmEteJQbLiT/3wa+Eg5vWKuSnjME1IdxMu0rAsjzyhUSVXXT aw7FqtohL4Jr8zM6UhWDyppVw7+NyWkriU5rAur1/SLXdeZz+X5IaGrklRvN/lxqbFce Hv5nLMDohZt1GqdYanGbncnIM3uwoGN/5E1sdklTlSrbX8n12Gklb92qc5SCMiLflc+l n0sg== X-Gm-Message-State: ABy/qLZ61ILY+Sxub6b1kFEEhetuaa7pyq7HtkTvwVVu/rjuHTrF5XSQ TzR0PwTNfT3xTZ+OJ/78v8WJ8SPxIcYPWPVq+xD47Q== X-Received: by 2002:a7b:ca4c:0:b0:3f8:fc96:6bfd with SMTP id m12-20020a7bca4c000000b003f8fc966bfdmr1803853wml.17.1689686016188; Tue, 18 Jul 2023 06:13:36 -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 h14-20020a1ccc0e000000b003fbb618f7adsm2157231wmb.15.2023.07.18.06.13.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 06:13:35 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED] ada: Constraint_Error caused by interface conversion Date: Tue, 18 Jul 2023 15:13:35 +0200 Message-Id: <20230718131335.81230-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771764540348750527 X-GMAIL-MSGID: 1771764540348750527 From: Javier Miranda When the sources have a type conversion from an interface type T2 to some ancestor interface type T1 (that is, T2 extends T1) the tag check added by the compiler may fail at runtime. gcc/ada/ * exp_disp.adb (Has_Dispatching_Constructor_Call): Removed. (Expand_Interface_Conversion): Reverse patch. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_disp.adb | 94 ++------------------------------------------ 1 file changed, 4 insertions(+), 90 deletions(-) diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb index 9381ceee60c..9e0c87a5095 100644 --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -1242,92 +1242,9 @@ package body Exp_Disp is procedure Expand_Interface_Conversion (N : Node_Id) is - function Has_Dispatching_Constructor_Call - (Expr : Node_Id) return Boolean; - -- Determines if the expression has a dispatching constructor call - function Underlying_Record_Type (Typ : Entity_Id) return Entity_Id; -- Return the underlying record type of Typ - -------------------------------------- - -- Has_Dispatching_Constructor_Call -- - -------------------------------------- - - function Has_Dispatching_Constructor_Call (Expr : Node_Id) return Boolean - is - function Is_Dispatching_Constructor_Call (N : Node_Id) return Boolean; - -- Determines if N is a dispatching constructor call - - function Process (Nod : Node_Id) return Traverse_Result; - -- Traverse the expression searching for constructor calls - - ------------------------------------- - -- Is_Dispatching_Constructor_Call -- - ------------------------------------- - - function Is_Dispatching_Constructor_Call (N : Node_Id) return Boolean - is - Param : Node_Id; - Param_Type : Entity_Id; - Assoc_Node : Node_Id; - Gen_Func_Id : Entity_Id; - - begin - if Nkind (N) = N_Function_Call - and then Present (Parameter_Associations (N)) - then - Param := First (Parameter_Associations (N)); - - if Nkind (Param) = N_Parameter_Association then - Param := Selector_Name (Param); - end if; - - Param_Type := Etype (Param); - - if Is_Itype (Param_Type) then - Assoc_Node := Associated_Node_For_Itype (Param_Type); - - if Nkind (Assoc_Node) = N_Function_Specification - and then Present (Generic_Parent (Assoc_Node)) - then - Gen_Func_Id := Generic_Parent (Assoc_Node); - - if Is_Intrinsic_Subprogram (Gen_Func_Id) - and then Chars (Gen_Func_Id) - = Name_Generic_Dispatching_Constructor - then - return True; - end if; - end if; - end if; - end if; - - return False; - end Is_Dispatching_Constructor_Call; - - ------------- - -- Process -- - ------------- - - function Process (Nod : Node_Id) return Traverse_Result is - begin - if Nkind (Nod) = N_Function_Call - and then Is_Dispatching_Constructor_Call (Nod) - then - return Abandon; - end if; - - return OK; - end Process; - - function Traverse_Expression is new Traverse_Func (Process); - - -- Start of processing for Has_Dispatching_Constructor_Call - - begin - return Traverse_Expression (Expr) = Abandon; - end Has_Dispatching_Constructor_Call; - ---------------------------- -- Underlying_Record_Type -- ---------------------------- @@ -1430,16 +1347,13 @@ package body Exp_Disp is -- object to reference the corresponding secondary dispatch table -- (cf. Make_DT and Expand_Dispatching_Constructor_Call)). - -- Under regular runtime this is a minor optimization that improves - -- the generated code; under configurable runtime (where generic - -- dispatching constructors are not supported) this optimization - -- allows supporting this interface conversion, which otherwise - -- would require calling the runtime routine to displace the - -- pointer to the object. + -- Under configurable runtime it is safe to skip generating code to + -- displace the pointer to the object, because generic dispatching + -- constructors are not supported. elsif Is_Interface (Iface_Typ) and then Is_Ancestor (Iface_Typ, Opnd, Use_Full_View => True) - and then not Has_Dispatching_Constructor_Call (Operand) + and then not RTE_Available (RE_Displace) then return; end if;