1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
10 -- Copyright (C) 1992-2002, Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc. --
26 ------------------------------------------------------------------------------
28 -- This unit contains the semantic processing for all pragmas, both language
29 -- and implementation defined. For most pragmas, the parser only does the
30 -- most basic job of checking the syntax, so Sem_Prag also contains the code
31 -- to complete the syntax checks. Certain pragmas are handled partially or
32 -- completely by the parser (see Par.Prag for further details).
34 with Atree
; use Atree
;
35 with Casing
; use Casing
;
36 with Csets
; use Csets
;
37 with Debug
; use Debug
;
38 with Einfo
; use Einfo
;
39 with Elists
; use Elists
;
40 with Errout
; use Errout
;
41 with Expander
; use Expander
;
42 with Exp_Dist
; use Exp_Dist
;
43 with Fname
; use Fname
;
44 with Hostparm
; use Hostparm
;
46 with Namet
; use Namet
;
47 with Nlists
; use Nlists
;
48 with Nmake
; use Nmake
;
50 with Output
; use Output
;
51 with Restrict
; use Restrict
;
52 with Rtsfind
; use Rtsfind
;
54 with Sem_Ch8
; use Sem_Ch8
;
55 with Sem_Ch13
; use Sem_Ch13
;
56 with Sem_Disp
; use Sem_Disp
;
57 with Sem_Elim
; use Sem_Elim
;
58 with Sem_Eval
; use Sem_Eval
;
59 with Sem_Intr
; use Sem_Intr
;
60 with Sem_Mech
; use Sem_Mech
;
61 with Sem_Res
; use Sem_Res
;
62 with Sem_Type
; use Sem_Type
;
63 with Sem_Util
; use Sem_Util
;
64 with Sem_VFpt
; use Sem_VFpt
;
65 with Stand
; use Stand
;
66 with Sinfo
; use Sinfo
;
67 with Sinfo
.CN
; use Sinfo
.CN
;
68 with Sinput
; use Sinput
;
69 with Snames
; use Snames
;
70 with Stringt
; use Stringt
;
71 with Stylesw
; use Stylesw
;
72 with Targparm
; use Targparm
;
73 with Tbuild
; use Tbuild
;
75 with Uintp
; use Uintp
;
76 with Urealp
; use Urealp
;
77 with Validsw
; use Validsw
;
79 with GNAT
.Spelling_Checker
; use GNAT
.Spelling_Checker
;
81 package body Sem_Prag
is
83 ----------------------------------------------
84 -- Common Handling of Import-Export Pragmas --
85 ----------------------------------------------
87 -- In the following section, a number of Import_xxx and Export_xxx
88 -- pragmas are defined by GNAT. These are compatible with the DEC
89 -- pragmas of the same name, and all have the following common
90 -- form and processing:
93 -- [Internal =>] LOCAL_NAME,
94 -- [, [External =>] EXTERNAL_SYMBOL]
95 -- [, other optional parameters ]);
98 -- [Internal =>] LOCAL_NAME,
99 -- [, [External =>] EXTERNAL_SYMBOL]
100 -- [, other optional parameters ]);
102 -- EXTERNAL_SYMBOL ::=
104 -- | static_string_EXPRESSION
106 -- The internal LOCAL_NAME designates the entity that is imported or
107 -- exported, and must refer to an entity in the current declarative
108 -- part (as required by the rules for LOCAL_NAME).
110 -- The external linker name is designated by the External parameter
111 -- if given, or the Internal parameter if not (if there is no External
112 -- parameter, the External parameter is a copy of the Internal name).
114 -- If the External parameter is given as a string, then this string
115 -- is treated as an external name (exactly as though it had been given
116 -- as an External_Name parameter for a normal Import pragma).
118 -- If the External parameter is given as an identifier (or there is no
119 -- External parameter, so that the Internal identifier is used), then
120 -- the external name is the characters of the identifier, translated
121 -- to all upper case letters for OpenVMS versions of GNAT, and to all
122 -- lower case letters for all other versions
124 -- Note: the external name specified or implied by any of these special
125 -- Import_xxx or Export_xxx pragmas override an external or link name
126 -- specified in a previous Import or Export pragma.
128 -- Note: these and all other DEC-compatible GNAT pragmas allow full
129 -- use of named notation, following the standard rules for subprogram
130 -- calls, i.e. parameters can be given in any order if named notation
131 -- is used, and positional and named notation can be mixed, subject to
132 -- the rule that all positional parameters must appear first.
134 -- Note: All these pragmas are implemented exactly following the DEC
135 -- design and implementation and are intended to be fully compatible
136 -- with the use of these pragmas in the DEC Ada compiler.
138 -------------------------------------
139 -- Local Subprograms and Variables --
140 -------------------------------------
142 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
;
143 -- This routine is used for possible casing adjustment of an explicit
144 -- external name supplied as a string literal (the node N), according
145 -- to the casing requirement of Opt.External_Name_Casing. If this is
146 -- set to As_Is, then the string literal is returned unchanged, but if
147 -- it is set to Uppercase or Lowercase, then a new string literal with
148 -- appropriate casing is constructed.
150 function Is_Generic_Subprogram
(Id
: Entity_Id
) return Boolean;
151 -- Return True if Id is a generic procedure or a function
153 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
;
154 -- If Def_Id refers to a renamed subprogram, then the base subprogram
155 -- (the original one, following the renaming chain) is returned.
156 -- Otherwise the entity is returned unchanged. Should be in Einfo???
158 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
);
159 -- Place semantic information on the argument of an Elaborate or
160 -- Elaborate_All pragma. Entity name for unit and its parents is
161 -- taken from item in previous with_clause that mentions the unit.
163 Locking_Policy_Sloc
: Source_Ptr
:= No_Location
;
164 Queuing_Policy_Sloc
: Source_Ptr
:= No_Location
;
165 Task_Dispatching_Policy_Sloc
: Source_Ptr
:= No_Location
;
166 -- These global variables remember the location of a previous locking,
167 -- queuing or task dispatching policy pragma, so that appropriate error
168 -- messages can be generated for inconsistent pragmas. Note that it is
169 -- fine that these are global locations, because the check for consistency
170 -- is over the entire program.
172 -------------------------------
173 -- Adjust_External_Name_Case --
174 -------------------------------
176 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
is
180 -- Adjust case of literal if required
182 if Opt
.External_Name_Exp_Casing
= As_Is
then
186 -- Copy existing string
192 for J
in 1 .. String_Length
(Strval
(N
)) loop
193 CC
:= Get_String_Char
(Strval
(N
), J
);
195 if Opt
.External_Name_Exp_Casing
= Uppercase
196 and then CC
>= Get_Char_Code
('a')
197 and then CC
<= Get_Char_Code
('z')
199 Store_String_Char
(CC
- 32);
201 elsif Opt
.External_Name_Exp_Casing
= Lowercase
202 and then CC
>= Get_Char_Code
('A')
203 and then CC
<= Get_Char_Code
('Z')
205 Store_String_Char
(CC
+ 32);
208 Store_String_Char
(CC
);
213 Make_String_Literal
(Sloc
(N
),
214 Strval
=> End_String
);
216 end Adjust_External_Name_Case
;
222 procedure Analyze_Pragma
(N
: Node_Id
) is
223 Loc
: constant Source_Ptr
:= Sloc
(N
);
226 Pragma_Exit
: exception;
227 -- This exception is used to exit pragma processing completely. It
228 -- is used when an error is detected, and in other situations where
229 -- it is known that no further processing is required.
232 -- Number of pragma argument associations
238 -- First four pragma arguments (pragma argument association nodes,
239 -- or Empty if the corresponding argument does not exist).
241 procedure Check_Ada_83_Warning
;
242 -- Issues a warning message for the current pragma if operating in Ada
243 -- 83 mode (used for language pragmas that are not a standard part of
244 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
247 procedure Check_Arg_Count
(Required
: Nat
);
248 -- Check argument count for pragma is equal to given parameter.
249 -- If not, then issue an error message and raise Pragma_Exit.
251 -- Note: all routines whose name is Check_Arg_Is_xxx take an
252 -- argument Arg which can either be a pragma argument association,
253 -- in which case the check is applied to the expression of the
254 -- association or an expression directly.
256 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
);
257 -- Check the specified argument Arg to make sure that it is an
258 -- identifier. If not give error and raise Pragma_Exit.
260 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
);
261 -- Check the specified argument Arg to make sure that it is an
262 -- integer literal. If not give error and raise Pragma_Exit.
264 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
);
265 -- Check the specified argument Arg to make sure that it has the
266 -- proper syntactic form for a local name and meets the semantic
267 -- requirements for a local name. The local name is analyzed as
268 -- part of the processing for this call. In addition, the local
269 -- name is required to represent an entity at the library level.
271 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
);
272 -- Check the specified argument Arg to make sure that it has the
273 -- proper syntactic form for a local name and meets the semantic
274 -- requirements for a local name. The local name is analyzed as
275 -- part of the processing for this call.
277 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
);
278 -- Check the specified argument Arg to make sure that it is a valid
279 -- locking policy name. If not give error and raise Pragma_Exit.
281 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
);
282 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
, N3
: Name_Id
);
283 -- Check the specified argument Arg to make sure that it is an
284 -- identifier whose name matches either N1 or N2 (or N3 if present).
285 -- If not then give error and raise Pragma_Exit.
287 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
);
288 -- Check the specified argument Arg to make sure that it is a valid
289 -- queuing policy name. If not give error and raise Pragma_Exit.
291 procedure Check_Arg_Is_Static_Expression
294 -- Check the specified argument Arg to make sure that it is a static
295 -- expression of the given type (i.e. it will be analyzed and resolved
296 -- using this type, which can be any valid argument to Resolve, e.g.
297 -- Any_Integer is OK). If not, given error and raise Pragma_Exit.
299 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
);
300 -- Check the specified argument Arg to make sure that it is a
301 -- string literal. If not give error and raise Pragma_Exit
303 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
);
304 -- Check the specified argument Arg to make sure that it is a valid
305 -- valid task dispatching policy name. If not give error and raise
308 procedure Check_At_Least_N_Arguments
(N
: Nat
);
309 -- Check there are at least N arguments present
311 procedure Check_At_Most_N_Arguments
(N
: Nat
);
312 -- Check there are no more than N arguments present
314 procedure Check_First_Subtype
(Arg
: Node_Id
);
315 -- Checks that Arg, whose expression is an entity name referencing
316 -- a subtype, does not reference a type that is not a first subtype.
318 procedure Check_In_Main_Program
;
319 -- Common checks for pragmas that appear within a main program
320 -- (Priority, Main_Storage, Time_Slice).
322 procedure Check_Interrupt_Or_Attach_Handler
;
323 -- Common processing for first argument of pragma Interrupt_Handler
324 -- or pragma Attach_Handler.
326 procedure Check_Is_In_Decl_Part_Or_Package_Spec
;
327 -- Check that pragma appears in a declarative part, or in a package
328 -- specification, i.e. that it does not occur in a statement sequence
331 procedure Check_No_Identifier
(Arg
: Node_Id
);
332 -- Checks that the given argument does not have an identifier. If
333 -- an identifier is present, then an error message is issued, and
334 -- Pragma_Exit is raised.
336 procedure Check_No_Identifiers
;
337 -- Checks that none of the arguments to the pragma has an identifier.
338 -- If any argument has an identifier, then an error message is issued,
339 -- and Pragma_Exit is raised.
341 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
);
342 -- Checks if the given argument has an identifier, and if so, requires
343 -- it to match the given identifier name. If there is a non-matching
344 -- identifier, then an error message is given and Error_Pragmas raised.
346 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String);
347 -- Checks if the given argument has an identifier, and if so, requires
348 -- it to match the given identifier name. If there is a non-matching
349 -- identifier, then an error message is given and Error_Pragmas raised.
350 -- In this version of the procedure, the identifier name is given as
351 -- a string with lower case letters.
353 procedure Check_Static_Constraint
(Constr
: Node_Id
);
354 -- Constr is a constraint from an N_Subtype_Indication node from a
355 -- component constraint in an Unchecked_Union type. This routine checks
356 -- that the constraint is static as required by the restrictions for
359 procedure Check_Valid_Configuration_Pragma
;
360 -- Legality checks for placement of a configuration pragma
362 procedure Check_Valid_Library_Unit_Pragma
;
363 -- Legality checks for library unit pragmas. A special case arises for
364 -- pragmas in generic instances that come from copies of the original
365 -- library unit pragmas in the generic templates. In the case of other
366 -- than library level instantiations these can appear in contexts which
367 -- would normally be invalid (they only apply to the original template
368 -- and to library level instantiations), and they are simply ignored,
369 -- which is implemented by rewriting them as null statements.
371 procedure Error_Pragma
(Msg
: String);
372 pragma No_Return
(Error_Pragma
);
373 -- Outputs error message for current pragma. The message contains an %
374 -- that will be replaced with the pragma name, and the flag is placed
375 -- on the pragma itself. Pragma_Exit is then raised.
377 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
);
378 pragma No_Return
(Error_Pragma_Arg
);
379 -- Outputs error message for current pragma. The message may contain
380 -- a % that will be replaced with the pragma name. The parameter Arg
381 -- may either be a pragma argument association, in which case the flag
382 -- is placed on the expression of this association, or an expression,
383 -- in which case the flag is placed directly on the expression. The
384 -- message is placed using Error_Msg_N, so the message may also contain
385 -- an & insertion character which will reference the given Arg value.
386 -- After placing the message, Pragma_Exit is raised.
388 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
);
389 pragma No_Return
(Error_Pragma_Arg
);
390 -- Similar to above form of Error_Pragma_Arg except that two messages
391 -- are provided, the second is a continuation comment starting with \.
393 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
);
394 pragma No_Return
(Error_Pragma_Arg_Ident
);
395 -- Outputs error message for current pragma. The message may contain
396 -- a % that will be replaced with the pragma name. The parameter Arg
397 -- must be a pragma argument association with a non-empty identifier
398 -- (i.e. its Chars field must be set), and the error message is placed
399 -- on the identifier. The message is placed using Error_Msg_N so
400 -- the message may also contain an & insertion character which will
401 -- reference the identifier. After placing the message, Pragma_Exit
404 function Find_Lib_Unit_Name
return Entity_Id
;
405 -- Used for a library unit pragma to find the entity to which the
406 -- library unit pragma applies, returns the entity found.
408 procedure Find_Program_Unit_Name
(Id
: Node_Id
);
409 -- If the pragma is a compilation unit pragma, the id must denote the
410 -- compilation unit in the same compilation, and the pragma must appear
411 -- in the list of preceding or trailing pragmas. If it is a program
412 -- unit pragma that is not a compilation unit pragma, then the
413 -- identifier must be visible.
415 type Name_List
is array (Natural range <>) of Name_Id
;
416 type Args_List
is array (Natural range <>) of Node_Id
;
417 procedure Gather_Associations
419 Args
: out Args_List
);
420 -- This procedure is used to gather the arguments for a pragma that
421 -- permits arbitrary ordering of parameters using the normal rules
422 -- for named and positional parameters. The Names argument is a list
423 -- of Name_Id values that corresponds to the allowed pragma argument
424 -- association identifiers in order. The result returned in Args is
425 -- a list of corresponding expressions that are the pragma arguments.
426 -- Note that this is a list of expressions, not of pragma argument
427 -- associations (Gather_Associations has completely checked all the
428 -- optional identifiers when it returns). An entry in Args is Empty
429 -- on return if the corresponding argument is not present.
431 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
;
432 -- All the routines that check pragma arguments take either a pragma
433 -- argument association (in which case the expression of the argument
434 -- association is checked), or the expression directly. The function
435 -- Get_Pragma_Arg is a utility used to deal with these two cases. If
436 -- Arg is a pragma argument association node, then its expression is
437 -- returned, otherwise Arg is returned unchanged.
439 procedure GNAT_Pragma
;
440 -- Called for all GNAT defined pragmas to note the use of the feature,
441 -- and also check the relevant restriction (No_Implementation_Pragmas).
443 function Is_Before_First_Decl
444 (Pragma_Node
: Node_Id
;
447 -- Return True if Pragma_Node is before the first declarative item in
448 -- Decls where Decls is the list of declarative items.
450 function Is_Configuration_Pragma
return Boolean;
451 -- Deterermines if the placement of the current pragma is appropriate
452 -- for a configuration pragma (precedes the current compilation unit)
454 procedure Pragma_Misplaced
;
455 -- Issue fatal error message for misplaced pragma
457 procedure Process_Atomic_Shared_Volatile
;
458 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
459 -- Shared is an obsolete Ada 83 pragma, treated as being identical
460 -- in effect to pragma Atomic.
462 procedure Process_Convention
(C
: out Convention_Id
; E
: out Entity_Id
);
463 -- Common procesing for Convention, Interface, Import and Export.
464 -- Checks first two arguments of pragma, and sets the appropriate
465 -- convention value in the specified entity or entities. On return
466 -- C is the convention, E is the referenced entity.
468 procedure Process_Extended_Import_Export_Exception_Pragma
469 (Arg_Internal
: Node_Id
;
470 Arg_External
: Node_Id
;
473 -- Common processing for the pragmas Import/Export_Exception.
474 -- The three arguments correspond to the three named parameters of
475 -- the pragma. An argument is empty if the corresponding parameter
476 -- is not present in the pragma.
478 procedure Process_Extended_Import_Export_Object_Pragma
479 (Arg_Internal
: Node_Id
;
480 Arg_External
: Node_Id
;
482 -- Common processing for the pragmass Import/Export_Object.
483 -- The three arguments correspond to the three named parameters
484 -- of the pragmas. An argument is empty if the corresponding
485 -- parameter is not present in the pragma.
487 procedure Process_Extended_Import_Export_Internal_Arg
488 (Arg_Internal
: Node_Id
:= Empty
);
489 -- Common processing for all extended Import and Export pragmas. The
490 -- argument is the pragma parameter for the Internal argument. If
491 -- Arg_Internal is empty or inappropriate, an error message is posted.
492 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
493 -- set to identify the referenced entity.
495 procedure Process_Extended_Import_Export_Subprogram_Pragma
496 (Arg_Internal
: Node_Id
;
497 Arg_External
: Node_Id
;
498 Arg_Parameter_Types
: Node_Id
;
499 Arg_Result_Type
: Node_Id
:= Empty
;
500 Arg_Mechanism
: Node_Id
;
501 Arg_Result_Mechanism
: Node_Id
:= Empty
;
502 Arg_First_Optional_Parameter
: Node_Id
:= Empty
);
503 -- Common processing for all extended Import and Export pragmas
504 -- applying to subprograms. The caller omits any arguments that do
505 -- bnot apply to the pragma in question (for example, Arg_Result_Type
506 -- can be non-Empty only in the Import_Function and Export_Function
507 -- cases). The argument names correspond to the allowed pragma
508 -- association identifiers.
510 procedure Process_Generic_List
;
511 -- Common processing for Share_Generic and Inline_Generic
513 procedure Process_Import_Or_Interface
;
514 -- Common processing for Import of Interface
516 procedure Process_Inline
(Active
: Boolean);
517 -- Common processing for Inline and Inline_Always. The parameter
518 -- indicates if the inline pragma is active, i.e. if it should
519 -- actually cause inlining to occur.
521 procedure Process_Interface_Name
522 (Subprogram_Def
: Entity_Id
;
525 -- Given the last two arguments of pragma Import, pragma Export, or
526 -- pragma Interface_Name, performs validity checks and sets the
527 -- Interface_Name field of the given subprogram entity to the
528 -- appropriate external or link name, depending on the arguments
529 -- given. Ext_Arg is always present, but Link_Arg may be missing.
530 -- Note that Ext_Arg may represent the Link_Name if Link_Arg is
531 -- missing, and appropriate named notation is used for Ext_Arg.
532 -- If neither Ext_Arg nor Link_Arg is present, the interface name
533 -- is set to the default from the subprogram name.
535 procedure Process_Interrupt_Or_Attach_Handler
;
536 -- Attach the pragmas to the rep item chain.
538 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean);
539 -- Common processing for Suppress and Unsuppress. The boolean parameter
540 -- Suppress_Case is True for the Suppress case, and False for the
543 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
);
544 -- This procedure sets the Is_Exported flag for the given entity,
545 -- checking that the entity was not previously imported. Arg is
546 -- the argument that specified the entity.
548 procedure Set_Extended_Import_Export_External_Name
549 (Internal_Ent
: Entity_Id
;
550 Arg_External
: Node_Id
);
551 -- Common processing for all extended import export pragmas. The first
552 -- argument, Internal_Ent, is the internal entity, which has already
553 -- been checked for validity by the caller. Arg_External is from the
554 -- Import or Export pragma, and may be null if no External parameter
555 -- was present. If Arg_External is present and is a non-null string
556 -- (a null string is treated as the default), then the Interface_Name
557 -- field of Internal_Ent is set appropriately.
559 procedure Set_Imported
(E
: Entity_Id
);
560 -- This procedure sets the Is_Imported flag for the given entity,
561 -- checking that it is not previously exported or imported.
563 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
);
564 -- Mech is a parameter passing mechanism (see Import_Function syntax
565 -- for MECHANISM_NAME). This routine checks that the mechanism argument
566 -- has the right form, and if not issues an error message. If the
567 -- argument has the right form then the Mechanism field of Ent is
568 -- set appropriately.
570 --------------------------
571 -- Check_Ada_83_Warning --
572 --------------------------
574 procedure Check_Ada_83_Warning
is
576 if Ada_83
and then Comes_From_Source
(N
) then
577 Error_Msg_N
("(Ada 83) pragma& is non-standard?", N
);
579 end Check_Ada_83_Warning
;
581 ---------------------
582 -- Check_Arg_Count --
583 ---------------------
585 procedure Check_Arg_Count
(Required
: Nat
) is
587 if Arg_Count
/= Required
then
588 Error_Pragma
("wrong number of arguments for pragma%");
592 -----------------------------
593 -- Check_Arg_Is_Identifier --
594 -----------------------------
596 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
) is
597 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
600 if Nkind
(Argx
) /= N_Identifier
then
602 ("argument for pragma% must be identifier", Argx
);
604 end Check_Arg_Is_Identifier
;
606 ----------------------------------
607 -- Check_Arg_Is_Integer_Literal --
608 ----------------------------------
610 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
) is
611 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
614 if Nkind
(Argx
) /= N_Integer_Literal
then
616 ("argument for pragma% must be integer literal", Argx
);
618 end Check_Arg_Is_Integer_Literal
;
620 -------------------------------------------
621 -- Check_Arg_Is_Library_Level_Local_Name --
622 -------------------------------------------
626 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
627 -- | library_unit_NAME
629 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
) is
631 Check_Arg_Is_Local_Name
(Arg
);
633 if not Is_Library_Level_Entity
(Entity
(Expression
(Arg
)))
634 and then Comes_From_Source
(N
)
637 ("argument for pragma% must be library level entity", Arg
);
639 end Check_Arg_Is_Library_Level_Local_Name
;
641 -----------------------------
642 -- Check_Arg_Is_Local_Name --
643 -----------------------------
647 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
648 -- | library_unit_NAME
650 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
) is
651 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
656 if Nkind
(Argx
) not in N_Direct_Name
657 and then (Nkind
(Argx
) /= N_Attribute_Reference
658 or else Present
(Expressions
(Argx
))
659 or else Nkind
(Prefix
(Argx
)) /= N_Identifier
)
660 and then (not Is_Entity_Name
(Argx
)
661 or else not Is_Compilation_Unit
(Entity
(Argx
)))
663 Error_Pragma_Arg
("argument for pragma% must be local name", Argx
);
666 if Is_Entity_Name
(Argx
)
667 and then Scope
(Entity
(Argx
)) /= Current_Scope
670 ("pragma% argument must be in same declarative part", Arg
);
672 end Check_Arg_Is_Local_Name
;
674 ---------------------------------
675 -- Check_Arg_Is_Locking_Policy --
676 ---------------------------------
678 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
) is
679 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
682 Check_Arg_Is_Identifier
(Argx
);
684 if not Is_Locking_Policy_Name
(Chars
(Argx
)) then
686 ("& is not a valid locking policy name", Argx
);
688 end Check_Arg_Is_Locking_Policy
;
690 -------------------------
691 -- Check_Arg_Is_One_Of --
692 -------------------------
694 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
) is
695 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
698 Check_Arg_Is_Identifier
(Argx
);
700 if Chars
(Argx
) /= N1
and then Chars
(Argx
) /= N2
then
701 Error_Msg_Name_2
:= N1
;
702 Error_Msg_Name_3
:= N2
;
703 Error_Pragma_Arg
("argument for pragma% must be% or%", Argx
);
705 end Check_Arg_Is_One_Of
;
707 procedure Check_Arg_Is_One_Of
709 N1
, N2
, N3
: Name_Id
)
711 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
714 Check_Arg_Is_Identifier
(Argx
);
716 if Chars
(Argx
) /= N1
717 and then Chars
(Argx
) /= N2
718 and then Chars
(Argx
) /= N3
720 Error_Pragma_Arg
("invalid argument for pragma%", Argx
);
722 end Check_Arg_Is_One_Of
;
724 ---------------------------------
725 -- Check_Arg_Is_Queuing_Policy --
726 ---------------------------------
728 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
) is
729 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
732 Check_Arg_Is_Identifier
(Argx
);
734 if not Is_Queuing_Policy_Name
(Chars
(Argx
)) then
736 ("& is not a valid queuing policy name", Argx
);
738 end Check_Arg_Is_Queuing_Policy
;
740 ------------------------------------
741 -- Check_Arg_Is_Static_Expression --
742 ------------------------------------
744 procedure Check_Arg_Is_Static_Expression
748 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
751 Analyze_And_Resolve
(Argx
, Typ
);
753 if Is_OK_Static_Expression
(Argx
) then
756 elsif Etype
(Argx
) = Any_Type
then
759 -- An interesting special case, if we have a string literal and
760 -- we are in Ada 83 mode, then we allow it even though it will
761 -- not be flagged as static. This allows the use of Ada 95
762 -- pragmas like Import in Ada 83 mode. They will of course be
763 -- flagged with warnings as usual, but will not cause errors.
765 elsif Ada_83
and then Nkind
(Argx
) = N_String_Literal
then
768 -- Static expression that raises Constraint_Error. This has
769 -- already been flagged, so just exit from pragma processing.
771 elsif Is_Static_Expression
(Argx
) then
774 -- Finally, we have a real error
778 ("argument for pragma% must be a static expression", Argx
);
781 end Check_Arg_Is_Static_Expression
;
783 ---------------------------------
784 -- Check_Arg_Is_String_Literal --
785 ---------------------------------
787 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
) is
788 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
791 if Nkind
(Argx
) /= N_String_Literal
then
793 ("argument for pragma% must be string literal", Argx
);
796 end Check_Arg_Is_String_Literal
;
798 ------------------------------------------
799 -- Check_Arg_Is_Task_Dispatching_Policy --
800 ------------------------------------------
802 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
) is
803 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
806 Check_Arg_Is_Identifier
(Argx
);
808 if not Is_Task_Dispatching_Policy_Name
(Chars
(Argx
)) then
810 ("& is not a valid task dispatching policy name", Argx
);
812 end Check_Arg_Is_Task_Dispatching_Policy
;
814 --------------------------------
815 -- Check_At_Least_N_Arguments --
816 --------------------------------
818 procedure Check_At_Least_N_Arguments
(N
: Nat
) is
820 if Arg_Count
< N
then
821 Error_Pragma
("too few arguments for pragma%");
823 end Check_At_Least_N_Arguments
;
825 -------------------------------
826 -- Check_At_Most_N_Arguments --
827 -------------------------------
829 procedure Check_At_Most_N_Arguments
(N
: Nat
) is
833 if Arg_Count
> N
then
838 Error_Pragma_Arg
("too many arguments for pragma%", Arg
);
841 end Check_At_Most_N_Arguments
;
843 -------------------------
844 -- Check_First_Subtype --
845 -------------------------
847 procedure Check_First_Subtype
(Arg
: Node_Id
) is
848 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
851 if not Is_First_Subtype
(Entity
(Argx
)) then
853 ("pragma% cannot apply to subtype", Argx
);
855 end Check_First_Subtype
;
857 ---------------------------
858 -- Check_In_Main_Program --
859 ---------------------------
861 procedure Check_In_Main_Program
is
862 P
: constant Node_Id
:= Parent
(N
);
865 -- Must be at in subprogram body
867 if Nkind
(P
) /= N_Subprogram_Body
then
868 Error_Pragma
("% pragma allowed only in subprogram");
870 -- Otherwise warn if obviously not main program
872 elsif Present
(Parameter_Specifications
(Specification
(P
)))
873 or else not Is_Library_Level_Entity
(Defining_Entity
(P
))
875 Error_Msg_Name_1
:= Chars
(N
);
877 ("?pragma% is only effective in main program", N
);
879 end Check_In_Main_Program
;
881 ---------------------------------------
882 -- Check_Interrupt_Or_Attach_Handler --
883 ---------------------------------------
885 procedure Check_Interrupt_Or_Attach_Handler
is
886 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
891 if not Is_Entity_Name
(Arg1_X
) then
893 ("argument of pragma% must be entity name", Arg1
);
895 elsif Prag_Id
= Pragma_Interrupt_Handler
then
896 Check_Restriction
(No_Dynamic_Interrupts
, N
);
900 Prot_Proc
: Entity_Id
:= Empty
;
901 Prot_Type
: Entity_Id
;
902 Found
: Boolean := False;
905 if not Is_Overloaded
(Arg1_X
) then
906 Prot_Proc
:= Entity
(Arg1_X
);
911 Index
: Interp_Index
;
914 Get_First_Interp
(Arg1_X
, Index
, It
);
915 while Present
(It
.Nam
) loop
918 if Ekind
(Prot_Proc
) = E_Procedure
919 and then No
(First_Formal
(Prot_Proc
))
923 Set_Entity
(Arg1_X
, Prot_Proc
);
924 Set_Is_Overloaded
(Arg1_X
, False);
927 ("ambiguous handler name for pragma% ", Arg1
);
931 Get_Next_Interp
(Index
, It
);
936 ("argument of pragma% must be parameterless procedure",
939 Prot_Proc
:= Entity
(Arg1_X
);
944 Prot_Type
:= Scope
(Prot_Proc
);
946 if Ekind
(Prot_Proc
) /= E_Procedure
947 or else Ekind
(Prot_Type
) /= E_Protected_Type
950 ("argument of pragma% must be protected procedure",
954 if not Is_Library_Level_Entity
(Prot_Type
) then
956 ("pragma% requires library level entity", Arg1
);
959 if Present
(First_Formal
(Prot_Proc
)) then
961 ("argument of pragma% must be parameterless procedure",
966 Protected_Definition
(Parent
(Prot_Type
))
968 Error_Pragma
("pragma% must be in protected definition");
972 end Check_Interrupt_Or_Attach_Handler
;
974 -------------------------------------------
975 -- Check_Is_In_Decl_Part_Or_Package_Spec --
976 -------------------------------------------
978 procedure Check_Is_In_Decl_Part_Or_Package_Spec
is
987 elsif Nkind
(P
) = N_Handled_Sequence_Of_Statements
then
990 elsif Nkind
(P
) = N_Package_Specification
then
993 elsif Nkind
(P
) = N_Block_Statement
then
996 -- Note: the following tests seem a little peculiar, because
997 -- they test for bodies, but if we were in the statement part
998 -- of the body, we would already have hit the handled statement
999 -- sequence, so the only way we get here is by being in the
1000 -- declarative part of the body.
1002 elsif Nkind
(P
) = N_Subprogram_Body
1003 or else Nkind
(P
) = N_Package_Body
1004 or else Nkind
(P
) = N_Task_Body
1005 or else Nkind
(P
) = N_Entry_Body
1013 Error_Pragma
("pragma% is not in declarative part or package spec");
1015 end Check_Is_In_Decl_Part_Or_Package_Spec
;
1017 -------------------------
1018 -- Check_No_Identifier --
1019 -------------------------
1021 procedure Check_No_Identifier
(Arg
: Node_Id
) is
1023 if Chars
(Arg
) /= No_Name
then
1024 Error_Pragma_Arg_Ident
1025 ("pragma% does not permit identifier& here", Arg
);
1027 end Check_No_Identifier
;
1029 --------------------------
1030 -- Check_No_Identifiers --
1031 --------------------------
1033 procedure Check_No_Identifiers
is
1037 if Arg_Count
> 0 then
1040 while Present
(Arg_Node
) loop
1041 Check_No_Identifier
(Arg_Node
);
1045 end Check_No_Identifiers
;
1047 -------------------------------
1048 -- Check_Optional_Identifier --
1049 -------------------------------
1051 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
) is
1053 if Present
(Arg
) and then Chars
(Arg
) /= No_Name
then
1054 if Chars
(Arg
) /= Id
then
1055 Error_Msg_Name_1
:= Chars
(N
);
1056 Error_Msg_Name_2
:= Id
;
1057 Error_Msg_N
("pragma% argument expects identifier%", Arg
);
1061 end Check_Optional_Identifier
;
1063 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String) is
1065 Name_Buffer
(1 .. Id
'Length) := Id
;
1066 Name_Len
:= Id
'Length;
1067 Check_Optional_Identifier
(Arg
, Name_Find
);
1068 end Check_Optional_Identifier
;
1070 -----------------------------
1071 -- Check_Static_Constraint --
1072 -----------------------------
1074 -- Note: for convenience in writing this procedure, in addition to
1075 -- the officially (i.e. by spec) allowed argument which is always
1076 -- a constraint, it also allows ranges and discriminant associations.
1078 procedure Check_Static_Constraint
(Constr
: Node_Id
) is
1080 --------------------
1081 -- Require_Static --
1082 --------------------
1084 procedure Require_Static
(E
: Node_Id
);
1085 -- Require given expression to be static expression
1087 procedure Require_Static
(E
: Node_Id
) is
1089 if not Is_OK_Static_Expression
(E
) then
1091 ("non-static constraint not allowed in Unchecked_Union", E
);
1096 -- Start of processing for Check_Static_Constraint
1099 case Nkind
(Constr
) is
1100 when N_Discriminant_Association
=>
1101 Require_Static
(Expression
(Constr
));
1104 Require_Static
(Low_Bound
(Constr
));
1105 Require_Static
(High_Bound
(Constr
));
1107 when N_Attribute_Reference
=>
1108 Require_Static
(Type_Low_Bound
(Etype
(Prefix
(Constr
))));
1109 Require_Static
(Type_High_Bound
(Etype
(Prefix
(Constr
))));
1111 when N_Range_Constraint
=>
1112 Check_Static_Constraint
(Range_Expression
(Constr
));
1114 when N_Index_Or_Discriminant_Constraint
=>
1116 IDC
: Entity_Id
:= First
(Constraints
(Constr
));
1119 while Present
(IDC
) loop
1120 Check_Static_Constraint
(IDC
);
1128 end Check_Static_Constraint
;
1130 --------------------------------------
1131 -- Check_Valid_Configuration_Pragma --
1132 --------------------------------------
1134 -- A configuration pragma must appear in the context clause of
1135 -- a compilation unit, at the start of the list (i.e. only other
1136 -- pragmas may precede it).
1138 procedure Check_Valid_Configuration_Pragma
is
1140 if not Is_Configuration_Pragma
then
1141 Error_Pragma
("incorrect placement for configuration pragma%");
1143 end Check_Valid_Configuration_Pragma
;
1145 -------------------------------------
1146 -- Check_Valid_Library_Unit_Pragma --
1147 -------------------------------------
1149 procedure Check_Valid_Library_Unit_Pragma
is
1151 Parent_Node
: Node_Id
;
1152 Unit_Name
: Entity_Id
;
1153 Valid
: Boolean := True;
1154 Unit_Kind
: Node_Kind
;
1155 Unit_Node
: Node_Id
;
1156 Sindex
: Source_File_Index
;
1159 if not Is_List_Member
(N
) then
1164 Plist
:= List_Containing
(N
);
1165 Parent_Node
:= Parent
(Plist
);
1167 if Parent_Node
= Empty
then
1170 -- Case of pragma appearing after a compilation unit. In this
1171 -- case it must have an argument with the corresponding name
1172 -- and must be part of the following pragmas of its parent.
1174 elsif Nkind
(Parent_Node
) = N_Compilation_Unit_Aux
then
1175 if Plist
/= Pragmas_After
(Parent_Node
) then
1178 elsif Arg_Count
= 0 then
1180 ("argument required if outside compilation unit");
1183 Check_No_Identifiers
;
1184 Check_Arg_Count
(1);
1185 Unit_Node
:= Unit
(Parent
(Parent_Node
));
1186 Unit_Kind
:= Nkind
(Unit_Node
);
1188 Analyze
(Expression
(Arg1
));
1190 if Unit_Kind
= N_Generic_Subprogram_Declaration
1191 or else Unit_Kind
= N_Subprogram_Declaration
1193 Unit_Name
:= Defining_Entity
(Unit_Node
);
1195 elsif Unit_Kind
= N_Function_Instantiation
1196 or else Unit_Kind
= N_Package_Instantiation
1197 or else Unit_Kind
= N_Procedure_Instantiation
1199 Unit_Name
:= Defining_Entity
(Unit_Node
);
1202 Unit_Name
:= Cunit_Entity
(Current_Sem_Unit
);
1205 if Chars
(Unit_Name
) /=
1206 Chars
(Entity
(Expression
(Arg1
)))
1209 ("pragma% argument is not current unit name", Arg1
);
1212 if Ekind
(Unit_Name
) = E_Package
1213 and then Present
(Renamed_Entity
(Unit_Name
))
1215 Error_Pragma
("pragma% not allowed for renamed package");
1219 -- Pragma appears other than after a compilation unit
1222 -- Here we check for the generic instantiation case and also
1223 -- for the case of processing a generic formal package. We
1224 -- detect these cases by noting that the Sloc on the node
1225 -- does not belong to the current compilation unit.
1227 Sindex
:= Source_Index
(Current_Sem_Unit
);
1229 if Loc
not in Source_First
(Sindex
) .. Source_Last
(Sindex
) then
1230 Rewrite
(N
, Make_Null_Statement
(Loc
));
1233 -- If before first declaration, the pragma applies to the
1234 -- enclosing unit, and the name if present must be this name.
1236 elsif Is_Before_First_Decl
(N
, Plist
) then
1237 Unit_Node
:= Unit_Declaration_Node
(Current_Scope
);
1238 Unit_Kind
:= Nkind
(Unit_Node
);
1240 if Nkind
(Parent
(Unit_Node
)) /= N_Compilation_Unit
then
1243 elsif Unit_Kind
= N_Subprogram_Body
1244 and then not Acts_As_Spec
(Unit_Node
)
1248 elsif Nkind
(Parent_Node
) = N_Package_Body
then
1251 elsif Nkind
(Parent_Node
) = N_Package_Specification
1252 and then Plist
= Private_Declarations
(Parent_Node
)
1256 elsif (Nkind
(Parent_Node
) = N_Generic_Package_Declaration
1257 or else Nkind
(Parent_Node
)
1258 = N_Generic_Subprogram_Declaration
)
1259 and then Plist
= Generic_Formal_Declarations
(Parent_Node
)
1263 elsif Arg_Count
> 0 then
1264 Analyze
(Expression
(Arg1
));
1266 if Entity
(Expression
(Arg1
)) /= Current_Scope
then
1268 ("name in pragma% must be enclosing unit", Arg1
);
1271 -- It is legal to have no argument in this context
1277 -- Error if not before first declaration. This is because a
1278 -- library unit pragma argument must be the name of a library
1279 -- unit (RM 10.1.5(7)), but the only names permitted in this
1280 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1281 -- generic subprogram declarations or generic instantiations.
1285 ("pragma% misplaced, must be before first declaration");
1290 end Check_Valid_Library_Unit_Pragma
;
1296 procedure Error_Pragma
(Msg
: String) is
1298 Error_Msg_Name_1
:= Chars
(N
);
1299 Error_Msg_N
(Msg
, N
);
1303 ----------------------
1304 -- Error_Pragma_Arg --
1305 ----------------------
1307 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
) is
1309 Error_Msg_Name_1
:= Chars
(N
);
1310 Error_Msg_N
(Msg
, Get_Pragma_Arg
(Arg
));
1312 end Error_Pragma_Arg
;
1314 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
) is
1316 Error_Msg_Name_1
:= Chars
(N
);
1317 Error_Msg_N
(Msg1
, Get_Pragma_Arg
(Arg
));
1318 Error_Pragma_Arg
(Msg2
, Arg
);
1319 end Error_Pragma_Arg
;
1321 ----------------------------
1322 -- Error_Pragma_Arg_Ident --
1323 ----------------------------
1325 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
) is
1327 Error_Msg_Name_1
:= Chars
(N
);
1328 Error_Msg_N
(Msg
, Arg
);
1330 end Error_Pragma_Arg_Ident
;
1332 ------------------------
1333 -- Find_Lib_Unit_Name --
1334 ------------------------
1336 function Find_Lib_Unit_Name
return Entity_Id
is
1338 -- Return inner compilation unit entity, for case of nested
1339 -- categorization pragmas. This happens in generic unit.
1341 if Nkind
(Parent
(N
)) = N_Package_Specification
1342 and then Defining_Entity
(Parent
(N
)) /= Current_Scope
1344 return Defining_Entity
(Parent
(N
));
1347 return Current_Scope
;
1349 end Find_Lib_Unit_Name
;
1351 ----------------------------
1352 -- Find_Program_Unit_Name --
1353 ----------------------------
1355 procedure Find_Program_Unit_Name
(Id
: Node_Id
) is
1356 Unit_Name
: Entity_Id
;
1357 Unit_Kind
: Node_Kind
;
1358 P
: constant Node_Id
:= Parent
(N
);
1361 if Nkind
(P
) = N_Compilation_Unit
then
1362 Unit_Kind
:= Nkind
(Unit
(P
));
1364 if Unit_Kind
= N_Subprogram_Declaration
1365 or else Unit_Kind
= N_Package_Declaration
1366 or else Unit_Kind
in N_Generic_Declaration
1368 Unit_Name
:= Defining_Entity
(Unit
(P
));
1370 if Chars
(Id
) = Chars
(Unit_Name
) then
1371 Set_Entity
(Id
, Unit_Name
);
1372 Set_Etype
(Id
, Etype
(Unit_Name
));
1374 Set_Etype
(Id
, Any_Type
);
1376 ("cannot find program unit referenced by pragma%");
1380 Set_Etype
(Id
, Any_Type
);
1381 Error_Pragma
("pragma% inapplicable to this unit");
1388 end Find_Program_Unit_Name
;
1390 -------------------------
1391 -- Gather_Associations --
1392 -------------------------
1394 procedure Gather_Associations
1396 Args
: out Args_List
)
1401 -- Initialize all parameters to Empty
1403 for J
in Args
'Range loop
1407 -- That's all we have to do if there are no argument associations
1409 if No
(Pragma_Argument_Associations
(N
)) then
1413 -- Otherwise first deal with any positional parameters present
1415 Arg
:= First
(Pragma_Argument_Associations
(N
));
1417 for Index
in Args
'Range loop
1418 exit when No
(Arg
) or else Chars
(Arg
) /= No_Name
;
1419 Args
(Index
) := Expression
(Arg
);
1423 -- Positional parameters all processed, if any left, then we
1424 -- have too many positional parameters.
1426 if Present
(Arg
) and then Chars
(Arg
) = No_Name
then
1428 ("too many positional associations for pragma%", Arg
);
1431 -- Process named parameters if any are present
1433 while Present
(Arg
) loop
1434 if Chars
(Arg
) = No_Name
then
1436 ("positional association cannot follow named association",
1440 for Index
in Names
'Range loop
1441 if Names
(Index
) = Chars
(Arg
) then
1442 if Present
(Args
(Index
)) then
1444 ("duplicate argument association for pragma%", Arg
);
1446 Args
(Index
) := Expression
(Arg
);
1451 if Index
= Names
'Last then
1452 Error_Msg_Name_1
:= Chars
(N
);
1453 Error_Msg_N
("pragma% does not allow & argument", Arg
);
1455 -- Check for possible misspelling
1457 for Index1
in Names
'Range loop
1458 if Is_Bad_Spelling_Of
1459 (Get_Name_String
(Chars
(Arg
)),
1460 Get_Name_String
(Names
(Index1
)))
1462 Error_Msg_Name_1
:= Names
(Index1
);
1463 Error_Msg_N
("\possible misspelling of%", Arg
);
1475 end Gather_Associations
;
1477 --------------------
1478 -- Get_Pragma_Arg --
1479 --------------------
1481 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
is
1483 if Nkind
(Arg
) = N_Pragma_Argument_Association
then
1484 return Expression
(Arg
);
1494 procedure GNAT_Pragma
is
1496 Check_Restriction
(No_Implementation_Pragmas
, N
);
1499 --------------------------
1500 -- Is_Before_First_Decl --
1501 --------------------------
1503 function Is_Before_First_Decl
1504 (Pragma_Node
: Node_Id
;
1508 Item
: Node_Id
:= First
(Decls
);
1511 -- Only other pragmas can come before this pragma
1514 if No
(Item
) or else Nkind
(Item
) /= N_Pragma
then
1517 elsif Item
= Pragma_Node
then
1524 end Is_Before_First_Decl
;
1526 -----------------------------
1527 -- Is_Configuration_Pragma --
1528 -----------------------------
1530 -- A configuration pragma must appear in the context clause of
1531 -- a compilation unit, at the start of the list (i.e. only other
1532 -- pragmas may precede it).
1534 function Is_Configuration_Pragma
return Boolean is
1535 Lis
: constant List_Id
:= List_Containing
(N
);
1536 Par
: constant Node_Id
:= Parent
(N
);
1540 -- If no parent, then we are in the configuration pragma file,
1541 -- so the placement is definitely appropriate.
1546 -- Otherwise we must be in the context clause of a compilation unit
1547 -- and the only thing allowed before us in the context list is more
1548 -- configuration pragmas.
1550 elsif Nkind
(Par
) = N_Compilation_Unit
1551 and then Context_Items
(Par
) = Lis
1558 elsif Nkind
(Prg
) /= N_Pragma
then
1569 end Is_Configuration_Pragma
;
1571 ----------------------
1572 -- Pragma_Misplaced --
1573 ----------------------
1575 procedure Pragma_Misplaced
is
1577 Error_Pragma
("incorrect placement of pragma%");
1578 end Pragma_Misplaced
;
1580 ------------------------------------
1581 -- Process Atomic_Shared_Volatile --
1582 ------------------------------------
1584 procedure Process_Atomic_Shared_Volatile
is
1592 Check_Ada_83_Warning
;
1593 Check_No_Identifiers
;
1594 Check_Arg_Count
(1);
1595 Check_Arg_Is_Local_Name
(Arg1
);
1596 E_Id
:= Expression
(Arg1
);
1598 if Etype
(E_Id
) = Any_Type
then
1603 D
:= Declaration_Node
(E
);
1607 if Rep_Item_Too_Early
(E
, N
)
1609 Rep_Item_Too_Late
(E
, N
)
1613 Check_First_Subtype
(Arg1
);
1616 if Prag_Id
/= Pragma_Volatile
then
1618 Set_Is_Atomic
(Underlying_Type
(E
));
1621 Set_Is_Volatile
(E
);
1622 Set_Is_Volatile
(Underlying_Type
(E
));
1624 elsif K
= N_Object_Declaration
1625 or else (K
= N_Component_Declaration
1626 and then Original_Record_Component
(E
) = E
)
1628 if Rep_Item_Too_Late
(E
, N
) then
1632 if Prag_Id
/= Pragma_Volatile
then
1635 -- An interesting improvement here. If an object of type X
1636 -- is declared atomic, and the type X is not atomic, that's
1637 -- a pity, since it may not have appropraite alignment etc.
1638 -- We can rescue this in the special case where the object
1639 -- and type are in the same unit by just setting the type
1640 -- as atomic, so that the back end will process it as atomic.
1642 Utyp
:= Underlying_Type
(Etype
(E
));
1645 and then Sloc
(E
) > No_Location
1646 and then Sloc
(Utyp
) > No_Location
1648 Get_Source_File_Index
(Sloc
(E
)) =
1649 Get_Source_File_Index
(Sloc
(Underlying_Type
(Etype
(E
))))
1651 Set_Is_Atomic
(Underlying_Type
(Etype
(E
)));
1655 Set_Is_Volatile
(E
);
1659 ("inappropriate entity for pragma%", Arg1
);
1661 end Process_Atomic_Shared_Volatile
;
1663 ------------------------
1664 -- Process_Convention --
1665 ------------------------
1667 procedure Process_Convention
1668 (C
: out Convention_Id
;
1673 Comp_Unit
: Unit_Number_Type
;
1676 procedure Set_Convention_From_Pragma
(E
: Entity_Id
);
1677 -- Set convention in entity E, and also flag that the entity has a
1678 -- convention pragma. If entity is for a private or incomplete type,
1679 -- also set convention and flag on underlying type. This procedure
1680 -- also deals with the special case of C_Pass_By_Copy convention.
1682 --------------------------------
1683 -- Set_Convention_From_Pragma --
1684 --------------------------------
1686 procedure Set_Convention_From_Pragma
(E
: Entity_Id
) is
1688 Set_Convention
(E
, C
);
1689 Set_Has_Convention_Pragma
(E
);
1691 if Is_Incomplete_Or_Private_Type
(E
) then
1692 Set_Convention
(Underlying_Type
(E
), C
);
1693 Set_Has_Convention_Pragma
(Underlying_Type
(E
), True);
1696 -- A class-wide type should inherit the convention of
1697 -- the specific root type (although this isn't specified
1698 -- clearly by the RM).
1700 if Is_Type
(E
) and then Present
(Class_Wide_Type
(E
)) then
1701 Set_Convention
(Class_Wide_Type
(E
), C
);
1704 -- If the entity is a record type, then check for special case
1705 -- of C_Pass_By_Copy, which is treated the same as C except that
1706 -- the special record flag is set. This convention is also only
1707 -- permitted on record types (see AI95-00131).
1709 if Cname
= Name_C_Pass_By_Copy
then
1710 if Is_Record_Type
(E
) then
1711 Set_C_Pass_By_Copy
(Base_Type
(E
));
1712 elsif Is_Incomplete_Or_Private_Type
(E
)
1713 and then Is_Record_Type
(Underlying_Type
(E
))
1715 Set_C_Pass_By_Copy
(Base_Type
(Underlying_Type
(E
)));
1718 ("C_Pass_By_Copy convention allowed only for record type",
1723 -- If the entity is a derived boolean type, check for the
1724 -- special case of convention C, C++, or Fortran, where we
1725 -- consider any nonzero value to represent true.
1727 if Is_Discrete_Type
(E
)
1728 and then Root_Type
(Etype
(E
)) = Standard_Boolean
1734 C
= Convention_Fortran
)
1736 Set_Nonzero_Is_True
(Base_Type
(E
));
1738 end Set_Convention_From_Pragma
;
1740 -- Start of processing for Process_Convention
1743 Check_At_Least_N_Arguments
(2);
1744 Check_Arg_Is_Identifier
(Arg1
);
1745 Check_Optional_Identifier
(Arg1
, Name_Convention
);
1746 Cname
:= Chars
(Expression
(Arg1
));
1748 -- C_Pass_By_Copy is treated as a synonym for convention C
1749 -- (this is tested again below to set the critical flag)
1751 if Cname
= Name_C_Pass_By_Copy
then
1754 -- Otherwise we must have something in the standard convention list
1756 elsif Is_Convention_Name
(Cname
) then
1757 C
:= Get_Convention_Id
(Chars
(Expression
(Arg1
)));
1759 -- In DEC VMS, it seems that there is an undocumented feature
1760 -- that any unrecognized convention is treated as the default,
1761 -- which for us is convention C. It does not seem so terrible
1762 -- to do this unconditionally, silently in the VMS case, and
1763 -- with a warning in the non-VMS case.
1766 if not OpenVMS_On_Target
then
1768 ("?unrecognized convention name, C assumed",
1775 Check_Arg_Is_Local_Name
(Arg2
);
1776 Check_Optional_Identifier
(Arg2
, Name_Entity
);
1778 Id
:= Expression
(Arg2
);
1781 if not Is_Entity_Name
(Id
) then
1782 Error_Pragma_Arg
("entity name required", Arg2
);
1787 -- Go to renamed subprogram if present, since convention applies
1788 -- to the actual renamed entity, not to the renaming entity.
1790 if Is_Subprogram
(E
)
1791 and then Present
(Alias
(E
))
1792 and then Nkind
(Parent
(Declaration_Node
(E
))) =
1793 N_Subprogram_Renaming_Declaration
1798 -- Check that we not applying this to a specless body
1800 if Is_Subprogram
(E
)
1801 and then Nkind
(Parent
(Declaration_Node
(E
))) = N_Subprogram_Body
1804 ("pragma% requires separate spec and must come before body");
1807 -- Check that we are not applying this to a named constant
1809 if Ekind
(E
) = E_Named_Integer
1811 Ekind
(E
) = E_Named_Real
1813 Error_Msg_Name_1
:= Chars
(N
);
1815 ("cannot apply pragma% to named constant!",
1816 Get_Pragma_Arg
(Arg2
));
1818 ("\supply appropriate type for&!", Arg2
);
1821 if Etype
(E
) = Any_Type
1822 or else Rep_Item_Too_Early
(E
, N
)
1826 E
:= Underlying_Type
(E
);
1829 if Rep_Item_Too_Late
(E
, N
) then
1833 if Has_Convention_Pragma
(E
) then
1835 ("at most one Convention/Export/Import pragma is allowed", Arg2
);
1837 elsif Convention
(E
) = Convention_Protected
1838 or else Ekind
(Scope
(E
)) = E_Protected_Type
1841 ("a protected operation cannot be given a different convention",
1845 -- For Intrinsic, a subprogram is required
1847 if C
= Convention_Intrinsic
1848 and then not Is_Subprogram
(E
)
1849 and then not Is_Generic_Subprogram
(E
)
1852 ("second argument of pragma% must be a subprogram", Arg2
);
1855 -- For Stdcall, a subprogram, variable or subprogram type is required
1857 if C
= Convention_Stdcall
1858 and then not Is_Subprogram
(E
)
1859 and then not Is_Generic_Subprogram
(E
)
1860 and then Ekind
(E
) /= E_Variable
1863 and then Ekind
(Designated_Type
(E
)) = E_Subprogram_Type
)
1866 ("second argument of pragma% must be subprogram (type)",
1870 if not Is_Subprogram
(E
)
1871 and then not Is_Generic_Subprogram
(E
)
1873 Set_Convention_From_Pragma
(E
);
1877 Check_First_Subtype
(Arg2
);
1878 Set_Convention_From_Pragma
(Base_Type
(E
));
1880 -- For subprograms, we must set the convention on the
1881 -- internally generated directly designated type as well.
1883 if Ekind
(E
) = E_Access_Subprogram_Type
then
1884 Set_Convention_From_Pragma
(Directly_Designated_Type
(E
));
1888 -- For the subprogram case, set proper convention for all homonyms
1889 -- in same compilation unit.
1890 -- Is the test of compilation unit really necessary ???
1891 -- What about subprogram renamings here???
1894 Comp_Unit
:= Get_Source_Unit
(E
);
1895 Set_Convention_From_Pragma
(E
);
1900 exit when No
(E1
) or else Scope
(E1
) /= Current_Scope
;
1902 -- Note: below we are missing a check for Rep_Item_Too_Late.
1903 -- That is deliberate, we cannot chain the rep item on more
1904 -- than one Rep_Item chain, to be fixed later ???
1906 if Comp_Unit
= Get_Source_Unit
(E1
) then
1907 Set_Convention_From_Pragma
(E1
);
1912 end Process_Convention
;
1914 -----------------------------------------------------
1915 -- Process_Extended_Import_Export_Exception_Pragma --
1916 -----------------------------------------------------
1918 procedure Process_Extended_Import_Export_Exception_Pragma
1919 (Arg_Internal
: Node_Id
;
1920 Arg_External
: Node_Id
;
1929 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
1930 Def_Id
:= Entity
(Arg_Internal
);
1932 if Ekind
(Def_Id
) /= E_Exception
then
1934 ("pragma% must refer to declared exception", Arg_Internal
);
1937 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
1939 if Present
(Arg_Form
) then
1940 Check_Arg_Is_One_Of
(Arg_Form
, Name_Ada
, Name_VMS
);
1943 if Present
(Arg_Form
)
1944 and then Chars
(Arg_Form
) = Name_Ada
1948 Set_Is_VMS_Exception
(Def_Id
);
1949 Set_Exception_Code
(Def_Id
, No_Uint
);
1952 if Present
(Arg_Code
) then
1953 if not Is_VMS_Exception
(Def_Id
) then
1955 ("Code option for pragma% not allowed for Ada case",
1959 Check_Arg_Is_Static_Expression
(Arg_Code
, Any_Integer
);
1960 Code_Val
:= Expr_Value
(Arg_Code
);
1962 if not UI_Is_In_Int_Range
(Code_Val
) then
1964 ("Code option for pragma% must be in 32-bit range",
1968 Set_Exception_Code
(Def_Id
, Code_Val
);
1972 end Process_Extended_Import_Export_Exception_Pragma
;
1974 -------------------------------------------------
1975 -- Process_Extended_Import_Export_Internal_Arg --
1976 -------------------------------------------------
1978 procedure Process_Extended_Import_Export_Internal_Arg
1979 (Arg_Internal
: Node_Id
:= Empty
)
1984 if No
(Arg_Internal
) then
1985 Error_Pragma
("Internal parameter required for pragma%");
1988 if Nkind
(Arg_Internal
) = N_Identifier
then
1991 elsif Nkind
(Arg_Internal
) = N_Operator_Symbol
1992 and then (Prag_Id
= Pragma_Import_Function
1994 Prag_Id
= Pragma_Export_Function
)
2000 ("wrong form for Internal parameter for pragma%", Arg_Internal
);
2003 Check_Arg_Is_Local_Name
(Arg_Internal
);
2005 end Process_Extended_Import_Export_Internal_Arg
;
2007 --------------------------------------------------
2008 -- Process_Extended_Import_Export_Object_Pragma --
2009 --------------------------------------------------
2011 procedure Process_Extended_Import_Export_Object_Pragma
2012 (Arg_Internal
: Node_Id
;
2013 Arg_External
: Node_Id
;
2019 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2020 Def_Id
:= Entity
(Arg_Internal
);
2022 if Ekind
(Def_Id
) /= E_Constant
2023 and then Ekind
(Def_Id
) /= E_Variable
2026 ("pragma% must designate an object", Arg_Internal
);
2029 if Is_Psected
(Def_Id
) then
2031 ("previous Psect_Object applies, pragma % not permitted",
2035 if Rep_Item_Too_Late
(Def_Id
, N
) then
2039 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2041 if Present
(Arg_Size
)
2042 and then Nkind
(Arg_Size
) /= N_Identifier
2043 and then Nkind
(Arg_Size
) /= N_String_Literal
2046 ("pragma% Size argument must be identifier or string literal",
2050 -- Export_Object case
2052 if Prag_Id
= Pragma_Export_Object
then
2054 if not Is_Library_Level_Entity
(Def_Id
) then
2056 ("argument for pragma% must be library level entity",
2060 if Ekind
(Current_Scope
) = E_Generic_Package
then
2061 Error_Pragma
("pragma& cannot appear in a generic unit");
2064 if not Size_Known_At_Compile_Time
(Etype
(Def_Id
)) then
2066 ("exported object must have compile time known size",
2070 if Is_Exported
(Def_Id
) then
2072 ("?duplicate Export_Object pragma", N
);
2074 Set_Exported
(Def_Id
, Arg_Internal
);
2077 -- Import_Object case
2080 if Is_Concurrent_Type
(Etype
(Def_Id
)) then
2082 ("cannot use pragma% for task/protected object",
2086 if Ekind
(Def_Id
) = E_Constant
then
2088 ("cannot import a constant", Arg_Internal
);
2091 if Has_Discriminants
(Etype
(Def_Id
)) then
2093 ("imported value must be initialized?", Arg_Internal
);
2096 if Is_Access_Type
(Etype
(Def_Id
)) then
2098 ("cannot import object of an access type?", Arg_Internal
);
2101 if Is_Imported
(Def_Id
) then
2103 ("?duplicate Import_Object pragma", N
);
2105 Set_Imported
(Def_Id
);
2109 end Process_Extended_Import_Export_Object_Pragma
;
2111 ------------------------------------------------------
2112 -- Process_Extended_Import_Export_Subprogram_Pragma --
2113 ------------------------------------------------------
2115 procedure Process_Extended_Import_Export_Subprogram_Pragma
2116 (Arg_Internal
: Node_Id
;
2117 Arg_External
: Node_Id
;
2118 Arg_Parameter_Types
: Node_Id
;
2119 Arg_Result_Type
: Node_Id
:= Empty
;
2120 Arg_Mechanism
: Node_Id
;
2121 Arg_Result_Mechanism
: Node_Id
:= Empty
;
2122 Arg_First_Optional_Parameter
: Node_Id
:= Empty
)
2128 Ambiguous
: Boolean;
2132 function Same_Base_Type
(Ptype
, Formal
: Entity_Id
) return Boolean;
2133 -- Determines if Ptype references the type of Formal. Note that
2134 -- only the base types need to match according to the spec.
2136 function Same_Base_Type
(Ptype
, Formal
: Entity_Id
) return Boolean is
2140 if not Is_Entity_Name
(Ptype
)
2141 or else Entity
(Ptype
) = Any_Type
2146 return Base_Type
(Entity
(Ptype
)) = Base_Type
(Etype
(Formal
));
2149 -- Start of processing for
2150 -- Process_Extended_Import_Export_Subprogram_Pragma
2153 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2154 Hom_Id
:= Entity
(Arg_Internal
);
2158 -- Loop through homonyms (overloadings) of Hom_Id
2160 while Present
(Hom_Id
) loop
2161 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
2163 -- We need a subprogram in the current scope
2165 if not Is_Subprogram
(Def_Id
)
2166 or else Scope
(Def_Id
) /= Current_Scope
2173 -- Pragma cannot apply to subprogram body
2175 if Is_Subprogram
(Def_Id
)
2178 (Declaration_Node
(Def_Id
))) = N_Subprogram_Body
2181 ("pragma% requires separate spec"
2182 & " and must come before body");
2185 -- Test result type if given, note that the result type
2186 -- parameter can only be present for the function cases.
2188 if Present
(Arg_Result_Type
)
2189 and then not Same_Base_Type
(Arg_Result_Type
, Def_Id
)
2193 -- Test parameter types if given. Note that this parameter
2194 -- has not been analyzed (and must not be, since it is
2195 -- semantic nonsense), so we get it as the parser left it.
2197 elsif Present
(Arg_Parameter_Types
) then
2198 Check_Matching_Types
: declare
2203 Formal
:= First_Formal
(Def_Id
);
2205 if Nkind
(Arg_Parameter_Types
) = N_Null
then
2206 if Present
(Formal
) then
2210 -- A list of one type, e.g. (List) is parsed as
2211 -- a parenthesized expression.
2213 elsif Nkind
(Arg_Parameter_Types
) /= N_Aggregate
2214 and then Paren_Count
(Arg_Parameter_Types
) = 1
2217 or else Present
(Next_Formal
(Formal
))
2222 Same_Base_Type
(Arg_Parameter_Types
, Formal
);
2225 -- A list of more than one type is parsed as a aggregate
2227 elsif Nkind
(Arg_Parameter_Types
) = N_Aggregate
2228 and then Paren_Count
(Arg_Parameter_Types
) = 0
2230 Ptype
:= First
(Expressions
(Arg_Parameter_Types
));
2232 while Present
(Ptype
) or else Present
(Formal
) loop
2235 or else not Same_Base_Type
(Ptype
, Formal
)
2240 Next_Formal
(Formal
);
2245 -- Anything else is of the wrong form
2249 ("wrong form for Parameter_Types parameter",
2250 Arg_Parameter_Types
);
2252 end Check_Matching_Types
;
2255 -- Match is now False if the entry we found did not match
2256 -- either a supplied Parameter_Types or Result_Types argument
2262 -- Ambiguous case, the flag Ambiguous shows if we already
2263 -- detected this and output the initial messages.
2266 if not Ambiguous
then
2268 Error_Msg_Name_1
:= Chars
(N
);
2270 ("pragma% does not uniquely identify subprogram!",
2272 Error_Msg_Sloc
:= Sloc
(Ent
);
2273 Error_Msg_N
("matching subprogram #!", N
);
2277 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2278 Error_Msg_N
("matching subprogram #!", N
);
2283 Hom_Id
:= Homonym
(Hom_Id
);
2286 -- See if we found an entry
2289 if not Ambiguous
then
2290 if Is_Generic_Subprogram
(Entity
(Arg_Internal
)) then
2292 ("pragma% cannot be given for generic subprogram");
2296 ("pragma% does not identify local subprogram");
2303 -- Import pragmas must be be for imported entities
2305 if (Prag_Id
= Pragma_Import_Function
2307 Prag_Id
= Pragma_Import_Procedure
2309 Prag_Id
= Pragma_Import_Valued_Procedure
)
2311 if not Is_Imported
(Ent
) then
2313 ("pragma Import or Interface must precede pragma%");
2316 -- For the Export cases, the pragma Export is sufficient to set
2317 -- the entity as exported, if it is not exported already. We
2318 -- leave the default Ada convention in this case.
2321 Set_Exported
(Ent
, Arg_Internal
);
2324 -- Special processing for Valued_Procedure cases
2326 if Prag_Id
= Pragma_Import_Valued_Procedure
2328 Prag_Id
= Pragma_Export_Valued_Procedure
2330 Formal
:= First_Formal
(Ent
);
2334 ("at least one parameter required for pragma%");
2336 elsif Ekind
(Formal
) /= E_Out_Parameter
then
2338 ("first parameter must have mode out for pragma%");
2341 Set_Is_Valued_Procedure
(Ent
);
2345 Set_Extended_Import_Export_External_Name
(Ent
, Arg_External
);
2347 -- Process Result_Mechanism argument if present. We have already
2348 -- checked that this is only allowed for the function case.
2350 if Present
(Arg_Result_Mechanism
) then
2351 Set_Mechanism_Value
(Ent
, Arg_Result_Mechanism
);
2354 -- Process Mechanism parameter if present. Note that this parameter
2355 -- is not analyzed, and must not be analyzed since it is semantic
2356 -- nonsense, so we get it in exactly as the parser left it.
2358 if Present
(Arg_Mechanism
) then
2367 -- A single mechanism association without a formal parameter
2368 -- name is parsed as a parenthesized expression. All other
2369 -- cases are parsed as aggregates, so we rewrite the single
2370 -- parameter case as an aggregate for consistency.
2372 if Nkind
(Arg_Mechanism
) /= N_Aggregate
2373 and then Paren_Count
(Arg_Mechanism
) = 1
2375 Rewrite
(Arg_Mechanism
,
2376 Make_Aggregate
(Sloc
(Arg_Mechanism
),
2377 Expressions
=> New_List
(
2378 Relocate_Node
(Arg_Mechanism
))));
2381 -- Case of only mechanism name given, applies to all formals
2383 if Nkind
(Arg_Mechanism
) /= N_Aggregate
then
2384 Formal
:= First_Formal
(Ent
);
2385 while Present
(Formal
) loop
2386 Set_Mechanism_Value
(Formal
, Arg_Mechanism
);
2387 Next_Formal
(Formal
);
2390 -- Case of list of mechanism associations given
2393 if Null_Record_Present
(Arg_Mechanism
) then
2395 ("inappropriate form for Mechanism parameter",
2399 -- Deal with positional ones first
2401 Formal
:= First_Formal
(Ent
);
2402 if Present
(Expressions
(Arg_Mechanism
)) then
2403 Mname
:= First
(Expressions
(Arg_Mechanism
));
2405 while Present
(Mname
) loop
2408 ("too many mechanism associations", Mname
);
2411 Set_Mechanism_Value
(Formal
, Mname
);
2412 Next_Formal
(Formal
);
2417 -- Deal with named entries
2419 if Present
(Component_Associations
(Arg_Mechanism
)) then
2420 Massoc
:= First
(Component_Associations
(Arg_Mechanism
));
2422 while Present
(Massoc
) loop
2423 Choice
:= First
(Choices
(Massoc
));
2425 if Nkind
(Choice
) /= N_Identifier
2426 or else Present
(Next
(Choice
))
2429 ("incorrect form for mechanism association",
2433 Formal
:= First_Formal
(Ent
);
2437 ("parameter name & not present", Choice
);
2440 if Chars
(Choice
) = Chars
(Formal
) then
2442 (Formal
, Expression
(Massoc
));
2446 Next_Formal
(Formal
);
2456 -- Process First_Optional_Parameter argument if present. We have
2457 -- already checked that this is only allowed for the Import case.
2459 if Present
(Arg_First_Optional_Parameter
) then
2460 if Nkind
(Arg_First_Optional_Parameter
) /= N_Identifier
then
2462 ("first optional parameter must be formal parameter name",
2463 Arg_First_Optional_Parameter
);
2466 Formal
:= First_Formal
(Ent
);
2470 ("specified formal parameter& not found",
2471 Arg_First_Optional_Parameter
);
2474 exit when Chars
(Formal
) =
2475 Chars
(Arg_First_Optional_Parameter
);
2477 Next_Formal
(Formal
);
2480 Set_First_Optional_Parameter
(Ent
, Formal
);
2482 -- Check specified and all remaining formals have right form
2484 while Present
(Formal
) loop
2485 if Ekind
(Formal
) /= E_In_Parameter
then
2487 ("optional formal& is not of mode in!",
2488 Arg_First_Optional_Parameter
, Formal
);
2491 Dval
:= Default_Value
(Formal
);
2493 if not Present
(Dval
) then
2495 ("optional formal& does not have default value!",
2496 Arg_First_Optional_Parameter
, Formal
);
2498 elsif Compile_Time_Known_Value_Or_Aggr
(Dval
) then
2503 ("default value for optional formal& is non-static!",
2504 Arg_First_Optional_Parameter
, Formal
);
2508 Set_Is_Optional_Parameter
(Formal
);
2509 Next_Formal
(Formal
);
2512 end Process_Extended_Import_Export_Subprogram_Pragma
;
2514 --------------------------
2515 -- Process_Generic_List --
2516 --------------------------
2518 procedure Process_Generic_List
is
2524 Check_No_Identifiers
;
2525 Check_At_Least_N_Arguments
(1);
2528 while Present
(Arg
) loop
2529 Exp
:= Expression
(Arg
);
2532 if not Is_Entity_Name
(Exp
)
2534 (not Is_Generic_Instance
(Entity
(Exp
))
2536 not Is_Generic_Unit
(Entity
(Exp
)))
2539 ("pragma% argument must be name of generic unit/instance",
2545 end Process_Generic_List
;
2547 ---------------------------------
2548 -- Process_Import_Or_Interface --
2549 ---------------------------------
2551 procedure Process_Import_Or_Interface
is
2557 Process_Convention
(C
, Def_Id
);
2558 Kill_Size_Check_Code
(Def_Id
);
2559 Note_Possible_Modification
(Expression
(Arg2
));
2561 if Ekind
(Def_Id
) = E_Variable
2563 Ekind
(Def_Id
) = E_Constant
2565 -- User initialization is not allowed for imported object, but
2566 -- the object declaration may contain a default initialization,
2567 -- that will be discarded.
2569 if Present
(Expression
(Parent
(Def_Id
)))
2570 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
2572 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2574 ("no initialization allowed for declaration of& #",
2575 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2579 Set_Imported
(Def_Id
);
2580 Set_Is_Public
(Def_Id
);
2581 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
2584 elsif Is_Subprogram
(Def_Id
)
2585 or else Is_Generic_Subprogram
(Def_Id
)
2587 -- If the name is overloaded, pragma applies to all of the
2588 -- denoted entities in the same declarative part.
2592 while Present
(Hom_Id
) loop
2593 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
2595 -- Ignore inherited subprograms because the pragma will
2596 -- apply to the parent operation, which is the one called.
2598 if Is_Overloadable
(Def_Id
)
2599 and then Present
(Alias
(Def_Id
))
2603 -- Verify that the homonym is in the same declarative
2604 -- part (not just the same scope).
2606 elsif Parent
(Unit_Declaration_Node
(Def_Id
)) /= Parent
(N
)
2607 and then Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
2612 Set_Imported
(Def_Id
);
2614 -- If Import intrinsic, set intrinsic flag
2615 -- and verify that it is known as such.
2617 if C
= Convention_Intrinsic
then
2618 Set_Is_Intrinsic_Subprogram
(Def_Id
);
2619 Check_Intrinsic_Subprogram
2620 (Def_Id
, Expression
(Arg2
));
2623 -- All interfaced procedures need an external
2624 -- symbol created for them since they are
2625 -- always referenced from another object file.
2627 Set_Is_Public
(Def_Id
);
2628 Set_Has_Completion
(Def_Id
);
2629 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
2632 if Is_Compilation_Unit
(Hom_Id
) then
2634 -- Its possible homonyms are not affected by the pragma.
2635 -- Such homonyms might be present in the context of other
2636 -- units being compiled.
2641 Hom_Id
:= Homonym
(Hom_Id
);
2645 -- When the convention is Java, we also allow Import to be given
2646 -- for packages, exceptions, and record components.
2648 elsif C
= Convention_Java
2649 and then (Ekind
(Def_Id
) = E_Package
2650 or else Ekind
(Def_Id
) = E_Exception
2651 or else Nkind
(Parent
(Def_Id
)) = N_Component_Declaration
)
2653 Set_Imported
(Def_Id
);
2654 Set_Is_Public
(Def_Id
);
2655 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
2659 ("second argument of pragma% must be object or subprogram",
2663 -- If this pragma applies to a compilation unit, then the unit,
2664 -- which is a subprogram, does not require (or allow) a body.
2665 -- We also do not need to elaborate imported procedures.
2667 if Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
2669 Cunit
: constant Node_Id
:= Parent
(Parent
(N
));
2672 Set_Body_Required
(Cunit
, False);
2676 end Process_Import_Or_Interface
;
2678 --------------------
2679 -- Process_Inline --
2680 --------------------
2682 procedure Process_Inline
(Active
: Boolean) is
2689 procedure Make_Inline
(Subp
: Entity_Id
);
2690 -- Subp is the defining unit name of the subprogram
2691 -- declaration. Set the flag, as well as the flag in the
2692 -- corresponding body, if there is one present.
2694 procedure Set_Inline_Flags
(Subp
: Entity_Id
);
2695 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp
2701 procedure Make_Inline
(Subp
: Entity_Id
) is
2702 Kind
: Entity_Kind
:= Ekind
(Subp
);
2703 Inner_Subp
: Entity_Id
:= Subp
;
2706 if Etype
(Subp
) = Any_Type
then
2709 -- Here we have a candidate for inlining, but we must exclude
2710 -- derived operations. Otherwise we will end up trying to
2711 -- inline a phantom declaration, and the result would be to
2712 -- drag in a body which has no direct inlining associated with
2713 -- it. That would not only be inefficient but would also result
2714 -- in the backend doing cross-unit inlining in cases where it
2715 -- was definitely inappropriate to do so.
2717 -- However, a simple Comes_From_Source test is insufficient,
2718 -- since we do want to allow inlining of generic instances,
2719 -- which also do not come from source. Predefined operators do
2720 -- not come from source but are not inlineable either.
2722 elsif not Comes_From_Source
(Subp
)
2723 and then not Is_Generic_Instance
(Subp
)
2724 and then Scope
(Subp
) /= Standard_Standard
2729 -- The referenced entity must either be the enclosing entity,
2730 -- or an entity declared within the current open scope.
2732 elsif Present
(Scope
(Subp
))
2733 and then Scope
(Subp
) /= Current_Scope
2734 and then Subp
/= Current_Scope
2737 ("argument of% must be entity in current scope", Assoc
);
2741 -- Processing for procedure, operator or function.
2742 -- If subprogram is aliased (as for an instance) indicate
2743 -- that the renamed entity is inlined.
2745 if Kind
= E_Procedure
2746 or else Kind
= E_Function
2747 or else Kind
= E_Operator
2749 while Present
(Alias
(Inner_Subp
)) loop
2750 Inner_Subp
:= Alias
(Inner_Subp
);
2753 Set_Inline_Flags
(Inner_Subp
);
2755 Decl
:= Parent
(Parent
(Inner_Subp
));
2757 if Nkind
(Decl
) = N_Subprogram_Declaration
2758 and then Present
(Corresponding_Body
(Decl
))
2760 Set_Inline_Flags
(Corresponding_Body
(Decl
));
2765 -- For a generic subprogram set flag as well, for use at
2766 -- the point of instantiation, to determine whether the
2767 -- body should be generated.
2769 elsif Kind
= E_Generic_Procedure
2770 or else Kind
= E_Generic_Function
2772 Set_Inline_Flags
(Subp
);
2775 -- Literals are by definition inlined.
2777 elsif Kind
= E_Enumeration_Literal
then
2780 -- Anything else is an error
2784 ("expect subprogram name for pragma%", Assoc
);
2788 ----------------------
2789 -- Set_Inline_Flags --
2790 ----------------------
2792 procedure Set_Inline_Flags
(Subp
: Entity_Id
) is
2795 Set_Is_Inlined
(Subp
, True);
2798 if not Has_Pragma_Inline
(Subp
) then
2799 Set_Has_Pragma_Inline
(Subp
);
2800 Set_Next_Rep_Item
(N
, First_Rep_Item
(Subp
));
2801 Set_First_Rep_Item
(Subp
, N
);
2803 end Set_Inline_Flags
;
2805 -- Start of processing for Process_Inline
2808 Check_No_Identifiers
;
2809 Check_At_Least_N_Arguments
(1);
2812 Inline_Processing_Required
:= True;
2816 while Present
(Assoc
) loop
2817 Subp_Id
:= Expression
(Assoc
);
2821 if Is_Entity_Name
(Subp_Id
) then
2822 Subp
:= Entity
(Subp_Id
);
2824 if Subp
= Any_Id
then
2830 while Present
(Homonym
(Subp
))
2831 and then Scope
(Homonym
(Subp
)) = Current_Scope
2833 Make_Inline
(Homonym
(Subp
));
2834 Subp
:= Homonym
(Subp
);
2841 ("inappropriate argument for pragma%", Assoc
);
2849 ----------------------------
2850 -- Process_Interface_Name --
2851 ----------------------------
2853 procedure Process_Interface_Name
2854 (Subprogram_Def
: Entity_Id
;
2860 String_Val
: String_Id
;
2862 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
);
2863 -- SN is a string literal node for an interface name. This routine
2864 -- performs some minimal checks that the name is reasonable. In
2865 -- particular that no spaces or other obviously incorrect characters
2866 -- appear. This is only a warning, since any characters are allowed.
2868 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
) is
2869 S
: constant String_Id
:= Strval
(Expr_Value_S
(SN
));
2870 SL
: constant Nat
:= String_Length
(S
);
2875 Error_Msg_N
("interface name cannot be null string", SN
);
2878 for J
in 1 .. SL
loop
2879 C
:= Get_String_Char
(S
, J
);
2881 if not In_Character_Range
(C
)
2882 or else Get_Character
(C
) = ' '
2883 or else Get_Character
(C
) = ','
2886 ("?interface name contains illegal character", SN
);
2889 end Check_Form_Of_Interface_Name
;
2891 -- Start of processing for Process_Interface_Name
2894 if No
(Link_Arg
) then
2895 if No
(Ext_Arg
) then
2898 elsif Chars
(Ext_Arg
) = Name_Link_Name
then
2900 Link_Nam
:= Expression
(Ext_Arg
);
2903 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
2904 Ext_Nam
:= Expression
(Ext_Arg
);
2909 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
2910 Check_Optional_Identifier
(Link_Arg
, Name_Link_Name
);
2911 Ext_Nam
:= Expression
(Ext_Arg
);
2912 Link_Nam
:= Expression
(Link_Arg
);
2915 -- Check expressions for external name and link name are static
2917 if Present
(Ext_Nam
) then
2918 Check_Arg_Is_Static_Expression
(Ext_Nam
, Standard_String
);
2919 Check_Form_Of_Interface_Name
(Ext_Nam
);
2921 -- Verify that the external name is not the name of a local
2922 -- entity, which would hide the imported one and lead to
2923 -- run-time surprises. The problem can only arise for entities
2924 -- declared in a package body (otherwise the external name is
2925 -- fully qualified and won't conflict).
2933 if Prag_Id
= Pragma_Import
then
2934 String_To_Name_Buffer
(Strval
(Expr_Value_S
(Ext_Nam
)));
2936 E
:= Entity_Id
(Get_Name_Table_Info
(Nam
));
2938 if Nam
/= Chars
(Subprogram_Def
)
2939 and then Present
(E
)
2940 and then not Is_Overloadable
(E
)
2941 and then Is_Immediately_Visible
(E
)
2942 and then not Is_Imported
(E
)
2943 and then Ekind
(Scope
(E
)) = E_Package
2947 while Present
(Par
) loop
2948 if Nkind
(Par
) = N_Package_Body
then
2949 Error_Msg_Sloc
:= Sloc
(E
);
2951 ("imported entity is hidden by & declared#",
2956 Par
:= Parent
(Par
);
2963 if Present
(Link_Nam
) then
2964 Check_Arg_Is_Static_Expression
(Link_Nam
, Standard_String
);
2965 Check_Form_Of_Interface_Name
(Link_Nam
);
2968 -- If there is no link name, just set the external name
2970 if No
(Link_Nam
) then
2971 Set_Encoded_Interface_Name
2972 (Get_Base_Subprogram
(Subprogram_Def
),
2973 Adjust_External_Name_Case
(Expr_Value_S
(Ext_Nam
)));
2975 -- For the Link_Name case, the given literal is preceded by an
2976 -- asterisk, which indicates to GCC that the given name should
2977 -- be taken literally, and in particular that no prepending of
2978 -- underlines should occur, even in systems where this is the
2983 Store_String_Char
(Get_Char_Code
('*'));
2984 String_Val
:= Strval
(Expr_Value_S
(Link_Nam
));
2986 for J
in 1 .. String_Length
(String_Val
) loop
2987 Store_String_Char
(Get_String_Char
(String_Val
, J
));
2991 Make_String_Literal
(Sloc
(Link_Nam
), End_String
);
2993 Set_Encoded_Interface_Name
2994 (Get_Base_Subprogram
(Subprogram_Def
), Link_Nam
);
2996 end Process_Interface_Name
;
2998 -----------------------------------------
2999 -- Process_Interrupt_Or_Attach_Handler --
3000 -----------------------------------------
3002 procedure Process_Interrupt_Or_Attach_Handler
is
3003 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
3004 Prot_Proc
: constant Entity_Id
:= Entity
(Arg1_X
);
3005 Prot_Type
: constant Entity_Id
:= Scope
(Prot_Proc
);
3008 Set_Is_Interrupt_Handler
(Prot_Proc
);
3010 if Prag_Id
= Pragma_Interrupt_Handler
3011 or Prag_Id
= Pragma_Attach_Handler
3013 Record_Rep_Item
(Prot_Type
, N
);
3016 end Process_Interrupt_Or_Attach_Handler
;
3018 ---------------------------------
3019 -- Process_Suppress_Unsuppress --
3020 ---------------------------------
3022 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean) is
3026 Effective
: Boolean;
3028 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
);
3029 -- Used to suppress a single check on the given entity
3031 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
) is
3033 -- First set appropriate suppress flags in the entity
3036 when Access_Check
=>
3037 Effective
:= Suppress_Access_Checks
(E
);
3038 Set_Suppress_Access_Checks
(E
, Suppress_Case
);
3040 when Accessibility_Check
=>
3041 Effective
:= Suppress_Accessibility_Checks
(E
);
3042 Set_Suppress_Accessibility_Checks
(E
, Suppress_Case
);
3044 when Discriminant_Check
=>
3045 Effective
:= Suppress_Discriminant_Checks
(E
);
3046 Set_Suppress_Discriminant_Checks
(E
, Suppress_Case
);
3048 when Division_Check
=>
3049 Effective
:= Suppress_Division_Checks
(E
);
3050 Set_Suppress_Division_Checks
(E
, Suppress_Case
);
3052 when Elaboration_Check
=>
3053 Effective
:= Suppress_Elaboration_Checks
(E
);
3054 Set_Suppress_Elaboration_Checks
(E
, Suppress_Case
);
3057 Effective
:= Suppress_Index_Checks
(E
);
3058 Set_Suppress_Index_Checks
(E
, Suppress_Case
);
3060 when Length_Check
=>
3061 Effective
:= Suppress_Length_Checks
(E
);
3062 Set_Suppress_Length_Checks
(E
, Suppress_Case
);
3064 when Overflow_Check
=>
3065 Effective
:= Suppress_Overflow_Checks
(E
);
3066 Set_Suppress_Overflow_Checks
(E
, Suppress_Case
);
3069 Effective
:= Suppress_Range_Checks
(E
);
3070 Set_Suppress_Range_Checks
(E
, Suppress_Case
);
3072 when Storage_Check
=>
3073 Effective
:= Suppress_Storage_Checks
(E
);
3074 Set_Suppress_Storage_Checks
(E
, Suppress_Case
);
3077 Effective
:= Suppress_Tag_Checks
(E
);
3078 Set_Suppress_Tag_Checks
(E
, Suppress_Case
);
3081 Suppress_Unsuppress_Echeck
(E
, Access_Check
);
3082 Suppress_Unsuppress_Echeck
(E
, Accessibility_Check
);
3083 Suppress_Unsuppress_Echeck
(E
, Discriminant_Check
);
3084 Suppress_Unsuppress_Echeck
(E
, Division_Check
);
3085 Suppress_Unsuppress_Echeck
(E
, Elaboration_Check
);
3086 Suppress_Unsuppress_Echeck
(E
, Index_Check
);
3087 Suppress_Unsuppress_Echeck
(E
, Length_Check
);
3088 Suppress_Unsuppress_Echeck
(E
, Overflow_Check
);
3089 Suppress_Unsuppress_Echeck
(E
, Range_Check
);
3090 Suppress_Unsuppress_Echeck
(E
, Storage_Check
);
3091 Suppress_Unsuppress_Echeck
(E
, Tag_Check
);
3094 -- If the entity is not declared in the current scope, then we
3095 -- make an entry in the Entity_Suppress table so that the flag
3096 -- will be removed on exit. This entry is only made if the
3097 -- suppress did something (i.e. the flag was not already set).
3099 if Effective
and then Scope
(E
) /= Current_Scope
then
3100 Entity_Suppress
.Increment_Last
;
3101 Entity_Suppress
.Table
3102 (Entity_Suppress
.Last
).Entity
:= E
;
3103 Entity_Suppress
.Table
3104 (Entity_Suppress
.Last
).Check
:= C
;
3107 -- If this is a first subtype, and the base type is distinct,
3108 -- then also set the suppress flags on the base type.
3110 if Is_First_Subtype
(E
)
3111 and then Etype
(E
) /= E
3113 Suppress_Unsuppress_Echeck
(Etype
(E
), C
);
3115 end Suppress_Unsuppress_Echeck
;
3117 -- Start of processing for Process_Suppress_Unsuppress
3120 -- Suppress/Unsuppress can appear as a configuration pragma,
3121 -- or in a declarative part or a package spec (RM 11.5(5))
3123 if not Is_Configuration_Pragma
then
3124 Check_Is_In_Decl_Part_Or_Package_Spec
;
3127 Check_At_Least_N_Arguments
(1);
3128 Check_At_Most_N_Arguments
(2);
3129 Check_No_Identifier
(Arg1
);
3130 Check_Arg_Is_Identifier
(Arg1
);
3132 if not Is_Check_Name
(Chars
(Expression
(Arg1
))) then
3134 ("argument of pragma% is not valid check name", Arg1
);
3137 C
:= Get_Check_Id
(Chars
(Expression
(Arg1
)));
3140 if Arg_Count
= 1 then
3142 when Access_Check
=>
3143 Scope_Suppress
.Access_Checks
:= Suppress_Case
;
3145 when Accessibility_Check
=>
3146 Scope_Suppress
.Accessibility_Checks
:= Suppress_Case
;
3148 when Discriminant_Check
=>
3149 Scope_Suppress
.Discriminant_Checks
:= Suppress_Case
;
3151 when Division_Check
=>
3152 Scope_Suppress
.Division_Checks
:= Suppress_Case
;
3154 when Elaboration_Check
=>
3155 Scope_Suppress
.Elaboration_Checks
:= Suppress_Case
;
3158 Scope_Suppress
.Index_Checks
:= Suppress_Case
;
3160 when Length_Check
=>
3161 Scope_Suppress
.Length_Checks
:= Suppress_Case
;
3163 when Overflow_Check
=>
3164 Scope_Suppress
.Overflow_Checks
:= Suppress_Case
;
3167 Scope_Suppress
.Range_Checks
:= Suppress_Case
;
3169 when Storage_Check
=>
3170 Scope_Suppress
.Storage_Checks
:= Suppress_Case
;
3173 Scope_Suppress
.Tag_Checks
:= Suppress_Case
;
3176 Scope_Suppress
:= (others => Suppress_Case
);
3180 -- Case of two arguments present, where the check is
3181 -- suppressed for a specified entity (given as the second
3182 -- argument of the pragma)
3185 Check_Optional_Identifier
(Arg2
, Name_On
);
3186 E_Id
:= Expression
(Arg2
);
3189 if not Is_Entity_Name
(E_Id
) then
3191 ("second argument of pragma% must be entity name", Arg2
);
3200 Suppress_Unsuppress_Echeck
(E
, C
);
3202 if Is_Generic_Instance
(E
)
3203 and then Is_Subprogram
(E
)
3204 and then Present
(Alias
(E
))
3206 Suppress_Unsuppress_Echeck
(Alias
(E
), C
);
3209 if C
= Elaboration_Check
and then Suppress_Case
then
3210 Set_Suppress_Elaboration_Warnings
(E
);
3213 -- If we are within a package specification, the
3214 -- pragma only applies to homonyms in the same scope.
3216 exit when No
(Homonym
(E
))
3217 or else (Scope
(Homonym
(E
)) /= Current_Scope
3218 and then Ekind
(Current_Scope
) = E_Package
3219 and then not In_Package_Body
(Current_Scope
));
3226 end Process_Suppress_Unsuppress
;
3232 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
) is
3234 if Is_Imported
(E
) then
3236 ("cannot export entity& that was previously imported", Arg
);
3238 elsif Present
(Address_Clause
(E
)) then
3240 ("cannot export entity& that has an address clause", Arg
);
3243 Set_Is_Exported
(E
);
3245 -- Deal with exporting non-library level entity
3247 if not Is_Library_Level_Entity
(E
) then
3249 -- Not allowed at all for subprograms
3251 if Is_Subprogram
(E
) then
3252 Error_Pragma_Arg
("local subprogram& cannot be exported", Arg
);
3254 -- Otherwise set public and statically allocated
3258 Set_Is_Statically_Allocated
(E
);
3262 if Inside_A_Generic
then
3264 ("all instances of& will have the same external name?", Arg
, E
);
3269 ----------------------------------------------
3270 -- Set_Extended_Import_Export_External_Name --
3271 ----------------------------------------------
3273 procedure Set_Extended_Import_Export_External_Name
3274 (Internal_Ent
: Entity_Id
;
3275 Arg_External
: Node_Id
)
3277 Old_Name
: constant Node_Id
:= Interface_Name
(Internal_Ent
);
3281 if No
(Arg_External
) then
3284 elsif Nkind
(Arg_External
) = N_String_Literal
then
3285 if String_Length
(Strval
(Arg_External
)) = 0 then
3288 New_Name
:= Adjust_External_Name_Case
(Arg_External
);
3291 elsif Nkind
(Arg_External
) = N_Identifier
then
3292 New_Name
:= Get_Default_External_Name
(Arg_External
);
3296 ("incorrect form for External parameter for pragma%",
3300 -- If we already have an external name set (by a prior normal
3301 -- Import or Export pragma), then the external names must match
3303 if Present
(Interface_Name
(Internal_Ent
)) then
3305 S1
: constant String_Id
:= Strval
(Old_Name
);
3306 S2
: constant String_Id
:= Strval
(New_Name
);
3309 -- Called if names do not match
3311 procedure Mismatch
is
3313 Error_Msg_Sloc
:= Sloc
(Old_Name
);
3315 ("external name does not match that given #",
3320 if String_Length
(S1
) /= String_Length
(S2
) then
3324 for J
in 1 .. String_Length
(S1
) loop
3325 if Get_String_Char
(S1
, J
) /= Get_String_Char
(S2
, J
) then
3332 -- Otherwise set the given name
3335 Set_Encoded_Interface_Name
(Internal_Ent
, New_Name
);
3338 end Set_Extended_Import_Export_External_Name
;
3344 procedure Set_Imported
(E
: Entity_Id
) is
3346 Error_Msg_Sloc
:= Sloc
(E
);
3348 if Is_Exported
(E
) or else Is_Imported
(E
) then
3349 Error_Msg_NE
("import of& declared# not allowed", N
, E
);
3351 if Is_Exported
(E
) then
3352 Error_Msg_N
("\entity was previously exported", N
);
3354 Error_Msg_N
("\entity was previously imported", N
);
3357 Error_Pragma
("\(pragma% applies to all previous entities)");
3360 Set_Is_Imported
(E
);
3362 -- If the entity is an object that is not at the library
3363 -- level, then it is statically allocated. We do not worry
3364 -- about objects with address clauses in this context since
3365 -- they are not really imported in the linker sense.
3368 and then not Is_Library_Level_Entity
(E
)
3369 and then No
(Address_Clause
(E
))
3371 Set_Is_Statically_Allocated
(E
);
3376 -------------------------
3377 -- Set_Mechanism_Value --
3378 -------------------------
3380 -- Note: the mechanism name has not been analyzed (and cannot indeed
3381 -- be analyzed, since it is semantic nonsense), so we get it in the
3382 -- exact form created by the parser.
3384 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
) is
3388 procedure Bad_Class
;
3389 -- Signal bad descriptor class name
3391 procedure Bad_Mechanism
;
3392 -- Signal bad mechanism name
3394 procedure Bad_Class
is
3396 Error_Pragma_Arg
("unrecognized descriptor class name", Class
);
3399 procedure Bad_Mechanism
is
3401 Error_Pragma_Arg
("unrecognized mechanism name", Mech_Name
);
3404 -- Start of processing for Set_Mechanism_Value
3407 if Mechanism
(Ent
) /= Default_Mechanism
then
3409 ("mechanism for & has already been set", Mech_Name
, Ent
);
3412 -- MECHANISM_NAME ::= value | reference | descriptor
3414 if Nkind
(Mech_Name
) = N_Identifier
then
3415 if Chars
(Mech_Name
) = Name_Value
then
3416 Set_Mechanism
(Ent
, By_Copy
);
3419 elsif Chars
(Mech_Name
) = Name_Reference
then
3420 Set_Mechanism
(Ent
, By_Reference
);
3423 elsif Chars
(Mech_Name
) = Name_Descriptor
then
3424 Check_VMS
(Mech_Name
);
3425 Set_Mechanism
(Ent
, By_Descriptor
);
3428 elsif Chars
(Mech_Name
) = Name_Copy
then
3430 ("bad mechanism name, Value assumed", Mech_Name
);
3436 -- MECHANISM_NAME ::= descriptor (CLASS_NAME)
3437 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3439 -- Note: this form is parsed as an indexed component
3441 elsif Nkind
(Mech_Name
) = N_Indexed_Component
then
3442 Class
:= First
(Expressions
(Mech_Name
));
3444 if Nkind
(Prefix
(Mech_Name
)) /= N_Identifier
3445 or else Chars
(Prefix
(Mech_Name
)) /= Name_Descriptor
3446 or else Present
(Next
(Class
))
3451 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME)
3452 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3454 -- Note: this form is parsed as a function call
3456 elsif Nkind
(Mech_Name
) = N_Function_Call
then
3458 Param
:= First
(Parameter_Associations
(Mech_Name
));
3460 if Nkind
(Name
(Mech_Name
)) /= N_Identifier
3461 or else Chars
(Name
(Mech_Name
)) /= Name_Descriptor
3462 or else Present
(Next
(Param
))
3463 or else No
(Selector_Name
(Param
))
3464 or else Chars
(Selector_Name
(Param
)) /= Name_Class
3468 Class
:= Explicit_Actual_Parameter
(Param
);
3475 -- Fall through here with Class set to descriptor class name
3477 Check_VMS
(Mech_Name
);
3479 if Nkind
(Class
) /= N_Identifier
then
3482 elsif Chars
(Class
) = Name_UBS
then
3483 Set_Mechanism
(Ent
, By_Descriptor_UBS
);
3485 elsif Chars
(Class
) = Name_UBSB
then
3486 Set_Mechanism
(Ent
, By_Descriptor_UBSB
);
3488 elsif Chars
(Class
) = Name_UBA
then
3489 Set_Mechanism
(Ent
, By_Descriptor_UBA
);
3491 elsif Chars
(Class
) = Name_S
then
3492 Set_Mechanism
(Ent
, By_Descriptor_S
);
3494 elsif Chars
(Class
) = Name_SB
then
3495 Set_Mechanism
(Ent
, By_Descriptor_SB
);
3497 elsif Chars
(Class
) = Name_A
then
3498 Set_Mechanism
(Ent
, By_Descriptor_A
);
3500 elsif Chars
(Class
) = Name_NCA
then
3501 Set_Mechanism
(Ent
, By_Descriptor_NCA
);
3507 end Set_Mechanism_Value
;
3509 -- Start of processing for Analyze_Pragma
3512 if not Is_Pragma_Name
(Chars
(N
)) then
3513 Error_Pragma
("unrecognized pragma%!?");
3515 Prag_Id
:= Get_Pragma_Id
(Chars
(N
));
3525 if Present
(Pragma_Argument_Associations
(N
)) then
3526 Arg1
:= First
(Pragma_Argument_Associations
(N
));
3528 if Present
(Arg1
) then
3529 Arg2
:= Next
(Arg1
);
3531 if Present
(Arg2
) then
3532 Arg3
:= Next
(Arg2
);
3534 if Present
(Arg3
) then
3535 Arg4
:= Next
(Arg3
);
3541 -- Count number of arguments
3550 while Present
(Arg_Node
) loop
3551 Arg_Count
:= Arg_Count
+ 1;
3556 -- An enumeration type defines the pragmas that are supported by the
3557 -- implementation. Get_Pragma_Id (in package Prag) transorms a name
3558 -- into the corresponding enumeration value for the following case.
3566 -- pragma Abort_Defer;
3568 when Pragma_Abort_Defer
=>
3570 Check_Arg_Count
(0);
3572 -- The only required semantic processing is to check the
3573 -- placement. This pragma must appear at the start of the
3574 -- statement sequence of a handled sequence of statements.
3576 if Nkind
(Parent
(N
)) /= N_Handled_Sequence_Of_Statements
3577 or else N
/= First
(Statements
(Parent
(N
)))
3588 -- Note: this pragma also has some specific processing in Par.Prag
3589 -- because we want to set the Ada 83 mode switch during parsing.
3591 when Pragma_Ada_83
=>
3595 Check_Arg_Count
(0);
3603 -- Note: this pragma also has some specific processing in Par.Prag
3604 -- because we want to set the Ada 83 mode switch during parsing.
3606 when Pragma_Ada_95
=>
3610 Check_Arg_Count
(0);
3612 ----------------------
3613 -- All_Calls_Remote --
3614 ----------------------
3616 -- pragma All_Calls_Remote [(library_package_NAME)];
3618 when Pragma_All_Calls_Remote
=> All_Calls_Remote
: declare
3619 Lib_Entity
: Entity_Id
;
3622 Check_Ada_83_Warning
;
3623 Check_Valid_Library_Unit_Pragma
;
3625 if Nkind
(N
) = N_Null_Statement
then
3629 Lib_Entity
:= Find_Lib_Unit_Name
;
3631 -- This pragma should only apply to a RCI unit (RM E.2.3(23)).
3633 if Present
(Lib_Entity
)
3634 and then not Debug_Flag_U
3636 if not Is_Remote_Call_Interface
(Lib_Entity
) then
3637 Error_Pragma
("pragma% only apply to rci unit");
3639 -- Set flag for entity of the library unit
3642 Set_Has_All_Calls_Remote
(Lib_Entity
);
3646 end All_Calls_Remote
;
3652 -- pragma Annotate (IDENTIFIER {, ARG});
3653 -- ARG ::= NAME | EXPRESSION
3655 when Pragma_Annotate
=> Annotate
: begin
3657 Check_At_Least_N_Arguments
(1);
3658 Check_Arg_Is_Identifier
(Arg1
);
3661 Arg
: Node_Id
:= Arg2
;
3665 while Present
(Arg
) loop
3666 Exp
:= Expression
(Arg
);
3669 if Is_Entity_Name
(Exp
) then
3672 elsif Nkind
(Exp
) = N_String_Literal
then
3673 Resolve
(Exp
, Standard_String
);
3675 elsif Is_Overloaded
(Exp
) then
3676 Error_Pragma_Arg
("ambiguous argument for pragma%", Exp
);
3679 Resolve
(Exp
, Etype
(Exp
));
3691 -- pragma Assert (Boolean_EXPRESSION [, static_string_EXPRESSION]);
3693 when Pragma_Assert
=>
3695 Check_No_Identifiers
;
3697 if Arg_Count
> 1 then
3698 Check_Arg_Count
(2);
3699 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
3702 -- If expansion is active and assertions are inactive, then
3703 -- we rewrite the Assertion as:
3705 -- if False and then condition then
3709 -- The reason we do this rewriting during semantic analysis
3710 -- rather than as part of normal expansion is that we cannot
3711 -- analyze and expand the code for the boolean expression
3712 -- directly, or it may cause insertion of actions that would
3713 -- escape the attempt to suppress the assertion code.
3715 if Expander_Active
and not Assertions_Enabled
then
3717 Make_If_Statement
(Loc
,
3720 Left_Opnd
=> New_Occurrence_Of
(Standard_False
, Loc
),
3721 Right_Opnd
=> Get_Pragma_Arg
(Arg1
)),
3722 Then_Statements
=> New_List
(
3723 Make_Null_Statement
(Loc
))));
3727 -- Otherwise (if assertions are enabled, or if we are not
3728 -- operating with expansion active), then we just analyze
3729 -- and resolve the expression.
3732 Analyze_And_Resolve
(Expression
(Arg1
), Any_Boolean
);
3739 -- pragma AST_Entry (entry_IDENTIFIER);
3741 when Pragma_AST_Entry
=> AST_Entry
: declare
3747 Check_Arg_Count
(1);
3748 Check_No_Identifiers
;
3749 Check_Arg_Is_Local_Name
(Arg1
);
3750 Ent
:= Entity
(Expression
(Arg1
));
3752 -- Note: the implementation of the AST_Entry pragma could handle
3753 -- the entry family case fine, but for now we are consistent with
3754 -- the DEC rules, and do not allow the pragma, which of course
3755 -- has the effect of also forbidding the attribute.
3757 if Ekind
(Ent
) /= E_Entry
then
3759 ("pragma% argument must be simple entry name", Arg1
);
3761 elsif Is_AST_Entry
(Ent
) then
3763 ("duplicate % pragma for entry", Arg1
);
3765 elsif Has_Homonym
(Ent
) then
3767 ("pragma% argument cannot specify overloaded entry", Arg1
);
3771 FF
: constant Entity_Id
:= First_Formal
(Ent
);
3774 if Present
(FF
) then
3775 if Present
(Next_Formal
(FF
)) then
3777 ("entry for pragma% can have only one argument",
3780 elsif Parameter_Mode
(FF
) /= E_In_Parameter
then
3782 ("entry parameter for pragma% must have mode IN",
3788 Set_Is_AST_Entry
(Ent
);
3796 -- pragma Asynchronous (LOCAL_NAME);
3798 when Pragma_Asynchronous
=> Asynchronous
: declare
3806 procedure Process_Async_Pragma
;
3807 -- Common processing for procedure and access-to-procedure case
3809 --------------------------
3810 -- Process_Async_Pragma --
3811 --------------------------
3813 procedure Process_Async_Pragma
is
3815 if not Present
(L
) then
3816 Set_Is_Asynchronous
(Nm
);
3820 -- The formals should be of mode IN (RM E.4.1(6))
3823 while Present
(S
) loop
3824 Formal
:= Defining_Identifier
(S
);
3826 if Nkind
(Formal
) = N_Defining_Identifier
3827 and then Ekind
(Formal
) /= E_In_Parameter
3830 ("pragma% procedure can only have IN parameter",
3837 Set_Is_Asynchronous
(Nm
);
3838 end Process_Async_Pragma
;
3840 -- Start of processing for pragma Asynchronous
3843 Check_Ada_83_Warning
;
3844 Check_No_Identifiers
;
3845 Check_Arg_Count
(1);
3846 Check_Arg_Is_Local_Name
(Arg1
);
3848 if Debug_Flag_U
then
3852 C_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
3853 Analyze
(Expression
(Arg1
));
3854 Nm
:= Entity
(Expression
(Arg1
));
3856 if not Is_Remote_Call_Interface
(C_Ent
)
3857 and then not Is_Remote_Types
(C_Ent
)
3859 -- This pragma should only appear in an RCI or Remote Types
3860 -- unit (RM E.4.1(4))
3863 ("pragma% not in Remote_Call_Interface or " &
3864 "Remote_Types unit");
3867 if Ekind
(Nm
) = E_Procedure
3868 and then Nkind
(Parent
(Nm
)) = N_Procedure_Specification
3870 if not Is_Remote_Call_Interface
(Nm
) then
3872 ("pragma% cannot be applied on non-remote procedure",
3876 L
:= Parameter_Specifications
(Parent
(Nm
));
3877 Process_Async_Pragma
;
3880 elsif Ekind
(Nm
) = E_Function
then
3882 ("pragma% cannot be applied to function", Arg1
);
3884 elsif Ekind
(Nm
) = E_Record_Type
3885 and then Present
(Corresponding_Remote_Type
(Nm
))
3887 N
:= Declaration_Node
(Corresponding_Remote_Type
(Nm
));
3889 if Nkind
(N
) = N_Full_Type_Declaration
3890 and then Nkind
(Type_Definition
(N
)) =
3891 N_Access_Procedure_Definition
3893 L
:= Parameter_Specifications
(Type_Definition
(N
));
3894 Process_Async_Pragma
;
3898 ("pragma% cannot reference access-to-function type",
3902 -- Only other possibility is Access-to-class-wide type
3904 elsif Is_Access_Type
(Nm
)
3905 and then Is_Class_Wide_Type
(Designated_Type
(Nm
))
3907 Check_First_Subtype
(Arg1
);
3908 Set_Is_Asynchronous
(Nm
);
3909 if Expander_Active
then
3910 RACW_Type_Is_Asynchronous
(Nm
);
3914 Error_Pragma_Arg
("inappropriate argument for pragma%", Arg1
);
3923 -- pragma Atomic (LOCAL_NAME);
3925 when Pragma_Atomic
=>
3926 Process_Atomic_Shared_Volatile
;
3928 -----------------------
3929 -- Atomic_Components --
3930 -----------------------
3932 -- pragma Atomic_Components (array_LOCAL_NAME);
3934 -- This processing is shared by Volatile_Components
3936 when Pragma_Atomic_Components |
3937 Pragma_Volatile_Components
=>
3939 Atomic_Components
: declare
3946 Check_Ada_83_Warning
;
3947 Check_No_Identifiers
;
3948 Check_Arg_Count
(1);
3949 Check_Arg_Is_Local_Name
(Arg1
);
3950 E_Id
:= Expression
(Arg1
);
3952 if Etype
(E_Id
) = Any_Type
then
3958 if Rep_Item_Too_Early
(E
, N
)
3960 Rep_Item_Too_Late
(E
, N
)
3965 D
:= Declaration_Node
(E
);
3968 if (K
= N_Full_Type_Declaration
and then Is_Array_Type
(E
))
3970 ((Ekind
(E
) = E_Constant
or else Ekind
(E
) = E_Variable
)
3971 and then Nkind
(D
) = N_Object_Declaration
3972 and then Nkind
(Object_Definition
(D
)) =
3973 N_Constrained_Array_Definition
)
3975 -- The flag is set on the object, or on the base type
3977 if Nkind
(D
) /= N_Object_Declaration
then
3981 Set_Has_Volatile_Components
(E
);
3983 if Prag_Id
= Pragma_Atomic_Components
then
3984 Set_Has_Atomic_Components
(E
);
3986 if Is_Packed
(E
) then
3987 Set_Is_Packed
(E
, False);
3990 ("?Pack canceled, cannot pack atomic components",
3996 Error_Pragma_Arg
("inappropriate entity for pragma%", Arg1
);
3998 end Atomic_Components
;
4000 --------------------
4001 -- Attach_Handler --
4002 --------------------
4004 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
4006 when Pragma_Attach_Handler
=>
4007 Check_Ada_83_Warning
;
4008 Check_No_Identifiers
;
4009 Check_Arg_Count
(2);
4010 Check_Interrupt_Or_Attach_Handler
;
4011 Analyze_And_Resolve
(Expression
(Arg2
), RTE
(RE_Interrupt_Id
));
4012 Process_Interrupt_Or_Attach_Handler
;
4014 --------------------
4015 -- C_Pass_By_Copy --
4016 --------------------
4018 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
4020 when Pragma_C_Pass_By_Copy
=> C_Pass_By_Copy
: declare
4026 Check_Valid_Configuration_Pragma
;
4027 Check_Arg_Count
(1);
4028 Check_Optional_Identifier
(Arg1
, "max_size");
4030 Arg
:= Expression
(Arg1
);
4031 Check_Arg_Is_Static_Expression
(Arg
, Any_Integer
);
4033 Val
:= Expr_Value
(Arg
);
4037 ("maximum size for pragma% must be positive", Arg1
);
4039 elsif UI_Is_In_Int_Range
(Val
) then
4040 Default_C_Record_Mechanism
:= UI_To_Int
(Val
);
4042 -- If a giant value is given, Int'Last will do well enough.
4043 -- If sometime someone complains that a record larger than
4044 -- two gigabytes is not copied, we will worry about it then!
4047 Default_C_Record_Mechanism
:= Mechanism_Type
'Last;
4055 -- pragma Comment (static_string_EXPRESSION)
4057 -- Processing for pragma Comment shares the circuitry for
4058 -- pragma Ident. The only differences are that Ident enforces
4059 -- a limit of 31 characters on its argument, and also enforces
4060 -- limitations on placement for DEC compatibility. Pragma
4061 -- Comment shares neither of these restrictions.
4067 -- pragma Common_Object (
4068 -- [Internal =>] LOCAL_NAME,
4069 -- [, [External =>] EXTERNAL_SYMBOL]
4070 -- [, [Size =>] EXTERNAL_SYMBOL]);
4072 -- Processing for this pragma is shared with Psect_Object
4074 ----------------------------
4075 -- Complex_Representation --
4076 ----------------------------
4078 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
4080 when Pragma_Complex_Representation
=> Complex_Representation
: declare
4087 Check_Arg_Count
(1);
4088 Check_Optional_Identifier
(Arg1
, Name_Entity
);
4089 Check_Arg_Is_Local_Name
(Arg1
);
4090 E_Id
:= Expression
(Arg1
);
4092 if Etype
(E_Id
) = Any_Type
then
4098 if not Is_Record_Type
(E
) then
4100 ("argument for pragma% must be record type", Arg1
);
4103 Ent
:= First_Entity
(E
);
4106 or else No
(Next_Entity
(Ent
))
4107 or else Present
(Next_Entity
(Next_Entity
(Ent
)))
4108 or else not Is_Floating_Point_Type
(Etype
(Ent
))
4109 or else Etype
(Ent
) /= Etype
(Next_Entity
(Ent
))
4112 ("record for pragma% must have two fields of same fpt type",
4116 Set_Has_Complex_Representation
(Base_Type
(E
));
4118 end Complex_Representation
;
4120 -------------------------
4121 -- Component_Alignment --
4122 -------------------------
4124 -- pragma Component_Alignment (
4125 -- [Form =>] ALIGNMENT_CHOICE
4126 -- [, [Name =>] type_LOCAL_NAME]);
4128 -- ALIGNMENT_CHOICE ::=
4130 -- | Component_Size_4
4134 when Pragma_Component_Alignment
=> Component_AlignmentP
: declare
4135 Args
: Args_List
(1 .. 2);
4136 Names
: Name_List
(1 .. 2) := (
4140 Form
: Node_Id
renames Args
(1);
4141 Name
: Node_Id
renames Args
(2);
4143 Atype
: Component_Alignment_Kind
;
4148 Gather_Associations
(Names
, Args
);
4151 Error_Pragma
("missing Form argument for pragma%");
4154 Check_Arg_Is_Identifier
(Form
);
4156 -- Get proper alignment, note that Default = Component_Size
4157 -- on all machines we have so far, and we want to set this
4158 -- value rather than the default value to indicate that it
4159 -- has been explicitly set (and thus will not get overridden
4160 -- by the default component alignment for the current scope)
4162 if Chars
(Form
) = Name_Component_Size
then
4163 Atype
:= Calign_Component_Size
;
4165 elsif Chars
(Form
) = Name_Component_Size_4
then
4166 Atype
:= Calign_Component_Size_4
;
4168 elsif Chars
(Form
) = Name_Default
then
4169 Atype
:= Calign_Component_Size
;
4171 elsif Chars
(Form
) = Name_Storage_Unit
then
4172 Atype
:= Calign_Storage_Unit
;
4176 ("invalid Form parameter for pragma%", Form
);
4179 -- Case with no name, supplied, affects scope table entry
4183 (Scope_Stack
.Last
).Component_Alignment_Default
:= Atype
;
4185 -- Case of name supplied
4188 Check_Arg_Is_Local_Name
(Name
);
4190 Typ
:= Entity
(Name
);
4193 or else Rep_Item_Too_Early
(Typ
, N
)
4197 Typ
:= Underlying_Type
(Typ
);
4200 if not Is_Record_Type
(Typ
)
4201 and then not Is_Array_Type
(Typ
)
4204 ("Name parameter of pragma% must identify record or " &
4205 "array type", Name
);
4208 -- An explicit Component_Alignment pragma overrides an
4209 -- implicit pragma Pack, but not an explicit one.
4211 if not Has_Pragma_Pack
(Base_Type
(Typ
)) then
4212 Set_Is_Packed
(Base_Type
(Typ
), False);
4213 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
);
4259 ---------------------------
4260 -- Convention_Identifier --
4261 ---------------------------
4263 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
4264 -- [Convention =>] convention_IDENTIFIER);
4266 when Pragma_Convention_Identifier
=> Convention_Identifier
: declare
4272 Check_Arg_Count
(2);
4273 Check_Optional_Identifier
(Arg1
, Name_Name
);
4274 Check_Optional_Identifier
(Arg2
, Name_Convention
);
4275 Check_Arg_Is_Identifier
(Arg1
);
4276 Check_Arg_Is_Identifier
(Arg1
);
4277 Idnam
:= Chars
(Expression
(Arg1
));
4278 Cname
:= Chars
(Expression
(Arg2
));
4280 if Is_Convention_Name
(Cname
) then
4281 Record_Convention_Identifier
4282 (Idnam
, Get_Convention_Id
(Cname
));
4285 ("second arg for % pragma must be convention", Arg2
);
4287 end Convention_Identifier
;
4293 -- pragma CPP_Class ([Entity =>] local_NAME)
4295 when Pragma_CPP_Class
=> CPP_Class
: declare
4298 Default_DTC
: Entity_Id
:= Empty
;
4299 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
4305 Check_Arg_Count
(1);
4306 Check_Optional_Identifier
(Arg1
, Name_Entity
);
4307 Check_Arg_Is_Local_Name
(Arg1
);
4309 Arg
:= Expression
(Arg1
);
4312 if Etype
(Arg
) = Any_Type
then
4316 if not Is_Entity_Name
(Arg
)
4317 or else not Is_Type
(Entity
(Arg
))
4319 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
4322 Typ
:= Entity
(Arg
);
4324 if not Is_Record_Type
(Typ
) then
4325 Error_Pragma_Arg
("pragma% applicable to a record, "
4326 & "tagged record or record extension", Arg1
);
4329 Default_DTC
:= First_Component
(Typ
);
4330 while Present
(Default_DTC
)
4331 and then Etype
(Default_DTC
) /= VTP_Type
4333 Next_Component
(Default_DTC
);
4336 -- Case of non tagged type
4338 if not Is_Tagged_Type
(Typ
) then
4339 Set_Is_CPP_Class
(Typ
);
4341 if Present
(Default_DTC
) then
4343 ("only tagged records can contain vtable pointers", Arg1
);
4346 -- Case of tagged type with no vtable ptr
4348 -- What is test for Typ = Root_Typ (Typ) about here ???
4350 elsif Is_Tagged_Type
(Typ
)
4351 and then Typ
= Root_Type
(Typ
)
4352 and then No
(Default_DTC
)
4355 ("a cpp_class must contain a vtable pointer", Arg1
);
4357 -- Tagged type that has a vtable ptr
4359 elsif Present
(Default_DTC
) then
4360 Set_Is_CPP_Class
(Typ
);
4361 Set_Is_Limited_Record
(Typ
);
4362 Set_Is_Tag
(Default_DTC
);
4363 Set_DT_Entry_Count
(Default_DTC
, No_Uint
);
4365 -- Since a CPP type has no direct link to its associated tag
4366 -- most tags checks cannot be performed
4368 Set_Suppress_Tag_Checks
(Typ
);
4369 Set_Suppress_Tag_Checks
(Class_Wide_Type
(Typ
));
4371 -- Get rid of the _tag component when there was one.
4372 -- It is only useful for regular tagged types
4374 if Expander_Active
and then Typ
= Root_Type
(Typ
) then
4376 Tag_C
:= Tag_Component
(Typ
);
4377 C
:= First_Entity
(Typ
);
4380 Set_First_Entity
(Typ
, Next_Entity
(Tag_C
));
4383 while Next_Entity
(C
) /= Tag_C
loop
4387 Set_Next_Entity
(C
, Next_Entity
(Tag_C
));
4393 ---------------------
4394 -- CPP_Constructor --
4395 ---------------------
4397 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
4399 when Pragma_CPP_Constructor
=> CPP_Constructor
: declare
4405 Check_Arg_Count
(1);
4406 Check_Optional_Identifier
(Arg1
, Name_Entity
);
4407 Check_Arg_Is_Local_Name
(Arg1
);
4409 Id
:= Expression
(Arg1
);
4410 Find_Program_Unit_Name
(Id
);
4412 -- If we did not find the name, we are done
4414 if Etype
(Id
) = Any_Type
then
4418 Def_Id
:= Entity
(Id
);
4420 if Ekind
(Def_Id
) = E_Function
4421 and then Is_Class_Wide_Type
(Etype
(Def_Id
))
4422 and then Is_CPP_Class
(Etype
(Etype
(Def_Id
)))
4424 -- What the heck is this??? this pragma allows only 1 arg
4426 if Arg_Count
>= 2 then
4427 Check_At_Most_N_Arguments
(3);
4428 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
4431 if No
(Parameter_Specifications
(Parent
(Def_Id
))) then
4432 Set_Has_Completion
(Def_Id
);
4433 Set_Is_Constructor
(Def_Id
);
4436 ("non-default constructors not implemented", Arg1
);
4441 ("pragma% requires function returning a 'C'P'P_Class type",
4444 end CPP_Constructor
;
4450 -- pragma CPP_Virtual
4451 -- [Entity =>] LOCAL_NAME
4452 -- [ [Vtable_Ptr =>] LOCAL_NAME,
4453 -- [Position =>] static_integer_EXPRESSION]);
4455 when Pragma_CPP_Virtual
=> CPP_Virtual
: declare
4459 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
4466 if Arg_Count
= 3 then
4467 Check_Optional_Identifier
(Arg2
, "vtable_ptr");
4469 -- We allow Entry_Count as well as Position for the third
4470 -- parameter for back compatibility with versions of GNAT
4471 -- before version 3.12. The documentation has always said
4472 -- Position, but the code up to 3.12 said Entry_Count.
4474 if Chars
(Arg3
) /= Name_Position
then
4475 Check_Optional_Identifier
(Arg3
, "entry_count");
4479 Check_Arg_Count
(1);
4482 Check_Optional_Identifier
(Arg1
, Name_Entity
);
4483 Check_Arg_Is_Local_Name
(Arg1
);
4485 -- First argument must be a subprogram name
4487 Arg
:= Expression
(Arg1
);
4488 Find_Program_Unit_Name
(Arg
);
4490 if Etype
(Arg
) = Any_Type
then
4493 Subp
:= Entity
(Arg
);
4496 if not (Is_Subprogram
(Subp
)
4497 and then Is_Dispatching_Operation
(Subp
))
4500 ("pragma% must reference a primitive operation", Arg1
);
4503 Typ
:= Find_Dispatching_Type
(Subp
);
4505 -- If only one Argument defaults are :
4506 -- . DTC_Entity is the default Vtable pointer
4507 -- . DT_Position will be set at the freezing point
4509 if Arg_Count
= 1 then
4510 Set_DTC_Entity
(Subp
, Tag_Component
(Typ
));
4514 -- Second argument is a component name of type Vtable_Ptr
4516 Arg
:= Expression
(Arg2
);
4518 if Nkind
(Arg
) /= N_Identifier
then
4519 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
4523 DTC
:= First_Component
(Typ
);
4524 while Present
(DTC
) and then Chars
(DTC
) /= Chars
(Arg
) loop
4525 Next_Component
(DTC
);
4529 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
4532 elsif Etype
(DTC
) /= VTP_Type
then
4533 Wrong_Type
(Arg
, VTP_Type
);
4537 -- Third argument is an integer (DT_Position)
4539 Arg
:= Expression
(Arg3
);
4540 Analyze_And_Resolve
(Arg
, Any_Integer
);
4542 if not Is_Static_Expression
(Arg
) then
4544 ("third argument of pragma% must be a static expression",
4548 V
:= Expr_Value
(Expression
(Arg3
));
4552 ("third argument of pragma% must be positive",
4556 Set_DTC_Entity
(Subp
, DTC
);
4557 Set_DT_Position
(Subp
, V
);
4566 -- pragma CPP_Vtable (
4567 -- [Entity =>] LOCAL_NAME
4568 -- [Vtable_Ptr =>] LOCAL_NAME,
4569 -- [Entry_Count =>] static_integer_EXPRESSION);
4571 when Pragma_CPP_Vtable
=> CPP_Vtable
: declare
4574 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
4581 Check_Arg_Count
(3);
4582 Check_Optional_Identifier
(Arg1
, Name_Entity
);
4583 Check_Optional_Identifier
(Arg2
, "vtable_ptr");
4584 Check_Optional_Identifier
(Arg3
, "entry_count");
4585 Check_Arg_Is_Local_Name
(Arg1
);
4587 -- First argument is a record type name
4589 Arg
:= Expression
(Arg1
);
4592 if Etype
(Arg
) = Any_Type
then
4595 Typ
:= Entity
(Arg
);
4598 if not (Is_Tagged_Type
(Typ
) and then Is_CPP_Class
(Typ
)) then
4599 Error_Pragma_Arg
("'C'P'P_Class tagged type expected", Arg1
);
4602 -- Second argument is a component name of type Vtable_Ptr
4604 Arg
:= Expression
(Arg2
);
4606 if Nkind
(Arg
) /= N_Identifier
then
4607 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
4611 DTC
:= First_Component
(Typ
);
4612 while Present
(DTC
) and then Chars
(DTC
) /= Chars
(Arg
) loop
4613 Next_Component
(DTC
);
4617 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
4620 elsif Etype
(DTC
) /= VTP_Type
then
4621 Wrong_Type
(DTC
, VTP_Type
);
4624 -- If it is the first pragma Vtable, This becomes the default tag
4626 elsif (not Is_Tag
(DTC
))
4627 and then DT_Entry_Count
(Tag_Component
(Typ
)) = No_Uint
4629 Set_Is_Tag
(Tag_Component
(Typ
), False);
4630 Set_Is_Tag
(DTC
, True);
4631 Set_DT_Entry_Count
(DTC
, No_Uint
);
4634 -- Those pragmas must appear before any primitive operation
4635 -- definition (except inherited ones) otherwise the default
4638 Elmt
:= First_Elmt
(Primitive_Operations
(Typ
));
4639 while Present
(Elmt
) loop
4640 if No
(Alias
(Node
(Elmt
))) then
4641 Error_Msg_Sloc
:= Sloc
(Node
(Elmt
));
4643 ("pragma% must appear before this primitive operation");
4649 -- Third argument is an integer (DT_Entry_Count)
4651 Arg
:= Expression
(Arg3
);
4652 Analyze_And_Resolve
(Arg
, Any_Integer
);
4654 if not Is_Static_Expression
(Arg
) then
4656 ("entry count for pragma% must be a static expression", Arg3
);
4659 V
:= Expr_Value
(Expression
(Arg3
));
4663 ("entry count for pragma% must be positive", Arg3
);
4665 Set_DT_Entry_Count
(DTC
, V
);
4675 -- pragma Debug (PROCEDURE_CALL_STATEMENT);
4677 when Pragma_Debug
=> Debug
: begin
4680 -- If assertions are enabled, and we are expanding code, then
4681 -- we rewrite the pragma with its corresponding procedure call
4682 -- and then analyze the call.
4684 if Assertions_Enabled
and Expander_Active
then
4685 Rewrite
(N
, Relocate_Node
(Debug_Statement
(N
)));
4688 -- Otherwise we work a bit to get a tree that makes sense
4689 -- for ASIS purposes, namely a pragma with an analyzed
4690 -- argument that looks like a procedure call.
4693 Expander_Mode_Save_And_Set
(False);
4694 Rewrite
(N
, Relocate_Node
(Debug_Statement
(N
)));
4698 Chars
=> Name_Debug
,
4699 Pragma_Argument_Associations
=>
4700 New_List
(Relocate_Node
(N
))));
4701 Expander_Mode_Restore
;
4709 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
4711 when Pragma_Discard_Names
=> Discard_Names
: declare
4716 Check_Ada_83_Warning
;
4718 -- Deal with configuration pragma case
4720 if Arg_Count
= 0 and then Is_Configuration_Pragma
then
4721 Global_Discard_Names
:= True;
4724 -- Otherwise, check correct appropriate context
4727 Check_Is_In_Decl_Part_Or_Package_Spec
;
4729 if Arg_Count
= 0 then
4731 -- If there is no parameter, then from now on this pragma
4732 -- applies to any enumeration, exception or tagged type
4733 -- defined in the current declarative part.
4735 Set_Discard_Names
(Current_Scope
);
4739 Check_Arg_Count
(1);
4740 Check_Optional_Identifier
(Arg1
, Name_On
);
4741 Check_Arg_Is_Local_Name
(Arg1
);
4742 E_Id
:= Expression
(Arg1
);
4744 if Etype
(E_Id
) = Any_Type
then
4750 if (Is_First_Subtype
(E
)
4751 and then (Is_Enumeration_Type
(E
)
4752 or else Is_Tagged_Type
(E
)))
4753 or else Ekind
(E
) = E_Exception
4755 Set_Discard_Names
(E
);
4758 ("inappropriate entity for pragma%", Arg1
);
4768 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
4770 when Pragma_Elaborate
=> Elaborate
: declare
4772 Parent_Node
: Node_Id
;
4777 -- Pragma must be in context items list of a compilation unit
4779 if not Is_List_Member
(N
) then
4784 Plist
:= List_Containing
(N
);
4785 Parent_Node
:= Parent
(Plist
);
4787 if Parent_Node
= Empty
4788 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
4789 or else Context_Items
(Parent_Node
) /= Plist
4796 -- Must be at least one argument
4798 if Arg_Count
= 0 then
4799 Error_Pragma
("pragma% requires at least one argument");
4802 -- In Ada 83 mode, there can be no items following it in the
4803 -- context list except other pragmas and implicit with clauses
4804 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
4805 -- placement rule does not apply.
4807 if Ada_83
and then Comes_From_Source
(N
) then
4810 while Present
(Citem
) loop
4811 if Nkind
(Citem
) = N_Pragma
4812 or else (Nkind
(Citem
) = N_With_Clause
4813 and then Implicit_With
(Citem
))
4818 ("(Ada 83) pragma% must be at end of context clause");
4825 -- Finally, the arguments must all be units mentioned in a with
4826 -- clause in the same context clause. Note we already checked
4827 -- (in Par.Prag) that the arguments are either identifiers or
4830 Outer
: while Present
(Arg
) loop
4831 Citem
:= First
(Plist
);
4833 Inner
: while Citem
/= N
loop
4834 if Nkind
(Citem
) = N_With_Clause
4835 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
4837 Set_Elaborate_Present
(Citem
, True);
4838 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
4839 Set_Suppress_Elaboration_Warnings
(Entity
(Name
(Citem
)));
4848 ("argument of pragma% is not with'ed unit", Arg
);
4859 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
4861 when Pragma_Elaborate_All
=> Elaborate_All
: declare
4863 Parent_Node
: Node_Id
;
4868 Check_Ada_83_Warning
;
4870 -- Pragma must be in context items list of a compilation unit
4872 if not Is_List_Member
(N
) then
4877 Plist
:= List_Containing
(N
);
4878 Parent_Node
:= Parent
(Plist
);
4880 if Parent_Node
= Empty
4881 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
4882 or else Context_Items
(Parent_Node
) /= Plist
4889 -- Must be at least one argument
4891 if Arg_Count
= 0 then
4892 Error_Pragma
("pragma% requires at least one argument");
4895 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
4896 -- have to appear at the end of the context clause, but may
4897 -- appear mixed in with other items, even in Ada 83 mode.
4899 -- Final check: the arguments must all be units mentioned in
4900 -- a with clause in the same context clause. Note that we
4901 -- already checked (in Par.Prag) that all the arguments are
4902 -- either identifiers or selected components.
4905 Outr
: while Present
(Arg
) loop
4906 Citem
:= First
(Plist
);
4908 Innr
: while Citem
/= N
loop
4909 if Nkind
(Citem
) = N_With_Clause
4910 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
4912 Set_Elaborate_All_Present
(Citem
, True);
4913 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
4914 Set_Suppress_Elaboration_Warnings
(Entity
(Name
(Citem
)));
4923 ("argument of pragma% is not with'ed unit", Arg
);
4930 --------------------
4931 -- Elaborate_Body --
4932 --------------------
4934 -- pragma Elaborate_Body [( library_unit_NAME )];
4936 when Pragma_Elaborate_Body
=> Elaborate_Body
: declare
4937 Cunit_Node
: Node_Id
;
4938 Cunit_Ent
: Entity_Id
;
4941 Check_Ada_83_Warning
;
4942 Check_Valid_Library_Unit_Pragma
;
4944 if Nkind
(N
) = N_Null_Statement
then
4948 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
4949 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
4951 if Nkind
(Unit
(Cunit_Node
)) = N_Package_Body
4953 Nkind
(Unit
(Cunit_Node
)) = N_Subprogram_Body
4955 Error_Pragma
("pragma% must refer to a spec, not a body");
4957 Set_Body_Required
(Cunit_Node
, True);
4958 Set_Has_Pragma_Elaborate_Body
(Cunit_Ent
);
4960 -- If we are in dynamic elaboration mode, then we suppress
4961 -- elaboration warnings for the unit, since it is definitely
4962 -- fine NOT to do dynamic checks at the first level (and such
4963 -- checks will be suppressed because no elaboration boolean
4964 -- is created for Elaborate_Body packages).
4966 -- But in the static model of elaboration, Elaborate_Body is
4967 -- definitely NOT good enough to ensure elaboration safety on
4968 -- its own, since the body may WITH other units that are not
4969 -- safe from an elaboration point of view, so a client must
4970 -- still do an Elaborate_All on such units.
4972 -- Debug flag -gnatdD restores the old behavior of 3.13,
4973 -- where Elaborate_Body always suppressed elab warnings.
4975 if Dynamic_Elaboration_Checks
or Debug_Flag_DD
then
4976 Set_Suppress_Elaboration_Warnings
(Cunit_Ent
);
4981 ------------------------
4982 -- Elaboration_Checks --
4983 ------------------------
4985 -- pragma Elaboration_Checks (Static | Dynamic);
4987 when Pragma_Elaboration_Checks
=>
4989 Check_Arg_Count
(1);
4990 Check_Arg_Is_One_Of
(Arg1
, Name_Static
, Name_Dynamic
);
4991 Dynamic_Elaboration_Checks
:=
4992 (Chars
(Get_Pragma_Arg
(Arg1
)) = Name_Dynamic
);
4998 -- pragma Eliminate (
4999 -- [Unit_Name =>] IDENTIFIER |
5000 -- SELECTED_COMPONENT
5001 -- [,[Entity =>] IDENTIFIER |
5002 -- SELECTED_COMPONENT |
5004 -- [,[Parameter_Types =>] PARAMETER_TYPES]
5005 -- [,[Result_Type =>] result_SUBTYPE_NAME]
5006 -- [,[Homonym_Number =>] INTEGER_LITERAL]);
5008 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
5009 -- SUBTYPE_NAME ::= STRING_LITERAL
5011 when Pragma_Eliminate
=> Eliminate
: declare
5012 Args
: Args_List
(1 .. 5);
5013 Names
: Name_List
(1 .. 5) := (
5016 Name_Parameter_Types
,
5018 Name_Homonym_Number
);
5020 Unit_Name
: Node_Id
renames Args
(1);
5021 Entity
: Node_Id
renames Args
(2);
5022 Parameter_Types
: Node_Id
renames Args
(3);
5023 Result_Type
: Node_Id
renames Args
(4);
5024 Homonym_Number
: Node_Id
renames Args
(5);
5028 Check_Valid_Configuration_Pragma
;
5029 Gather_Associations
(Names
, Args
);
5031 if No
(Unit_Name
) then
5032 Error_Pragma
("missing Unit_Name argument for pragma%");
5036 and then (Present
(Parameter_Types
)
5038 Present
(Result_Type
)
5040 Present
(Homonym_Number
))
5042 Error_Pragma
("missing Entity argument for pragma%");
5045 Process_Eliminate_Pragma
5058 -- [ Convention =>] convention_IDENTIFIER,
5059 -- [ Entity =>] local_NAME
5060 -- [, [External_Name =>] static_string_EXPRESSION ]
5061 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5063 when Pragma_Export
=> Export
: declare
5068 Check_Ada_83_Warning
;
5069 Check_At_Least_N_Arguments
(2);
5070 Check_At_Most_N_Arguments
(4);
5071 Process_Convention
(C
, Def_Id
);
5073 if Ekind
(Def_Id
) /= E_Constant
then
5074 Note_Possible_Modification
(Expression
(Arg2
));
5077 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
5078 Set_Exported
(Def_Id
, Arg2
);
5081 ----------------------
5082 -- Export_Exception --
5083 ----------------------
5085 -- pragma Export_Exception (
5086 -- [Internal =>] LOCAL_NAME,
5087 -- [, [External =>] EXTERNAL_SYMBOL,]
5088 -- [, [Form =>] Ada | VMS]
5089 -- [, [Code =>] static_integer_EXPRESSION]);
5091 when Pragma_Export_Exception
=> Export_Exception
: declare
5092 Args
: Args_List
(1 .. 4);
5093 Names
: Name_List
(1 .. 4) := (
5099 Internal
: Node_Id
renames Args
(1);
5100 External
: Node_Id
renames Args
(2);
5101 Form
: Node_Id
renames Args
(3);
5102 Code
: Node_Id
renames Args
(4);
5105 if Inside_A_Generic
then
5106 Error_Pragma
("pragma% cannot be used for generic entities");
5109 Gather_Associations
(Names
, Args
);
5110 Process_Extended_Import_Export_Exception_Pragma
(
5111 Arg_Internal
=> Internal
,
5112 Arg_External
=> External
,
5116 if not Is_VMS_Exception
(Entity
(Internal
)) then
5117 Set_Exported
(Entity
(Internal
), Internal
);
5120 end Export_Exception
;
5122 ---------------------
5123 -- Export_Function --
5124 ---------------------
5126 -- pragma Export_Function (
5127 -- [Internal =>] LOCAL_NAME,
5128 -- [, [External =>] EXTERNAL_SYMBOL,]
5129 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5130 -- [, [Result_Type =>] SUBTYPE_MARK]
5131 -- [, [Mechanism =>] MECHANISM]
5132 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
5134 when Pragma_Export_Function
=> Export_Function
: declare
5135 Args
: Args_List
(1 .. 6);
5136 Names
: Name_List
(1 .. 6) := (
5139 Name_Parameter_Types
,
5142 Name_Result_Mechanism
);
5144 Internal
: Node_Id
renames Args
(1);
5145 External
: Node_Id
renames Args
(2);
5146 Parameter_Types
: Node_Id
renames Args
(3);
5147 Result_Type
: Node_Id
renames Args
(4);
5148 Mechanism
: Node_Id
renames Args
(5);
5149 Result_Mechanism
: Node_Id
renames Args
(6);
5153 Gather_Associations
(Names
, Args
);
5154 Process_Extended_Import_Export_Subprogram_Pragma
(
5155 Arg_Internal
=> Internal
,
5156 Arg_External
=> External
,
5157 Arg_Parameter_Types
=> Parameter_Types
,
5158 Arg_Result_Type
=> Result_Type
,
5159 Arg_Mechanism
=> Mechanism
,
5160 Arg_Result_Mechanism
=> Result_Mechanism
);
5161 end Export_Function
;
5167 -- pragma Export_Object (
5168 -- [Internal =>] LOCAL_NAME,
5169 -- [, [External =>] EXTERNAL_SYMBOL]
5170 -- [, [Size =>] EXTERNAL_SYMBOL]);
5172 when Pragma_Export_Object
=> Export_Object
: declare
5173 Args
: Args_List
(1 .. 3);
5174 Names
: Name_List
(1 .. 3) := (
5179 Internal
: Node_Id
renames Args
(1);
5180 External
: Node_Id
renames Args
(2);
5181 Size
: Node_Id
renames Args
(3);
5185 Gather_Associations
(Names
, Args
);
5186 Process_Extended_Import_Export_Object_Pragma
(
5187 Arg_Internal
=> Internal
,
5188 Arg_External
=> External
,
5192 ----------------------
5193 -- Export_Procedure --
5194 ----------------------
5196 -- pragma Export_Procedure (
5197 -- [Internal =>] LOCAL_NAME,
5198 -- [, [External =>] EXTERNAL_SYMBOL,]
5199 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5200 -- [, [Mechanism =>] MECHANISM]);
5202 when Pragma_Export_Procedure
=> Export_Procedure
: declare
5203 Args
: Args_List
(1 .. 4);
5204 Names
: Name_List
(1 .. 4) := (
5207 Name_Parameter_Types
,
5210 Internal
: Node_Id
renames Args
(1);
5211 External
: Node_Id
renames Args
(2);
5212 Parameter_Types
: Node_Id
renames Args
(3);
5213 Mechanism
: Node_Id
renames Args
(4);
5217 Gather_Associations
(Names
, Args
);
5218 Process_Extended_Import_Export_Subprogram_Pragma
(
5219 Arg_Internal
=> Internal
,
5220 Arg_External
=> External
,
5221 Arg_Parameter_Types
=> Parameter_Types
,
5222 Arg_Mechanism
=> Mechanism
);
5223 end Export_Procedure
;
5225 -----------------------------
5226 -- Export_Valued_Procedure --
5227 -----------------------------
5229 -- pragma Export_Valued_Procedure (
5230 -- [Internal =>] LOCAL_NAME,
5231 -- [, [External =>] EXTERNAL_SYMBOL,]
5232 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5233 -- [, [Mechanism =>] MECHANISM]);
5235 when Pragma_Export_Valued_Procedure
=>
5236 Export_Valued_Procedure
: declare
5237 Args
: Args_List
(1 .. 4);
5238 Names
: Name_List
(1 .. 4) := (
5241 Name_Parameter_Types
,
5244 Internal
: Node_Id
renames Args
(1);
5245 External
: Node_Id
renames Args
(2);
5246 Parameter_Types
: Node_Id
renames Args
(3);
5247 Mechanism
: Node_Id
renames Args
(4);
5251 Gather_Associations
(Names
, Args
);
5252 Process_Extended_Import_Export_Subprogram_Pragma
(
5253 Arg_Internal
=> Internal
,
5254 Arg_External
=> External
,
5255 Arg_Parameter_Types
=> Parameter_Types
,
5256 Arg_Mechanism
=> Mechanism
);
5257 end Export_Valued_Procedure
;
5263 -- pragma Extend_System ([Name =>] Identifier);
5265 when Pragma_Extend_System
=> Extend_System
: declare
5268 Check_Valid_Configuration_Pragma
;
5269 Check_Arg_Count
(1);
5270 Check_Optional_Identifier
(Arg1
, Name_Name
);
5271 Check_Arg_Is_Identifier
(Arg1
);
5273 Get_Name_String
(Chars
(Expression
(Arg1
)));
5276 and then Name_Buffer
(1 .. 4) = "aux_"
5278 if Present
(System_Extend_Pragma_Arg
) then
5279 if Chars
(Expression
(Arg1
)) =
5280 Chars
(Expression
(System_Extend_Pragma_Arg
))
5284 Error_Msg_Sloc
:= Sloc
(System_Extend_Pragma_Arg
);
5285 Error_Pragma
("pragma% conflicts with that at#");
5289 System_Extend_Pragma_Arg
:= Arg1
;
5292 Error_Pragma
("incorrect name for pragma%, must be Aux_xxx");
5296 ------------------------
5297 -- Extensions_Allowed --
5298 ------------------------
5300 -- pragma Extensions_Allowed (ON | OFF);
5302 when Pragma_Extensions_Allowed
=>
5304 Check_Arg_Count
(1);
5305 Check_No_Identifiers
;
5306 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
5307 Extensions_Allowed
:= (Chars
(Expression
(Arg1
)) = Name_On
);
5313 -- pragma External (
5314 -- [ Convention =>] convention_IDENTIFIER,
5315 -- [ Entity =>] local_NAME
5316 -- [, [External_Name =>] static_string_EXPRESSION ]
5317 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5319 when Pragma_External
=> External
: declare
5325 Check_At_Least_N_Arguments
(2);
5326 Check_At_Most_N_Arguments
(4);
5327 Process_Convention
(C
, Def_Id
);
5328 Note_Possible_Modification
(Expression
(Arg2
));
5329 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
5330 Set_Exported
(Def_Id
, Arg2
);
5333 --------------------------
5334 -- External_Name_Casing --
5335 --------------------------
5337 -- pragma External_Name_Casing (
5338 -- UPPERCASE | LOWERCASE
5339 -- [, AS_IS | UPPERCASE | LOWERCASE]);
5341 when Pragma_External_Name_Casing
=>
5343 External_Name_Casing
: declare
5346 Check_No_Identifiers
;
5348 if Arg_Count
= 2 then
5350 (Arg2
, Name_As_Is
, Name_Uppercase
, Name_Lowercase
);
5352 case Chars
(Get_Pragma_Arg
(Arg2
)) is
5354 Opt
.External_Name_Exp_Casing
:= As_Is
;
5356 when Name_Uppercase
=>
5357 Opt
.External_Name_Exp_Casing
:= Uppercase
;
5359 when Name_Lowercase
=>
5360 Opt
.External_Name_Exp_Casing
:= Lowercase
;
5367 Check_Arg_Count
(1);
5370 Check_Arg_Is_One_Of
(Arg1
, Name_Uppercase
, Name_Lowercase
);
5372 case Chars
(Get_Pragma_Arg
(Arg1
)) is
5373 when Name_Uppercase
=>
5374 Opt
.External_Name_Imp_Casing
:= Uppercase
;
5376 when Name_Lowercase
=>
5377 Opt
.External_Name_Imp_Casing
:= Lowercase
;
5382 end External_Name_Casing
;
5384 ---------------------------
5385 -- Finalize_Storage_Only --
5386 ---------------------------
5388 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
5390 when Pragma_Finalize_Storage_Only
=> Finalize_Storage
: declare
5391 Assoc
: Node_Id
:= Arg1
;
5392 Type_Id
: Node_Id
:= Expression
(Assoc
);
5396 Check_No_Identifiers
;
5397 Check_Arg_Count
(1);
5398 Check_Arg_Is_Local_Name
(Arg1
);
5400 Find_Type
(Type_Id
);
5401 Typ
:= Entity
(Type_Id
);
5404 or else Rep_Item_Too_Early
(Typ
, N
)
5408 Typ
:= Underlying_Type
(Typ
);
5411 if not Is_Controlled
(Typ
) then
5412 Error_Pragma
("pragma% must specify controlled type");
5415 Check_First_Subtype
(Arg1
);
5417 if Finalize_Storage_Only
(Typ
) then
5418 Error_Pragma
("duplicate pragma%, only one allowed");
5420 elsif not Rep_Item_Too_Late
(Typ
, N
) then
5421 Set_Finalize_Storage_Only
(Base_Type
(Typ
), True);
5423 end Finalize_Storage
;
5425 --------------------------
5426 -- Float_Representation --
5427 --------------------------
5429 -- pragma Float_Representation (VAX_Float | IEEE_Float);
5431 when Pragma_Float_Representation
=> Float_Representation
: declare
5439 if Arg_Count
= 1 then
5440 Check_Valid_Configuration_Pragma
;
5442 Check_Arg_Count
(2);
5443 Check_Optional_Identifier
(Arg2
, Name_Entity
);
5444 Check_Arg_Is_Local_Name
(Arg2
);
5447 Check_No_Identifier
(Arg1
);
5448 Check_Arg_Is_One_Of
(Arg1
, Name_VAX_Float
, Name_IEEE_Float
);
5450 if not OpenVMS_On_Target
then
5451 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
5453 ("?pragma% ignored (applies only to Open'V'M'S)");
5459 -- One argument case
5461 if Arg_Count
= 1 then
5463 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
5465 if Opt
.Float_Format
= 'I' then
5466 Error_Pragma
("'I'E'E'E format previously specified");
5469 Opt
.Float_Format
:= 'V';
5472 if Opt
.Float_Format
= 'V' then
5473 Error_Pragma
("'V'A'X format previously specified");
5476 Opt
.Float_Format
:= 'I';
5479 Set_Standard_Fpt_Formats
;
5481 -- Two argument case
5484 Argx
:= Get_Pragma_Arg
(Arg2
);
5486 if not Is_Entity_Name
(Argx
)
5487 or else not Is_Floating_Point_Type
(Entity
(Argx
))
5490 ("second argument of% pragma must be floating-point type",
5494 Ent
:= Entity
(Argx
);
5495 Digs
:= UI_To_Int
(Digits_Value
(Ent
));
5497 -- Two arguments, VAX_Float case
5499 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
5502 when 6 => Set_F_Float
(Ent
);
5503 when 9 => Set_D_Float
(Ent
);
5504 when 15 => Set_G_Float
(Ent
);
5508 ("wrong digits value, must be 6,9 or 15", Arg2
);
5511 -- Two arguments, IEEE_Float case
5515 when 6 => Set_IEEE_Short
(Ent
);
5516 when 15 => Set_IEEE_Long
(Ent
);
5520 ("wrong digits value, must be 6 or 15", Arg2
);
5524 end Float_Representation
;
5530 -- pragma Ident (static_string_EXPRESSION)
5532 -- Note: pragma Comment shares this processing. Pragma Comment
5533 -- is identical to Ident, except that the restriction of the
5534 -- argument to 31 characters and the placement restrictions
5535 -- are not enforced for pragma Comment.
5537 when Pragma_Ident | Pragma_Comment
=> Ident
: declare
5542 Check_Arg_Count
(1);
5543 Check_No_Identifiers
;
5544 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
5546 -- For pragma Ident, preserve DEC compatibility by requiring
5547 -- the pragma to appear in a declarative part or package spec.
5549 if Prag_Id
= Pragma_Ident
then
5550 Check_Is_In_Decl_Part_Or_Package_Spec
;
5553 Str
:= Expr_Value_S
(Expression
(Arg1
));
5555 -- For pragma Ident, preserve DEC compatibility by limiting
5556 -- the length to 31 characters.
5558 if Prag_Id
= Pragma_Ident
5559 and then String_Length
(Strval
(Str
)) > 31
5562 ("argument for pragma% is too long, maximum is 31", Arg1
);
5570 GP
:= Parent
(Parent
(N
));
5572 if Nkind
(GP
) = N_Package_Declaration
5574 Nkind
(GP
) = N_Generic_Package_Declaration
5579 -- If we have a compilation unit, then record the ident
5580 -- value, checking for improper duplication.
5582 if Nkind
(GP
) = N_Compilation_Unit
then
5583 CS
:= Ident_String
(Current_Sem_Unit
);
5585 if Present
(CS
) then
5587 -- For Ident, we do not permit multiple instances
5589 if Prag_Id
= Pragma_Ident
then
5590 Error_Pragma
("duplicate% pragma not permitted");
5592 -- For Comment, we concatenate the string, unless we
5593 -- want to preserve the tree structure for ASIS.
5595 elsif not Tree_Output
then
5596 Start_String
(Strval
(CS
));
5597 Store_String_Char
(' ');
5598 Store_String_Chars
(Strval
(Str
));
5599 Set_Strval
(CS
, End_String
);
5603 -- In VMS, the effect of IDENT is achieved by passing
5604 -- IDENTIFICATION=name as a --for-linker switch.
5606 if OpenVMS_On_Target
then
5609 ("--for-linker=IDENTIFICATION=");
5610 String_To_Name_Buffer
(Strval
(Str
));
5611 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
5613 -- Only the last processed IDENT is saved. The main
5614 -- purpose is so an IDENT associated with a main
5615 -- procedure will be used in preference to an IDENT
5616 -- associated with a with'd package.
5618 Replace_Linker_Option_String
5619 (End_String
, "--for-linker=IDENTIFICATION=");
5622 Set_Ident_String
(Current_Sem_Unit
, Str
);
5625 -- For subunits, we just ignore the Ident, since in GNAT
5626 -- these are not separate object files, and hence not
5627 -- separate units in the unit table.
5629 elsif Nkind
(GP
) = N_Subunit
then
5632 -- Otherwise we have a misplaced pragma Ident, but we ignore
5633 -- this if we are in an instantiation, since it comes from
5634 -- a generic, and has no relevance to the instantiation.
5636 elsif Prag_Id
= Pragma_Ident
then
5637 if Instantiation_Location
(Loc
) = No_Location
then
5638 Error_Pragma
("pragma% only allowed at outer level");
5649 -- [ Convention =>] convention_IDENTIFIER,
5650 -- [ Entity =>] local_NAME
5651 -- [, [External_Name =>] static_string_EXPRESSION ]
5652 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5654 when Pragma_Import
=>
5655 Check_Ada_83_Warning
;
5656 Check_At_Least_N_Arguments
(2);
5657 Check_At_Most_N_Arguments
(4);
5658 Process_Import_Or_Interface
;
5660 ----------------------
5661 -- Import_Exception --
5662 ----------------------
5664 -- pragma Import_Exception (
5665 -- [Internal =>] LOCAL_NAME,
5666 -- [, [External =>] EXTERNAL_SYMBOL,]
5667 -- [, [Form =>] Ada | VMS]
5668 -- [, [Code =>] static_integer_EXPRESSION]);
5670 when Pragma_Import_Exception
=> Import_Exception
: declare
5671 Args
: Args_List
(1 .. 4);
5672 Names
: Name_List
(1 .. 4) := (
5678 Internal
: Node_Id
renames Args
(1);
5679 External
: Node_Id
renames Args
(2);
5680 Form
: Node_Id
renames Args
(3);
5681 Code
: Node_Id
renames Args
(4);
5684 Gather_Associations
(Names
, Args
);
5686 if Present
(External
) and then Present
(Code
) then
5688 ("cannot give both External and Code options for pragma%");
5691 Process_Extended_Import_Export_Exception_Pragma
(
5692 Arg_Internal
=> Internal
,
5693 Arg_External
=> External
,
5697 if not Is_VMS_Exception
(Entity
(Internal
)) then
5698 Set_Imported
(Entity
(Internal
));
5700 end Import_Exception
;
5702 ---------------------
5703 -- Import_Function --
5704 ---------------------
5706 -- pragma Import_Function (
5707 -- [Internal =>] LOCAL_NAME,
5708 -- [, [External =>] EXTERNAL_SYMBOL]
5709 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5710 -- [, [Result_Type =>] SUBTYPE_MARK]
5711 -- [, [Mechanism =>] MECHANISM]
5712 -- [, [Result_Mechanism =>] MECHANISM_NAME]
5713 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
5715 when Pragma_Import_Function
=> Import_Function
: declare
5716 Args
: Args_List
(1 .. 7);
5717 Names
: Name_List
(1 .. 7) := (
5720 Name_Parameter_Types
,
5723 Name_Result_Mechanism
,
5724 Name_First_Optional_Parameter
);
5726 Internal
: Node_Id
renames Args
(1);
5727 External
: Node_Id
renames Args
(2);
5728 Parameter_Types
: Node_Id
renames Args
(3);
5729 Result_Type
: Node_Id
renames Args
(4);
5730 Mechanism
: Node_Id
renames Args
(5);
5731 Result_Mechanism
: Node_Id
renames Args
(6);
5732 First_Optional_Parameter
: Node_Id
renames Args
(7);
5736 Gather_Associations
(Names
, Args
);
5737 Process_Extended_Import_Export_Subprogram_Pragma
(
5738 Arg_Internal
=> Internal
,
5739 Arg_External
=> External
,
5740 Arg_Parameter_Types
=> Parameter_Types
,
5741 Arg_Result_Type
=> Result_Type
,
5742 Arg_Mechanism
=> Mechanism
,
5743 Arg_Result_Mechanism
=> Result_Mechanism
,
5744 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
5745 end Import_Function
;
5751 -- pragma Import_Object (
5752 -- [Internal =>] LOCAL_NAME,
5753 -- [, [External =>] EXTERNAL_SYMBOL]
5754 -- [, [Size =>] EXTERNAL_SYMBOL]);
5756 when Pragma_Import_Object
=> Import_Object
: declare
5757 Args
: Args_List
(1 .. 3);
5758 Names
: Name_List
(1 .. 3) := (
5763 Internal
: Node_Id
renames Args
(1);
5764 External
: Node_Id
renames Args
(2);
5765 Size
: Node_Id
renames Args
(3);
5769 Gather_Associations
(Names
, Args
);
5770 Process_Extended_Import_Export_Object_Pragma
(
5771 Arg_Internal
=> Internal
,
5772 Arg_External
=> External
,
5776 ----------------------
5777 -- Import_Procedure --
5778 ----------------------
5780 -- pragma Import_Procedure (
5781 -- [Internal =>] LOCAL_NAME,
5782 -- [, [External =>] EXTERNAL_SYMBOL]
5783 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5784 -- [, [Mechanism =>] MECHANISM]
5785 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
5787 when Pragma_Import_Procedure
=> Import_Procedure
: declare
5788 Args
: Args_List
(1 .. 5);
5789 Names
: Name_List
(1 .. 5) := (
5792 Name_Parameter_Types
,
5794 Name_First_Optional_Parameter
);
5796 Internal
: Node_Id
renames Args
(1);
5797 External
: Node_Id
renames Args
(2);
5798 Parameter_Types
: Node_Id
renames Args
(3);
5799 Mechanism
: Node_Id
renames Args
(4);
5800 First_Optional_Parameter
: Node_Id
renames Args
(5);
5804 Gather_Associations
(Names
, Args
);
5805 Process_Extended_Import_Export_Subprogram_Pragma
(
5806 Arg_Internal
=> Internal
,
5807 Arg_External
=> External
,
5808 Arg_Parameter_Types
=> Parameter_Types
,
5809 Arg_Mechanism
=> Mechanism
,
5810 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
5811 end Import_Procedure
;
5813 -----------------------------
5814 -- Import_Valued_Procedure --
5815 -----------------------------
5817 -- pragma Import_Valued_Procedure (
5818 -- [Internal =>] LOCAL_NAME,
5819 -- [, [External =>] EXTERNAL_SYMBOL]
5820 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5821 -- [, [Mechanism =>] MECHANISM]
5822 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
5824 when Pragma_Import_Valued_Procedure
=>
5825 Import_Valued_Procedure
: declare
5826 Args
: Args_List
(1 .. 5);
5827 Names
: Name_List
(1 .. 5) := (
5830 Name_Parameter_Types
,
5832 Name_First_Optional_Parameter
);
5834 Internal
: Node_Id
renames Args
(1);
5835 External
: Node_Id
renames Args
(2);
5836 Parameter_Types
: Node_Id
renames Args
(3);
5837 Mechanism
: Node_Id
renames Args
(4);
5838 First_Optional_Parameter
: Node_Id
renames Args
(5);
5842 Gather_Associations
(Names
, Args
);
5843 Process_Extended_Import_Export_Subprogram_Pragma
(
5844 Arg_Internal
=> Internal
,
5845 Arg_External
=> External
,
5846 Arg_Parameter_Types
=> Parameter_Types
,
5847 Arg_Mechanism
=> Mechanism
,
5848 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
5849 end Import_Valued_Procedure
;
5851 ------------------------
5852 -- Initialize_Scalars --
5853 ------------------------
5855 -- pragma Initialize_Scalars;
5857 when Pragma_Initialize_Scalars
=>
5859 Check_Arg_Count
(0);
5860 Check_Valid_Configuration_Pragma
;
5861 Init_Or_Norm_Scalars
:= True;
5862 Initialize_Scalars
:= True;
5868 -- pragma Inline ( NAME {, NAME} );
5870 when Pragma_Inline
=>
5872 -- Pragma is active if inlining option is active
5874 if Inline_Active
then
5875 Process_Inline
(True);
5877 -- Pragma is active in a predefined file in no run time mode
5881 Is_Predefined_File_Name
(Unit_File_Name
(Current_Sem_Unit
))
5883 Process_Inline
(True);
5886 Process_Inline
(False);
5893 -- pragma Inline_Always ( NAME {, NAME} );
5895 when Pragma_Inline_Always
=>
5896 Process_Inline
(True);
5898 --------------------
5899 -- Inline_Generic --
5900 --------------------
5902 -- pragma Inline_Generic (NAME {, NAME});
5904 when Pragma_Inline_Generic
=>
5905 Process_Generic_List
;
5907 ----------------------
5908 -- Inspection_Point --
5909 ----------------------
5911 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
5913 when Pragma_Inspection_Point
=> Inspection_Point
: declare
5918 if Arg_Count
> 0 then
5921 Exp
:= Expression
(Arg
);
5924 if not Is_Entity_Name
(Exp
)
5925 or else not Is_Object
(Entity
(Exp
))
5927 Error_Pragma_Arg
("object name required", Arg
);
5934 end Inspection_Point
;
5940 -- pragma Interface (
5941 -- convention_IDENTIFIER,
5944 when Pragma_Interface
=>
5946 Check_Arg_Count
(2);
5947 Check_No_Identifiers
;
5948 Process_Import_Or_Interface
;
5950 --------------------
5951 -- Interface_Name --
5952 --------------------
5954 -- pragma Interface_Name (
5955 -- [ Entity =>] local_NAME
5956 -- [,[External_Name =>] static_string_EXPRESSION ]
5957 -- [,[Link_Name =>] static_string_EXPRESSION ]);
5959 when Pragma_Interface_Name
=> Interface_Name
: declare
5967 Check_At_Least_N_Arguments
(2);
5968 Check_At_Most_N_Arguments
(3);
5969 Id
:= Expression
(Arg1
);
5972 if not Is_Entity_Name
(Id
) then
5974 ("first argument for pragma% must be entity name", Arg1
);
5975 elsif Etype
(Id
) = Any_Type
then
5978 Def_Id
:= Entity
(Id
);
5981 -- Special DEC-compatible processing for the object case,
5982 -- forces object to be imported.
5984 if Ekind
(Def_Id
) = E_Variable
then
5985 Kill_Size_Check_Code
(Def_Id
);
5986 Note_Possible_Modification
(Id
);
5988 -- Initialization is not allowed for imported variable
5990 if Present
(Expression
(Parent
(Def_Id
)))
5991 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
5993 Error_Msg_Sloc
:= Sloc
(Def_Id
);
5995 ("no initialization allowed for declaration of& #",
5999 -- For compatibility, support VADS usage of providing both
6000 -- pragmas Interface and Interface_Name to obtain the effect
6001 -- of a single Import pragma.
6003 if Is_Imported
(Def_Id
)
6004 and then Present
(First_Rep_Item
(Def_Id
))
6005 and then Nkind
(First_Rep_Item
(Def_Id
)) = N_Pragma
6006 and then Chars
(First_Rep_Item
(Def_Id
)) = Name_Interface
6010 Set_Imported
(Def_Id
);
6013 Set_Is_Public
(Def_Id
);
6014 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
6017 -- Otherwise must be subprogram
6019 elsif not Is_Subprogram
(Def_Id
) then
6021 ("argument of pragma% is not subprogram", Arg1
);
6024 Check_At_Most_N_Arguments
(3);
6028 -- Loop through homonyms
6031 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
6033 if Is_Imported
(Def_Id
) then
6034 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
6038 Hom_Id
:= Homonym
(Hom_Id
);
6040 exit when No
(Hom_Id
)
6041 or else Scope
(Hom_Id
) /= Current_Scope
;
6046 ("argument of pragma% is not imported subprogram",
6052 -----------------------
6053 -- Interrupt_Handler --
6054 -----------------------
6056 -- pragma Interrupt_Handler (handler_NAME);
6058 when Pragma_Interrupt_Handler
=>
6059 Check_Ada_83_Warning
;
6060 Check_Arg_Count
(1);
6061 Check_No_Identifiers
;
6062 Check_Interrupt_Or_Attach_Handler
;
6063 Process_Interrupt_Or_Attach_Handler
;
6065 ------------------------
6066 -- Interrupt_Priority --
6067 ------------------------
6069 -- pragma Interrupt_Priority [(EXPRESSION)];
6071 when Pragma_Interrupt_Priority
=> Interrupt_Priority
: declare
6072 P
: constant Node_Id
:= Parent
(N
);
6076 Check_Ada_83_Warning
;
6078 if Arg_Count
/= 0 then
6079 Arg
:= Expression
(Arg1
);
6080 Check_Arg_Count
(1);
6081 Check_No_Identifiers
;
6083 -- Set In_Default_Expression for per-object case???
6085 Analyze_And_Resolve
(Arg
, Standard_Integer
);
6086 if Expander_Active
then
6088 Convert_To
(RTE
(RE_Interrupt_Priority
), Arg
));
6092 if Nkind
(P
) /= N_Task_Definition
6093 and then Nkind
(P
) /= N_Protected_Definition
6098 elsif Has_Priority_Pragma
(P
) then
6099 Error_Pragma
("duplicate pragma% not allowed");
6102 Set_Has_Priority_Pragma
(P
, True);
6103 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
6105 end Interrupt_Priority
;
6107 ----------------------
6108 -- Java_Constructor --
6109 ----------------------
6111 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
6113 when Pragma_Java_Constructor
=> Java_Constructor
: declare
6120 Check_Arg_Count
(1);
6121 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6122 Check_Arg_Is_Local_Name
(Arg1
);
6124 Id
:= Expression
(Arg1
);
6125 Find_Program_Unit_Name
(Id
);
6127 -- If we did not find the name, we are done
6129 if Etype
(Id
) = Any_Type
then
6133 Hom_Id
:= Entity
(Id
);
6135 -- Loop through homonyms
6138 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
6140 -- The constructor is required to be a function returning
6141 -- an access type whose designated type has convention Java.
6143 if Ekind
(Def_Id
) = E_Function
6144 and then Ekind
(Etype
(Def_Id
)) in Access_Kind
6147 (Designated_Type
(Etype
(Def_Id
))) = Convention_Java
6150 (Root_Type
(Designated_Type
(Etype
(Def_Id
))))
6153 Set_Is_Constructor
(Def_Id
);
6154 Set_Convention
(Def_Id
, Convention_Java
);
6158 ("pragma% requires function returning a 'Java access type",
6162 Hom_Id
:= Homonym
(Hom_Id
);
6164 exit when No
(Hom_Id
) or else Scope
(Hom_Id
) /= Current_Scope
;
6166 end Java_Constructor
;
6168 ----------------------
6169 -- Java_Interface --
6170 ----------------------
6172 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
6174 when Pragma_Java_Interface
=> Java_Interface
: declare
6180 Check_Arg_Count
(1);
6181 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6182 Check_Arg_Is_Local_Name
(Arg1
);
6184 Arg
:= Expression
(Arg1
);
6187 if Etype
(Arg
) = Any_Type
then
6191 if not Is_Entity_Name
(Arg
)
6192 or else not Is_Type
(Entity
(Arg
))
6194 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
6197 Typ
:= Underlying_Type
(Entity
(Arg
));
6199 -- For now we simply check some of the semantic constraints
6200 -- on the type. This currently leaves out some restrictions
6201 -- on interface types, namely that the parent type must be
6202 -- java.lang.Object.Typ and that all primitives of the type
6203 -- should be declared abstract. ???
6205 if not Is_Tagged_Type
(Typ
) or else not Is_Abstract
(Typ
) then
6206 Error_Pragma_Arg
("pragma% requires an abstract "
6207 & "tagged type", Arg1
);
6209 elsif not Has_Discriminants
(Typ
)
6210 or else Ekind
(Etype
(First_Discriminant
(Typ
)))
6211 /= E_Anonymous_Access_Type
6213 not Is_Class_Wide_Type
6214 (Designated_Type
(Etype
(First_Discriminant
(Typ
))))
6217 ("type must have a class-wide access discriminant", Arg1
);
6225 -- pragma License (RESTRICTED | UNRESRICTED | GPL | MODIFIED_GPL);
6227 when Pragma_License
=>
6229 Check_Arg_Count
(1);
6230 Check_No_Identifiers
;
6231 Check_Valid_Configuration_Pragma
;
6232 Check_Arg_Is_Identifier
(Arg1
);
6235 Sind
: constant Source_File_Index
:=
6236 Source_Index
(Current_Sem_Unit
);
6239 case Chars
(Get_Pragma_Arg
(Arg1
)) is
6241 Set_License
(Sind
, GPL
);
6243 when Name_Modified_GPL
=>
6244 Set_License
(Sind
, Modified_GPL
);
6246 when Name_Restricted
=>
6247 Set_License
(Sind
, Restricted
);
6249 when Name_Unrestricted
=>
6250 Set_License
(Sind
, Unrestricted
);
6253 Error_Pragma_Arg
("invalid license name", Arg1
);
6261 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
6263 when Pragma_Link_With
=> Link_With
: declare
6269 if Operating_Mode
= Generate_Code
6270 and then In_Extended_Main_Source_Unit
(N
)
6272 Check_At_Least_N_Arguments
(1);
6273 Check_No_Identifiers
;
6274 Check_Is_In_Decl_Part_Or_Package_Spec
;
6275 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
6279 while Present
(Arg
) loop
6280 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
6282 -- Store argument, converting sequences of spaces
6283 -- to a single null character (this is one of the
6284 -- differences in processing between Link_With
6285 -- and Linker_Options).
6288 C
: constant Char_Code
:= Get_Char_Code
(' ');
6289 S
: constant String_Id
:=
6290 Strval
(Expr_Value_S
(Expression
(Arg
)));
6293 L
: Nat
:= String_Length
(S
);
6295 procedure Skip_Spaces
;
6296 -- Advance F past any spaces
6298 procedure Skip_Spaces
is
6300 while F
<= L
and then Get_String_Char
(S
, F
) = C
loop
6306 Skip_Spaces
; -- skip leading spaces
6308 -- Loop through characters, changing any embedded
6309 -- sequence of spaces to a single null character
6310 -- (this is how Link_With/Linker_Options differ)
6313 if Get_String_Char
(S
, F
) = C
then
6316 Store_String_Char
(ASCII
.NUL
);
6319 Store_String_Char
(Get_String_Char
(S
, F
));
6327 if Present
(Arg
) then
6328 Store_String_Char
(ASCII
.NUL
);
6332 Store_Linker_Option_String
(End_String
);
6340 -- pragma Linker_Alias (
6341 -- [Entity =>] LOCAL_NAME
6342 -- [Alias =>] static_string_EXPRESSION);
6344 when Pragma_Linker_Alias
=>
6346 Check_Arg_Count
(2);
6347 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6348 Check_Optional_Identifier
(Arg2
, "alias");
6349 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
6350 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
6352 -- The only processing required is to link this item on to the
6353 -- list of rep items for the given entity. This is accomplished
6354 -- by the call to Rep_Item_Too_Late (when no error is detected
6355 -- and False is returned).
6357 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
6360 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
6363 --------------------
6364 -- Linker_Options --
6365 --------------------
6367 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
6369 when Pragma_Linker_Options
=> Linker_Options
: declare
6373 Check_Ada_83_Warning
;
6374 Check_No_Identifiers
;
6375 Check_Arg_Count
(1);
6376 Check_Is_In_Decl_Part_Or_Package_Spec
;
6378 if Operating_Mode
= Generate_Code
6379 and then In_Extended_Main_Source_Unit
(N
)
6381 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
6382 Start_String
(Strval
(Expr_Value_S
(Expression
(Arg1
))));
6385 while Present
(Arg
) loop
6386 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
6387 Store_String_Char
(ASCII
.NUL
);
6389 (Strval
(Expr_Value_S
(Expression
(Arg
))));
6393 Store_Linker_Option_String
(End_String
);
6397 --------------------
6398 -- Linker_Section --
6399 --------------------
6401 -- pragma Linker_Section (
6402 -- [Entity =>] LOCAL_NAME
6403 -- [Section =>] static_string_EXPRESSION);
6405 when Pragma_Linker_Section
=>
6407 Check_Arg_Count
(2);
6408 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6409 Check_Optional_Identifier
(Arg2
, Name_Section
);
6410 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
6411 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
6413 -- The only processing required is to link this item on to the
6414 -- list of rep items for the given entity. This is accomplished
6415 -- by the call to Rep_Item_Too_Late (when no error is detected
6416 -- and False is returned).
6418 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
6421 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
6428 -- pragma List (On | Off)
6430 -- There is nothing to do here, since we did all the processing
6431 -- for this pragma in Par.Prag (so that it works properly even in
6432 -- syntax only mode)
6437 --------------------
6438 -- Locking_Policy --
6439 --------------------
6441 -- pragma Locking_Policy (policy_IDENTIFIER);
6443 when Pragma_Locking_Policy
=> declare
6447 Check_Ada_83_Warning
;
6448 Check_Arg_Count
(1);
6449 Check_No_Identifiers
;
6450 Check_Arg_Is_Locking_Policy
(Arg1
);
6451 Check_Valid_Configuration_Pragma
;
6452 Get_Name_String
(Chars
(Expression
(Arg1
)));
6453 LP
:= Fold_Upper
(Name_Buffer
(1));
6455 if Locking_Policy
/= ' '
6456 and then Locking_Policy
/= LP
6458 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
6459 Error_Pragma
("locking policy incompatible with policy#");
6461 Locking_Policy
:= LP
;
6462 Locking_Policy_Sloc
:= Loc
;
6470 -- pragma Long_Float (D_Float | G_Float);
6472 when Pragma_Long_Float
=>
6474 Check_Valid_Configuration_Pragma
;
6475 Check_Arg_Count
(1);
6476 Check_No_Identifier
(Arg1
);
6477 Check_Arg_Is_One_Of
(Arg1
, Name_D_Float
, Name_G_Float
);
6479 if not OpenVMS_On_Target
then
6480 Error_Pragma
("?pragma% ignored (applies only to Open'V'M'S)");
6485 if Chars
(Expression
(Arg1
)) = Name_D_Float
then
6486 if Opt
.Float_Format_Long
= 'G' then
6487 Error_Pragma
("G_Float previously specified");
6490 Opt
.Float_Format_Long
:= 'D';
6492 -- G_Float case (this is the default, does not need overriding)
6495 if Opt
.Float_Format_Long
= 'D' then
6496 Error_Pragma
("D_Float previously specified");
6499 Opt
.Float_Format_Long
:= 'G';
6502 Set_Standard_Fpt_Formats
;
6504 -----------------------
6505 -- Machine_Attribute --
6506 -----------------------
6508 -- pragma Machine_Attribute (
6509 -- [Entity =>] LOCAL_NAME,
6510 -- [Attribute_Name =>] static_string_EXPRESSION
6511 -- [,[Info =>] static_string_EXPRESSION] );
6513 when Pragma_Machine_Attribute
=> Machine_Attribute
: declare
6519 if Arg_Count
= 3 then
6520 Check_Optional_Identifier
(Arg3
, "info");
6521 Check_Arg_Is_Static_Expression
(Arg3
, Standard_String
);
6523 Check_Arg_Count
(2);
6526 Check_Arg_Is_Local_Name
(Arg1
);
6527 Check_Optional_Identifier
(Arg2
, "attribute_name");
6528 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6529 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
6530 Def_Id
:= Entity
(Expression
(Arg1
));
6532 if Is_Access_Type
(Def_Id
) then
6533 Def_Id
:= Designated_Type
(Def_Id
);
6536 if Rep_Item_Too_Early
(Def_Id
, N
) then
6540 Def_Id
:= Underlying_Type
(Def_Id
);
6542 -- The only processing required is to link this item on to the
6543 -- list of rep items for the given entity. This is accomplished
6544 -- by the call to Rep_Item_Too_Late (when no error is detected
6545 -- and False is returned).
6547 if Rep_Item_Too_Late
(Def_Id
, N
) then
6550 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
6552 end Machine_Attribute
;
6558 -- pragma Main_Storage
6559 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
6561 -- MAIN_STORAGE_OPTION ::=
6562 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
6563 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
6565 when Pragma_Main
=> Main
: declare
6566 Args
: Args_List
(1 .. 3);
6567 Names
: Name_List
(1 .. 3) := (
6569 Name_Task_Stack_Size_Default
,
6570 Name_Time_Slicing_Enabled
);
6576 Gather_Associations
(Names
, Args
);
6578 for J
in 1 .. 2 loop
6579 if Present
(Args
(J
)) then
6580 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
6584 if Present
(Args
(3)) then
6585 Check_Arg_Is_Static_Expression
(Args
(3), Standard_Boolean
);
6589 while Present
(Nod
) loop
6590 if Nkind
(Nod
) = N_Pragma
6591 and then Chars
(Nod
) = Name_Main
6593 Error_Msg_Name_1
:= Chars
(N
);
6594 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
6605 -- pragma Main_Storage
6606 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
6608 -- MAIN_STORAGE_OPTION ::=
6609 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
6610 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
6612 when Pragma_Main_Storage
=> Main_Storage
: declare
6613 Args
: Args_List
(1 .. 2);
6614 Names
: Name_List
(1 .. 2) := (
6615 Name_Working_Storage
,
6622 Gather_Associations
(Names
, Args
);
6624 for J
in 1 .. 2 loop
6625 if Present
(Args
(J
)) then
6626 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
6630 Check_In_Main_Program
;
6633 while Present
(Nod
) loop
6634 if Nkind
(Nod
) = N_Pragma
6635 and then Chars
(Nod
) = Name_Main_Storage
6637 Error_Msg_Name_1
:= Chars
(N
);
6638 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
6649 -- pragma Memory_Size (NUMERIC_LITERAL)
6651 when Pragma_Memory_Size
=>
6654 -- Memory size is simply ignored
6656 Check_No_Identifiers
;
6657 Check_Arg_Count
(1);
6658 Check_Arg_Is_Integer_Literal
(Arg1
);
6664 -- pragma No_Return (procedure_LOCAL_NAME);
6666 when Pragma_No_Return
=> declare
6673 Check_Arg_Count
(1);
6674 Check_No_Identifiers
;
6675 Check_Arg_Is_Local_Name
(Arg1
);
6676 Id
:= Expression
(Arg1
);
6679 if not Is_Entity_Name
(Id
) then
6680 Error_Pragma_Arg
("entity name required", Arg1
);
6683 if Etype
(Id
) = Any_Type
then
6691 and then Scope
(E
) = Current_Scope
6693 if Ekind
(E
) = E_Procedure
6694 or else Ekind
(E
) = E_Generic_Procedure
6704 Error_Pragma
("no procedures found for pragma%");
6712 -- pragma No_Run_Time
6714 when Pragma_No_Run_Time
=>
6716 Check_Valid_Configuration_Pragma
;
6717 Check_Arg_Count
(0);
6718 Set_No_Run_Time_Mode
;
6720 -----------------------
6721 -- Normalize_Scalars --
6722 -----------------------
6724 -- pragma Normalize_Scalars;
6726 when Pragma_Normalize_Scalars
=>
6727 Check_Ada_83_Warning
;
6728 Check_Arg_Count
(0);
6729 Check_Valid_Configuration_Pragma
;
6730 Normalize_Scalars
:= True;
6731 Init_Or_Norm_Scalars
:= True;
6737 -- pragma Optimize (Time | Space);
6739 -- The actual check for optimize is done in Gigi. Note that this
6740 -- pragma does not actually change the optimization setting, it
6741 -- simply checks that it is consistent with the pragma.
6743 when Pragma_Optimize
=>
6744 Check_No_Identifiers
;
6745 Check_Arg_Count
(1);
6746 Check_Arg_Is_One_Of
(Arg1
, Name_Time
, Name_Space
, Name_Off
);
6752 -- pragma Pack (first_subtype_LOCAL_NAME);
6754 when Pragma_Pack
=> Pack
: declare
6755 Assoc
: Node_Id
:= Arg1
;
6760 Check_No_Identifiers
;
6761 Check_Arg_Count
(1);
6762 Check_Arg_Is_Local_Name
(Arg1
);
6764 Type_Id
:= Expression
(Assoc
);
6765 Find_Type
(Type_Id
);
6766 Typ
:= Entity
(Type_Id
);
6769 or else Rep_Item_Too_Early
(Typ
, N
)
6773 Typ
:= Underlying_Type
(Typ
);
6776 if not Is_Array_Type
(Typ
) and then not Is_Record_Type
(Typ
) then
6777 Error_Pragma
("pragma% must specify array or record type");
6780 Check_First_Subtype
(Arg1
);
6782 if Has_Pragma_Pack
(Typ
) then
6783 Error_Pragma
("duplicate pragma%, only one allowed");
6785 -- Array type. We set the Has_Pragma_Pack flag, and Is_Packed,
6786 -- but not Has_Non_Standard_Rep, because we don't actually know
6787 -- till freeze time if the array can have packed representation.
6788 -- That's because in the general case we do not know enough about
6789 -- the component type until it in turn is frozen, which certainly
6790 -- happens before the array type is frozen, but not necessarily
6791 -- till that point (i.e. right now it may be unfrozen).
6793 elsif Is_Array_Type
(Typ
) then
6795 if Has_Aliased_Components
(Base_Type
(Typ
)) then
6797 ("pragma% ignored, cannot pack aliased components?");
6799 elsif Has_Atomic_Components
(Typ
) then
6801 ("?pragma% ignored, cannot pack atomic components");
6803 elsif not Rep_Item_Too_Late
(Typ
, N
) then
6804 Set_Is_Packed
(Base_Type
(Typ
));
6805 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
6806 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
6809 -- Record type. For record types, the pack is always effective
6811 else -- Is_Record_Type (Typ)
6812 if not Rep_Item_Too_Late
(Typ
, N
) then
6813 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
6814 Set_Is_Packed
(Base_Type
(Typ
));
6815 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
6826 -- There is nothing to do here, since we did all the processing
6827 -- for this pragma in Par.Prag (so that it works properly even in
6828 -- syntax only mode)
6837 -- pragma Passive [(PASSIVE_FORM)];
6839 -- PASSIVE_FORM ::= Semaphore | No
6841 when Pragma_Passive
=>
6844 if Nkind
(Parent
(N
)) /= N_Task_Definition
then
6845 Error_Pragma
("pragma% must be within task definition");
6848 if Arg_Count
/= 0 then
6849 Check_Arg_Count
(1);
6850 Check_Arg_Is_One_Of
(Arg1
, Name_Semaphore
, Name_No
);
6857 -- pragma Polling (ON | OFF);
6859 when Pragma_Polling
=>
6861 Check_Arg_Count
(1);
6862 Check_No_Identifiers
;
6863 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
6864 Polling_Required
:= (Chars
(Expression
(Arg1
)) = Name_On
);
6870 -- pragma Preelaborate [(library_unit_NAME)];
6872 -- Set the flag Is_Preelaborated of program unit name entity
6874 when Pragma_Preelaborate
=> Preelaborate
: declare
6876 Pa
: Node_Id
:= Parent
(N
);
6877 Pk
: Node_Kind
:= Nkind
(Pa
);
6880 Check_Ada_83_Warning
;
6881 Check_Valid_Library_Unit_Pragma
;
6883 if Nkind
(N
) = N_Null_Statement
then
6887 Ent
:= Find_Lib_Unit_Name
;
6889 -- This filters out pragmas inside generic parent then
6890 -- show up inside instantiation
6893 and then not (Pk
= N_Package_Specification
6894 and then Present
(Generic_Parent
(Pa
)))
6896 if not Debug_Flag_U
then
6897 Set_Is_Preelaborated
(Ent
);
6898 Set_Suppress_Elaboration_Warnings
(Ent
);
6907 -- pragma Priority (EXPRESSION);
6909 when Pragma_Priority
=> Priority
: declare
6910 P
: constant Node_Id
:= Parent
(N
);
6914 Check_No_Identifiers
;
6915 Check_Arg_Count
(1);
6917 Arg
:= Expression
(Arg1
);
6918 Analyze_And_Resolve
(Arg
, Standard_Integer
);
6920 if not Is_Static_Expression
(Arg
) then
6921 Check_Restriction
(Static_Priorities
, Arg
);
6926 if Nkind
(P
) = N_Subprogram_Body
then
6927 Check_In_Main_Program
;
6931 if not Is_Static_Expression
(Arg
) then
6933 ("main subprogram priority is not static", Arg1
);
6935 -- If constraint error, then we already signalled an error
6937 elsif Raises_Constraint_Error
(Arg
) then
6940 -- Otherwise check in range
6944 Val
: constant Uint
:= Expr_Value
(Arg
);
6948 or else Val
> Expr_Value
(Expression
6949 (Parent
(RTE
(RE_Max_Priority
))))
6952 ("main subprogram priority is out of range", Arg1
);
6958 (Current_Sem_Unit
, UI_To_Int
(Expr_Value
(Arg
)));
6960 -- Task or Protected, must be of type Integer
6962 elsif Nkind
(P
) = N_Protected_Definition
6964 Nkind
(P
) = N_Task_Definition
6966 if Expander_Active
then
6968 Convert_To
(RTE
(RE_Any_Priority
), Arg
));
6971 -- Anything else is incorrect
6977 if Has_Priority_Pragma
(P
) then
6978 Error_Pragma
("duplicate pragma% not allowed");
6980 Set_Has_Priority_Pragma
(P
, True);
6982 if Nkind
(P
) = N_Protected_Definition
6984 Nkind
(P
) = N_Task_Definition
6986 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
6987 -- exp_ch9 should use this ???
6992 --------------------------
6993 -- Propagate_Exceptions --
6994 --------------------------
6996 -- pragma Propagate_Exceptions;
6998 when Pragma_Propagate_Exceptions
=>
7000 Check_Arg_Count
(0);
7002 if In_Extended_Main_Source_Unit
(N
) then
7003 Propagate_Exceptions
:= True;
7010 -- pragma Psect_Object (
7011 -- [Internal =>] LOCAL_NAME,
7012 -- [, [External =>] EXTERNAL_SYMBOL]
7013 -- [, [Size =>] EXTERNAL_SYMBOL]);
7015 when Pragma_Psect_Object | Pragma_Common_Object
=>
7016 Psect_Object
: declare
7017 Args
: Args_List
(1 .. 3);
7018 Names
: Name_List
(1 .. 3) := (
7023 Internal
: Node_Id
renames Args
(1);
7024 External
: Node_Id
renames Args
(2);
7025 Size
: Node_Id
renames Args
(3);
7027 R_Internal
: Node_Id
;
7028 R_External
: Node_Id
;
7035 procedure Check_Too_Long
(Arg
: Node_Id
);
7036 -- Posts message if the argument is an identifier with more
7037 -- than 31 characters, or a string literal with more than
7038 -- 31 characters, and we are operating under VMS
7040 --------------------
7041 -- Check_Too_Long --
7042 --------------------
7044 procedure Check_Too_Long
(Arg
: Node_Id
) is
7045 X
: Node_Id
:= Original_Node
(Arg
);
7048 if Nkind
(X
) /= N_String_Literal
7050 Nkind
(X
) /= N_Identifier
7053 ("inappropriate argument for pragma %", Arg
);
7056 if OpenVMS_On_Target
then
7057 if (Nkind
(X
) = N_String_Literal
7058 and then String_Length
(Strval
(X
)) > 31)
7060 (Nkind
(X
) = N_Identifier
7061 and then Length_Of_Name
(Chars
(X
)) > 31)
7064 ("argument for pragma % is longer than 31 characters",
7070 -- Start of processing for Common_Object/Psect_Object
7074 Gather_Associations
(Names
, Args
);
7075 Process_Extended_Import_Export_Internal_Arg
(Internal
);
7077 R_Internal
:= Relocate_Node
(Internal
);
7079 Def_Id
:= Entity
(R_Internal
);
7081 if Ekind
(Def_Id
) /= E_Constant
7082 and then Ekind
(Def_Id
) /= E_Variable
7085 ("pragma% must designate an object", Internal
);
7088 Check_Too_Long
(R_Internal
);
7090 if Is_Imported
(Def_Id
) or else Is_Exported
(Def_Id
) then
7092 ("cannot use pragma% for imported/exported object",
7096 if Is_Concurrent_Type
(Etype
(R_Internal
)) then
7098 ("cannot specify pragma % for task/protected object",
7102 if Is_Psected
(Def_Id
) then
7103 Error_Msg_N
("?duplicate Psect_Object pragma", N
);
7105 Set_Is_Psected
(Def_Id
);
7108 if Ekind
(Def_Id
) = E_Constant
then
7110 ("cannot specify pragma % for a constant", R_Internal
);
7113 if Is_Record_Type
(Etype
(R_Internal
)) then
7119 Ent
:= First_Entity
(Etype
(R_Internal
));
7120 while Present
(Ent
) loop
7121 Decl
:= Declaration_Node
(Ent
);
7123 if Ekind
(Ent
) = E_Component
7124 and then Nkind
(Decl
) = N_Component_Declaration
7125 and then Present
(Expression
(Decl
))
7128 ("?object for pragma % has defaults", R_Internal
);
7138 if Present
(Size
) then
7139 Check_Too_Long
(Size
);
7142 -- Make Psect case-insensitive.
7144 if Present
(External
) then
7145 Check_Too_Long
(External
);
7147 if Nkind
(External
) = N_String_Literal
then
7148 String_To_Name_Buffer
(Strval
(External
));
7150 Get_Name_String
(Chars
(External
));
7155 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
7157 R_External
:= Make_String_Literal
7158 (Sloc
=> Sloc
(External
), Strval
=> Str
);
7160 Get_Name_String
(Chars
(Internal
));
7163 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
7165 R_External
:= Make_String_Literal
7166 (Sloc
=> Sloc
(Internal
), Strval
=> Str
);
7169 -- Transform into pragma Linker_Section, add attributes to
7170 -- match what DEC Ada does. Ignore size for now?
7175 Name_Linker_Section
,
7177 (Make_Pragma_Argument_Association
7178 (Sloc
=> Sloc
(R_Internal
),
7179 Expression
=> R_Internal
),
7180 Make_Pragma_Argument_Association
7181 (Sloc
=> Sloc
(R_External
),
7182 Expression
=> R_External
))));
7186 -- Add Machine_Attribute of "overlaid", so the section overlays
7187 -- other sections of the same name.
7190 Store_String_Chars
("overlaid");
7196 Name_Machine_Attribute
,
7198 (Make_Pragma_Argument_Association
7199 (Sloc
=> Sloc
(R_Internal
),
7200 Expression
=> R_Internal
),
7201 Make_Pragma_Argument_Association
7202 (Sloc
=> Sloc
(R_External
),
7205 (Sloc
=> Sloc
(R_External
),
7209 -- Add Machine_Attribute of "global", so the section is visible
7213 Store_String_Chars
("global");
7219 Name_Machine_Attribute
,
7221 (Make_Pragma_Argument_Association
7222 (Sloc
=> Sloc
(R_Internal
),
7223 Expression
=> R_Internal
),
7224 Make_Pragma_Argument_Association
7225 (Sloc
=> Sloc
(R_External
),
7228 (Sloc
=> Sloc
(R_External
),
7232 -- Add Machine_Attribute of "initialize", so the section is
7236 Store_String_Chars
("initialize");
7242 Name_Machine_Attribute
,
7244 (Make_Pragma_Argument_Association
7245 (Sloc
=> Sloc
(R_Internal
),
7246 Expression
=> R_Internal
),
7247 Make_Pragma_Argument_Association
7248 (Sloc
=> Sloc
(R_External
),
7251 (Sloc
=> Sloc
(R_External
),
7260 -- pragma Pure [(library_unit_NAME)];
7262 when Pragma_Pure
=> Pure
: declare
7265 Check_Ada_83_Warning
;
7266 Check_Valid_Library_Unit_Pragma
;
7268 if Nkind
(N
) = N_Null_Statement
then
7272 Ent
:= Find_Lib_Unit_Name
;
7274 Set_Suppress_Elaboration_Warnings
(Ent
);
7281 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
7283 when Pragma_Pure_Function
=> Pure_Function
: declare
7290 Check_Arg_Count
(1);
7291 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7292 Check_Arg_Is_Local_Name
(Arg1
);
7293 E_Id
:= Expression
(Arg1
);
7295 if Error_Posted
(E_Id
) then
7299 -- Loop through homonyms (overloadings) of referenced entity
7302 while Present
(E
) loop
7303 Def_Id
:= Get_Base_Subprogram
(E
);
7305 if Ekind
(Def_Id
) /= E_Function
7306 and then Ekind
(Def_Id
) /= E_Generic_Function
7307 and then Ekind
(Def_Id
) /= E_Operator
7309 Error_Pragma_Arg
("pragma% requires a function name", Arg1
);
7312 Set_Is_Pure
(Def_Id
);
7313 Set_Has_Pragma_Pure_Function
(Def_Id
);
7318 --------------------
7319 -- Queuing_Policy --
7320 --------------------
7322 -- pragma Queuing_Policy (policy_IDENTIFIER);
7324 when Pragma_Queuing_Policy
=> declare
7328 Check_Ada_83_Warning
;
7329 Check_Arg_Count
(1);
7330 Check_No_Identifiers
;
7331 Check_Arg_Is_Queuing_Policy
(Arg1
);
7332 Check_Valid_Configuration_Pragma
;
7333 Get_Name_String
(Chars
(Expression
(Arg1
)));
7334 QP
:= Fold_Upper
(Name_Buffer
(1));
7336 if Queuing_Policy
/= ' '
7337 and then Queuing_Policy
/= QP
7339 Error_Msg_Sloc
:= Queuing_Policy_Sloc
;
7340 Error_Pragma
("queuing policy incompatible with policy#");
7342 Queuing_Policy
:= QP
;
7343 Queuing_Policy_Sloc
:= Loc
;
7347 ---------------------------
7348 -- Remote_Call_Interface --
7349 ---------------------------
7351 -- pragma Remote_Call_Interface [(library_unit_NAME)];
7353 when Pragma_Remote_Call_Interface
=> Remote_Call_Interface
: declare
7354 Cunit_Node
: Node_Id
;
7355 Cunit_Ent
: Entity_Id
;
7359 Check_Ada_83_Warning
;
7360 Check_Valid_Library_Unit_Pragma
;
7362 if Nkind
(N
) = N_Null_Statement
then
7366 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
7367 K
:= Nkind
(Unit
(Cunit_Node
));
7368 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
7370 if K
= N_Package_Declaration
7371 or else K
= N_Generic_Package_Declaration
7372 or else K
= N_Subprogram_Declaration
7373 or else K
= N_Generic_Subprogram_Declaration
7374 or else (K
= N_Subprogram_Body
7375 and then Acts_As_Spec
(Unit
(Cunit_Node
)))
7380 "pragma% must apply to package or subprogram declaration");
7383 Set_Is_Remote_Call_Interface
(Cunit_Ent
);
7384 end Remote_Call_Interface
;
7390 -- pragma Remote_Types [(library_unit_NAME)];
7392 when Pragma_Remote_Types
=> Remote_Types
: declare
7393 Cunit_Node
: Node_Id
;
7394 Cunit_Ent
: Entity_Id
;
7397 Check_Ada_83_Warning
;
7398 Check_Valid_Library_Unit_Pragma
;
7400 if Nkind
(N
) = N_Null_Statement
then
7404 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
7405 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
7407 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
7409 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
7412 "pragma% can only apply to a package declaration");
7415 Set_Is_Remote_Types
(Cunit_Ent
);
7422 when Pragma_Ravenscar
=>
7424 Check_Arg_Count
(0);
7425 Check_Valid_Configuration_Pragma
;
7428 -------------------------
7429 -- Restricted_Run_Time --
7430 -------------------------
7432 when Pragma_Restricted_Run_Time
=>
7434 Check_Arg_Count
(0);
7435 Check_Valid_Configuration_Pragma
;
7436 Set_Restricted_Profile
;
7442 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
7445 -- restriction_IDENTIFIER
7446 -- | restriction_parameter_IDENTIFIER => EXPRESSION
7448 when Pragma_Restrictions
=> Restrictions_Pragma
: declare
7450 R_Id
: Restriction_Id
;
7451 RP_Id
: Restriction_Parameter_Id
;
7457 Check_Ada_83_Warning
;
7458 Check_At_Least_N_Arguments
(1);
7459 Check_Valid_Configuration_Pragma
;
7463 while Present
(Arg
) loop
7465 Expr
:= Expression
(Arg
);
7467 -- Case of no restriction identifier
7469 if Id
= No_Name
then
7470 if Nkind
(Expr
) /= N_Identifier
then
7472 ("invalid form for restriction", Arg
);
7475 R_Id
:= Get_Restriction_Id
(Chars
(Expr
));
7477 if R_Id
= Not_A_Restriction_Id
then
7479 ("invalid restriction identifier", Arg
);
7481 -- Restriction is active
7484 if Implementation_Restriction
(R_Id
) then
7486 (No_Implementation_Restrictions
, Arg
);
7489 Restrictions
(R_Id
) := True;
7490 Restrictions_Loc
(R_Id
) := Sloc
(N
);
7492 -- Record the restriction if we are in the main unit,
7493 -- or in the extended main unit. The reason that we
7494 -- test separately for Main_Unit is that gnat.adc is
7495 -- processed with Current_Sem_Unit = Main_Unit, but
7496 -- nodes in gnat.adc do not appear to be the extended
7497 -- main source unit (they probably should do ???)
7499 if Current_Sem_Unit
= Main_Unit
7500 or else In_Extended_Main_Source_Unit
(N
)
7502 Main_Restrictions
(R_Id
) := True;
7505 -- A very special case that must be processed here:
7506 -- pragma Restrictions (No_Exceptions) turns off all
7507 -- run-time checking. This is a bit dubious in terms
7508 -- of the formal language definition, but it is what
7509 -- is intended by the wording of RM H.4(12).
7511 if R_Id
= No_Exceptions
then
7512 Scope_Suppress
:= (others => True);
7517 -- Case of restriction identifier present
7520 RP_Id
:= Get_Restriction_Parameter_Id
(Id
);
7521 Analyze_And_Resolve
(Expr
, Any_Integer
);
7523 if RP_Id
= Not_A_Restriction_Parameter_Id
then
7525 ("invalid restriction parameter identifier", Arg
);
7527 elsif not Is_OK_Static_Expression
(Expr
)
7528 or else not Is_Integer_Type
(Etype
(Expr
))
7529 or else Expr_Value
(Expr
) < 0
7532 ("value must be non-negative static integer", Arg
);
7534 -- Restriction pragma is active
7537 Val
:= Expr_Value
(Expr
);
7539 -- Record pragma if most restrictive so far
7541 if Restriction_Parameters
(RP_Id
) = No_Uint
7542 or else Val
< Restriction_Parameters
(RP_Id
)
7544 Restriction_Parameters
(RP_Id
) := Expr_Value
(Expr
);
7545 Restriction_Parameters_Loc
(RP_Id
) := Sloc
(N
);
7552 end Restrictions_Pragma
;
7558 -- pragma Reviewable;
7560 when Pragma_Reviewable
=>
7561 Check_Ada_83_Warning
;
7562 Check_Arg_Count
(0);
7568 -- pragma Share_Generic (NAME {, NAME});
7570 when Pragma_Share_Generic
=>
7572 Process_Generic_List
;
7578 -- pragma Shared (LOCAL_NAME);
7580 when Pragma_Shared
=>
7582 Process_Atomic_Shared_Volatile
;
7584 --------------------
7585 -- Shared_Passive --
7586 --------------------
7588 -- pragma Shared_Passive [(library_unit_NAME)];
7590 -- Set the flag Is_Shared_Passive of program unit name entity
7592 when Pragma_Shared_Passive
=> Shared_Passive
: declare
7593 Cunit_Node
: Node_Id
;
7594 Cunit_Ent
: Entity_Id
;
7597 Check_Ada_83_Warning
;
7598 Check_Valid_Library_Unit_Pragma
;
7600 if Nkind
(N
) = N_Null_Statement
then
7604 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
7605 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
7607 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
7609 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
7612 "pragma% can only apply to a package declaration");
7615 Set_Is_Shared_Passive
(Cunit_Ent
);
7618 ----------------------
7619 -- Source_File_Name --
7620 ----------------------
7622 -- pragma Source_File_Name (
7623 -- [UNIT_NAME =>] unit_NAME,
7624 -- [BODY_FILE_NAME | SPEC_FILE_NAME] => STRING_LITERAL);
7626 -- No processing here. Processing was completed during parsing,
7627 -- since we need to have file names set as early as possible.
7628 -- Units are loaded well before semantic processing starts.
7630 -- The only processing we defer to this point is the check
7631 -- for correct placement.
7633 when Pragma_Source_File_Name
=>
7635 Check_Valid_Configuration_Pragma
;
7637 ----------------------
7638 -- Source_Reference --
7639 ----------------------
7641 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
7643 -- Nothing to do, all processing completed in Par.Prag, since we
7644 -- need the information for possible parser messages that are output
7646 when Pragma_Source_Reference
=>
7653 -- pragma Storage_Size (EXPRESSION);
7655 when Pragma_Storage_Size
=> Storage_Size
: declare
7656 P
: constant Node_Id
:= Parent
(N
);
7660 Check_No_Identifiers
;
7661 Check_Arg_Count
(1);
7663 -- Set In_Default_Expression for per-object case???
7665 X
:= Expression
(Arg1
);
7666 Analyze_And_Resolve
(X
, Any_Integer
);
7668 if not Is_Static_Expression
(X
) then
7669 Check_Restriction
(Static_Storage_Size
, X
);
7672 if Nkind
(P
) /= N_Task_Definition
then
7677 if Has_Storage_Size_Pragma
(P
) then
7678 Error_Pragma
("duplicate pragma% not allowed");
7680 Set_Has_Storage_Size_Pragma
(P
, True);
7683 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
7684 -- ??? exp_ch9 should use this!
7692 -- pragma Storage_Unit (NUMERIC_LITERAL);
7694 -- Only permitted argument is System'Storage_Unit value
7696 when Pragma_Storage_Unit
=>
7697 Check_No_Identifiers
;
7698 Check_Arg_Count
(1);
7699 Check_Arg_Is_Integer_Literal
(Arg1
);
7701 if Intval
(Expression
(Arg1
)) /=
7702 UI_From_Int
(Ttypes
.System_Storage_Unit
)
7704 Error_Msg_Uint_1
:= UI_From_Int
(Ttypes
.System_Storage_Unit
);
7706 ("the only allowed argument for pragma% is ^", Arg1
);
7709 --------------------
7710 -- Stream_Convert --
7711 --------------------
7713 -- pragma Stream_Convert (
7714 -- [Entity =>] type_LOCAL_NAME,
7715 -- [Read =>] function_NAME,
7716 -- [Write =>] function NAME);
7718 when Pragma_Stream_Convert
=> Stream_Convert
: declare
7720 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
);
7721 -- Check that the given argument is the name of a local
7722 -- function of one argument that is not overloaded earlier
7723 -- in the current local scope. A check is also made that the
7724 -- argument is a function with one parameter.
7726 --------------------------------------
7727 -- Check_OK_Stream_Convert_Function --
7728 --------------------------------------
7730 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
) is
7734 Check_Arg_Is_Local_Name
(Arg
);
7735 Ent
:= Entity
(Expression
(Arg
));
7737 if Has_Homonym
(Ent
) then
7739 ("argument for pragma% may not be overloaded", Arg
);
7742 if Ekind
(Ent
) /= E_Function
7743 or else No
(First_Formal
(Ent
))
7744 or else Present
(Next_Formal
(First_Formal
(Ent
)))
7747 ("argument for pragma% must be" &
7748 " function of one argument", Arg
);
7750 end Check_OK_Stream_Convert_Function
;
7752 -- Start of procecessing for Stream_Convert
7756 Check_Arg_Count
(3);
7757 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7758 Check_Optional_Identifier
(Arg2
, Name_Read
);
7759 Check_Optional_Identifier
(Arg3
, Name_Write
);
7760 Check_Arg_Is_Local_Name
(Arg1
);
7761 Check_OK_Stream_Convert_Function
(Arg2
);
7762 Check_OK_Stream_Convert_Function
(Arg3
);
7765 Typ
: constant Entity_Id
:=
7766 Underlying_Type
(Entity
(Expression
(Arg1
)));
7767 Read
: constant Entity_Id
:= Entity
(Expression
(Arg2
));
7768 Write
: constant Entity_Id
:= Entity
(Expression
(Arg3
));
7771 if Etype
(Typ
) = Any_Type
7773 Etype
(Read
) = Any_Type
7775 Etype
(Write
) = Any_Type
7780 Check_First_Subtype
(Arg1
);
7782 if Rep_Item_Too_Early
(Typ
, N
)
7784 Rep_Item_Too_Late
(Typ
, N
)
7789 if Underlying_Type
(Etype
(Read
)) /= Typ
then
7791 ("incorrect return type for function&", Arg2
);
7794 if Underlying_Type
(Etype
(First_Formal
(Write
))) /= Typ
then
7796 ("incorrect parameter type for function&", Arg3
);
7799 if Underlying_Type
(Etype
(First_Formal
(Read
))) /=
7800 Underlying_Type
(Etype
(Write
))
7803 ("result type of & does not match Read parameter type",
7809 -------------------------
7810 -- Style_Checks (GNAT) --
7811 -------------------------
7813 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
7815 -- This is processed by the parser since some of the style
7816 -- checks take place during source scanning and parsing. This
7817 -- means that we don't need to issue error messages here.
7819 when Pragma_Style_Checks
=> Style_Checks
: declare
7820 A
: constant Node_Id
:= Expression
(Arg1
);
7826 Check_No_Identifiers
;
7828 -- Two argument form
7830 if Arg_Count
= 2 then
7831 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
7838 E_Id
:= Expression
(Arg2
);
7841 if not Is_Entity_Name
(E_Id
) then
7843 ("second argument of pragma% must be entity name",
7853 Set_Suppress_Style_Checks
(E
,
7854 (Chars
(Expression
(Arg1
)) = Name_Off
));
7855 exit when No
(Homonym
(E
));
7861 -- One argument form
7864 Check_Arg_Count
(1);
7866 if Nkind
(A
) = N_String_Literal
then
7870 Slen
: Natural := Natural (String_Length
(S
));
7871 Options
: String (1 .. Slen
);
7877 C
:= Get_String_Char
(S
, Int
(J
));
7878 exit when not In_Character_Range
(C
);
7879 Options
(J
) := Get_Character
(C
);
7882 Set_Style_Check_Options
(Options
);
7890 elsif Nkind
(A
) = N_Identifier
then
7892 if Chars
(A
) = Name_All_Checks
then
7893 Set_Default_Style_Check_Options
;
7895 elsif Chars
(A
) = Name_On
then
7896 Style_Check
:= True;
7898 elsif Chars
(A
) = Name_Off
then
7899 Style_Check
:= False;
7910 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
7912 when Pragma_Subtitle
=>
7914 Check_Arg_Count
(1);
7915 Check_Optional_Identifier
(Arg1
, Name_Subtitle
);
7916 Check_Arg_Is_String_Literal
(Arg1
);
7922 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
7924 when Pragma_Suppress
=>
7925 Process_Suppress_Unsuppress
(True);
7931 -- pragma Suppress_All;
7933 -- The only check made here is that the pragma appears in the
7934 -- proper place, i.e. following a compilation unit. If indeed
7935 -- it appears in this context, then the parser has already
7936 -- inserted an equivalent pragma Suppress (All_Checks) to get
7937 -- the required effect.
7939 when Pragma_Suppress_All
=>
7941 Check_Arg_Count
(0);
7943 if Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
7944 or else not Is_List_Member
(N
)
7945 or else List_Containing
(N
) /= Pragmas_After
(Parent
(N
))
7948 ("misplaced pragma%, must follow compilation unit");
7951 -------------------------
7952 -- Suppress_Debug_Info --
7953 -------------------------
7955 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
7957 when Pragma_Suppress_Debug_Info
=>
7959 Check_Arg_Count
(1);
7960 Check_Arg_Is_Local_Name
(Arg1
);
7961 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7962 Set_Debug_Info_Off
(Entity
(Get_Pragma_Arg
(Arg1
)));
7964 -----------------------------
7965 -- Suppress_Initialization --
7966 -----------------------------
7968 -- pragma Suppress_Initialization ([Entity =>] type_Name);
7970 when Pragma_Suppress_Initialization
=> Suppress_Init
: declare
7976 Check_Arg_Count
(1);
7977 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7978 Check_Arg_Is_Local_Name
(Arg1
);
7980 E_Id
:= Expression
(Arg1
);
7982 if Etype
(E_Id
) = Any_Type
then
7989 if Is_Incomplete_Or_Private_Type
(E
) then
7990 if No
(Full_View
(Base_Type
(E
))) then
7992 ("argument of pragma% cannot be an incomplete type",
7995 Set_Suppress_Init_Proc
(Full_View
(Base_Type
(E
)));
7998 Set_Suppress_Init_Proc
(Base_Type
(E
));
8003 ("pragma% requires argument that is a type name", Arg1
);
8011 -- pragma System_Name (DIRECT_NAME);
8013 -- Syntax check: one argument, which must be the identifier GNAT
8014 -- or the identifier GCC, no other identifiers are acceptable.
8016 when Pragma_System_Name
=>
8017 Check_No_Identifiers
;
8018 Check_Arg_Count
(1);
8019 Check_Arg_Is_One_Of
(Arg1
, Name_Gcc
, Name_Gnat
);
8021 -----------------------------
8022 -- Task_Dispatching_Policy --
8023 -----------------------------
8025 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
8027 when Pragma_Task_Dispatching_Policy
=> declare
8031 Check_Ada_83_Warning
;
8032 Check_Arg_Count
(1);
8033 Check_No_Identifiers
;
8034 Check_Arg_Is_Task_Dispatching_Policy
(Arg1
);
8035 Check_Valid_Configuration_Pragma
;
8036 Get_Name_String
(Chars
(Expression
(Arg1
)));
8037 DP
:= Fold_Upper
(Name_Buffer
(1));
8039 if Task_Dispatching_Policy
/= ' '
8040 and then Task_Dispatching_Policy
/= DP
8042 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
8044 ("task dispatching policy incompatible with policy#");
8046 Task_Dispatching_Policy
:= DP
;
8047 Task_Dispatching_Policy_Sloc
:= Loc
;
8055 -- pragma Task_Info (EXPRESSION);
8057 when Pragma_Task_Info
=> Task_Info
: declare
8058 P
: constant Node_Id
:= Parent
(N
);
8063 if Nkind
(P
) /= N_Task_Definition
then
8064 Error_Pragma
("pragma% must appear in task definition");
8067 Check_No_Identifiers
;
8068 Check_Arg_Count
(1);
8070 Analyze_And_Resolve
(Expression
(Arg1
), RTE
(RE_Task_Info_Type
));
8072 if Etype
(Expression
(Arg1
)) = Any_Type
then
8076 if Has_Task_Info_Pragma
(P
) then
8077 Error_Pragma
("duplicate pragma% not allowed");
8079 Set_Has_Task_Info_Pragma
(P
, True);
8087 -- pragma Task_Name (string_EXPRESSION);
8089 when Pragma_Task_Name
=> Task_Name
: declare
8090 -- pragma Priority (EXPRESSION);
8092 P
: constant Node_Id
:= Parent
(N
);
8096 Check_No_Identifiers
;
8097 Check_Arg_Count
(1);
8099 Arg
:= Expression
(Arg1
);
8100 Analyze_And_Resolve
(Arg
, Standard_String
);
8102 if Nkind
(P
) /= N_Task_Definition
then
8106 if Has_Task_Name_Pragma
(P
) then
8107 Error_Pragma
("duplicate pragma% not allowed");
8109 Set_Has_Task_Name_Pragma
(P
, True);
8110 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
8118 -- pragma Task_Storage (
8119 -- [Task_Type =>] LOCAL_NAME,
8120 -- [Top_Guard =>] static_integer_EXPRESSION);
8122 when Pragma_Task_Storage
=> Task_Storage
: declare
8123 Args
: Args_List
(1 .. 2);
8124 Names
: Name_List
(1 .. 2) := (
8128 Task_Type
: Node_Id
renames Args
(1);
8129 Top_Guard
: Node_Id
renames Args
(2);
8135 Gather_Associations
(Names
, Args
);
8136 Check_Arg_Is_Local_Name
(Task_Type
);
8138 Ent
:= Entity
(Task_Type
);
8140 if not Is_Task_Type
(Ent
) then
8142 ("argument for pragma% must be task type", Task_Type
);
8145 if No
(Top_Guard
) then
8147 ("pragma% takes two arguments", Task_Type
);
8149 Check_Arg_Is_Static_Expression
(Top_Guard
, Any_Integer
);
8152 Check_First_Subtype
(Task_Type
);
8154 if Rep_Item_Too_Late
(Ent
, N
) then
8163 -- pragma Time_Slice (static_duration_EXPRESSION);
8165 when Pragma_Time_Slice
=> Time_Slice
: declare
8171 Check_Arg_Count
(1);
8172 Check_No_Identifiers
;
8173 Check_In_Main_Program
;
8174 Check_Arg_Is_Static_Expression
(Arg1
, Standard_Duration
);
8176 if not Error_Posted
(Arg1
) then
8178 while Present
(Nod
) loop
8179 if Nkind
(Nod
) = N_Pragma
8180 and then Chars
(Nod
) = Name_Time_Slice
8182 Error_Msg_Name_1
:= Chars
(N
);
8183 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
8190 -- Process only if in main unit
8192 if Get_Source_Unit
(Loc
) = Main_Unit
then
8193 Opt
.Time_Slice_Set
:= True;
8194 Val
:= Expr_Value_R
(Expression
(Arg1
));
8196 if Val
<= Ureal_0
then
8197 Opt
.Time_Slice_Value
:= 0;
8199 elsif Val
> UR_From_Uint
(UI_From_Int
(1000)) then
8200 Opt
.Time_Slice_Value
:= 1_000_000_000
;
8203 Opt
.Time_Slice_Value
:=
8204 UI_To_Int
(UR_To_Uint
(Val
* UI_From_Int
(1_000_000
)));
8213 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
8215 -- TITLING_OPTION ::=
8216 -- [Title =>] STRING_LITERAL
8217 -- | [Subtitle =>] STRING_LITERAL
8219 when Pragma_Title
=> Title
: declare
8220 Args
: Args_List
(1 .. 2);
8221 Names
: Name_List
(1 .. 2) := (
8227 Gather_Associations
(Names
, Args
);
8229 for J
in 1 .. 2 loop
8230 if Present
(Args
(J
)) then
8231 Check_Arg_Is_String_Literal
(Args
(J
));
8236 ---------------------
8237 -- Unchecked_Union --
8238 ---------------------
8240 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
8242 when Pragma_Unchecked_Union
=> Unchecked_Union
: declare
8243 Assoc
: Node_Id
:= Arg1
;
8244 Type_Id
: Node_Id
:= Expression
(Assoc
);
8255 Check_No_Identifiers
;
8256 Check_Arg_Count
(1);
8257 Check_Arg_Is_Local_Name
(Arg1
);
8259 Find_Type
(Type_Id
);
8260 Typ
:= Entity
(Type_Id
);
8263 or else Rep_Item_Too_Early
(Typ
, N
)
8267 Typ
:= Underlying_Type
(Typ
);
8270 if Rep_Item_Too_Late
(Typ
, N
) then
8274 Check_First_Subtype
(Arg1
);
8276 -- Note remaining cases are references to a type in the current
8277 -- declarative part. If we find an error, we post the error on
8278 -- the relevant type declaration at an appropriate point.
8280 if not Is_Record_Type
(Typ
) then
8281 Error_Msg_N
("Unchecked_Union must be record type", Typ
);
8284 elsif Is_Tagged_Type
(Typ
) then
8285 Error_Msg_N
("Unchecked_Union must not be tagged", Typ
);
8288 elsif Is_Limited_Type
(Typ
) then
8290 ("Unchecked_Union must not be limited record type", Typ
);
8294 if not Has_Discriminants
(Typ
) then
8296 ("Unchecked_Union must have one discriminant", Typ
);
8300 Discr
:= First_Discriminant
(Typ
);
8302 if Present
(Next_Discriminant
(Discr
)) then
8304 ("Unchecked_Union must have exactly one discriminant",
8305 Next_Discriminant
(Discr
));
8309 if No
(Discriminant_Default_Value
(Discr
)) then
8311 ("Unchecked_Union discriminant must have default value",
8315 Tdef
:= Type_Definition
(Declaration_Node
(Typ
));
8316 Clist
:= Component_List
(Tdef
);
8318 if No
(Clist
) or else No
(Variant_Part
(Clist
)) then
8320 ("Unchecked_Union must have variant part",
8325 Vpart
:= Variant_Part
(Clist
);
8327 if Is_Non_Empty_List
(Component_Items
(Clist
)) then
8329 ("components before variant not allowed " &
8330 "in Unchecked_Union",
8331 First
(Component_Items
(Clist
)));
8334 Variant
:= First
(Variants
(Vpart
));
8335 while Present
(Variant
) loop
8336 Clist
:= Component_List
(Variant
);
8338 if Present
(Variant_Part
(Clist
)) then
8340 ("Unchecked_Union may not have nested variants",
8341 Variant_Part
(Clist
));
8344 if not Is_Non_Empty_List
(Component_Items
(Clist
)) then
8346 ("Unchecked_Union may not have empty component list",
8351 Comp
:= First
(Component_Items
(Clist
));
8353 if Nkind
(Comp
) = N_Component_Declaration
then
8355 if Present
(Expression
(Comp
)) then
8357 ("default initialization not allowed " &
8358 "in Unchecked_Union",
8363 Sindic
: constant Node_Id
:=
8364 Subtype_Indication
(Comp
);
8367 if Nkind
(Sindic
) = N_Subtype_Indication
then
8368 Check_Static_Constraint
(Constraint
(Sindic
));
8373 if Present
(Next
(Comp
)) then
8375 ("Unchecked_Union variant can have only one component",
8383 Set_Is_Unchecked_Union
(Typ
, True);
8384 Set_Suppress_Discriminant_Checks
(Typ
, True);
8385 Set_Convention
(Typ
, Convention_C
);
8387 Set_Has_Unchecked_Union
(Base_Type
(Typ
), True);
8388 Set_Is_Unchecked_Union
(Base_Type
(Typ
), True);
8390 end Unchecked_Union
;
8392 ------------------------
8393 -- Unimplemented_Unit --
8394 ------------------------
8396 -- pragma Unimplemented_Unit;
8398 -- Note: this only gives an error if we are generating code,
8399 -- or if we are in a generic library unit (where the pragma
8400 -- appears in the body, not in the spec).
8402 when Pragma_Unimplemented_Unit
=> Unimplemented_Unit
: declare
8403 Cunitent
: Entity_Id
:= Cunit_Entity
(Get_Source_Unit
(Loc
));
8404 Ent_Kind
: Entity_Kind
:= Ekind
(Cunitent
);
8408 Check_Arg_Count
(0);
8410 if Operating_Mode
= Generate_Code
8411 or else Ent_Kind
= E_Generic_Function
8412 or else Ent_Kind
= E_Generic_Procedure
8413 or else Ent_Kind
= E_Generic_Package
8415 Get_Name_String
(Chars
(Cunitent
));
8416 Set_Casing
(Mixed_Case
);
8417 Write_Str
(Name_Buffer
(1 .. Name_Len
));
8418 Write_Str
(" is not implemented");
8420 raise Unrecoverable_Error
;
8422 end Unimplemented_Unit
;
8424 --------------------
8425 -- Universal_Data --
8426 --------------------
8428 -- pragma Universal_Data;
8430 when Pragma_Universal_Data
=>
8432 Check_Arg_Count
(0);
8433 Check_Valid_Library_Unit_Pragma
;
8435 if not AAMP_On_Target
then
8436 Error_Pragma
("?pragma% ignored (applies only to AAMP)");
8443 -- pragma Unreferenced (local_Name {, local_Name});
8445 when Pragma_Unreferenced
=> Unreferenced
: declare
8451 Check_At_Least_N_Arguments
(1);
8455 while Present
(Arg_Node
) loop
8456 Check_No_Identifier
(Arg_Node
);
8458 -- Note that the analyze call done by Check_Arg_Is_Local_Name
8459 -- will in fact generate a reference, so that the entity will
8460 -- have a reference, which will inhibit any warnings about it
8461 -- not being referenced, and also properly show up in the ali
8462 -- file as a reference. But this reference is recorded before
8463 -- the Has_Pragma_Unreferenced flag is set, so that no warning
8464 -- is generated for this reference.
8466 Check_Arg_Is_Local_Name
(Arg_Node
);
8467 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
8469 if Is_Entity_Name
(Arg_Expr
) then
8470 Set_Has_Pragma_Unreferenced
(Entity
(Arg_Expr
));
8477 ------------------------------
8478 -- Unreserve_All_Interrupts --
8479 ------------------------------
8481 -- pragma Unreserve_All_Interrupts;
8483 when Pragma_Unreserve_All_Interrupts
=>
8485 Check_Arg_Count
(0);
8487 if In_Extended_Main_Code_Unit
(Main_Unit_Entity
) then
8488 Unreserve_All_Interrupts
:= True;
8495 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
8497 when Pragma_Unsuppress
=>
8499 Process_Suppress_Unsuppress
(False);
8505 -- pragma Use_VADS_Size;
8507 when Pragma_Use_VADS_Size
=>
8509 Check_Arg_Count
(0);
8510 Check_Valid_Configuration_Pragma
;
8511 Use_VADS_Size
:= True;
8513 ---------------------
8514 -- Validity_Checks --
8515 ---------------------
8517 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
8519 when Pragma_Validity_Checks
=> Validity_Checks
: declare
8520 A
: constant Node_Id
:= Expression
(Arg1
);
8526 Check_Arg_Count
(1);
8527 Check_No_Identifiers
;
8529 if Nkind
(A
) = N_String_Literal
then
8533 Slen
: Natural := Natural (String_Length
(S
));
8534 Options
: String (1 .. Slen
);
8540 C
:= Get_String_Char
(S
, Int
(J
));
8541 exit when not In_Character_Range
(C
);
8542 Options
(J
) := Get_Character
(C
);
8545 Set_Validity_Check_Options
(Options
);
8553 elsif Nkind
(A
) = N_Identifier
then
8555 if Chars
(A
) = Name_All_Checks
then
8556 Set_Validity_Check_Options
("a");
8558 elsif Chars
(A
) = Name_On
then
8559 Validity_Checks_On
:= True;
8561 elsif Chars
(A
) = Name_Off
then
8562 Validity_Checks_On
:= False;
8566 end Validity_Checks
;
8572 -- pragma Volatile (LOCAL_NAME);
8574 when Pragma_Volatile
=>
8575 Process_Atomic_Shared_Volatile
;
8577 -------------------------
8578 -- Volatile_Components --
8579 -------------------------
8581 -- pragma Volatile_Components (array_LOCAL_NAME);
8583 -- Volatile is handled by the same circuit as Atomic_Components
8589 -- pragma Warnings (On | Off, [LOCAL_NAME])
8591 when Pragma_Warnings
=>
8593 Check_At_Least_N_Arguments
(1);
8594 Check_At_Most_N_Arguments
(2);
8595 Check_No_Identifiers
;
8597 -- One argument case was processed by parser in Par.Prag
8599 if Arg_Count
/= 1 then
8600 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
8601 Check_Arg_Count
(2);
8608 E_Id
:= Expression
(Arg2
);
8611 if not Is_Entity_Name
(E_Id
) then
8613 ("second argument of pragma% must be entity name",
8623 Set_Warnings_Off
(E
,
8624 (Chars
(Expression
(Arg1
)) = Name_Off
));
8626 if Is_Enumeration_Type
(E
) then
8628 Lit
: Entity_Id
:= First_Literal
(E
);
8631 while Present
(Lit
) loop
8632 Set_Warnings_Off
(Lit
);
8638 exit when No
(Homonym
(E
));
8649 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
8651 when Pragma_Weak_External
=> Weak_External
: declare
8656 Check_Arg_Count
(1);
8657 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8658 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
8659 Ent
:= Entity
(Expression
(Arg1
));
8661 if Rep_Item_Too_Early
(Ent
, N
) then
8664 Ent
:= Underlying_Type
(Ent
);
8667 -- The only processing required is to link this item on to the
8668 -- list of rep items for the given entity. This is accomplished
8669 -- by the call to Rep_Item_Too_Late (when no error is detected
8670 -- and False is returned).
8672 if Rep_Item_Too_Late
(Ent
, N
) then
8675 Set_Has_Gigi_Rep_Item
(Ent
);
8682 when Pragma_Exit
=> null;
8686 -------------------------
8687 -- Get_Base_Subprogram --
8688 -------------------------
8690 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
is
8696 -- Follow subprogram renaming chain
8698 while Is_Subprogram
(Result
)
8700 (Is_Generic_Instance
(Result
)
8701 or else Nkind
(Parent
(Declaration_Node
(Result
))) =
8702 N_Subprogram_Renaming_Declaration
)
8703 and then Present
(Alias
(Result
))
8705 Result
:= Alias
(Result
);
8709 end Get_Base_Subprogram
;
8711 ---------------------------
8712 -- Is_Generic_Subprogram --
8713 ---------------------------
8715 function Is_Generic_Subprogram
(Id
: Entity_Id
) return Boolean is
8717 return Ekind
(Id
) = E_Generic_Procedure
8718 or else Ekind
(Id
) = E_Generic_Function
;
8719 end Is_Generic_Subprogram
;
8721 ------------------------------
8722 -- Is_Pragma_String_Literal --
8723 ------------------------------
8725 -- This function returns true if the corresponding pragma argument is
8726 -- a static string expression. These are the only cases in which string
8727 -- literals can appear as pragma arguments. We also allow a string
8728 -- literal as the first argument to pragma Assert (although it will
8729 -- of course always generate a type error).
8731 function Is_Pragma_String_Literal
(Par
: Node_Id
) return Boolean is
8732 Pragn
: constant Node_Id
:= Parent
(Par
);
8733 Assoc
: constant List_Id
:= Pragma_Argument_Associations
(Pragn
);
8734 Pname
: constant Name_Id
:= Chars
(Pragn
);
8747 if Pname
= Name_Assert
then
8750 elsif Pname
= Name_Export
then
8753 elsif Pname
= Name_Ident
then
8756 elsif Pname
= Name_Import
then
8759 elsif Pname
= Name_Interface_Name
then
8762 elsif Pname
= Name_Linker_Alias
then
8765 elsif Pname
= Name_Linker_Section
then
8768 elsif Pname
= Name_Machine_Attribute
then
8771 elsif Pname
= Name_Source_File_Name
then
8774 elsif Pname
= Name_Source_Reference
then
8777 elsif Pname
= Name_Title
then
8780 elsif Pname
= Name_Subtitle
then
8786 end Is_Pragma_String_Literal
;
8788 --------------------------------------
8789 -- Process_Compilation_Unit_Pragmas --
8790 --------------------------------------
8792 procedure Process_Compilation_Unit_Pragmas
(N
: Node_Id
) is
8794 -- A special check for pragma Suppress_All. This is a strange DEC
8795 -- pragma, strange because it comes at the end of the unit. If we
8796 -- have a pragma Suppress_All in the Pragmas_After of the current
8797 -- unit, then we insert a pragma Suppress (All_Checks) at the start
8798 -- of the context clause to ensure the correct processing.
8801 PA
: constant List_Id
:= Pragmas_After
(Aux_Decls_Node
(N
));
8805 if Present
(PA
) then
8807 while Present
(P
) loop
8808 if Chars
(P
) = Name_Suppress_All
then
8809 Prepend_To
(Context_Items
(N
),
8810 Make_Pragma
(Sloc
(P
),
8811 Chars
=> Name_Suppress
,
8812 Pragma_Argument_Associations
=> New_List
(
8813 Make_Pragma_Argument_Association
(Sloc
(P
),
8815 Make_Identifier
(Sloc
(P
),
8816 Chars
=> Name_All_Checks
)))));
8824 end Process_Compilation_Unit_Pragmas
;
8826 --------------------------------
8827 -- Set_Encoded_Interface_Name --
8828 --------------------------------
8830 procedure Set_Encoded_Interface_Name
(E
: Entity_Id
; S
: Node_Id
) is
8831 Str
: constant String_Id
:= Strval
(S
);
8832 Len
: constant Int
:= String_Length
(Str
);
8837 Hex
: constant array (0 .. 15) of Character := "0123456789abcdef";
8840 -- Stores encoded value of character code CC. The encoding we
8841 -- use an underscore followed by four lower case hex digits.
8845 Store_String_Char
(Get_Char_Code
('_'));
8847 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 12))));
8849 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 8 and 16#
0F#
))));
8851 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 4 and 16#
0F#
))));
8853 (Get_Char_Code
(Hex
(Integer (CC
and 16#
0F#
))));
8856 -- Start of processing for Set_Encoded_Interface_Name
8859 -- If first character is asterisk, this is a link name, and we
8860 -- leave it completely unmodified. We also ignore null strings
8861 -- (the latter case happens only in error cases) and no encoding
8862 -- should occur for Java interface names.
8865 or else Get_String_Char
(Str
, 1) = Get_Char_Code
('*')
8868 Set_Interface_Name
(E
, S
);
8873 CC
:= Get_String_Char
(Str
, J
);
8875 exit when not In_Character_Range
(CC
);
8877 C
:= Get_Character
(CC
);
8879 exit when C
/= '_' and then C
/= '$'
8880 and then C
not in '0' .. '9'
8881 and then C
not in 'a' .. 'z'
8882 and then C
not in 'A' .. 'Z';
8885 Set_Interface_Name
(E
, S
);
8893 -- Here we need to encode. The encoding we use as follows:
8894 -- three underscores + four hex digits (lower case)
8898 for J
in 1 .. String_Length
(Str
) loop
8899 CC
:= Get_String_Char
(Str
, J
);
8901 if not In_Character_Range
(CC
) then
8904 C
:= Get_Character
(CC
);
8906 if C
= '_' or else C
= '$'
8907 or else C
in '0' .. '9'
8908 or else C
in 'a' .. 'z'
8909 or else C
in 'A' .. 'Z'
8911 Store_String_Char
(CC
);
8918 Set_Interface_Name
(E
,
8919 Make_String_Literal
(Sloc
(S
),
8920 Strval
=> End_String
));
8922 end Set_Encoded_Interface_Name
;
8928 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
) is
8933 if Nkind
(N
) = N_Identifier
8934 and then Nkind
(With_Item
) = N_Identifier
8936 Set_Entity
(N
, Entity
(With_Item
));
8938 elsif Nkind
(N
) = N_Selected_Component
then
8939 Change_Selected_Component_To_Expanded_Name
(N
);
8940 Set_Entity
(N
, Entity
(With_Item
));
8941 Set_Entity
(Selector_Name
(N
), Entity
(N
));
8944 Scop
:= Scope
(Entity
(N
));
8946 while Nkind
(Pref
) = N_Selected_Component
loop
8947 Change_Selected_Component_To_Expanded_Name
(Pref
);
8948 Set_Entity
(Selector_Name
(Pref
), Scop
);
8949 Set_Entity
(Pref
, Scop
);
8950 Pref
:= Prefix
(Pref
);
8951 Scop
:= Scope
(Scop
);
8954 Set_Entity
(Pref
, Scop
);