Commit e841d4d8 by Bob Duff Committed by Pierre-Marie de Rodat

[Ada] Ada2020: Update Impunit for Ada 202X

2019-12-13  Bob Duff  <duff@adacore.com>

gcc/ada/

	* impunit.ads: Add Ada_202X_Unit.
	* impunit.adb: Add a table Non_Imp_File_Names_2X analogous to
	the other tables. Add code to search this table.
	* opt.ads: Add Warn_On_Ada_202X_Compatibility flag, currently
	always True.
	* sem_ch10.adb (Analyze_With_Clause): Give a warning if an Ada
	2020 unit is with-ed when Ada_Version < Ada_2020.  Change 'if'
	to 'case': Full coverage rules rule.

From-SVN: r279346
parent 90366d65
2019-12-13 Bob Duff <duff@adacore.com> 2019-12-13 Bob Duff <duff@adacore.com>
* impunit.ads: Add Ada_202X_Unit.
* impunit.adb: Add a table Non_Imp_File_Names_2X analogous to
the other tables. Add code to search this table.
* opt.ads: Add Warn_On_Ada_202X_Compatibility flag, currently
always True.
* sem_ch10.adb (Analyze_With_Clause): Give a warning if an Ada
2020 unit is with-ed when Ada_Version < Ada_2020. Change 'if'
to 'case': Full coverage rules rule.
2019-12-13 Bob Duff <duff@adacore.com>
* rtsfind.ads: Minor comment fix. * rtsfind.ads: Minor comment fix.
2019-12-13 Gary Dismukes <dismukes@adacore.com> 2019-12-13 Gary Dismukes <dismukes@adacore.com>
......
...@@ -613,6 +613,19 @@ package body Impunit is ...@@ -613,6 +613,19 @@ package body Impunit is
("a-cvgpso", F) -- Ada.Containers.Vectors.Generic_Parallel_Sorting from ("a-cvgpso", F) -- Ada.Containers.Vectors.Generic_Parallel_Sorting from
); -- GNATCOLL.OMP ); -- GNATCOLL.OMP
--------------------
-- Ada 202X Units --
--------------------
-- The following units should be used only in Ada 202X mode
Non_Imp_File_Names_2X : constant File_List := (
0 => ("a-stteou", T) -- Ada.Strings.Text_Output
-- ???We use named notation, because there is only one of these so far.
-- When we add more, we should switch to positional notation, and erase
-- the "0 =>".
);
----------------------- -----------------------
-- Alternative Units -- -- Alternative Units --
----------------------- -----------------------
...@@ -733,6 +746,14 @@ package body Impunit is ...@@ -733,6 +746,14 @@ package body Impunit is
end if; end if;
end loop; end loop;
-- See if name is in 202X list
for J in Non_Imp_File_Names_2X'Range loop
if Buffer = Non_Imp_File_Names_2X (J).Fname then
return Ada_202X_Unit;
end if;
end loop;
-- Only remaining special possibilities are children of System.RPC and -- Only remaining special possibilities are children of System.RPC and
-- System.Garlic and special files of the form System.Aux... -- System.Garlic and special files of the form System.Aux...
......
...@@ -45,19 +45,13 @@ package Impunit is ...@@ -45,19 +45,13 @@ package Impunit is
-- This is not a predefined unit, so no checks are needed -- This is not a predefined unit, so no checks are needed
Ada_95_Unit, Ada_95_Unit,
-- This unit is defined in the Ada 95 RM, and can be freely with'ed in
-- both Ada 95 mode and Ada 05 mode. Note that in Ada 83 mode, no child
-- units are allowed, so you can't even name such a unit.
Ada_2005_Unit, Ada_2005_Unit,
-- This unit is defined in the Ada 2005 RM. Withing this unit from an Ada_2012_Unit,
-- Ada 95 mode program will generate a warning (again, strictly speaking Ada_202X_Unit);
-- this should be an error, but that seems over-strenuous). -- This unit is defined in the Ada RM of the given year. This is used to
-- give a warning when withing a unit from a wrong mode (e.g. withing an
Ada_2012_Unit); -- Ada_2012_Unit when compiling with -gnat95). Note that in Ada 83 mode,
-- This unit is defined in the Ada 2012 RM. Withing this unit from an -- no child units are allowed, so you can't even name such a unit.
-- Ada 95 or 2005 mode program will generate a warning (again, strictly
-- speaking this should be an error, but that seems over-strenuous).
function Get_Kind_Of_Unit (U : Unit_Number_Type) return Kind_Of_Unit; function Get_Kind_Of_Unit (U : Unit_Number_Type) return Kind_Of_Unit;
-- Given the unit number of a unit, this function determines the type -- Given the unit number of a unit, this function determines the type
......
...@@ -1767,6 +1767,12 @@ package Opt is ...@@ -1767,6 +1767,12 @@ package Opt is
-- including warnings on Ada 2012 obsolescent features used in Ada 2012 -- including warnings on Ada 2012 obsolescent features used in Ada 2012
-- mode. Modified by use of -gnatwy/Y. -- mode. Modified by use of -gnatwy/Y.
Warn_On_Ada_202X_Compatibility : Boolean := True;
-- GNAT
-- Set to True to generate all warnings on Ada 202X compatibility issues,
-- including warnings on Ada 202X obsolescent features used in Ada 202X
-- mode. ???There is no warning switch for this yet.
Warn_On_All_Unread_Out_Parameters : Boolean := False; Warn_On_All_Unread_Out_Parameters : Boolean := False;
-- GNAT -- GNAT
-- Set to True to generate warnings in all cases where a variable is -- Set to True to generate warnings in all cases where a variable is
......
...@@ -2666,12 +2666,8 @@ package body Sem_Ch10 is ...@@ -2666,12 +2666,8 @@ package body Sem_Ch10 is
and then not Implicit_With (N) and then not Implicit_With (N)
and then not Restriction_Violation and then not Restriction_Violation
then then
declare case Get_Kind_Of_Unit (Get_Source_Unit (U)) is
U_Kind : constant Kind_Of_Unit := when Implementation_Unit =>
Get_Kind_Of_Unit (Get_Source_Unit (U));
begin
if U_Kind = Implementation_Unit then
Error_Msg_F ("& is an internal 'G'N'A'T unit?i?", Name (N)); Error_Msg_F ("& is an internal 'G'N'A'T unit?i?", Name (N));
-- Add alternative name if available, otherwise issue a -- Add alternative name if available, otherwise issue a
...@@ -2685,19 +2681,30 @@ package body Sem_Ch10 is ...@@ -2685,19 +2681,30 @@ package body Sem_Ch10 is
& "version-dependent?i?", Name (N)); & "version-dependent?i?", Name (N));
end if; end if;
elsif U_Kind = Ada_2005_Unit when Not_Predefined_Unit | Ada_95_Unit =>
and then Ada_Version < Ada_2005 null; -- no checks needed
and then Warn_On_Ada_2005_Compatibility
then
Error_Msg_N ("& is an Ada 2005 unit?i?", Name (N));
elsif U_Kind = Ada_2012_Unit when Ada_2005_Unit =>
and then Ada_Version < Ada_2012 if Ada_Version < Ada_2005
and then Warn_On_Ada_2012_Compatibility and then Warn_On_Ada_2005_Compatibility
then then
Error_Msg_N ("& is an Ada 2012 unit?i?", Name (N)); Error_Msg_N ("& is an Ada 2005 unit?i?", Name (N));
end if; end if;
end;
when Ada_2012_Unit =>
if Ada_Version < Ada_2012
and then Warn_On_Ada_2012_Compatibility
then
Error_Msg_N ("& is an Ada 2012 unit?i?", Name (N));
end if;
when Ada_202X_Unit =>
if Ada_Version < Ada_2020
and then Warn_On_Ada_202X_Compatibility
then
Error_Msg_N ("& is an Ada 202X unit?i?", Name (N));
end if;
end case;
end if; end if;
end if; end if;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment