1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2009, 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 3, 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 COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- This unit contains the semantic processing for all pragmas, both language
27 -- and implementation defined. For most pragmas, the parser only does the
28 -- most basic job of checking the syntax, so Sem_Prag also contains the code
29 -- to complete the syntax checks. Certain pragmas are handled partially or
30 -- completely by the parser (see Par.Prag for further details).
32 with Atree
; use Atree
;
33 with Casing
; use Casing
;
34 with Checks
; use Checks
;
35 with Csets
; use Csets
;
36 with Debug
; use Debug
;
37 with Einfo
; use Einfo
;
38 with Errout
; use Errout
;
39 with Exp_Dist
; use Exp_Dist
;
41 with Lib
.Writ
; use Lib
.Writ
;
42 with Lib
.Xref
; use Lib
.Xref
;
43 with Namet
.Sp
; use Namet
.Sp
;
44 with Nlists
; use Nlists
;
45 with Nmake
; use Nmake
;
47 with Output
; use Output
;
48 with Restrict
; use Restrict
;
49 with Rident
; use Rident
;
50 with Rtsfind
; use Rtsfind
;
52 with Sem_Aux
; use Sem_Aux
;
53 with Sem_Ch3
; use Sem_Ch3
;
54 with Sem_Ch6
; use Sem_Ch6
;
55 with Sem_Ch8
; use Sem_Ch8
;
56 with Sem_Ch12
; use Sem_Ch12
;
57 with Sem_Ch13
; use Sem_Ch13
;
58 with Sem_Dist
; use Sem_Dist
;
59 with Sem_Elim
; use Sem_Elim
;
60 with Sem_Eval
; use Sem_Eval
;
61 with Sem_Intr
; use Sem_Intr
;
62 with Sem_Mech
; use Sem_Mech
;
63 with Sem_Res
; use Sem_Res
;
64 with Sem_Type
; use Sem_Type
;
65 with Sem_Util
; use Sem_Util
;
66 with Sem_VFpt
; use Sem_VFpt
;
67 with Sem_Warn
; use Sem_Warn
;
68 with Stand
; use Stand
;
69 with Sinfo
; use Sinfo
;
70 with Sinfo
.CN
; use Sinfo
.CN
;
71 with Sinput
; use Sinput
;
72 with Snames
; use Snames
;
73 with Stringt
; use Stringt
;
74 with Stylesw
; use Stylesw
;
76 with Targparm
; use Targparm
;
77 with Tbuild
; use Tbuild
;
79 with Uintp
; use Uintp
;
80 with Uname
; use Uname
;
81 with Urealp
; use Urealp
;
82 with Validsw
; use Validsw
;
84 package body Sem_Prag
is
86 ----------------------------------------------
87 -- Common Handling of Import-Export Pragmas --
88 ----------------------------------------------
90 -- In the following section, a number of Import_xxx and Export_xxx
91 -- pragmas are defined by GNAT. These are compatible with the DEC
92 -- pragmas of the same name, and all have the following common
93 -- form and processing:
96 -- [Internal =>] LOCAL_NAME
97 -- [, [External =>] EXTERNAL_SYMBOL]
98 -- [, other optional parameters ]);
101 -- [Internal =>] LOCAL_NAME
102 -- [, [External =>] EXTERNAL_SYMBOL]
103 -- [, other optional parameters ]);
105 -- EXTERNAL_SYMBOL ::=
107 -- | static_string_EXPRESSION
109 -- The internal LOCAL_NAME designates the entity that is imported or
110 -- exported, and must refer to an entity in the current declarative
111 -- part (as required by the rules for LOCAL_NAME).
113 -- The external linker name is designated by the External parameter if
114 -- given, or the Internal parameter if not (if there is no External
115 -- parameter, the External parameter is a copy of the Internal name).
117 -- If the External parameter is given as a string, then this string is
118 -- treated as an external name (exactly as though it had been given as an
119 -- External_Name parameter for a normal Import pragma).
121 -- If the External parameter is given as an identifier (or there is no
122 -- External parameter, so that the Internal identifier is used), then
123 -- the external name is the characters of the identifier, translated
124 -- to all upper case letters for OpenVMS versions of GNAT, and to all
125 -- lower case letters for all other versions
127 -- Note: the external name specified or implied by any of these special
128 -- Import_xxx or Export_xxx pragmas override an external or link name
129 -- specified in a previous Import or Export pragma.
131 -- Note: these and all other DEC-compatible GNAT pragmas allow full use of
132 -- named notation, following the standard rules for subprogram calls, i.e.
133 -- parameters can be given in any order if named notation is used, and
134 -- positional and named notation can be mixed, subject to the rule that all
135 -- positional parameters must appear first.
137 -- Note: All these pragmas are implemented exactly following the DEC design
138 -- and implementation and are intended to be fully compatible with the use
139 -- of these pragmas in the DEC Ada compiler.
141 --------------------------------------------
142 -- Checking for Duplicated External Names --
143 --------------------------------------------
145 -- It is suspicious if two separate Export pragmas use the same external
146 -- name. The following table is used to diagnose this situation so that
147 -- an appropriate warning can be issued.
149 -- The Node_Id stored is for the N_String_Literal node created to hold
150 -- the value of the external name. The Sloc of this node is used to
151 -- cross-reference the location of the duplication.
153 package Externals
is new Table
.Table
(
154 Table_Component_Type
=> Node_Id
,
155 Table_Index_Type
=> Int
,
156 Table_Low_Bound
=> 0,
157 Table_Initial
=> 100,
158 Table_Increment
=> 100,
159 Table_Name
=> "Name_Externals");
161 -------------------------------------
162 -- Local Subprograms and Variables --
163 -------------------------------------
165 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
;
166 -- This routine is used for possible casing adjustment of an explicit
167 -- external name supplied as a string literal (the node N), according to
168 -- the casing requirement of Opt.External_Name_Casing. If this is set to
169 -- As_Is, then the string literal is returned unchanged, but if it is set
170 -- to Uppercase or Lowercase, then a new string literal with appropriate
171 -- casing is constructed.
173 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
;
174 -- If Def_Id refers to a renamed subprogram, then the base subprogram (the
175 -- original one, following the renaming chain) is returned. Otherwise the
176 -- entity is returned unchanged. Should be in Einfo???
178 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
;
179 -- All the routines that check pragma arguments take either a pragma
180 -- argument association (in which case the expression of the argument
181 -- association is checked), or the expression directly. The function
182 -- Get_Pragma_Arg is a utility used to deal with these two cases. If Arg
183 -- is a pragma argument association node, then its expression is returned,
184 -- otherwise Arg is returned unchanged.
187 -- This is a dummy function called by the processing for pragma Reviewable.
188 -- It is there for assisting front end debugging. By placing a Reviewable
189 -- pragma in the source program, a breakpoint on rv catches this place in
190 -- the source, allowing convenient stepping to the point of interest.
192 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
);
193 -- Place semantic information on the argument of an Elaborate/Elaborate_All
194 -- pragma. Entity name for unit and its parents is taken from item in
195 -- previous with_clause that mentions the unit.
197 -------------------------------
198 -- Adjust_External_Name_Case --
199 -------------------------------
201 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
is
205 -- Adjust case of literal if required
207 if Opt
.External_Name_Exp_Casing
= As_Is
then
211 -- Copy existing string
217 for J
in 1 .. String_Length
(Strval
(N
)) loop
218 CC
:= Get_String_Char
(Strval
(N
), J
);
220 if Opt
.External_Name_Exp_Casing
= Uppercase
221 and then CC
>= Get_Char_Code
('a')
222 and then CC
<= Get_Char_Code
('z')
224 Store_String_Char
(CC
- 32);
226 elsif Opt
.External_Name_Exp_Casing
= Lowercase
227 and then CC
>= Get_Char_Code
('A')
228 and then CC
<= Get_Char_Code
('Z')
230 Store_String_Char
(CC
+ 32);
233 Store_String_Char
(CC
);
238 Make_String_Literal
(Sloc
(N
),
239 Strval
=> End_String
);
241 end Adjust_External_Name_Case
;
243 ------------------------------
244 -- Analyze_PPC_In_Decl_Part --
245 ------------------------------
247 procedure Analyze_PPC_In_Decl_Part
(N
: Node_Id
; S
: Entity_Id
) is
248 Arg1
: constant Node_Id
:=
249 First
(Pragma_Argument_Associations
(N
));
250 Arg2
: constant Node_Id
:= Next
(Arg1
);
253 -- Install formals and push subprogram spec onto scope stack so that we
254 -- can see the formals from the pragma.
259 -- Preanalyze the boolean expression, we treat this as a spec expression
260 -- (i.e. similar to a default expression).
262 Preanalyze_Spec_Expression
263 (Get_Pragma_Arg
(Arg1
), Standard_Boolean
);
265 -- If there is a message argument, analyze it the same way
267 if Present
(Arg2
) then
268 Preanalyze_Spec_Expression
269 (Get_Pragma_Arg
(Arg2
), Standard_String
);
272 -- Remove the subprogram from the scope stack now that the pre-analysis
273 -- of the precondition/postcondition is done.
276 end Analyze_PPC_In_Decl_Part
;
282 procedure Analyze_Pragma
(N
: Node_Id
) is
283 Loc
: constant Source_Ptr
:= Sloc
(N
);
284 Pname
: constant Name_Id
:= Pragma_Name
(N
);
287 Pragma_Exit
: exception;
288 -- This exception is used to exit pragma processing completely. It is
289 -- used when an error is detected, and no further processing is
290 -- required. It is also used if an earlier error has left the tree in
291 -- a state where the pragma should not be processed.
294 -- Number of pragma argument associations
300 -- First four pragma arguments (pragma argument association nodes, or
301 -- Empty if the corresponding argument does not exist).
303 type Name_List
is array (Natural range <>) of Name_Id
;
304 type Args_List
is array (Natural range <>) of Node_Id
;
305 -- Types used for arguments to Check_Arg_Order and Gather_Associations
307 procedure Ada_2005_Pragma
;
308 -- Called for pragmas defined in Ada 2005, that are not in Ada 95. In
309 -- Ada 95 mode, these are implementation defined pragmas, so should be
310 -- caught by the No_Implementation_Pragmas restriction
312 procedure Check_Ada_83_Warning
;
313 -- Issues a warning message for the current pragma if operating in Ada
314 -- 83 mode (used for language pragmas that are not a standard part of
315 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
318 procedure Check_Arg_Count
(Required
: Nat
);
319 -- Check argument count for pragma is equal to given parameter. If not,
320 -- then issue an error message and raise Pragma_Exit.
322 -- Note: all routines whose name is Check_Arg_Is_xxx take an argument
323 -- Arg which can either be a pragma argument association, in which case
324 -- the check is applied to the expression of the association or an
325 -- expression directly.
327 procedure Check_Arg_Is_External_Name
(Arg
: Node_Id
);
328 -- Check that an argument has the right form for an EXTERNAL_NAME
329 -- parameter of an extended import/export pragma. The rule is that the
330 -- name must be an identifier or string literal (in Ada 83 mode) or a
331 -- static string expression (in Ada 95 mode).
333 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
);
334 -- Check the specified argument Arg to make sure that it is an
335 -- identifier. If not give error and raise Pragma_Exit.
337 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
);
338 -- Check the specified argument Arg to make sure that it is an integer
339 -- literal. If not give error and raise Pragma_Exit.
341 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
);
342 -- Check the specified argument Arg to make sure that it has the proper
343 -- syntactic form for a local name and meets the semantic requirements
344 -- for a local name. The local name is analyzed as part of the
345 -- processing for this call. In addition, the local name is required
346 -- to represent an entity at the library level.
348 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
);
349 -- Check the specified argument Arg to make sure that it has the proper
350 -- syntactic form for a local name and meets the semantic requirements
351 -- for a local name. The local name is analyzed as part of the
352 -- processing for this call.
354 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
);
355 -- Check the specified argument Arg to make sure that it is a valid
356 -- locking policy name. If not give error and raise Pragma_Exit.
358 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
);
359 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
, N3
: Name_Id
);
360 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
, N3
, N4
: Name_Id
);
361 -- Check the specified argument Arg to make sure that it is an
362 -- identifier whose name matches either N1 or N2 (or N3 if present).
363 -- If not then give error and raise Pragma_Exit.
365 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
);
366 -- Check the specified argument Arg to make sure that it is a valid
367 -- queuing policy name. If not give error and raise Pragma_Exit.
369 procedure Check_Arg_Is_Static_Expression
372 -- Check the specified argument Arg to make sure that it is a static
373 -- expression of the given type (i.e. it will be analyzed and resolved
374 -- using this type, which can be any valid argument to Resolve, e.g.
375 -- Any_Integer is OK). If not, given error and raise Pragma_Exit.
377 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
);
378 -- Check the specified argument Arg to make sure that it is a string
379 -- literal. If not give error and raise Pragma_Exit
381 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
);
382 -- Check the specified argument Arg to make sure that it is a valid task
383 -- dispatching policy name. If not give error and raise Pragma_Exit.
385 procedure Check_Arg_Order
(Names
: Name_List
);
386 -- Checks for an instance of two arguments with identifiers for the
387 -- current pragma which are not in the sequence indicated by Names,
388 -- and if so, generates a fatal message about bad order of arguments.
390 procedure Check_At_Least_N_Arguments
(N
: Nat
);
391 -- Check there are at least N arguments present
393 procedure Check_At_Most_N_Arguments
(N
: Nat
);
394 -- Check there are no more than N arguments present
396 procedure Check_Component
(Comp
: Node_Id
);
397 -- Examine Unchecked_Union component for correct use of per-object
398 -- constrained subtypes, and for restrictions on finalizable components.
400 procedure Check_Duplicated_Export_Name
(Nam
: Node_Id
);
401 -- Nam is an N_String_Literal node containing the external name set by
402 -- an Import or Export pragma (or extended Import or Export pragma).
403 -- This procedure checks for possible duplications if this is the export
404 -- case, and if found, issues an appropriate error message.
406 procedure Check_First_Subtype
(Arg
: Node_Id
);
407 -- Checks that Arg, whose expression is an entity name referencing a
408 -- subtype, does not reference a type that is not a first subtype.
410 procedure Check_In_Main_Program
;
411 -- Common checks for pragmas that appear within a main program
412 -- (Priority, Main_Storage, Time_Slice, Relative_Deadline).
414 procedure Check_Interrupt_Or_Attach_Handler
;
415 -- Common processing for first argument of pragma Interrupt_Handler or
416 -- pragma Attach_Handler.
418 procedure Check_Is_In_Decl_Part_Or_Package_Spec
;
419 -- Check that pragma appears in a declarative part, or in a package
420 -- specification, i.e. that it does not occur in a statement sequence
423 procedure Check_No_Identifier
(Arg
: Node_Id
);
424 -- Checks that the given argument does not have an identifier. If
425 -- an identifier is present, then an error message is issued, and
426 -- Pragma_Exit is raised.
428 procedure Check_No_Identifiers
;
429 -- Checks that none of the arguments to the pragma has an identifier.
430 -- If any argument has an identifier, then an error message is issued,
431 -- and Pragma_Exit is raised.
433 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
);
434 -- Checks if the given argument has an identifier, and if so, requires
435 -- it to match the given identifier name. If there is a non-matching
436 -- identifier, then an error message is given and Error_Pragmas raised.
438 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String);
439 -- Checks if the given argument has an identifier, and if so, requires
440 -- it to match the given identifier name. If there is a non-matching
441 -- identifier, then an error message is given and Error_Pragmas raised.
442 -- In this version of the procedure, the identifier name is given as
443 -- a string with lower case letters.
445 procedure Check_Precondition_Postcondition
(In_Body
: out Boolean);
446 -- Called to process a precondition or postcondition pragma. There are
449 -- The pragma appears after a subprogram spec
451 -- If the corresponding check is not enabled, the pragma is analyzed
452 -- but otherwise ignored and control returns with In_Body set False.
454 -- If the check is enabled, then the first step is to analyze the
455 -- pragma, but this is skipped if the subprogram spec appears within
456 -- a package specification (because this is the case where we delay
457 -- analysis till the end of the spec). Then (whether or not it was
458 -- analyzed), the pragma is chained to the subprogram in question
459 -- (using Spec_PPC_List and Next_Pragma) and control returns to the
460 -- caller with In_Body set False.
462 -- The pragma appears at the start of subprogram body declarations
464 -- In this case an immediate return to the caller is made with
465 -- In_Body set True, and the pragma is NOT analyzed.
467 -- In all other cases, an error message for bad placement is given
469 procedure Check_Static_Constraint
(Constr
: Node_Id
);
470 -- Constr is a constraint from an N_Subtype_Indication node from a
471 -- component constraint in an Unchecked_Union type. This routine checks
472 -- that the constraint is static as required by the restrictions for
475 procedure Check_Valid_Configuration_Pragma
;
476 -- Legality checks for placement of a configuration pragma
478 procedure Check_Valid_Library_Unit_Pragma
;
479 -- Legality checks for library unit pragmas. A special case arises for
480 -- pragmas in generic instances that come from copies of the original
481 -- library unit pragmas in the generic templates. In the case of other
482 -- than library level instantiations these can appear in contexts which
483 -- would normally be invalid (they only apply to the original template
484 -- and to library level instantiations), and they are simply ignored,
485 -- which is implemented by rewriting them as null statements.
487 procedure Check_Variant
(Variant
: Node_Id
);
488 -- Check Unchecked_Union variant for lack of nested variants and
489 -- presence of at least one component.
491 procedure Error_Pragma
(Msg
: String);
492 pragma No_Return
(Error_Pragma
);
493 -- Outputs error message for current pragma. The message contains a %
494 -- that will be replaced with the pragma name, and the flag is placed
495 -- on the pragma itself. Pragma_Exit is then raised.
497 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
);
498 pragma No_Return
(Error_Pragma_Arg
);
499 -- Outputs error message for current pragma. The message may contain
500 -- a % that will be replaced with the pragma name. The parameter Arg
501 -- may either be a pragma argument association, in which case the flag
502 -- is placed on the expression of this association, or an expression,
503 -- in which case the flag is placed directly on the expression. The
504 -- message is placed using Error_Msg_N, so the message may also contain
505 -- an & insertion character which will reference the given Arg value.
506 -- After placing the message, Pragma_Exit is raised.
508 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
);
509 pragma No_Return
(Error_Pragma_Arg
);
510 -- Similar to above form of Error_Pragma_Arg except that two messages
511 -- are provided, the second is a continuation comment starting with \.
513 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
);
514 pragma No_Return
(Error_Pragma_Arg_Ident
);
515 -- Outputs error message for current pragma. The message may contain
516 -- a % that will be replaced with the pragma name. The parameter Arg
517 -- must be a pragma argument association with a non-empty identifier
518 -- (i.e. its Chars field must be set), and the error message is placed
519 -- on the identifier. The message is placed using Error_Msg_N so
520 -- the message may also contain an & insertion character which will
521 -- reference the identifier. After placing the message, Pragma_Exit
524 procedure Error_Pragma_Ref
(Msg
: String; Ref
: Entity_Id
);
525 pragma No_Return
(Error_Pragma_Ref
);
526 -- Outputs error message for current pragma. The message may contain
527 -- a % that will be replaced with the pragma name. The parameter Ref
528 -- must be an entity whose name can be referenced by & and sloc by #.
529 -- After placing the message, Pragma_Exit is raised.
531 function Find_Lib_Unit_Name
return Entity_Id
;
532 -- Used for a library unit pragma to find the entity to which the
533 -- library unit pragma applies, returns the entity found.
535 procedure Find_Program_Unit_Name
(Id
: Node_Id
);
536 -- If the pragma is a compilation unit pragma, the id must denote the
537 -- compilation unit in the same compilation, and the pragma must appear
538 -- in the list of preceding or trailing pragmas. If it is a program
539 -- unit pragma that is not a compilation unit pragma, then the
540 -- identifier must be visible.
542 function Find_Unique_Parameterless_Procedure
544 Arg
: Node_Id
) return Entity_Id
;
545 -- Used for a procedure pragma to find the unique parameterless
546 -- procedure identified by Name, returns it if it exists, otherwise
547 -- errors out and uses Arg as the pragma argument for the message.
549 procedure Gather_Associations
551 Args
: out Args_List
);
552 -- This procedure is used to gather the arguments for a pragma that
553 -- permits arbitrary ordering of parameters using the normal rules
554 -- for named and positional parameters. The Names argument is a list
555 -- of Name_Id values that corresponds to the allowed pragma argument
556 -- association identifiers in order. The result returned in Args is
557 -- a list of corresponding expressions that are the pragma arguments.
558 -- Note that this is a list of expressions, not of pragma argument
559 -- associations (Gather_Associations has completely checked all the
560 -- optional identifiers when it returns). An entry in Args is Empty
561 -- on return if the corresponding argument is not present.
563 procedure GNAT_Pragma
;
564 -- Called for all GNAT defined pragmas to check the relevant restriction
565 -- (No_Implementation_Pragmas).
567 function Is_Before_First_Decl
568 (Pragma_Node
: Node_Id
;
569 Decls
: List_Id
) return Boolean;
570 -- Return True if Pragma_Node is before the first declarative item in
571 -- Decls where Decls is the list of declarative items.
573 function Is_Configuration_Pragma
return Boolean;
574 -- Determines if the placement of the current pragma is appropriate
575 -- for a configuration pragma.
577 function Is_In_Context_Clause
return Boolean;
578 -- Returns True if pragma appears within the context clause of a unit,
579 -- and False for any other placement (does not generate any messages).
581 function Is_Static_String_Expression
(Arg
: Node_Id
) return Boolean;
582 -- Analyzes the argument, and determines if it is a static string
583 -- expression, returns True if so, False if non-static or not String.
585 procedure Pragma_Misplaced
;
586 pragma No_Return
(Pragma_Misplaced
);
587 -- Issue fatal error message for misplaced pragma
589 procedure Process_Atomic_Shared_Volatile
;
590 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
591 -- Shared is an obsolete Ada 83 pragma, treated as being identical
592 -- in effect to pragma Atomic.
594 procedure Process_Compile_Time_Warning_Or_Error
;
595 -- Common processing for Compile_Time_Error and Compile_Time_Warning
597 procedure Process_Convention
(C
: out Convention_Id
; E
: out Entity_Id
);
598 -- Common processing for Convention, Interface, Import and Export.
599 -- Checks first two arguments of pragma, and sets the appropriate
600 -- convention value in the specified entity or entities. On return
601 -- C is the convention, E is the referenced entity.
603 procedure Process_Extended_Import_Export_Exception_Pragma
604 (Arg_Internal
: Node_Id
;
605 Arg_External
: Node_Id
;
608 -- Common processing for the pragmas Import/Export_Exception. The three
609 -- arguments correspond to the three named parameters of the pragma. An
610 -- argument is empty if the corresponding parameter is not present in
613 procedure Process_Extended_Import_Export_Object_Pragma
614 (Arg_Internal
: Node_Id
;
615 Arg_External
: Node_Id
;
617 -- Common processing for the pragmas Import/Export_Object. The three
618 -- arguments correspond to the three named parameters of the pragmas. An
619 -- argument is empty if the corresponding parameter is not present in
622 procedure Process_Extended_Import_Export_Internal_Arg
623 (Arg_Internal
: Node_Id
:= Empty
);
624 -- Common processing for all extended Import and Export pragmas. The
625 -- argument is the pragma parameter for the Internal argument. If
626 -- Arg_Internal is empty or inappropriate, an error message is posted.
627 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
628 -- set to identify the referenced entity.
630 procedure Process_Extended_Import_Export_Subprogram_Pragma
631 (Arg_Internal
: Node_Id
;
632 Arg_External
: Node_Id
;
633 Arg_Parameter_Types
: Node_Id
;
634 Arg_Result_Type
: Node_Id
:= Empty
;
635 Arg_Mechanism
: Node_Id
;
636 Arg_Result_Mechanism
: Node_Id
:= Empty
;
637 Arg_First_Optional_Parameter
: Node_Id
:= Empty
);
638 -- Common processing for all extended Import and Export pragmas applying
639 -- to subprograms. The caller omits any arguments that do not apply to
640 -- the pragma in question (for example, Arg_Result_Type can be non-Empty
641 -- only in the Import_Function and Export_Function cases). The argument
642 -- names correspond to the allowed pragma association identifiers.
644 procedure Process_Generic_List
;
645 -- Common processing for Share_Generic and Inline_Generic
647 procedure Process_Import_Or_Interface
;
648 -- Common processing for Import of Interface
650 procedure Process_Inline
(Active
: Boolean);
651 -- Common processing for Inline and Inline_Always. The parameter
652 -- indicates if the inline pragma is active, i.e. if it should actually
653 -- cause inlining to occur.
655 procedure Process_Interface_Name
656 (Subprogram_Def
: Entity_Id
;
659 -- Given the last two arguments of pragma Import, pragma Export, or
660 -- pragma Interface_Name, performs validity checks and sets the
661 -- Interface_Name field of the given subprogram entity to the
662 -- appropriate external or link name, depending on the arguments given.
663 -- Ext_Arg is always present, but Link_Arg may be missing. Note that
664 -- Ext_Arg may represent the Link_Name if Link_Arg is missing, and
665 -- appropriate named notation is used for Ext_Arg. If neither Ext_Arg
666 -- nor Link_Arg is present, the interface name is set to the default
667 -- from the subprogram name.
669 procedure Process_Interrupt_Or_Attach_Handler
;
670 -- Common processing for Interrupt and Attach_Handler pragmas
672 procedure Process_Restrictions_Or_Restriction_Warnings
(Warn
: Boolean);
673 -- Common processing for Restrictions and Restriction_Warnings pragmas.
674 -- Warn is True for Restriction_Warnings, or for Restrictions if the
675 -- flag Treat_Restrictions_As_Warnings is set, and False if this flag
676 -- is not set in the Restrictions case.
678 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean);
679 -- Common processing for Suppress and Unsuppress. The boolean parameter
680 -- Suppress_Case is True for the Suppress case, and False for the
683 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
);
684 -- This procedure sets the Is_Exported flag for the given entity,
685 -- checking that the entity was not previously imported. Arg is
686 -- the argument that specified the entity. A check is also made
687 -- for exporting inappropriate entities.
689 procedure Set_Extended_Import_Export_External_Name
690 (Internal_Ent
: Entity_Id
;
691 Arg_External
: Node_Id
);
692 -- Common processing for all extended import export pragmas. The first
693 -- argument, Internal_Ent, is the internal entity, which has already
694 -- been checked for validity by the caller. Arg_External is from the
695 -- Import or Export pragma, and may be null if no External parameter
696 -- was present. If Arg_External is present and is a non-null string
697 -- (a null string is treated as the default), then the Interface_Name
698 -- field of Internal_Ent is set appropriately.
700 procedure Set_Imported
(E
: Entity_Id
);
701 -- This procedure sets the Is_Imported flag for the given entity,
702 -- checking that it is not previously exported or imported.
704 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
);
705 -- Mech is a parameter passing mechanism (see Import_Function syntax
706 -- for MECHANISM_NAME). This routine checks that the mechanism argument
707 -- has the right form, and if not issues an error message. If the
708 -- argument has the right form then the Mechanism field of Ent is
709 -- set appropriately.
711 procedure Set_Ravenscar_Profile
(N
: Node_Id
);
712 -- Activate the set of configuration pragmas and restrictions that make
713 -- up the Ravenscar Profile. N is the corresponding pragma node, which
714 -- is used for error messages on any constructs that violate the
717 ---------------------
718 -- Ada_2005_Pragma --
719 ---------------------
721 procedure Ada_2005_Pragma
is
723 if Ada_Version
<= Ada_95
then
724 Check_Restriction
(No_Implementation_Pragmas
, N
);
728 --------------------------
729 -- Check_Ada_83_Warning --
730 --------------------------
732 procedure Check_Ada_83_Warning
is
734 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
735 Error_Msg_N
("(Ada 83) pragma& is non-standard?", N
);
737 end Check_Ada_83_Warning
;
739 ---------------------
740 -- Check_Arg_Count --
741 ---------------------
743 procedure Check_Arg_Count
(Required
: Nat
) is
745 if Arg_Count
/= Required
then
746 Error_Pragma
("wrong number of arguments for pragma%");
750 --------------------------------
751 -- Check_Arg_Is_External_Name --
752 --------------------------------
754 procedure Check_Arg_Is_External_Name
(Arg
: Node_Id
) is
755 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
758 if Nkind
(Argx
) = N_Identifier
then
762 Analyze_And_Resolve
(Argx
, Standard_String
);
764 if Is_OK_Static_Expression
(Argx
) then
767 elsif Etype
(Argx
) = Any_Type
then
770 -- An interesting special case, if we have a string literal and
771 -- we are in Ada 83 mode, then we allow it even though it will
772 -- not be flagged as static. This allows expected Ada 83 mode
773 -- use of external names which are string literals, even though
774 -- technically these are not static in Ada 83.
776 elsif Ada_Version
= Ada_83
777 and then Nkind
(Argx
) = N_String_Literal
781 -- Static expression that raises Constraint_Error. This has
782 -- already been flagged, so just exit from pragma processing.
784 elsif Is_Static_Expression
(Argx
) then
787 -- Here we have a real error (non-static expression)
790 Error_Msg_Name_1
:= Pname
;
792 ("argument for pragma% must be a identifier or " &
793 "static string expression!", Argx
);
797 end Check_Arg_Is_External_Name
;
799 -----------------------------
800 -- Check_Arg_Is_Identifier --
801 -----------------------------
803 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
) is
804 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
806 if Nkind
(Argx
) /= N_Identifier
then
808 ("argument for pragma% must be identifier", Argx
);
810 end Check_Arg_Is_Identifier
;
812 ----------------------------------
813 -- Check_Arg_Is_Integer_Literal --
814 ----------------------------------
816 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
) is
817 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
819 if Nkind
(Argx
) /= N_Integer_Literal
then
821 ("argument for pragma% must be integer literal", Argx
);
823 end Check_Arg_Is_Integer_Literal
;
825 -------------------------------------------
826 -- Check_Arg_Is_Library_Level_Local_Name --
827 -------------------------------------------
831 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
832 -- | library_unit_NAME
834 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
) is
836 Check_Arg_Is_Local_Name
(Arg
);
838 if not Is_Library_Level_Entity
(Entity
(Expression
(Arg
)))
839 and then Comes_From_Source
(N
)
842 ("argument for pragma% must be library level entity", Arg
);
844 end Check_Arg_Is_Library_Level_Local_Name
;
846 -----------------------------
847 -- Check_Arg_Is_Local_Name --
848 -----------------------------
852 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
853 -- | library_unit_NAME
855 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
) is
856 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
861 if Nkind
(Argx
) not in N_Direct_Name
862 and then (Nkind
(Argx
) /= N_Attribute_Reference
863 or else Present
(Expressions
(Argx
))
864 or else Nkind
(Prefix
(Argx
)) /= N_Identifier
)
865 and then (not Is_Entity_Name
(Argx
)
866 or else not Is_Compilation_Unit
(Entity
(Argx
)))
868 Error_Pragma_Arg
("argument for pragma% must be local name", Argx
);
871 if Is_Entity_Name
(Argx
)
872 and then Scope
(Entity
(Argx
)) /= Current_Scope
875 ("pragma% argument must be in same declarative part", Arg
);
877 end Check_Arg_Is_Local_Name
;
879 ---------------------------------
880 -- Check_Arg_Is_Locking_Policy --
881 ---------------------------------
883 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
) is
884 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
887 Check_Arg_Is_Identifier
(Argx
);
889 if not Is_Locking_Policy_Name
(Chars
(Argx
)) then
891 ("& is not a valid locking policy name", Argx
);
893 end Check_Arg_Is_Locking_Policy
;
895 -------------------------
896 -- Check_Arg_Is_One_Of --
897 -------------------------
899 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
) is
900 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
903 Check_Arg_Is_Identifier
(Argx
);
905 if Chars
(Argx
) /= N1
and then Chars
(Argx
) /= N2
then
906 Error_Msg_Name_2
:= N1
;
907 Error_Msg_Name_3
:= N2
;
908 Error_Pragma_Arg
("argument for pragma% must be% or%", Argx
);
910 end Check_Arg_Is_One_Of
;
912 procedure Check_Arg_Is_One_Of
914 N1
, N2
, N3
: Name_Id
)
916 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
919 Check_Arg_Is_Identifier
(Argx
);
921 if Chars
(Argx
) /= N1
922 and then Chars
(Argx
) /= N2
923 and then Chars
(Argx
) /= N3
925 Error_Pragma_Arg
("invalid argument for pragma%", Argx
);
927 end Check_Arg_Is_One_Of
;
929 procedure Check_Arg_Is_One_Of
931 N1
, N2
, N3
, N4
: Name_Id
)
933 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
936 Check_Arg_Is_Identifier
(Argx
);
938 if Chars
(Argx
) /= N1
939 and then Chars
(Argx
) /= N2
940 and then Chars
(Argx
) /= N3
941 and then Chars
(Argx
) /= N4
943 Error_Pragma_Arg
("invalid argument for pragma%", Argx
);
945 end Check_Arg_Is_One_Of
;
947 ---------------------------------
948 -- Check_Arg_Is_Queuing_Policy --
949 ---------------------------------
951 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
) is
952 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
955 Check_Arg_Is_Identifier
(Argx
);
957 if not Is_Queuing_Policy_Name
(Chars
(Argx
)) then
959 ("& is not a valid queuing policy name", Argx
);
961 end Check_Arg_Is_Queuing_Policy
;
963 ------------------------------------
964 -- Check_Arg_Is_Static_Expression --
965 ------------------------------------
967 procedure Check_Arg_Is_Static_Expression
971 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
974 Analyze_And_Resolve
(Argx
, Typ
);
976 if Is_OK_Static_Expression
(Argx
) then
979 elsif Etype
(Argx
) = Any_Type
then
982 -- An interesting special case, if we have a string literal and we
983 -- are in Ada 83 mode, then we allow it even though it will not be
984 -- flagged as static. This allows the use of Ada 95 pragmas like
985 -- Import in Ada 83 mode. They will of course be flagged with
986 -- warnings as usual, but will not cause errors.
988 elsif Ada_Version
= Ada_83
989 and then Nkind
(Argx
) = N_String_Literal
993 -- Static expression that raises Constraint_Error. This has already
994 -- been flagged, so just exit from pragma processing.
996 elsif Is_Static_Expression
(Argx
) then
999 -- Finally, we have a real error
1002 Error_Msg_Name_1
:= Pname
;
1003 Flag_Non_Static_Expr
1004 ("argument for pragma% must be a static expression!", Argx
);
1007 end Check_Arg_Is_Static_Expression
;
1009 ---------------------------------
1010 -- Check_Arg_Is_String_Literal --
1011 ---------------------------------
1013 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
) is
1014 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1016 if Nkind
(Argx
) /= N_String_Literal
then
1018 ("argument for pragma% must be string literal", Argx
);
1020 end Check_Arg_Is_String_Literal
;
1022 ------------------------------------------
1023 -- Check_Arg_Is_Task_Dispatching_Policy --
1024 ------------------------------------------
1026 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
) is
1027 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1030 Check_Arg_Is_Identifier
(Argx
);
1032 if not Is_Task_Dispatching_Policy_Name
(Chars
(Argx
)) then
1034 ("& is not a valid task dispatching policy name", Argx
);
1036 end Check_Arg_Is_Task_Dispatching_Policy
;
1038 ---------------------
1039 -- Check_Arg_Order --
1040 ---------------------
1042 procedure Check_Arg_Order
(Names
: Name_List
) is
1045 Highest_So_Far
: Natural := 0;
1046 -- Highest index in Names seen do far
1050 for J
in 1 .. Arg_Count
loop
1051 if Chars
(Arg
) /= No_Name
then
1052 for K
in Names
'Range loop
1053 if Chars
(Arg
) = Names
(K
) then
1054 if K
< Highest_So_Far
then
1055 Error_Msg_Name_1
:= Pname
;
1057 ("parameters out of order for pragma%", Arg
);
1058 Error_Msg_Name_1
:= Names
(K
);
1059 Error_Msg_Name_2
:= Names
(Highest_So_Far
);
1060 Error_Msg_N
("\% must appear before %", Arg
);
1064 Highest_So_Far
:= K
;
1072 end Check_Arg_Order
;
1074 --------------------------------
1075 -- Check_At_Least_N_Arguments --
1076 --------------------------------
1078 procedure Check_At_Least_N_Arguments
(N
: Nat
) is
1080 if Arg_Count
< N
then
1081 Error_Pragma
("too few arguments for pragma%");
1083 end Check_At_Least_N_Arguments
;
1085 -------------------------------
1086 -- Check_At_Most_N_Arguments --
1087 -------------------------------
1089 procedure Check_At_Most_N_Arguments
(N
: Nat
) is
1092 if Arg_Count
> N
then
1094 for J
in 1 .. N
loop
1096 Error_Pragma_Arg
("too many arguments for pragma%", Arg
);
1099 end Check_At_Most_N_Arguments
;
1101 ---------------------
1102 -- Check_Component --
1103 ---------------------
1105 procedure Check_Component
(Comp
: Node_Id
) is
1107 if Nkind
(Comp
) = N_Component_Declaration
then
1109 Sindic
: constant Node_Id
:=
1110 Subtype_Indication
(Component_Definition
(Comp
));
1111 Typ
: constant Entity_Id
:=
1112 Etype
(Defining_Identifier
(Comp
));
1114 if Nkind
(Sindic
) = N_Subtype_Indication
then
1116 -- Ada 2005 (AI-216): If a component subtype is subject to
1117 -- a per-object constraint, then the component type shall
1118 -- be an Unchecked_Union.
1120 if Has_Per_Object_Constraint
(Defining_Identifier
(Comp
))
1122 not Is_Unchecked_Union
(Etype
(Subtype_Mark
(Sindic
)))
1124 Error_Msg_N
("component subtype subject to per-object" &
1125 " constraint must be an Unchecked_Union", Comp
);
1129 if Is_Controlled
(Typ
) then
1131 ("component of unchecked union cannot be controlled", Comp
);
1133 elsif Has_Task
(Typ
) then
1135 ("component of unchecked union cannot have tasks", Comp
);
1139 end Check_Component
;
1141 ----------------------------------
1142 -- Check_Duplicated_Export_Name --
1143 ----------------------------------
1145 procedure Check_Duplicated_Export_Name
(Nam
: Node_Id
) is
1146 String_Val
: constant String_Id
:= Strval
(Nam
);
1149 -- We are only interested in the export case, and in the case of
1150 -- generics, it is the instance, not the template, that is the
1151 -- problem (the template will generate a warning in any case).
1153 if not Inside_A_Generic
1154 and then (Prag_Id
= Pragma_Export
1156 Prag_Id
= Pragma_Export_Procedure
1158 Prag_Id
= Pragma_Export_Valued_Procedure
1160 Prag_Id
= Pragma_Export_Function
)
1162 for J
in Externals
.First
.. Externals
.Last
loop
1163 if String_Equal
(String_Val
, Strval
(Externals
.Table
(J
))) then
1164 Error_Msg_Sloc
:= Sloc
(Externals
.Table
(J
));
1165 Error_Msg_N
("external name duplicates name given#", Nam
);
1170 Externals
.Append
(Nam
);
1172 end Check_Duplicated_Export_Name
;
1174 -------------------------
1175 -- Check_First_Subtype --
1176 -------------------------
1178 procedure Check_First_Subtype
(Arg
: Node_Id
) is
1179 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1181 if not Is_First_Subtype
(Entity
(Argx
)) then
1183 ("pragma% cannot apply to subtype", Argx
);
1185 end Check_First_Subtype
;
1187 ---------------------------
1188 -- Check_In_Main_Program --
1189 ---------------------------
1191 procedure Check_In_Main_Program
is
1192 P
: constant Node_Id
:= Parent
(N
);
1195 -- Must be at in subprogram body
1197 if Nkind
(P
) /= N_Subprogram_Body
then
1198 Error_Pragma
("% pragma allowed only in subprogram");
1200 -- Otherwise warn if obviously not main program
1202 elsif Present
(Parameter_Specifications
(Specification
(P
)))
1203 or else not Is_Compilation_Unit
(Defining_Entity
(P
))
1205 Error_Msg_Name_1
:= Pname
;
1207 ("?pragma% is only effective in main program", N
);
1209 end Check_In_Main_Program
;
1211 ---------------------------------------
1212 -- Check_Interrupt_Or_Attach_Handler --
1213 ---------------------------------------
1215 procedure Check_Interrupt_Or_Attach_Handler
is
1216 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
1217 Handler_Proc
, Proc_Scope
: Entity_Id
;
1222 if Prag_Id
= Pragma_Interrupt_Handler
then
1223 Check_Restriction
(No_Dynamic_Attachment
, N
);
1226 Handler_Proc
:= Find_Unique_Parameterless_Procedure
(Arg1_X
, Arg1
);
1227 Proc_Scope
:= Scope
(Handler_Proc
);
1229 -- On AAMP only, a pragma Interrupt_Handler is supported for
1230 -- nonprotected parameterless procedures.
1232 if not AAMP_On_Target
1233 or else Prag_Id
= Pragma_Attach_Handler
1235 if Ekind
(Proc_Scope
) /= E_Protected_Type
then
1237 ("argument of pragma% must be protected procedure", Arg1
);
1240 if Parent
(N
) /= Protected_Definition
(Parent
(Proc_Scope
)) then
1241 Error_Pragma
("pragma% must be in protected definition");
1245 if not Is_Library_Level_Entity
(Proc_Scope
)
1246 or else (AAMP_On_Target
1247 and then not Is_Library_Level_Entity
(Handler_Proc
))
1250 ("argument for pragma% must be library level entity", Arg1
);
1252 end Check_Interrupt_Or_Attach_Handler
;
1254 -------------------------------------------
1255 -- Check_Is_In_Decl_Part_Or_Package_Spec --
1256 -------------------------------------------
1258 procedure Check_Is_In_Decl_Part_Or_Package_Spec
is
1267 elsif Nkind
(P
) = N_Handled_Sequence_Of_Statements
then
1270 elsif Nkind_In
(P
, N_Package_Specification
,
1275 -- Note: the following tests seem a little peculiar, because
1276 -- they test for bodies, but if we were in the statement part
1277 -- of the body, we would already have hit the handled statement
1278 -- sequence, so the only way we get here is by being in the
1279 -- declarative part of the body.
1281 elsif Nkind_In
(P
, N_Subprogram_Body
,
1292 Error_Pragma
("pragma% is not in declarative part or package spec");
1293 end Check_Is_In_Decl_Part_Or_Package_Spec
;
1295 -------------------------
1296 -- Check_No_Identifier --
1297 -------------------------
1299 procedure Check_No_Identifier
(Arg
: Node_Id
) is
1301 if Chars
(Arg
) /= No_Name
then
1302 Error_Pragma_Arg_Ident
1303 ("pragma% does not permit identifier& here", Arg
);
1305 end Check_No_Identifier
;
1307 --------------------------
1308 -- Check_No_Identifiers --
1309 --------------------------
1311 procedure Check_No_Identifiers
is
1314 if Arg_Count
> 0 then
1316 while Present
(Arg_Node
) loop
1317 Check_No_Identifier
(Arg_Node
);
1321 end Check_No_Identifiers
;
1323 -------------------------------
1324 -- Check_Optional_Identifier --
1325 -------------------------------
1327 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
) is
1329 if Present
(Arg
) and then Chars
(Arg
) /= No_Name
then
1330 if Chars
(Arg
) /= Id
then
1331 Error_Msg_Name_1
:= Pname
;
1332 Error_Msg_Name_2
:= Id
;
1333 Error_Msg_N
("pragma% argument expects identifier%", Arg
);
1337 end Check_Optional_Identifier
;
1339 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String) is
1341 Name_Buffer
(1 .. Id
'Length) := Id
;
1342 Name_Len
:= Id
'Length;
1343 Check_Optional_Identifier
(Arg
, Name_Find
);
1344 end Check_Optional_Identifier
;
1346 --------------------------------------
1347 -- Check_Precondition_Postcondition --
1348 --------------------------------------
1350 procedure Check_Precondition_Postcondition
(In_Body
: out Boolean) is
1354 procedure Chain_PPC
(PO
: Node_Id
);
1355 -- If PO is a subprogram declaration node (or a generic subprogram
1356 -- declaration node), then the precondition/postcondition applies
1357 -- to this subprogram and the processing for the pragma is completed.
1358 -- Otherwise the pragma is misplaced.
1364 procedure Chain_PPC
(PO
: Node_Id
) is
1368 if not Nkind_In
(PO
, N_Subprogram_Declaration
,
1369 N_Generic_Subprogram_Declaration
)
1374 -- Here if we have subprogram or generic subprogram declaration
1376 S
:= Defining_Unit_Name
(Specification
(PO
));
1378 -- Analyze the pragma unless it appears within a package spec,
1379 -- which is the case where we delay the analysis of the PPC until
1380 -- the end of the package declarations (for details, see
1381 -- Analyze_Package_Specification.Analyze_PPCs).
1383 if not Is_Package_Or_Generic_Package
(Scope
(S
)) then
1384 Analyze_PPC_In_Decl_Part
(N
, S
);
1387 -- Chain spec PPC pragma to list for subprogram
1389 Set_Next_Pragma
(N
, Spec_PPC_List
(S
));
1390 Set_Spec_PPC_List
(S
, N
);
1392 -- Return indicating spec case
1398 -- Start of processing for Check_Precondition_Postcondition
1401 if not Is_List_Member
(N
) then
1405 -- Record whether pragma is enabled
1407 Set_PPC_Enabled
(N
, Check_Enabled
(Pname
));
1409 -- If we are within an inlined body, the legality of the pragma
1410 -- has been checked already.
1412 if In_Inlined_Body
then
1417 -- Search prior declarations
1420 while Present
(Prev
(P
)) loop
1423 -- If the previous node is a generic subprogram, do not go to to
1424 -- the original node, which is the unanalyzed tree: we need to
1425 -- attach the pre/postconditions to the analyzed version at this
1426 -- point. They get propagated to the original tree when analyzing
1427 -- the corresponding body.
1429 if Nkind
(P
) not in N_Generic_Declaration
then
1430 PO
:= Original_Node
(P
);
1435 -- Skip past prior pragma
1437 if Nkind
(PO
) = N_Pragma
then
1440 -- Skip stuff not coming from source
1442 elsif not Comes_From_Source
(PO
) then
1445 -- Only remaining possibility is subprogram declaration
1453 -- If we fall through loop, pragma is at start of list, so see if it
1454 -- is at the start of declarations of a subprogram body.
1456 if Nkind
(Parent
(N
)) = N_Subprogram_Body
1457 and then List_Containing
(N
) = Declarations
(Parent
(N
))
1459 if Operating_Mode
/= Generate_Code
1460 or else Inside_A_Generic
1463 -- Analyze expression in pragma, for correctness
1464 -- and for ASIS use.
1466 Preanalyze_Spec_Expression
1467 (Get_Pragma_Arg
(Arg1
), Standard_Boolean
);
1473 -- See if it is in the pragmas after a library level subprogram
1475 elsif Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
1476 Chain_PPC
(Unit
(Parent
(Parent
(N
))));
1480 -- If we fall through, pragma was misplaced
1483 end Check_Precondition_Postcondition
;
1485 -----------------------------
1486 -- Check_Static_Constraint --
1487 -----------------------------
1489 -- Note: for convenience in writing this procedure, in addition to
1490 -- the officially (i.e. by spec) allowed argument which is always a
1491 -- constraint, it also allows ranges and discriminant associations.
1492 -- Above is not clear ???
1494 procedure Check_Static_Constraint
(Constr
: Node_Id
) is
1496 procedure Require_Static
(E
: Node_Id
);
1497 -- Require given expression to be static expression
1499 --------------------
1500 -- Require_Static --
1501 --------------------
1503 procedure Require_Static
(E
: Node_Id
) is
1505 if not Is_OK_Static_Expression
(E
) then
1506 Flag_Non_Static_Expr
1507 ("non-static constraint not allowed in Unchecked_Union!", E
);
1512 -- Start of processing for Check_Static_Constraint
1515 case Nkind
(Constr
) is
1516 when N_Discriminant_Association
=>
1517 Require_Static
(Expression
(Constr
));
1520 Require_Static
(Low_Bound
(Constr
));
1521 Require_Static
(High_Bound
(Constr
));
1523 when N_Attribute_Reference
=>
1524 Require_Static
(Type_Low_Bound
(Etype
(Prefix
(Constr
))));
1525 Require_Static
(Type_High_Bound
(Etype
(Prefix
(Constr
))));
1527 when N_Range_Constraint
=>
1528 Check_Static_Constraint
(Range_Expression
(Constr
));
1530 when N_Index_Or_Discriminant_Constraint
=>
1534 IDC
:= First
(Constraints
(Constr
));
1535 while Present
(IDC
) loop
1536 Check_Static_Constraint
(IDC
);
1544 end Check_Static_Constraint
;
1546 --------------------------------------
1547 -- Check_Valid_Configuration_Pragma --
1548 --------------------------------------
1550 -- A configuration pragma must appear in the context clause of a
1551 -- compilation unit, and only other pragmas may precede it. Note that
1552 -- the test also allows use in a configuration pragma file.
1554 procedure Check_Valid_Configuration_Pragma
is
1556 if not Is_Configuration_Pragma
then
1557 Error_Pragma
("incorrect placement for configuration pragma%");
1559 end Check_Valid_Configuration_Pragma
;
1561 -------------------------------------
1562 -- Check_Valid_Library_Unit_Pragma --
1563 -------------------------------------
1565 procedure Check_Valid_Library_Unit_Pragma
is
1567 Parent_Node
: Node_Id
;
1568 Unit_Name
: Entity_Id
;
1569 Unit_Kind
: Node_Kind
;
1570 Unit_Node
: Node_Id
;
1571 Sindex
: Source_File_Index
;
1574 if not Is_List_Member
(N
) then
1578 Plist
:= List_Containing
(N
);
1579 Parent_Node
:= Parent
(Plist
);
1581 if Parent_Node
= Empty
then
1584 -- Case of pragma appearing after a compilation unit. In this case
1585 -- it must have an argument with the corresponding name and must
1586 -- be part of the following pragmas of its parent.
1588 elsif Nkind
(Parent_Node
) = N_Compilation_Unit_Aux
then
1589 if Plist
/= Pragmas_After
(Parent_Node
) then
1592 elsif Arg_Count
= 0 then
1594 ("argument required if outside compilation unit");
1597 Check_No_Identifiers
;
1598 Check_Arg_Count
(1);
1599 Unit_Node
:= Unit
(Parent
(Parent_Node
));
1600 Unit_Kind
:= Nkind
(Unit_Node
);
1602 Analyze
(Expression
(Arg1
));
1604 if Unit_Kind
= N_Generic_Subprogram_Declaration
1605 or else Unit_Kind
= N_Subprogram_Declaration
1607 Unit_Name
:= Defining_Entity
(Unit_Node
);
1609 elsif Unit_Kind
in N_Generic_Instantiation
then
1610 Unit_Name
:= Defining_Entity
(Unit_Node
);
1613 Unit_Name
:= Cunit_Entity
(Current_Sem_Unit
);
1616 if Chars
(Unit_Name
) /=
1617 Chars
(Entity
(Expression
(Arg1
)))
1620 ("pragma% argument is not current unit name", Arg1
);
1623 if Ekind
(Unit_Name
) = E_Package
1624 and then Present
(Renamed_Entity
(Unit_Name
))
1626 Error_Pragma
("pragma% not allowed for renamed package");
1630 -- Pragma appears other than after a compilation unit
1633 -- Here we check for the generic instantiation case and also
1634 -- for the case of processing a generic formal package. We
1635 -- detect these cases by noting that the Sloc on the node
1636 -- does not belong to the current compilation unit.
1638 Sindex
:= Source_Index
(Current_Sem_Unit
);
1640 if Loc
not in Source_First
(Sindex
) .. Source_Last
(Sindex
) then
1641 Rewrite
(N
, Make_Null_Statement
(Loc
));
1644 -- If before first declaration, the pragma applies to the
1645 -- enclosing unit, and the name if present must be this name.
1647 elsif Is_Before_First_Decl
(N
, Plist
) then
1648 Unit_Node
:= Unit_Declaration_Node
(Current_Scope
);
1649 Unit_Kind
:= Nkind
(Unit_Node
);
1651 if Nkind
(Parent
(Unit_Node
)) /= N_Compilation_Unit
then
1654 elsif Unit_Kind
= N_Subprogram_Body
1655 and then not Acts_As_Spec
(Unit_Node
)
1659 elsif Nkind
(Parent_Node
) = N_Package_Body
then
1662 elsif Nkind
(Parent_Node
) = N_Package_Specification
1663 and then Plist
= Private_Declarations
(Parent_Node
)
1667 elsif (Nkind
(Parent_Node
) = N_Generic_Package_Declaration
1668 or else Nkind
(Parent_Node
) =
1669 N_Generic_Subprogram_Declaration
)
1670 and then Plist
= Generic_Formal_Declarations
(Parent_Node
)
1674 elsif Arg_Count
> 0 then
1675 Analyze
(Expression
(Arg1
));
1677 if Entity
(Expression
(Arg1
)) /= Current_Scope
then
1679 ("name in pragma% must be enclosing unit", Arg1
);
1682 -- It is legal to have no argument in this context
1688 -- Error if not before first declaration. This is because a
1689 -- library unit pragma argument must be the name of a library
1690 -- unit (RM 10.1.5(7)), but the only names permitted in this
1691 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1692 -- generic subprogram declarations or generic instantiations.
1696 ("pragma% misplaced, must be before first declaration");
1700 end Check_Valid_Library_Unit_Pragma
;
1706 procedure Check_Variant
(Variant
: Node_Id
) is
1707 Clist
: constant Node_Id
:= Component_List
(Variant
);
1711 if not Is_Non_Empty_List
(Component_Items
(Clist
)) then
1713 ("Unchecked_Union may not have empty component list",
1718 Comp
:= First
(Component_Items
(Clist
));
1719 while Present
(Comp
) loop
1720 Check_Component
(Comp
);
1729 procedure Error_Pragma
(Msg
: String) is
1731 Error_Msg_Name_1
:= Pname
;
1732 Error_Msg_N
(Msg
, N
);
1736 ----------------------
1737 -- Error_Pragma_Arg --
1738 ----------------------
1740 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
) is
1742 Error_Msg_Name_1
:= Pname
;
1743 Error_Msg_N
(Msg
, Get_Pragma_Arg
(Arg
));
1745 end Error_Pragma_Arg
;
1747 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
) is
1749 Error_Msg_Name_1
:= Pname
;
1750 Error_Msg_N
(Msg1
, Get_Pragma_Arg
(Arg
));
1751 Error_Pragma_Arg
(Msg2
, Arg
);
1752 end Error_Pragma_Arg
;
1754 ----------------------------
1755 -- Error_Pragma_Arg_Ident --
1756 ----------------------------
1758 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
) is
1760 Error_Msg_Name_1
:= Pname
;
1761 Error_Msg_N
(Msg
, Arg
);
1763 end Error_Pragma_Arg_Ident
;
1765 ----------------------
1766 -- Error_Pragma_Ref --
1767 ----------------------
1769 procedure Error_Pragma_Ref
(Msg
: String; Ref
: Entity_Id
) is
1771 Error_Msg_Name_1
:= Pname
;
1772 Error_Msg_Sloc
:= Sloc
(Ref
);
1773 Error_Msg_NE
(Msg
, N
, Ref
);
1775 end Error_Pragma_Ref
;
1777 ------------------------
1778 -- Find_Lib_Unit_Name --
1779 ------------------------
1781 function Find_Lib_Unit_Name
return Entity_Id
is
1783 -- Return inner compilation unit entity, for case of nested
1784 -- categorization pragmas. This happens in generic unit.
1786 if Nkind
(Parent
(N
)) = N_Package_Specification
1787 and then Defining_Entity
(Parent
(N
)) /= Current_Scope
1789 return Defining_Entity
(Parent
(N
));
1791 return Current_Scope
;
1793 end Find_Lib_Unit_Name
;
1795 ----------------------------
1796 -- Find_Program_Unit_Name --
1797 ----------------------------
1799 procedure Find_Program_Unit_Name
(Id
: Node_Id
) is
1800 Unit_Name
: Entity_Id
;
1801 Unit_Kind
: Node_Kind
;
1802 P
: constant Node_Id
:= Parent
(N
);
1805 if Nkind
(P
) = N_Compilation_Unit
then
1806 Unit_Kind
:= Nkind
(Unit
(P
));
1808 if Unit_Kind
= N_Subprogram_Declaration
1809 or else Unit_Kind
= N_Package_Declaration
1810 or else Unit_Kind
in N_Generic_Declaration
1812 Unit_Name
:= Defining_Entity
(Unit
(P
));
1814 if Chars
(Id
) = Chars
(Unit_Name
) then
1815 Set_Entity
(Id
, Unit_Name
);
1816 Set_Etype
(Id
, Etype
(Unit_Name
));
1818 Set_Etype
(Id
, Any_Type
);
1820 ("cannot find program unit referenced by pragma%");
1824 Set_Etype
(Id
, Any_Type
);
1825 Error_Pragma
("pragma% inapplicable to this unit");
1831 end Find_Program_Unit_Name
;
1833 -----------------------------------------
1834 -- Find_Unique_Parameterless_Procedure --
1835 -----------------------------------------
1837 function Find_Unique_Parameterless_Procedure
1839 Arg
: Node_Id
) return Entity_Id
1841 Proc
: Entity_Id
:= Empty
;
1844 -- The body of this procedure needs some comments ???
1846 if not Is_Entity_Name
(Name
) then
1848 ("argument of pragma% must be entity name", Arg
);
1850 elsif not Is_Overloaded
(Name
) then
1851 Proc
:= Entity
(Name
);
1853 if Ekind
(Proc
) /= E_Procedure
1854 or else Present
(First_Formal
(Proc
)) then
1856 ("argument of pragma% must be parameterless procedure", Arg
);
1861 Found
: Boolean := False;
1863 Index
: Interp_Index
;
1866 Get_First_Interp
(Name
, Index
, It
);
1867 while Present
(It
.Nam
) loop
1870 if Ekind
(Proc
) = E_Procedure
1871 and then No
(First_Formal
(Proc
))
1875 Set_Entity
(Name
, Proc
);
1876 Set_Is_Overloaded
(Name
, False);
1879 ("ambiguous handler name for pragma% ", Arg
);
1883 Get_Next_Interp
(Index
, It
);
1888 ("argument of pragma% must be parameterless procedure",
1891 Proc
:= Entity
(Name
);
1897 end Find_Unique_Parameterless_Procedure
;
1899 -------------------------
1900 -- Gather_Associations --
1901 -------------------------
1903 procedure Gather_Associations
1905 Args
: out Args_List
)
1910 -- Initialize all parameters to Empty
1912 for J
in Args
'Range loop
1916 -- That's all we have to do if there are no argument associations
1918 if No
(Pragma_Argument_Associations
(N
)) then
1922 -- Otherwise first deal with any positional parameters present
1924 Arg
:= First
(Pragma_Argument_Associations
(N
));
1925 for Index
in Args
'Range loop
1926 exit when No
(Arg
) or else Chars
(Arg
) /= No_Name
;
1927 Args
(Index
) := Expression
(Arg
);
1931 -- Positional parameters all processed, if any left, then we
1932 -- have too many positional parameters.
1934 if Present
(Arg
) and then Chars
(Arg
) = No_Name
then
1936 ("too many positional associations for pragma%", Arg
);
1939 -- Process named parameters if any are present
1941 while Present
(Arg
) loop
1942 if Chars
(Arg
) = No_Name
then
1944 ("positional association cannot follow named association",
1948 for Index
in Names
'Range loop
1949 if Names
(Index
) = Chars
(Arg
) then
1950 if Present
(Args
(Index
)) then
1952 ("duplicate argument association for pragma%", Arg
);
1954 Args
(Index
) := Expression
(Arg
);
1959 if Index
= Names
'Last then
1960 Error_Msg_Name_1
:= Pname
;
1961 Error_Msg_N
("pragma% does not allow & argument", Arg
);
1963 -- Check for possible misspelling
1965 for Index1
in Names
'Range loop
1966 if Is_Bad_Spelling_Of
1967 (Chars
(Arg
), Names
(Index1
))
1969 Error_Msg_Name_1
:= Names
(Index1
);
1970 Error_Msg_N
-- CODEFIX
1971 ("\possible misspelling of%", Arg
);
1983 end Gather_Associations
;
1989 procedure GNAT_Pragma
is
1991 Check_Restriction
(No_Implementation_Pragmas
, N
);
1994 --------------------------
1995 -- Is_Before_First_Decl --
1996 --------------------------
1998 function Is_Before_First_Decl
1999 (Pragma_Node
: Node_Id
;
2000 Decls
: List_Id
) return Boolean
2002 Item
: Node_Id
:= First
(Decls
);
2005 -- Only other pragmas can come before this pragma
2008 if No
(Item
) or else Nkind
(Item
) /= N_Pragma
then
2011 elsif Item
= Pragma_Node
then
2017 end Is_Before_First_Decl
;
2019 -----------------------------
2020 -- Is_Configuration_Pragma --
2021 -----------------------------
2023 -- A configuration pragma must appear in the context clause of a
2024 -- compilation unit, and only other pragmas may precede it. Note that
2025 -- the test below also permits use in a configuration pragma file.
2027 function Is_Configuration_Pragma
return Boolean is
2028 Lis
: constant List_Id
:= List_Containing
(N
);
2029 Par
: constant Node_Id
:= Parent
(N
);
2033 -- If no parent, then we are in the configuration pragma file,
2034 -- so the placement is definitely appropriate.
2039 -- Otherwise we must be in the context clause of a compilation unit
2040 -- and the only thing allowed before us in the context list is more
2041 -- configuration pragmas.
2043 elsif Nkind
(Par
) = N_Compilation_Unit
2044 and then Context_Items
(Par
) = Lis
2051 elsif Nkind
(Prg
) /= N_Pragma
then
2061 end Is_Configuration_Pragma
;
2063 --------------------------
2064 -- Is_In_Context_Clause --
2065 --------------------------
2067 function Is_In_Context_Clause
return Boolean is
2069 Parent_Node
: Node_Id
;
2072 if not Is_List_Member
(N
) then
2076 Plist
:= List_Containing
(N
);
2077 Parent_Node
:= Parent
(Plist
);
2079 if Parent_Node
= Empty
2080 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
2081 or else Context_Items
(Parent_Node
) /= Plist
2088 end Is_In_Context_Clause
;
2090 ---------------------------------
2091 -- Is_Static_String_Expression --
2092 ---------------------------------
2094 function Is_Static_String_Expression
(Arg
: Node_Id
) return Boolean is
2095 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
2098 Analyze_And_Resolve
(Argx
);
2099 return Is_OK_Static_Expression
(Argx
)
2100 and then Nkind
(Argx
) = N_String_Literal
;
2101 end Is_Static_String_Expression
;
2103 ----------------------
2104 -- Pragma_Misplaced --
2105 ----------------------
2107 procedure Pragma_Misplaced
is
2109 Error_Pragma
("incorrect placement of pragma%");
2110 end Pragma_Misplaced
;
2112 ------------------------------------
2113 -- Process Atomic_Shared_Volatile --
2114 ------------------------------------
2116 procedure Process_Atomic_Shared_Volatile
is
2123 procedure Set_Atomic
(E
: Entity_Id
);
2124 -- Set given type as atomic, and if no explicit alignment was given,
2125 -- set alignment to unknown, since back end knows what the alignment
2126 -- requirements are for atomic arrays. Note: this step is necessary
2127 -- for derived types.
2133 procedure Set_Atomic
(E
: Entity_Id
) is
2137 if not Has_Alignment_Clause
(E
) then
2138 Set_Alignment
(E
, Uint_0
);
2142 -- Start of processing for Process_Atomic_Shared_Volatile
2145 Check_Ada_83_Warning
;
2146 Check_No_Identifiers
;
2147 Check_Arg_Count
(1);
2148 Check_Arg_Is_Local_Name
(Arg1
);
2149 E_Id
:= Expression
(Arg1
);
2151 if Etype
(E_Id
) = Any_Type
then
2156 D
:= Declaration_Node
(E
);
2160 if Rep_Item_Too_Early
(E
, N
)
2162 Rep_Item_Too_Late
(E
, N
)
2166 Check_First_Subtype
(Arg1
);
2169 if Prag_Id
/= Pragma_Volatile
then
2171 Set_Atomic
(Underlying_Type
(E
));
2172 Set_Atomic
(Base_Type
(E
));
2175 -- Attribute belongs on the base type. If the view of the type is
2176 -- currently private, it also belongs on the underlying type.
2178 Set_Is_Volatile
(Base_Type
(E
));
2179 Set_Is_Volatile
(Underlying_Type
(E
));
2181 Set_Treat_As_Volatile
(E
);
2182 Set_Treat_As_Volatile
(Underlying_Type
(E
));
2184 elsif K
= N_Object_Declaration
2185 or else (K
= N_Component_Declaration
2186 and then Original_Record_Component
(E
) = E
)
2188 if Rep_Item_Too_Late
(E
, N
) then
2192 if Prag_Id
/= Pragma_Volatile
then
2195 -- If the object declaration has an explicit initialization, a
2196 -- temporary may have to be created to hold the expression, to
2197 -- ensure that access to the object remain atomic.
2199 if Nkind
(Parent
(E
)) = N_Object_Declaration
2200 and then Present
(Expression
(Parent
(E
)))
2202 Set_Has_Delayed_Freeze
(E
);
2205 -- An interesting improvement here. If an object of type X is
2206 -- declared atomic, and the type X is not atomic, that's a
2207 -- pity, since it may not have appropriate alignment etc. We
2208 -- can rescue this in the special case where the object and
2209 -- type are in the same unit by just setting the type as
2210 -- atomic, so that the back end will process it as atomic.
2212 Utyp
:= Underlying_Type
(Etype
(E
));
2215 and then Sloc
(E
) > No_Location
2216 and then Sloc
(Utyp
) > No_Location
2218 Get_Source_File_Index
(Sloc
(E
)) =
2219 Get_Source_File_Index
(Sloc
(Underlying_Type
(Etype
(E
))))
2221 Set_Is_Atomic
(Underlying_Type
(Etype
(E
)));
2225 Set_Is_Volatile
(E
);
2226 Set_Treat_As_Volatile
(E
);
2230 ("inappropriate entity for pragma%", Arg1
);
2232 end Process_Atomic_Shared_Volatile
;
2234 -------------------------------------------
2235 -- Process_Compile_Time_Warning_Or_Error --
2236 -------------------------------------------
2238 procedure Process_Compile_Time_Warning_Or_Error
is
2239 Arg1x
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
2242 Check_Arg_Count
(2);
2243 Check_No_Identifiers
;
2244 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
2245 Analyze_And_Resolve
(Arg1x
, Standard_Boolean
);
2247 if Compile_Time_Known_Value
(Arg1x
) then
2248 if Is_True
(Expr_Value
(Get_Pragma_Arg
(Arg1
))) then
2250 Str
: constant String_Id
:=
2251 Strval
(Get_Pragma_Arg
(Arg2
));
2252 Len
: constant Int
:= String_Length
(Str
);
2257 Cent
: constant Entity_Id
:=
2258 Cunit_Entity
(Current_Sem_Unit
);
2260 Force
: constant Boolean :=
2261 Prag_Id
= Pragma_Compile_Time_Warning
2263 Is_Spec_Name
(Unit_Name
(Current_Sem_Unit
))
2264 and then (Ekind
(Cent
) /= E_Package
2265 or else not In_Private_Part
(Cent
));
2266 -- Set True if this is the warning case, and we are in the
2267 -- visible part of a package spec, or in a subprogram spec,
2268 -- in which case we want to force the client to see the
2269 -- warning, even though it is not in the main unit.
2272 -- Loop through segments of message separated by line feeds.
2273 -- We output these segments as separate messages with
2274 -- continuation marks for all but the first.
2279 Error_Msg_Strlen
:= 0;
2281 -- Loop to copy characters from argument to error message
2285 exit when Ptr
> Len
;
2286 CC
:= Get_String_Char
(Str
, Ptr
);
2289 -- Ignore wide chars ??? else store character
2291 if In_Character_Range
(CC
) then
2292 C
:= Get_Character
(CC
);
2293 exit when C
= ASCII
.LF
;
2294 Error_Msg_Strlen
:= Error_Msg_Strlen
+ 1;
2295 Error_Msg_String
(Error_Msg_Strlen
) := C
;
2299 -- Here with one line ready to go
2301 Error_Msg_Warn
:= Prag_Id
= Pragma_Compile_Time_Warning
;
2303 -- If this is a warning in a spec, then we want clients
2304 -- to see the warning, so mark the message with the
2305 -- special sequence !! to force the warning. In the case
2306 -- of a package spec, we do not force this if we are in
2307 -- the private part of the spec.
2310 if Cont
= False then
2311 Error_Msg_N
("<~!!", Arg1
);
2314 Error_Msg_N
("\<~!!", Arg1
);
2317 -- Error, rather than warning, or in a body, so we do not
2318 -- need to force visibility for client (error will be
2319 -- output in any case, and this is the situation in which
2320 -- we do not want a client to get a warning, since the
2321 -- warning is in the body or the spec private part.
2324 if Cont
= False then
2325 Error_Msg_N
("<~", Arg1
);
2328 Error_Msg_N
("\<~", Arg1
);
2332 exit when Ptr
> Len
;
2337 end Process_Compile_Time_Warning_Or_Error
;
2339 ------------------------
2340 -- Process_Convention --
2341 ------------------------
2343 procedure Process_Convention
2344 (C
: out Convention_Id
;
2350 Comp_Unit
: Unit_Number_Type
;
2352 procedure Set_Convention_From_Pragma
(E
: Entity_Id
);
2353 -- Set convention in entity E, and also flag that the entity has a
2354 -- convention pragma. If entity is for a private or incomplete type,
2355 -- also set convention and flag on underlying type. This procedure
2356 -- also deals with the special case of C_Pass_By_Copy convention.
2358 --------------------------------
2359 -- Set_Convention_From_Pragma --
2360 --------------------------------
2362 procedure Set_Convention_From_Pragma
(E
: Entity_Id
) is
2364 -- Ada 2005 (AI-430): Check invalid attempt to change convention
2365 -- for an overridden dispatching operation. Technically this is
2366 -- an amendment and should only be done in Ada 2005 mode. However,
2367 -- this is clearly a mistake, since the problem that is addressed
2368 -- by this AI is that there is a clear gap in the RM!
2370 if Is_Dispatching_Operation
(E
)
2371 and then Present
(Overridden_Operation
(E
))
2372 and then C
/= Convention
(Overridden_Operation
(E
))
2375 ("cannot change convention for " &
2376 "overridden dispatching operation",
2380 -- Set the convention
2382 Set_Convention
(E
, C
);
2383 Set_Has_Convention_Pragma
(E
);
2385 if Is_Incomplete_Or_Private_Type
(E
) then
2386 Set_Convention
(Underlying_Type
(E
), C
);
2387 Set_Has_Convention_Pragma
(Underlying_Type
(E
), True);
2390 -- A class-wide type should inherit the convention of the specific
2391 -- root type (although this isn't specified clearly by the RM).
2393 if Is_Type
(E
) and then Present
(Class_Wide_Type
(E
)) then
2394 Set_Convention
(Class_Wide_Type
(E
), C
);
2397 -- If the entity is a record type, then check for special case of
2398 -- C_Pass_By_Copy, which is treated the same as C except that the
2399 -- special record flag is set. This convention is only permitted
2400 -- on record types (see AI95-00131).
2402 if Cname
= Name_C_Pass_By_Copy
then
2403 if Is_Record_Type
(E
) then
2404 Set_C_Pass_By_Copy
(Base_Type
(E
));
2405 elsif Is_Incomplete_Or_Private_Type
(E
)
2406 and then Is_Record_Type
(Underlying_Type
(E
))
2408 Set_C_Pass_By_Copy
(Base_Type
(Underlying_Type
(E
)));
2411 ("C_Pass_By_Copy convention allowed only for record type",
2416 -- If the entity is a derived boolean type, check for the special
2417 -- case of convention C, C++, or Fortran, where we consider any
2418 -- nonzero value to represent true.
2420 if Is_Discrete_Type
(E
)
2421 and then Root_Type
(Etype
(E
)) = Standard_Boolean
2427 C
= Convention_Fortran
)
2429 Set_Nonzero_Is_True
(Base_Type
(E
));
2431 end Set_Convention_From_Pragma
;
2433 -- Start of processing for Process_Convention
2436 Check_At_Least_N_Arguments
(2);
2437 Check_Optional_Identifier
(Arg1
, Name_Convention
);
2438 Check_Arg_Is_Identifier
(Arg1
);
2439 Cname
:= Chars
(Expression
(Arg1
));
2441 -- C_Pass_By_Copy is treated as a synonym for convention C (this is
2442 -- tested again below to set the critical flag).
2443 if Cname
= Name_C_Pass_By_Copy
then
2446 -- Otherwise we must have something in the standard convention list
2448 elsif Is_Convention_Name
(Cname
) then
2449 C
:= Get_Convention_Id
(Chars
(Expression
(Arg1
)));
2451 -- In DEC VMS, it seems that there is an undocumented feature that
2452 -- any unrecognized convention is treated as the default, which for
2453 -- us is convention C. It does not seem so terrible to do this
2454 -- unconditionally, silently in the VMS case, and with a warning
2455 -- in the non-VMS case.
2458 if Warn_On_Export_Import
and not OpenVMS_On_Target
then
2460 ("?unrecognized convention name, C assumed",
2467 Check_Optional_Identifier
(Arg2
, Name_Entity
);
2468 Check_Arg_Is_Local_Name
(Arg2
);
2470 Id
:= Expression
(Arg2
);
2473 if not Is_Entity_Name
(Id
) then
2474 Error_Pragma_Arg
("entity name required", Arg2
);
2479 -- Go to renamed subprogram if present, since convention applies to
2480 -- the actual renamed entity, not to the renaming entity. If the
2481 -- subprogram is inherited, go to parent subprogram.
2483 if Is_Subprogram
(E
)
2484 and then Present
(Alias
(E
))
2486 if Nkind
(Parent
(Declaration_Node
(E
))) =
2487 N_Subprogram_Renaming_Declaration
2489 if Scope
(E
) /= Scope
(Alias
(E
)) then
2491 ("cannot apply pragma% to non-local entity&#", E
);
2496 elsif Nkind_In
(Parent
(E
), N_Full_Type_Declaration
,
2497 N_Private_Extension_Declaration
)
2498 and then Scope
(E
) = Scope
(Alias
(E
))
2504 -- Check that we are not applying this to a specless body
2506 if Is_Subprogram
(E
)
2507 and then Nkind
(Parent
(Declaration_Node
(E
))) = N_Subprogram_Body
2510 ("pragma% requires separate spec and must come before body");
2513 -- Check that we are not applying this to a named constant
2515 if Ekind
(E
) = E_Named_Integer
2517 Ekind
(E
) = E_Named_Real
2519 Error_Msg_Name_1
:= Pname
;
2521 ("cannot apply pragma% to named constant!",
2522 Get_Pragma_Arg
(Arg2
));
2524 ("\supply appropriate type for&!", Arg2
);
2527 if Ekind
(E
) = E_Enumeration_Literal
then
2528 Error_Pragma
("enumeration literal not allowed for pragma%");
2531 -- Check for rep item appearing too early or too late
2533 if Etype
(E
) = Any_Type
2534 or else Rep_Item_Too_Early
(E
, N
)
2538 E
:= Underlying_Type
(E
);
2541 if Rep_Item_Too_Late
(E
, N
) then
2545 if Has_Convention_Pragma
(E
) then
2547 ("at most one Convention/Export/Import pragma is allowed", Arg2
);
2549 elsif Convention
(E
) = Convention_Protected
2550 or else Ekind
(Scope
(E
)) = E_Protected_Type
2553 ("a protected operation cannot be given a different convention",
2557 -- For Intrinsic, a subprogram is required
2559 if C
= Convention_Intrinsic
2560 and then not Is_Subprogram
(E
)
2561 and then not Is_Generic_Subprogram
(E
)
2564 ("second argument of pragma% must be a subprogram", Arg2
);
2567 -- For Stdcall, a subprogram, variable or subprogram type is required
2569 if C
= Convention_Stdcall
2570 and then not Is_Subprogram
(E
)
2571 and then not Is_Generic_Subprogram
(E
)
2572 and then Ekind
(E
) /= E_Variable
2575 and then Ekind
(Designated_Type
(E
)) = E_Subprogram_Type
)
2578 ("second argument of pragma% must be subprogram (type)",
2582 if not Is_Subprogram
(E
)
2583 and then not Is_Generic_Subprogram
(E
)
2585 Set_Convention_From_Pragma
(E
);
2589 Check_First_Subtype
(Arg2
);
2590 Set_Convention_From_Pragma
(Base_Type
(E
));
2592 -- For subprograms, we must set the convention on the
2593 -- internally generated directly designated type as well.
2595 if Ekind
(E
) = E_Access_Subprogram_Type
then
2596 Set_Convention_From_Pragma
(Directly_Designated_Type
(E
));
2600 -- For the subprogram case, set proper convention for all homonyms
2601 -- in same scope and the same declarative part, i.e. the same
2602 -- compilation unit.
2605 Comp_Unit
:= Get_Source_Unit
(E
);
2606 Set_Convention_From_Pragma
(E
);
2608 -- Treat a pragma Import as an implicit body, for GPS use
2610 if Prag_Id
= Pragma_Import
then
2611 Generate_Reference
(E
, Id
, 'b');
2617 exit when No
(E1
) or else Scope
(E1
) /= Current_Scope
;
2619 -- Do not set the pragma on inherited operations or on formal
2622 if Comes_From_Source
(E1
)
2623 and then Comp_Unit
= Get_Source_Unit
(E1
)
2624 and then not Is_Formal_Subprogram
(E1
)
2625 and then Nkind
(Original_Node
(Parent
(E1
))) /=
2626 N_Full_Type_Declaration
2628 if Present
(Alias
(E1
))
2629 and then Scope
(E1
) /= Scope
(Alias
(E1
))
2632 ("cannot apply pragma% to non-local entity& declared#",
2636 Set_Convention_From_Pragma
(E1
);
2638 if Prag_Id
= Pragma_Import
then
2639 Generate_Reference
(E
, Id
, 'b');
2644 end Process_Convention
;
2646 -----------------------------------------------------
2647 -- Process_Extended_Import_Export_Exception_Pragma --
2648 -----------------------------------------------------
2650 procedure Process_Extended_Import_Export_Exception_Pragma
2651 (Arg_Internal
: Node_Id
;
2652 Arg_External
: Node_Id
;
2660 if not OpenVMS_On_Target
then
2662 ("?pragma% ignored (applies only to Open'V'M'S)");
2665 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2666 Def_Id
:= Entity
(Arg_Internal
);
2668 if Ekind
(Def_Id
) /= E_Exception
then
2670 ("pragma% must refer to declared exception", Arg_Internal
);
2673 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2675 if Present
(Arg_Form
) then
2676 Check_Arg_Is_One_Of
(Arg_Form
, Name_Ada
, Name_VMS
);
2679 if Present
(Arg_Form
)
2680 and then Chars
(Arg_Form
) = Name_Ada
2684 Set_Is_VMS_Exception
(Def_Id
);
2685 Set_Exception_Code
(Def_Id
, No_Uint
);
2688 if Present
(Arg_Code
) then
2689 if not Is_VMS_Exception
(Def_Id
) then
2691 ("Code option for pragma% not allowed for Ada case",
2695 Check_Arg_Is_Static_Expression
(Arg_Code
, Any_Integer
);
2696 Code_Val
:= Expr_Value
(Arg_Code
);
2698 if not UI_Is_In_Int_Range
(Code_Val
) then
2700 ("Code option for pragma% must be in 32-bit range",
2704 Set_Exception_Code
(Def_Id
, Code_Val
);
2707 end Process_Extended_Import_Export_Exception_Pragma
;
2709 -------------------------------------------------
2710 -- Process_Extended_Import_Export_Internal_Arg --
2711 -------------------------------------------------
2713 procedure Process_Extended_Import_Export_Internal_Arg
2714 (Arg_Internal
: Node_Id
:= Empty
)
2717 if No
(Arg_Internal
) then
2718 Error_Pragma
("Internal parameter required for pragma%");
2721 if Nkind
(Arg_Internal
) = N_Identifier
then
2724 elsif Nkind
(Arg_Internal
) = N_Operator_Symbol
2725 and then (Prag_Id
= Pragma_Import_Function
2727 Prag_Id
= Pragma_Export_Function
)
2733 ("wrong form for Internal parameter for pragma%", Arg_Internal
);
2736 Check_Arg_Is_Local_Name
(Arg_Internal
);
2737 end Process_Extended_Import_Export_Internal_Arg
;
2739 --------------------------------------------------
2740 -- Process_Extended_Import_Export_Object_Pragma --
2741 --------------------------------------------------
2743 procedure Process_Extended_Import_Export_Object_Pragma
2744 (Arg_Internal
: Node_Id
;
2745 Arg_External
: Node_Id
;
2751 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2752 Def_Id
:= Entity
(Arg_Internal
);
2754 if Ekind
(Def_Id
) /= E_Constant
2755 and then Ekind
(Def_Id
) /= E_Variable
2758 ("pragma% must designate an object", Arg_Internal
);
2761 if Has_Rep_Pragma
(Def_Id
, Name_Common_Object
)
2763 Has_Rep_Pragma
(Def_Id
, Name_Psect_Object
)
2766 ("previous Common/Psect_Object applies, pragma % not permitted",
2770 if Rep_Item_Too_Late
(Def_Id
, N
) then
2774 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2776 if Present
(Arg_Size
) then
2777 Check_Arg_Is_External_Name
(Arg_Size
);
2780 -- Export_Object case
2782 if Prag_Id
= Pragma_Export_Object
then
2783 if not Is_Library_Level_Entity
(Def_Id
) then
2785 ("argument for pragma% must be library level entity",
2789 if Ekind
(Current_Scope
) = E_Generic_Package
then
2790 Error_Pragma
("pragma& cannot appear in a generic unit");
2793 if not Size_Known_At_Compile_Time
(Etype
(Def_Id
)) then
2795 ("exported object must have compile time known size",
2799 if Warn_On_Export_Import
and then Is_Exported
(Def_Id
) then
2801 ("?duplicate Export_Object pragma", N
);
2803 Set_Exported
(Def_Id
, Arg_Internal
);
2806 -- Import_Object case
2809 if Is_Concurrent_Type
(Etype
(Def_Id
)) then
2811 ("cannot use pragma% for task/protected object",
2815 if Ekind
(Def_Id
) = E_Constant
then
2817 ("cannot import a constant", Arg_Internal
);
2820 if Warn_On_Export_Import
2821 and then Has_Discriminants
(Etype
(Def_Id
))
2824 ("imported value must be initialized?", Arg_Internal
);
2827 if Warn_On_Export_Import
2828 and then Is_Access_Type
(Etype
(Def_Id
))
2831 ("cannot import object of an access type?", Arg_Internal
);
2834 if Warn_On_Export_Import
2835 and then Is_Imported
(Def_Id
)
2838 ("?duplicate Import_Object pragma", N
);
2840 -- Check for explicit initialization present. Note that an
2841 -- initialization that generated by the code generator, e.g.
2842 -- for an access type, does not count here.
2844 elsif Present
(Expression
(Parent
(Def_Id
)))
2847 (Original_Node
(Expression
(Parent
(Def_Id
))))
2849 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2851 ("imported entities cannot be initialized (RM B.1(24))",
2852 "\no initialization allowed for & declared#", Arg1
);
2854 Set_Imported
(Def_Id
);
2855 Note_Possible_Modification
(Arg_Internal
, Sure
=> False);
2858 end Process_Extended_Import_Export_Object_Pragma
;
2860 ------------------------------------------------------
2861 -- Process_Extended_Import_Export_Subprogram_Pragma --
2862 ------------------------------------------------------
2864 procedure Process_Extended_Import_Export_Subprogram_Pragma
2865 (Arg_Internal
: Node_Id
;
2866 Arg_External
: Node_Id
;
2867 Arg_Parameter_Types
: Node_Id
;
2868 Arg_Result_Type
: Node_Id
:= Empty
;
2869 Arg_Mechanism
: Node_Id
;
2870 Arg_Result_Mechanism
: Node_Id
:= Empty
;
2871 Arg_First_Optional_Parameter
: Node_Id
:= Empty
)
2877 Ambiguous
: Boolean;
2881 function Same_Base_Type
2883 Formal
: Entity_Id
) return Boolean;
2884 -- Determines if Ptype references the type of Formal. Note that only
2885 -- the base types need to match according to the spec. Ptype here is
2886 -- the argument from the pragma, which is either a type name, or an
2887 -- access attribute.
2889 --------------------
2890 -- Same_Base_Type --
2891 --------------------
2893 function Same_Base_Type
2895 Formal
: Entity_Id
) return Boolean
2897 Ftyp
: constant Entity_Id
:= Base_Type
(Etype
(Formal
));
2901 -- Case where pragma argument is typ'Access
2903 if Nkind
(Ptype
) = N_Attribute_Reference
2904 and then Attribute_Name
(Ptype
) = Name_Access
2906 Pref
:= Prefix
(Ptype
);
2909 if not Is_Entity_Name
(Pref
)
2910 or else Entity
(Pref
) = Any_Type
2915 -- We have a match if the corresponding argument is of an
2916 -- anonymous access type, and its designated type matches the
2917 -- type of the prefix of the access attribute
2919 return Ekind
(Ftyp
) = E_Anonymous_Access_Type
2920 and then Base_Type
(Entity
(Pref
)) =
2921 Base_Type
(Etype
(Designated_Type
(Ftyp
)));
2923 -- Case where pragma argument is a type name
2928 if not Is_Entity_Name
(Ptype
)
2929 or else Entity
(Ptype
) = Any_Type
2934 -- We have a match if the corresponding argument is of the type
2935 -- given in the pragma (comparing base types)
2937 return Base_Type
(Entity
(Ptype
)) = Ftyp
;
2941 -- Start of processing for
2942 -- Process_Extended_Import_Export_Subprogram_Pragma
2945 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2949 -- Loop through homonyms (overloadings) of the entity
2951 Hom_Id
:= Entity
(Arg_Internal
);
2952 while Present
(Hom_Id
) loop
2953 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
2955 -- We need a subprogram in the current scope
2957 if not Is_Subprogram
(Def_Id
)
2958 or else Scope
(Def_Id
) /= Current_Scope
2965 -- Pragma cannot apply to subprogram body
2967 if Is_Subprogram
(Def_Id
)
2968 and then Nkind
(Parent
(Declaration_Node
(Def_Id
))) =
2972 ("pragma% requires separate spec"
2973 & " and must come before body");
2976 -- Test result type if given, note that the result type
2977 -- parameter can only be present for the function cases.
2979 if Present
(Arg_Result_Type
)
2980 and then not Same_Base_Type
(Arg_Result_Type
, Def_Id
)
2984 elsif Etype
(Def_Id
) /= Standard_Void_Type
2986 (Pname
= Name_Export_Procedure
2988 Pname
= Name_Import_Procedure
)
2992 -- Test parameter types if given. Note that this parameter
2993 -- has not been analyzed (and must not be, since it is
2994 -- semantic nonsense), so we get it as the parser left it.
2996 elsif Present
(Arg_Parameter_Types
) then
2997 Check_Matching_Types
: declare
3002 Formal
:= First_Formal
(Def_Id
);
3004 if Nkind
(Arg_Parameter_Types
) = N_Null
then
3005 if Present
(Formal
) then
3009 -- A list of one type, e.g. (List) is parsed as
3010 -- a parenthesized expression.
3012 elsif Nkind
(Arg_Parameter_Types
) /= N_Aggregate
3013 and then Paren_Count
(Arg_Parameter_Types
) = 1
3016 or else Present
(Next_Formal
(Formal
))
3021 Same_Base_Type
(Arg_Parameter_Types
, Formal
);
3024 -- A list of more than one type is parsed as a aggregate
3026 elsif Nkind
(Arg_Parameter_Types
) = N_Aggregate
3027 and then Paren_Count
(Arg_Parameter_Types
) = 0
3029 Ptype
:= First
(Expressions
(Arg_Parameter_Types
));
3030 while Present
(Ptype
) or else Present
(Formal
) loop
3033 or else not Same_Base_Type
(Ptype
, Formal
)
3038 Next_Formal
(Formal
);
3043 -- Anything else is of the wrong form
3047 ("wrong form for Parameter_Types parameter",
3048 Arg_Parameter_Types
);
3050 end Check_Matching_Types
;
3053 -- Match is now False if the entry we found did not match
3054 -- either a supplied Parameter_Types or Result_Types argument
3060 -- Ambiguous case, the flag Ambiguous shows if we already
3061 -- detected this and output the initial messages.
3064 if not Ambiguous
then
3066 Error_Msg_Name_1
:= Pname
;
3068 ("pragma% does not uniquely identify subprogram!",
3070 Error_Msg_Sloc
:= Sloc
(Ent
);
3071 Error_Msg_N
("matching subprogram #!", N
);
3075 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3076 Error_Msg_N
("matching subprogram #!", N
);
3081 Hom_Id
:= Homonym
(Hom_Id
);
3084 -- See if we found an entry
3087 if not Ambiguous
then
3088 if Is_Generic_Subprogram
(Entity
(Arg_Internal
)) then
3090 ("pragma% cannot be given for generic subprogram");
3093 ("pragma% does not identify local subprogram");
3100 -- Import pragmas must be for imported entities
3102 if Prag_Id
= Pragma_Import_Function
3104 Prag_Id
= Pragma_Import_Procedure
3106 Prag_Id
= Pragma_Import_Valued_Procedure
3108 if not Is_Imported
(Ent
) then
3109 Error_Pragma
-- CODEFIX???
3110 ("pragma Import or Interface must precede pragma%");
3113 -- Here we have the Export case which can set the entity as exported
3115 -- But does not do so if the specified external name is null, since
3116 -- that is taken as a signal in DEC Ada 83 (with which we want to be
3117 -- compatible) to request no external name.
3119 elsif Nkind
(Arg_External
) = N_String_Literal
3120 and then String_Length
(Strval
(Arg_External
)) = 0
3124 -- In all other cases, set entity as exported
3127 Set_Exported
(Ent
, Arg_Internal
);
3130 -- Special processing for Valued_Procedure cases
3132 if Prag_Id
= Pragma_Import_Valued_Procedure
3134 Prag_Id
= Pragma_Export_Valued_Procedure
3136 Formal
:= First_Formal
(Ent
);
3140 ("at least one parameter required for pragma%");
3142 elsif Ekind
(Formal
) /= E_Out_Parameter
then
3144 ("first parameter must have mode out for pragma%");
3147 Set_Is_Valued_Procedure
(Ent
);
3151 Set_Extended_Import_Export_External_Name
(Ent
, Arg_External
);
3153 -- Process Result_Mechanism argument if present. We have already
3154 -- checked that this is only allowed for the function case.
3156 if Present
(Arg_Result_Mechanism
) then
3157 Set_Mechanism_Value
(Ent
, Arg_Result_Mechanism
);
3160 -- Process Mechanism parameter if present. Note that this parameter
3161 -- is not analyzed, and must not be analyzed since it is semantic
3162 -- nonsense, so we get it in exactly as the parser left it.
3164 if Present
(Arg_Mechanism
) then
3172 -- A single mechanism association without a formal parameter
3173 -- name is parsed as a parenthesized expression. All other
3174 -- cases are parsed as aggregates, so we rewrite the single
3175 -- parameter case as an aggregate for consistency.
3177 if Nkind
(Arg_Mechanism
) /= N_Aggregate
3178 and then Paren_Count
(Arg_Mechanism
) = 1
3180 Rewrite
(Arg_Mechanism
,
3181 Make_Aggregate
(Sloc
(Arg_Mechanism
),
3182 Expressions
=> New_List
(
3183 Relocate_Node
(Arg_Mechanism
))));
3186 -- Case of only mechanism name given, applies to all formals
3188 if Nkind
(Arg_Mechanism
) /= N_Aggregate
then
3189 Formal
:= First_Formal
(Ent
);
3190 while Present
(Formal
) loop
3191 Set_Mechanism_Value
(Formal
, Arg_Mechanism
);
3192 Next_Formal
(Formal
);
3195 -- Case of list of mechanism associations given
3198 if Null_Record_Present
(Arg_Mechanism
) then
3200 ("inappropriate form for Mechanism parameter",
3204 -- Deal with positional ones first
3206 Formal
:= First_Formal
(Ent
);
3208 if Present
(Expressions
(Arg_Mechanism
)) then
3209 Mname
:= First
(Expressions
(Arg_Mechanism
));
3210 while Present
(Mname
) loop
3213 ("too many mechanism associations", Mname
);
3216 Set_Mechanism_Value
(Formal
, Mname
);
3217 Next_Formal
(Formal
);
3222 -- Deal with named entries
3224 if Present
(Component_Associations
(Arg_Mechanism
)) then
3225 Massoc
:= First
(Component_Associations
(Arg_Mechanism
));
3226 while Present
(Massoc
) loop
3227 Choice
:= First
(Choices
(Massoc
));
3229 if Nkind
(Choice
) /= N_Identifier
3230 or else Present
(Next
(Choice
))
3233 ("incorrect form for mechanism association",
3237 Formal
:= First_Formal
(Ent
);
3241 ("parameter name & not present", Choice
);
3244 if Chars
(Choice
) = Chars
(Formal
) then
3246 (Formal
, Expression
(Massoc
));
3248 -- Set entity on identifier for ASIS
3250 Set_Entity
(Choice
, Formal
);
3255 Next_Formal
(Formal
);
3265 -- Process First_Optional_Parameter argument if present. We have
3266 -- already checked that this is only allowed for the Import case.
3268 if Present
(Arg_First_Optional_Parameter
) then
3269 if Nkind
(Arg_First_Optional_Parameter
) /= N_Identifier
then
3271 ("first optional parameter must be formal parameter name",
3272 Arg_First_Optional_Parameter
);
3275 Formal
:= First_Formal
(Ent
);
3279 ("specified formal parameter& not found",
3280 Arg_First_Optional_Parameter
);
3283 exit when Chars
(Formal
) =
3284 Chars
(Arg_First_Optional_Parameter
);
3286 Next_Formal
(Formal
);
3289 Set_First_Optional_Parameter
(Ent
, Formal
);
3291 -- Check specified and all remaining formals have right form
3293 while Present
(Formal
) loop
3294 if Ekind
(Formal
) /= E_In_Parameter
then
3296 ("optional formal& is not of mode in!",
3297 Arg_First_Optional_Parameter
, Formal
);
3300 Dval
:= Default_Value
(Formal
);
3304 ("optional formal& does not have default value!",
3305 Arg_First_Optional_Parameter
, Formal
);
3307 elsif Compile_Time_Known_Value_Or_Aggr
(Dval
) then
3312 ("default value for optional formal& is non-static!",
3313 Arg_First_Optional_Parameter
, Formal
);
3317 Set_Is_Optional_Parameter
(Formal
);
3318 Next_Formal
(Formal
);
3321 end Process_Extended_Import_Export_Subprogram_Pragma
;
3323 --------------------------
3324 -- Process_Generic_List --
3325 --------------------------
3327 procedure Process_Generic_List
is
3332 Check_No_Identifiers
;
3333 Check_At_Least_N_Arguments
(1);
3336 while Present
(Arg
) loop
3337 Exp
:= Expression
(Arg
);
3340 if not Is_Entity_Name
(Exp
)
3342 (not Is_Generic_Instance
(Entity
(Exp
))
3344 not Is_Generic_Unit
(Entity
(Exp
)))
3347 ("pragma% argument must be name of generic unit/instance",
3353 end Process_Generic_List
;
3355 ---------------------------------
3356 -- Process_Import_Or_Interface --
3357 ---------------------------------
3359 procedure Process_Import_Or_Interface
is
3365 Process_Convention
(C
, Def_Id
);
3366 Kill_Size_Check_Code
(Def_Id
);
3367 Note_Possible_Modification
(Expression
(Arg2
), Sure
=> False);
3369 if Ekind
(Def_Id
) = E_Variable
3371 Ekind
(Def_Id
) = E_Constant
3373 -- We do not permit Import to apply to a renaming declaration
3375 if Present
(Renamed_Object
(Def_Id
)) then
3377 ("pragma% not allowed for object renaming", Arg2
);
3379 -- User initialization is not allowed for imported object, but
3380 -- the object declaration may contain a default initialization,
3381 -- that will be discarded. Note that an explicit initialization
3382 -- only counts if it comes from source, otherwise it is simply
3383 -- the code generator making an implicit initialization explicit.
3385 elsif Present
(Expression
(Parent
(Def_Id
)))
3386 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
3388 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3390 ("no initialization allowed for declaration of& #",
3391 "\imported entities cannot be initialized (RM B.1(24))",
3395 Set_Imported
(Def_Id
);
3396 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3398 -- Note that we do not set Is_Public here. That's because we
3399 -- only want to set it if there is no address clause, and we
3400 -- don't know that yet, so we delay that processing till
3403 -- pragma Import completes deferred constants
3405 if Ekind
(Def_Id
) = E_Constant
then
3406 Set_Has_Completion
(Def_Id
);
3409 -- It is not possible to import a constant of an unconstrained
3410 -- array type (e.g. string) because there is no simple way to
3411 -- write a meaningful subtype for it.
3413 if Is_Array_Type
(Etype
(Def_Id
))
3414 and then not Is_Constrained
(Etype
(Def_Id
))
3417 ("imported constant& must have a constrained subtype",
3422 elsif Is_Subprogram
(Def_Id
)
3423 or else Is_Generic_Subprogram
(Def_Id
)
3425 -- If the name is overloaded, pragma applies to all of the
3426 -- denoted entities in the same declarative part.
3429 while Present
(Hom_Id
) loop
3430 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
3432 -- Ignore inherited subprograms because the pragma will
3433 -- apply to the parent operation, which is the one called.
3435 if Is_Overloadable
(Def_Id
)
3436 and then Present
(Alias
(Def_Id
))
3440 -- If it is not a subprogram, it must be in an outer scope and
3441 -- pragma does not apply.
3443 elsif not Is_Subprogram
(Def_Id
)
3444 and then not Is_Generic_Subprogram
(Def_Id
)
3448 -- Verify that the homonym is in the same declarative part (not
3449 -- just the same scope).
3451 elsif Parent
(Unit_Declaration_Node
(Def_Id
)) /= Parent
(N
)
3452 and then Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
3457 Set_Imported
(Def_Id
);
3459 -- Special processing for Convention_Intrinsic
3461 if C
= Convention_Intrinsic
then
3463 -- Link_Name argument not allowed for intrinsic
3466 and then Chars
(Arg3
) = Name_Link_Name
3471 if Present
(Arg4
) then
3473 ("Link_Name argument not allowed for " &
3478 Set_Is_Intrinsic_Subprogram
(Def_Id
);
3480 -- If no external name is present, then check that this
3481 -- is a valid intrinsic subprogram. If an external name
3482 -- is present, then this is handled by the back end.
3485 Check_Intrinsic_Subprogram
(Def_Id
, Expression
(Arg2
));
3489 -- All interfaced procedures need an external symbol created
3490 -- for them since they are always referenced from another
3493 Set_Is_Public
(Def_Id
);
3495 -- Verify that the subprogram does not have a completion
3496 -- through a renaming declaration. For other completions the
3497 -- pragma appears as a too late representation.
3500 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Def_Id
);
3504 and then Nkind
(Decl
) = N_Subprogram_Declaration
3505 and then Present
(Corresponding_Body
(Decl
))
3506 and then Nkind
(Unit_Declaration_Node
3507 (Corresponding_Body
(Decl
))) =
3508 N_Subprogram_Renaming_Declaration
3510 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3512 ("cannot import&, renaming already provided for " &
3513 "declaration #", N
, Def_Id
);
3517 Set_Has_Completion
(Def_Id
);
3518 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3521 if Is_Compilation_Unit
(Hom_Id
) then
3523 -- Its possible homonyms are not affected by the pragma.
3524 -- Such homonyms might be present in the context of other
3525 -- units being compiled.
3530 Hom_Id
:= Homonym
(Hom_Id
);
3534 -- When the convention is Java or CIL, we also allow Import to be
3535 -- given for packages, generic packages, exceptions, record
3536 -- components, and access to subprograms.
3538 elsif (C
= Convention_Java
or else C
= Convention_CIL
)
3540 (Is_Package_Or_Generic_Package
(Def_Id
)
3541 or else Ekind
(Def_Id
) = E_Exception
3542 or else Ekind
(Def_Id
) = E_Access_Subprogram_Type
3543 or else Nkind
(Parent
(Def_Id
)) = N_Component_Declaration
)
3545 Set_Imported
(Def_Id
);
3546 Set_Is_Public
(Def_Id
);
3547 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3549 -- Import a CPP class
3551 elsif Is_Record_Type
(Def_Id
)
3552 and then C
= Convention_CPP
3554 if not Is_Tagged_Type
(Def_Id
) then
3555 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3556 Error_Pragma_Arg
("imported 'C'P'P type must be tagged", Arg2
);
3559 -- Types treated as CPP classes are treated as limited, but we
3560 -- don't require them to be declared this way. A warning is
3561 -- issued to encourage the user to declare them as limited.
3562 -- This is not an error, for compatibility reasons, because
3563 -- these types have been supported this way for some time.
3565 if not Is_Limited_Type
(Def_Id
) then
3567 ("imported 'C'P'P type should be " &
3568 "explicitly declared limited?",
3569 Get_Pragma_Arg
(Arg2
));
3571 ("\type will be considered limited",
3572 Get_Pragma_Arg
(Arg2
));
3575 Set_Is_CPP_Class
(Def_Id
);
3576 Set_Is_Limited_Record
(Def_Id
);
3578 -- Imported CPP types must not have discriminants (because C++
3579 -- classes do not have discriminants).
3581 if Has_Discriminants
(Def_Id
) then
3583 ("imported 'C'P'P type cannot have discriminants",
3584 First
(Discriminant_Specifications
3585 (Declaration_Node
(Def_Id
))));
3588 -- Components of imported CPP types must not have default
3589 -- expressions because the constructor (if any) is in the
3593 Tdef
: constant Node_Id
:=
3594 Type_Definition
(Declaration_Node
(Def_Id
));
3599 if Nkind
(Tdef
) = N_Record_Definition
then
3600 Clist
:= Component_List
(Tdef
);
3603 pragma Assert
(Nkind
(Tdef
) = N_Derived_Type_Definition
);
3604 Clist
:= Component_List
(Record_Extension_Part
(Tdef
));
3607 if Present
(Clist
) then
3608 Comp
:= First
(Component_Items
(Clist
));
3609 while Present
(Comp
) loop
3610 if Present
(Expression
(Comp
)) then
3612 ("component of imported 'C'P'P type cannot have" &
3613 " default expression", Expression
(Comp
));
3624 ("second argument of pragma% must be object or subprogram",
3628 -- If this pragma applies to a compilation unit, then the unit, which
3629 -- is a subprogram, does not require (or allow) a body. We also do
3630 -- not need to elaborate imported procedures.
3632 if Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
3634 Cunit
: constant Node_Id
:= Parent
(Parent
(N
));
3636 Set_Body_Required
(Cunit
, False);
3639 end Process_Import_Or_Interface
;
3641 --------------------
3642 -- Process_Inline --
3643 --------------------
3645 procedure Process_Inline
(Active
: Boolean) is
3651 Effective
: Boolean := False;
3653 procedure Make_Inline
(Subp
: Entity_Id
);
3654 -- Subp is the defining unit name of the subprogram declaration. Set
3655 -- the flag, as well as the flag in the corresponding body, if there
3658 procedure Set_Inline_Flags
(Subp
: Entity_Id
);
3659 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp and also
3660 -- Has_Pragma_Inline_Always for the Inline_Always case.
3662 function Inlining_Not_Possible
(Subp
: Entity_Id
) return Boolean;
3663 -- Returns True if it can be determined at this stage that inlining
3664 -- is not possible, for example if the body is available and contains
3665 -- exception handlers, we prevent inlining, since otherwise we can
3666 -- get undefined symbols at link time. This function also emits a
3667 -- warning if front-end inlining is enabled and the pragma appears
3670 -- ??? is business with link symbols still valid, or does it relate
3671 -- to front end ZCX which is being phased out ???
3673 ---------------------------
3674 -- Inlining_Not_Possible --
3675 ---------------------------
3677 function Inlining_Not_Possible
(Subp
: Entity_Id
) return Boolean is
3678 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Subp
);
3682 if Nkind
(Decl
) = N_Subprogram_Body
then
3683 Stats
:= Handled_Statement_Sequence
(Decl
);
3684 return Present
(Exception_Handlers
(Stats
))
3685 or else Present
(At_End_Proc
(Stats
));
3687 elsif Nkind
(Decl
) = N_Subprogram_Declaration
3688 and then Present
(Corresponding_Body
(Decl
))
3690 if Front_End_Inlining
3691 and then Analyzed
(Corresponding_Body
(Decl
))
3693 Error_Msg_N
("pragma appears too late, ignored?", N
);
3696 -- If the subprogram is a renaming as body, the body is just a
3697 -- call to the renamed subprogram, and inlining is trivially
3701 Nkind
(Unit_Declaration_Node
(Corresponding_Body
(Decl
))) =
3702 N_Subprogram_Renaming_Declaration
3708 Handled_Statement_Sequence
3709 (Unit_Declaration_Node
(Corresponding_Body
(Decl
)));
3712 Present
(Exception_Handlers
(Stats
))
3713 or else Present
(At_End_Proc
(Stats
));
3717 -- If body is not available, assume the best, the check is
3718 -- performed again when compiling enclosing package bodies.
3722 end Inlining_Not_Possible
;
3728 procedure Make_Inline
(Subp
: Entity_Id
) is
3729 Kind
: constant Entity_Kind
:= Ekind
(Subp
);
3730 Inner_Subp
: Entity_Id
:= Subp
;
3733 -- Ignore if bad type, avoid cascaded error
3735 if Etype
(Subp
) = Any_Type
then
3739 -- Ignore if all inlining is suppressed
3741 elsif Suppress_All_Inlining
then
3745 -- If inlining is not possible, for now do not treat as an error
3747 elsif Inlining_Not_Possible
(Subp
) then
3751 -- Here we have a candidate for inlining, but we must exclude
3752 -- derived operations. Otherwise we would end up trying to inline
3753 -- a phantom declaration, and the result would be to drag in a
3754 -- body which has no direct inlining associated with it. That
3755 -- would not only be inefficient but would also result in the
3756 -- backend doing cross-unit inlining in cases where it was
3757 -- definitely inappropriate to do so.
3759 -- However, a simple Comes_From_Source test is insufficient, since
3760 -- we do want to allow inlining of generic instances which also do
3761 -- not come from source. We also need to recognize specs generated
3762 -- by the front-end for bodies that carry the pragma. Finally,
3763 -- predefined operators do not come from source but are not
3764 -- inlineable either.
3766 elsif Is_Generic_Instance
(Subp
)
3767 or else Nkind
(Parent
(Parent
(Subp
))) = N_Subprogram_Declaration
3771 elsif not Comes_From_Source
(Subp
)
3772 and then Scope
(Subp
) /= Standard_Standard
3778 -- The referenced entity must either be the enclosing entity, or
3779 -- an entity declared within the current open scope.
3781 if Present
(Scope
(Subp
))
3782 and then Scope
(Subp
) /= Current_Scope
3783 and then Subp
/= Current_Scope
3786 ("argument of% must be entity in current scope", Assoc
);
3790 -- Processing for procedure, operator or function. If subprogram
3791 -- is aliased (as for an instance) indicate that the renamed
3792 -- entity (if declared in the same unit) is inlined.
3794 if Is_Subprogram
(Subp
) then
3795 while Present
(Alias
(Inner_Subp
)) loop
3796 Inner_Subp
:= Alias
(Inner_Subp
);
3799 if In_Same_Source_Unit
(Subp
, Inner_Subp
) then
3800 Set_Inline_Flags
(Inner_Subp
);
3802 Decl
:= Parent
(Parent
(Inner_Subp
));
3804 if Nkind
(Decl
) = N_Subprogram_Declaration
3805 and then Present
(Corresponding_Body
(Decl
))
3807 Set_Inline_Flags
(Corresponding_Body
(Decl
));
3809 elsif Is_Generic_Instance
(Subp
) then
3811 -- Indicate that the body needs to be created for
3812 -- inlining subsequent calls. The instantiation node
3813 -- follows the declaration of the wrapper package
3816 if Scope
(Subp
) /= Standard_Standard
3818 Need_Subprogram_Instance_Body
3819 (Next
(Unit_Declaration_Node
(Scope
(Alias
(Subp
)))),
3829 -- For a generic subprogram set flag as well, for use at the point
3830 -- of instantiation, to determine whether the body should be
3833 elsif Is_Generic_Subprogram
(Subp
) then
3834 Set_Inline_Flags
(Subp
);
3837 -- Literals are by definition inlined
3839 elsif Kind
= E_Enumeration_Literal
then
3842 -- Anything else is an error
3846 ("expect subprogram name for pragma%", Assoc
);
3850 ----------------------
3851 -- Set_Inline_Flags --
3852 ----------------------
3854 procedure Set_Inline_Flags
(Subp
: Entity_Id
) is
3857 Set_Is_Inlined
(Subp
, True);
3860 if not Has_Pragma_Inline
(Subp
) then
3861 Set_Has_Pragma_Inline
(Subp
);
3865 if Prag_Id
= Pragma_Inline_Always
then
3866 Set_Has_Pragma_Inline_Always
(Subp
);
3868 end Set_Inline_Flags
;
3870 -- Start of processing for Process_Inline
3873 Check_No_Identifiers
;
3874 Check_At_Least_N_Arguments
(1);
3877 Inline_Processing_Required
:= True;
3881 while Present
(Assoc
) loop
3882 Subp_Id
:= Expression
(Assoc
);
3886 if Is_Entity_Name
(Subp_Id
) then
3887 Subp
:= Entity
(Subp_Id
);
3889 if Subp
= Any_Id
then
3891 -- If previous error, avoid cascaded errors
3899 while Present
(Homonym
(Subp
))
3900 and then Scope
(Homonym
(Subp
)) = Current_Scope
3902 Make_Inline
(Homonym
(Subp
));
3903 Subp
:= Homonym
(Subp
);
3910 ("inappropriate argument for pragma%", Assoc
);
3913 and then Warn_On_Redundant_Constructs
3914 and then not Suppress_All_Inlining
3916 if Inlining_Not_Possible
(Subp
) then
3918 ("pragma Inline for& is ignored?", N
, Entity
(Subp_Id
));
3921 ("pragma Inline for& is redundant?", N
, Entity
(Subp_Id
));
3929 ----------------------------
3930 -- Process_Interface_Name --
3931 ----------------------------
3933 procedure Process_Interface_Name
3934 (Subprogram_Def
: Entity_Id
;
3940 String_Val
: String_Id
;
3942 procedure Check_Form_Of_Interface_Name
3944 Ext_Name_Case
: Boolean);
3945 -- SN is a string literal node for an interface name. This routine
3946 -- performs some minimal checks that the name is reasonable. In
3947 -- particular that no spaces or other obviously incorrect characters
3948 -- appear. This is only a warning, since any characters are allowed.
3949 -- Ext_Name_Case is True for an External_Name, False for a Link_Name.
3951 ----------------------------------
3952 -- Check_Form_Of_Interface_Name --
3953 ----------------------------------
3955 procedure Check_Form_Of_Interface_Name
3957 Ext_Name_Case
: Boolean)
3959 S
: constant String_Id
:= Strval
(Expr_Value_S
(SN
));
3960 SL
: constant Nat
:= String_Length
(S
);
3965 Error_Msg_N
("interface name cannot be null string", SN
);
3968 for J
in 1 .. SL
loop
3969 C
:= Get_String_Char
(S
, J
);
3971 -- Look for dubious character and issue unconditional warning.
3972 -- Definitely dubious if not in character range.
3974 if not In_Character_Range
(C
)
3976 -- For all cases except CLI target,
3977 -- commas, spaces and slashes are dubious (in CLI, we use
3978 -- commas and backslashes in external names to specify
3979 -- assembly version and public key, while slashes and spaces
3980 -- can be used in names to mark nested classes and
3983 or else ((not Ext_Name_Case
or else VM_Target
/= CLI_Target
)
3984 and then (Get_Character
(C
) = ','
3986 Get_Character
(C
) = '\'))
3987 or else (VM_Target
/= CLI_Target
3988 and then (Get_Character
(C
) = ' '
3990 Get_Character
(C
) = '/'))
3993 ("?interface name contains illegal character",
3994 Sloc
(SN
) + Source_Ptr
(J
));
3997 end Check_Form_Of_Interface_Name
;
3999 -- Start of processing for Process_Interface_Name
4002 if No
(Link_Arg
) then
4003 if No
(Ext_Arg
) then
4004 if VM_Target
= CLI_Target
4005 and then Ekind
(Subprogram_Def
) = E_Package
4006 and then Nkind
(Parent
(Subprogram_Def
)) =
4007 N_Package_Specification
4008 and then Present
(Generic_Parent
(Parent
(Subprogram_Def
)))
4013 (Generic_Parent
(Parent
(Subprogram_Def
))));
4018 elsif Chars
(Ext_Arg
) = Name_Link_Name
then
4020 Link_Nam
:= Expression
(Ext_Arg
);
4023 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
4024 Ext_Nam
:= Expression
(Ext_Arg
);
4029 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
4030 Check_Optional_Identifier
(Link_Arg
, Name_Link_Name
);
4031 Ext_Nam
:= Expression
(Ext_Arg
);
4032 Link_Nam
:= Expression
(Link_Arg
);
4035 -- Check expressions for external name and link name are static
4037 if Present
(Ext_Nam
) then
4038 Check_Arg_Is_Static_Expression
(Ext_Nam
, Standard_String
);
4039 Check_Form_Of_Interface_Name
(Ext_Nam
, Ext_Name_Case
=> True);
4041 -- Verify that external name is not the name of a local entity,
4042 -- which would hide the imported one and could lead to run-time
4043 -- surprises. The problem can only arise for entities declared in
4044 -- a package body (otherwise the external name is fully qualified
4045 -- and will not conflict).
4053 if Prag_Id
= Pragma_Import
then
4054 String_To_Name_Buffer
(Strval
(Expr_Value_S
(Ext_Nam
)));
4056 E
:= Entity_Id
(Get_Name_Table_Info
(Nam
));
4058 if Nam
/= Chars
(Subprogram_Def
)
4059 and then Present
(E
)
4060 and then not Is_Overloadable
(E
)
4061 and then Is_Immediately_Visible
(E
)
4062 and then not Is_Imported
(E
)
4063 and then Ekind
(Scope
(E
)) = E_Package
4066 while Present
(Par
) loop
4067 if Nkind
(Par
) = N_Package_Body
then
4068 Error_Msg_Sloc
:= Sloc
(E
);
4070 ("imported entity is hidden by & declared#",
4075 Par
:= Parent
(Par
);
4082 if Present
(Link_Nam
) then
4083 Check_Arg_Is_Static_Expression
(Link_Nam
, Standard_String
);
4084 Check_Form_Of_Interface_Name
(Link_Nam
, Ext_Name_Case
=> False);
4087 -- If there is no link name, just set the external name
4089 if No
(Link_Nam
) then
4090 Link_Nam
:= Adjust_External_Name_Case
(Expr_Value_S
(Ext_Nam
));
4092 -- For the Link_Name case, the given literal is preceded by an
4093 -- asterisk, which indicates to GCC that the given name should be
4094 -- taken literally, and in particular that no prepending of
4095 -- underlines should occur, even in systems where this is the
4101 if VM_Target
= No_VM
then
4102 Store_String_Char
(Get_Char_Code
('*'));
4105 String_Val
:= Strval
(Expr_Value_S
(Link_Nam
));
4106 Store_String_Chars
(String_Val
);
4108 Make_String_Literal
(Sloc
(Link_Nam
),
4109 Strval
=> End_String
);
4112 Set_Encoded_Interface_Name
4113 (Get_Base_Subprogram
(Subprogram_Def
), Link_Nam
);
4114 Check_Duplicated_Export_Name
(Link_Nam
);
4115 end Process_Interface_Name
;
4117 -----------------------------------------
4118 -- Process_Interrupt_Or_Attach_Handler --
4119 -----------------------------------------
4121 procedure Process_Interrupt_Or_Attach_Handler
is
4122 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
4123 Handler_Proc
: constant Entity_Id
:= Entity
(Arg1_X
);
4124 Proc_Scope
: constant Entity_Id
:= Scope
(Handler_Proc
);
4127 Set_Is_Interrupt_Handler
(Handler_Proc
);
4129 -- If the pragma is not associated with a handler procedure within a
4130 -- protected type, then it must be for a nonprotected procedure for
4131 -- the AAMP target, in which case we don't associate a representation
4132 -- item with the procedure's scope.
4134 if Ekind
(Proc_Scope
) = E_Protected_Type
then
4135 if Prag_Id
= Pragma_Interrupt_Handler
4137 Prag_Id
= Pragma_Attach_Handler
4139 Record_Rep_Item
(Proc_Scope
, N
);
4142 end Process_Interrupt_Or_Attach_Handler
;
4144 --------------------------------------------------
4145 -- Process_Restrictions_Or_Restriction_Warnings --
4146 --------------------------------------------------
4148 -- Note: some of the simple identifier cases were handled in par-prag,
4149 -- but it is harmless (and more straightforward) to simply handle all
4150 -- cases here, even if it means we repeat a bit of work in some cases.
4152 procedure Process_Restrictions_Or_Restriction_Warnings
4156 R_Id
: Restriction_Id
;
4161 procedure Check_Unit_Name
(N
: Node_Id
);
4162 -- Checks unit name parameter for No_Dependence. Returns if it has
4163 -- an appropriate form, otherwise raises pragma argument error.
4165 ---------------------
4166 -- Check_Unit_Name --
4167 ---------------------
4169 procedure Check_Unit_Name
(N
: Node_Id
) is
4171 if Nkind
(N
) = N_Selected_Component
then
4172 Check_Unit_Name
(Prefix
(N
));
4173 Check_Unit_Name
(Selector_Name
(N
));
4175 elsif Nkind
(N
) = N_Identifier
then
4180 ("wrong form for unit name for No_Dependence", N
);
4182 end Check_Unit_Name
;
4184 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
4187 Check_Ada_83_Warning
;
4188 Check_At_Least_N_Arguments
(1);
4189 Check_Valid_Configuration_Pragma
;
4192 while Present
(Arg
) loop
4194 Expr
:= Expression
(Arg
);
4196 -- Case of no restriction identifier present
4198 if Id
= No_Name
then
4199 if Nkind
(Expr
) /= N_Identifier
then
4201 ("invalid form for restriction", Arg
);
4206 (Process_Restriction_Synonyms
(Expr
));
4208 if R_Id
not in All_Boolean_Restrictions
then
4209 Error_Msg_Name_1
:= Pname
;
4211 ("invalid restriction identifier&", Get_Pragma_Arg
(Arg
));
4213 -- Check for possible misspelling
4215 for J
in Restriction_Id
loop
4217 Rnm
: constant String := Restriction_Id
'Image (J
);
4220 Name_Buffer
(1 .. Rnm
'Length) := Rnm
;
4221 Name_Len
:= Rnm
'Length;
4222 Set_Casing
(All_Lower_Case
);
4224 if Is_Bad_Spelling_Of
(Chars
(Expr
), Name_Enter
) then
4226 (Identifier_Casing
(Current_Source_File
));
4227 Error_Msg_String
(1 .. Rnm
'Length) :=
4228 Name_Buffer
(1 .. Name_Len
);
4229 Error_Msg_Strlen
:= Rnm
'Length;
4230 Error_Msg_N
-- CODEFIX
4231 ("\possible misspelling of ""~""",
4232 Get_Pragma_Arg
(Arg
));
4241 if Implementation_Restriction
(R_Id
) then
4242 Check_Restriction
(No_Implementation_Restrictions
, Arg
);
4245 -- If this is a warning, then set the warning unless we already
4246 -- have a real restriction active (we never want a warning to
4247 -- override a real restriction).
4250 if not Restriction_Active
(R_Id
) then
4251 Set_Restriction
(R_Id
, N
);
4252 Restriction_Warnings
(R_Id
) := True;
4255 -- If real restriction case, then set it and make sure that the
4256 -- restriction warning flag is off, since a real restriction
4257 -- always overrides a warning.
4260 Set_Restriction
(R_Id
, N
);
4261 Restriction_Warnings
(R_Id
) := False;
4264 -- A very special case that must be processed here: pragma
4265 -- Restrictions (No_Exceptions) turns off all run-time
4266 -- checking. This is a bit dubious in terms of the formal
4267 -- language definition, but it is what is intended by RM
4268 -- H.4(12). Restriction_Warnings never affects generated code
4269 -- so this is done only in the real restriction case.
4271 if R_Id
= No_Exceptions
and then not Warn
then
4272 Scope_Suppress
:= (others => True);
4275 -- Case of No_Dependence => unit-name. Note that the parser
4276 -- already made the necessary entry in the No_Dependence table.
4278 elsif Id
= Name_No_Dependence
then
4279 Check_Unit_Name
(Expr
);
4281 -- All other cases of restriction identifier present
4284 R_Id
:= Get_Restriction_Id
(Process_Restriction_Synonyms
(Arg
));
4285 Analyze_And_Resolve
(Expr
, Any_Integer
);
4287 if R_Id
not in All_Parameter_Restrictions
then
4289 ("invalid restriction parameter identifier", Arg
);
4291 elsif not Is_OK_Static_Expression
(Expr
) then
4292 Flag_Non_Static_Expr
4293 ("value must be static expression!", Expr
);
4296 elsif not Is_Integer_Type
(Etype
(Expr
))
4297 or else Expr_Value
(Expr
) < 0
4300 ("value must be non-negative integer", Arg
);
4303 -- Restriction pragma is active
4305 Val
:= Expr_Value
(Expr
);
4307 if not UI_Is_In_Int_Range
(Val
) then
4309 ("pragma ignored, value too large?", Arg
);
4312 -- Warning case. If the real restriction is active, then we
4313 -- ignore the request, since warning never overrides a real
4314 -- restriction. Otherwise we set the proper warning. Note that
4315 -- this circuit sets the warning again if it is already set,
4316 -- which is what we want, since the constant may have changed.
4319 if not Restriction_Active
(R_Id
) then
4321 (R_Id
, N
, Integer (UI_To_Int
(Val
)));
4322 Restriction_Warnings
(R_Id
) := True;
4325 -- Real restriction case, set restriction and make sure warning
4326 -- flag is off since real restriction always overrides warning.
4329 Set_Restriction
(R_Id
, N
, Integer (UI_To_Int
(Val
)));
4330 Restriction_Warnings
(R_Id
) := False;
4336 end Process_Restrictions_Or_Restriction_Warnings
;
4338 ---------------------------------
4339 -- Process_Suppress_Unsuppress --
4340 ---------------------------------
4342 -- Note: this procedure makes entries in the check suppress data
4343 -- structures managed by Sem. See spec of package Sem for full
4344 -- details on how we handle recording of check suppression.
4346 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean) is
4351 In_Package_Spec
: constant Boolean :=
4352 Is_Package_Or_Generic_Package
(Current_Scope
)
4353 and then not In_Package_Body
(Current_Scope
);
4355 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
);
4356 -- Used to suppress a single check on the given entity
4358 --------------------------------
4359 -- Suppress_Unsuppress_Echeck --
4360 --------------------------------
4362 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
) is
4364 Set_Checks_May_Be_Suppressed
(E
);
4366 if In_Package_Spec
then
4367 Push_Global_Suppress_Stack_Entry
4370 Suppress
=> Suppress_Case
);
4373 Push_Local_Suppress_Stack_Entry
4376 Suppress
=> Suppress_Case
);
4379 -- If this is a first subtype, and the base type is distinct,
4380 -- then also set the suppress flags on the base type.
4382 if Is_First_Subtype
(E
)
4383 and then Etype
(E
) /= E
4385 Suppress_Unsuppress_Echeck
(Etype
(E
), C
);
4387 end Suppress_Unsuppress_Echeck
;
4389 -- Start of processing for Process_Suppress_Unsuppress
4392 -- Suppress/Unsuppress can appear as a configuration pragma, or in a
4393 -- declarative part or a package spec (RM 11.5(5)).
4395 if not Is_Configuration_Pragma
then
4396 Check_Is_In_Decl_Part_Or_Package_Spec
;
4399 Check_At_Least_N_Arguments
(1);
4400 Check_At_Most_N_Arguments
(2);
4401 Check_No_Identifier
(Arg1
);
4402 Check_Arg_Is_Identifier
(Arg1
);
4404 C
:= Get_Check_Id
(Chars
(Expression
(Arg1
)));
4406 if C
= No_Check_Id
then
4408 ("argument of pragma% is not valid check name", Arg1
);
4411 if not Suppress_Case
4412 and then (C
= All_Checks
or else C
= Overflow_Check
)
4414 Opt
.Overflow_Checks_Unsuppressed
:= True;
4417 if Arg_Count
= 1 then
4419 -- Make an entry in the local scope suppress table. This is the
4420 -- table that directly shows the current value of the scope
4421 -- suppress check for any check id value.
4423 if C
= All_Checks
then
4425 -- For All_Checks, we set all specific predefined checks with
4426 -- the exception of Elaboration_Check, which is handled
4427 -- specially because of not wanting All_Checks to have the
4428 -- effect of deactivating static elaboration order processing.
4430 for J
in Scope_Suppress
'Range loop
4431 if J
/= Elaboration_Check
then
4432 Scope_Suppress
(J
) := Suppress_Case
;
4436 -- If not All_Checks, and predefined check, then set appropriate
4437 -- scope entry. Note that we will set Elaboration_Check if this
4438 -- is explicitly specified.
4440 elsif C
in Predefined_Check_Id
then
4441 Scope_Suppress
(C
) := Suppress_Case
;
4444 -- Also make an entry in the Local_Entity_Suppress table
4446 Push_Local_Suppress_Stack_Entry
4449 Suppress
=> Suppress_Case
);
4451 -- Case of two arguments present, where the check is suppressed for
4452 -- a specified entity (given as the second argument of the pragma)
4455 Check_Optional_Identifier
(Arg2
, Name_On
);
4456 E_Id
:= Expression
(Arg2
);
4459 if not Is_Entity_Name
(E_Id
) then
4461 ("second argument of pragma% must be entity name", Arg2
);
4470 -- Enforce RM 11.5(7) which requires that for a pragma that
4471 -- appears within a package spec, the named entity must be
4472 -- within the package spec. We allow the package name itself
4473 -- to be mentioned since that makes sense, although it is not
4474 -- strictly allowed by 11.5(7).
4477 and then E
/= Current_Scope
4478 and then Scope
(E
) /= Current_Scope
4481 ("entity in pragma% is not in package spec (RM 11.5(7))",
4485 -- Loop through homonyms. As noted below, in the case of a package
4486 -- spec, only homonyms within the package spec are considered.
4489 Suppress_Unsuppress_Echeck
(E
, C
);
4491 if Is_Generic_Instance
(E
)
4492 and then Is_Subprogram
(E
)
4493 and then Present
(Alias
(E
))
4495 Suppress_Unsuppress_Echeck
(Alias
(E
), C
);
4498 -- Move to next homonym
4503 -- If we are within a package specification, the pragma only
4504 -- applies to homonyms in the same scope.
4506 exit when In_Package_Spec
4507 and then Scope
(E
) /= Current_Scope
;
4510 end Process_Suppress_Unsuppress
;
4516 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
) is
4518 if Is_Imported
(E
) then
4520 ("cannot export entity& that was previously imported", Arg
);
4522 elsif Present
(Address_Clause
(E
)) then
4524 ("cannot export entity& that has an address clause", Arg
);
4527 Set_Is_Exported
(E
);
4529 -- Generate a reference for entity explicitly, because the
4530 -- identifier may be overloaded and name resolution will not
4533 Generate_Reference
(E
, Arg
);
4535 -- Deal with exporting non-library level entity
4537 if not Is_Library_Level_Entity
(E
) then
4539 -- Not allowed at all for subprograms
4541 if Is_Subprogram
(E
) then
4542 Error_Pragma_Arg
("local subprogram& cannot be exported", Arg
);
4544 -- Otherwise set public and statically allocated
4548 Set_Is_Statically_Allocated
(E
);
4550 -- Warn if the corresponding W flag is set and the pragma comes
4551 -- from source. The latter may not be true e.g. on VMS where we
4552 -- expand export pragmas for exception codes associated with
4553 -- imported or exported exceptions. We do not want to generate
4554 -- a warning for something that the user did not write.
4556 if Warn_On_Export_Import
4557 and then Comes_From_Source
(Arg
)
4560 ("?& has been made static as a result of Export", Arg
, E
);
4562 ("\this usage is non-standard and non-portable", Arg
);
4567 if Warn_On_Export_Import
and then Is_Type
(E
) then
4569 ("exporting a type has no effect?", Arg
, E
);
4572 if Warn_On_Export_Import
and Inside_A_Generic
then
4574 ("all instances of& will have the same external name?", Arg
, E
);
4578 ----------------------------------------------
4579 -- Set_Extended_Import_Export_External_Name --
4580 ----------------------------------------------
4582 procedure Set_Extended_Import_Export_External_Name
4583 (Internal_Ent
: Entity_Id
;
4584 Arg_External
: Node_Id
)
4586 Old_Name
: constant Node_Id
:= Interface_Name
(Internal_Ent
);
4590 if No
(Arg_External
) then
4594 Check_Arg_Is_External_Name
(Arg_External
);
4596 if Nkind
(Arg_External
) = N_String_Literal
then
4597 if String_Length
(Strval
(Arg_External
)) = 0 then
4600 New_Name
:= Adjust_External_Name_Case
(Arg_External
);
4603 elsif Nkind
(Arg_External
) = N_Identifier
then
4604 New_Name
:= Get_Default_External_Name
(Arg_External
);
4606 -- Check_Arg_Is_External_Name should let through only identifiers and
4607 -- string literals or static string expressions (which are folded to
4608 -- string literals).
4611 raise Program_Error
;
4614 -- If we already have an external name set (by a prior normal Import
4615 -- or Export pragma), then the external names must match
4617 if Present
(Interface_Name
(Internal_Ent
)) then
4618 Check_Matching_Internal_Names
: declare
4619 S1
: constant String_Id
:= Strval
(Old_Name
);
4620 S2
: constant String_Id
:= Strval
(New_Name
);
4623 -- Called if names do not match
4629 procedure Mismatch
is
4631 Error_Msg_Sloc
:= Sloc
(Old_Name
);
4633 ("external name does not match that given #",
4637 -- Start of processing for Check_Matching_Internal_Names
4640 if String_Length
(S1
) /= String_Length
(S2
) then
4644 for J
in 1 .. String_Length
(S1
) loop
4645 if Get_String_Char
(S1
, J
) /= Get_String_Char
(S2
, J
) then
4650 end Check_Matching_Internal_Names
;
4652 -- Otherwise set the given name
4655 Set_Encoded_Interface_Name
(Internal_Ent
, New_Name
);
4656 Check_Duplicated_Export_Name
(New_Name
);
4658 end Set_Extended_Import_Export_External_Name
;
4664 procedure Set_Imported
(E
: Entity_Id
) is
4666 -- Error message if already imported or exported
4668 if Is_Exported
(E
) or else Is_Imported
(E
) then
4669 if Is_Exported
(E
) then
4670 Error_Msg_NE
("entity& was previously exported", N
, E
);
4672 Error_Msg_NE
("entity& was previously imported", N
, E
);
4675 Error_Msg_Name_1
:= Pname
;
4677 ("\(pragma% applies to all previous entities)", N
);
4679 Error_Msg_Sloc
:= Sloc
(E
);
4680 Error_Msg_NE
("\import not allowed for& declared#", N
, E
);
4682 -- Here if not previously imported or exported, OK to import
4685 Set_Is_Imported
(E
);
4687 -- If the entity is an object that is not at the library level,
4688 -- then it is statically allocated. We do not worry about objects
4689 -- with address clauses in this context since they are not really
4690 -- imported in the linker sense.
4693 and then not Is_Library_Level_Entity
(E
)
4694 and then No
(Address_Clause
(E
))
4696 Set_Is_Statically_Allocated
(E
);
4701 -------------------------
4702 -- Set_Mechanism_Value --
4703 -------------------------
4705 -- Note: the mechanism name has not been analyzed (and cannot indeed be
4706 -- analyzed, since it is semantic nonsense), so we get it in the exact
4707 -- form created by the parser.
4709 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
) is
4712 Mech_Name_Id
: Name_Id
;
4714 procedure Bad_Class
;
4715 -- Signal bad descriptor class name
4717 procedure Bad_Mechanism
;
4718 -- Signal bad mechanism name
4724 procedure Bad_Class
is
4726 Error_Pragma_Arg
("unrecognized descriptor class name", Class
);
4729 -------------------------
4730 -- Bad_Mechanism_Value --
4731 -------------------------
4733 procedure Bad_Mechanism
is
4735 Error_Pragma_Arg
("unrecognized mechanism name", Mech_Name
);
4738 -- Start of processing for Set_Mechanism_Value
4741 if Mechanism
(Ent
) /= Default_Mechanism
then
4743 ("mechanism for & has already been set", Mech_Name
, Ent
);
4746 -- MECHANISM_NAME ::= value | reference | descriptor |
4749 if Nkind
(Mech_Name
) = N_Identifier
then
4750 if Chars
(Mech_Name
) = Name_Value
then
4751 Set_Mechanism
(Ent
, By_Copy
);
4754 elsif Chars
(Mech_Name
) = Name_Reference
then
4755 Set_Mechanism
(Ent
, By_Reference
);
4758 elsif Chars
(Mech_Name
) = Name_Descriptor
then
4759 Check_VMS
(Mech_Name
);
4760 Set_Mechanism
(Ent
, By_Descriptor
);
4763 elsif Chars
(Mech_Name
) = Name_Short_Descriptor
then
4764 Check_VMS
(Mech_Name
);
4765 Set_Mechanism
(Ent
, By_Short_Descriptor
);
4768 elsif Chars
(Mech_Name
) = Name_Copy
then
4770 ("bad mechanism name, Value assumed", Mech_Name
);
4776 -- MECHANISM_NAME ::= descriptor (CLASS_NAME) |
4777 -- short_descriptor (CLASS_NAME)
4778 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4780 -- Note: this form is parsed as an indexed component
4782 elsif Nkind
(Mech_Name
) = N_Indexed_Component
then
4784 Class
:= First
(Expressions
(Mech_Name
));
4786 if Nkind
(Prefix
(Mech_Name
)) /= N_Identifier
4787 or else not (Chars
(Prefix
(Mech_Name
)) = Name_Descriptor
or else
4788 Chars
(Prefix
(Mech_Name
)) = Name_Short_Descriptor
)
4789 or else Present
(Next
(Class
))
4793 Mech_Name_Id
:= Chars
(Prefix
(Mech_Name
));
4796 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME) |
4797 -- short_descriptor (Class => CLASS_NAME)
4798 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4800 -- Note: this form is parsed as a function call
4802 elsif Nkind
(Mech_Name
) = N_Function_Call
then
4804 Param
:= First
(Parameter_Associations
(Mech_Name
));
4806 if Nkind
(Name
(Mech_Name
)) /= N_Identifier
4807 or else not (Chars
(Name
(Mech_Name
)) = Name_Descriptor
or else
4808 Chars
(Name
(Mech_Name
)) = Name_Short_Descriptor
)
4809 or else Present
(Next
(Param
))
4810 or else No
(Selector_Name
(Param
))
4811 or else Chars
(Selector_Name
(Param
)) /= Name_Class
4815 Class
:= Explicit_Actual_Parameter
(Param
);
4816 Mech_Name_Id
:= Chars
(Name
(Mech_Name
));
4823 -- Fall through here with Class set to descriptor class name
4825 Check_VMS
(Mech_Name
);
4827 if Nkind
(Class
) /= N_Identifier
then
4830 elsif Mech_Name_Id
= Name_Descriptor
4831 and then Chars
(Class
) = Name_UBS
4833 Set_Mechanism
(Ent
, By_Descriptor_UBS
);
4835 elsif Mech_Name_Id
= Name_Descriptor
4836 and then Chars
(Class
) = Name_UBSB
4838 Set_Mechanism
(Ent
, By_Descriptor_UBSB
);
4840 elsif Mech_Name_Id
= Name_Descriptor
4841 and then Chars
(Class
) = Name_UBA
4843 Set_Mechanism
(Ent
, By_Descriptor_UBA
);
4845 elsif Mech_Name_Id
= Name_Descriptor
4846 and then Chars
(Class
) = Name_S
4848 Set_Mechanism
(Ent
, By_Descriptor_S
);
4850 elsif Mech_Name_Id
= Name_Descriptor
4851 and then Chars
(Class
) = Name_SB
4853 Set_Mechanism
(Ent
, By_Descriptor_SB
);
4855 elsif Mech_Name_Id
= Name_Descriptor
4856 and then Chars
(Class
) = Name_A
4858 Set_Mechanism
(Ent
, By_Descriptor_A
);
4860 elsif Mech_Name_Id
= Name_Descriptor
4861 and then Chars
(Class
) = Name_NCA
4863 Set_Mechanism
(Ent
, By_Descriptor_NCA
);
4865 elsif Mech_Name_Id
= Name_Short_Descriptor
4866 and then Chars
(Class
) = Name_UBS
4868 Set_Mechanism
(Ent
, By_Short_Descriptor_UBS
);
4870 elsif Mech_Name_Id
= Name_Short_Descriptor
4871 and then Chars
(Class
) = Name_UBSB
4873 Set_Mechanism
(Ent
, By_Short_Descriptor_UBSB
);
4875 elsif Mech_Name_Id
= Name_Short_Descriptor
4876 and then Chars
(Class
) = Name_UBA
4878 Set_Mechanism
(Ent
, By_Short_Descriptor_UBA
);
4880 elsif Mech_Name_Id
= Name_Short_Descriptor
4881 and then Chars
(Class
) = Name_S
4883 Set_Mechanism
(Ent
, By_Short_Descriptor_S
);
4885 elsif Mech_Name_Id
= Name_Short_Descriptor
4886 and then Chars
(Class
) = Name_SB
4888 Set_Mechanism
(Ent
, By_Short_Descriptor_SB
);
4890 elsif Mech_Name_Id
= Name_Short_Descriptor
4891 and then Chars
(Class
) = Name_A
4893 Set_Mechanism
(Ent
, By_Short_Descriptor_A
);
4895 elsif Mech_Name_Id
= Name_Short_Descriptor
4896 and then Chars
(Class
) = Name_NCA
4898 Set_Mechanism
(Ent
, By_Short_Descriptor_NCA
);
4903 end Set_Mechanism_Value
;
4905 ---------------------------
4906 -- Set_Ravenscar_Profile --
4907 ---------------------------
4909 -- The tasks to be done here are
4911 -- Set required policies
4913 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4914 -- pragma Locking_Policy (Ceiling_Locking)
4916 -- Set Detect_Blocking mode
4918 -- Set required restrictions (see System.Rident for detailed list)
4920 procedure Set_Ravenscar_Profile
(N
: Node_Id
) is
4922 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4924 if Task_Dispatching_Policy
/= ' '
4925 and then Task_Dispatching_Policy
/= 'F'
4927 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
4928 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4930 -- Set the FIFO_Within_Priorities policy, but always preserve
4931 -- System_Location since we like the error message with the run time
4935 Task_Dispatching_Policy
:= 'F';
4937 if Task_Dispatching_Policy_Sloc
/= System_Location
then
4938 Task_Dispatching_Policy_Sloc
:= Loc
;
4942 -- pragma Locking_Policy (Ceiling_Locking)
4944 if Locking_Policy
/= ' '
4945 and then Locking_Policy
/= 'C'
4947 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
4948 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4950 -- Set the Ceiling_Locking policy, but preserve System_Location since
4951 -- we like the error message with the run time name.
4954 Locking_Policy
:= 'C';
4956 if Locking_Policy_Sloc
/= System_Location
then
4957 Locking_Policy_Sloc
:= Loc
;
4961 -- pragma Detect_Blocking
4963 Detect_Blocking
:= True;
4965 -- Set the corresponding restrictions
4967 Set_Profile_Restrictions
4968 (Ravenscar
, N
, Warn
=> Treat_Restrictions_As_Warnings
);
4969 end Set_Ravenscar_Profile
;
4971 -- Start of processing for Analyze_Pragma
4974 -- Deal with unrecognized pragma
4976 if not Is_Pragma_Name
(Pname
) then
4977 if Warn_On_Unrecognized_Pragma
then
4978 Error_Msg_Name_1
:= Pname
;
4979 Error_Msg_N
("?unrecognized pragma%!", Pragma_Identifier
(N
));
4981 for PN
in First_Pragma_Name
.. Last_Pragma_Name
loop
4982 if Is_Bad_Spelling_Of
(Pname
, PN
) then
4983 Error_Msg_Name_1
:= PN
;
4984 Error_Msg_N
-- CODEFIX
4985 ("\?possible misspelling of %!", Pragma_Identifier
(N
));
4994 -- Here to start processing for recognized pragma
4996 Prag_Id
:= Get_Pragma_Id
(Pname
);
5005 if Present
(Pragma_Argument_Associations
(N
)) then
5006 Arg1
:= First
(Pragma_Argument_Associations
(N
));
5008 if Present
(Arg1
) then
5009 Arg2
:= Next
(Arg1
);
5011 if Present
(Arg2
) then
5012 Arg3
:= Next
(Arg2
);
5014 if Present
(Arg3
) then
5015 Arg4
:= Next
(Arg3
);
5021 -- Count number of arguments
5028 while Present
(Arg_Node
) loop
5029 Arg_Count
:= Arg_Count
+ 1;
5034 -- An enumeration type defines the pragmas that are supported by the
5035 -- implementation. Get_Pragma_Id (in package Prag) transforms a name
5036 -- into the corresponding enumeration value for the following case.
5044 -- pragma Abort_Defer;
5046 when Pragma_Abort_Defer
=>
5048 Check_Arg_Count
(0);
5050 -- The only required semantic processing is to check the
5051 -- placement. This pragma must appear at the start of the
5052 -- statement sequence of a handled sequence of statements.
5054 if Nkind
(Parent
(N
)) /= N_Handled_Sequence_Of_Statements
5055 or else N
/= First
(Statements
(Parent
(N
)))
5066 -- Note: this pragma also has some specific processing in Par.Prag
5067 -- because we want to set the Ada version mode during parsing.
5069 when Pragma_Ada_83
=>
5071 Check_Arg_Count
(0);
5073 -- We really should check unconditionally for proper configuration
5074 -- pragma placement, since we really don't want mixed Ada modes
5075 -- within a single unit, and the GNAT reference manual has always
5076 -- said this was a configuration pragma, but we did not check and
5077 -- are hesitant to add the check now.
5079 -- However, we really cannot tolerate mixing Ada 2005 with Ada 83
5080 -- or Ada 95, so we must check if we are in Ada 2005 mode.
5082 if Ada_Version
>= Ada_05
then
5083 Check_Valid_Configuration_Pragma
;
5086 -- Now set Ada 83 mode
5088 Ada_Version
:= Ada_83
;
5089 Ada_Version_Explicit
:= Ada_Version
;
5097 -- Note: this pragma also has some specific processing in Par.Prag
5098 -- because we want to set the Ada 83 version mode during parsing.
5100 when Pragma_Ada_95
=>
5102 Check_Arg_Count
(0);
5104 -- We really should check unconditionally for proper configuration
5105 -- pragma placement, since we really don't want mixed Ada modes
5106 -- within a single unit, and the GNAT reference manual has always
5107 -- said this was a configuration pragma, but we did not check and
5108 -- are hesitant to add the check now.
5110 -- However, we really cannot tolerate mixing Ada 2005 with Ada 83
5111 -- or Ada 95, so we must check if we are in Ada 2005 mode.
5113 if Ada_Version
>= Ada_05
then
5114 Check_Valid_Configuration_Pragma
;
5117 -- Now set Ada 95 mode
5119 Ada_Version
:= Ada_95
;
5120 Ada_Version_Explicit
:= Ada_Version
;
5122 ---------------------
5123 -- Ada_05/Ada_2005 --
5124 ---------------------
5127 -- pragma Ada_05 (LOCAL_NAME);
5130 -- pragma Ada_2005 (LOCAL_NAME):
5132 -- Note: these pragma also have some specific processing in Par.Prag
5133 -- because we want to set the Ada 2005 version mode during parsing.
5135 when Pragma_Ada_05 | Pragma_Ada_2005
=> declare
5141 if Arg_Count
= 1 then
5142 Check_Arg_Is_Local_Name
(Arg1
);
5143 E_Id
:= Expression
(Arg1
);
5145 if Etype
(E_Id
) = Any_Type
then
5149 Set_Is_Ada_2005_Only
(Entity
(E_Id
));
5152 Check_Arg_Count
(0);
5154 -- For Ada_2005 we unconditionally enforce the documented
5155 -- configuration pragma placement, since we do not want to
5156 -- tolerate mixed modes in a unit involving Ada 2005. That
5157 -- would cause real difficulties for those cases where there
5158 -- are incompatibilities between Ada 95 and Ada 2005.
5160 Check_Valid_Configuration_Pragma
;
5162 -- Now set Ada 2005 mode
5164 Ada_Version
:= Ada_05
;
5165 Ada_Version_Explicit
:= Ada_05
;
5169 ----------------------
5170 -- All_Calls_Remote --
5171 ----------------------
5173 -- pragma All_Calls_Remote [(library_package_NAME)];
5175 when Pragma_All_Calls_Remote
=> All_Calls_Remote
: declare
5176 Lib_Entity
: Entity_Id
;
5179 Check_Ada_83_Warning
;
5180 Check_Valid_Library_Unit_Pragma
;
5182 if Nkind
(N
) = N_Null_Statement
then
5186 Lib_Entity
:= Find_Lib_Unit_Name
;
5188 -- This pragma should only apply to a RCI unit (RM E.2.3(23))
5190 if Present
(Lib_Entity
)
5191 and then not Debug_Flag_U
5193 if not Is_Remote_Call_Interface
(Lib_Entity
) then
5194 Error_Pragma
("pragma% only apply to rci unit");
5196 -- Set flag for entity of the library unit
5199 Set_Has_All_Calls_Remote
(Lib_Entity
);
5203 end All_Calls_Remote
;
5209 -- pragma Annotate (IDENTIFIER {, ARG});
5210 -- ARG ::= NAME | EXPRESSION
5212 when Pragma_Annotate
=> Annotate
: begin
5214 Check_At_Least_N_Arguments
(1);
5215 Check_Arg_Is_Identifier
(Arg1
);
5223 while Present
(Arg
) loop
5224 Exp
:= Expression
(Arg
);
5227 if Is_Entity_Name
(Exp
) then
5230 elsif Nkind
(Exp
) = N_String_Literal
then
5231 Resolve
(Exp
, Standard_String
);
5233 elsif Is_Overloaded
(Exp
) then
5234 Error_Pragma_Arg
("ambiguous argument for pragma%", Exp
);
5249 -- pragma Assert ([Check =>] Boolean_EXPRESSION
5250 -- [, [Message =>] Static_String_EXPRESSION]);
5252 when Pragma_Assert
=> Assert
: declare
5258 Check_At_Least_N_Arguments
(1);
5259 Check_At_Most_N_Arguments
(2);
5260 Check_Arg_Order
((Name_Check
, Name_Message
));
5261 Check_Optional_Identifier
(Arg1
, Name_Check
);
5263 -- We treat pragma Assert as equivalent to:
5265 -- pragma Check (Assertion, condition [, msg]);
5267 -- So rewrite pragma in this manner, and analyze the result
5269 Expr
:= Get_Pragma_Arg
(Arg1
);
5271 Make_Pragma_Argument_Association
(Loc
,
5273 Make_Identifier
(Loc
,
5274 Chars
=> Name_Assertion
)),
5276 Make_Pragma_Argument_Association
(Sloc
(Expr
),
5277 Expression
=> Expr
));
5279 if Arg_Count
> 1 then
5280 Check_Optional_Identifier
(Arg2
, Name_Message
);
5281 Analyze_And_Resolve
(Get_Pragma_Arg
(Arg2
), Standard_String
);
5282 Append_To
(Newa
, Relocate_Node
(Arg2
));
5287 Chars
=> Name_Check
,
5288 Pragma_Argument_Associations
=> Newa
));
5292 ----------------------
5293 -- Assertion_Policy --
5294 ----------------------
5296 -- pragma Assertion_Policy (Check | Ignore)
5298 when Pragma_Assertion_Policy
=> Assertion_Policy
: declare
5303 Check_Valid_Configuration_Pragma
;
5304 Check_Arg_Count
(1);
5305 Check_No_Identifiers
;
5306 Check_Arg_Is_One_Of
(Arg1
, Name_Check
, Name_Ignore
);
5308 -- We treat pragma Assertion_Policy as equivalent to:
5310 -- pragma Check_Policy (Assertion, policy)
5312 -- So rewrite the pragma in that manner and link on to the chain
5313 -- of Check_Policy pragmas, marking the pragma as analyzed.
5315 Policy
:= Get_Pragma_Arg
(Arg1
);
5319 Chars
=> Name_Check_Policy
,
5321 Pragma_Argument_Associations
=> New_List
(
5322 Make_Pragma_Argument_Association
(Loc
,
5324 Make_Identifier
(Loc
,
5325 Chars
=> Name_Assertion
)),
5327 Make_Pragma_Argument_Association
(Loc
,
5329 Make_Identifier
(Sloc
(Policy
),
5330 Chars
=> Chars
(Policy
))))));
5333 Set_Next_Pragma
(N
, Opt
.Check_Policy_List
);
5334 Opt
.Check_Policy_List
:= N
;
5335 end Assertion_Policy
;
5337 ------------------------------
5338 -- Assume_No_Invalid_Values --
5339 ------------------------------
5341 -- pragma Assume_No_Invalid_Values (On | Off);
5343 when Pragma_Assume_No_Invalid_Values
=>
5345 Check_Valid_Configuration_Pragma
;
5346 Check_Arg_Count
(1);
5347 Check_No_Identifiers
;
5348 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
5350 if Chars
(Expression
(Arg1
)) = Name_On
then
5351 Assume_No_Invalid_Values
:= True;
5353 Assume_No_Invalid_Values
:= False;
5360 -- pragma AST_Entry (entry_IDENTIFIER);
5362 when Pragma_AST_Entry
=> AST_Entry
: declare
5368 Check_Arg_Count
(1);
5369 Check_No_Identifiers
;
5370 Check_Arg_Is_Local_Name
(Arg1
);
5371 Ent
:= Entity
(Expression
(Arg1
));
5373 -- Note: the implementation of the AST_Entry pragma could handle
5374 -- the entry family case fine, but for now we are consistent with
5375 -- the DEC rules, and do not allow the pragma, which of course
5376 -- has the effect of also forbidding the attribute.
5378 if Ekind
(Ent
) /= E_Entry
then
5380 ("pragma% argument must be simple entry name", Arg1
);
5382 elsif Is_AST_Entry
(Ent
) then
5384 ("duplicate % pragma for entry", Arg1
);
5386 elsif Has_Homonym
(Ent
) then
5388 ("pragma% argument cannot specify overloaded entry", Arg1
);
5392 FF
: constant Entity_Id
:= First_Formal
(Ent
);
5395 if Present
(FF
) then
5396 if Present
(Next_Formal
(FF
)) then
5398 ("entry for pragma% can have only one argument",
5401 elsif Parameter_Mode
(FF
) /= E_In_Parameter
then
5403 ("entry parameter for pragma% must have mode IN",
5409 Set_Is_AST_Entry
(Ent
);
5417 -- pragma Asynchronous (LOCAL_NAME);
5419 when Pragma_Asynchronous
=> Asynchronous
: declare
5427 procedure Process_Async_Pragma
;
5428 -- Common processing for procedure and access-to-procedure case
5430 --------------------------
5431 -- Process_Async_Pragma --
5432 --------------------------
5434 procedure Process_Async_Pragma
is
5437 Set_Is_Asynchronous
(Nm
);
5441 -- The formals should be of mode IN (RM E.4.1(6))
5444 while Present
(S
) loop
5445 Formal
:= Defining_Identifier
(S
);
5447 if Nkind
(Formal
) = N_Defining_Identifier
5448 and then Ekind
(Formal
) /= E_In_Parameter
5451 ("pragma% procedure can only have IN parameter",
5458 Set_Is_Asynchronous
(Nm
);
5459 end Process_Async_Pragma
;
5461 -- Start of processing for pragma Asynchronous
5464 Check_Ada_83_Warning
;
5465 Check_No_Identifiers
;
5466 Check_Arg_Count
(1);
5467 Check_Arg_Is_Local_Name
(Arg1
);
5469 if Debug_Flag_U
then
5473 C_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
5474 Analyze
(Expression
(Arg1
));
5475 Nm
:= Entity
(Expression
(Arg1
));
5477 if not Is_Remote_Call_Interface
(C_Ent
)
5478 and then not Is_Remote_Types
(C_Ent
)
5480 -- This pragma should only appear in an RCI or Remote Types
5481 -- unit (RM E.4.1(4)).
5484 ("pragma% not in Remote_Call_Interface or " &
5485 "Remote_Types unit");
5488 if Ekind
(Nm
) = E_Procedure
5489 and then Nkind
(Parent
(Nm
)) = N_Procedure_Specification
5491 if not Is_Remote_Call_Interface
(Nm
) then
5493 ("pragma% cannot be applied on non-remote procedure",
5497 L
:= Parameter_Specifications
(Parent
(Nm
));
5498 Process_Async_Pragma
;
5501 elsif Ekind
(Nm
) = E_Function
then
5503 ("pragma% cannot be applied to function", Arg1
);
5505 elsif Is_Remote_Access_To_Subprogram_Type
(Nm
) then
5507 if Is_Record_Type
(Nm
) then
5509 -- A record type that is the Equivalent_Type for a remote
5510 -- access-to-subprogram type.
5512 N
:= Declaration_Node
(Corresponding_Remote_Type
(Nm
));
5515 -- A non-expanded RAS type (distribution is not enabled)
5517 N
:= Declaration_Node
(Nm
);
5520 if Nkind
(N
) = N_Full_Type_Declaration
5521 and then Nkind
(Type_Definition
(N
)) =
5522 N_Access_Procedure_Definition
5524 L
:= Parameter_Specifications
(Type_Definition
(N
));
5525 Process_Async_Pragma
;
5527 if Is_Asynchronous
(Nm
)
5528 and then Expander_Active
5529 and then Get_PCS_Name
/= Name_No_DSA
5531 RACW_Type_Is_Asynchronous
(Underlying_RACW_Type
(Nm
));
5536 ("pragma% cannot reference access-to-function type",
5540 -- Only other possibility is Access-to-class-wide type
5542 elsif Is_Access_Type
(Nm
)
5543 and then Is_Class_Wide_Type
(Designated_Type
(Nm
))
5545 Check_First_Subtype
(Arg1
);
5546 Set_Is_Asynchronous
(Nm
);
5547 if Expander_Active
then
5548 RACW_Type_Is_Asynchronous
(Nm
);
5552 Error_Pragma_Arg
("inappropriate argument for pragma%", Arg1
);
5560 -- pragma Atomic (LOCAL_NAME);
5562 when Pragma_Atomic
=>
5563 Process_Atomic_Shared_Volatile
;
5565 -----------------------
5566 -- Atomic_Components --
5567 -----------------------
5569 -- pragma Atomic_Components (array_LOCAL_NAME);
5571 -- This processing is shared by Volatile_Components
5573 when Pragma_Atomic_Components |
5574 Pragma_Volatile_Components
=>
5576 Atomic_Components
: declare
5583 Check_Ada_83_Warning
;
5584 Check_No_Identifiers
;
5585 Check_Arg_Count
(1);
5586 Check_Arg_Is_Local_Name
(Arg1
);
5587 E_Id
:= Expression
(Arg1
);
5589 if Etype
(E_Id
) = Any_Type
then
5595 if Rep_Item_Too_Early
(E
, N
)
5597 Rep_Item_Too_Late
(E
, N
)
5602 D
:= Declaration_Node
(E
);
5605 if (K
= N_Full_Type_Declaration
and then Is_Array_Type
(E
))
5607 ((Ekind
(E
) = E_Constant
or else Ekind
(E
) = E_Variable
)
5608 and then Nkind
(D
) = N_Object_Declaration
5609 and then Nkind
(Object_Definition
(D
)) =
5610 N_Constrained_Array_Definition
)
5612 -- The flag is set on the object, or on the base type
5614 if Nkind
(D
) /= N_Object_Declaration
then
5618 Set_Has_Volatile_Components
(E
);
5620 if Prag_Id
= Pragma_Atomic_Components
then
5621 Set_Has_Atomic_Components
(E
);
5623 if Is_Packed
(E
) then
5624 Set_Is_Packed
(E
, False);
5627 ("?Pack canceled, cannot pack atomic components",
5633 Error_Pragma_Arg
("inappropriate entity for pragma%", Arg1
);
5635 end Atomic_Components
;
5637 --------------------
5638 -- Attach_Handler --
5639 --------------------
5641 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
5643 when Pragma_Attach_Handler
=>
5644 Check_Ada_83_Warning
;
5645 Check_No_Identifiers
;
5646 Check_Arg_Count
(2);
5648 if No_Run_Time_Mode
then
5649 Error_Msg_CRT
("Attach_Handler pragma", N
);
5651 Check_Interrupt_Or_Attach_Handler
;
5653 -- The expression that designates the attribute may
5654 -- depend on a discriminant, and is therefore a per-
5655 -- object expression, to be expanded in the init proc.
5656 -- If expansion is enabled, perform semantic checks
5659 if Expander_Active
then
5661 Temp
: constant Node_Id
:=
5662 New_Copy_Tree
(Expression
(Arg2
));
5664 Set_Parent
(Temp
, N
);
5665 Preanalyze_And_Resolve
(Temp
, RTE
(RE_Interrupt_ID
));
5669 Analyze
(Expression
(Arg2
));
5670 Resolve
(Expression
(Arg2
), RTE
(RE_Interrupt_ID
));
5673 Process_Interrupt_Or_Attach_Handler
;
5676 --------------------
5677 -- C_Pass_By_Copy --
5678 --------------------
5680 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
5682 when Pragma_C_Pass_By_Copy
=> C_Pass_By_Copy
: declare
5688 Check_Valid_Configuration_Pragma
;
5689 Check_Arg_Count
(1);
5690 Check_Optional_Identifier
(Arg1
, "max_size");
5692 Arg
:= Expression
(Arg1
);
5693 Check_Arg_Is_Static_Expression
(Arg
, Any_Integer
);
5695 Val
:= Expr_Value
(Arg
);
5699 ("maximum size for pragma% must be positive", Arg1
);
5701 elsif UI_Is_In_Int_Range
(Val
) then
5702 Default_C_Record_Mechanism
:= UI_To_Int
(Val
);
5704 -- If a giant value is given, Int'Last will do well enough.
5705 -- If sometime someone complains that a record larger than
5706 -- two gigabytes is not copied, we will worry about it then!
5709 Default_C_Record_Mechanism
:= Mechanism_Type
'Last;
5717 -- pragma Check ([Name =>] Identifier,
5718 -- [Check =>] Boolean_Expression
5719 -- [,[Message =>] String_Expression]);
5721 when Pragma_Check
=> Check
: declare
5726 -- Set True if category of assertions referenced by Name enabled
5730 Check_At_Least_N_Arguments
(2);
5731 Check_At_Most_N_Arguments
(3);
5732 Check_Optional_Identifier
(Arg1
, Name_Name
);
5733 Check_Optional_Identifier
(Arg2
, Name_Check
);
5735 if Arg_Count
= 3 then
5736 Check_Optional_Identifier
(Arg3
, Name_Message
);
5737 Analyze_And_Resolve
(Get_Pragma_Arg
(Arg3
), Standard_String
);
5740 Check_Arg_Is_Identifier
(Arg1
);
5741 Check_On
:= Check_Enabled
(Chars
(Get_Pragma_Arg
(Arg1
)));
5743 -- If expansion is active and the check is not enabled then we
5744 -- rewrite the Check as:
5746 -- if False and then condition then
5750 -- The reason we do this rewriting during semantic analysis rather
5751 -- than as part of normal expansion is that we cannot analyze and
5752 -- expand the code for the boolean expression directly, or it may
5753 -- cause insertion of actions that would escape the attempt to
5754 -- suppress the check code.
5756 -- Note that the Sloc for the if statement corresponds to the
5757 -- argument condition, not the pragma itself. The reason for this
5758 -- is that we may generate a warning if the condition is False at
5759 -- compile time, and we do not want to delete this warning when we
5760 -- delete the if statement.
5762 Expr
:= Expression
(Arg2
);
5764 if Expander_Active
and then not Check_On
then
5765 Eloc
:= Sloc
(Expr
);
5768 Make_If_Statement
(Eloc
,
5770 Make_And_Then
(Eloc
,
5771 Left_Opnd
=> New_Occurrence_Of
(Standard_False
, Eloc
),
5772 Right_Opnd
=> Expr
),
5773 Then_Statements
=> New_List
(
5774 Make_Null_Statement
(Eloc
))));
5781 Analyze_And_Resolve
(Expr
, Any_Boolean
);
5789 -- pragma Check_Name (check_IDENTIFIER);
5791 when Pragma_Check_Name
=>
5792 Check_No_Identifiers
;
5794 Check_Valid_Configuration_Pragma
;
5795 Check_Arg_Count
(1);
5796 Check_Arg_Is_Identifier
(Arg1
);
5799 Nam
: constant Name_Id
:= Chars
(Expression
(Arg1
));
5802 for J
in Check_Names
.First
.. Check_Names
.Last
loop
5803 if Check_Names
.Table
(J
) = Nam
then
5808 Check_Names
.Append
(Nam
);
5815 -- pragma Check_Policy (
5816 -- [Name =>] IDENTIFIER,
5817 -- [Policy =>] POLICY_IDENTIFIER);
5819 -- POLICY_IDENTIFIER ::= ON | OFF | CHECK | IGNORE
5821 -- Note: this is a configuration pragma, but it is allowed to appear
5824 when Pragma_Check_Policy
=>
5826 Check_Arg_Count
(2);
5827 Check_Optional_Identifier
(Arg1
, Name_Name
);
5828 Check_Optional_Identifier
(Arg2
, Name_Policy
);
5830 (Arg2
, Name_On
, Name_Off
, Name_Check
, Name_Ignore
);
5832 -- A Check_Policy pragma can appear either as a configuration
5833 -- pragma, or in a declarative part or a package spec (see RM
5834 -- 11.5(5) for rules for Suppress/Unsuppress which are also
5835 -- followed for Check_Policy).
5837 if not Is_Configuration_Pragma
then
5838 Check_Is_In_Decl_Part_Or_Package_Spec
;
5841 Set_Next_Pragma
(N
, Opt
.Check_Policy_List
);
5842 Opt
.Check_Policy_List
:= N
;
5844 ---------------------
5845 -- CIL_Constructor --
5846 ---------------------
5848 -- pragma CIL_Constructor ([Entity =>] LOCAL_NAME);
5850 -- Processing for this pragma is shared with Java_Constructor
5856 -- pragma Comment (static_string_EXPRESSION)
5858 -- Processing for pragma Comment shares the circuitry for pragma
5859 -- Ident. The only differences are that Ident enforces a limit of 31
5860 -- characters on its argument, and also enforces limitations on
5861 -- placement for DEC compatibility. Pragma Comment shares neither of
5862 -- these restrictions.
5868 -- pragma Common_Object (
5869 -- [Internal =>] LOCAL_NAME
5870 -- [, [External =>] EXTERNAL_SYMBOL]
5871 -- [, [Size =>] EXTERNAL_SYMBOL]);
5873 -- Processing for this pragma is shared with Psect_Object
5875 ------------------------
5876 -- Compile_Time_Error --
5877 ------------------------
5879 -- pragma Compile_Time_Error
5880 -- (boolean_EXPRESSION, static_string_EXPRESSION);
5882 when Pragma_Compile_Time_Error
=>
5884 Process_Compile_Time_Warning_Or_Error
;
5886 --------------------------
5887 -- Compile_Time_Warning --
5888 --------------------------
5890 -- pragma Compile_Time_Warning
5891 -- (boolean_EXPRESSION, static_string_EXPRESSION);
5893 when Pragma_Compile_Time_Warning
=>
5895 Process_Compile_Time_Warning_Or_Error
;
5901 when Pragma_Compiler_Unit
=>
5903 Check_Arg_Count
(0);
5904 Set_Is_Compiler_Unit
(Get_Source_Unit
(N
));
5906 -----------------------------
5907 -- Complete_Representation --
5908 -----------------------------
5910 -- pragma Complete_Representation;
5912 when Pragma_Complete_Representation
=>
5914 Check_Arg_Count
(0);
5916 if Nkind
(Parent
(N
)) /= N_Record_Representation_Clause
then
5918 ("pragma & must appear within record representation clause");
5921 ----------------------------
5922 -- Complex_Representation --
5923 ----------------------------
5925 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
5927 when Pragma_Complex_Representation
=> Complex_Representation
: declare
5934 Check_Arg_Count
(1);
5935 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5936 Check_Arg_Is_Local_Name
(Arg1
);
5937 E_Id
:= Expression
(Arg1
);
5939 if Etype
(E_Id
) = Any_Type
then
5945 if not Is_Record_Type
(E
) then
5947 ("argument for pragma% must be record type", Arg1
);
5950 Ent
:= First_Entity
(E
);
5953 or else No
(Next_Entity
(Ent
))
5954 or else Present
(Next_Entity
(Next_Entity
(Ent
)))
5955 or else not Is_Floating_Point_Type
(Etype
(Ent
))
5956 or else Etype
(Ent
) /= Etype
(Next_Entity
(Ent
))
5959 ("record for pragma% must have two fields of the same "
5960 & "floating-point type", Arg1
);
5963 Set_Has_Complex_Representation
(Base_Type
(E
));
5965 -- We need to treat the type has having a non-standard
5966 -- representation, for back-end purposes, even though in
5967 -- general a complex will have the default representation
5968 -- of a record with two real components.
5970 Set_Has_Non_Standard_Rep
(Base_Type
(E
));
5972 end Complex_Representation
;
5974 -------------------------
5975 -- Component_Alignment --
5976 -------------------------
5978 -- pragma Component_Alignment (
5979 -- [Form =>] ALIGNMENT_CHOICE
5980 -- [, [Name =>] type_LOCAL_NAME]);
5982 -- ALIGNMENT_CHOICE ::=
5984 -- | Component_Size_4
5988 when Pragma_Component_Alignment
=> Component_AlignmentP
: declare
5989 Args
: Args_List
(1 .. 2);
5990 Names
: constant Name_List
(1 .. 2) := (
5994 Form
: Node_Id
renames Args
(1);
5995 Name
: Node_Id
renames Args
(2);
5997 Atype
: Component_Alignment_Kind
;
6002 Gather_Associations
(Names
, Args
);
6005 Error_Pragma
("missing Form argument for pragma%");
6008 Check_Arg_Is_Identifier
(Form
);
6010 -- Get proper alignment, note that Default = Component_Size on all
6011 -- machines we have so far, and we want to set this value rather
6012 -- than the default value to indicate that it has been explicitly
6013 -- set (and thus will not get overridden by the default component
6014 -- alignment for the current scope)
6016 if Chars
(Form
) = Name_Component_Size
then
6017 Atype
:= Calign_Component_Size
;
6019 elsif Chars
(Form
) = Name_Component_Size_4
then
6020 Atype
:= Calign_Component_Size_4
;
6022 elsif Chars
(Form
) = Name_Default
then
6023 Atype
:= Calign_Component_Size
;
6025 elsif Chars
(Form
) = Name_Storage_Unit
then
6026 Atype
:= Calign_Storage_Unit
;
6030 ("invalid Form parameter for pragma%", Form
);
6033 -- Case with no name, supplied, affects scope table entry
6037 (Scope_Stack
.Last
).Component_Alignment_Default
:= Atype
;
6039 -- Case of name supplied
6042 Check_Arg_Is_Local_Name
(Name
);
6044 Typ
:= Entity
(Name
);
6047 or else Rep_Item_Too_Early
(Typ
, N
)
6051 Typ
:= Underlying_Type
(Typ
);
6054 if not Is_Record_Type
(Typ
)
6055 and then not Is_Array_Type
(Typ
)
6058 ("Name parameter of pragma% must identify record or " &
6059 "array type", Name
);
6062 -- An explicit Component_Alignment pragma overrides an
6063 -- implicit pragma Pack, but not an explicit one.
6065 if not Has_Pragma_Pack
(Base_Type
(Typ
)) then
6066 Set_Is_Packed
(Base_Type
(Typ
), False);
6067 Set_Component_Alignment
(Base_Type
(Typ
), Atype
);
6070 end Component_AlignmentP
;
6076 -- pragma Controlled (first_subtype_LOCAL_NAME);
6078 when Pragma_Controlled
=> Controlled
: declare
6082 Check_No_Identifiers
;
6083 Check_Arg_Count
(1);
6084 Check_Arg_Is_Local_Name
(Arg1
);
6085 Arg
:= Expression
(Arg1
);
6087 if not Is_Entity_Name
(Arg
)
6088 or else not Is_Access_Type
(Entity
(Arg
))
6090 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
6092 Set_Has_Pragma_Controlled
(Base_Type
(Entity
(Arg
)));
6100 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
6101 -- [Entity =>] LOCAL_NAME);
6103 when Pragma_Convention
=> Convention
: declare
6106 pragma Warnings
(Off
, C
);
6107 pragma Warnings
(Off
, E
);
6109 Check_Arg_Order
((Name_Convention
, Name_Entity
));
6110 Check_Ada_83_Warning
;
6111 Check_Arg_Count
(2);
6112 Process_Convention
(C
, E
);
6115 ---------------------------
6116 -- Convention_Identifier --
6117 ---------------------------
6119 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
6120 -- [Convention =>] convention_IDENTIFIER);
6122 when Pragma_Convention_Identifier
=> Convention_Identifier
: declare
6128 Check_Arg_Order
((Name_Name
, Name_Convention
));
6129 Check_Arg_Count
(2);
6130 Check_Optional_Identifier
(Arg1
, Name_Name
);
6131 Check_Optional_Identifier
(Arg2
, Name_Convention
);
6132 Check_Arg_Is_Identifier
(Arg1
);
6133 Check_Arg_Is_Identifier
(Arg2
);
6134 Idnam
:= Chars
(Expression
(Arg1
));
6135 Cname
:= Chars
(Expression
(Arg2
));
6137 if Is_Convention_Name
(Cname
) then
6138 Record_Convention_Identifier
6139 (Idnam
, Get_Convention_Id
(Cname
));
6142 ("second arg for % pragma must be convention", Arg2
);
6144 end Convention_Identifier
;
6150 -- pragma CPP_Class ([Entity =>] local_NAME)
6152 when Pragma_CPP_Class
=> CPP_Class
: declare
6157 if Warn_On_Obsolescent_Feature
then
6159 ("'G'N'A'T pragma cpp'_class is now obsolete; replace it" &
6160 " by pragma import?", N
);
6164 Check_Arg_Count
(1);
6165 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6166 Check_Arg_Is_Local_Name
(Arg1
);
6168 Arg
:= Expression
(Arg1
);
6171 if Etype
(Arg
) = Any_Type
then
6175 if not Is_Entity_Name
(Arg
)
6176 or else not Is_Type
(Entity
(Arg
))
6178 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
6181 Typ
:= Entity
(Arg
);
6183 if not Is_Tagged_Type
(Typ
) then
6184 Error_Pragma_Arg
("pragma% applicable to tagged types ", Arg1
);
6187 -- Types treated as CPP classes are treated as limited, but we
6188 -- don't require them to be declared this way. A warning is issued
6189 -- to encourage the user to declare them as limited. This is not
6190 -- an error, for compatibility reasons, because these types have
6191 -- been supported this way for some time.
6193 if not Is_Limited_Type
(Typ
) then
6195 ("imported 'C'P'P type should be " &
6196 "explicitly declared limited?",
6197 Get_Pragma_Arg
(Arg1
));
6199 ("\type will be considered limited",
6200 Get_Pragma_Arg
(Arg1
));
6203 Set_Is_CPP_Class
(Typ
);
6204 Set_Is_Limited_Record
(Typ
);
6205 Set_Convention
(Typ
, Convention_CPP
);
6207 -- Imported CPP types must not have discriminants (because C++
6208 -- classes do not have discriminants).
6210 if Has_Discriminants
(Typ
) then
6212 ("imported 'C'P'P type cannot have discriminants",
6213 First
(Discriminant_Specifications
6214 (Declaration_Node
(Typ
))));
6217 -- Components of imported CPP types must not have default
6218 -- expressions because the constructor (if any) is in the
6221 if Is_Incomplete_Or_Private_Type
(Typ
)
6222 and then No
(Underlying_Type
(Typ
))
6224 -- It should be an error to apply pragma CPP to a private
6225 -- type if the underlying type is not visible (as it is
6226 -- for any representation item). For now, for backward
6227 -- compatibility we do nothing but we cannot check components
6228 -- because they are not available at this stage. All this code
6229 -- will be removed when we cleanup this obsolete GNAT pragma???
6235 Tdef
: constant Node_Id
:=
6236 Type_Definition
(Declaration_Node
(Typ
));
6241 if Nkind
(Tdef
) = N_Record_Definition
then
6242 Clist
:= Component_List
(Tdef
);
6244 pragma Assert
(Nkind
(Tdef
) = N_Derived_Type_Definition
);
6245 Clist
:= Component_List
(Record_Extension_Part
(Tdef
));
6248 if Present
(Clist
) then
6249 Comp
:= First
(Component_Items
(Clist
));
6250 while Present
(Comp
) loop
6251 if Present
(Expression
(Comp
)) then
6253 ("component of imported 'C'P'P type cannot have" &
6254 " default expression", Expression
(Comp
));
6264 ---------------------
6265 -- CPP_Constructor --
6266 ---------------------
6268 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME
6269 -- [, [External_Name =>] static_string_EXPRESSION ]
6270 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6272 when Pragma_CPP_Constructor
=> CPP_Constructor
: declare
6278 Check_At_Least_N_Arguments
(1);
6279 Check_At_Most_N_Arguments
(3);
6280 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6281 Check_Arg_Is_Local_Name
(Arg1
);
6283 Id
:= Expression
(Arg1
);
6284 Find_Program_Unit_Name
(Id
);
6286 -- If we did not find the name, we are done
6288 if Etype
(Id
) = Any_Type
then
6292 Def_Id
:= Entity
(Id
);
6294 if Ekind
(Def_Id
) = E_Function
6295 and then Is_Class_Wide_Type
(Etype
(Def_Id
))
6296 and then Is_CPP_Class
(Etype
(Etype
(Def_Id
)))
6298 if Arg_Count
>= 2 then
6299 Set_Imported
(Def_Id
);
6300 Set_Is_Public
(Def_Id
);
6301 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
6304 Set_Has_Completion
(Def_Id
);
6305 Set_Is_Constructor
(Def_Id
);
6309 ("pragma% requires function returning a 'C'P'P_Class type",
6312 end CPP_Constructor
;
6318 when Pragma_CPP_Virtual
=> CPP_Virtual
: declare
6322 if Warn_On_Obsolescent_Feature
then
6324 ("'G'N'A'T pragma cpp'_virtual is now obsolete and has " &
6333 when Pragma_CPP_Vtable
=> CPP_Vtable
: declare
6337 if Warn_On_Obsolescent_Feature
then
6339 ("'G'N'A'T pragma cpp'_vtable is now obsolete and has " &
6348 -- pragma Debug ([boolean_EXPRESSION,] PROCEDURE_CALL_STATEMENT);
6350 when Pragma_Debug
=> Debug
: declare
6358 (Boolean_Literals
(Debug_Pragmas_Enabled
and Expander_Active
),
6361 if Arg_Count
= 2 then
6364 Left_Opnd
=> Relocate_Node
(Cond
),
6365 Right_Opnd
=> Expression
(Arg1
));
6368 -- Rewrite into a conditional with an appropriate condition. We
6369 -- wrap the procedure call in a block so that overhead from e.g.
6370 -- use of the secondary stack does not generate execution overhead
6371 -- for suppressed conditions.
6373 Rewrite
(N
, Make_Implicit_If_Statement
(N
,
6375 Then_Statements
=> New_List
(
6376 Make_Block_Statement
(Loc
,
6377 Handled_Statement_Sequence
=>
6378 Make_Handled_Sequence_Of_Statements
(Loc
,
6379 Statements
=> New_List
(
6380 Relocate_Node
(Debug_Statement
(N
))))))));
6388 -- pragma Debug_Policy (Check | Ignore)
6390 when Pragma_Debug_Policy
=>
6392 Check_Arg_Count
(1);
6393 Check_Arg_Is_One_Of
(Arg1
, Name_Check
, Name_Ignore
);
6394 Debug_Pragmas_Enabled
:= Chars
(Expression
(Arg1
)) = Name_Check
;
6396 ---------------------
6397 -- Detect_Blocking --
6398 ---------------------
6400 -- pragma Detect_Blocking;
6402 when Pragma_Detect_Blocking
=>
6404 Check_Arg_Count
(0);
6405 Check_Valid_Configuration_Pragma
;
6406 Detect_Blocking
:= True;
6412 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
6414 when Pragma_Discard_Names
=> Discard_Names
: declare
6419 Check_Ada_83_Warning
;
6421 -- Deal with configuration pragma case
6423 if Arg_Count
= 0 and then Is_Configuration_Pragma
then
6424 Global_Discard_Names
:= True;
6427 -- Otherwise, check correct appropriate context
6430 Check_Is_In_Decl_Part_Or_Package_Spec
;
6432 if Arg_Count
= 0 then
6434 -- If there is no parameter, then from now on this pragma
6435 -- applies to any enumeration, exception or tagged type
6436 -- defined in the current declarative part, and recursively
6437 -- to any nested scope.
6439 Set_Discard_Names
(Current_Scope
);
6443 Check_Arg_Count
(1);
6444 Check_Optional_Identifier
(Arg1
, Name_On
);
6445 Check_Arg_Is_Local_Name
(Arg1
);
6447 E_Id
:= Expression
(Arg1
);
6449 if Etype
(E_Id
) = Any_Type
then
6455 if (Is_First_Subtype
(E
)
6457 (Is_Enumeration_Type
(E
) or else Is_Tagged_Type
(E
)))
6458 or else Ekind
(E
) = E_Exception
6460 Set_Discard_Names
(E
);
6463 ("inappropriate entity for pragma%", Arg1
);
6474 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
6476 when Pragma_Elaborate
=> Elaborate
: declare
6481 -- Pragma must be in context items list of a compilation unit
6483 if not Is_In_Context_Clause
then
6487 -- Must be at least one argument
6489 if Arg_Count
= 0 then
6490 Error_Pragma
("pragma% requires at least one argument");
6493 -- In Ada 83 mode, there can be no items following it in the
6494 -- context list except other pragmas and implicit with clauses
6495 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
6496 -- placement rule does not apply.
6498 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
6500 while Present
(Citem
) loop
6501 if Nkind
(Citem
) = N_Pragma
6502 or else (Nkind
(Citem
) = N_With_Clause
6503 and then Implicit_With
(Citem
))
6508 ("(Ada 83) pragma% must be at end of context clause");
6515 -- Finally, the arguments must all be units mentioned in a with
6516 -- clause in the same context clause. Note we already checked (in
6517 -- Par.Prag) that the arguments are all identifiers or selected
6521 Outer
: while Present
(Arg
) loop
6522 Citem
:= First
(List_Containing
(N
));
6523 Inner
: while Citem
/= N
loop
6524 if Nkind
(Citem
) = N_With_Clause
6525 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
6527 Set_Elaborate_Present
(Citem
, True);
6528 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
6530 -- With the pragma present, elaboration calls on
6531 -- subprograms from the named unit need no further
6532 -- checks, as long as the pragma appears in the current
6533 -- compilation unit. If the pragma appears in some unit
6534 -- in the context, there might still be a need for an
6535 -- Elaborate_All_Desirable from the current compilation
6536 -- to the named unit, so we keep the check enabled.
6538 if In_Extended_Main_Source_Unit
(N
) then
6539 Set_Suppress_Elaboration_Warnings
6540 (Entity
(Name
(Citem
)));
6551 ("argument of pragma% is not with'ed unit", Arg
);
6557 -- Give a warning if operating in static mode with -gnatwl
6558 -- (elaboration warnings enabled) switch set.
6560 if Elab_Warnings
and not Dynamic_Elaboration_Checks
then
6562 ("?use of pragma Elaborate may not be safe", N
);
6564 ("?use pragma Elaborate_All instead if possible", N
);
6572 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
6574 when Pragma_Elaborate_All
=> Elaborate_All
: declare
6579 Check_Ada_83_Warning
;
6581 -- Pragma must be in context items list of a compilation unit
6583 if not Is_In_Context_Clause
then
6587 -- Must be at least one argument
6589 if Arg_Count
= 0 then
6590 Error_Pragma
("pragma% requires at least one argument");
6593 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
6594 -- have to appear at the end of the context clause, but may
6595 -- appear mixed in with other items, even in Ada 83 mode.
6597 -- Final check: the arguments must all be units mentioned in
6598 -- a with clause in the same context clause. Note that we
6599 -- already checked (in Par.Prag) that all the arguments are
6600 -- either identifiers or selected components.
6603 Outr
: while Present
(Arg
) loop
6604 Citem
:= First
(List_Containing
(N
));
6605 Innr
: while Citem
/= N
loop
6606 if Nkind
(Citem
) = N_With_Clause
6607 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
6609 Set_Elaborate_All_Present
(Citem
, True);
6610 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
6612 -- Suppress warnings and elaboration checks on the named
6613 -- unit if the pragma is in the current compilation, as
6614 -- for pragma Elaborate.
6616 if In_Extended_Main_Source_Unit
(N
) then
6617 Set_Suppress_Elaboration_Warnings
6618 (Entity
(Name
(Citem
)));
6627 Set_Error_Posted
(N
);
6629 ("argument of pragma% is not with'ed unit", Arg
);
6636 --------------------
6637 -- Elaborate_Body --
6638 --------------------
6640 -- pragma Elaborate_Body [( library_unit_NAME )];
6642 when Pragma_Elaborate_Body
=> Elaborate_Body
: declare
6643 Cunit_Node
: Node_Id
;
6644 Cunit_Ent
: Entity_Id
;
6647 Check_Ada_83_Warning
;
6648 Check_Valid_Library_Unit_Pragma
;
6650 if Nkind
(N
) = N_Null_Statement
then
6654 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
6655 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
6657 if Nkind_In
(Unit
(Cunit_Node
), N_Package_Body
,
6660 Error_Pragma
("pragma% must refer to a spec, not a body");
6662 Set_Body_Required
(Cunit_Node
, True);
6663 Set_Has_Pragma_Elaborate_Body
(Cunit_Ent
);
6665 -- If we are in dynamic elaboration mode, then we suppress
6666 -- elaboration warnings for the unit, since it is definitely
6667 -- fine NOT to do dynamic checks at the first level (and such
6668 -- checks will be suppressed because no elaboration boolean
6669 -- is created for Elaborate_Body packages).
6671 -- But in the static model of elaboration, Elaborate_Body is
6672 -- definitely NOT good enough to ensure elaboration safety on
6673 -- its own, since the body may WITH other units that are not
6674 -- safe from an elaboration point of view, so a client must
6675 -- still do an Elaborate_All on such units.
6677 -- Debug flag -gnatdD restores the old behavior of 3.13, where
6678 -- Elaborate_Body always suppressed elab warnings.
6680 if Dynamic_Elaboration_Checks
or Debug_Flag_DD
then
6681 Set_Suppress_Elaboration_Warnings
(Cunit_Ent
);
6686 ------------------------
6687 -- Elaboration_Checks --
6688 ------------------------
6690 -- pragma Elaboration_Checks (Static | Dynamic);
6692 when Pragma_Elaboration_Checks
=>
6694 Check_Arg_Count
(1);
6695 Check_Arg_Is_One_Of
(Arg1
, Name_Static
, Name_Dynamic
);
6696 Dynamic_Elaboration_Checks
:=
6697 (Chars
(Get_Pragma_Arg
(Arg1
)) = Name_Dynamic
);
6703 -- pragma Eliminate (
6704 -- [Unit_Name =>] IDENTIFIER | SELECTED_COMPONENT,
6705 -- [,[Entity =>] IDENTIFIER |
6706 -- SELECTED_COMPONENT |
6708 -- [, OVERLOADING_RESOLUTION]);
6710 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
6713 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
6716 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
6718 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
6719 -- Result_Type => result_SUBTYPE_NAME]
6721 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
6722 -- SUBTYPE_NAME ::= STRING_LITERAL
6724 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
6725 -- SOURCE_TRACE ::= STRING_LITERAL
6727 when Pragma_Eliminate
=> Eliminate
: declare
6728 Args
: Args_List
(1 .. 5);
6729 Names
: constant Name_List
(1 .. 5) := (
6732 Name_Parameter_Types
,
6734 Name_Source_Location
);
6736 Unit_Name
: Node_Id
renames Args
(1);
6737 Entity
: Node_Id
renames Args
(2);
6738 Parameter_Types
: Node_Id
renames Args
(3);
6739 Result_Type
: Node_Id
renames Args
(4);
6740 Source_Location
: Node_Id
renames Args
(5);
6744 Check_Valid_Configuration_Pragma
;
6745 Gather_Associations
(Names
, Args
);
6747 if No
(Unit_Name
) then
6748 Error_Pragma
("missing Unit_Name argument for pragma%");
6752 and then (Present
(Parameter_Types
)
6754 Present
(Result_Type
)
6756 Present
(Source_Location
))
6758 Error_Pragma
("missing Entity argument for pragma%");
6761 if (Present
(Parameter_Types
)
6763 Present
(Result_Type
))
6765 Present
(Source_Location
)
6768 ("parameter profile and source location cannot " &
6769 "be used together in pragma%");
6772 Process_Eliminate_Pragma
6786 -- [ Convention =>] convention_IDENTIFIER,
6787 -- [ Entity =>] local_NAME
6788 -- [, [External_Name =>] static_string_EXPRESSION ]
6789 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6791 when Pragma_Export
=> Export
: declare
6795 pragma Warnings
(Off
, C
);
6798 Check_Ada_83_Warning
;
6804 Check_At_Least_N_Arguments
(2);
6805 Check_At_Most_N_Arguments
(4);
6806 Process_Convention
(C
, Def_Id
);
6808 if Ekind
(Def_Id
) /= E_Constant
then
6809 Note_Possible_Modification
(Expression
(Arg2
), Sure
=> False);
6812 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
6813 Set_Exported
(Def_Id
, Arg2
);
6815 -- If the entity is a deferred constant, propagate the information
6816 -- to the full view, because gigi elaborates the full view only.
6818 if Ekind
(Def_Id
) = E_Constant
6819 and then Present
(Full_View
(Def_Id
))
6822 Id2
: constant Entity_Id
:= Full_View
(Def_Id
);
6824 Set_Is_Exported
(Id2
, Is_Exported
(Def_Id
));
6825 Set_First_Rep_Item
(Id2
, First_Rep_Item
(Def_Id
));
6826 Set_Interface_Name
(Id2
, Einfo
.Interface_Name
(Def_Id
));
6831 ----------------------
6832 -- Export_Exception --
6833 ----------------------
6835 -- pragma Export_Exception (
6836 -- [Internal =>] LOCAL_NAME
6837 -- [, [External =>] EXTERNAL_SYMBOL]
6838 -- [, [Form =>] Ada | VMS]
6839 -- [, [Code =>] static_integer_EXPRESSION]);
6841 when Pragma_Export_Exception
=> Export_Exception
: declare
6842 Args
: Args_List
(1 .. 4);
6843 Names
: constant Name_List
(1 .. 4) := (
6849 Internal
: Node_Id
renames Args
(1);
6850 External
: Node_Id
renames Args
(2);
6851 Form
: Node_Id
renames Args
(3);
6852 Code
: Node_Id
renames Args
(4);
6857 if Inside_A_Generic
then
6858 Error_Pragma
("pragma% cannot be used for generic entities");
6861 Gather_Associations
(Names
, Args
);
6862 Process_Extended_Import_Export_Exception_Pragma
(
6863 Arg_Internal
=> Internal
,
6864 Arg_External
=> External
,
6868 if not Is_VMS_Exception
(Entity
(Internal
)) then
6869 Set_Exported
(Entity
(Internal
), Internal
);
6871 end Export_Exception
;
6873 ---------------------
6874 -- Export_Function --
6875 ---------------------
6877 -- pragma Export_Function (
6878 -- [Internal =>] LOCAL_NAME
6879 -- [, [External =>] EXTERNAL_SYMBOL]
6880 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6881 -- [, [Result_Type =>] TYPE_DESIGNATOR]
6882 -- [, [Mechanism =>] MECHANISM]
6883 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
6885 -- EXTERNAL_SYMBOL ::=
6887 -- | static_string_EXPRESSION
6889 -- PARAMETER_TYPES ::=
6891 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6893 -- TYPE_DESIGNATOR ::=
6895 -- | subtype_Name ' Access
6899 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6901 -- MECHANISM_ASSOCIATION ::=
6902 -- [formal_parameter_NAME =>] MECHANISM_NAME
6904 -- MECHANISM_NAME ::=
6907 -- | Descriptor [([Class =>] CLASS_NAME)]
6909 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6911 when Pragma_Export_Function
=> Export_Function
: declare
6912 Args
: Args_List
(1 .. 6);
6913 Names
: constant Name_List
(1 .. 6) := (
6916 Name_Parameter_Types
,
6919 Name_Result_Mechanism
);
6921 Internal
: Node_Id
renames Args
(1);
6922 External
: Node_Id
renames Args
(2);
6923 Parameter_Types
: Node_Id
renames Args
(3);
6924 Result_Type
: Node_Id
renames Args
(4);
6925 Mechanism
: Node_Id
renames Args
(5);
6926 Result_Mechanism
: Node_Id
renames Args
(6);
6930 Gather_Associations
(Names
, Args
);
6931 Process_Extended_Import_Export_Subprogram_Pragma
(
6932 Arg_Internal
=> Internal
,
6933 Arg_External
=> External
,
6934 Arg_Parameter_Types
=> Parameter_Types
,
6935 Arg_Result_Type
=> Result_Type
,
6936 Arg_Mechanism
=> Mechanism
,
6937 Arg_Result_Mechanism
=> Result_Mechanism
);
6938 end Export_Function
;
6944 -- pragma Export_Object (
6945 -- [Internal =>] LOCAL_NAME
6946 -- [, [External =>] EXTERNAL_SYMBOL]
6947 -- [, [Size =>] EXTERNAL_SYMBOL]);
6949 -- EXTERNAL_SYMBOL ::=
6951 -- | static_string_EXPRESSION
6953 -- PARAMETER_TYPES ::=
6955 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6957 -- TYPE_DESIGNATOR ::=
6959 -- | subtype_Name ' Access
6963 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6965 -- MECHANISM_ASSOCIATION ::=
6966 -- [formal_parameter_NAME =>] MECHANISM_NAME
6968 -- MECHANISM_NAME ::=
6971 -- | Descriptor [([Class =>] CLASS_NAME)]
6973 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6975 when Pragma_Export_Object
=> Export_Object
: declare
6976 Args
: Args_List
(1 .. 3);
6977 Names
: constant Name_List
(1 .. 3) := (
6982 Internal
: Node_Id
renames Args
(1);
6983 External
: Node_Id
renames Args
(2);
6984 Size
: Node_Id
renames Args
(3);
6988 Gather_Associations
(Names
, Args
);
6989 Process_Extended_Import_Export_Object_Pragma
(
6990 Arg_Internal
=> Internal
,
6991 Arg_External
=> External
,
6995 ----------------------
6996 -- Export_Procedure --
6997 ----------------------
6999 -- pragma Export_Procedure (
7000 -- [Internal =>] LOCAL_NAME
7001 -- [, [External =>] EXTERNAL_SYMBOL]
7002 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7003 -- [, [Mechanism =>] MECHANISM]);
7005 -- EXTERNAL_SYMBOL ::=
7007 -- | static_string_EXPRESSION
7009 -- PARAMETER_TYPES ::=
7011 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7013 -- TYPE_DESIGNATOR ::=
7015 -- | subtype_Name ' Access
7019 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7021 -- MECHANISM_ASSOCIATION ::=
7022 -- [formal_parameter_NAME =>] MECHANISM_NAME
7024 -- MECHANISM_NAME ::=
7027 -- | Descriptor [([Class =>] CLASS_NAME)]
7029 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7031 when Pragma_Export_Procedure
=> Export_Procedure
: declare
7032 Args
: Args_List
(1 .. 4);
7033 Names
: constant Name_List
(1 .. 4) := (
7036 Name_Parameter_Types
,
7039 Internal
: Node_Id
renames Args
(1);
7040 External
: Node_Id
renames Args
(2);
7041 Parameter_Types
: Node_Id
renames Args
(3);
7042 Mechanism
: Node_Id
renames Args
(4);
7046 Gather_Associations
(Names
, Args
);
7047 Process_Extended_Import_Export_Subprogram_Pragma
(
7048 Arg_Internal
=> Internal
,
7049 Arg_External
=> External
,
7050 Arg_Parameter_Types
=> Parameter_Types
,
7051 Arg_Mechanism
=> Mechanism
);
7052 end Export_Procedure
;
7058 -- pragma Export_Value (
7059 -- [Value =>] static_integer_EXPRESSION,
7060 -- [Link_Name =>] static_string_EXPRESSION);
7062 when Pragma_Export_Value
=>
7064 Check_Arg_Order
((Name_Value
, Name_Link_Name
));
7065 Check_Arg_Count
(2);
7067 Check_Optional_Identifier
(Arg1
, Name_Value
);
7068 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
7070 Check_Optional_Identifier
(Arg2
, Name_Link_Name
);
7071 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7073 -----------------------------
7074 -- Export_Valued_Procedure --
7075 -----------------------------
7077 -- pragma Export_Valued_Procedure (
7078 -- [Internal =>] LOCAL_NAME
7079 -- [, [External =>] EXTERNAL_SYMBOL,]
7080 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7081 -- [, [Mechanism =>] MECHANISM]);
7083 -- EXTERNAL_SYMBOL ::=
7085 -- | static_string_EXPRESSION
7087 -- PARAMETER_TYPES ::=
7089 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7091 -- TYPE_DESIGNATOR ::=
7093 -- | subtype_Name ' Access
7097 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7099 -- MECHANISM_ASSOCIATION ::=
7100 -- [formal_parameter_NAME =>] MECHANISM_NAME
7102 -- MECHANISM_NAME ::=
7105 -- | Descriptor [([Class =>] CLASS_NAME)]
7107 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7109 when Pragma_Export_Valued_Procedure
=>
7110 Export_Valued_Procedure
: declare
7111 Args
: Args_List
(1 .. 4);
7112 Names
: constant Name_List
(1 .. 4) := (
7115 Name_Parameter_Types
,
7118 Internal
: Node_Id
renames Args
(1);
7119 External
: Node_Id
renames Args
(2);
7120 Parameter_Types
: Node_Id
renames Args
(3);
7121 Mechanism
: Node_Id
renames Args
(4);
7125 Gather_Associations
(Names
, Args
);
7126 Process_Extended_Import_Export_Subprogram_Pragma
(
7127 Arg_Internal
=> Internal
,
7128 Arg_External
=> External
,
7129 Arg_Parameter_Types
=> Parameter_Types
,
7130 Arg_Mechanism
=> Mechanism
);
7131 end Export_Valued_Procedure
;
7137 -- pragma Extend_System ([Name =>] Identifier);
7139 when Pragma_Extend_System
=> Extend_System
: declare
7142 Check_Valid_Configuration_Pragma
;
7143 Check_Arg_Count
(1);
7144 Check_Optional_Identifier
(Arg1
, Name_Name
);
7145 Check_Arg_Is_Identifier
(Arg1
);
7147 Get_Name_String
(Chars
(Expression
(Arg1
)));
7150 and then Name_Buffer
(1 .. 4) = "aux_"
7152 if Present
(System_Extend_Pragma_Arg
) then
7153 if Chars
(Expression
(Arg1
)) =
7154 Chars
(Expression
(System_Extend_Pragma_Arg
))
7158 Error_Msg_Sloc
:= Sloc
(System_Extend_Pragma_Arg
);
7159 Error_Pragma
("pragma% conflicts with that #");
7163 System_Extend_Pragma_Arg
:= Arg1
;
7165 if not GNAT_Mode
then
7166 System_Extend_Unit
:= Arg1
;
7170 Error_Pragma
("incorrect name for pragma%, must be Aux_xxx");
7174 ------------------------
7175 -- Extensions_Allowed --
7176 ------------------------
7178 -- pragma Extensions_Allowed (ON | OFF);
7180 when Pragma_Extensions_Allowed
=>
7182 Check_Arg_Count
(1);
7183 Check_No_Identifiers
;
7184 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
7186 if Chars
(Expression
(Arg1
)) = Name_On
then
7187 Extensions_Allowed
:= True;
7189 Extensions_Allowed
:= False;
7196 -- pragma External (
7197 -- [ Convention =>] convention_IDENTIFIER,
7198 -- [ Entity =>] local_NAME
7199 -- [, [External_Name =>] static_string_EXPRESSION ]
7200 -- [, [Link_Name =>] static_string_EXPRESSION ]);
7202 when Pragma_External
=> External
: declare
7206 pragma Warnings
(Off
, C
);
7215 Check_At_Least_N_Arguments
(2);
7216 Check_At_Most_N_Arguments
(4);
7217 Process_Convention
(C
, Def_Id
);
7218 Note_Possible_Modification
(Expression
(Arg2
), Sure
=> False);
7219 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
7220 Set_Exported
(Def_Id
, Arg2
);
7223 --------------------------
7224 -- External_Name_Casing --
7225 --------------------------
7227 -- pragma External_Name_Casing (
7228 -- UPPERCASE | LOWERCASE
7229 -- [, AS_IS | UPPERCASE | LOWERCASE]);
7231 when Pragma_External_Name_Casing
=> External_Name_Casing
: declare
7234 Check_No_Identifiers
;
7236 if Arg_Count
= 2 then
7238 (Arg2
, Name_As_Is
, Name_Uppercase
, Name_Lowercase
);
7240 case Chars
(Get_Pragma_Arg
(Arg2
)) is
7242 Opt
.External_Name_Exp_Casing
:= As_Is
;
7244 when Name_Uppercase
=>
7245 Opt
.External_Name_Exp_Casing
:= Uppercase
;
7247 when Name_Lowercase
=>
7248 Opt
.External_Name_Exp_Casing
:= Lowercase
;
7255 Check_Arg_Count
(1);
7258 Check_Arg_Is_One_Of
(Arg1
, Name_Uppercase
, Name_Lowercase
);
7260 case Chars
(Get_Pragma_Arg
(Arg1
)) is
7261 when Name_Uppercase
=>
7262 Opt
.External_Name_Imp_Casing
:= Uppercase
;
7264 when Name_Lowercase
=>
7265 Opt
.External_Name_Imp_Casing
:= Lowercase
;
7270 end External_Name_Casing
;
7272 --------------------------
7273 -- Favor_Top_Level --
7274 --------------------------
7276 -- pragma Favor_Top_Level (type_NAME);
7278 when Pragma_Favor_Top_Level
=> Favor_Top_Level
: declare
7279 Named_Entity
: Entity_Id
;
7283 Check_No_Identifiers
;
7284 Check_Arg_Count
(1);
7285 Check_Arg_Is_Local_Name
(Arg1
);
7286 Named_Entity
:= Entity
(Expression
(Arg1
));
7288 -- If it's an access-to-subprogram type (in particular, not a
7289 -- subtype), set the flag on that type.
7291 if Is_Access_Subprogram_Type
(Named_Entity
) then
7292 Set_Can_Use_Internal_Rep
(Named_Entity
, False);
7294 -- Otherwise it's an error (name denotes the wrong sort of entity)
7298 ("access-to-subprogram type expected", Expression
(Arg1
));
7300 end Favor_Top_Level
;
7306 -- pragma Fast_Math;
7308 when Pragma_Fast_Math
=>
7310 Check_No_Identifiers
;
7311 Check_Valid_Configuration_Pragma
;
7314 ---------------------------
7315 -- Finalize_Storage_Only --
7316 ---------------------------
7318 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
7320 when Pragma_Finalize_Storage_Only
=> Finalize_Storage
: declare
7321 Assoc
: constant Node_Id
:= Arg1
;
7322 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
7327 Check_No_Identifiers
;
7328 Check_Arg_Count
(1);
7329 Check_Arg_Is_Local_Name
(Arg1
);
7331 Find_Type
(Type_Id
);
7332 Typ
:= Entity
(Type_Id
);
7335 or else Rep_Item_Too_Early
(Typ
, N
)
7339 Typ
:= Underlying_Type
(Typ
);
7342 if not Is_Controlled
(Typ
) then
7343 Error_Pragma
("pragma% must specify controlled type");
7346 Check_First_Subtype
(Arg1
);
7348 if Finalize_Storage_Only
(Typ
) then
7349 Error_Pragma
("duplicate pragma%, only one allowed");
7351 elsif not Rep_Item_Too_Late
(Typ
, N
) then
7352 Set_Finalize_Storage_Only
(Base_Type
(Typ
), True);
7354 end Finalize_Storage
;
7356 --------------------------
7357 -- Float_Representation --
7358 --------------------------
7360 -- pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
7362 -- FLOAT_REP ::= VAX_Float | IEEE_Float
7364 when Pragma_Float_Representation
=> Float_Representation
: declare
7372 if Arg_Count
= 1 then
7373 Check_Valid_Configuration_Pragma
;
7375 Check_Arg_Count
(2);
7376 Check_Optional_Identifier
(Arg2
, Name_Entity
);
7377 Check_Arg_Is_Local_Name
(Arg2
);
7380 Check_No_Identifier
(Arg1
);
7381 Check_Arg_Is_One_Of
(Arg1
, Name_VAX_Float
, Name_IEEE_Float
);
7383 if not OpenVMS_On_Target
then
7384 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
7386 ("?pragma% ignored (applies only to Open'V'M'S)");
7392 -- One argument case
7394 if Arg_Count
= 1 then
7395 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
7396 if Opt
.Float_Format
= 'I' then
7397 Error_Pragma
("'I'E'E'E format previously specified");
7400 Opt
.Float_Format
:= 'V';
7403 if Opt
.Float_Format
= 'V' then
7404 Error_Pragma
("'V'A'X format previously specified");
7407 Opt
.Float_Format
:= 'I';
7410 Set_Standard_Fpt_Formats
;
7412 -- Two argument case
7415 Argx
:= Get_Pragma_Arg
(Arg2
);
7417 if not Is_Entity_Name
(Argx
)
7418 or else not Is_Floating_Point_Type
(Entity
(Argx
))
7421 ("second argument of% pragma must be floating-point type",
7425 Ent
:= Entity
(Argx
);
7426 Digs
:= UI_To_Int
(Digits_Value
(Ent
));
7428 -- Two arguments, VAX_Float case
7430 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
7432 when 6 => Set_F_Float
(Ent
);
7433 when 9 => Set_D_Float
(Ent
);
7434 when 15 => Set_G_Float
(Ent
);
7438 ("wrong digits value, must be 6,9 or 15", Arg2
);
7441 -- Two arguments, IEEE_Float case
7445 when 6 => Set_IEEE_Short
(Ent
);
7446 when 15 => Set_IEEE_Long
(Ent
);
7450 ("wrong digits value, must be 6 or 15", Arg2
);
7454 end Float_Representation
;
7460 -- pragma Ident (static_string_EXPRESSION)
7462 -- Note: pragma Comment shares this processing. Pragma Comment is
7463 -- identical to Ident, except that the restriction of the argument to
7464 -- 31 characters and the placement restrictions are not enforced for
7467 when Pragma_Ident | Pragma_Comment
=> Ident
: declare
7472 Check_Arg_Count
(1);
7473 Check_No_Identifiers
;
7474 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7476 -- For pragma Ident, preserve DEC compatibility by requiring the
7477 -- pragma to appear in a declarative part or package spec.
7479 if Prag_Id
= Pragma_Ident
then
7480 Check_Is_In_Decl_Part_Or_Package_Spec
;
7483 Str
:= Expr_Value_S
(Expression
(Arg1
));
7490 GP
:= Parent
(Parent
(N
));
7492 if Nkind_In
(GP
, N_Package_Declaration
,
7493 N_Generic_Package_Declaration
)
7498 -- If we have a compilation unit, then record the ident value,
7499 -- checking for improper duplication.
7501 if Nkind
(GP
) = N_Compilation_Unit
then
7502 CS
:= Ident_String
(Current_Sem_Unit
);
7504 if Present
(CS
) then
7506 -- For Ident, we do not permit multiple instances
7508 if Prag_Id
= Pragma_Ident
then
7509 Error_Pragma
("duplicate% pragma not permitted");
7511 -- For Comment, we concatenate the string, unless we want
7512 -- to preserve the tree structure for ASIS.
7514 elsif not ASIS_Mode
then
7515 Start_String
(Strval
(CS
));
7516 Store_String_Char
(' ');
7517 Store_String_Chars
(Strval
(Str
));
7518 Set_Strval
(CS
, End_String
);
7522 -- In VMS, the effect of IDENT is achieved by passing
7523 -- IDENTIFICATION=name as a --for-linker switch.
7525 if OpenVMS_On_Target
then
7528 ("--for-linker=IDENTIFICATION=");
7529 String_To_Name_Buffer
(Strval
(Str
));
7530 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
7532 -- Only the last processed IDENT is saved. The main
7533 -- purpose is so an IDENT associated with a main
7534 -- procedure will be used in preference to an IDENT
7535 -- associated with a with'd package.
7537 Replace_Linker_Option_String
7538 (End_String
, "--for-linker=IDENTIFICATION=");
7541 Set_Ident_String
(Current_Sem_Unit
, Str
);
7544 -- For subunits, we just ignore the Ident, since in GNAT these
7545 -- are not separate object files, and hence not separate units
7546 -- in the unit table.
7548 elsif Nkind
(GP
) = N_Subunit
then
7551 -- Otherwise we have a misplaced pragma Ident, but we ignore
7552 -- this if we are in an instantiation, since it comes from
7553 -- a generic, and has no relevance to the instantiation.
7555 elsif Prag_Id
= Pragma_Ident
then
7556 if Instantiation_Location
(Loc
) = No_Location
then
7557 Error_Pragma
("pragma% only allowed at outer level");
7563 --------------------------
7564 -- Implemented_By_Entry --
7565 --------------------------
7567 -- pragma Implemented_By_Entry (DIRECT_NAME);
7569 when Pragma_Implemented_By_Entry
=> Implemented_By_Entry
: declare
7574 Check_Arg_Count
(1);
7575 Check_No_Identifiers
;
7576 Check_Arg_Is_Identifier
(Arg1
);
7577 Check_Arg_Is_Local_Name
(Arg1
);
7578 Ent
:= Entity
(Expression
(Arg1
));
7580 -- Pragma Implemented_By_Entry must be applied only to protected
7581 -- synchronized or task interface primitives.
7583 if (Ekind
(Ent
) /= E_Function
7584 and then Ekind
(Ent
) /= E_Procedure
)
7585 or else not Present
(First_Formal
(Ent
))
7586 or else not Is_Concurrent_Interface
(Etype
(First_Formal
(Ent
)))
7589 ("pragma % must be applied to a concurrent interface " &
7593 if Einfo
.Implemented_By_Entry
(Ent
)
7594 and then Warn_On_Redundant_Constructs
7596 Error_Pragma
("?duplicate pragma%!");
7598 Set_Implemented_By_Entry
(Ent
);
7601 end Implemented_By_Entry
;
7603 -----------------------
7604 -- Implicit_Packing --
7605 -----------------------
7607 -- pragma Implicit_Packing;
7609 when Pragma_Implicit_Packing
=>
7611 Check_Arg_Count
(0);
7612 Implicit_Packing
:= True;
7619 -- [Convention =>] convention_IDENTIFIER,
7620 -- [Entity =>] local_NAME
7621 -- [, [External_Name =>] static_string_EXPRESSION ]
7622 -- [, [Link_Name =>] static_string_EXPRESSION ]);
7624 when Pragma_Import
=>
7625 Check_Ada_83_Warning
;
7631 Check_At_Least_N_Arguments
(2);
7632 Check_At_Most_N_Arguments
(4);
7633 Process_Import_Or_Interface
;
7635 ----------------------
7636 -- Import_Exception --
7637 ----------------------
7639 -- pragma Import_Exception (
7640 -- [Internal =>] LOCAL_NAME
7641 -- [, [External =>] EXTERNAL_SYMBOL]
7642 -- [, [Form =>] Ada | VMS]
7643 -- [, [Code =>] static_integer_EXPRESSION]);
7645 when Pragma_Import_Exception
=> Import_Exception
: declare
7646 Args
: Args_List
(1 .. 4);
7647 Names
: constant Name_List
(1 .. 4) := (
7653 Internal
: Node_Id
renames Args
(1);
7654 External
: Node_Id
renames Args
(2);
7655 Form
: Node_Id
renames Args
(3);
7656 Code
: Node_Id
renames Args
(4);
7660 Gather_Associations
(Names
, Args
);
7662 if Present
(External
) and then Present
(Code
) then
7664 ("cannot give both External and Code options for pragma%");
7667 Process_Extended_Import_Export_Exception_Pragma
(
7668 Arg_Internal
=> Internal
,
7669 Arg_External
=> External
,
7673 if not Is_VMS_Exception
(Entity
(Internal
)) then
7674 Set_Imported
(Entity
(Internal
));
7676 end Import_Exception
;
7678 ---------------------
7679 -- Import_Function --
7680 ---------------------
7682 -- pragma Import_Function (
7683 -- [Internal =>] LOCAL_NAME,
7684 -- [, [External =>] EXTERNAL_SYMBOL]
7685 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7686 -- [, [Result_Type =>] SUBTYPE_MARK]
7687 -- [, [Mechanism =>] MECHANISM]
7688 -- [, [Result_Mechanism =>] MECHANISM_NAME]
7689 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
7691 -- EXTERNAL_SYMBOL ::=
7693 -- | static_string_EXPRESSION
7695 -- PARAMETER_TYPES ::=
7697 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7699 -- TYPE_DESIGNATOR ::=
7701 -- | subtype_Name ' Access
7705 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7707 -- MECHANISM_ASSOCIATION ::=
7708 -- [formal_parameter_NAME =>] MECHANISM_NAME
7710 -- MECHANISM_NAME ::=
7713 -- | Descriptor [([Class =>] CLASS_NAME)]
7715 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7717 when Pragma_Import_Function
=> Import_Function
: declare
7718 Args
: Args_List
(1 .. 7);
7719 Names
: constant Name_List
(1 .. 7) := (
7722 Name_Parameter_Types
,
7725 Name_Result_Mechanism
,
7726 Name_First_Optional_Parameter
);
7728 Internal
: Node_Id
renames Args
(1);
7729 External
: Node_Id
renames Args
(2);
7730 Parameter_Types
: Node_Id
renames Args
(3);
7731 Result_Type
: Node_Id
renames Args
(4);
7732 Mechanism
: Node_Id
renames Args
(5);
7733 Result_Mechanism
: Node_Id
renames Args
(6);
7734 First_Optional_Parameter
: Node_Id
renames Args
(7);
7738 Gather_Associations
(Names
, Args
);
7739 Process_Extended_Import_Export_Subprogram_Pragma
(
7740 Arg_Internal
=> Internal
,
7741 Arg_External
=> External
,
7742 Arg_Parameter_Types
=> Parameter_Types
,
7743 Arg_Result_Type
=> Result_Type
,
7744 Arg_Mechanism
=> Mechanism
,
7745 Arg_Result_Mechanism
=> Result_Mechanism
,
7746 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
7747 end Import_Function
;
7753 -- pragma Import_Object (
7754 -- [Internal =>] LOCAL_NAME
7755 -- [, [External =>] EXTERNAL_SYMBOL]
7756 -- [, [Size =>] EXTERNAL_SYMBOL]);
7758 -- EXTERNAL_SYMBOL ::=
7760 -- | static_string_EXPRESSION
7762 when Pragma_Import_Object
=> Import_Object
: declare
7763 Args
: Args_List
(1 .. 3);
7764 Names
: constant Name_List
(1 .. 3) := (
7769 Internal
: Node_Id
renames Args
(1);
7770 External
: Node_Id
renames Args
(2);
7771 Size
: Node_Id
renames Args
(3);
7775 Gather_Associations
(Names
, Args
);
7776 Process_Extended_Import_Export_Object_Pragma
(
7777 Arg_Internal
=> Internal
,
7778 Arg_External
=> External
,
7782 ----------------------
7783 -- Import_Procedure --
7784 ----------------------
7786 -- pragma Import_Procedure (
7787 -- [Internal =>] LOCAL_NAME
7788 -- [, [External =>] EXTERNAL_SYMBOL]
7789 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7790 -- [, [Mechanism =>] MECHANISM]
7791 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
7793 -- EXTERNAL_SYMBOL ::=
7795 -- | static_string_EXPRESSION
7797 -- PARAMETER_TYPES ::=
7799 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7801 -- TYPE_DESIGNATOR ::=
7803 -- | subtype_Name ' Access
7807 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7809 -- MECHANISM_ASSOCIATION ::=
7810 -- [formal_parameter_NAME =>] MECHANISM_NAME
7812 -- MECHANISM_NAME ::=
7815 -- | Descriptor [([Class =>] CLASS_NAME)]
7817 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7819 when Pragma_Import_Procedure
=> Import_Procedure
: declare
7820 Args
: Args_List
(1 .. 5);
7821 Names
: constant Name_List
(1 .. 5) := (
7824 Name_Parameter_Types
,
7826 Name_First_Optional_Parameter
);
7828 Internal
: Node_Id
renames Args
(1);
7829 External
: Node_Id
renames Args
(2);
7830 Parameter_Types
: Node_Id
renames Args
(3);
7831 Mechanism
: Node_Id
renames Args
(4);
7832 First_Optional_Parameter
: Node_Id
renames Args
(5);
7836 Gather_Associations
(Names
, Args
);
7837 Process_Extended_Import_Export_Subprogram_Pragma
(
7838 Arg_Internal
=> Internal
,
7839 Arg_External
=> External
,
7840 Arg_Parameter_Types
=> Parameter_Types
,
7841 Arg_Mechanism
=> Mechanism
,
7842 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
7843 end Import_Procedure
;
7845 -----------------------------
7846 -- Import_Valued_Procedure --
7847 -----------------------------
7849 -- pragma Import_Valued_Procedure (
7850 -- [Internal =>] LOCAL_NAME
7851 -- [, [External =>] EXTERNAL_SYMBOL]
7852 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7853 -- [, [Mechanism =>] MECHANISM]
7854 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
7856 -- EXTERNAL_SYMBOL ::=
7858 -- | static_string_EXPRESSION
7860 -- PARAMETER_TYPES ::=
7862 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7864 -- TYPE_DESIGNATOR ::=
7866 -- | subtype_Name ' Access
7870 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7872 -- MECHANISM_ASSOCIATION ::=
7873 -- [formal_parameter_NAME =>] MECHANISM_NAME
7875 -- MECHANISM_NAME ::=
7878 -- | Descriptor [([Class =>] CLASS_NAME)]
7880 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7882 when Pragma_Import_Valued_Procedure
=>
7883 Import_Valued_Procedure
: declare
7884 Args
: Args_List
(1 .. 5);
7885 Names
: constant Name_List
(1 .. 5) := (
7888 Name_Parameter_Types
,
7890 Name_First_Optional_Parameter
);
7892 Internal
: Node_Id
renames Args
(1);
7893 External
: Node_Id
renames Args
(2);
7894 Parameter_Types
: Node_Id
renames Args
(3);
7895 Mechanism
: Node_Id
renames Args
(4);
7896 First_Optional_Parameter
: Node_Id
renames Args
(5);
7900 Gather_Associations
(Names
, Args
);
7901 Process_Extended_Import_Export_Subprogram_Pragma
(
7902 Arg_Internal
=> Internal
,
7903 Arg_External
=> External
,
7904 Arg_Parameter_Types
=> Parameter_Types
,
7905 Arg_Mechanism
=> Mechanism
,
7906 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
7907 end Import_Valued_Procedure
;
7909 ------------------------
7910 -- Initialize_Scalars --
7911 ------------------------
7913 -- pragma Initialize_Scalars;
7915 when Pragma_Initialize_Scalars
=>
7917 Check_Arg_Count
(0);
7918 Check_Valid_Configuration_Pragma
;
7919 Check_Restriction
(No_Initialize_Scalars
, N
);
7921 if not Restriction_Active
(No_Initialize_Scalars
) then
7922 Init_Or_Norm_Scalars
:= True;
7923 Initialize_Scalars
:= True;
7930 -- pragma Inline ( NAME {, NAME} );
7932 when Pragma_Inline
=>
7934 -- Pragma is active if inlining option is active
7936 Process_Inline
(Inline_Active
);
7942 -- pragma Inline_Always ( NAME {, NAME} );
7944 when Pragma_Inline_Always
=>
7946 Process_Inline
(True);
7948 --------------------
7949 -- Inline_Generic --
7950 --------------------
7952 -- pragma Inline_Generic (NAME {, NAME});
7954 when Pragma_Inline_Generic
=>
7956 Process_Generic_List
;
7958 ----------------------
7959 -- Inspection_Point --
7960 ----------------------
7962 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
7964 when Pragma_Inspection_Point
=> Inspection_Point
: declare
7969 if Arg_Count
> 0 then
7972 Exp
:= Expression
(Arg
);
7975 if not Is_Entity_Name
(Exp
)
7976 or else not Is_Object
(Entity
(Exp
))
7978 Error_Pragma_Arg
("object name required", Arg
);
7985 end Inspection_Point
;
7991 -- pragma Interface (
7992 -- [ Convention =>] convention_IDENTIFIER,
7993 -- [ Entity =>] local_NAME
7994 -- [, [External_Name =>] static_string_EXPRESSION ]
7995 -- [, [Link_Name =>] static_string_EXPRESSION ]);
7997 when Pragma_Interface
=>
8004 Check_At_Least_N_Arguments
(2);
8005 Check_At_Most_N_Arguments
(4);
8006 Process_Import_Or_Interface
;
8008 --------------------
8009 -- Interface_Name --
8010 --------------------
8012 -- pragma Interface_Name (
8013 -- [ Entity =>] local_NAME
8014 -- [,[External_Name =>] static_string_EXPRESSION ]
8015 -- [,[Link_Name =>] static_string_EXPRESSION ]);
8017 when Pragma_Interface_Name
=> Interface_Name
: declare
8026 ((Name_Entity
, Name_External_Name
, Name_Link_Name
));
8027 Check_At_Least_N_Arguments
(2);
8028 Check_At_Most_N_Arguments
(3);
8029 Id
:= Expression
(Arg1
);
8032 if not Is_Entity_Name
(Id
) then
8034 ("first argument for pragma% must be entity name", Arg1
);
8035 elsif Etype
(Id
) = Any_Type
then
8038 Def_Id
:= Entity
(Id
);
8041 -- Special DEC-compatible processing for the object case, forces
8042 -- object to be imported.
8044 if Ekind
(Def_Id
) = E_Variable
then
8045 Kill_Size_Check_Code
(Def_Id
);
8046 Note_Possible_Modification
(Id
, Sure
=> False);
8048 -- Initialization is not allowed for imported variable
8050 if Present
(Expression
(Parent
(Def_Id
)))
8051 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
8053 Error_Msg_Sloc
:= Sloc
(Def_Id
);
8055 ("no initialization allowed for declaration of& #",
8059 -- For compatibility, support VADS usage of providing both
8060 -- pragmas Interface and Interface_Name to obtain the effect
8061 -- of a single Import pragma.
8063 if Is_Imported
(Def_Id
)
8064 and then Present
(First_Rep_Item
(Def_Id
))
8065 and then Nkind
(First_Rep_Item
(Def_Id
)) = N_Pragma
8067 Pragma_Name
(First_Rep_Item
(Def_Id
)) = Name_Interface
8071 Set_Imported
(Def_Id
);
8074 Set_Is_Public
(Def_Id
);
8075 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
8078 -- Otherwise must be subprogram
8080 elsif not Is_Subprogram
(Def_Id
) then
8082 ("argument of pragma% is not subprogram", Arg1
);
8085 Check_At_Most_N_Arguments
(3);
8089 -- Loop through homonyms
8092 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
8094 if Is_Imported
(Def_Id
) then
8095 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
8099 Hom_Id
:= Homonym
(Hom_Id
);
8101 exit when No
(Hom_Id
)
8102 or else Scope
(Hom_Id
) /= Current_Scope
;
8107 ("argument of pragma% is not imported subprogram",
8113 -----------------------
8114 -- Interrupt_Handler --
8115 -----------------------
8117 -- pragma Interrupt_Handler (handler_NAME);
8119 when Pragma_Interrupt_Handler
=>
8120 Check_Ada_83_Warning
;
8121 Check_Arg_Count
(1);
8122 Check_No_Identifiers
;
8124 if No_Run_Time_Mode
then
8125 Error_Msg_CRT
("Interrupt_Handler pragma", N
);
8127 Check_Interrupt_Or_Attach_Handler
;
8128 Process_Interrupt_Or_Attach_Handler
;
8131 ------------------------
8132 -- Interrupt_Priority --
8133 ------------------------
8135 -- pragma Interrupt_Priority [(EXPRESSION)];
8137 when Pragma_Interrupt_Priority
=> Interrupt_Priority
: declare
8138 P
: constant Node_Id
:= Parent
(N
);
8142 Check_Ada_83_Warning
;
8144 if Arg_Count
/= 0 then
8145 Arg
:= Expression
(Arg1
);
8146 Check_Arg_Count
(1);
8147 Check_No_Identifiers
;
8149 -- The expression must be analyzed in the special manner
8150 -- described in "Handling of Default and Per-Object
8151 -- Expressions" in sem.ads.
8153 Preanalyze_Spec_Expression
(Arg
, RTE
(RE_Interrupt_Priority
));
8156 if not Nkind_In
(P
, N_Task_Definition
, N_Protected_Definition
) then
8160 elsif Has_Priority_Pragma
(P
) then
8161 Error_Pragma
("duplicate pragma% not allowed");
8164 Set_Has_Priority_Pragma
(P
, True);
8165 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
8167 end Interrupt_Priority
;
8169 ---------------------
8170 -- Interrupt_State --
8171 ---------------------
8173 -- pragma Interrupt_State (
8174 -- [Name =>] INTERRUPT_ID,
8175 -- [State =>] INTERRUPT_STATE);
8177 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
8178 -- INTERRUPT_STATE => System | Runtime | User
8180 -- Note: if the interrupt id is given as an identifier, then it must
8181 -- be one of the identifiers in Ada.Interrupts.Names. Otherwise it is
8182 -- given as a static integer expression which must be in the range of
8183 -- Ada.Interrupts.Interrupt_ID.
8185 when Pragma_Interrupt_State
=> Interrupt_State
: declare
8187 Int_Id
: constant Entity_Id
:= RTE
(RE_Interrupt_ID
);
8188 -- This is the entity Ada.Interrupts.Interrupt_ID;
8190 State_Type
: Character;
8191 -- Set to 's'/'r'/'u' for System/Runtime/User
8194 -- Index to entry in Interrupt_States table
8197 -- Value of interrupt
8199 Arg1X
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
8200 -- The first argument to the pragma
8202 Int_Ent
: Entity_Id
;
8203 -- Interrupt entity in Ada.Interrupts.Names
8207 Check_Arg_Order
((Name_Name
, Name_State
));
8208 Check_Arg_Count
(2);
8210 Check_Optional_Identifier
(Arg1
, Name_Name
);
8211 Check_Optional_Identifier
(Arg2
, Name_State
);
8212 Check_Arg_Is_Identifier
(Arg2
);
8214 -- First argument is identifier
8216 if Nkind
(Arg1X
) = N_Identifier
then
8218 -- Search list of names in Ada.Interrupts.Names
8220 Int_Ent
:= First_Entity
(RTE
(RE_Names
));
8222 if No
(Int_Ent
) then
8223 Error_Pragma_Arg
("invalid interrupt name", Arg1
);
8225 elsif Chars
(Int_Ent
) = Chars
(Arg1X
) then
8226 Int_Val
:= Expr_Value
(Constant_Value
(Int_Ent
));
8230 Next_Entity
(Int_Ent
);
8233 -- First argument is not an identifier, so it must be a static
8234 -- expression of type Ada.Interrupts.Interrupt_ID.
8237 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
8238 Int_Val
:= Expr_Value
(Arg1X
);
8240 if Int_Val
< Expr_Value
(Type_Low_Bound
(Int_Id
))
8242 Int_Val
> Expr_Value
(Type_High_Bound
(Int_Id
))
8245 ("value not in range of type " &
8246 """Ada.Interrupts.Interrupt_'I'D""", Arg1
);
8252 case Chars
(Get_Pragma_Arg
(Arg2
)) is
8253 when Name_Runtime
=> State_Type
:= 'r';
8254 when Name_System
=> State_Type
:= 's';
8255 when Name_User
=> State_Type
:= 'u';
8258 Error_Pragma_Arg
("invalid interrupt state", Arg2
);
8261 -- Check if entry is already stored
8263 IST_Num
:= Interrupt_States
.First
;
8265 -- If entry not found, add it
8267 if IST_Num
> Interrupt_States
.Last
then
8268 Interrupt_States
.Append
8269 ((Interrupt_Number
=> UI_To_Int
(Int_Val
),
8270 Interrupt_State
=> State_Type
,
8271 Pragma_Loc
=> Loc
));
8274 -- Case of entry for the same entry
8276 elsif Int_Val
= Interrupt_States
.Table
(IST_Num
).
8279 -- If state matches, done, no need to make redundant entry
8282 State_Type
= Interrupt_States
.Table
(IST_Num
).
8285 -- Otherwise if state does not match, error
8288 Interrupt_States
.Table
(IST_Num
).Pragma_Loc
;
8290 ("state conflicts with that given #", Arg2
);
8294 IST_Num
:= IST_Num
+ 1;
8296 end Interrupt_State
;
8298 ----------------------
8299 -- Java_Constructor --
8300 ----------------------
8302 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
8304 -- Also handles pragma CIL_Constructor
8306 when Pragma_CIL_Constructor | Pragma_Java_Constructor
=>
8307 Java_Constructor
: declare
8311 Convention
: Convention_Id
;
8315 Check_Arg_Count
(1);
8316 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8317 Check_Arg_Is_Local_Name
(Arg1
);
8319 Id
:= Expression
(Arg1
);
8320 Find_Program_Unit_Name
(Id
);
8322 -- If we did not find the name, we are done
8324 if Etype
(Id
) = Any_Type
then
8329 when Pragma_CIL_Constructor
=> Convention
:= Convention_CIL
;
8330 when Pragma_Java_Constructor
=> Convention
:= Convention_Java
;
8331 when others => null;
8334 Hom_Id
:= Entity
(Id
);
8336 -- Loop through homonyms
8339 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
8341 -- The constructor is required to be a function returning an
8342 -- access type whose designated type has convention Java/CIL.
8344 if Ekind
(Def_Id
) = E_Function
8346 (Is_Value_Type
(Etype
(Def_Id
))
8348 (Ekind
(Etype
(Def_Id
)) = E_Access_Subprogram_Type
8350 Atree
.Convention
(Etype
(Def_Id
)) = Convention
)
8352 (Ekind
(Etype
(Def_Id
)) in Access_Kind
8355 (Designated_Type
(Etype
(Def_Id
))) = Convention
8358 (Root_Type
(Designated_Type
(Etype
(Def_Id
)))) =
8361 Set_Is_Constructor
(Def_Id
);
8362 Set_Convention
(Def_Id
, Convention
);
8363 Set_Is_Imported
(Def_Id
);
8366 if Convention
= Convention_Java
then
8368 ("pragma% requires function returning a " &
8369 "'Java access type", Arg1
);
8371 pragma Assert
(Convention
= Convention_CIL
);
8373 ("pragma% requires function returning a " &
8374 "'C'I'L access type", Arg1
);
8378 Hom_Id
:= Homonym
(Hom_Id
);
8380 exit when No
(Hom_Id
) or else Scope
(Hom_Id
) /= Current_Scope
;
8382 end Java_Constructor
;
8384 ----------------------
8385 -- Java_Interface --
8386 ----------------------
8388 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
8390 when Pragma_Java_Interface
=> Java_Interface
: declare
8396 Check_Arg_Count
(1);
8397 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8398 Check_Arg_Is_Local_Name
(Arg1
);
8400 Arg
:= Expression
(Arg1
);
8403 if Etype
(Arg
) = Any_Type
then
8407 if not Is_Entity_Name
(Arg
)
8408 or else not Is_Type
(Entity
(Arg
))
8410 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
8413 Typ
:= Underlying_Type
(Entity
(Arg
));
8415 -- For now simply check some of the semantic constraints on the
8416 -- type. This currently leaves out some restrictions on interface
8417 -- types, namely that the parent type must be java.lang.Object.Typ
8418 -- and that all primitives of the type should be declared
8421 if not Is_Tagged_Type
(Typ
) or else not Is_Abstract_Type
(Typ
) then
8422 Error_Pragma_Arg
("pragma% requires an abstract "
8423 & "tagged type", Arg1
);
8425 elsif not Has_Discriminants
(Typ
)
8426 or else Ekind
(Etype
(First_Discriminant
(Typ
)))
8427 /= E_Anonymous_Access_Type
8429 not Is_Class_Wide_Type
8430 (Designated_Type
(Etype
(First_Discriminant
(Typ
))))
8433 ("type must have a class-wide access discriminant", Arg1
);
8441 -- pragma Keep_Names ([On => ] local_NAME);
8443 when Pragma_Keep_Names
=> Keep_Names
: declare
8448 Check_Arg_Count
(1);
8449 Check_Optional_Identifier
(Arg1
, Name_On
);
8450 Check_Arg_Is_Local_Name
(Arg1
);
8452 Arg
:= Expression
(Arg1
);
8455 if Etype
(Arg
) = Any_Type
then
8459 if not Is_Entity_Name
(Arg
)
8460 or else Ekind
(Entity
(Arg
)) /= E_Enumeration_Type
8463 ("pragma% requires a local enumeration type", Arg1
);
8466 Set_Discard_Names
(Entity
(Arg
), False);
8473 -- pragma License (RESTRICTED | UNRESTRICTED | GPL | MODIFIED_GPL);
8475 when Pragma_License
=>
8477 Check_Arg_Count
(1);
8478 Check_No_Identifiers
;
8479 Check_Valid_Configuration_Pragma
;
8480 Check_Arg_Is_Identifier
(Arg1
);
8483 Sind
: constant Source_File_Index
:=
8484 Source_Index
(Current_Sem_Unit
);
8487 case Chars
(Get_Pragma_Arg
(Arg1
)) is
8489 Set_License
(Sind
, GPL
);
8491 when Name_Modified_GPL
=>
8492 Set_License
(Sind
, Modified_GPL
);
8494 when Name_Restricted
=>
8495 Set_License
(Sind
, Restricted
);
8497 when Name_Unrestricted
=>
8498 Set_License
(Sind
, Unrestricted
);
8501 Error_Pragma_Arg
("invalid license name", Arg1
);
8509 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
8511 when Pragma_Link_With
=> Link_With
: declare
8517 if Operating_Mode
= Generate_Code
8518 and then In_Extended_Main_Source_Unit
(N
)
8520 Check_At_Least_N_Arguments
(1);
8521 Check_No_Identifiers
;
8522 Check_Is_In_Decl_Part_Or_Package_Spec
;
8523 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
8527 while Present
(Arg
) loop
8528 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
8530 -- Store argument, converting sequences of spaces to a
8531 -- single null character (this is one of the differences
8532 -- in processing between Link_With and Linker_Options).
8535 C
: constant Char_Code
:= Get_Char_Code
(' ');
8536 S
: constant String_Id
:=
8537 Strval
(Expr_Value_S
(Expression
(Arg
)));
8538 L
: constant Nat
:= String_Length
(S
);
8541 procedure Skip_Spaces
;
8542 -- Advance F past any spaces
8548 procedure Skip_Spaces
is
8550 while F
<= L
and then Get_String_Char
(S
, F
) = C
loop
8555 -- Start of processing for Arg_Store
8558 Skip_Spaces
; -- skip leading spaces
8560 -- Loop through characters, changing any embedded
8561 -- sequence of spaces to a single null character (this
8562 -- is how Link_With/Linker_Options differ)
8565 if Get_String_Char
(S
, F
) = C
then
8568 Store_String_Char
(ASCII
.NUL
);
8571 Store_String_Char
(Get_String_Char
(S
, F
));
8579 if Present
(Arg
) then
8580 Store_String_Char
(ASCII
.NUL
);
8584 Store_Linker_Option_String
(End_String
);
8592 -- pragma Linker_Alias (
8593 -- [Entity =>] LOCAL_NAME
8594 -- [Target =>] static_string_EXPRESSION);
8596 when Pragma_Linker_Alias
=>
8598 Check_Arg_Order
((Name_Entity
, Name_Target
));
8599 Check_Arg_Count
(2);
8600 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8601 Check_Optional_Identifier
(Arg2
, Name_Target
);
8602 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
8603 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
8605 -- The only processing required is to link this item on to the
8606 -- list of rep items for the given entity. This is accomplished
8607 -- by the call to Rep_Item_Too_Late (when no error is detected
8608 -- and False is returned).
8610 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
8613 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
8616 ------------------------
8617 -- Linker_Constructor --
8618 ------------------------
8620 -- pragma Linker_Constructor (procedure_LOCAL_NAME);
8622 -- Code is shared with Linker_Destructor
8624 -----------------------
8625 -- Linker_Destructor --
8626 -----------------------
8628 -- pragma Linker_Destructor (procedure_LOCAL_NAME);
8630 when Pragma_Linker_Constructor |
8631 Pragma_Linker_Destructor
=>
8632 Linker_Constructor
: declare
8638 Check_Arg_Count
(1);
8639 Check_No_Identifiers
;
8640 Check_Arg_Is_Local_Name
(Arg1
);
8641 Arg1_X
:= Expression
(Arg1
);
8643 Proc
:= Find_Unique_Parameterless_Procedure
(Arg1_X
, Arg1
);
8645 if not Is_Library_Level_Entity
(Proc
) then
8647 ("argument for pragma% must be library level entity", Arg1
);
8650 -- The only processing required is to link this item on to the
8651 -- list of rep items for the given entity. This is accomplished
8652 -- by the call to Rep_Item_Too_Late (when no error is detected
8653 -- and False is returned).
8655 if Rep_Item_Too_Late
(Proc
, N
) then
8658 Set_Has_Gigi_Rep_Item
(Proc
);
8660 end Linker_Constructor
;
8662 --------------------
8663 -- Linker_Options --
8664 --------------------
8666 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
8668 when Pragma_Linker_Options
=> Linker_Options
: declare
8672 Check_Ada_83_Warning
;
8673 Check_No_Identifiers
;
8674 Check_Arg_Count
(1);
8675 Check_Is_In_Decl_Part_Or_Package_Spec
;
8676 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
8677 Start_String
(Strval
(Expr_Value_S
(Expression
(Arg1
))));
8680 while Present
(Arg
) loop
8681 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
8682 Store_String_Char
(ASCII
.NUL
);
8683 Store_String_Chars
(Strval
(Expr_Value_S
(Expression
(Arg
))));
8687 if Operating_Mode
= Generate_Code
8688 and then In_Extended_Main_Source_Unit
(N
)
8690 Store_Linker_Option_String
(End_String
);
8694 --------------------
8695 -- Linker_Section --
8696 --------------------
8698 -- pragma Linker_Section (
8699 -- [Entity =>] LOCAL_NAME
8700 -- [Section =>] static_string_EXPRESSION);
8702 when Pragma_Linker_Section
=>
8704 Check_Arg_Order
((Name_Entity
, Name_Section
));
8705 Check_Arg_Count
(2);
8706 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8707 Check_Optional_Identifier
(Arg2
, Name_Section
);
8708 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
8709 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
8711 -- This pragma applies only to objects
8713 if not Is_Object
(Entity
(Expression
(Arg1
))) then
8714 Error_Pragma_Arg
("pragma% applies only to objects", Arg1
);
8717 -- The only processing required is to link this item on to the
8718 -- list of rep items for the given entity. This is accomplished
8719 -- by the call to Rep_Item_Too_Late (when no error is detected
8720 -- and False is returned).
8722 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
8725 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
8732 -- pragma List (On | Off)
8734 -- There is nothing to do here, since we did all the processing for
8735 -- this pragma in Par.Prag (so that it works properly even in syntax
8741 --------------------
8742 -- Locking_Policy --
8743 --------------------
8745 -- pragma Locking_Policy (policy_IDENTIFIER);
8747 when Pragma_Locking_Policy
=> declare
8751 Check_Ada_83_Warning
;
8752 Check_Arg_Count
(1);
8753 Check_No_Identifiers
;
8754 Check_Arg_Is_Locking_Policy
(Arg1
);
8755 Check_Valid_Configuration_Pragma
;
8756 Get_Name_String
(Chars
(Expression
(Arg1
)));
8757 LP
:= Fold_Upper
(Name_Buffer
(1));
8759 if Locking_Policy
/= ' '
8760 and then Locking_Policy
/= LP
8762 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
8763 Error_Pragma
("locking policy incompatible with policy#");
8765 -- Set new policy, but always preserve System_Location since we
8766 -- like the error message with the run time name.
8769 Locking_Policy
:= LP
;
8771 if Locking_Policy_Sloc
/= System_Location
then
8772 Locking_Policy_Sloc
:= Loc
;
8781 -- pragma Long_Float (D_Float | G_Float);
8783 when Pragma_Long_Float
=>
8785 Check_Valid_Configuration_Pragma
;
8786 Check_Arg_Count
(1);
8787 Check_No_Identifier
(Arg1
);
8788 Check_Arg_Is_One_Of
(Arg1
, Name_D_Float
, Name_G_Float
);
8790 if not OpenVMS_On_Target
then
8791 Error_Pragma
("?pragma% ignored (applies only to Open'V'M'S)");
8796 if Chars
(Expression
(Arg1
)) = Name_D_Float
then
8797 if Opt
.Float_Format_Long
= 'G' then
8798 Error_Pragma
("G_Float previously specified");
8801 Opt
.Float_Format_Long
:= 'D';
8803 -- G_Float case (this is the default, does not need overriding)
8806 if Opt
.Float_Format_Long
= 'D' then
8807 Error_Pragma
("D_Float previously specified");
8810 Opt
.Float_Format_Long
:= 'G';
8813 Set_Standard_Fpt_Formats
;
8815 -----------------------
8816 -- Machine_Attribute --
8817 -----------------------
8819 -- pragma Machine_Attribute (
8820 -- [Entity =>] LOCAL_NAME,
8821 -- [Attribute_Name =>] static_string_EXPRESSION
8822 -- [, [Info =>] static_string_EXPRESSION] );
8824 when Pragma_Machine_Attribute
=> Machine_Attribute
: declare
8829 Check_Arg_Order
((Name_Entity
, Name_Attribute_Name
, Name_Info
));
8831 if Arg_Count
= 3 then
8832 Check_Optional_Identifier
(Arg3
, Name_Info
);
8833 Check_Arg_Is_Static_Expression
(Arg3
, Standard_String
);
8835 Check_Arg_Count
(2);
8838 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8839 Check_Optional_Identifier
(Arg2
, Name_Attribute_Name
);
8840 Check_Arg_Is_Local_Name
(Arg1
);
8841 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
8842 Def_Id
:= Entity
(Expression
(Arg1
));
8844 if Is_Access_Type
(Def_Id
) then
8845 Def_Id
:= Designated_Type
(Def_Id
);
8848 if Rep_Item_Too_Early
(Def_Id
, N
) then
8852 Def_Id
:= Underlying_Type
(Def_Id
);
8854 -- The only processing required is to link this item on to the
8855 -- list of rep items for the given entity. This is accomplished
8856 -- by the call to Rep_Item_Too_Late (when no error is detected
8857 -- and False is returned).
8859 if Rep_Item_Too_Late
(Def_Id
, N
) then
8862 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
8864 end Machine_Attribute
;
8871 -- (MAIN_OPTION [, MAIN_OPTION]);
8874 -- [STACK_SIZE =>] static_integer_EXPRESSION
8875 -- | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
8876 -- | [TIME_SLICING_ENABLED =>] static_boolean_EXPRESSION
8878 when Pragma_Main
=> Main
: declare
8879 Args
: Args_List
(1 .. 3);
8880 Names
: constant Name_List
(1 .. 3) := (
8882 Name_Task_Stack_Size_Default
,
8883 Name_Time_Slicing_Enabled
);
8889 Gather_Associations
(Names
, Args
);
8891 for J
in 1 .. 2 loop
8892 if Present
(Args
(J
)) then
8893 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
8897 if Present
(Args
(3)) then
8898 Check_Arg_Is_Static_Expression
(Args
(3), Standard_Boolean
);
8902 while Present
(Nod
) loop
8903 if Nkind
(Nod
) = N_Pragma
8904 and then Pragma_Name
(Nod
) = Name_Main
8906 Error_Msg_Name_1
:= Pname
;
8907 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
8918 -- pragma Main_Storage
8919 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
8921 -- MAIN_STORAGE_OPTION ::=
8922 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
8923 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
8925 when Pragma_Main_Storage
=> Main_Storage
: declare
8926 Args
: Args_List
(1 .. 2);
8927 Names
: constant Name_List
(1 .. 2) := (
8928 Name_Working_Storage
,
8935 Gather_Associations
(Names
, Args
);
8937 for J
in 1 .. 2 loop
8938 if Present
(Args
(J
)) then
8939 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
8943 Check_In_Main_Program
;
8946 while Present
(Nod
) loop
8947 if Nkind
(Nod
) = N_Pragma
8948 and then Pragma_Name
(Nod
) = Name_Main_Storage
8950 Error_Msg_Name_1
:= Pname
;
8951 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
8962 -- pragma Memory_Size (NUMERIC_LITERAL)
8964 when Pragma_Memory_Size
=>
8967 -- Memory size is simply ignored
8969 Check_No_Identifiers
;
8970 Check_Arg_Count
(1);
8971 Check_Arg_Is_Integer_Literal
(Arg1
);
8979 -- The only correct use of this pragma is on its own in a file, in
8980 -- which case it is specially processed (see Gnat1drv.Check_Bad_Body
8981 -- and Frontend, which use Sinput.L.Source_File_Is_Pragma_No_Body to
8982 -- check for a file containing nothing but a No_Body pragma). If we
8983 -- attempt to process it during normal semantics processing, it means
8984 -- it was misplaced.
8986 when Pragma_No_Body
=>
8994 -- pragma No_Return (procedure_LOCAL_NAME {, procedure_Local_Name});
8996 when Pragma_No_Return
=> No_Return
: declare
9004 Check_At_Least_N_Arguments
(1);
9006 -- Loop through arguments of pragma
9009 while Present
(Arg
) loop
9010 Check_Arg_Is_Local_Name
(Arg
);
9011 Id
:= Expression
(Arg
);
9014 if not Is_Entity_Name
(Id
) then
9015 Error_Pragma_Arg
("entity name required", Arg
);
9018 if Etype
(Id
) = Any_Type
then
9022 -- Loop to find matching procedures
9027 and then Scope
(E
) = Current_Scope
9029 if Ekind
(E
) = E_Procedure
9030 or else Ekind
(E
) = E_Generic_Procedure
9034 -- Set flag on any alias as well
9036 if Is_Overloadable
(E
) and then Present
(Alias
(E
)) then
9037 Set_No_Return
(Alias
(E
));
9047 Error_Pragma_Arg
("no procedure & found for pragma%", Arg
);
9058 -- pragma No_Run_Time;
9060 -- Note: this pragma is retained for backwards compatibility. See
9061 -- body of Rtsfind for full details on its handling.
9063 when Pragma_No_Run_Time
=>
9065 Check_Valid_Configuration_Pragma
;
9066 Check_Arg_Count
(0);
9068 No_Run_Time_Mode
:= True;
9069 Configurable_Run_Time_Mode
:= True;
9071 -- Set Duration to 32 bits if word size is 32
9073 if Ttypes
.System_Word_Size
= 32 then
9074 Duration_32_Bits_On_Target
:= True;
9077 -- Set appropriate restrictions
9079 Set_Restriction
(No_Finalization
, N
);
9080 Set_Restriction
(No_Exception_Handlers
, N
);
9081 Set_Restriction
(Max_Tasks
, N
, 0);
9082 Set_Restriction
(No_Tasking
, N
);
9084 ------------------------
9085 -- No_Strict_Aliasing --
9086 ------------------------
9088 -- pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
9090 when Pragma_No_Strict_Aliasing
=> No_Strict_Aliasing
: declare
9095 Check_At_Most_N_Arguments
(1);
9097 if Arg_Count
= 0 then
9098 Check_Valid_Configuration_Pragma
;
9099 Opt
.No_Strict_Aliasing
:= True;
9102 Check_Optional_Identifier
(Arg2
, Name_Entity
);
9103 Check_Arg_Is_Local_Name
(Arg1
);
9104 E_Id
:= Entity
(Expression
(Arg1
));
9106 if E_Id
= Any_Type
then
9108 elsif No
(E_Id
) or else not Is_Access_Type
(E_Id
) then
9109 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
9112 Set_No_Strict_Aliasing
(Implementation_Base_Type
(E_Id
));
9114 end No_Strict_Aliasing
;
9116 -----------------------
9117 -- Normalize_Scalars --
9118 -----------------------
9120 -- pragma Normalize_Scalars;
9122 when Pragma_Normalize_Scalars
=>
9123 Check_Ada_83_Warning
;
9124 Check_Arg_Count
(0);
9125 Check_Valid_Configuration_Pragma
;
9126 Normalize_Scalars
:= True;
9127 Init_Or_Norm_Scalars
:= True;
9133 -- pragma Obsolescent;
9135 -- pragma Obsolescent (
9136 -- [Message =>] static_string_EXPRESSION
9137 -- [,[Version =>] Ada_05]]);
9139 -- pragma Obsolescent (
9141 -- [,[Message =>] static_string_EXPRESSION
9142 -- [,[Version =>] Ada_05]] );
9144 when Pragma_Obsolescent
=> Obsolescent
: declare
9148 procedure Set_Obsolescent
(E
: Entity_Id
);
9149 -- Given an entity Ent, mark it as obsolescent if appropriate
9151 ---------------------
9152 -- Set_Obsolescent --
9153 ---------------------
9155 procedure Set_Obsolescent
(E
: Entity_Id
) is
9164 -- Entity name was given
9166 if Present
(Ename
) then
9168 -- If entity name matches, we are fine. Save entity in
9169 -- pragma argument, for ASIS use.
9171 if Chars
(Ename
) = Chars
(Ent
) then
9172 Set_Entity
(Ename
, Ent
);
9173 Generate_Reference
(Ent
, Ename
);
9175 -- If entity name does not match, only possibility is an
9176 -- enumeration literal from an enumeration type declaration.
9178 elsif Ekind
(Ent
) /= E_Enumeration_Type
then
9180 ("pragma % entity name does not match declaration");
9183 Ent
:= First_Literal
(E
);
9187 ("pragma % entity name does not match any " &
9188 "enumeration literal");
9190 elsif Chars
(Ent
) = Chars
(Ename
) then
9191 Set_Entity
(Ename
, Ent
);
9192 Generate_Reference
(Ent
, Ename
);
9196 Ent
:= Next_Literal
(Ent
);
9202 -- Ent points to entity to be marked
9204 if Arg_Count
>= 1 then
9206 -- Deal with static string argument
9208 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
9209 S
:= Strval
(Expression
(Arg1
));
9211 for J
in 1 .. String_Length
(S
) loop
9212 if not In_Character_Range
(Get_String_Char
(S
, J
)) then
9214 ("pragma% argument does not allow wide characters",
9219 Obsolescent_Warnings
.Append
9220 ((Ent
=> Ent
, Msg
=> Strval
(Expression
(Arg1
))));
9222 -- Check for Ada_05 parameter
9224 if Arg_Count
/= 1 then
9225 Check_Arg_Count
(2);
9228 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg2
);
9231 Check_Arg_Is_Identifier
(Argx
);
9233 if Chars
(Argx
) /= Name_Ada_05
then
9234 Error_Msg_Name_2
:= Name_Ada_05
;
9236 ("only allowed argument for pragma% is %", Argx
);
9239 if Ada_Version_Explicit
< Ada_05
9240 or else not Warn_On_Ada_2005_Compatibility
9248 -- Set flag if pragma active
9251 Set_Is_Obsolescent
(Ent
);
9255 end Set_Obsolescent
;
9257 -- Start of processing for pragma Obsolescent
9262 Check_At_Most_N_Arguments
(3);
9264 -- See if first argument specifies an entity name
9268 (Chars
(Arg1
) = Name_Entity
9270 Nkind_In
(Get_Pragma_Arg
(Arg1
), N_Character_Literal
,
9274 Ename
:= Get_Pragma_Arg
(Arg1
);
9276 -- Eliminate first argument, so we can share processing
9280 Arg_Count
:= Arg_Count
- 1;
9282 -- No Entity name argument given
9288 if Arg_Count
>= 1 then
9289 Check_Optional_Identifier
(Arg1
, Name_Message
);
9291 if Arg_Count
= 2 then
9292 Check_Optional_Identifier
(Arg2
, Name_Version
);
9296 -- Get immediately preceding declaration
9299 while Present
(Decl
) and then Nkind
(Decl
) = N_Pragma
loop
9303 -- Cases where we do not follow anything other than another pragma
9307 -- First case: library level compilation unit declaration with
9308 -- the pragma immediately following the declaration.
9310 if Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
9312 (Defining_Entity
(Unit
(Parent
(Parent
(N
)))));
9315 -- Case 2: library unit placement for package
9319 Ent
: constant Entity_Id
:= Find_Lib_Unit_Name
;
9321 if Is_Package_Or_Generic_Package
(Ent
) then
9322 Set_Obsolescent
(Ent
);
9328 -- Cases where we must follow a declaration
9331 if Nkind
(Decl
) not in N_Declaration
9332 and then Nkind
(Decl
) not in N_Later_Decl_Item
9333 and then Nkind
(Decl
) not in N_Generic_Declaration
9334 and then Nkind
(Decl
) not in N_Renaming_Declaration
9337 ("pragma% misplaced, "
9338 & "must immediately follow a declaration");
9341 Set_Obsolescent
(Defining_Entity
(Decl
));
9351 -- pragma Optimize (Time | Space | Off);
9353 -- The actual check for optimize is done in Gigi. Note that this
9354 -- pragma does not actually change the optimization setting, it
9355 -- simply checks that it is consistent with the pragma.
9357 when Pragma_Optimize
=>
9358 Check_No_Identifiers
;
9359 Check_Arg_Count
(1);
9360 Check_Arg_Is_One_Of
(Arg1
, Name_Time
, Name_Space
, Name_Off
);
9362 ------------------------
9363 -- Optimize_Alignment --
9364 ------------------------
9366 -- pragma Optimize_Alignment (Time | Space | Off);
9368 when Pragma_Optimize_Alignment
=>
9370 Check_No_Identifiers
;
9371 Check_Arg_Count
(1);
9372 Check_Valid_Configuration_Pragma
;
9375 Nam
: constant Name_Id
:= Chars
(Get_Pragma_Arg
(Arg1
));
9379 Opt
.Optimize_Alignment
:= 'T';
9381 Opt
.Optimize_Alignment
:= 'S';
9383 Opt
.Optimize_Alignment
:= 'O';
9385 Error_Pragma_Arg
("invalid argument for pragma%", Arg1
);
9389 -- Set indication that mode is set locally. If we are in fact in a
9390 -- configuration pragma file, this setting is harmless since the
9391 -- switch will get reset anyway at the start of each unit.
9393 Optimize_Alignment_Local
:= True;
9399 -- pragma Pack (first_subtype_LOCAL_NAME);
9401 when Pragma_Pack
=> Pack
: declare
9402 Assoc
: constant Node_Id
:= Arg1
;
9407 Check_No_Identifiers
;
9408 Check_Arg_Count
(1);
9409 Check_Arg_Is_Local_Name
(Arg1
);
9411 Type_Id
:= Expression
(Assoc
);
9412 Find_Type
(Type_Id
);
9413 Typ
:= Entity
(Type_Id
);
9416 or else Rep_Item_Too_Early
(Typ
, N
)
9420 Typ
:= Underlying_Type
(Typ
);
9423 if not Is_Array_Type
(Typ
) and then not Is_Record_Type
(Typ
) then
9424 Error_Pragma
("pragma% must specify array or record type");
9427 Check_First_Subtype
(Arg1
);
9429 if Has_Pragma_Pack
(Typ
) then
9430 Error_Pragma
("duplicate pragma%, only one allowed");
9434 elsif Is_Array_Type
(Typ
) then
9436 -- Pack not allowed for aliased or atomic components
9438 if Has_Aliased_Components
(Base_Type
(Typ
)) then
9440 ("pragma% ignored, cannot pack aliased components?");
9442 elsif Has_Atomic_Components
(Typ
)
9443 or else Is_Atomic
(Component_Type
(Typ
))
9446 ("?pragma% ignored, cannot pack atomic components");
9449 -- If we had an explicit component size given, then we do not
9450 -- let Pack override this given size. We also give a warning
9451 -- that Pack is being ignored unless we can tell for sure that
9452 -- the Pack would not have had any effect anyway.
9454 if Has_Component_Size_Clause
(Typ
) then
9455 if Known_Static_RM_Size
(Component_Type
(Typ
))
9457 RM_Size
(Component_Type
(Typ
)) = Component_Size
(Typ
)
9462 ("?pragma% ignored, explicit component size given");
9465 -- If no prior array component size given, Pack is effective
9468 if not Rep_Item_Too_Late
(Typ
, N
) then
9469 if VM_Target
= No_VM
then
9470 Set_Is_Packed
(Base_Type
(Typ
));
9471 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
9472 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
9474 elsif not GNAT_Mode
then
9476 ("?pragma% ignored in this configuration");
9481 -- For record types, the pack is always effective
9483 else pragma Assert
(Is_Record_Type
(Typ
));
9484 if not Rep_Item_Too_Late
(Typ
, N
) then
9485 if VM_Target
= No_VM
then
9486 Set_Is_Packed
(Base_Type
(Typ
));
9487 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
9488 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
9490 elsif not GNAT_Mode
then
9491 Error_Pragma
("?pragma% ignored in this configuration");
9503 -- There is nothing to do here, since we did all the processing for
9504 -- this pragma in Par.Prag (so that it works properly even in syntax
9514 -- pragma Passive [(PASSIVE_FORM)];
9516 -- PASSIVE_FORM ::= Semaphore | No
9518 when Pragma_Passive
=>
9521 if Nkind
(Parent
(N
)) /= N_Task_Definition
then
9522 Error_Pragma
("pragma% must be within task definition");
9525 if Arg_Count
/= 0 then
9526 Check_Arg_Count
(1);
9527 Check_Arg_Is_One_Of
(Arg1
, Name_Semaphore
, Name_No
);
9530 ----------------------------------
9531 -- Preelaborable_Initialization --
9532 ----------------------------------
9534 -- pragma Preelaborable_Initialization (DIRECT_NAME);
9536 when Pragma_Preelaborable_Initialization
=> Preelab_Init
: declare
9541 Check_Arg_Count
(1);
9542 Check_No_Identifiers
;
9543 Check_Arg_Is_Identifier
(Arg1
);
9544 Check_Arg_Is_Local_Name
(Arg1
);
9545 Check_First_Subtype
(Arg1
);
9546 Ent
:= Entity
(Expression
(Arg1
));
9548 if not Is_Private_Type
(Ent
)
9549 and then not Is_Protected_Type
(Ent
)
9552 ("pragma % can only be applied to private or protected type",
9556 -- Give an error if the pragma is applied to a protected type that
9557 -- does not qualify (due to having entries, or due to components
9558 -- that do not qualify).
9560 if Is_Protected_Type
(Ent
)
9561 and then not Has_Preelaborable_Initialization
(Ent
)
9564 ("protected type & does not have preelaborable " &
9565 "initialization", Ent
);
9567 -- Otherwise mark the type as definitely having preelaborable
9571 Set_Known_To_Have_Preelab_Init
(Ent
);
9574 if Has_Pragma_Preelab_Init
(Ent
)
9575 and then Warn_On_Redundant_Constructs
9577 Error_Pragma
("?duplicate pragma%!");
9579 Set_Has_Pragma_Preelab_Init
(Ent
);
9583 --------------------
9584 -- Persistent_BSS --
9585 --------------------
9587 when Pragma_Persistent_BSS
=> Persistent_BSS
: declare
9594 Check_At_Most_N_Arguments
(1);
9596 -- Case of application to specific object (one argument)
9598 if Arg_Count
= 1 then
9599 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
9601 if not Is_Entity_Name
(Expression
(Arg1
))
9603 (Ekind
(Entity
(Expression
(Arg1
))) /= E_Variable
9604 and then Ekind
(Entity
(Expression
(Arg1
))) /= E_Constant
)
9606 Error_Pragma_Arg
("pragma% only applies to objects", Arg1
);
9609 Ent
:= Entity
(Expression
(Arg1
));
9610 Decl
:= Parent
(Ent
);
9612 if Rep_Item_Too_Late
(Ent
, N
) then
9616 if Present
(Expression
(Decl
)) then
9618 ("object for pragma% cannot have initialization", Arg1
);
9621 if not Is_Potentially_Persistent_Type
(Etype
(Ent
)) then
9623 ("object type for pragma% is not potentially persistent",
9628 Make_Linker_Section_Pragma
9629 (Ent
, Sloc
(N
), ".persistent.bss");
9630 Insert_After
(N
, Prag
);
9633 -- Case of use as configuration pragma with no arguments
9636 Check_Valid_Configuration_Pragma
;
9637 Persistent_BSS_Mode
:= True;
9645 -- pragma Polling (ON | OFF);
9647 when Pragma_Polling
=>
9649 Check_Arg_Count
(1);
9650 Check_No_Identifiers
;
9651 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
9652 Polling_Required
:= (Chars
(Expression
(Arg1
)) = Name_On
);
9658 -- pragma Postcondition ([Check =>] Boolean_Expression
9659 -- [,[Message =>] String_Expression]);
9661 when Pragma_Postcondition
=> Postcondition
: declare
9663 pragma Warnings
(Off
, In_Body
);
9667 Check_At_Least_N_Arguments
(1);
9668 Check_At_Most_N_Arguments
(2);
9669 Check_Optional_Identifier
(Arg1
, Name_Check
);
9671 -- All we need to do here is call the common check procedure,
9672 -- the remainder of the processing is found in Sem_Ch6/Sem_Ch7.
9674 Check_Precondition_Postcondition
(In_Body
);
9681 -- pragma Precondition ([Check =>] Boolean_Expression
9682 -- [,[Message =>] String_Expression]);
9684 when Pragma_Precondition
=> Precondition
: declare
9689 Check_At_Least_N_Arguments
(1);
9690 Check_At_Most_N_Arguments
(2);
9691 Check_Optional_Identifier
(Arg1
, Name_Check
);
9693 Check_Precondition_Postcondition
(In_Body
);
9695 -- If in spec, nothing more to do. If in body, then we convert the
9696 -- pragma to pragma Check (Precondition, cond [, msg]). Note we do
9697 -- this whether or not precondition checks are enabled. That works
9698 -- fine since pragma Check will do this check.
9701 if Arg_Count
= 2 then
9702 Check_Optional_Identifier
(Arg3
, Name_Message
);
9703 Analyze_And_Resolve
(Get_Pragma_Arg
(Arg2
), Standard_String
);
9706 Analyze_And_Resolve
(Get_Pragma_Arg
(Arg1
), Standard_Boolean
);
9710 Chars
=> Name_Check
,
9711 Pragma_Argument_Associations
=> New_List
(
9712 Make_Pragma_Argument_Association
(Loc
,
9714 Make_Identifier
(Loc
,
9715 Chars
=> Name_Precondition
)),
9717 Make_Pragma_Argument_Association
(Sloc
(Arg1
),
9718 Expression
=> Relocate_Node
(Get_Pragma_Arg
(Arg1
))))));
9720 if Arg_Count
= 2 then
9721 Append_To
(Pragma_Argument_Associations
(N
),
9722 Make_Pragma_Argument_Association
(Sloc
(Arg2
),
9723 Expression
=> Relocate_Node
(Get_Pragma_Arg
(Arg2
))));
9734 -- pragma Preelaborate [(library_unit_NAME)];
9736 -- Set the flag Is_Preelaborated of program unit name entity
9738 when Pragma_Preelaborate
=> Preelaborate
: declare
9739 Pa
: constant Node_Id
:= Parent
(N
);
9740 Pk
: constant Node_Kind
:= Nkind
(Pa
);
9744 Check_Ada_83_Warning
;
9745 Check_Valid_Library_Unit_Pragma
;
9747 if Nkind
(N
) = N_Null_Statement
then
9751 Ent
:= Find_Lib_Unit_Name
;
9753 -- This filters out pragmas inside generic parent then
9754 -- show up inside instantiation
9757 and then not (Pk
= N_Package_Specification
9758 and then Present
(Generic_Parent
(Pa
)))
9760 if not Debug_Flag_U
then
9761 Set_Is_Preelaborated
(Ent
);
9762 Set_Suppress_Elaboration_Warnings
(Ent
);
9767 ---------------------
9768 -- Preelaborate_05 --
9769 ---------------------
9771 -- pragma Preelaborate_05 [(library_unit_NAME)];
9773 -- This pragma is useable only in GNAT_Mode, where it is used like
9774 -- pragma Preelaborate but it is only effective in Ada 2005 mode
9775 -- (otherwise it is ignored). This is used to implement AI-362 which
9776 -- recategorizes some run-time packages in Ada 2005 mode.
9778 when Pragma_Preelaborate_05
=> Preelaborate_05
: declare
9783 Check_Valid_Library_Unit_Pragma
;
9785 if not GNAT_Mode
then
9786 Error_Pragma
("pragma% only available in GNAT mode");
9789 if Nkind
(N
) = N_Null_Statement
then
9793 -- This is one of the few cases where we need to test the value of
9794 -- Ada_Version_Explicit rather than Ada_Version (which is always
9795 -- set to Ada_05 in a predefined unit), we need to know the
9796 -- explicit version set to know if this pragma is active.
9798 if Ada_Version_Explicit
>= Ada_05
then
9799 Ent
:= Find_Lib_Unit_Name
;
9800 Set_Is_Preelaborated
(Ent
);
9801 Set_Suppress_Elaboration_Warnings
(Ent
);
9803 end Preelaborate_05
;
9809 -- pragma Priority (EXPRESSION);
9811 when Pragma_Priority
=> Priority
: declare
9812 P
: constant Node_Id
:= Parent
(N
);
9816 Check_No_Identifiers
;
9817 Check_Arg_Count
(1);
9821 if Nkind
(P
) = N_Subprogram_Body
then
9822 Check_In_Main_Program
;
9824 Arg
:= Expression
(Arg1
);
9825 Analyze_And_Resolve
(Arg
, Standard_Integer
);
9829 if not Is_Static_Expression
(Arg
) then
9830 Flag_Non_Static_Expr
9831 ("main subprogram priority is not static!", Arg
);
9834 -- If constraint error, then we already signalled an error
9836 elsif Raises_Constraint_Error
(Arg
) then
9839 -- Otherwise check in range
9843 Val
: constant Uint
:= Expr_Value
(Arg
);
9847 or else Val
> Expr_Value
(Expression
9848 (Parent
(RTE
(RE_Max_Priority
))))
9851 ("main subprogram priority is out of range", Arg1
);
9857 (Current_Sem_Unit
, UI_To_Int
(Expr_Value
(Arg
)));
9859 -- Load an arbitrary entity from System.Tasking to make sure
9860 -- this package is implicitly with'ed, since we need to have
9861 -- the tasking run-time active for the pragma Priority to have
9865 Discard
: Entity_Id
;
9866 pragma Warnings
(Off
, Discard
);
9868 Discard
:= RTE
(RE_Task_List
);
9871 -- Task or Protected, must be of type Integer
9873 elsif Nkind_In
(P
, N_Protected_Definition
, N_Task_Definition
) then
9874 Arg
:= Expression
(Arg1
);
9876 -- The expression must be analyzed in the special manner
9877 -- described in "Handling of Default and Per-Object
9878 -- Expressions" in sem.ads.
9880 Preanalyze_Spec_Expression
(Arg
, Standard_Integer
);
9882 if not Is_Static_Expression
(Arg
) then
9883 Check_Restriction
(Static_Priorities
, Arg
);
9886 -- Anything else is incorrect
9892 if Has_Priority_Pragma
(P
) then
9893 Error_Pragma
("duplicate pragma% not allowed");
9895 Set_Has_Priority_Pragma
(P
, True);
9897 if Nkind_In
(P
, N_Protected_Definition
, N_Task_Definition
) then
9898 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
9899 -- exp_ch9 should use this ???
9904 -----------------------------------
9905 -- Priority_Specific_Dispatching --
9906 -----------------------------------
9908 -- pragma Priority_Specific_Dispatching (
9909 -- policy_IDENTIFIER,
9910 -- first_priority_EXPRESSION,
9911 -- last_priority_EXPRESSION);
9913 when Pragma_Priority_Specific_Dispatching
=>
9914 Priority_Specific_Dispatching
: declare
9915 Prio_Id
: constant Entity_Id
:= RTE
(RE_Any_Priority
);
9916 -- This is the entity System.Any_Priority;
9919 Lower_Bound
: Node_Id
;
9920 Upper_Bound
: Node_Id
;
9926 Check_Arg_Count
(3);
9927 Check_No_Identifiers
;
9928 Check_Arg_Is_Task_Dispatching_Policy
(Arg1
);
9929 Check_Valid_Configuration_Pragma
;
9930 Get_Name_String
(Chars
(Expression
(Arg1
)));
9931 DP
:= Fold_Upper
(Name_Buffer
(1));
9933 Lower_Bound
:= Expression
(Arg2
);
9934 Check_Arg_Is_Static_Expression
(Lower_Bound
, Standard_Integer
);
9935 Lower_Val
:= Expr_Value
(Lower_Bound
);
9937 Upper_Bound
:= Expression
(Arg3
);
9938 Check_Arg_Is_Static_Expression
(Upper_Bound
, Standard_Integer
);
9939 Upper_Val
:= Expr_Value
(Upper_Bound
);
9941 -- It is not allowed to use Task_Dispatching_Policy and
9942 -- Priority_Specific_Dispatching in the same partition.
9944 if Task_Dispatching_Policy
/= ' ' then
9945 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
9947 ("pragma% incompatible with Task_Dispatching_Policy#");
9949 -- Check lower bound in range
9951 elsif Lower_Val
< Expr_Value
(Type_Low_Bound
(Prio_Id
))
9953 Lower_Val
> Expr_Value
(Type_High_Bound
(Prio_Id
))
9956 ("first_priority is out of range", Arg2
);
9958 -- Check upper bound in range
9960 elsif Upper_Val
< Expr_Value
(Type_Low_Bound
(Prio_Id
))
9962 Upper_Val
> Expr_Value
(Type_High_Bound
(Prio_Id
))
9965 ("last_priority is out of range", Arg3
);
9967 -- Check that the priority range is valid
9969 elsif Lower_Val
> Upper_Val
then
9971 ("last_priority_expression must be greater than" &
9972 " or equal to first_priority_expression");
9974 -- Store the new policy, but always preserve System_Location since
9975 -- we like the error message with the run-time name.
9978 -- Check overlapping in the priority ranges specified in other
9979 -- Priority_Specific_Dispatching pragmas within the same
9980 -- partition. We can only check those we know about!
9983 Specific_Dispatching
.First
.. Specific_Dispatching
.Last
9985 if Specific_Dispatching
.Table
(J
).First_Priority
in
9986 UI_To_Int
(Lower_Val
) .. UI_To_Int
(Upper_Val
)
9987 or else Specific_Dispatching
.Table
(J
).Last_Priority
in
9988 UI_To_Int
(Lower_Val
) .. UI_To_Int
(Upper_Val
)
9991 Specific_Dispatching
.Table
(J
).Pragma_Loc
;
9993 ("priority range overlaps with "
9994 & "Priority_Specific_Dispatching#");
9998 -- The use of Priority_Specific_Dispatching is incompatible
9999 -- with Task_Dispatching_Policy.
10001 if Task_Dispatching_Policy
/= ' ' then
10002 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
10004 ("Priority_Specific_Dispatching incompatible "
10005 & "with Task_Dispatching_Policy#");
10008 -- The use of Priority_Specific_Dispatching forces ceiling
10011 if Locking_Policy
/= ' ' and then Locking_Policy
/= 'C' then
10012 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
10014 ("Priority_Specific_Dispatching incompatible "
10015 & "with Locking_Policy#");
10017 -- Set the Ceiling_Locking policy, but preserve System_Location
10018 -- since we like the error message with the run time name.
10021 Locking_Policy
:= 'C';
10023 if Locking_Policy_Sloc
/= System_Location
then
10024 Locking_Policy_Sloc
:= Loc
;
10028 -- Add entry in the table
10030 Specific_Dispatching
.Append
10031 ((Dispatching_Policy
=> DP
,
10032 First_Priority
=> UI_To_Int
(Lower_Val
),
10033 Last_Priority
=> UI_To_Int
(Upper_Val
),
10034 Pragma_Loc
=> Loc
));
10036 end Priority_Specific_Dispatching
;
10042 -- pragma Profile (profile_IDENTIFIER);
10044 -- profile_IDENTIFIER => Restricted | Ravenscar
10046 when Pragma_Profile
=>
10048 Check_Arg_Count
(1);
10049 Check_Valid_Configuration_Pragma
;
10050 Check_No_Identifiers
;
10053 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
10055 if Chars
(Argx
) = Name_Ravenscar
then
10056 Set_Ravenscar_Profile
(N
);
10057 elsif Chars
(Argx
) = Name_Restricted
then
10058 Set_Profile_Restrictions
10059 (Restricted
, N
, Warn
=> Treat_Restrictions_As_Warnings
);
10061 Error_Pragma_Arg
("& is not a valid profile", Argx
);
10065 ----------------------
10066 -- Profile_Warnings --
10067 ----------------------
10069 -- pragma Profile_Warnings (profile_IDENTIFIER);
10071 -- profile_IDENTIFIER => Restricted | Ravenscar
10073 when Pragma_Profile_Warnings
=>
10075 Check_Arg_Count
(1);
10076 Check_Valid_Configuration_Pragma
;
10077 Check_No_Identifiers
;
10080 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
10082 if Chars
(Argx
) = Name_Ravenscar
then
10083 Set_Profile_Restrictions
(Ravenscar
, N
, Warn
=> True);
10084 elsif Chars
(Argx
) = Name_Restricted
then
10085 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> True);
10087 Error_Pragma_Arg
("& is not a valid profile", Argx
);
10091 --------------------------
10092 -- Propagate_Exceptions --
10093 --------------------------
10095 -- pragma Propagate_Exceptions;
10097 -- Note: this pragma is obsolete and has no effect
10099 when Pragma_Propagate_Exceptions
=>
10101 Check_Arg_Count
(0);
10103 if In_Extended_Main_Source_Unit
(N
) then
10104 Propagate_Exceptions
:= True;
10111 -- pragma Psect_Object (
10112 -- [Internal =>] LOCAL_NAME,
10113 -- [, [External =>] EXTERNAL_SYMBOL]
10114 -- [, [Size =>] EXTERNAL_SYMBOL]);
10116 when Pragma_Psect_Object | Pragma_Common_Object
=>
10117 Psect_Object
: declare
10118 Args
: Args_List
(1 .. 3);
10119 Names
: constant Name_List
(1 .. 3) := (
10124 Internal
: Node_Id
renames Args
(1);
10125 External
: Node_Id
renames Args
(2);
10126 Size
: Node_Id
renames Args
(3);
10128 Def_Id
: Entity_Id
;
10130 procedure Check_Too_Long
(Arg
: Node_Id
);
10131 -- Posts message if the argument is an identifier with more
10132 -- than 31 characters, or a string literal with more than
10133 -- 31 characters, and we are operating under VMS
10135 --------------------
10136 -- Check_Too_Long --
10137 --------------------
10139 procedure Check_Too_Long
(Arg
: Node_Id
) is
10140 X
: constant Node_Id
:= Original_Node
(Arg
);
10143 if not Nkind_In
(X
, N_String_Literal
, N_Identifier
) then
10145 ("inappropriate argument for pragma %", Arg
);
10148 if OpenVMS_On_Target
then
10149 if (Nkind
(X
) = N_String_Literal
10150 and then String_Length
(Strval
(X
)) > 31)
10152 (Nkind
(X
) = N_Identifier
10153 and then Length_Of_Name
(Chars
(X
)) > 31)
10156 ("argument for pragma % is longer than 31 characters",
10160 end Check_Too_Long
;
10162 -- Start of processing for Common_Object/Psect_Object
10166 Gather_Associations
(Names
, Args
);
10167 Process_Extended_Import_Export_Internal_Arg
(Internal
);
10169 Def_Id
:= Entity
(Internal
);
10171 if Ekind
(Def_Id
) /= E_Constant
10172 and then Ekind
(Def_Id
) /= E_Variable
10175 ("pragma% must designate an object", Internal
);
10178 Check_Too_Long
(Internal
);
10180 if Is_Imported
(Def_Id
) or else Is_Exported
(Def_Id
) then
10182 ("cannot use pragma% for imported/exported object",
10186 if Is_Concurrent_Type
(Etype
(Internal
)) then
10188 ("cannot specify pragma % for task/protected object",
10192 if Has_Rep_Pragma
(Def_Id
, Name_Common_Object
)
10194 Has_Rep_Pragma
(Def_Id
, Name_Psect_Object
)
10196 Error_Msg_N
("?duplicate Common/Psect_Object pragma", N
);
10199 if Ekind
(Def_Id
) = E_Constant
then
10201 ("cannot specify pragma % for a constant", Internal
);
10204 if Is_Record_Type
(Etype
(Internal
)) then
10210 Ent
:= First_Entity
(Etype
(Internal
));
10211 while Present
(Ent
) loop
10212 Decl
:= Declaration_Node
(Ent
);
10214 if Ekind
(Ent
) = E_Component
10215 and then Nkind
(Decl
) = N_Component_Declaration
10216 and then Present
(Expression
(Decl
))
10217 and then Warn_On_Export_Import
10220 ("?object for pragma % has defaults", Internal
);
10230 if Present
(Size
) then
10231 Check_Too_Long
(Size
);
10234 if Present
(External
) then
10235 Check_Arg_Is_External_Name
(External
);
10236 Check_Too_Long
(External
);
10239 -- If all error tests pass, link pragma on to the rep item chain
10241 Record_Rep_Item
(Def_Id
, N
);
10248 -- pragma Pure [(library_unit_NAME)];
10250 when Pragma_Pure
=> Pure
: declare
10254 Check_Ada_83_Warning
;
10255 Check_Valid_Library_Unit_Pragma
;
10257 if Nkind
(N
) = N_Null_Statement
then
10261 Ent
:= Find_Lib_Unit_Name
;
10263 Set_Has_Pragma_Pure
(Ent
);
10264 Set_Suppress_Elaboration_Warnings
(Ent
);
10271 -- pragma Pure_05 [(library_unit_NAME)];
10273 -- This pragma is useable only in GNAT_Mode, where it is used like
10274 -- pragma Pure but it is only effective in Ada 2005 mode (otherwise
10275 -- it is ignored). It may be used after a pragma Preelaborate, in
10276 -- which case it overrides the effect of the pragma Preelaborate.
10277 -- This is used to implement AI-362 which recategorizes some run-time
10278 -- packages in Ada 2005 mode.
10280 when Pragma_Pure_05
=> Pure_05
: declare
10285 Check_Valid_Library_Unit_Pragma
;
10287 if not GNAT_Mode
then
10288 Error_Pragma
("pragma% only available in GNAT mode");
10291 if Nkind
(N
) = N_Null_Statement
then
10295 -- This is one of the few cases where we need to test the value of
10296 -- Ada_Version_Explicit rather than Ada_Version (which is always
10297 -- set to Ada_05 in a predefined unit), we need to know the
10298 -- explicit version set to know if this pragma is active.
10300 if Ada_Version_Explicit
>= Ada_05
then
10301 Ent
:= Find_Lib_Unit_Name
;
10302 Set_Is_Preelaborated
(Ent
, False);
10304 Set_Suppress_Elaboration_Warnings
(Ent
);
10308 -------------------
10309 -- Pure_Function --
10310 -------------------
10312 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
10314 when Pragma_Pure_Function
=> Pure_Function
: declare
10317 Def_Id
: Entity_Id
;
10318 Effective
: Boolean := False;
10322 Check_Arg_Count
(1);
10323 Check_Optional_Identifier
(Arg1
, Name_Entity
);
10324 Check_Arg_Is_Local_Name
(Arg1
);
10325 E_Id
:= Expression
(Arg1
);
10327 if Error_Posted
(E_Id
) then
10331 -- Loop through homonyms (overloadings) of referenced entity
10333 E
:= Entity
(E_Id
);
10335 if Present
(E
) then
10337 Def_Id
:= Get_Base_Subprogram
(E
);
10339 if Ekind
(Def_Id
) /= E_Function
10340 and then Ekind
(Def_Id
) /= E_Generic_Function
10341 and then Ekind
(Def_Id
) /= E_Operator
10344 ("pragma% requires a function name", Arg1
);
10347 Set_Is_Pure
(Def_Id
);
10349 if not Has_Pragma_Pure_Function
(Def_Id
) then
10350 Set_Has_Pragma_Pure_Function
(Def_Id
);
10355 exit when No
(E
) or else Scope
(E
) /= Current_Scope
;
10359 and then Warn_On_Redundant_Constructs
10361 Error_Msg_NE
("pragma Pure_Function on& is redundant?",
10367 --------------------
10368 -- Queuing_Policy --
10369 --------------------
10371 -- pragma Queuing_Policy (policy_IDENTIFIER);
10373 when Pragma_Queuing_Policy
=> declare
10377 Check_Ada_83_Warning
;
10378 Check_Arg_Count
(1);
10379 Check_No_Identifiers
;
10380 Check_Arg_Is_Queuing_Policy
(Arg1
);
10381 Check_Valid_Configuration_Pragma
;
10382 Get_Name_String
(Chars
(Expression
(Arg1
)));
10383 QP
:= Fold_Upper
(Name_Buffer
(1));
10385 if Queuing_Policy
/= ' '
10386 and then Queuing_Policy
/= QP
10388 Error_Msg_Sloc
:= Queuing_Policy_Sloc
;
10389 Error_Pragma
("queuing policy incompatible with policy#");
10391 -- Set new policy, but always preserve System_Location since we
10392 -- like the error message with the run time name.
10395 Queuing_Policy
:= QP
;
10397 if Queuing_Policy_Sloc
/= System_Location
then
10398 Queuing_Policy_Sloc
:= Loc
;
10403 -----------------------
10404 -- Relative_Deadline --
10405 -----------------------
10407 -- pragma Relative_Deadline (time_span_EXPRESSION);
10409 when Pragma_Relative_Deadline
=> Relative_Deadline
: declare
10410 P
: constant Node_Id
:= Parent
(N
);
10415 Check_No_Identifiers
;
10416 Check_Arg_Count
(1);
10418 Arg
:= Expression
(Arg1
);
10420 -- The expression must be analyzed in the special manner described
10421 -- in "Handling of Default and Per-Object Expressions" in sem.ads.
10423 Preanalyze_Spec_Expression
(Arg
, RTE
(RE_Time_Span
));
10427 if Nkind
(P
) = N_Subprogram_Body
then
10428 Check_In_Main_Program
;
10432 elsif Nkind
(P
) = N_Task_Definition
then
10435 -- Anything else is incorrect
10441 if Has_Relative_Deadline_Pragma
(P
) then
10442 Error_Pragma
("duplicate pragma% not allowed");
10444 Set_Has_Relative_Deadline_Pragma
(P
, True);
10446 if Nkind
(P
) = N_Task_Definition
then
10447 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
10450 end Relative_Deadline
;
10452 ---------------------------
10453 -- Remote_Call_Interface --
10454 ---------------------------
10456 -- pragma Remote_Call_Interface [(library_unit_NAME)];
10458 when Pragma_Remote_Call_Interface
=> Remote_Call_Interface
: declare
10459 Cunit_Node
: Node_Id
;
10460 Cunit_Ent
: Entity_Id
;
10464 Check_Ada_83_Warning
;
10465 Check_Valid_Library_Unit_Pragma
;
10467 if Nkind
(N
) = N_Null_Statement
then
10471 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
10472 K
:= Nkind
(Unit
(Cunit_Node
));
10473 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
10475 if K
= N_Package_Declaration
10476 or else K
= N_Generic_Package_Declaration
10477 or else K
= N_Subprogram_Declaration
10478 or else K
= N_Generic_Subprogram_Declaration
10479 or else (K
= N_Subprogram_Body
10480 and then Acts_As_Spec
(Unit
(Cunit_Node
)))
10485 "pragma% must apply to package or subprogram declaration");
10488 Set_Is_Remote_Call_Interface
(Cunit_Ent
);
10489 end Remote_Call_Interface
;
10495 -- pragma Remote_Types [(library_unit_NAME)];
10497 when Pragma_Remote_Types
=> Remote_Types
: declare
10498 Cunit_Node
: Node_Id
;
10499 Cunit_Ent
: Entity_Id
;
10502 Check_Ada_83_Warning
;
10503 Check_Valid_Library_Unit_Pragma
;
10505 if Nkind
(N
) = N_Null_Statement
then
10509 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
10510 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
10512 if not Nkind_In
(Unit
(Cunit_Node
), N_Package_Declaration
,
10513 N_Generic_Package_Declaration
)
10516 ("pragma% can only apply to a package declaration");
10519 Set_Is_Remote_Types
(Cunit_Ent
);
10526 -- pragma Ravenscar;
10528 when Pragma_Ravenscar
=>
10530 Check_Arg_Count
(0);
10531 Check_Valid_Configuration_Pragma
;
10532 Set_Ravenscar_Profile
(N
);
10534 if Warn_On_Obsolescent_Feature
then
10536 ("pragma Ravenscar is an obsolescent feature?", N
);
10538 ("|use pragma Profile (Ravenscar) instead", N
);
10541 -------------------------
10542 -- Restricted_Run_Time --
10543 -------------------------
10545 -- pragma Restricted_Run_Time;
10547 when Pragma_Restricted_Run_Time
=>
10549 Check_Arg_Count
(0);
10550 Check_Valid_Configuration_Pragma
;
10551 Set_Profile_Restrictions
10552 (Restricted
, N
, Warn
=> Treat_Restrictions_As_Warnings
);
10554 if Warn_On_Obsolescent_Feature
then
10556 ("pragma Restricted_Run_Time is an obsolescent feature?", N
);
10558 ("|use pragma Profile (Restricted) instead", N
);
10565 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
10568 -- restriction_IDENTIFIER
10569 -- | restriction_parameter_IDENTIFIER => EXPRESSION
10571 when Pragma_Restrictions
=>
10572 Process_Restrictions_Or_Restriction_Warnings
10573 (Warn
=> Treat_Restrictions_As_Warnings
);
10575 --------------------------
10576 -- Restriction_Warnings --
10577 --------------------------
10579 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
10582 -- restriction_IDENTIFIER
10583 -- | restriction_parameter_IDENTIFIER => EXPRESSION
10585 when Pragma_Restriction_Warnings
=>
10587 Process_Restrictions_Or_Restriction_Warnings
(Warn
=> True);
10593 -- pragma Reviewable;
10595 when Pragma_Reviewable
=>
10596 Check_Ada_83_Warning
;
10597 Check_Arg_Count
(0);
10600 -------------------
10601 -- Share_Generic --
10602 -------------------
10604 -- pragma Share_Generic (NAME {, NAME});
10606 when Pragma_Share_Generic
=>
10608 Process_Generic_List
;
10614 -- pragma Shared (LOCAL_NAME);
10616 when Pragma_Shared
=>
10618 Process_Atomic_Shared_Volatile
;
10620 --------------------
10621 -- Shared_Passive --
10622 --------------------
10624 -- pragma Shared_Passive [(library_unit_NAME)];
10626 -- Set the flag Is_Shared_Passive of program unit name entity
10628 when Pragma_Shared_Passive
=> Shared_Passive
: declare
10629 Cunit_Node
: Node_Id
;
10630 Cunit_Ent
: Entity_Id
;
10633 Check_Ada_83_Warning
;
10634 Check_Valid_Library_Unit_Pragma
;
10636 if Nkind
(N
) = N_Null_Statement
then
10640 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
10641 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
10643 if not Nkind_In
(Unit
(Cunit_Node
), N_Package_Declaration
,
10644 N_Generic_Package_Declaration
)
10647 ("pragma% can only apply to a package declaration");
10650 Set_Is_Shared_Passive
(Cunit_Ent
);
10651 end Shared_Passive
;
10653 ----------------------
10654 -- Source_File_Name --
10655 ----------------------
10657 -- There are five forms for this pragma:
10659 -- pragma Source_File_Name (
10660 -- [UNIT_NAME =>] unit_NAME,
10661 -- BODY_FILE_NAME => STRING_LITERAL
10662 -- [, [INDEX =>] INTEGER_LITERAL]);
10664 -- pragma Source_File_Name (
10665 -- [UNIT_NAME =>] unit_NAME,
10666 -- SPEC_FILE_NAME => STRING_LITERAL
10667 -- [, [INDEX =>] INTEGER_LITERAL]);
10669 -- pragma Source_File_Name (
10670 -- BODY_FILE_NAME => STRING_LITERAL
10671 -- [, DOT_REPLACEMENT => STRING_LITERAL]
10672 -- [, CASING => CASING_SPEC]);
10674 -- pragma Source_File_Name (
10675 -- SPEC_FILE_NAME => STRING_LITERAL
10676 -- [, DOT_REPLACEMENT => STRING_LITERAL]
10677 -- [, CASING => CASING_SPEC]);
10679 -- pragma Source_File_Name (
10680 -- SUBUNIT_FILE_NAME => STRING_LITERAL
10681 -- [, DOT_REPLACEMENT => STRING_LITERAL]
10682 -- [, CASING => CASING_SPEC]);
10684 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
10686 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
10687 -- Source_File_Name (SFN), however their usage is exclusive: SFN can
10688 -- only be used when no project file is used, while SFNP can only be
10689 -- used when a project file is used.
10691 -- No processing here. Processing was completed during parsing, since
10692 -- we need to have file names set as early as possible. Units are
10693 -- loaded well before semantic processing starts.
10695 -- The only processing we defer to this point is the check for
10696 -- correct placement.
10698 when Pragma_Source_File_Name
=>
10700 Check_Valid_Configuration_Pragma
;
10702 ------------------------------
10703 -- Source_File_Name_Project --
10704 ------------------------------
10706 -- See Source_File_Name for syntax
10708 -- No processing here. Processing was completed during parsing, since
10709 -- we need to have file names set as early as possible. Units are
10710 -- loaded well before semantic processing starts.
10712 -- The only processing we defer to this point is the check for
10713 -- correct placement.
10715 when Pragma_Source_File_Name_Project
=>
10717 Check_Valid_Configuration_Pragma
;
10719 -- Check that a pragma Source_File_Name_Project is used only in a
10720 -- configuration pragmas file.
10722 -- Pragmas Source_File_Name_Project should only be generated by
10723 -- the Project Manager in configuration pragmas files.
10725 -- This is really an ugly test. It seems to depend on some
10726 -- accidental and undocumented property. At the very least it
10727 -- needs to be documented, but it would be better to have a
10728 -- clean way of testing if we are in a configuration file???
10730 if Present
(Parent
(N
)) then
10732 ("pragma% can only appear in a configuration pragmas file");
10735 ----------------------
10736 -- Source_Reference --
10737 ----------------------
10739 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
10741 -- Nothing to do, all processing completed in Par.Prag, since we need
10742 -- the information for possible parser messages that are output.
10744 when Pragma_Source_Reference
=>
10747 --------------------------------
10748 -- Static_Elaboration_Desired --
10749 --------------------------------
10751 -- pragma Static_Elaboration_Desired (DIRECT_NAME);
10753 when Pragma_Static_Elaboration_Desired
=>
10755 Check_At_Most_N_Arguments
(1);
10757 if Is_Compilation_Unit
(Current_Scope
)
10758 and then Ekind
(Current_Scope
) = E_Package
10760 Set_Static_Elaboration_Desired
(Current_Scope
, True);
10762 Error_Pragma
("pragma% must apply to a library-level package");
10769 -- pragma Storage_Size (EXPRESSION);
10771 when Pragma_Storage_Size
=> Storage_Size
: declare
10772 P
: constant Node_Id
:= Parent
(N
);
10776 Check_No_Identifiers
;
10777 Check_Arg_Count
(1);
10779 -- The expression must be analyzed in the special manner described
10780 -- in "Handling of Default Expressions" in sem.ads.
10782 Arg
:= Expression
(Arg1
);
10783 Preanalyze_Spec_Expression
(Arg
, Any_Integer
);
10785 if not Is_Static_Expression
(Arg
) then
10786 Check_Restriction
(Static_Storage_Size
, Arg
);
10789 if Nkind
(P
) /= N_Task_Definition
then
10794 if Has_Storage_Size_Pragma
(P
) then
10795 Error_Pragma
("duplicate pragma% not allowed");
10797 Set_Has_Storage_Size_Pragma
(P
, True);
10800 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
10801 -- ??? exp_ch9 should use this!
10809 -- pragma Storage_Unit (NUMERIC_LITERAL);
10811 -- Only permitted argument is System'Storage_Unit value
10813 when Pragma_Storage_Unit
=>
10814 Check_No_Identifiers
;
10815 Check_Arg_Count
(1);
10816 Check_Arg_Is_Integer_Literal
(Arg1
);
10818 if Intval
(Expression
(Arg1
)) /=
10819 UI_From_Int
(Ttypes
.System_Storage_Unit
)
10821 Error_Msg_Uint_1
:= UI_From_Int
(Ttypes
.System_Storage_Unit
);
10823 ("the only allowed argument for pragma% is ^", Arg1
);
10826 --------------------
10827 -- Stream_Convert --
10828 --------------------
10830 -- pragma Stream_Convert (
10831 -- [Entity =>] type_LOCAL_NAME,
10832 -- [Read =>] function_NAME,
10833 -- [Write =>] function NAME);
10835 when Pragma_Stream_Convert
=> Stream_Convert
: declare
10837 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
);
10838 -- Check that the given argument is the name of a local function
10839 -- of one argument that is not overloaded earlier in the current
10840 -- local scope. A check is also made that the argument is a
10841 -- function with one parameter.
10843 --------------------------------------
10844 -- Check_OK_Stream_Convert_Function --
10845 --------------------------------------
10847 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
) is
10851 Check_Arg_Is_Local_Name
(Arg
);
10852 Ent
:= Entity
(Expression
(Arg
));
10854 if Has_Homonym
(Ent
) then
10856 ("argument for pragma% may not be overloaded", Arg
);
10859 if Ekind
(Ent
) /= E_Function
10860 or else No
(First_Formal
(Ent
))
10861 or else Present
(Next_Formal
(First_Formal
(Ent
)))
10864 ("argument for pragma% must be" &
10865 " function of one argument", Arg
);
10867 end Check_OK_Stream_Convert_Function
;
10869 -- Start of processing for Stream_Convert
10873 Check_Arg_Order
((Name_Entity
, Name_Read
, Name_Write
));
10874 Check_Arg_Count
(3);
10875 Check_Optional_Identifier
(Arg1
, Name_Entity
);
10876 Check_Optional_Identifier
(Arg2
, Name_Read
);
10877 Check_Optional_Identifier
(Arg3
, Name_Write
);
10878 Check_Arg_Is_Local_Name
(Arg1
);
10879 Check_OK_Stream_Convert_Function
(Arg2
);
10880 Check_OK_Stream_Convert_Function
(Arg3
);
10883 Typ
: constant Entity_Id
:=
10884 Underlying_Type
(Entity
(Expression
(Arg1
)));
10885 Read
: constant Entity_Id
:= Entity
(Expression
(Arg2
));
10886 Write
: constant Entity_Id
:= Entity
(Expression
(Arg3
));
10889 Check_First_Subtype
(Arg1
);
10891 -- Check for too early or too late. Note that we don't enforce
10892 -- the rule about primitive operations in this case, since, as
10893 -- is the case for explicit stream attributes themselves, these
10894 -- restrictions are not appropriate. Note that the chaining of
10895 -- the pragma by Rep_Item_Too_Late is actually the critical
10896 -- processing done for this pragma.
10898 if Rep_Item_Too_Early
(Typ
, N
)
10900 Rep_Item_Too_Late
(Typ
, N
, FOnly
=> True)
10905 -- Return if previous error
10907 if Etype
(Typ
) = Any_Type
10909 Etype
(Read
) = Any_Type
10911 Etype
(Write
) = Any_Type
10918 if Underlying_Type
(Etype
(Read
)) /= Typ
then
10920 ("incorrect return type for function&", Arg2
);
10923 if Underlying_Type
(Etype
(First_Formal
(Write
))) /= Typ
then
10925 ("incorrect parameter type for function&", Arg3
);
10928 if Underlying_Type
(Etype
(First_Formal
(Read
))) /=
10929 Underlying_Type
(Etype
(Write
))
10932 ("result type of & does not match Read parameter type",
10936 end Stream_Convert
;
10938 -------------------------
10939 -- Style_Checks (GNAT) --
10940 -------------------------
10942 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
10944 -- This is processed by the parser since some of the style checks
10945 -- take place during source scanning and parsing. This means that
10946 -- we don't need to issue error messages here.
10948 when Pragma_Style_Checks
=> Style_Checks
: declare
10949 A
: constant Node_Id
:= Expression
(Arg1
);
10955 Check_No_Identifiers
;
10957 -- Two argument form
10959 if Arg_Count
= 2 then
10960 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
10967 E_Id
:= Expression
(Arg2
);
10970 if not Is_Entity_Name
(E_Id
) then
10972 ("second argument of pragma% must be entity name",
10976 E
:= Entity
(E_Id
);
10982 Set_Suppress_Style_Checks
(E
,
10983 (Chars
(Expression
(Arg1
)) = Name_Off
));
10984 exit when No
(Homonym
(E
));
10990 -- One argument form
10993 Check_Arg_Count
(1);
10995 if Nkind
(A
) = N_String_Literal
then
10999 Slen
: constant Natural := Natural (String_Length
(S
));
11000 Options
: String (1 .. Slen
);
11006 C
:= Get_String_Char
(S
, Int
(J
));
11007 exit when not In_Character_Range
(C
);
11008 Options
(J
) := Get_Character
(C
);
11010 -- If at end of string, set options. As per discussion
11011 -- above, no need to check for errors, since we issued
11012 -- them in the parser.
11015 Set_Style_Check_Options
(Options
);
11023 elsif Nkind
(A
) = N_Identifier
then
11024 if Chars
(A
) = Name_All_Checks
then
11025 Set_Default_Style_Check_Options
;
11027 elsif Chars
(A
) = Name_On
then
11028 Style_Check
:= True;
11030 elsif Chars
(A
) = Name_Off
then
11031 Style_Check
:= False;
11041 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
11043 when Pragma_Subtitle
=>
11045 Check_Arg_Count
(1);
11046 Check_Optional_Identifier
(Arg1
, Name_Subtitle
);
11047 Check_Arg_Is_String_Literal
(Arg1
);
11053 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
11055 when Pragma_Suppress
=>
11056 Process_Suppress_Unsuppress
(True);
11062 -- pragma Suppress_All;
11064 -- The only check made here is that the pragma appears in the proper
11065 -- place, i.e. following a compilation unit. If indeed it appears in
11066 -- this context, then the parser has already inserted an equivalent
11067 -- pragma Suppress (All_Checks) to get the required effect.
11069 when Pragma_Suppress_All
=>
11071 Check_Arg_Count
(0);
11073 if Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
11074 or else not Is_List_Member
(N
)
11075 or else List_Containing
(N
) /= Pragmas_After
(Parent
(N
))
11078 ("misplaced pragma%, must follow compilation unit");
11081 -------------------------
11082 -- Suppress_Debug_Info --
11083 -------------------------
11085 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
11087 when Pragma_Suppress_Debug_Info
=>
11089 Check_Arg_Count
(1);
11090 Check_Optional_Identifier
(Arg1
, Name_Entity
);
11091 Check_Arg_Is_Local_Name
(Arg1
);
11092 Set_Debug_Info_Off
(Entity
(Get_Pragma_Arg
(Arg1
)));
11094 ----------------------------------
11095 -- Suppress_Exception_Locations --
11096 ----------------------------------
11098 -- pragma Suppress_Exception_Locations;
11100 when Pragma_Suppress_Exception_Locations
=>
11102 Check_Arg_Count
(0);
11103 Check_Valid_Configuration_Pragma
;
11104 Exception_Locations_Suppressed
:= True;
11106 -----------------------------
11107 -- Suppress_Initialization --
11108 -----------------------------
11110 -- pragma Suppress_Initialization ([Entity =>] type_Name);
11112 when Pragma_Suppress_Initialization
=> Suppress_Init
: declare
11118 Check_Arg_Count
(1);
11119 Check_Optional_Identifier
(Arg1
, Name_Entity
);
11120 Check_Arg_Is_Local_Name
(Arg1
);
11122 E_Id
:= Expression
(Arg1
);
11124 if Etype
(E_Id
) = Any_Type
then
11128 E
:= Entity
(E_Id
);
11130 if Is_Type
(E
) then
11131 if Is_Incomplete_Or_Private_Type
(E
) then
11132 if No
(Full_View
(Base_Type
(E
))) then
11134 ("argument of pragma% cannot be an incomplete type",
11137 Set_Suppress_Init_Proc
(Full_View
(Base_Type
(E
)));
11140 Set_Suppress_Init_Proc
(Base_Type
(E
));
11145 ("pragma% requires argument that is a type name", Arg1
);
11153 -- pragma System_Name (DIRECT_NAME);
11155 -- Syntax check: one argument, which must be the identifier GNAT or
11156 -- the identifier GCC, no other identifiers are acceptable.
11158 when Pragma_System_Name
=>
11160 Check_No_Identifiers
;
11161 Check_Arg_Count
(1);
11162 Check_Arg_Is_One_Of
(Arg1
, Name_Gcc
, Name_Gnat
);
11164 -----------------------------
11165 -- Task_Dispatching_Policy --
11166 -----------------------------
11168 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
11170 when Pragma_Task_Dispatching_Policy
=> declare
11174 Check_Ada_83_Warning
;
11175 Check_Arg_Count
(1);
11176 Check_No_Identifiers
;
11177 Check_Arg_Is_Task_Dispatching_Policy
(Arg1
);
11178 Check_Valid_Configuration_Pragma
;
11179 Get_Name_String
(Chars
(Expression
(Arg1
)));
11180 DP
:= Fold_Upper
(Name_Buffer
(1));
11182 if Task_Dispatching_Policy
/= ' '
11183 and then Task_Dispatching_Policy
/= DP
11185 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
11187 ("task dispatching policy incompatible with policy#");
11189 -- Set new policy, but always preserve System_Location since we
11190 -- like the error message with the run time name.
11193 Task_Dispatching_Policy
:= DP
;
11195 if Task_Dispatching_Policy_Sloc
/= System_Location
then
11196 Task_Dispatching_Policy_Sloc
:= Loc
;
11205 -- pragma Task_Info (EXPRESSION);
11207 when Pragma_Task_Info
=> Task_Info
: declare
11208 P
: constant Node_Id
:= Parent
(N
);
11213 if Nkind
(P
) /= N_Task_Definition
then
11214 Error_Pragma
("pragma% must appear in task definition");
11217 Check_No_Identifiers
;
11218 Check_Arg_Count
(1);
11220 Analyze_And_Resolve
(Expression
(Arg1
), RTE
(RE_Task_Info_Type
));
11222 if Etype
(Expression
(Arg1
)) = Any_Type
then
11226 if Has_Task_Info_Pragma
(P
) then
11227 Error_Pragma
("duplicate pragma% not allowed");
11229 Set_Has_Task_Info_Pragma
(P
, True);
11237 -- pragma Task_Name (string_EXPRESSION);
11239 when Pragma_Task_Name
=> Task_Name
: declare
11240 P
: constant Node_Id
:= Parent
(N
);
11244 Check_No_Identifiers
;
11245 Check_Arg_Count
(1);
11247 Arg
:= Expression
(Arg1
);
11249 -- The expression is used in the call to Create_Task, and must be
11250 -- expanded there, not in the context of the current spec.
11252 Preanalyze_And_Resolve
(New_Copy_Tree
(Arg
), Standard_String
);
11254 if Nkind
(P
) /= N_Task_Definition
then
11258 if Has_Task_Name_Pragma
(P
) then
11259 Error_Pragma
("duplicate pragma% not allowed");
11261 Set_Has_Task_Name_Pragma
(P
, True);
11262 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
11270 -- pragma Task_Storage (
11271 -- [Task_Type =>] LOCAL_NAME,
11272 -- [Top_Guard =>] static_integer_EXPRESSION);
11274 when Pragma_Task_Storage
=> Task_Storage
: declare
11275 Args
: Args_List
(1 .. 2);
11276 Names
: constant Name_List
(1 .. 2) := (
11280 Task_Type
: Node_Id
renames Args
(1);
11281 Top_Guard
: Node_Id
renames Args
(2);
11287 Gather_Associations
(Names
, Args
);
11289 if No
(Task_Type
) then
11291 ("missing task_type argument for pragma%");
11294 Check_Arg_Is_Local_Name
(Task_Type
);
11296 Ent
:= Entity
(Task_Type
);
11298 if not Is_Task_Type
(Ent
) then
11300 ("argument for pragma% must be task type", Task_Type
);
11303 if No
(Top_Guard
) then
11305 ("pragma% takes two arguments", Task_Type
);
11307 Check_Arg_Is_Static_Expression
(Top_Guard
, Any_Integer
);
11310 Check_First_Subtype
(Task_Type
);
11312 if Rep_Item_Too_Late
(Ent
, N
) then
11317 --------------------------
11318 -- Thread_Local_Storage --
11319 --------------------------
11321 -- pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
11323 when Pragma_Thread_Local_Storage
=> Thread_Local_Storage
: declare
11329 Check_Arg_Count
(1);
11330 Check_Optional_Identifier
(Arg1
, Name_Entity
);
11331 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
11333 Id
:= Expression
(Arg1
);
11336 if not Is_Entity_Name
(Id
)
11337 or else Ekind
(Entity
(Id
)) /= E_Variable
11339 Error_Pragma_Arg
("local variable name required", Arg1
);
11344 if Rep_Item_Too_Early
(E
, N
)
11345 or else Rep_Item_Too_Late
(E
, N
)
11350 Set_Has_Pragma_Thread_Local_Storage
(E
);
11351 Set_Has_Gigi_Rep_Item
(E
);
11352 end Thread_Local_Storage
;
11358 -- pragma Time_Slice (static_duration_EXPRESSION);
11360 when Pragma_Time_Slice
=> Time_Slice
: declare
11366 Check_Arg_Count
(1);
11367 Check_No_Identifiers
;
11368 Check_In_Main_Program
;
11369 Check_Arg_Is_Static_Expression
(Arg1
, Standard_Duration
);
11371 if not Error_Posted
(Arg1
) then
11373 while Present
(Nod
) loop
11374 if Nkind
(Nod
) = N_Pragma
11375 and then Pragma_Name
(Nod
) = Name_Time_Slice
11377 Error_Msg_Name_1
:= Pname
;
11378 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
11385 -- Process only if in main unit
11387 if Get_Source_Unit
(Loc
) = Main_Unit
then
11388 Opt
.Time_Slice_Set
:= True;
11389 Val
:= Expr_Value_R
(Expression
(Arg1
));
11391 if Val
<= Ureal_0
then
11392 Opt
.Time_Slice_Value
:= 0;
11394 elsif Val
> UR_From_Uint
(UI_From_Int
(1000)) then
11395 Opt
.Time_Slice_Value
:= 1_000_000_000
;
11398 Opt
.Time_Slice_Value
:=
11399 UI_To_Int
(UR_To_Uint
(Val
* UI_From_Int
(1_000_000
)));
11408 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
11410 -- TITLING_OPTION ::=
11411 -- [Title =>] STRING_LITERAL
11412 -- | [Subtitle =>] STRING_LITERAL
11414 when Pragma_Title
=> Title
: declare
11415 Args
: Args_List
(1 .. 2);
11416 Names
: constant Name_List
(1 .. 2) := (
11422 Gather_Associations
(Names
, Args
);
11424 for J
in 1 .. 2 loop
11425 if Present
(Args
(J
)) then
11426 Check_Arg_Is_String_Literal
(Args
(J
));
11431 ---------------------
11432 -- Unchecked_Union --
11433 ---------------------
11435 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
11437 when Pragma_Unchecked_Union
=> Unchecked_Union
: declare
11438 Assoc
: constant Node_Id
:= Arg1
;
11439 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
11450 Check_No_Identifiers
;
11451 Check_Arg_Count
(1);
11452 Check_Arg_Is_Local_Name
(Arg1
);
11454 Find_Type
(Type_Id
);
11455 Typ
:= Entity
(Type_Id
);
11458 or else Rep_Item_Too_Early
(Typ
, N
)
11462 Typ
:= Underlying_Type
(Typ
);
11465 if Rep_Item_Too_Late
(Typ
, N
) then
11469 Check_First_Subtype
(Arg1
);
11471 -- Note remaining cases are references to a type in the current
11472 -- declarative part. If we find an error, we post the error on
11473 -- the relevant type declaration at an appropriate point.
11475 if not Is_Record_Type
(Typ
) then
11476 Error_Msg_N
("Unchecked_Union must be record type", Typ
);
11479 elsif Is_Tagged_Type
(Typ
) then
11480 Error_Msg_N
("Unchecked_Union must not be tagged", Typ
);
11483 elsif Is_Limited_Type
(Typ
) then
11485 ("Unchecked_Union must not be limited record type", Typ
);
11486 Explain_Limited_Type
(Typ
, Typ
);
11490 if not Has_Discriminants
(Typ
) then
11492 ("Unchecked_Union must have one discriminant", Typ
);
11496 Discr
:= First_Discriminant
(Typ
);
11497 while Present
(Discr
) loop
11498 if No
(Discriminant_Default_Value
(Discr
)) then
11500 ("Unchecked_Union discriminant must have default value",
11503 Next_Discriminant
(Discr
);
11506 Tdef
:= Type_Definition
(Declaration_Node
(Typ
));
11507 Clist
:= Component_List
(Tdef
);
11509 Comp
:= First
(Component_Items
(Clist
));
11510 while Present
(Comp
) loop
11511 Check_Component
(Comp
);
11515 if No
(Clist
) or else No
(Variant_Part
(Clist
)) then
11517 ("Unchecked_Union must have variant part",
11522 Vpart
:= Variant_Part
(Clist
);
11524 Variant
:= First
(Variants
(Vpart
));
11525 while Present
(Variant
) loop
11526 Check_Variant
(Variant
);
11531 Set_Is_Unchecked_Union
(Typ
, True);
11532 Set_Convention
(Typ
, Convention_C
);
11534 Set_Has_Unchecked_Union
(Base_Type
(Typ
), True);
11535 Set_Is_Unchecked_Union
(Base_Type
(Typ
), True);
11536 end Unchecked_Union
;
11538 ------------------------
11539 -- Unimplemented_Unit --
11540 ------------------------
11542 -- pragma Unimplemented_Unit;
11544 -- Note: this only gives an error if we are generating code, or if
11545 -- we are in a generic library unit (where the pragma appears in the
11546 -- body, not in the spec).
11548 when Pragma_Unimplemented_Unit
=> Unimplemented_Unit
: declare
11549 Cunitent
: constant Entity_Id
:=
11550 Cunit_Entity
(Get_Source_Unit
(Loc
));
11551 Ent_Kind
: constant Entity_Kind
:=
11556 Check_Arg_Count
(0);
11558 if Operating_Mode
= Generate_Code
11559 or else Ent_Kind
= E_Generic_Function
11560 or else Ent_Kind
= E_Generic_Procedure
11561 or else Ent_Kind
= E_Generic_Package
11563 Get_Name_String
(Chars
(Cunitent
));
11564 Set_Casing
(Mixed_Case
);
11565 Write_Str
(Name_Buffer
(1 .. Name_Len
));
11566 Write_Str
(" is not supported in this configuration");
11568 raise Unrecoverable_Error
;
11570 end Unimplemented_Unit
;
11572 ------------------------
11573 -- Universal_Aliasing --
11574 ------------------------
11576 -- pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
11578 when Pragma_Universal_Aliasing
=> Universal_Alias
: declare
11583 Check_Arg_Count
(1);
11584 Check_Optional_Identifier
(Arg2
, Name_Entity
);
11585 Check_Arg_Is_Local_Name
(Arg1
);
11586 E_Id
:= Entity
(Expression
(Arg1
));
11588 if E_Id
= Any_Type
then
11590 elsif No
(E_Id
) or else not Is_Type
(E_Id
) then
11591 Error_Pragma_Arg
("pragma% requires type", Arg1
);
11594 Set_Universal_Aliasing
(Implementation_Base_Type
(E_Id
));
11595 end Universal_Alias
;
11597 --------------------
11598 -- Universal_Data --
11599 --------------------
11601 -- pragma Universal_Data [(library_unit_NAME)];
11603 when Pragma_Universal_Data
=>
11606 -- If this is a configuration pragma, then set the universal
11607 -- addressing option, otherwise confirm that the pragma satisfies
11608 -- the requirements of library unit pragma placement and leave it
11609 -- to the GNAAMP back end to detect the pragma (avoids transitive
11610 -- setting of the option due to withed units).
11612 if Is_Configuration_Pragma
then
11613 Universal_Addressing_On_AAMP
:= True;
11615 Check_Valid_Library_Unit_Pragma
;
11618 if not AAMP_On_Target
then
11619 Error_Pragma
("?pragma% ignored (applies only to AAMP)");
11626 -- pragma Unmodified (local_Name {, local_Name});
11628 when Pragma_Unmodified
=> Unmodified
: declare
11629 Arg_Node
: Node_Id
;
11630 Arg_Expr
: Node_Id
;
11631 Arg_Ent
: Entity_Id
;
11635 Check_At_Least_N_Arguments
(1);
11637 -- Loop through arguments
11640 while Present
(Arg_Node
) loop
11641 Check_No_Identifier
(Arg_Node
);
11643 -- Note: the analyze call done by Check_Arg_Is_Local_Name will
11644 -- in fact generate reference, so that the entity will have a
11645 -- reference, which will inhibit any warnings about it not
11646 -- being referenced, and also properly show up in the ali file
11647 -- as a reference. But this reference is recorded before the
11648 -- Has_Pragma_Unreferenced flag is set, so that no warning is
11649 -- generated for this reference.
11651 Check_Arg_Is_Local_Name
(Arg_Node
);
11652 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
11654 if Is_Entity_Name
(Arg_Expr
) then
11655 Arg_Ent
:= Entity
(Arg_Expr
);
11657 if not Is_Assignable
(Arg_Ent
) then
11659 ("pragma% can only be applied to a variable",
11662 Set_Has_Pragma_Unmodified
(Arg_Ent
);
11674 -- pragma Unreferenced (local_Name {, local_Name});
11676 -- or when used in a context clause:
11678 -- pragma Unreferenced (library_unit_NAME {, library_unit_NAME}
11680 when Pragma_Unreferenced
=> Unreferenced
: declare
11681 Arg_Node
: Node_Id
;
11682 Arg_Expr
: Node_Id
;
11683 Arg_Ent
: Entity_Id
;
11688 Check_At_Least_N_Arguments
(1);
11690 -- Check case of appearing within context clause
11692 if Is_In_Context_Clause
then
11694 -- The arguments must all be units mentioned in a with clause
11695 -- in the same context clause. Note we already checked (in
11696 -- Par.Prag) that the arguments are either identifiers or
11697 -- selected components.
11700 while Present
(Arg_Node
) loop
11701 Citem
:= First
(List_Containing
(N
));
11702 while Citem
/= N
loop
11703 if Nkind
(Citem
) = N_With_Clause
11704 and then Same_Name
(Name
(Citem
), Expression
(Arg_Node
))
11706 Set_Has_Pragma_Unreferenced
11709 (Library_Unit
(Citem
))));
11710 Set_Unit_Name
(Expression
(Arg_Node
), Name
(Citem
));
11719 ("argument of pragma% is not with'ed unit", Arg_Node
);
11725 -- Case of not in list of context items
11729 while Present
(Arg_Node
) loop
11730 Check_No_Identifier
(Arg_Node
);
11732 -- Note: the analyze call done by Check_Arg_Is_Local_Name
11733 -- will in fact generate reference, so that the entity will
11734 -- have a reference, which will inhibit any warnings about
11735 -- it not being referenced, and also properly show up in the
11736 -- ali file as a reference. But this reference is recorded
11737 -- before the Has_Pragma_Unreferenced flag is set, so that
11738 -- no warning is generated for this reference.
11740 Check_Arg_Is_Local_Name
(Arg_Node
);
11741 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
11743 if Is_Entity_Name
(Arg_Expr
) then
11744 Arg_Ent
:= Entity
(Arg_Expr
);
11746 -- If the entity is overloaded, the pragma applies to the
11747 -- most recent overloading, as documented. In this case,
11748 -- name resolution does not generate a reference, so it
11749 -- must be done here explicitly.
11751 if Is_Overloaded
(Arg_Expr
) then
11752 Generate_Reference
(Arg_Ent
, N
);
11755 Set_Has_Pragma_Unreferenced
(Arg_Ent
);
11763 --------------------------
11764 -- Unreferenced_Objects --
11765 --------------------------
11767 -- pragma Unreferenced_Objects (local_Name {, local_Name});
11769 when Pragma_Unreferenced_Objects
=> Unreferenced_Objects
: declare
11770 Arg_Node
: Node_Id
;
11771 Arg_Expr
: Node_Id
;
11775 Check_At_Least_N_Arguments
(1);
11778 while Present
(Arg_Node
) loop
11779 Check_No_Identifier
(Arg_Node
);
11780 Check_Arg_Is_Local_Name
(Arg_Node
);
11781 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
11783 if not Is_Entity_Name
(Arg_Expr
)
11784 or else not Is_Type
(Entity
(Arg_Expr
))
11787 ("argument for pragma% must be type or subtype", Arg_Node
);
11790 Set_Has_Pragma_Unreferenced_Objects
(Entity
(Arg_Expr
));
11793 end Unreferenced_Objects
;
11795 ------------------------------
11796 -- Unreserve_All_Interrupts --
11797 ------------------------------
11799 -- pragma Unreserve_All_Interrupts;
11801 when Pragma_Unreserve_All_Interrupts
=>
11803 Check_Arg_Count
(0);
11805 if In_Extended_Main_Code_Unit
(Main_Unit_Entity
) then
11806 Unreserve_All_Interrupts
:= True;
11813 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
11815 when Pragma_Unsuppress
=>
11817 Process_Suppress_Unsuppress
(False);
11819 -------------------
11820 -- Use_VADS_Size --
11821 -------------------
11823 -- pragma Use_VADS_Size;
11825 when Pragma_Use_VADS_Size
=>
11827 Check_Arg_Count
(0);
11828 Check_Valid_Configuration_Pragma
;
11829 Use_VADS_Size
:= True;
11831 ---------------------
11832 -- Validity_Checks --
11833 ---------------------
11835 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
11837 when Pragma_Validity_Checks
=> Validity_Checks
: declare
11838 A
: constant Node_Id
:= Expression
(Arg1
);
11844 Check_Arg_Count
(1);
11845 Check_No_Identifiers
;
11847 if Nkind
(A
) = N_String_Literal
then
11851 Slen
: constant Natural := Natural (String_Length
(S
));
11852 Options
: String (1 .. Slen
);
11858 C
:= Get_String_Char
(S
, Int
(J
));
11859 exit when not In_Character_Range
(C
);
11860 Options
(J
) := Get_Character
(C
);
11863 Set_Validity_Check_Options
(Options
);
11871 elsif Nkind
(A
) = N_Identifier
then
11873 if Chars
(A
) = Name_All_Checks
then
11874 Set_Validity_Check_Options
("a");
11876 elsif Chars
(A
) = Name_On
then
11877 Validity_Checks_On
:= True;
11879 elsif Chars
(A
) = Name_Off
then
11880 Validity_Checks_On
:= False;
11884 end Validity_Checks
;
11890 -- pragma Volatile (LOCAL_NAME);
11892 when Pragma_Volatile
=>
11893 Process_Atomic_Shared_Volatile
;
11895 -------------------------
11896 -- Volatile_Components --
11897 -------------------------
11899 -- pragma Volatile_Components (array_LOCAL_NAME);
11901 -- Volatile is handled by the same circuit as Atomic_Components
11907 -- pragma Warnings (On | Off);
11908 -- pragma Warnings (On | Off, LOCAL_NAME);
11909 -- pragma Warnings (static_string_EXPRESSION);
11910 -- pragma Warnings (On | Off, STRING_LITERAL);
11912 when Pragma_Warnings
=> Warnings
: begin
11914 Check_At_Least_N_Arguments
(1);
11915 Check_No_Identifiers
;
11918 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
11921 -- One argument case
11923 if Arg_Count
= 1 then
11925 -- On/Off one argument case was processed by parser
11927 if Nkind
(Argx
) = N_Identifier
11929 (Chars
(Argx
) = Name_On
11931 Chars
(Argx
) = Name_Off
)
11935 -- One argument case must be ON/OFF or static string expr
11937 elsif not Is_Static_String_Expression
(Arg1
) then
11939 ("argument of pragma% must be On/Off or " &
11940 "static string expression", Arg2
);
11942 -- One argument string expression case
11946 Lit
: constant Node_Id
:= Expr_Value_S
(Argx
);
11947 Str
: constant String_Id
:= Strval
(Lit
);
11948 Len
: constant Nat
:= String_Length
(Str
);
11956 while J
<= Len
loop
11957 C
:= Get_String_Char
(Str
, J
);
11958 OK
:= In_Character_Range
(C
);
11961 Chr
:= Get_Character
(C
);
11965 if J
< Len
and then Chr
= '.' then
11967 C
:= Get_String_Char
(Str
, J
);
11968 Chr
:= Get_Character
(C
);
11970 if not Set_Dot_Warning_Switch
(Chr
) then
11972 ("invalid warning switch character " &
11979 OK
:= Set_Warning_Switch
(Chr
);
11985 ("invalid warning switch character " & Chr
,
11994 -- Two or more arguments (must be two)
11997 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
11998 Check_At_Most_N_Arguments
(2);
12006 E_Id
:= Expression
(Arg2
);
12009 -- In the expansion of an inlined body, a reference to
12010 -- the formal may be wrapped in a conversion if the
12011 -- actual is a conversion. Retrieve the real entity name.
12013 if (In_Instance_Body
12014 or else In_Inlined_Body
)
12015 and then Nkind
(E_Id
) = N_Unchecked_Type_Conversion
12017 E_Id
:= Expression
(E_Id
);
12020 -- Entity name case
12022 if Is_Entity_Name
(E_Id
) then
12023 E
:= Entity
(E_Id
);
12030 (E
, (Chars
(Expression
(Arg1
)) = Name_Off
));
12032 if Chars
(Expression
(Arg1
)) = Name_Off
12033 and then Warn_On_Warnings_Off
12035 Warnings_Off_Pragmas
.Append
((N
, E
));
12038 if Is_Enumeration_Type
(E
) then
12042 Lit
:= First_Literal
(E
);
12043 while Present
(Lit
) loop
12044 Set_Warnings_Off
(Lit
);
12045 Next_Literal
(Lit
);
12050 exit when No
(Homonym
(E
));
12055 -- Error if not entity or static string literal case
12057 elsif not Is_Static_String_Expression
(Arg2
) then
12059 ("second argument of pragma% must be entity " &
12060 "name or static string expression", Arg2
);
12062 -- String literal case
12065 String_To_Name_Buffer
12066 (Strval
(Expr_Value_S
(Expression
(Arg2
))));
12068 -- Note on configuration pragma case: If this is a
12069 -- configuration pragma, then for an OFF pragma, we
12070 -- just set Config True in the call, which is all
12071 -- that needs to be done. For the case of ON, this
12072 -- is normally an error, unless it is canceling the
12073 -- effect of a previous OFF pragma in the same file.
12074 -- In any other case, an error will be signalled (ON
12075 -- with no matching OFF).
12077 if Chars
(Argx
) = Name_Off
then
12078 Set_Specific_Warning_Off
12079 (Loc
, Name_Buffer
(1 .. Name_Len
),
12080 Config
=> Is_Configuration_Pragma
);
12082 elsif Chars
(Argx
) = Name_On
then
12083 Set_Specific_Warning_On
12084 (Loc
, Name_Buffer
(1 .. Name_Len
), Err
);
12088 ("?pragma Warnings On with no " &
12089 "matching Warnings Off",
12099 -------------------
12100 -- Weak_External --
12101 -------------------
12103 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
12105 when Pragma_Weak_External
=> Weak_External
: declare
12110 Check_Arg_Count
(1);
12111 Check_Optional_Identifier
(Arg1
, Name_Entity
);
12112 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
12113 Ent
:= Entity
(Expression
(Arg1
));
12115 if Rep_Item_Too_Early
(Ent
, N
) then
12118 Ent
:= Underlying_Type
(Ent
);
12121 -- The only processing required is to link this item on to the
12122 -- list of rep items for the given entity. This is accomplished
12123 -- by the call to Rep_Item_Too_Late (when no error is detected
12124 -- and False is returned).
12126 if Rep_Item_Too_Late
(Ent
, N
) then
12129 Set_Has_Gigi_Rep_Item
(Ent
);
12133 -----------------------------
12134 -- Wide_Character_Encoding --
12135 -----------------------------
12137 -- pragma Wide_Character_Encoding (IDENTIFIER);
12139 when Pragma_Wide_Character_Encoding
=>
12142 -- Nothing to do, handled in parser. Note that we do not enforce
12143 -- configuration pragma placement, this pragma can appear at any
12144 -- place in the source, allowing mixed encodings within a single
12149 --------------------
12150 -- Unknown_Pragma --
12151 --------------------
12153 -- Should be impossible, since the case of an unknown pragma is
12154 -- separately processed before the case statement is entered.
12156 when Unknown_Pragma
=>
12157 raise Program_Error
;
12161 when Pragma_Exit
=> null;
12162 end Analyze_Pragma
;
12164 -------------------
12165 -- Check_Enabled --
12166 -------------------
12168 function Check_Enabled
(Nam
: Name_Id
) return Boolean is
12172 PP
:= Opt
.Check_Policy_List
;
12175 return Assertions_Enabled
;
12178 Nam
= Chars
(Expression
(First
(Pragma_Argument_Associations
(PP
))))
12181 Chars
(Expression
(Last
(Pragma_Argument_Associations
(PP
))))
12183 when Name_On | Name_Check
=>
12185 when Name_Off | Name_Ignore
=>
12188 raise Program_Error
;
12192 PP
:= Next_Pragma
(PP
);
12197 ---------------------------------
12198 -- Delay_Config_Pragma_Analyze --
12199 ---------------------------------
12201 function Delay_Config_Pragma_Analyze
(N
: Node_Id
) return Boolean is
12203 return Pragma_Name
(N
) = Name_Interrupt_State
12205 Pragma_Name
(N
) = Name_Priority_Specific_Dispatching
;
12206 end Delay_Config_Pragma_Analyze
;
12208 -------------------------
12209 -- Get_Base_Subprogram --
12210 -------------------------
12212 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
is
12213 Result
: Entity_Id
;
12216 -- Follow subprogram renaming chain
12219 while Is_Subprogram
(Result
)
12221 (Is_Generic_Instance
(Result
)
12222 or else Nkind
(Parent
(Declaration_Node
(Result
))) =
12223 N_Subprogram_Renaming_Declaration
)
12224 and then Present
(Alias
(Result
))
12226 Result
:= Alias
(Result
);
12230 end Get_Base_Subprogram
;
12232 --------------------
12233 -- Get_Pragma_Arg --
12234 --------------------
12236 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
is
12238 if Nkind
(Arg
) = N_Pragma_Argument_Association
then
12239 return Expression
(Arg
);
12243 end Get_Pragma_Arg
;
12249 procedure Initialize
is
12254 -----------------------------
12255 -- Is_Config_Static_String --
12256 -----------------------------
12258 function Is_Config_Static_String
(Arg
: Node_Id
) return Boolean is
12260 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean;
12261 -- This is an internal recursive function that is just like the outer
12262 -- function except that it adds the string to the name buffer rather
12263 -- than placing the string in the name buffer.
12265 ------------------------------
12266 -- Add_Config_Static_String --
12267 ------------------------------
12269 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean is
12276 if Nkind
(N
) = N_Op_Concat
then
12277 if Add_Config_Static_String
(Left_Opnd
(N
)) then
12278 N
:= Right_Opnd
(N
);
12284 if Nkind
(N
) /= N_String_Literal
then
12285 Error_Msg_N
("string literal expected for pragma argument", N
);
12289 for J
in 1 .. String_Length
(Strval
(N
)) loop
12290 C
:= Get_String_Char
(Strval
(N
), J
);
12292 if not In_Character_Range
(C
) then
12294 ("string literal contains invalid wide character",
12295 Sloc
(N
) + 1 + Source_Ptr
(J
));
12299 Add_Char_To_Name_Buffer
(Get_Character
(C
));
12304 end Add_Config_Static_String
;
12306 -- Start of processing for Is_Config_Static_String
12311 return Add_Config_Static_String
(Arg
);
12312 end Is_Config_Static_String
;
12314 -----------------------------------------
12315 -- Is_Non_Significant_Pragma_Reference --
12316 -----------------------------------------
12318 -- This function makes use of the following static table which indicates
12319 -- whether a given pragma is significant. A value of -1 in this table
12320 -- indicates that the reference is significant. A value of zero indicates
12321 -- than appearance as any argument is insignificant, a positive value
12322 -- indicates that appearance in that parameter position is significant.
12324 -- A value of 99 flags a special case requiring a special check (this is
12325 -- used for cases not covered by this standard encoding, e.g. pragma Check
12326 -- where the first argument is not significant, but the others are).
12328 Sig_Flags
: constant array (Pragma_Id
) of Int
:=
12329 (Pragma_AST_Entry
=> -1,
12330 Pragma_Abort_Defer
=> -1,
12331 Pragma_Ada_83
=> -1,
12332 Pragma_Ada_95
=> -1,
12333 Pragma_Ada_05
=> -1,
12334 Pragma_Ada_2005
=> -1,
12335 Pragma_All_Calls_Remote
=> -1,
12336 Pragma_Annotate
=> -1,
12337 Pragma_Assert
=> -1,
12338 Pragma_Assertion_Policy
=> 0,
12339 Pragma_Assume_No_Invalid_Values
=> 0,
12340 Pragma_Asynchronous
=> -1,
12341 Pragma_Atomic
=> 0,
12342 Pragma_Atomic_Components
=> 0,
12343 Pragma_Attach_Handler
=> -1,
12344 Pragma_Check
=> 99,
12345 Pragma_Check_Name
=> 0,
12346 Pragma_Check_Policy
=> 0,
12347 Pragma_CIL_Constructor
=> -1,
12348 Pragma_CPP_Class
=> 0,
12349 Pragma_CPP_Constructor
=> 0,
12350 Pragma_CPP_Virtual
=> 0,
12351 Pragma_CPP_Vtable
=> 0,
12352 Pragma_C_Pass_By_Copy
=> 0,
12353 Pragma_Comment
=> 0,
12354 Pragma_Common_Object
=> -1,
12355 Pragma_Compile_Time_Error
=> -1,
12356 Pragma_Compile_Time_Warning
=> -1,
12357 Pragma_Compiler_Unit
=> 0,
12358 Pragma_Complete_Representation
=> 0,
12359 Pragma_Complex_Representation
=> 0,
12360 Pragma_Component_Alignment
=> -1,
12361 Pragma_Controlled
=> 0,
12362 Pragma_Convention
=> 0,
12363 Pragma_Convention_Identifier
=> 0,
12364 Pragma_Debug
=> -1,
12365 Pragma_Debug_Policy
=> 0,
12366 Pragma_Detect_Blocking
=> -1,
12367 Pragma_Discard_Names
=> 0,
12368 Pragma_Elaborate
=> -1,
12369 Pragma_Elaborate_All
=> -1,
12370 Pragma_Elaborate_Body
=> -1,
12371 Pragma_Elaboration_Checks
=> -1,
12372 Pragma_Eliminate
=> -1,
12373 Pragma_Export
=> -1,
12374 Pragma_Export_Exception
=> -1,
12375 Pragma_Export_Function
=> -1,
12376 Pragma_Export_Object
=> -1,
12377 Pragma_Export_Procedure
=> -1,
12378 Pragma_Export_Value
=> -1,
12379 Pragma_Export_Valued_Procedure
=> -1,
12380 Pragma_Extend_System
=> -1,
12381 Pragma_Extensions_Allowed
=> -1,
12382 Pragma_External
=> -1,
12383 Pragma_Favor_Top_Level
=> -1,
12384 Pragma_External_Name_Casing
=> -1,
12385 Pragma_Fast_Math
=> -1,
12386 Pragma_Finalize_Storage_Only
=> 0,
12387 Pragma_Float_Representation
=> 0,
12388 Pragma_Ident
=> -1,
12389 Pragma_Implemented_By_Entry
=> -1,
12390 Pragma_Implicit_Packing
=> 0,
12391 Pragma_Import
=> +2,
12392 Pragma_Import_Exception
=> 0,
12393 Pragma_Import_Function
=> 0,
12394 Pragma_Import_Object
=> 0,
12395 Pragma_Import_Procedure
=> 0,
12396 Pragma_Import_Valued_Procedure
=> 0,
12397 Pragma_Initialize_Scalars
=> -1,
12398 Pragma_Inline
=> 0,
12399 Pragma_Inline_Always
=> 0,
12400 Pragma_Inline_Generic
=> 0,
12401 Pragma_Inspection_Point
=> -1,
12402 Pragma_Interface
=> +2,
12403 Pragma_Interface_Name
=> +2,
12404 Pragma_Interrupt_Handler
=> -1,
12405 Pragma_Interrupt_Priority
=> -1,
12406 Pragma_Interrupt_State
=> -1,
12407 Pragma_Java_Constructor
=> -1,
12408 Pragma_Java_Interface
=> -1,
12409 Pragma_Keep_Names
=> 0,
12410 Pragma_License
=> -1,
12411 Pragma_Link_With
=> -1,
12412 Pragma_Linker_Alias
=> -1,
12413 Pragma_Linker_Constructor
=> -1,
12414 Pragma_Linker_Destructor
=> -1,
12415 Pragma_Linker_Options
=> -1,
12416 Pragma_Linker_Section
=> -1,
12418 Pragma_Locking_Policy
=> -1,
12419 Pragma_Long_Float
=> -1,
12420 Pragma_Machine_Attribute
=> -1,
12422 Pragma_Main_Storage
=> -1,
12423 Pragma_Memory_Size
=> -1,
12424 Pragma_No_Return
=> 0,
12425 Pragma_No_Body
=> 0,
12426 Pragma_No_Run_Time
=> -1,
12427 Pragma_No_Strict_Aliasing
=> -1,
12428 Pragma_Normalize_Scalars
=> -1,
12429 Pragma_Obsolescent
=> 0,
12430 Pragma_Optimize
=> -1,
12431 Pragma_Optimize_Alignment
=> -1,
12434 Pragma_Passive
=> -1,
12435 Pragma_Preelaborable_Initialization
=> -1,
12436 Pragma_Polling
=> -1,
12437 Pragma_Persistent_BSS
=> 0,
12438 Pragma_Postcondition
=> -1,
12439 Pragma_Precondition
=> -1,
12440 Pragma_Preelaborate
=> -1,
12441 Pragma_Preelaborate_05
=> -1,
12442 Pragma_Priority
=> -1,
12443 Pragma_Priority_Specific_Dispatching
=> -1,
12444 Pragma_Profile
=> 0,
12445 Pragma_Profile_Warnings
=> 0,
12446 Pragma_Propagate_Exceptions
=> -1,
12447 Pragma_Psect_Object
=> -1,
12449 Pragma_Pure_05
=> -1,
12450 Pragma_Pure_Function
=> -1,
12451 Pragma_Queuing_Policy
=> -1,
12452 Pragma_Ravenscar
=> -1,
12453 Pragma_Relative_Deadline
=> -1,
12454 Pragma_Remote_Call_Interface
=> -1,
12455 Pragma_Remote_Types
=> -1,
12456 Pragma_Restricted_Run_Time
=> -1,
12457 Pragma_Restriction_Warnings
=> -1,
12458 Pragma_Restrictions
=> -1,
12459 Pragma_Reviewable
=> -1,
12460 Pragma_Share_Generic
=> -1,
12461 Pragma_Shared
=> -1,
12462 Pragma_Shared_Passive
=> -1,
12463 Pragma_Source_File_Name
=> -1,
12464 Pragma_Source_File_Name_Project
=> -1,
12465 Pragma_Source_Reference
=> -1,
12466 Pragma_Storage_Size
=> -1,
12467 Pragma_Storage_Unit
=> -1,
12468 Pragma_Static_Elaboration_Desired
=> -1,
12469 Pragma_Stream_Convert
=> -1,
12470 Pragma_Style_Checks
=> -1,
12471 Pragma_Subtitle
=> -1,
12472 Pragma_Suppress
=> 0,
12473 Pragma_Suppress_Exception_Locations
=> 0,
12474 Pragma_Suppress_All
=> -1,
12475 Pragma_Suppress_Debug_Info
=> 0,
12476 Pragma_Suppress_Initialization
=> 0,
12477 Pragma_System_Name
=> -1,
12478 Pragma_Task_Dispatching_Policy
=> -1,
12479 Pragma_Task_Info
=> -1,
12480 Pragma_Task_Name
=> -1,
12481 Pragma_Task_Storage
=> 0,
12482 Pragma_Thread_Local_Storage
=> 0,
12483 Pragma_Time_Slice
=> -1,
12484 Pragma_Title
=> -1,
12485 Pragma_Unchecked_Union
=> 0,
12486 Pragma_Unimplemented_Unit
=> -1,
12487 Pragma_Universal_Aliasing
=> -1,
12488 Pragma_Universal_Data
=> -1,
12489 Pragma_Unmodified
=> -1,
12490 Pragma_Unreferenced
=> -1,
12491 Pragma_Unreferenced_Objects
=> -1,
12492 Pragma_Unreserve_All_Interrupts
=> -1,
12493 Pragma_Unsuppress
=> 0,
12494 Pragma_Use_VADS_Size
=> -1,
12495 Pragma_Validity_Checks
=> -1,
12496 Pragma_Volatile
=> 0,
12497 Pragma_Volatile_Components
=> 0,
12498 Pragma_Warnings
=> -1,
12499 Pragma_Weak_External
=> -1,
12500 Pragma_Wide_Character_Encoding
=> 0,
12501 Unknown_Pragma
=> 0);
12503 function Is_Non_Significant_Pragma_Reference
(N
: Node_Id
) return Boolean is
12512 if Nkind
(P
) /= N_Pragma_Argument_Association
then
12516 Id
:= Get_Pragma_Id
(Parent
(P
));
12517 C
:= Sig_Flags
(Id
);
12529 -- For pragma Check, the first argument is not significant,
12530 -- the second and the third (if present) arguments are
12533 when Pragma_Check
=>
12535 P
= First
(Pragma_Argument_Associations
(Parent
(P
)));
12538 raise Program_Error
;
12542 A
:= First
(Pragma_Argument_Associations
(Parent
(P
)));
12543 for J
in 1 .. C
- 1 loop
12551 return A
= P
; -- is this wrong way round ???
12554 end Is_Non_Significant_Pragma_Reference
;
12556 ------------------------------
12557 -- Is_Pragma_String_Literal --
12558 ------------------------------
12560 -- This function returns true if the corresponding pragma argument is a
12561 -- static string expression. These are the only cases in which string
12562 -- literals can appear as pragma arguments. We also allow a string literal
12563 -- as the first argument to pragma Assert (although it will of course
12564 -- always generate a type error).
12566 function Is_Pragma_String_Literal
(Par
: Node_Id
) return Boolean is
12567 Pragn
: constant Node_Id
:= Parent
(Par
);
12568 Assoc
: constant List_Id
:= Pragma_Argument_Associations
(Pragn
);
12569 Pname
: constant Name_Id
:= Pragma_Name
(Pragn
);
12575 N
:= First
(Assoc
);
12582 if Pname
= Name_Assert
then
12585 elsif Pname
= Name_Export
then
12588 elsif Pname
= Name_Ident
then
12591 elsif Pname
= Name_Import
then
12594 elsif Pname
= Name_Interface_Name
then
12597 elsif Pname
= Name_Linker_Alias
then
12600 elsif Pname
= Name_Linker_Section
then
12603 elsif Pname
= Name_Machine_Attribute
then
12606 elsif Pname
= Name_Source_File_Name
then
12609 elsif Pname
= Name_Source_Reference
then
12612 elsif Pname
= Name_Title
then
12615 elsif Pname
= Name_Subtitle
then
12621 end Is_Pragma_String_Literal
;
12623 --------------------------------------
12624 -- Process_Compilation_Unit_Pragmas --
12625 --------------------------------------
12627 procedure Process_Compilation_Unit_Pragmas
(N
: Node_Id
) is
12629 -- A special check for pragma Suppress_All, a very strange DEC pragma,
12630 -- strange because it comes at the end of the unit. If we have a pragma
12631 -- Suppress_All in the Pragmas_After of the current unit, then we insert
12632 -- a pragma Suppress (All_Checks) at the start of the context clause to
12633 -- ensure the correct processing.
12636 PA
: constant List_Id
:= Pragmas_After
(Aux_Decls_Node
(N
));
12640 if Present
(PA
) then
12642 while Present
(P
) loop
12643 if Pragma_Name
(P
) = Name_Suppress_All
then
12644 Prepend_To
(Context_Items
(N
),
12645 Make_Pragma
(Sloc
(P
),
12646 Chars
=> Name_Suppress
,
12647 Pragma_Argument_Associations
=> New_List
(
12648 Make_Pragma_Argument_Association
(Sloc
(P
),
12650 Make_Identifier
(Sloc
(P
),
12651 Chars
=> Name_All_Checks
)))));
12659 end Process_Compilation_Unit_Pragmas
;
12670 --------------------------------
12671 -- Set_Encoded_Interface_Name --
12672 --------------------------------
12674 procedure Set_Encoded_Interface_Name
(E
: Entity_Id
; S
: Node_Id
) is
12675 Str
: constant String_Id
:= Strval
(S
);
12676 Len
: constant Int
:= String_Length
(Str
);
12681 Hex
: constant array (0 .. 15) of Character := "0123456789abcdef";
12684 -- Stores encoded value of character code CC. The encoding we use an
12685 -- underscore followed by four lower case hex digits.
12691 procedure Encode
is
12693 Store_String_Char
(Get_Char_Code
('_'));
12695 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 12))));
12697 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 8 and 16#
0F#
))));
12699 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 4 and 16#
0F#
))));
12701 (Get_Char_Code
(Hex
(Integer (CC
and 16#
0F#
))));
12704 -- Start of processing for Set_Encoded_Interface_Name
12707 -- If first character is asterisk, this is a link name, and we leave it
12708 -- completely unmodified. We also ignore null strings (the latter case
12709 -- happens only in error cases) and no encoding should occur for Java or
12710 -- AAMP interface names.
12713 or else Get_String_Char
(Str
, 1) = Get_Char_Code
('*')
12714 or else VM_Target
/= No_VM
12715 or else AAMP_On_Target
12717 Set_Interface_Name
(E
, S
);
12722 CC
:= Get_String_Char
(Str
, J
);
12724 exit when not In_Character_Range
(CC
);
12726 C
:= Get_Character
(CC
);
12728 exit when C
/= '_' and then C
/= '$'
12729 and then C
not in '0' .. '9'
12730 and then C
not in 'a' .. 'z'
12731 and then C
not in 'A' .. 'Z';
12734 Set_Interface_Name
(E
, S
);
12742 -- Here we need to encode. The encoding we use as follows:
12743 -- three underscores + four hex digits (lower case)
12747 for J
in 1 .. String_Length
(Str
) loop
12748 CC
:= Get_String_Char
(Str
, J
);
12750 if not In_Character_Range
(CC
) then
12753 C
:= Get_Character
(CC
);
12755 if C
= '_' or else C
= '$'
12756 or else C
in '0' .. '9'
12757 or else C
in 'a' .. 'z'
12758 or else C
in 'A' .. 'Z'
12760 Store_String_Char
(CC
);
12767 Set_Interface_Name
(E
,
12768 Make_String_Literal
(Sloc
(S
),
12769 Strval
=> End_String
));
12771 end Set_Encoded_Interface_Name
;
12773 -------------------
12774 -- Set_Unit_Name --
12775 -------------------
12777 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
) is
12782 if Nkind
(N
) = N_Identifier
12783 and then Nkind
(With_Item
) = N_Identifier
12785 Set_Entity
(N
, Entity
(With_Item
));
12787 elsif Nkind
(N
) = N_Selected_Component
then
12788 Change_Selected_Component_To_Expanded_Name
(N
);
12789 Set_Entity
(N
, Entity
(With_Item
));
12790 Set_Entity
(Selector_Name
(N
), Entity
(N
));
12792 Pref
:= Prefix
(N
);
12793 Scop
:= Scope
(Entity
(N
));
12794 while Nkind
(Pref
) = N_Selected_Component
loop
12795 Change_Selected_Component_To_Expanded_Name
(Pref
);
12796 Set_Entity
(Selector_Name
(Pref
), Scop
);
12797 Set_Entity
(Pref
, Scop
);
12798 Pref
:= Prefix
(Pref
);
12799 Scop
:= Scope
(Scop
);
12802 Set_Entity
(Pref
, Scop
);