From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 2E09B385043A for ; Fri, 13 May 2022 08:07:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E09B385043A Received: by mail-wr1-x42e.google.com with SMTP id d5so10343894wrb.6 for ; Fri, 13 May 2022 01:07:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=xmZeD2DQqfszAtrB8pzhwb4LKeZtgeJFslAfyCsrCxc=; b=KcAbg+Qzf9DQQfFZWf/fktC+rMwyFJNTzxpAjmJN30KUGVz9qtwXLOfQTgBpPfJqC+ m4bBMEZuJC9s+SOc8VePdHOh2khSmH6JuQpF2o+gyo7rBCgbxlGC+BIAl5zrajQdWmG/ zuGr4KG0a5O281JxSCgr9kLLLwQttVWLWUFW92Yn+8xMGRGqqPdfyE3Ywee2W+A6wg+y /Hmgxjy+tjpup9F8n7ofMfmNc3RvIQQkGVm3sDQpmrGuTeoA53SmCNH4uJuKGtOIr6ra McBaS+ndLReDm57/LJUSqUEcLPc/RGyZgXOo4X2RFOKULhkJr9b3d4H4kTXwhCbG6dot mTYQ== X-Gm-Message-State: AOAM532MctRHZq1AVgCkikI9MCLLraqJM6kXPs0gmGvwVsS2q/kCOHkq mQ4cn9sVwh9orO7UUtMbDLYGRyFPxOIoAw== X-Google-Smtp-Source: ABdhPJz+SUM/eRrrGMTipF/SF7h3injzbt/XjeeFaX5h3UblvsOpTUqyJhvzdsHTW7dDzGnaSxEenQ== X-Received: by 2002:a5d:444f:0:b0:20a:cd55:8c32 with SMTP id x15-20020a5d444f000000b0020acd558c32mr2907996wrr.586.1652429268869; Fri, 13 May 2022 01:07:48 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id k20-20020a7bc414000000b003942a244ee9sm1614760wmi.46.2022.05.13.01.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 01:07:48 -0700 (PDT) Date: Fri, 13 May 2022 08:07:48 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [Ada] Ada ABI change when building with assertions Message-ID: <20220513080748.GA2525022@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Q68bSM7Ycu6FN28Q" Content-Disposition: inline X-Spam-Status: No, score=-13.2 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-List-Received-Date: Fri, 13 May 2022 08:07:51 -0000 --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Compiling with and without assertions enabled the name of some generated symbols differ; this is an issue when using pre-built libraries. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Check_Inherited_Conditions): Dispatch table wrappers must be placed in the list of entities of their scope at the same place of their wrapped primitive. This is required for private types since these wrappers are built when their full tagged type declaration is frozen but they may override a primitive defined in the public part of the package (and it is important to maintain the wrapper in the list of public entities of the package to ensure their correct visibility). --Q68bSM7Ycu6FN28Q Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -1981,6 +1981,9 @@ package body Freeze is DTW_Id : Entity_Id; DTW_Spec : Node_Id; + Prim_Next_E : constant Entity_Id := Next_Entity (Prim); + Prim_Prev_E : constant Entity_Id := Prev_Entity (Prim); + begin -- The wrapper must be analyzed in the scope of its wrapped -- primitive (to ensure its correct decoration). @@ -2049,9 +2052,46 @@ package body Freeze is Insert_Before_And_Analyze (Freeze_Node (R), DTW_Decl); else Append_Freeze_Action (R, DTW_Decl); + Analyze (DTW_Decl); end if; - Analyze (DTW_Decl); + -- The analyis of DTW_Decl has removed Prim from its scope + -- chain and added DTW_Id at the end of the scope chain. Move + -- DTW_Id to its correct place in the scope chain: the analysis + -- of the wrapper declaration has just added DTW_Id at the end + -- of the list of entities of its scope. However, given that + -- this wrapper overrides Prim, we must move DTW_Id to the + -- original place of Prim in its scope chain. This is required + -- for wrappers of private type primitives to ensure their + -- correct visibility since wrappers are built when the full + -- tagged type declaration is frozen (in the private part of + -- the package) but they may override primitives defined in the + -- public part of the package. + + declare + DTW_Prev_E : constant Entity_Id := Prev_Entity (DTW_Id); + + begin + pragma Assert (Last_Entity (Current_Scope) = DTW_Id); + pragma Assert + (Ekind (Current_Scope) not in E_Package | E_Generic_Package + or else No (First_Private_Entity (Current_Scope)) + or else First_Private_Entity (Current_Scope) /= DTW_Id); + + -- Remove DTW_Id from the end of the doubly-linked list of + -- entities of this scope; no need to handle removing it + -- from the beginning of the chain since such case can never + -- occur for this entity. + + Set_Last_Entity (Current_Scope, DTW_Prev_E); + Set_Next_Entity (DTW_Prev_E, Empty); + + -- Place DTW_Id back in the original place of its wrapped + -- primitive in the list of entities of this scope. + + Link_Entities (Prim_Prev_E, DTW_Id); + Link_Entities (DTW_Id, Prim_Next_E); + end; -- Insert the body of the wrapper in the freeze actions of -- its record type declaration to ensure that it is placed --Q68bSM7Ycu6FN28Q--