1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 1992-2001, Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
27 ------------------------------------------------------------------------------
29 -- This unit contains the semantic processing for all pragmas, both language
30 -- and implementation defined. For most pragmas, the parser only does the
31 -- most basic job of checking the syntax, so Sem_Prag also contains the code
32 -- to complete the syntax checks. Certain pragmas are handled partially or
33 -- completely by the parser (see Par.Prag for further details).
35 with Atree
; use Atree
;
36 with Casing
; use Casing
;
37 with Csets
; use Csets
;
38 with Debug
; use Debug
;
39 with Einfo
; use Einfo
;
40 with Elists
; use Elists
;
41 with Errout
; use Errout
;
42 with Expander
; use Expander
;
43 with Exp_Dist
; use Exp_Dist
;
44 with Fname
; use Fname
;
45 with Hostparm
; use Hostparm
;
47 with Namet
; use Namet
;
48 with Nlists
; use Nlists
;
49 with Nmake
; use Nmake
;
51 with Output
; use Output
;
52 with Restrict
; use Restrict
;
53 with Rtsfind
; use Rtsfind
;
55 with Sem_Ch8
; use Sem_Ch8
;
56 with Sem_Ch13
; use Sem_Ch13
;
57 with Sem_Disp
; use Sem_Disp
;
58 with Sem_Elim
; use Sem_Elim
;
59 with Sem_Eval
; use Sem_Eval
;
60 with Sem_Intr
; use Sem_Intr
;
61 with Sem_Mech
; use Sem_Mech
;
62 with Sem_Res
; use Sem_Res
;
63 with Sem_Type
; use Sem_Type
;
64 with Sem_Util
; use Sem_Util
;
65 with Sem_VFpt
; use Sem_VFpt
;
66 with Stand
; use Stand
;
67 with Sinfo
; use Sinfo
;
68 with Sinfo
.CN
; use Sinfo
.CN
;
69 with Sinput
; use Sinput
;
70 with Snames
; use Snames
;
71 with Stringt
; use Stringt
;
72 with Stylesw
; use Stylesw
;
73 with Targparm
; use Targparm
;
74 with Tbuild
; use Tbuild
;
76 with Uintp
; use Uintp
;
77 with Urealp
; use Urealp
;
78 with Validsw
; use Validsw
;
80 package body Sem_Prag
is
82 ----------------------------------------------
83 -- Common Handling of Import-Export Pragmas --
84 ----------------------------------------------
86 -- In the following section, a number of Import_xxx and Export_xxx
87 -- pragmas are defined by GNAT. These are compatible with the DEC
88 -- pragmas of the same name, and all have the following common
89 -- form and processing:
92 -- [Internal =>] LOCAL_NAME,
93 -- [, [External =>] EXTERNAL_SYMBOL]
94 -- [, other optional parameters ]);
97 -- [Internal =>] LOCAL_NAME,
98 -- [, [External =>] EXTERNAL_SYMBOL]
99 -- [, other optional parameters ]);
101 -- EXTERNAL_SYMBOL ::=
103 -- | static_string_EXPRESSION
105 -- The internal LOCAL_NAME designates the entity that is imported or
106 -- exported, and must refer to an entity in the current declarative
107 -- part (as required by the rules for LOCAL_NAME).
109 -- The external linker name is designated by the External parameter
110 -- if given, or the Internal parameter if not (if there is no External
111 -- parameter, the External parameter is a copy of the Internal name).
113 -- If the External parameter is given as a string, then this string
114 -- is treated as an external name (exactly as though it had been given
115 -- as an External_Name parameter for a normal Import pragma).
117 -- If the External parameter is given as an identifier (or there is no
118 -- External parameter, so that the Internal identifier is used), then
119 -- the external name is the characters of the identifier, translated
120 -- to all upper case letters for OpenVMS versions of GNAT, and to all
121 -- lower case letters for all other versions
123 -- Note: the external name specified or implied by any of these special
124 -- Import_xxx or Export_xxx pragmas override an external or link name
125 -- specified in a previous Import or Export pragma.
127 -- Note: these and all other DEC-compatible GNAT pragmas allow full
128 -- use of named notation, following the standard rules for subprogram
129 -- calls, i.e. parameters can be given in any order if named notation
130 -- is used, and positional and named notation can be mixed, subject to
131 -- the rule that all positional parameters must appear first.
133 -- Note: All these pragmas are implemented exactly following the DEC
134 -- design and implementation and are intended to be fully compatible
135 -- with the use of these pragmas in the DEC Ada compiler.
137 -------------------------------------
138 -- Local Subprograms and Variables --
139 -------------------------------------
141 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
;
142 -- This routine is used for possible casing adjustment of an explicit
143 -- external name supplied as a string literal (the node N), according
144 -- to the casing requirement of Opt.External_Name_Casing. If this is
145 -- set to As_Is, then the string literal is returned unchanged, but if
146 -- it is set to Uppercase or Lowercase, then a new string literal with
147 -- appropriate casing is constructed.
149 function Is_Generic_Subprogram
(Id
: Entity_Id
) return Boolean;
150 -- Return True if Id is a generic procedure or a function
152 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
;
153 -- If Def_Id refers to a renamed subprogram, then the base subprogram
154 -- (the original one, following the renaming chain) is returned.
155 -- Otherwise the entity is returned unchanged. Should be in Einfo???
157 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
);
158 -- Place semantic information on the argument of an Elaborate or
159 -- Elaborate_All pragma. Entity name for unit and its parents is
160 -- taken from item in previous with_clause that mentions the unit.
162 Locking_Policy_Sloc
: Source_Ptr
:= No_Location
;
163 Queuing_Policy_Sloc
: Source_Ptr
:= No_Location
;
164 Task_Dispatching_Policy_Sloc
: Source_Ptr
:= No_Location
;
165 -- These global variables remember the location of a previous locking,
166 -- queuing or task dispatching policy pragma, so that appropriate error
167 -- messages can be generated for inconsistent pragmas. Note that it is
168 -- fine that these are global locations, because the check for consistency
169 -- is over the entire program.
171 -------------------------------
172 -- Adjust_External_Name_Case --
173 -------------------------------
175 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
is
179 -- Adjust case of literal if required
181 if Opt
.External_Name_Exp_Casing
= As_Is
then
185 -- Copy existing string
191 for J
in 1 .. String_Length
(Strval
(N
)) loop
192 CC
:= Get_String_Char
(Strval
(N
), J
);
194 if Opt
.External_Name_Exp_Casing
= Uppercase
195 and then CC
>= Get_Char_Code
('a')
196 and then CC
<= Get_Char_Code
('z')
198 Store_String_Char
(CC
- 32);
200 elsif Opt
.External_Name_Exp_Casing
= Lowercase
201 and then CC
>= Get_Char_Code
('A')
202 and then CC
<= Get_Char_Code
('Z')
204 Store_String_Char
(CC
+ 32);
207 Store_String_Char
(CC
);
212 Make_String_Literal
(Sloc
(N
),
213 Strval
=> End_String
);
215 end Adjust_External_Name_Case
;
221 procedure Analyze_Pragma
(N
: Node_Id
) is
222 Loc
: constant Source_Ptr
:= Sloc
(N
);
225 Pragma_Exit
: exception;
226 -- This exception is used to exit pragma processing completely. It
227 -- is used when an error is detected, and in other situations where
228 -- it is known that no further processing is required.
231 -- Number of pragma argument associations
237 -- First four pragma arguments (pragma argument association nodes,
238 -- or Empty if the corresponding argument does not exist).
240 procedure Check_Ada_83_Warning
;
241 -- Issues a warning message for the current pragma if operating in Ada
242 -- 83 mode (used for language pragmas that are not a standard part of
243 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
246 procedure Check_Arg_Count
(Required
: Nat
);
247 -- Check argument count for pragma is equal to given parameter.
248 -- If not, then issue an error message and raise Pragma_Exit.
250 -- Note: all routines whose name is Check_Arg_Is_xxx take an
251 -- argument Arg which can either be a pragma argument association,
252 -- in which case the check is applied to the expression of the
253 -- association or an expression directly.
255 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
);
256 -- Check the specified argument Arg to make sure that it is an
257 -- identifier. If not give error and raise Pragma_Exit.
259 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
);
260 -- Check the specified argument Arg to make sure that it is an
261 -- integer literal. If not give error and raise Pragma_Exit.
263 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
);
264 -- Check the specified argument Arg to make sure that it has the
265 -- proper syntactic form for a local name and meets the semantic
266 -- requirements for a local name. The local name is analyzed as
267 -- part of the processing for this call. In addition, the local
268 -- name is required to represent an entity at the library level.
270 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
);
271 -- Check the specified argument Arg to make sure that it has the
272 -- proper syntactic form for a local name and meets the semantic
273 -- requirements for a local name. The local name is analyzed as
274 -- part of the processing for this call.
276 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
);
277 -- Check the specified argument Arg to make sure that it is a valid
278 -- locking policy name. If not give error and raise Pragma_Exit.
280 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
);
281 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
, N3
: Name_Id
);
282 -- Check the specified argument Arg to make sure that it is an
283 -- identifier whose name matches either N1 or N2 (or N3 if present).
284 -- If not then give error and raise Pragma_Exit.
286 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
);
287 -- Check the specified argument Arg to make sure that it is a valid
288 -- queuing policy name. If not give error and raise Pragma_Exit.
290 procedure Check_Arg_Is_Static_Expression
293 -- Check the specified argument Arg to make sure that it is a static
294 -- expression of the given type (i.e. it will be analyzed and resolved
295 -- using this type, which can be any valid argument to Resolve, e.g.
296 -- Any_Integer is OK). If not, given error and raise Pragma_Exit.
298 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
);
299 -- Check the specified argument Arg to make sure that it is a
300 -- string literal. If not give error and raise Pragma_Exit
302 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
);
303 -- Check the specified argument Arg to make sure that it is a valid
304 -- valid task dispatching policy name. If not give error and raise
307 procedure Check_At_Least_N_Arguments
(N
: Nat
);
308 -- Check there are at least N arguments present
310 procedure Check_At_Most_N_Arguments
(N
: Nat
);
311 -- Check there are no more than N arguments present
313 procedure Check_First_Subtype
(Arg
: Node_Id
);
314 -- Checks that Arg, whose expression is an entity name referencing
315 -- a subtype, does not reference a type that is not a first subtype.
317 procedure Check_In_Main_Program
;
318 -- Common checks for pragmas that appear within a main program
319 -- (Priority, Main_Storage, Time_Slice).
321 procedure Check_Interrupt_Or_Attach_Handler
;
322 -- Common processing for first argument of pragma Interrupt_Handler
323 -- or pragma Attach_Handler.
325 procedure Check_Is_In_Decl_Part_Or_Package_Spec
;
326 -- Check that pragma appears in a declarative part, or in a package
327 -- specification, i.e. that it does not occur in a statement sequence
330 procedure Check_No_Identifier
(Arg
: Node_Id
);
331 -- Checks that the given argument does not have an identifier. If
332 -- an identifier is present, then an error message is issued, and
333 -- Pragma_Exit is raised.
335 procedure Check_No_Identifiers
;
336 -- Checks that none of the arguments to the pragma has an identifier.
337 -- If any argument has an identifier, then an error message is issued,
338 -- and Pragma_Exit is raised.
340 procedure Check_Non_Overloaded_Function
(Arg
: Node_Id
);
341 -- Check that the given argument is the name of a local function of
342 -- one argument that is not overloaded in the current local scope.
344 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
);
345 -- Checks if the given argument has an identifier, and if so, requires
346 -- it to match the given identifier name. If there is a non-matching
347 -- identifier, then an error message is given and Error_Pragmas raised.
349 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String);
350 -- Checks if the given argument has an identifier, and if so, requires
351 -- it to match the given identifier name. If there is a non-matching
352 -- identifier, then an error message is given and Error_Pragmas raised.
353 -- In this version of the procedure, the identifier name is given as
354 -- a string with lower case letters.
356 procedure Check_Static_Constraint
(Constr
: Node_Id
);
357 -- Constr is a constraint from an N_Subtype_Indication node from a
358 -- component constraint in an Unchecked_Union type. This routine checks
359 -- that the constraint is static as required by the restrictions for
362 procedure Check_Valid_Configuration_Pragma
;
363 -- Legality checks for placement of a configuration pragma
365 procedure Check_Valid_Library_Unit_Pragma
;
366 -- Legality checks for library unit pragmas. A special case arises for
367 -- pragmas in generic instances that come from copies of the original
368 -- library unit pragmas in the generic templates. In the case of other
369 -- than library level instantiations these can appear in contexts which
370 -- would normally be invalid (they only apply to the original template
371 -- and to library level instantiations), and they are simply ignored,
372 -- which is implemented by rewriting them as null statements.
374 procedure Error_Pragma
(Msg
: String);
375 pragma No_Return
(Error_Pragma
);
376 -- Outputs error message for current pragma. The message contains an %
377 -- that will be replaced with the pragma name, and the flag is placed
378 -- on the pragma itself. Pragma_Exit is then raised.
380 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
);
381 pragma No_Return
(Error_Pragma_Arg
);
382 -- Outputs error message for current pragma. The message may contain
383 -- a % that will be replaced with the pragma name. The parameter Arg
384 -- may either be a pragma argument association, in which case the flag
385 -- is placed on the expression of this association, or an expression,
386 -- in which case the flag is placed directly on the expression. The
387 -- message is placed using Error_Msg_N, so the message may also contain
388 -- an & insertion character which will reference the given Arg value.
389 -- After placing the message, Pragma_Exit is raised.
391 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
);
392 pragma No_Return
(Error_Pragma_Arg
);
393 -- Similar to above form of Error_Pragma_Arg except that two messages
394 -- are provided, the second is a continuation comment starting with \.
396 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
);
397 pragma No_Return
(Error_Pragma_Arg_Ident
);
398 -- Outputs error message for current pragma. The message may contain
399 -- a % that will be replaced with the pragma name. The parameter Arg
400 -- must be a pragma argument association with a non-empty identifier
401 -- (i.e. its Chars field must be set), and the error message is placed
402 -- on the identifier. The message is placed using Error_Msg_N so
403 -- the message may also contain an & insertion character which will
404 -- reference the identifier. After placing the message, Pragma_Exit
407 function Find_Lib_Unit_Name
return Entity_Id
;
408 -- Used for a library unit pragma to find the entity to which the
409 -- library unit pragma applies, returns the entity found.
411 procedure Find_Program_Unit_Name
(Id
: Node_Id
);
412 -- If the pragma is a compilation unit pragma, the id must denote the
413 -- compilation unit in the same compilation, and the pragma must appear
414 -- in the list of preceding or trailing pragmas. If it is a program
415 -- unit pragma that is not a compilation unit pragma, then the
416 -- identifier must be visible.
418 type Name_List
is array (Natural range <>) of Name_Id
;
419 type Args_List
is array (Natural range <>) of Node_Id
;
420 procedure Gather_Associations
422 Args
: out Args_List
);
423 -- This procedure is used to gather the arguments for a pragma that
424 -- permits arbitrary ordering of parameters using the normal rules
425 -- for named and positional parameters. The Names argument is a list
426 -- of Name_Id values that corresponds to the allowed pragma argument
427 -- association identifiers in order. The result returned in Args is
428 -- a list of corresponding expressions that are the pragma arguments.
429 -- Note that this is a list of expressions, not of pragma argument
430 -- associations (Gather_Associations has completely checked all the
431 -- optional identifiers when it returns). An entry in Args is Empty
432 -- on return if the corresponding argument is not present.
434 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
;
435 -- All the routines that check pragma arguments take either a pragma
436 -- argument association (in which case the expression of the argument
437 -- association is checked), or the expression directly. The function
438 -- Get_Pragma_Arg is a utility used to deal with these two cases. If
439 -- Arg is a pragma argument association node, then its expression is
440 -- returned, otherwise Arg is returned unchanged.
442 procedure GNAT_Pragma
;
443 -- Called for all GNAT defined pragmas to note the use of the feature,
444 -- and also check the relevant restriction (No_Implementation_Pragmas).
446 function Is_Before_First_Decl
447 (Pragma_Node
: Node_Id
;
450 -- Return True if Pragma_Node is before the first declarative item in
451 -- Decls where Decls is the list of declarative items.
453 function Is_Configuration_Pragma
return Boolean;
454 -- Deterermines if the placement of the current pragma is appropriate
455 -- for a configuration pragma (precedes the current compilation unit)
457 procedure Pragma_Misplaced
;
458 -- Issue fatal error message for misplaced pragma
460 procedure Process_Atomic_Shared_Volatile
;
461 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
462 -- Shared is an obsolete Ada 83 pragma, treated as being identical
463 -- in effect to pragma Atomic.
465 procedure Process_Convention
(C
: out Convention_Id
; E
: out Entity_Id
);
466 -- Common procesing for Convention, Interface, Import and Export.
467 -- Checks first two arguments of pragma, and sets the appropriate
468 -- convention value in the specified entity or entities. On return
469 -- C is the convention, E is the referenced entity.
471 procedure Process_Extended_Import_Export_Exception_Pragma
472 (Arg_Internal
: Node_Id
;
473 Arg_External
: Node_Id
;
476 -- Common processing for the pragmas Import/Export_Exception.
477 -- The three arguments correspond to the three named parameters of
478 -- the pragma. An argument is empty if the corresponding parameter
479 -- is not present in the pragma.
481 procedure Process_Extended_Import_Export_Object_Pragma
482 (Arg_Internal
: Node_Id
;
483 Arg_External
: Node_Id
;
485 -- Common processing for the pragmass Import/Export_Object.
486 -- The three arguments correspond to the three named parameters
487 -- of the pragmas. An argument is empty if the corresponding
488 -- parameter is not present in the pragma.
490 procedure Process_Extended_Import_Export_Internal_Arg
491 (Arg_Internal
: Node_Id
:= Empty
);
492 -- Common processing for all extended Import and Export pragmas. The
493 -- argument is the pragma parameter for the Internal argument. If
494 -- Arg_Internal is empty or inappropriate, an error message is posted.
495 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
496 -- set to identify the referenced entity.
498 procedure Process_Extended_Import_Export_Subprogram_Pragma
499 (Arg_Internal
: Node_Id
;
500 Arg_External
: Node_Id
;
501 Arg_Parameter_Types
: Node_Id
;
502 Arg_Result_Type
: Node_Id
:= Empty
;
503 Arg_Mechanism
: Node_Id
;
504 Arg_Result_Mechanism
: Node_Id
:= Empty
;
505 Arg_First_Optional_Parameter
: Node_Id
:= Empty
);
506 -- Common processing for all extended Import and Export pragmas
507 -- applying to subprograms. The caller omits any arguments that do
508 -- bnot apply to the pragma in question (for example, Arg_Result_Type
509 -- can be non-Empty only in the Import_Function and Export_Function
510 -- cases). The argument names correspond to the allowed pragma
511 -- association identifiers.
513 procedure Process_Generic_List
;
514 -- Common processing for Share_Generic and Inline_Generic
516 procedure Process_Import_Or_Interface
;
517 -- Common processing for Import of Interface
519 procedure Process_Inline
(Active
: Boolean);
520 -- Common processing for Inline and Inline_Always. The parameter
521 -- indicates if the inline pragma is active, i.e. if it should
522 -- actually cause inlining to occur.
524 procedure Process_Interface_Name
525 (Subprogram_Def
: Entity_Id
;
528 -- Given the last two arguments of pragma Import, pragma Export, or
529 -- pragma Interface_Name, performs validity checks and sets the
530 -- Interface_Name field of the given subprogram entity to the
531 -- appropriate external or link name, depending on the arguments
532 -- given. Ext_Arg is always present, but Link_Arg may be missing.
533 -- Note that Ext_Arg may represent the Link_Name if Link_Arg is
534 -- missing, and appropriate named notation is used for Ext_Arg.
535 -- If neither Ext_Arg nor Link_Arg is present, the interface name
536 -- is set to the default from the subprogram name.
538 procedure Process_Interrupt_Or_Attach_Handler
;
539 -- Attach the pragmas to the rep item chain.
541 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean);
542 -- Common processing for Suppress and Unsuppress. The boolean parameter
543 -- Suppress_Case is True for the Suppress case, and False for the
546 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
);
547 -- This procedure sets the Is_Exported flag for the given entity,
548 -- checking that the entity was not previously imported. Arg is
549 -- the argument that specified the entity.
551 procedure Set_Extended_Import_Export_External_Name
552 (Internal_Ent
: Entity_Id
;
553 Arg_External
: Node_Id
);
554 -- Common processing for all extended import export pragmas. The first
555 -- argument, Internal_Ent, is the internal entity, which has already
556 -- been checked for validity by the caller. Arg_External is from the
557 -- Import or Export pragma, and may be null if no External parameter
558 -- was present. If Arg_External is present and is a non-null string
559 -- (a null string is treated as the default), then the Interface_Name
560 -- field of Internal_Ent is set appropriately.
562 procedure Set_Imported
(E
: Entity_Id
);
563 -- This procedure sets the Is_Imported flag for the given entity,
564 -- checking that it is not previously exported or imported.
566 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
);
567 -- Mech is a parameter passing mechanism (see Import_Function syntax
568 -- for MECHANISM_NAME). This routine checks that the mechanism argument
569 -- has the right form, and if not issues an error message. If the
570 -- argument has the right form then the Mechanism field of Ent is
571 -- set appropriately.
573 --------------------------
574 -- Check_Ada_83_Warning --
575 --------------------------
577 procedure Check_Ada_83_Warning
is
581 if Ada_83
and then Comes_From_Source
(N
) then
582 Error_Msg_N
("(Ada 83) pragma& is non-standard?", N
);
584 end Check_Ada_83_Warning
;
586 ---------------------
587 -- Check_Arg_Count --
588 ---------------------
590 procedure Check_Arg_Count
(Required
: Nat
) is
592 if Arg_Count
/= Required
then
593 Error_Pragma
("wrong number of arguments for pragma%");
597 -----------------------------
598 -- Check_Arg_Is_Identifier --
599 -----------------------------
601 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
) is
602 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
605 if Nkind
(Argx
) /= N_Identifier
then
607 ("argument for pragma% must be identifier", Argx
);
609 end Check_Arg_Is_Identifier
;
611 ----------------------------------
612 -- Check_Arg_Is_Integer_Literal --
613 ----------------------------------
615 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
) is
616 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
619 if Nkind
(Argx
) /= N_Integer_Literal
then
621 ("argument for pragma% must be integer literal", Argx
);
623 end Check_Arg_Is_Integer_Literal
;
625 -------------------------------------------
626 -- Check_Arg_Is_Library_Level_Local_Name --
627 -------------------------------------------
631 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
632 -- | library_unit_NAME
634 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
) is
636 Check_Arg_Is_Local_Name
(Arg
);
638 if not Is_Library_Level_Entity
(Entity
(Expression
(Arg
)))
639 and then Comes_From_Source
(N
)
642 ("argument for pragma% must be library level entity", Arg
);
644 end Check_Arg_Is_Library_Level_Local_Name
;
646 -----------------------------
647 -- Check_Arg_Is_Local_Name --
648 -----------------------------
652 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
653 -- | library_unit_NAME
655 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
) is
656 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
661 if Nkind
(Argx
) not in N_Direct_Name
662 and then (Nkind
(Argx
) /= N_Attribute_Reference
663 or else Present
(Expressions
(Argx
))
664 or else Nkind
(Prefix
(Argx
)) /= N_Identifier
)
665 and then (not Is_Entity_Name
(Argx
)
666 or else not Is_Compilation_Unit
(Entity
(Argx
)))
668 Error_Pragma_Arg
("argument for pragma% must be local name", Argx
);
671 if Is_Entity_Name
(Argx
)
672 and then Scope
(Entity
(Argx
)) /= Current_Scope
675 ("pragma% argument must be in same declarative part", Arg
);
677 end Check_Arg_Is_Local_Name
;
679 ---------------------------------
680 -- Check_Arg_Is_Locking_Policy --
681 ---------------------------------
683 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
) is
684 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
687 Check_Arg_Is_Identifier
(Argx
);
689 if not Is_Locking_Policy_Name
(Chars
(Argx
)) then
691 ("& is not a valid locking policy name", Argx
);
693 end Check_Arg_Is_Locking_Policy
;
695 -------------------------
696 -- Check_Arg_Is_One_Of --
697 -------------------------
699 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
) is
700 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
703 Check_Arg_Is_Identifier
(Argx
);
705 if Chars
(Argx
) /= N1
and then Chars
(Argx
) /= N2
then
706 Error_Msg_Name_2
:= N1
;
707 Error_Msg_Name_3
:= N2
;
708 Error_Pragma_Arg
("argument for pragma% must be% or%", Argx
);
710 end Check_Arg_Is_One_Of
;
712 procedure Check_Arg_Is_One_Of
714 N1
, N2
, N3
: Name_Id
)
716 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
719 Check_Arg_Is_Identifier
(Argx
);
721 if Chars
(Argx
) /= N1
722 and then Chars
(Argx
) /= N2
723 and then Chars
(Argx
) /= N3
725 Error_Pragma_Arg
("invalid argument for pragma%", Argx
);
727 end Check_Arg_Is_One_Of
;
729 ---------------------------------
730 -- Check_Arg_Is_Queuing_Policy --
731 ---------------------------------
733 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
) is
734 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
737 Check_Arg_Is_Identifier
(Argx
);
739 if not Is_Queuing_Policy_Name
(Chars
(Argx
)) then
741 ("& is not a valid queuing policy name", Argx
);
743 end Check_Arg_Is_Queuing_Policy
;
745 ------------------------------------
746 -- Check_Arg_Is_Static_Expression --
747 ------------------------------------
749 procedure Check_Arg_Is_Static_Expression
753 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
756 Analyze_And_Resolve
(Argx
, Typ
);
758 if Is_OK_Static_Expression
(Argx
) then
761 elsif Etype
(Argx
) = Any_Type
then
764 -- An interesting special case, if we have a string literal and
765 -- we are in Ada 83 mode, then we allow it even though it will
766 -- not be flagged as static. This allows the use of Ada 95
767 -- pragmas like Import in Ada 83 mode. They will of course be
768 -- flagged with warnings as usual, but will not cause errors.
770 elsif Ada_83
and then Nkind
(Argx
) = N_String_Literal
then
773 -- Static expression that raises Constraint_Error. This has
774 -- already been flagged, so just exit from pragma processing.
776 elsif Is_Static_Expression
(Argx
) then
779 -- Finally, we have a real error
783 ("argument for pragma% must be a static expression", Argx
);
786 end Check_Arg_Is_Static_Expression
;
788 ---------------------------------
789 -- Check_Arg_Is_String_Literal --
790 ---------------------------------
792 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
) is
793 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
796 if Nkind
(Argx
) /= N_String_Literal
then
798 ("argument for pragma% must be string literal", Argx
);
801 end Check_Arg_Is_String_Literal
;
803 ------------------------------------------
804 -- Check_Arg_Is_Task_Dispatching_Policy --
805 ------------------------------------------
807 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
) is
808 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
811 Check_Arg_Is_Identifier
(Argx
);
813 if not Is_Task_Dispatching_Policy_Name
(Chars
(Argx
)) then
815 ("& is not a valid task dispatching policy name", Argx
);
817 end Check_Arg_Is_Task_Dispatching_Policy
;
819 --------------------------------
820 -- Check_At_Least_N_Arguments --
821 --------------------------------
823 procedure Check_At_Least_N_Arguments
(N
: Nat
) is
825 if Arg_Count
< N
then
826 Error_Pragma
("too few arguments for pragma%");
828 end Check_At_Least_N_Arguments
;
830 -------------------------------
831 -- Check_At_Most_N_Arguments --
832 -------------------------------
834 procedure Check_At_Most_N_Arguments
(N
: Nat
) is
838 if Arg_Count
> N
then
843 Error_Pragma_Arg
("too many arguments for pragma%", Arg
);
846 end Check_At_Most_N_Arguments
;
848 -------------------------
849 -- Check_First_Subtype --
850 -------------------------
852 procedure Check_First_Subtype
(Arg
: Node_Id
) is
853 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
856 if not Is_First_Subtype
(Entity
(Argx
)) then
858 ("pragma% cannot apply to subtype", Argx
);
860 end Check_First_Subtype
;
862 ---------------------------
863 -- Check_In_Main_Program --
864 ---------------------------
866 procedure Check_In_Main_Program
is
867 P
: constant Node_Id
:= Parent
(N
);
870 -- Must be at in subprogram body
872 if Nkind
(P
) /= N_Subprogram_Body
then
873 Error_Pragma
("% pragma allowed only in subprogram");
875 -- Otherwise warn if obviously not main program
877 elsif Present
(Parameter_Specifications
(Specification
(P
)))
878 or else not Is_Library_Level_Entity
(Defining_Entity
(P
))
880 Error_Msg_Name_1
:= Chars
(N
);
882 ("?pragma% is only effective in main program", N
);
884 end Check_In_Main_Program
;
886 ---------------------------------------
887 -- Check_Interrupt_Or_Attach_Handler --
888 ---------------------------------------
890 procedure Check_Interrupt_Or_Attach_Handler
is
891 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
896 if not Is_Entity_Name
(Arg1_X
) then
898 ("argument of pragma% must be entity name", Arg1
);
900 elsif Prag_Id
= Pragma_Interrupt_Handler
then
901 Check_Restriction
(No_Dynamic_Interrupts
, N
);
905 Prot_Proc
: Entity_Id
:= Empty
;
906 Prot_Type
: Entity_Id
;
907 Found
: Boolean := False;
910 if not Is_Overloaded
(Arg1_X
) then
911 Prot_Proc
:= Entity
(Arg1_X
);
916 Index
: Interp_Index
;
919 Get_First_Interp
(Arg1_X
, Index
, It
);
920 while Present
(It
.Nam
) loop
923 if Ekind
(Prot_Proc
) = E_Procedure
924 and then No
(First_Formal
(Prot_Proc
))
928 Set_Entity
(Arg1_X
, Prot_Proc
);
929 Set_Is_Overloaded
(Arg1_X
, False);
932 ("ambiguous handler name for pragma% ", Arg1
);
936 Get_Next_Interp
(Index
, It
);
941 ("argument of pragma% must be parameterless procedure",
944 Prot_Proc
:= Entity
(Arg1_X
);
949 Prot_Type
:= Scope
(Prot_Proc
);
951 if Ekind
(Prot_Proc
) /= E_Procedure
952 or else Ekind
(Prot_Type
) /= E_Protected_Type
955 ("argument of pragma% must be protected procedure",
959 if not Is_Library_Level_Entity
(Prot_Type
) then
961 ("pragma% requires library level entity", Arg1
);
964 if Present
(First_Formal
(Prot_Proc
)) then
966 ("argument of pragma% must be parameterless procedure",
971 Protected_Definition
(Parent
(Prot_Type
))
973 Error_Pragma
("pragma% must be in protected definition");
977 end Check_Interrupt_Or_Attach_Handler
;
979 -------------------------------------------
980 -- Check_Is_In_Decl_Part_Or_Package_Spec --
981 -------------------------------------------
983 procedure Check_Is_In_Decl_Part_Or_Package_Spec
is
992 elsif Nkind
(P
) = N_Handled_Sequence_Of_Statements
then
995 elsif Nkind
(P
) = N_Package_Specification
then
998 elsif Nkind
(P
) = N_Block_Statement
then
1001 -- Note: the following tests seem a little peculiar, because
1002 -- they test for bodies, but if we were in the statement part
1003 -- of the body, we would already have hit the handled statement
1004 -- sequence, so the only way we get here is by being in the
1005 -- declarative part of the body.
1007 elsif Nkind
(P
) = N_Subprogram_Body
1008 or else Nkind
(P
) = N_Package_Body
1009 or else Nkind
(P
) = N_Task_Body
1010 or else Nkind
(P
) = N_Entry_Body
1018 Error_Pragma
("pragma% is not in declarative part or package spec");
1020 end Check_Is_In_Decl_Part_Or_Package_Spec
;
1022 -------------------------
1023 -- Check_No_Identifier --
1024 -------------------------
1026 procedure Check_No_Identifier
(Arg
: Node_Id
) is
1028 if Chars
(Arg
) /= No_Name
then
1029 Error_Pragma_Arg_Ident
1030 ("pragma% does not permit identifier& here", Arg
);
1032 end Check_No_Identifier
;
1034 --------------------------
1035 -- Check_No_Identifiers --
1036 --------------------------
1038 procedure Check_No_Identifiers
is
1042 if Arg_Count
> 0 then
1045 while Present
(Arg_Node
) loop
1046 Check_No_Identifier
(Arg_Node
);
1050 end Check_No_Identifiers
;
1052 -----------------------------------
1053 -- Check_Non_Overloaded_Function --
1054 -----------------------------------
1056 procedure Check_Non_Overloaded_Function
(Arg
: Node_Id
) is
1060 Check_Arg_Is_Local_Name
(Arg
);
1061 Ent
:= Entity
(Expression
(Arg
));
1063 if Present
(Homonym
(Ent
))
1064 and then Scope
(Homonym
(Ent
)) = Current_Scope
1067 ("argument for pragma% may not be overloaded", Arg
);
1070 if Ekind
(Ent
) /= E_Function
1071 or else No
(First_Formal
(Ent
))
1072 or else Present
(Next_Formal
(First_Formal
(Ent
)))
1075 ("argument for pragma% must be function of one argument", Arg
);
1077 end Check_Non_Overloaded_Function
;
1079 -------------------------------
1080 -- Check_Optional_Identifier --
1081 -------------------------------
1083 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
) is
1085 if Present
(Arg
) and then Chars
(Arg
) /= No_Name
then
1086 if Chars
(Arg
) /= Id
then
1087 Error_Msg_Name_1
:= Chars
(N
);
1088 Error_Msg_Name_2
:= Id
;
1089 Error_Msg_N
("pragma% argument expects identifier%", Arg
);
1093 end Check_Optional_Identifier
;
1095 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String) is
1097 Name_Buffer
(1 .. Id
'Length) := Id
;
1098 Name_Len
:= Id
'Length;
1099 Check_Optional_Identifier
(Arg
, Name_Find
);
1100 end Check_Optional_Identifier
;
1102 -----------------------------
1103 -- Check_Static_Constraint --
1104 -----------------------------
1106 -- Note: for convenience in writing this procedure, in addition to
1107 -- the officially (i.e. by spec) allowed argument which is always
1108 -- a constraint, it also allows ranges and discriminant associations.
1110 procedure Check_Static_Constraint
(Constr
: Node_Id
) is
1112 --------------------
1113 -- Require_Static --
1114 --------------------
1116 procedure Require_Static
(E
: Node_Id
);
1117 -- Require given expression to be static expression
1119 procedure Require_Static
(E
: Node_Id
) is
1121 if not Is_OK_Static_Expression
(E
) then
1123 ("non-static constraint not allowed in Unchecked_Union", E
);
1128 -- Start of processing for Check_Static_Constraint
1131 case Nkind
(Constr
) is
1132 when N_Discriminant_Association
=>
1133 Require_Static
(Expression
(Constr
));
1136 Require_Static
(Low_Bound
(Constr
));
1137 Require_Static
(High_Bound
(Constr
));
1139 when N_Attribute_Reference
=>
1140 Require_Static
(Type_Low_Bound
(Etype
(Prefix
(Constr
))));
1141 Require_Static
(Type_High_Bound
(Etype
(Prefix
(Constr
))));
1143 when N_Range_Constraint
=>
1144 Check_Static_Constraint
(Range_Expression
(Constr
));
1146 when N_Index_Or_Discriminant_Constraint
=>
1148 IDC
: Entity_Id
:= First
(Constraints
(Constr
));
1151 while Present
(IDC
) loop
1152 Check_Static_Constraint
(IDC
);
1160 end Check_Static_Constraint
;
1162 --------------------------------------
1163 -- Check_Valid_Configuration_Pragma --
1164 --------------------------------------
1166 -- A configuration pragma must appear in the context clause of
1167 -- a compilation unit, at the start of the list (i.e. only other
1168 -- pragmas may precede it).
1170 procedure Check_Valid_Configuration_Pragma
is
1172 if not Is_Configuration_Pragma
then
1173 Error_Pragma
("incorrect placement for configuration pragma%");
1175 end Check_Valid_Configuration_Pragma
;
1177 -------------------------------------
1178 -- Check_Valid_Library_Unit_Pragma --
1179 -------------------------------------
1181 procedure Check_Valid_Library_Unit_Pragma
is
1183 Parent_Node
: Node_Id
;
1184 Unit_Name
: Entity_Id
;
1185 Valid
: Boolean := True;
1186 Unit_Kind
: Node_Kind
;
1187 Unit_Node
: Node_Id
;
1188 Sindex
: Source_File_Index
;
1191 if not Is_List_Member
(N
) then
1196 Plist
:= List_Containing
(N
);
1197 Parent_Node
:= Parent
(Plist
);
1199 if Parent_Node
= Empty
then
1202 -- Case of pragma appearing after a compilation unit. In this
1203 -- case it must have an argument with the corresponding name
1204 -- and must be part of the following pragmas of its parent.
1206 elsif Nkind
(Parent_Node
) = N_Compilation_Unit_Aux
then
1207 if Plist
/= Pragmas_After
(Parent_Node
) then
1210 elsif Arg_Count
= 0 then
1212 ("argument required if outside compilation unit");
1215 Check_No_Identifiers
;
1216 Check_Arg_Count
(1);
1217 Unit_Node
:= Unit
(Parent
(Parent_Node
));
1218 Unit_Kind
:= Nkind
(Unit_Node
);
1220 Analyze
(Expression
(Arg1
));
1222 if Unit_Kind
= N_Generic_Subprogram_Declaration
1223 or else Unit_Kind
= N_Subprogram_Declaration
1225 Unit_Name
:= Defining_Entity
(Unit_Node
);
1227 elsif Unit_Kind
= N_Function_Instantiation
1228 or else Unit_Kind
= N_Package_Instantiation
1229 or else Unit_Kind
= N_Procedure_Instantiation
1231 Unit_Name
:= Defining_Entity
(Unit_Node
);
1234 Unit_Name
:= Cunit_Entity
(Current_Sem_Unit
);
1237 if Chars
(Unit_Name
) /=
1238 Chars
(Entity
(Expression
(Arg1
)))
1241 ("pragma% argument is not current unit name", Arg1
);
1244 if Ekind
(Unit_Name
) = E_Package
1245 and then Present
(Renamed_Entity
(Unit_Name
))
1247 Error_Pragma
("pragma% not allowed for renamed package");
1251 -- Pragma appears other than after a compilation unit
1254 -- Here we check for the generic instantiation case and also
1255 -- for the case of processing a generic formal package. We
1256 -- detect these cases by noting that the Sloc on the node
1257 -- does not belong to the current compilation unit.
1259 Sindex
:= Source_Index
(Current_Sem_Unit
);
1261 if Loc
not in Source_First
(Sindex
) .. Source_Last
(Sindex
) then
1262 Rewrite
(N
, Make_Null_Statement
(Loc
));
1265 -- If before first declaration, the pragma applies to the
1266 -- enclosing unit, and the name if present must be this name.
1268 elsif Is_Before_First_Decl
(N
, Plist
) then
1269 Unit_Node
:= Unit_Declaration_Node
(Current_Scope
);
1270 Unit_Kind
:= Nkind
(Unit_Node
);
1272 if Nkind
(Parent
(Unit_Node
)) /= N_Compilation_Unit
then
1275 elsif Unit_Kind
= N_Subprogram_Body
1276 and then not Acts_As_Spec
(Unit_Node
)
1280 elsif Nkind
(Parent_Node
) = N_Package_Body
then
1283 elsif Nkind
(Parent_Node
) = N_Package_Specification
1284 and then Plist
= Private_Declarations
(Parent_Node
)
1288 elsif (Nkind
(Parent_Node
) = N_Generic_Package_Declaration
1289 or else Nkind
(Parent_Node
)
1290 = N_Generic_Subprogram_Declaration
)
1291 and then Plist
= Generic_Formal_Declarations
(Parent_Node
)
1295 elsif Arg_Count
> 0 then
1296 Analyze
(Expression
(Arg1
));
1298 if Entity
(Expression
(Arg1
)) /= Current_Scope
then
1300 ("name in pragma% must be enclosing unit", Arg1
);
1303 -- It is legal to have no argument in this context
1309 -- Error if not before first declaration. This is because a
1310 -- library unit pragma argument must be the name of a library
1311 -- unit (RM 10.1.5(7)), but the only names permitted in this
1312 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1313 -- generic subprogram declarations or generic instantiations.
1317 ("pragma% misplaced, must be before first declaration");
1322 end Check_Valid_Library_Unit_Pragma
;
1328 procedure Error_Pragma
(Msg
: String) is
1330 Error_Msg_Name_1
:= Chars
(N
);
1331 Error_Msg_N
(Msg
, N
);
1335 ----------------------
1336 -- Error_Pragma_Arg --
1337 ----------------------
1339 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
) is
1341 Error_Msg_Name_1
:= Chars
(N
);
1342 Error_Msg_N
(Msg
, Get_Pragma_Arg
(Arg
));
1344 end Error_Pragma_Arg
;
1346 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
) is
1348 Error_Msg_Name_1
:= Chars
(N
);
1349 Error_Msg_N
(Msg1
, Get_Pragma_Arg
(Arg
));
1350 Error_Pragma_Arg
(Msg2
, Arg
);
1351 end Error_Pragma_Arg
;
1353 ----------------------------
1354 -- Error_Pragma_Arg_Ident --
1355 ----------------------------
1357 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
) is
1359 Error_Msg_Name_1
:= Chars
(N
);
1360 Error_Msg_N
(Msg
, Arg
);
1362 end Error_Pragma_Arg_Ident
;
1364 ------------------------
1365 -- Find_Lib_Unit_Name --
1366 ------------------------
1368 function Find_Lib_Unit_Name
return Entity_Id
is
1370 -- Return inner compilation unit entity, for case of nested
1371 -- categorization pragmas. This happens in generic unit.
1373 if Nkind
(Parent
(N
)) = N_Package_Specification
1374 and then Defining_Entity
(Parent
(N
)) /= Current_Scope
1376 return Defining_Entity
(Parent
(N
));
1379 return Current_Scope
;
1381 end Find_Lib_Unit_Name
;
1383 ----------------------------
1384 -- Find_Program_Unit_Name --
1385 ----------------------------
1387 procedure Find_Program_Unit_Name
(Id
: Node_Id
) is
1388 Unit_Name
: Entity_Id
;
1389 Unit_Kind
: Node_Kind
;
1390 P
: constant Node_Id
:= Parent
(N
);
1393 if Nkind
(P
) = N_Compilation_Unit
then
1394 Unit_Kind
:= Nkind
(Unit
(P
));
1396 if Unit_Kind
= N_Subprogram_Declaration
1397 or else Unit_Kind
= N_Package_Declaration
1398 or else Unit_Kind
in N_Generic_Declaration
1400 Unit_Name
:= Defining_Entity
(Unit
(P
));
1402 if Chars
(Id
) = Chars
(Unit_Name
) then
1403 Set_Entity
(Id
, Unit_Name
);
1404 Set_Etype
(Id
, Etype
(Unit_Name
));
1406 Set_Etype
(Id
, Any_Type
);
1408 ("cannot find program unit referenced by pragma%");
1412 Set_Etype
(Id
, Any_Type
);
1413 Error_Pragma
("pragma% inapplicable to this unit");
1420 end Find_Program_Unit_Name
;
1422 -------------------------
1423 -- Gather_Associations --
1424 -------------------------
1426 procedure Gather_Associations
1428 Args
: out Args_List
)
1433 -- Initialize all parameters to Empty
1435 for J
in Args
'Range loop
1439 -- That's all we have to do if there are no argument associations
1441 if No
(Pragma_Argument_Associations
(N
)) then
1445 -- Otherwise first deal with any positional parameters present
1447 Arg
:= First
(Pragma_Argument_Associations
(N
));
1449 for Index
in Args
'Range loop
1450 exit when No
(Arg
) or else Chars
(Arg
) /= No_Name
;
1451 Args
(Index
) := Expression
(Arg
);
1455 -- Positional parameters all processed, if any left, then we
1456 -- have too many positional parameters.
1458 if Present
(Arg
) and then Chars
(Arg
) = No_Name
then
1460 ("too many positional associations for pragma%", Arg
);
1463 -- Process named parameters if any are present
1465 while Present
(Arg
) loop
1466 if Chars
(Arg
) = No_Name
then
1468 ("positional association cannot follow named association",
1472 for Index
in Names
'Range loop
1473 if Names
(Index
) = Chars
(Arg
) then
1474 if Present
(Args
(Index
)) then
1476 ("duplicate argument association for pragma%", Arg
);
1478 Args
(Index
) := Expression
(Arg
);
1483 if Index
= Names
'Last then
1484 Error_Pragma_Arg_Ident
1485 ("pragma% does not allow & argument", Arg
);
1492 end Gather_Associations
;
1494 --------------------
1495 -- Get_Pragma_Arg --
1496 --------------------
1498 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
is
1500 if Nkind
(Arg
) = N_Pragma_Argument_Association
then
1501 return Expression
(Arg
);
1511 procedure GNAT_Pragma
is
1513 Check_Restriction
(No_Implementation_Pragmas
, N
);
1516 --------------------------
1517 -- Is_Before_First_Decl --
1518 --------------------------
1520 function Is_Before_First_Decl
1521 (Pragma_Node
: Node_Id
;
1525 Item
: Node_Id
:= First
(Decls
);
1528 -- Only other pragmas can come before this pragma
1531 if No
(Item
) or else Nkind
(Item
) /= N_Pragma
then
1534 elsif Item
= Pragma_Node
then
1541 end Is_Before_First_Decl
;
1543 -----------------------------
1544 -- Is_Configuration_Pragma --
1545 -----------------------------
1547 -- A configuration pragma must appear in the context clause of
1548 -- a compilation unit, at the start of the list (i.e. only other
1549 -- pragmas may precede it).
1551 function Is_Configuration_Pragma
return Boolean is
1552 Lis
: constant List_Id
:= List_Containing
(N
);
1553 Par
: constant Node_Id
:= Parent
(N
);
1557 -- If no parent, then we are in the configuration pragma file,
1558 -- so the placement is definitely appropriate.
1563 -- Otherwise we must be in the context clause of a compilation unit
1564 -- and the only thing allowed before us in the context list is more
1565 -- configuration pragmas.
1567 elsif Nkind
(Par
) = N_Compilation_Unit
1568 and then Context_Items
(Par
) = Lis
1575 elsif Nkind
(Prg
) /= N_Pragma
then
1586 end Is_Configuration_Pragma
;
1588 ----------------------
1589 -- Pragma_Misplaced --
1590 ----------------------
1592 procedure Pragma_Misplaced
is
1594 Error_Pragma
("incorrect placement of pragma%");
1595 end Pragma_Misplaced
;
1597 ------------------------------------
1598 -- Process Atomic_Shared_Volatile --
1599 ------------------------------------
1601 procedure Process_Atomic_Shared_Volatile
is
1609 Check_Ada_83_Warning
;
1610 Check_No_Identifiers
;
1611 Check_Arg_Count
(1);
1612 Check_Arg_Is_Local_Name
(Arg1
);
1613 E_Id
:= Expression
(Arg1
);
1615 if Etype
(E_Id
) = Any_Type
then
1620 D
:= Declaration_Node
(E
);
1624 if Rep_Item_Too_Early
(E
, N
)
1626 Rep_Item_Too_Late
(E
, N
)
1630 Check_First_Subtype
(Arg1
);
1633 if Prag_Id
/= Pragma_Volatile
then
1635 Set_Is_Atomic
(Underlying_Type
(E
));
1638 Set_Is_Volatile
(E
);
1639 Set_Is_Volatile
(Underlying_Type
(E
));
1641 elsif K
= N_Object_Declaration
1642 or else (K
= N_Component_Declaration
1643 and then Original_Record_Component
(E
) = E
)
1645 if Rep_Item_Too_Late
(E
, N
) then
1649 if Prag_Id
/= Pragma_Volatile
then
1653 Set_Is_Volatile
(E
);
1657 ("inappropriate entity for pragma%", Arg1
);
1659 end Process_Atomic_Shared_Volatile
;
1661 ------------------------
1662 -- Process_Convention --
1663 ------------------------
1665 procedure Process_Convention
1666 (C
: out Convention_Id
;
1671 Comp_Unit
: Unit_Number_Type
;
1674 procedure Set_Convention_From_Pragma
(E
: Entity_Id
);
1675 -- Set convention in entity E, and also flag that the entity has a
1676 -- convention pragma. If entity is for a private or incomplete type,
1677 -- also set convention and flag on underlying type. This procedure
1678 -- also deals with the special case of C_Pass_By_Copy convention.
1680 --------------------------------
1681 -- Set_Convention_From_Pragma --
1682 --------------------------------
1684 procedure Set_Convention_From_Pragma
(E
: Entity_Id
) is
1686 Set_Convention
(E
, C
);
1687 Set_Has_Convention_Pragma
(E
);
1689 if Is_Incomplete_Or_Private_Type
(E
) then
1690 Set_Convention
(Underlying_Type
(E
), C
);
1691 Set_Has_Convention_Pragma
(Underlying_Type
(E
), True);
1694 -- A class-wide type should inherit the convention of
1695 -- the specific root type (although this isn't specified
1696 -- clearly by the RM).
1698 if Is_Type
(E
) and then Present
(Class_Wide_Type
(E
)) then
1699 Set_Convention
(Class_Wide_Type
(E
), C
);
1702 -- If the entity is a record type, then check for special case
1703 -- of C_Pass_By_Copy, which is treated the same as C except that
1704 -- the special record flag is set. This convention is also only
1705 -- permitted on record types (see AI95-00131).
1707 if Cname
= Name_C_Pass_By_Copy
then
1708 if Is_Record_Type
(E
) then
1709 Set_C_Pass_By_Copy
(Base_Type
(E
));
1710 elsif Is_Incomplete_Or_Private_Type
(E
)
1711 and then Is_Record_Type
(Underlying_Type
(E
))
1713 Set_C_Pass_By_Copy
(Base_Type
(Underlying_Type
(E
)));
1716 ("C_Pass_By_Copy convention allowed only for record type",
1721 -- If the entity is a derived boolean type, check for the
1722 -- special case of convention C, C++, or Fortran, where we
1723 -- consider any nonzero value to represent true.
1725 if Is_Discrete_Type
(E
)
1726 and then Root_Type
(Etype
(E
)) = Standard_Boolean
1732 C
= Convention_Fortran
)
1734 Set_Nonzero_Is_True
(Base_Type
(E
));
1736 end Set_Convention_From_Pragma
;
1738 -- Start of processing for Process_Convention
1741 Check_At_Least_N_Arguments
(2);
1742 Check_Arg_Is_Identifier
(Arg1
);
1743 Check_Optional_Identifier
(Arg1
, Name_Convention
);
1744 Cname
:= Chars
(Expression
(Arg1
));
1746 -- C_Pass_By_Copy is treated as a synonym for convention C
1747 -- (this is tested again below to set the critical flag)
1749 if Cname
= Name_C_Pass_By_Copy
then
1752 -- Otherwise we must have something in the standard convention list
1754 elsif Is_Convention_Name
(Cname
) then
1755 C
:= Get_Convention_Id
(Chars
(Expression
(Arg1
)));
1757 -- In DEC VMS, it seems that there is an undocumented feature
1758 -- that any unrecognized convention is treated as the default,
1759 -- which for us is convention C. It does not seem so terrible
1760 -- to do this unconditionally, silently in the VMS case, and
1761 -- with a warning in the non-VMS case.
1764 if not OpenVMS_On_Target
then
1766 ("?unrecognized convention name, C assumed",
1773 Check_Arg_Is_Local_Name
(Arg2
);
1774 Check_Optional_Identifier
(Arg2
, Name_Entity
);
1776 Id
:= Expression
(Arg2
);
1779 if not Is_Entity_Name
(Id
) then
1780 Error_Pragma_Arg
("entity name required", Arg2
);
1785 -- Go to renamed subprogram if present, since convention applies
1786 -- to the actual renamed entity, not to the renaming entity.
1788 if Is_Subprogram
(E
)
1789 and then Present
(Alias
(E
))
1790 and then Nkind
(Parent
(Declaration_Node
(E
))) =
1791 N_Subprogram_Renaming_Declaration
1796 -- Check that we not applying this to a specless body
1798 if Is_Subprogram
(E
)
1799 and then Nkind
(Parent
(Declaration_Node
(E
))) = N_Subprogram_Body
1802 ("pragma% requires separate spec and must come before body");
1805 -- Check that we are not applying this to a named constant
1807 if Ekind
(E
) = E_Named_Integer
1809 Ekind
(E
) = E_Named_Real
1811 Error_Msg_Name_1
:= Chars
(N
);
1813 ("cannot apply pragma% to named constant!",
1814 Get_Pragma_Arg
(Arg2
));
1816 ("\supply appropriate type for&!", Arg2
);
1819 if Etype
(E
) = Any_Type
1820 or else Rep_Item_Too_Early
(E
, N
)
1824 E
:= Underlying_Type
(E
);
1827 if Rep_Item_Too_Late
(E
, N
) then
1831 if Has_Convention_Pragma
(E
) then
1833 ("at most one Convention/Export/Import pragma is allowed", Arg2
);
1835 elsif Convention
(E
) = Convention_Protected
1836 or else Ekind
(Scope
(E
)) = E_Protected_Type
1839 ("a protected operation cannot be given a different convention",
1843 -- For Intrinsic, a subprogram is required
1845 if C
= Convention_Intrinsic
1846 and then not Is_Subprogram
(E
)
1847 and then not Is_Generic_Subprogram
(E
)
1850 ("second argument of pragma% must be a subprogram", Arg2
);
1853 -- For Stdcall, a subprogram, variable or subprogram type is required
1855 if C
= Convention_Stdcall
1856 and then not Is_Subprogram
(E
)
1857 and then not Is_Generic_Subprogram
(E
)
1858 and then Ekind
(E
) /= E_Variable
1861 and then Ekind
(Designated_Type
(E
)) = E_Subprogram_Type
)
1864 ("second argument of pragma% must be subprogram (type)",
1868 if not Is_Subprogram
(E
)
1869 and then not Is_Generic_Subprogram
(E
)
1871 Set_Convention_From_Pragma
(E
);
1875 Check_First_Subtype
(Arg2
);
1876 Set_Convention_From_Pragma
(Base_Type
(E
));
1878 -- For subprograms, we must set the convention on the
1879 -- internally generated directly designated type as well.
1881 if Ekind
(E
) = E_Access_Subprogram_Type
then
1882 Set_Convention_From_Pragma
(Directly_Designated_Type
(E
));
1886 -- For the subprogram case, set proper convention for all homonyms
1887 -- in same compilation unit.
1888 -- Is the test of compilation unit really necessary ???
1889 -- What about subprogram renamings here???
1892 Comp_Unit
:= Get_Source_Unit
(E
);
1893 Set_Convention_From_Pragma
(E
);
1898 exit when No
(E1
) or else Scope
(E1
) /= Current_Scope
;
1900 -- Note: below we are missing a check for Rep_Item_Too_Late.
1901 -- That is deliberate, we cannot chain the rep item on more
1902 -- than one Rep_Item chain, to be fixed later ???
1904 if Comp_Unit
= Get_Source_Unit
(E1
) then
1905 Set_Convention_From_Pragma
(E1
);
1910 end Process_Convention
;
1912 -----------------------------------------------------
1913 -- Process_Extended_Import_Export_Exception_Pragma --
1914 -----------------------------------------------------
1916 procedure Process_Extended_Import_Export_Exception_Pragma
1917 (Arg_Internal
: Node_Id
;
1918 Arg_External
: Node_Id
;
1926 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
1927 Def_Id
:= Entity
(Arg_Internal
);
1929 if Ekind
(Def_Id
) /= E_Exception
then
1931 ("pragma% must refer to declared exception", Arg_Internal
);
1934 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
1936 if Present
(Arg_Form
) then
1937 Check_Arg_Is_One_Of
(Arg_Form
, Name_Ada
, Name_VMS
);
1940 if Present
(Arg_Form
)
1941 and then Chars
(Arg_Form
) = Name_Ada
1945 Set_Is_VMS_Exception
(Def_Id
);
1946 Set_Exception_Code
(Def_Id
, No_Uint
);
1949 if Present
(Arg_Code
) then
1950 if not Is_VMS_Exception
(Def_Id
) then
1952 ("Code option for pragma% not allowed for Ada case",
1956 Check_Arg_Is_Static_Expression
(Arg_Code
, Any_Integer
);
1957 Code_Val
:= Expr_Value
(Arg_Code
);
1959 if not UI_Is_In_Int_Range
(Code_Val
) then
1961 ("Code option for pragma% must be in 32-bit range",
1965 Set_Exception_Code
(Def_Id
, Code_Val
);
1969 end Process_Extended_Import_Export_Exception_Pragma
;
1971 -------------------------------------------------
1972 -- Process_Extended_Import_Export_Internal_Arg --
1973 -------------------------------------------------
1975 procedure Process_Extended_Import_Export_Internal_Arg
1976 (Arg_Internal
: Node_Id
:= Empty
)
1981 if No
(Arg_Internal
) then
1982 Error_Pragma
("Internal parameter required for pragma%");
1985 if Nkind
(Arg_Internal
) = N_Identifier
then
1988 elsif Nkind
(Arg_Internal
) = N_Operator_Symbol
1989 and then (Prag_Id
= Pragma_Import_Function
1991 Prag_Id
= Pragma_Export_Function
)
1997 ("wrong form for Internal parameter for pragma%", Arg_Internal
);
2000 Check_Arg_Is_Local_Name
(Arg_Internal
);
2002 end Process_Extended_Import_Export_Internal_Arg
;
2004 --------------------------------------------------
2005 -- Process_Extended_Import_Export_Object_Pragma --
2006 --------------------------------------------------
2008 procedure Process_Extended_Import_Export_Object_Pragma
2009 (Arg_Internal
: Node_Id
;
2010 Arg_External
: Node_Id
;
2016 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2017 Def_Id
:= Entity
(Arg_Internal
);
2019 if Ekind
(Def_Id
) /= E_Constant
2020 and then Ekind
(Def_Id
) /= E_Variable
2023 ("pragma% must designate an object", Arg_Internal
);
2026 if Is_Psected
(Def_Id
) then
2028 ("previous Psect_Object applies, pragma % not permitted",
2032 if Rep_Item_Too_Late
(Def_Id
, N
) then
2036 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2038 if Present
(Arg_Size
)
2039 and then Nkind
(Arg_Size
) /= N_Identifier
2040 and then Nkind
(Arg_Size
) /= N_String_Literal
2043 ("pragma% Size argument must be identifier or string literal",
2047 -- Export_Object case
2049 if Prag_Id
= Pragma_Export_Object
then
2051 if not Is_Library_Level_Entity
(Def_Id
) then
2053 ("argument for pragma% must be library level entity",
2057 if Ekind
(Current_Scope
) = E_Generic_Package
then
2058 Error_Pragma
("pragma& cannot appear in a generic unit");
2061 if not Size_Known_At_Compile_Time
(Etype
(Def_Id
)) then
2063 ("exported object must have compile time known size",
2067 if Is_Exported
(Def_Id
) then
2069 ("?duplicate Export_Object pragma", N
);
2071 Set_Exported
(Def_Id
, Arg_Internal
);
2074 -- Import_Object case
2077 if Is_Concurrent_Type
(Etype
(Def_Id
)) then
2079 ("cannot use pragma% for task/protected object",
2083 if Ekind
(Def_Id
) = E_Constant
then
2085 ("cannot import a constant", Arg_Internal
);
2088 if Has_Discriminants
(Etype
(Def_Id
)) then
2090 ("imported value must be initialized?", Arg_Internal
);
2093 if Is_Access_Type
(Etype
(Def_Id
)) then
2095 ("cannot import object of an access type?", Arg_Internal
);
2098 if Is_Imported
(Def_Id
) then
2100 ("?duplicate Import_Object pragma", N
);
2102 Set_Imported
(Def_Id
);
2106 end Process_Extended_Import_Export_Object_Pragma
;
2108 ------------------------------------------------------
2109 -- Process_Extended_Import_Export_Subprogram_Pragma --
2110 ------------------------------------------------------
2112 procedure Process_Extended_Import_Export_Subprogram_Pragma
2113 (Arg_Internal
: Node_Id
;
2114 Arg_External
: Node_Id
;
2115 Arg_Parameter_Types
: Node_Id
;
2116 Arg_Result_Type
: Node_Id
:= Empty
;
2117 Arg_Mechanism
: Node_Id
;
2118 Arg_Result_Mechanism
: Node_Id
:= Empty
;
2119 Arg_First_Optional_Parameter
: Node_Id
:= Empty
)
2125 Ambiguous
: Boolean;
2129 function Same_Base_Type
(Ptype
, Formal
: Entity_Id
) return Boolean;
2130 -- Determines if Ptype references the type of Formal. Note that
2131 -- only the base types need to match according to the spec.
2133 function Same_Base_Type
(Ptype
, Formal
: Entity_Id
) return Boolean is
2137 if not Is_Entity_Name
(Ptype
)
2138 or else Entity
(Ptype
) = Any_Type
2143 return Base_Type
(Entity
(Ptype
)) = Base_Type
(Etype
(Formal
));
2146 -- Start of processing for
2147 -- Process_Extended_Import_Export_Subprogram_Pragma
2150 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2151 Hom_Id
:= Entity
(Arg_Internal
);
2155 -- Loop through homonyms (overloadings) of Hom_Id
2157 while Present
(Hom_Id
) loop
2158 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
2160 -- We need a subprogram in the current scope
2162 if not Is_Subprogram
(Def_Id
)
2163 or else Scope
(Def_Id
) /= Current_Scope
2170 -- Pragma cannot apply to subprogram body
2172 if Is_Subprogram
(Def_Id
)
2175 (Declaration_Node
(Def_Id
))) = N_Subprogram_Body
2178 ("pragma% requires separate spec"
2179 & " and must come before body");
2182 -- Test result type if given, note that the result type
2183 -- parameter can only be present for the function cases.
2185 if Present
(Arg_Result_Type
)
2186 and then not Same_Base_Type
(Arg_Result_Type
, Def_Id
)
2190 -- Test parameter types if given. Note that this parameter
2191 -- has not been analyzed (and must not be, since it is
2192 -- semantic nonsense), so we get it as the parser left it.
2194 elsif Present
(Arg_Parameter_Types
) then
2195 Check_Matching_Types
: declare
2200 Formal
:= First_Formal
(Def_Id
);
2202 if Nkind
(Arg_Parameter_Types
) = N_Null
then
2203 if Present
(Formal
) then
2207 -- A list of one type, e.g. (List) is parsed as
2208 -- a parenthesized expression.
2210 elsif Nkind
(Arg_Parameter_Types
) /= N_Aggregate
2211 and then Paren_Count
(Arg_Parameter_Types
) = 1
2214 or else Present
(Next_Formal
(Formal
))
2219 Same_Base_Type
(Arg_Parameter_Types
, Formal
);
2222 -- A list of more than one type is parsed as a aggregate
2224 elsif Nkind
(Arg_Parameter_Types
) = N_Aggregate
2225 and then Paren_Count
(Arg_Parameter_Types
) = 0
2227 Ptype
:= First
(Expressions
(Arg_Parameter_Types
));
2229 while Present
(Ptype
) or else Present
(Formal
) loop
2232 or else not Same_Base_Type
(Ptype
, Formal
)
2237 Next_Formal
(Formal
);
2242 -- Anything else is of the wrong form
2246 ("wrong form for Parameter_Types parameter",
2247 Arg_Parameter_Types
);
2249 end Check_Matching_Types
;
2252 -- Match is now False if the entry we found did not match
2253 -- either a supplied Parameter_Types or Result_Types argument
2259 -- Ambiguous case, the flag Ambiguous shows if we already
2260 -- detected this and output the initial messages.
2263 if not Ambiguous
then
2265 Error_Msg_Name_1
:= Chars
(N
);
2267 ("pragma% does not uniquely identify subprogram!",
2269 Error_Msg_Sloc
:= Sloc
(Ent
);
2270 Error_Msg_N
("matching subprogram #!", N
);
2274 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2275 Error_Msg_N
("matching subprogram #!", N
);
2280 Hom_Id
:= Homonym
(Hom_Id
);
2283 -- See if we found an entry
2286 if not Ambiguous
then
2287 if Is_Generic_Subprogram
(Entity
(Arg_Internal
)) then
2289 ("pragma% cannot be given for generic subprogram");
2293 ("pragma% does not identify local subprogram");
2300 -- Import pragmas must be be for imported entities
2302 if (Prag_Id
= Pragma_Import_Function
2304 Prag_Id
= Pragma_Import_Procedure
2306 Prag_Id
= Pragma_Import_Valued_Procedure
)
2308 if not Is_Imported
(Ent
) then
2310 ("pragma Import or Interface must precede pragma%");
2313 -- For the Export cases, the pragma Export is sufficient to set
2314 -- the entity as exported, if it is not exported already. We
2315 -- leave the default Ada convention in this case.
2318 Set_Exported
(Ent
, Arg_Internal
);
2321 -- Special processing for Valued_Procedure cases
2323 if Prag_Id
= Pragma_Import_Valued_Procedure
2325 Prag_Id
= Pragma_Export_Valued_Procedure
2327 Formal
:= First_Formal
(Ent
);
2331 ("at least one parameter required for pragma%");
2333 elsif Ekind
(Formal
) /= E_Out_Parameter
then
2335 ("first parameter must have mode out for pragma%");
2338 Set_Is_Valued_Procedure
(Ent
);
2342 Set_Extended_Import_Export_External_Name
(Ent
, Arg_External
);
2344 -- Process Result_Mechanism argument if present. We have already
2345 -- checked that this is only allowed for the function case.
2347 if Present
(Arg_Result_Mechanism
) then
2348 Set_Mechanism_Value
(Ent
, Arg_Result_Mechanism
);
2351 -- Process Mechanism parameter if present. Note that this parameter
2352 -- is not analyzed, and must not be analyzed since it is semantic
2353 -- nonsense, so we get it in exactly as the parser left it.
2355 if Present
(Arg_Mechanism
) then
2364 -- A single mechanism association without a formal parameter
2365 -- name is parsed as a parenthesized expression. All other
2366 -- cases are parsed as aggregates, so we rewrite the single
2367 -- parameter case as an aggregate for consistency.
2369 if Nkind
(Arg_Mechanism
) /= N_Aggregate
2370 and then Paren_Count
(Arg_Mechanism
) = 1
2372 Rewrite
(Arg_Mechanism
,
2373 Make_Aggregate
(Sloc
(Arg_Mechanism
),
2374 Expressions
=> New_List
(
2375 Relocate_Node
(Arg_Mechanism
))));
2378 -- Case of only mechanism name given, applies to all formals
2380 if Nkind
(Arg_Mechanism
) /= N_Aggregate
then
2381 Formal
:= First_Formal
(Ent
);
2382 while Present
(Formal
) loop
2383 Set_Mechanism_Value
(Formal
, Arg_Mechanism
);
2384 Next_Formal
(Formal
);
2387 -- Case of list of mechanism associations given
2390 if Null_Record_Present
(Arg_Mechanism
) then
2392 ("inappropriate form for Mechanism parameter",
2396 -- Deal with positional ones first
2398 Formal
:= First_Formal
(Ent
);
2399 if Present
(Expressions
(Arg_Mechanism
)) then
2400 Mname
:= First
(Expressions
(Arg_Mechanism
));
2402 while Present
(Mname
) loop
2405 ("too many mechanism associations", Mname
);
2408 Set_Mechanism_Value
(Formal
, Mname
);
2409 Next_Formal
(Formal
);
2414 -- Deal with named entries
2416 if Present
(Component_Associations
(Arg_Mechanism
)) then
2417 Massoc
:= First
(Component_Associations
(Arg_Mechanism
));
2419 while Present
(Massoc
) loop
2420 Choice
:= First
(Choices
(Massoc
));
2422 if Nkind
(Choice
) /= N_Identifier
2423 or else Present
(Next
(Choice
))
2426 ("incorrect form for mechanism association",
2430 Formal
:= First_Formal
(Ent
);
2434 ("parameter name & not present", Choice
);
2437 if Chars
(Choice
) = Chars
(Formal
) then
2439 (Formal
, Expression
(Massoc
));
2443 Next_Formal
(Formal
);
2453 -- Process First_Optional_Parameter argument if present. We have
2454 -- already checked that this is only allowed for the Import case.
2456 if Present
(Arg_First_Optional_Parameter
) then
2457 if Nkind
(Arg_First_Optional_Parameter
) /= N_Identifier
then
2459 ("first optional parameter must be formal parameter name",
2460 Arg_First_Optional_Parameter
);
2463 Formal
:= First_Formal
(Ent
);
2467 ("specified formal parameter& not found",
2468 Arg_First_Optional_Parameter
);
2471 exit when Chars
(Formal
) =
2472 Chars
(Arg_First_Optional_Parameter
);
2474 Next_Formal
(Formal
);
2477 Set_First_Optional_Parameter
(Ent
, Formal
);
2479 -- Check specified and all remaining formals have right form
2481 while Present
(Formal
) loop
2482 if Ekind
(Formal
) /= E_In_Parameter
then
2484 ("optional formal& is not of mode in!",
2485 Arg_First_Optional_Parameter
, Formal
);
2488 Dval
:= Default_Value
(Formal
);
2490 if not Present
(Dval
) then
2492 ("optional formal& does not have default value!",
2493 Arg_First_Optional_Parameter
, Formal
);
2495 elsif Compile_Time_Known_Value_Or_Aggr
(Dval
) then
2500 ("default value for optional formal& is non-static!",
2501 Arg_First_Optional_Parameter
, Formal
);
2505 Set_Is_Optional_Parameter
(Formal
);
2506 Next_Formal
(Formal
);
2510 end Process_Extended_Import_Export_Subprogram_Pragma
;
2512 --------------------------
2513 -- Process_Generic_List --
2514 --------------------------
2516 procedure Process_Generic_List
is
2522 Check_No_Identifiers
;
2523 Check_At_Least_N_Arguments
(1);
2526 while Present
(Arg
) loop
2527 Exp
:= Expression
(Arg
);
2530 if not Is_Entity_Name
(Exp
)
2532 (not Is_Generic_Instance
(Entity
(Exp
))
2534 not Is_Generic_Unit
(Entity
(Exp
)))
2537 ("pragma% argument must be name of generic unit/instance",
2543 end Process_Generic_List
;
2545 ---------------------------------
2546 -- Process_Import_Or_Interface --
2547 ---------------------------------
2549 procedure Process_Import_Or_Interface
is
2555 Process_Convention
(C
, Def_Id
);
2556 Kill_Size_Check_Code
(Def_Id
);
2557 Note_Possible_Modification
(Expression
(Arg2
));
2559 if Ekind
(Def_Id
) = E_Variable
2561 Ekind
(Def_Id
) = E_Constant
2563 -- User initialization is not allowed for imported object, but
2564 -- the object declaration may contain a default initialization,
2565 -- that will be discarded.
2567 if Present
(Expression
(Parent
(Def_Id
)))
2568 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
2570 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2572 ("no initialization allowed for declaration of& #",
2573 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2577 Set_Imported
(Def_Id
);
2578 Set_Is_Public
(Def_Id
);
2579 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
2582 elsif Is_Subprogram
(Def_Id
)
2583 or else Is_Generic_Subprogram
(Def_Id
)
2585 -- If the name is overloaded, pragma applies to all of the
2586 -- denoted entities in the same declarative part.
2590 while Present
(Hom_Id
) loop
2591 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
2593 -- Ignore inherited subprograms because the pragma will
2594 -- apply to the parent operation, which is the one called.
2596 if Is_Overloadable
(Def_Id
)
2597 and then Present
(Alias
(Def_Id
))
2601 -- Verify that the homonym is in the same declarative
2602 -- part (not just the same scope).
2604 elsif Parent
(Unit_Declaration_Node
(Def_Id
)) /= Parent
(N
)
2605 and then Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
2610 Set_Imported
(Def_Id
);
2612 -- If Import intrinsic, set intrinsic flag
2613 -- and verify that it is known as such.
2615 if C
= Convention_Intrinsic
then
2616 Set_Is_Intrinsic_Subprogram
(Def_Id
);
2617 Check_Intrinsic_Subprogram
2618 (Def_Id
, Expression
(Arg2
));
2621 -- All interfaced procedures need an external
2622 -- symbol created for them since they are
2623 -- always referenced from another object file.
2625 Set_Is_Public
(Def_Id
);
2626 Set_Has_Completion
(Def_Id
);
2627 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
2630 if Is_Compilation_Unit
(Hom_Id
) then
2632 -- Its possible homonyms are not affected by the pragma.
2633 -- Such homonyms might be present in the context of other
2634 -- units being compiled.
2639 Hom_Id
:= Homonym
(Hom_Id
);
2643 -- When the convention is Java, we also allow Import to be given
2644 -- for packages, exceptions, and record components.
2646 elsif C
= Convention_Java
2647 and then (Ekind
(Def_Id
) = E_Package
2648 or else Ekind
(Def_Id
) = E_Exception
2649 or else Nkind
(Parent
(Def_Id
)) = N_Component_Declaration
)
2651 Set_Imported
(Def_Id
);
2652 Set_Is_Public
(Def_Id
);
2653 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
2657 ("second argument of pragma% must be object or subprogram",
2661 -- If this pragma applies to a compilation unit, then the unit,
2662 -- which is a subprogram, does not require (or allow) a body.
2663 -- We also do not need to elaborate imported procedures.
2665 if Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
2667 Cunit
: constant Node_Id
:= Parent
(Parent
(N
));
2670 Set_Body_Required
(Cunit
, False);
2674 end Process_Import_Or_Interface
;
2676 --------------------
2677 -- Process_Inline --
2678 --------------------
2680 procedure Process_Inline
(Active
: Boolean) is
2687 procedure Make_Inline
(Subp
: Entity_Id
);
2688 -- Subp is the defining unit name of the subprogram
2689 -- declaration. Set the flag, as well as the flag in the
2690 -- corresponding body, if there is one present.
2692 procedure Set_Inline_Flags
(Subp
: Entity_Id
);
2693 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp
2699 procedure Make_Inline
(Subp
: Entity_Id
) is
2700 Kind
: Entity_Kind
:= Ekind
(Subp
);
2701 Inner_Subp
: Entity_Id
:= Subp
;
2704 if Etype
(Subp
) = Any_Type
then
2707 -- Here we have a candidate for inlining, but we must exclude
2708 -- derived operations. Otherwise we will end up trying to
2709 -- inline a phantom declaration, and the result would be to
2710 -- drag in a body which has no direct inlining associated with
2711 -- it. That would not only be inefficient but would also result
2712 -- in the backend doing cross-unit inlining in cases where it
2713 -- was definitely inappropriate to do so.
2715 -- However, a simple Comes_From_Source test is insufficient,
2716 -- since we do want to allow inlining of generic instances,
2717 -- which also do not come from source. Predefined operators do
2718 -- not come from source but are not inlineable either.
2720 elsif not Comes_From_Source
(Subp
)
2721 and then not Is_Generic_Instance
(Subp
)
2722 and then Scope
(Subp
) /= Standard_Standard
2727 -- The referenced entity must either be the enclosing entity,
2728 -- or an entity declared within the current open scope.
2730 elsif Present
(Scope
(Subp
))
2731 and then Scope
(Subp
) /= Current_Scope
2732 and then Subp
/= Current_Scope
2735 ("argument of% must be entity in current scope", Assoc
);
2739 -- Processing for procedure, operator or function.
2740 -- If subprogram is aliased (as for an instance) indicate
2741 -- that the renamed entity is inlined.
2743 if Kind
= E_Procedure
2744 or else Kind
= E_Function
2745 or else Kind
= E_Operator
2747 while Present
(Alias
(Inner_Subp
)) loop
2748 Inner_Subp
:= Alias
(Inner_Subp
);
2751 Set_Inline_Flags
(Inner_Subp
);
2753 Decl
:= Parent
(Parent
(Inner_Subp
));
2755 if Nkind
(Decl
) = N_Subprogram_Declaration
2756 and then Present
(Corresponding_Body
(Decl
))
2758 Set_Inline_Flags
(Corresponding_Body
(Decl
));
2763 -- For a generic subprogram set flag as well, for use at
2764 -- the point of instantiation, to determine whether the
2765 -- body should be generated.
2767 elsif Kind
= E_Generic_Procedure
2768 or else Kind
= E_Generic_Function
2770 Set_Inline_Flags
(Subp
);
2773 -- Literals are by definition inlined.
2775 elsif Kind
= E_Enumeration_Literal
then
2778 -- Anything else is an error
2782 ("expect subprogram name for pragma%", Assoc
);
2786 ----------------------
2787 -- Set_Inline_Flags --
2788 ----------------------
2790 procedure Set_Inline_Flags
(Subp
: Entity_Id
) is
2793 Set_Is_Inlined
(Subp
, True);
2796 if not Has_Pragma_Inline
(Subp
) then
2797 Set_Has_Pragma_Inline
(Subp
);
2798 Set_Next_Rep_Item
(N
, First_Rep_Item
(Subp
));
2799 Set_First_Rep_Item
(Subp
, N
);
2801 end Set_Inline_Flags
;
2803 -- Start of processing for Process_Inline
2806 Check_No_Identifiers
;
2807 Check_At_Least_N_Arguments
(1);
2810 Inline_Processing_Required
:= True;
2814 while Present
(Assoc
) loop
2815 Subp_Id
:= Expression
(Assoc
);
2819 if Is_Entity_Name
(Subp_Id
) then
2820 Subp
:= Entity
(Subp_Id
);
2822 if Subp
= Any_Id
then
2828 while Present
(Homonym
(Subp
))
2829 and then Scope
(Homonym
(Subp
)) = Current_Scope
2831 Make_Inline
(Homonym
(Subp
));
2832 Subp
:= Homonym
(Subp
);
2839 ("inappropriate argument for pragma%", Assoc
);
2847 ----------------------------
2848 -- Process_Interface_Name --
2849 ----------------------------
2851 procedure Process_Interface_Name
2852 (Subprogram_Def
: Entity_Id
;
2858 String_Val
: String_Id
;
2860 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
);
2861 -- SN is a string literal node for an interface name. This routine
2862 -- performs some minimal checks that the name is reasonable. In
2863 -- particular that no spaces or other obviously incorrect characters
2864 -- appear. This is only a warning, since any characters are allowed.
2866 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
) is
2867 S
: constant String_Id
:= Strval
(Expr_Value_S
(SN
));
2868 SL
: constant Nat
:= String_Length
(S
);
2873 Error_Msg_N
("interface name cannot be null string", SN
);
2876 for J
in 1 .. SL
loop
2877 C
:= Get_String_Char
(S
, J
);
2879 if not In_Character_Range
(C
)
2880 or else Get_Character
(C
) = ' '
2881 or else Get_Character
(C
) = ','
2884 ("?interface name contains illegal character", SN
);
2887 end Check_Form_Of_Interface_Name
;
2889 -- Start of processing for Process_Interface_Name
2892 if No
(Link_Arg
) then
2893 if No
(Ext_Arg
) then
2896 elsif Chars
(Ext_Arg
) = Name_Link_Name
then
2898 Link_Nam
:= Expression
(Ext_Arg
);
2901 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
2902 Ext_Nam
:= Expression
(Ext_Arg
);
2907 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
2908 Check_Optional_Identifier
(Link_Arg
, Name_Link_Name
);
2909 Ext_Nam
:= Expression
(Ext_Arg
);
2910 Link_Nam
:= Expression
(Link_Arg
);
2913 -- Check expressions for external name and link name are static
2915 if Present
(Ext_Nam
) then
2916 Check_Arg_Is_Static_Expression
(Ext_Nam
, Standard_String
);
2917 Check_Form_Of_Interface_Name
(Ext_Nam
);
2919 -- Verify that the external name is not the name of a local
2920 -- entity, which would hide the imported one and lead to
2921 -- run-time surprises. The problem can only arise for entities
2922 -- declared in a package body (otherwise the external name is
2923 -- fully qualified and won't conflict).
2931 if Prag_Id
= Pragma_Import
then
2932 String_To_Name_Buffer
(Strval
(Expr_Value_S
(Ext_Nam
)));
2934 E
:= Entity_Id
(Get_Name_Table_Info
(Nam
));
2936 if Nam
/= Chars
(Subprogram_Def
)
2937 and then Present
(E
)
2938 and then not Is_Overloadable
(E
)
2939 and then Is_Immediately_Visible
(E
)
2940 and then not Is_Imported
(E
)
2941 and then Ekind
(Scope
(E
)) = E_Package
2945 while Present
(Par
) loop
2946 if Nkind
(Par
) = N_Package_Body
then
2947 Error_Msg_Sloc
:= Sloc
(E
);
2949 ("imported entity is hidden by & declared#",
2954 Par
:= Parent
(Par
);
2961 if Present
(Link_Nam
) then
2962 Check_Arg_Is_Static_Expression
(Link_Nam
, Standard_String
);
2963 Check_Form_Of_Interface_Name
(Link_Nam
);
2966 -- If there is no link name, just set the external name
2968 if No
(Link_Nam
) then
2969 Set_Encoded_Interface_Name
2970 (Get_Base_Subprogram
(Subprogram_Def
),
2971 Adjust_External_Name_Case
(Expr_Value_S
(Ext_Nam
)));
2973 -- For the Link_Name case, the given literal is preceded by an
2974 -- asterisk, which indicates to GCC that the given name should
2975 -- be taken literally, and in particular that no prepending of
2976 -- underlines should occur, even in systems where this is the
2981 Store_String_Char
(Get_Char_Code
('*'));
2982 String_Val
:= Strval
(Expr_Value_S
(Link_Nam
));
2984 for J
in 1 .. String_Length
(String_Val
) loop
2985 Store_String_Char
(Get_String_Char
(String_Val
, J
));
2989 Make_String_Literal
(Sloc
(Link_Nam
), End_String
);
2991 Set_Encoded_Interface_Name
2992 (Get_Base_Subprogram
(Subprogram_Def
), Link_Nam
);
2994 end Process_Interface_Name
;
2996 -----------------------------------------
2997 -- Process_Interrupt_Or_Attach_Handler --
2998 -----------------------------------------
3000 procedure Process_Interrupt_Or_Attach_Handler
is
3001 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
3002 Prot_Proc
: constant Entity_Id
:= Entity
(Arg1_X
);
3003 Prot_Type
: constant Entity_Id
:= Scope
(Prot_Proc
);
3006 Set_Is_Interrupt_Handler
(Prot_Proc
);
3008 if Prag_Id
= Pragma_Interrupt_Handler
3009 or Prag_Id
= Pragma_Attach_Handler
3011 Record_Rep_Item
(Prot_Type
, N
);
3014 end Process_Interrupt_Or_Attach_Handler
;
3016 ---------------------------------
3017 -- Process_Suppress_Unsuppress --
3018 ---------------------------------
3020 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean) is
3024 Effective
: Boolean;
3026 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
);
3027 -- Used to suppress a single check on the given entity
3029 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
) is
3031 -- First set appropriate suppress flags in the entity
3034 when Access_Check
=>
3035 Effective
:= Suppress_Access_Checks
(E
);
3036 Set_Suppress_Access_Checks
(E
, Suppress_Case
);
3038 when Accessibility_Check
=>
3039 Effective
:= Suppress_Accessibility_Checks
(E
);
3040 Set_Suppress_Accessibility_Checks
(E
, Suppress_Case
);
3042 when Discriminant_Check
=>
3043 Effective
:= Suppress_Discriminant_Checks
(E
);
3044 Set_Suppress_Discriminant_Checks
(E
, Suppress_Case
);
3046 when Division_Check
=>
3047 Effective
:= Suppress_Division_Checks
(E
);
3048 Set_Suppress_Division_Checks
(E
, Suppress_Case
);
3050 when Elaboration_Check
=>
3051 Effective
:= Suppress_Elaboration_Checks
(E
);
3052 Set_Suppress_Elaboration_Checks
(E
, Suppress_Case
);
3055 Effective
:= Suppress_Index_Checks
(E
);
3056 Set_Suppress_Index_Checks
(E
, Suppress_Case
);
3058 when Length_Check
=>
3059 Effective
:= Suppress_Length_Checks
(E
);
3060 Set_Suppress_Length_Checks
(E
, Suppress_Case
);
3062 when Overflow_Check
=>
3063 Effective
:= Suppress_Overflow_Checks
(E
);
3064 Set_Suppress_Overflow_Checks
(E
, Suppress_Case
);
3067 Effective
:= Suppress_Range_Checks
(E
);
3068 Set_Suppress_Range_Checks
(E
, Suppress_Case
);
3070 when Storage_Check
=>
3071 Effective
:= Suppress_Storage_Checks
(E
);
3072 Set_Suppress_Storage_Checks
(E
, Suppress_Case
);
3075 Effective
:= Suppress_Tag_Checks
(E
);
3076 Set_Suppress_Tag_Checks
(E
, Suppress_Case
);
3079 Suppress_Unsuppress_Echeck
(E
, Access_Check
);
3080 Suppress_Unsuppress_Echeck
(E
, Accessibility_Check
);
3081 Suppress_Unsuppress_Echeck
(E
, Discriminant_Check
);
3082 Suppress_Unsuppress_Echeck
(E
, Division_Check
);
3083 Suppress_Unsuppress_Echeck
(E
, Elaboration_Check
);
3084 Suppress_Unsuppress_Echeck
(E
, Index_Check
);
3085 Suppress_Unsuppress_Echeck
(E
, Length_Check
);
3086 Suppress_Unsuppress_Echeck
(E
, Overflow_Check
);
3087 Suppress_Unsuppress_Echeck
(E
, Range_Check
);
3088 Suppress_Unsuppress_Echeck
(E
, Storage_Check
);
3089 Suppress_Unsuppress_Echeck
(E
, Tag_Check
);
3092 -- If the entity is not declared in the current scope, then we
3093 -- make an entry in the Entity_Suppress table so that the flag
3094 -- will be removed on exit. This entry is only made if the
3095 -- suppress did something (i.e. the flag was not already set).
3097 if Effective
and then Scope
(E
) /= Current_Scope
then
3098 Entity_Suppress
.Increment_Last
;
3099 Entity_Suppress
.Table
3100 (Entity_Suppress
.Last
).Entity
:= E
;
3101 Entity_Suppress
.Table
3102 (Entity_Suppress
.Last
).Check
:= C
;
3105 -- If this is a first subtype, and the base type is distinct,
3106 -- then also set the suppress flags on the base type.
3108 if Is_First_Subtype
(E
)
3109 and then Etype
(E
) /= E
3111 Suppress_Unsuppress_Echeck
(Etype
(E
), C
);
3113 end Suppress_Unsuppress_Echeck
;
3115 -- Start of processing for Process_Suppress_Unsuppress
3118 -- Suppress/Unsuppress can appear as a configuration pragma,
3119 -- or in a declarative part or a package spec (RM 11.5(5))
3121 if not Is_Configuration_Pragma
then
3122 Check_Is_In_Decl_Part_Or_Package_Spec
;
3125 Check_At_Least_N_Arguments
(1);
3126 Check_At_Most_N_Arguments
(2);
3127 Check_No_Identifier
(Arg1
);
3128 Check_Arg_Is_Identifier
(Arg1
);
3130 if not Is_Check_Name
(Chars
(Expression
(Arg1
))) then
3132 ("argument of pragma% is not valid check name", Arg1
);
3135 C
:= Get_Check_Id
(Chars
(Expression
(Arg1
)));
3138 if Arg_Count
= 1 then
3140 when Access_Check
=>
3141 Scope_Suppress
.Access_Checks
:= Suppress_Case
;
3143 when Accessibility_Check
=>
3144 Scope_Suppress
.Accessibility_Checks
:= Suppress_Case
;
3146 when Discriminant_Check
=>
3147 Scope_Suppress
.Discriminant_Checks
:= Suppress_Case
;
3149 when Division_Check
=>
3150 Scope_Suppress
.Division_Checks
:= Suppress_Case
;
3152 when Elaboration_Check
=>
3153 Scope_Suppress
.Elaboration_Checks
:= Suppress_Case
;
3156 Scope_Suppress
.Index_Checks
:= Suppress_Case
;
3158 when Length_Check
=>
3159 Scope_Suppress
.Length_Checks
:= Suppress_Case
;
3161 when Overflow_Check
=>
3162 Scope_Suppress
.Overflow_Checks
:= Suppress_Case
;
3165 Scope_Suppress
.Range_Checks
:= Suppress_Case
;
3167 when Storage_Check
=>
3168 Scope_Suppress
.Storage_Checks
:= Suppress_Case
;
3171 Scope_Suppress
.Tag_Checks
:= Suppress_Case
;
3174 Scope_Suppress
:= (others => Suppress_Case
);
3178 -- Case of two arguments present, where the check is
3179 -- suppressed for a specified entity (given as the second
3180 -- argument of the pragma)
3183 Check_Optional_Identifier
(Arg2
, Name_On
);
3184 E_Id
:= Expression
(Arg2
);
3187 if not Is_Entity_Name
(E_Id
) then
3189 ("second argument of pragma% must be entity name", Arg2
);
3198 Suppress_Unsuppress_Echeck
(E
, C
);
3200 if Is_Generic_Instance
(E
)
3201 and then Is_Subprogram
(E
)
3202 and then Present
(Alias
(E
))
3204 Suppress_Unsuppress_Echeck
(Alias
(E
), C
);
3207 if C
= Elaboration_Check
and then Suppress_Case
then
3208 Set_Suppress_Elaboration_Warnings
(E
);
3211 -- If we are within a package specification, the
3212 -- pragma only applies to homonyms in the same scope.
3214 exit when No
(Homonym
(E
))
3215 or else (Scope
(Homonym
(E
)) /= Current_Scope
3216 and then Ekind
(Current_Scope
) = E_Package
3217 and then not In_Package_Body
(Current_Scope
));
3224 end Process_Suppress_Unsuppress
;
3230 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
) is
3232 if Is_Imported
(E
) then
3234 ("cannot export entity& that was previously imported", Arg
);
3236 elsif Present
(Address_Clause
(E
)) then
3238 ("cannot export entity& that has an address clause", Arg
);
3241 Set_Is_Exported
(E
);
3243 -- Deal with exporting non-library level entity
3245 if not Is_Library_Level_Entity
(E
) then
3247 -- Not allowed at all for subprograms
3249 if Is_Subprogram
(E
) then
3250 Error_Pragma_Arg
("local subprogram& cannot be exported", Arg
);
3252 -- Otherwise set public and statically allocated
3256 Set_Is_Statically_Allocated
(E
);
3260 if Inside_A_Generic
then
3262 ("all instances of& will have the same external name?", Arg
, E
);
3267 ----------------------------------------------
3268 -- Set_Extended_Import_Export_External_Name --
3269 ----------------------------------------------
3271 procedure Set_Extended_Import_Export_External_Name
3272 (Internal_Ent
: Entity_Id
;
3273 Arg_External
: Node_Id
)
3275 Old_Name
: constant Node_Id
:= Interface_Name
(Internal_Ent
);
3279 if No
(Arg_External
) then
3282 elsif Nkind
(Arg_External
) = N_String_Literal
then
3283 if String_Length
(Strval
(Arg_External
)) = 0 then
3286 New_Name
:= Adjust_External_Name_Case
(Arg_External
);
3289 elsif Nkind
(Arg_External
) = N_Identifier
then
3290 New_Name
:= Get_Default_External_Name
(Arg_External
);
3294 ("incorrect form for External parameter for pragma%",
3298 -- If we already have an external name set (by a prior normal
3299 -- Import or Export pragma), then the external names must match
3301 if Present
(Interface_Name
(Internal_Ent
)) then
3303 S1
: constant String_Id
:= Strval
(Old_Name
);
3304 S2
: constant String_Id
:= Strval
(New_Name
);
3307 -- Called if names do not match
3309 procedure Mismatch
is
3311 Error_Msg_Sloc
:= Sloc
(Old_Name
);
3313 ("external name does not match that given #",
3318 if String_Length
(S1
) /= String_Length
(S2
) then
3322 for J
in 1 .. String_Length
(S1
) loop
3323 if Get_String_Char
(S1
, J
) /= Get_String_Char
(S2
, J
) then
3330 -- Otherwise set the given name
3333 Set_Encoded_Interface_Name
(Internal_Ent
, New_Name
);
3336 end Set_Extended_Import_Export_External_Name
;
3342 procedure Set_Imported
(E
: Entity_Id
) is
3344 Error_Msg_Sloc
:= Sloc
(E
);
3346 if Is_Exported
(E
) or else Is_Imported
(E
) then
3347 Error_Msg_NE
("import of& declared# not allowed", N
, E
);
3349 if Is_Exported
(E
) then
3350 Error_Msg_N
("\entity was previously exported", N
);
3352 Error_Msg_N
("\entity was previously imported", N
);
3355 Error_Pragma
("\(pragma% applies to all previous entities)");
3358 Set_Is_Imported
(E
);
3360 -- If the entity is an object that is not at the library
3361 -- level, then it is statically allocated. We do not worry
3362 -- about objects with address clauses in this context since
3363 -- they are not really imported in the linker sense.
3366 and then not Is_Library_Level_Entity
(E
)
3367 and then No
(Address_Clause
(E
))
3369 Set_Is_Statically_Allocated
(E
);
3374 -------------------------
3375 -- Set_Mechanism_Value --
3376 -------------------------
3378 -- Note: the mechanism name has not been analyzed (and cannot indeed
3379 -- be analyzed, since it is semantic nonsense), so we get it in the
3380 -- exact form created by the parser.
3382 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
) is
3386 procedure Bad_Class
;
3387 -- Signal bad descriptor class name
3389 procedure Bad_Mechanism
;
3390 -- Signal bad mechanism name
3392 procedure Bad_Class
is
3394 Error_Pragma_Arg
("unrecognized descriptor class name", Class
);
3397 procedure Bad_Mechanism
is
3399 Error_Pragma_Arg
("unrecognized mechanism name", Mech_Name
);
3402 -- Start of processing for Set_Mechanism_Value
3405 if Mechanism
(Ent
) /= Default_Mechanism
then
3407 ("mechanism for & has already been set", Mech_Name
, Ent
);
3410 -- MECHANISM_NAME ::= value | reference | descriptor
3412 if Nkind
(Mech_Name
) = N_Identifier
then
3413 if Chars
(Mech_Name
) = Name_Value
then
3414 Set_Mechanism
(Ent
, By_Copy
);
3417 elsif Chars
(Mech_Name
) = Name_Reference
then
3418 Set_Mechanism
(Ent
, By_Reference
);
3421 elsif Chars
(Mech_Name
) = Name_Descriptor
then
3422 Check_VMS
(Mech_Name
);
3423 Set_Mechanism
(Ent
, By_Descriptor
);
3426 elsif Chars
(Mech_Name
) = Name_Copy
then
3428 ("bad mechanism name, Value assumed", Mech_Name
);
3434 -- MECHANISM_NAME ::= descriptor (CLASS_NAME)
3435 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3437 -- Note: this form is parsed as an indexed component
3439 elsif Nkind
(Mech_Name
) = N_Indexed_Component
then
3440 Class
:= First
(Expressions
(Mech_Name
));
3442 if Nkind
(Prefix
(Mech_Name
)) /= N_Identifier
3443 or else Chars
(Prefix
(Mech_Name
)) /= Name_Descriptor
3444 or else Present
(Next
(Class
))
3449 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME)
3450 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3452 -- Note: this form is parsed as a function call
3454 elsif Nkind
(Mech_Name
) = N_Function_Call
then
3456 Param
:= First
(Parameter_Associations
(Mech_Name
));
3458 if Nkind
(Name
(Mech_Name
)) /= N_Identifier
3459 or else Chars
(Name
(Mech_Name
)) /= Name_Descriptor
3460 or else Present
(Next
(Param
))
3461 or else No
(Selector_Name
(Param
))
3462 or else Chars
(Selector_Name
(Param
)) /= Name_Class
3466 Class
:= Explicit_Actual_Parameter
(Param
);
3473 -- Fall through here with Class set to descriptor class name
3475 Check_VMS
(Mech_Name
);
3477 if Nkind
(Class
) /= N_Identifier
then
3480 elsif Chars
(Class
) = Name_UBS
then
3481 Set_Mechanism
(Ent
, By_Descriptor_UBS
);
3483 elsif Chars
(Class
) = Name_UBSB
then
3484 Set_Mechanism
(Ent
, By_Descriptor_UBSB
);
3486 elsif Chars
(Class
) = Name_UBA
then
3487 Set_Mechanism
(Ent
, By_Descriptor_UBA
);
3489 elsif Chars
(Class
) = Name_S
then
3490 Set_Mechanism
(Ent
, By_Descriptor_S
);
3492 elsif Chars
(Class
) = Name_SB
then
3493 Set_Mechanism
(Ent
, By_Descriptor_SB
);
3495 elsif Chars
(Class
) = Name_A
then
3496 Set_Mechanism
(Ent
, By_Descriptor_A
);
3498 elsif Chars
(Class
) = Name_NCA
then
3499 Set_Mechanism
(Ent
, By_Descriptor_NCA
);
3505 end Set_Mechanism_Value
;
3507 -- Start of processing for Analyze_Pragma
3510 if not Is_Pragma_Name
(Chars
(N
)) then
3511 Error_Pragma
("unrecognized pragma%!?");
3513 Prag_Id
:= Get_Pragma_Id
(Chars
(N
));
3523 if Present
(Pragma_Argument_Associations
(N
)) then
3524 Arg1
:= First
(Pragma_Argument_Associations
(N
));
3526 if Present
(Arg1
) then
3527 Arg2
:= Next
(Arg1
);
3529 if Present
(Arg2
) then
3530 Arg3
:= Next
(Arg2
);
3532 if Present
(Arg3
) then
3533 Arg4
:= Next
(Arg3
);
3539 -- Count number of arguments
3548 while Present
(Arg_Node
) loop
3549 Arg_Count
:= Arg_Count
+ 1;
3554 -- An enumeration type defines the pragmas that are supported by the
3555 -- implementation. Get_Pragma_Id (in package Prag) transorms a name
3556 -- into the corresponding enumeration value for the following case.
3564 -- pragma Abort_Defer;
3566 when Pragma_Abort_Defer
=>
3568 Check_Arg_Count
(0);
3570 -- The only required semantic processing is to check the
3571 -- placement. This pragma must appear at the start of the
3572 -- statement sequence of a handled sequence of statements.
3574 if Nkind
(Parent
(N
)) /= N_Handled_Sequence_Of_Statements
3575 or else N
/= First
(Statements
(Parent
(N
)))
3586 -- Note: this pragma also has some specific processing in Par.Prag
3587 -- because we want to set the Ada 83 mode switch during parsing.
3589 when Pragma_Ada_83
=>
3593 Check_Arg_Count
(0);
3601 -- Note: this pragma also has some specific processing in Par.Prag
3602 -- because we want to set the Ada 83 mode switch during parsing.
3604 when Pragma_Ada_95
=>
3608 Check_Arg_Count
(0);
3610 ----------------------
3611 -- All_Calls_Remote --
3612 ----------------------
3614 -- pragma All_Calls_Remote [(library_package_NAME)];
3616 when Pragma_All_Calls_Remote
=> All_Calls_Remote
: declare
3617 Lib_Entity
: Entity_Id
;
3620 Check_Ada_83_Warning
;
3621 Check_Valid_Library_Unit_Pragma
;
3623 if Nkind
(N
) = N_Null_Statement
then
3627 Lib_Entity
:= Find_Lib_Unit_Name
;
3629 -- This pragma should only apply to a RCI unit (RM E.2.3(23)).
3631 if Present
(Lib_Entity
)
3632 and then not Debug_Flag_U
3634 if not Is_Remote_Call_Interface
(Lib_Entity
) then
3635 Error_Pragma
("pragma% only apply to rci unit");
3637 -- Set flag for entity of the library unit
3640 Set_Has_All_Calls_Remote
(Lib_Entity
);
3644 end All_Calls_Remote
;
3650 -- pragma Annotate (IDENTIFIER {, ARG});
3651 -- ARG ::= NAME | EXPRESSION
3653 when Pragma_Annotate
=> Annotate
: begin
3655 Check_At_Least_N_Arguments
(1);
3656 Check_Arg_Is_Identifier
(Arg1
);
3659 Arg
: Node_Id
:= Arg2
;
3663 while Present
(Arg
) loop
3664 Exp
:= Expression
(Arg
);
3667 if Is_Entity_Name
(Exp
) then
3670 elsif Nkind
(Exp
) = N_String_Literal
then
3671 Resolve
(Exp
, Standard_String
);
3673 elsif Is_Overloaded
(Exp
) then
3674 Error_Pragma_Arg
("ambiguous argument for pragma%", Exp
);
3677 Resolve
(Exp
, Etype
(Exp
));
3689 -- pragma Assert (Boolean_EXPRESSION [, static_string_EXPRESSION]);
3691 when Pragma_Assert
=>
3693 Check_No_Identifiers
;
3695 if Arg_Count
> 1 then
3696 Check_Arg_Count
(2);
3697 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
3700 -- If expansion is active and assertions are inactive, then
3701 -- we rewrite the Assertion as:
3703 -- if False and then condition then
3707 -- The reason we do this rewriting during semantic analysis
3708 -- rather than as part of normal expansion is that we cannot
3709 -- analyze and expand the code for the boolean expression
3710 -- directly, or it may cause insertion of actions that would
3711 -- escape the attempt to suppress the assertion code.
3713 if Expander_Active
and not Assertions_Enabled
then
3715 Make_If_Statement
(Loc
,
3718 Left_Opnd
=> New_Occurrence_Of
(Standard_False
, Loc
),
3719 Right_Opnd
=> Get_Pragma_Arg
(Arg1
)),
3720 Then_Statements
=> New_List
(
3721 Make_Null_Statement
(Loc
))));
3725 -- Otherwise (if assertions are enabled, or if we are not
3726 -- operating with expansion active), then we just analyze
3727 -- and resolve the expression.
3730 Analyze_And_Resolve
(Expression
(Arg1
), Any_Boolean
);
3737 -- pragma AST_Entry (entry_IDENTIFIER);
3739 when Pragma_AST_Entry
=> AST_Entry
: declare
3745 Check_Arg_Count
(1);
3746 Check_No_Identifiers
;
3747 Check_Arg_Is_Local_Name
(Arg1
);
3748 Ent
:= Entity
(Expression
(Arg1
));
3750 -- Note: the implementation of the AST_Entry pragma could handle
3751 -- the entry family case fine, but for now we are consistent with
3752 -- the DEC rules, and do not allow the pragma, which of course
3753 -- has the effect of also forbidding the attribute.
3755 if Ekind
(Ent
) /= E_Entry
then
3757 ("pragma% argument must be simple entry name", Arg1
);
3759 elsif Is_AST_Entry
(Ent
) then
3761 ("duplicate % pragma for entry", Arg1
);
3763 elsif Has_Homonym
(Ent
) then
3765 ("pragma% argument cannot specify overloaded entry", Arg1
);
3769 FF
: constant Entity_Id
:= First_Formal
(Ent
);
3772 if Present
(FF
) then
3773 if Present
(Next_Formal
(FF
)) then
3775 ("entry for pragma% can have only one argument",
3778 elsif Parameter_Mode
(FF
) /= E_In_Parameter
then
3780 ("entry parameter for pragma% must have mode IN",
3786 Set_Is_AST_Entry
(Ent
);
3794 -- pragma Asynchronous (LOCAL_NAME);
3796 when Pragma_Asynchronous
=> Asynchronous
: declare
3804 procedure Process_Async_Pragma
;
3805 -- Common processing for procedure and access-to-procedure case
3807 --------------------------
3808 -- Process_Async_Pragma --
3809 --------------------------
3811 procedure Process_Async_Pragma
is
3813 if not Present
(L
) then
3814 Set_Is_Asynchronous
(Nm
);
3818 -- The formals should be of mode IN (RM E.4.1(6))
3821 while Present
(S
) loop
3822 Formal
:= Defining_Identifier
(S
);
3824 if Nkind
(Formal
) = N_Defining_Identifier
3825 and then Ekind
(Formal
) /= E_In_Parameter
3828 ("pragma% procedure can only have IN parameter",
3835 Set_Is_Asynchronous
(Nm
);
3836 end Process_Async_Pragma
;
3838 -- Start of processing for pragma Asynchronous
3841 Check_Ada_83_Warning
;
3842 Check_No_Identifiers
;
3843 Check_Arg_Count
(1);
3844 Check_Arg_Is_Local_Name
(Arg1
);
3846 if Debug_Flag_U
then
3850 C_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
3851 Analyze
(Expression
(Arg1
));
3852 Nm
:= Entity
(Expression
(Arg1
));
3854 if not Is_Remote_Call_Interface
(C_Ent
)
3855 and then not Is_Remote_Types
(C_Ent
)
3857 -- This pragma should only appear in an RCI or Remote Types
3858 -- unit (RM E.4.1(4))
3861 ("pragma% not in Remote_Call_Interface or " &
3862 "Remote_Types unit");
3865 if Ekind
(Nm
) = E_Procedure
3866 and then Nkind
(Parent
(Nm
)) = N_Procedure_Specification
3868 if not Is_Remote_Call_Interface
(Nm
) then
3870 ("pragma% cannot be applied on non-remote procedure",
3874 L
:= Parameter_Specifications
(Parent
(Nm
));
3875 Process_Async_Pragma
;
3878 elsif Ekind
(Nm
) = E_Function
then
3880 ("pragma% cannot be applied to function", Arg1
);
3882 elsif Ekind
(Nm
) = E_Record_Type
3883 and then Present
(Corresponding_Remote_Type
(Nm
))
3885 N
:= Declaration_Node
(Corresponding_Remote_Type
(Nm
));
3887 if Nkind
(N
) = N_Full_Type_Declaration
3888 and then Nkind
(Type_Definition
(N
)) =
3889 N_Access_Procedure_Definition
3891 L
:= Parameter_Specifications
(Type_Definition
(N
));
3892 Process_Async_Pragma
;
3896 ("pragma% cannot reference access-to-function type",
3900 -- Only other possibility is Access-to-class-wide type
3902 elsif Is_Access_Type
(Nm
)
3903 and then Is_Class_Wide_Type
(Designated_Type
(Nm
))
3905 Check_First_Subtype
(Arg1
);
3906 Set_Is_Asynchronous
(Nm
);
3907 if Expander_Active
then
3908 RACW_Type_Is_Asynchronous
(Nm
);
3912 Error_Pragma_Arg
("inappropriate argument for pragma%", Arg1
);
3921 -- pragma Atomic (LOCAL_NAME);
3923 when Pragma_Atomic
=>
3924 Process_Atomic_Shared_Volatile
;
3926 -----------------------
3927 -- Atomic_Components --
3928 -----------------------
3930 -- pragma Atomic_Components (array_LOCAL_NAME);
3932 -- This processing is shared by Volatile_Components
3934 when Pragma_Atomic_Components |
3935 Pragma_Volatile_Components
=>
3937 Atomic_Components
: declare
3945 Check_Ada_83_Warning
;
3946 Check_No_Identifiers
;
3947 Check_Arg_Count
(1);
3948 Check_Arg_Is_Local_Name
(Arg1
);
3949 E_Id
:= Expression
(Arg1
);
3951 if Etype
(E_Id
) = Any_Type
then
3957 if Rep_Item_Too_Early
(E
, N
)
3959 Rep_Item_Too_Late
(E
, N
)
3964 D
:= Declaration_Node
(E
);
3967 if (K
= N_Full_Type_Declaration
and then Is_Array_Type
(E
))
3969 ((Ekind
(E
) = E_Constant
or else Ekind
(E
) = E_Variable
)
3970 and then Nkind
(D
) = N_Object_Declaration
3971 and then Nkind
(Object_Definition
(D
)) =
3972 N_Constrained_Array_Definition
)
3974 -- The flag is set on the object, or on the base type
3976 if Nkind
(D
) /= N_Object_Declaration
then
3980 Set_Has_Volatile_Components
(E
);
3982 if Prag_Id
= Pragma_Atomic_Components
then
3983 Set_Has_Atomic_Components
(E
);
3985 if Is_Packed
(E
) then
3986 Set_Is_Packed
(E
, False);
3989 ("?Pack canceled, cannot pack atomic components",
3995 Error_Pragma_Arg
("inappropriate entity for pragma%", Arg1
);
3997 end Atomic_Components
;
3999 --------------------
4000 -- Attach_Handler --
4001 --------------------
4003 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
4005 when Pragma_Attach_Handler
=>
4006 Check_Ada_83_Warning
;
4007 Check_No_Identifiers
;
4008 Check_Arg_Count
(2);
4009 Check_Interrupt_Or_Attach_Handler
;
4010 Analyze_And_Resolve
(Expression
(Arg2
), RTE
(RE_Interrupt_Id
));
4011 Process_Interrupt_Or_Attach_Handler
;
4013 --------------------
4014 -- C_Pass_By_Copy --
4015 --------------------
4017 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
4019 when Pragma_C_Pass_By_Copy
=> C_Pass_By_Copy
: declare
4025 Check_Valid_Configuration_Pragma
;
4026 Check_Arg_Count
(1);
4027 Check_Optional_Identifier
(Arg1
, "max_size");
4029 Arg
:= Expression
(Arg1
);
4030 Check_Arg_Is_Static_Expression
(Arg
, Any_Integer
);
4032 Val
:= Expr_Value
(Arg
);
4036 ("maximum size for pragma% must be positive", Arg1
);
4038 elsif UI_Is_In_Int_Range
(Val
) then
4039 Default_C_Record_Mechanism
:= UI_To_Int
(Val
);
4041 -- If a giant value is given, Int'Last will do well enough.
4042 -- If sometime someone complains that a record larger than
4043 -- two gigabytes is not copied, we will worry about it then!
4046 Default_C_Record_Mechanism
:= Mechanism_Type
'Last;
4054 -- pragma Comment (static_string_EXPRESSION)
4056 -- Processing for pragma Comment shares the circuitry for
4057 -- pragma Ident. The only differences are that Ident enforces
4058 -- a limit of 31 characters on its argument, and also enforces
4059 -- limitations on placement for DEC compatibility. Pragma
4060 -- Comment shares neither of these restrictions.
4066 -- pragma Common_Object (
4067 -- [Internal =>] LOCAL_NAME,
4068 -- [, [External =>] EXTERNAL_SYMBOL]
4069 -- [, [Size =>] EXTERNAL_SYMBOL]);
4071 -- Processing for this pragma is shared with Psect_Object
4073 ----------------------------
4074 -- Complex_Representation --
4075 ----------------------------
4077 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
4079 when Pragma_Complex_Representation
=> Complex_Representation
: declare
4086 Check_Arg_Count
(1);
4087 Check_Optional_Identifier
(Arg1
, Name_Entity
);
4088 Check_Arg_Is_Local_Name
(Arg1
);
4089 E_Id
:= Expression
(Arg1
);
4091 if Etype
(E_Id
) = Any_Type
then
4097 if not Is_Record_Type
(E
) then
4099 ("argument for pragma% must be record type", Arg1
);
4102 Ent
:= First_Entity
(E
);
4105 or else No
(Next_Entity
(Ent
))
4106 or else Present
(Next_Entity
(Next_Entity
(Ent
)))
4107 or else not Is_Floating_Point_Type
(Etype
(Ent
))
4108 or else Etype
(Ent
) /= Etype
(Next_Entity
(Ent
))
4111 ("record for pragma% must have two fields of same fpt type",
4115 Set_Has_Complex_Representation
(Base_Type
(E
));
4117 end Complex_Representation
;
4119 -------------------------
4120 -- Component_Alignment --
4121 -------------------------
4123 -- pragma Component_Alignment (
4124 -- [Form =>] ALIGNMENT_CHOICE
4125 -- [, [Name =>] type_LOCAL_NAME]);
4127 -- ALIGNMENT_CHOICE ::=
4129 -- | Component_Size_4
4133 when Pragma_Component_Alignment
=> Component_AlignmentP
: declare
4134 Args
: Args_List
(1 .. 2);
4135 Names
: Name_List
(1 .. 2) := (
4139 Form
: Node_Id
renames Args
(1);
4140 Name
: Node_Id
renames Args
(2);
4142 Atype
: Component_Alignment_Kind
;
4147 Gather_Associations
(Names
, Args
);
4150 Error_Pragma
("missing Form argument for pragma%");
4153 Check_Arg_Is_Identifier
(Form
);
4155 -- Get proper alignment, note that Default = Component_Size
4156 -- on all machines we have so far, and we want to set this
4157 -- value rather than the default value to indicate that it
4158 -- has been explicitly set (and thus will not get overridden
4159 -- by the default component alignment for the current scope)
4161 if Chars
(Form
) = Name_Component_Size
then
4162 Atype
:= Calign_Component_Size
;
4164 elsif Chars
(Form
) = Name_Component_Size_4
then
4165 Atype
:= Calign_Component_Size_4
;
4167 elsif Chars
(Form
) = Name_Default
then
4168 Atype
:= Calign_Component_Size
;
4170 elsif Chars
(Form
) = Name_Storage_Unit
then
4171 Atype
:= Calign_Storage_Unit
;
4175 ("invalid Form parameter for pragma%", Form
);
4178 -- Case with no name, supplied, affects scope table entry
4182 (Scope_Stack
.Last
).Component_Alignment_Default
:= Atype
;
4184 -- Case of name supplied
4187 Check_Arg_Is_Local_Name
(Name
);
4189 Typ
:= Entity
(Name
);
4192 or else Rep_Item_Too_Early
(Typ
, N
)
4196 Typ
:= Underlying_Type
(Typ
);
4199 if not Is_Record_Type
(Typ
)
4200 and then not Is_Array_Type
(Typ
)
4203 ("Name parameter of pragma% must identify record or " &
4204 "array type", Name
);
4207 -- An explicit Component_Alignment pragma overrides an
4208 -- implicit pragma Pack, but not an explicit one.
4210 if not Has_Pragma_Pack
(Base_Type
(Typ
)) then
4211 Set_Is_Packed
(Base_Type
(Typ
), False);
4212 Set_Component_Alignment
(Base_Type
(Typ
), Atype
);
4216 end Component_AlignmentP
;
4222 -- pragma Controlled (first_subtype_LOCAL_NAME);
4224 when Pragma_Controlled
=> Controlled
: declare
4228 Check_No_Identifiers
;
4229 Check_Arg_Count
(1);
4230 Check_Arg_Is_Local_Name
(Arg1
);
4231 Arg
:= Expression
(Arg1
);
4233 if not Is_Entity_Name
(Arg
)
4234 or else not Is_Access_Type
(Entity
(Arg
))
4236 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
4238 Set_Has_Pragma_Controlled
(Base_Type
(Entity
(Arg
)));
4246 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
4247 -- [Entity =>] LOCAL_NAME);
4249 when Pragma_Convention
=> Convention
: declare
4254 Check_Ada_83_Warning
;
4255 Check_Arg_Count
(2);
4256 Process_Convention
(C
, E
);
4263 -- pragma CPP_Class ([Entity =>] local_NAME)
4265 when Pragma_CPP_Class
=> CPP_Class
: declare
4268 Default_DTC
: Entity_Id
:= Empty
;
4269 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
4275 Check_Arg_Count
(1);
4276 Check_Optional_Identifier
(Arg1
, Name_Entity
);
4277 Check_Arg_Is_Local_Name
(Arg1
);
4279 Arg
:= Expression
(Arg1
);
4282 if Etype
(Arg
) = Any_Type
then
4286 if not Is_Entity_Name
(Arg
)
4287 or else not Is_Type
(Entity
(Arg
))
4289 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
4292 Typ
:= Entity
(Arg
);
4294 if not Is_Record_Type
(Typ
) then
4295 Error_Pragma_Arg
("pragma% applicable to a record, "
4296 & "tagged record or record extension", Arg1
);
4299 Default_DTC
:= First_Component
(Typ
);
4300 while Present
(Default_DTC
)
4301 and then Etype
(Default_DTC
) /= VTP_Type
4303 Next_Component
(Default_DTC
);
4306 -- Case of non tagged type
4308 if not Is_Tagged_Type
(Typ
) then
4309 Set_Is_CPP_Class
(Typ
);
4311 if Present
(Default_DTC
) then
4313 ("only tagged records can contain vtable pointers", Arg1
);
4316 -- Case of tagged type with no vtable ptr
4318 -- What is test for Typ = Root_Typ (Typ) about here ???
4320 elsif Is_Tagged_Type
(Typ
)
4321 and then Typ
= Root_Type
(Typ
)
4322 and then No
(Default_DTC
)
4325 ("a cpp_class must contain a vtable pointer", Arg1
);
4327 -- Tagged type that has a vtable ptr
4329 elsif Present
(Default_DTC
) then
4330 Set_Is_CPP_Class
(Typ
);
4331 Set_Is_Limited_Record
(Typ
);
4332 Set_Is_Tag
(Default_DTC
);
4333 Set_DT_Entry_Count
(Default_DTC
, No_Uint
);
4335 -- Since a CPP type has no direct link to its associated tag
4336 -- most tags checks cannot be performed
4338 Set_Suppress_Tag_Checks
(Typ
);
4339 Set_Suppress_Tag_Checks
(Class_Wide_Type
(Typ
));
4341 -- Get rid of the _tag component when there was one.
4342 -- It is only useful for regular tagged types
4344 if Expander_Active
and then Typ
= Root_Type
(Typ
) then
4346 Tag_C
:= Tag_Component
(Typ
);
4347 C
:= First_Entity
(Typ
);
4350 Set_First_Entity
(Typ
, Next_Entity
(Tag_C
));
4353 while Next_Entity
(C
) /= Tag_C
loop
4357 Set_Next_Entity
(C
, Next_Entity
(Tag_C
));
4363 ---------------------
4364 -- CPP_Constructor --
4365 ---------------------
4367 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
4369 when Pragma_CPP_Constructor
=> CPP_Constructor
: declare
4375 Check_Arg_Count
(1);
4376 Check_Optional_Identifier
(Arg1
, Name_Entity
);
4377 Check_Arg_Is_Local_Name
(Arg1
);
4379 Id
:= Expression
(Arg1
);
4380 Find_Program_Unit_Name
(Id
);
4382 -- If we did not find the name, we are done
4384 if Etype
(Id
) = Any_Type
then
4388 Def_Id
:= Entity
(Id
);
4390 if Ekind
(Def_Id
) = E_Function
4391 and then Is_Class_Wide_Type
(Etype
(Def_Id
))
4392 and then Is_CPP_Class
(Etype
(Etype
(Def_Id
)))
4394 -- What the heck is this??? this pragma allows only 1 arg
4396 if Arg_Count
>= 2 then
4397 Check_At_Most_N_Arguments
(3);
4398 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
4401 if No
(Parameter_Specifications
(Parent
(Def_Id
))) then
4402 Set_Has_Completion
(Def_Id
);
4403 Set_Is_Constructor
(Def_Id
);
4406 ("non-default constructors not implemented", Arg1
);
4411 ("pragma% requires function returning a 'C'P'P_Class type",
4414 end CPP_Constructor
;
4420 -- pragma CPP_Virtual
4421 -- [Entity =>] LOCAL_NAME
4422 -- [ [Vtable_Ptr =>] LOCAL_NAME,
4423 -- [Position =>] static_integer_EXPRESSION]);
4425 when Pragma_CPP_Virtual
=> CPP_Virtual
: declare
4429 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
4436 if Arg_Count
= 3 then
4437 Check_Optional_Identifier
(Arg2
, "vtable_ptr");
4439 -- We allow Entry_Count as well as Position for the third
4440 -- parameter for back compatibility with versions of GNAT
4441 -- before version 3.12. The documentation has always said
4442 -- Position, but the code up to 3.12 said Entry_Count.
4444 if Chars
(Arg3
) /= Name_Position
then
4445 Check_Optional_Identifier
(Arg3
, "entry_count");
4449 Check_Arg_Count
(1);
4452 Check_Optional_Identifier
(Arg1
, Name_Entity
);
4453 Check_Arg_Is_Local_Name
(Arg1
);
4455 -- First argument must be a subprogram name
4457 Arg
:= Expression
(Arg1
);
4458 Find_Program_Unit_Name
(Arg
);
4460 if Etype
(Arg
) = Any_Type
then
4463 Subp
:= Entity
(Arg
);
4466 if not (Is_Subprogram
(Subp
)
4467 and then Is_Dispatching_Operation
(Subp
))
4470 ("pragma% must reference a primitive operation", Arg1
);
4473 Typ
:= Find_Dispatching_Type
(Subp
);
4475 -- If only one Argument defaults are :
4476 -- . DTC_Entity is the default Vtable pointer
4477 -- . DT_Position will be set at the freezing point
4479 if Arg_Count
= 1 then
4480 Set_DTC_Entity
(Subp
, Tag_Component
(Typ
));
4484 -- Second argument is a component name of type Vtable_Ptr
4486 Arg
:= Expression
(Arg2
);
4488 if Nkind
(Arg
) /= N_Identifier
then
4489 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
4493 DTC
:= First_Component
(Typ
);
4494 while Present
(DTC
) and then Chars
(DTC
) /= Chars
(Arg
) loop
4495 Next_Component
(DTC
);
4499 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
4502 elsif Etype
(DTC
) /= VTP_Type
then
4503 Wrong_Type
(Arg
, VTP_Type
);
4507 -- Third argument is an integer (DT_Position)
4509 Arg
:= Expression
(Arg3
);
4510 Analyze_And_Resolve
(Arg
, Any_Integer
);
4512 if not Is_Static_Expression
(Arg
) then
4514 ("third argument of pragma% must be a static expression",
4518 V
:= Expr_Value
(Expression
(Arg3
));
4522 ("third argument of pragma% must be positive",
4526 Set_DTC_Entity
(Subp
, DTC
);
4527 Set_DT_Position
(Subp
, V
);
4536 -- pragma CPP_Vtable (
4537 -- [Entity =>] LOCAL_NAME
4538 -- [Vtable_Ptr =>] LOCAL_NAME,
4539 -- [Entry_Count =>] static_integer_EXPRESSION);
4541 when Pragma_CPP_Vtable
=> CPP_Vtable
: declare
4544 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
4551 Check_Arg_Count
(3);
4552 Check_Optional_Identifier
(Arg1
, Name_Entity
);
4553 Check_Optional_Identifier
(Arg2
, "vtable_ptr");
4554 Check_Optional_Identifier
(Arg3
, "entry_count");
4555 Check_Arg_Is_Local_Name
(Arg1
);
4557 -- First argument is a record type name
4559 Arg
:= Expression
(Arg1
);
4562 if Etype
(Arg
) = Any_Type
then
4565 Typ
:= Entity
(Arg
);
4568 if not (Is_Tagged_Type
(Typ
) and then Is_CPP_Class
(Typ
)) then
4569 Error_Pragma_Arg
("'C'P'P_Class tagged type expected", Arg1
);
4572 -- Second argument is a component name of type Vtable_Ptr
4574 Arg
:= Expression
(Arg2
);
4576 if Nkind
(Arg
) /= N_Identifier
then
4577 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
4581 DTC
:= First_Component
(Typ
);
4582 while Present
(DTC
) and then Chars
(DTC
) /= Chars
(Arg
) loop
4583 Next_Component
(DTC
);
4587 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
4590 elsif Etype
(DTC
) /= VTP_Type
then
4591 Wrong_Type
(DTC
, VTP_Type
);
4594 -- If it is the first pragma Vtable, This becomes the default tag
4596 elsif (not Is_Tag
(DTC
))
4597 and then DT_Entry_Count
(Tag_Component
(Typ
)) = No_Uint
4599 Set_Is_Tag
(Tag_Component
(Typ
), False);
4600 Set_Is_Tag
(DTC
, True);
4601 Set_DT_Entry_Count
(DTC
, No_Uint
);
4604 -- Those pragmas must appear before any primitive operation
4605 -- definition (except inherited ones) otherwise the default
4608 Elmt
:= First_Elmt
(Primitive_Operations
(Typ
));
4609 while Present
(Elmt
) loop
4610 if No
(Alias
(Node
(Elmt
))) then
4611 Error_Msg_Sloc
:= Sloc
(Node
(Elmt
));
4613 ("pragma% must appear before this primitive operation");
4619 -- Third argument is an integer (DT_Entry_Count)
4621 Arg
:= Expression
(Arg3
);
4622 Analyze_And_Resolve
(Arg
, Any_Integer
);
4624 if not Is_Static_Expression
(Arg
) then
4626 ("entry count for pragma% must be a static expression", Arg3
);
4629 V
:= Expr_Value
(Expression
(Arg3
));
4633 ("entry count for pragma% must be positive", Arg3
);
4635 Set_DT_Entry_Count
(DTC
, V
);
4645 -- pragma Debug (PROCEDURE_CALL_STATEMENT);
4647 when Pragma_Debug
=> Debug
: begin
4650 -- If assertions are enabled, and we are expanding code, then
4651 -- we rewrite the pragma with its corresponding procedure call
4652 -- and then analyze the call.
4654 if Assertions_Enabled
and Expander_Active
then
4655 Rewrite
(N
, Relocate_Node
(Debug_Statement
(N
)));
4658 -- Otherwise we work a bit to get a tree that makes sense
4659 -- for ASIS purposes, namely a pragma with an analyzed
4660 -- argument that looks like a procedure call.
4663 Expander_Mode_Save_And_Set
(False);
4664 Rewrite
(N
, Relocate_Node
(Debug_Statement
(N
)));
4668 Chars
=> Name_Debug
,
4669 Pragma_Argument_Associations
=>
4670 New_List
(Relocate_Node
(N
))));
4671 Expander_Mode_Restore
;
4679 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
4681 when Pragma_Discard_Names
=> Discard_Names
: declare
4687 Check_Ada_83_Warning
;
4689 -- Deal with configuration pragma case
4691 if Arg_Count
= 0 and then Is_Configuration_Pragma
then
4692 Global_Discard_Names
:= True;
4695 -- Otherwise, check correct appropriate context
4698 Check_Is_In_Decl_Part_Or_Package_Spec
;
4700 if Arg_Count
= 0 then
4702 -- If there is no parameter, then from now on this pragma
4703 -- applies to any enumeration, exception or tagged type
4704 -- defined in the current declarative part.
4706 Set_Discard_Names
(Current_Scope
);
4710 Check_Arg_Count
(1);
4711 Check_Optional_Identifier
(Arg1
, Name_On
);
4712 Check_Arg_Is_Local_Name
(Arg1
);
4713 E_Id
:= Expression
(Arg1
);
4715 if Etype
(E_Id
) = Any_Type
then
4721 if (Is_First_Subtype
(E
)
4722 and then (Is_Enumeration_Type
(E
)
4723 or else Is_Tagged_Type
(E
)))
4724 or else Ekind
(E
) = E_Exception
4726 Set_Discard_Names
(E
);
4729 ("inappropriate entity for pragma%", Arg1
);
4739 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
4741 when Pragma_Elaborate
=> Elaborate
: declare
4743 Parent_Node
: Node_Id
;
4748 -- Pragma must be in context items list of a compilation unit
4750 if not Is_List_Member
(N
) then
4755 Plist
:= List_Containing
(N
);
4756 Parent_Node
:= Parent
(Plist
);
4758 if Parent_Node
= Empty
4759 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
4760 or else Context_Items
(Parent_Node
) /= Plist
4767 -- Must be at least one argument
4769 if Arg_Count
= 0 then
4770 Error_Pragma
("pragma% requires at least one argument");
4773 -- In Ada 83 mode, there can be no items following it in the
4774 -- context list except other pragmas and implicit with clauses
4775 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
4776 -- placement rule does not apply.
4778 if Ada_83
and then Comes_From_Source
(N
) then
4781 while Present
(Citem
) loop
4782 if Nkind
(Citem
) = N_Pragma
4783 or else (Nkind
(Citem
) = N_With_Clause
4784 and then Implicit_With
(Citem
))
4789 ("(Ada 83) pragma% must be at end of context clause");
4796 -- Finally, the arguments must all be units mentioned in a with
4797 -- clause in the same context clause. Note we already checked
4798 -- (in Par.Prag) that the arguments are either identifiers or
4801 Outer
: while Present
(Arg
) loop
4802 Citem
:= First
(Plist
);
4804 Inner
: while Citem
/= N
loop
4805 if Nkind
(Citem
) = N_With_Clause
4806 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
4808 Set_Elaborate_Present
(Citem
, True);
4809 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
4810 Set_Suppress_Elaboration_Warnings
(Entity
(Name
(Citem
)));
4819 ("argument of pragma% is not with'ed unit", Arg
);
4830 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
4832 when Pragma_Elaborate_All
=> Elaborate_All
: declare
4834 Parent_Node
: Node_Id
;
4839 Check_Ada_83_Warning
;
4841 -- Pragma must be in context items list of a compilation unit
4843 if not Is_List_Member
(N
) then
4848 Plist
:= List_Containing
(N
);
4849 Parent_Node
:= Parent
(Plist
);
4851 if Parent_Node
= Empty
4852 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
4853 or else Context_Items
(Parent_Node
) /= Plist
4860 -- Must be at least one argument
4862 if Arg_Count
= 0 then
4863 Error_Pragma
("pragma% requires at least one argument");
4866 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
4867 -- have to appear at the end of the context clause, but may
4868 -- appear mixed in with other items, even in Ada 83 mode.
4870 -- Final check: the arguments must all be units mentioned in
4871 -- a with clause in the same context clause. Note that we
4872 -- already checked (in Par.Prag) that all the arguments are
4873 -- either identifiers or selected components.
4876 Outr
: while Present
(Arg
) loop
4877 Citem
:= First
(Plist
);
4879 Innr
: while Citem
/= N
loop
4880 if Nkind
(Citem
) = N_With_Clause
4881 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
4883 Set_Elaborate_All_Present
(Citem
, True);
4884 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
4885 Set_Suppress_Elaboration_Warnings
(Entity
(Name
(Citem
)));
4894 ("argument of pragma% is not with'ed unit", Arg
);
4901 --------------------
4902 -- Elaborate_Body --
4903 --------------------
4905 -- pragma Elaborate_Body [( library_unit_NAME )];
4907 when Pragma_Elaborate_Body
=> Elaborate_Body
: declare
4908 Cunit_Node
: Node_Id
;
4909 Cunit_Ent
: Entity_Id
;
4912 Check_Ada_83_Warning
;
4913 Check_Valid_Library_Unit_Pragma
;
4915 if Nkind
(N
) = N_Null_Statement
then
4919 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
4920 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
4922 if Nkind
(Unit
(Cunit_Node
)) = N_Package_Body
4924 Nkind
(Unit
(Cunit_Node
)) = N_Subprogram_Body
4926 Error_Pragma
("pragma% must refer to a spec, not a body");
4928 Set_Body_Required
(Cunit_Node
, True);
4929 Set_Has_Pragma_Elaborate_Body
(Cunit_Ent
);
4931 -- If we are in dynamic elaboration mode, then we suppress
4932 -- elaboration warnings for the unit, since it is definitely
4933 -- fine NOT to do dynamic checks at the first level (and such
4934 -- checks will be suppressed because no elaboration boolean
4935 -- is created for Elaborate_Body packages).
4937 -- But in the static model of elaboration, Elaborate_Body is
4938 -- definitely NOT good enough to ensure elaboration safety on
4939 -- its own, since the body may WITH other units that are not
4940 -- safe from an elaboration point of view, so a client must
4941 -- still do an Elaborate_All on such units.
4943 -- Debug flag -gnatdD restores the old behavior of 3.13,
4944 -- where Elaborate_Body always suppressed elab warnings.
4946 if Dynamic_Elaboration_Checks
or Debug_Flag_DD
then
4947 Set_Suppress_Elaboration_Warnings
(Cunit_Ent
);
4952 ------------------------
4953 -- Elaboration_Checks --
4954 ------------------------
4956 -- pragma Elaboration_Checks (Static | Dynamic);
4958 when Pragma_Elaboration_Checks
=>
4960 Check_Arg_Count
(1);
4961 Check_Arg_Is_One_Of
(Arg1
, Name_Static
, Name_Dynamic
);
4962 Dynamic_Elaboration_Checks
:=
4963 (Chars
(Get_Pragma_Arg
(Arg1
)) = Name_Dynamic
);
4969 -- pragma Eliminate (
4970 -- [Unit_Name =>] IDENTIFIER |
4971 -- SELECTED_COMPONENT
4972 -- [,[Entity =>] IDENTIFIER |
4973 -- SELECTED_COMPONENT |
4975 -- [,[Parameter_Types =>] PARAMETER_TYPES]
4976 -- [,[Result_Type =>] result_SUBTYPE_MARK]);
4978 -- PARAMETER_TYPES ::=
4980 -- (SUBTYPE_MARK, SUBTYPE_MARK, ...)
4982 when Pragma_Eliminate
=> Eliminate
: begin
4984 Check_Ada_83_Warning
;
4985 Check_Valid_Configuration_Pragma
;
4986 Check_At_Least_N_Arguments
(1);
4987 Check_At_Most_N_Arguments
(4);
4990 and then Chars
(Arg3
) = Name_Result_Type
4996 Check_Optional_Identifier
(Arg1
, "unit_name");
4997 Check_Optional_Identifier
(Arg2
, Name_Entity
);
4998 Check_Optional_Identifier
(Arg3
, Name_Parameter_Types
);
4999 Check_Optional_Identifier
(Arg4
, Name_Result_Type
);
5002 Process_Eliminate_Pragma
(Arg1
, Arg2
, Arg3
, Arg4
);
5010 -- [ Convention =>] convention_IDENTIFIER,
5011 -- [ Entity =>] local_NAME
5012 -- [, [External_Name =>] static_string_EXPRESSION ]
5013 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5015 when Pragma_Export
=> Export
: declare
5020 Check_Ada_83_Warning
;
5021 Check_At_Least_N_Arguments
(2);
5022 Check_At_Most_N_Arguments
(4);
5023 Process_Convention
(C
, Def_Id
);
5025 if Ekind
(Def_Id
) /= E_Constant
then
5026 Note_Possible_Modification
(Expression
(Arg2
));
5029 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
5030 Set_Exported
(Def_Id
, Arg2
);
5033 ----------------------
5034 -- Export_Exception --
5035 ----------------------
5037 -- pragma Export_Exception (
5038 -- [Internal =>] LOCAL_NAME,
5039 -- [, [External =>] EXTERNAL_SYMBOL,]
5040 -- [, [Form =>] Ada | VMS]
5041 -- [, [Code =>] static_integer_EXPRESSION]);
5043 when Pragma_Export_Exception
=> Export_Exception
: declare
5044 Args
: Args_List
(1 .. 4);
5045 Names
: Name_List
(1 .. 4) := (
5051 Internal
: Node_Id
renames Args
(1);
5052 External
: Node_Id
renames Args
(2);
5053 Form
: Node_Id
renames Args
(3);
5054 Code
: Node_Id
renames Args
(4);
5059 if Inside_A_Generic
then
5060 Error_Pragma
("pragma% cannot be used for generic entities");
5063 Gather_Associations
(Names
, Args
);
5064 Process_Extended_Import_Export_Exception_Pragma
(
5065 Arg_Internal
=> Internal
,
5066 Arg_External
=> External
,
5070 if not Is_VMS_Exception
(Entity
(Internal
)) then
5071 Set_Exported
(Entity
(Internal
), Internal
);
5074 end Export_Exception
;
5076 ---------------------
5077 -- Export_Function --
5078 ---------------------
5080 -- pragma Export_Function (
5081 -- [Internal =>] LOCAL_NAME,
5082 -- [, [External =>] EXTERNAL_SYMBOL,]
5083 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5084 -- [, [Result_Type =>] SUBTYPE_MARK]
5085 -- [, [Mechanism =>] MECHANISM]
5086 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
5088 when Pragma_Export_Function
=> Export_Function
: declare
5089 Args
: Args_List
(1 .. 6);
5090 Names
: Name_List
(1 .. 6) := (
5093 Name_Parameter_Types
,
5096 Name_Result_Mechanism
);
5098 Internal
: Node_Id
renames Args
(1);
5099 External
: Node_Id
renames Args
(2);
5100 Parameter_Types
: Node_Id
renames Args
(3);
5101 Result_Type
: Node_Id
renames Args
(4);
5102 Mechanism
: Node_Id
renames Args
(5);
5103 Result_Mechanism
: Node_Id
renames Args
(6);
5107 Gather_Associations
(Names
, Args
);
5108 Process_Extended_Import_Export_Subprogram_Pragma
(
5109 Arg_Internal
=> Internal
,
5110 Arg_External
=> External
,
5111 Arg_Parameter_Types
=> Parameter_Types
,
5112 Arg_Result_Type
=> Result_Type
,
5113 Arg_Mechanism
=> Mechanism
,
5114 Arg_Result_Mechanism
=> Result_Mechanism
);
5115 end Export_Function
;
5121 -- pragma Export_Object (
5122 -- [Internal =>] LOCAL_NAME,
5123 -- [, [External =>] EXTERNAL_SYMBOL]
5124 -- [, [Size =>] EXTERNAL_SYMBOL]);
5126 when Pragma_Export_Object
=> Export_Object
: declare
5127 Args
: Args_List
(1 .. 3);
5128 Names
: Name_List
(1 .. 3) := (
5133 Internal
: Node_Id
renames Args
(1);
5134 External
: Node_Id
renames Args
(2);
5135 Size
: Node_Id
renames Args
(3);
5139 Gather_Associations
(Names
, Args
);
5140 Process_Extended_Import_Export_Object_Pragma
(
5141 Arg_Internal
=> Internal
,
5142 Arg_External
=> External
,
5146 ----------------------
5147 -- Export_Procedure --
5148 ----------------------
5150 -- pragma Export_Procedure (
5151 -- [Internal =>] LOCAL_NAME,
5152 -- [, [External =>] EXTERNAL_SYMBOL,]
5153 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5154 -- [, [Mechanism =>] MECHANISM]);
5156 when Pragma_Export_Procedure
=> Export_Procedure
: declare
5157 Args
: Args_List
(1 .. 4);
5158 Names
: Name_List
(1 .. 4) := (
5161 Name_Parameter_Types
,
5164 Internal
: Node_Id
renames Args
(1);
5165 External
: Node_Id
renames Args
(2);
5166 Parameter_Types
: Node_Id
renames Args
(3);
5167 Mechanism
: Node_Id
renames Args
(4);
5171 Gather_Associations
(Names
, Args
);
5172 Process_Extended_Import_Export_Subprogram_Pragma
(
5173 Arg_Internal
=> Internal
,
5174 Arg_External
=> External
,
5175 Arg_Parameter_Types
=> Parameter_Types
,
5176 Arg_Mechanism
=> Mechanism
);
5177 end Export_Procedure
;
5179 -----------------------------
5180 -- Export_Valued_Procedure --
5181 -----------------------------
5183 -- pragma Export_Valued_Procedure (
5184 -- [Internal =>] LOCAL_NAME,
5185 -- [, [External =>] EXTERNAL_SYMBOL,]
5186 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5187 -- [, [Mechanism =>] MECHANISM]);
5189 when Pragma_Export_Valued_Procedure
=>
5190 Export_Valued_Procedure
: declare
5191 Args
: Args_List
(1 .. 4);
5192 Names
: Name_List
(1 .. 4) := (
5195 Name_Parameter_Types
,
5198 Internal
: Node_Id
renames Args
(1);
5199 External
: Node_Id
renames Args
(2);
5200 Parameter_Types
: Node_Id
renames Args
(3);
5201 Mechanism
: Node_Id
renames Args
(4);
5205 Gather_Associations
(Names
, Args
);
5206 Process_Extended_Import_Export_Subprogram_Pragma
(
5207 Arg_Internal
=> Internal
,
5208 Arg_External
=> External
,
5209 Arg_Parameter_Types
=> Parameter_Types
,
5210 Arg_Mechanism
=> Mechanism
);
5211 end Export_Valued_Procedure
;
5217 -- pragma Extend_System ([Name =>] Identifier);
5219 when Pragma_Extend_System
=> Extend_System
: declare
5222 Check_Valid_Configuration_Pragma
;
5223 Check_Arg_Count
(1);
5224 Check_Optional_Identifier
(Arg1
, Name_Name
);
5225 Check_Arg_Is_Identifier
(Arg1
);
5227 Get_Name_String
(Chars
(Expression
(Arg1
)));
5230 and then Name_Buffer
(1 .. 4) = "aux_"
5232 if Present
(System_Extend_Pragma_Arg
) then
5233 if Chars
(Expression
(Arg1
)) =
5234 Chars
(Expression
(System_Extend_Pragma_Arg
))
5238 Error_Msg_Sloc
:= Sloc
(System_Extend_Pragma_Arg
);
5239 Error_Pragma
("pragma% conflicts with that at#");
5243 System_Extend_Pragma_Arg
:= Arg1
;
5246 Error_Pragma
("incorrect name for pragma%, must be Aux_xxx");
5250 ------------------------
5251 -- Extensions_Allowed --
5252 ------------------------
5254 -- pragma Extensions_Allowed (ON | OFF);
5256 when Pragma_Extensions_Allowed
=>
5258 Check_Arg_Count
(1);
5259 Check_No_Identifiers
;
5260 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
5261 Extensions_Allowed
:= (Chars
(Expression
(Arg1
)) = Name_On
);
5267 -- pragma External (
5268 -- [ Convention =>] convention_IDENTIFIER,
5269 -- [ Entity =>] local_NAME
5270 -- [, [External_Name =>] static_string_EXPRESSION ]
5271 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5273 when Pragma_External
=> External
: declare
5279 Check_At_Least_N_Arguments
(2);
5280 Check_At_Most_N_Arguments
(4);
5281 Process_Convention
(C
, Def_Id
);
5282 Note_Possible_Modification
(Expression
(Arg2
));
5283 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
5284 Set_Exported
(Def_Id
, Arg2
);
5287 --------------------------
5288 -- External_Name_Casing --
5289 --------------------------
5291 -- pragma External_Name_Casing (
5292 -- UPPERCASE | LOWERCASE
5293 -- [, AS_IS | UPPERCASE | LOWERCASE]);
5295 when Pragma_External_Name_Casing
=>
5297 External_Name_Casing
: declare
5300 Check_No_Identifiers
;
5302 if Arg_Count
= 2 then
5304 (Arg2
, Name_As_Is
, Name_Uppercase
, Name_Lowercase
);
5306 case Chars
(Get_Pragma_Arg
(Arg2
)) is
5308 Opt
.External_Name_Exp_Casing
:= As_Is
;
5310 when Name_Uppercase
=>
5311 Opt
.External_Name_Exp_Casing
:= Uppercase
;
5313 when Name_Lowercase
=>
5314 Opt
.External_Name_Exp_Casing
:= Lowercase
;
5321 Check_Arg_Count
(1);
5324 Check_Arg_Is_One_Of
(Arg1
, Name_Uppercase
, Name_Lowercase
);
5326 case Chars
(Get_Pragma_Arg
(Arg1
)) is
5327 when Name_Uppercase
=>
5328 Opt
.External_Name_Imp_Casing
:= Uppercase
;
5330 when Name_Lowercase
=>
5331 Opt
.External_Name_Imp_Casing
:= Lowercase
;
5337 end External_Name_Casing
;
5339 ---------------------------
5340 -- Finalize_Storage_Only --
5341 ---------------------------
5343 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
5345 when Pragma_Finalize_Storage_Only
=> Finalize_Storage
: declare
5346 Assoc
: Node_Id
:= Arg1
;
5347 Type_Id
: Node_Id
:= Expression
(Assoc
);
5351 Check_No_Identifiers
;
5352 Check_Arg_Count
(1);
5353 Check_Arg_Is_Local_Name
(Arg1
);
5355 Find_Type
(Type_Id
);
5356 Typ
:= Entity
(Type_Id
);
5359 or else Rep_Item_Too_Early
(Typ
, N
)
5363 Typ
:= Underlying_Type
(Typ
);
5366 if not Is_Controlled
(Typ
) then
5367 Error_Pragma
("pragma% must specify controlled type");
5370 Check_First_Subtype
(Arg1
);
5372 if Finalize_Storage_Only
(Typ
) then
5373 Error_Pragma
("duplicate pragma%, only one allowed");
5375 elsif not Rep_Item_Too_Late
(Typ
, N
) then
5376 Set_Finalize_Storage_Only
(Typ
, True);
5378 end Finalize_Storage
;
5380 --------------------------
5381 -- Float_Representation --
5382 --------------------------
5384 -- pragma Float_Representation (VAX_Float | IEEE_Float);
5386 when Pragma_Float_Representation
=> Float_Representation
: declare
5394 if Arg_Count
= 1 then
5395 Check_Valid_Configuration_Pragma
;
5397 Check_Arg_Count
(2);
5398 Check_Optional_Identifier
(Arg2
, Name_Entity
);
5399 Check_Arg_Is_Local_Name
(Arg2
);
5402 Check_No_Identifier
(Arg1
);
5403 Check_Arg_Is_One_Of
(Arg1
, Name_VAX_Float
, Name_IEEE_Float
);
5405 if not OpenVMS_On_Target
then
5406 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
5408 ("?pragma% ignored (applies only to Open'V'M'S)");
5414 -- One argument case
5416 if Arg_Count
= 1 then
5418 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
5420 if Opt
.Float_Format
= 'I' then
5421 Error_Pragma
("'I'E'E'E format previously specified");
5424 Opt
.Float_Format
:= 'V';
5427 if Opt
.Float_Format
= 'V' then
5428 Error_Pragma
("'V'A'X format previously specified");
5431 Opt
.Float_Format
:= 'I';
5434 Set_Standard_Fpt_Formats
;
5436 -- Two argument case
5439 Argx
:= Get_Pragma_Arg
(Arg2
);
5441 if not Is_Entity_Name
(Argx
)
5442 or else not Is_Floating_Point_Type
(Entity
(Argx
))
5445 ("second argument of% pragma must be floating-point type",
5449 Ent
:= Entity
(Argx
);
5450 Digs
:= UI_To_Int
(Digits_Value
(Ent
));
5452 -- Two arguments, VAX_Float case
5454 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
5457 when 6 => Set_F_Float
(Ent
);
5458 when 9 => Set_D_Float
(Ent
);
5459 when 15 => Set_G_Float
(Ent
);
5463 ("wrong digits value, must be 6,9 or 15", Arg2
);
5466 -- Two arguments, IEEE_Float case
5470 when 6 => Set_IEEE_Short
(Ent
);
5471 when 15 => Set_IEEE_Long
(Ent
);
5475 ("wrong digits value, must be 6 or 15", Arg2
);
5480 end Float_Representation
;
5486 -- pragma Ident (static_string_EXPRESSION)
5488 -- Note: pragma Comment shares this processing. Pragma Comment
5489 -- is identical to Ident, except that the restriction of the
5490 -- argument to 31 characters and the placement restrictions
5491 -- are not enforced for pragma Comment.
5493 when Pragma_Ident | Pragma_Comment
=> Ident
: declare
5498 Check_Arg_Count
(1);
5499 Check_No_Identifiers
;
5500 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
5502 -- For pragma Ident, preserve DEC compatibility by requiring
5503 -- the pragma to appear in a declarative part or package spec.
5505 if Prag_Id
= Pragma_Ident
then
5506 Check_Is_In_Decl_Part_Or_Package_Spec
;
5509 Str
:= Expr_Value_S
(Expression
(Arg1
));
5511 -- For pragma Ident, preserve DEC compatibility by limiting
5512 -- the length to 31 characters.
5514 if Prag_Id
= Pragma_Ident
5515 and then String_Length
(Strval
(Str
)) > 31
5518 ("argument for pragma% is too long, maximum is 31", Arg1
);
5526 GP
:= Parent
(Parent
(N
));
5528 if Nkind
(GP
) = N_Package_Declaration
5530 Nkind
(GP
) = N_Generic_Package_Declaration
5535 -- If we have a compilation unit, then record the ident
5536 -- value, checking for improper duplication.
5538 if Nkind
(GP
) = N_Compilation_Unit
then
5539 CS
:= Ident_String
(Current_Sem_Unit
);
5541 if Present
(CS
) then
5543 -- For Ident, we do not permit multiple instances
5545 if Prag_Id
= Pragma_Ident
then
5546 Error_Pragma
("duplicate% pragma not permitted");
5548 -- For Comment, we concatenate the string, unless we
5549 -- want to preserve the tree structure for ASIS.
5551 elsif not Tree_Output
then
5552 Start_String
(Strval
(CS
));
5553 Store_String_Char
(' ');
5554 Store_String_Chars
(Strval
(Str
));
5555 Set_Strval
(CS
, End_String
);
5559 -- In VMS, the effect of IDENT is achieved by passing
5560 -- IDENTIFICATION=name as a --for-linker switch.
5562 if OpenVMS_On_Target
then
5565 ("--for-linker=IDENTIFICATION=");
5566 String_To_Name_Buffer
(Strval
(Str
));
5567 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
5569 -- Only the last processed IDENT is saved. The main
5570 -- purpose is so an IDENT associated with a main
5571 -- procedure will be used in preference to an IDENT
5572 -- associated with a with'd package.
5574 Replace_Linker_Option_String
5575 (End_String
, "--for-linker=IDENTIFICATION=");
5578 Set_Ident_String
(Current_Sem_Unit
, Str
);
5581 -- For subunits, we just ignore the Ident, since in GNAT
5582 -- these are not separate object files, and hence not
5583 -- separate units in the unit table.
5585 elsif Nkind
(GP
) = N_Subunit
then
5588 -- Otherwise we have a misplaced pragma Ident, but we ignore
5589 -- this if we are in an instantiation, since it comes from
5590 -- a generic, and has no relevance to the instantiation.
5592 elsif Prag_Id
= Pragma_Ident
then
5593 if Instantiation_Location
(Loc
) = No_Location
then
5594 Error_Pragma
("pragma% only allowed at outer level");
5605 -- [ Convention =>] convention_IDENTIFIER,
5606 -- [ Entity =>] local_NAME
5607 -- [, [External_Name =>] static_string_EXPRESSION ]
5608 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5610 when Pragma_Import
=>
5611 Check_Ada_83_Warning
;
5612 Check_At_Least_N_Arguments
(2);
5613 Check_At_Most_N_Arguments
(4);
5614 Process_Import_Or_Interface
;
5616 ----------------------
5617 -- Import_Exception --
5618 ----------------------
5620 -- pragma Import_Exception (
5621 -- [Internal =>] LOCAL_NAME,
5622 -- [, [External =>] EXTERNAL_SYMBOL,]
5623 -- [, [Form =>] Ada | VMS]
5624 -- [, [Code =>] static_integer_EXPRESSION]);
5626 when Pragma_Import_Exception
=> Import_Exception
: declare
5627 Args
: Args_List
(1 .. 4);
5628 Names
: Name_List
(1 .. 4) := (
5634 Internal
: Node_Id
renames Args
(1);
5635 External
: Node_Id
renames Args
(2);
5636 Form
: Node_Id
renames Args
(3);
5637 Code
: Node_Id
renames Args
(4);
5641 Gather_Associations
(Names
, Args
);
5643 if Present
(External
) and then Present
(Code
) then
5645 ("cannot give both External and Code options for pragma%");
5648 Process_Extended_Import_Export_Exception_Pragma
(
5649 Arg_Internal
=> Internal
,
5650 Arg_External
=> External
,
5654 if not Is_VMS_Exception
(Entity
(Internal
)) then
5655 Set_Imported
(Entity
(Internal
));
5658 end Import_Exception
;
5660 ---------------------
5661 -- Import_Function --
5662 ---------------------
5664 -- pragma Import_Function (
5665 -- [Internal =>] LOCAL_NAME,
5666 -- [, [External =>] EXTERNAL_SYMBOL]
5667 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5668 -- [, [Result_Type =>] SUBTYPE_MARK]
5669 -- [, [Mechanism =>] MECHANISM]
5670 -- [, [Result_Mechanism =>] MECHANISM_NAME]
5671 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
5673 when Pragma_Import_Function
=> Import_Function
: declare
5674 Args
: Args_List
(1 .. 7);
5675 Names
: Name_List
(1 .. 7) := (
5678 Name_Parameter_Types
,
5681 Name_Result_Mechanism
,
5682 Name_First_Optional_Parameter
);
5684 Internal
: Node_Id
renames Args
(1);
5685 External
: Node_Id
renames Args
(2);
5686 Parameter_Types
: Node_Id
renames Args
(3);
5687 Result_Type
: Node_Id
renames Args
(4);
5688 Mechanism
: Node_Id
renames Args
(5);
5689 Result_Mechanism
: Node_Id
renames Args
(6);
5690 First_Optional_Parameter
: Node_Id
renames Args
(7);
5694 Gather_Associations
(Names
, Args
);
5695 Process_Extended_Import_Export_Subprogram_Pragma
(
5696 Arg_Internal
=> Internal
,
5697 Arg_External
=> External
,
5698 Arg_Parameter_Types
=> Parameter_Types
,
5699 Arg_Result_Type
=> Result_Type
,
5700 Arg_Mechanism
=> Mechanism
,
5701 Arg_Result_Mechanism
=> Result_Mechanism
,
5702 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
5703 end Import_Function
;
5709 -- pragma Import_Object (
5710 -- [Internal =>] LOCAL_NAME,
5711 -- [, [External =>] EXTERNAL_SYMBOL]
5712 -- [, [Size =>] EXTERNAL_SYMBOL]);
5714 when Pragma_Import_Object
=> Import_Object
: declare
5715 Args
: Args_List
(1 .. 3);
5716 Names
: Name_List
(1 .. 3) := (
5721 Internal
: Node_Id
renames Args
(1);
5722 External
: Node_Id
renames Args
(2);
5723 Size
: Node_Id
renames Args
(3);
5727 Gather_Associations
(Names
, Args
);
5728 Process_Extended_Import_Export_Object_Pragma
(
5729 Arg_Internal
=> Internal
,
5730 Arg_External
=> External
,
5734 ----------------------
5735 -- Import_Procedure --
5736 ----------------------
5738 -- pragma Import_Procedure (
5739 -- [Internal =>] LOCAL_NAME,
5740 -- [, [External =>] EXTERNAL_SYMBOL]
5741 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5742 -- [, [Mechanism =>] MECHANISM]
5743 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
5745 when Pragma_Import_Procedure
=> Import_Procedure
: declare
5746 Args
: Args_List
(1 .. 5);
5747 Names
: Name_List
(1 .. 5) := (
5750 Name_Parameter_Types
,
5752 Name_First_Optional_Parameter
);
5754 Internal
: Node_Id
renames Args
(1);
5755 External
: Node_Id
renames Args
(2);
5756 Parameter_Types
: Node_Id
renames Args
(3);
5757 Mechanism
: Node_Id
renames Args
(4);
5758 First_Optional_Parameter
: Node_Id
renames Args
(5);
5762 Gather_Associations
(Names
, Args
);
5763 Process_Extended_Import_Export_Subprogram_Pragma
(
5764 Arg_Internal
=> Internal
,
5765 Arg_External
=> External
,
5766 Arg_Parameter_Types
=> Parameter_Types
,
5767 Arg_Mechanism
=> Mechanism
,
5768 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
5769 end Import_Procedure
;
5771 -----------------------------
5772 -- Import_Valued_Procedure --
5773 -----------------------------
5775 -- pragma Import_Valued_Procedure (
5776 -- [Internal =>] LOCAL_NAME,
5777 -- [, [External =>] EXTERNAL_SYMBOL]
5778 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5779 -- [, [Mechanism =>] MECHANISM]
5780 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
5782 when Pragma_Import_Valued_Procedure
=>
5783 Import_Valued_Procedure
: declare
5784 Args
: Args_List
(1 .. 5);
5785 Names
: Name_List
(1 .. 5) := (
5788 Name_Parameter_Types
,
5790 Name_First_Optional_Parameter
);
5792 Internal
: Node_Id
renames Args
(1);
5793 External
: Node_Id
renames Args
(2);
5794 Parameter_Types
: Node_Id
renames Args
(3);
5795 Mechanism
: Node_Id
renames Args
(4);
5796 First_Optional_Parameter
: Node_Id
renames Args
(5);
5800 Gather_Associations
(Names
, Args
);
5801 Process_Extended_Import_Export_Subprogram_Pragma
(
5802 Arg_Internal
=> Internal
,
5803 Arg_External
=> External
,
5804 Arg_Parameter_Types
=> Parameter_Types
,
5805 Arg_Mechanism
=> Mechanism
,
5806 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
5807 end Import_Valued_Procedure
;
5809 ------------------------
5810 -- Initialize_Scalars --
5811 ------------------------
5813 -- pragma Initialize_Scalars;
5815 when Pragma_Initialize_Scalars
=>
5817 Check_Arg_Count
(0);
5818 Check_Valid_Configuration_Pragma
;
5819 Init_Or_Norm_Scalars
:= True;
5820 Initialize_Scalars
:= True;
5826 -- pragma Inline ( NAME {, NAME} );
5828 when Pragma_Inline
=>
5830 -- Pragma is active if inlining option is active
5832 if Inline_Active
then
5833 Process_Inline
(True);
5835 -- Pragma is active in a predefined file in no run time mode
5839 Is_Predefined_File_Name
(Unit_File_Name
(Current_Sem_Unit
))
5841 Process_Inline
(True);
5844 Process_Inline
(False);
5851 -- pragma Inline_Always ( NAME {, NAME} );
5853 when Pragma_Inline_Always
=>
5854 Process_Inline
(True);
5856 --------------------
5857 -- Inline_Generic --
5858 --------------------
5860 -- pragma Inline_Generic (NAME {, NAME});
5862 when Pragma_Inline_Generic
=>
5863 Process_Generic_List
;
5865 ----------------------
5866 -- Inspection_Point --
5867 ----------------------
5869 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
5871 when Pragma_Inspection_Point
=> Inspection_Point
: declare
5876 if Arg_Count
> 0 then
5879 Exp
:= Expression
(Arg
);
5882 if not Is_Entity_Name
(Exp
)
5883 or else not Is_Object
(Entity
(Exp
))
5885 Error_Pragma_Arg
("object name required", Arg
);
5892 end Inspection_Point
;
5898 -- pragma Interface (
5899 -- convention_IDENTIFIER,
5902 when Pragma_Interface
=>
5904 Check_Arg_Count
(2);
5905 Check_No_Identifiers
;
5906 Process_Import_Or_Interface
;
5908 --------------------
5909 -- Interface_Name --
5910 --------------------
5912 -- pragma Interface_Name (
5913 -- [ Entity =>] local_NAME
5914 -- [,[External_Name =>] static_string_EXPRESSION ]
5915 -- [,[Link_Name =>] static_string_EXPRESSION ]);
5917 when Pragma_Interface_Name
=> Interface_Name
: declare
5925 Check_At_Least_N_Arguments
(2);
5926 Check_At_Most_N_Arguments
(3);
5927 Id
:= Expression
(Arg1
);
5930 if not Is_Entity_Name
(Id
) then
5932 ("first argument for pragma% must be entity name", Arg1
);
5933 elsif Etype
(Id
) = Any_Type
then
5936 Def_Id
:= Entity
(Id
);
5939 -- Special DEC-compatible processing for the object case,
5940 -- forces object to be imported.
5942 if Ekind
(Def_Id
) = E_Variable
then
5943 Kill_Size_Check_Code
(Def_Id
);
5944 Note_Possible_Modification
(Id
);
5946 -- Initialization is not allowed for imported variable
5948 if Present
(Expression
(Parent
(Def_Id
)))
5949 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
5951 Error_Msg_Sloc
:= Sloc
(Def_Id
);
5953 ("no initialization allowed for declaration of& #",
5957 -- For compatibility, support VADS usage of providing both
5958 -- pragmas Interface and Interface_Name to obtain the effect
5959 -- of a single Import pragma.
5961 if Is_Imported
(Def_Id
)
5962 and then Present
(First_Rep_Item
(Def_Id
))
5963 and then Nkind
(First_Rep_Item
(Def_Id
)) = N_Pragma
5964 and then Chars
(First_Rep_Item
(Def_Id
)) = Name_Interface
5968 Set_Imported
(Def_Id
);
5971 Set_Is_Public
(Def_Id
);
5972 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
5975 -- Otherwise must be subprogram
5977 elsif not Is_Subprogram
(Def_Id
) then
5979 ("argument of pragma% is not subprogram", Arg1
);
5982 Check_At_Most_N_Arguments
(3);
5986 -- Loop through homonyms
5989 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
5991 if Is_Imported
(Def_Id
) then
5992 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
5996 Hom_Id
:= Homonym
(Hom_Id
);
5998 exit when No
(Hom_Id
)
5999 or else Scope
(Hom_Id
) /= Current_Scope
;
6004 ("argument of pragma% is not imported subprogram",
6010 -----------------------
6011 -- Interrupt_Handler --
6012 -----------------------
6014 -- pragma Interrupt_Handler (handler_NAME);
6016 when Pragma_Interrupt_Handler
=>
6017 Check_Ada_83_Warning
;
6018 Check_Arg_Count
(1);
6019 Check_No_Identifiers
;
6020 Check_Interrupt_Or_Attach_Handler
;
6021 Process_Interrupt_Or_Attach_Handler
;
6023 ------------------------
6024 -- Interrupt_Priority --
6025 ------------------------
6027 -- pragma Interrupt_Priority [(EXPRESSION)];
6029 when Pragma_Interrupt_Priority
=> Interrupt_Priority
: declare
6030 P
: constant Node_Id
:= Parent
(N
);
6034 Check_Ada_83_Warning
;
6036 if Arg_Count
/= 0 then
6037 Arg
:= Expression
(Arg1
);
6038 Check_Arg_Count
(1);
6039 Check_No_Identifiers
;
6041 -- Set In_Default_Expression for per-object case???
6043 Analyze_And_Resolve
(Arg
, Standard_Integer
);
6044 if Expander_Active
then
6046 Convert_To
(RTE
(RE_Interrupt_Priority
), Arg
));
6050 if Nkind
(P
) /= N_Task_Definition
6051 and then Nkind
(P
) /= N_Protected_Definition
6056 elsif Has_Priority_Pragma
(P
) then
6057 Error_Pragma
("duplicate pragma% not allowed");
6060 Set_Has_Priority_Pragma
(P
, True);
6061 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
6063 end Interrupt_Priority
;
6065 ----------------------
6066 -- Java_Constructor --
6067 ----------------------
6069 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
6071 when Pragma_Java_Constructor
=> Java_Constructor
: declare
6078 Check_Arg_Count
(1);
6079 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6080 Check_Arg_Is_Local_Name
(Arg1
);
6082 Id
:= Expression
(Arg1
);
6083 Find_Program_Unit_Name
(Id
);
6085 -- If we did not find the name, we are done
6087 if Etype
(Id
) = Any_Type
then
6091 Hom_Id
:= Entity
(Id
);
6093 -- Loop through homonyms
6096 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
6098 -- The constructor is required to be a function returning
6099 -- an access type whose designated type has convention Java.
6101 if Ekind
(Def_Id
) = E_Function
6102 and then Ekind
(Etype
(Def_Id
)) in Access_Kind
6105 (Designated_Type
(Etype
(Def_Id
))) = Convention_Java
6108 (Root_Type
(Designated_Type
(Etype
(Def_Id
))))
6111 Set_Is_Constructor
(Def_Id
);
6112 Set_Convention
(Def_Id
, Convention_Java
);
6116 ("pragma% requires function returning a 'Java access type",
6120 Hom_Id
:= Homonym
(Hom_Id
);
6122 exit when No
(Hom_Id
) or else Scope
(Hom_Id
) /= Current_Scope
;
6124 end Java_Constructor
;
6126 ----------------------
6127 -- Java_Interface --
6128 ----------------------
6130 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
6132 when Pragma_Java_Interface
=> Java_Interface
: declare
6138 Check_Arg_Count
(1);
6139 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6140 Check_Arg_Is_Local_Name
(Arg1
);
6142 Arg
:= Expression
(Arg1
);
6145 if Etype
(Arg
) = Any_Type
then
6149 if not Is_Entity_Name
(Arg
)
6150 or else not Is_Type
(Entity
(Arg
))
6152 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
6155 Typ
:= Underlying_Type
(Entity
(Arg
));
6157 -- For now we simply check some of the semantic constraints
6158 -- on the type. This currently leaves out some restrictions
6159 -- on interface types, namely that the parent type must be
6160 -- java.lang.Object.Typ and that all primitives of the type
6161 -- should be declared abstract. ???
6163 if not Is_Tagged_Type
(Typ
) or else not Is_Abstract
(Typ
) then
6164 Error_Pragma_Arg
("pragma% requires an abstract "
6165 & "tagged type", Arg1
);
6167 elsif not Has_Discriminants
(Typ
)
6168 or else Ekind
(Etype
(First_Discriminant
(Typ
)))
6169 /= E_Anonymous_Access_Type
6171 not Is_Class_Wide_Type
6172 (Designated_Type
(Etype
(First_Discriminant
(Typ
))))
6175 ("type must have a class-wide access discriminant", Arg1
);
6183 -- pragma License (RESTRICTED | UNRESRICTED | GPL | MODIFIED_GPL);
6185 when Pragma_License
=>
6187 Check_Arg_Count
(1);
6188 Check_No_Identifiers
;
6189 Check_Valid_Configuration_Pragma
;
6190 Check_Arg_Is_Identifier
(Arg1
);
6193 Sind
: constant Source_File_Index
:=
6194 Source_Index
(Current_Sem_Unit
);
6197 case Chars
(Get_Pragma_Arg
(Arg1
)) is
6199 Set_License
(Sind
, GPL
);
6201 when Name_Modified_GPL
=>
6202 Set_License
(Sind
, Modified_GPL
);
6204 when Name_Restricted
=>
6205 Set_License
(Sind
, Restricted
);
6207 when Name_Unrestricted
=>
6208 Set_License
(Sind
, Unrestricted
);
6211 Error_Pragma_Arg
("invalid license name", Arg1
);
6219 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
6221 when Pragma_Link_With
=> Link_With
: declare
6227 if Operating_Mode
= Generate_Code
6228 and then In_Extended_Main_Source_Unit
(N
)
6230 Check_At_Least_N_Arguments
(1);
6231 Check_No_Identifiers
;
6232 Check_Is_In_Decl_Part_Or_Package_Spec
;
6233 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
6237 while Present
(Arg
) loop
6238 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
6240 -- Store argument, converting sequences of spaces to
6241 -- a single null character (this is the difference in
6242 -- processing between Link_With, and Linker_Options).
6245 C
: constant Char_Code
:= Get_Char_Code
(' ');
6246 S
: constant String_Id
:=
6247 Strval
(Expr_Value_S
(Expression
(Arg
)));
6250 L
: Nat
:= String_Length
(S
);
6252 procedure Skip_Spaces
;
6253 -- Advance F past any spaces
6255 procedure Skip_Spaces
is
6257 while F
<= L
and then Get_String_Char
(S
, F
) = C
loop
6263 Skip_Spaces
; -- skip leading spaces
6265 -- Loop through characters, changing any embedded
6266 -- sequence of spaces to a single null character
6267 -- (this is how Link_With/Linker_Options differ)
6270 if Get_String_Char
(S
, F
) = C
then
6273 Store_String_Char
(ASCII
.NUL
);
6276 Store_String_Char
(Get_String_Char
(S
, F
));
6284 if Present
(Arg
) then
6285 Store_String_Char
(ASCII
.NUL
);
6289 Store_Linker_Option_String
(End_String
);
6297 -- pragma Linker_Alias (
6298 -- [Entity =>] LOCAL_NAME
6299 -- [Alias =>] static_string_EXPRESSION);
6301 when Pragma_Linker_Alias
=>
6303 Check_Arg_Count
(2);
6304 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6305 Check_Optional_Identifier
(Arg2
, "alias");
6306 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
6307 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
6309 -- The only processing required is to link this item on to the
6310 -- list of rep items for the given entity. This is accomplished
6311 -- by the call to Rep_Item_Too_Late (when no error is detected
6312 -- and False is returned).
6314 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
6317 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
6320 --------------------
6321 -- Linker_Options --
6322 --------------------
6324 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
6326 -- Note: the use of multiple arguments is a GNAT extension
6328 when Pragma_Linker_Options
=> Linker_Options
: declare
6332 if Operating_Mode
= Generate_Code
6333 and then In_Extended_Main_Source_Unit
(N
)
6335 Check_Ada_83_Warning
;
6336 Check_At_Least_N_Arguments
(1);
6337 Check_No_Identifiers
;
6338 Check_Is_In_Decl_Part_Or_Package_Spec
;
6339 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
6340 Start_String
(Strval
(Expr_Value_S
(Expression
(Arg1
))));
6343 while Present
(Arg
) loop
6344 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
6345 Store_String_Char
(ASCII
.NUL
);
6347 (Strval
(Expr_Value_S
(Expression
(Arg
))));
6351 Store_Linker_Option_String
(End_String
);
6355 --------------------
6356 -- Linker_Section --
6357 --------------------
6359 -- pragma Linker_Section (
6360 -- [Entity =>] LOCAL_NAME
6361 -- [Section =>] static_string_EXPRESSION);
6363 when Pragma_Linker_Section
=>
6365 Check_Arg_Count
(2);
6366 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6367 Check_Optional_Identifier
(Arg2
, Name_Section
);
6368 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
6369 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
6371 -- The only processing required is to link this item on to the
6372 -- list of rep items for the given entity. This is accomplished
6373 -- by the call to Rep_Item_Too_Late (when no error is detected
6374 -- and False is returned).
6376 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
6379 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
6386 -- pragma List (On | Off)
6388 -- There is nothing to do here, since we did all the processing
6389 -- for this pragma in Par.Prag (so that it works properly even in
6390 -- syntax only mode)
6395 --------------------
6396 -- Locking_Policy --
6397 --------------------
6399 -- pragma Locking_Policy (policy_IDENTIFIER);
6401 when Pragma_Locking_Policy
=> declare
6405 Check_Ada_83_Warning
;
6406 Check_Arg_Count
(1);
6407 Check_No_Identifiers
;
6408 Check_Arg_Is_Locking_Policy
(Arg1
);
6409 Check_Valid_Configuration_Pragma
;
6410 Get_Name_String
(Chars
(Expression
(Arg1
)));
6411 LP
:= Fold_Upper
(Name_Buffer
(1));
6413 if Locking_Policy
/= ' '
6414 and then Locking_Policy
/= LP
6416 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
6417 Error_Pragma
("locking policy incompatible with policy#");
6419 Locking_Policy
:= LP
;
6420 Locking_Policy_Sloc
:= Loc
;
6428 -- pragma Long_Float (D_Float | G_Float);
6430 when Pragma_Long_Float
=>
6432 Check_Valid_Configuration_Pragma
;
6433 Check_Arg_Count
(1);
6434 Check_No_Identifier
(Arg1
);
6435 Check_Arg_Is_One_Of
(Arg1
, Name_D_Float
, Name_G_Float
);
6437 if not OpenVMS_On_Target
then
6438 Error_Pragma
("?pragma% ignored (applies only to Open'V'M'S)");
6443 if Chars
(Expression
(Arg1
)) = Name_D_Float
then
6444 if Opt
.Float_Format_Long
= 'G' then
6445 Error_Pragma
("G_Float previously specified");
6448 Opt
.Float_Format_Long
:= 'D';
6450 -- G_Float case (this is the default, does not need overriding)
6453 if Opt
.Float_Format_Long
= 'D' then
6454 Error_Pragma
("D_Float previously specified");
6457 Opt
.Float_Format_Long
:= 'G';
6460 Set_Standard_Fpt_Formats
;
6462 -----------------------
6463 -- Machine_Attribute --
6464 -----------------------
6466 -- pragma Machine_Attribute (
6467 -- [Entity =>] LOCAL_NAME,
6468 -- [Attribute_Name =>] static_string_EXPRESSION
6469 -- [,[Info =>] static_string_EXPRESSION] );
6471 when Pragma_Machine_Attribute
=> Machine_Attribute
: declare
6477 if Arg_Count
= 3 then
6478 Check_Optional_Identifier
(Arg3
, "info");
6479 Check_Arg_Is_Static_Expression
(Arg3
, Standard_String
);
6481 Check_Arg_Count
(2);
6484 Check_Arg_Is_Local_Name
(Arg1
);
6485 Check_Optional_Identifier
(Arg2
, "attribute_name");
6486 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6487 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
6488 Def_Id
:= Entity
(Expression
(Arg1
));
6490 if Is_Access_Type
(Def_Id
) then
6491 Def_Id
:= Designated_Type
(Def_Id
);
6494 if Rep_Item_Too_Early
(Def_Id
, N
) then
6498 Def_Id
:= Underlying_Type
(Def_Id
);
6500 -- The only processing required is to link this item on to the
6501 -- list of rep items for the given entity. This is accomplished
6502 -- by the call to Rep_Item_Too_Late (when no error is detected
6503 -- and False is returned).
6505 if Rep_Item_Too_Late
(Def_Id
, N
) then
6508 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
6510 end Machine_Attribute
;
6516 -- pragma Main_Storage
6517 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
6519 -- MAIN_STORAGE_OPTION ::=
6520 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
6521 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
6523 when Pragma_Main
=> Main
: declare
6524 Args
: Args_List
(1 .. 3);
6525 Names
: Name_List
(1 .. 3) := (
6527 Name_Task_Stack_Size_Default
,
6528 Name_Time_Slicing_Enabled
);
6534 Gather_Associations
(Names
, Args
);
6536 for J
in 1 .. 2 loop
6537 if Present
(Args
(J
)) then
6538 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
6542 if Present
(Args
(3)) then
6543 Check_Arg_Is_Static_Expression
(Args
(3), Standard_Boolean
);
6547 while Present
(Nod
) loop
6548 if Nkind
(Nod
) = N_Pragma
6549 and then Chars
(Nod
) = Name_Main
6551 Error_Msg_Name_1
:= Chars
(N
);
6552 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
6563 -- pragma Main_Storage
6564 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
6566 -- MAIN_STORAGE_OPTION ::=
6567 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
6568 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
6570 when Pragma_Main_Storage
=> Main_Storage
: declare
6571 Args
: Args_List
(1 .. 2);
6572 Names
: Name_List
(1 .. 2) := (
6573 Name_Working_Storage
,
6580 Gather_Associations
(Names
, Args
);
6582 for J
in 1 .. 2 loop
6583 if Present
(Args
(J
)) then
6584 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
6588 Check_In_Main_Program
;
6591 while Present
(Nod
) loop
6592 if Nkind
(Nod
) = N_Pragma
6593 and then Chars
(Nod
) = Name_Main_Storage
6595 Error_Msg_Name_1
:= Chars
(N
);
6596 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
6608 -- pragma Memory_Size (NUMERIC_LITERAL)
6610 when Pragma_Memory_Size
=>
6613 -- Memory size is simply ignored
6615 Check_No_Identifiers
;
6616 Check_Arg_Count
(1);
6617 Check_Arg_Is_Integer_Literal
(Arg1
);
6623 -- pragma No_Return (procedure_LOCAL_NAME);
6625 when Pragma_No_Return
=> declare
6632 Check_Arg_Count
(1);
6633 Check_No_Identifiers
;
6634 Check_Arg_Is_Local_Name
(Arg1
);
6635 Id
:= Expression
(Arg1
);
6638 if not Is_Entity_Name
(Id
) then
6639 Error_Pragma_Arg
("entity name required", Arg1
);
6642 if Etype
(Id
) = Any_Type
then
6650 and then Scope
(E
) = Current_Scope
6652 if Ekind
(E
) = E_Procedure
6653 or else Ekind
(E
) = E_Generic_Procedure
6663 Error_Pragma
("no procedures found for pragma%");
6671 -- pragma No_Run_Time
6673 when Pragma_No_Run_Time
=>
6675 Check_Valid_Configuration_Pragma
;
6676 Check_Arg_Count
(0);
6677 Set_No_Run_Time_Mode
;
6679 -----------------------
6680 -- Normalize_Scalars --
6681 -----------------------
6683 -- pragma Normalize_Scalars;
6685 when Pragma_Normalize_Scalars
=>
6686 Check_Ada_83_Warning
;
6687 Check_Arg_Count
(0);
6688 Check_Valid_Configuration_Pragma
;
6689 Normalize_Scalars
:= True;
6690 Init_Or_Norm_Scalars
:= True;
6696 -- pragma Optimize (Time | Space);
6698 -- The actual check for optimize is done in Gigi. Note that this
6699 -- pragma does not actually change the optimization setting, it
6700 -- simply checks that it is consistent with the pragma.
6702 when Pragma_Optimize
=>
6703 Check_No_Identifiers
;
6704 Check_Arg_Count
(1);
6705 Check_Arg_Is_One_Of
(Arg1
, Name_Time
, Name_Space
, Name_Off
);
6711 -- pragma Pack (first_subtype_LOCAL_NAME);
6713 when Pragma_Pack
=> Pack
: declare
6714 Assoc
: Node_Id
:= Arg1
;
6719 Check_No_Identifiers
;
6720 Check_Arg_Count
(1);
6721 Check_Arg_Is_Local_Name
(Arg1
);
6723 Type_Id
:= Expression
(Assoc
);
6724 Find_Type
(Type_Id
);
6725 Typ
:= Entity
(Type_Id
);
6728 or else Rep_Item_Too_Early
(Typ
, N
)
6732 Typ
:= Underlying_Type
(Typ
);
6735 if not Is_Array_Type
(Typ
) and then not Is_Record_Type
(Typ
) then
6736 Error_Pragma
("pragma% must specify array or record type");
6739 Check_First_Subtype
(Arg1
);
6741 if Has_Pragma_Pack
(Typ
) then
6742 Error_Pragma
("duplicate pragma%, only one allowed");
6744 -- Array type. We set the Has_Pragma_Pack flag, and Is_Packed,
6745 -- but not Has_Non_Standard_Rep, because we don't actually know
6746 -- till freeze time if the array can have packed representation.
6747 -- That's because in the general case we do not know enough about
6748 -- the component type until it in turn is frozen, which certainly
6749 -- happens before the array type is frozen, but not necessarily
6750 -- till that point (i.e. right now it may be unfrozen).
6752 elsif Is_Array_Type
(Typ
) then
6754 if Has_Aliased_Components
(Base_Type
(Typ
)) then
6756 ("pragma% ignored, cannot pack aliased components?");
6758 elsif Has_Atomic_Components
(Typ
) then
6760 ("?pragma% ignored, cannot pack atomic components");
6762 elsif not Rep_Item_Too_Late
(Typ
, N
) then
6763 Set_Is_Packed
(Base_Type
(Typ
));
6764 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
6765 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
6768 -- Record type. For record types, the pack is always effective
6770 else -- Is_Record_Type (Typ)
6771 if not Rep_Item_Too_Late
(Typ
, N
) then
6772 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
6773 Set_Is_Packed
(Base_Type
(Typ
));
6774 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
6785 -- There is nothing to do here, since we did all the processing
6786 -- for this pragma in Par.Prag (so that it works properly even in
6787 -- syntax only mode)
6796 -- pragma Passive [(PASSIVE_FORM)];
6798 -- PASSIVE_FORM ::= Semaphore | No
6800 when Pragma_Passive
=>
6803 if Nkind
(Parent
(N
)) /= N_Task_Definition
then
6804 Error_Pragma
("pragma% must be within task definition");
6807 if Arg_Count
/= 0 then
6808 Check_Arg_Count
(1);
6809 Check_Arg_Is_One_Of
(Arg1
, Name_Semaphore
, Name_No
);
6816 -- pragma Polling (ON | OFF);
6818 when Pragma_Polling
=>
6820 Check_Arg_Count
(1);
6821 Check_No_Identifiers
;
6822 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
6823 Polling_Required
:= (Chars
(Expression
(Arg1
)) = Name_On
);
6829 -- pragma Preelaborate [(library_unit_NAME)];
6831 -- Set the flag Is_Preelaborated of program unit name entity
6833 when Pragma_Preelaborate
=> Preelaborate
: declare
6835 Pa
: Node_Id
:= Parent
(N
);
6836 Pk
: Node_Kind
:= Nkind
(Pa
);
6839 Check_Ada_83_Warning
;
6840 Check_Valid_Library_Unit_Pragma
;
6842 if Nkind
(N
) = N_Null_Statement
then
6846 Ent
:= Find_Lib_Unit_Name
;
6848 -- This filters out pragmas inside generic parent then
6849 -- show up inside instantiation
6852 and then not (Pk
= N_Package_Specification
6853 and then Present
(Generic_Parent
(Pa
)))
6855 if not Debug_Flag_U
then
6856 Set_Is_Preelaborated
(Ent
);
6857 Set_Suppress_Elaboration_Warnings
(Ent
);
6866 -- pragma Priority (EXPRESSION);
6868 when Pragma_Priority
=> Priority
: declare
6869 P
: constant Node_Id
:= Parent
(N
);
6873 Check_No_Identifiers
;
6874 Check_Arg_Count
(1);
6876 Arg
:= Expression
(Arg1
);
6877 Analyze_And_Resolve
(Arg
, Standard_Integer
);
6879 if not Is_Static_Expression
(Arg
) then
6880 Check_Restriction
(Static_Priorities
, Arg
);
6885 if Nkind
(P
) = N_Subprogram_Body
then
6886 Check_In_Main_Program
;
6890 if not Is_Static_Expression
(Arg
) then
6892 ("main subprogram priority is not static", Arg1
);
6894 -- If constraint error, then we already signalled an error
6896 elsif Raises_Constraint_Error
(Arg
) then
6899 -- Otherwise check in range
6903 Val
: constant Uint
:= Expr_Value
(Arg
);
6907 or else Val
> Expr_Value
(Expression
6908 (Parent
(RTE
(RE_Max_Priority
))))
6911 ("main subprogram priority is out of range", Arg1
);
6917 (Current_Sem_Unit
, UI_To_Int
(Expr_Value
(Arg
)));
6919 -- Task or Protected, must be of type Integer
6921 elsif Nkind
(P
) = N_Protected_Definition
6923 Nkind
(P
) = N_Task_Definition
6925 if Expander_Active
then
6927 Convert_To
(RTE
(RE_Any_Priority
), Arg
));
6930 -- Anything else is incorrect
6936 if Has_Priority_Pragma
(P
) then
6937 Error_Pragma
("duplicate pragma% not allowed");
6939 Set_Has_Priority_Pragma
(P
, True);
6941 if Nkind
(P
) = N_Protected_Definition
6943 Nkind
(P
) = N_Task_Definition
6945 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
6946 -- exp_ch9 should use this ???
6952 --------------------------
6953 -- Propagate_Exceptions --
6954 --------------------------
6956 -- pragma Propagate_Exceptions;
6958 when Pragma_Propagate_Exceptions
=>
6960 Check_Arg_Count
(0);
6962 if In_Extended_Main_Source_Unit
(N
) then
6963 Propagate_Exceptions
:= True;
6970 -- pragma Psect_Object (
6971 -- [Internal =>] LOCAL_NAME,
6972 -- [, [External =>] EXTERNAL_SYMBOL]
6973 -- [, [Size =>] EXTERNAL_SYMBOL]);
6975 when Pragma_Psect_Object | Pragma_Common_Object
=>
6976 Psect_Object
: declare
6977 Args
: Args_List
(1 .. 3);
6978 Names
: Name_List
(1 .. 3) := (
6983 Internal
: Node_Id
renames Args
(1);
6984 External
: Node_Id
renames Args
(2);
6985 Size
: Node_Id
renames Args
(3);
6987 R_Internal
: Node_Id
;
6988 R_External
: Node_Id
;
6995 procedure Check_Too_Long
(Arg
: Node_Id
);
6996 -- Posts message if the argument is an identifier with more
6997 -- than 31 characters, or a string literal with more than
6998 -- 31 characters, and we are operating under VMS
7000 procedure Check_Too_Long
(Arg
: Node_Id
) is
7001 X
: Node_Id
:= Original_Node
(Arg
);
7004 if Nkind
(X
) /= N_String_Literal
7006 Nkind
(X
) /= N_Identifier
7009 ("inappropriate argument for pragma %", Arg
);
7012 if OpenVMS_On_Target
then
7013 if (Nkind
(X
) = N_String_Literal
7014 and then String_Length
(Strval
(X
)) > 31)
7016 (Nkind
(X
) = N_Identifier
7017 and then Length_Of_Name
(Chars
(X
)) > 31)
7020 ("argument for pragma % is longer than 31 characters",
7026 -- Start of processing for Common_Object/Psect_Object
7030 Gather_Associations
(Names
, Args
);
7031 Process_Extended_Import_Export_Internal_Arg
(Internal
);
7033 R_Internal
:= Relocate_Node
(Internal
);
7035 Def_Id
:= Entity
(R_Internal
);
7037 if Ekind
(Def_Id
) /= E_Constant
7038 and then Ekind
(Def_Id
) /= E_Variable
7041 ("pragma% must designate an object", Internal
);
7044 Check_Too_Long
(R_Internal
);
7046 if Is_Imported
(Def_Id
) or else Is_Exported
(Def_Id
) then
7048 ("cannot use pragma% for imported/exported object",
7052 if Is_Concurrent_Type
(Etype
(R_Internal
)) then
7054 ("cannot specify pragma % for task/protected object",
7058 if Is_Psected
(Def_Id
) then
7059 Error_Msg_N
("?duplicate Psect_Object pragma", N
);
7061 Set_Is_Psected
(Def_Id
);
7064 if Ekind
(Def_Id
) = E_Constant
then
7066 ("cannot specify pragma % for a constant", R_Internal
);
7069 if Is_Record_Type
(Etype
(R_Internal
)) then
7075 Ent
:= First_Entity
(Etype
(R_Internal
));
7076 while Present
(Ent
) loop
7077 Decl
:= Declaration_Node
(Ent
);
7079 if Ekind
(Ent
) = E_Component
7080 and then Nkind
(Decl
) = N_Component_Declaration
7081 and then Present
(Expression
(Decl
))
7084 ("?object for pragma % has defaults", R_Internal
);
7094 if Present
(Size
) then
7095 Check_Too_Long
(Size
);
7098 -- Make Psect case-insensitive.
7100 if Present
(External
) then
7101 Check_Too_Long
(External
);
7103 if Nkind
(External
) = N_String_Literal
then
7104 String_To_Name_Buffer
(Strval
(External
));
7106 Get_Name_String
(Chars
(External
));
7111 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
7113 R_External
:= Make_String_Literal
7114 (Sloc
=> Sloc
(External
), Strval
=> Str
);
7116 Get_Name_String
(Chars
(Internal
));
7119 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
7121 R_External
:= Make_String_Literal
7122 (Sloc
=> Sloc
(Internal
), Strval
=> Str
);
7125 -- Transform into pragma Linker_Section, add attributes to
7126 -- match what DEC Ada does. Ignore size for now?
7131 Name_Linker_Section
,
7133 (Make_Pragma_Argument_Association
7134 (Sloc
=> Sloc
(R_Internal
),
7135 Expression
=> R_Internal
),
7136 Make_Pragma_Argument_Association
7137 (Sloc
=> Sloc
(R_External
),
7138 Expression
=> R_External
))));
7142 -- Add Machine_Attribute of "overlaid", so the section overlays
7143 -- other sections of the same name.
7146 Store_String_Chars
("overlaid");
7152 Name_Machine_Attribute
,
7154 (Make_Pragma_Argument_Association
7155 (Sloc
=> Sloc
(R_Internal
),
7156 Expression
=> R_Internal
),
7157 Make_Pragma_Argument_Association
7158 (Sloc
=> Sloc
(R_External
),
7161 (Sloc
=> Sloc
(R_External
),
7165 -- Add Machine_Attribute of "global", so the section is visible
7169 Store_String_Chars
("global");
7175 Name_Machine_Attribute
,
7177 (Make_Pragma_Argument_Association
7178 (Sloc
=> Sloc
(R_Internal
),
7179 Expression
=> R_Internal
),
7180 Make_Pragma_Argument_Association
7181 (Sloc
=> Sloc
(R_External
),
7184 (Sloc
=> Sloc
(R_External
),
7188 -- Add Machine_Attribute of "initialize", so the section is
7192 Store_String_Chars
("initialize");
7198 Name_Machine_Attribute
,
7200 (Make_Pragma_Argument_Association
7201 (Sloc
=> Sloc
(R_Internal
),
7202 Expression
=> R_Internal
),
7203 Make_Pragma_Argument_Association
7204 (Sloc
=> Sloc
(R_External
),
7207 (Sloc
=> Sloc
(R_External
),
7217 -- pragma Pure [(library_unit_NAME)];
7219 when Pragma_Pure
=> Pure
: declare
7222 Check_Ada_83_Warning
;
7223 Check_Valid_Library_Unit_Pragma
;
7225 if Nkind
(N
) = N_Null_Statement
then
7229 Ent
:= Find_Lib_Unit_Name
;
7231 Set_Suppress_Elaboration_Warnings
(Ent
);
7238 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
7240 when Pragma_Pure_Function
=> Pure_Function
: declare
7247 Check_Arg_Count
(1);
7248 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7249 Check_Arg_Is_Local_Name
(Arg1
);
7250 E_Id
:= Expression
(Arg1
);
7252 if Error_Posted
(E_Id
) then
7256 -- Loop through homonyms (overloadings) of referenced entity
7259 while Present
(E
) loop
7260 Def_Id
:= Get_Base_Subprogram
(E
);
7262 if Ekind
(Def_Id
) /= E_Function
7263 and then Ekind
(Def_Id
) /= E_Generic_Function
7264 and then Ekind
(Def_Id
) /= E_Operator
7266 Error_Pragma_Arg
("pragma% requires a function name", Arg1
);
7269 Set_Is_Pure
(Def_Id
);
7274 --------------------
7275 -- Queuing_Policy --
7276 --------------------
7278 -- pragma Queuing_Policy (policy_IDENTIFIER);
7280 when Pragma_Queuing_Policy
=> declare
7284 Check_Ada_83_Warning
;
7285 Check_Arg_Count
(1);
7286 Check_No_Identifiers
;
7287 Check_Arg_Is_Queuing_Policy
(Arg1
);
7288 Check_Valid_Configuration_Pragma
;
7289 Get_Name_String
(Chars
(Expression
(Arg1
)));
7290 QP
:= Fold_Upper
(Name_Buffer
(1));
7292 if Queuing_Policy
/= ' '
7293 and then Queuing_Policy
/= QP
7295 Error_Msg_Sloc
:= Queuing_Policy_Sloc
;
7296 Error_Pragma
("queuing policy incompatible with policy#");
7298 Queuing_Policy
:= QP
;
7299 Queuing_Policy_Sloc
:= Loc
;
7303 ---------------------------
7304 -- Remote_Call_Interface --
7305 ---------------------------
7307 -- pragma Remote_Call_Interface [(library_unit_NAME)];
7309 when Pragma_Remote_Call_Interface
=> Remote_Call_Interface
: declare
7310 Cunit_Node
: Node_Id
;
7311 Cunit_Ent
: Entity_Id
;
7315 Check_Ada_83_Warning
;
7316 Check_Valid_Library_Unit_Pragma
;
7318 if Nkind
(N
) = N_Null_Statement
then
7322 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
7323 K
:= Nkind
(Unit
(Cunit_Node
));
7324 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
7326 if K
= N_Package_Declaration
7327 or else K
= N_Generic_Package_Declaration
7328 or else K
= N_Subprogram_Declaration
7329 or else K
= N_Generic_Subprogram_Declaration
7330 or else (K
= N_Subprogram_Body
7331 and then Acts_As_Spec
(Unit
(Cunit_Node
)))
7336 "pragma% must apply to package or subprogram declaration");
7339 Set_Is_Remote_Call_Interface
(Cunit_Ent
);
7340 end Remote_Call_Interface
;
7346 -- pragma Remote_Types [(library_unit_NAME)];
7348 when Pragma_Remote_Types
=> Remote_Types
: declare
7349 Cunit_Node
: Node_Id
;
7350 Cunit_Ent
: Entity_Id
;
7353 Check_Ada_83_Warning
;
7354 Check_Valid_Library_Unit_Pragma
;
7356 if Nkind
(N
) = N_Null_Statement
then
7360 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
7361 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
7363 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
7365 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
7368 "pragma% can only apply to a package declaration");
7371 Set_Is_Remote_Types
(Cunit_Ent
);
7378 when Pragma_Ravenscar
=>
7380 Check_Arg_Count
(0);
7381 Check_Valid_Configuration_Pragma
;
7384 -------------------------
7385 -- Restricted_Run_Time --
7386 -------------------------
7388 when Pragma_Restricted_Run_Time
=>
7390 Check_Arg_Count
(0);
7391 Check_Valid_Configuration_Pragma
;
7392 Set_Restricted_Profile
;
7398 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
7401 -- restriction_IDENTIFIER
7402 -- | restriction_parameter_IDENTIFIER => EXPRESSION
7404 when Pragma_Restrictions
=> Restrictions_Pragma
: declare
7406 R_Id
: Restriction_Id
;
7407 RP_Id
: Restriction_Parameter_Id
;
7413 Check_Ada_83_Warning
;
7414 Check_At_Least_N_Arguments
(1);
7415 Check_Valid_Configuration_Pragma
;
7419 while Present
(Arg
) loop
7421 Expr
:= Expression
(Arg
);
7423 -- Case of no restriction identifier
7425 if Id
= No_Name
then
7426 if Nkind
(Expr
) /= N_Identifier
then
7428 ("invalid form for restriction", Arg
);
7431 R_Id
:= Get_Restriction_Id
(Chars
(Expr
));
7433 if R_Id
= Not_A_Restriction_Id
then
7435 ("invalid restriction identifier", Arg
);
7437 -- Restriction is active
7440 Restrictions
(R_Id
) := True;
7441 Restrictions_Loc
(R_Id
) := Sloc
(N
);
7443 -- Record the restriction if we are in the main unit,
7444 -- or in the extended main unit. The reason that we
7445 -- test separately for Main_Unit is that gnat.adc is
7446 -- processed with Current_Sem_Unit = Main_Unit, but
7447 -- nodes in gnat.adc do not appear to be the extended
7448 -- main source unit (they probably should do ???)
7450 if Current_Sem_Unit
= Main_Unit
7451 or else In_Extended_Main_Source_Unit
(N
)
7453 Main_Restrictions
(R_Id
) := True;
7456 -- A very special case that must be processed here:
7457 -- pragma Restrictions (No_Exceptions) turns off all
7458 -- run-time checking. This is a bit dubious in terms
7459 -- of the formal language definition, but it is what
7460 -- is intended by the wording of RM H.4(12).
7462 if R_Id
= No_Exceptions
then
7463 Scope_Suppress
:= (others => True);
7468 -- Case of restriction identifier present
7471 RP_Id
:= Get_Restriction_Parameter_Id
(Id
);
7472 Analyze_And_Resolve
(Expr
, Any_Integer
);
7474 if RP_Id
= Not_A_Restriction_Parameter_Id
then
7476 ("invalid restriction parameter identifier", Arg
);
7478 elsif not Is_OK_Static_Expression
(Expr
)
7479 or else not Is_Integer_Type
(Etype
(Expr
))
7480 or else Expr_Value
(Expr
) < 0
7483 ("value must be non-negative static integer", Arg
);
7485 -- Restriction pragma is active
7488 Val
:= Expr_Value
(Expr
);
7490 -- Record pragma if most restrictive so far
7492 if Restriction_Parameters
(RP_Id
) = No_Uint
7493 or else Val
< Restriction_Parameters
(RP_Id
)
7495 Restriction_Parameters
(RP_Id
) := Expr_Value
(Expr
);
7496 Restriction_Parameters_Loc
(RP_Id
) := Sloc
(N
);
7503 end Restrictions_Pragma
;
7509 -- pragma Reviewable;
7511 when Pragma_Reviewable
=>
7512 Check_Ada_83_Warning
;
7513 Check_Arg_Count
(0);
7519 -- pragma Share_Generic (NAME {, NAME});
7521 when Pragma_Share_Generic
=>
7523 Process_Generic_List
;
7529 -- pragma Shared (LOCAL_NAME);
7531 when Pragma_Shared
=>
7532 Process_Atomic_Shared_Volatile
;
7534 --------------------
7535 -- Shared_Passive --
7536 --------------------
7538 -- pragma Shared_Passive [(library_unit_NAME)];
7540 -- Set the flag Is_Shared_Passive of program unit name entity
7542 when Pragma_Shared_Passive
=> Shared_Passive
: declare
7543 Cunit_Node
: Node_Id
;
7544 Cunit_Ent
: Entity_Id
;
7547 Check_Ada_83_Warning
;
7548 Check_Valid_Library_Unit_Pragma
;
7550 if Nkind
(N
) = N_Null_Statement
then
7554 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
7555 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
7557 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
7559 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
7562 "pragma% can only apply to a package declaration");
7565 Set_Is_Shared_Passive
(Cunit_Ent
);
7568 ----------------------
7569 -- Source_File_Name --
7570 ----------------------
7572 -- pragma Source_File_Name (
7573 -- [UNIT_NAME =>] unit_NAME,
7574 -- [BODY_FILE_NAME | SPEC_FILE_NAME] => STRING_LITERAL);
7576 -- No processing here. Processing was completed during parsing,
7577 -- since we need to have file names set as early as possible.
7578 -- Units are loaded well before semantic processing starts.
7580 -- The only processing we defer to this point is the check
7581 -- for correct placement.
7583 when Pragma_Source_File_Name
=>
7585 Check_Valid_Configuration_Pragma
;
7587 ----------------------
7588 -- Source_Reference --
7589 ----------------------
7591 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
7593 -- Nothing to do, all processing completed in Par.Prag, since we
7594 -- need the information for possible parser messages that are output
7596 when Pragma_Source_Reference
=>
7603 -- pragma Storage_Size (EXPRESSION);
7605 when Pragma_Storage_Size
=> Storage_Size
: declare
7606 P
: constant Node_Id
:= Parent
(N
);
7610 Check_No_Identifiers
;
7611 Check_Arg_Count
(1);
7613 -- Set In_Default_Expression for per-object case???
7615 X
:= Expression
(Arg1
);
7616 Analyze_And_Resolve
(X
, Any_Integer
);
7618 if not Is_Static_Expression
(X
) then
7619 Check_Restriction
(Static_Storage_Size
, X
);
7622 if Nkind
(P
) /= N_Task_Definition
then
7627 if Has_Storage_Size_Pragma
(P
) then
7628 Error_Pragma
("duplicate pragma% not allowed");
7630 Set_Has_Storage_Size_Pragma
(P
, True);
7633 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
7634 -- ??? exp_ch9 should use this!
7642 -- pragma Storage_Unit (NUMERIC_LITERAL);
7644 -- Only permitted argument is System'Storage_Unit value
7646 when Pragma_Storage_Unit
=>
7647 Check_No_Identifiers
;
7648 Check_Arg_Count
(1);
7649 Check_Arg_Is_Integer_Literal
(Arg1
);
7651 if Intval
(Expression
(Arg1
)) /=
7652 UI_From_Int
(Ttypes
.System_Storage_Unit
)
7654 Error_Msg_Uint_1
:= UI_From_Int
(Ttypes
.System_Storage_Unit
);
7656 ("the only allowed argument for pragma% is ^", Arg1
);
7659 --------------------
7660 -- Stream_Convert --
7661 --------------------
7663 -- pragma Stream_Convert (
7664 -- [Entity =>] type_LOCAL_NAME,
7665 -- [Read =>] function_NAME,
7666 -- [Write =>] function NAME);
7668 when Pragma_Stream_Convert
=> Stream_Convert
: begin
7670 Check_Arg_Count
(3);
7671 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7672 Check_Optional_Identifier
(Arg2
, Name_Read
);
7673 Check_Optional_Identifier
(Arg3
, Name_Write
);
7674 Check_Arg_Is_Local_Name
(Arg1
);
7675 Check_Non_Overloaded_Function
(Arg2
);
7676 Check_Non_Overloaded_Function
(Arg3
);
7679 Typ
: constant Entity_Id
:=
7680 Underlying_Type
(Entity
(Expression
(Arg1
)));
7681 Read
: constant Entity_Id
:= Entity
(Expression
(Arg2
));
7682 Write
: constant Entity_Id
:= Entity
(Expression
(Arg3
));
7685 if Etype
(Typ
) = Any_Type
7687 Etype
(Read
) = Any_Type
7689 Etype
(Write
) = Any_Type
7694 Check_First_Subtype
(Arg1
);
7696 if Rep_Item_Too_Early
(Typ
, N
)
7698 Rep_Item_Too_Late
(Typ
, N
)
7703 if Underlying_Type
(Etype
(Read
)) /= Typ
then
7705 ("incorrect return type for function&", Arg2
);
7708 if Underlying_Type
(Etype
(First_Formal
(Write
))) /= Typ
then
7710 ("incorrect parameter type for function&", Arg3
);
7713 if Underlying_Type
(Etype
(First_Formal
(Read
))) /=
7714 Underlying_Type
(Etype
(Write
))
7717 ("result type of & does not match Read parameter type",
7723 -------------------------
7724 -- Style_Checks (GNAT) --
7725 -------------------------
7727 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
7729 -- This is processed by the parser since some of the style
7730 -- checks take place during source scanning and parsing. This
7731 -- means that we don't need to issue error messages here.
7733 when Pragma_Style_Checks
=> Style_Checks
: declare
7734 A
: constant Node_Id
:= Expression
(Arg1
);
7740 Check_No_Identifiers
;
7742 -- Two argument form
7744 if Arg_Count
= 2 then
7745 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
7752 E_Id
:= Expression
(Arg2
);
7755 if not Is_Entity_Name
(E_Id
) then
7757 ("second argument of pragma% must be entity name",
7767 Set_Suppress_Style_Checks
(E
,
7768 (Chars
(Expression
(Arg1
)) = Name_Off
));
7769 exit when No
(Homonym
(E
));
7775 -- One argument form
7778 Check_Arg_Count
(1);
7780 if Nkind
(A
) = N_String_Literal
then
7784 Slen
: Natural := Natural (String_Length
(S
));
7785 Options
: String (1 .. Slen
);
7791 C
:= Get_String_Char
(S
, Int
(J
));
7792 exit when not In_Character_Range
(C
);
7793 Options
(J
) := Get_Character
(C
);
7796 Set_Style_Check_Options
(Options
);
7804 elsif Nkind
(A
) = N_Identifier
then
7806 if Chars
(A
) = Name_All_Checks
then
7807 Set_Default_Style_Check_Options
;
7809 elsif Chars
(A
) = Name_On
then
7810 Style_Check
:= True;
7812 elsif Chars
(A
) = Name_Off
then
7813 Style_Check
:= False;
7824 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
7826 when Pragma_Subtitle
=>
7828 Check_Arg_Count
(1);
7829 Check_Optional_Identifier
(Arg1
, Name_Subtitle
);
7830 Check_Arg_Is_String_Literal
(Arg1
);
7836 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
7838 when Pragma_Suppress
=>
7839 Process_Suppress_Unsuppress
(True);
7845 -- pragma Suppress_All;
7847 -- The only check made here is that the pragma appears in the
7848 -- proper place, i.e. following a compilation unit. If indeed
7849 -- it appears in this context, then the parser has already
7850 -- inserted an equivalent pragma Suppress (All_Checks) to get
7851 -- the required effect.
7853 when Pragma_Suppress_All
=>
7855 Check_Arg_Count
(0);
7857 if Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
7858 or else not Is_List_Member
(N
)
7859 or else List_Containing
(N
) /= Pragmas_After
(Parent
(N
))
7862 ("misplaced pragma%, must follow compilation unit");
7865 -------------------------
7866 -- Suppress_Debug_Info --
7867 -------------------------
7869 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
7871 when Pragma_Suppress_Debug_Info
=>
7873 Check_Arg_Count
(1);
7874 Check_Arg_Is_Local_Name
(Arg1
);
7875 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7876 Set_Debug_Info_Off
(Entity
(Get_Pragma_Arg
(Arg1
)));
7878 -----------------------------
7879 -- Suppress_Initialization --
7880 -----------------------------
7882 -- pragma Suppress_Initialization ([Entity =>] type_Name);
7884 when Pragma_Suppress_Initialization
=> Suppress_Init
: declare
7890 Check_Arg_Count
(1);
7891 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7892 Check_Arg_Is_Local_Name
(Arg1
);
7894 E_Id
:= Expression
(Arg1
);
7896 if Etype
(E_Id
) = Any_Type
then
7903 if Is_Incomplete_Or_Private_Type
(E
) then
7904 if No
(Full_View
(Base_Type
(E
))) then
7906 ("argument of pragma% cannot be an incomplete type",
7909 Set_Suppress_Init_Proc
(Full_View
(Base_Type
(E
)));
7912 Set_Suppress_Init_Proc
(Base_Type
(E
));
7917 ("pragma% requires argument that is a type name", Arg1
);
7925 -- pragma System_Name (DIRECT_NAME);
7927 -- Syntax check: one argument, which must be the identifier GNAT
7928 -- or the identifier GCC, no other identifiers are acceptable.
7930 when Pragma_System_Name
=>
7931 Check_No_Identifiers
;
7932 Check_Arg_Count
(1);
7933 Check_Arg_Is_One_Of
(Arg1
, Name_Gcc
, Name_Gnat
);
7935 -----------------------------
7936 -- Task_Dispatching_Policy --
7937 -----------------------------
7939 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
7941 when Pragma_Task_Dispatching_Policy
=> declare
7945 Check_Ada_83_Warning
;
7946 Check_Arg_Count
(1);
7947 Check_No_Identifiers
;
7948 Check_Arg_Is_Task_Dispatching_Policy
(Arg1
);
7949 Check_Valid_Configuration_Pragma
;
7950 Get_Name_String
(Chars
(Expression
(Arg1
)));
7951 DP
:= Fold_Upper
(Name_Buffer
(1));
7953 if Task_Dispatching_Policy
/= ' '
7954 and then Task_Dispatching_Policy
/= DP
7956 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
7958 ("task dispatching policy incompatible with policy#");
7960 Task_Dispatching_Policy
:= DP
;
7961 Task_Dispatching_Policy_Sloc
:= Loc
;
7969 -- pragma Task_Info (EXPRESSION);
7971 when Pragma_Task_Info
=> Task_Info
: declare
7972 P
: constant Node_Id
:= Parent
(N
);
7977 if Nkind
(P
) /= N_Task_Definition
then
7978 Error_Pragma
("pragma% must appear in task definition");
7981 Check_No_Identifiers
;
7982 Check_Arg_Count
(1);
7984 Analyze_And_Resolve
(Expression
(Arg1
), RTE
(RE_Task_Info_Type
));
7986 if Etype
(Expression
(Arg1
)) = Any_Type
then
7990 if Has_Task_Info_Pragma
(P
) then
7991 Error_Pragma
("duplicate pragma% not allowed");
7993 Set_Has_Task_Info_Pragma
(P
, True);
8002 -- pragma Task_Name (string_EXPRESSION);
8004 when Pragma_Task_Name
=> Task_Name
: declare
8005 -- pragma Priority (EXPRESSION);
8007 P
: constant Node_Id
:= Parent
(N
);
8011 Check_No_Identifiers
;
8012 Check_Arg_Count
(1);
8014 Arg
:= Expression
(Arg1
);
8015 Analyze_And_Resolve
(Arg
, Standard_String
);
8017 if Nkind
(P
) /= N_Task_Definition
then
8021 if Has_Task_Name_Pragma
(P
) then
8022 Error_Pragma
("duplicate pragma% not allowed");
8024 Set_Has_Task_Name_Pragma
(P
, True);
8025 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
8034 -- pragma Task_Storage (
8035 -- [Task_Type =>] LOCAL_NAME,
8036 -- [Top_Guard =>] static_integer_EXPRESSION);
8038 when Pragma_Task_Storage
=> Task_Storage
: declare
8039 Args
: Args_List
(1 .. 2);
8040 Names
: Name_List
(1 .. 2) := (
8044 Task_Type
: Node_Id
renames Args
(1);
8045 Top_Guard
: Node_Id
renames Args
(2);
8051 Gather_Associations
(Names
, Args
);
8052 Check_Arg_Is_Local_Name
(Task_Type
);
8054 Ent
:= Entity
(Task_Type
);
8056 if not Is_Task_Type
(Ent
) then
8058 ("argument for pragma% must be task type", Task_Type
);
8061 if No
(Top_Guard
) then
8063 ("pragma% takes two arguments", Task_Type
);
8065 Check_Arg_Is_Static_Expression
(Top_Guard
, Any_Integer
);
8068 Check_First_Subtype
(Task_Type
);
8070 if Rep_Item_Too_Late
(Ent
, N
) then
8080 -- pragma Time_Slice (static_duration_EXPRESSION);
8082 when Pragma_Time_Slice
=> Time_Slice
: declare
8088 Check_Arg_Count
(1);
8089 Check_No_Identifiers
;
8090 Check_In_Main_Program
;
8091 Check_Arg_Is_Static_Expression
(Arg1
, Standard_Duration
);
8093 if not Error_Posted
(Arg1
) then
8095 while Present
(Nod
) loop
8096 if Nkind
(Nod
) = N_Pragma
8097 and then Chars
(Nod
) = Name_Time_Slice
8099 Error_Msg_Name_1
:= Chars
(N
);
8100 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
8107 -- Process only if in main unit
8109 if Get_Source_Unit
(Loc
) = Main_Unit
then
8110 Opt
.Time_Slice_Set
:= True;
8111 Val
:= Expr_Value_R
(Expression
(Arg1
));
8113 if Val
<= Ureal_0
then
8114 Opt
.Time_Slice_Value
:= 0;
8116 elsif Val
> UR_From_Uint
(UI_From_Int
(1000)) then
8117 Opt
.Time_Slice_Value
:= 1_000_000_000
;
8120 Opt
.Time_Slice_Value
:=
8121 UI_To_Int
(UR_To_Uint
(Val
* UI_From_Int
(1_000_000
)));
8130 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
8132 -- TITLING_OPTION ::=
8133 -- [Title =>] STRING_LITERAL
8134 -- | [Subtitle =>] STRING_LITERAL
8136 when Pragma_Title
=> Title
: declare
8137 Args
: Args_List
(1 .. 2);
8138 Names
: Name_List
(1 .. 2) := (
8144 Gather_Associations
(Names
, Args
);
8146 for J
in 1 .. 2 loop
8147 if Present
(Args
(J
)) then
8148 Check_Arg_Is_String_Literal
(Args
(J
));
8153 ---------------------
8154 -- Unchecked_Union --
8155 ---------------------
8157 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
8159 when Pragma_Unchecked_Union
=> Unchecked_Union
: declare
8160 Assoc
: Node_Id
:= Arg1
;
8161 Type_Id
: Node_Id
:= Expression
(Assoc
);
8172 Check_No_Identifiers
;
8173 Check_Arg_Count
(1);
8174 Check_Arg_Is_Local_Name
(Arg1
);
8176 Find_Type
(Type_Id
);
8177 Typ
:= Entity
(Type_Id
);
8180 or else Rep_Item_Too_Early
(Typ
, N
)
8184 Typ
:= Underlying_Type
(Typ
);
8187 if Rep_Item_Too_Late
(Typ
, N
) then
8191 Check_First_Subtype
(Arg1
);
8193 -- Note remaining cases are references to a type in the current
8194 -- declarative part. If we find an error, we post the error on
8195 -- the relevant type declaration at an appropriate point.
8197 if not Is_Record_Type
(Typ
) then
8198 Error_Msg_N
("Unchecked_Union must be record type", Typ
);
8201 elsif Is_Tagged_Type
(Typ
) then
8202 Error_Msg_N
("Unchecked_Union must not be tagged", Typ
);
8205 elsif Is_Limited_Type
(Typ
) then
8207 ("Unchecked_Union must not be limited record type", Typ
);
8211 if not Has_Discriminants
(Typ
) then
8213 ("Unchecked_Union must have one discriminant", Typ
);
8217 Discr
:= First_Discriminant
(Typ
);
8219 if Present
(Next_Discriminant
(Discr
)) then
8221 ("Unchecked_Union must have exactly one discriminant",
8222 Next_Discriminant
(Discr
));
8226 if No
(Discriminant_Default_Value
(Discr
)) then
8228 ("Unchecked_Union discriminant must have default value",
8232 Tdef
:= Type_Definition
(Declaration_Node
(Typ
));
8233 Clist
:= Component_List
(Tdef
);
8235 if No
(Clist
) or else No
(Variant_Part
(Clist
)) then
8237 ("Unchecked_Union must have variant part",
8242 Vpart
:= Variant_Part
(Clist
);
8244 if Is_Non_Empty_List
(Component_Items
(Clist
)) then
8246 ("components before variant not allowed " &
8247 "in Unchecked_Union",
8248 First
(Component_Items
(Clist
)));
8251 Variant
:= First
(Variants
(Vpart
));
8252 while Present
(Variant
) loop
8253 Clist
:= Component_List
(Variant
);
8255 if Present
(Variant_Part
(Clist
)) then
8257 ("Unchecked_Union may not have nested variants",
8258 Variant_Part
(Clist
));
8261 if not Is_Non_Empty_List
(Component_Items
(Clist
)) then
8263 ("Unchecked_Union may not have empty component list",
8268 Comp
:= First
(Component_Items
(Clist
));
8270 if Nkind
(Comp
) = N_Component_Declaration
then
8272 if Present
(Expression
(Comp
)) then
8274 ("default initialization not allowed " &
8275 "in Unchecked_Union",
8280 Sindic
: constant Node_Id
:=
8281 Subtype_Indication
(Comp
);
8284 if Nkind
(Sindic
) = N_Subtype_Indication
then
8285 Check_Static_Constraint
(Constraint
(Sindic
));
8290 if Present
(Next
(Comp
)) then
8292 ("Unchecked_Union variant can have only one component",
8300 Set_Is_Unchecked_Union
(Typ
, True);
8301 Set_Suppress_Discriminant_Checks
(Typ
, True);
8302 Set_Convention
(Typ
, Convention_C
);
8304 Set_Has_Unchecked_Union
(Base_Type
(Typ
), True);
8305 Set_Is_Unchecked_Union
(Base_Type
(Typ
), True);
8307 end Unchecked_Union
;
8309 ------------------------
8310 -- Unimplemented_Unit --
8311 ------------------------
8313 -- pragma Unimplemented_Unit;
8315 -- Note: this only gives an error if we are generating code,
8316 -- or if we are in a generic library unit (where the pragma
8317 -- appears in the body, not in the spec).
8319 when Pragma_Unimplemented_Unit
=> Unimplemented_Unit
: declare
8320 Cunitent
: Entity_Id
:= Cunit_Entity
(Get_Source_Unit
(Loc
));
8321 Ent_Kind
: Entity_Kind
:= Ekind
(Cunitent
);
8325 Check_Arg_Count
(0);
8327 if Operating_Mode
= Generate_Code
8328 or else Ent_Kind
= E_Generic_Function
8329 or else Ent_Kind
= E_Generic_Procedure
8330 or else Ent_Kind
= E_Generic_Package
8332 Get_Name_String
(Chars
(Cunitent
));
8333 Set_Casing
(Mixed_Case
);
8334 Write_Str
(Name_Buffer
(1 .. Name_Len
));
8335 Write_Str
(" is not implemented");
8337 raise Unrecoverable_Error
;
8339 end Unimplemented_Unit
;
8341 ------------------------------
8342 -- Unreserve_All_Interrupts --
8343 ------------------------------
8345 -- pragma Unreserve_All_Interrupts;
8347 when Pragma_Unreserve_All_Interrupts
=>
8349 Check_Arg_Count
(0);
8351 if In_Extended_Main_Code_Unit
(Main_Unit_Entity
) then
8352 Unreserve_All_Interrupts
:= True;
8359 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
8361 when Pragma_Unsuppress
=>
8363 Process_Suppress_Unsuppress
(False);
8369 -- pragma Use_VADS_Size;
8371 when Pragma_Use_VADS_Size
=>
8373 Check_Arg_Count
(0);
8374 Check_Valid_Configuration_Pragma
;
8375 Use_VADS_Size
:= True;
8377 ---------------------
8378 -- Validity_Checks --
8379 ---------------------
8381 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
8383 when Pragma_Validity_Checks
=> Validity_Checks
: declare
8384 A
: constant Node_Id
:= Expression
(Arg1
);
8390 Check_Arg_Count
(1);
8391 Check_Valid_Configuration_Pragma
;
8392 Check_No_Identifiers
;
8394 if Nkind
(A
) = N_String_Literal
then
8398 Slen
: Natural := Natural (String_Length
(S
));
8399 Options
: String (1 .. Slen
);
8405 C
:= Get_String_Char
(S
, Int
(J
));
8406 exit when not In_Character_Range
(C
);
8407 Options
(J
) := Get_Character
(C
);
8410 Set_Validity_Check_Options
(Options
);
8418 elsif Nkind
(A
) = N_Identifier
then
8420 if Chars
(A
) = Name_All_Checks
then
8421 Set_Validity_Check_Options
("a");
8423 elsif Chars
(A
) = Name_On
then
8424 Validity_Checks_On
:= True;
8426 elsif Chars
(A
) = Name_Off
then
8427 Validity_Checks_On
:= False;
8431 end Validity_Checks
;
8437 -- pragma Volatile (LOCAL_NAME);
8439 when Pragma_Volatile
=>
8440 Process_Atomic_Shared_Volatile
;
8442 -------------------------
8443 -- Volatile_Components --
8444 -------------------------
8446 -- pragma Volatile_Components (array_LOCAL_NAME);
8448 -- Volatile is handled by the same circuit as Atomic_Components
8454 -- pragma Warnings (On | Off, [LOCAL_NAME])
8456 when Pragma_Warnings
=>
8458 Check_At_Least_N_Arguments
(1);
8459 Check_At_Most_N_Arguments
(2);
8460 Check_No_Identifiers
;
8462 -- One argument case was processed by parser in Par.Prag
8464 if Arg_Count
/= 1 then
8465 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
8466 Check_Arg_Count
(2);
8473 E_Id
:= Expression
(Arg2
);
8476 if not Is_Entity_Name
(E_Id
) then
8478 ("second argument of pragma% must be entity name",
8488 Set_Warnings_Off
(E
,
8489 (Chars
(Expression
(Arg1
)) = Name_Off
));
8491 if Is_Enumeration_Type
(E
) then
8493 Lit
: Entity_Id
:= First_Literal
(E
);
8496 while Present
(Lit
) loop
8497 Set_Warnings_Off
(Lit
);
8503 exit when No
(Homonym
(E
));
8514 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
8516 when Pragma_Weak_External
=> Weak_External
: declare
8521 Check_Arg_Count
(1);
8522 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8523 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
8524 Ent
:= Entity
(Expression
(Arg1
));
8526 if Rep_Item_Too_Early
(Ent
, N
) then
8529 Ent
:= Underlying_Type
(Ent
);
8532 -- The only processing required is to link this item on to the
8533 -- list of rep items for the given entity. This is accomplished
8534 -- by the call to Rep_Item_Too_Late (when no error is detected
8535 -- and False is returned).
8537 if Rep_Item_Too_Late
(Ent
, N
) then
8540 Set_Has_Gigi_Rep_Item
(Ent
);
8547 when Pragma_Exit
=> null;
8551 -------------------------
8552 -- Get_Base_Subprogram --
8553 -------------------------
8555 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
is
8561 -- Follow subprogram renaming chain
8563 while Is_Subprogram
(Result
)
8565 (Is_Generic_Instance
(Result
)
8566 or else Nkind
(Parent
(Declaration_Node
(Result
))) =
8567 N_Subprogram_Renaming_Declaration
)
8568 and then Present
(Alias
(Result
))
8570 Result
:= Alias
(Result
);
8574 end Get_Base_Subprogram
;
8576 ---------------------------
8577 -- Is_Generic_Subprogram --
8578 ---------------------------
8580 function Is_Generic_Subprogram
(Id
: Entity_Id
) return Boolean is
8582 return Ekind
(Id
) = E_Generic_Procedure
8583 or else Ekind
(Id
) = E_Generic_Function
;
8584 end Is_Generic_Subprogram
;
8586 ------------------------------
8587 -- Is_Pragma_String_Literal --
8588 ------------------------------
8590 -- This function returns true if the corresponding pragma argument is
8591 -- a static string expression. These are the only cases in which string
8592 -- literals can appear as pragma arguments. We also allow a string
8593 -- literal as the first argument to pragma Assert (although it will
8594 -- of course always generate a type error).
8596 function Is_Pragma_String_Literal
(Par
: Node_Id
) return Boolean is
8597 Pragn
: constant Node_Id
:= Parent
(Par
);
8598 Assoc
: constant List_Id
:= Pragma_Argument_Associations
(Pragn
);
8599 Pname
: constant Name_Id
:= Chars
(Pragn
);
8612 if Pname
= Name_Assert
then
8615 elsif Pname
= Name_Export
then
8618 elsif Pname
= Name_Ident
then
8621 elsif Pname
= Name_Import
then
8624 elsif Pname
= Name_Interface_Name
then
8627 elsif Pname
= Name_Linker_Alias
then
8630 elsif Pname
= Name_Linker_Section
then
8633 elsif Pname
= Name_Machine_Attribute
then
8636 elsif Pname
= Name_Source_File_Name
then
8639 elsif Pname
= Name_Source_Reference
then
8642 elsif Pname
= Name_Title
then
8645 elsif Pname
= Name_Subtitle
then
8652 end Is_Pragma_String_Literal
;
8654 --------------------------------------
8655 -- Process_Compilation_Unit_Pragmas --
8656 --------------------------------------
8658 procedure Process_Compilation_Unit_Pragmas
(N
: Node_Id
) is
8660 -- A special check for pragma Suppress_All. This is a strange DEC
8661 -- pragma, strange because it comes at the end of the unit. If we
8662 -- have a pragma Suppress_All in the Pragmas_After of the current
8663 -- unit, then we insert a pragma Suppress (All_Checks) at the start
8664 -- of the context clause to ensure the correct processing.
8667 PA
: constant List_Id
:= Pragmas_After
(Aux_Decls_Node
(N
));
8671 if Present
(PA
) then
8673 while Present
(P
) loop
8674 if Chars
(P
) = Name_Suppress_All
then
8675 Prepend_To
(Context_Items
(N
),
8676 Make_Pragma
(Sloc
(P
),
8677 Chars
=> Name_Suppress
,
8678 Pragma_Argument_Associations
=> New_List
(
8679 Make_Pragma_Argument_Association
(Sloc
(P
),
8681 Make_Identifier
(Sloc
(P
),
8682 Chars
=> Name_All_Checks
)))));
8690 end Process_Compilation_Unit_Pragmas
;
8692 --------------------------------
8693 -- Set_Encoded_Interface_Name --
8694 --------------------------------
8696 procedure Set_Encoded_Interface_Name
(E
: Entity_Id
; S
: Node_Id
) is
8697 Str
: constant String_Id
:= Strval
(S
);
8698 Len
: constant Int
:= String_Length
(Str
);
8703 Hex
: constant array (0 .. 15) of Character := "0123456789abcdef";
8706 -- Stores encoded value of character code CC. The encoding we
8707 -- use an underscore followed by four lower case hex digits.
8711 Store_String_Char
(Get_Char_Code
('_'));
8713 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 12))));
8715 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 8 and 16#
0F#
))));
8717 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 4 and 16#
0F#
))));
8719 (Get_Char_Code
(Hex
(Integer (CC
and 16#
0F#
))));
8722 -- Start of processing for Set_Encoded_Interface_Name
8725 -- If first character is asterisk, this is a link name, and we
8726 -- leave it completely unmodified. We also ignore null strings
8727 -- (the latter case happens only in error cases) and no encoding
8728 -- should occur for Java interface names.
8731 or else Get_String_Char
(Str
, 1) = Get_Char_Code
('*')
8734 Set_Interface_Name
(E
, S
);
8739 CC
:= Get_String_Char
(Str
, J
);
8741 exit when not In_Character_Range
(CC
);
8743 C
:= Get_Character
(CC
);
8745 exit when C
/= '_' and then C
/= '$'
8746 and then C
not in '0' .. '9'
8747 and then C
not in 'a' .. 'z'
8748 and then C
not in 'A' .. 'Z';
8751 Set_Interface_Name
(E
, S
);
8759 -- Here we need to encode. The encoding we use as follows:
8760 -- three underscores + four hex digits (lower case)
8764 for J
in 1 .. String_Length
(Str
) loop
8765 CC
:= Get_String_Char
(Str
, J
);
8767 if not In_Character_Range
(CC
) then
8770 C
:= Get_Character
(CC
);
8772 if C
= '_' or else C
= '$'
8773 or else C
in '0' .. '9'
8774 or else C
in 'a' .. 'z'
8775 or else C
in 'A' .. 'Z'
8777 Store_String_Char
(CC
);
8784 Set_Interface_Name
(E
,
8785 Make_String_Literal
(Sloc
(S
),
8786 Strval
=> End_String
));
8788 end Set_Encoded_Interface_Name
;
8794 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
) is
8799 if Nkind
(N
) = N_Identifier
8800 and then Nkind
(With_Item
) = N_Identifier
8802 Set_Entity
(N
, Entity
(With_Item
));
8804 elsif Nkind
(N
) = N_Selected_Component
then
8805 Change_Selected_Component_To_Expanded_Name
(N
);
8806 Set_Entity
(N
, Entity
(With_Item
));
8807 Set_Entity
(Selector_Name
(N
), Entity
(N
));
8810 Scop
:= Scope
(Entity
(N
));
8812 while Nkind
(Pref
) = N_Selected_Component
loop
8813 Change_Selected_Component_To_Expanded_Name
(Pref
);
8814 Set_Entity
(Selector_Name
(Pref
), Scop
);
8815 Set_Entity
(Pref
, Scop
);
8816 Pref
:= Prefix
(Pref
);
8817 Scop
:= Scope
(Scop
);
8820 Set_Entity
(Pref
, Scop
);