1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- Generally the parser checks the basic syntax of pragmas, but does not
28 -- do specialized syntax checks for individual pragmas, these are deferred
29 -- to semantic analysis time (see unit Sem_Prag). There are some pragmas
30 -- which require recognition and either partial or complete processing
31 -- during parsing, and this unit performs this required processing.
33 with Fname
.UF
; use Fname
.UF
;
34 with Osint
; use Osint
;
35 with Rident
; use Rident
;
36 with Restrict
; use Restrict
;
37 with Stringt
; use Stringt
;
38 with Stylesw
; use Stylesw
;
39 with Uintp
; use Uintp
;
40 with Uname
; use Uname
;
44 function Prag
(Pragma_Node
: Node_Id
; Semi
: Source_Ptr
) return Node_Id
is
45 Pragma_Name
: constant Name_Id
:= Chars
(Pragma_Node
);
46 Prag_Id
: constant Pragma_Id
:= Get_Pragma_Id
(Pragma_Name
);
47 Pragma_Sloc
: constant Source_Ptr
:= Sloc
(Pragma_Node
);
51 -----------------------
52 -- Local Subprograms --
53 -----------------------
55 function Arg1
return Node_Id
;
56 function Arg2
return Node_Id
;
57 function Arg3
return Node_Id
;
58 -- Obtain specified Pragma_Argument_Association. It is allowable to call
59 -- the routine for the argument one past the last present argument, but
60 -- that is the only case in which a non-present argument can be referenced.
62 procedure Check_Arg_Count
(Required
: Int
);
63 -- Check argument count for pragma = Required.
64 -- If not give error and raise Error_Resync.
66 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
);
67 -- Check the expression of the specified argument to make sure that it
68 -- is a string literal. If not give error and raise Error_Resync.
70 procedure Check_Arg_Is_On_Or_Off
(Arg
: Node_Id
);
71 -- Check the expression of the specified argument to make sure that it
72 -- is an identifier which is either ON or OFF, and if not, then issue
73 -- an error message and raise Error_Resync.
75 procedure Check_No_Identifier
(Arg
: Node_Id
);
76 -- Checks that the given argument does not have an identifier. If
77 -- an identifier is present, then an error message is issued, and
78 -- Error_Resync is raised.
80 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
);
81 -- Checks if the given argument has an identifier, and if so, requires
82 -- it to match the given identifier name. If there is a non-matching
83 -- identifier, then an error message is given and Error_Resync raised.
85 procedure Check_Required_Identifier
(Arg
: Node_Id
; Id
: Name_Id
);
86 -- Same as Check_Optional_Identifier, except that the name is required
87 -- to be present and to match the given Id value.
89 procedure Process_Restrictions_Or_Restriction_Warnings
;
90 -- Common processing for Restrictions and Restriction_Warnings pragmas.
91 -- This routine only processes the case of No_Obsolescent_Features,
92 -- which is the only restriction that has syntactic effects. No general
93 -- error checking is done, since this will be done in Sem_Prag. The
94 -- other case processed is pragma Restrictions No_Dependence, since
95 -- otherwise this is done too late.
101 function Arg1
return Node_Id
is
103 return First
(Pragma_Argument_Associations
(Pragma_Node
));
110 function Arg2
return Node_Id
is
119 function Arg3
return Node_Id
is
124 ---------------------
125 -- Check_Arg_Count --
126 ---------------------
128 procedure Check_Arg_Count
(Required
: Int
) is
130 if Arg_Count
/= Required
then
131 Error_Msg
("wrong number of arguments for pragma%", Pragma_Sloc
);
136 ----------------------------
137 -- Check_Arg_Is_On_Or_Off --
138 ----------------------------
140 procedure Check_Arg_Is_On_Or_Off
(Arg
: Node_Id
) is
141 Argx
: constant Node_Id
:= Expression
(Arg
);
144 if Nkind
(Expression
(Arg
)) /= N_Identifier
145 or else (Chars
(Argx
) /= Name_On
147 Chars
(Argx
) /= Name_Off
)
149 Error_Msg_Name_2
:= Name_On
;
150 Error_Msg_Name_3
:= Name_Off
;
153 ("argument for pragma% must be% or%", Sloc
(Argx
));
156 end Check_Arg_Is_On_Or_Off
;
158 ---------------------------------
159 -- Check_Arg_Is_String_Literal --
160 ---------------------------------
162 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
) is
164 if Nkind
(Expression
(Arg
)) /= N_String_Literal
then
166 ("argument for pragma% must be string literal",
167 Sloc
(Expression
(Arg
)));
170 end Check_Arg_Is_String_Literal
;
172 -------------------------
173 -- Check_No_Identifier --
174 -------------------------
176 procedure Check_No_Identifier
(Arg
: Node_Id
) is
178 if Chars
(Arg
) /= No_Name
then
179 Error_Msg_N
("pragma% does not permit named arguments", Arg
);
182 end Check_No_Identifier
;
184 -------------------------------
185 -- Check_Optional_Identifier --
186 -------------------------------
188 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
) is
190 if Present
(Arg
) and then Chars
(Arg
) /= No_Name
then
191 if Chars
(Arg
) /= Id
then
192 Error_Msg_Name_2
:= Id
;
193 Error_Msg_N
("pragma% argument expects identifier%", Arg
);
196 end Check_Optional_Identifier
;
198 -------------------------------
199 -- Check_Required_Identifier --
200 -------------------------------
202 procedure Check_Required_Identifier
(Arg
: Node_Id
; Id
: Name_Id
) is
204 if Chars
(Arg
) /= Id
then
205 Error_Msg_Name_2
:= Id
;
206 Error_Msg_N
("pragma% argument must have identifier%", Arg
);
208 end Check_Required_Identifier
;
210 --------------------------------------------------
211 -- Process_Restrictions_Or_Restriction_Warnings --
212 --------------------------------------------------
214 procedure Process_Restrictions_Or_Restriction_Warnings
is
221 while Present
(Arg
) loop
223 Expr
:= Expression
(Arg
);
226 and then Nkind
(Expr
) = N_Identifier
227 and then Get_Restriction_Id
(Chars
(Expr
)) = No_Obsolescent_Features
229 Set_Restriction
(No_Obsolescent_Features
, Pragma_Node
);
230 Restriction_Warnings
(No_Obsolescent_Features
) :=
231 Prag_Id
= Pragma_Restriction_Warnings
;
233 elsif Id
= Name_No_Dependence
then
234 Set_Restriction_No_Dependence
236 Warn
=> Prag_Id
= Pragma_Restriction_Warnings
);
241 end Process_Restrictions_Or_Restriction_Warnings
;
243 -- Start if processing for Prag
246 Error_Msg_Name_1
:= Pragma_Name
;
248 -- Ignore unrecognized pragma. We let Sem post the warning for this, since
249 -- it is a semantic error, not a syntactic one (we have already checked
250 -- the syntax for the unrecognized pragma as required by (RM 2.8(11)).
252 if Prag_Id
= Unknown_Pragma
then
256 -- Count number of arguments. This loop also checks if any of the arguments
257 -- are Error, indicating a syntax error as they were parsed. If so, we
258 -- simply return, because we get into trouble with cascaded errors if we
259 -- try to perform our error checks on junk arguments.
263 if Present
(Pragma_Argument_Associations
(Pragma_Node
)) then
266 while Arg_Node
/= Empty
loop
267 Arg_Count
:= Arg_Count
+ 1;
269 if Expression
(Arg_Node
) = Error
then
277 -- Remaining processing is pragma dependent
285 -- This pragma must be processed at parse time, since we want to set
286 -- the Ada version properly at parse time to recognize the appropriate
287 -- Ada version syntax.
289 when Pragma_Ada_83
=>
290 Ada_Version
:= Ada_83
;
291 Ada_Version_Explicit
:= Ada_Version
;
297 -- This pragma must be processed at parse time, since we want to set
298 -- the Ada version properly at parse time to recognize the appropriate
299 -- Ada version syntax.
301 when Pragma_Ada_95
=>
302 Ada_Version
:= Ada_95
;
303 Ada_Version_Explicit
:= Ada_Version
;
309 -- This pragma must be processed at parse time, since we want to set
310 -- the Ada version properly at parse time to recognize the appropriate
311 -- Ada version syntax. However, it is only the zero argument form that
312 -- must be processed at parse time.
314 when Pragma_Ada_05
=>
315 if Arg_Count
= 0 then
316 Ada_Version
:= Ada_05
;
317 Ada_Version_Explicit
:= Ada_Version
;
324 -- pragma Debug (PROCEDURE_CALL_STATEMENT);
326 -- This has to be processed by the parser because of the very peculiar
327 -- form of the second parameter, which is syntactically from a formal
328 -- point of view a function call (since it must be an expression), but
329 -- semantically we treat it as a procedure call (which has exactly the
330 -- same syntactic form, so that's why we can get away with this!)
332 when Pragma_Debug
=> Debug
: declare
336 if Arg_Count
= 2 then
337 Check_No_Identifier
(Arg1
);
338 Check_No_Identifier
(Arg2
);
339 Expr
:= New_Copy
(Expression
(Arg2
));
343 Check_No_Identifier
(Arg1
);
344 Expr
:= New_Copy
(Expression
(Arg1
));
347 if Nkind
(Expr
) /= N_Indexed_Component
348 and then Nkind
(Expr
) /= N_Function_Call
349 and then Nkind
(Expr
) /= N_Identifier
350 and then Nkind
(Expr
) /= N_Selected_Component
353 ("argument of pragma% is not procedure call", Sloc
(Expr
));
357 (Pragma_Node
, P_Statement_Name
(Expr
));
361 -------------------------------
362 -- Extensions_Allowed (GNAT) --
363 -------------------------------
365 -- pragma Extensions_Allowed (Off | On)
367 -- The processing for pragma Extensions_Allowed must be done at
368 -- parse time, since extensions mode may affect what is accepted.
370 when Pragma_Extensions_Allowed
=>
372 Check_No_Identifier
(Arg1
);
373 Check_Arg_Is_On_Or_Off
(Arg1
);
375 if Chars
(Expression
(Arg1
)) = Name_On
then
376 Extensions_Allowed
:= True;
377 Ada_Version
:= Ada_Version_Type
'Last;
379 Extensions_Allowed
:= False;
380 Ada_Version
:= Ada_Version_Type
'Min (Ada_Version
, Ada_95
);
383 Ada_Version_Explicit
:= Ada_Version
;
389 -- pragma List (Off | On)
391 -- The processing for pragma List must be done at parse time,
392 -- since a listing can be generated in parse only mode.
396 Check_No_Identifier
(Arg1
);
397 Check_Arg_Is_On_Or_Off
(Arg1
);
399 -- We unconditionally make a List_On entry for the pragma, so that
400 -- in the List (Off) case, the pragma will print even in a region
401 -- of code with listing turned off (this is required!)
403 List_Pragmas
.Increment_Last
;
404 List_Pragmas
.Table
(List_Pragmas
.Last
) :=
405 (Ptyp
=> List_On
, Ploc
=> Sloc
(Pragma_Node
));
407 -- Now generate the list off entry for pragma List (Off)
409 if Chars
(Expression
(Arg1
)) = Name_Off
then
410 List_Pragmas
.Increment_Last
;
411 List_Pragmas
.Table
(List_Pragmas
.Last
) :=
412 (Ptyp
=> List_Off
, Ploc
=> Semi
);
421 -- Processing for this pragma must be done at parse time, since a
422 -- listing can be generated in parse only mode with semantics off.
426 List_Pragmas
.Increment_Last
;
427 List_Pragmas
.Table
(List_Pragmas
.Last
) := (Page
, Semi
);
433 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
436 -- restriction_IDENTIFIER
437 -- | restriction_parameter_IDENTIFIER => EXPRESSION
439 -- We process the case of No_Obsolescent_Features, since this has
440 -- a syntactic effect that we need to detect at parse time (the use
441 -- of replacement characters such as colon for pound sign).
443 when Pragma_Restrictions
=>
444 Process_Restrictions_Or_Restriction_Warnings
;
446 --------------------------
447 -- Restriction_Warnings --
448 --------------------------
450 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
453 -- restriction_IDENTIFIER
454 -- | restriction_parameter_IDENTIFIER => EXPRESSION
456 -- See above comment for pragma Restrictions
458 when Pragma_Restriction_Warnings
=>
459 Process_Restrictions_Or_Restriction_Warnings
;
461 ----------------------------------------------------------
462 -- Source_File_Name and Source_File_Name_Project (GNAT) --
463 ----------------------------------------------------------
465 -- These two pragmas have the same syntax and semantics.
466 -- There are five forms of these pragmas:
468 -- pragma Source_File_Name[_Project] (
469 -- [UNIT_NAME =>] unit_NAME,
470 -- BODY_FILE_NAME => STRING_LITERAL
471 -- [, [INDEX =>] INTEGER_LITERAL]);
473 -- pragma Source_File_Name[_Project] (
474 -- [UNIT_NAME =>] unit_NAME,
475 -- SPEC_FILE_NAME => STRING_LITERAL
476 -- [, [INDEX =>] INTEGER_LITERAL]);
478 -- pragma Source_File_Name[_Project] (
479 -- BODY_FILE_NAME => STRING_LITERAL
480 -- [, DOT_REPLACEMENT => STRING_LITERAL]
481 -- [, CASING => CASING_SPEC]);
483 -- pragma Source_File_Name[_Project] (
484 -- SPEC_FILE_NAME => STRING_LITERAL
485 -- [, DOT_REPLACEMENT => STRING_LITERAL]
486 -- [, CASING => CASING_SPEC]);
488 -- pragma Source_File_Name[_Project] (
489 -- SUBUNIT_FILE_NAME => STRING_LITERAL
490 -- [, DOT_REPLACEMENT => STRING_LITERAL]
491 -- [, CASING => CASING_SPEC]);
493 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
495 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
496 -- Source_File_Name (SFN), however their usage is exclusive:
497 -- SFN can only be used when no project file is used, while
498 -- SFNP can only be used when a project file is used.
500 -- The Project Manager produces a configuration pragmas file that
501 -- is communicated to the compiler with -gnatec switch. This file
502 -- contains only SFNP pragmas (at least two for the default naming
503 -- scheme. As this configuration pragmas file is always the first
504 -- processed by the compiler, it prevents the use of pragmas SFN in
505 -- other config files when a project file is in use.
507 -- Note: we process this during parsing, since we need to have the
508 -- source file names set well before the semantic analysis starts,
509 -- since we load the spec and with'ed packages before analysis.
511 when Pragma_Source_File_Name | Pragma_Source_File_Name_Project
=>
512 Source_File_Name
: declare
513 Unam
: Unit_Name_Type
;
523 function Get_Fname
(Arg
: Node_Id
) return Name_Id
;
524 -- Process file name from unit name form of pragma
526 function Get_String_Argument
(Arg
: Node_Id
) return String_Ptr
;
527 -- Process string literal value from argument
529 procedure Process_Casing
(Arg
: Node_Id
);
530 -- Process Casing argument of pattern form of pragma
532 procedure Process_Dot_Replacement
(Arg
: Node_Id
);
533 -- Process Dot_Replacement argument of patterm form of pragma
539 function Get_Fname
(Arg
: Node_Id
) return Name_Id
is
541 String_To_Name_Buffer
(Strval
(Expression
(Arg
)));
543 for J
in 1 .. Name_Len
loop
544 if Is_Directory_Separator
(Name_Buffer
(J
)) then
546 ("directory separator character not allowed",
547 Sloc
(Expression
(Arg
)) + Source_Ptr
(J
));
554 -------------------------
555 -- Get_String_Argument --
556 -------------------------
558 function Get_String_Argument
(Arg
: Node_Id
) return String_Ptr
is
562 if Nkind
(Expression
(Arg
)) /= N_String_Literal
564 Nkind
(Expression
(Arg
)) /= N_Operator_Symbol
567 ("argument for pragma% must be string literal", Arg
);
571 Str
:= Strval
(Expression
(Arg
));
573 -- Check string has no wide chars
575 for J
in 1 .. String_Length
(Str
) loop
576 if Get_String_Char
(Str
, J
) > 255 then
578 ("wide character not allowed in pattern for pragma%",
579 Sloc
(Expression
(Arg2
)) + Text_Ptr
(J
) - 1);
585 String_To_Name_Buffer
(Str
);
586 return new String'(Name_Buffer (1 .. Name_Len));
587 end Get_String_Argument;
593 procedure Process_Casing (Arg : Node_Id) is
594 Expr : constant Node_Id := Expression (Arg);
597 Check_Required_Identifier (Arg, Name_Casing);
599 if Nkind (Expr) = N_Identifier then
600 if Chars (Expr) = Name_Lowercase then
601 Cas := All_Lower_Case;
603 elsif Chars (Expr) = Name_Uppercase then
604 Cas := All_Upper_Case;
606 elsif Chars (Expr) = Name_Mixedcase then
613 ("Casing argument for pragma% must be " &
614 "one of Mixedcase, Lowercase, Uppercase",
618 -----------------------------
619 -- Process_Dot_Replacement --
620 -----------------------------
622 procedure Process_Dot_Replacement (Arg : Node_Id) is
624 Check_Required_Identifier (Arg, Name_Dot_Replacement);
625 Dot := Get_String_Argument (Arg);
626 end Process_Dot_Replacement;
628 -- Start of processing for Source_File_Name and
629 -- Source_File_Name_Project pragmas.
632 if Get_Pragma_Id (Pragma_Name) = Pragma_Source_File_Name then
633 if Project_File_In_Use = In_Use then
635 ("pragma Source_File_Name cannot be used " &
636 "with a project file", Pragma_Sloc);
639 Project_File_In_Use := Not_In_Use;
643 if Project_File_In_Use = Not_In_Use then
645 ("pragma Source_File_Name_Project should only be used " &
646 "with a project file", Pragma_Sloc);
648 Project_File_In_Use := In_Use;
652 -- We permit from 1 to 3 arguments
654 if Arg_Count not in 1 .. 3 then
658 Expr1 := Expression (Arg1);
660 -- If first argument is identifier or selected component, then
661 -- we have the specific file case of the Source_File_Name pragma,
662 -- and the first argument is a unit name.
664 if Nkind (Expr1) = N_Identifier
666 (Nkind (Expr1) = N_Selected_Component
668 Nkind (Selector_Name (Expr1)) = N_Identifier)
670 if Nkind (Expr1) = N_Identifier
671 and then Chars (Expr1) = Name_System
674 ("pragma Source_File_Name may not be used for System",
679 -- Process index argument if present
681 if Arg_Count = 3 then
682 Expr := Expression (Arg3);
684 if Nkind (Expr) /= N_Integer_Literal
685 or else not UI_Is_In_Int_Range (Intval (Expr))
686 or else Intval (Expr) > 999
687 or else Intval (Expr) <= 0
690 ("pragma% index must be integer literal" &
691 " in range 1 .. 999", Sloc (Expr));
694 Index := UI_To_Int (Intval (Expr));
697 -- No index argument present
704 Check_Optional_Identifier (Arg1, Name_Unit_Name);
705 Unam := Get_Unit_Name (Expr1);
707 Check_Arg_Is_String_Literal (Arg2);
709 if Chars (Arg2) = Name_Spec_File_Name then
711 (Get_Spec_Name (Unam), Get_Fname (Arg2), Index);
713 elsif Chars (Arg2) = Name_Body_File_Name then
715 (Unam, Get_Fname (Arg2), Index);
719 ("pragma% argument has incorrect identifier", Arg2);
723 -- If the first argument is not an identifier, then we must have
724 -- the pattern form of the pragma, and the first argument must be
725 -- the pattern string with an appropriate name.
728 if Chars (Arg1) = Name_Spec_File_Name then
731 elsif Chars (Arg1) = Name_Body_File_Name then
734 elsif Chars (Arg1) = Name_Subunit_File_Name then
737 elsif Chars (Arg1) = Name_Unit_Name then
739 ("Unit_Name parameter for pragma% must be an identifier",
745 ("pragma% argument has incorrect identifier", Arg1);
749 Pat := Get_String_Argument (Arg1);
751 -- Check pattern has exactly one asterisk
754 for J in Pat'Range loop
755 if Pat (J) = '*' then
762 ("file name pattern must have exactly one * character",
767 -- Set defaults for Casing and Dot_Separator parameters
769 Cas := All_Lower_Case;
770 Dot := new String'(".");
772 -- Process second and third arguments if present
774 if Arg_Count
> 1 then
775 if Chars
(Arg2
) = Name_Casing
then
776 Process_Casing
(Arg2
);
778 if Arg_Count
= 3 then
779 Process_Dot_Replacement
(Arg3
);
783 Process_Dot_Replacement
(Arg2
);
785 if Arg_Count
= 3 then
786 Process_Casing
(Arg3
);
791 Set_File_Name_Pattern
(Pat
, Typ
, Dot
, Cas
);
793 end Source_File_Name
;
795 -----------------------------
796 -- Source_Reference (GNAT) --
797 -----------------------------
799 -- pragma Source_Reference
800 -- (INTEGER_LITERAL [, STRING_LITERAL] );
802 -- Processing for this pragma must be done at parse time, since error
803 -- messages needing the proper line numbers can be generated in parse
804 -- only mode with semantic checking turned off, and indeed we usually
805 -- turn off semantic checking anyway if any parse errors are found.
807 when Pragma_Source_Reference
=> Source_Reference
: declare
811 if Arg_Count
/= 1 then
813 Check_No_Identifier
(Arg2
);
816 -- Check that this is first line of file. We skip this test if
817 -- we are in syntax check only mode, since we may be dealing with
818 -- multiple compilation units.
820 if Get_Physical_Line_Number
(Pragma_Sloc
) /= 1
821 and then Num_SRef_Pragmas
(Current_Source_File
) = 0
822 and then Operating_Mode
/= Check_Syntax
825 ("first % pragma must be first line of file", Pragma_Sloc
);
829 Check_No_Identifier
(Arg1
);
831 if Arg_Count
= 1 then
832 if Num_SRef_Pragmas
(Current_Source_File
) = 0 then
834 ("file name required for first % pragma in file",
844 Check_Arg_Is_String_Literal
(Arg2
);
845 String_To_Name_Buffer
(Strval
(Expression
(Arg2
)));
848 if Num_SRef_Pragmas
(Current_Source_File
) > 0 then
849 if Fname
/= Full_Ref_Name
(Current_Source_File
) then
851 ("file name must be same in all % pragmas", Pragma_Sloc
);
857 if Nkind
(Expression
(Arg1
)) /= N_Integer_Literal
then
859 ("argument for pragma% must be integer literal",
860 Sloc
(Expression
(Arg1
)));
863 -- OK, this source reference pragma is effective, however, we
864 -- ignore it if it is not in the first unit in the multiple unit
865 -- case. This is because the only purpose in this case is to
866 -- provide source pragmas for subsequent use by gnatchop.
869 if Num_Library_Units
= 1 then
870 Register_Source_Ref_Pragma
872 Strip_Directory
(Fname
),
873 UI_To_Int
(Intval
(Expression
(Arg1
))),
874 Get_Physical_Line_Number
(Pragma_Sloc
) + 1);
877 end Source_Reference
;
879 -------------------------
880 -- Style_Checks (GNAT) --
881 -------------------------
883 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
885 -- This is processed by the parser since some of the style
886 -- checks take place during source scanning and parsing.
888 when Pragma_Style_Checks
=> Style_Checks
: declare
892 OK
: Boolean := True;
895 -- Two argument case is only for semantics
897 if Arg_Count
= 2 then
902 Check_No_Identifier
(Arg1
);
903 A
:= Expression
(Arg1
);
905 if Nkind
(A
) = N_String_Literal
then
909 Slen
: constant Natural := Natural (String_Length
(S
));
910 Options
: String (1 .. Slen
);
917 C
:= Get_String_Char
(S
, Int
(J
));
919 if not In_Character_Range
(C
) then
925 Options
(J
) := Get_Character
(C
);
929 Set_Style_Check_Options
(Options
, OK
, Ptr
);
939 (Style_Msg_Buf
(1 .. Style_Msg_Len
),
940 Sloc
(Expression
(Arg1
)) + Source_Ptr
(Ptr
));
945 elsif Nkind
(A
) /= N_Identifier
then
948 elsif Chars
(A
) = Name_All_Checks
then
949 Stylesw
.Set_Default_Style_Check_Options
;
951 elsif Chars
(A
) = Name_On
then
954 elsif Chars
(A
) = Name_Off
then
955 Style_Check
:= False;
962 Error_Msg
("incorrect argument for pragma%", Sloc
(A
));
968 ---------------------
969 -- Warnings (GNAT) --
970 ---------------------
972 -- pragma Warnings (On | Off, [LOCAL_NAME])
973 -- pragma Warnings (static_string_EXPRESSION);
975 -- The one argument ON/OFF case is processed by the parser, since it may
976 -- control parser warnings as well as semantic warnings, and in any case
977 -- we want to be absolutely sure that the range in the warnings table is
978 -- set well before any semantic analysis is performed.
980 when Pragma_Warnings
=>
981 if Arg_Count
= 1 then
982 Check_No_Identifier
(Arg1
);
985 Argx
: constant Node_Id
:= Expression
(Arg1
);
987 if Nkind
(Argx
) = N_Identifier
then
988 if Chars
(Argx
) = Name_On
then
989 Set_Warnings_Mode_On
(Pragma_Sloc
);
990 elsif Chars
(Argx
) = Name_Off
then
991 Set_Warnings_Mode_Off
(Pragma_Sloc
);
997 -----------------------
998 -- All Other Pragmas --
999 -----------------------
1001 -- For all other pragmas, checking and processing is handled
1002 -- entirely in Sem_Prag, and no further checking is done by Par.
1004 when Pragma_Abort_Defer |
1005 Pragma_Assertion_Policy |
1007 Pragma_All_Calls_Remote |
1010 Pragma_Asynchronous |
1012 Pragma_Atomic_Components |
1013 Pragma_Attach_Handler |
1014 Pragma_Compile_Time_Warning |
1015 Pragma_Convention_Identifier |
1017 Pragma_CPP_Constructor |
1018 Pragma_CPP_Virtual |
1020 Pragma_C_Pass_By_Copy |
1022 Pragma_Common_Object |
1023 Pragma_Complete_Representation |
1024 Pragma_Complex_Representation |
1025 Pragma_Component_Alignment |
1028 Pragma_Debug_Policy |
1029 Pragma_Detect_Blocking |
1030 Pragma_Discard_Names |
1033 Pragma_Elaborate_All |
1034 Pragma_Elaborate_Body |
1035 Pragma_Elaboration_Checks |
1036 Pragma_Explicit_Overriding |
1038 Pragma_Export_Exception |
1039 Pragma_Export_Function |
1040 Pragma_Export_Object |
1041 Pragma_Export_Procedure |
1042 Pragma_Export_Value |
1043 Pragma_Export_Valued_Procedure |
1044 Pragma_Extend_System |
1046 Pragma_External_Name_Casing |
1047 Pragma_Finalize_Storage_Only |
1048 Pragma_Float_Representation |
1051 Pragma_Import_Exception |
1052 Pragma_Import_Function |
1053 Pragma_Import_Object |
1054 Pragma_Import_Procedure |
1055 Pragma_Import_Valued_Procedure |
1056 Pragma_Initialize_Scalars |
1058 Pragma_Inline_Always |
1059 Pragma_Inline_Generic |
1060 Pragma_Inspection_Point |
1062 Pragma_Interface_Name |
1063 Pragma_Interrupt_Handler |
1064 Pragma_Interrupt_State |
1065 Pragma_Interrupt_Priority |
1066 Pragma_Java_Constructor |
1067 Pragma_Java_Interface |
1071 Pragma_Linker_Alias |
1072 Pragma_Linker_Constructor |
1073 Pragma_Linker_Destructor |
1074 Pragma_Linker_Options |
1075 Pragma_Linker_Section |
1076 Pragma_Locking_Policy |
1078 Pragma_Machine_Attribute |
1080 Pragma_Main_Storage |
1081 Pragma_Memory_Size |
1083 Pragma_Obsolescent |
1084 Pragma_No_Run_Time |
1085 Pragma_No_Strict_Aliasing |
1086 Pragma_Normalize_Scalars |
1088 Pragma_Optional_Overriding |
1092 Pragma_Persistent_BSS |
1093 Pragma_Preelaborate |
1094 Pragma_Preelaborate_05 |
1097 Pragma_Profile_Warnings |
1098 Pragma_Propagate_Exceptions |
1099 Pragma_Psect_Object |
1102 Pragma_Pure_Function |
1103 Pragma_Queuing_Policy |
1104 Pragma_Remote_Call_Interface |
1105 Pragma_Remote_Types |
1106 Pragma_Restricted_Run_Time |
1109 Pragma_Share_Generic |
1111 Pragma_Shared_Passive |
1112 Pragma_Storage_Size |
1113 Pragma_Storage_Unit |
1114 Pragma_Stream_Convert |
1117 Pragma_Suppress_All |
1118 Pragma_Suppress_Debug_Info |
1119 Pragma_Suppress_Exception_Locations |
1120 Pragma_Suppress_Initialization |
1121 Pragma_System_Name |
1122 Pragma_Task_Dispatching_Policy |
1125 Pragma_Task_Storage |
1126 Pragma_Thread_Body |
1129 Pragma_Unchecked_Union |
1130 Pragma_Unimplemented_Unit |
1131 Pragma_Universal_Data |
1132 Pragma_Unreferenced |
1133 Pragma_Unreserve_All_Interrupts |
1135 Pragma_Use_VADS_Size |
1137 Pragma_Volatile_Components |
1138 Pragma_Weak_External |
1139 Pragma_Validity_Checks
=>
1142 --------------------
1143 -- Unknown_Pragma --
1144 --------------------
1146 -- Should be impossible, since we excluded this case earlier on
1148 when Unknown_Pragma
=>
1149 raise Program_Error
;
1155 --------------------
1156 -- Error Handling --
1157 --------------------
1160 when Error_Resync
=>