+2010-08-10 Robert Dewar <dewar@adacore.com>
+
+ * a-chahan.ads: Add comments on handling of obsolescent entries.
+ * opt.ads: Add Ada_2005 and Ada_2012 renamings for versions.
+ * restrict.adb (Check_Obsolescent_2005_Entity): New procedure.
+ * restrict.ads (Check_Obsolescent_2005_Entity): New procedure.
+ * sem_attr.adb (Analyze_Access_Attribute): Call
+ Check_Obsolescent_2005_Entity to check for access to obsolescent
+ Ada.Characters.Handling subprogram.
+ (Analyze_Attribute, case Class): Applying Class to untagged incomplete
+ type is obsolescent in Ada 2005.
+ (Analyze_Attribute, case Constrained): Better placement of flag when
+ flagged as obsolescent feature.
+ (Analyze_Attribute, case Storage_Size): Use with tasks is obsolescent
+ * sem_ch10.adb (Analyze_With_Clause): With of renamings such as Text_IO
+ is an obsolescent feature.
+ * sem_ch11.adb (Analyze_Raise_Statement): Numeric_Error is obsolescent
+ feature.
+ * sem_ch8.adb (Analyze_Subprogram_Renaming): Call
+ Check_Obsolescent_2005_Entity to check for renaming obsolete
+ Ada.Characters.Handling subprogram.
+ * sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings): Check
+ for obsolescent restrictions in Ada 2005.
+ (Analyze_Pragma, case Suppress): Entity arg is obsolescent in Ada 2005
+ (Analyze_Pragma, case Interface): Interface is obsolescent in Ada 2005
+ * sem_res.adb (Resolve_Call): Call Check_Obsolescent_2005_Entity to
+ check for obsolescent references to Ada.Characters.Handling subprograms
+
+2010-08-10 Robert Dewar <dewar@adacore.com>
+
+ * einfo.adb, einfo.ads: Fix bad -gnatdt output for incomplete type.
+
+2010-08-10 Robert Dewar <dewar@adacore.com>
+
+ * errout.ads: Add VMS table entries for 2005, 12, 2012 switches
+ * par-ch4.adb: Change wording of Ada 2012 messages
+ * vms_data.ads: Add VMS entries for /2005, /12, /2012
+
2010-08-10 Robert Dewar <dewar@adacore.com>
* a-suenco.adb (Convert): Fix bug in UTF-16 to UTF-8 conversion for
-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- to use these routines when creating code that is intended to run in
-- either Ada 95 or Ada 2005 mode.
+ -- We do however have to flag these if the pragma No_Obsolescent_Features
+ -- restriction is active (see Restrict.Check_Obsolescent_2005_Entity).
+
function Is_Character (Item : Wide_Character) return Boolean;
function Is_String (Item : Wide_String) return Boolean;
-- to use these routines when creating code that is intended to run in
-- either Ada 95 or Ada 2005 mode.
+ -- We do however have to flag these if the pragma No_Obsolescent_Features
+ -- restriction is active (see Restrict.Check_Obsolescent_2005_Entity).
+
function To_Character
(Item : Wide_Character;
Substitute : Character := ' ') return Character;
Write_Str ("Storage_Size_Variable");
when Class_Wide_Kind |
+ Incomplete_Kind |
E_Record_Type |
E_Record_Subtype |
Private_Kind =>
-- is an error to reference the primitive operations field of a type
-- that is not tagged). In order to fulfill the C++ ABI, entities of
-- primitives that come from source must be stored in this list following
--- their order of occurrence in the sources.
+-- their order of occurrence in the sources. Also present in incomplete
+-- types, but in this case the list is always empty.
-- Prival (Node17)
-- Present in private components of protected types. Refers to the entity
Gname5 : aliased constant String := "gnat05";
Vname5 : aliased constant String := "05";
- Gname6 : aliased constant String := "gnat12";
- Vname6 : aliased constant String := "12";
+ Gname6 : aliased constant String := "gnat2005";
+ Vname6 : aliased constant String := "2005";
+
+ Gname7 : aliased constant String := "gnat12";
+ Vname7 : aliased constant String := "12";
+
+ Gname8 : aliased constant String := "gnat2012";
+ Vname8 : aliased constant String := "2012";
type Cstring_Ptr is access constant String;
Gname3'Access,
Gname4'Access,
Gname5'Access,
- Gname6'Access);
+ Gname6'Access,
+ Gname7'Access,
+ Gname8'Access);
Vnames : array (Nat range <>) of Cstring_Ptr :=
(Vname1'Access,
Vname3'Access,
Vname4'Access,
Vname5'Access,
- Vname6'Access);
+ Vname6'Access,
+ Vname7'Access,
+ Vname8'Access);
-----------------------------------------------------
-- Global Values Used for Error Message Insertions --
-- Versions of Ada for Ada_Version below. Note that these are ordered,
-- so that tests like Ada_Version >= Ada_95 are legitimate and useful.
+ Ada_2005 : Ada_Version_Type renames Ada_05;
+ Ada_2012 : Ada_Version_Type renames Ada_12;
+ -- Renamings with full names (preferred usage)
+
Ada_Version_Default : constant Ada_Version_Type := Ada_05;
pragma Warnings (Off, Ada_Version_Default);
-- GNAT
begin
if Ada_Version < Ada_12 then
Error_Msg_SC ("|case expression is an Ada 2012 feature");
- Error_Msg_SC ("\|use -gnat12 switch to compile this unit");
+ Error_Msg_SC ("\|unit must be compiled with -gnat2012 switch");
end if;
Scan; -- past CASE
if Token = Tok_If and then Ada_Version < Ada_12 then
Error_Msg_SC ("|conditional expression is an Ada 2012 feature");
- Error_Msg_SC ("\|use -gnat12 switch to compile this unit");
+ Error_Msg_SC ("\|unit must be compiled with -gnat2012 switch");
end if;
Scan; -- past IF or ELSIF
if Token = Tok_Vertical_Bar then
if Ada_Version < Ada_12 then
Error_Msg_SC ("set notation is an Ada 2012 feature");
- Error_Msg_SC ("\|use -gnat12 switch to compile this unit");
+ Error_Msg_SC ("\|unit must be compiled with -gnat2012 switch");
end if;
Set_Alternatives (N, New_List (Alt));
with Sinfo; use Sinfo;
with Sinput; use Sinput;
with Snames; use Snames;
+with Stand; use Stand;
with Uname; use Uname;
package body Restrict is
Check_Restriction (No_Implicit_Heap_Allocations, N);
end Check_No_Implicit_Heap_Alloc;
+ -----------------------------------
+ -- Check_Obsolescent_2005_Entity --
+ -----------------------------------
+
+ procedure Check_Obsolescent_2005_Entity (E : Entity_Id; N : Node_Id) is
+ function Chars_Is (E : Entity_Id; S : String) return Boolean;
+ -- Return True iff Chars (E) matches S (given in lower case)
+
+ function Chars_Is (E : Entity_Id; S : String) return Boolean is
+ Nam : constant Name_Id := Chars (E);
+ begin
+ if Length_Of_Name (Nam) /= S'Length then
+ return False;
+ else
+ return Get_Name_String (Nam) = S;
+ end if;
+ end Chars_Is;
+
+ -- Start of processing for Check_Obsolescent_2005_Entity
+
+ begin
+ if Ada_Version >= Ada_2005
+ and then Restriction_Active (No_Obsolescent_Features)
+ and then Chars_Is (Scope (E), "handling")
+ and then Chars_Is (Scope (Scope (E)), "characters")
+ and then Chars_Is (Scope (Scope (Scope (E))), "ada")
+ and then Scope (Scope (Scope (Scope (E)))) = Standard_Standard
+ then
+ if Chars_Is (E, "is_character") or else
+ Chars_Is (E, "is_string") or else
+ Chars_Is (E, "to_character") or else
+ Chars_Is (E, "to_string") or else
+ Chars_Is (E, "to_wide_character") or else
+ Chars_Is (E, "to_wide_string")
+ then
+ Check_Restriction (No_Obsolescent_Features, N);
+ end if;
+ end if;
+ end Check_Obsolescent_2005_Entity;
+
---------------------------
-- Check_Restricted_Unit --
---------------------------
-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- Equivalent to Check_Restriction (No_Implicit_Heap_Allocations, N).
-- Provided for easy use by back end, which has to check this restriction.
+ procedure Check_Obsolescent_2005_Entity (E : Entity_Id; N : Node_Id);
+ -- This routine checks if the entity E is one of the obsolescent entries
+ -- in Ada.Characters.Handling in Ada 2005 and No_Obsolescent_Features
+ -- restriction is active. If so an appropriate message is given. N is
+ -- the node on which the message is to be placed. It's a bit kludgy to
+ -- have this highly specialized routine rather than some wonderful general
+ -- mechanism (e.g. a special pragma) to handle this case, but there are
+ -- only six cases, and it is not worth the effort to do something general.
+
function Cunit_Boolean_Restrictions_Save
return Save_Cunit_Boolean_Restrictions;
-- This function saves the compilation unit restriction settings, and
Check_For_Eliminated_Subprogram (P, Entity (P));
+ -- Check for obsolescent subprogram reference
+
+ Check_Obsolescent_2005_Entity (Entity (P), P);
+
-- Build the appropriate subprogram type
Build_Access_Subprogram_Type (P);
Check_E0;
Find_Type (N);
+ -- Applying Class to untagged incomplete type is obsolescent in Ada
+ -- 2005. Note that we can't test Is_Tagged_Type here on P_Type, since
+ -- this flag gets set by Find_Type in this situation.
+
+ if Restriction_Active (No_Obsolescent_Features)
+ and then Ada_Version >= Ada_2005
+ and then Ekind (P_Type) = E_Incomplete_Type
+ then
+ declare
+ DN : constant Node_Id := Declaration_Node (P_Type);
+ begin
+ if Nkind (DN) = N_Incomplete_Type_Declaration
+ and then not Tagged_Present (DN)
+ then
+ Check_Restriction (No_Obsolescent_Features, P);
+ end if;
+ end;
+ end if;
+
------------------
-- Code_Address --
------------------
-- Case from RM J.4(2) of constrained applied to private type
if Is_Entity_Name (P) and then Is_Type (Entity (P)) then
- Check_Restriction (No_Obsolescent_Features, N);
+ Check_Restriction (No_Obsolescent_Features, P);
if Warn_On_Obsolescent_Feature then
Error_Msg_N
if Is_Task_Type (P_Type) then
Set_Etype (N, Universal_Integer);
+ -- Use with tasks is an obsolescent feature
+
+ Check_Restriction (No_Obsolescent_Features, P);
+
elsif Is_Access_Type (P_Type) then
if Ekind (P_Type) = E_Access_Subprogram_Type then
Error_Attr_P
-- Set True if the unit currently being compiled is an internal unit
Save_Style_Check : constant Boolean := Opt.Style_Check;
- Save_C_Restrict : constant Save_Cunit_Boolean_Restrictions :=
- Cunit_Boolean_Restrictions_Save;
+ Save_C_Restrict : Save_Cunit_Boolean_Restrictions;
begin
U := Unit (Library_Unit (N));
+ -- If this is an internal unit which is a renaming, then this is a
+ -- violation of No_Obsolescent_Features.
+
+ -- Note: this is not quite right if the user defines one of these units
+ -- himself, but that's a marginal case, and fixing it is hard ???
+
+ if Restriction_Active (No_Obsolescent_Features) then
+ declare
+ F : constant File_Name_Type :=
+ Unit_File_Name (Get_Source_Unit (U));
+ begin
+ if Is_Predefined_File_Name (F, Renamings_Included => True)
+ and then not
+ Is_Predefined_File_Name (F, Renamings_Included => False)
+ then
+ Check_Restriction (No_Obsolescent_Features, N);
+ end if;
+ end;
+ end if;
+
+ -- Save current restriction set, does not apply to with'ed unit
+
+ Save_C_Restrict := Cunit_Boolean_Restrictions_Save;
+
-- Several actions are skipped for dummy packages (those supplied for
-- with's where no matching file could be found). Such packages are
-- identified by the Sloc value being set to No_Location.
-- explicit with'ing of run-time units.
if Configurable_Run_Time_Mode
- and then
- Is_Predefined_File_Name
- (Unit_File_Name (Get_Source_Unit (Unit (Library_Unit (N)))))
+ and then Is_Predefined_File_Name (Unit_File_Name (Get_Source_Unit (U)))
then
Configurable_Run_Time_Mode := False;
Semantics (Library_Unit (N));
end if;
end if;
+ -- Check obsolescent use of Numeric_Error
+
+ if Exception_Name = Standard_Numeric_Error then
+ Check_Restriction (No_Obsolescent_Features, Exception_Id);
+ end if;
+
+ -- Kill last assignment indication
+
Kill_Current_Values (Last_Assignment_Only => True);
end Analyze_Raise_Statement;
end if;
-- A useful warning, suggested by Ada Bug Finder (Ada-Europe 2005)
+ -- is to warn if an operator is being renamed as a different operator.
if Comes_From_Source (N)
and then Present (Old_S)
New_S, Old_S);
end if;
+ -- Check for renaming of obsolescent subprogram
+
+ Check_Obsolescent_2005_Entity (Entity (Nam), Nam);
+
-- Another warning or some utility: if the new subprogram as the same
-- name as the old one, the old one is not hidden by an outer homograph,
-- the new one is not a public symbol, and the old one is otherwise
Restriction_Warnings (R_Id) := False;
end if;
+ -- Check for obsolescent restrictions in Ada 2005 mode
+
+ if not Warn
+ and then Ada_Version >= Ada_2005
+ and then (R_Id = No_Asynchronous_Control
+ or else
+ R_Id = No_Unchecked_Deallocation
+ or else
+ R_Id = No_Unchecked_Conversion)
+ then
+ Check_Restriction (No_Obsolescent_Features, N);
+ end if;
+
-- A very special case that must be processed here: pragma
-- Restrictions (No_Exceptions) turns off all run-time
-- checking. This is a bit dubious in terms of the formal
-- a specified entity (given as the second argument of the pragma)
else
+ -- This is obsolescent in Ada 2005 mode
+
+ if Ada_Version >= Ada_2005 then
+ Check_Restriction (No_Obsolescent_Features, Arg2);
+ end if;
+
Check_Optional_Identifier (Arg2, Name_On);
E_Id := Expression (Arg2);
Analyze (E_Id);
Check_At_Most_N_Arguments (4);
Process_Import_Or_Interface;
+ -- In Ada 2005, the permission to use Interface (a reserved word)
+ -- as a pragma name is considered an obsolescent feature.
+
+ if Ada_Version >= Ada_2005 then
+ Check_Restriction
+ (No_Obsolescent_Features, Pragma_Identifier (N));
+ end if;
+
--------------------
-- Interface_Name --
--------------------
K : constant Node_Kind := Nkind (Parent (N));
begin
if (K = N_Loop_Statement
- and then Present (Iteration_Scheme (Parent (N))))
+ and then Present (Iteration_Scheme (Parent (N))))
or else K = N_If_Statement
or else K = N_Elsif_Part
or else K = N_Case_Statement_Alternative
end if;
end if;
+ -- Check obsolescent reference to Ada.Characters.Handling subprogram
+
+ Check_Obsolescent_2005_Entity (Nam, Subp);
+
-- If subprogram name is a predefined operator, it was given in
-- functional notation. Replace call node with operator node, so
-- that actuals can be resolved appropriately.
--
-- Allows GNAT to recognize the full range of Ada 2005 constructs.
+ S_GCC_Ada_2005 : aliased constant S := "/2005 " &
+ "-gnat2005";
+ -- /05 (D)
+ --
+ -- Allows GNAT to recognize the full range of Ada 2005 constructs.
+ -- Equivalent to /05 (/2005 is the preferred usage).
+
S_GCC_Ada_12 : aliased constant S := "/12 " &
"-gnat12";
-- /05 (D)
-- Allows GNAT to recognize all implemented proposed Ada 2012
-- extensions. See features file for list of implemented features.
+ S_GCC_Ada_2012 : aliased constant S := "/2012 " &
+ "-gnat2012";
+ -- /05 (D)
+ --
+ -- Allows GNAT to recognize all implemented proposed Ada 2012
+ -- extensions. See features file for list of implemented features.
+ -- Equivalent to /12 (/2012 is the preferred usage).
+
S_GCC_Add : aliased constant S := "/ADD_PROJECT_SEARCH_DIR=*" &
"-aP*";
-- /ADD_PROJECT_SEARCH_PATH=(directory[,...])
(S_GCC_Ada_83 'Access,
S_GCC_Ada_95 'Access,
S_GCC_Ada_05 'Access,
+ S_GCC_Ada_2005'Access,
+ S_GCC_Ada_12 'Access,
+ S_GCC_Ada_2012'Access,
S_GCC_Add 'Access,
S_GCC_Asm 'Access,
S_GCC_AValid 'Access,