From patchwork Thu Dec 2 16:28:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 48402 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 379B43857C4A for ; Thu, 2 Dec 2021 16:38:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 379B43857C4A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1638463106; bh=2lLnwMqWmvbINeHonl6vYtySniIBhuWAzIjWbGTsZKo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=YTGBhMWD8rfP3Ri2bIWVZB0MzNcbzf+sI66ZvlxVf5ow13zz7WPz/IhFrLPGKFKhT IJpPGwXK25sdRAmZbAO9ehF0BCoZqNW7IdEONwIMchqniKjUI75Q7fYaj99K4fccGO a+8eLx8b1xNKor7zHMlztRo9x3VjHWamyDnpWI+Y= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 82931385C403 for ; Thu, 2 Dec 2021 16:28:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 82931385C403 Received: by mail-wr1-x42e.google.com with SMTP id d9so39985372wrw.4 for ; Thu, 02 Dec 2021 08:28:48 -0800 (PST) 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=2lLnwMqWmvbINeHonl6vYtySniIBhuWAzIjWbGTsZKo=; b=c2TKkjeA9IjT1V1ZykUBpSzkApw9RoscIsyU+tE/Lxw/WekAUA12w8Zy0YzZYoe5PF D8iQMsp2tFyGjKhgbWlg6hlccqlL8GqZD0dfQoISrG/OxxKGStgHqJ/HvI92oOdrHnW6 c4IzA7eA5IAeKfGPv/N1colsSU3I4SOrOYtU5HtsKOZN9ykVY8VI7cTvIMSok+rpzCT5 dxodczJsDt+CkuMoXhv+wsT4JyxoR62S4Ru90BT/3jMup6MFkNOrHsFi0wlTSIK+0m41 u0gR253xgzhd6Rxvw3f+rovVXfXt9enWcYBMS84gqfNJyOtHa5ySefdevNbYuFzMD2zE Td6g== X-Gm-Message-State: AOAM530ZGdlk98vtgFf1071l8NoMQXsXbFM8j7iTGqrKR2mgvR8m5gVF ajBZ5ybmGWf+y5GdDWGx6+0lx9PGZWiMaQ== X-Google-Smtp-Source: ABdhPJwL0sYHk5pY6T89iYcpM12PFrC61rEpbmq5k5TGnguWbZRLElrjlkSvKuUGsWg5KrAR9yBJUg== X-Received: by 2002:a5d:6d8c:: with SMTP id l12mr15471023wrs.435.1638462527669; Thu, 02 Dec 2021 08:28:47 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id w17sm223484wrp.79.2021.12.02.08.28.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 08:28:46 -0800 (PST) Date: Thu, 2 Dec 2021 16:28:46 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Don't allow entry in implicit with chain to be ghost Message-ID: <20211202162846.GA2157510@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.1 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Richard Kenner Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" When we add an entry to the implicit with chain of a unit while adding an RTS unit, we must not mark it as a ignored ghost statement because it points to the next with in the chain. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * rtsfind.adb (Maybe_Add_With): Ensure that the added "with" is never marked as ignored ghost code. diff --git a/gcc/ada/rtsfind.adb b/gcc/ada/rtsfind.adb --- a/gcc/ada/rtsfind.adb +++ b/gcc/ada/rtsfind.adb @@ -1248,9 +1248,10 @@ package body Rtsfind is -- for this unit to the current compilation unit. declare - LibUnit : constant Node_Id := Unit (Cunit (U.Unum)); - Clause : Node_Id; - Withn : Node_Id; + LibUnit : constant Node_Id := Unit (Cunit (U.Unum)); + Saved_GM : constant Ghost_Mode_Type := Ghost_Mode; + Clause : Node_Id; + Withn : Node_Id; begin Clause := U.First_Implicit_With; @@ -1262,11 +1263,18 @@ package body Rtsfind is Clause := Next_Implicit_With (Clause); end loop; + -- We want to make sure that the "with" we create below isn't + -- marked as ignored ghost code because this list may be walked + -- later, after ignored ghost code is converted to a null + -- statement. + + Ghost_Mode := None; Withn := Make_With_Clause (Standard_Location, Name => Make_Unit_Name (U, Defining_Unit_Name (Specification (LibUnit)))); + Ghost_Mode := Saved_GM; Set_Corresponding_Spec (Withn, U.Entity); Set_First_Name (Withn);