-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2007, 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- --
--- ware Foundation; either version 2, or (at your option) any later ver- --
+-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
--- Public License distributed with GNAT; see file COPYING. If not, write --
--- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
--- Boston, MA 02110-1301, USA. --
+-- Public License distributed with GNAT; see file COPYING3. If not, go to --
+-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
with Atree; use Atree;
with Casing; use Casing;
+with Checks; use Checks;
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;
with Lib; use Lib;
with Lib.Writ; use Lib.Writ;
with Lib.Xref; use Lib.Xref;
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;
with Sem_Type; use Sem_Type;
with Sem_Util; use Sem_Util;
with Sem_VFpt; use Sem_VFpt;
+with Sem_Warn; use Sem_Warn;
with Stand; use Stand;
with Sinfo; use Sinfo;
with Sinfo.CN; use Sinfo.CN;
-- (the original one, following the renaming chain) is returned.
-- Otherwise the entity is returned unchanged. Should be in Einfo???
+ procedure rv;
+ -- This is a dummy function called by the processing for pragma Reviewable.
+ -- It is there for assisting front end debugging. By placing a Reviewable
+ -- pragma in the source program, a breakpoint on rv catches this place in
+ -- the source, allowing convenient stepping to the point of interest.
+
procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id);
-- Place semantic information on the argument of an Elaborate or
-- Elaborate_All pragma. Entity name for unit and its parents is
Pragma_Exit : exception;
-- This exception is used to exit pragma processing completely. It
- -- is used when an error is detected, and in other situations where
- -- it is known that no further processing is required.
+ -- is used when an error is detected, and no further processing is
+ -- required. It is also used if an earlier error has left the tree
+ -- in a state where the pragma should not be processed.
Arg_Count : Nat;
-- Number of pragma argument associations
type Args_List is array (Natural range <>) of Node_Id;
-- Types used for arguments to Check_Arg_Order and Gather_Associations
+ procedure Ada_2005_Pragma;
+ -- Called for pragmas defined in Ada 2005, that are not in Ada 95. In
+ -- Ada 95 mode, these are implementation defined pragmas, so should be
+ -- caught by the No_Implementation_Pragmas restriction
+
procedure Check_Ada_83_Warning;
-- Issues a warning message for the current pragma if operating in Ada
-- 83 mode (used for language pragmas that are not a standard part of
procedure Check_Component (Comp : Node_Id);
-- Examine Unchecked_Union component for correct use of per-object
- -- constrained subtypes.
+ -- constrained subtypes, and for restrictions on finalizable components.
procedure Check_Duplicated_Export_Name (Nam : Node_Id);
-- Nam is an N_String_Literal node containing the external name set
-- returned, otherwise Arg is returned unchanged.
procedure GNAT_Pragma;
- -- Called for all GNAT defined pragmas to note the use of the feature,
- -- and also check the relevant restriction (No_Implementation_Pragmas).
+ -- Called for all GNAT defined pragmas to check the relevant restriction
+ -- (No_Implementation_Pragmas).
function Is_Before_First_Decl
(Pragma_Node : Node_Id;
function Is_Configuration_Pragma return Boolean;
-- Deterermines if the placement of the current pragma is appropriate
- -- for a configuration pragma (precedes the current compilation unit)
+ -- for a configuration pragma (precedes the current compilation unit).
+
+ function Is_In_Context_Clause return Boolean;
+ -- Returns True if pragma appears within the context clause of a unit,
+ -- and False for any other placement (does not generate any messages).
+
+ function Is_Static_String_Expression (Arg : Node_Id) return Boolean;
+ -- Analyzes the argument, and determines if it is a static string
+ -- expression, returns True if so, False if non-static or not String.
procedure Pragma_Misplaced;
-- Issue fatal error message for misplaced pragma
-- 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
procedure Process_Interrupt_Or_Attach_Handler;
-- Common processing for Interrupt and Attach_Handler pragmas
- procedure Process_Restrictions_Or_Restriction_Warnings;
- -- Common processing for Restrictions and Restriction_Warnings pragmas
+ procedure Process_Restrictions_Or_Restriction_Warnings (Warn : Boolean);
+ -- Common processing for Restrictions and Restriction_Warnings pragmas.
+ -- Warn is False for Restrictions, True for Restriction_Warnings.
procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean);
-- Common processing for Suppress and Unsuppress. The boolean parameter
-- node, which is used for error messages on any constructs
-- that violate the profile.
+ ---------------------
+ -- Ada_2005_Pragma --
+ ---------------------
+
+ procedure Ada_2005_Pragma is
+ begin
+ if Ada_Version <= Ada_95 then
+ Check_Restriction (No_Implementation_Pragmas, N);
+ end if;
+ end Ada_2005_Pragma;
+
--------------------------
-- Check_Ada_83_Warning --
--------------------------
declare
Sindic : constant Node_Id :=
Subtype_Indication (Component_Definition (Comp));
-
+ Typ : constant Entity_Id :=
+ Etype (Defining_Identifier (Comp));
begin
if Nkind (Sindic) = N_Subtype_Indication then
" constraint must be an Unchecked_Union", Comp);
end if;
end if;
+
+ if Is_Controlled (Typ) then
+ Error_Msg_N
+ ("component of unchecked union cannot be controlled", Comp);
+
+ elsif Has_Task (Typ) then
+ Error_Msg_N
+ ("component of unchecked union cannot have tasks", Comp);
+ end if;
end;
end if;
end Check_Component;
Analyze (Expression (Arg1));
- if Unit_Kind = N_Generic_Subprogram_Declaration
+ if Unit_Kind = N_Generic_Subprogram_Declaration
or else Unit_Kind = N_Subprogram_Declaration
then
Unit_Name := Defining_Entity (Unit_Node);
- elsif Unit_Kind = N_Function_Instantiation
- or else Unit_Kind = N_Package_Instantiation
- or else Unit_Kind = N_Procedure_Instantiation
- then
+ elsif Unit_Kind in N_Generic_Instantiation then
Unit_Name := Defining_Entity (Unit_Node);
else
Pragma_Misplaced;
elsif (Nkind (Parent_Node) = N_Generic_Package_Declaration
- or else Nkind (Parent_Node)
- = N_Generic_Subprogram_Declaration)
+ or else Nkind (Parent_Node) =
+ N_Generic_Subprogram_Declaration)
and then Plist = Generic_Formal_Declarations (Parent_Node)
then
Pragma_Misplaced;
Comp : Node_Id;
begin
- if Present (Variant_Part (Clist)) then
- Error_Msg_N
- ("Unchecked_Union may not have nested variants",
- Variant_Part (Clist));
- end if;
-
if not Is_Non_Empty_List (Component_Items (Clist)) then
Error_Msg_N
("Unchecked_Union may not have empty component list",
end if;
end Is_Configuration_Pragma;
+ --------------------------
+ -- Is_In_Context_Clause --
+ --------------------------
+
+ function Is_In_Context_Clause return Boolean is
+ Plist : List_Id;
+ Parent_Node : Node_Id;
+
+ begin
+ if not Is_List_Member (N) then
+ return False;
+
+ else
+ Plist := List_Containing (N);
+ Parent_Node := Parent (Plist);
+
+ if Parent_Node = Empty
+ or else Nkind (Parent_Node) /= N_Compilation_Unit
+ or else Context_Items (Parent_Node) /= Plist
+ then
+ return False;
+ end if;
+ end if;
+
+ return True;
+ end Is_In_Context_Clause;
+
+ ---------------------------------
+ -- Is_Static_String_Expression --
+ ---------------------------------
+
+ function Is_Static_String_Expression (Arg : Node_Id) return Boolean is
+ Argx : constant Node_Id := Get_Pragma_Arg (Arg);
+
+ begin
+ Analyze_And_Resolve (Argx);
+ return Is_OK_Static_Expression (Argx)
+ and then Nkind (Argx) = N_String_Literal;
+ end Is_Static_String_Expression;
+
----------------------
-- Pragma_Misplaced --
----------------------
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 --
------------------------
procedure Set_Convention_From_Pragma (E : Entity_Id) is
begin
+ -- Ada 2005 (AI-430): Check invalid attempt to change convention
+ -- for an overridden dispatching operation. Technically this is
+ -- an amendment and should only be done in Ada 2005 mode. However,
+ -- this is clearly a mistake, since the problem that is addressed
+ -- by this AI is that there is a clear gap in the RM!
+
+ if Is_Dispatching_Operation (E)
+ and then Present (Overridden_Operation (E))
+ and then C /= Convention (Overridden_Operation (E))
+ then
+ Error_Pragma_Arg
+ ("cannot change convention for " &
+ "overridden dispatching operation",
+ Arg1);
+ end if;
+
+ -- Set the convention
+
Set_Convention (E, C);
Set_Has_Convention_Pragma (E);
Set_Convention (Class_Wide_Type (E), C);
end if;
- -- If the entity is a record type, then check for special case
- -- of C_Pass_By_Copy, which is treated the same as C except that
- -- the special record flag is set. This convention is also only
- -- permitted on record types (see AI95-00131).
+ -- If the entity is a record type, then check for special case of
+ -- C_Pass_By_Copy, which is treated the same as C except that the
+ -- special record flag is set. This convention is only permitted
+ -- on record types (see AI95-00131).
if Cname = Name_C_Pass_By_Copy then
if Is_Record_Type (E) then
elsif Is_Convention_Name (Cname) then
C := Get_Convention_Id (Chars (Expression (Arg1)));
- -- In DEC VMS, it seems that there is an undocumented feature
- -- that any unrecognized convention is treated as the default,
- -- which for us is convention C. It does not seem so terrible
- -- to do this unconditionally, silently in the VMS case, and
- -- with a warning in the non-VMS case.
+ -- In DEC VMS, it seems that there is an undocumented feature that
+ -- any unrecognized convention is treated as the default, which for
+ -- us is convention C. It does not seem so terrible to do this
+ -- unconditionally, silently in the VMS case, and with a warning
+ -- in the non-VMS case.
else
if Warn_On_Export_Import and not OpenVMS_On_Target then
Error_Pragma_Arg ("entity name required", Arg2);
end if;
+ if Ekind (Entity (Id)) = E_Enumeration_Literal then
+ Error_Pragma ("enumeration literal not allowed for pragma%");
+ end if;
+
E := Entity (Id);
- -- Go to renamed subprogram if present, since convention applies
- -- to the actual renamed entity, not to the renaming entity.
- -- If subprogram is inherited, go to parent subprogram.
+ -- Go to renamed subprogram if present, since convention applies to
+ -- the actual renamed entity, not to the renaming entity. If the
+ -- subprogram is inherited, go to parent subprogram.
if Is_Subprogram (E)
and then Present (Alias (E))
then
- if Nkind (Parent (Declaration_Node (E)))
- = N_Subprogram_Renaming_Declaration
+ if Nkind (Parent (Declaration_Node (E))) =
+ N_Subprogram_Renaming_Declaration
then
E := Alias (E);
and then Ekind (E) /= E_Variable
and then not
(Is_Access_Type (E)
- and then Ekind (Designated_Type (E)) = E_Subprogram_Type)
+ and then Ekind (Designated_Type (E)) = E_Subprogram_Type)
then
Error_Pragma_Arg
("second argument of pragma% must be subprogram (type)",
-- 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;
then
Error_Msg_Sloc := Sloc (Def_Id);
Error_Pragma_Arg
- ("no initialization allowed for declaration of& #",
- "\imported entities cannot be initialized ('R'M' 'B.1(24))",
- Arg1);
+ ("imported entities cannot be initialized (RM B.1(24))",
+ "\no initialization allowed for & declared#", Arg1);
else
Set_Imported (Def_Id);
Note_Possible_Modification (Arg_Internal);
-- Here we have the Export case which can set the entity as exported
- -- But does not do so if the specified external name is null,
- -- since that is taken as a signal in DEC Ada 83 (with which
- -- we want to be compatible) to request no external name.
+ -- But does not do so if the specified external name is null, since
+ -- that is taken as a signal in DEC Ada 83 (with which we want to be
+ -- compatible) to request no external name.
elsif Nkind (Arg_External) = N_String_Literal
and then String_Length (Strval (Arg_External)) = 0
if Present (Expressions (Arg_Mechanism)) then
Mname := First (Expressions (Arg_Mechanism));
-
while Present (Mname) loop
if No (Formal) then
Error_Pragma_Arg
if Present (Component_Associations (Arg_Mechanism)) then
Massoc := First (Component_Associations (Arg_Mechanism));
-
while Present (Massoc) loop
Choice := First (Choices (Massoc));
else
Dval := Default_Value (Formal);
- if not Present (Dval) then
+ if No (Dval) then
Error_Msg_NE
("optional formal& does not have default value!",
Arg_First_Optional_Parameter, Formal);
or else
Ekind (Def_Id) = E_Constant
then
+ -- We do not permit Import to apply to a renaming declaration
+
+ if Present (Renamed_Object (Def_Id)) then
+ Error_Pragma_Arg
+ ("pragma% not allowed for object renaming", Arg2);
+
-- User initialization is not allowed for imported object, but
-- the object declaration may contain a default initialization,
-- that will be discarded. Note that an explicit initialization
-- only counts if it comes from source, otherwise it is simply
-- the code generator making an implicit initialization explicit.
- if Present (Expression (Parent (Def_Id)))
- and then Comes_From_Source (Expression (Parent (Def_Id)))
+ elsif Present (Expression (Parent (Def_Id)))
+ and then Comes_From_Source (Expression (Parent (Def_Id)))
then
Error_Msg_Sloc := Sloc (Def_Id);
Error_Pragma_Arg
("no initialization allowed for declaration of& #",
- "\imported entities cannot be initialized ('R'M' 'B.1(24))",
+ "\imported entities cannot be initialized (RM B.1(24))",
Arg2);
else
N_Subprogram_Renaming_Declaration
then
Error_Msg_Sloc := Sloc (Def_Id);
- Error_Msg_NE ("cannot import&#," &
- " already completed by a renaming",
- N, Def_Id);
+ Error_Msg_NE
+ ("cannot import&, renaming already provided for " &
+ "declaration #", N, Def_Id);
end if;
end;
end if;
end loop;
- -- When the convention is Java, we also allow Import to be given
- -- for packages, exceptions, and record components.
+ -- When the convention is Java or CIL, we also allow Import to be
+ -- given for packages, generic packages, exceptions, and record
+ -- components.
- elsif C = Convention_Java
+ elsif (C = Convention_Java or else C = Convention_CIL)
and then
(Ekind (Def_Id) = E_Package
+ or else Ekind (Def_Id) = E_Generic_Package
or else Ekind (Def_Id) = E_Exception
or else Nkind (Parent (Def_Id)) = N_Component_Declaration)
then
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
+ -- Types treated as CPP classes are treated as limited, but we
+ -- don't require them to be declared this way. A warning is
+ -- issued to encourage the user to declare them as limited.
+ -- This is not an error, for compatibility reasons, because
+ -- these types have been supported this way for some time.
+
+ if not Is_Limited_Type (Def_Id) then
+ Error_Msg_N
+ ("imported 'C'P'P type should be " &
+ "explicitly declared limited?",
+ Get_Pragma_Arg (Arg2));
+ Error_Msg_N
+ ("\type will be considered limited",
+ Get_Pragma_Arg (Arg2));
+ end if;
+
+ 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",
-- trivially possible.
elsif
- Nkind (Unit_Declaration_Node (Corresponding_Body (Decl)))
- = N_Subprogram_Renaming_Declaration
+ Nkind (Unit_Declaration_Node (Corresponding_Body (Decl))) =
+ N_Subprogram_Renaming_Declaration
then
return False;
C := Get_String_Char (S, J);
if Warn_On_Export_Import
- and then (not In_Character_Range (C)
- or else Get_Character (C) = ' '
- or else Get_Character (C) = ',')
+ and then
+ (not In_Character_Range (C)
+ or else (Get_Character (C) = ' '
+ and then VM_Target /= CLI_Target)
+ or else Get_Character (C) = ',')
then
Error_Msg_N
("?interface name contains illegal character", SN);
begin
if No (Link_Arg) then
if No (Ext_Arg) then
+ if VM_Target = CLI_Target
+ and then Ekind (Subprogram_Def) = E_Package
+ and then Nkind (Parent (Subprogram_Def)) =
+ N_Package_Specification
+ and then Present (Generic_Parent (Parent (Subprogram_Def)))
+ then
+ Set_Interface_Name
+ (Subprogram_Def,
+ Interface_Name
+ (Generic_Parent (Parent (Subprogram_Def))));
+ end if;
+
return;
elsif Chars (Ext_Arg) = Name_Link_Name then
and then Ekind (Scope (E)) = E_Package
then
Par := Parent (E);
-
while Present (Par) loop
if Nkind (Par) = N_Package_Body then
Error_Msg_Sloc := Sloc (E);
else
Start_String;
- Store_String_Char (Get_Char_Code ('*'));
- String_Val := Strval (Expr_Value_S (Link_Nam));
- for J in 1 .. String_Length (String_Val) loop
- Store_String_Char (Get_String_Char (String_Val, J));
- end loop;
+ if VM_Target = No_VM then
+ Store_String_Char (Get_Char_Code ('*'));
+ end if;
+ String_Val := Strval (Expr_Value_S (Link_Nam));
+ Store_String_Chars (String_Val);
Link_Nam :=
- Make_String_Literal (Sloc (Link_Nam), End_String);
+ Make_String_Literal (Sloc (Link_Nam),
+ Strval => End_String);
end if;
Set_Encoded_Interface_Name
-- but it is harmless (and more straightforward) to simply handle all
-- cases here, even if it means we repeat a bit of work in some cases.
- procedure Process_Restrictions_Or_Restriction_Warnings is
+ procedure Process_Restrictions_Or_Restriction_Warnings
+ (Warn : Boolean)
+ is
Arg : Node_Id;
R_Id : Restriction_Id;
Id : Name_Id;
-- Checks unit name parameter for No_Dependence. Returns if it has
-- an appropriate form, otherwise raises pragma argument error.
- procedure Set_Warning (R : All_Restrictions);
- -- If this is a Restriction_Warnings pragma, set warning flag,
- -- otherwise reset the flag.
-
---------------------
-- Check_Unit_Name --
---------------------
end if;
end Check_Unit_Name;
- -----------------
- -- Set_Warning --
- -----------------
-
- procedure Set_Warning (R : All_Restrictions) is
- begin
- if Prag_Id = Pragma_Restriction_Warnings then
- Restriction_Warnings (R) := True;
- else
- Restriction_Warnings (R) := False;
- end if;
- end Set_Warning;
-
-- Start of processing for Process_Restrictions_Or_Restriction_Warnings
begin
(No_Implementation_Restrictions, Arg);
end if;
- Set_Restriction (R_Id, N);
- Set_Warning (R_Id);
+ -- If this is a warning, then set the warning unless we already
+ -- have a real restriction active (we never want a warning to
+ -- override a real restriction).
- -- 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 language definition, but it
- -- is what is intended by RM H.4(12).
+ if Warn then
+ if not Restriction_Active (R_Id) then
+ Set_Restriction (R_Id, N);
+ Restriction_Warnings (R_Id) := True;
+ end if;
+
+ -- If real restriction case, then set it and make sure that the
+ -- restriction warning flag is off, since a real restriction
+ -- always overrides a warning.
+
+ else
+ Set_Restriction (R_Id, N);
+ Restriction_Warnings (R_Id) := False;
+ 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
+ -- language definition, but it is what is intended by RM
+ -- H.4(12). Restriction_Warnings never affects generated code
+ -- so this is done only in the real restriction case.
- if R_Id = No_Exceptions then
+ if R_Id = No_Exceptions and then not Warn then
Scope_Suppress := (others => True);
end if;
then
Error_Pragma_Arg
("value must be non-negative integer", Arg);
+ end if;
- -- Restriction pragma is active
+ -- Restriction pragma is active
- else
- Val := Expr_Value (Expr);
+ Val := Expr_Value (Expr);
- if not UI_Is_In_Int_Range (Val) then
- Error_Pragma_Arg
- ("pragma ignored, value too large?", Arg);
- else
- Set_Restriction (R_Id, N, Integer (UI_To_Int (Val)));
- Set_Warning (R_Id);
+ if not UI_Is_In_Int_Range (Val) then
+ Error_Pragma_Arg
+ ("pragma ignored, value too large?", Arg);
+ end if;
+
+ -- Warning case. If the real restriction is active, then we
+ -- ignore the request, since warning never overrides a real
+ -- restriction. Otherwise we set the proper warning. Note that
+ -- this circuit sets the warning again if it is already set,
+ -- which is what we want, since the constant may have changed.
+
+ if Warn then
+ if not Restriction_Active (R_Id) then
+ Set_Restriction
+ (R_Id, N, Integer (UI_To_Int (Val)));
+ Restriction_Warnings (R_Id) := True;
end if;
+
+ -- Real restriction case, set restriction and make sure warning
+ -- flag is off since real restriction always overrides warning.
+
+ else
+ Set_Restriction (R_Id, N, Integer (UI_To_Int (Val)));
+ Restriction_Warnings (R_Id) := False;
end if;
end if;
--------------------------------
procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id) is
- ESR : constant Entity_Check_Suppress_Record :=
- (Entity => E,
- Check => C,
- Suppress => Suppress_Case);
-
begin
Set_Checks_May_Be_Suppressed (E);
if In_Package_Spec then
- Global_Entity_Suppress.Append (ESR);
+ Push_Global_Suppress_Stack_Entry
+ (Entity => E,
+ Check => C,
+ Suppress => Suppress_Case);
+
else
- Local_Entity_Suppress.Append (ESR);
+ Push_Local_Suppress_Stack_Entry
+ (Entity => E,
+ Check => C,
+ Suppress => Suppress_Case);
end if;
-- If this is a first subtype, and the base type is distinct,
Check_No_Identifier (Arg1);
Check_Arg_Is_Identifier (Arg1);
- if not Is_Check_Name (Chars (Expression (Arg1))) then
+ C := Get_Check_Id (Chars (Expression (Arg1)));
+
+ if C = No_Check_Id then
Error_Pragma_Arg
("argument of pragma% is not valid check name", Arg1);
- else
- C := Get_Check_Id (Chars (Expression (Arg1)));
+ end if;
+
+ if not Suppress_Case
+ and then (C = All_Checks or else C = Overflow_Check)
+ then
+ Opt.Overflow_Checks_Unsuppressed := True;
end if;
if Arg_Count = 1 then
-- suppress check for any check id value.
if C = All_Checks then
+
+ -- For All_Checks, we set all specific predefined checks with
+ -- the exception of Elaboration_Check, which is handled
+ -- specially because of not wanting All_Checks to have the
+ -- effect of deactivating static elaboration order processing.
+
for J in Scope_Suppress'Range loop
- Scope_Suppress (J) := Suppress_Case;
+ if J /= Elaboration_Check then
+ Scope_Suppress (J) := Suppress_Case;
+ end if;
end loop;
- else
+
+ -- If not All_Checks, and predefined check, then set appropriate
+ -- scope entry. Note that we will set Elaboration_Check if this
+ -- is explicitly specified.
+
+ elsif C in Predefined_Check_Id then
Scope_Suppress (C) := Suppress_Case;
end if;
- -- Also make an entry in the Local_Entity_Suppress table. See
- -- extended description in the package spec of Sem for details.
+ -- Also make an entry in the Local_Entity_Suppress table
- Local_Entity_Suppress.Append
- ((Entity => Empty,
- Check => C,
- Suppress => Suppress_Case));
+ Push_Local_Suppress_Stack_Entry
+ (Entity => Empty,
+ Check => C,
+ Suppress => Suppress_Case);
- -- Case of two arguments present, where the check is
- -- suppressed for a specified entity (given as the second
- -- argument of the pragma)
+ -- Case of two arguments present, where the check is suppressed for
+ -- a specified entity (given as the second argument of the pragma)
else
Check_Optional_Identifier (Arg2, Name_On);
and then Scope (E) /= Current_Scope
then
Error_Pragma_Arg
- ("entity in pragma% is not in package spec ('R'M 11.5(7))",
+ ("entity in pragma% is not in package spec (RM 11.5(7))",
Arg2);
end if;
procedure Set_Imported (E : Entity_Id) is
begin
- Error_Msg_Sloc := Sloc (E);
+ -- Error message if already imported or exported
if Is_Exported (E) or else Is_Imported (E) then
- Error_Msg_NE ("import of& declared# not allowed", N, E);
-
if Is_Exported (E) then
- Error_Msg_N ("\entity was previously exported", N);
+ Error_Msg_NE ("entity& was previously exported", N, E);
else
- Error_Msg_N ("\entity was previously imported", N);
+ Error_Msg_NE ("entity& was previously imported", N, E);
end if;
- Error_Pragma ("\(pragma% applies to all previous entities)");
+ Error_Msg_Name_1 := Chars (N);
+ Error_Msg_N
+ ("\(pragma% applies to all previous entities)", N);
+
+ Error_Msg_Sloc := Sloc (E);
+ Error_Msg_NE ("\import not allowed for& declared#", N, E);
+
+ -- Here if not previously imported or exported, OK to import
else
Set_Is_Imported (E);
Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
- -- Set the FIFO_Within_Priorities policy, but always
- -- preserve System_Location since we like the error
- -- message with the run time name.
+ -- Set the FIFO_Within_Priorities policy, but always preserve
+ -- System_Location since we like the error message with the run time
+ -- name.
else
Task_Dispatching_Policy := 'F';
Error_Msg_Sloc := Locking_Policy_Sloc;
Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
- -- Set the Ceiling_Locking policy, but always preserve
- -- System_Location since we like the error message with the
- -- run time name.
+ -- Set the Ceiling_Locking policy, but preserve System_Location since
+ -- we like the error message with the run time name.
else
Locking_Policy := 'C';
-- Start of processing for Analyze_Pragma
begin
+ -- Deal with unrecognized pragma
+
if not Is_Pragma_Name (Chars (N)) then
if Warn_On_Unrecognized_Pragma then
- Error_Pragma ("unrecognized pragma%!?");
- else
- raise Pragma_Exit;
+ Error_Msg_Name_1 := Chars (N);
+ Error_Msg_N ("?unrecognized pragma%!", N);
+
+ for PN in First_Pragma_Name .. Last_Pragma_Name loop
+ if Is_Bad_Spelling_Of
+ (Get_Name_String (Chars (N)),
+ Get_Name_String (PN))
+ then
+ Error_Msg_Name_1 := PN;
+ Error_Msg_N ("\?possible misspelling of %!", N);
+ exit;
+ end if;
+ end loop;
end if;
- else
- Prag_Id := Get_Pragma_Id (Chars (N));
+
+ return;
end if;
+ -- Here to start processing for recognized pragma
+
+ Prag_Id := Get_Pragma_Id (Chars (N));
+
-- Preset arguments
Arg1 := Empty;
when Pragma_Ada_83 =>
GNAT_Pragma;
+ Check_Arg_Count (0);
+
+ -- We really should check unconditionally for proper configuration
+ -- pragma placement, since we really don't want mixed Ada modes
+ -- within a single unit, and the GNAT reference manual has always
+ -- said this was a configuration pragma, but we did not check and
+ -- are hesitant to add the check now.
+
+ -- However, we really cannot tolerate mixing Ada 2005 with Ada 83
+ -- or Ada 95, so we must check if we are in Ada 2005 mode.
+
+ if Ada_Version >= Ada_05 then
+ Check_Valid_Configuration_Pragma;
+ end if;
+
+ -- Now set Ada 83 mode
+
Ada_Version := Ada_83;
Ada_Version_Explicit := Ada_Version;
- Check_Arg_Count (0);
------------
-- Ada_95 --
when Pragma_Ada_95 =>
GNAT_Pragma;
+ Check_Arg_Count (0);
+
+ -- We really should check unconditionally for proper configuration
+ -- pragma placement, since we really don't want mixed Ada modes
+ -- within a single unit, and the GNAT reference manual has always
+ -- said this was a configuration pragma, but we did not check and
+ -- are hesitant to add the check now.
+
+ -- However, we really cannot tolerate mixing Ada 2005 with Ada 83
+ -- or Ada 95, so we must check if we are in Ada 2005 mode.
+
+ if Ada_Version >= Ada_05 then
+ Check_Valid_Configuration_Pragma;
+ end if;
+
+ -- Now set Ada 95 mode
+
Ada_Version := Ada_95;
Ada_Version_Explicit := Ada_Version;
- Check_Arg_Count (0);
- ------------
- -- Ada_05 --
- ------------
+ ---------------------
+ -- Ada_05/Ada_2005 --
+ ---------------------
-- pragma Ada_05;
-- pragma Ada_05 (LOCAL_NAME);
- -- Note: this pragma also has some specific processing in Par.Prag
+ -- pragma Ada_2005;
+ -- pragma Ada_2005 (LOCAL_NAME):
+
+ -- Note: these pragma also have some specific processing in Par.Prag
-- because we want to set the Ada 2005 version mode during parsing.
- when Pragma_Ada_05 => declare
+ when Pragma_Ada_05 | Pragma_Ada_2005 => declare
E_Id : Node_Id;
begin
return;
end if;
- Set_Is_Ada_2005 (Entity (E_Id));
+ Set_Is_Ada_2005_Only (Entity (E_Id));
else
Check_Arg_Count (0);
+
+ -- For Ada_2005 we unconditionally enforce the documented
+ -- configuration pragma placement, since we do not want to
+ -- tolerate mixed modes in a unit involving Ada 2005. That
+ -- would cause real difficulties for those cases where there
+ -- are incompatibilities between Ada 95 and Ada 2005.
+
+ Check_Valid_Configuration_Pragma;
+
+ -- Now set Ada 2005 mode
+
Ada_Version := Ada_05;
- Ada_Version_Explicit := Ada_Version;
+ Ada_Version_Explicit := Ada_05;
end if;
end;
Check_Arg_Is_Identifier (Arg1);
declare
- Arg : Node_Id := Arg2;
+ Arg : Node_Id;
Exp : Node_Id;
begin
+ Arg := Arg2;
while Present (Arg) loop
Exp := Expression (Arg);
Analyze (Exp);
-- pragma Assert ([Check =>] Boolean_EXPRESSION
-- [, [Message =>] Static_String_EXPRESSION]);
- when Pragma_Assert =>
+ when Pragma_Assert => Assert : declare
+ Expr : Node_Id;
+
+ begin
+ Ada_2005_Pragma;
Check_At_Least_N_Arguments (1);
Check_At_Most_N_Arguments (2);
Check_Arg_Order ((Name_Check, Name_Message));
-- directly, or it may cause insertion of actions that would
-- escape the attempt to suppress the assertion code.
+ Expr := Expression (Arg1);
+
if Expander_Active and not Assertions_Enabled then
Rewrite (N,
Make_If_Statement (Loc,
Condition =>
Make_And_Then (Loc,
Left_Opnd => New_Occurrence_Of (Standard_False, Loc),
- Right_Opnd => Get_Pragma_Arg (Arg1)),
+ Right_Opnd => Expr),
Then_Statements => New_List (
Make_Null_Statement (Loc))));
-- and resolve the expression.
else
- Analyze_And_Resolve (Expression (Arg1), Any_Boolean);
+ Analyze_And_Resolve (Expr, Any_Boolean);
+ end if;
+
+ -- If assertion is of the form (X'First = literal), where X is
+ -- formal parameter, then set Low_Bound_Known flag on this formal.
+
+ if Nkind (Expr) = N_Op_Eq then
+ declare
+ Right : constant Node_Id := Right_Opnd (Expr);
+ Left : constant Node_Id := Left_Opnd (Expr);
+ begin
+ if Nkind (Left) = N_Attribute_Reference
+ and then Attribute_Name (Left) = Name_First
+ and then Is_Entity_Name (Prefix (Left))
+ and then Is_Formal (Entity (Prefix (Left)))
+ and then Nkind (Right) = N_Integer_Literal
+ then
+ Set_Low_Bound_Known (Entity (Prefix (Left)));
+ end if;
+ end;
end if;
+ end Assert;
----------------------
-- Assertion_Policy --
-- pragma Assertion_Policy (Check | Ignore)
when Pragma_Assertion_Policy =>
+ Ada_2005_Pragma;
Check_Arg_Count (1);
Check_Arg_Is_One_Of (Arg1, Name_Check, Name_Ignore);
Assertions_Enabled := Chars (Expression (Arg1)) = Name_Check;
procedure Process_Async_Pragma is
begin
- if not Present (L) then
+ if No (L) then
Set_Is_Asynchronous (Nm);
return;
end if;
end if;
end C_Pass_By_Copy;
+ ----------------
+ -- Check_Name --
+ ----------------
+
+ -- pragma Check_Name (check_IDENTIFIER);
+
+ when Pragma_Check_Name =>
+ Check_No_Identifiers;
+ GNAT_Pragma;
+ Check_Valid_Configuration_Pragma;
+ Check_Arg_Count (1);
+ Check_Arg_Is_Identifier (Arg1);
+
+ declare
+ Nam : constant Name_Id := Chars (Expression (Arg1));
+
+ begin
+ for J in Check_Names.First .. Check_Names.Last loop
+ if Check_Names.Table (J) = Nam then
+ return;
+ end if;
+ end loop;
+
+ Check_Names.Append (Nam);
+ end;
+
+ ---------------------
+ -- CIL_Constructor --
+ ---------------------
+
+ -- pragma CIL_Constructor ([Entity =>] LOCAL_NAME);
+
+ -- Processing for this pragma is shared with Java_Constructor
+
-------------
-- Comment --
-------------
-- 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 --
--------------------------
-- 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);
+ when Pragma_Compile_Time_Warning =>
+ Process_Compile_Time_Warning_Or_Error;
- begin
- GNAT_Pragma;
- Check_Arg_Count (2);
- Check_No_Identifiers;
- Check_Arg_Is_Static_Expression (Arg2, Standard_String);
- Analyze_And_Resolve (Arg1x, Standard_Boolean);
+ -------------------
+ -- Compiler_Unit --
+ -------------------
- if Compile_Time_Known_Value (Arg1x) then
- if Is_True (Expr_Value (Get_Pragma_Arg (Arg1))) then
- String_To_Name_Buffer (Strval (Get_Pragma_Arg (Arg2)));
- Add_Char_To_Name_Buffer ('?');
+ when Pragma_Compiler_Unit =>
+ GNAT_Pragma;
+ Check_Arg_Count (0);
+ Set_Is_Compiler_Unit (Get_Source_Unit (N));
- declare
- Msg : String (1 .. Name_Len) :=
- Name_Buffer (1 .. Name_Len);
+ -----------------------------
+ -- Complete_Representation --
+ -----------------------------
- B : Natural;
+ -- pragma Complete_Representation;
- begin
- -- This loop looks for multiple lines separated by
- -- ASCII.LF and breaks them into continuation error
- -- messages marked with the usual back slash.
-
- B := 1;
- for S in 2 .. Msg'Length - 1 loop
- if Msg (S) = ASCII.LF then
- Msg (S) := '?';
- Error_Msg_N (Msg (B .. S), Arg1);
- B := S;
- Msg (B) := '\';
- end if;
- end loop;
+ when Pragma_Complete_Representation =>
+ GNAT_Pragma;
+ Check_Arg_Count (0);
- Error_Msg_N (Msg (B .. Msg'Length), Arg1);
- end;
- end if;
+ if Nkind (Parent (N)) /= N_Record_Representation_Clause then
+ Error_Pragma
+ ("pragma & must appear within record representation clause");
end if;
- end Compile_Time_Warning;
----------------------------
-- Complex_Representation --
else
Set_Has_Complex_Representation (Base_Type (E));
+
+ -- We need to treat the type has having a non-standard
+ -- representation, for back-end purposes, even though in
+ -- general a complex will have the default representation
+ -- of a record with two real components.
+
+ Set_Has_Non_Standard_Rep (Base_Type (E));
end if;
end Complex_Representation;
when Pragma_Convention => Convention : declare
C : Convention_Id;
E : Entity_Id;
+ pragma Warnings (Off, C);
+ pragma Warnings (Off, E);
begin
Check_Arg_Order ((Name_Convention, Name_Entity));
Check_Ada_83_Warning;
Check_Optional_Identifier (Arg1, Name_Name);
Check_Optional_Identifier (Arg2, Name_Convention);
Check_Arg_Is_Identifier (Arg1);
- Check_Arg_Is_Identifier (Arg1);
+ Check_Arg_Is_Identifier (Arg2);
Idnam := Chars (Expression (Arg1));
Cname := Chars (Expression (Arg2));
-- 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);
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 vtable ptr
-
- -- What is test for Typ = Root_Typ (Typ) about here ???
-
- elsif Is_Tagged_Type (Typ)
- and then Typ = Root_Type (Typ)
- and then No (Default_DTC)
- then
- Error_Pragma_Arg
- ("a cpp_class must contain a vtable pointer", Arg1);
-
- -- 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));
+ Error_Pragma_Arg ("pragma% applicable to tagged types ", Arg1);
+ end if;
- else
- while Next_Entity (C) /= Tag_C loop
- Next_Entity (C);
- end loop;
+ -- Types treated as CPP classes are treated as limited, but we
+ -- don't require them to be declared this way. A warning is issued
+ -- to encourage the user to declare them as limited. This is not
+ -- an error, for compatibility reasons, because these types have
+ -- been supported this way for some time.
- Set_Next_Entity (C, Next_Entity (Tag_C));
- end if;
- end if;
+ if not Is_Limited_Type (Typ) then
+ Error_Msg_N
+ ("imported 'C'P'P type should be " &
+ "explicitly declared limited?",
+ Get_Pragma_Arg (Arg1));
+ Error_Msg_N
+ ("\type will be considered limited",
+ Get_Pragma_Arg (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;
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);
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;
-- 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;
-
- 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;
-- 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;
-- Debug --
-----------
- -- pragma Debug (PROCEDURE_CALL_STATEMENT);
+ -- pragma Debug ([boolean_EXPRESSION,] PROCEDURE_CALL_STATEMENT);
- when Pragma_Debug => Debug : begin
+ when Pragma_Debug => Debug : declare
+ Cond : Node_Id;
+
+ begin
GNAT_Pragma;
- -- Rewrite into a conditional with a static condition
+ Cond :=
+ New_Occurrence_Of
+ (Boolean_Literals (Debug_Pragmas_Enabled and Expander_Active),
+ Loc);
+
+ if Arg_Count = 2 then
+ Cond :=
+ Make_And_Then (Loc,
+ Left_Opnd => Relocate_Node (Cond),
+ Right_Opnd => Expression (Arg1));
+ end if;
+
+ -- Rewrite into a conditional with an appropriate condition. We
+ -- wrap the procedure call in a block so that overhead from e.g.
+ -- use of the secondary stack does not generate execution overhead
+ -- for suppressed conditions.
Rewrite (N, Make_Implicit_If_Statement (N,
- Condition => New_Occurrence_Of (Boolean_Literals (
- Debug_Pragmas_Enabled and Expander_Active), Loc),
- Then_Statements => New_List (
- Relocate_Node (Debug_Statement (N)))));
+ Condition => Cond,
+ Then_Statements => New_List (
+ Make_Block_Statement (Loc,
+ Handled_Statement_Sequence =>
+ Make_Handled_Sequence_Of_Statements (Loc,
+ Statements => New_List (
+ Relocate_Node (Debug_Statement (N))))))));
Analyze (N);
end Debug;
-- pragma Detect_Blocking;
when Pragma_Detect_Blocking =>
- GNAT_Pragma;
+ Ada_2005_Pragma;
Check_Arg_Count (0);
Check_Valid_Configuration_Pragma;
Detect_Blocking := True;
-- If there is no parameter, then from now on this pragma
-- applies to any enumeration, exception or tagged type
- -- defined in the current declarative part.
+ -- defined in the current declarative part, and recursively
+ -- to any nested scope.
Set_Discard_Names (Current_Scope);
return;
-- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
when Pragma_Elaborate => Elaborate : declare
- Plist : List_Id;
- Parent_Node : Node_Id;
- Arg : Node_Id;
- Citem : Node_Id;
+ Arg : Node_Id;
+ Citem : Node_Id;
begin
-- Pragma must be in context items list of a compilation unit
- if not Is_List_Member (N) then
+ if not Is_In_Context_Clause then
Pragma_Misplaced;
- return;
-
- else
- Plist := List_Containing (N);
- Parent_Node := Parent (Plist);
-
- if Parent_Node = Empty
- or else Nkind (Parent_Node) /= N_Compilation_Unit
- or else Context_Items (Parent_Node) /= Plist
- then
- Pragma_Misplaced;
- return;
- end if;
end if;
-- Must be at least one argument
if Ada_Version = Ada_83 and then Comes_From_Source (N) then
Citem := Next (N);
-
while Present (Citem) loop
if Nkind (Citem) = N_Pragma
or else (Nkind (Citem) = N_With_Clause
end if;
-- Finally, the arguments must all be units mentioned in a with
- -- clause in the same context clause. Note we already checked
- -- (in Par.Prag) that the arguments are either identifiers or
+ -- clause in the same context clause. Note we already checked (in
+ -- Par.Prag) that the arguments are all identifiers or selected
+ -- components.
Arg := Arg1;
Outer : while Present (Arg) loop
- Citem := First (Plist);
-
+ Citem := First (List_Containing (N));
Inner : while Citem /= N loop
if Nkind (Citem) = N_With_Clause
and then Same_Name (Name (Citem), Expression (Arg))
Set_Suppress_Elaboration_Warnings
(Entity (Name (Citem)));
end if;
+
exit Inner;
end if;
-- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
when Pragma_Elaborate_All => Elaborate_All : declare
- Plist : List_Id;
- Parent_Node : Node_Id;
- Arg : Node_Id;
- Citem : Node_Id;
+ Arg : Node_Id;
+ Citem : Node_Id;
begin
Check_Ada_83_Warning;
-- Pragma must be in context items list of a compilation unit
- if not Is_List_Member (N) then
+ if not Is_In_Context_Clause then
Pragma_Misplaced;
- return;
-
- else
- Plist := List_Containing (N);
- Parent_Node := Parent (Plist);
-
- if Parent_Node = Empty
- or else Nkind (Parent_Node) /= N_Compilation_Unit
- or else Context_Items (Parent_Node) /= Plist
- then
- Pragma_Misplaced;
- return;
- end if;
end if;
-- Must be at least one argument
Arg := Arg1;
Outr : while Present (Arg) loop
- Citem := First (Plist);
-
+ Citem := First (List_Containing (N));
Innr : while Citem /= N loop
if Nkind (Citem) = N_With_Clause
and then Same_Name (Name (Citem), Expression (Arg))
Error_Pragma ("pragma% must refer to a spec, not a body");
else
Set_Body_Required (Cunit_Node, True);
- Set_Has_Pragma_Elaborate_Body (Cunit_Ent);
+ Set_Has_Pragma_Elaborate_Body (Cunit_Ent);
-- If we are in dynamic elaboration mode, then we suppress
-- elaboration warnings for the unit, since it is definitely
Present (Source_Location)
then
Error_Pragma
- ("parameter profile and source location can not " &
+ ("parameter profile and source location cannot " &
"be used together in pragma%");
end if;
Source_Location);
end Eliminate;
- -------------------------
- -- Explicit_Overriding --
- -------------------------
-
- when Pragma_Explicit_Overriding =>
- Check_Valid_Configuration_Pragma;
- Check_Arg_Count (0);
- Explicit_Overriding := True;
-
------------
-- Export --
------------
C : Convention_Id;
Def_Id : Entity_Id;
+ pragma Warnings (Off, C);
+
begin
Check_Ada_83_Warning;
Check_Arg_Order
null;
else
Error_Msg_Sloc := Sloc (System_Extend_Pragma_Arg);
- Error_Pragma ("pragma% conflicts with that at#");
+ Error_Pragma ("pragma% conflicts with that #");
end if;
else
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 --
--------------
-- [, [Link_Name =>] static_string_EXPRESSION ]);
when Pragma_External => External : declare
- C : Convention_Id;
- Def_Id : Entity_Id;
+ Def_Id : Entity_Id;
+
+ C : Convention_Id;
+ pragma Warnings (Off, C);
+
begin
GNAT_Pragma;
Check_Arg_Order
end;
end Ident;
+ -----------------------
+ -- Implicit_Packing --
+ -----------------------
+
+ -- pragma Implicit_Packing;
+
+ when Pragma_Implicit_Packing =>
+ GNAT_Pragma;
+ Check_Arg_Count (0);
+ Implicit_Packing := True;
+
------------
-- Import --
------------
---------------
-- pragma Interface (
- -- convention_IDENTIFIER,
- -- local_NAME );
+ -- [ Convention =>] convention_IDENTIFIER,
+ -- [ Entity =>] local_NAME
+ -- [, [External_Name =>] static_string_EXPRESSION ]
+ -- [, [Link_Name =>] static_string_EXPRESSION ]);
when Pragma_Interface =>
GNAT_Pragma;
- Check_Arg_Count (2);
- Check_No_Identifiers;
+ Check_Arg_Order
+ ((Name_Convention,
+ Name_Entity,
+ Name_External_Name,
+ Name_Link_Name));
+ Check_At_Least_N_Arguments (2);
+ Check_At_Most_N_Arguments (4);
Process_Import_Or_Interface;
--------------------
Error_Msg_Sloc :=
Interrupt_States.Table (IST_Num).Pragma_Loc;
Error_Pragma_Arg
- ("state conflicts with that given at #", Arg2);
+ ("state conflicts with that given #", Arg2);
exit;
end if;
-- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
- when Pragma_Java_Constructor => Java_Constructor : declare
- Id : Entity_Id;
- Def_Id : Entity_Id;
- Hom_Id : Entity_Id;
+ -- Also handles pragma CIL_Constructor
+
+ when Pragma_CIL_Constructor | Pragma_Java_Constructor =>
+ Java_Constructor : declare
+ Id : Entity_Id;
+ Def_Id : Entity_Id;
+ Hom_Id : Entity_Id;
+ Convention : Convention_Id;
begin
GNAT_Pragma;
return;
end if;
+ case Prag_Id is
+ when Pragma_CIL_Constructor => Convention := Convention_CIL;
+ when Pragma_Java_Constructor => Convention := Convention_Java;
+ when others => null;
+ end case;
+
Hom_Id := Entity (Id);
-- Loop through homonyms
loop
Def_Id := Get_Base_Subprogram (Hom_Id);
- -- The constructor is required to be a function returning
- -- an access type whose designated type has convention Java.
+ -- The constructor is required to be a function returning an
+ -- access type whose designated type has convention Java/CIL.
if Ekind (Def_Id) = E_Function
- and then Ekind (Etype (Def_Id)) in Access_Kind
and then
- (Atree.Convention
- (Designated_Type (Etype (Def_Id))) = Convention_Java
- or else
- Atree.Convention
- (Root_Type (Designated_Type (Etype (Def_Id))))
- = Convention_Java)
+ (Is_Value_Type (Etype (Def_Id))
+ or else
+ (Ekind (Etype (Def_Id)) in Access_Kind
+ and then
+ (Atree.Convention
+ (Designated_Type (Etype (Def_Id))) = Convention
+ or else
+ Atree.Convention
+ (Root_Type (Designated_Type (Etype (Def_Id)))) =
+ Convention)))
then
Set_Is_Constructor (Def_Id);
- Set_Convention (Def_Id, Convention_Java);
+ Set_Convention (Def_Id, Convention);
+ Set_Is_Imported (Def_Id);
else
- Error_Pragma_Arg
- ("pragma% requires function returning a 'Java access type",
- Arg1);
+ if Convention = Convention_Java then
+ Error_Pragma_Arg
+ ("pragma% requires function returning a " &
+ "'Java access type", Arg1);
+ else
+ pragma Assert (Convention = Convention_CIL);
+ Error_Pragma_Arg
+ ("pragma% requires function returning a " &
+ "'CIL access type", Arg1);
+ end if;
end if;
Hom_Id := Homonym (Hom_Id);
-- 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);
-- differences in processing between Link_With
-- and Linker_Options).
- declare
+ Arg_Store : declare
C : constant Char_Code := Get_Char_Code (' ');
S : constant String_Id :=
Strval (Expr_Value_S (Expression (Arg)));
procedure Skip_Spaces;
-- Advance F past any spaces
+ -----------------
+ -- Skip_Spaces --
+ -----------------
+
procedure Skip_Spaces is
begin
while F <= L and then Get_String_Char (S, F) = C loop
end loop;
end Skip_Spaces;
+ -- Start of processing for Arg_Store
+
begin
Skip_Spaces; -- skip leading spaces
F := F + 1;
end if;
end loop;
- end;
+ end Arg_Store;
Arg := Next (Arg);
-- Main --
----------
- -- pragma Main_Storage
- -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
+ -- pragma Main
+ -- (MAIN_OPTION [, MAIN_OPTION]);
- -- MAIN_STORAGE_OPTION ::=
- -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
- -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
+ -- MAIN_OPTION ::=
+ -- [STACK_SIZE =>] static_integer_EXPRESSION
+ -- | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
+ -- | [TIME_SLICING_ENABLED =>] static_boolean_EXPRESSION
when Pragma_Main => Main : declare
Args : Args_List (1 .. 3);
Check_Arg_Count (1);
Check_Arg_Is_Integer_Literal (Arg1);
- ---------------
- -- No_Return --
- ---------------
+ -------------
+ -- No_Body --
+ -------------
+
+ -- pragma No_Body;
+
+ -- The only correct use of this pragma is on its own in a file, in
+ -- which case it is specially processed (see Gnat1drv.Check_Bad_Body
+ -- and Frontend, which use Sinput.L.Source_File_Is_Pragma_No_Body to
+ -- check for a file containing nothing but a No_Body pragma). If we
+ -- attempt to process it during normal semantics processing, it means
+ -- it was misplaced.
+
+ when Pragma_No_Body =>
+ Error_Pragma ("misplaced pragma %");
+
+ ---------------
+ -- No_Return --
+ ---------------
- -- pragma No_Return (procedure_LOCAL_NAME);
+ -- pragma No_Return (procedure_LOCAL_NAME {, procedure_Local_Name});
when Pragma_No_Return => No_Return : declare
Id : Node_Id;
E : Entity_Id;
Found : Boolean;
+ Arg : Node_Id;
begin
GNAT_Pragma;
- Check_Arg_Count (1);
- Check_No_Identifiers;
- Check_Arg_Is_Local_Name (Arg1);
- Id := Expression (Arg1);
- Analyze (Id);
+ Check_At_Least_N_Arguments (1);
- if not Is_Entity_Name (Id) then
- Error_Pragma_Arg ("entity name required", Arg1);
- end if;
+ -- Loop through arguments of pragma
- if Etype (Id) = Any_Type then
- raise Pragma_Exit;
- end if;
+ Arg := Arg1;
+ while Present (Arg) loop
+ Check_Arg_Is_Local_Name (Arg);
+ Id := Expression (Arg);
+ Analyze (Id);
- E := Entity (Id);
+ if not Is_Entity_Name (Id) then
+ Error_Pragma_Arg ("entity name required", Arg);
+ end if;
- Found := False;
- while Present (E)
- and then Scope (E) = Current_Scope
- loop
- if Ekind (E) = E_Procedure
- or else Ekind (E) = E_Generic_Procedure
- then
- Set_No_Return (E);
- Found := True;
+ if Etype (Id) = Any_Type then
+ raise Pragma_Exit;
end if;
- E := Homonym (E);
- end loop;
+ -- Loop to find matching procedures
- if not Found then
- Error_Pragma ("no procedures found for pragma%");
- end if;
+ E := Entity (Id);
+ Found := False;
+ while Present (E)
+ and then Scope (E) = Current_Scope
+ loop
+ if Ekind (E) = E_Procedure
+ or else Ekind (E) = E_Generic_Procedure
+ then
+ Set_No_Return (E);
+ Found := True;
+ end if;
+
+ E := Homonym (E);
+ end loop;
+
+ if not Found then
+ Error_Pragma_Arg ("no procedure & found for pragma%", Arg);
+ end if;
+
+ Next (Arg);
+ end loop;
end No_Return;
------------------------
-- Obsolescent --
-----------------
- -- pragma Obsolescent [(static_string_EXPRESSION [, Ada_05])];
+ -- pragma Obsolescent [(
+ -- [Entity => NAME,]
+ -- [(static_string_EXPRESSION [, Ada_05])];
when Pragma_Obsolescent => Obsolescent : declare
- Subp : Node_Or_Entity_Id;
- S : String_Id;
- Active : Boolean := True;
+ Ename : Node_Id;
+ Decl : Node_Id;
- begin
- GNAT_Pragma;
- Check_At_Most_N_Arguments (2);
- Check_No_Identifiers;
+ procedure Set_Obsolescent (E : Entity_Id);
+ -- Given an entity Ent, mark it as obsolescent if appropriate
- -- Check OK placement
+ ---------------------
+ -- Set_Obsolescent --
+ ---------------------
- -- First possibility is within a declarative region, where the
- -- pragma immediately follows a subprogram declaration.
+ procedure Set_Obsolescent (E : Entity_Id) is
+ Active : Boolean;
+ Ent : Entity_Id;
+ S : String_Id;
- if Present (Prev (N)) then
- Subp := Prev (N);
+ begin
+ Active := True;
+ Ent := E;
- -- Second possibility, stand alone subprogram declaration with the
- -- pragma immediately following the declaration.
+ -- Entity name was given
- elsif No (Prev (N))
- and then Nkind (Parent (N)) = N_Compilation_Unit_Aux
- then
- Subp := Unit (Parent (Parent (N)));
+ if Present (Ename) then
- -- Any other possibility is a misplacement
+ -- If entity name matches, we are fine
- else
- Subp := Empty;
- end if;
+ if Chars (Ename) = Chars (Ent) then
+ null;
- -- Check correct placement
+ -- If entity name does not match, only possibility is an
+ -- enumeration literal from an enumeration type declaration.
- if Nkind (Subp) /= N_Subprogram_Declaration then
- Error_Pragma
- ("pragma% misplaced, must immediately " &
- "follow subprogram spec");
- end if;
+ elsif Ekind (Ent) /= E_Enumeration_Type then
+ Error_Pragma
+ ("pragma % entity name does not match declaration");
- -- If OK placement, acquire arguments
+ else
+ Ent := First_Literal (E);
+ loop
+ if No (Ent) then
+ Error_Pragma
+ ("pragma % entity name does not match any " &
+ "enumeration literal");
+
+ elsif Chars (Ent) = Chars (Ename) then
+ exit;
+
+ else
+ Ent := Next_Literal (Ent);
+ end if;
+ end loop;
+ end if;
+ end if;
- Subp := Defining_Entity (Subp);
+ -- Ent points to entity to be marked
- if Arg_Count >= 1 then
+ if Arg_Count >= 1 then
- -- Deal with static string argument
+ -- Deal with static string argument
- Check_Arg_Is_Static_Expression (Arg1, Standard_String);
- S := Strval (Expression (Arg1));
+ Check_Arg_Is_Static_Expression (Arg1, Standard_String);
+ S := Strval (Expression (Arg1));
- for J in 1 .. String_Length (S) loop
- if not In_Character_Range (Get_String_Char (S, J)) then
- Error_Pragma_Arg
- ("pragma% argument does not allow wide characters",
- Arg1);
+ for J in 1 .. String_Length (S) loop
+ if not In_Character_Range (Get_String_Char (S, J)) then
+ Error_Pragma_Arg
+ ("pragma% argument does not allow wide characters",
+ Arg1);
+ end if;
+ end loop;
+
+ Set_Obsolescent_Warning (Ent, Expression (Arg1));
+
+ -- Check for Ada_05 parameter
+
+ if Arg_Count /= 1 then
+ Check_Arg_Count (2);
+
+ declare
+ Argx : constant Node_Id := Get_Pragma_Arg (Arg2);
+
+ begin
+ Check_Arg_Is_Identifier (Argx);
+
+ if Chars (Argx) /= Name_Ada_05 then
+ Error_Msg_Name_2 := Name_Ada_05;
+ Error_Pragma_Arg
+ ("only allowed argument for pragma% is %", Argx);
+ end if;
+
+ if Ada_Version_Explicit < Ada_05
+ or else not Warn_On_Ada_2005_Compatibility
+ then
+ Active := False;
+ end if;
+ end;
end if;
- end loop;
+ end if;
- Set_Obsolescent_Warning (Subp, Expression (Arg1));
+ -- Set flag if pragma active
- -- Check for Ada_05 parameter
+ if Active then
+ Set_Is_Obsolescent (Ent);
+ end if;
- if Arg_Count /= 1 then
- Check_Arg_Count (2);
+ return;
+ end Set_Obsolescent;
- declare
- Argx : constant Node_Id := Get_Pragma_Arg (Arg2);
+ -- Start of processing for pragma Obsolescent
- begin
- Check_Arg_Is_Identifier (Argx);
+ begin
+ GNAT_Pragma;
- if Chars (Argx) /= Name_Ada_05 then
- Error_Msg_Name_2 := Name_Ada_05;
- Error_Pragma_Arg
- ("only allowed argument for pragma% is %", Argx);
- end if;
+ Check_At_Most_N_Arguments (3);
+
+ -- See if first argument specifies an entity name
+
+ if Arg_Count >= 1
+ and then Chars (Arg1) = Name_Entity
+ then
+ Ename := Get_Pragma_Arg (Arg1);
+
+ if Nkind (Ename) /= N_Character_Literal
+ and then
+ Nkind (Ename) /= N_Identifier
+ and then
+ Nkind (Ename) /= N_Operator_Symbol
+ then
+ Error_Pragma_Arg ("entity name expected for pragma%", Arg1);
+ end if;
+
+ -- Eliminate first argument, so we can share processing
+
+ Arg1 := Arg2;
+ Arg2 := Arg3;
+ Arg_Count := Arg_Count - 1;
+
+ -- No Entity name argument given
+
+ else
+ Ename := Empty;
+ end if;
+
+ Check_No_Identifiers;
- if Ada_Version_Explicit < Ada_05
- or else not Warn_On_Ada_2005_Compatibility
+ -- Get immediately preceding declaration
+
+ Decl := Prev (N);
+ while Present (Decl) and then Nkind (Decl) = N_Pragma loop
+ Prev (Decl);
+ end loop;
+
+ -- Cases where we do not follow anything other than another pragma
+
+ if No (Decl) then
+
+ -- First case: library level compilation unit declaration with
+ -- the pragma immediately following the declaration.
+
+ if Nkind (Parent (N)) = N_Compilation_Unit_Aux then
+ Set_Obsolescent
+ (Defining_Entity (Unit (Parent (Parent (N)))));
+ return;
+
+ -- Case 2: library unit placement for package
+
+ else
+ declare
+ Ent : constant Entity_Id := Find_Lib_Unit_Name;
+ begin
+ if Ekind (Ent) = E_Package
+ or else Ekind (Ent) = E_Generic_Package
then
- Active := False;
+ Set_Obsolescent (Ent);
+ return;
end if;
end;
end if;
- end if;
- -- Set flag if pragma active
+ -- Cases where we must follow a declaration
- if Active then
- Set_Is_Obsolescent (Subp);
+ else
+ if Nkind (Decl) not in N_Declaration
+ and then Nkind (Decl) not in N_Later_Decl_Item
+ and then Nkind (Decl) not in N_Generic_Declaration
+ then
+ Error_Pragma
+ ("pragma% misplaced, " &
+ "must immediately follow a declaration");
+
+ else
+ Set_Obsolescent (Defining_Entity (Decl));
+ return;
+ end if;
end if;
end Obsolescent;
Check_Arg_Count (1);
Check_Arg_Is_One_Of (Arg1, Name_Time, Name_Space, Name_Off);
- -------------------------
- -- Optional_Overriding --
- -------------------------
-
- -- These pragmas are treated as part of the previous subprogram
- -- declaration, and analyzed immediately after it (see sem_ch6,
- -- Check_Overriding_Operation). If the pragma has not been analyzed
- -- yet, it appears in the wrong place.
-
- when Pragma_Optional_Overriding =>
- Error_Msg_N ("pragma must appear immediately after subprogram", N);
-
----------
-- Pack --
----------
or else Is_Atomic (Component_Type (Typ))
then
Error_Pragma
- ("?pragma% ignored, cannot pack atomic components");
+ ("?pragma% ignored, cannot pack atomic components");
end if;
-- If we had an explicit component size given, then we do not
else
if not Rep_Item_Too_Late (Typ, N) then
- Set_Is_Packed (Base_Type (Typ));
+ if VM_Target = No_VM then
+ Set_Is_Packed (Base_Type (Typ));
+ elsif not GNAT_Mode then
+ Error_Pragma
+ ("?pragma% ignored in this configuration");
+ end if;
+
Set_Has_Pragma_Pack (Base_Type (Typ));
Set_Has_Non_Standard_Rep (Base_Type (Typ));
end if;
else pragma Assert (Is_Record_Type (Typ));
if not Rep_Item_Too_Late (Typ, N) then
+ if VM_Target = No_VM then
+ Set_Is_Packed (Base_Type (Typ));
+ elsif not GNAT_Mode then
+ Error_Pragma ("?pragma% ignored in this configuration");
+ end if;
+
Set_Has_Pragma_Pack (Base_Type (Typ));
- Set_Is_Packed (Base_Type (Typ));
Set_Has_Non_Standard_Rep (Base_Type (Typ));
end if;
end if;
Check_Arg_Is_One_Of (Arg1, Name_Semaphore, Name_No);
end if;
+ ----------------------------------
+ -- Preelaborable_Initialization --
+ ----------------------------------
+
+ -- pragma Preelaborable_Initialization (DIRECT_NAME);
+
+ when Pragma_Preelaborable_Initialization => Preelab_Init : declare
+ Ent : Entity_Id;
+
+ begin
+ Ada_2005_Pragma;
+ Check_Arg_Count (1);
+ Check_No_Identifiers;
+ Check_Arg_Is_Identifier (Arg1);
+ Check_Arg_Is_Local_Name (Arg1);
+ Check_First_Subtype (Arg1);
+ Ent := Entity (Expression (Arg1));
+
+ if not Is_Private_Type (Ent) then
+ Error_Pragma_Arg
+ ("pragma % can only be applied to private type", Arg1);
+ end if;
+
+ Set_Known_To_Have_Preelab_Init (Ent);
+
+ if Has_Pragma_Preelab_Init (Ent)
+ and then Warn_On_Redundant_Constructs
+ then
+ Error_Pragma ("?duplicate pragma%!");
+ else
+ Set_Has_Pragma_Preelab_Init (Ent);
+ end if;
+ end Preelab_Init;
+
-------------
-- Polling --
-------------
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
end if;
end Priority;
+ -----------------------------------
+ -- Priority_Specific_Dispatching --
+ -----------------------------------
+
+ -- pragma Priority_Specific_Dispatching (
+ -- policy_IDENTIFIER,
+ -- first_priority_EXPRESSION,
+ -- last_priority_EXPRESSION);
+
+ when Pragma_Priority_Specific_Dispatching =>
+ Priority_Specific_Dispatching : declare
+ Prio_Id : constant Entity_Id := RTE (RE_Any_Priority);
+ -- This is the entity System.Any_Priority;
+
+ DP : Character;
+ Lower_Bound : Node_Id;
+ Upper_Bound : Node_Id;
+ Lower_Val : Uint;
+ Upper_Val : Uint;
+
+ begin
+ Ada_2005_Pragma;
+ Check_Arg_Count (3);
+ Check_No_Identifiers;
+ Check_Arg_Is_Task_Dispatching_Policy (Arg1);
+ Check_Valid_Configuration_Pragma;
+ Get_Name_String (Chars (Expression (Arg1)));
+ DP := Fold_Upper (Name_Buffer (1));
+
+ Lower_Bound := Expression (Arg2);
+ Check_Arg_Is_Static_Expression (Lower_Bound, Standard_Integer);
+ Lower_Val := Expr_Value (Lower_Bound);
+
+ Upper_Bound := Expression (Arg3);
+ Check_Arg_Is_Static_Expression (Upper_Bound, Standard_Integer);
+ Upper_Val := Expr_Value (Upper_Bound);
+
+ -- It is not allowed to use Task_Dispatching_Policy and
+ -- Priority_Specific_Dispatching in the same partition.
+
+ if Task_Dispatching_Policy /= ' ' then
+ Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
+ Error_Pragma
+ ("pragma% incompatible with Task_Dispatching_Policy#");
+
+ -- Check lower bound in range
+
+ elsif Lower_Val < Expr_Value (Type_Low_Bound (Prio_Id))
+ or else
+ Lower_Val > Expr_Value (Type_High_Bound (Prio_Id))
+ then
+ Error_Pragma_Arg
+ ("first_priority is out of range", Arg2);
+
+ -- Check upper bound in range
+
+ elsif Upper_Val < Expr_Value (Type_Low_Bound (Prio_Id))
+ or else
+ Upper_Val > Expr_Value (Type_High_Bound (Prio_Id))
+ then
+ Error_Pragma_Arg
+ ("last_priority is out of range", Arg3);
+
+ -- Check that the priority range is valid
+
+ elsif Lower_Val > Upper_Val then
+ Error_Pragma
+ ("last_priority_expression must be greater than" &
+ " or equal to first_priority_expression");
+
+ -- Store the new policy, but always preserve System_Location since
+ -- we like the error message with the run-time name.
+
+ else
+ -- Check overlapping in the priority ranges specified in other
+ -- Priority_Specific_Dispatching pragmas within the same
+ -- partition. We can only check those we know about!
+
+ for J in
+ Specific_Dispatching.First .. Specific_Dispatching.Last
+ loop
+ if Specific_Dispatching.Table (J).First_Priority in
+ UI_To_Int (Lower_Val) .. UI_To_Int (Upper_Val)
+ or else Specific_Dispatching.Table (J).Last_Priority in
+ UI_To_Int (Lower_Val) .. UI_To_Int (Upper_Val)
+ then
+ Error_Msg_Sloc :=
+ Specific_Dispatching.Table (J).Pragma_Loc;
+ Error_Pragma
+ ("priority range overlaps with "
+ & "Priority_Specific_Dispatching#");
+ end if;
+ end loop;
+
+ -- The use of Priority_Specific_Dispatching is incompatible
+ -- with Task_Dispatching_Policy.
+
+ if Task_Dispatching_Policy /= ' ' then
+ Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
+ Error_Pragma
+ ("Priority_Specific_Dispatching incompatible "
+ & "with Task_Dispatching_Policy#");
+ end if;
+
+ -- The use of Priority_Specific_Dispatching forces ceiling
+ -- locking policy.
+
+ if Locking_Policy /= ' ' and then Locking_Policy /= 'C' then
+ Error_Msg_Sloc := Locking_Policy_Sloc;
+ Error_Pragma
+ ("Priority_Specific_Dispatching incompatible "
+ & "with Locking_Policy#");
+
+ -- Set the Ceiling_Locking policy, but preserve System_Location
+ -- since we like the error message with the run time name.
+
+ else
+ Locking_Policy := 'C';
+
+ if Locking_Policy_Sloc /= System_Location then
+ Locking_Policy_Sloc := Loc;
+ end if;
+ end if;
+
+ -- Add entry in the table
+
+ Specific_Dispatching.Append
+ ((Dispatching_Policy => DP,
+ First_Priority => UI_To_Int (Lower_Val),
+ Last_Priority => UI_To_Int (Upper_Val),
+ Pragma_Loc => Loc));
+ end if;
+ end Priority_Specific_Dispatching;
+
-------------
-- Profile --
-------------
-- profile_IDENTIFIER => Protected | Ravenscar
when Pragma_Profile =>
+ Ada_2005_Pragma;
Check_Arg_Count (1);
Check_Valid_Configuration_Pragma;
Check_No_Identifiers;
begin
if Chars (Argx) = Name_Ravenscar then
Set_Ravenscar_Profile (N);
-
elsif Chars (Argx) = Name_Restricted then
Set_Profile_Restrictions (Restricted, N, Warn => False);
else
begin
if Chars (Argx) = Name_Ravenscar then
Set_Profile_Restrictions (Ravenscar, N, Warn => True);
-
elsif Chars (Argx) = Name_Restricted then
Set_Profile_Restrictions (Restricted, N, Warn => True);
else
-- pragma Propagate_Exceptions;
+ -- Note: this pragma is obsolete and has no effect
+
when Pragma_Propagate_Exceptions =>
GNAT_Pragma;
Check_Arg_Count (0);
Ent := Find_Lib_Unit_Name;
Set_Is_Pure (Ent);
+ Set_Has_Pragma_Pure (Ent);
Set_Suppress_Elaboration_Warnings (Ent);
end Pure;
-- | restriction_parameter_IDENTIFIER => EXPRESSION
when Pragma_Restrictions =>
- Process_Restrictions_Or_Restriction_Warnings;
+ Process_Restrictions_Or_Restriction_Warnings (Warn => False);
--------------------------
-- Restriction_Warnings --
-- | restriction_parameter_IDENTIFIER => EXPRESSION
when Pragma_Restriction_Warnings =>
- Process_Restrictions_Or_Restriction_Warnings;
+ Process_Restrictions_Or_Restriction_Warnings (Warn => True);
----------------
-- Reviewable --
when Pragma_Reviewable =>
Check_Ada_83_Warning;
Check_Arg_Count (0);
+ rv;
-------------------
-- Share_Generic --
when Pragma_Source_Reference =>
GNAT_Pragma;
+ --------------------------------
+ -- Static_Elaboration_Desired --
+ --------------------------------
+
+ -- pragma Static_Elaboration_Desired (DIRECT_NAME);
+
+ when Pragma_Static_Elaboration_Desired =>
+ GNAT_Pragma;
+ Check_At_Most_N_Arguments (1);
+
+ if Is_Compilation_Unit (Current_Scope)
+ and then Ekind (Current_Scope) = E_Package
+ then
+ Set_Static_Elaboration_Desired (Current_Scope, True);
+ else
+ Error_Pragma ("pragma% must apply to a library-level package");
+ end if;
+
------------------
-- Storage_Size --
------------------
exit when not In_Character_Range (C);
Options (J) := Get_Character (C);
+ -- If at end of string, set options. As per discussion
+ -- above, no need to check for errors, since we issued
+ -- them in the parser.
+
if J = Slen then
Set_Style_Check_Options (Options);
exit;
- else
- J := J + 1;
end if;
+
+ J := J + 1;
end loop;
end;
elsif Nkind (A) = N_Identifier then
-
if Chars (A) = Name_All_Checks then
Set_Default_Style_Check_Options;
elsif Chars (A) = Name_Off then
Style_Check := False;
-
end if;
end if;
end if;
end if;
end Task_Storage;
- -----------------
- -- Thread_Body --
- -----------------
-
- -- pragma Thread_Body
- -- ( [Entity =>] LOCAL_NAME
- -- [,[Secondary_Stack_Size =>] static_integer_EXPRESSION]);
-
- when Pragma_Thread_Body => Thread_Body : declare
- Id : Node_Id;
- SS : Node_Id;
- E : Entity_Id;
-
- begin
- GNAT_Pragma;
- Check_Arg_Order ((Name_Entity, Name_Secondary_Stack_Size));
- Check_At_Least_N_Arguments (1);
- Check_At_Most_N_Arguments (2);
- Check_Optional_Identifier (Arg1, Name_Entity);
- Check_Arg_Is_Local_Name (Arg1);
-
- Id := Expression (Arg1);
-
- if not Is_Entity_Name (Id)
- or else not Is_Subprogram (Entity (Id))
- then
- Error_Pragma_Arg ("subprogram name required", Arg1);
- end if;
-
- E := Entity (Id);
-
- -- Go to renamed subprogram if present, since Thread_Body applies
- -- to the actual renamed entity, not to the renaming entity.
-
- if Present (Alias (E))
- and then Nkind (Parent (Declaration_Node (E))) =
- N_Subprogram_Renaming_Declaration
- then
- E := Alias (E);
- end if;
-
- -- Various error checks
-
- if Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Body then
- Error_Pragma
- ("pragma% requires separate spec and must come before body");
-
- elsif Rep_Item_Too_Early (E, N)
- or else
- Rep_Item_Too_Late (E, N)
- then
- raise Pragma_Exit;
-
- elsif Is_Thread_Body (E) then
- Error_Pragma_Arg
- ("only one thread body pragma allowed", Arg1);
-
- elsif Present (Homonym (E))
- and then Scope (Homonym (E)) = Current_Scope
- then
- Error_Pragma_Arg
- ("thread body subprogram must not be overloaded", Arg1);
- end if;
-
- Set_Is_Thread_Body (E);
-
- -- Deal with secondary stack argument
-
- if Arg_Count = 2 then
- Check_Optional_Identifier (Arg2, Name_Secondary_Stack_Size);
- SS := Expression (Arg2);
- Analyze_And_Resolve (SS, Any_Integer);
- end if;
- end Thread_Body;
-
----------------
-- Time_Slice --
----------------
end if;
Discr := First_Discriminant (Typ);
-
- if Present (Next_Discriminant (Discr)) then
- Error_Msg_N
- ("Unchecked_Union must have exactly one discriminant",
- Next_Discriminant (Discr));
- return;
- end if;
-
- if No (Discriminant_Default_Value (Discr)) then
- Error_Msg_N
- ("Unchecked_Union discriminant must have default value",
- Discr);
- end if;
+ while Present (Discr) loop
+ if No (Discriminant_Default_Value (Discr)) then
+ Error_Msg_N
+ ("Unchecked_Union discriminant must have default value",
+ Discr);
+ end if;
+ Next_Discriminant (Discr);
+ end loop;
Tdef := Type_Definition (Declaration_Node (Typ));
Clist := Component_List (Tdef);
Comp := First (Component_Items (Clist));
while Present (Comp) loop
-
Check_Component (Comp);
Next (Comp);
-
end loop;
if No (Clist) or else No (Variant_Part (Clist)) then
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;
end Unimplemented_Unit;
+ ------------------------
+ -- Universal_Aliasing --
+ ------------------------
+
+ -- pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
+
+ when Pragma_Universal_Aliasing => Universal_Alias : declare
+ E_Id : Entity_Id;
+
+ begin
+ GNAT_Pragma;
+ Check_Arg_Count (1);
+ Check_Optional_Identifier (Arg2, Name_Entity);
+ Check_Arg_Is_Local_Name (Arg1);
+ E_Id := Entity (Expression (Arg1));
+
+ if E_Id = Any_Type then
+ return;
+ elsif No (E_Id) or else not Is_Type (E_Id) then
+ Error_Pragma_Arg ("pragma% requires type", Arg1);
+ end if;
+
+ Set_Universal_Aliasing (Implementation_Base_Type (E_Id));
+ end Universal_Alias;
+
--------------------
-- Universal_Data --
--------------------
-- pragma Unreferenced (local_Name {, local_Name});
+ -- or when used in a context clause:
+
+ -- pragma Unreferenced (library_unit_NAME {, library_unit_NAME}
+
when Pragma_Unreferenced => Unreferenced : declare
Arg_Node : Node_Id;
Arg_Expr : Node_Id;
Arg_Ent : Entity_Id;
+ Citem : 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 case of appearing within context clause
- -- Note that the analyze call done by Check_Arg_Is_Local_Name
- -- will in fact generate a reference, so that the entity will
- -- have a reference, which will inhibit any warnings about it
- -- not being referenced, and also properly show up in the ali
- -- file as a reference. But this reference is recorded before
- -- the Has_Pragma_Unreferenced flag is set, so that no warning
- -- is generated for this reference.
+ if Is_In_Context_Clause then
- Check_Arg_Is_Local_Name (Arg_Node);
- Arg_Expr := Get_Pragma_Arg (Arg_Node);
+ -- The arguments must all be units mentioned in a with clause
+ -- in the same context clause. Note we already checked (in
+ -- Par.Prag) that the arguments are either identifiers or
+ -- selected components.
+
+ Arg_Node := Arg1;
+ while Present (Arg_Node) loop
+ Citem := First (List_Containing (N));
+ while Citem /= N loop
+ if Nkind (Citem) = N_With_Clause
+ and then Same_Name (Name (Citem), Expression (Arg_Node))
+ then
+ Set_Has_Pragma_Unreferenced
+ (Cunit_Entity
+ (Get_Source_Unit
+ (Library_Unit (Citem))));
+ Set_Unit_Name (Expression (Arg_Node), Name (Citem));
+ exit;
+ end if;
+
+ Next (Citem);
+ end loop;
+
+ if Citem = N then
+ Error_Pragma_Arg
+ ("argument of pragma% is not with'ed unit", Arg_Node);
+ end if;
+
+ Next (Arg_Node);
+ end loop;
- if Is_Entity_Name (Arg_Expr) then
- Arg_Ent := Entity (Arg_Expr);
+ -- Case of not in list of context items
- -- If the entity is overloaded, the pragma applies to the
- -- most recent overloading, as documented. In this case,
- -- name resolution does not generate a reference, so it
- -- must be done here explicitly.
+ else
+ Arg_Node := Arg1;
+ while Present (Arg_Node) loop
+ Check_No_Identifier (Arg_Node);
+
+ -- Note: the analyze call done by Check_Arg_Is_Local_Name
+ -- will in fact generate reference, so that the entity will
+ -- have a reference, which will inhibit any warnings about
+ -- it not being referenced, and also properly show up in the
+ -- ali file as a reference. But this reference is recorded
+ -- before the Has_Pragma_Unreferenced flag is set, so that
+ -- no warning is generated for this reference.
+
+ Check_Arg_Is_Local_Name (Arg_Node);
+ Arg_Expr := Get_Pragma_Arg (Arg_Node);
+
+ if Is_Entity_Name (Arg_Expr) then
+ Arg_Ent := Entity (Arg_Expr);
+
+ -- If the entity is overloaded, the pragma applies to the
+ -- most recent overloading, as documented. In this case,
+ -- name resolution does not generate a reference, so it
+ -- must be done here explicitly.
+
+ if Is_Overloaded (Arg_Expr) then
+ Generate_Reference (Arg_Ent, N);
+ end if;
- if Is_Overloaded (Arg_Expr) then
- Generate_Reference (Arg_Ent, N);
+ Set_Has_Pragma_Unreferenced (Arg_Ent);
end if;
- Set_Has_Pragma_Unreferenced (Arg_Ent);
+ Next (Arg_Node);
+ end loop;
+ 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;
+ end Unreferenced_Objects;
------------------------------
-- Unreserve_All_Interrupts --
-- Warnings --
--------------
- -- pragma Warnings (On | Off, [LOCAL_NAME])
+ -- pragma Warnings (On | Off);
+ -- pragma Warnings (On | Off, LOCAL_NAME);
+ -- pragma Warnings (static_string_EXPRESSION);
+ -- pragma Warnings (On | Off, STRING_LITERAL);
when Pragma_Warnings => Warnings : begin
GNAT_Pragma;
Check_At_Least_N_Arguments (1);
- Check_At_Most_N_Arguments (2);
Check_No_Identifiers;
- -- One argument case was processed by parser in Par.Prag
-
- if Arg_Count /= 1 then
- Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
- Check_Arg_Count (2);
+ declare
+ Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
- declare
- E_Id : Node_Id;
- E : Entity_Id;
+ begin
+ -- One argument case
- begin
- E_Id := Expression (Arg2);
- Analyze (E_Id);
+ if Arg_Count = 1 then
- -- In the expansion of an inlined body, a reference to
- -- the formal may be wrapped in a conversion if the actual
- -- is a conversion. Retrieve the real entity name.
+ -- On/Off one argument case was processed by parser
- if (In_Instance_Body
- or else In_Inlined_Body)
- and then Nkind (E_Id) = N_Unchecked_Type_Conversion
+ if Nkind (Argx) = N_Identifier
+ and then
+ (Chars (Argx) = Name_On
+ or else
+ Chars (Argx) = Name_Off)
then
- E_Id := Expression (E_Id);
- end if;
+ null;
- if not Is_Entity_Name (E_Id) then
+ -- One argument case must be ON/OFF or static string expr
+
+ elsif not Is_Static_String_Expression (Arg1) then
Error_Pragma_Arg
- ("second argument of pragma% must be entity name",
- Arg2);
- end if;
+ ("argument of pragma% must be On/Off or " &
+ "static string expression", Arg2);
- E := Entity (E_Id);
+ -- One argument string expression case
- if E = Any_Id then
- return;
else
- loop
- Set_Warnings_Off (E,
- (Chars (Expression (Arg1)) = Name_Off));
+ 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;
- if Is_Enumeration_Type (E) then
- declare
- Lit : Entity_Id;
- begin
- Lit := First_Literal (E);
- while Present (Lit) loop
- Set_Warnings_Off (Lit);
- Next_Literal (Lit);
- end loop;
- end;
- end if;
+ begin
+ J := 1;
+ while J <= Len loop
+ C := Get_String_Char (Str, J);
+ OK := In_Character_Range (C);
- exit when No (Homonym (E));
- E := Homonym (E);
- end loop;
+ 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;
- end;
- end if;
+
+ -- Two or more arguments (must be two)
+
+ else
+ Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
+ Check_At_Most_N_Arguments (2);
+
+ declare
+ E_Id : Node_Id;
+ E : Entity_Id;
+ Err : Boolean;
+
+ begin
+ E_Id := Expression (Arg2);
+ Analyze (E_Id);
+
+ -- In the expansion of an inlined body, a reference to
+ -- the formal may be wrapped in a conversion if the
+ -- actual is a conversion. Retrieve the real entity name.
+
+ if (In_Instance_Body
+ or else In_Inlined_Body)
+ and then Nkind (E_Id) = N_Unchecked_Type_Conversion
+ then
+ E_Id := Expression (E_Id);
+ end if;
+
+ -- Entity name case
+
+ if Is_Entity_Name (E_Id) then
+ E := Entity (E_Id);
+
+ if E = Any_Id then
+ return;
+ else
+ loop
+ Set_Warnings_Off
+ (E, (Chars (Expression (Arg1)) = Name_Off));
+
+ if Is_Enumeration_Type (E) then
+ declare
+ Lit : Entity_Id;
+ begin
+ Lit := First_Literal (E);
+ while Present (Lit) loop
+ Set_Warnings_Off (Lit);
+ Next_Literal (Lit);
+ end loop;
+ end;
+ end if;
+
+ exit when No (Homonym (E));
+ E := Homonym (E);
+ end loop;
+ end if;
+
+ -- Error if not entity or static string literal case
+
+ elsif not Is_Static_String_Expression (Arg2) then
+ Error_Pragma_Arg
+ ("second argument of pragma% must be entity " &
+ "name or static string expression", Arg2);
+
+ -- String literal case
+
+ else
+ String_To_Name_Buffer
+ (Strval (Expr_Value_S (Expression (Arg2))));
+
+ -- Note on configuration pragma case: If this is a
+ -- configuration pragma, then for an OFF pragma, we
+ -- just set Config True in the call, which is all
+ -- that needs to be done. For the case of ON, this
+ -- is normally an error, unless it is canceling the
+ -- effect of a previous OFF pragma in the same file.
+ -- In any other case, an error will be signalled (ON
+ -- with no matching OFF).
+
+ if Chars (Argx) = Name_Off then
+ Set_Specific_Warning_Off
+ (Loc, Name_Buffer (1 .. Name_Len),
+ Config => Is_Configuration_Pragma);
+
+ elsif Chars (Argx) = Name_On then
+ Set_Specific_Warning_On
+ (Loc, Name_Buffer (1 .. Name_Len), Err);
+
+ if Err then
+ Error_Msg
+ ("?pragma Warnings On with no " &
+ "matching Warnings Off",
+ Loc);
+ end if;
+ end if;
+ end if;
+ end;
+ end if;
+ end;
end Warnings;
-------------------
end if;
end Weak_External;
+ -----------------------------
+ -- Wide_Character_Encoding --
+ -----------------------------
+
+ -- pragma Wide_Character_Encoding (IDENTIFIER);
+
+ when Pragma_Wide_Character_Encoding =>
+
+ -- Nothing to do, handled in parser. Note that we do not enforce
+ -- configuration pragma placement, this pragma can appear at any
+ -- place in the source, allowing mixed encodings within a single
+ -- source program.
+
+ null;
+
--------------------
-- Unknown_Pragma --
--------------------
function Delay_Config_Pragma_Analyze (N : Node_Id) return Boolean is
begin
- return Chars (N) = Name_Interrupt_State;
+ return Chars (N) = Name_Interrupt_State
+ or else
+ Chars (N) = Name_Priority_Specific_Dispatching;
end Delay_Config_Pragma_Analyze;
-------------------------
Sig_Flags : constant array (Pragma_Id) of Int :=
- (Pragma_AST_Entry => -1,
- Pragma_Abort_Defer => -1,
- Pragma_Ada_83 => -1,
- Pragma_Ada_95 => -1,
- Pragma_Ada_05 => -1,
- Pragma_All_Calls_Remote => -1,
- Pragma_Annotate => -1,
- Pragma_Assert => -1,
- Pragma_Assertion_Policy => 0,
- Pragma_Asynchronous => -1,
- Pragma_Atomic => 0,
- Pragma_Atomic_Components => 0,
- Pragma_Attach_Handler => -1,
- Pragma_CPP_Class => 0,
- Pragma_CPP_Constructor => 0,
- Pragma_CPP_Virtual => 0,
- Pragma_CPP_Vtable => 0,
- Pragma_C_Pass_By_Copy => 0,
- Pragma_Comment => 0,
- Pragma_Common_Object => -1,
- Pragma_Compile_Time_Warning => -1,
- Pragma_Complex_Representation => 0,
- Pragma_Component_Alignment => -1,
- Pragma_Controlled => 0,
- Pragma_Convention => 0,
- Pragma_Convention_Identifier => 0,
- Pragma_Debug => -1,
- Pragma_Debug_Policy => 0,
- Pragma_Detect_Blocking => -1,
- Pragma_Discard_Names => 0,
- Pragma_Elaborate => -1,
- Pragma_Elaborate_All => -1,
- Pragma_Elaborate_Body => -1,
- Pragma_Elaboration_Checks => -1,
- Pragma_Eliminate => -1,
- Pragma_Explicit_Overriding => -1,
- Pragma_Export => -1,
- Pragma_Export_Exception => -1,
- Pragma_Export_Function => -1,
- Pragma_Export_Object => -1,
- Pragma_Export_Procedure => -1,
- Pragma_Export_Value => -1,
- Pragma_Export_Valued_Procedure => -1,
- Pragma_Extend_System => -1,
- Pragma_Extensions_Allowed => -1,
- Pragma_External => -1,
- Pragma_External_Name_Casing => -1,
- Pragma_Finalize_Storage_Only => 0,
- Pragma_Float_Representation => 0,
- Pragma_Ident => -1,
- Pragma_Import => +2,
- Pragma_Import_Exception => 0,
- Pragma_Import_Function => 0,
- Pragma_Import_Object => 0,
- Pragma_Import_Procedure => 0,
- Pragma_Import_Valued_Procedure => 0,
- Pragma_Initialize_Scalars => -1,
- Pragma_Inline => 0,
- Pragma_Inline_Always => 0,
- Pragma_Inline_Generic => 0,
- Pragma_Inspection_Point => -1,
- Pragma_Interface => +2,
- Pragma_Interface_Name => +2,
- Pragma_Interrupt_Handler => -1,
- Pragma_Interrupt_Priority => -1,
- Pragma_Interrupt_State => -1,
- Pragma_Java_Constructor => -1,
- Pragma_Java_Interface => -1,
- Pragma_Keep_Names => 0,
- Pragma_License => -1,
- Pragma_Link_With => -1,
- Pragma_Linker_Alias => -1,
- Pragma_Linker_Constructor => -1,
- Pragma_Linker_Destructor => -1,
- Pragma_Linker_Options => -1,
- Pragma_Linker_Section => -1,
- Pragma_List => -1,
- Pragma_Locking_Policy => -1,
- Pragma_Long_Float => -1,
- Pragma_Machine_Attribute => -1,
- Pragma_Main => -1,
- Pragma_Main_Storage => -1,
- Pragma_Memory_Size => -1,
- Pragma_No_Return => 0,
- Pragma_No_Run_Time => -1,
- Pragma_No_Strict_Aliasing => -1,
- Pragma_Normalize_Scalars => -1,
- Pragma_Obsolescent => 0,
- Pragma_Optimize => -1,
- Pragma_Optional_Overriding => -1,
- Pragma_Pack => 0,
- Pragma_Page => -1,
- Pragma_Passive => -1,
- Pragma_Polling => -1,
- Pragma_Persistent_BSS => 0,
- Pragma_Preelaborate => -1,
- Pragma_Preelaborate_05 => -1,
- Pragma_Priority => -1,
- Pragma_Profile => 0,
- Pragma_Profile_Warnings => 0,
- Pragma_Propagate_Exceptions => -1,
- Pragma_Psect_Object => -1,
- Pragma_Pure => -1,
- Pragma_Pure_05 => -1,
- Pragma_Pure_Function => -1,
- Pragma_Queuing_Policy => -1,
- Pragma_Ravenscar => -1,
- Pragma_Remote_Call_Interface => -1,
- Pragma_Remote_Types => -1,
- Pragma_Restricted_Run_Time => -1,
- Pragma_Restriction_Warnings => -1,
- Pragma_Restrictions => -1,
- Pragma_Reviewable => -1,
- Pragma_Share_Generic => -1,
- Pragma_Shared => -1,
- Pragma_Shared_Passive => -1,
- Pragma_Source_File_Name => -1,
- Pragma_Source_File_Name_Project => -1,
- Pragma_Source_Reference => -1,
- Pragma_Storage_Size => -1,
- Pragma_Storage_Unit => -1,
- Pragma_Stream_Convert => -1,
- Pragma_Style_Checks => -1,
- Pragma_Subtitle => -1,
- Pragma_Suppress => 0,
- Pragma_Suppress_Exception_Locations => 0,
- Pragma_Suppress_All => -1,
- Pragma_Suppress_Debug_Info => 0,
- Pragma_Suppress_Initialization => 0,
- Pragma_System_Name => -1,
- Pragma_Task_Dispatching_Policy => -1,
- Pragma_Task_Info => -1,
- Pragma_Task_Name => -1,
- Pragma_Task_Storage => 0,
- Pragma_Thread_Body => +2,
- Pragma_Time_Slice => -1,
- Pragma_Title => -1,
- Pragma_Unchecked_Union => 0,
- Pragma_Unimplemented_Unit => -1,
- Pragma_Universal_Data => -1,
- Pragma_Unreferenced => -1,
- Pragma_Unreserve_All_Interrupts => -1,
- Pragma_Unsuppress => 0,
- Pragma_Use_VADS_Size => -1,
- Pragma_Validity_Checks => -1,
- Pragma_Volatile => 0,
- Pragma_Volatile_Components => 0,
- Pragma_Warnings => -1,
- Pragma_Weak_External => 0,
- Unknown_Pragma => 0);
+ (Pragma_AST_Entry => -1,
+ Pragma_Abort_Defer => -1,
+ Pragma_Ada_83 => -1,
+ Pragma_Ada_95 => -1,
+ Pragma_Ada_05 => -1,
+ Pragma_Ada_2005 => -1,
+ Pragma_All_Calls_Remote => -1,
+ Pragma_Annotate => -1,
+ Pragma_Assert => -1,
+ Pragma_Assertion_Policy => 0,
+ Pragma_Asynchronous => -1,
+ Pragma_Atomic => 0,
+ Pragma_Atomic_Components => 0,
+ Pragma_Attach_Handler => -1,
+ Pragma_Check_Name => 0,
+ Pragma_CIL_Constructor => -1,
+ Pragma_CPP_Class => 0,
+ Pragma_CPP_Constructor => 0,
+ Pragma_CPP_Virtual => 0,
+ Pragma_CPP_Vtable => 0,
+ Pragma_C_Pass_By_Copy => 0,
+ Pragma_Comment => 0,
+ Pragma_Common_Object => -1,
+ Pragma_Compile_Time_Error => -1,
+ Pragma_Compile_Time_Warning => -1,
+ Pragma_Compiler_Unit => 0,
+ Pragma_Complete_Representation => 0,
+ Pragma_Complex_Representation => 0,
+ Pragma_Component_Alignment => -1,
+ Pragma_Controlled => 0,
+ Pragma_Convention => 0,
+ Pragma_Convention_Identifier => 0,
+ Pragma_Debug => -1,
+ Pragma_Debug_Policy => 0,
+ Pragma_Detect_Blocking => -1,
+ Pragma_Discard_Names => 0,
+ Pragma_Elaborate => -1,
+ Pragma_Elaborate_All => -1,
+ Pragma_Elaborate_Body => -1,
+ Pragma_Elaboration_Checks => -1,
+ Pragma_Eliminate => -1,
+ Pragma_Export => -1,
+ Pragma_Export_Exception => -1,
+ Pragma_Export_Function => -1,
+ Pragma_Export_Object => -1,
+ Pragma_Export_Procedure => -1,
+ Pragma_Export_Value => -1,
+ Pragma_Export_Valued_Procedure => -1,
+ Pragma_Extend_System => -1,
+ Pragma_Extensions_Allowed => -1,
+ Pragma_External => -1,
+ Pragma_External_Name_Casing => -1,
+ Pragma_Finalize_Storage_Only => 0,
+ Pragma_Float_Representation => 0,
+ Pragma_Ident => -1,
+ Pragma_Implicit_Packing => 0,
+ Pragma_Import => +2,
+ Pragma_Import_Exception => 0,
+ Pragma_Import_Function => 0,
+ Pragma_Import_Object => 0,
+ Pragma_Import_Procedure => 0,
+ Pragma_Import_Valued_Procedure => 0,
+ Pragma_Initialize_Scalars => -1,
+ Pragma_Inline => 0,
+ Pragma_Inline_Always => 0,
+ Pragma_Inline_Generic => 0,
+ Pragma_Inspection_Point => -1,
+ Pragma_Interface => +2,
+ Pragma_Interface_Name => +2,
+ Pragma_Interrupt_Handler => -1,
+ Pragma_Interrupt_Priority => -1,
+ Pragma_Interrupt_State => -1,
+ Pragma_Java_Constructor => -1,
+ Pragma_Java_Interface => -1,
+ Pragma_Keep_Names => 0,
+ Pragma_License => -1,
+ Pragma_Link_With => -1,
+ Pragma_Linker_Alias => -1,
+ Pragma_Linker_Constructor => -1,
+ Pragma_Linker_Destructor => -1,
+ Pragma_Linker_Options => -1,
+ Pragma_Linker_Section => -1,
+ Pragma_List => -1,
+ Pragma_Locking_Policy => -1,
+ Pragma_Long_Float => -1,
+ Pragma_Machine_Attribute => -1,
+ Pragma_Main => -1,
+ Pragma_Main_Storage => -1,
+ Pragma_Memory_Size => -1,
+ Pragma_No_Return => 0,
+ Pragma_No_Body => 0,
+ Pragma_No_Run_Time => -1,
+ Pragma_No_Strict_Aliasing => -1,
+ Pragma_Normalize_Scalars => -1,
+ Pragma_Obsolescent => 0,
+ Pragma_Optimize => -1,
+ Pragma_Pack => 0,
+ Pragma_Page => -1,
+ Pragma_Passive => -1,
+ Pragma_Preelaborable_Initialization => -1,
+ Pragma_Polling => -1,
+ Pragma_Persistent_BSS => 0,
+ Pragma_Preelaborate => -1,
+ Pragma_Preelaborate_05 => -1,
+ Pragma_Priority => -1,
+ Pragma_Priority_Specific_Dispatching => -1,
+ Pragma_Profile => 0,
+ Pragma_Profile_Warnings => 0,
+ Pragma_Propagate_Exceptions => -1,
+ Pragma_Psect_Object => -1,
+ Pragma_Pure => -1,
+ Pragma_Pure_05 => -1,
+ Pragma_Pure_Function => -1,
+ Pragma_Queuing_Policy => -1,
+ Pragma_Ravenscar => -1,
+ Pragma_Remote_Call_Interface => -1,
+ Pragma_Remote_Types => -1,
+ Pragma_Restricted_Run_Time => -1,
+ Pragma_Restriction_Warnings => -1,
+ Pragma_Restrictions => -1,
+ Pragma_Reviewable => -1,
+ Pragma_Share_Generic => -1,
+ Pragma_Shared => -1,
+ Pragma_Shared_Passive => -1,
+ Pragma_Source_File_Name => -1,
+ Pragma_Source_File_Name_Project => -1,
+ Pragma_Source_Reference => -1,
+ Pragma_Storage_Size => -1,
+ Pragma_Storage_Unit => -1,
+ Pragma_Static_Elaboration_Desired => -1,
+ Pragma_Stream_Convert => -1,
+ Pragma_Style_Checks => -1,
+ Pragma_Subtitle => -1,
+ Pragma_Suppress => 0,
+ Pragma_Suppress_Exception_Locations => 0,
+ Pragma_Suppress_All => -1,
+ Pragma_Suppress_Debug_Info => 0,
+ Pragma_Suppress_Initialization => 0,
+ Pragma_System_Name => -1,
+ Pragma_Task_Dispatching_Policy => -1,
+ Pragma_Task_Info => -1,
+ Pragma_Task_Name => -1,
+ Pragma_Task_Storage => 0,
+ Pragma_Time_Slice => -1,
+ Pragma_Title => -1,
+ Pragma_Unchecked_Union => 0,
+ Pragma_Unimplemented_Unit => -1,
+ Pragma_Universal_Aliasing => -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,
+ Pragma_Validity_Checks => -1,
+ Pragma_Volatile => 0,
+ Pragma_Volatile_Components => 0,
+ Pragma_Warnings => -1,
+ Pragma_Weak_External => -1,
+ Pragma_Wide_Character_Encoding => 0,
+ Unknown_Pragma => 0);
function Is_Non_Significant_Pragma_Reference (N : Node_Id) return Boolean is
P : Node_Id;
end;
end Process_Compilation_Unit_Pragmas;
+ --------
+ -- rv --
+ --------
+
+ procedure rv is
+ begin
+ null;
+ end rv;
+
--------------------------------
-- Set_Encoded_Interface_Name --
--------------------------------
-- If first character is asterisk, this is a link name, and we
-- leave it completely unmodified. We also ignore null strings
-- (the latter case happens only in error cases) and no encoding
- -- should occur for Java interface names.
+ -- should occur for Java or AAMP interface names.
if Len = 0
or else Get_String_Char (Str, 1) = Get_Char_Code ('*')
- or else Java_VM
+ or else VM_Target /= No_VM
+ or else AAMP_On_Target
then
Set_Interface_Name (E, S);