aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2019-12-13 09:03:50 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-12-13 09:03:50 +0000
commite841d4d8b3d1e64fe2f31329c8644ceca341874f (patch)
treeaed108db93f82ae274c1278b8bea90bd77d2f1b3 /gcc
parent90366d65738e17da9998dc5618d6e970b6ee3b48 (diff)
downloadgcc-e841d4d8b3d1e64fe2f31329c8644ceca341874f.zip
gcc-e841d4d8b3d1e64fe2f31329c8644ceca341874f.tar.gz
gcc-e841d4d8b3d1e64fe2f31329c8644ceca341874f.tar.bz2
[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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog11
-rw-r--r--gcc/ada/impunit.adb21
-rw-r--r--gcc/ada/impunit.ads18
-rw-r--r--gcc/ada/opt.ads6
-rw-r--r--gcc/ada/sem_ch10.adb43
5 files changed, 69 insertions, 30 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 5f2b502..209a2d4 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,16 @@
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.
2019-12-13 Gary Dismukes <dismukes@adacore.com>
diff --git a/gcc/ada/impunit.adb b/gcc/ada/impunit.adb
index 11d3a90..6bff383 100644
--- a/gcc/ada/impunit.adb
+++ b/gcc/ada/impunit.adb
@@ -613,6 +613,19 @@ package body Impunit is
("a-cvgpso", F) -- Ada.Containers.Vectors.Generic_Parallel_Sorting from
); -- 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 --
-----------------------
@@ -733,6 +746,14 @@ package body Impunit is
end if;
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
-- System.Garlic and special files of the form System.Aux...
diff --git a/gcc/ada/impunit.ads b/gcc/ada/impunit.ads
index 466cb86..7e6ea61 100644
--- a/gcc/ada/impunit.ads
+++ b/gcc/ada/impunit.ads
@@ -45,19 +45,13 @@ package Impunit is
-- This is not a predefined unit, so no checks are needed
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,
- -- This unit is defined in the Ada 2005 RM. Withing this unit from an
- -- Ada 95 mode program will generate a warning (again, strictly speaking
- -- this should be an error, but that seems over-strenuous).
-
- Ada_2012_Unit);
- -- This unit is defined in the Ada 2012 RM. Withing this unit from an
- -- Ada 95 or 2005 mode program will generate a warning (again, strictly
- -- speaking this should be an error, but that seems over-strenuous).
+ Ada_2012_Unit,
+ Ada_202X_Unit);
+ -- 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 when compiling with -gnat95). Note that in Ada 83 mode,
+ -- no child units are allowed, so you can't even name such a 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
diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads
index 9453464..fcfafc4 100644
--- a/gcc/ada/opt.ads
+++ b/gcc/ada/opt.ads
@@ -1767,6 +1767,12 @@ package Opt is
-- including warnings on Ada 2012 obsolescent features used in Ada 2012
-- 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;
-- GNAT
-- Set to True to generate warnings in all cases where a variable is
diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb
index 37518df..ae8bca7 100644
--- a/gcc/ada/sem_ch10.adb
+++ b/gcc/ada/sem_ch10.adb
@@ -2666,12 +2666,8 @@ package body Sem_Ch10 is
and then not Implicit_With (N)
and then not Restriction_Violation
then
- declare
- U_Kind : constant Kind_Of_Unit :=
- Get_Kind_Of_Unit (Get_Source_Unit (U));
-
- begin
- if U_Kind = Implementation_Unit then
+ case Get_Kind_Of_Unit (Get_Source_Unit (U)) is
+ when Implementation_Unit =>
Error_Msg_F ("& is an internal 'G'N'A'T unit?i?", Name (N));
-- Add alternative name if available, otherwise issue a
@@ -2685,19 +2681,30 @@ package body Sem_Ch10 is
& "version-dependent?i?", Name (N));
end if;
- elsif U_Kind = Ada_2005_Unit
- and then Ada_Version < Ada_2005
- and then Warn_On_Ada_2005_Compatibility
- then
- Error_Msg_N ("& is an Ada 2005 unit?i?", Name (N));
+ when Not_Predefined_Unit | Ada_95_Unit =>
+ null; -- no checks needed
- elsif U_Kind = Ada_2012_Unit
- and then 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;
- end;
+ when Ada_2005_Unit =>
+ if Ada_Version < Ada_2005
+ and then Warn_On_Ada_2005_Compatibility
+ then
+ Error_Msg_N ("& is an Ada 2005 unit?i?", Name (N));
+ end if;
+
+ 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;