-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2003 Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2005 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- --
with Fname.UF; use Fname.UF;
with Osint; use Osint;
+with Rident; use Rident;
+with Restrict; use Restrict;
with Stringt; use Stringt;
with Stylesw; use Stylesw;
with Uintp; use Uintp;
function Prag (Pragma_Node : Node_Id; Semi : Source_Ptr) return Node_Id is
Pragma_Name : constant Name_Id := Chars (Pragma_Node);
+ Prag_Id : constant Pragma_Id := Get_Pragma_Id (Pragma_Name);
Pragma_Sloc : constant Source_Ptr := Sloc (Pragma_Node);
Arg_Count : Nat;
Arg_Node : Node_Id;
-- Same as Check_Optional_Identifier, except that the name is required
-- to be present and to match the given Id value.
+ procedure Process_Restrictions_Or_Restriction_Warnings;
+ -- Common processing for Restrictions and Restriction_Warnings pragmas.
+ -- This routine only processes the case of No_Obsolescent_Features,
+ -- which is the only restriction that has syntactic effects. No general
+ -- error checking is done, since this will be done in Sem_Prag. The
+ -- other case processed is pragma Restrictions No_Dependence, since
+ -- otherwise this is done too late.
+
----------
-- Arg1 --
----------
end if;
end Check_Required_Identifier;
- ----------
- -- Prag --
- ----------
+ --------------------------------------------------
+ -- Process_Restrictions_Or_Restriction_Warnings --
+ --------------------------------------------------
+
+ procedure Process_Restrictions_Or_Restriction_Warnings is
+ Arg : Node_Id;
+ Id : Name_Id;
+ Expr : Node_Id;
+
+ begin
+ Arg := Arg1;
+ while Present (Arg) loop
+ Id := Chars (Arg);
+ Expr := Expression (Arg);
+
+ if Id = No_Name
+ and then Nkind (Expr) = N_Identifier
+ and then Get_Restriction_Id (Chars (Expr)) = No_Obsolescent_Features
+ then
+ Set_Restriction (No_Obsolescent_Features, Pragma_Node);
+ Restriction_Warnings (No_Obsolescent_Features) :=
+ Prag_Id = Pragma_Restriction_Warnings;
+
+ elsif Id = Name_No_Dependence then
+ Set_Restriction_No_Dependence
+ (Unit => Expr,
+ Warn => Prag_Id = Pragma_Restriction_Warnings);
+ end if;
+
+ Next (Arg);
+ end loop;
+ end Process_Restrictions_Or_Restriction_Warnings;
+
+-- Start if processing for Prag
begin
Error_Msg_Name_1 := Pragma_Name;
-- it is a semantic error, not a syntactic one (we have already checked
-- the syntax for the unrecognized pragma as required by (RM 2.8(11)).
- if not Is_Pragma_Name (Chars (Pragma_Node)) then
+ if Prag_Id = Unknown_Pragma then
return Pragma_Node;
end if;
-- Remaining processing is pragma dependent
- case Get_Pragma_Id (Pragma_Name) is
+ case Prag_Id is
------------
-- Ada_83 --
------------
-- This pragma must be processed at parse time, since we want to set
- -- the Ada 83 and Ada 95 switches properly at parse time to recognize
- -- Ada 83 syntax or Ada 95 syntax as appropriate.
+ -- the Ada version properly at parse time to recognize the appropriate
+ -- Ada version syntax.
when Pragma_Ada_83 =>
- Ada_83 := True;
- Ada_95 := False;
+ Ada_Version := Ada_83;
------------
-- Ada_95 --
------------
-- This pragma must be processed at parse time, since we want to set
- -- the Ada 83 and Ada_95 switches properly at parse time to recognize
- -- Ada 83 syntax or Ada 95 syntax as appropriate.
+ -- the Ada version properly at parse time to recognize the appropriate
+ -- Ada version syntax.
when Pragma_Ada_95 =>
- Ada_83 := False;
- Ada_95 := True;
+ Ada_Version := Ada_95;
+
+ ------------
+ -- Ada_05 --
+ ------------
+
+ -- This pragma must be processed at parse time, since we want to set
+ -- the Ada version properly at parse time to recognize the appropriate
+ -- Ada version syntax. However, it is only the zero argument form that
+ -- must be processed at parse time.
+
+ when Pragma_Ada_05 =>
+ if Arg_Count = 0 then
+ Ada_Version := Ada_05;
+ end if;
-----------
-- Debug --
Check_Arg_Count (1);
Check_No_Identifier (Arg1);
Check_Arg_Is_On_Or_Off (Arg1);
- Opt.Extensions_Allowed := (Chars (Expression (Arg1)) = Name_On);
+
+ 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;
----------------
-- List (2.8) --
List_Pragmas.Increment_Last;
List_Pragmas.Table (List_Pragmas.Last) := (Page, Semi);
+ ------------------
+ -- Restrictions --
+ ------------------
+
+ -- pragma Restrictions (RESTRICTION {, RESTRICTION});
+
+ -- RESTRICTION ::=
+ -- restriction_IDENTIFIER
+ -- | restriction_parameter_IDENTIFIER => EXPRESSION
+
+ -- We process the case of No_Obsolescent_Features, since this has
+ -- a syntactic effect that we need to detect at parse time (the use
+ -- of replacement characters such as colon for pound sign).
+
+ when Pragma_Restrictions =>
+ Process_Restrictions_Or_Restriction_Warnings;
+
+ --------------------------
+ -- Restriction_Warnings --
+ --------------------------
+
+ -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
+
+ -- RESTRICTION ::=
+ -- restriction_IDENTIFIER
+ -- | restriction_parameter_IDENTIFIER => EXPRESSION
+
+ -- See above comment for pragma Restrictions
+
+ when Pragma_Restriction_Warnings =>
+ Process_Restrictions_Or_Restriction_Warnings;
+
----------------------------------------------------------
-- Source_File_Name and Source_File_Name_Project (GNAT) --
----------------------------------------------------------
-- These two pragmas have the same syntax and semantics.
-- There are five forms of these pragmas:
- -- pragma Source_File_Name (
+ -- pragma Source_File_Name[_Project] (
-- [UNIT_NAME =>] unit_NAME,
- -- BODY_FILE_NAME => STRING_LITERAL);
+ -- BODY_FILE_NAME => STRING_LITERAL
+ -- [, [INDEX =>] INTEGER_LITERAL]);
- -- pragma Source_File_Name (
+ -- pragma Source_File_Name[_Project] (
-- [UNIT_NAME =>] unit_NAME,
- -- SPEC_FILE_NAME => STRING_LITERAL);
+ -- SPEC_FILE_NAME => STRING_LITERAL
+ -- [, [INDEX =>] INTEGER_LITERAL]);
- -- pragma Source_File_Name (
+ -- pragma Source_File_Name[_Project] (
-- BODY_FILE_NAME => STRING_LITERAL
-- [, DOT_REPLACEMENT => STRING_LITERAL]
-- [, CASING => CASING_SPEC]);
- -- pragma Source_File_Name (
+ -- pragma Source_File_Name[_Project] (
-- SPEC_FILE_NAME => STRING_LITERAL
-- [, DOT_REPLACEMENT => STRING_LITERAL]
-- [, CASING => CASING_SPEC]);
- -- pragma Source_File_Name (
+ -- pragma Source_File_Name[_Project] (
-- SUBUNIT_FILE_NAME => STRING_LITERAL
-- [, DOT_REPLACEMENT => STRING_LITERAL]
-- [, CASING => CASING_SPEC]);
Dot : String_Ptr;
Cas : Casing_Type;
Nast : Nat;
+ Expr : Node_Id;
+ Index : Nat;
function Get_Fname (Arg : Node_Id) return Name_Id;
-- Process file name from unit name form of pragma
-- Source_File_Name_Project pragmas.
begin
-
if Get_Pragma_Id (Pragma_Name) = Pragma_Source_File_Name then
if Project_File_In_Use = In_Use then
Error_Msg
Error_Msg
("pragma Source_File_Name_Project should only be used " &
"with a project file", Pragma_Sloc);
-
else
Project_File_In_Use := In_Use;
end if;
return Error;
end if;
- Check_Arg_Count (2);
+ -- Process index argument if present
+
+ if Arg_Count = 3 then
+ Expr := Expression (Arg3);
+
+ if Nkind (Expr) /= N_Integer_Literal
+ or else not UI_Is_In_Int_Range (Intval (Expr))
+ or else Intval (Expr) > 999
+ or else Intval (Expr) <= 0
+ then
+ Error_Msg
+ ("pragma% index must be integer literal" &
+ " in range 1 .. 999", Sloc (Expr));
+ raise Error_Resync;
+ else
+ Index := UI_To_Int (Intval (Expr));
+ end if;
+
+ -- No index argument present
+
+ else
+ Check_Arg_Count (2);
+ Index := 0;
+ end if;
Check_Optional_Identifier (Arg1, Name_Unit_Name);
Unam := Get_Unit_Name (Expr1);
Check_Arg_Is_String_Literal (Arg2);
if Chars (Arg2) = Name_Spec_File_Name then
- Set_File_Name (Get_Spec_Name (Unam), Get_Fname (Arg2));
+ Set_File_Name
+ (Get_Spec_Name (Unam), Get_Fname (Arg2), Index);
elsif Chars (Arg2) = Name_Body_File_Name then
- Set_File_Name (Unam, Get_Fname (Arg2));
+ Set_File_Name
+ (Unam, Get_Fname (Arg2), Index);
else
Error_Msg_N
if Nast /= 1 then
Error_Msg_N
("file name pattern must have exactly one * character",
- Arg2);
+ Arg1);
return Pragma_Node;
end if;
-- Set defaults for Casing and Dot_Separator parameters
Cas := All_Lower_Case;
-
Dot := new String'(".");
-- Process second and third arguments if present
("file name required for first % pragma in file",
Pragma_Sloc);
raise Error_Resync;
-
else
Fname := No_Name;
end if;
Pragma_Component_Alignment |
Pragma_Controlled |
Pragma_Convention |
+ Pragma_Detect_Blocking |
Pragma_Discard_Names |
Pragma_Eliminate |
Pragma_Elaborate |
Pragma_No_Return |
Pragma_Obsolescent |
Pragma_No_Run_Time |
+ Pragma_No_Strict_Aliasing |
Pragma_Normalize_Scalars |
Pragma_Optimize |
Pragma_Optional_Overriding |
- Pragma_Overriding |
Pragma_Pack |
Pragma_Passive |
Pragma_Polling |
Pragma_Persistent_Object |
Pragma_Preelaborate |
Pragma_Priority |
+ Pragma_Profile |
+ Pragma_Profile_Warnings |
Pragma_Propagate_Exceptions |
Pragma_Psect_Object |
Pragma_Pure |
Pragma_Queuing_Policy |
Pragma_Remote_Call_Interface |
Pragma_Remote_Types |
- Pragma_Restrictions |
- Pragma_Restriction_Warnings |
Pragma_Restricted_Run_Time |
Pragma_Ravenscar |
Pragma_Reviewable |
Pragma_Task_Info |
Pragma_Task_Name |
Pragma_Task_Storage |
+ Pragma_Thread_Body |
Pragma_Time_Slice |
Pragma_Title |
Pragma_Unchecked_Union |