From patchwork Tue Jul 5 08:30:01 2022 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: 1652355 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=YvBvRxEF; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LcbdR1QGMz9s1l for ; Tue, 5 Jul 2022 18:37:15 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 86C653898380 for ; Tue, 5 Jul 2022 08:37:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 86C653898380 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1657010232; bh=dxmeoNe7GAb7Ou/7vs5OvkS62JieQiZH+uXUYZDf3aY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=YvBvRxEFb1tniXgYyp68usnN+XKDnjB5UelpqBaSH5u72YVAlboTUbx81m4BByq8A oUUtBXPOfHFXtaP8OJhIaun42SYlWiRaCHdV2z9Ua90v1Qv8Qg9rUSTQyk97AOIXkk 4rdEOtZsPVcWnkPp/qgOOIM5hqRfxPnKc3fZfUFo= 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 CDD253852777 for ; Tue, 5 Jul 2022 08:30:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CDD253852777 Received: by mail-wr1-x429.google.com with SMTP id d16so10112427wrv.10 for ; Tue, 05 Jul 2022 01:30:03 -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=dxmeoNe7GAb7Ou/7vs5OvkS62JieQiZH+uXUYZDf3aY=; b=i4COgobx3ZvhPjAN1r7r/c7/nyoFneBCdN+8zwDbm1106n9XVctJqS/Y4dylJ3gpl9 894ZSNtIoTp4cOb0FWcQ5wRX1IvHXHp71/59AtA7mnU7APFrHT0daMhFJEA56fUSnMbH KDN8snAnuMMirq1ta8Yx2OxqrmBN2a++4Hs/+5Q0LC9ilMBY8tfLvniSKOJkxEPOd9Ix ThIwYG8bp5DB9b3GvOYjXkYUbAlZHr6rldTcxphW5rfGDrV9FWqAg4KgoCxuK9TRi2Jk Un3dnWaiSdCUwphFTc4GRYkrUNpxiTwq2Vf/Dvmg95yb5OevqG0VouQQybYPqfwH0u6j jApA== X-Gm-Message-State: AJIora+2Zsd4/Or56A3pyy0Zqkf3tPKI8aEZAqHtriLounYENCZdGcN8 X1+mgtiNAzwATm5xPuia5Ijy3xDgFvyrhQ== X-Google-Smtp-Source: AGRyM1sKlz0dS4k4e3BgXkvnR9jwf/yN/s+52MCOWhXNrcy6ZpKR6YJ3KUS5fG/YvkmEKQwIcL5gtg== X-Received: by 2002:a05:6000:144a:b0:21b:c9bc:ec87 with SMTP id v10-20020a056000144a00b0021bc9bcec87mr32012822wrx.178.1657009802661; Tue, 05 Jul 2022 01:30:02 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id t5-20020a1c4605000000b0039db31f6372sm18459929wma.2.2022.07.05.01.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 01:30:02 -0700 (PDT) Date: Tue, 5 Jul 2022 08:30:01 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix spurious error on object renaming with ghost type Message-ID: <20220705083001.GA3191542@adacore.com> MIME-Version: 1.0 Content-Disposition: inline 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, 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: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Yannick Moy Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Renaming of an object of ghost type leads to a spurious error. Now fixed. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * ghost.adb (Is_OK_Ghost_Context): Detect ghost type inside object renaming. diff --git a/gcc/ada/ghost.adb b/gcc/ada/ghost.adb --- a/gcc/ada/ghost.adb +++ b/gcc/ada/ghost.adb @@ -508,7 +508,16 @@ package body Ghost is elsif Nkind (Parent (Par)) in N_Generic_Instantiation | N_Renaming_Declaration | N_Generic_Renaming_Declaration - and then Par = Name (Parent (Par)) + and then Par = Name (Parent (Par)) + then + return True; + + -- In the case of the renaming of a ghost object, the type + -- itself may be ghost. + + elsif Nkind (Parent (Par)) = N_Object_Renaming_Declaration + and then (Par = Subtype_Mark (Parent (Par)) + or else Par = Access_Definition (Parent (Par))) then return True;