From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 A89F5383D807 for ; Thu, 12 May 2022 12:40:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A89F5383D807 Received: by mail-wr1-x429.google.com with SMTP id b19so7051386wrh.11 for ; Thu, 12 May 2022 05:40:12 -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=H2NPCJoveOrvkqH7dbuUHZdIdDQ2p4atLF2Vz3UWDRU=; b=D/NJfCE/xLvkRirdaC62iv70/GRhbw8AQfh8Txkkb2+TmZkAXhK+g4rYLk2MP0jtXx YxF5vZt7IOM0xRBRPutGmoaaF2Vlf1e7cbN12yw/cJRblLa0IuLAOw0QDtzzway8Kzl5 6KaBpo+g54NARaDICX6opsYwMymbW9Hg9u9P5pjQ7LLsTBulEUCAzNrFFesvBY6W9+Kf Mk1km0r/k9MedyF6P7RPxQemk2rrsIasQDnkugw7IkIv6jDFhdTMlchY7NPGTEGAz66r HNnVMF+fVj1atY3gq0k4nMX/Yn91CZUAw+VV+XBD3z4+mwKiyKQcYi7N/ikjwolOMlGh Zs3Q== X-Gm-Message-State: AOAM532Zz4DGhdNyLlX2v1d+XiwNHdh+qzWCWOAPgyhcwZ/yDnwsR6yZ IAYiYkSgcCSocsrUDeKX8UcqJcj+5t1IYw== X-Google-Smtp-Source: ABdhPJzCLXycuBL1fZC1ujSgSPK45ymt0WTCFpXbjW01wWWndKf2jGQYiM6n+sxTdIyseQ3/pFeLxQ== X-Received: by 2002:a05:6000:1f9d:b0:20c:87b6:e775 with SMTP id bw29-20020a0560001f9d00b0020c87b6e775mr27015267wrb.253.1652359211452; Thu, 12 May 2022 05:40:11 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id o20-20020a1c4d14000000b0039453fe55a7sm2554514wmh.35.2022.05.12.05.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 05:40:10 -0700 (PDT) Date: Thu, 12 May 2022 12:40:10 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [Ada] Fix warning about generic subprograms withed but not instantiated Message-ID: <20220512124010.GA781101@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="fdj2RfSjLxBAspz7" Content-Disposition: inline X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, 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: Thu, 12 May 2022 12:40:14 -0000 --fdj2RfSjLxBAspz7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline The compiler should warn when a generic subprogram unit is withed but not instantiated by the current main unit. This warning relies on flag Is_Instantiated, which was wrongly set when the generic unit was also withed and instantiated by some other unit. This change merely reverts a fix done 20 years ago, which worked around some spurious warning emitted with inlining enabled. Now the Is_Instantiated flag is set similarly for generic subprograms and generic packages. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * atree.adb, atree.ads: Move WITH clause from spec to body; to prevent new warnings stopping the bootstrap. * fmap.adb, fname-sf.adb, libgnat/a-direct.adb, libgnat/s-bignum.adb: Remove unnecessary WITH clauses; to prevent new warnings stopping the bootstrap. * sem_ch12.adb (Analyze_Subprogram_Instantiation): Only set Is_Instantiated flag when the instance is in the extended main source unit. --fdj2RfSjLxBAspz7 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/atree.adb b/gcc/ada/atree.adb --- a/gcc/ada/atree.adb +++ b/gcc/ada/atree.adb @@ -31,6 +31,7 @@ with Opt; use Opt; with Output; use Output; with Sinfo.Utils; use Sinfo.Utils; with System.Storage_Elements; +with Unchecked_Conversion; package body Atree is diff --git a/gcc/ada/atree.ads b/gcc/ada/atree.ads --- a/gcc/ada/atree.ads +++ b/gcc/ada/atree.ads @@ -52,7 +52,6 @@ with Types; use Types; with Seinfo; use Seinfo; with System; use System; with Table; -with Unchecked_Conversion; package Atree is diff --git a/gcc/ada/fmap.adb b/gcc/ada/fmap.adb --- a/gcc/ada/fmap.adb +++ b/gcc/ada/fmap.adb @@ -34,8 +34,6 @@ pragma Warnings (Off); with System.OS_Lib; use System.OS_Lib; pragma Warnings (On); -with Unchecked_Conversion; - with GNAT.HTable; package body Fmap is diff --git a/gcc/ada/fname-sf.adb b/gcc/ada/fname-sf.adb --- a/gcc/ada/fname-sf.adb +++ b/gcc/ada/fname-sf.adb @@ -30,8 +30,6 @@ with Osint; use Osint; with Types; use Types; with System.OS_Lib; use System.OS_Lib; -with Unchecked_Conversion; - package body Fname.SF is ---------------------- diff --git a/gcc/ada/libgnat/a-direct.adb b/gcc/ada/libgnat/a-direct.adb --- a/gcc/ada/libgnat/a-direct.adb +++ b/gcc/ada/libgnat/a-direct.adb @@ -38,7 +38,6 @@ use Ada.Directories.Hierarchical_File_Names; with Ada.Strings.Fixed; with Ada.Strings.Maps; use Ada.Strings.Maps; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; -with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with Interfaces.C; diff --git a/gcc/ada/libgnat/s-bignum.adb b/gcc/ada/libgnat/s-bignum.adb --- a/gcc/ada/libgnat/s-bignum.adb +++ b/gcc/ada/libgnat/s-bignum.adb @@ -29,7 +29,6 @@ -- -- ------------------------------------------------------------------------------ -with Ada.Unchecked_Conversion; with System.Generic_Bignums; with System.Secondary_Stack; use System.Secondary_Stack; with System.Shared_Bignums; use System.Shared_Bignums; diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -5708,9 +5708,9 @@ package body Sem_Ch12 is Set_Scope (Inst_Id, Current_Scope); Set_Entity (Gen_Id, Gen_Unit); - Set_Is_Instantiated (Gen_Unit); if In_Extended_Main_Source_Unit (N) then + Set_Is_Instantiated (Gen_Unit); Generate_Reference (Gen_Unit, N); end if; --fdj2RfSjLxBAspz7--