par-prag.adb (Prag): Add dummy entry for pragma Compile_Time_Error

2007-04-06  Robert Dewar  <dewar@adacore.com>
	    Javier Miranda  <miranda@adacore.com>
	    Bob Duff  <duff@adacore.com>
	    Vincent Celier  <celier@adacore.com>

	* par-prag.adb (Prag): Add dummy entry for pragma Compile_Time_Error
	(Extensions_Allowed): No longer sets Ada_Version
	Entry for pragma Unreferenced_Objects

	* sem_prag.adb (Analyze_Pragma, case Priority): Force with of
	system.tasking if pragma priority used in a procedure
	(Analyze_Pragma, case Warning): Handle dot warning switches
	(Process_Compile_Time_Warning_Or_Error): New procedure
	(Analyze_Pragma): Add processing for Compile_Time_Error
	Add support for extra arguments External_Name and Link_Name.
	Remove code associated with pragmas CPP_Virtual and CPP_Vtable.
	(Process_Import_Or_Interface): Add support for the use of pragma Import
	with tagged types.
	(Extensions_Allowed): No longer affects Ada_Version
	(Analyze_Pragma): Split Is_Abstract flag into Is_Abstract_Subprogram and
	Is_Abstract_Type. Make sure these are called only when appropriate.
	Add processing for pragma Unreferenced_Objects

	* snames.h, snames.ads, snames.adb: Add entry for pragma
	Compile_Time_Error
	Add new standard name Minimum_Binder_Options for new gprmake
	Add new standard names for gprmake: Archive_Suffix,
	Library_Auto_Init_Supported, Library_Major_Minor_Id_Supported,
	Library_Support, Library_Version_Options,
	Shared_Library_Minimum_Options,
	Shared_Library_Prefix, Shared_Library_Suffix, Symbolic_Link_Supported.
	Change Name_Call to Name_uCall so that it cannot clash with a legal
	subprogram name.
	Add new standard names Mapping_Spec_Suffix and Mapping_Body_Suffix
	Append C_Plus_Plus to convention identifiers as synonym for CPP
	Add new standard names Stack and Builder_Switches
	Add new standard names: Compiler_Minimum_Options, Global_Config_File,
	Library_Builder, Local_Config_File, Objects_Path, Objects_Path_File,
	Run_Path_Option, Toolchain_Version.
	Entry for pragma Unreferenced_Objects

	* switch-c.adb (Scan_Front_End_Switches): Store correct -gnateD
	switches, without repetition of "eD". Make sure that last character of
	-gnatep= switch is not taken as -gnat switch character.
	Complete rewrite of circuit for handling saving compilation options
	Occasioned by need to support dot switchs for -gnatw, but cleans up
	things in general.
	-gnatX does not affect Ada_Version
	Include -gnatyA in -gnatg style switches

	* sem_warn.ads, sem_warn.adb (Output_Unreferenced_Messages): Exclude
	warnings on return objects.
	(Warn_On_Useless_Assignment): Exclude warnings on return objects
	(Set_Dot_Warning_Switch): New procedure
	(Check_References): Add missing case of test for
	Has_Pragma_Unreferenced_Objects
	(Output_Unreferenced_Messages): Implement effect of new pragma
	Unreferenced_Objects, remove special casing of limited controlled
	variables.

From-SVN: r123588
This commit is contained in:
Robert Dewar 2007-04-06 11:25:05 +02:00 committed by Arnaud Charlet
parent 6c929a2ea0
commit 874a0341c8
8 changed files with 1234 additions and 1334 deletions

View File

@ -376,14 +376,10 @@ begin
if Chars (Expression (Arg1)) = Name_On then
Extensions_Allowed := True;
Ada_Version := Ada_Version_Type'Last;
else
Extensions_Allowed := False;
Ada_Version := Ada_Version_Type'Min (Ada_Version, Ada_95);
end if;
Ada_Version_Explicit := Ada_Version;
----------------
-- List (2.8) --
----------------
@ -1058,6 +1054,7 @@ begin
Pragma_Atomic |
Pragma_Atomic_Components |
Pragma_Attach_Handler |
Pragma_Compile_Time_Error |
Pragma_Compile_Time_Warning |
Pragma_Convention_Identifier |
Pragma_CPP_Class |
@ -1179,6 +1176,7 @@ begin
Pragma_Unimplemented_Unit |
Pragma_Universal_Data |
Pragma_Unreferenced |
Pragma_Unreferenced_Objects |
Pragma_Unreserve_All_Interrupts |
Pragma_Unsuppress |
Pragma_Use_VADS_Size |

View File

