[Ada] Fix warning about generic subprograms withed but not instantiated

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.
This commit is contained in:
Piotr Trojanek 2022-02-11 10:40:32 +01:00 committed by Pierre-Marie de Rodat
parent dff98f76fb
commit 3707c8feb1
7 changed files with 2 additions and 8 deletions

View 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

View 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

View 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

View 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
----------------------

View 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;

View 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;

View 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;