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: 1655935 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=sqUZXqiD; 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 4LjYCJ235Vz9ryY for ; Wed, 13 Jul 2022 20:05:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 359CF3885507 for ; Wed, 13 Jul 2022 10:05:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 359CF3885507 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1657706714; 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=sqUZXqiD6VIRaA4wURI6hrluVjSHWNhYCeXswq/4JeXqWi0oK1iOhdVSXkm+MG9Vz OoPk4J6SFtqihnMh9aDXLLcVu9K2AOZwEY6sLCa+eErD7+SVtz7Cdmv2wq2pHM4zjK oeTGBHt9i7UfFm0HxfGnv7DoJ4qBULVQhFIiYaxo= 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-Google-Smtp-Source: AGRyM1uhnGkg2b27ZjtJnFRI5ZmJT6oGTA5bWnt2ZXUzLz/LIaEPParDduOspilt/ZU+2bVcDfFYyA== 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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