+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.
("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 --
-----------------------
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...
-- 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
-- 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
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
& "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;