From patchwork Wed Jul 13 10:02:53 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: 219 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp165440eik; Wed, 13 Jul 2022 03:09:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vMAfPQ6rKQ8kigQeQK2iiiF5VpV+cVEaczr7fscrVPQg3QPkiK13mxSJG3V1JaBXISvjbw X-Received: by 2002:aa7:c9d3:0:b0:43a:67b9:6eea with SMTP id i19-20020aa7c9d3000000b0043a67b96eeamr3805365edt.94.1657706952857; Wed, 13 Jul 2022 03:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657706952; cv=none; d=google.com; s=arc-20160816; b=mH5QhnhgHIHWqSlGLwjSpxlaRCTSPZol4pY4atcEg+bYYixu4rkK15oh3goAgAQVza DvPBSg4X+mUCyXCKwAriJ7p8fo9cwkqvcntgr+0K7WratbLeIYAnLlvQ7X+CWGPty25s pxw5cOKNYbVSDDK2K2tkn0rz0ojYpnHrEtZperhbjXky5CPlM2w0/RspS4ZPwCnCOHCw m9FwSYbBmMquduS6GrzKrmhn8LBVh3XgU3M11gIzN972V4UYBc4KCCQgaBbjL+XDAzUJ W0Z8iUQ8zds3a1AlOqgtgdHD8NmHfg4/E2zIeiBgpF/9lrqZxJUSb6g9QDYRzIpe/B0L PyFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Nt1+bDQZH3tfCsruYvfMW9HcHnw1sfiIHpZ+5dGe9y8=; b=hKLCTOME8VD3FGV1cCXcph9sWpGFAnWvFoVR5r2IPZfajwA7ifTGvlVf46+f2OTsLy B3FuUQAnOQcdxCfyzNi/L5Az4AQGqLPZhhgzqpwpmiXrnllaDG58Ql5d/3uXh9mQ6GQD m+tITU0+Vhyt4lHpNM39Ygy9QJFHUFMovllzDuWgq0Mxa4tWjqO0lCZIB0rgAMyPJPC5 ByK4DWfpkH2bjkdjAZ0/HL9cdYr9IUTAk00/hDGxeEUz4LwjA+Zd4fhEOR3AujZSKKVe tlF9M6yX240J0UdDBtateUtn0a42S/irPgl50j6n/XvqR5Fnu0h/oTqlbbbpc2a6nmFF Cojg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=oZz3V5uF; 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 sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id yr10-20020a170907334a00b00711bc35fedfsi13965282ejb.957.2022.07.13.03.09.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 03:09:12 -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=oZz3V5uF; 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 ABED0382C165 for ; Wed, 13 Jul 2022 10:05:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABED0382C165 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1657706737; bh=Nt1+bDQZH3tfCsruYvfMW9HcHnw1sfiIHpZ+5dGe9y8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=oZz3V5uFRkrBNURQCBaFxMJnC9CeJFdWHLRkSjvQogJC94MEdbpF+l2oqDH7f5qvs V/vqZVbprYsML4U6+Ku+gfScHFJi1lucbHR2cy+pyolI+5n6pNpllm9fsKB+3phHy5 PEfFVYxQzs217JHNdXmtlCi6jwYQJQSRMEePxFDU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 9C90A385141D for ; Wed, 13 Jul 2022 10:02:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9C90A385141D Received: by mail-ej1-x634.google.com with SMTP id bp15so8675508ejb.6 for ; Wed, 13 Jul 2022 03:02:55 -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=Nt1+bDQZH3tfCsruYvfMW9HcHnw1sfiIHpZ+5dGe9y8=; b=k0Y+eAz7zWIzyqQFE1+PMiGfKVrN/RM2P7+R0lF1dBHItiIo5j3isW0jvo6tcR5ojo SzU4dH4eq6VqbIk5/Fguf8jSYgLlvy87lw0dCCOnfgWMotolszOSQv+VXbKKkTfxG0jx Zqxc8aNk+rruUlvcdrT55hNgbhbZEHlcnMiCjwn2QvVelSOj5v2QF62iH8r2u6wh7iNR H7MvbqPWq3OE/kX4oCeOiOKa3I5+yNa/Ef0rnwVzvIZd6w081geRlXvr4v/fbbWrAWN4 VET8XEOQ6sgHqzKoaDZ/lU9NIN1gKnojNu9SHRwoX+m1UtPztz3jBm82MPGVk26ylp66 /vmQ== X-Gm-Message-State: AJIora+kX/u1Bplk+IsBdkiU78bYORYBk/lEBHTpZh+gveDHwJy5Kmn+ z7DBiNow0yPboim8kFEDi1GZ2wSRh3gxBA== X-Received: by 2002:a17:907:c0d:b0:72b:d0b0:2b55 with SMTP id ga13-20020a1709070c0d00b0072bd0b02b55mr1434878ejc.110.1657706574395; Wed, 13 Jul 2022 03:02:54 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id w13-20020aa7dccd000000b00435a62d35b5sm7627864edu.45.2022.07.13.03.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 03:02:53 -0700 (PDT) Date: Wed, 13 Jul 2022 10:02:53 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix incorrect handling of Ghost aspect Message-ID: <20220713100253.GA994627@adacore.com> MIME-Version: 1.0 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1738231726142203933?= X-GMAIL-MSGID: =?utf-8?q?1738231726142203933?= When a formal generic type is marked as Ghost, the instantiation of that generic will contain a generic subtype for the actual with the Ghost pragma. Recognize this case. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_prag.adb (Analyze_Pragma): Recognize a generated subtype with Ghost pragma for generic instantiations. diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -16999,6 +16999,16 @@ package body Sem_Prag is then Id := Defining_Entity (Stmt); exit; + + -- When pragma Ghost applies to a generic formal type, the + -- type declaration in the instantiation is a generated + -- subtype declaration. + + elsif Nkind (Stmt) = N_Subtype_Declaration + and then Present (Generic_Parent_Type (Stmt)) + then + Id := Defining_Entity (Stmt); + exit; end if; -- The pragma applies to a legal construct, stop the traversal