@ -35,7 +35,6 @@ with Casing; use Casing;
with Csets; use Csets;
with Debug; use Debug;
with Einfo; use Einfo;
with Elists; use Elists;
with Errout; use Errout;
with Exp_Dist; use Exp_Dist;
with Hostparm; use Hostparm;
@ -54,7 +53,6 @@ with Sem; use Sem;
with Sem_Ch3; use Sem_Ch3;
with Sem_Ch8; use Sem_Ch8;
with Sem_Ch13; use Sem_Ch13;
with Sem_Disp; use Sem_Disp;
with Sem_Dist; use Sem_Dist;
with Sem_Elim; use Sem_Elim;
with Sem_Eval; use Sem_Eval;
@ -513,6 +511,9 @@ package body Sem_Prag is
-- Shared is an obsolete Ada 83 pragma, treated as being identical
-- in effect to pragma Atomic.
procedure Process_Compile_Time_Warning_Or_Error;
-- Common processing for Compile_Time_Error and Compile_Time_Warning
procedure Process_Convention (C : out Convention_Id; E : out Entity_Id);
-- Common procesing for Convention, Interface, Import and Export.
-- Checks first two arguments of pragma, and sets the appropriate
@ -1985,6 +1986,78 @@ package body Sem_Prag is
end if;
end Process_Atomic_Shared_Volatile;
-------------------------------------------
-- Process_Compile_Time_Warning_Or_Error --
-------------------------------------------
procedure Process_Compile_Time_Warning_Or_Error is
Arg1x : constant Node_Id := Get_Pragma_Arg (Arg1);
begin
GNAT_Pragma;
Check_Arg_Count (2);
Check_No_Identifiers;
Check_Arg_Is_Static_Expression (Arg2, Standard_String);
Analyze_And_Resolve (Arg1x, Standard_Boolean);
if Compile_Time_Known_Value (Arg1x) then
if Is_True (Expr_Value (Get_Pragma_Arg (Arg1))) then
declare
Str : constant String_Id :=
Strval (Get_Pragma_Arg (Arg2));
Len : constant Int := String_Length (Str);
Cont : Boolean;
Ptr : Nat;
CC : Char_Code;
C : Character;
begin
Cont := False;
Ptr := 1;
-- Loop through segments of message separated by line
-- feeds. We output these segments as separate messages
-- with continuation marks for all but the first.
loop
Error_Msg_Strlen := 0;
-- Loop to copy characters from argument to error
-- message string buffer.
loop
exit when Ptr > Len;
CC := Get_String_Char (Str, Ptr);
Ptr := Ptr + 1;
-- Ignore wide chars ??? else store character
if In_Character_Range (CC) then
C := Get_Character (CC);
exit when C = ASCII.LF;
Error_Msg_Strlen := Error_Msg_Strlen + 1;
Error_Msg_String (Error_Msg_Strlen) := C;
end if;
end loop;
-- Here with one line ready to go
Error_Msg_Warn := Prag_Id = Pragma_Compile_Time_Warning;
if Cont = False then
Error_Msg_N ("<~", Arg1);
Cont := True;
else
Error_Msg_N ("\<~", Arg1);
end if;
exit when Ptr > Len;
end loop;
end;
end if;
end if;
end Process_Compile_Time_Warning_Or_Error;
------------------------
-- Process_Convention --
------------------------
@ -2247,7 +2320,7 @@ package body Sem_Prag is
-- Treat a pragma Import as an implicit body, for GPS use
if Prag_Id = Pragma_Import then
Generate_Reference (E, Id, 'b');
Generate_Reference (E, Id, 'b');
end if;
E1 := E;
@ -3175,6 +3248,19 @@ package body Sem_Prag is
Set_Is_Public (Def_Id);
Process_Interface_Name (Def_Id, Arg3, Arg4);
-- Import a CPP class
elsif Is_Record_Type (Def_Id)
and then C = Convention_CPP
then
if not Is_Tagged_Type (Def_Id) then
Error_Msg_Sloc := Sloc (Def_Id);
Error_Pragma_Arg ("imported 'C'P'P type must be tagged", Arg2);
else
Set_Is_CPP_Class (Def_Id);
Set_Is_Limited_Record (Def_Id);
end if;
else
Error_Pragma_Arg
("second argument of pragma% must be object or subprogram",
@ -5035,6 +5121,16 @@ package body Sem_Prag is
-- Processing for this pragma is shared with Psect_Object
------------------------
-- Compile_Time_Error --
------------------------
-- pragma Compile_Time_Error
-- (boolean_EXPRESSION, static_string_EXPRESSION);
when Pragma_Compile_Time_Error =>
Process_Compile_Time_Warning_Or_Error;
--------------------------
-- Compile_Time_Warning --
--------------------------
@ -5042,71 +5138,8 @@ package body Sem_Prag is
-- pragma Compile_Time_Warning
-- (boolean_EXPRESSION, static_string_EXPRESSION);
when Pragma_Compile_Time_Warning => Compile_Time_Warning : declare
Arg1x : constant Node_Id := Get_Pragma_Arg (Arg1);
begin
GNAT_Pragma;
Check_Arg_Count (2);
Check_No_Identifiers;
Check_Arg_Is_Static_Expression (Arg2, Standard_String);
Analyze_And_Resolve (Arg1x, Standard_Boolean);
if Compile_Time_Known_Value (Arg1x) then
if Is_True (Expr_Value (Get_Pragma_Arg (Arg1))) then
declare
Str : constant String_Id :=
Strval (Get_Pragma_Arg (Arg2));
Len : constant Int := String_Length (Str);
Cont : Boolean;
Ptr : Nat;
CC : Char_Code;
C : Character;
begin
Cont := False;
Ptr := 1;
-- Loop through segments of message separated by line
-- feeds. We output these segments as separate messages
-- with continuation marks for all but the first.
loop
Error_Msg_Strlen := 0;
-- Loop to copy characters from argument to error
-- message string buffer.
loop
exit when Ptr > Len;
CC := Get_String_Char (Str, Ptr);
Ptr := Ptr + 1;
-- Ignore wide chars ??? else store character
if In_Character_Range (CC) then
C := Get_Character (CC);
exit when C = ASCII.LF;
Error_Msg_Strlen := Error_Msg_Strlen + 1;
Error_Msg_String (Error_Msg_Strlen) := C;
end if;
end loop;
-- Here with one line ready to go
if Cont = False then
Error_Msg_N ("?~", Arg1);
Cont := True;
else
Error_Msg_N ("\?~", Arg1);
end if;
exit when Ptr > Len;
end loop;
end;
end if;
end if;
end Compile_Time_Warning;
when Pragma_Compile_Time_Warning =>
Process_Compile_Time_Warning_Or_Error;
-----------------------------
-- Complete_Representation --
@ -5346,14 +5379,16 @@ package body Sem_Prag is
-- pragma CPP_Class ([Entity =>] local_NAME)
when Pragma_CPP_Class => CPP_Class : declare
Arg : Node_Id;
Typ : Entity_Id;
Default_DTC : Entity_Id := Empty;
VTP_Type : constant Entity_Id := RTE (RE_Vtable_Ptr);
C : Entity_Id;
Tag_C : Entity_Id;
Arg : Node_Id;
Typ : Entity_Id;
begin
if Warn_On_Obsolescent_Feature then
Error_Msg_N
("'G'N'A'T pragma cpp'_class is now obsolete; replace it" &
" by pragma import?", N);
end if;
GNAT_Pragma;
Check_Arg_Count (1);
Check_Optional_Identifier (Arg1, Name_Entity);
@ -5374,79 +5409,22 @@ package body Sem_Prag is
Typ := Entity (Arg);
if not Is_Record_Type (Typ) then
Error_Pragma_Arg ("pragma% applicable to a record, "
& "tagged record or record extension", Arg1);
end if;
Default_DTC := First_Component (Typ);
while Present (Default_DTC)
and then Etype (Default_DTC) /= VTP_Type
loop
Next_Component (Default_DTC);
end loop;
-- Case of non tagged type
if not Is_Tagged_Type (Typ) then
Set_Is_CPP_Class (Typ);
if Present (Default_DTC) then
Error_Pragma_Arg
("only tagged records can contain vtable pointers", Arg1);
end if;
-- Case of tagged type with no user-defined vtable ptr. In this
-- case, because of our C++ ABI compatibility, the programmer
-- does not need to specify the tag component.
elsif Is_Tagged_Type (Typ)
and then No (Default_DTC)
then
Set_Is_CPP_Class (Typ);
Set_Is_Limited_Record (Typ);
-- Tagged type that has a vtable ptr
elsif Present (Default_DTC) then
Set_Is_CPP_Class (Typ);
Set_Is_Limited_Record (Typ);
Set_Is_Tag (Default_DTC);
Set_DT_Entry_Count (Default_DTC, No_Uint);
-- Since a CPP type has no direct link to its associated tag
-- most tags checks cannot be performed
Set_Kill_Tag_Checks (Typ);
Set_Kill_Tag_Checks (Class_Wide_Type (Typ));
-- Get rid of the _tag component when there was one.
-- It is only useful for regular tagged types
if Expander_Active and then Typ = Root_Type (Typ) then
Tag_C := First_Tag_Component (Typ);
C := First_Entity (Typ);
if C = Tag_C then
Set_First_Entity (Typ, Next_Entity (Tag_C));
else
while Next_Entity (C) /= Tag_C loop
Next_Entity (C);
end loop;
Set_Next_Entity (C, Next_Entity (Tag_C));
end if;
end if;
Error_Pragma_Arg ("pragma% applicable to tagged types ", Arg1);
end if;
Set_Is_CPP_Class (Typ);
Set_Is_Limited_Record (Typ);
Set_Convention (Typ, Convention_CPP);
end CPP_Class;
---------------------
-- CPP_Constructor --
---------------------
-- pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
-- pragma CPP_Constructor ([Entity =>] LOCAL_NAME
-- [, [External_Name =>] static_string_EXPRESSION ]
-- [, [Link_Name =>] static_string_EXPRESSION ]);
when Pragma_CPP_Constructor => CPP_Constructor : declare
Id : Entity_Id;
@ -5454,7 +5432,8 @@ package body Sem_Prag is
begin
GNAT_Pragma;
Check_Arg_Count (1);
Check_At_Least_N_Arguments (1);
Check_At_Most_N_Arguments (3);
Check_Optional_Identifier (Arg1, Name_Entity);
Check_Arg_Is_Local_Name (Arg1);
@ -5473,10 +5452,9 @@ package body Sem_Prag is
and then Is_Class_Wide_Type (Etype (Def_Id))
and then Is_CPP_Class (Etype (Etype (Def_Id)))
then
-- What the heck is this??? this pragma allows only 1 arg
if Arg_Count >= 2 then
Check_At_Most_N_Arguments (3);
Set_Imported (Def_Id);
Set_Is_Public (Def_Id);
Process_Interface_Name (Def_Id, Arg2, Arg3);
end if;
@ -5499,119 +5477,12 @@ package body Sem_Prag is
-- CPP_Virtual --
-----------------
-- pragma CPP_Virtual
-- [Entity =>] LOCAL_NAME
-- [ [Vtable_Ptr =>] LOCAL_NAME,
-- [Position =>] static_integer_EXPRESSION]);
when Pragma_CPP_Virtual => CPP_Virtual : declare
Arg : Node_Id;
Typ : Entity_Id;
Subp : Entity_Id;
VTP_Type : constant Entity_Id := RTE (RE_Vtable_Ptr);
DTC : Entity_Id;
V : Uint;
begin
GNAT_Pragma;
Check_Arg_Order ((Name_Entity, Name_Vtable_Ptr, Name_Position));
if Arg_Count = 3 then
Check_Optional_Identifier (Arg2, Name_Vtable_Ptr);
-- We allow Entry_Count as well as Position for the third
-- parameter for back compatibility with versions of GNAT
-- before version 3.12. The documentation has always said
-- Position, but the code up to 3.12 said Entry_Count.
if Chars (Arg3) /= Name_Entry_Count then
Check_Optional_Identifier (Arg3, Name_Position);
end if;
else
Check_Arg_Count (1);
end if;
Check_Optional_Identifier (Arg1, Name_Entity);
Check_Arg_Is_Local_Name (Arg1);
-- First argument must be a subprogram name
Arg := Expression (Arg1);
Find_Program_Unit_Name (Arg);
if Etype (Arg) = Any_Type then
return;
else
Subp := Entity (Arg);
end if;
if not (Is_Subprogram (Subp)
and then Is_Dispatching_Operation (Subp))
then
Error_Pragma_Arg
("pragma% must reference a primitive operation", Arg1);
end if;
Typ := Find_Dispatching_Type (Subp);
-- If only one Argument defaults are :
-- . DTC_Entity is the default Vtable pointer
-- . DT_Position will be set at the freezing point
if Arg_Count = 1 then
Set_DTC_Entity (Subp, First_Tag_Component (Typ));
return;
end if;
-- Second argument is a component name of type Vtable_Ptr
Arg := Expression (Arg2);
if Nkind (Arg) /= N_Identifier then
Error_Msg_NE ("must be a& component name", Arg, Typ);
raise Pragma_Exit;
end if;
DTC := First_Component (Typ);
while Present (DTC) and then Chars (DTC) /= Chars (Arg) loop
Next_Component (DTC);
end loop;
-- Case of tagged type with no user-defined vtable ptr
if No (DTC) then
Error_Msg_NE ("must be a& component name", Arg, Typ);
raise Pragma_Exit;
elsif Etype (DTC) /= VTP_Type then
Wrong_Type (Arg, VTP_Type);
return;
end if;
-- Third argument is an integer (DT_Position)
Arg := Expression (Arg3);
Analyze_And_Resolve (Arg, Any_Integer);
if not Is_Static_Expression (Arg) then
Flag_Non_Static_Expr
("third argument of pragma CPP_Virtual must be static!",
Arg3);
raise Pragma_Exit;
else
V := Expr_Value (Expression (Arg3));
if V <= 0 then
Error_Pragma_Arg
("third argument of pragma% must be positive",
Arg3);
else
Set_DTC_Entity (Subp, DTC);
Set_DT_Position (Subp, V);
end if;
if Warn_On_Obsolescent_Feature then
Error_Msg_N
("'G'N'A'T pragma cpp'_virtual is now obsolete and has " &
"no effect?", N);
end if;
end CPP_Virtual;
@ -5619,110 +5490,12 @@ package body Sem_Prag is
-- CPP_Vtable --
----------------
-- pragma CPP_Vtable (
-- [Entity =>] LOCAL_NAME
-- [Vtable_Ptr =>] LOCAL_NAME,
-- [Entry_Count =>] static_integer_EXPRESSION);
when Pragma_CPP_Vtable => CPP_Vtable : declare
Arg : Node_Id;
Typ : Entity_Id;
VTP_Type : constant Entity_Id := RTE (RE_Vtable_Ptr);
DTC : Entity_Id;
V : Uint;
Elmt : Elmt_Id;
begin
GNAT_Pragma;
Check_Arg_Order ((Name_Entity, Name_Vtable_Ptr, Name_Entry_Count));
Check_Arg_Count (3);
Check_Optional_Identifier (Arg1, Name_Entity);
Check_Optional_Identifier (Arg2, Name_Vtable_Ptr);
Check_Optional_Identifier (Arg3, Name_Entry_Count);
Check_Arg_Is_Local_Name (Arg1);
-- First argument is a record type name
Arg := Expression (Arg1);
Analyze (Arg);
if Etype (Arg) = Any_Type then
return;
else
Typ := Entity (Arg);
end if;
if not (Is_Tagged_Type (Typ) and then Is_CPP_Class (Typ)) then
Error_Pragma_Arg ("'C'P'P_Class tagged type expected", Arg1);
end if;
-- Second argument is a component name of type Vtable_Ptr
Arg := Expression (Arg2);
if Nkind (Arg) /= N_Identifier then
Error_Msg_NE ("must be a& component name", Arg, Typ);
raise Pragma_Exit;
end if;
DTC := First_Component (Typ);
while Present (DTC) and then Chars (DTC) /= Chars (Arg) loop
Next_Component (DTC);
end loop;
if No (DTC) then
Error_Msg_NE ("must be a& component name", Arg, Typ);
raise Pragma_Exit;
elsif Etype (DTC) /= VTP_Type then
Wrong_Type (DTC, VTP_Type);
return;
-- If it is the first pragma Vtable, This becomes the default tag
elsif (not Is_Tag (DTC))
and then DT_Entry_Count (First_Tag_Component (Typ)) = No_Uint
then
Set_Is_Tag (First_Tag_Component (Typ), False);
Set_Is_Tag (DTC, True);
Set_DT_Entry_Count (DTC, No_Uint);
end if;
-- Those pragmas must appear before any primitive operation
-- definition (except inherited ones) otherwise the default
-- may be wrong
Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Elmt) loop
if No (Alias (Node (Elmt))) then
Error_Msg_Sloc := Sloc (Node (Elmt));
Error_Pragma
("pragma% must appear before this primitive operation");
end if;
Next_Elmt (Elmt);
end loop;
-- Third argument is an integer (DT_Entry_Count)
Arg := Expression (Arg3);
Analyze_And_Resolve (Arg, Any_Integer);
if not Is_Static_Expression (Arg) then
Flag_Non_Static_Expr
("entry count for pragma CPP_Vtable must be a static " &
"expression!", Arg3);
raise Pragma_Exit;
else
V := Expr_Value (Expression (Arg3));
if V <= 0 then
Error_Pragma_Arg
("entry count for pragma% must be positive", Arg3);
else
Set_DT_Entry_Count (DTC, V);
end if;
if Warn_On_Obsolescent_Feature then
Error_Msg_N
("'G'N'A'T pragma cpp'_vtable is now obsolete and has " &
"no effect?", N);
end if;
end CPP_Vtable;
@ -6560,14 +6333,10 @@ package body Sem_Prag is
if Chars (Expression (Arg1)) = Name_On then
Extensions_Allowed := True;
Ada_Version := Ada_Version_Type'Last;
else
Extensions_Allowed := False;
Ada_Version := Ada_Version_Type'Min (Ada_Version, Ada_95);
end if;
Ada_Version_Explicit := Ada_Version;
--------------
-- External --
--------------
@ -7674,7 +7443,7 @@ package body Sem_Prag is
-- java.lang.Object.Typ and that all primitives of the type
-- should be declared abstract. ???
if not Is_Tagged_Type (Typ) or else not Is_Abstract (Typ) then
if not Is_Tagged_Type (Typ) or else not Is_Abstract_Type (Typ) then
Error_Pragma_Arg ("pragma% requires an abstract "
& "tagged type", Arg1);
@ -8927,7 +8696,19 @@ package body Sem_Prag is
end if;
Set_Main_Priority
(Current_Sem_Unit, UI_To_Int (Expr_Value (Arg)));
(Current_Sem_Unit, UI_To_Int (Expr_Value (Arg)));
-- Load an arbitrary entity from System.Tasking to make sure
-- this package is implicitly with'ed, since we need to have
-- the tasking run-time active for the pragma Priority to have
-- any effect.
declare
Discard : Entity_Id;
pragma Warnings (Off, Discard);
begin
Discard := RTE (RE_Task_List);
end;
-- Task or Protected, must be of type Integer
@ -10586,7 +10367,7 @@ package body Sem_Prag is
Get_Name_String (Chars (Cunitent));
Set_Casing (Mixed_Case);
Write_Str (Name_Buffer (1 .. Name_Len));
Write_Str (" is not implemented");
Write_Str (" is not supported in this configuration");
Write_Eol;
raise Unrecoverable_Error;
end if;
@ -10709,6 +10490,38 @@ package body Sem_Prag is
end if;
end Unreferenced;
--------------------------
-- Unreferenced_Objects --
--------------------------
-- pragma Unreferenced_Objects (local_Name {, local_Name});
when Pragma_Unreferenced_Objects => Unreferenced_Objects : declare
Arg_Node : Node_Id;
Arg_Expr : Node_Id;
begin
GNAT_Pragma;
Check_At_Least_N_Arguments (1);
Arg_Node := Arg1;
while Present (Arg_Node) loop
Check_No_Identifier (Arg_Node);
Check_Arg_Is_Local_Name (Arg_Node);
Arg_Expr := Get_Pragma_Arg (Arg_Node);
if not Is_Entity_Name (Arg_Expr)
or else not Is_Type (Entity (Arg_Expr))
then
Error_Pragma_Arg
("argument for pragma% must be type or subtype", Arg_Node);
end if;
Set_Has_Pragma_Unreferenced_Objects (Entity (Arg_Expr));
Next (Arg_Node);
end loop;
end Unreferenced_Objects;
------------------------------
-- Unreserve_All_Interrupts --
------------------------------
@ -10862,20 +10675,48 @@ package body Sem_Prag is
declare
Lit : constant Node_Id := Expr_Value_S (Argx);
Str : constant String_Id := Strval (Lit);
Len : constant Nat := String_Length (Str);
C : Char_Code;
J : Nat;
OK : Boolean;
Chr : Character;
begin
for J in 1 .. String_Length (Str) loop
J := 1;
while J <= Len loop
C := Get_String_Char (Str, J);
OK := In_Character_Range (C);
if In_Character_Range (C)
and then Set_Warning_Switch (Get_Character (C))
then
null;
else
Error_Pragma_Arg
("invalid warning switch character", Arg1);
if OK then
Chr := Get_Character (C);
-- Dot case
if J < Len and then Chr = '.' then
J := J + 1;
C := Get_String_Char (Str, J);
Chr := Get_Character (C);
if not Set_Dot_Warning_Switch (Chr) then
Error_Pragma_Arg
("invalid warning switch character " &
'.' & Chr, Arg1);
end if;
-- Non-Dot case
else
OK := Set_Warning_Switch (Chr);
end if;
end if;
if not OK then
Error_Pragma_Arg
("invalid warning switch character " & Chr,
Arg1);
end if;
J := J + 1;
end loop;
end;
end if;
@ -10953,7 +10794,7 @@ package body Sem_Prag is
if Is_Configuration_Pragma then
if Chars (Argx) = Name_On then
Error_Pragma
("pragma Warnings (Off, string) cannot be " &
("pragma Warnings (On, string) cannot be " &
"used as configuration pragma");
else
@ -11178,6 +11019,7 @@ package body Sem_Prag is
Pragma_C_Pass_By_Copy => 0,
Pragma_Comment => 0,
Pragma_Common_Object => -1,
Pragma_Compile_Time_Error => -1,
Pragma_Compile_Time_Warning => -1,
Pragma_Complete_Representation => 0,
Pragma_Complex_Representation => 0,
@ -11302,6 +11144,7 @@ package body Sem_Prag is
Pragma_Unimplemented_Unit => -1,
Pragma_Universal_Data => -1,
Pragma_Unreferenced => -1,
Pragma_Unreferenced_Objects => -1,
Pragma_Unreserve_All_Interrupts => -1,
Pragma_Unsuppress => 0,
Pragma_Use_VADS_Size => -1,

View File

@ -392,6 +392,7 @@ package body Sem_Warn is
-- or if it is a parameter, to the corresponding spec.
if Has_Pragma_Unreferenced (E1)
or else Has_Pragma_Unreferenced_Objects (Etype (E1))
or else (Is_Formal (E1)
and then Present (Spec_Entity (E1))
and then
@ -1641,6 +1642,7 @@ package body Sem_Warn is
then
if Warn_On_Modified_Unread
and then not Is_Imported (E)
and then not Is_Return_Object (E)
-- Suppress message for aliased or renamed variables,
-- since there may be other entities that read the
@ -1658,20 +1660,12 @@ package body Sem_Warn is
-- Normal case of neither assigned nor read
else
-- We suppress the message for limited controlled types,
-- to catch the common design pattern (known as RAII, or
-- Resource Acquisition Is Initialization) which uses
-- such types solely for their initialization and
-- finalization semantics.
-- We suppress the message for types for which a valid
-- pragma Unreferenced_Objects has been given, otherwise
-- we go ahead and give the message.
if Is_Controlled (Etype (E))
and then Is_Limited_Type (Etype (E))
then
null;
if not Has_Pragma_Unreferenced_Objects (Etype (E)) then
-- Normal case where we want to give message
else
-- Distinguish renamed case in message
if Present (Renamed_Object (E))
@ -1740,6 +1734,26 @@ package body Sem_Warn is
end loop;
end Output_Unreferenced_Messages;
----------------------------
-- Set_Dot_Warning_Switch --
----------------------------
function Set_Dot_Warning_Switch (C : Character) return Boolean is
begin
case C is
when 'x' =>
Warn_On_Non_Local_Exception := True;
when 'X' =>
Warn_On_Non_Local_Exception := False;
when others =>
return False;
end case;
return True;
end Set_Dot_Warning_Switch;
------------------------
-- Set_Warning_Switch --
------------------------
@ -1761,6 +1775,7 @@ package body Sem_Warn is
Warn_On_Export_Import := True;
Warn_On_Modified_Unread := True;
Warn_On_No_Value_Assigned := True;
Warn_On_Non_Local_Exception := True;
Warn_On_Obsolescent_Feature := True;
Warn_On_Questionable_Missing_Parens := True;
Warn_On_Redundant_Constructs := True;
@ -1784,8 +1799,9 @@ package body Sem_Warn is
Warn_On_Hiding := False;
Warn_On_Modified_Unread := False;
Warn_On_No_Value_Assigned := False;
Warn_On_Non_Local_Exception := False;
Warn_On_Obsolescent_Feature := False;
Warn_On_Questionable_Missing_Parens := True;
Warn_On_Questionable_Missing_Parens := False;
Warn_On_Redundant_Constructs := False;
Warn_On_Unchecked_Conversion := False;
Warn_On_Unrecognized_Pragma := False;
@ -2409,11 +2425,12 @@ package body Sem_Warn is
-- Start of processing for Warn_On_Useless_Assignment
begin
-- Check if this is a case we want to warn on, a variable with
-- the last assignment field set, with warnings enabled, and
-- which is not imported or exported.
-- Check if this is a case we want to warn on, a variable with the
-- last assignment field set, with warnings enabled, and which is
-- not imported or exported.
if Ekind (Ent) = E_Variable
and then not Is_Return_Object (Ent)
and then Present (Last_Assignment (Ent))
and then not Warnings_Off (Ent)
and then not Has_Pragma_Unreferenced (Ent)

View File

@ -37,9 +37,16 @@ package Sem_Warn is
--------------------
function Set_Warning_Switch (C : Character) return Boolean;
-- This function sets the warning switch or switches corresponding to
-- the given character. It is used for processing a -gnatw switch on the
-- command line, or a string literal in pragma Warnings.
-- This function sets the warning switch or switches corresponding to the
-- given character. It is used to process a -gnatw switch on the command
-- line, or a character in a string literal in pragma Warnings. Returns
-- True for valid warning character C, False for invalid character.
function Set_Dot_Warning_Switch (C : Character) return Boolean;
-- This function sets the warning switch or switches corresponding to the
-- given character preceded by a dot. Used to process a -gnatw. switch on
-- the command line or .C in a string literal in pragma Warnings. Returns
-- True for valid warning character C, False for invalid character.
------------------------------------------
-- Routines to Handle Unused References --

View File

@ -139,7 +139,7 @@ package body Snames is
"partition#" &
"partition_interface#" &
"ras#" &
"call#" &
"_call#" &
"rci_name#" &
"receiver#" &
"result#" &
@ -178,6 +178,7 @@ package body Snames is
"ada_2005#" &
"assertion_policy#" &
"c_pass_by_copy#" &
"compile_time_error#" &
"compile_time_warning#" &
"component_alignment#" &
"convention_identifier#" &
@ -317,6 +318,7 @@ package body Snames is
"unchecked_union#" &
"unimplemented_unit#" &
"unreferenced#" &
"unreferenced_objects#" &
"unreserve_all_interrupts#" &
"volatile#" &
"volatile_components#" &
@ -333,6 +335,7 @@ package body Snames is
"asm#" &
"assembly#" &
"default#" &
"c_plus_plus#" &
"dll#" &
"win32#" &
"as_is#" &
@ -664,13 +667,16 @@ package body Snames is
"ada_roots#" &
"archive_builder#" &
"archive_indexer#" &
"archive_suffix#" &
"binder#" &
"binder_driver#" &
"body_suffix#" &
"builder#" &
"builder_switches#" &
"compiler#" &
"compiler_driver#" &
"compiler_kind#" &
"compiler_minimum_options#" &
"compiler_pic_option#" &
"compute_dependency#" &
"config_body_file_name#" &
@ -695,6 +701,7 @@ package body Snames is
"finder#" &
"global_compiler_switches#" &
"global_configuration_pragmas#" &
"global_config_file#" &
"gnatls#" &
"gnatstub#" &
"implementation#" &
@ -707,32 +714,47 @@ package body Snames is
"language_processing#" &
"languages#" &
"library_ali_dir#" &
"library_dir#" &
"library_auto_init#" &
"library_auto_init_supported#" &
"library_builder#" &
"library_dir#" &
"library_gcc#" &
"library_interface#" &
"library_kind#" &
"library_name#" &
"library_major_minor_id_supported#" &
"library_options#" &
"library_reference_symbol_file#" &
"library_src_dir#" &
"library_support#" &
"library_symbol_file#" &
"library_symbol_policy#" &
"library_version#" &
"library_version_options#" &
"linker#" &
"linker_executable_option#" &
"linker_lib_dir_option#" &
"linker_lib_name_option#" &
"local_config_file#" &
"local_configuration_pragmas#" &
"locally_removed_files#" &
"mapping_file_switches#" &
"mapping_spec_suffix#" &
"mapping_body_suffix#" &
"metrics#" &
"minimum_binder_options#" &
"naming#" &
"objects_path#" &
"objects_path_file#" &
"object_dir#" &
"pretty_printer#" &
"project#" &
"roots#" &
"run_path_option#" &
"runtime_project#" &
"shared_library_minimum_options#" &
"shared_library_prefix#" &
"shared_library_suffix#" &
"separate_suffix#" &
"source_dirs#" &
"source_files#" &
@ -742,7 +764,10 @@ package body Snames is
"specification#" &
"specification_exceptions#" &
"specification_suffix#" &
"stack#" &
"switches#" &
"symbolic_link_supported#" &
"toolchain_version#" &
"unaligned_valid#" &
"interface#" &
"overriding#" &
@ -976,14 +1001,16 @@ package body Snames is
Convention_Identifiers.Init;
Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
Convention_Identifiers.Append ((Name_Default, Convention_C));
Convention_Identifiers.Append ((Name_External, Convention_C));
Convention_Identifiers.Append ((Name_Default, Convention_C));
Convention_Identifiers.Append ((Name_External, Convention_C));
Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
Convention_Identifiers.Append ((Name_C_Plus_Plus, Convention_CPP));
Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
end Initialize;
-----------------------

File diff suppressed because it is too large Load Diff

View File

@ -220,153 +220,155 @@ extern unsigned char Get_Pragma_Id (int);
#define Pragma_Ada_2005 3
#define Pragma_Assertion_Policy 4
#define Pragma_C_Pass_By_Copy 5
#define Pragma_Compile_Time_Warning 6
#define Pragma_Component_Alignment 7
#define Pragma_Convention_Identifier 8
#define Pragma_Debug_Policy 9
#define Pragma_Detect_Blocking 10
#define Pragma_Discard_Names 11
#define Pragma_Elaboration_Checks 12
#define Pragma_Eliminate 13
#define Pragma_Explicit_Overriding 14
#define Pragma_Extend_System 15
#define Pragma_Extensions_Allowed 16
#define Pragma_External_Name_Casing 17
#define Pragma_Float_Representation 18
#define Pragma_Initialize_Scalars 19
#define Pragma_Interrupt_State 20
#define Pragma_License 21
#define Pragma_Locking_Policy 22
#define Pragma_Long_Float 23
#define Pragma_No_Run_Time 24
#define Pragma_No_Strict_Aliasing 25
#define Pragma_Normalize_Scalars 26
#define Pragma_Polling 27
#define Pragma_Persistent_BSS 28
#define Pragma_Priority_Specific_Dispatching 29
#define Pragma_Profile 30
#define Pragma_Profile_Warnings 31
#define Pragma_Propagate_Exceptions 32
#define Pragma_Queuing_Policy 33
#define Pragma_Ravenscar 34
#define Pragma_Restricted_Run_Time 35
#define Pragma_Restrictions 36
#define Pragma_Restriction_Warnings 37
#define Pragma_Reviewable 38
#define Pragma_Source_File_Name 39
#define Pragma_Source_File_Name_Project 40
#define Pragma_Style_Checks 41
#define Pragma_Suppress 42
#define Pragma_Suppress_Exception_Locations 43
#define Pragma_Task_Dispatching_Policy 44
#define Pragma_Universal_Data 45
#define Pragma_Unsuppress 46
#define Pragma_Use_VADS_Size 47
#define Pragma_Validity_Checks 48
#define Pragma_Warnings 49
#define Pragma_Wide_Character_Encoding 50
#define Pragma_Abort_Defer 51
#define Pragma_All_Calls_Remote 52
#define Pragma_Annotate 53
#define Pragma_Assert 54
#define Pragma_Asynchronous 55
#define Pragma_Atomic 56
#define Pragma_Atomic_Components 57
#define Pragma_Attach_Handler 58
#define Pragma_Comment 59
#define Pragma_Common_Object 60
#define Pragma_Complete_Representation 61
#define Pragma_Complex_Representation 62
#define Pragma_Controlled 63
#define Pragma_Convention 64
#define Pragma_CPP_Class 65
#define Pragma_CPP_Constructor 66
#define Pragma_CPP_Virtual 67
#define Pragma_CPP_Vtable 68
#define Pragma_Debug 69
#define Pragma_Elaborate 70
#define Pragma_Elaborate_All 71
#define Pragma_Elaborate_Body 72
#define Pragma_Export 73
#define Pragma_Export_Exception 74
#define Pragma_Export_Function 75
#define Pragma_Export_Object 76
#define Pragma_Export_Procedure 77
#define Pragma_Export_Value 78
#define Pragma_Export_Valued_Procedure 79
#define Pragma_External 80
#define Pragma_Finalize_Storage_Only 81
#define Pragma_Ident 82
#define Pragma_Import 83
#define Pragma_Import_Exception 84
#define Pragma_Import_Function 85
#define Pragma_Import_Object 86
#define Pragma_Import_Procedure 87
#define Pragma_Import_Valued_Procedure 88
#define Pragma_Inline 89
#define Pragma_Inline_Always 90
#define Pragma_Inline_Generic 91
#define Pragma_Inspection_Point 92
#define Pragma_Interface_Name 93
#define Pragma_Interrupt_Handler 94
#define Pragma_Interrupt_Priority 95
#define Pragma_Java_Constructor 96
#define Pragma_Java_Interface 97
#define Pragma_Keep_Names 98
#define Pragma_Link_With 99
#define Pragma_Linker_Alias 100
#define Pragma_Linker_Constructor 101
#define Pragma_Linker_Destructor 102
#define Pragma_Linker_Options 103
#define Pragma_Linker_Section 104
#define Pragma_List 105
#define Pragma_Machine_Attribute 106
#define Pragma_Main 107
#define Pragma_Main_Storage 108
#define Pragma_Memory_Size 109
#define Pragma_No_Return 110
#define Pragma_Obsolescent 111
#define Pragma_Optimize 112
#define Pragma_Optional_Overriding 113
#define Pragma_Pack 114
#define Pragma_Page 115
#define Pragma_Passive 116
#define Pragma_Preelaborable_Initialization 117
#define Pragma_Preelaborate 118
#define Pragma_Preelaborate_05 119
#define Pragma_Psect_Object 120
#define Pragma_Pure 121
#define Pragma_Pure_05 122
#define Pragma_Pure_Function 123
#define Pragma_Remote_Call_Interface 124
#define Pragma_Remote_Types 125
#define Pragma_Share_Generic 126
#define Pragma_Shared 127
#define Pragma_Shared_Passive 128
#define Pragma_Source_Reference 129
#define Pragma_Stream_Convert 130
#define Pragma_Subtitle 131
#define Pragma_Suppress_All 132
#define Pragma_Suppress_Debug_Info 133
#define Pragma_Suppress_Initialization 134
#define Pragma_System_Name 135
#define Pragma_Task_Info 136
#define Pragma_Task_Name 137
#define Pragma_Task_Storage 138
#define Pragma_Thread_Body 139
#define Pragma_Time_Slice 140
#define Pragma_Title 141
#define Pragma_Unchecked_Union 142
#define Pragma_Unimplemented_Unit 143
#define Pragma_Unreferenced 144
#define Pragma_Unreserve_All_Interrupts 145
#define Pragma_Volatile 146
#define Pragma_Volatile_Components 147
#define Pragma_Weak_External 148
#define Pragma_AST_Entry 149
#define Pragma_Interface 150
#define Pragma_Priority 151
#define Pragma_Storage_Size 152
#define Pragma_Storage_Unit 153
#define Pragma_Compile_Time_Error 6
#define Pragma_Compile_Time_Warning 7
#define Pragma_Component_Alignment 8
#define Pragma_Convention_Identifier 9
#define Pragma_Debug_Policy 10
#define Pragma_Detect_Blocking 11
#define Pragma_Discard_Names 12
#define Pragma_Elaboration_Checks 13
#define Pragma_Eliminate 14
#define Pragma_Explicit_Overriding 15
#define Pragma_Extend_System 16
#define Pragma_Extensions_Allowed 17
#define Pragma_External_Name_Casing 18
#define Pragma_Float_Representation 19
#define Pragma_Initialize_Scalars 20
#define Pragma_Interrupt_State 21
#define Pragma_License 22
#define Pragma_Locking_Policy 23
#define Pragma_Long_Float 24
#define Pragma_No_Run_Time 25
#define Pragma_No_Strict_Aliasing 26
#define Pragma_Normalize_Scalars 27
#define Pragma_Polling 28
#define Pragma_Persistent_BSS 29
#define Pragma_Priority_Specific_Dispatching 30
#define Pragma_Profile 31
#define Pragma_Profile_Warnings 32
#define Pragma_Propagate_Exceptions 33
#define Pragma_Queuing_Policy 34
#define Pragma_Ravenscar 35
#define Pragma_Restricted_Run_Time 36
#define Pragma_Restrictions 37
#define Pragma_Restriction_Warnings 38
#define Pragma_Reviewable 39
#define Pragma_Source_File_Name 40
#define Pragma_Source_File_Name_Project 41
#define Pragma_Style_Checks 42
#define Pragma_Suppress 43
#define Pragma_Suppress_Exception_Locations 44
#define Pragma_Task_Dispatching_Policy 45
#define Pragma_Universal_Data 46
#define Pragma_Unsuppress 47
#define Pragma_Use_VADS_Size 48
#define Pragma_Validity_Checks 49
#define Pragma_Warnings 50
#define Pragma_Wide_Character_Encoding 51
#define Pragma_Abort_Defer 52
#define Pragma_All_Calls_Remote 53
#define Pragma_Annotate 54
#define Pragma_Assert 55
#define Pragma_Asynchronous 56
#define Pragma_Atomic 57
#define Pragma_Atomic_Components 58
#define Pragma_Attach_Handler 59
#define Pragma_Comment 60
#define Pragma_Common_Object 61
#define Pragma_Complete_Representation 62
#define Pragma_Complex_Representation 63
#define Pragma_Controlled 64
#define Pragma_Convention 65
#define Pragma_CPP_Class 66
#define Pragma_CPP_Constructor 67
#define Pragma_CPP_Virtual 68
#define Pragma_CPP_Vtable 69
#define Pragma_Debug 70
#define Pragma_Elaborate 71
#define Pragma_Elaborate_All 72
#define Pragma_Elaborate_Body 73
#define Pragma_Export 74
#define Pragma_Export_Exception 75
#define Pragma_Export_Function 76
#define Pragma_Export_Object 77
#define Pragma_Export_Procedure 78
#define Pragma_Export_Value 79
#define Pragma_Export_Valued_Procedure 80
#define Pragma_External 81
#define Pragma_Finalize_Storage_Only 82
#define Pragma_Ident 83
#define Pragma_Import 84
#define Pragma_Import_Exception 85
#define Pragma_Import_Function 86
#define Pragma_Import_Object 87
#define Pragma_Import_Procedure 88
#define Pragma_Import_Valued_Procedure 89
#define Pragma_Inline 90
#define Pragma_Inline_Always 91
#define Pragma_Inline_Generic 92
#define Pragma_Inspection_Point 93
#define Pragma_Interface_Name 94
#define Pragma_Interrupt_Handler 95
#define Pragma_Interrupt_Priority 96
#define Pragma_Java_Constructor 97
#define Pragma_Java_Interface 98
#define Pragma_Keep_Names 99
#define Pragma_Link_With 100
#define Pragma_Linker_Alias 101
#define Pragma_Linker_Constructor 102
#define Pragma_Linker_Destructor 103
#define Pragma_Linker_Options 104
#define Pragma_Linker_Section 105
#define Pragma_List 106
#define Pragma_Machine_Attribute 107
#define Pragma_Main 108
#define Pragma_Main_Storage 109
#define Pragma_Memory_Size 110
#define Pragma_No_Return 111
#define Pragma_Obsolescent 112
#define Pragma_Optimize 113
#define Pragma_Optional_Overriding 114
#define Pragma_Pack 115
#define Pragma_Page 116
#define Pragma_Passive 117
#define Pragma_Preelaborable_Initialization 118
#define Pragma_Preelaborate 119
#define Pragma_Preelaborate_05 120
#define Pragma_Psect_Object 121
#define Pragma_Pure 122
#define Pragma_Pure_05 123
#define Pragma_Pure_Function 124
#define Pragma_Remote_Call_Interface 125
#define Pragma_Remote_Types 126
#define Pragma_Share_Generic 127
#define Pragma_Shared 128
#define Pragma_Shared_Passive 129
#define Pragma_Source_Reference 130
#define Pragma_Stream_Convert 131
#define Pragma_Subtitle 132
#define Pragma_Suppress_All 133
#define Pragma_Suppress_Debug_Info 134
#define Pragma_Suppress_Initialization 135
#define Pragma_System_Name 136
#define Pragma_Task_Info 137
#define Pragma_Task_Name 138
#define Pragma_Task_Storage 139
#define Pragma_Thread_Body 140
#define Pragma_Time_Slice 141
#define Pragma_Title 142
#define Pragma_Unchecked_Union 143
#define Pragma_Unimplemented_Unit 144
#define Pragma_Unreferenced 145
#define Pragma_Unreferenced_Objects 146
#define Pragma_Unreserve_All_Interrupts 147
#define Pragma_Volatile 148
#define Pragma_Volatile_Components 149
#define Pragma_Weak_External 150
#define Pragma_AST_Entry 151
#define Pragma_Interface 152
#define Pragma_Priority 153
#define Pragma_Storage_Size 154
#define Pragma_Storage_Unit 155
/* End of snames.h (C version of Snames package spec) */

View File

@ -24,8 +24,6 @@
-- --
------------------------------------------------------------------------------
with GNAT.OS_Lib; use GNAT.OS_Lib;
with Debug; use Debug;
with Lib; use Lib;
with Osint; use Osint;
@ -35,6 +33,8 @@ with Validsw; use Validsw;
with Sem_Warn; use Sem_Warn;
with Stylesw; use Stylesw;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with System.WCh_Con; use System.WCh_Con;
package body Switch.C is
@ -47,24 +47,29 @@ package body Switch.C is
-----------------------------
procedure Scan_Front_End_Switches (Switch_Chars : String) is
Switch_Starts_With_Gnat : Boolean;
-- True if first four switch characters are "gnat"
First_Switch : Boolean := True;
-- False for all but first switch
Ptr : Integer := Switch_Chars'First;
Max : constant Integer := Switch_Chars'Last;
Max : constant Natural := Switch_Chars'Last;
Ptr : Natural;
C : Character := ' ';
Dot : Boolean;
Store_Switch : Boolean := True;
First_Char : Integer := Ptr;
Storing : String := Switch_Chars;
First_Stored : Positive := Ptr + 1;
-- The above need comments ???
Store_Switch : Boolean;
-- For -gnatxx switches, the normal processing, signalled by this flag
-- being set to True, is to store the switch on exit from the case
-- statement, the switch stored is -gnat followed by the characters
-- from First_Char to Ptr-1. For cases like -gnaty, where the switch
-- is stored in separate pieces, this flag is set to False, and the
-- appropriate calls to Store_Compilation_Switch are made from within
-- the case branch.
First_Char : Positive;
-- Marks start of switch to be stored
begin
Ptr := Switch_Chars'First;
-- Skip past the initial character (must be the switch character)
if Ptr = Max then
@ -73,123 +78,120 @@ package body Switch.C is
Ptr := Ptr + 1;
end if;
-- Remove "gnat" from the switch, if present
-- Handle switches that do not start with -gnat
Switch_Starts_With_Gnat :=
Ptr + 3 <= Max and then Switch_Chars (Ptr .. Ptr + 3) = "gnat";
if Ptr + 3 > Max
or else Switch_Chars (Ptr .. Ptr + 3) /= "gnat"
then
-- There are two front-end switches that do not start with -gnat:
-- -I, --RTS
if Switch_Starts_With_Gnat then
Ptr := Ptr + 4;
First_Stored := Ptr;
end if;
if Switch_Chars (Ptr) = 'I' then
-- Loop to scan through switches given in switch string
-- Set flag Search_Directory_Present if switch is "-I" only:
-- the directory will be the next argument.
while Ptr <= Max loop
Store_Switch := True;
First_Char := Ptr;
C := Switch_Chars (Ptr);
if Ptr = Max then
Search_Directory_Present := True;
return;
end if;
-- Processing for a switch
Ptr := Ptr + 1;
case Switch_Starts_With_Gnat is
-- Find out whether this is a -I- or regular -Ixxx switch
when False =>
-- Note: -I switches are not recorded in the ALI file, since the
-- meaning of the program depends on the source files compiled,
-- not where they came from.
-- There are few front-end switches that
-- do not start with -gnat: -I, --RTS
if Ptr = Max and then Switch_Chars (Ptr) = '-' then
Look_In_Primary_Dir := False;
else
Add_Src_Search_Dir (Switch_Chars (Ptr .. Max));
end if;
if Switch_Chars (Ptr) = 'I' then
Store_Switch := False;
-- Processing of the --RTS switch. --RTS has been modified by
-- gcc and is now of the form -fRTS.
-- Set flag Search_Directory_Present if switch is "-I" only:
-- the directory will be the next argument.
elsif Ptr + 3 <= Max
and then Switch_Chars (Ptr .. Ptr + 3) = "fRTS"
then
Ptr := Ptr + 1;
if Ptr = Max then
Search_Directory_Present := True;
return;
end if;
if Ptr + 4 > Max
or else Switch_Chars (Ptr + 3) /= '='
then
Osint.Fail ("missing path for --RTS");
else
-- Check that this is the first time --RTS is specified or if
-- it is not the first time, the same path has been specified.
Ptr := Ptr + 1;
if RTS_Specified = null then
RTS_Specified :=
new String'(Switch_Chars (Ptr + 4 .. Max));
-- Find out whether this is a -I- or regular -Ixxx switch
if Ptr = Max and then Switch_Chars (Ptr) = '-' then
Look_In_Primary_Dir := False;
else
Add_Src_Search_Dir (Switch_Chars (Ptr .. Max));
end if;
Ptr := Max + 1;
-- Processing of the --RTS switch. --RTS has been modified by
-- gcc and is now of the form -fRTS
elsif Ptr + 3 <= Max
and then Switch_Chars (Ptr .. Ptr + 3) = "fRTS"
elsif
RTS_Specified.all /= Switch_Chars (Ptr + 4 .. Max)
then
Ptr := Ptr + 1;
if Ptr + 4 > Max
or else Switch_Chars (Ptr + 3) /= '='
then
Osint.Fail ("missing path for --RTS");
else
-- Check that this is the first time --RTS is specified
-- or if it is not the first time, the same path has
-- been specified.
if RTS_Specified = null then
RTS_Specified :=
new String'(Switch_Chars (Ptr + 4 .. Max));
elsif
RTS_Specified.all /= Switch_Chars (Ptr + 4 .. Max)
then
Osint.Fail
("--RTS cannot be specified multiple times");
end if;
-- Valid --RTS switch
Opt.No_Stdinc := True;
Opt.RTS_Switch := True;
RTS_Src_Path_Name := Get_RTS_Search_Dir
(Switch_Chars (Ptr + 4 .. Max),
Include);
RTS_Lib_Path_Name := Get_RTS_Search_Dir
(Switch_Chars (Ptr + 4 .. Max),
Objects);
if RTS_Src_Path_Name /= null and then
RTS_Lib_Path_Name /= null
then
Ptr := Max + 1;
elsif RTS_Src_Path_Name = null and then
RTS_Lib_Path_Name = null
then
Osint.Fail ("RTS path not valid: missing " &
"adainclude and adalib directories");
elsif RTS_Src_Path_Name = null then
Osint.Fail ("RTS path not valid: missing " &
"adainclude directory");
elsif RTS_Lib_Path_Name = null then
Osint.Fail ("RTS path not valid: missing " &
"adalib directory");
end if;
end if;
else
Bad_Switch (C);
Osint.Fail
("--RTS cannot be specified multiple times");
end if;
when True =>
-- Valid --RTS switch
-- Process -gnat* options
Opt.No_Stdinc := True;
Opt.RTS_Switch := True;
RTS_Src_Path_Name :=
Get_RTS_Search_Dir
(Switch_Chars (Ptr + 4 .. Max), Include);
RTS_Lib_Path_Name :=
Get_RTS_Search_Dir
(Switch_Chars (Ptr + 4 .. Max), Objects);
if RTS_Src_Path_Name /= null
and then RTS_Lib_Path_Name /= null
then
-- Store the -fRTS switch (Note: Store_Compilation_Switch
-- changes -fRTS back into --RTS for the actual output).
Store_Compilation_Switch (Switch_Chars);
elsif RTS_Src_Path_Name = null
and then RTS_Lib_Path_Name = null
then
Osint.Fail ("RTS path not valid: missing " &
"adainclude and adalib directories");
elsif RTS_Src_Path_Name = null then
Osint.Fail ("RTS path not valid: missing " &
"adainclude directory");
elsif RTS_Lib_Path_Name = null then
Osint.Fail ("RTS path not valid: missing " &
"adalib directory");
end if;
end if;
-- There are no other switches not starting with -gnat
else
Bad_Switch (C);
end if;
-- Case of switch starting with -gnat
else
Ptr := Ptr + 4;
-- Loop to scan through switches given in switch string
while Ptr <= Max loop
First_Char := Ptr;
Store_Switch := True;
C := Switch_Chars (Ptr);
case C is
@ -229,7 +231,6 @@ package body Switch.C is
when 'd' =>
Store_Switch := False;
Storing (First_Stored) := 'd';
Dot := False;
-- Note: for the debug switch, the remaining characters in this
@ -249,17 +250,10 @@ package body Switch.C is
then
if Dot then
Set_Dotted_Debug_Flag (C);
Storing (First_Stored + 1) := '.';
Storing (First_Stored + 2) := C;
Store_Compilation_Switch
(Storing (Storing'First .. First_Stored + 2));
Dot := False;
Store_Compilation_Switch ("-gnatd." & C);
else
Set_Debug_Flag (C);
Storing (First_Stored + 1) := C;
Store_Compilation_Switch
(Storing (Storing'First .. First_Stored + 1));
Store_Compilation_Switch ("-gnatd" & C);
end if;
elsif C = '.' then
@ -349,7 +343,7 @@ package body Switch.C is
return;
-- -gnateD switch (symbol definition)
-- -gnateD switch (preprocessing symbol definition)
when 'D' =>
Store_Switch := False;
@ -363,13 +357,9 @@ package body Switch.C is
-- Store the switch
Storing (First_Stored .. First_Stored + 1) := "eD";
Storing
(First_Stored + 2 .. First_Stored + Max - Ptr + 2) :=
Switch_Chars (Ptr .. Max);
Store_Compilation_Switch (Storing
(Storing'First .. First_Stored + Max - Ptr + 2));
return;
Store_Compilation_Switch
("-gnateD" & Switch_Chars (Ptr .. Max));
Ptr := Max + 1;
-- -gnatef (full source path for brief error messages)
@ -383,8 +373,7 @@ package body Switch.C is
when 'I' =>
Ptr := Ptr + 1;
Scan_Pos
(Switch_Chars, Max, Ptr, Multiple_Unit_Index, C);
Scan_Pos (Switch_Chars, Max, Ptr, Multiple_Unit_Index, C);
-- -gnatem (mapping file)
@ -427,22 +416,12 @@ package body Switch.C is
Preprocessing_Data_File :=
new String'(Switch_Chars (Ptr .. Max));
-- Store the switch.
-- Because we may store a longer switch (we normalize
-- to -gnatep=), use a local variable.
-- Store the switch, normalizing to -gnatep=
declare
To_Store : String
(1 .. Preprocessing_Data_File'Length + 8);
Store_Compilation_Switch
("-gnatep=" & Preprocessing_Data_File.all);
begin
To_Store (1 .. 8) := "-gnatep=";
To_Store (9 .. Preprocessing_Data_File'Length + 8) :=
Preprocessing_Data_File.all;
Store_Compilation_Switch (To_Store);
end;
return;
Ptr := Max + 1;
when 'z' =>
Store_Switch := False;
@ -509,7 +488,7 @@ package body Switch.C is
Warn_On_Unchecked_Conversion := True;
Warn_On_Unrecognized_Pragma := True;
Set_Style_Check_Options ("3abcdefhiklmnprstux");
Set_Style_Check_Options ("3aAbcdefhiklmnprstux");
-- Processing for G switch
@ -680,10 +659,10 @@ package body Switch.C is
-- Processing for R switch
when 'R' =>
Ptr := Ptr + 1;
Back_Annotate_Rep_Info := True;
List_Representation_Info := 1;
Ptr := Ptr + 1;
while Ptr <= Max loop
C := Switch_Chars (Ptr);
@ -761,7 +740,6 @@ package body Switch.C is
when 'V' =>
Store_Switch := False;
Storing (First_Stored) := 'V';
Ptr := Ptr + 1;
if Ptr > Max then
@ -780,10 +758,8 @@ package body Switch.C is
end if;
for Index in First_Char + 1 .. Max loop
Storing (First_Stored + 1) :=
Switch_Chars (Index);
Store_Compilation_Switch
(Storing (Storing'First .. First_Stored + 1));
("-gnatV" & Switch_Chars (Index));
end loop;
end;
end if;
@ -794,7 +770,6 @@ package body Switch.C is
when 'w' =>
Store_Switch := False;
Storing (First_Stored) := 'w';
Ptr := Ptr + 1;
if Ptr > Max then
@ -804,16 +779,26 @@ package body Switch.C is
while Ptr <= Max loop
C := Switch_Chars (Ptr);
if Set_Warning_Switch (C) then
null;
else
Bad_Switch (C);
end if;
-- Case of dot switch
if C /= 'w' then
Storing (First_Stored + 1) := C;
Store_Compilation_Switch
(Storing (Storing'First .. First_Stored + 1));
if C = '.' and then Ptr < Max then
Ptr := Ptr + 1;
C := Switch_Chars (Ptr);
if Set_Dot_Warning_Switch (C) then
Store_Compilation_Switch ("-gnatw." & C);
else
Bad_Switch (C);
end if;
-- Normal case, no dot
else
if Set_Warning_Switch (C) then
Store_Compilation_Switch ("-gnatw" & C);
else
Bad_Switch (C);
end if;
end if;
Ptr := Ptr + 1;
@ -855,8 +840,6 @@ package body Switch.C is
when 'X' =>
Ptr := Ptr + 1;
Extensions_Allowed := True;
Ada_Version := Ada_Version_Type'Last;
Ada_Version_Explicit := Ada_Version;
-- Processing for y switch
@ -868,11 +851,9 @@ package body Switch.C is
else
Store_Switch := False;
Storing (First_Stored) := 'y';
declare
OK : Boolean;
Last_Stored : Integer;
begin
Set_Style_Check_Options
@ -886,24 +867,22 @@ package body Switch.C is
Ptr := First_Char + 1;
while Ptr <= Max loop
Last_Stored := First_Stored + 1;
Storing (Last_Stored) := Switch_Chars (Ptr);
if Switch_Chars (Ptr) = 'M' then
First_Char := Ptr;
loop
Ptr := Ptr + 1;
exit when Ptr > Max
or else Switch_Chars (Ptr) not in '0' .. '9';
Last_Stored := Last_Stored + 1;
Storing (Last_Stored) := Switch_Chars (Ptr);
end loop;
Store_Compilation_Switch
("-gnaty" & Switch_Chars (First_Char .. Ptr - 1));
else
Store_Compilation_Switch
("-gnaty" & Switch_Chars (Ptr));
Ptr := Ptr + 1;
end if;
Store_Compilation_Switch
(Storing (Storing'First .. Last_Stored));
end loop;
end;
end if;
@ -929,7 +908,6 @@ package body Switch.C is
end case;
Ptr := Ptr + 1;
end if;
-- Processing for Z switch
@ -1000,17 +978,15 @@ package body Switch.C is
when others =>
Bad_Switch (C);
end case;
end case;
if Store_Switch then
Storing (First_Stored .. First_Stored + Ptr - First_Char - 1) :=
Switch_Chars (First_Char .. Ptr - 1);
Store_Compilation_Switch
(Storing (Storing'First .. First_Stored + Ptr - First_Char - 1));
end if;
if Store_Switch then
Store_Compilation_Switch
("-gnat" & Switch_Chars (First_Char .. Ptr - 1));
end if;
First_Switch := False;
end loop;
First_Switch := False;
end loop;
end if;
end Scan_Front_End_Switches;
end Switch.C;