]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Fix warning about generic subprograms withed but not instantiated
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 11 Feb 2022 09:40:32 +0000 (10:40 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 12 May 2022 12:38:40 +0000 (12:38 +0000)
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.

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.

gcc/ada/atree.adb
gcc/ada/atree.ads
gcc/ada/fmap.adb
gcc/ada/fname-sf.adb
gcc/ada/libgnat/a-direct.adb
gcc/ada/libgnat/s-bignum.adb
gcc/ada/sem_ch12.adb

index bb4c3b46b41fba536b1179728190f06202d8addd..08e3667dffa94075059f5db8f21654dd34d98338 100644 (file)
@@ -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
 
index 417a7ab6f82f59ac2d6fbf896d057b7e3520e19a..9d01cfca140615d545ba3d1400a461dc4b310e60 100644 (file)
@@ -52,7 +52,6 @@ with Types;          use Types;
 with Seinfo;         use Seinfo;
 with System;         use System;
 with Table;
-with Unchecked_Conversion;
 
 package Atree is
 
index afa9ee443308100b2ad235aec5e0dc9349c2c8b6..0fa4649cd661c2053e9b3d961d5b48d6e39afb95 100644 (file)
@@ -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
index 39ce267abd52eb394b89a7f64decba49281fcaea..bb72b3004dc1adf1f628c49355926e030da9077b 100644 (file)
@@ -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
 
    ----------------------
index 2c07cc4a332b76cc54d8adb819c95da7ba659210..7a65587c003ac5e0f37f97e5926fbc4fbe90620e 100644 (file)
@@ -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;
index 937710290b9d233ae09ace945ce96dca49ac3977..93f22294f3d8e1125c1e0da4f8a4f99e92694653 100644 (file)
@@ -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;
index 963f353d063d1a0967b9059b10ed1302c9d25c3a..6a914ec880abc3c85e577d85bbf7ecbcb2bad9b3 100644 (file)
@@ -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;