1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- This unit contains the semantic processing for all pragmas, both language
28 -- and implementation defined. For most pragmas, the parser only does the
29 -- most basic job of checking the syntax, so Sem_Prag also contains the code
30 -- to complete the syntax checks. Certain pragmas are handled partially or
31 -- completely by the parser (see Par.Prag for further details).
33 with Atree
; use Atree
;
34 with Casing
; use Casing
;
35 with Csets
; use Csets
;
36 with Debug
; use Debug
;
37 with Einfo
; use Einfo
;
38 with Elists
; use Elists
;
39 with Errout
; use Errout
;
40 with Exp_Dist
; use Exp_Dist
;
41 with Fname
; use Fname
;
42 with Hostparm
; use Hostparm
;
44 with Lib
.Writ
; use Lib
.Writ
;
45 with Lib
.Xref
; use Lib
.Xref
;
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 Rident
; use Rident
;
53 with Rtsfind
; use Rtsfind
;
55 with Sem_Ch3
; use Sem_Ch3
;
56 with Sem_Ch8
; use Sem_Ch8
;
57 with Sem_Ch13
; use Sem_Ch13
;
58 with Sem_Disp
; use Sem_Disp
;
59 with Sem_Elim
; use Sem_Elim
;
60 with Sem_Eval
; use Sem_Eval
;
61 with Sem_Intr
; use Sem_Intr
;
62 with Sem_Mech
; use Sem_Mech
;
63 with Sem_Res
; use Sem_Res
;
64 with Sem_Type
; use Sem_Type
;
65 with Sem_Util
; use Sem_Util
;
66 with Sem_VFpt
; use Sem_VFpt
;
67 with Stand
; use Stand
;
68 with Sinfo
; use Sinfo
;
69 with Sinfo
.CN
; use Sinfo
.CN
;
70 with Sinput
; use Sinput
;
71 with Snames
; use Snames
;
72 with Stringt
; use Stringt
;
73 with Stylesw
; use Stylesw
;
75 with Targparm
; use Targparm
;
76 with Tbuild
; use Tbuild
;
78 with Uintp
; use Uintp
;
79 with Urealp
; use Urealp
;
80 with Validsw
; use Validsw
;
82 with GNAT
.Spelling_Checker
; use GNAT
.Spelling_Checker
;
84 package body Sem_Prag
is
86 ----------------------------------------------
87 -- Common Handling of Import-Export Pragmas --
88 ----------------------------------------------
90 -- In the following section, a number of Import_xxx and Export_xxx
91 -- pragmas are defined by GNAT. These are compatible with the DEC
92 -- pragmas of the same name, and all have the following common
93 -- form and processing:
96 -- [Internal =>] LOCAL_NAME,
97 -- [, [External =>] EXTERNAL_SYMBOL]
98 -- [, other optional parameters ]);
101 -- [Internal =>] LOCAL_NAME,
102 -- [, [External =>] EXTERNAL_SYMBOL]
103 -- [, other optional parameters ]);
105 -- EXTERNAL_SYMBOL ::=
107 -- | static_string_EXPRESSION
109 -- The internal LOCAL_NAME designates the entity that is imported or
110 -- exported, and must refer to an entity in the current declarative
111 -- part (as required by the rules for LOCAL_NAME).
113 -- The external linker name is designated by the External parameter
114 -- if given, or the Internal parameter if not (if there is no External
115 -- parameter, the External parameter is a copy of the Internal name).
117 -- If the External parameter is given as a string, then this string
118 -- is treated as an external name (exactly as though it had been given
119 -- as an External_Name parameter for a normal Import pragma).
121 -- If the External parameter is given as an identifier (or there is no
122 -- External parameter, so that the Internal identifier is used), then
123 -- the external name is the characters of the identifier, translated
124 -- to all upper case letters for OpenVMS versions of GNAT, and to all
125 -- lower case letters for all other versions
127 -- Note: the external name specified or implied by any of these special
128 -- Import_xxx or Export_xxx pragmas override an external or link name
129 -- specified in a previous Import or Export pragma.
131 -- Note: these and all other DEC-compatible GNAT pragmas allow full
132 -- use of named notation, following the standard rules for subprogram
133 -- calls, i.e. parameters can be given in any order if named notation
134 -- is used, and positional and named notation can be mixed, subject to
135 -- the rule that all positional parameters must appear first.
137 -- Note: All these pragmas are implemented exactly following the DEC
138 -- design and implementation and are intended to be fully compatible
139 -- with the use of these pragmas in the DEC Ada compiler.
141 --------------------------------------------
142 -- Checking for Duplicated External Names --
143 --------------------------------------------
145 -- It is suspicious if two separate Export pragmas use the same external
146 -- name. The following table is used to diagnose this situation so that
147 -- an appropriate warning can be issued.
149 -- The Node_Id stored is for the N_String_Literal node created to
150 -- hold the value of the external name. The Sloc of this node is
151 -- used to cross-reference the location of the duplication.
153 package Externals
is new Table
.Table
(
154 Table_Component_Type
=> Node_Id
,
155 Table_Index_Type
=> Int
,
156 Table_Low_Bound
=> 0,
157 Table_Initial
=> 100,
158 Table_Increment
=> 100,
159 Table_Name
=> "Name_Externals");
161 -------------------------------------
162 -- Local Subprograms and Variables --
163 -------------------------------------
165 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
;
166 -- This routine is used for possible casing adjustment of an explicit
167 -- external name supplied as a string literal (the node N), according
168 -- to the casing requirement of Opt.External_Name_Casing. If this is
169 -- set to As_Is, then the string literal is returned unchanged, but if
170 -- it is set to Uppercase or Lowercase, then a new string literal with
171 -- appropriate casing is constructed.
173 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
;
174 -- If Def_Id refers to a renamed subprogram, then the base subprogram
175 -- (the original one, following the renaming chain) is returned.
176 -- Otherwise the entity is returned unchanged. Should be in Einfo???
178 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
);
179 -- Place semantic information on the argument of an Elaborate or
180 -- Elaborate_All pragma. Entity name for unit and its parents is
181 -- taken from item in previous with_clause that mentions the unit.
183 -------------------------------
184 -- Adjust_External_Name_Case --
185 -------------------------------
187 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
is
191 -- Adjust case of literal if required
193 if Opt
.External_Name_Exp_Casing
= As_Is
then
197 -- Copy existing string
203 for J
in 1 .. String_Length
(Strval
(N
)) loop
204 CC
:= Get_String_Char
(Strval
(N
), J
);
206 if Opt
.External_Name_Exp_Casing
= Uppercase
207 and then CC
>= Get_Char_Code
('a')
208 and then CC
<= Get_Char_Code
('z')
210 Store_String_Char
(CC
- 32);
212 elsif Opt
.External_Name_Exp_Casing
= Lowercase
213 and then CC
>= Get_Char_Code
('A')
214 and then CC
<= Get_Char_Code
('Z')
216 Store_String_Char
(CC
+ 32);
219 Store_String_Char
(CC
);
224 Make_String_Literal
(Sloc
(N
),
225 Strval
=> End_String
);
227 end Adjust_External_Name_Case
;
233 procedure Analyze_Pragma
(N
: Node_Id
) is
234 Loc
: constant Source_Ptr
:= Sloc
(N
);
237 Pragma_Exit
: exception;
238 -- This exception is used to exit pragma processing completely. It
239 -- is used when an error is detected, and in other situations where
240 -- it is known that no further processing is required.
243 -- Number of pragma argument associations
249 -- First four pragma arguments (pragma argument association nodes,
250 -- or Empty if the corresponding argument does not exist).
252 procedure Check_Ada_83_Warning
;
253 -- Issues a warning message for the current pragma if operating in Ada
254 -- 83 mode (used for language pragmas that are not a standard part of
255 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
258 procedure Check_Arg_Count
(Required
: Nat
);
259 -- Check argument count for pragma is equal to given parameter.
260 -- If not, then issue an error message and raise Pragma_Exit.
262 -- Note: all routines whose name is Check_Arg_Is_xxx take an
263 -- argument Arg which can either be a pragma argument association,
264 -- in which case the check is applied to the expression of the
265 -- association or an expression directly.
267 procedure Check_Arg_Is_External_Name
(Arg
: Node_Id
);
268 -- Check that an argument has the right form for an EXTERNAL_NAME
269 -- parameter of an extended import/export pragma. The rule is that
270 -- the name must be an identifier or string literal (in Ada 83 mode)
271 -- or a static string expression (in Ada 95 mode).
273 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
);
274 -- Check the specified argument Arg to make sure that it is an
275 -- identifier. If not give error and raise Pragma_Exit.
277 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
);
278 -- Check the specified argument Arg to make sure that it is an
279 -- integer literal. If not give error and raise Pragma_Exit.
281 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
);
282 -- Check the specified argument Arg to make sure that it has the
283 -- proper syntactic form for a local name and meets the semantic
284 -- requirements for a local name. The local name is analyzed as
285 -- part of the processing for this call. In addition, the local
286 -- name is required to represent an entity at the library level.
288 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
);
289 -- Check the specified argument Arg to make sure that it has the
290 -- proper syntactic form for a local name and meets the semantic
291 -- requirements for a local name. The local name is analyzed as
292 -- part of the processing for this call.
294 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
);
295 -- Check the specified argument Arg to make sure that it is a valid
296 -- locking policy name. If not give error and raise Pragma_Exit.
298 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
);
299 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
, N3
: Name_Id
);
300 -- Check the specified argument Arg to make sure that it is an
301 -- identifier whose name matches either N1 or N2 (or N3 if present).
302 -- If not then give error and raise Pragma_Exit.
304 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
);
305 -- Check the specified argument Arg to make sure that it is a valid
306 -- queuing policy name. If not give error and raise Pragma_Exit.
308 procedure Check_Arg_Is_Static_Expression
311 -- Check the specified argument Arg to make sure that it is a static
312 -- expression of the given type (i.e. it will be analyzed and resolved
313 -- using this type, which can be any valid argument to Resolve, e.g.
314 -- Any_Integer is OK). If not, given error and raise Pragma_Exit.
316 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
);
317 -- Check the specified argument Arg to make sure that it is a
318 -- string literal. If not give error and raise Pragma_Exit
320 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
);
321 -- Check the specified argument Arg to make sure that it is a valid
322 -- valid task dispatching policy name. If not give error and raise
325 procedure Check_At_Least_N_Arguments
(N
: Nat
);
326 -- Check there are at least N arguments present
328 procedure Check_At_Most_N_Arguments
(N
: Nat
);
329 -- Check there are no more than N arguments present
331 procedure Check_Component
(Comp
: Node_Id
);
332 -- Examine Unchecked_Union component for correct use of per-object
333 -- constrained subtypes.
335 procedure Check_Duplicated_Export_Name
(Nam
: Node_Id
);
336 -- Nam is an N_String_Literal node containing the external name set
337 -- by an Import or Export pragma (or extended Import or Export pragma).
338 -- This procedure checks for possible duplications if this is the
339 -- export case, and if found, issues an appropriate error message.
341 procedure Check_First_Subtype
(Arg
: Node_Id
);
342 -- Checks that Arg, whose expression is an entity name referencing
343 -- a subtype, does not reference a type that is not a first subtype.
345 procedure Check_In_Main_Program
;
346 -- Common checks for pragmas that appear within a main program
347 -- (Priority, Main_Storage, Time_Slice).
349 procedure Check_Interrupt_Or_Attach_Handler
;
350 -- Common processing for first argument of pragma Interrupt_Handler
351 -- or pragma Attach_Handler.
353 procedure Check_Is_In_Decl_Part_Or_Package_Spec
;
354 -- Check that pragma appears in a declarative part, or in a package
355 -- specification, i.e. that it does not occur in a statement sequence
358 procedure Check_No_Identifier
(Arg
: Node_Id
);
359 -- Checks that the given argument does not have an identifier. If
360 -- an identifier is present, then an error message is issued, and
361 -- Pragma_Exit is raised.
363 procedure Check_No_Identifiers
;
364 -- Checks that none of the arguments to the pragma has an identifier.
365 -- If any argument has an identifier, then an error message is issued,
366 -- and Pragma_Exit is raised.
368 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
);
369 -- Checks if the given argument has an identifier, and if so, requires
370 -- it to match the given identifier name. If there is a non-matching
371 -- identifier, then an error message is given and Error_Pragmas raised.
373 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String);
374 -- Checks if the given argument has an identifier, and if so, requires
375 -- it to match the given identifier name. If there is a non-matching
376 -- identifier, then an error message is given and Error_Pragmas raised.
377 -- In this version of the procedure, the identifier name is given as
378 -- a string with lower case letters.
380 procedure Check_Static_Constraint
(Constr
: Node_Id
);
381 -- Constr is a constraint from an N_Subtype_Indication node from a
382 -- component constraint in an Unchecked_Union type. This routine checks
383 -- that the constraint is static as required by the restrictions for
386 procedure Check_Valid_Configuration_Pragma
;
387 -- Legality checks for placement of a configuration pragma
389 procedure Check_Valid_Library_Unit_Pragma
;
390 -- Legality checks for library unit pragmas. A special case arises for
391 -- pragmas in generic instances that come from copies of the original
392 -- library unit pragmas in the generic templates. In the case of other
393 -- than library level instantiations these can appear in contexts which
394 -- would normally be invalid (they only apply to the original template
395 -- and to library level instantiations), and they are simply ignored,
396 -- which is implemented by rewriting them as null statements.
398 procedure Check_Variant
(Variant
: Node_Id
);
399 -- Check Unchecked_Union variant for lack of nested variants and
400 -- presence of at least one component.
402 procedure Error_Pragma
(Msg
: String);
403 pragma No_Return
(Error_Pragma
);
404 -- Outputs error message for current pragma. The message contains an %
405 -- that will be replaced with the pragma name, and the flag is placed
406 -- on the pragma itself. Pragma_Exit is then raised.
408 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
);
409 pragma No_Return
(Error_Pragma_Arg
);
410 -- Outputs error message for current pragma. The message may contain
411 -- a % that will be replaced with the pragma name. The parameter Arg
412 -- may either be a pragma argument association, in which case the flag
413 -- is placed on the expression of this association, or an expression,
414 -- in which case the flag is placed directly on the expression. The
415 -- message is placed using Error_Msg_N, so the message may also contain
416 -- an & insertion character which will reference the given Arg value.
417 -- After placing the message, Pragma_Exit is raised.
419 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
);
420 pragma No_Return
(Error_Pragma_Arg
);
421 -- Similar to above form of Error_Pragma_Arg except that two messages
422 -- are provided, the second is a continuation comment starting with \.
424 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
);
425 pragma No_Return
(Error_Pragma_Arg_Ident
);
426 -- Outputs error message for current pragma. The message may contain
427 -- a % that will be replaced with the pragma name. The parameter Arg
428 -- must be a pragma argument association with a non-empty identifier
429 -- (i.e. its Chars field must be set), and the error message is placed
430 -- on the identifier. The message is placed using Error_Msg_N so
431 -- the message may also contain an & insertion character which will
432 -- reference the identifier. After placing the message, Pragma_Exit
435 function Find_Lib_Unit_Name
return Entity_Id
;
436 -- Used for a library unit pragma to find the entity to which the
437 -- library unit pragma applies, returns the entity found.
439 procedure Find_Program_Unit_Name
(Id
: Node_Id
);
440 -- If the pragma is a compilation unit pragma, the id must denote the
441 -- compilation unit in the same compilation, and the pragma must appear
442 -- in the list of preceding or trailing pragmas. If it is a program
443 -- unit pragma that is not a compilation unit pragma, then the
444 -- identifier must be visible.
446 type Name_List
is array (Natural range <>) of Name_Id
;
447 type Args_List
is array (Natural range <>) of Node_Id
;
448 procedure Gather_Associations
450 Args
: out Args_List
);
451 -- This procedure is used to gather the arguments for a pragma that
452 -- permits arbitrary ordering of parameters using the normal rules
453 -- for named and positional parameters. The Names argument is a list
454 -- of Name_Id values that corresponds to the allowed pragma argument
455 -- association identifiers in order. The result returned in Args is
456 -- a list of corresponding expressions that are the pragma arguments.
457 -- Note that this is a list of expressions, not of pragma argument
458 -- associations (Gather_Associations has completely checked all the
459 -- optional identifiers when it returns). An entry in Args is Empty
460 -- on return if the corresponding argument is not present.
462 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
;
463 -- All the routines that check pragma arguments take either a pragma
464 -- argument association (in which case the expression of the argument
465 -- association is checked), or the expression directly. The function
466 -- Get_Pragma_Arg is a utility used to deal with these two cases. If
467 -- Arg is a pragma argument association node, then its expression is
468 -- returned, otherwise Arg is returned unchanged.
470 procedure GNAT_Pragma
;
471 -- Called for all GNAT defined pragmas to note the use of the feature,
472 -- and also check the relevant restriction (No_Implementation_Pragmas).
474 function Is_Before_First_Decl
475 (Pragma_Node
: Node_Id
;
476 Decls
: List_Id
) return Boolean;
477 -- Return True if Pragma_Node is before the first declarative item in
478 -- Decls where Decls is the list of declarative items.
480 function Is_Configuration_Pragma
return Boolean;
481 -- Deterermines if the placement of the current pragma is appropriate
482 -- for a configuration pragma (precedes the current compilation unit)
484 procedure Pragma_Misplaced
;
485 -- Issue fatal error message for misplaced pragma
487 procedure Process_Atomic_Shared_Volatile
;
488 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
489 -- Shared is an obsolete Ada 83 pragma, treated as being identical
490 -- in effect to pragma Atomic.
492 procedure Process_Convention
(C
: out Convention_Id
; E
: out Entity_Id
);
493 -- Common procesing for Convention, Interface, Import and Export.
494 -- Checks first two arguments of pragma, and sets the appropriate
495 -- convention value in the specified entity or entities. On return
496 -- C is the convention, E is the referenced entity.
498 procedure Process_Extended_Import_Export_Exception_Pragma
499 (Arg_Internal
: Node_Id
;
500 Arg_External
: Node_Id
;
503 -- Common processing for the pragmas Import/Export_Exception.
504 -- The three arguments correspond to the three named parameters of
505 -- the pragma. An argument is empty if the corresponding parameter
506 -- is not present in the pragma.
508 procedure Process_Extended_Import_Export_Object_Pragma
509 (Arg_Internal
: Node_Id
;
510 Arg_External
: Node_Id
;
512 -- Common processing for the pragmass Import/Export_Object.
513 -- The three arguments correspond to the three named parameters
514 -- of the pragmas. An argument is empty if the corresponding
515 -- parameter is not present in the pragma.
517 procedure Process_Extended_Import_Export_Internal_Arg
518 (Arg_Internal
: Node_Id
:= Empty
);
519 -- Common processing for all extended Import and Export pragmas. The
520 -- argument is the pragma parameter for the Internal argument. If
521 -- Arg_Internal is empty or inappropriate, an error message is posted.
522 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
523 -- set to identify the referenced entity.
525 procedure Process_Extended_Import_Export_Subprogram_Pragma
526 (Arg_Internal
: Node_Id
;
527 Arg_External
: Node_Id
;
528 Arg_Parameter_Types
: Node_Id
;
529 Arg_Result_Type
: Node_Id
:= Empty
;
530 Arg_Mechanism
: Node_Id
;
531 Arg_Result_Mechanism
: Node_Id
:= Empty
;
532 Arg_First_Optional_Parameter
: Node_Id
:= Empty
);
533 -- Common processing for all extended Import and Export pragmas
534 -- applying to subprograms. The caller omits any arguments that do
535 -- bnot apply to the pragma in question (for example, Arg_Result_Type
536 -- can be non-Empty only in the Import_Function and Export_Function
537 -- cases). The argument names correspond to the allowed pragma
538 -- association identifiers.
540 procedure Process_Generic_List
;
541 -- Common processing for Share_Generic and Inline_Generic
543 procedure Process_Import_Or_Interface
;
544 -- Common processing for Import of Interface
546 procedure Process_Inline
(Active
: Boolean);
547 -- Common processing for Inline and Inline_Always. The parameter
548 -- indicates if the inline pragma is active, i.e. if it should
549 -- actually cause inlining to occur.
551 procedure Process_Interface_Name
552 (Subprogram_Def
: Entity_Id
;
555 -- Given the last two arguments of pragma Import, pragma Export, or
556 -- pragma Interface_Name, performs validity checks and sets the
557 -- Interface_Name field of the given subprogram entity to the
558 -- appropriate external or link name, depending on the arguments
559 -- given. Ext_Arg is always present, but Link_Arg may be missing.
560 -- Note that Ext_Arg may represent the Link_Name if Link_Arg is
561 -- missing, and appropriate named notation is used for Ext_Arg.
562 -- If neither Ext_Arg nor Link_Arg is present, the interface name
563 -- is set to the default from the subprogram name.
565 procedure Process_Interrupt_Or_Attach_Handler
;
566 -- Common processing for Interrupt and Attach_Handler pragmas
568 procedure Process_Restrictions_Or_Restriction_Warnings
;
569 -- Common processing for Restrictions and Restriction_Warnings pragmas
571 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean);
572 -- Common processing for Suppress and Unsuppress. The boolean parameter
573 -- Suppress_Case is True for the Suppress case, and False for the
576 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
);
577 -- This procedure sets the Is_Exported flag for the given entity,
578 -- checking that the entity was not previously imported. Arg is
579 -- the argument that specified the entity. A check is also made
580 -- for exporting inappropriate entities.
582 procedure Set_Extended_Import_Export_External_Name
583 (Internal_Ent
: Entity_Id
;
584 Arg_External
: Node_Id
);
585 -- Common processing for all extended import export pragmas. The first
586 -- argument, Internal_Ent, is the internal entity, which has already
587 -- been checked for validity by the caller. Arg_External is from the
588 -- Import or Export pragma, and may be null if no External parameter
589 -- was present. If Arg_External is present and is a non-null string
590 -- (a null string is treated as the default), then the Interface_Name
591 -- field of Internal_Ent is set appropriately.
593 procedure Set_Imported
(E
: Entity_Id
);
594 -- This procedure sets the Is_Imported flag for the given entity,
595 -- checking that it is not previously exported or imported.
597 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
);
598 -- Mech is a parameter passing mechanism (see Import_Function syntax
599 -- for MECHANISM_NAME). This routine checks that the mechanism argument
600 -- has the right form, and if not issues an error message. If the
601 -- argument has the right form then the Mechanism field of Ent is
602 -- set appropriately.
604 procedure Set_Ravenscar_Profile
(N
: Node_Id
);
605 -- Activate the set of configuration pragmas and restrictions that
606 -- make up the Ravenscar Profile. N is the corresponding pragma
607 -- node, which is used for error messages on any constructs
608 -- that violate the profile.
610 --------------------------
611 -- Check_Ada_83_Warning --
612 --------------------------
614 procedure Check_Ada_83_Warning
is
616 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
617 Error_Msg_N
("(Ada 83) pragma& is non-standard?", N
);
619 end Check_Ada_83_Warning
;
621 ---------------------
622 -- Check_Arg_Count --
623 ---------------------
625 procedure Check_Arg_Count
(Required
: Nat
) is
627 if Arg_Count
/= Required
then
628 Error_Pragma
("wrong number of arguments for pragma%");
632 --------------------------------
633 -- Check_Arg_Is_External_Name --
634 --------------------------------
636 procedure Check_Arg_Is_External_Name
(Arg
: Node_Id
) is
637 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
640 if Nkind
(Argx
) = N_Identifier
then
644 Analyze_And_Resolve
(Argx
, Standard_String
);
646 if Is_OK_Static_Expression
(Argx
) then
649 elsif Etype
(Argx
) = Any_Type
then
652 -- An interesting special case, if we have a string literal and
653 -- we are in Ada 83 mode, then we allow it even though it will
654 -- not be flagged as static. This allows expected Ada 83 mode
655 -- use of external names which are string literals, even though
656 -- technically these are not static in Ada 83.
658 elsif Ada_Version
= Ada_83
659 and then Nkind
(Argx
) = N_String_Literal
663 -- Static expression that raises Constraint_Error. This has
664 -- already been flagged, so just exit from pragma processing.
666 elsif Is_Static_Expression
(Argx
) then
669 -- Here we have a real error (non-static expression)
672 Error_Msg_Name_1
:= Chars
(N
);
674 ("argument for pragma% must be a identifier or " &
675 "static string expression!", Argx
);
679 end Check_Arg_Is_External_Name
;
681 -----------------------------
682 -- Check_Arg_Is_Identifier --
683 -----------------------------
685 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
) is
686 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
688 if Nkind
(Argx
) /= N_Identifier
then
690 ("argument for pragma% must be identifier", Argx
);
692 end Check_Arg_Is_Identifier
;
694 ----------------------------------
695 -- Check_Arg_Is_Integer_Literal --
696 ----------------------------------
698 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
) is
699 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
701 if Nkind
(Argx
) /= N_Integer_Literal
then
703 ("argument for pragma% must be integer literal", Argx
);
705 end Check_Arg_Is_Integer_Literal
;
707 -------------------------------------------
708 -- Check_Arg_Is_Library_Level_Local_Name --
709 -------------------------------------------
713 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
714 -- | library_unit_NAME
716 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
) is
718 Check_Arg_Is_Local_Name
(Arg
);
720 if not Is_Library_Level_Entity
(Entity
(Expression
(Arg
)))
721 and then Comes_From_Source
(N
)
724 ("argument for pragma% must be library level entity", Arg
);
726 end Check_Arg_Is_Library_Level_Local_Name
;
728 -----------------------------
729 -- Check_Arg_Is_Local_Name --
730 -----------------------------
734 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
735 -- | library_unit_NAME
737 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
) is
738 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
743 if Nkind
(Argx
) not in N_Direct_Name
744 and then (Nkind
(Argx
) /= N_Attribute_Reference
745 or else Present
(Expressions
(Argx
))
746 or else Nkind
(Prefix
(Argx
)) /= N_Identifier
)
747 and then (not Is_Entity_Name
(Argx
)
748 or else not Is_Compilation_Unit
(Entity
(Argx
)))
750 Error_Pragma_Arg
("argument for pragma% must be local name", Argx
);
753 if Is_Entity_Name
(Argx
)
754 and then Scope
(Entity
(Argx
)) /= Current_Scope
757 ("pragma% argument must be in same declarative part", Arg
);
759 end Check_Arg_Is_Local_Name
;
761 ---------------------------------
762 -- Check_Arg_Is_Locking_Policy --
763 ---------------------------------
765 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
) is
766 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
769 Check_Arg_Is_Identifier
(Argx
);
771 if not Is_Locking_Policy_Name
(Chars
(Argx
)) then
773 ("& is not a valid locking policy name", Argx
);
775 end Check_Arg_Is_Locking_Policy
;
777 -------------------------
778 -- Check_Arg_Is_One_Of --
779 -------------------------
781 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
) is
782 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
785 Check_Arg_Is_Identifier
(Argx
);
787 if Chars
(Argx
) /= N1
and then Chars
(Argx
) /= N2
then
788 Error_Msg_Name_2
:= N1
;
789 Error_Msg_Name_3
:= N2
;
790 Error_Pragma_Arg
("argument for pragma% must be% or%", Argx
);
792 end Check_Arg_Is_One_Of
;
794 procedure Check_Arg_Is_One_Of
796 N1
, N2
, N3
: Name_Id
)
798 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
801 Check_Arg_Is_Identifier
(Argx
);
803 if Chars
(Argx
) /= N1
804 and then Chars
(Argx
) /= N2
805 and then Chars
(Argx
) /= N3
807 Error_Pragma_Arg
("invalid argument for pragma%", Argx
);
809 end Check_Arg_Is_One_Of
;
811 ---------------------------------
812 -- Check_Arg_Is_Queuing_Policy --
813 ---------------------------------
815 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
) is
816 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
819 Check_Arg_Is_Identifier
(Argx
);
821 if not Is_Queuing_Policy_Name
(Chars
(Argx
)) then
823 ("& is not a valid queuing policy name", Argx
);
825 end Check_Arg_Is_Queuing_Policy
;
827 ------------------------------------
828 -- Check_Arg_Is_Static_Expression --
829 ------------------------------------
831 procedure Check_Arg_Is_Static_Expression
835 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
838 Analyze_And_Resolve
(Argx
, Typ
);
840 if Is_OK_Static_Expression
(Argx
) then
843 elsif Etype
(Argx
) = Any_Type
then
846 -- An interesting special case, if we have a string literal and
847 -- we are in Ada 83 mode, then we allow it even though it will
848 -- not be flagged as static. This allows the use of Ada 95
849 -- pragmas like Import in Ada 83 mode. They will of course be
850 -- flagged with warnings as usual, but will not cause errors.
852 elsif Ada_Version
= Ada_83
853 and then Nkind
(Argx
) = N_String_Literal
857 -- Static expression that raises Constraint_Error. This has
858 -- already been flagged, so just exit from pragma processing.
860 elsif Is_Static_Expression
(Argx
) then
863 -- Finally, we have a real error
866 Error_Msg_Name_1
:= Chars
(N
);
868 ("argument for pragma% must be a static expression!", Argx
);
871 end Check_Arg_Is_Static_Expression
;
873 ---------------------------------
874 -- Check_Arg_Is_String_Literal --
875 ---------------------------------
877 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
) is
878 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
881 if Nkind
(Argx
) /= N_String_Literal
then
883 ("argument for pragma% must be string literal", Argx
);
886 end Check_Arg_Is_String_Literal
;
888 ------------------------------------------
889 -- Check_Arg_Is_Task_Dispatching_Policy --
890 ------------------------------------------
892 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
) is
893 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
896 Check_Arg_Is_Identifier
(Argx
);
898 if not Is_Task_Dispatching_Policy_Name
(Chars
(Argx
)) then
900 ("& is not a valid task dispatching policy name", Argx
);
902 end Check_Arg_Is_Task_Dispatching_Policy
;
904 --------------------------------
905 -- Check_At_Least_N_Arguments --
906 --------------------------------
908 procedure Check_At_Least_N_Arguments
(N
: Nat
) is
910 if Arg_Count
< N
then
911 Error_Pragma
("too few arguments for pragma%");
913 end Check_At_Least_N_Arguments
;
915 -------------------------------
916 -- Check_At_Most_N_Arguments --
917 -------------------------------
919 procedure Check_At_Most_N_Arguments
(N
: Nat
) is
923 if Arg_Count
> N
then
928 Error_Pragma_Arg
("too many arguments for pragma%", Arg
);
931 end Check_At_Most_N_Arguments
;
933 ---------------------
934 -- Check_Component --
935 ---------------------
937 procedure Check_Component
(Comp
: Node_Id
) is
939 if Nkind
(Comp
) = N_Component_Declaration
then
941 Sindic
: constant Node_Id
:=
942 Subtype_Indication
(Component_Definition
(Comp
));
945 if Nkind
(Sindic
) = N_Subtype_Indication
then
947 -- Ada 2005 (AI-216): If a component subtype is subject to
948 -- a per-object constraint, then the component type shall
949 -- be an Unchecked_Union.
951 if Has_Per_Object_Constraint
(Defining_Identifier
(Comp
))
953 not Is_Unchecked_Union
(Etype
(Subtype_Mark
(Sindic
)))
955 Error_Msg_N
("component subtype subject to per-object" &
956 " constraint must be an Unchecked_Union", Comp
);
963 ----------------------------------
964 -- Check_Duplicated_Export_Name --
965 ----------------------------------
967 procedure Check_Duplicated_Export_Name
(Nam
: Node_Id
) is
968 String_Val
: constant String_Id
:= Strval
(Nam
);
971 -- We are only interested in the export case, and in the case of
972 -- generics, it is the instance, not the template, that is the
973 -- problem (the template will generate a warning in any case).
975 if not Inside_A_Generic
976 and then (Prag_Id
= Pragma_Export
978 Prag_Id
= Pragma_Export_Procedure
980 Prag_Id
= Pragma_Export_Valued_Procedure
982 Prag_Id
= Pragma_Export_Function
)
984 for J
in Externals
.First
.. Externals
.Last
loop
985 if String_Equal
(String_Val
, Strval
(Externals
.Table
(J
))) then
986 Error_Msg_Sloc
:= Sloc
(Externals
.Table
(J
));
987 Error_Msg_N
("external name duplicates name given#", Nam
);
992 Externals
.Append
(Nam
);
994 end Check_Duplicated_Export_Name
;
996 -------------------------
997 -- Check_First_Subtype --
998 -------------------------
1000 procedure Check_First_Subtype
(Arg
: Node_Id
) is
1001 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1004 if not Is_First_Subtype
(Entity
(Argx
)) then
1006 ("pragma% cannot apply to subtype", Argx
);
1008 end Check_First_Subtype
;
1010 ---------------------------
1011 -- Check_In_Main_Program --
1012 ---------------------------
1014 procedure Check_In_Main_Program
is
1015 P
: constant Node_Id
:= Parent
(N
);
1018 -- Must be at in subprogram body
1020 if Nkind
(P
) /= N_Subprogram_Body
then
1021 Error_Pragma
("% pragma allowed only in subprogram");
1023 -- Otherwise warn if obviously not main program
1025 elsif Present
(Parameter_Specifications
(Specification
(P
)))
1026 or else not Is_Compilation_Unit
(Defining_Entity
(P
))
1028 Error_Msg_Name_1
:= Chars
(N
);
1030 ("?pragma% is only effective in main program", N
);
1032 end Check_In_Main_Program
;
1034 ---------------------------------------
1035 -- Check_Interrupt_Or_Attach_Handler --
1036 ---------------------------------------
1038 procedure Check_Interrupt_Or_Attach_Handler
is
1039 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
1044 if not Is_Entity_Name
(Arg1_X
) then
1046 ("argument of pragma% must be entity name", Arg1
);
1048 elsif Prag_Id
= Pragma_Interrupt_Handler
then
1049 Check_Restriction
(No_Dynamic_Attachment
, N
);
1053 Handler_Proc
: Entity_Id
:= Empty
;
1054 Proc_Scope
: Entity_Id
;
1055 Found
: Boolean := False;
1058 if not Is_Overloaded
(Arg1_X
) then
1059 Handler_Proc
:= Entity
(Arg1_X
);
1064 Index
: Interp_Index
;
1067 Get_First_Interp
(Arg1_X
, Index
, It
);
1068 while Present
(It
.Nam
) loop
1069 Handler_Proc
:= It
.Nam
;
1071 if Ekind
(Handler_Proc
) = E_Procedure
1072 and then No
(First_Formal
(Handler_Proc
))
1076 Set_Entity
(Arg1_X
, Handler_Proc
);
1077 Set_Is_Overloaded
(Arg1_X
, False);
1080 ("ambiguous handler name for pragma% ", Arg1
);
1084 Get_Next_Interp
(Index
, It
);
1089 ("argument of pragma% must be parameterless procedure",
1092 Handler_Proc
:= Entity
(Arg1_X
);
1097 Proc_Scope
:= Scope
(Handler_Proc
);
1099 -- On AAMP only, a pragma Interrupt_Handler is supported for
1100 -- nonprotected parameterless procedures.
1103 and then Prag_Id
= Pragma_Interrupt_Handler
1105 if Ekind
(Handler_Proc
) /= E_Procedure
then
1107 ("argument of pragma% must be a procedure", Arg1
);
1110 elsif Ekind
(Handler_Proc
) /= E_Procedure
1111 or else Ekind
(Proc_Scope
) /= E_Protected_Type
1114 ("argument of pragma% must be protected procedure", Arg1
);
1117 if (not AAMP_On_Target
or else Prag_Id
= Pragma_Attach_Handler
)
1118 and then Ekind
(Proc_Scope
) = E_Protected_Type
1121 Protected_Definition
(Parent
(Proc_Scope
))
1123 Error_Pragma
("pragma% must be in protected definition");
1127 if not Is_Library_Level_Entity
(Proc_Scope
)
1128 or else (AAMP_On_Target
1129 and then not Is_Library_Level_Entity
(Handler_Proc
))
1132 ("pragma% requires library-level entity", Arg1
);
1135 if Present
(First_Formal
(Handler_Proc
)) then
1137 ("argument of pragma% must be parameterless procedure",
1141 end Check_Interrupt_Or_Attach_Handler
;
1143 -------------------------------------------
1144 -- Check_Is_In_Decl_Part_Or_Package_Spec --
1145 -------------------------------------------
1147 procedure Check_Is_In_Decl_Part_Or_Package_Spec
is
1156 elsif Nkind
(P
) = N_Handled_Sequence_Of_Statements
then
1159 elsif Nkind
(P
) = N_Package_Specification
then
1162 elsif Nkind
(P
) = N_Block_Statement
then
1165 -- Note: the following tests seem a little peculiar, because
1166 -- they test for bodies, but if we were in the statement part
1167 -- of the body, we would already have hit the handled statement
1168 -- sequence, so the only way we get here is by being in the
1169 -- declarative part of the body.
1171 elsif Nkind
(P
) = N_Subprogram_Body
1172 or else Nkind
(P
) = N_Package_Body
1173 or else Nkind
(P
) = N_Task_Body
1174 or else Nkind
(P
) = N_Entry_Body
1182 Error_Pragma
("pragma% is not in declarative part or package spec");
1183 end Check_Is_In_Decl_Part_Or_Package_Spec
;
1185 -------------------------
1186 -- Check_No_Identifier --
1187 -------------------------
1189 procedure Check_No_Identifier
(Arg
: Node_Id
) is
1191 if Chars
(Arg
) /= No_Name
then
1192 Error_Pragma_Arg_Ident
1193 ("pragma% does not permit identifier& here", Arg
);
1195 end Check_No_Identifier
;
1197 --------------------------
1198 -- Check_No_Identifiers --
1199 --------------------------
1201 procedure Check_No_Identifiers
is
1205 if Arg_Count
> 0 then
1208 while Present
(Arg_Node
) loop
1209 Check_No_Identifier
(Arg_Node
);
1213 end Check_No_Identifiers
;
1215 -------------------------------
1216 -- Check_Optional_Identifier --
1217 -------------------------------
1219 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
) is
1221 if Present
(Arg
) and then Chars
(Arg
) /= No_Name
then
1222 if Chars
(Arg
) /= Id
then
1223 Error_Msg_Name_1
:= Chars
(N
);
1224 Error_Msg_Name_2
:= Id
;
1225 Error_Msg_N
("pragma% argument expects identifier%", Arg
);
1229 end Check_Optional_Identifier
;
1231 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String) is
1233 Name_Buffer
(1 .. Id
'Length) := Id
;
1234 Name_Len
:= Id
'Length;
1235 Check_Optional_Identifier
(Arg
, Name_Find
);
1236 end Check_Optional_Identifier
;
1238 -----------------------------
1239 -- Check_Static_Constraint --
1240 -----------------------------
1242 -- Note: for convenience in writing this procedure, in addition to
1243 -- the officially (i.e. by spec) allowed argument which is always
1244 -- a constraint, it also allows ranges and discriminant associations.
1245 -- Above is not clear ???
1247 procedure Check_Static_Constraint
(Constr
: Node_Id
) is
1249 --------------------
1250 -- Require_Static --
1251 --------------------
1253 procedure Require_Static
(E
: Node_Id
);
1254 -- Require given expression to be static expression
1256 procedure Require_Static
(E
: Node_Id
) is
1258 if not Is_OK_Static_Expression
(E
) then
1259 Flag_Non_Static_Expr
1260 ("non-static constraint not allowed in Unchecked_Union!", E
);
1265 -- Start of processing for Check_Static_Constraint
1268 case Nkind
(Constr
) is
1269 when N_Discriminant_Association
=>
1270 Require_Static
(Expression
(Constr
));
1273 Require_Static
(Low_Bound
(Constr
));
1274 Require_Static
(High_Bound
(Constr
));
1276 when N_Attribute_Reference
=>
1277 Require_Static
(Type_Low_Bound
(Etype
(Prefix
(Constr
))));
1278 Require_Static
(Type_High_Bound
(Etype
(Prefix
(Constr
))));
1280 when N_Range_Constraint
=>
1281 Check_Static_Constraint
(Range_Expression
(Constr
));
1283 when N_Index_Or_Discriminant_Constraint
=>
1285 IDC
: Entity_Id
:= First
(Constraints
(Constr
));
1287 while Present
(IDC
) loop
1288 Check_Static_Constraint
(IDC
);
1296 end Check_Static_Constraint
;
1298 --------------------------------------
1299 -- Check_Valid_Configuration_Pragma --
1300 --------------------------------------
1302 -- A configuration pragma must appear in the context clause of
1303 -- a compilation unit, at the start of the list (i.e. only other
1304 -- pragmas may precede it).
1306 procedure Check_Valid_Configuration_Pragma
is
1308 if not Is_Configuration_Pragma
then
1309 Error_Pragma
("incorrect placement for configuration pragma%");
1311 end Check_Valid_Configuration_Pragma
;
1313 -------------------------------------
1314 -- Check_Valid_Library_Unit_Pragma --
1315 -------------------------------------
1317 procedure Check_Valid_Library_Unit_Pragma
is
1319 Parent_Node
: Node_Id
;
1320 Unit_Name
: Entity_Id
;
1321 Unit_Kind
: Node_Kind
;
1322 Unit_Node
: Node_Id
;
1323 Sindex
: Source_File_Index
;
1326 if not Is_List_Member
(N
) then
1330 Plist
:= List_Containing
(N
);
1331 Parent_Node
:= Parent
(Plist
);
1333 if Parent_Node
= Empty
then
1336 -- Case of pragma appearing after a compilation unit. In this
1337 -- case it must have an argument with the corresponding name
1338 -- and must be part of the following pragmas of its parent.
1340 elsif Nkind
(Parent_Node
) = N_Compilation_Unit_Aux
then
1341 if Plist
/= Pragmas_After
(Parent_Node
) then
1344 elsif Arg_Count
= 0 then
1346 ("argument required if outside compilation unit");
1349 Check_No_Identifiers
;
1350 Check_Arg_Count
(1);
1351 Unit_Node
:= Unit
(Parent
(Parent_Node
));
1352 Unit_Kind
:= Nkind
(Unit_Node
);
1354 Analyze
(Expression
(Arg1
));
1356 if Unit_Kind
= N_Generic_Subprogram_Declaration
1357 or else Unit_Kind
= N_Subprogram_Declaration
1359 Unit_Name
:= Defining_Entity
(Unit_Node
);
1361 elsif Unit_Kind
= N_Function_Instantiation
1362 or else Unit_Kind
= N_Package_Instantiation
1363 or else Unit_Kind
= N_Procedure_Instantiation
1365 Unit_Name
:= Defining_Entity
(Unit_Node
);
1368 Unit_Name
:= Cunit_Entity
(Current_Sem_Unit
);
1371 if Chars
(Unit_Name
) /=
1372 Chars
(Entity
(Expression
(Arg1
)))
1375 ("pragma% argument is not current unit name", Arg1
);
1378 if Ekind
(Unit_Name
) = E_Package
1379 and then Present
(Renamed_Entity
(Unit_Name
))
1381 Error_Pragma
("pragma% not allowed for renamed package");
1385 -- Pragma appears other than after a compilation unit
1388 -- Here we check for the generic instantiation case and also
1389 -- for the case of processing a generic formal package. We
1390 -- detect these cases by noting that the Sloc on the node
1391 -- does not belong to the current compilation unit.
1393 Sindex
:= Source_Index
(Current_Sem_Unit
);
1395 if Loc
not in Source_First
(Sindex
) .. Source_Last
(Sindex
) then
1396 Rewrite
(N
, Make_Null_Statement
(Loc
));
1399 -- If before first declaration, the pragma applies to the
1400 -- enclosing unit, and the name if present must be this name.
1402 elsif Is_Before_First_Decl
(N
, Plist
) then
1403 Unit_Node
:= Unit_Declaration_Node
(Current_Scope
);
1404 Unit_Kind
:= Nkind
(Unit_Node
);
1406 if Nkind
(Parent
(Unit_Node
)) /= N_Compilation_Unit
then
1409 elsif Unit_Kind
= N_Subprogram_Body
1410 and then not Acts_As_Spec
(Unit_Node
)
1414 elsif Nkind
(Parent_Node
) = N_Package_Body
then
1417 elsif Nkind
(Parent_Node
) = N_Package_Specification
1418 and then Plist
= Private_Declarations
(Parent_Node
)
1422 elsif (Nkind
(Parent_Node
) = N_Generic_Package_Declaration
1423 or else Nkind
(Parent_Node
)
1424 = N_Generic_Subprogram_Declaration
)
1425 and then Plist
= Generic_Formal_Declarations
(Parent_Node
)
1429 elsif Arg_Count
> 0 then
1430 Analyze
(Expression
(Arg1
));
1432 if Entity
(Expression
(Arg1
)) /= Current_Scope
then
1434 ("name in pragma% must be enclosing unit", Arg1
);
1437 -- It is legal to have no argument in this context
1443 -- Error if not before first declaration. This is because a
1444 -- library unit pragma argument must be the name of a library
1445 -- unit (RM 10.1.5(7)), but the only names permitted in this
1446 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1447 -- generic subprogram declarations or generic instantiations.
1451 ("pragma% misplaced, must be before first declaration");
1455 end Check_Valid_Library_Unit_Pragma
;
1461 procedure Check_Variant
(Variant
: Node_Id
) is
1462 Clist
: constant Node_Id
:= Component_List
(Variant
);
1466 if Present
(Variant_Part
(Clist
)) then
1468 ("Unchecked_Union may not have nested variants",
1469 Variant_Part
(Clist
));
1472 if not Is_Non_Empty_List
(Component_Items
(Clist
)) then
1474 ("Unchecked_Union may not have empty component list",
1479 Comp
:= First
(Component_Items
(Clist
));
1480 while Present
(Comp
) loop
1482 Check_Component
(Comp
);
1492 procedure Error_Pragma
(Msg
: String) is
1494 Error_Msg_Name_1
:= Chars
(N
);
1495 Error_Msg_N
(Msg
, N
);
1499 ----------------------
1500 -- Error_Pragma_Arg --
1501 ----------------------
1503 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
) is
1505 Error_Msg_Name_1
:= Chars
(N
);
1506 Error_Msg_N
(Msg
, Get_Pragma_Arg
(Arg
));
1508 end Error_Pragma_Arg
;
1510 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
) is
1512 Error_Msg_Name_1
:= Chars
(N
);
1513 Error_Msg_N
(Msg1
, Get_Pragma_Arg
(Arg
));
1514 Error_Pragma_Arg
(Msg2
, Arg
);
1515 end Error_Pragma_Arg
;
1517 ----------------------------
1518 -- Error_Pragma_Arg_Ident --
1519 ----------------------------
1521 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
) is
1523 Error_Msg_Name_1
:= Chars
(N
);
1524 Error_Msg_N
(Msg
, Arg
);
1526 end Error_Pragma_Arg_Ident
;
1528 ------------------------
1529 -- Find_Lib_Unit_Name --
1530 ------------------------
1532 function Find_Lib_Unit_Name
return Entity_Id
is
1534 -- Return inner compilation unit entity, for case of nested
1535 -- categorization pragmas. This happens in generic unit.
1537 if Nkind
(Parent
(N
)) = N_Package_Specification
1538 and then Defining_Entity
(Parent
(N
)) /= Current_Scope
1540 return Defining_Entity
(Parent
(N
));
1542 return Current_Scope
;
1544 end Find_Lib_Unit_Name
;
1546 ----------------------------
1547 -- Find_Program_Unit_Name --
1548 ----------------------------
1550 procedure Find_Program_Unit_Name
(Id
: Node_Id
) is
1551 Unit_Name
: Entity_Id
;
1552 Unit_Kind
: Node_Kind
;
1553 P
: constant Node_Id
:= Parent
(N
);
1556 if Nkind
(P
) = N_Compilation_Unit
then
1557 Unit_Kind
:= Nkind
(Unit
(P
));
1559 if Unit_Kind
= N_Subprogram_Declaration
1560 or else Unit_Kind
= N_Package_Declaration
1561 or else Unit_Kind
in N_Generic_Declaration
1563 Unit_Name
:= Defining_Entity
(Unit
(P
));
1565 if Chars
(Id
) = Chars
(Unit_Name
) then
1566 Set_Entity
(Id
, Unit_Name
);
1567 Set_Etype
(Id
, Etype
(Unit_Name
));
1569 Set_Etype
(Id
, Any_Type
);
1571 ("cannot find program unit referenced by pragma%");
1575 Set_Etype
(Id
, Any_Type
);
1576 Error_Pragma
("pragma% inapplicable to this unit");
1583 end Find_Program_Unit_Name
;
1585 -------------------------
1586 -- Gather_Associations --
1587 -------------------------
1589 procedure Gather_Associations
1591 Args
: out Args_List
)
1596 -- Initialize all parameters to Empty
1598 for J
in Args
'Range loop
1602 -- That's all we have to do if there are no argument associations
1604 if No
(Pragma_Argument_Associations
(N
)) then
1608 -- Otherwise first deal with any positional parameters present
1610 Arg
:= First
(Pragma_Argument_Associations
(N
));
1612 for Index
in Args
'Range loop
1613 exit when No
(Arg
) or else Chars
(Arg
) /= No_Name
;
1614 Args
(Index
) := Expression
(Arg
);
1618 -- Positional parameters all processed, if any left, then we
1619 -- have too many positional parameters.
1621 if Present
(Arg
) and then Chars
(Arg
) = No_Name
then
1623 ("too many positional associations for pragma%", Arg
);
1626 -- Process named parameters if any are present
1628 while Present
(Arg
) loop
1629 if Chars
(Arg
) = No_Name
then
1631 ("positional association cannot follow named association",
1635 for Index
in Names
'Range loop
1636 if Names
(Index
) = Chars
(Arg
) then
1637 if Present
(Args
(Index
)) then
1639 ("duplicate argument association for pragma%", Arg
);
1641 Args
(Index
) := Expression
(Arg
);
1646 if Index
= Names
'Last then
1647 Error_Msg_Name_1
:= Chars
(N
);
1648 Error_Msg_N
("pragma% does not allow & argument", Arg
);
1650 -- Check for possible misspelling
1652 for Index1
in Names
'Range loop
1653 if Is_Bad_Spelling_Of
1654 (Get_Name_String
(Chars
(Arg
)),
1655 Get_Name_String
(Names
(Index1
)))
1657 Error_Msg_Name_1
:= Names
(Index1
);
1658 Error_Msg_N
("\possible misspelling of%", Arg
);
1670 end Gather_Associations
;
1672 --------------------
1673 -- Get_Pragma_Arg --
1674 --------------------
1676 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
is
1678 if Nkind
(Arg
) = N_Pragma_Argument_Association
then
1679 return Expression
(Arg
);
1689 procedure GNAT_Pragma
is
1691 Check_Restriction
(No_Implementation_Pragmas
, N
);
1694 --------------------------
1695 -- Is_Before_First_Decl --
1696 --------------------------
1698 function Is_Before_First_Decl
1699 (Pragma_Node
: Node_Id
;
1700 Decls
: List_Id
) return Boolean
1702 Item
: Node_Id
:= First
(Decls
);
1705 -- Only other pragmas can come before this pragma
1708 if No
(Item
) or else Nkind
(Item
) /= N_Pragma
then
1711 elsif Item
= Pragma_Node
then
1717 end Is_Before_First_Decl
;
1719 -----------------------------
1720 -- Is_Configuration_Pragma --
1721 -----------------------------
1723 -- A configuration pragma must appear in the context clause of
1724 -- a compilation unit, at the start of the list (i.e. only other
1725 -- pragmas may precede it).
1727 function Is_Configuration_Pragma
return Boolean is
1728 Lis
: constant List_Id
:= List_Containing
(N
);
1729 Par
: constant Node_Id
:= Parent
(N
);
1733 -- If no parent, then we are in the configuration pragma file,
1734 -- so the placement is definitely appropriate.
1739 -- Otherwise we must be in the context clause of a compilation unit
1740 -- and the only thing allowed before us in the context list is more
1741 -- configuration pragmas.
1743 elsif Nkind
(Par
) = N_Compilation_Unit
1744 and then Context_Items
(Par
) = Lis
1751 elsif Nkind
(Prg
) /= N_Pragma
then
1761 end Is_Configuration_Pragma
;
1763 ----------------------
1764 -- Pragma_Misplaced --
1765 ----------------------
1767 procedure Pragma_Misplaced
is
1769 Error_Pragma
("incorrect placement of pragma%");
1770 end Pragma_Misplaced
;
1772 ------------------------------------
1773 -- Process Atomic_Shared_Volatile --
1774 ------------------------------------
1776 procedure Process_Atomic_Shared_Volatile
is
1783 procedure Set_Atomic
(E
: Entity_Id
);
1784 -- Set given type as atomic, and if no explicit alignment was
1785 -- given, set alignment to unknown, since back end knows what
1786 -- the alignment requirements are for atomic arrays. Note that
1787 -- this step is necessary for derived types.
1793 procedure Set_Atomic
(E
: Entity_Id
) is
1797 if not Has_Alignment_Clause
(E
) then
1798 Set_Alignment
(E
, Uint_0
);
1802 -- Start of processing for Process_Atomic_Shared_Volatile
1805 Check_Ada_83_Warning
;
1806 Check_No_Identifiers
;
1807 Check_Arg_Count
(1);
1808 Check_Arg_Is_Local_Name
(Arg1
);
1809 E_Id
:= Expression
(Arg1
);
1811 if Etype
(E_Id
) = Any_Type
then
1816 D
:= Declaration_Node
(E
);
1820 if Rep_Item_Too_Early
(E
, N
)
1822 Rep_Item_Too_Late
(E
, N
)
1826 Check_First_Subtype
(Arg1
);
1829 if Prag_Id
/= Pragma_Volatile
then
1831 Set_Atomic
(Underlying_Type
(E
));
1832 Set_Atomic
(Base_Type
(E
));
1835 -- Attribute belongs on the base type. If the
1836 -- view of the type is currently private, it also
1837 -- belongs on the underlying type.
1839 Set_Is_Volatile
(Base_Type
(E
));
1840 Set_Is_Volatile
(Underlying_Type
(E
));
1842 Set_Treat_As_Volatile
(E
);
1843 Set_Treat_As_Volatile
(Underlying_Type
(E
));
1845 elsif K
= N_Object_Declaration
1846 or else (K
= N_Component_Declaration
1847 and then Original_Record_Component
(E
) = E
)
1849 if Rep_Item_Too_Late
(E
, N
) then
1853 if Prag_Id
/= Pragma_Volatile
then
1856 -- If the object declaration has an explicit
1857 -- initialization, a temporary may have to be
1858 -- created to hold the expression, to insure
1859 -- that access to the object remain atomic.
1861 if Nkind
(Parent
(E
)) = N_Object_Declaration
1862 and then Present
(Expression
(Parent
(E
)))
1864 Set_Has_Delayed_Freeze
(E
);
1867 -- An interesting improvement here. If an object of type X
1868 -- is declared atomic, and the type X is not atomic, that's
1869 -- a pity, since it may not have appropraite alignment etc.
1870 -- We can rescue this in the special case where the object
1871 -- and type are in the same unit by just setting the type
1872 -- as atomic, so that the back end will process it as atomic.
1874 Utyp
:= Underlying_Type
(Etype
(E
));
1877 and then Sloc
(E
) > No_Location
1878 and then Sloc
(Utyp
) > No_Location
1880 Get_Source_File_Index
(Sloc
(E
)) =
1881 Get_Source_File_Index
(Sloc
(Underlying_Type
(Etype
(E
))))
1883 Set_Is_Atomic
(Underlying_Type
(Etype
(E
)));
1887 Set_Is_Volatile
(E
);
1888 Set_Treat_As_Volatile
(E
);
1892 ("inappropriate entity for pragma%", Arg1
);
1894 end Process_Atomic_Shared_Volatile
;
1896 ------------------------
1897 -- Process_Convention --
1898 ------------------------
1900 procedure Process_Convention
1901 (C
: out Convention_Id
;
1907 Comp_Unit
: Unit_Number_Type
;
1909 procedure Set_Convention_From_Pragma
(E
: Entity_Id
);
1910 -- Set convention in entity E, and also flag that the entity has a
1911 -- convention pragma. If entity is for a private or incomplete type,
1912 -- also set convention and flag on underlying type. This procedure
1913 -- also deals with the special case of C_Pass_By_Copy convention.
1915 --------------------------------
1916 -- Set_Convention_From_Pragma --
1917 --------------------------------
1919 procedure Set_Convention_From_Pragma
(E
: Entity_Id
) is
1921 Set_Convention
(E
, C
);
1922 Set_Has_Convention_Pragma
(E
);
1924 if Is_Incomplete_Or_Private_Type
(E
) then
1925 Set_Convention
(Underlying_Type
(E
), C
);
1926 Set_Has_Convention_Pragma
(Underlying_Type
(E
), True);
1929 -- A class-wide type should inherit the convention of
1930 -- the specific root type (although this isn't specified
1931 -- clearly by the RM).
1933 if Is_Type
(E
) and then Present
(Class_Wide_Type
(E
)) then
1934 Set_Convention
(Class_Wide_Type
(E
), C
);
1937 -- If the entity is a record type, then check for special case
1938 -- of C_Pass_By_Copy, which is treated the same as C except that
1939 -- the special record flag is set. This convention is also only
1940 -- permitted on record types (see AI95-00131).
1942 if Cname
= Name_C_Pass_By_Copy
then
1943 if Is_Record_Type
(E
) then
1944 Set_C_Pass_By_Copy
(Base_Type
(E
));
1945 elsif Is_Incomplete_Or_Private_Type
(E
)
1946 and then Is_Record_Type
(Underlying_Type
(E
))
1948 Set_C_Pass_By_Copy
(Base_Type
(Underlying_Type
(E
)));
1951 ("C_Pass_By_Copy convention allowed only for record type",
1956 -- If the entity is a derived boolean type, check for the
1957 -- special case of convention C, C++, or Fortran, where we
1958 -- consider any nonzero value to represent true.
1960 if Is_Discrete_Type
(E
)
1961 and then Root_Type
(Etype
(E
)) = Standard_Boolean
1967 C
= Convention_Fortran
)
1969 Set_Nonzero_Is_True
(Base_Type
(E
));
1971 end Set_Convention_From_Pragma
;
1973 -- Start of processing for Process_Convention
1976 Check_At_Least_N_Arguments
(2);
1977 Check_Arg_Is_Identifier
(Arg1
);
1978 Check_Optional_Identifier
(Arg1
, Name_Convention
);
1979 Cname
:= Chars
(Expression
(Arg1
));
1981 -- C_Pass_By_Copy is treated as a synonym for convention C
1982 -- (this is tested again below to set the critical flag)
1984 if Cname
= Name_C_Pass_By_Copy
then
1987 -- Otherwise we must have something in the standard convention list
1989 elsif Is_Convention_Name
(Cname
) then
1990 C
:= Get_Convention_Id
(Chars
(Expression
(Arg1
)));
1992 -- In DEC VMS, it seems that there is an undocumented feature
1993 -- that any unrecognized convention is treated as the default,
1994 -- which for us is convention C. It does not seem so terrible
1995 -- to do this unconditionally, silently in the VMS case, and
1996 -- with a warning in the non-VMS case.
1999 if Warn_On_Export_Import
and not OpenVMS_On_Target
then
2001 ("?unrecognized convention name, C assumed",
2008 Check_Arg_Is_Local_Name
(Arg2
);
2009 Check_Optional_Identifier
(Arg2
, Name_Entity
);
2011 Id
:= Expression
(Arg2
);
2014 if not Is_Entity_Name
(Id
) then
2015 Error_Pragma_Arg
("entity name required", Arg2
);
2020 -- Go to renamed subprogram if present, since convention applies
2021 -- to the actual renamed entity, not to the renaming entity.
2023 if Is_Subprogram
(E
)
2024 and then Present
(Alias
(E
))
2025 and then Nkind
(Parent
(Declaration_Node
(E
))) =
2026 N_Subprogram_Renaming_Declaration
2031 -- Check that we not applying this to a specless body
2033 if Is_Subprogram
(E
)
2034 and then Nkind
(Parent
(Declaration_Node
(E
))) = N_Subprogram_Body
2037 ("pragma% requires separate spec and must come before body");
2040 -- Check that we are not applying this to a named constant
2042 if Ekind
(E
) = E_Named_Integer
2044 Ekind
(E
) = E_Named_Real
2046 Error_Msg_Name_1
:= Chars
(N
);
2048 ("cannot apply pragma% to named constant!",
2049 Get_Pragma_Arg
(Arg2
));
2051 ("\supply appropriate type for&!", Arg2
);
2054 if Etype
(E
) = Any_Type
2055 or else Rep_Item_Too_Early
(E
, N
)
2059 E
:= Underlying_Type
(E
);
2062 if Rep_Item_Too_Late
(E
, N
) then
2066 if Has_Convention_Pragma
(E
) then
2068 ("at most one Convention/Export/Import pragma is allowed", Arg2
);
2070 elsif Convention
(E
) = Convention_Protected
2071 or else Ekind
(Scope
(E
)) = E_Protected_Type
2074 ("a protected operation cannot be given a different convention",
2078 -- For Intrinsic, a subprogram is required
2080 if C
= Convention_Intrinsic
2081 and then not Is_Subprogram
(E
)
2082 and then not Is_Generic_Subprogram
(E
)
2085 ("second argument of pragma% must be a subprogram", Arg2
);
2088 -- For Stdcall, a subprogram, variable or subprogram type is required
2090 if C
= Convention_Stdcall
2091 and then not Is_Subprogram
(E
)
2092 and then not Is_Generic_Subprogram
(E
)
2093 and then Ekind
(E
) /= E_Variable
2096 and then Ekind
(Designated_Type
(E
)) = E_Subprogram_Type
)
2099 ("second argument of pragma% must be subprogram (type)",
2103 if not Is_Subprogram
(E
)
2104 and then not Is_Generic_Subprogram
(E
)
2106 Set_Convention_From_Pragma
(E
);
2110 Check_First_Subtype
(Arg2
);
2111 Set_Convention_From_Pragma
(Base_Type
(E
));
2113 -- For subprograms, we must set the convention on the
2114 -- internally generated directly designated type as well.
2116 if Ekind
(E
) = E_Access_Subprogram_Type
then
2117 Set_Convention_From_Pragma
(Directly_Designated_Type
(E
));
2121 -- For the subprogram case, set proper convention for all homonyms
2122 -- in same scope and the same declarative part, i.e. the same
2123 -- compilation unit.
2126 Comp_Unit
:= Get_Source_Unit
(E
);
2127 Set_Convention_From_Pragma
(E
);
2129 -- Treat a pragma Import as an implicit body, for GPS use.
2131 if Prag_Id
= Pragma_Import
then
2132 Generate_Reference
(E
, Id
, 'b');
2138 exit when No
(E1
) or else Scope
(E1
) /= Current_Scope
;
2140 -- Note: below we are missing a check for Rep_Item_Too_Late.
2141 -- That is deliberate, we cannot chain the rep item on more
2142 -- than one Rep_Item chain, to be fixed later ???
2144 if Comes_From_Source
(E1
)
2145 and then Comp_Unit
= Get_Source_Unit
(E1
)
2146 and then Nkind
(Original_Node
(Parent
(E1
))) /=
2147 N_Full_Type_Declaration
2149 Set_Convention_From_Pragma
(E1
);
2151 if Prag_Id
= Pragma_Import
then
2152 Generate_Reference
(E
, Id
, 'b');
2157 end Process_Convention
;
2159 -----------------------------------------------------
2160 -- Process_Extended_Import_Export_Exception_Pragma --
2161 -----------------------------------------------------
2163 procedure Process_Extended_Import_Export_Exception_Pragma
2164 (Arg_Internal
: Node_Id
;
2165 Arg_External
: Node_Id
;
2175 if not OpenVMS_On_Target
then
2177 ("?pragma% ignored (applies only to Open'V'M'S)");
2180 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2181 Def_Id
:= Entity
(Arg_Internal
);
2183 if Ekind
(Def_Id
) /= E_Exception
then
2185 ("pragma% must refer to declared exception", Arg_Internal
);
2188 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2190 if Present
(Arg_Form
) then
2191 Check_Arg_Is_One_Of
(Arg_Form
, Name_Ada
, Name_VMS
);
2194 if Present
(Arg_Form
)
2195 and then Chars
(Arg_Form
) = Name_Ada
2199 Set_Is_VMS_Exception
(Def_Id
);
2200 Set_Exception_Code
(Def_Id
, No_Uint
);
2203 if Present
(Arg_Code
) then
2204 if not Is_VMS_Exception
(Def_Id
) then
2206 ("Code option for pragma% not allowed for Ada case",
2210 Check_Arg_Is_Static_Expression
(Arg_Code
, Any_Integer
);
2211 Code_Val
:= Expr_Value
(Arg_Code
);
2213 if not UI_Is_In_Int_Range
(Code_Val
) then
2215 ("Code option for pragma% must be in 32-bit range",
2219 Set_Exception_Code
(Def_Id
, Code_Val
);
2222 end Process_Extended_Import_Export_Exception_Pragma
;
2224 -------------------------------------------------
2225 -- Process_Extended_Import_Export_Internal_Arg --
2226 -------------------------------------------------
2228 procedure Process_Extended_Import_Export_Internal_Arg
2229 (Arg_Internal
: Node_Id
:= Empty
)
2234 if No
(Arg_Internal
) then
2235 Error_Pragma
("Internal parameter required for pragma%");
2238 if Nkind
(Arg_Internal
) = N_Identifier
then
2241 elsif Nkind
(Arg_Internal
) = N_Operator_Symbol
2242 and then (Prag_Id
= Pragma_Import_Function
2244 Prag_Id
= Pragma_Export_Function
)
2250 ("wrong form for Internal parameter for pragma%", Arg_Internal
);
2253 Check_Arg_Is_Local_Name
(Arg_Internal
);
2254 end Process_Extended_Import_Export_Internal_Arg
;
2256 --------------------------------------------------
2257 -- Process_Extended_Import_Export_Object_Pragma --
2258 --------------------------------------------------
2260 procedure Process_Extended_Import_Export_Object_Pragma
2261 (Arg_Internal
: Node_Id
;
2262 Arg_External
: Node_Id
;
2268 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2269 Def_Id
:= Entity
(Arg_Internal
);
2271 if Ekind
(Def_Id
) /= E_Constant
2272 and then Ekind
(Def_Id
) /= E_Variable
2275 ("pragma% must designate an object", Arg_Internal
);
2278 if Is_Psected
(Def_Id
) then
2280 ("previous Psect_Object applies, pragma % not permitted",
2284 if Rep_Item_Too_Late
(Def_Id
, N
) then
2288 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2290 if Present
(Arg_Size
) then
2291 Check_Arg_Is_External_Name
(Arg_Size
);
2294 -- Export_Object case
2296 if Prag_Id
= Pragma_Export_Object
then
2297 if not Is_Library_Level_Entity
(Def_Id
) then
2299 ("argument for pragma% must be library level entity",
2303 if Ekind
(Current_Scope
) = E_Generic_Package
then
2304 Error_Pragma
("pragma& cannot appear in a generic unit");
2307 if not Size_Known_At_Compile_Time
(Etype
(Def_Id
)) then
2309 ("exported object must have compile time known size",
2313 if Warn_On_Export_Import
and then Is_Exported
(Def_Id
) then
2315 ("?duplicate Export_Object pragma", N
);
2317 Set_Exported
(Def_Id
, Arg_Internal
);
2320 -- Import_Object case
2323 if Is_Concurrent_Type
(Etype
(Def_Id
)) then
2325 ("cannot use pragma% for task/protected object",
2329 if Ekind
(Def_Id
) = E_Constant
then
2331 ("cannot import a constant", Arg_Internal
);
2334 if Warn_On_Export_Import
2335 and then Has_Discriminants
(Etype
(Def_Id
))
2338 ("imported value must be initialized?", Arg_Internal
);
2341 if Warn_On_Export_Import
2342 and then Is_Access_Type
(Etype
(Def_Id
))
2345 ("cannot import object of an access type?", Arg_Internal
);
2348 if Warn_On_Export_Import
2349 and then Is_Imported
(Def_Id
)
2352 ("?duplicate Import_Object pragma", N
);
2354 -- Check for explicit initialization present. Note that an
2355 -- initialization that generated by the code generator, e.g.
2356 -- for an access type, does not count here.
2358 elsif Present
(Expression
(Parent
(Def_Id
)))
2361 (Original_Node
(Expression
(Parent
(Def_Id
))))
2363 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2365 ("no initialization allowed for declaration of& #",
2366 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2369 Set_Imported
(Def_Id
);
2370 Note_Possible_Modification
(Arg_Internal
);
2373 end Process_Extended_Import_Export_Object_Pragma
;
2375 ------------------------------------------------------
2376 -- Process_Extended_Import_Export_Subprogram_Pragma --
2377 ------------------------------------------------------
2379 procedure Process_Extended_Import_Export_Subprogram_Pragma
2380 (Arg_Internal
: Node_Id
;
2381 Arg_External
: Node_Id
;
2382 Arg_Parameter_Types
: Node_Id
;
2383 Arg_Result_Type
: Node_Id
:= Empty
;
2384 Arg_Mechanism
: Node_Id
;
2385 Arg_Result_Mechanism
: Node_Id
:= Empty
;
2386 Arg_First_Optional_Parameter
: Node_Id
:= Empty
)
2392 Ambiguous
: Boolean;
2396 function Same_Base_Type
2398 Formal
: Entity_Id
) return Boolean;
2399 -- Determines if Ptype references the type of Formal. Note that
2400 -- only the base types need to match according to the spec. Ptype
2401 -- here is the argument from the pragma, which is either a type
2402 -- name, or an access attribute.
2404 --------------------
2405 -- Same_Base_Type --
2406 --------------------
2408 function Same_Base_Type
2410 Formal
: Entity_Id
) return Boolean
2412 Ftyp
: constant Entity_Id
:= Base_Type
(Etype
(Formal
));
2416 -- Case where pragma argument is typ'Access
2418 if Nkind
(Ptype
) = N_Attribute_Reference
2419 and then Attribute_Name
(Ptype
) = Name_Access
2421 Pref
:= Prefix
(Ptype
);
2424 if not Is_Entity_Name
(Pref
)
2425 or else Entity
(Pref
) = Any_Type
2430 -- We have a match if the corresponding argument is of an
2431 -- anonymous access type, and its designicated type matches
2432 -- the type of the prefix of the access attribute
2434 return Ekind
(Ftyp
) = E_Anonymous_Access_Type
2435 and then Base_Type
(Entity
(Pref
)) =
2436 Base_Type
(Etype
(Designated_Type
(Ftyp
)));
2438 -- Case where pragma argument is a type name
2443 if not Is_Entity_Name
(Ptype
)
2444 or else Entity
(Ptype
) = Any_Type
2449 -- We have a match if the corresponding argument is of
2450 -- the type given in the pragma (comparing base types)
2452 return Base_Type
(Entity
(Ptype
)) = Ftyp
;
2456 -- Start of processing for
2457 -- Process_Extended_Import_Export_Subprogram_Pragma
2460 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2461 Hom_Id
:= Entity
(Arg_Internal
);
2465 -- Loop through homonyms (overloadings) of Hom_Id
2467 while Present
(Hom_Id
) loop
2468 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
2470 -- We need a subprogram in the current scope
2472 if not Is_Subprogram
(Def_Id
)
2473 or else Scope
(Def_Id
) /= Current_Scope
2480 -- Pragma cannot apply to subprogram body
2482 if Is_Subprogram
(Def_Id
)
2485 (Declaration_Node
(Def_Id
))) = N_Subprogram_Body
2488 ("pragma% requires separate spec"
2489 & " and must come before body");
2492 -- Test result type if given, note that the result type
2493 -- parameter can only be present for the function cases.
2495 if Present
(Arg_Result_Type
)
2496 and then not Same_Base_Type
(Arg_Result_Type
, Def_Id
)
2500 elsif Etype
(Def_Id
) /= Standard_Void_Type
2502 (Chars
(N
) = Name_Export_Procedure
2503 or else Chars
(N
) = Name_Import_Procedure
)
2507 -- Test parameter types if given. Note that this parameter
2508 -- has not been analyzed (and must not be, since it is
2509 -- semantic nonsense), so we get it as the parser left it.
2511 elsif Present
(Arg_Parameter_Types
) then
2512 Check_Matching_Types
: declare
2517 Formal
:= First_Formal
(Def_Id
);
2519 if Nkind
(Arg_Parameter_Types
) = N_Null
then
2520 if Present
(Formal
) then
2524 -- A list of one type, e.g. (List) is parsed as
2525 -- a parenthesized expression.
2527 elsif Nkind
(Arg_Parameter_Types
) /= N_Aggregate
2528 and then Paren_Count
(Arg_Parameter_Types
) = 1
2531 or else Present
(Next_Formal
(Formal
))
2536 Same_Base_Type
(Arg_Parameter_Types
, Formal
);
2539 -- A list of more than one type is parsed as a aggregate
2541 elsif Nkind
(Arg_Parameter_Types
) = N_Aggregate
2542 and then Paren_Count
(Arg_Parameter_Types
) = 0
2544 Ptype
:= First
(Expressions
(Arg_Parameter_Types
));
2545 while Present
(Ptype
) or else Present
(Formal
) loop
2548 or else not Same_Base_Type
(Ptype
, Formal
)
2553 Next_Formal
(Formal
);
2558 -- Anything else is of the wrong form
2562 ("wrong form for Parameter_Types parameter",
2563 Arg_Parameter_Types
);
2565 end Check_Matching_Types
;
2568 -- Match is now False if the entry we found did not match
2569 -- either a supplied Parameter_Types or Result_Types argument
2575 -- Ambiguous case, the flag Ambiguous shows if we already
2576 -- detected this and output the initial messages.
2579 if not Ambiguous
then
2581 Error_Msg_Name_1
:= Chars
(N
);
2583 ("pragma% does not uniquely identify subprogram!",
2585 Error_Msg_Sloc
:= Sloc
(Ent
);
2586 Error_Msg_N
("matching subprogram #!", N
);
2590 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2591 Error_Msg_N
("matching subprogram #!", N
);
2596 Hom_Id
:= Homonym
(Hom_Id
);
2599 -- See if we found an entry
2602 if not Ambiguous
then
2603 if Is_Generic_Subprogram
(Entity
(Arg_Internal
)) then
2605 ("pragma% cannot be given for generic subprogram");
2609 ("pragma% does not identify local subprogram");
2616 -- Import pragmas must be be for imported entities
2618 if Prag_Id
= Pragma_Import_Function
2620 Prag_Id
= Pragma_Import_Procedure
2622 Prag_Id
= Pragma_Import_Valued_Procedure
2624 if not Is_Imported
(Ent
) then
2626 ("pragma Import or Interface must precede pragma%");
2629 -- Here we have the Export case which can set the entity as exported
2631 -- But does not do so if the specified external name is null,
2632 -- since that is taken as a signal in DEC Ada 83 (with which
2633 -- we want to be compatible) to request no external name.
2635 elsif Nkind
(Arg_External
) = N_String_Literal
2636 and then String_Length
(Strval
(Arg_External
)) = 0
2640 -- In all other cases, set entit as exported
2643 Set_Exported
(Ent
, Arg_Internal
);
2646 -- Special processing for Valued_Procedure cases
2648 if Prag_Id
= Pragma_Import_Valued_Procedure
2650 Prag_Id
= Pragma_Export_Valued_Procedure
2652 Formal
:= First_Formal
(Ent
);
2656 ("at least one parameter required for pragma%");
2658 elsif Ekind
(Formal
) /= E_Out_Parameter
then
2660 ("first parameter must have mode out for pragma%");
2663 Set_Is_Valued_Procedure
(Ent
);
2667 Set_Extended_Import_Export_External_Name
(Ent
, Arg_External
);
2669 -- Process Result_Mechanism argument if present. We have already
2670 -- checked that this is only allowed for the function case.
2672 if Present
(Arg_Result_Mechanism
) then
2673 Set_Mechanism_Value
(Ent
, Arg_Result_Mechanism
);
2676 -- Process Mechanism parameter if present. Note that this parameter
2677 -- is not analyzed, and must not be analyzed since it is semantic
2678 -- nonsense, so we get it in exactly as the parser left it.
2680 if Present
(Arg_Mechanism
) then
2688 -- A single mechanism association without a formal parameter
2689 -- name is parsed as a parenthesized expression. All other
2690 -- cases are parsed as aggregates, so we rewrite the single
2691 -- parameter case as an aggregate for consistency.
2693 if Nkind
(Arg_Mechanism
) /= N_Aggregate
2694 and then Paren_Count
(Arg_Mechanism
) = 1
2696 Rewrite
(Arg_Mechanism
,
2697 Make_Aggregate
(Sloc
(Arg_Mechanism
),
2698 Expressions
=> New_List
(
2699 Relocate_Node
(Arg_Mechanism
))));
2702 -- Case of only mechanism name given, applies to all formals
2704 if Nkind
(Arg_Mechanism
) /= N_Aggregate
then
2705 Formal
:= First_Formal
(Ent
);
2706 while Present
(Formal
) loop
2707 Set_Mechanism_Value
(Formal
, Arg_Mechanism
);
2708 Next_Formal
(Formal
);
2711 -- Case of list of mechanism associations given
2714 if Null_Record_Present
(Arg_Mechanism
) then
2716 ("inappropriate form for Mechanism parameter",
2720 -- Deal with positional ones first
2722 Formal
:= First_Formal
(Ent
);
2723 if Present
(Expressions
(Arg_Mechanism
)) then
2724 Mname
:= First
(Expressions
(Arg_Mechanism
));
2726 while Present
(Mname
) loop
2729 ("too many mechanism associations", Mname
);
2732 Set_Mechanism_Value
(Formal
, Mname
);
2733 Next_Formal
(Formal
);
2738 -- Deal with named entries
2740 if Present
(Component_Associations
(Arg_Mechanism
)) then
2741 Massoc
:= First
(Component_Associations
(Arg_Mechanism
));
2743 while Present
(Massoc
) loop
2744 Choice
:= First
(Choices
(Massoc
));
2746 if Nkind
(Choice
) /= N_Identifier
2747 or else Present
(Next
(Choice
))
2750 ("incorrect form for mechanism association",
2754 Formal
:= First_Formal
(Ent
);
2758 ("parameter name & not present", Choice
);
2761 if Chars
(Choice
) = Chars
(Formal
) then
2763 (Formal
, Expression
(Massoc
));
2767 Next_Formal
(Formal
);
2777 -- Process First_Optional_Parameter argument if present. We have
2778 -- already checked that this is only allowed for the Import case.
2780 if Present
(Arg_First_Optional_Parameter
) then
2781 if Nkind
(Arg_First_Optional_Parameter
) /= N_Identifier
then
2783 ("first optional parameter must be formal parameter name",
2784 Arg_First_Optional_Parameter
);
2787 Formal
:= First_Formal
(Ent
);
2791 ("specified formal parameter& not found",
2792 Arg_First_Optional_Parameter
);
2795 exit when Chars
(Formal
) =
2796 Chars
(Arg_First_Optional_Parameter
);
2798 Next_Formal
(Formal
);
2801 Set_First_Optional_Parameter
(Ent
, Formal
);
2803 -- Check specified and all remaining formals have right form
2805 while Present
(Formal
) loop
2806 if Ekind
(Formal
) /= E_In_Parameter
then
2808 ("optional formal& is not of mode in!",
2809 Arg_First_Optional_Parameter
, Formal
);
2812 Dval
:= Default_Value
(Formal
);
2814 if not Present
(Dval
) then
2816 ("optional formal& does not have default value!",
2817 Arg_First_Optional_Parameter
, Formal
);
2819 elsif Compile_Time_Known_Value_Or_Aggr
(Dval
) then
2824 ("default value for optional formal& is non-static!",
2825 Arg_First_Optional_Parameter
, Formal
);
2829 Set_Is_Optional_Parameter
(Formal
);
2830 Next_Formal
(Formal
);
2833 end Process_Extended_Import_Export_Subprogram_Pragma
;
2835 --------------------------
2836 -- Process_Generic_List --
2837 --------------------------
2839 procedure Process_Generic_List
is
2845 Check_No_Identifiers
;
2846 Check_At_Least_N_Arguments
(1);
2849 while Present
(Arg
) loop
2850 Exp
:= Expression
(Arg
);
2853 if not Is_Entity_Name
(Exp
)
2855 (not Is_Generic_Instance
(Entity
(Exp
))
2857 not Is_Generic_Unit
(Entity
(Exp
)))
2860 ("pragma% argument must be name of generic unit/instance",
2866 end Process_Generic_List
;
2868 ---------------------------------
2869 -- Process_Import_Or_Interface --
2870 ---------------------------------
2872 procedure Process_Import_Or_Interface
is
2878 Process_Convention
(C
, Def_Id
);
2879 Kill_Size_Check_Code
(Def_Id
);
2880 Note_Possible_Modification
(Expression
(Arg2
));
2882 if Ekind
(Def_Id
) = E_Variable
2884 Ekind
(Def_Id
) = E_Constant
2886 -- User initialization is not allowed for imported object, but
2887 -- the object declaration may contain a default initialization,
2888 -- that will be discarded. Note that an explicit initialization
2889 -- only counts if it comes from source, otherwise it is simply
2890 -- the code generator making an implicit initialization explicit.
2892 if Present
(Expression
(Parent
(Def_Id
)))
2893 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
2895 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2897 ("no initialization allowed for declaration of& #",
2898 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2902 Set_Imported
(Def_Id
);
2903 Set_Is_Public
(Def_Id
);
2904 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
2906 -- pragma Import completes deferred constants
2908 if Ekind
(Def_Id
) = E_Constant
then
2909 Set_Has_Completion
(Def_Id
);
2912 -- It is not possible to import a constant of an unconstrained
2913 -- array type (e.g. string) because there is no simple way to
2914 -- write a meaningful subtype for it.
2916 if Is_Array_Type
(Etype
(Def_Id
))
2917 and then not Is_Constrained
(Etype
(Def_Id
))
2920 ("imported constant& must have a constrained subtype",
2925 elsif Is_Subprogram
(Def_Id
)
2926 or else Is_Generic_Subprogram
(Def_Id
)
2928 -- If the name is overloaded, pragma applies to all of the
2929 -- denoted entities in the same declarative part.
2932 while Present
(Hom_Id
) loop
2933 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
2935 -- Ignore inherited subprograms because the pragma will
2936 -- apply to the parent operation, which is the one called.
2938 if Is_Overloadable
(Def_Id
)
2939 and then Present
(Alias
(Def_Id
))
2943 -- If it is not a subprogram, it must be in an outer
2944 -- scope and pragma does not apply.
2946 elsif not Is_Subprogram
(Def_Id
)
2947 and then not Is_Generic_Subprogram
(Def_Id
)
2951 -- Verify that the homonym is in the same declarative
2952 -- part (not just the same scope).
2954 elsif Parent
(Unit_Declaration_Node
(Def_Id
)) /= Parent
(N
)
2955 and then Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
2960 Set_Imported
(Def_Id
);
2962 -- If Import intrinsic, set intrinsic flag
2963 -- and verify that it is known as such.
2965 if C
= Convention_Intrinsic
then
2966 Set_Is_Intrinsic_Subprogram
(Def_Id
);
2967 Check_Intrinsic_Subprogram
2968 (Def_Id
, Expression
(Arg2
));
2971 -- All interfaced procedures need an external
2972 -- symbol created for them since they are
2973 -- always referenced from another object file.
2975 Set_Is_Public
(Def_Id
);
2977 -- Verify that the subprogram does not have a completion
2978 -- through a renaming declaration. For other completions
2979 -- the pragma appears as a too late representation.
2982 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Def_Id
);
2986 and then Nkind
(Decl
) = N_Subprogram_Declaration
2987 and then Present
(Corresponding_Body
(Decl
))
2990 (Unit_Declaration_Node
2991 (Corresponding_Body
(Decl
))) =
2992 N_Subprogram_Renaming_Declaration
2994 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2995 Error_Msg_NE
("cannot import&#," &
2996 " already completed by a renaming",
3001 Set_Has_Completion
(Def_Id
);
3002 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3005 if Is_Compilation_Unit
(Hom_Id
) then
3007 -- Its possible homonyms are not affected by the pragma.
3008 -- Such homonyms might be present in the context of other
3009 -- units being compiled.
3014 Hom_Id
:= Homonym
(Hom_Id
);
3018 -- When the convention is Java, we also allow Import to be given
3019 -- for packages, exceptions, and record components.
3021 elsif C
= Convention_Java
3023 (Ekind
(Def_Id
) = E_Package
3024 or else Ekind
(Def_Id
) = E_Exception
3025 or else Nkind
(Parent
(Def_Id
)) = N_Component_Declaration
)
3027 Set_Imported
(Def_Id
);
3028 Set_Is_Public
(Def_Id
);
3029 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3033 ("second argument of pragma% must be object or subprogram",
3037 -- If this pragma applies to a compilation unit, then the unit,
3038 -- which is a subprogram, does not require (or allow) a body.
3039 -- We also do not need to elaborate imported procedures.
3041 if Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
3043 Cunit
: constant Node_Id
:= Parent
(Parent
(N
));
3045 Set_Body_Required
(Cunit
, False);
3048 end Process_Import_Or_Interface
;
3050 --------------------
3051 -- Process_Inline --
3052 --------------------
3054 procedure Process_Inline
(Active
: Boolean) is
3060 Effective
: Boolean := False;
3062 procedure Make_Inline
(Subp
: Entity_Id
);
3063 -- Subp is the defining unit name of the subprogram
3064 -- declaration. Set the flag, as well as the flag in the
3065 -- corresponding body, if there is one present.
3067 procedure Set_Inline_Flags
(Subp
: Entity_Id
);
3068 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp
3070 function Cannot_Inline
(Subp
: Entity_Id
) return Boolean;
3071 -- Do not set the inline flag if body is available and contains
3072 -- exception handlers, to prevent undefined symbols at link time.
3073 -- Emit warning if front-end inlining is enabled and the pragma
3074 -- appears too late.
3080 function Cannot_Inline
(Subp
: Entity_Id
) return Boolean is
3081 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Subp
);
3084 if Nkind
(Decl
) = N_Subprogram_Body
then
3087 (Exception_Handlers
(Handled_Statement_Sequence
(Decl
)));
3089 elsif Nkind
(Decl
) = N_Subprogram_Declaration
3090 and then Present
(Corresponding_Body
(Decl
))
3092 if Front_End_Inlining
3093 and then Analyzed
(Corresponding_Body
(Decl
))
3095 Error_Msg_N
("pragma appears too late, ignored?", N
);
3098 -- If the subprogram is a renaming as body, the body is
3099 -- just a call to the renamed subprogram, and inlining is
3100 -- trivially possible.
3103 Nkind
(Unit_Declaration_Node
(Corresponding_Body
(Decl
)))
3104 = N_Subprogram_Renaming_Declaration
3110 Present
(Exception_Handlers
3111 (Handled_Statement_Sequence
3112 (Unit_Declaration_Node
(Corresponding_Body
(Decl
)))));
3115 -- If body is not available, assume the best, the check is
3116 -- performed again when compiling enclosing package bodies.
3126 procedure Make_Inline
(Subp
: Entity_Id
) is
3127 Kind
: constant Entity_Kind
:= Ekind
(Subp
);
3128 Inner_Subp
: Entity_Id
:= Subp
;
3131 if Etype
(Subp
) = Any_Type
then
3134 elsif Cannot_Inline
(Subp
) then
3135 Applies
:= True; -- Do not treat as an error.
3138 -- Here we have a candidate for inlining, but we must exclude
3139 -- derived operations. Otherwise we will end up trying to
3140 -- inline a phantom declaration, and the result would be to
3141 -- drag in a body which has no direct inlining associated with
3142 -- it. That would not only be inefficient but would also result
3143 -- in the backend doing cross-unit inlining in cases where it
3144 -- was definitely inappropriate to do so.
3146 -- However, a simple Comes_From_Source test is insufficient,
3147 -- since we do want to allow inlining of generic instances,
3148 -- which also do not come from source. Predefined operators do
3149 -- not come from source but are not inlineable either.
3151 elsif not Comes_From_Source
(Subp
)
3152 and then not Is_Generic_Instance
(Subp
)
3153 and then Scope
(Subp
) /= Standard_Standard
3158 -- The referenced entity must either be the enclosing entity,
3159 -- or an entity declared within the current open scope.
3161 elsif Present
(Scope
(Subp
))
3162 and then Scope
(Subp
) /= Current_Scope
3163 and then Subp
/= Current_Scope
3166 ("argument of% must be entity in current scope", Assoc
);
3170 -- Processing for procedure, operator or function.
3171 -- If subprogram is aliased (as for an instance) indicate
3172 -- that the renamed entity (if declared in the same unit)
3175 if Is_Subprogram
(Subp
) then
3176 while Present
(Alias
(Inner_Subp
)) loop
3177 Inner_Subp
:= Alias
(Inner_Subp
);
3180 if In_Same_Source_Unit
(Subp
, Inner_Subp
) then
3181 Set_Inline_Flags
(Inner_Subp
);
3183 Decl
:= Parent
(Parent
(Inner_Subp
));
3185 if Nkind
(Decl
) = N_Subprogram_Declaration
3186 and then Present
(Corresponding_Body
(Decl
))
3188 Set_Inline_Flags
(Corresponding_Body
(Decl
));
3194 -- For a generic subprogram set flag as well, for use at
3195 -- the point of instantiation, to determine whether the
3196 -- body should be generated.
3198 elsif Is_Generic_Subprogram
(Subp
) then
3199 Set_Inline_Flags
(Subp
);
3202 -- Literals are by definition inlined
3204 elsif Kind
= E_Enumeration_Literal
then
3207 -- Anything else is an error
3211 ("expect subprogram name for pragma%", Assoc
);
3215 ----------------------
3216 -- Set_Inline_Flags --
3217 ----------------------
3219 procedure Set_Inline_Flags
(Subp
: Entity_Id
) is
3222 Set_Is_Inlined
(Subp
, True);
3225 if not Has_Pragma_Inline
(Subp
) then
3226 Set_Has_Pragma_Inline
(Subp
);
3227 Set_Next_Rep_Item
(N
, First_Rep_Item
(Subp
));
3228 Set_First_Rep_Item
(Subp
, N
);
3231 end Set_Inline_Flags
;
3233 -- Start of processing for Process_Inline
3236 Check_No_Identifiers
;
3237 Check_At_Least_N_Arguments
(1);
3240 Inline_Processing_Required
:= True;
3244 while Present
(Assoc
) loop
3245 Subp_Id
:= Expression
(Assoc
);
3249 if Is_Entity_Name
(Subp_Id
) then
3250 Subp
:= Entity
(Subp_Id
);
3252 if Subp
= Any_Id
then
3258 while Present
(Homonym
(Subp
))
3259 and then Scope
(Homonym
(Subp
)) = Current_Scope
3261 Make_Inline
(Homonym
(Subp
));
3262 Subp
:= Homonym
(Subp
);
3269 ("inappropriate argument for pragma%", Assoc
);
3272 and then Warn_On_Redundant_Constructs
3274 Error_Msg_NE
("pragma inline on& is redundant?",
3275 N
, Entity
(Subp_Id
));
3282 ----------------------------
3283 -- Process_Interface_Name --
3284 ----------------------------
3286 procedure Process_Interface_Name
3287 (Subprogram_Def
: Entity_Id
;
3293 String_Val
: String_Id
;
3295 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
);
3296 -- SN is a string literal node for an interface name. This routine
3297 -- performs some minimal checks that the name is reasonable. In
3298 -- particular that no spaces or other obviously incorrect characters
3299 -- appear. This is only a warning, since any characters are allowed.
3301 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
) is
3302 S
: constant String_Id
:= Strval
(Expr_Value_S
(SN
));
3303 SL
: constant Nat
:= String_Length
(S
);
3308 Error_Msg_N
("interface name cannot be null string", SN
);
3311 for J
in 1 .. SL
loop
3312 C
:= Get_String_Char
(S
, J
);
3314 if Warn_On_Export_Import
3315 and then (not In_Character_Range
(C
)
3316 or else Get_Character
(C
) = ' '
3317 or else Get_Character
(C
) = ',')
3320 ("?interface name contains illegal character", SN
);
3323 end Check_Form_Of_Interface_Name
;
3325 -- Start of processing for Process_Interface_Name
3328 if No
(Link_Arg
) then
3329 if No
(Ext_Arg
) then
3332 elsif Chars
(Ext_Arg
) = Name_Link_Name
then
3334 Link_Nam
:= Expression
(Ext_Arg
);
3337 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
3338 Ext_Nam
:= Expression
(Ext_Arg
);
3343 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
3344 Check_Optional_Identifier
(Link_Arg
, Name_Link_Name
);
3345 Ext_Nam
:= Expression
(Ext_Arg
);
3346 Link_Nam
:= Expression
(Link_Arg
);
3349 -- Check expressions for external name and link name are static
3351 if Present
(Ext_Nam
) then
3352 Check_Arg_Is_Static_Expression
(Ext_Nam
, Standard_String
);
3353 Check_Form_Of_Interface_Name
(Ext_Nam
);
3355 -- Verify that the external name is not the name of a local
3356 -- entity, which would hide the imported one and lead to
3357 -- run-time surprises. The problem can only arise for entities
3358 -- declared in a package body (otherwise the external name is
3359 -- fully qualified and won't conflict).
3367 if Prag_Id
= Pragma_Import
then
3368 String_To_Name_Buffer
(Strval
(Expr_Value_S
(Ext_Nam
)));
3370 E
:= Entity_Id
(Get_Name_Table_Info
(Nam
));
3372 if Nam
/= Chars
(Subprogram_Def
)
3373 and then Present
(E
)
3374 and then not Is_Overloadable
(E
)
3375 and then Is_Immediately_Visible
(E
)
3376 and then not Is_Imported
(E
)
3377 and then Ekind
(Scope
(E
)) = E_Package
3381 while Present
(Par
) loop
3382 if Nkind
(Par
) = N_Package_Body
then
3383 Error_Msg_Sloc
:= Sloc
(E
);
3385 ("imported entity is hidden by & declared#",
3390 Par
:= Parent
(Par
);
3397 if Present
(Link_Nam
) then
3398 Check_Arg_Is_Static_Expression
(Link_Nam
, Standard_String
);
3399 Check_Form_Of_Interface_Name
(Link_Nam
);
3402 -- If there is no link name, just set the external name
3404 if No
(Link_Nam
) then
3405 Link_Nam
:= Adjust_External_Name_Case
(Expr_Value_S
(Ext_Nam
));
3407 -- For the Link_Name case, the given literal is preceded by an
3408 -- asterisk, which indicates to GCC that the given name should
3409 -- be taken literally, and in particular that no prepending of
3410 -- underlines should occur, even in systems where this is the
3415 Store_String_Char
(Get_Char_Code
('*'));
3416 String_Val
:= Strval
(Expr_Value_S
(Link_Nam
));
3418 for J
in 1 .. String_Length
(String_Val
) loop
3419 Store_String_Char
(Get_String_Char
(String_Val
, J
));
3423 Make_String_Literal
(Sloc
(Link_Nam
), End_String
);
3426 Set_Encoded_Interface_Name
3427 (Get_Base_Subprogram
(Subprogram_Def
), Link_Nam
);
3428 Check_Duplicated_Export_Name
(Link_Nam
);
3429 end Process_Interface_Name
;
3431 -----------------------------------------
3432 -- Process_Interrupt_Or_Attach_Handler --
3433 -----------------------------------------
3435 procedure Process_Interrupt_Or_Attach_Handler
is
3436 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
3437 Handler_Proc
: constant Entity_Id
:= Entity
(Arg1_X
);
3438 Proc_Scope
: constant Entity_Id
:= Scope
(Handler_Proc
);
3441 Set_Is_Interrupt_Handler
(Handler_Proc
);
3443 -- If the pragma is not associated with a handler procedure
3444 -- within a protected type, then it must be for a nonprotected
3445 -- procedure for the AAMP target, in which case we don't
3446 -- associate a representation item with the procedure's scope.
3448 if Ekind
(Proc_Scope
) = E_Protected_Type
then
3449 if Prag_Id
= Pragma_Interrupt_Handler
3451 Prag_Id
= Pragma_Attach_Handler
3453 Record_Rep_Item
(Proc_Scope
, N
);
3456 end Process_Interrupt_Or_Attach_Handler
;
3458 --------------------------------------------------
3459 -- Process_Restrictions_Or_Restriction_Warnings --
3460 --------------------------------------------------
3462 procedure Process_Restrictions_Or_Restriction_Warnings
is
3464 R_Id
: Restriction_Id
;
3469 procedure Set_Warning
(R
: All_Restrictions
);
3470 -- If this is a Restriction_Warnings pragma, set warning flag,
3471 -- otherwise reset the flag.
3477 procedure Set_Warning
(R
: All_Restrictions
) is
3479 if Prag_Id
= Pragma_Restriction_Warnings
then
3480 Restriction_Warnings
(R
) := True;
3482 Restriction_Warnings
(R
) := False;
3486 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
3489 Check_Ada_83_Warning
;
3490 Check_At_Least_N_Arguments
(1);
3491 Check_Valid_Configuration_Pragma
;
3494 while Present
(Arg
) loop
3496 Expr
:= Expression
(Arg
);
3498 -- Case of no restriction identifier present
3500 if Id
= No_Name
then
3501 if Nkind
(Expr
) /= N_Identifier
then
3503 ("invalid form for restriction", Arg
);
3508 (Process_Restriction_Synonyms
(Expr
));
3510 if R_Id
not in All_Boolean_Restrictions
then
3512 ("invalid restriction identifier", Arg
);
3515 if Implementation_Restriction
(R_Id
) then
3517 (No_Implementation_Restrictions
, Arg
);
3520 Set_Restriction
(R_Id
, N
);
3523 -- A very special case that must be processed here:
3524 -- pragma Restrictions (No_Exceptions) turns off
3525 -- all run-time checking. This is a bit dubious in
3526 -- terms of the formal language definition, but it
3527 -- is what is intended by RM H.4(12).
3529 if R_Id
= No_Exceptions
then
3530 Scope_Suppress
:= (others => True);
3533 -- Case of restriction identifier present
3536 R_Id
:= Get_Restriction_Id
(Process_Restriction_Synonyms
(Arg
));
3537 Analyze_And_Resolve
(Expr
, Any_Integer
);
3539 if R_Id
not in All_Parameter_Restrictions
then
3541 ("invalid restriction parameter identifier", Arg
);
3543 elsif not Is_OK_Static_Expression
(Expr
) then
3544 Flag_Non_Static_Expr
3545 ("value must be static expression!", Expr
);
3548 elsif not Is_Integer_Type
(Etype
(Expr
))
3549 or else Expr_Value
(Expr
) < 0
3552 ("value must be non-negative integer", Arg
);
3554 -- Restriction pragma is active
3557 Val
:= Expr_Value
(Expr
);
3559 if not UI_Is_In_Int_Range
(Val
) then
3561 ("pragma ignored, value too large?", Arg
);
3563 Set_Restriction
(R_Id
, N
, Integer (UI_To_Int
(Val
)));
3571 end Process_Restrictions_Or_Restriction_Warnings
;
3573 ---------------------------------
3574 -- Process_Suppress_Unsuppress --
3575 ---------------------------------
3577 -- Note: this procedure makes entries in the check suppress data
3578 -- structures managed by Sem. See spec of package Sem for full
3579 -- details on how we handle recording of check suppression.
3581 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean) is
3586 In_Package_Spec
: constant Boolean :=
3587 (Ekind
(Current_Scope
) = E_Package
3589 Ekind
(Current_Scope
) = E_Generic_Package
)
3590 and then not In_Package_Body
(Current_Scope
);
3592 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
);
3593 -- Used to suppress a single check on the given entity
3595 --------------------------------
3596 -- Suppress_Unsuppress_Echeck --
3597 --------------------------------
3599 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
) is
3600 ESR
: constant Entity_Check_Suppress_Record
:=
3603 Suppress
=> Suppress_Case
);
3606 Set_Checks_May_Be_Suppressed
(E
);
3608 if In_Package_Spec
then
3609 Global_Entity_Suppress
.Append
(ESR
);
3611 Local_Entity_Suppress
.Append
(ESR
);
3614 -- If this is a first subtype, and the base type is distinct,
3615 -- then also set the suppress flags on the base type.
3617 if Is_First_Subtype
(E
)
3618 and then Etype
(E
) /= E
3620 Suppress_Unsuppress_Echeck
(Etype
(E
), C
);
3622 end Suppress_Unsuppress_Echeck
;
3624 -- Start of processing for Process_Suppress_Unsuppress
3627 -- Suppress/Unsuppress can appear as a configuration pragma,
3628 -- or in a declarative part or a package spec (RM 11.5(5))
3630 if not Is_Configuration_Pragma
then
3631 Check_Is_In_Decl_Part_Or_Package_Spec
;
3634 Check_At_Least_N_Arguments
(1);
3635 Check_At_Most_N_Arguments
(2);
3636 Check_No_Identifier
(Arg1
);
3637 Check_Arg_Is_Identifier
(Arg1
);
3639 if not Is_Check_Name
(Chars
(Expression
(Arg1
))) then
3641 ("argument of pragma% is not valid check name", Arg1
);
3643 C
:= Get_Check_Id
(Chars
(Expression
(Arg1
)));
3646 if Arg_Count
= 1 then
3648 -- Make an entry in the local scope suppress table. This is the
3649 -- table that directly shows the current value of the scope
3650 -- suppress check for any check id value.
3652 if C
= All_Checks
then
3653 for J
in Scope_Suppress
'Range loop
3654 Scope_Suppress
(J
) := Suppress_Case
;
3657 Scope_Suppress
(C
) := Suppress_Case
;
3660 -- Also make an entry in the Local_Entity_Suppress table. See
3661 -- extended description in the package spec of Sem for details.
3663 Local_Entity_Suppress
.Append
3666 Suppress
=> Suppress_Case
));
3668 -- Case of two arguments present, where the check is
3669 -- suppressed for a specified entity (given as the second
3670 -- argument of the pragma)
3673 Check_Optional_Identifier
(Arg2
, Name_On
);
3674 E_Id
:= Expression
(Arg2
);
3677 if not Is_Entity_Name
(E_Id
) then
3679 ("second argument of pragma% must be entity name", Arg2
);
3688 -- Enforce RM 11.5(7) which requires that for a pragma that
3689 -- appears within a package spec, the named entity must be
3690 -- within the package spec. We allow the package name itself
3691 -- to be mentioned since that makes sense, although it is not
3692 -- strictly allowed by 11.5(7).
3695 and then E
/= Current_Scope
3696 and then Scope
(E
) /= Current_Scope
3699 ("entity in pragma% is not in package spec ('R'M 11.5(7))",
3703 -- Loop through homonyms. As noted below, in the case of a package
3704 -- spec, only homonyms within the package spec are considered.
3707 Suppress_Unsuppress_Echeck
(E
, C
);
3709 if Is_Generic_Instance
(E
)
3710 and then Is_Subprogram
(E
)
3711 and then Present
(Alias
(E
))
3713 Suppress_Unsuppress_Echeck
(Alias
(E
), C
);
3716 -- Move to next homonym
3721 -- If we are within a package specification, the
3722 -- pragma only applies to homonyms in the same scope.
3724 exit when In_Package_Spec
3725 and then Scope
(E
) /= Current_Scope
;
3728 end Process_Suppress_Unsuppress
;
3734 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
) is
3736 if Is_Imported
(E
) then
3738 ("cannot export entity& that was previously imported", Arg
);
3740 elsif Present
(Address_Clause
(E
)) then
3742 ("cannot export entity& that has an address clause", Arg
);
3745 Set_Is_Exported
(E
);
3747 -- Generate a reference for entity explicitly, because the
3748 -- identifier may be overloaded and name resolution will not
3751 Generate_Reference
(E
, Arg
);
3753 -- Deal with exporting non-library level entity
3755 if not Is_Library_Level_Entity
(E
) then
3757 -- Not allowed at all for subprograms
3759 if Is_Subprogram
(E
) then
3760 Error_Pragma_Arg
("local subprogram& cannot be exported", Arg
);
3762 -- Otherwise set public and statically allocated
3766 Set_Is_Statically_Allocated
(E
);
3768 -- Warn if the corresponding W flag is set and the pragma
3769 -- comes from source. The latter may not be true e.g. on
3770 -- VMS where we expand export pragmas for exception codes
3771 -- associated with imported or exported exceptions. We do
3772 -- not want to generate a warning for something that the
3773 -- user did not write.
3775 if Warn_On_Export_Import
3776 and then Comes_From_Source
(Arg
)
3779 ("?& has been made static as a result of Export", Arg
, E
);
3781 ("\this usage is non-standard and non-portable", Arg
);
3786 if Warn_On_Export_Import
and then Is_Type
(E
) then
3788 ("exporting a type has no effect?", Arg
, E
);
3791 if Warn_On_Export_Import
and Inside_A_Generic
then
3793 ("all instances of& will have the same external name?", Arg
, E
);
3797 ----------------------------------------------
3798 -- Set_Extended_Import_Export_External_Name --
3799 ----------------------------------------------
3801 procedure Set_Extended_Import_Export_External_Name
3802 (Internal_Ent
: Entity_Id
;
3803 Arg_External
: Node_Id
)
3805 Old_Name
: constant Node_Id
:= Interface_Name
(Internal_Ent
);
3809 if No
(Arg_External
) then
3813 Check_Arg_Is_External_Name
(Arg_External
);
3815 if Nkind
(Arg_External
) = N_String_Literal
then
3816 if String_Length
(Strval
(Arg_External
)) = 0 then
3819 New_Name
:= Adjust_External_Name_Case
(Arg_External
);
3822 elsif Nkind
(Arg_External
) = N_Identifier
then
3823 New_Name
:= Get_Default_External_Name
(Arg_External
);
3825 -- Check_Arg_Is_External_Name should let through only
3826 -- identifiers and string literals or static string
3827 -- expressions (which are folded to string literals).
3830 raise Program_Error
;
3833 -- If we already have an external name set (by a prior normal
3834 -- Import or Export pragma), then the external names must match
3836 if Present
(Interface_Name
(Internal_Ent
)) then
3838 S1
: constant String_Id
:= Strval
(Old_Name
);
3839 S2
: constant String_Id
:= Strval
(New_Name
);
3842 -- Called if names do not match
3844 procedure Mismatch
is
3846 Error_Msg_Sloc
:= Sloc
(Old_Name
);
3848 ("external name does not match that given #",
3853 if String_Length
(S1
) /= String_Length
(S2
) then
3857 for J
in 1 .. String_Length
(S1
) loop
3858 if Get_String_Char
(S1
, J
) /= Get_String_Char
(S2
, J
) then
3865 -- Otherwise set the given name
3868 Set_Encoded_Interface_Name
(Internal_Ent
, New_Name
);
3869 Check_Duplicated_Export_Name
(New_Name
);
3871 end Set_Extended_Import_Export_External_Name
;
3877 procedure Set_Imported
(E
: Entity_Id
) is
3879 Error_Msg_Sloc
:= Sloc
(E
);
3881 if Is_Exported
(E
) or else Is_Imported
(E
) then
3882 Error_Msg_NE
("import of& declared# not allowed", N
, E
);
3884 if Is_Exported
(E
) then
3885 Error_Msg_N
("\entity was previously exported", N
);
3887 Error_Msg_N
("\entity was previously imported", N
);
3890 Error_Pragma
("\(pragma% applies to all previous entities)");
3893 Set_Is_Imported
(E
);
3895 -- If the entity is an object that is not at the library
3896 -- level, then it is statically allocated. We do not worry
3897 -- about objects with address clauses in this context since
3898 -- they are not really imported in the linker sense.
3901 and then not Is_Library_Level_Entity
(E
)
3902 and then No
(Address_Clause
(E
))
3904 Set_Is_Statically_Allocated
(E
);
3909 -------------------------
3910 -- Set_Mechanism_Value --
3911 -------------------------
3913 -- Note: the mechanism name has not been analyzed (and cannot indeed
3914 -- be analyzed, since it is semantic nonsense), so we get it in the
3915 -- exact form created by the parser.
3917 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
) is
3921 procedure Bad_Class
;
3922 -- Signal bad descriptor class name
3924 procedure Bad_Mechanism
;
3925 -- Signal bad mechanism name
3927 procedure Bad_Class
is
3929 Error_Pragma_Arg
("unrecognized descriptor class name", Class
);
3932 procedure Bad_Mechanism
is
3934 Error_Pragma_Arg
("unrecognized mechanism name", Mech_Name
);
3937 -- Start of processing for Set_Mechanism_Value
3940 if Mechanism
(Ent
) /= Default_Mechanism
then
3942 ("mechanism for & has already been set", Mech_Name
, Ent
);
3945 -- MECHANISM_NAME ::= value | reference | descriptor
3947 if Nkind
(Mech_Name
) = N_Identifier
then
3948 if Chars
(Mech_Name
) = Name_Value
then
3949 Set_Mechanism
(Ent
, By_Copy
);
3952 elsif Chars
(Mech_Name
) = Name_Reference
then
3953 Set_Mechanism
(Ent
, By_Reference
);
3956 elsif Chars
(Mech_Name
) = Name_Descriptor
then
3957 Check_VMS
(Mech_Name
);
3958 Set_Mechanism
(Ent
, By_Descriptor
);
3961 elsif Chars
(Mech_Name
) = Name_Copy
then
3963 ("bad mechanism name, Value assumed", Mech_Name
);
3969 -- MECHANISM_NAME ::= descriptor (CLASS_NAME)
3970 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3972 -- Note: this form is parsed as an indexed component
3974 elsif Nkind
(Mech_Name
) = N_Indexed_Component
then
3975 Class
:= First
(Expressions
(Mech_Name
));
3977 if Nkind
(Prefix
(Mech_Name
)) /= N_Identifier
3978 or else Chars
(Prefix
(Mech_Name
)) /= Name_Descriptor
3979 or else Present
(Next
(Class
))
3984 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME)
3985 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3987 -- Note: this form is parsed as a function call
3989 elsif Nkind
(Mech_Name
) = N_Function_Call
then
3991 Param
:= First
(Parameter_Associations
(Mech_Name
));
3993 if Nkind
(Name
(Mech_Name
)) /= N_Identifier
3994 or else Chars
(Name
(Mech_Name
)) /= Name_Descriptor
3995 or else Present
(Next
(Param
))
3996 or else No
(Selector_Name
(Param
))
3997 or else Chars
(Selector_Name
(Param
)) /= Name_Class
4001 Class
:= Explicit_Actual_Parameter
(Param
);
4008 -- Fall through here with Class set to descriptor class name
4010 Check_VMS
(Mech_Name
);
4012 if Nkind
(Class
) /= N_Identifier
then
4015 elsif Chars
(Class
) = Name_UBS
then
4016 Set_Mechanism
(Ent
, By_Descriptor_UBS
);
4018 elsif Chars
(Class
) = Name_UBSB
then
4019 Set_Mechanism
(Ent
, By_Descriptor_UBSB
);
4021 elsif Chars
(Class
) = Name_UBA
then
4022 Set_Mechanism
(Ent
, By_Descriptor_UBA
);
4024 elsif Chars
(Class
) = Name_S
then
4025 Set_Mechanism
(Ent
, By_Descriptor_S
);
4027 elsif Chars
(Class
) = Name_SB
then
4028 Set_Mechanism
(Ent
, By_Descriptor_SB
);
4030 elsif Chars
(Class
) = Name_A
then
4031 Set_Mechanism
(Ent
, By_Descriptor_A
);
4033 elsif Chars
(Class
) = Name_NCA
then
4034 Set_Mechanism
(Ent
, By_Descriptor_NCA
);
4040 end Set_Mechanism_Value
;
4042 ---------------------------
4043 -- Set_Ravenscar_Profile --
4044 ---------------------------
4046 -- The tasks to be done here are
4048 -- Set required policies
4050 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4051 -- pragma Locking_Policy (Ceiling_Locking)
4053 -- Set Detect_Blocking mode
4055 -- Set required restrictions (see System.Rident for detailed list)
4057 procedure Set_Ravenscar_Profile
(N
: Node_Id
) is
4059 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4061 if Task_Dispatching_Policy
/= ' '
4062 and then Task_Dispatching_Policy
/= 'F'
4064 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
4065 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4067 -- Set the FIFO_Within_Priorities policy, but always
4068 -- preserve System_Location since we like the error
4069 -- message with the run time name.
4072 Task_Dispatching_Policy
:= 'F';
4074 if Task_Dispatching_Policy_Sloc
/= System_Location
then
4075 Task_Dispatching_Policy_Sloc
:= Loc
;
4079 -- pragma Locking_Policy (Ceiling_Locking)
4081 if Locking_Policy
/= ' '
4082 and then Locking_Policy
/= 'C'
4084 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
4085 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4087 -- Set the Ceiling_Locking policy, but always preserve
4088 -- System_Location since we like the error message with the
4092 Locking_Policy
:= 'C';
4094 if Locking_Policy_Sloc
/= System_Location
then
4095 Locking_Policy_Sloc
:= Loc
;
4099 -- pragma Detect_Blocking
4101 Detect_Blocking
:= True;
4103 -- Set the corresponding restrictions
4105 Set_Profile_Restrictions
(Ravenscar
, N
, Warn
=> False);
4106 end Set_Ravenscar_Profile
;
4108 -- Start of processing for Analyze_Pragma
4111 if not Is_Pragma_Name
(Chars
(N
)) then
4112 if Warn_On_Unrecognized_Pragma
then
4113 Error_Pragma
("unrecognized pragma%!?");
4118 Prag_Id
:= Get_Pragma_Id
(Chars
(N
));
4128 if Present
(Pragma_Argument_Associations
(N
)) then
4129 Arg1
:= First
(Pragma_Argument_Associations
(N
));
4131 if Present
(Arg1
) then
4132 Arg2
:= Next
(Arg1
);
4134 if Present
(Arg2
) then
4135 Arg3
:= Next
(Arg2
);
4137 if Present
(Arg3
) then
4138 Arg4
:= Next
(Arg3
);
4144 -- Count number of arguments
4151 while Present
(Arg_Node
) loop
4152 Arg_Count
:= Arg_Count
+ 1;
4157 -- An enumeration type defines the pragmas that are supported by the
4158 -- implementation. Get_Pragma_Id (in package Prag) transorms a name
4159 -- into the corresponding enumeration value for the following case.
4167 -- pragma Abort_Defer;
4169 when Pragma_Abort_Defer
=>
4171 Check_Arg_Count
(0);
4173 -- The only required semantic processing is to check the
4174 -- placement. This pragma must appear at the start of the
4175 -- statement sequence of a handled sequence of statements.
4177 if Nkind
(Parent
(N
)) /= N_Handled_Sequence_Of_Statements
4178 or else N
/= First
(Statements
(Parent
(N
)))
4189 -- Note: this pragma also has some specific processing in Par.Prag
4190 -- because we want to set the Ada version mode during parsing.
4192 when Pragma_Ada_83
=>
4194 Ada_Version
:= Ada_83
;
4195 Check_Arg_Count
(0);
4203 -- Note: this pragma also has some specific processing in Par.Prag
4204 -- because we want to set the Ada 83 version mode during parsing.
4206 when Pragma_Ada_95
=>
4208 Ada_Version
:= Ada_95
;
4209 Check_Arg_Count
(0);
4217 -- Note: this pragma also has some specific processing in Par.Prag
4218 -- because we want to set the Ada 83 version mode during parsing.
4220 when Pragma_Ada_05
=>
4222 Ada_Version
:= Ada_05
;
4223 Check_Arg_Count
(0);
4225 ----------------------
4226 -- All_Calls_Remote --
4227 ----------------------
4229 -- pragma All_Calls_Remote [(library_package_NAME)];
4231 when Pragma_All_Calls_Remote
=> All_Calls_Remote
: declare
4232 Lib_Entity
: Entity_Id
;
4235 Check_Ada_83_Warning
;
4236 Check_Valid_Library_Unit_Pragma
;
4238 if Nkind
(N
) = N_Null_Statement
then
4242 Lib_Entity
:= Find_Lib_Unit_Name
;
4244 -- This pragma should only apply to a RCI unit (RM E.2.3(23)).
4246 if Present
(Lib_Entity
)
4247 and then not Debug_Flag_U
4249 if not Is_Remote_Call_Interface
(Lib_Entity
) then
4250 Error_Pragma
("pragma% only apply to rci unit");
4252 -- Set flag for entity of the library unit
4255 Set_Has_All_Calls_Remote
(Lib_Entity
);
4259 end All_Calls_Remote
;
4265 -- pragma Annotate (IDENTIFIER {, ARG});
4266 -- ARG ::= NAME | EXPRESSION
4268 when Pragma_Annotate
=> Annotate
: begin
4270 Check_At_Least_N_Arguments
(1);
4271 Check_Arg_Is_Identifier
(Arg1
);
4274 Arg
: Node_Id
:= Arg2
;
4278 while Present
(Arg
) loop
4279 Exp
:= Expression
(Arg
);
4282 if Is_Entity_Name
(Exp
) then
4285 elsif Nkind
(Exp
) = N_String_Literal
then
4286 Resolve
(Exp
, Standard_String
);
4288 elsif Is_Overloaded
(Exp
) then
4289 Error_Pragma_Arg
("ambiguous argument for pragma%", Exp
);
4304 -- pragma Assert (Boolean_EXPRESSION [, static_string_EXPRESSION]);
4306 when Pragma_Assert
=>
4308 Check_No_Identifiers
;
4310 if Arg_Count
> 1 then
4311 Check_Arg_Count
(2);
4312 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
4315 -- If expansion is active and assertions are inactive, then
4316 -- we rewrite the Assertion as:
4318 -- if False and then condition then
4322 -- The reason we do this rewriting during semantic analysis
4323 -- rather than as part of normal expansion is that we cannot
4324 -- analyze and expand the code for the boolean expression
4325 -- directly, or it may cause insertion of actions that would
4326 -- escape the attempt to suppress the assertion code.
4328 if Expander_Active
and not Assertions_Enabled
then
4330 Make_If_Statement
(Loc
,
4333 Left_Opnd
=> New_Occurrence_Of
(Standard_False
, Loc
),
4334 Right_Opnd
=> Get_Pragma_Arg
(Arg1
)),
4335 Then_Statements
=> New_List
(
4336 Make_Null_Statement
(Loc
))));
4340 -- Otherwise (if assertions are enabled, or if we are not
4341 -- operating with expansion active), then we just analyze
4342 -- and resolve the expression.
4345 Analyze_And_Resolve
(Expression
(Arg1
), Any_Boolean
);
4352 -- pragma AST_Entry (entry_IDENTIFIER);
4354 when Pragma_AST_Entry
=> AST_Entry
: declare
4360 Check_Arg_Count
(1);
4361 Check_No_Identifiers
;
4362 Check_Arg_Is_Local_Name
(Arg1
);
4363 Ent
:= Entity
(Expression
(Arg1
));
4365 -- Note: the implementation of the AST_Entry pragma could handle
4366 -- the entry family case fine, but for now we are consistent with
4367 -- the DEC rules, and do not allow the pragma, which of course
4368 -- has the effect of also forbidding the attribute.
4370 if Ekind
(Ent
) /= E_Entry
then
4372 ("pragma% argument must be simple entry name", Arg1
);
4374 elsif Is_AST_Entry
(Ent
) then
4376 ("duplicate % pragma for entry", Arg1
);
4378 elsif Has_Homonym
(Ent
) then
4380 ("pragma% argument cannot specify overloaded entry", Arg1
);
4384 FF
: constant Entity_Id
:= First_Formal
(Ent
);
4387 if Present
(FF
) then
4388 if Present
(Next_Formal
(FF
)) then
4390 ("entry for pragma% can have only one argument",
4393 elsif Parameter_Mode
(FF
) /= E_In_Parameter
then
4395 ("entry parameter for pragma% must have mode IN",
4401 Set_Is_AST_Entry
(Ent
);
4409 -- pragma Asynchronous (LOCAL_NAME);
4411 when Pragma_Asynchronous
=> Asynchronous
: declare
4419 procedure Process_Async_Pragma
;
4420 -- Common processing for procedure and access-to-procedure case
4422 --------------------------
4423 -- Process_Async_Pragma --
4424 --------------------------
4426 procedure Process_Async_Pragma
is
4428 if not Present
(L
) then
4429 Set_Is_Asynchronous
(Nm
);
4433 -- The formals should be of mode IN (RM E.4.1(6))
4436 while Present
(S
) loop
4437 Formal
:= Defining_Identifier
(S
);
4439 if Nkind
(Formal
) = N_Defining_Identifier
4440 and then Ekind
(Formal
) /= E_In_Parameter
4443 ("pragma% procedure can only have IN parameter",
4450 Set_Is_Asynchronous
(Nm
);
4451 end Process_Async_Pragma
;
4453 -- Start of processing for pragma Asynchronous
4456 Check_Ada_83_Warning
;
4457 Check_No_Identifiers
;
4458 Check_Arg_Count
(1);
4459 Check_Arg_Is_Local_Name
(Arg1
);
4461 if Debug_Flag_U
then
4465 C_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
4466 Analyze
(Expression
(Arg1
));
4467 Nm
:= Entity
(Expression
(Arg1
));
4469 if not Is_Remote_Call_Interface
(C_Ent
)
4470 and then not Is_Remote_Types
(C_Ent
)
4472 -- This pragma should only appear in an RCI or Remote Types
4473 -- unit (RM E.4.1(4))
4476 ("pragma% not in Remote_Call_Interface or " &
4477 "Remote_Types unit");
4480 if Ekind
(Nm
) = E_Procedure
4481 and then Nkind
(Parent
(Nm
)) = N_Procedure_Specification
4483 if not Is_Remote_Call_Interface
(Nm
) then
4485 ("pragma% cannot be applied on non-remote procedure",
4489 L
:= Parameter_Specifications
(Parent
(Nm
));
4490 Process_Async_Pragma
;
4493 elsif Ekind
(Nm
) = E_Function
then
4495 ("pragma% cannot be applied to function", Arg1
);
4497 elsif Ekind
(Nm
) = E_Record_Type
4498 and then Present
(Corresponding_Remote_Type
(Nm
))
4500 -- A record type that is the Equivalent_Type for
4501 -- a remote access-to-subprogram type.
4503 N
:= Declaration_Node
(Corresponding_Remote_Type
(Nm
));
4505 if Nkind
(N
) = N_Full_Type_Declaration
4506 and then Nkind
(Type_Definition
(N
)) =
4507 N_Access_Procedure_Definition
4509 L
:= Parameter_Specifications
(Type_Definition
(N
));
4510 Process_Async_Pragma
;
4512 if Is_Asynchronous
(Nm
)
4513 and then Expander_Active
4515 RACW_Type_Is_Asynchronous
(
4516 Underlying_RACW_Type
(Nm
));
4521 ("pragma% cannot reference access-to-function type",
4525 -- Only other possibility is Access-to-class-wide type
4527 elsif Is_Access_Type
(Nm
)
4528 and then Is_Class_Wide_Type
(Designated_Type
(Nm
))
4530 Check_First_Subtype
(Arg1
);
4531 Set_Is_Asynchronous
(Nm
);
4532 if Expander_Active
then
4533 RACW_Type_Is_Asynchronous
(Nm
);
4537 Error_Pragma_Arg
("inappropriate argument for pragma%", Arg1
);
4545 -- pragma Atomic (LOCAL_NAME);
4547 when Pragma_Atomic
=>
4548 Process_Atomic_Shared_Volatile
;
4550 -----------------------
4551 -- Atomic_Components --
4552 -----------------------
4554 -- pragma Atomic_Components (array_LOCAL_NAME);
4556 -- This processing is shared by Volatile_Components
4558 when Pragma_Atomic_Components |
4559 Pragma_Volatile_Components
=>
4561 Atomic_Components
: declare
4568 Check_Ada_83_Warning
;
4569 Check_No_Identifiers
;
4570 Check_Arg_Count
(1);
4571 Check_Arg_Is_Local_Name
(Arg1
);
4572 E_Id
:= Expression
(Arg1
);
4574 if Etype
(E_Id
) = Any_Type
then
4580 if Rep_Item_Too_Early
(E
, N
)
4582 Rep_Item_Too_Late
(E
, N
)
4587 D
:= Declaration_Node
(E
);
4590 if (K
= N_Full_Type_Declaration
and then Is_Array_Type
(E
))
4592 ((Ekind
(E
) = E_Constant
or else Ekind
(E
) = E_Variable
)
4593 and then Nkind
(D
) = N_Object_Declaration
4594 and then Nkind
(Object_Definition
(D
)) =
4595 N_Constrained_Array_Definition
)
4597 -- The flag is set on the object, or on the base type
4599 if Nkind
(D
) /= N_Object_Declaration
then
4603 Set_Has_Volatile_Components
(E
);
4605 if Prag_Id
= Pragma_Atomic_Components
then
4606 Set_Has_Atomic_Components
(E
);
4608 if Is_Packed
(E
) then
4609 Set_Is_Packed
(E
, False);
4612 ("?Pack canceled, cannot pack atomic components",
4618 Error_Pragma_Arg
("inappropriate entity for pragma%", Arg1
);
4620 end Atomic_Components
;
4622 --------------------
4623 -- Attach_Handler --
4624 --------------------
4626 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
4628 when Pragma_Attach_Handler
=>
4629 Check_Ada_83_Warning
;
4630 Check_No_Identifiers
;
4631 Check_Arg_Count
(2);
4633 if No_Run_Time_Mode
then
4634 Error_Msg_CRT
("Attach_Handler pragma", N
);
4636 Check_Interrupt_Or_Attach_Handler
;
4638 -- The expression that designates the attribute may
4639 -- depend on a discriminant, and is therefore a per-
4640 -- object expression, to be expanded in the init proc.
4641 -- If expansion is enabled, perform semantic checks
4644 if Expander_Active
then
4646 Temp
: constant Node_Id
:=
4647 New_Copy_Tree
(Expression
(Arg2
));
4649 Set_Parent
(Temp
, N
);
4650 Pre_Analyze_And_Resolve
(Temp
, RTE
(RE_Interrupt_ID
));
4654 Analyze
(Expression
(Arg2
));
4655 Resolve
(Expression
(Arg2
), RTE
(RE_Interrupt_ID
));
4658 Process_Interrupt_Or_Attach_Handler
;
4661 --------------------
4662 -- C_Pass_By_Copy --
4663 --------------------
4665 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
4667 when Pragma_C_Pass_By_Copy
=> C_Pass_By_Copy
: declare
4673 Check_Valid_Configuration_Pragma
;
4674 Check_Arg_Count
(1);
4675 Check_Optional_Identifier
(Arg1
, "max_size");
4677 Arg
:= Expression
(Arg1
);
4678 Check_Arg_Is_Static_Expression
(Arg
, Any_Integer
);
4680 Val
:= Expr_Value
(Arg
);
4684 ("maximum size for pragma% must be positive", Arg1
);
4686 elsif UI_Is_In_Int_Range
(Val
) then
4687 Default_C_Record_Mechanism
:= UI_To_Int
(Val
);
4689 -- If a giant value is given, Int'Last will do well enough.
4690 -- If sometime someone complains that a record larger than
4691 -- two gigabytes is not copied, we will worry about it then!
4694 Default_C_Record_Mechanism
:= Mechanism_Type
'Last;
4702 -- pragma Comment (static_string_EXPRESSION)
4704 -- Processing for pragma Comment shares the circuitry for
4705 -- pragma Ident. The only differences are that Ident enforces
4706 -- a limit of 31 characters on its argument, and also enforces
4707 -- limitations on placement for DEC compatibility. Pragma
4708 -- Comment shares neither of these restrictions.
4714 -- pragma Common_Object (
4715 -- [Internal =>] LOCAL_NAME,
4716 -- [, [External =>] EXTERNAL_SYMBOL]
4717 -- [, [Size =>] EXTERNAL_SYMBOL]);
4719 -- Processing for this pragma is shared with Psect_Object
4721 --------------------------
4722 -- Compile_Time_Warning --
4723 --------------------------
4725 -- pragma Compile_Time_Warning
4726 -- (boolean_EXPRESSION, static_string_EXPRESSION);
4728 when Pragma_Compile_Time_Warning
=> Compile_Time_Warning
: declare
4729 Arg1x
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
4733 Check_Arg_Count
(2);
4734 Check_No_Identifiers
;
4735 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
4736 Analyze_And_Resolve
(Arg1x
, Standard_Boolean
);
4738 if Compile_Time_Known_Value
(Arg1x
) then
4739 if Is_True
(Expr_Value
(Get_Pragma_Arg
(Arg1
))) then
4740 String_To_Name_Buffer
(Strval
(Get_Pragma_Arg
(Arg2
)));
4741 Add_Char_To_Name_Buffer
('?');
4744 Msg
: String (1 .. Name_Len
) :=
4745 Name_Buffer
(1 .. Name_Len
);
4750 -- This loop looks for multiple lines separated by
4751 -- ASCII.LF and breaks them into continuation error
4752 -- messages marked with the usual back slash.
4755 for S
in 2 .. Msg
'Length - 1 loop
4756 if Msg
(S
) = ASCII
.LF
then
4758 Error_Msg_N
(Msg
(B
.. S
), Arg1
);
4764 Error_Msg_N
(Msg
(B
.. Msg
'Length), Arg1
);
4768 end Compile_Time_Warning
;
4770 ----------------------------
4771 -- Complex_Representation --
4772 ----------------------------
4774 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
4776 when Pragma_Complex_Representation
=> Complex_Representation
: declare
4783 Check_Arg_Count
(1);
4784 Check_Optional_Identifier
(Arg1
, Name_Entity
);
4785 Check_Arg_Is_Local_Name
(Arg1
);
4786 E_Id
:= Expression
(Arg1
);
4788 if Etype
(E_Id
) = Any_Type
then
4794 if not Is_Record_Type
(E
) then
4796 ("argument for pragma% must be record type", Arg1
);
4799 Ent
:= First_Entity
(E
);
4802 or else No
(Next_Entity
(Ent
))
4803 or else Present
(Next_Entity
(Next_Entity
(Ent
)))
4804 or else not Is_Floating_Point_Type
(Etype
(Ent
))
4805 or else Etype
(Ent
) /= Etype
(Next_Entity
(Ent
))
4808 ("record for pragma% must have two fields of same fpt type",
4812 Set_Has_Complex_Representation
(Base_Type
(E
));
4814 end Complex_Representation
;
4816 -------------------------
4817 -- Component_Alignment --
4818 -------------------------
4820 -- pragma Component_Alignment (
4821 -- [Form =>] ALIGNMENT_CHOICE
4822 -- [, [Name =>] type_LOCAL_NAME]);
4824 -- ALIGNMENT_CHOICE ::=
4826 -- | Component_Size_4
4830 when Pragma_Component_Alignment
=> Component_AlignmentP
: declare
4831 Args
: Args_List
(1 .. 2);
4832 Names
: constant Name_List
(1 .. 2) := (
4836 Form
: Node_Id
renames Args
(1);
4837 Name
: Node_Id
renames Args
(2);
4839 Atype
: Component_Alignment_Kind
;
4844 Gather_Associations
(Names
, Args
);
4847 Error_Pragma
("missing Form argument for pragma%");
4850 Check_Arg_Is_Identifier
(Form
);
4852 -- Get proper alignment, note that Default = Component_Size
4853 -- on all machines we have so far, and we want to set this
4854 -- value rather than the default value to indicate that it
4855 -- has been explicitly set (and thus will not get overridden
4856 -- by the default component alignment for the current scope)
4858 if Chars
(Form
) = Name_Component_Size
then
4859 Atype
:= Calign_Component_Size
;
4861 elsif Chars
(Form
) = Name_Component_Size_4
then
4862 Atype
:= Calign_Component_Size_4
;
4864 elsif Chars
(Form
) = Name_Default
then
4865 Atype
:= Calign_Component_Size
;
4867 elsif Chars
(Form
) = Name_Storage_Unit
then
4868 Atype
:= Calign_Storage_Unit
;
4872 ("invalid Form parameter for pragma%", Form
);
4875 -- Case with no name, supplied, affects scope table entry
4879 (Scope_Stack
.Last
).Component_Alignment_Default
:= Atype
;
4881 -- Case of name supplied
4884 Check_Arg_Is_Local_Name
(Name
);
4886 Typ
:= Entity
(Name
);
4889 or else Rep_Item_Too_Early
(Typ
, N
)
4893 Typ
:= Underlying_Type
(Typ
);
4896 if not Is_Record_Type
(Typ
)
4897 and then not Is_Array_Type
(Typ
)
4900 ("Name parameter of pragma% must identify record or " &
4901 "array type", Name
);
4904 -- An explicit Component_Alignment pragma overrides an
4905 -- implicit pragma Pack, but not an explicit one.
4907 if not Has_Pragma_Pack
(Base_Type
(Typ
)) then
4908 Set_Is_Packed
(Base_Type
(Typ
), False);
4909 Set_Component_Alignment
(Base_Type
(Typ
), Atype
);
4912 end Component_AlignmentP
;
4918 -- pragma Controlled (first_subtype_LOCAL_NAME);
4920 when Pragma_Controlled
=> Controlled
: declare
4924 Check_No_Identifiers
;
4925 Check_Arg_Count
(1);
4926 Check_Arg_Is_Local_Name
(Arg1
);
4927 Arg
:= Expression
(Arg1
);
4929 if not Is_Entity_Name
(Arg
)
4930 or else not Is_Access_Type
(Entity
(Arg
))
4932 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
4934 Set_Has_Pragma_Controlled
(Base_Type
(Entity
(Arg
)));
4942 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
4943 -- [Entity =>] LOCAL_NAME);
4945 when Pragma_Convention
=> Convention
: declare
4949 Check_Ada_83_Warning
;
4950 Check_Arg_Count
(2);
4951 Process_Convention
(C
, E
);
4954 ---------------------------
4955 -- Convention_Identifier --
4956 ---------------------------
4958 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
4959 -- [Convention =>] convention_IDENTIFIER);
4961 when Pragma_Convention_Identifier
=> Convention_Identifier
: declare
4967 Check_Arg_Count
(2);
4968 Check_Optional_Identifier
(Arg1
, Name_Name
);
4969 Check_Optional_Identifier
(Arg2
, Name_Convention
);
4970 Check_Arg_Is_Identifier
(Arg1
);
4971 Check_Arg_Is_Identifier
(Arg1
);
4972 Idnam
:= Chars
(Expression
(Arg1
));
4973 Cname
:= Chars
(Expression
(Arg2
));
4975 if Is_Convention_Name
(Cname
) then
4976 Record_Convention_Identifier
4977 (Idnam
, Get_Convention_Id
(Cname
));
4980 ("second arg for % pragma must be convention", Arg2
);
4982 end Convention_Identifier
;
4988 -- pragma CPP_Class ([Entity =>] local_NAME)
4990 when Pragma_CPP_Class
=> CPP_Class
: declare
4993 Default_DTC
: Entity_Id
:= Empty
;
4994 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
5000 Check_Arg_Count
(1);
5001 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5002 Check_Arg_Is_Local_Name
(Arg1
);
5004 Arg
:= Expression
(Arg1
);
5007 if Etype
(Arg
) = Any_Type
then
5011 if not Is_Entity_Name
(Arg
)
5012 or else not Is_Type
(Entity
(Arg
))
5014 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
5017 Typ
:= Entity
(Arg
);
5019 if not Is_Record_Type
(Typ
) then
5020 Error_Pragma_Arg
("pragma% applicable to a record, "
5021 & "tagged record or record extension", Arg1
);
5024 Default_DTC
:= First_Component
(Typ
);
5025 while Present
(Default_DTC
)
5026 and then Etype
(Default_DTC
) /= VTP_Type
5028 Next_Component
(Default_DTC
);
5031 -- Case of non tagged type
5033 if not Is_Tagged_Type
(Typ
) then
5034 Set_Is_CPP_Class
(Typ
);
5036 if Present
(Default_DTC
) then
5038 ("only tagged records can contain vtable pointers", Arg1
);
5041 -- Case of tagged type with no vtable ptr
5043 -- What is test for Typ = Root_Typ (Typ) about here ???
5045 elsif Is_Tagged_Type
(Typ
)
5046 and then Typ
= Root_Type
(Typ
)
5047 and then No
(Default_DTC
)
5050 ("a cpp_class must contain a vtable pointer", Arg1
);
5052 -- Tagged type that has a vtable ptr
5054 elsif Present
(Default_DTC
) then
5055 Set_Is_CPP_Class
(Typ
);
5056 Set_Is_Limited_Record
(Typ
);
5057 Set_Is_Tag
(Default_DTC
);
5058 Set_DT_Entry_Count
(Default_DTC
, No_Uint
);
5060 -- Since a CPP type has no direct link to its associated tag
5061 -- most tags checks cannot be performed
5063 Set_Kill_Tag_Checks
(Typ
);
5064 Set_Kill_Tag_Checks
(Class_Wide_Type
(Typ
));
5066 -- Get rid of the _tag component when there was one.
5067 -- It is only useful for regular tagged types
5069 if Expander_Active
and then Typ
= Root_Type
(Typ
) then
5071 Tag_C
:= Tag_Component
(Typ
);
5072 C
:= First_Entity
(Typ
);
5075 Set_First_Entity
(Typ
, Next_Entity
(Tag_C
));
5078 while Next_Entity
(C
) /= Tag_C
loop
5082 Set_Next_Entity
(C
, Next_Entity
(Tag_C
));
5088 ---------------------
5089 -- CPP_Constructor --
5090 ---------------------
5092 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
5094 when Pragma_CPP_Constructor
=> CPP_Constructor
: declare
5100 Check_Arg_Count
(1);
5101 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5102 Check_Arg_Is_Local_Name
(Arg1
);
5104 Id
:= Expression
(Arg1
);
5105 Find_Program_Unit_Name
(Id
);
5107 -- If we did not find the name, we are done
5109 if Etype
(Id
) = Any_Type
then
5113 Def_Id
:= Entity
(Id
);
5115 if Ekind
(Def_Id
) = E_Function
5116 and then Is_Class_Wide_Type
(Etype
(Def_Id
))
5117 and then Is_CPP_Class
(Etype
(Etype
(Def_Id
)))
5119 -- What the heck is this??? this pragma allows only 1 arg
5121 if Arg_Count
>= 2 then
5122 Check_At_Most_N_Arguments
(3);
5123 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
5126 if No
(Parameter_Specifications
(Parent
(Def_Id
))) then
5127 Set_Has_Completion
(Def_Id
);
5128 Set_Is_Constructor
(Def_Id
);
5131 ("non-default constructors not implemented", Arg1
);
5136 ("pragma% requires function returning a 'C'P'P_Class type",
5139 end CPP_Constructor
;
5145 -- pragma CPP_Virtual
5146 -- [Entity =>] LOCAL_NAME
5147 -- [ [Vtable_Ptr =>] LOCAL_NAME,
5148 -- [Position =>] static_integer_EXPRESSION]);
5150 when Pragma_CPP_Virtual
=> CPP_Virtual
: declare
5154 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
5161 if Arg_Count
= 3 then
5162 Check_Optional_Identifier
(Arg2
, "vtable_ptr");
5164 -- We allow Entry_Count as well as Position for the third
5165 -- parameter for back compatibility with versions of GNAT
5166 -- before version 3.12. The documentation has always said
5167 -- Position, but the code up to 3.12 said Entry_Count.
5169 if Chars
(Arg3
) /= Name_Position
then
5170 Check_Optional_Identifier
(Arg3
, "entry_count");
5174 Check_Arg_Count
(1);
5177 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5178 Check_Arg_Is_Local_Name
(Arg1
);
5180 -- First argument must be a subprogram name
5182 Arg
:= Expression
(Arg1
);
5183 Find_Program_Unit_Name
(Arg
);
5185 if Etype
(Arg
) = Any_Type
then
5188 Subp
:= Entity
(Arg
);
5191 if not (Is_Subprogram
(Subp
)
5192 and then Is_Dispatching_Operation
(Subp
))
5195 ("pragma% must reference a primitive operation", Arg1
);
5198 Typ
:= Find_Dispatching_Type
(Subp
);
5200 -- If only one Argument defaults are :
5201 -- . DTC_Entity is the default Vtable pointer
5202 -- . DT_Position will be set at the freezing point
5204 if Arg_Count
= 1 then
5205 Set_DTC_Entity
(Subp
, Tag_Component
(Typ
));
5209 -- Second argument is a component name of type Vtable_Ptr
5211 Arg
:= Expression
(Arg2
);
5213 if Nkind
(Arg
) /= N_Identifier
then
5214 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5218 DTC
:= First_Component
(Typ
);
5219 while Present
(DTC
) and then Chars
(DTC
) /= Chars
(Arg
) loop
5220 Next_Component
(DTC
);
5224 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5227 elsif Etype
(DTC
) /= VTP_Type
then
5228 Wrong_Type
(Arg
, VTP_Type
);
5232 -- Third argument is an integer (DT_Position)
5234 Arg
:= Expression
(Arg3
);
5235 Analyze_And_Resolve
(Arg
, Any_Integer
);
5237 if not Is_Static_Expression
(Arg
) then
5238 Flag_Non_Static_Expr
5239 ("third argument of pragma CPP_Virtual must be static!",
5244 V
:= Expr_Value
(Expression
(Arg3
));
5248 ("third argument of pragma% must be positive",
5252 Set_DTC_Entity
(Subp
, DTC
);
5253 Set_DT_Position
(Subp
, V
);
5262 -- pragma CPP_Vtable (
5263 -- [Entity =>] LOCAL_NAME
5264 -- [Vtable_Ptr =>] LOCAL_NAME,
5265 -- [Entry_Count =>] static_integer_EXPRESSION);
5267 when Pragma_CPP_Vtable
=> CPP_Vtable
: declare
5270 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
5277 Check_Arg_Count
(3);
5278 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5279 Check_Optional_Identifier
(Arg2
, "vtable_ptr");
5280 Check_Optional_Identifier
(Arg3
, "entry_count");
5281 Check_Arg_Is_Local_Name
(Arg1
);
5283 -- First argument is a record type name
5285 Arg
:= Expression
(Arg1
);
5288 if Etype
(Arg
) = Any_Type
then
5291 Typ
:= Entity
(Arg
);
5294 if not (Is_Tagged_Type
(Typ
) and then Is_CPP_Class
(Typ
)) then
5295 Error_Pragma_Arg
("'C'P'P_Class tagged type expected", Arg1
);
5298 -- Second argument is a component name of type Vtable_Ptr
5300 Arg
:= Expression
(Arg2
);
5302 if Nkind
(Arg
) /= N_Identifier
then
5303 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5307 DTC
:= First_Component
(Typ
);
5308 while Present
(DTC
) and then Chars
(DTC
) /= Chars
(Arg
) loop
5309 Next_Component
(DTC
);
5313 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5316 elsif Etype
(DTC
) /= VTP_Type
then
5317 Wrong_Type
(DTC
, VTP_Type
);
5320 -- If it is the first pragma Vtable, This becomes the default tag
5322 elsif (not Is_Tag
(DTC
))
5323 and then DT_Entry_Count
(Tag_Component
(Typ
)) = No_Uint
5325 Set_Is_Tag
(Tag_Component
(Typ
), False);
5326 Set_Is_Tag
(DTC
, True);
5327 Set_DT_Entry_Count
(DTC
, No_Uint
);
5330 -- Those pragmas must appear before any primitive operation
5331 -- definition (except inherited ones) otherwise the default
5334 Elmt
:= First_Elmt
(Primitive_Operations
(Typ
));
5335 while Present
(Elmt
) loop
5336 if No
(Alias
(Node
(Elmt
))) then
5337 Error_Msg_Sloc
:= Sloc
(Node
(Elmt
));
5339 ("pragma% must appear before this primitive operation");
5345 -- Third argument is an integer (DT_Entry_Count)
5347 Arg
:= Expression
(Arg3
);
5348 Analyze_And_Resolve
(Arg
, Any_Integer
);
5350 if not Is_Static_Expression
(Arg
) then
5351 Flag_Non_Static_Expr
5352 ("entry count for pragma CPP_Vtable must be a static " &
5353 "expression!", Arg3
);
5357 V
:= Expr_Value
(Expression
(Arg3
));
5361 ("entry count for pragma% must be positive", Arg3
);
5363 Set_DT_Entry_Count
(DTC
, V
);
5372 -- pragma Debug (PROCEDURE_CALL_STATEMENT);
5374 when Pragma_Debug
=> Debug
: begin
5377 -- Rewrite into a conditional with a static condition
5379 Rewrite
(N
, Make_Implicit_If_Statement
(N
,
5380 Condition
=> New_Occurrence_Of
(Boolean_Literals
(
5381 Assertions_Enabled
and Expander_Active
), Loc
),
5382 Then_Statements
=> New_List
(
5383 Relocate_Node
(Debug_Statement
(N
)))));
5387 ---------------------
5388 -- Detect_Blocking --
5389 ---------------------
5391 -- pragma Detect_Blocking;
5393 when Pragma_Detect_Blocking
=>
5395 Check_Arg_Count
(0);
5396 Check_Valid_Configuration_Pragma
;
5397 Detect_Blocking
:= True;
5403 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
5405 when Pragma_Discard_Names
=> Discard_Names
: declare
5410 Check_Ada_83_Warning
;
5412 -- Deal with configuration pragma case
5414 if Arg_Count
= 0 and then Is_Configuration_Pragma
then
5415 Global_Discard_Names
:= True;
5418 -- Otherwise, check correct appropriate context
5421 Check_Is_In_Decl_Part_Or_Package_Spec
;
5423 if Arg_Count
= 0 then
5425 -- If there is no parameter, then from now on this pragma
5426 -- applies to any enumeration, exception or tagged type
5427 -- defined in the current declarative part.
5429 Set_Discard_Names
(Current_Scope
);
5433 Check_Arg_Count
(1);
5434 Check_Optional_Identifier
(Arg1
, Name_On
);
5435 Check_Arg_Is_Local_Name
(Arg1
);
5436 E_Id
:= Expression
(Arg1
);
5438 if Etype
(E_Id
) = Any_Type
then
5444 if (Is_First_Subtype
(E
)
5445 and then (Is_Enumeration_Type
(E
)
5446 or else Is_Tagged_Type
(E
)))
5447 or else Ekind
(E
) = E_Exception
5449 Set_Discard_Names
(E
);
5452 ("inappropriate entity for pragma%", Arg1
);
5462 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
5464 when Pragma_Elaborate
=> Elaborate
: declare
5466 Parent_Node
: Node_Id
;
5471 -- Pragma must be in context items list of a compilation unit
5473 if not Is_List_Member
(N
) then
5478 Plist
:= List_Containing
(N
);
5479 Parent_Node
:= Parent
(Plist
);
5481 if Parent_Node
= Empty
5482 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
5483 or else Context_Items
(Parent_Node
) /= Plist
5490 -- Must be at least one argument
5492 if Arg_Count
= 0 then
5493 Error_Pragma
("pragma% requires at least one argument");
5496 -- In Ada 83 mode, there can be no items following it in the
5497 -- context list except other pragmas and implicit with clauses
5498 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
5499 -- placement rule does not apply.
5501 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
5504 while Present
(Citem
) loop
5505 if Nkind
(Citem
) = N_Pragma
5506 or else (Nkind
(Citem
) = N_With_Clause
5507 and then Implicit_With
(Citem
))
5512 ("(Ada 83) pragma% must be at end of context clause");
5519 -- Finally, the arguments must all be units mentioned in a with
5520 -- clause in the same context clause. Note we already checked
5521 -- (in Par.Prag) that the arguments are either identifiers or
5524 Outer
: while Present
(Arg
) loop
5525 Citem
:= First
(Plist
);
5527 Inner
: while Citem
/= N
loop
5528 if Nkind
(Citem
) = N_With_Clause
5529 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
5531 Set_Elaborate_Present
(Citem
, True);
5532 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
5533 Set_Suppress_Elaboration_Warnings
(Entity
(Name
(Citem
)));
5542 ("argument of pragma% is not with'ed unit", Arg
);
5548 -- Give a warning if operating in static mode with -gnatwl
5549 -- (elaboration warnings eanbled) switch set.
5551 if Elab_Warnings
and not Dynamic_Elaboration_Checks
then
5553 ("?use of pragma Elaborate may not be safe", N
);
5555 ("?use pragma Elaborate_All instead if possible", N
);
5563 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
5565 when Pragma_Elaborate_All
=> Elaborate_All
: declare
5567 Parent_Node
: Node_Id
;
5572 Check_Ada_83_Warning
;
5574 -- Pragma must be in context items list of a compilation unit
5576 if not Is_List_Member
(N
) then
5581 Plist
:= List_Containing
(N
);
5582 Parent_Node
:= Parent
(Plist
);
5584 if Parent_Node
= Empty
5585 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
5586 or else Context_Items
(Parent_Node
) /= Plist
5593 -- Must be at least one argument
5595 if Arg_Count
= 0 then
5596 Error_Pragma
("pragma% requires at least one argument");
5599 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
5600 -- have to appear at the end of the context clause, but may
5601 -- appear mixed in with other items, even in Ada 83 mode.
5603 -- Final check: the arguments must all be units mentioned in
5604 -- a with clause in the same context clause. Note that we
5605 -- already checked (in Par.Prag) that all the arguments are
5606 -- either identifiers or selected components.
5609 Outr
: while Present
(Arg
) loop
5610 Citem
:= First
(Plist
);
5612 Innr
: while Citem
/= N
loop
5613 if Nkind
(Citem
) = N_With_Clause
5614 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
5616 Set_Elaborate_All_Present
(Citem
, True);
5617 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
5618 Set_Suppress_Elaboration_Warnings
(Entity
(Name
(Citem
)));
5626 Set_Error_Posted
(N
);
5628 ("argument of pragma% is not with'ed unit", Arg
);
5635 --------------------
5636 -- Elaborate_Body --
5637 --------------------
5639 -- pragma Elaborate_Body [( library_unit_NAME )];
5641 when Pragma_Elaborate_Body
=> Elaborate_Body
: declare
5642 Cunit_Node
: Node_Id
;
5643 Cunit_Ent
: Entity_Id
;
5646 Check_Ada_83_Warning
;
5647 Check_Valid_Library_Unit_Pragma
;
5649 if Nkind
(N
) = N_Null_Statement
then
5653 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
5654 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
5656 if Nkind
(Unit
(Cunit_Node
)) = N_Package_Body
5658 Nkind
(Unit
(Cunit_Node
)) = N_Subprogram_Body
5660 Error_Pragma
("pragma% must refer to a spec, not a body");
5662 Set_Body_Required
(Cunit_Node
, True);
5663 Set_Has_Pragma_Elaborate_Body
(Cunit_Ent
);
5665 -- If we are in dynamic elaboration mode, then we suppress
5666 -- elaboration warnings for the unit, since it is definitely
5667 -- fine NOT to do dynamic checks at the first level (and such
5668 -- checks will be suppressed because no elaboration boolean
5669 -- is created for Elaborate_Body packages).
5671 -- But in the static model of elaboration, Elaborate_Body is
5672 -- definitely NOT good enough to ensure elaboration safety on
5673 -- its own, since the body may WITH other units that are not
5674 -- safe from an elaboration point of view, so a client must
5675 -- still do an Elaborate_All on such units.
5677 -- Debug flag -gnatdD restores the old behavior of 3.13,
5678 -- where Elaborate_Body always suppressed elab warnings.
5680 if Dynamic_Elaboration_Checks
or Debug_Flag_DD
then
5681 Set_Suppress_Elaboration_Warnings
(Cunit_Ent
);
5686 ------------------------
5687 -- Elaboration_Checks --
5688 ------------------------
5690 -- pragma Elaboration_Checks (Static | Dynamic);
5692 when Pragma_Elaboration_Checks
=>
5694 Check_Arg_Count
(1);
5695 Check_Arg_Is_One_Of
(Arg1
, Name_Static
, Name_Dynamic
);
5696 Dynamic_Elaboration_Checks
:=
5697 (Chars
(Get_Pragma_Arg
(Arg1
)) = Name_Dynamic
);
5703 -- pragma Eliminate (
5704 -- [Unit_Name =>] IDENTIFIER |
5705 -- SELECTED_COMPONENT
5706 -- [,[Entity =>] IDENTIFIER |
5707 -- SELECTED_COMPONENT |
5709 -- [,]OVERLOADING_RESOLUTION);
5711 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
5714 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
5717 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
5719 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
5720 -- Result_Type => result_SUBTYPE_NAME]
5722 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
5723 -- SUBTYPE_NAME ::= STRING_LITERAL
5725 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
5726 -- SOURCE_TRACE ::= STRING_LITERAL
5728 when Pragma_Eliminate
=> Eliminate
: declare
5729 Args
: Args_List
(1 .. 5);
5730 Names
: constant Name_List
(1 .. 5) := (
5733 Name_Parameter_Types
,
5735 Name_Source_Location
);
5737 Unit_Name
: Node_Id
renames Args
(1);
5738 Entity
: Node_Id
renames Args
(2);
5739 Parameter_Types
: Node_Id
renames Args
(3);
5740 Result_Type
: Node_Id
renames Args
(4);
5741 Source_Location
: Node_Id
renames Args
(5);
5745 Check_Valid_Configuration_Pragma
;
5746 Gather_Associations
(Names
, Args
);
5748 if No
(Unit_Name
) then
5749 Error_Pragma
("missing Unit_Name argument for pragma%");
5753 and then (Present
(Parameter_Types
)
5755 Present
(Result_Type
)
5757 Present
(Source_Location
))
5759 Error_Pragma
("missing Entity argument for pragma%");
5762 if (Present
(Parameter_Types
)
5764 Present
(Result_Type
))
5766 Present
(Source_Location
)
5769 ("parameter profile and source location can not " &
5770 "be used together in pragma%");
5773 Process_Eliminate_Pragma
5782 -------------------------
5783 -- Explicit_Overriding --
5784 -------------------------
5786 when Pragma_Explicit_Overriding
=>
5787 Check_Valid_Configuration_Pragma
;
5788 Check_Arg_Count
(0);
5789 Explicit_Overriding
:= True;
5796 -- [ Convention =>] convention_IDENTIFIER,
5797 -- [ Entity =>] local_NAME
5798 -- [, [External_Name =>] static_string_EXPRESSION ]
5799 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5801 when Pragma_Export
=> Export
: declare
5806 Check_Ada_83_Warning
;
5807 Check_At_Least_N_Arguments
(2);
5808 Check_At_Most_N_Arguments
(4);
5809 Process_Convention
(C
, Def_Id
);
5811 if Ekind
(Def_Id
) /= E_Constant
then
5812 Note_Possible_Modification
(Expression
(Arg2
));
5815 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
5816 Set_Exported
(Def_Id
, Arg2
);
5819 ----------------------
5820 -- Export_Exception --
5821 ----------------------
5823 -- pragma Export_Exception (
5824 -- [Internal =>] LOCAL_NAME,
5825 -- [, [External =>] EXTERNAL_SYMBOL,]
5826 -- [, [Form =>] Ada | VMS]
5827 -- [, [Code =>] static_integer_EXPRESSION]);
5829 when Pragma_Export_Exception
=> Export_Exception
: declare
5830 Args
: Args_List
(1 .. 4);
5831 Names
: constant Name_List
(1 .. 4) := (
5837 Internal
: Node_Id
renames Args
(1);
5838 External
: Node_Id
renames Args
(2);
5839 Form
: Node_Id
renames Args
(3);
5840 Code
: Node_Id
renames Args
(4);
5843 if Inside_A_Generic
then
5844 Error_Pragma
("pragma% cannot be used for generic entities");
5847 Gather_Associations
(Names
, Args
);
5848 Process_Extended_Import_Export_Exception_Pragma
(
5849 Arg_Internal
=> Internal
,
5850 Arg_External
=> External
,
5854 if not Is_VMS_Exception
(Entity
(Internal
)) then
5855 Set_Exported
(Entity
(Internal
), Internal
);
5857 end Export_Exception
;
5859 ---------------------
5860 -- Export_Function --
5861 ---------------------
5863 -- pragma Export_Function (
5864 -- [Internal =>] LOCAL_NAME,
5865 -- [, [External =>] EXTERNAL_SYMBOL,]
5866 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5867 -- [, [Result_Type =>] TYPE_DESIGNATOR]
5868 -- [, [Mechanism =>] MECHANISM]
5869 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
5871 -- EXTERNAL_SYMBOL ::=
5873 -- | static_string_EXPRESSION
5875 -- PARAMETER_TYPES ::=
5877 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
5879 -- TYPE_DESIGNATOR ::=
5881 -- | subtype_Name ' Access
5885 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
5887 -- MECHANISM_ASSOCIATION ::=
5888 -- [formal_parameter_NAME =>] MECHANISM_NAME
5890 -- MECHANISM_NAME ::=
5893 -- | Descriptor [([Class =>] CLASS_NAME)]
5895 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
5897 when Pragma_Export_Function
=> Export_Function
: declare
5898 Args
: Args_List
(1 .. 6);
5899 Names
: constant Name_List
(1 .. 6) := (
5902 Name_Parameter_Types
,
5905 Name_Result_Mechanism
);
5907 Internal
: Node_Id
renames Args
(1);
5908 External
: Node_Id
renames Args
(2);
5909 Parameter_Types
: Node_Id
renames Args
(3);
5910 Result_Type
: Node_Id
renames Args
(4);
5911 Mechanism
: Node_Id
renames Args
(5);
5912 Result_Mechanism
: Node_Id
renames Args
(6);
5916 Gather_Associations
(Names
, Args
);
5917 Process_Extended_Import_Export_Subprogram_Pragma
(
5918 Arg_Internal
=> Internal
,
5919 Arg_External
=> External
,
5920 Arg_Parameter_Types
=> Parameter_Types
,
5921 Arg_Result_Type
=> Result_Type
,
5922 Arg_Mechanism
=> Mechanism
,
5923 Arg_Result_Mechanism
=> Result_Mechanism
);
5924 end Export_Function
;
5930 -- pragma Export_Object (
5931 -- [Internal =>] LOCAL_NAME,
5932 -- [, [External =>] EXTERNAL_SYMBOL]
5933 -- [, [Size =>] EXTERNAL_SYMBOL]);
5935 -- EXTERNAL_SYMBOL ::=
5937 -- | static_string_EXPRESSION
5939 -- PARAMETER_TYPES ::=
5941 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
5943 -- TYPE_DESIGNATOR ::=
5945 -- | subtype_Name ' Access
5949 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
5951 -- MECHANISM_ASSOCIATION ::=
5952 -- [formal_parameter_NAME =>] MECHANISM_NAME
5954 -- MECHANISM_NAME ::=
5957 -- | Descriptor [([Class =>] CLASS_NAME)]
5959 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
5961 when Pragma_Export_Object
=> Export_Object
: declare
5962 Args
: Args_List
(1 .. 3);
5963 Names
: constant Name_List
(1 .. 3) := (
5968 Internal
: Node_Id
renames Args
(1);
5969 External
: Node_Id
renames Args
(2);
5970 Size
: Node_Id
renames Args
(3);
5974 Gather_Associations
(Names
, Args
);
5975 Process_Extended_Import_Export_Object_Pragma
(
5976 Arg_Internal
=> Internal
,
5977 Arg_External
=> External
,
5981 ----------------------
5982 -- Export_Procedure --
5983 ----------------------
5985 -- pragma Export_Procedure (
5986 -- [Internal =>] LOCAL_NAME,
5987 -- [, [External =>] EXTERNAL_SYMBOL,]
5988 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5989 -- [, [Mechanism =>] MECHANISM]);
5991 -- EXTERNAL_SYMBOL ::=
5993 -- | static_string_EXPRESSION
5995 -- PARAMETER_TYPES ::=
5997 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
5999 -- TYPE_DESIGNATOR ::=
6001 -- | subtype_Name ' Access
6005 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6007 -- MECHANISM_ASSOCIATION ::=
6008 -- [formal_parameter_NAME =>] MECHANISM_NAME
6010 -- MECHANISM_NAME ::=
6013 -- | Descriptor [([Class =>] CLASS_NAME)]
6015 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6017 when Pragma_Export_Procedure
=> Export_Procedure
: declare
6018 Args
: Args_List
(1 .. 4);
6019 Names
: constant Name_List
(1 .. 4) := (
6022 Name_Parameter_Types
,
6025 Internal
: Node_Id
renames Args
(1);
6026 External
: Node_Id
renames Args
(2);
6027 Parameter_Types
: Node_Id
renames Args
(3);
6028 Mechanism
: Node_Id
renames Args
(4);
6032 Gather_Associations
(Names
, Args
);
6033 Process_Extended_Import_Export_Subprogram_Pragma
(
6034 Arg_Internal
=> Internal
,
6035 Arg_External
=> External
,
6036 Arg_Parameter_Types
=> Parameter_Types
,
6037 Arg_Mechanism
=> Mechanism
);
6038 end Export_Procedure
;
6044 -- pragma Export_Value (
6045 -- [Value =>] static_integer_EXPRESSION,
6046 -- [Link_Name =>] static_string_EXPRESSION);
6048 when Pragma_Export_Value
=>
6050 Check_Arg_Count
(2);
6052 Check_Optional_Identifier
(Arg1
, Name_Value
);
6053 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
6055 Check_Optional_Identifier
(Arg2
, Name_Link_Name
);
6056 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
6058 -----------------------------
6059 -- Export_Valued_Procedure --
6060 -----------------------------
6062 -- pragma Export_Valued_Procedure (
6063 -- [Internal =>] LOCAL_NAME,
6064 -- [, [External =>] EXTERNAL_SYMBOL,]
6065 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6066 -- [, [Mechanism =>] MECHANISM]);
6068 -- EXTERNAL_SYMBOL ::=
6070 -- | static_string_EXPRESSION
6072 -- PARAMETER_TYPES ::=
6074 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6076 -- TYPE_DESIGNATOR ::=
6078 -- | subtype_Name ' Access
6082 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6084 -- MECHANISM_ASSOCIATION ::=
6085 -- [formal_parameter_NAME =>] MECHANISM_NAME
6087 -- MECHANISM_NAME ::=
6090 -- | Descriptor [([Class =>] CLASS_NAME)]
6092 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6094 when Pragma_Export_Valued_Procedure
=>
6095 Export_Valued_Procedure
: declare
6096 Args
: Args_List
(1 .. 4);
6097 Names
: constant Name_List
(1 .. 4) := (
6100 Name_Parameter_Types
,
6103 Internal
: Node_Id
renames Args
(1);
6104 External
: Node_Id
renames Args
(2);
6105 Parameter_Types
: Node_Id
renames Args
(3);
6106 Mechanism
: Node_Id
renames Args
(4);
6110 Gather_Associations
(Names
, Args
);
6111 Process_Extended_Import_Export_Subprogram_Pragma
(
6112 Arg_Internal
=> Internal
,
6113 Arg_External
=> External
,
6114 Arg_Parameter_Types
=> Parameter_Types
,
6115 Arg_Mechanism
=> Mechanism
);
6116 end Export_Valued_Procedure
;
6122 -- pragma Extend_System ([Name =>] Identifier);
6124 when Pragma_Extend_System
=> Extend_System
: declare
6127 Check_Valid_Configuration_Pragma
;
6128 Check_Arg_Count
(1);
6129 Check_Optional_Identifier
(Arg1
, Name_Name
);
6130 Check_Arg_Is_Identifier
(Arg1
);
6132 Get_Name_String
(Chars
(Expression
(Arg1
)));
6135 and then Name_Buffer
(1 .. 4) = "aux_"
6137 if Present
(System_Extend_Pragma_Arg
) then
6138 if Chars
(Expression
(Arg1
)) =
6139 Chars
(Expression
(System_Extend_Pragma_Arg
))
6143 Error_Msg_Sloc
:= Sloc
(System_Extend_Pragma_Arg
);
6144 Error_Pragma
("pragma% conflicts with that at#");
6148 System_Extend_Pragma_Arg
:= Arg1
;
6150 if not GNAT_Mode
then
6151 System_Extend_Unit
:= Arg1
;
6155 Error_Pragma
("incorrect name for pragma%, must be Aux_xxx");
6159 ------------------------
6160 -- Extensions_Allowed --
6161 ------------------------
6163 -- pragma Extensions_Allowed (ON | OFF);
6165 when Pragma_Extensions_Allowed
=>
6167 Check_Arg_Count
(1);
6168 Check_No_Identifiers
;
6169 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
6171 if Chars
(Expression
(Arg1
)) = Name_On
then
6172 Extensions_Allowed
:= True;
6173 Ada_Version
:= Ada_Version_Type
'Last;
6175 Extensions_Allowed
:= False;
6176 Ada_Version
:= Ada_Version_Type
'Min (Ada_Version
, Ada_95
);
6183 -- pragma External (
6184 -- [ Convention =>] convention_IDENTIFIER,
6185 -- [ Entity =>] local_NAME
6186 -- [, [External_Name =>] static_string_EXPRESSION ]
6187 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6189 when Pragma_External
=> External
: declare
6195 Check_At_Least_N_Arguments
(2);
6196 Check_At_Most_N_Arguments
(4);
6197 Process_Convention
(C
, Def_Id
);
6198 Note_Possible_Modification
(Expression
(Arg2
));
6199 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
6200 Set_Exported
(Def_Id
, Arg2
);
6203 --------------------------
6204 -- External_Name_Casing --
6205 --------------------------
6207 -- pragma External_Name_Casing (
6208 -- UPPERCASE | LOWERCASE
6209 -- [, AS_IS | UPPERCASE | LOWERCASE]);
6211 when Pragma_External_Name_Casing
=>
6213 External_Name_Casing
: declare
6216 Check_No_Identifiers
;
6218 if Arg_Count
= 2 then
6220 (Arg2
, Name_As_Is
, Name_Uppercase
, Name_Lowercase
);
6222 case Chars
(Get_Pragma_Arg
(Arg2
)) is
6224 Opt
.External_Name_Exp_Casing
:= As_Is
;
6226 when Name_Uppercase
=>
6227 Opt
.External_Name_Exp_Casing
:= Uppercase
;
6229 when Name_Lowercase
=>
6230 Opt
.External_Name_Exp_Casing
:= Lowercase
;
6237 Check_Arg_Count
(1);
6240 Check_Arg_Is_One_Of
(Arg1
, Name_Uppercase
, Name_Lowercase
);
6242 case Chars
(Get_Pragma_Arg
(Arg1
)) is
6243 when Name_Uppercase
=>
6244 Opt
.External_Name_Imp_Casing
:= Uppercase
;
6246 when Name_Lowercase
=>
6247 Opt
.External_Name_Imp_Casing
:= Lowercase
;
6252 end External_Name_Casing
;
6254 ---------------------------
6255 -- Finalize_Storage_Only --
6256 ---------------------------
6258 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
6260 when Pragma_Finalize_Storage_Only
=> Finalize_Storage
: declare
6261 Assoc
: constant Node_Id
:= Arg1
;
6262 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
6266 Check_No_Identifiers
;
6267 Check_Arg_Count
(1);
6268 Check_Arg_Is_Local_Name
(Arg1
);
6270 Find_Type
(Type_Id
);
6271 Typ
:= Entity
(Type_Id
);
6274 or else Rep_Item_Too_Early
(Typ
, N
)
6278 Typ
:= Underlying_Type
(Typ
);
6281 if not Is_Controlled
(Typ
) then
6282 Error_Pragma
("pragma% must specify controlled type");
6285 Check_First_Subtype
(Arg1
);
6287 if Finalize_Storage_Only
(Typ
) then
6288 Error_Pragma
("duplicate pragma%, only one allowed");
6290 elsif not Rep_Item_Too_Late
(Typ
, N
) then
6291 Set_Finalize_Storage_Only
(Base_Type
(Typ
), True);
6293 end Finalize_Storage
;
6295 --------------------------
6296 -- Float_Representation --
6297 --------------------------
6299 -- pragma Float_Representation (VAX_Float | IEEE_Float);
6301 when Pragma_Float_Representation
=> Float_Representation
: declare
6309 if Arg_Count
= 1 then
6310 Check_Valid_Configuration_Pragma
;
6312 Check_Arg_Count
(2);
6313 Check_Optional_Identifier
(Arg2
, Name_Entity
);
6314 Check_Arg_Is_Local_Name
(Arg2
);
6317 Check_No_Identifier
(Arg1
);
6318 Check_Arg_Is_One_Of
(Arg1
, Name_VAX_Float
, Name_IEEE_Float
);
6320 if not OpenVMS_On_Target
then
6321 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6323 ("?pragma% ignored (applies only to Open'V'M'S)");
6329 -- One argument case
6331 if Arg_Count
= 1 then
6333 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6335 if Opt
.Float_Format
= 'I' then
6336 Error_Pragma
("'I'E'E'E format previously specified");
6339 Opt
.Float_Format
:= 'V';
6342 if Opt
.Float_Format
= 'V' then
6343 Error_Pragma
("'V'A'X format previously specified");
6346 Opt
.Float_Format
:= 'I';
6349 Set_Standard_Fpt_Formats
;
6351 -- Two argument case
6354 Argx
:= Get_Pragma_Arg
(Arg2
);
6356 if not Is_Entity_Name
(Argx
)
6357 or else not Is_Floating_Point_Type
(Entity
(Argx
))
6360 ("second argument of% pragma must be floating-point type",
6364 Ent
:= Entity
(Argx
);
6365 Digs
:= UI_To_Int
(Digits_Value
(Ent
));
6367 -- Two arguments, VAX_Float case
6369 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6372 when 6 => Set_F_Float
(Ent
);
6373 when 9 => Set_D_Float
(Ent
);
6374 when 15 => Set_G_Float
(Ent
);
6378 ("wrong digits value, must be 6,9 or 15", Arg2
);
6381 -- Two arguments, IEEE_Float case
6385 when 6 => Set_IEEE_Short
(Ent
);
6386 when 15 => Set_IEEE_Long
(Ent
);
6390 ("wrong digits value, must be 6 or 15", Arg2
);
6394 end Float_Representation
;
6400 -- pragma Ident (static_string_EXPRESSION)
6402 -- Note: pragma Comment shares this processing. Pragma Comment
6403 -- is identical to Ident, except that the restriction of the
6404 -- argument to 31 characters and the placement restrictions
6405 -- are not enforced for pragma Comment.
6407 when Pragma_Ident | Pragma_Comment
=> Ident
: declare
6412 Check_Arg_Count
(1);
6413 Check_No_Identifiers
;
6414 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
6416 -- For pragma Ident, preserve DEC compatibility by requiring
6417 -- the pragma to appear in a declarative part or package spec.
6419 if Prag_Id
= Pragma_Ident
then
6420 Check_Is_In_Decl_Part_Or_Package_Spec
;
6423 Str
:= Expr_Value_S
(Expression
(Arg1
));
6430 GP
:= Parent
(Parent
(N
));
6432 if Nkind
(GP
) = N_Package_Declaration
6434 Nkind
(GP
) = N_Generic_Package_Declaration
6439 -- If we have a compilation unit, then record the ident
6440 -- value, checking for improper duplication.
6442 if Nkind
(GP
) = N_Compilation_Unit
then
6443 CS
:= Ident_String
(Current_Sem_Unit
);
6445 if Present
(CS
) then
6447 -- For Ident, we do not permit multiple instances
6449 if Prag_Id
= Pragma_Ident
then
6450 Error_Pragma
("duplicate% pragma not permitted");
6452 -- For Comment, we concatenate the string, unless we
6453 -- want to preserve the tree structure for ASIS.
6455 elsif not ASIS_Mode
then
6456 Start_String
(Strval
(CS
));
6457 Store_String_Char
(' ');
6458 Store_String_Chars
(Strval
(Str
));
6459 Set_Strval
(CS
, End_String
);
6463 -- In VMS, the effect of IDENT is achieved by passing
6464 -- IDENTIFICATION=name as a --for-linker switch.
6466 if OpenVMS_On_Target
then
6469 ("--for-linker=IDENTIFICATION=");
6470 String_To_Name_Buffer
(Strval
(Str
));
6471 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
6473 -- Only the last processed IDENT is saved. The main
6474 -- purpose is so an IDENT associated with a main
6475 -- procedure will be used in preference to an IDENT
6476 -- associated with a with'd package.
6478 Replace_Linker_Option_String
6479 (End_String
, "--for-linker=IDENTIFICATION=");
6482 Set_Ident_String
(Current_Sem_Unit
, Str
);
6485 -- For subunits, we just ignore the Ident, since in GNAT
6486 -- these are not separate object files, and hence not
6487 -- separate units in the unit table.
6489 elsif Nkind
(GP
) = N_Subunit
then
6492 -- Otherwise we have a misplaced pragma Ident, but we ignore
6493 -- this if we are in an instantiation, since it comes from
6494 -- a generic, and has no relevance to the instantiation.
6496 elsif Prag_Id
= Pragma_Ident
then
6497 if Instantiation_Location
(Loc
) = No_Location
then
6498 Error_Pragma
("pragma% only allowed at outer level");
6509 -- [ Convention =>] convention_IDENTIFIER,
6510 -- [ Entity =>] local_NAME
6511 -- [, [External_Name =>] static_string_EXPRESSION ]
6512 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6514 when Pragma_Import
=>
6515 Check_Ada_83_Warning
;
6516 Check_At_Least_N_Arguments
(2);
6517 Check_At_Most_N_Arguments
(4);
6518 Process_Import_Or_Interface
;
6520 ----------------------
6521 -- Import_Exception --
6522 ----------------------
6524 -- pragma Import_Exception (
6525 -- [Internal =>] LOCAL_NAME,
6526 -- [, [External =>] EXTERNAL_SYMBOL,]
6527 -- [, [Form =>] Ada | VMS]
6528 -- [, [Code =>] static_integer_EXPRESSION]);
6530 when Pragma_Import_Exception
=> Import_Exception
: declare
6531 Args
: Args_List
(1 .. 4);
6532 Names
: constant Name_List
(1 .. 4) := (
6538 Internal
: Node_Id
renames Args
(1);
6539 External
: Node_Id
renames Args
(2);
6540 Form
: Node_Id
renames Args
(3);
6541 Code
: Node_Id
renames Args
(4);
6544 Gather_Associations
(Names
, Args
);
6546 if Present
(External
) and then Present
(Code
) then
6548 ("cannot give both External and Code options for pragma%");
6551 Process_Extended_Import_Export_Exception_Pragma
(
6552 Arg_Internal
=> Internal
,
6553 Arg_External
=> External
,
6557 if not Is_VMS_Exception
(Entity
(Internal
)) then
6558 Set_Imported
(Entity
(Internal
));
6560 end Import_Exception
;
6562 ---------------------
6563 -- Import_Function --
6564 ---------------------
6566 -- pragma Import_Function (
6567 -- [Internal =>] LOCAL_NAME,
6568 -- [, [External =>] EXTERNAL_SYMBOL]
6569 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6570 -- [, [Result_Type =>] SUBTYPE_MARK]
6571 -- [, [Mechanism =>] MECHANISM]
6572 -- [, [Result_Mechanism =>] MECHANISM_NAME]
6573 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6575 -- EXTERNAL_SYMBOL ::=
6577 -- | static_string_EXPRESSION
6579 -- PARAMETER_TYPES ::=
6581 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6583 -- TYPE_DESIGNATOR ::=
6585 -- | subtype_Name ' Access
6589 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6591 -- MECHANISM_ASSOCIATION ::=
6592 -- [formal_parameter_NAME =>] MECHANISM_NAME
6594 -- MECHANISM_NAME ::=
6597 -- | Descriptor [([Class =>] CLASS_NAME)]
6599 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6601 when Pragma_Import_Function
=> Import_Function
: declare
6602 Args
: Args_List
(1 .. 7);
6603 Names
: constant Name_List
(1 .. 7) := (
6606 Name_Parameter_Types
,
6609 Name_Result_Mechanism
,
6610 Name_First_Optional_Parameter
);
6612 Internal
: Node_Id
renames Args
(1);
6613 External
: Node_Id
renames Args
(2);
6614 Parameter_Types
: Node_Id
renames Args
(3);
6615 Result_Type
: Node_Id
renames Args
(4);
6616 Mechanism
: Node_Id
renames Args
(5);
6617 Result_Mechanism
: Node_Id
renames Args
(6);
6618 First_Optional_Parameter
: Node_Id
renames Args
(7);
6622 Gather_Associations
(Names
, Args
);
6623 Process_Extended_Import_Export_Subprogram_Pragma
(
6624 Arg_Internal
=> Internal
,
6625 Arg_External
=> External
,
6626 Arg_Parameter_Types
=> Parameter_Types
,
6627 Arg_Result_Type
=> Result_Type
,
6628 Arg_Mechanism
=> Mechanism
,
6629 Arg_Result_Mechanism
=> Result_Mechanism
,
6630 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
6631 end Import_Function
;
6637 -- pragma Import_Object (
6638 -- [Internal =>] LOCAL_NAME,
6639 -- [, [External =>] EXTERNAL_SYMBOL]
6640 -- [, [Size =>] EXTERNAL_SYMBOL]);
6642 -- EXTERNAL_SYMBOL ::=
6644 -- | static_string_EXPRESSION
6646 when Pragma_Import_Object
=> Import_Object
: declare
6647 Args
: Args_List
(1 .. 3);
6648 Names
: constant Name_List
(1 .. 3) := (
6653 Internal
: Node_Id
renames Args
(1);
6654 External
: Node_Id
renames Args
(2);
6655 Size
: Node_Id
renames Args
(3);
6659 Gather_Associations
(Names
, Args
);
6660 Process_Extended_Import_Export_Object_Pragma
(
6661 Arg_Internal
=> Internal
,
6662 Arg_External
=> External
,
6666 ----------------------
6667 -- Import_Procedure --
6668 ----------------------
6670 -- pragma Import_Procedure (
6671 -- [Internal =>] LOCAL_NAME,
6672 -- [, [External =>] EXTERNAL_SYMBOL]
6673 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6674 -- [, [Mechanism =>] MECHANISM]
6675 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6677 -- EXTERNAL_SYMBOL ::=
6679 -- | static_string_EXPRESSION
6681 -- PARAMETER_TYPES ::=
6683 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6685 -- TYPE_DESIGNATOR ::=
6687 -- | subtype_Name ' Access
6691 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6693 -- MECHANISM_ASSOCIATION ::=
6694 -- [formal_parameter_NAME =>] MECHANISM_NAME
6696 -- MECHANISM_NAME ::=
6699 -- | Descriptor [([Class =>] CLASS_NAME)]
6701 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6703 when Pragma_Import_Procedure
=> Import_Procedure
: declare
6704 Args
: Args_List
(1 .. 5);
6705 Names
: constant Name_List
(1 .. 5) := (
6708 Name_Parameter_Types
,
6710 Name_First_Optional_Parameter
);
6712 Internal
: Node_Id
renames Args
(1);
6713 External
: Node_Id
renames Args
(2);
6714 Parameter_Types
: Node_Id
renames Args
(3);
6715 Mechanism
: Node_Id
renames Args
(4);
6716 First_Optional_Parameter
: Node_Id
renames Args
(5);
6720 Gather_Associations
(Names
, Args
);
6721 Process_Extended_Import_Export_Subprogram_Pragma
(
6722 Arg_Internal
=> Internal
,
6723 Arg_External
=> External
,
6724 Arg_Parameter_Types
=> Parameter_Types
,
6725 Arg_Mechanism
=> Mechanism
,
6726 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
6727 end Import_Procedure
;
6729 -----------------------------
6730 -- Import_Valued_Procedure --
6731 -----------------------------
6733 -- pragma Import_Valued_Procedure (
6734 -- [Internal =>] LOCAL_NAME,
6735 -- [, [External =>] EXTERNAL_SYMBOL]
6736 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6737 -- [, [Mechanism =>] MECHANISM]
6738 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6740 -- EXTERNAL_SYMBOL ::=
6742 -- | static_string_EXPRESSION
6744 -- PARAMETER_TYPES ::=
6746 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6748 -- TYPE_DESIGNATOR ::=
6750 -- | subtype_Name ' Access
6754 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6756 -- MECHANISM_ASSOCIATION ::=
6757 -- [formal_parameter_NAME =>] MECHANISM_NAME
6759 -- MECHANISM_NAME ::=
6762 -- | Descriptor [([Class =>] CLASS_NAME)]
6764 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6766 when Pragma_Import_Valued_Procedure
=>
6767 Import_Valued_Procedure
: declare
6768 Args
: Args_List
(1 .. 5);
6769 Names
: constant Name_List
(1 .. 5) := (
6772 Name_Parameter_Types
,
6774 Name_First_Optional_Parameter
);
6776 Internal
: Node_Id
renames Args
(1);
6777 External
: Node_Id
renames Args
(2);
6778 Parameter_Types
: Node_Id
renames Args
(3);
6779 Mechanism
: Node_Id
renames Args
(4);
6780 First_Optional_Parameter
: Node_Id
renames Args
(5);
6784 Gather_Associations
(Names
, Args
);
6785 Process_Extended_Import_Export_Subprogram_Pragma
(
6786 Arg_Internal
=> Internal
,
6787 Arg_External
=> External
,
6788 Arg_Parameter_Types
=> Parameter_Types
,
6789 Arg_Mechanism
=> Mechanism
,
6790 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
6791 end Import_Valued_Procedure
;
6793 ------------------------
6794 -- Initialize_Scalars --
6795 ------------------------
6797 -- pragma Initialize_Scalars;
6799 when Pragma_Initialize_Scalars
=>
6801 Check_Arg_Count
(0);
6802 Check_Valid_Configuration_Pragma
;
6803 Check_Restriction
(No_Initialize_Scalars
, N
);
6805 if not Restriction_Active
(No_Initialize_Scalars
) then
6806 Init_Or_Norm_Scalars
:= True;
6807 Initialize_Scalars
:= True;
6814 -- pragma Inline ( NAME {, NAME} );
6816 when Pragma_Inline
=>
6818 -- Pragma is active if inlining option is active
6820 if Inline_Active
then
6821 Process_Inline
(True);
6823 -- Pragma is active in a predefined file in config run time mode
6825 elsif Configurable_Run_Time_Mode
6827 Is_Predefined_File_Name
(Unit_File_Name
(Current_Sem_Unit
))
6829 Process_Inline
(True);
6831 -- Otherwise inlining is not active
6834 Process_Inline
(False);
6841 -- pragma Inline_Always ( NAME {, NAME} );
6843 when Pragma_Inline_Always
=>
6844 Process_Inline
(True);
6846 --------------------
6847 -- Inline_Generic --
6848 --------------------
6850 -- pragma Inline_Generic (NAME {, NAME});
6852 when Pragma_Inline_Generic
=>
6853 Process_Generic_List
;
6855 ----------------------
6856 -- Inspection_Point --
6857 ----------------------
6859 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
6861 when Pragma_Inspection_Point
=> Inspection_Point
: declare
6866 if Arg_Count
> 0 then
6869 Exp
:= Expression
(Arg
);
6872 if not Is_Entity_Name
(Exp
)
6873 or else not Is_Object
(Entity
(Exp
))
6875 Error_Pragma_Arg
("object name required", Arg
);
6882 end Inspection_Point
;
6888 -- pragma Interface (
6889 -- convention_IDENTIFIER,
6892 when Pragma_Interface
=>
6894 Check_Arg_Count
(2);
6895 Check_No_Identifiers
;
6896 Process_Import_Or_Interface
;
6898 --------------------
6899 -- Interface_Name --
6900 --------------------
6902 -- pragma Interface_Name (
6903 -- [ Entity =>] local_NAME
6904 -- [,[External_Name =>] static_string_EXPRESSION ]
6905 -- [,[Link_Name =>] static_string_EXPRESSION ]);
6907 when Pragma_Interface_Name
=> Interface_Name
: declare
6915 Check_At_Least_N_Arguments
(2);
6916 Check_At_Most_N_Arguments
(3);
6917 Id
:= Expression
(Arg1
);
6920 if not Is_Entity_Name
(Id
) then
6922 ("first argument for pragma% must be entity name", Arg1
);
6923 elsif Etype
(Id
) = Any_Type
then
6926 Def_Id
:= Entity
(Id
);
6929 -- Special DEC-compatible processing for the object case,
6930 -- forces object to be imported.
6932 if Ekind
(Def_Id
) = E_Variable
then
6933 Kill_Size_Check_Code
(Def_Id
);
6934 Note_Possible_Modification
(Id
);
6936 -- Initialization is not allowed for imported variable
6938 if Present
(Expression
(Parent
(Def_Id
)))
6939 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
6941 Error_Msg_Sloc
:= Sloc
(Def_Id
);
6943 ("no initialization allowed for declaration of& #",
6947 -- For compatibility, support VADS usage of providing both
6948 -- pragmas Interface and Interface_Name to obtain the effect
6949 -- of a single Import pragma.
6951 if Is_Imported
(Def_Id
)
6952 and then Present
(First_Rep_Item
(Def_Id
))
6953 and then Nkind
(First_Rep_Item
(Def_Id
)) = N_Pragma
6954 and then Chars
(First_Rep_Item
(Def_Id
)) = Name_Interface
6958 Set_Imported
(Def_Id
);
6961 Set_Is_Public
(Def_Id
);
6962 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
6965 -- Otherwise must be subprogram
6967 elsif not Is_Subprogram
(Def_Id
) then
6969 ("argument of pragma% is not subprogram", Arg1
);
6972 Check_At_Most_N_Arguments
(3);
6976 -- Loop through homonyms
6979 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
6981 if Is_Imported
(Def_Id
) then
6982 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
6986 Hom_Id
:= Homonym
(Hom_Id
);
6988 exit when No
(Hom_Id
)
6989 or else Scope
(Hom_Id
) /= Current_Scope
;
6994 ("argument of pragma% is not imported subprogram",
7000 -----------------------
7001 -- Interrupt_Handler --
7002 -----------------------
7004 -- pragma Interrupt_Handler (handler_NAME);
7006 when Pragma_Interrupt_Handler
=>
7007 Check_Ada_83_Warning
;
7008 Check_Arg_Count
(1);
7009 Check_No_Identifiers
;
7011 if No_Run_Time_Mode
then
7012 Error_Msg_CRT
("Interrupt_Handler pragma", N
);
7014 Check_Interrupt_Or_Attach_Handler
;
7015 Process_Interrupt_Or_Attach_Handler
;
7018 ------------------------
7019 -- Interrupt_Priority --
7020 ------------------------
7022 -- pragma Interrupt_Priority [(EXPRESSION)];
7024 when Pragma_Interrupt_Priority
=> Interrupt_Priority
: declare
7025 P
: constant Node_Id
:= Parent
(N
);
7029 Check_Ada_83_Warning
;
7031 if Arg_Count
/= 0 then
7032 Arg
:= Expression
(Arg1
);
7033 Check_Arg_Count
(1);
7034 Check_No_Identifiers
;
7036 -- The expression must be analyzed in the special manner
7037 -- described in "Handling of Default and Per-Object
7038 -- Expressions" in sem.ads.
7040 Analyze_Per_Use_Expression
(Arg
, RTE
(RE_Interrupt_Priority
));
7043 if Nkind
(P
) /= N_Task_Definition
7044 and then Nkind
(P
) /= N_Protected_Definition
7049 elsif Has_Priority_Pragma
(P
) then
7050 Error_Pragma
("duplicate pragma% not allowed");
7053 Set_Has_Priority_Pragma
(P
, True);
7054 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
7056 end Interrupt_Priority
;
7058 ---------------------
7059 -- Interrupt_State --
7060 ---------------------
7062 -- pragma Interrupt_State (
7063 -- [Name =>] INTERRUPT_ID,
7064 -- [State =>] INTERRUPT_STATE);
7066 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
7067 -- INTERRUPT_STATE => System | Runtime | User
7069 -- Note: if the interrupt id is given as an identifier, then
7070 -- it must be one of the identifiers in Ada.Interrupts.Names.
7071 -- Otherwise it is given as a static integer expression which
7072 -- must be in the range of Ada.Interrupts.Interrupt_ID.
7074 when Pragma_Interrupt_State
=> Interrupt_State
: declare
7076 Int_Id
: constant Entity_Id
:= RTE
(RE_Interrupt_ID
);
7077 -- This is the entity Ada.Interrupts.Interrupt_ID;
7079 State_Type
: Character;
7080 -- Set to 's'/'r'/'u' for System/Runtime/User
7083 -- Index to entry in Interrupt_States table
7086 -- Value of interrupt
7088 Arg1X
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
7089 -- The first argument to the pragma
7091 Int_Ent
: Entity_Id
;
7092 -- Interrupt entity in Ada.Interrupts.Names
7096 Check_Arg_Count
(2);
7098 Check_Optional_Identifier
(Arg1
, Name_Name
);
7099 Check_Optional_Identifier
(Arg2
, "state");
7100 Check_Arg_Is_Identifier
(Arg2
);
7102 -- First argument is identifier
7104 if Nkind
(Arg1X
) = N_Identifier
then
7106 -- Search list of names in Ada.Interrupts.Names
7108 Int_Ent
:= First_Entity
(RTE
(RE_Names
));
7110 if No
(Int_Ent
) then
7111 Error_Pragma_Arg
("invalid interrupt name", Arg1
);
7113 elsif Chars
(Int_Ent
) = Chars
(Arg1X
) then
7114 Int_Val
:= Expr_Value
(Constant_Value
(Int_Ent
));
7118 Next_Entity
(Int_Ent
);
7121 -- First argument is not an identifier, so it must be a
7122 -- static expression of type Ada.Interrupts.Interrupt_ID.
7125 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
7126 Int_Val
:= Expr_Value
(Arg1X
);
7128 if Int_Val
< Expr_Value
(Type_Low_Bound
(Int_Id
))
7130 Int_Val
> Expr_Value
(Type_High_Bound
(Int_Id
))
7133 ("value not in range of type " &
7134 """Ada.Interrupts.Interrupt_'I'D""", Arg1
);
7140 case Chars
(Get_Pragma_Arg
(Arg2
)) is
7141 when Name_Runtime
=> State_Type
:= 'r';
7142 when Name_System
=> State_Type
:= 's';
7143 when Name_User
=> State_Type
:= 'u';
7146 Error_Pragma_Arg
("invalid interrupt state", Arg2
);
7149 -- Check if entry is already stored
7151 IST_Num
:= Interrupt_States
.First
;
7153 -- If entry not found, add it
7155 if IST_Num
> Interrupt_States
.Last
then
7156 Interrupt_States
.Append
7157 ((Interrupt_Number
=> UI_To_Int
(Int_Val
),
7158 Interrupt_State
=> State_Type
,
7159 Pragma_Loc
=> Loc
));
7162 -- Case of entry for the same entry
7164 elsif Int_Val
= Interrupt_States
.Table
(IST_Num
).
7167 -- If state matches, done, no need to make redundant entry
7170 State_Type
= Interrupt_States
.Table
(IST_Num
).
7173 -- Otherwise if state does not match, error
7176 Interrupt_States
.Table
(IST_Num
).Pragma_Loc
;
7178 ("state conflicts with that given at #", Arg2
);
7182 IST_Num
:= IST_Num
+ 1;
7184 end Interrupt_State
;
7186 ----------------------
7187 -- Java_Constructor --
7188 ----------------------
7190 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
7192 when Pragma_Java_Constructor
=> Java_Constructor
: declare
7199 Check_Arg_Count
(1);
7200 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7201 Check_Arg_Is_Local_Name
(Arg1
);
7203 Id
:= Expression
(Arg1
);
7204 Find_Program_Unit_Name
(Id
);
7206 -- If we did not find the name, we are done
7208 if Etype
(Id
) = Any_Type
then
7212 Hom_Id
:= Entity
(Id
);
7214 -- Loop through homonyms
7217 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
7219 -- The constructor is required to be a function returning
7220 -- an access type whose designated type has convention Java.
7222 if Ekind
(Def_Id
) = E_Function
7223 and then Ekind
(Etype
(Def_Id
)) in Access_Kind
7226 (Designated_Type
(Etype
(Def_Id
))) = Convention_Java
7229 (Root_Type
(Designated_Type
(Etype
(Def_Id
))))
7232 Set_Is_Constructor
(Def_Id
);
7233 Set_Convention
(Def_Id
, Convention_Java
);
7237 ("pragma% requires function returning a 'Java access type",
7241 Hom_Id
:= Homonym
(Hom_Id
);
7243 exit when No
(Hom_Id
) or else Scope
(Hom_Id
) /= Current_Scope
;
7245 end Java_Constructor
;
7247 ----------------------
7248 -- Java_Interface --
7249 ----------------------
7251 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
7253 when Pragma_Java_Interface
=> Java_Interface
: declare
7259 Check_Arg_Count
(1);
7260 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7261 Check_Arg_Is_Local_Name
(Arg1
);
7263 Arg
:= Expression
(Arg1
);
7266 if Etype
(Arg
) = Any_Type
then
7270 if not Is_Entity_Name
(Arg
)
7271 or else not Is_Type
(Entity
(Arg
))
7273 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
7276 Typ
:= Underlying_Type
(Entity
(Arg
));
7278 -- For now we simply check some of the semantic constraints
7279 -- on the type. This currently leaves out some restrictions
7280 -- on interface types, namely that the parent type must be
7281 -- java.lang.Object.Typ and that all primitives of the type
7282 -- should be declared abstract. ???
7284 if not Is_Tagged_Type
(Typ
) or else not Is_Abstract
(Typ
) then
7285 Error_Pragma_Arg
("pragma% requires an abstract "
7286 & "tagged type", Arg1
);
7288 elsif not Has_Discriminants
(Typ
)
7289 or else Ekind
(Etype
(First_Discriminant
(Typ
)))
7290 /= E_Anonymous_Access_Type
7292 not Is_Class_Wide_Type
7293 (Designated_Type
(Etype
(First_Discriminant
(Typ
))))
7296 ("type must have a class-wide access discriminant", Arg1
);
7304 -- pragma Keep_Names ([On => ] local_NAME);
7306 when Pragma_Keep_Names
=> Keep_Names
: declare
7311 Check_Arg_Count
(1);
7312 Check_Optional_Identifier
(Arg1
, Name_On
);
7313 Check_Arg_Is_Local_Name
(Arg1
);
7315 Arg
:= Expression
(Arg1
);
7318 if Etype
(Arg
) = Any_Type
then
7322 if not Is_Entity_Name
(Arg
)
7323 or else Ekind
(Entity
(Arg
)) /= E_Enumeration_Type
7326 ("pragma% requires a local enumeration type", Arg1
);
7329 Set_Discard_Names
(Entity
(Arg
), False);
7336 -- pragma License (RESTRICTED | UNRESRICTED | GPL | MODIFIED_GPL);
7338 when Pragma_License
=>
7340 Check_Arg_Count
(1);
7341 Check_No_Identifiers
;
7342 Check_Valid_Configuration_Pragma
;
7343 Check_Arg_Is_Identifier
(Arg1
);
7346 Sind
: constant Source_File_Index
:=
7347 Source_Index
(Current_Sem_Unit
);
7350 case Chars
(Get_Pragma_Arg
(Arg1
)) is
7352 Set_License
(Sind
, GPL
);
7354 when Name_Modified_GPL
=>
7355 Set_License
(Sind
, Modified_GPL
);
7357 when Name_Restricted
=>
7358 Set_License
(Sind
, Restricted
);
7360 when Name_Unrestricted
=>
7361 Set_License
(Sind
, Unrestricted
);
7364 Error_Pragma_Arg
("invalid license name", Arg1
);
7372 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
7374 when Pragma_Link_With
=> Link_With
: declare
7380 if Operating_Mode
= Generate_Code
7381 and then In_Extended_Main_Source_Unit
(N
)
7383 Check_At_Least_N_Arguments
(1);
7384 Check_No_Identifiers
;
7385 Check_Is_In_Decl_Part_Or_Package_Spec
;
7386 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7390 while Present
(Arg
) loop
7391 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
7393 -- Store argument, converting sequences of spaces
7394 -- to a single null character (this is one of the
7395 -- differences in processing between Link_With
7396 -- and Linker_Options).
7399 C
: constant Char_Code
:= Get_Char_Code
(' ');
7400 S
: constant String_Id
:=
7401 Strval
(Expr_Value_S
(Expression
(Arg
)));
7402 L
: constant Nat
:= String_Length
(S
);
7405 procedure Skip_Spaces
;
7406 -- Advance F past any spaces
7408 procedure Skip_Spaces
is
7410 while F
<= L
and then Get_String_Char
(S
, F
) = C
loop
7416 Skip_Spaces
; -- skip leading spaces
7418 -- Loop through characters, changing any embedded
7419 -- sequence of spaces to a single null character
7420 -- (this is how Link_With/Linker_Options differ)
7423 if Get_String_Char
(S
, F
) = C
then
7426 Store_String_Char
(ASCII
.NUL
);
7429 Store_String_Char
(Get_String_Char
(S
, F
));
7437 if Present
(Arg
) then
7438 Store_String_Char
(ASCII
.NUL
);
7442 Store_Linker_Option_String
(End_String
);
7450 -- pragma Linker_Alias (
7451 -- [Entity =>] LOCAL_NAME
7452 -- [Alias =>] static_string_EXPRESSION);
7454 when Pragma_Linker_Alias
=>
7456 Check_Arg_Count
(2);
7457 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7458 Check_Optional_Identifier
(Arg2
, "alias");
7459 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
7460 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7462 -- The only processing required is to link this item on to the
7463 -- list of rep items for the given entity. This is accomplished
7464 -- by the call to Rep_Item_Too_Late (when no error is detected
7465 -- and False is returned).
7467 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
7470 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7473 --------------------
7474 -- Linker_Options --
7475 --------------------
7477 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
7479 when Pragma_Linker_Options
=> Linker_Options
: declare
7483 Check_Ada_83_Warning
;
7484 Check_No_Identifiers
;
7485 Check_Arg_Count
(1);
7486 Check_Is_In_Decl_Part_Or_Package_Spec
;
7488 if Operating_Mode
= Generate_Code
7489 and then In_Extended_Main_Source_Unit
(N
)
7491 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7492 Start_String
(Strval
(Expr_Value_S
(Expression
(Arg1
))));
7495 while Present
(Arg
) loop
7496 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
7497 Store_String_Char
(ASCII
.NUL
);
7499 (Strval
(Expr_Value_S
(Expression
(Arg
))));
7503 Store_Linker_Option_String
(End_String
);
7507 --------------------
7508 -- Linker_Section --
7509 --------------------
7511 -- pragma Linker_Section (
7512 -- [Entity =>] LOCAL_NAME
7513 -- [Section =>] static_string_EXPRESSION);
7515 when Pragma_Linker_Section
=>
7517 Check_Arg_Count
(2);
7518 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7519 Check_Optional_Identifier
(Arg2
, Name_Section
);
7520 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
7521 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7523 -- The only processing required is to link this item on to the
7524 -- list of rep items for the given entity. This is accomplished
7525 -- by the call to Rep_Item_Too_Late (when no error is detected
7526 -- and False is returned).
7528 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
7531 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7538 -- pragma List (On | Off)
7540 -- There is nothing to do here, since we did all the processing
7541 -- for this pragma in Par.Prag (so that it works properly even in
7542 -- syntax only mode)
7547 --------------------
7548 -- Locking_Policy --
7549 --------------------
7551 -- pragma Locking_Policy (policy_IDENTIFIER);
7553 when Pragma_Locking_Policy
=> declare
7557 Check_Ada_83_Warning
;
7558 Check_Arg_Count
(1);
7559 Check_No_Identifiers
;
7560 Check_Arg_Is_Locking_Policy
(Arg1
);
7561 Check_Valid_Configuration_Pragma
;
7562 Get_Name_String
(Chars
(Expression
(Arg1
)));
7563 LP
:= Fold_Upper
(Name_Buffer
(1));
7565 if Locking_Policy
/= ' '
7566 and then Locking_Policy
/= LP
7568 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
7569 Error_Pragma
("locking policy incompatible with policy#");
7571 -- Set new policy, but always preserve System_Location since
7572 -- we like the error message with the run time name.
7575 Locking_Policy
:= LP
;
7577 if Locking_Policy_Sloc
/= System_Location
then
7578 Locking_Policy_Sloc
:= Loc
;
7587 -- pragma Long_Float (D_Float | G_Float);
7589 when Pragma_Long_Float
=>
7591 Check_Valid_Configuration_Pragma
;
7592 Check_Arg_Count
(1);
7593 Check_No_Identifier
(Arg1
);
7594 Check_Arg_Is_One_Of
(Arg1
, Name_D_Float
, Name_G_Float
);
7596 if not OpenVMS_On_Target
then
7597 Error_Pragma
("?pragma% ignored (applies only to Open'V'M'S)");
7602 if Chars
(Expression
(Arg1
)) = Name_D_Float
then
7603 if Opt
.Float_Format_Long
= 'G' then
7604 Error_Pragma
("G_Float previously specified");
7607 Opt
.Float_Format_Long
:= 'D';
7609 -- G_Float case (this is the default, does not need overriding)
7612 if Opt
.Float_Format_Long
= 'D' then
7613 Error_Pragma
("D_Float previously specified");
7616 Opt
.Float_Format_Long
:= 'G';
7619 Set_Standard_Fpt_Formats
;
7621 -----------------------
7622 -- Machine_Attribute --
7623 -----------------------
7625 -- pragma Machine_Attribute (
7626 -- [Entity =>] LOCAL_NAME,
7627 -- [Attribute_Name =>] static_string_EXPRESSION
7628 -- [,[Info =>] static_string_EXPRESSION] );
7630 when Pragma_Machine_Attribute
=> Machine_Attribute
: declare
7636 if Arg_Count
= 3 then
7637 Check_Optional_Identifier
(Arg3
, "info");
7638 Check_Arg_Is_Static_Expression
(Arg3
, Standard_String
);
7640 Check_Arg_Count
(2);
7643 Check_Arg_Is_Local_Name
(Arg1
);
7644 Check_Optional_Identifier
(Arg2
, "attribute_name");
7645 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7646 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7647 Def_Id
:= Entity
(Expression
(Arg1
));
7649 if Is_Access_Type
(Def_Id
) then
7650 Def_Id
:= Designated_Type
(Def_Id
);
7653 if Rep_Item_Too_Early
(Def_Id
, N
) then
7657 Def_Id
:= Underlying_Type
(Def_Id
);
7659 -- The only processing required is to link this item on to the
7660 -- list of rep items for the given entity. This is accomplished
7661 -- by the call to Rep_Item_Too_Late (when no error is detected
7662 -- and False is returned).
7664 if Rep_Item_Too_Late
(Def_Id
, N
) then
7667 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7669 end Machine_Attribute
;
7675 -- pragma Main_Storage
7676 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
7678 -- MAIN_STORAGE_OPTION ::=
7679 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
7680 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
7682 when Pragma_Main
=> Main
: declare
7683 Args
: Args_List
(1 .. 3);
7684 Names
: constant Name_List
(1 .. 3) := (
7686 Name_Task_Stack_Size_Default
,
7687 Name_Time_Slicing_Enabled
);
7693 Gather_Associations
(Names
, Args
);
7695 for J
in 1 .. 2 loop
7696 if Present
(Args
(J
)) then
7697 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
7701 if Present
(Args
(3)) then
7702 Check_Arg_Is_Static_Expression
(Args
(3), Standard_Boolean
);
7706 while Present
(Nod
) loop
7707 if Nkind
(Nod
) = N_Pragma
7708 and then Chars
(Nod
) = Name_Main
7710 Error_Msg_Name_1
:= Chars
(N
);
7711 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
7722 -- pragma Main_Storage
7723 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
7725 -- MAIN_STORAGE_OPTION ::=
7726 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
7727 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
7729 when Pragma_Main_Storage
=> Main_Storage
: declare
7730 Args
: Args_List
(1 .. 2);
7731 Names
: constant Name_List
(1 .. 2) := (
7732 Name_Working_Storage
,
7739 Gather_Associations
(Names
, Args
);
7741 for J
in 1 .. 2 loop
7742 if Present
(Args
(J
)) then
7743 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
7747 Check_In_Main_Program
;
7750 while Present
(Nod
) loop
7751 if Nkind
(Nod
) = N_Pragma
7752 and then Chars
(Nod
) = Name_Main_Storage
7754 Error_Msg_Name_1
:= Chars
(N
);
7755 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
7766 -- pragma Memory_Size (NUMERIC_LITERAL)
7768 when Pragma_Memory_Size
=>
7771 -- Memory size is simply ignored
7773 Check_No_Identifiers
;
7774 Check_Arg_Count
(1);
7775 Check_Arg_Is_Integer_Literal
(Arg1
);
7781 -- pragma No_Return (procedure_LOCAL_NAME);
7783 when Pragma_No_Return
=> No_Return
: declare
7790 Check_Arg_Count
(1);
7791 Check_No_Identifiers
;
7792 Check_Arg_Is_Local_Name
(Arg1
);
7793 Id
:= Expression
(Arg1
);
7796 if not Is_Entity_Name
(Id
) then
7797 Error_Pragma_Arg
("entity name required", Arg1
);
7800 if Etype
(Id
) = Any_Type
then
7808 and then Scope
(E
) = Current_Scope
7810 if Ekind
(E
) = E_Procedure
7811 or else Ekind
(E
) = E_Generic_Procedure
7821 Error_Pragma
("no procedures found for pragma%");
7825 ------------------------
7826 -- No_Strict_Aliasing --
7827 ------------------------
7829 when Pragma_No_Strict_Aliasing
=> No_Strict_Alias
: declare
7834 Check_At_Most_N_Arguments
(1);
7836 if Arg_Count
= 0 then
7837 Check_Valid_Configuration_Pragma
;
7838 Opt
.No_Strict_Aliasing
:= True;
7841 Check_Optional_Identifier
(Arg2
, Name_Entity
);
7842 Check_Arg_Is_Local_Name
(Arg1
);
7843 E_Id
:= Entity
(Expression
(Arg1
));
7845 if E_Id
= Any_Type
then
7847 elsif No
(E_Id
) or else not Is_Access_Type
(E_Id
) then
7848 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
7851 Set_No_Strict_Aliasing
(Implementation_Base_Type
(E_Id
));
7853 end No_Strict_Alias
;
7859 -- pragma Obsolescent [(static_string_EXPRESSION)];
7861 when Pragma_Obsolescent
=> Obsolescent
: declare
7864 Check_At_Most_N_Arguments
(1);
7865 Check_No_Identifiers
;
7867 if Arg_Count
= 1 then
7868 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7872 or else (Nkind
(Prev
(N
))) /= N_Subprogram_Declaration
7875 ("pragma% misplaced, must immediately " &
7876 "follow subprogram spec");
7884 -- pragma No_Run_Time
7886 -- Note: this pragma is retained for backwards compatibiltiy.
7887 -- See body of Rtsfind for full details on its handling.
7889 when Pragma_No_Run_Time
=>
7891 Check_Valid_Configuration_Pragma
;
7892 Check_Arg_Count
(0);
7894 No_Run_Time_Mode
:= True;
7895 Configurable_Run_Time_Mode
:= True;
7898 Word32
: constant Boolean := Ttypes
.System_Word_Size
= 32;
7901 Duration_32_Bits_On_Target
:= True;
7905 Set_Restriction
(No_Finalization
, N
);
7906 Set_Restriction
(No_Exception_Handlers
, N
);
7907 Set_Restriction
(Max_Tasks
, N
, 0);
7908 Set_Restriction
(No_Tasking
, N
);
7910 -----------------------
7911 -- Normalize_Scalars --
7912 -----------------------
7914 -- pragma Normalize_Scalars;
7916 when Pragma_Normalize_Scalars
=>
7917 Check_Ada_83_Warning
;
7918 Check_Arg_Count
(0);
7919 Check_Valid_Configuration_Pragma
;
7920 Normalize_Scalars
:= True;
7921 Init_Or_Norm_Scalars
:= True;
7927 -- pragma Optimize (Time | Space);
7929 -- The actual check for optimize is done in Gigi. Note that this
7930 -- pragma does not actually change the optimization setting, it
7931 -- simply checks that it is consistent with the pragma.
7933 when Pragma_Optimize
=>
7934 Check_No_Identifiers
;
7935 Check_Arg_Count
(1);
7936 Check_Arg_Is_One_Of
(Arg1
, Name_Time
, Name_Space
, Name_Off
);
7938 -------------------------
7939 -- Optional_Overriding --
7940 -------------------------
7942 -- These pragmas are treated as part of the previous subprogram
7943 -- declaration, and analyzed immediately after it (see sem_ch6,
7944 -- Check_Overriding_Operation). If the pragma has not been analyzed
7945 -- yet, it appears in the wrong place.
7947 when Pragma_Optional_Overriding
=>
7948 Error_Msg_N
("pragma must appear immediately after subprogram", N
);
7954 when Pragma_Overriding
=>
7955 Error_Msg_N
("pragma must appear immediately after subprogram", N
);
7961 -- pragma Pack (first_subtype_LOCAL_NAME);
7963 when Pragma_Pack
=> Pack
: declare
7964 Assoc
: constant Node_Id
:= Arg1
;
7969 Check_No_Identifiers
;
7970 Check_Arg_Count
(1);
7971 Check_Arg_Is_Local_Name
(Arg1
);
7973 Type_Id
:= Expression
(Assoc
);
7974 Find_Type
(Type_Id
);
7975 Typ
:= Entity
(Type_Id
);
7978 or else Rep_Item_Too_Early
(Typ
, N
)
7982 Typ
:= Underlying_Type
(Typ
);
7985 if not Is_Array_Type
(Typ
) and then not Is_Record_Type
(Typ
) then
7986 Error_Pragma
("pragma% must specify array or record type");
7989 Check_First_Subtype
(Arg1
);
7991 if Has_Pragma_Pack
(Typ
) then
7992 Error_Pragma
("duplicate pragma%, only one allowed");
7994 -- Array type. We set the Has_Pragma_Pack flag, and Is_Packed,
7995 -- but not Has_Non_Standard_Rep, because we don't actually know
7996 -- till freeze time if the array can have packed representation.
7997 -- That's because in the general case we do not know enough about
7998 -- the component type until it in turn is frozen, which certainly
7999 -- happens before the array type is frozen, but not necessarily
8000 -- till that point (i.e. right now it may be unfrozen).
8002 elsif Is_Array_Type
(Typ
) then
8003 if Has_Aliased_Components
(Base_Type
(Typ
)) then
8005 ("pragma% ignored, cannot pack aliased components?");
8007 elsif Has_Atomic_Components
(Typ
)
8008 or else Is_Atomic
(Component_Type
(Typ
))
8011 ("?pragma% ignored, cannot pack atomic components");
8013 elsif not Rep_Item_Too_Late
(Typ
, N
) then
8014 Set_Is_Packed
(Base_Type
(Typ
));
8015 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
8016 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
8019 -- Record type. For record types, the pack is always effective
8021 else pragma Assert
(Is_Record_Type
(Typ
));
8022 if not Rep_Item_Too_Late
(Typ
, N
) then
8023 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
8024 Set_Is_Packed
(Base_Type
(Typ
));
8025 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
8036 -- There is nothing to do here, since we did all the processing
8037 -- for this pragma in Par.Prag (so that it works properly even in
8038 -- syntax only mode)
8047 -- pragma Passive [(PASSIVE_FORM)];
8049 -- PASSIVE_FORM ::= Semaphore | No
8051 when Pragma_Passive
=>
8054 if Nkind
(Parent
(N
)) /= N_Task_Definition
then
8055 Error_Pragma
("pragma% must be within task definition");
8058 if Arg_Count
/= 0 then
8059 Check_Arg_Count
(1);
8060 Check_Arg_Is_One_Of
(Arg1
, Name_Semaphore
, Name_No
);
8067 -- pragma Polling (ON | OFF);
8069 when Pragma_Polling
=>
8071 Check_Arg_Count
(1);
8072 Check_No_Identifiers
;
8073 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
8074 Polling_Required
:= (Chars
(Expression
(Arg1
)) = Name_On
);
8076 ---------------------
8077 -- Persistent_Data --
8078 ---------------------
8080 when Pragma_Persistent_Data
=> declare
8084 -- Register the pragma as applying to the compilation unit.
8085 -- Individual Persistent_Object pragmas for relevant objects
8086 -- are generated the end of the compilation.
8089 Check_Valid_Configuration_Pragma
;
8090 Check_Arg_Count
(0);
8091 Ent
:= Find_Lib_Unit_Name
;
8092 Set_Is_Preelaborated
(Ent
);
8095 -----------------------
8096 -- Persistent_Object --
8097 -----------------------
8099 when Pragma_Persistent_Object
=> declare
8107 Check_Arg_Count
(1);
8108 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
8110 if not Is_Entity_Name
(Expression
(Arg1
))
8112 (Ekind
(Entity
(Expression
(Arg1
))) /= E_Variable
8113 and then Ekind
(Entity
(Expression
(Arg1
))) /= E_Constant
)
8115 Error_Pragma_Arg
("pragma only applies to objects", Arg1
);
8118 Ent
:= Entity
(Expression
(Arg1
));
8119 Decl
:= Parent
(Ent
);
8121 if Nkind
(Decl
) /= N_Object_Declaration
then
8125 -- Placement of the object depends on whether there is
8126 -- an initial value or none. If the No_Initialization flag
8127 -- is set, the initialization has been transformed into
8128 -- assignments, which is disallowed elaboration code.
8130 if No_Initialization
(Decl
) then
8132 ("initialization for persistent object"
8133 & "must be static expression", Decl
);
8137 if No
(Expression
(Decl
)) then
8139 Store_String_Chars
("section ("".persistent.bss"")");
8143 if not Is_OK_Static_Expression
(Expression
(Decl
)) then
8144 Flag_Non_Static_Expr
8145 ("initialization for persistent object"
8146 & "must be static expression!", Expression
(Decl
));
8151 Store_String_Chars
("section ("".persistent.data"")");
8158 Name_Machine_Attribute
,
8160 (Make_Pragma_Argument_Association
8161 (Sloc
=> Sloc
(Arg1
),
8162 Expression
=> New_Occurrence_Of
(Ent
, Sloc
(Ent
))),
8163 Make_Pragma_Argument_Association
8164 (Sloc
=> Sloc
(Arg1
),
8167 (Sloc
=> Sloc
(Arg1
),
8170 Insert_After
(N
, MA
);
8172 Set_Has_Gigi_Rep_Item
(Ent
);
8179 -- pragma Preelaborate [(library_unit_NAME)];
8181 -- Set the flag Is_Preelaborated of program unit name entity
8183 when Pragma_Preelaborate
=> Preelaborate
: declare
8184 Pa
: constant Node_Id
:= Parent
(N
);
8185 Pk
: constant Node_Kind
:= Nkind
(Pa
);
8189 Check_Ada_83_Warning
;
8190 Check_Valid_Library_Unit_Pragma
;
8192 if Nkind
(N
) = N_Null_Statement
then
8196 Ent
:= Find_Lib_Unit_Name
;
8198 -- This filters out pragmas inside generic parent then
8199 -- show up inside instantiation
8202 and then not (Pk
= N_Package_Specification
8203 and then Present
(Generic_Parent
(Pa
)))
8205 if not Debug_Flag_U
then
8206 Set_Is_Preelaborated
(Ent
);
8207 Set_Suppress_Elaboration_Warnings
(Ent
);
8216 -- pragma Priority (EXPRESSION);
8218 when Pragma_Priority
=> Priority
: declare
8219 P
: constant Node_Id
:= Parent
(N
);
8223 Check_No_Identifiers
;
8224 Check_Arg_Count
(1);
8228 if Nkind
(P
) = N_Subprogram_Body
then
8229 Check_In_Main_Program
;
8231 Arg
:= Expression
(Arg1
);
8232 Analyze_And_Resolve
(Arg
, Standard_Integer
);
8236 if not Is_Static_Expression
(Arg
) then
8237 Flag_Non_Static_Expr
8238 ("main subprogram priority is not static!", Arg
);
8241 -- If constraint error, then we already signalled an error
8243 elsif Raises_Constraint_Error
(Arg
) then
8246 -- Otherwise check in range
8250 Val
: constant Uint
:= Expr_Value
(Arg
);
8254 or else Val
> Expr_Value
(Expression
8255 (Parent
(RTE
(RE_Max_Priority
))))
8258 ("main subprogram priority is out of range", Arg1
);
8264 (Current_Sem_Unit
, UI_To_Int
(Expr_Value
(Arg
)));
8266 -- Task or Protected, must be of type Integer
8268 elsif Nkind
(P
) = N_Protected_Definition
8270 Nkind
(P
) = N_Task_Definition
8272 Arg
:= Expression
(Arg1
);
8274 -- The expression must be analyzed in the special manner
8275 -- described in "Handling of Default and Per-Object
8276 -- Expressions" in sem.ads.
8278 Analyze_Per_Use_Expression
(Arg
, Standard_Integer
);
8280 if not Is_Static_Expression
(Arg
) then
8281 Check_Restriction
(Static_Priorities
, Arg
);
8284 -- Anything else is incorrect
8290 if Has_Priority_Pragma
(P
) then
8291 Error_Pragma
("duplicate pragma% not allowed");
8293 Set_Has_Priority_Pragma
(P
, True);
8295 if Nkind
(P
) = N_Protected_Definition
8297 Nkind
(P
) = N_Task_Definition
8299 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
8300 -- exp_ch9 should use this ???
8309 -- pragma Profile (profile_IDENTIFIER);
8311 -- profile_IDENTIFIER => Protected | Ravenscar
8313 when Pragma_Profile
=>
8314 Check_Arg_Count
(1);
8315 Check_Valid_Configuration_Pragma
;
8316 Check_No_Identifiers
;
8319 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
8321 if Chars
(Argx
) = Name_Ravenscar
then
8322 Set_Ravenscar_Profile
(N
);
8324 elsif Chars
(Argx
) = Name_Restricted
then
8325 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> False);
8327 Error_Pragma_Arg
("& is not a valid profile", Argx
);
8331 ----------------------
8332 -- Profile_Warnings --
8333 ----------------------
8335 -- pragma Profile_Warnings (profile_IDENTIFIER);
8337 -- profile_IDENTIFIER => Protected | Ravenscar
8339 when Pragma_Profile_Warnings
=>
8341 Check_Arg_Count
(1);
8342 Check_Valid_Configuration_Pragma
;
8343 Check_No_Identifiers
;
8346 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
8348 if Chars
(Argx
) = Name_Ravenscar
then
8349 Set_Profile_Restrictions
(Ravenscar
, N
, Warn
=> True);
8351 elsif Chars
(Argx
) = Name_Restricted
then
8352 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> True);
8354 Error_Pragma_Arg
("& is not a valid profile", Argx
);
8358 --------------------------
8359 -- Propagate_Exceptions --
8360 --------------------------
8362 -- pragma Propagate_Exceptions;
8364 when Pragma_Propagate_Exceptions
=>
8366 Check_Arg_Count
(0);
8368 if In_Extended_Main_Source_Unit
(N
) then
8369 Propagate_Exceptions
:= True;
8376 -- pragma Psect_Object (
8377 -- [Internal =>] LOCAL_NAME,
8378 -- [, [External =>] EXTERNAL_SYMBOL]
8379 -- [, [Size =>] EXTERNAL_SYMBOL]);
8381 when Pragma_Psect_Object | Pragma_Common_Object
=>
8382 Psect_Object
: declare
8383 Args
: Args_List
(1 .. 3);
8384 Names
: constant Name_List
(1 .. 3) := (
8389 Internal
: Node_Id
renames Args
(1);
8390 External
: Node_Id
renames Args
(2);
8391 Size
: Node_Id
renames Args
(3);
8393 R_Internal
: Node_Id
;
8394 R_External
: Node_Id
;
8401 procedure Check_Too_Long
(Arg
: Node_Id
);
8402 -- Posts message if the argument is an identifier with more
8403 -- than 31 characters, or a string literal with more than
8404 -- 31 characters, and we are operating under VMS
8406 --------------------
8407 -- Check_Too_Long --
8408 --------------------
8410 procedure Check_Too_Long
(Arg
: Node_Id
) is
8411 X
: constant Node_Id
:= Original_Node
(Arg
);
8414 if Nkind
(X
) /= N_String_Literal
8416 Nkind
(X
) /= N_Identifier
8419 ("inappropriate argument for pragma %", Arg
);
8422 if OpenVMS_On_Target
then
8423 if (Nkind
(X
) = N_String_Literal
8424 and then String_Length
(Strval
(X
)) > 31)
8426 (Nkind
(X
) = N_Identifier
8427 and then Length_Of_Name
(Chars
(X
)) > 31)
8430 ("argument for pragma % is longer than 31 characters",
8436 -- Start of processing for Common_Object/Psect_Object
8440 Gather_Associations
(Names
, Args
);
8441 Process_Extended_Import_Export_Internal_Arg
(Internal
);
8443 R_Internal
:= Relocate_Node
(Internal
);
8445 Def_Id
:= Entity
(R_Internal
);
8447 if Ekind
(Def_Id
) /= E_Constant
8448 and then Ekind
(Def_Id
) /= E_Variable
8451 ("pragma% must designate an object", Internal
);
8454 Check_Too_Long
(R_Internal
);
8456 if Is_Imported
(Def_Id
) or else Is_Exported
(Def_Id
) then
8458 ("cannot use pragma% for imported/exported object",
8462 if Is_Concurrent_Type
(Etype
(R_Internal
)) then
8464 ("cannot specify pragma % for task/protected object",
8468 if Is_Psected
(Def_Id
) then
8469 Error_Msg_N
("?duplicate Psect_Object pragma", N
);
8471 Set_Is_Psected
(Def_Id
);
8474 if Ekind
(Def_Id
) = E_Constant
then
8476 ("cannot specify pragma % for a constant", R_Internal
);
8479 if Is_Record_Type
(Etype
(R_Internal
)) then
8485 Ent
:= First_Entity
(Etype
(R_Internal
));
8486 while Present
(Ent
) loop
8487 Decl
:= Declaration_Node
(Ent
);
8489 if Ekind
(Ent
) = E_Component
8490 and then Nkind
(Decl
) = N_Component_Declaration
8491 and then Present
(Expression
(Decl
))
8492 and then Warn_On_Export_Import
8495 ("?object for pragma % has defaults", R_Internal
);
8505 if Present
(Size
) then
8506 Check_Too_Long
(Size
);
8509 -- Make Psect case-insensitive.
8511 if Present
(External
) then
8512 Check_Too_Long
(External
);
8514 if Nkind
(External
) = N_String_Literal
then
8515 String_To_Name_Buffer
(Strval
(External
));
8517 Get_Name_String
(Chars
(External
));
8522 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
8524 R_External
:= Make_String_Literal
8525 (Sloc
=> Sloc
(External
), Strval
=> Str
);
8527 Get_Name_String
(Chars
(Internal
));
8530 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
8532 R_External
:= Make_String_Literal
8533 (Sloc
=> Sloc
(Internal
), Strval
=> Str
);
8536 -- Transform into pragma Linker_Section, add attributes to
8537 -- match what DEC Ada does. Ignore size for now?
8542 Name_Linker_Section
,
8544 (Make_Pragma_Argument_Association
8545 (Sloc
=> Sloc
(R_Internal
),
8546 Expression
=> R_Internal
),
8547 Make_Pragma_Argument_Association
8548 (Sloc
=> Sloc
(R_External
),
8549 Expression
=> R_External
))));
8553 -- Add Machine_Attribute of "overlaid", so the section overlays
8554 -- other sections of the same name.
8557 Store_String_Chars
("overlaid");
8563 Name_Machine_Attribute
,
8565 (Make_Pragma_Argument_Association
8566 (Sloc
=> Sloc
(R_Internal
),
8567 Expression
=> R_Internal
),
8568 Make_Pragma_Argument_Association
8569 (Sloc
=> Sloc
(R_External
),
8572 (Sloc
=> Sloc
(R_External
),
8576 -- Add Machine_Attribute of "global", so the section is visible
8580 Store_String_Chars
("global");
8586 Name_Machine_Attribute
,
8588 (Make_Pragma_Argument_Association
8589 (Sloc
=> Sloc
(R_Internal
),
8590 Expression
=> R_Internal
),
8592 Make_Pragma_Argument_Association
8593 (Sloc
=> Sloc
(R_External
),
8596 (Sloc
=> Sloc
(R_External
),
8600 -- Add Machine_Attribute of "initialize", so the section is
8604 Store_String_Chars
("initialize");
8610 Name_Machine_Attribute
,
8612 (Make_Pragma_Argument_Association
8613 (Sloc
=> Sloc
(R_Internal
),
8614 Expression
=> R_Internal
),
8616 Make_Pragma_Argument_Association
8617 (Sloc
=> Sloc
(R_External
),
8620 (Sloc
=> Sloc
(R_External
),
8629 -- pragma Pure [(library_unit_NAME)];
8631 when Pragma_Pure
=> Pure
: declare
8634 Check_Ada_83_Warning
;
8635 Check_Valid_Library_Unit_Pragma
;
8637 if Nkind
(N
) = N_Null_Statement
then
8641 Ent
:= Find_Lib_Unit_Name
;
8643 Set_Suppress_Elaboration_Warnings
(Ent
);
8650 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
8652 when Pragma_Pure_Function
=> Pure_Function
: declare
8656 Effective
: Boolean := False;
8660 Check_Arg_Count
(1);
8661 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8662 Check_Arg_Is_Local_Name
(Arg1
);
8663 E_Id
:= Expression
(Arg1
);
8665 if Error_Posted
(E_Id
) then
8669 -- Loop through homonyms (overloadings) of referenced entity
8675 Def_Id
:= Get_Base_Subprogram
(E
);
8677 if Ekind
(Def_Id
) /= E_Function
8678 and then Ekind
(Def_Id
) /= E_Generic_Function
8679 and then Ekind
(Def_Id
) /= E_Operator
8682 ("pragma% requires a function name", Arg1
);
8685 Set_Is_Pure
(Def_Id
);
8687 if not Has_Pragma_Pure_Function
(Def_Id
) then
8688 Set_Has_Pragma_Pure_Function
(Def_Id
);
8693 exit when No
(E
) or else Scope
(E
) /= Current_Scope
;
8697 and then Warn_On_Redundant_Constructs
8699 Error_Msg_NE
("pragma Pure_Function on& is redundant?",
8705 --------------------
8706 -- Queuing_Policy --
8707 --------------------
8709 -- pragma Queuing_Policy (policy_IDENTIFIER);
8711 when Pragma_Queuing_Policy
=> declare
8715 Check_Ada_83_Warning
;
8716 Check_Arg_Count
(1);
8717 Check_No_Identifiers
;
8718 Check_Arg_Is_Queuing_Policy
(Arg1
);
8719 Check_Valid_Configuration_Pragma
;
8720 Get_Name_String
(Chars
(Expression
(Arg1
)));
8721 QP
:= Fold_Upper
(Name_Buffer
(1));
8723 if Queuing_Policy
/= ' '
8724 and then Queuing_Policy
/= QP
8726 Error_Msg_Sloc
:= Queuing_Policy_Sloc
;
8727 Error_Pragma
("queuing policy incompatible with policy#");
8729 -- Set new policy, but always preserve System_Location since
8730 -- we like the error message with the run time name.
8733 Queuing_Policy
:= QP
;
8735 if Queuing_Policy_Sloc
/= System_Location
then
8736 Queuing_Policy_Sloc
:= Loc
;
8741 ---------------------------
8742 -- Remote_Call_Interface --
8743 ---------------------------
8745 -- pragma Remote_Call_Interface [(library_unit_NAME)];
8747 when Pragma_Remote_Call_Interface
=> Remote_Call_Interface
: declare
8748 Cunit_Node
: Node_Id
;
8749 Cunit_Ent
: Entity_Id
;
8753 Check_Ada_83_Warning
;
8754 Check_Valid_Library_Unit_Pragma
;
8756 if Nkind
(N
) = N_Null_Statement
then
8760 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
8761 K
:= Nkind
(Unit
(Cunit_Node
));
8762 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
8764 if K
= N_Package_Declaration
8765 or else K
= N_Generic_Package_Declaration
8766 or else K
= N_Subprogram_Declaration
8767 or else K
= N_Generic_Subprogram_Declaration
8768 or else (K
= N_Subprogram_Body
8769 and then Acts_As_Spec
(Unit
(Cunit_Node
)))
8774 "pragma% must apply to package or subprogram declaration");
8777 Set_Is_Remote_Call_Interface
(Cunit_Ent
);
8778 end Remote_Call_Interface
;
8784 -- pragma Remote_Types [(library_unit_NAME)];
8786 when Pragma_Remote_Types
=> Remote_Types
: declare
8787 Cunit_Node
: Node_Id
;
8788 Cunit_Ent
: Entity_Id
;
8791 Check_Ada_83_Warning
;
8792 Check_Valid_Library_Unit_Pragma
;
8794 if Nkind
(N
) = N_Null_Statement
then
8798 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
8799 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
8801 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
8803 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
8806 "pragma% can only apply to a package declaration");
8809 Set_Is_Remote_Types
(Cunit_Ent
);
8816 -- pragma Ravenscar;
8818 when Pragma_Ravenscar
=>
8820 Check_Arg_Count
(0);
8821 Check_Valid_Configuration_Pragma
;
8822 Set_Ravenscar_Profile
(N
);
8824 if Warn_On_Obsolescent_Feature
then
8826 ("pragma Ravenscar is an obsolescent feature?", N
);
8828 ("|use pragma Profile (Ravenscar) instead", N
);
8831 -------------------------
8832 -- Restricted_Run_Time --
8833 -------------------------
8835 -- pragma Restricted_Run_Time;
8837 when Pragma_Restricted_Run_Time
=>
8839 Check_Arg_Count
(0);
8840 Check_Valid_Configuration_Pragma
;
8841 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> False);
8843 if Warn_On_Obsolescent_Feature
then
8845 ("pragma Restricted_Run_Time is an obsolescent feature?", N
);
8847 ("|use pragma Profile (Restricted) instead", N
);
8854 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
8857 -- restriction_IDENTIFIER
8858 -- | restriction_parameter_IDENTIFIER => EXPRESSION
8860 when Pragma_Restrictions
=>
8861 Process_Restrictions_Or_Restriction_Warnings
;
8863 --------------------------
8864 -- Restriction_Warnings --
8865 --------------------------
8867 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
8870 -- restriction_IDENTIFIER
8871 -- | restriction_parameter_IDENTIFIER => EXPRESSION
8873 when Pragma_Restriction_Warnings
=>
8874 Process_Restrictions_Or_Restriction_Warnings
;
8880 -- pragma Reviewable;
8882 when Pragma_Reviewable
=>
8883 Check_Ada_83_Warning
;
8884 Check_Arg_Count
(0);
8890 -- pragma Share_Generic (NAME {, NAME});
8892 when Pragma_Share_Generic
=>
8894 Process_Generic_List
;
8900 -- pragma Shared (LOCAL_NAME);
8902 when Pragma_Shared
=>
8904 Process_Atomic_Shared_Volatile
;
8906 --------------------
8907 -- Shared_Passive --
8908 --------------------
8910 -- pragma Shared_Passive [(library_unit_NAME)];
8912 -- Set the flag Is_Shared_Passive of program unit name entity
8914 when Pragma_Shared_Passive
=> Shared_Passive
: declare
8915 Cunit_Node
: Node_Id
;
8916 Cunit_Ent
: Entity_Id
;
8919 Check_Ada_83_Warning
;
8920 Check_Valid_Library_Unit_Pragma
;
8922 if Nkind
(N
) = N_Null_Statement
then
8926 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
8927 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
8929 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
8931 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
8934 "pragma% can only apply to a package declaration");
8937 Set_Is_Shared_Passive
(Cunit_Ent
);
8940 ----------------------
8941 -- Source_File_Name --
8942 ----------------------
8944 -- There are five forms for this pragma:
8946 -- pragma Source_File_Name (
8947 -- [UNIT_NAME =>] unit_NAME,
8948 -- BODY_FILE_NAME => STRING_LITERAL
8949 -- [, [INDEX =>] INTEGER_LITERAL]);
8951 -- pragma Source_File_Name (
8952 -- [UNIT_NAME =>] unit_NAME,
8953 -- SPEC_FILE_NAME => STRING_LITERAL
8954 -- [, [INDEX =>] INTEGER_LITERAL]);
8956 -- pragma Source_File_Name (
8957 -- BODY_FILE_NAME => STRING_LITERAL
8958 -- [, DOT_REPLACEMENT => STRING_LITERAL]
8959 -- [, CASING => CASING_SPEC]);
8961 -- pragma Source_File_Name (
8962 -- SPEC_FILE_NAME => STRING_LITERAL
8963 -- [, DOT_REPLACEMENT => STRING_LITERAL]
8964 -- [, CASING => CASING_SPEC]);
8966 -- pragma Source_File_Name (
8967 -- SUBUNIT_FILE_NAME => STRING_LITERAL
8968 -- [, DOT_REPLACEMENT => STRING_LITERAL]
8969 -- [, CASING => CASING_SPEC]);
8971 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
8973 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
8974 -- Source_File_Name (SFN), however their usage is exclusive:
8975 -- SFN can only be used when no project file is used, while
8976 -- SFNP can only be used when a project file is used.
8978 -- No processing here. Processing was completed during parsing,
8979 -- since we need to have file names set as early as possible.
8980 -- Units are loaded well before semantic processing starts.
8982 -- The only processing we defer to this point is the check
8983 -- for correct placement.
8985 when Pragma_Source_File_Name
=>
8987 Check_Valid_Configuration_Pragma
;
8989 ------------------------------
8990 -- Source_File_Name_Project --
8991 ------------------------------
8993 -- See Source_File_Name for syntax
8995 -- No processing here. Processing was completed during parsing,
8996 -- since we need to have file names set as early as possible.
8997 -- Units are loaded well before semantic processing starts.
8999 -- The only processing we defer to this point is the check
9000 -- for correct placement.
9002 when Pragma_Source_File_Name_Project
=>
9004 Check_Valid_Configuration_Pragma
;
9006 -- Check that a pragma Source_File_Name_Project is used only
9007 -- in a configuration pragmas file.
9009 -- Pragmas Source_File_Name_Project should only be generated
9010 -- by the Project Manager in configuration pragmas files.
9012 -- This is really an ugly test. It seems to depend on some
9013 -- accidental and undocumented property. At the very least
9014 -- it needs to be documented, but it would be better to have
9015 -- a clean way of testing if we are in a configuration file???
9017 if Present
(Parent
(N
)) then
9019 ("pragma% can only appear in a configuration pragmas file");
9022 ----------------------
9023 -- Source_Reference --
9024 ----------------------
9026 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
9028 -- Nothing to do, all processing completed in Par.Prag, since we
9029 -- need the information for possible parser messages that are output
9031 when Pragma_Source_Reference
=>
9038 -- pragma Storage_Size (EXPRESSION);
9040 when Pragma_Storage_Size
=> Storage_Size
: declare
9041 P
: constant Node_Id
:= Parent
(N
);
9045 Check_No_Identifiers
;
9046 Check_Arg_Count
(1);
9048 -- The expression must be analyzed in the special manner
9049 -- described in "Handling of Default Expressions" in sem.ads.
9051 -- Set In_Default_Expression for per-object case ???
9053 Arg
:= Expression
(Arg1
);
9054 Analyze_Per_Use_Expression
(Arg
, Any_Integer
);
9056 if not Is_Static_Expression
(Arg
) then
9057 Check_Restriction
(Static_Storage_Size
, Arg
);
9060 if Nkind
(P
) /= N_Task_Definition
then
9065 if Has_Storage_Size_Pragma
(P
) then
9066 Error_Pragma
("duplicate pragma% not allowed");
9068 Set_Has_Storage_Size_Pragma
(P
, True);
9071 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
9072 -- ??? exp_ch9 should use this!
9080 -- pragma Storage_Unit (NUMERIC_LITERAL);
9082 -- Only permitted argument is System'Storage_Unit value
9084 when Pragma_Storage_Unit
=>
9085 Check_No_Identifiers
;
9086 Check_Arg_Count
(1);
9087 Check_Arg_Is_Integer_Literal
(Arg1
);
9089 if Intval
(Expression
(Arg1
)) /=
9090 UI_From_Int
(Ttypes
.System_Storage_Unit
)
9092 Error_Msg_Uint_1
:= UI_From_Int
(Ttypes
.System_Storage_Unit
);
9094 ("the only allowed argument for pragma% is ^", Arg1
);
9097 --------------------
9098 -- Stream_Convert --
9099 --------------------
9101 -- pragma Stream_Convert (
9102 -- [Entity =>] type_LOCAL_NAME,
9103 -- [Read =>] function_NAME,
9104 -- [Write =>] function NAME);
9106 when Pragma_Stream_Convert
=> Stream_Convert
: declare
9108 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
);
9109 -- Check that the given argument is the name of a local
9110 -- function of one argument that is not overloaded earlier
9111 -- in the current local scope. A check is also made that the
9112 -- argument is a function with one parameter.
9114 --------------------------------------
9115 -- Check_OK_Stream_Convert_Function --
9116 --------------------------------------
9118 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
) is
9122 Check_Arg_Is_Local_Name
(Arg
);
9123 Ent
:= Entity
(Expression
(Arg
));
9125 if Has_Homonym
(Ent
) then
9127 ("argument for pragma% may not be overloaded", Arg
);
9130 if Ekind
(Ent
) /= E_Function
9131 or else No
(First_Formal
(Ent
))
9132 or else Present
(Next_Formal
(First_Formal
(Ent
)))
9135 ("argument for pragma% must be" &
9136 " function of one argument", Arg
);
9138 end Check_OK_Stream_Convert_Function
;
9140 -- Start of procecessing for Stream_Convert
9144 Check_Arg_Count
(3);
9145 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9146 Check_Optional_Identifier
(Arg2
, Name_Read
);
9147 Check_Optional_Identifier
(Arg3
, Name_Write
);
9148 Check_Arg_Is_Local_Name
(Arg1
);
9149 Check_OK_Stream_Convert_Function
(Arg2
);
9150 Check_OK_Stream_Convert_Function
(Arg3
);
9153 Typ
: constant Entity_Id
:=
9154 Underlying_Type
(Entity
(Expression
(Arg1
)));
9155 Read
: constant Entity_Id
:= Entity
(Expression
(Arg2
));
9156 Write
: constant Entity_Id
:= Entity
(Expression
(Arg3
));
9159 if Etype
(Typ
) = Any_Type
9161 Etype
(Read
) = Any_Type
9163 Etype
(Write
) = Any_Type
9168 Check_First_Subtype
(Arg1
);
9170 if Rep_Item_Too_Early
(Typ
, N
)
9172 Rep_Item_Too_Late
(Typ
, N
)
9177 if Underlying_Type
(Etype
(Read
)) /= Typ
then
9179 ("incorrect return type for function&", Arg2
);
9182 if Underlying_Type
(Etype
(First_Formal
(Write
))) /= Typ
then
9184 ("incorrect parameter type for function&", Arg3
);
9187 if Underlying_Type
(Etype
(First_Formal
(Read
))) /=
9188 Underlying_Type
(Etype
(Write
))
9191 ("result type of & does not match Read parameter type",
9197 -------------------------
9198 -- Style_Checks (GNAT) --
9199 -------------------------
9201 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
9203 -- This is processed by the parser since some of the style
9204 -- checks take place during source scanning and parsing. This
9205 -- means that we don't need to issue error messages here.
9207 when Pragma_Style_Checks
=> Style_Checks
: declare
9208 A
: constant Node_Id
:= Expression
(Arg1
);
9214 Check_No_Identifiers
;
9216 -- Two argument form
9218 if Arg_Count
= 2 then
9219 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
9226 E_Id
:= Expression
(Arg2
);
9229 if not Is_Entity_Name
(E_Id
) then
9231 ("second argument of pragma% must be entity name",
9241 Set_Suppress_Style_Checks
(E
,
9242 (Chars
(Expression
(Arg1
)) = Name_Off
));
9243 exit when No
(Homonym
(E
));
9249 -- One argument form
9252 Check_Arg_Count
(1);
9254 if Nkind
(A
) = N_String_Literal
then
9258 Slen
: constant Natural := Natural (String_Length
(S
));
9259 Options
: String (1 .. Slen
);
9265 C
:= Get_String_Char
(S
, Int
(J
));
9266 exit when not In_Character_Range
(C
);
9267 Options
(J
) := Get_Character
(C
);
9270 Set_Style_Check_Options
(Options
);
9278 elsif Nkind
(A
) = N_Identifier
then
9280 if Chars
(A
) = Name_All_Checks
then
9281 Set_Default_Style_Check_Options
;
9283 elsif Chars
(A
) = Name_On
then
9284 Style_Check
:= True;
9286 elsif Chars
(A
) = Name_Off
then
9287 Style_Check
:= False;
9298 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
9300 when Pragma_Subtitle
=>
9302 Check_Arg_Count
(1);
9303 Check_Optional_Identifier
(Arg1
, Name_Subtitle
);
9304 Check_Arg_Is_String_Literal
(Arg1
);
9310 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
9312 when Pragma_Suppress
=>
9313 Process_Suppress_Unsuppress
(True);
9319 -- pragma Suppress_All;
9321 -- The only check made here is that the pragma appears in the
9322 -- proper place, i.e. following a compilation unit. If indeed
9323 -- it appears in this context, then the parser has already
9324 -- inserted an equivalent pragma Suppress (All_Checks) to get
9325 -- the required effect.
9327 when Pragma_Suppress_All
=>
9329 Check_Arg_Count
(0);
9331 if Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
9332 or else not Is_List_Member
(N
)
9333 or else List_Containing
(N
) /= Pragmas_After
(Parent
(N
))
9336 ("misplaced pragma%, must follow compilation unit");
9339 -------------------------
9340 -- Suppress_Debug_Info --
9341 -------------------------
9343 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
9345 when Pragma_Suppress_Debug_Info
=>
9347 Check_Arg_Count
(1);
9348 Check_Arg_Is_Local_Name
(Arg1
);
9349 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9350 Set_Debug_Info_Off
(Entity
(Get_Pragma_Arg
(Arg1
)));
9352 ----------------------------------
9353 -- Suppress_Exception_Locations --
9354 ----------------------------------
9356 -- pragma Suppress_Exception_Locations;
9358 when Pragma_Suppress_Exception_Locations
=>
9360 Check_Arg_Count
(0);
9361 Check_Valid_Configuration_Pragma
;
9362 Exception_Locations_Suppressed
:= True;
9364 -----------------------------
9365 -- Suppress_Initialization --
9366 -----------------------------
9368 -- pragma Suppress_Initialization ([Entity =>] type_Name);
9370 when Pragma_Suppress_Initialization
=> Suppress_Init
: declare
9376 Check_Arg_Count
(1);
9377 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9378 Check_Arg_Is_Local_Name
(Arg1
);
9380 E_Id
:= Expression
(Arg1
);
9382 if Etype
(E_Id
) = Any_Type
then
9389 if Is_Incomplete_Or_Private_Type
(E
) then
9390 if No
(Full_View
(Base_Type
(E
))) then
9392 ("argument of pragma% cannot be an incomplete type",
9395 Set_Suppress_Init_Proc
(Full_View
(Base_Type
(E
)));
9398 Set_Suppress_Init_Proc
(Base_Type
(E
));
9403 ("pragma% requires argument that is a type name", Arg1
);
9411 -- pragma System_Name (DIRECT_NAME);
9413 -- Syntax check: one argument, which must be the identifier GNAT
9414 -- or the identifier GCC, no other identifiers are acceptable.
9416 when Pragma_System_Name
=>
9417 Check_No_Identifiers
;
9418 Check_Arg_Count
(1);
9419 Check_Arg_Is_One_Of
(Arg1
, Name_Gcc
, Name_Gnat
);
9421 -----------------------------
9422 -- Task_Dispatching_Policy --
9423 -----------------------------
9425 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
9427 when Pragma_Task_Dispatching_Policy
=> declare
9431 Check_Ada_83_Warning
;
9432 Check_Arg_Count
(1);
9433 Check_No_Identifiers
;
9434 Check_Arg_Is_Task_Dispatching_Policy
(Arg1
);
9435 Check_Valid_Configuration_Pragma
;
9436 Get_Name_String
(Chars
(Expression
(Arg1
)));
9437 DP
:= Fold_Upper
(Name_Buffer
(1));
9439 if Task_Dispatching_Policy
/= ' '
9440 and then Task_Dispatching_Policy
/= DP
9442 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
9444 ("task dispatching policy incompatible with policy#");
9446 -- Set new policy, but always preserve System_Location since
9447 -- we like the error message with the run time name.
9450 Task_Dispatching_Policy
:= DP
;
9452 if Task_Dispatching_Policy_Sloc
/= System_Location
then
9453 Task_Dispatching_Policy_Sloc
:= Loc
;
9462 -- pragma Task_Info (EXPRESSION);
9464 when Pragma_Task_Info
=> Task_Info
: declare
9465 P
: constant Node_Id
:= Parent
(N
);
9470 if Nkind
(P
) /= N_Task_Definition
then
9471 Error_Pragma
("pragma% must appear in task definition");
9474 Check_No_Identifiers
;
9475 Check_Arg_Count
(1);
9477 Analyze_And_Resolve
(Expression
(Arg1
), RTE
(RE_Task_Info_Type
));
9479 if Etype
(Expression
(Arg1
)) = Any_Type
then
9483 if Has_Task_Info_Pragma
(P
) then
9484 Error_Pragma
("duplicate pragma% not allowed");
9486 Set_Has_Task_Info_Pragma
(P
, True);
9494 -- pragma Task_Name (string_EXPRESSION);
9496 when Pragma_Task_Name
=> Task_Name
: declare
9497 -- pragma Priority (EXPRESSION);
9499 P
: constant Node_Id
:= Parent
(N
);
9503 Check_No_Identifiers
;
9504 Check_Arg_Count
(1);
9506 Arg
:= Expression
(Arg1
);
9507 Analyze_And_Resolve
(Arg
, Standard_String
);
9509 if Nkind
(P
) /= N_Task_Definition
then
9513 if Has_Task_Name_Pragma
(P
) then
9514 Error_Pragma
("duplicate pragma% not allowed");
9516 Set_Has_Task_Name_Pragma
(P
, True);
9517 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
9525 -- pragma Task_Storage (
9526 -- [Task_Type =>] LOCAL_NAME,
9527 -- [Top_Guard =>] static_integer_EXPRESSION);
9529 when Pragma_Task_Storage
=> Task_Storage
: declare
9530 Args
: Args_List
(1 .. 2);
9531 Names
: constant Name_List
(1 .. 2) := (
9535 Task_Type
: Node_Id
renames Args
(1);
9536 Top_Guard
: Node_Id
renames Args
(2);
9542 Gather_Associations
(Names
, Args
);
9544 if No
(Task_Type
) then
9546 ("missing task_type argument for pragma%");
9549 Check_Arg_Is_Local_Name
(Task_Type
);
9551 Ent
:= Entity
(Task_Type
);
9553 if not Is_Task_Type
(Ent
) then
9555 ("argument for pragma% must be task type", Task_Type
);
9558 if No
(Top_Guard
) then
9560 ("pragma% takes two arguments", Task_Type
);
9562 Check_Arg_Is_Static_Expression
(Top_Guard
, Any_Integer
);
9565 Check_First_Subtype
(Task_Type
);
9567 if Rep_Item_Too_Late
(Ent
, N
) then
9576 -- pragma Thread_Body
9577 -- ( [Entity =>] LOCAL_NAME
9578 -- [,[Secondary_Stack_Size =>] static_integer_EXPRESSION]);
9580 when Pragma_Thread_Body
=> Thread_Body
: declare
9587 Check_At_Least_N_Arguments
(1);
9588 Check_At_Most_N_Arguments
(2);
9589 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9590 Check_Arg_Is_Local_Name
(Arg1
);
9592 Id
:= Expression
(Arg1
);
9594 if not Is_Entity_Name
(Id
)
9595 or else not Is_Subprogram
(Entity
(Id
))
9597 Error_Pragma_Arg
("subprogram name required", Arg1
);
9602 -- Go to renamed subprogram if present, since Thread_Body applies
9603 -- to the actual renamed entity, not to the renaming entity.
9605 if Present
(Alias
(E
))
9606 and then Nkind
(Parent
(Declaration_Node
(E
))) =
9607 N_Subprogram_Renaming_Declaration
9612 -- Various error checks
9614 if Nkind
(Parent
(Declaration_Node
(E
))) = N_Subprogram_Body
then
9616 ("pragma% requires separate spec and must come before body");
9618 elsif Rep_Item_Too_Early
(E
, N
)
9620 Rep_Item_Too_Late
(E
, N
)
9624 elsif Is_Thread_Body
(E
) then
9626 ("only one thread body pragma allowed", Arg1
);
9628 elsif Present
(Homonym
(E
))
9629 and then Scope
(Homonym
(E
)) = Current_Scope
9632 ("thread body subprogram must not be overloaded", Arg1
);
9635 Set_Is_Thread_Body
(E
);
9637 -- Deal with secondary stack argument
9639 if Arg_Count
= 2 then
9640 Check_Optional_Identifier
(Arg2
, Name_Secondary_Stack_Size
);
9641 SS
:= Expression
(Arg2
);
9642 Analyze_And_Resolve
(SS
, Any_Integer
);
9650 -- pragma Time_Slice (static_duration_EXPRESSION);
9652 when Pragma_Time_Slice
=> Time_Slice
: declare
9658 Check_Arg_Count
(1);
9659 Check_No_Identifiers
;
9660 Check_In_Main_Program
;
9661 Check_Arg_Is_Static_Expression
(Arg1
, Standard_Duration
);
9663 if not Error_Posted
(Arg1
) then
9665 while Present
(Nod
) loop
9666 if Nkind
(Nod
) = N_Pragma
9667 and then Chars
(Nod
) = Name_Time_Slice
9669 Error_Msg_Name_1
:= Chars
(N
);
9670 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
9677 -- Process only if in main unit
9679 if Get_Source_Unit
(Loc
) = Main_Unit
then
9680 Opt
.Time_Slice_Set
:= True;
9681 Val
:= Expr_Value_R
(Expression
(Arg1
));
9683 if Val
<= Ureal_0
then
9684 Opt
.Time_Slice_Value
:= 0;
9686 elsif Val
> UR_From_Uint
(UI_From_Int
(1000)) then
9687 Opt
.Time_Slice_Value
:= 1_000_000_000
;
9690 Opt
.Time_Slice_Value
:=
9691 UI_To_Int
(UR_To_Uint
(Val
* UI_From_Int
(1_000_000
)));
9700 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
9702 -- TITLING_OPTION ::=
9703 -- [Title =>] STRING_LITERAL
9704 -- | [Subtitle =>] STRING_LITERAL
9706 when Pragma_Title
=> Title
: declare
9707 Args
: Args_List
(1 .. 2);
9708 Names
: constant Name_List
(1 .. 2) := (
9714 Gather_Associations
(Names
, Args
);
9716 for J
in 1 .. 2 loop
9717 if Present
(Args
(J
)) then
9718 Check_Arg_Is_String_Literal
(Args
(J
));
9723 ---------------------
9724 -- Unchecked_Union --
9725 ---------------------
9727 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
9729 when Pragma_Unchecked_Union
=> Unchecked_Union
: declare
9730 Assoc
: constant Node_Id
:= Arg1
;
9731 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
9742 Check_No_Identifiers
;
9743 Check_Arg_Count
(1);
9744 Check_Arg_Is_Local_Name
(Arg1
);
9746 Find_Type
(Type_Id
);
9747 Typ
:= Entity
(Type_Id
);
9750 or else Rep_Item_Too_Early
(Typ
, N
)
9754 Typ
:= Underlying_Type
(Typ
);
9757 if Rep_Item_Too_Late
(Typ
, N
) then
9761 Check_First_Subtype
(Arg1
);
9763 -- Note remaining cases are references to a type in the current
9764 -- declarative part. If we find an error, we post the error on
9765 -- the relevant type declaration at an appropriate point.
9767 if not Is_Record_Type
(Typ
) then
9768 Error_Msg_N
("Unchecked_Union must be record type", Typ
);
9771 elsif Is_Tagged_Type
(Typ
) then
9772 Error_Msg_N
("Unchecked_Union must not be tagged", Typ
);
9775 elsif Is_Limited_Type
(Typ
) then
9777 ("Unchecked_Union must not be limited record type", Typ
);
9778 Explain_Limited_Type
(Typ
, Typ
);
9782 if not Has_Discriminants
(Typ
) then
9784 ("Unchecked_Union must have one discriminant", Typ
);
9788 Discr
:= First_Discriminant
(Typ
);
9790 if Present
(Next_Discriminant
(Discr
)) then
9792 ("Unchecked_Union must have exactly one discriminant",
9793 Next_Discriminant
(Discr
));
9797 if No
(Discriminant_Default_Value
(Discr
)) then
9799 ("Unchecked_Union discriminant must have default value",
9803 Tdef
:= Type_Definition
(Declaration_Node
(Typ
));
9804 Clist
:= Component_List
(Tdef
);
9806 Comp
:= First
(Component_Items
(Clist
));
9807 while Present
(Comp
) loop
9809 Check_Component
(Comp
);
9814 if No
(Clist
) or else No
(Variant_Part
(Clist
)) then
9816 ("Unchecked_Union must have variant part",
9821 Vpart
:= Variant_Part
(Clist
);
9822 Variant
:= First
(Variants
(Vpart
));
9823 while Present
(Variant
) loop
9825 Check_Variant
(Variant
);
9831 Set_Is_Unchecked_Union
(Typ
, True);
9832 Set_Convention
(Typ
, Convention_C
);
9834 Set_Has_Unchecked_Union
(Base_Type
(Typ
), True);
9835 Set_Is_Unchecked_Union
(Base_Type
(Typ
), True);
9836 end Unchecked_Union
;
9838 ------------------------
9839 -- Unimplemented_Unit --
9840 ------------------------
9842 -- pragma Unimplemented_Unit;
9844 -- Note: this only gives an error if we are generating code,
9845 -- or if we are in a generic library unit (where the pragma
9846 -- appears in the body, not in the spec).
9848 when Pragma_Unimplemented_Unit
=> Unimplemented_Unit
: declare
9849 Cunitent
: constant Entity_Id
:=
9850 Cunit_Entity
(Get_Source_Unit
(Loc
));
9851 Ent_Kind
: constant Entity_Kind
:=
9856 Check_Arg_Count
(0);
9858 if Operating_Mode
= Generate_Code
9859 or else Ent_Kind
= E_Generic_Function
9860 or else Ent_Kind
= E_Generic_Procedure
9861 or else Ent_Kind
= E_Generic_Package
9863 Get_Name_String
(Chars
(Cunitent
));
9864 Set_Casing
(Mixed_Case
);
9865 Write_Str
(Name_Buffer
(1 .. Name_Len
));
9866 Write_Str
(" is not implemented");
9868 raise Unrecoverable_Error
;
9870 end Unimplemented_Unit
;
9872 --------------------
9873 -- Universal_Data --
9874 --------------------
9876 -- pragma Universal_Data [(library_unit_NAME)];
9878 when Pragma_Universal_Data
=>
9881 -- If this is a configuration pragma, then set the universal
9882 -- addressing option, otherwise confirm that the pragma
9883 -- satisfies the requirements of library unit pragma placement
9884 -- and leave it to the GNAAMP back end to detect the pragma
9885 -- (avoids transitive setting of the option due to withed units).
9887 if Is_Configuration_Pragma
then
9888 Universal_Addressing_On_AAMP
:= True;
9890 Check_Valid_Library_Unit_Pragma
;
9893 if not AAMP_On_Target
then
9894 Error_Pragma
("?pragma% ignored (applies only to AAMP)");
9901 -- pragma Unreferenced (local_Name {, local_Name});
9903 when Pragma_Unreferenced
=> Unreferenced
: declare
9906 Arg_Ent
: Entity_Id
;
9910 Check_At_Least_N_Arguments
(1);
9914 while Present
(Arg_Node
) loop
9915 Check_No_Identifier
(Arg_Node
);
9917 -- Note that the analyze call done by Check_Arg_Is_Local_Name
9918 -- will in fact generate a reference, so that the entity will
9919 -- have a reference, which will inhibit any warnings about it
9920 -- not being referenced, and also properly show up in the ali
9921 -- file as a reference. But this reference is recorded before
9922 -- the Has_Pragma_Unreferenced flag is set, so that no warning
9923 -- is generated for this reference.
9925 Check_Arg_Is_Local_Name
(Arg_Node
);
9926 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
9928 if Is_Entity_Name
(Arg_Expr
) then
9929 Arg_Ent
:= Entity
(Arg_Expr
);
9931 -- If the entity is overloaded, the pragma applies to the
9932 -- most recent overloading, as documented. In this case,
9933 -- name resolution does not generate a reference, so it
9934 -- must be done here explicitly.
9936 if Is_Overloaded
(Arg_Expr
) then
9937 Generate_Reference
(Arg_Ent
, N
);
9940 Set_Has_Pragma_Unreferenced
(Arg_Ent
);
9947 ------------------------------
9948 -- Unreserve_All_Interrupts --
9949 ------------------------------
9951 -- pragma Unreserve_All_Interrupts;
9953 when Pragma_Unreserve_All_Interrupts
=>
9955 Check_Arg_Count
(0);
9957 if In_Extended_Main_Code_Unit
(Main_Unit_Entity
) then
9958 Unreserve_All_Interrupts
:= True;
9965 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
9967 when Pragma_Unsuppress
=>
9969 Process_Suppress_Unsuppress
(False);
9975 -- pragma Use_VADS_Size;
9977 when Pragma_Use_VADS_Size
=>
9979 Check_Arg_Count
(0);
9980 Check_Valid_Configuration_Pragma
;
9981 Use_VADS_Size
:= True;
9983 ---------------------
9984 -- Validity_Checks --
9985 ---------------------
9987 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
9989 when Pragma_Validity_Checks
=> Validity_Checks
: declare
9990 A
: constant Node_Id
:= Expression
(Arg1
);
9996 Check_Arg_Count
(1);
9997 Check_No_Identifiers
;
9999 if Nkind
(A
) = N_String_Literal
then
10003 Slen
: constant Natural := Natural (String_Length
(S
));
10004 Options
: String (1 .. Slen
);
10010 C
:= Get_String_Char
(S
, Int
(J
));
10011 exit when not In_Character_Range
(C
);
10012 Options
(J
) := Get_Character
(C
);
10015 Set_Validity_Check_Options
(Options
);
10023 elsif Nkind
(A
) = N_Identifier
then
10025 if Chars
(A
) = Name_All_Checks
then
10026 Set_Validity_Check_Options
("a");
10028 elsif Chars
(A
) = Name_On
then
10029 Validity_Checks_On
:= True;
10031 elsif Chars
(A
) = Name_Off
then
10032 Validity_Checks_On
:= False;
10036 end Validity_Checks
;
10042 -- pragma Volatile (LOCAL_NAME);
10044 when Pragma_Volatile
=>
10045 Process_Atomic_Shared_Volatile
;
10047 -------------------------
10048 -- Volatile_Components --
10049 -------------------------
10051 -- pragma Volatile_Components (array_LOCAL_NAME);
10053 -- Volatile is handled by the same circuit as Atomic_Components
10059 -- pragma Warnings (On | Off, [LOCAL_NAME])
10061 when Pragma_Warnings
=> Warnings
: begin
10063 Check_At_Least_N_Arguments
(1);
10064 Check_At_Most_N_Arguments
(2);
10065 Check_No_Identifiers
;
10067 -- One argument case was processed by parser in Par.Prag
10069 if Arg_Count
/= 1 then
10070 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
10071 Check_Arg_Count
(2);
10078 E_Id
:= Expression
(Arg2
);
10081 -- In the expansion of an inlined body, a reference to
10082 -- the formal may be wrapped in a conversion if the actual
10083 -- is a conversion. Retrieve the real entity name.
10085 if (In_Instance_Body
10086 or else In_Inlined_Body
)
10087 and then Nkind
(E_Id
) = N_Unchecked_Type_Conversion
10089 E_Id
:= Expression
(E_Id
);
10092 if not Is_Entity_Name
(E_Id
) then
10094 ("second argument of pragma% must be entity name",
10098 E
:= Entity
(E_Id
);
10104 Set_Warnings_Off
(E
,
10105 (Chars
(Expression
(Arg1
)) = Name_Off
));
10107 if Is_Enumeration_Type
(E
) then
10109 Lit
: Entity_Id
:= First_Literal
(E
);
10112 while Present
(Lit
) loop
10113 Set_Warnings_Off
(Lit
);
10114 Next_Literal
(Lit
);
10119 exit when No
(Homonym
(E
));
10127 -------------------
10128 -- Weak_External --
10129 -------------------
10131 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
10133 when Pragma_Weak_External
=> Weak_External
: declare
10138 Check_Arg_Count
(1);
10139 Check_Optional_Identifier
(Arg1
, Name_Entity
);
10140 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
10141 Ent
:= Entity
(Expression
(Arg1
));
10143 if Rep_Item_Too_Early
(Ent
, N
) then
10146 Ent
:= Underlying_Type
(Ent
);
10149 -- The only processing required is to link this item on to the
10150 -- list of rep items for the given entity. This is accomplished
10151 -- by the call to Rep_Item_Too_Late (when no error is detected
10152 -- and False is returned).
10154 if Rep_Item_Too_Late
(Ent
, N
) then
10157 Set_Has_Gigi_Rep_Item
(Ent
);
10161 --------------------
10162 -- Unknown_Pragma --
10163 --------------------
10165 -- Should be impossible, since the case of an unknown pragma is
10166 -- separately processed before the case statement is entered.
10168 when Unknown_Pragma
=>
10169 raise Program_Error
;
10173 when Pragma_Exit
=> null;
10174 end Analyze_Pragma
;
10176 ---------------------------------
10177 -- Delay_Config_Pragma_Analyze --
10178 ---------------------------------
10180 function Delay_Config_Pragma_Analyze
(N
: Node_Id
) return Boolean is
10182 return Chars
(N
) = Name_Interrupt_State
;
10183 end Delay_Config_Pragma_Analyze
;
10185 -------------------------
10186 -- Get_Base_Subprogram --
10187 -------------------------
10189 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
is
10190 Result
: Entity_Id
;
10195 -- Follow subprogram renaming chain
10197 while Is_Subprogram
(Result
)
10199 (Is_Generic_Instance
(Result
)
10200 or else Nkind
(Parent
(Declaration_Node
(Result
))) =
10201 N_Subprogram_Renaming_Declaration
)
10202 and then Present
(Alias
(Result
))
10204 Result
:= Alias
(Result
);
10208 end Get_Base_Subprogram
;
10210 -----------------------------
10211 -- Is_Config_Static_String --
10212 -----------------------------
10214 function Is_Config_Static_String
(Arg
: Node_Id
) return Boolean is
10216 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean;
10217 -- This is an internal recursive function that is just like the
10218 -- outer function except that it adds the string to the name buffer
10219 -- rather than placing the string in the name buffer.
10221 ------------------------------
10222 -- Add_Config_Static_String --
10223 ------------------------------
10225 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean is
10232 if Nkind
(N
) = N_Op_Concat
then
10233 if Add_Config_Static_String
(Left_Opnd
(N
)) then
10234 N
:= Right_Opnd
(N
);
10240 if Nkind
(N
) /= N_String_Literal
then
10241 Error_Msg_N
("string literal expected for pragma argument", N
);
10245 for J
in 1 .. String_Length
(Strval
(N
)) loop
10246 C
:= Get_String_Char
(Strval
(N
), J
);
10248 if not In_Character_Range
(C
) then
10250 ("string literal contains invalid wide character",
10251 Sloc
(N
) + 1 + Source_Ptr
(J
));
10255 Add_Char_To_Name_Buffer
(Get_Character
(C
));
10260 end Add_Config_Static_String
;
10262 -- Start of prorcessing for Is_Config_Static_String
10267 return Add_Config_Static_String
(Arg
);
10268 end Is_Config_Static_String
;
10270 -----------------------------------------
10271 -- Is_Non_Significant_Pragma_Reference --
10272 -----------------------------------------
10274 -- This function makes use of the following static table which indicates
10275 -- whether a given pragma is significant. A value of -1 in this table
10276 -- indicates that the reference is significant. A value of zero indicates
10277 -- than appearence as any argument is insignificant, a positive value
10278 -- indicates that appearence in that parameter position is significant.
10280 Sig_Flags
: constant array (Pragma_Id
) of Int
:=
10282 (Pragma_AST_Entry
=> -1,
10283 Pragma_Abort_Defer
=> -1,
10284 Pragma_Ada_83
=> -1,
10285 Pragma_Ada_95
=> -1,
10286 Pragma_Ada_05
=> -1,
10287 Pragma_All_Calls_Remote
=> -1,
10288 Pragma_Annotate
=> -1,
10289 Pragma_Assert
=> -1,
10290 Pragma_Asynchronous
=> -1,
10291 Pragma_Atomic
=> 0,
10292 Pragma_Atomic_Components
=> 0,
10293 Pragma_Attach_Handler
=> -1,
10294 Pragma_CPP_Class
=> 0,
10295 Pragma_CPP_Constructor
=> 0,
10296 Pragma_CPP_Virtual
=> 0,
10297 Pragma_CPP_Vtable
=> 0,
10298 Pragma_C_Pass_By_Copy
=> 0,
10299 Pragma_Comment
=> 0,
10300 Pragma_Common_Object
=> -1,
10301 Pragma_Compile_Time_Warning
=> -1,
10302 Pragma_Complex_Representation
=> 0,
10303 Pragma_Component_Alignment
=> -1,
10304 Pragma_Controlled
=> 0,
10305 Pragma_Convention
=> 0,
10306 Pragma_Convention_Identifier
=> 0,
10307 Pragma_Debug
=> -1,
10308 Pragma_Detect_Blocking
=> -1,
10309 Pragma_Discard_Names
=> 0,
10310 Pragma_Elaborate
=> -1,
10311 Pragma_Elaborate_All
=> -1,
10312 Pragma_Elaborate_Body
=> -1,
10313 Pragma_Elaboration_Checks
=> -1,
10314 Pragma_Eliminate
=> -1,
10315 Pragma_Explicit_Overriding
=> -1,
10316 Pragma_Export
=> -1,
10317 Pragma_Export_Exception
=> -1,
10318 Pragma_Export_Function
=> -1,
10319 Pragma_Export_Object
=> -1,
10320 Pragma_Export_Procedure
=> -1,
10321 Pragma_Export_Value
=> -1,
10322 Pragma_Export_Valued_Procedure
=> -1,
10323 Pragma_Extend_System
=> -1,
10324 Pragma_Extensions_Allowed
=> -1,
10325 Pragma_External
=> -1,
10326 Pragma_External_Name_Casing
=> -1,
10327 Pragma_Finalize_Storage_Only
=> 0,
10328 Pragma_Float_Representation
=> 0,
10329 Pragma_Ident
=> -1,
10330 Pragma_Import
=> +2,
10331 Pragma_Import_Exception
=> 0,
10332 Pragma_Import_Function
=> 0,
10333 Pragma_Import_Object
=> 0,
10334 Pragma_Import_Procedure
=> 0,
10335 Pragma_Import_Valued_Procedure
=> 0,
10336 Pragma_Initialize_Scalars
=> -1,
10337 Pragma_Inline
=> 0,
10338 Pragma_Inline_Always
=> 0,
10339 Pragma_Inline_Generic
=> 0,
10340 Pragma_Inspection_Point
=> -1,
10341 Pragma_Interface
=> +2,
10342 Pragma_Interface_Name
=> +2,
10343 Pragma_Interrupt_Handler
=> -1,
10344 Pragma_Interrupt_Priority
=> -1,
10345 Pragma_Interrupt_State
=> -1,
10346 Pragma_Java_Constructor
=> -1,
10347 Pragma_Java_Interface
=> -1,
10348 Pragma_Keep_Names
=> 0,
10349 Pragma_License
=> -1,
10350 Pragma_Link_With
=> -1,
10351 Pragma_Linker_Alias
=> -1,
10352 Pragma_Linker_Options
=> -1,
10353 Pragma_Linker_Section
=> -1,
10355 Pragma_Locking_Policy
=> -1,
10356 Pragma_Long_Float
=> -1,
10357 Pragma_Machine_Attribute
=> -1,
10359 Pragma_Main_Storage
=> -1,
10360 Pragma_Memory_Size
=> -1,
10361 Pragma_No_Return
=> 0,
10362 Pragma_No_Run_Time
=> -1,
10363 Pragma_No_Strict_Aliasing
=> -1,
10364 Pragma_Normalize_Scalars
=> -1,
10365 Pragma_Obsolescent
=> 0,
10366 Pragma_Optimize
=> -1,
10367 Pragma_Optional_Overriding
=> -1,
10368 Pragma_Overriding
=> -1,
10371 Pragma_Passive
=> -1,
10372 Pragma_Polling
=> -1,
10373 Pragma_Persistent_Data
=> -1,
10374 Pragma_Persistent_Object
=> -1,
10375 Pragma_Preelaborate
=> -1,
10376 Pragma_Priority
=> -1,
10377 Pragma_Profile
=> 0,
10378 Pragma_Profile_Warnings
=> 0,
10379 Pragma_Propagate_Exceptions
=> -1,
10380 Pragma_Psect_Object
=> -1,
10382 Pragma_Pure_Function
=> 0,
10383 Pragma_Queuing_Policy
=> -1,
10384 Pragma_Ravenscar
=> -1,
10385 Pragma_Remote_Call_Interface
=> -1,
10386 Pragma_Remote_Types
=> -1,
10387 Pragma_Restricted_Run_Time
=> -1,
10388 Pragma_Restriction_Warnings
=> -1,
10389 Pragma_Restrictions
=> -1,
10390 Pragma_Reviewable
=> -1,
10391 Pragma_Share_Generic
=> -1,
10392 Pragma_Shared
=> -1,
10393 Pragma_Shared_Passive
=> -1,
10394 Pragma_Source_File_Name
=> -1,
10395 Pragma_Source_File_Name_Project
=> -1,
10396 Pragma_Source_Reference
=> -1,
10397 Pragma_Storage_Size
=> -1,
10398 Pragma_Storage_Unit
=> -1,
10399 Pragma_Stream_Convert
=> -1,
10400 Pragma_Style_Checks
=> -1,
10401 Pragma_Subtitle
=> -1,
10402 Pragma_Suppress
=> 0,
10403 Pragma_Suppress_Exception_Locations
=> 0,
10404 Pragma_Suppress_All
=> -1,
10405 Pragma_Suppress_Debug_Info
=> 0,
10406 Pragma_Suppress_Initialization
=> 0,
10407 Pragma_System_Name
=> -1,
10408 Pragma_Task_Dispatching_Policy
=> -1,
10409 Pragma_Task_Info
=> -1,
10410 Pragma_Task_Name
=> -1,
10411 Pragma_Task_Storage
=> 0,
10412 Pragma_Thread_Body
=> +2,
10413 Pragma_Time_Slice
=> -1,
10414 Pragma_Title
=> -1,
10415 Pragma_Unchecked_Union
=> 0,
10416 Pragma_Unimplemented_Unit
=> -1,
10417 Pragma_Universal_Data
=> -1,
10418 Pragma_Unreferenced
=> -1,
10419 Pragma_Unreserve_All_Interrupts
=> -1,
10420 Pragma_Unsuppress
=> 0,
10421 Pragma_Use_VADS_Size
=> -1,
10422 Pragma_Validity_Checks
=> -1,
10423 Pragma_Volatile
=> 0,
10424 Pragma_Volatile_Components
=> 0,
10425 Pragma_Warnings
=> -1,
10426 Pragma_Weak_External
=> 0,
10427 Unknown_Pragma
=> 0);
10429 function Is_Non_Significant_Pragma_Reference
(N
: Node_Id
) return Boolean is
10437 if Nkind
(P
) /= N_Pragma_Argument_Association
then
10441 C
:= Sig_Flags
(Get_Pragma_Id
(Chars
(Parent
(P
))));
10451 A
:= First
(Pragma_Argument_Associations
(Parent
(P
)));
10452 for J
in 1 .. C
- 1 loop
10463 end Is_Non_Significant_Pragma_Reference
;
10465 ------------------------------
10466 -- Is_Pragma_String_Literal --
10467 ------------------------------
10469 -- This function returns true if the corresponding pragma argument is
10470 -- a static string expression. These are the only cases in which string
10471 -- literals can appear as pragma arguments. We also allow a string
10472 -- literal as the first argument to pragma Assert (although it will
10473 -- of course always generate a type error).
10475 function Is_Pragma_String_Literal
(Par
: Node_Id
) return Boolean is
10476 Pragn
: constant Node_Id
:= Parent
(Par
);
10477 Assoc
: constant List_Id
:= Pragma_Argument_Associations
(Pragn
);
10478 Pname
: constant Name_Id
:= Chars
(Pragn
);
10484 N
:= First
(Assoc
);
10491 if Pname
= Name_Assert
then
10494 elsif Pname
= Name_Export
then
10497 elsif Pname
= Name_Ident
then
10500 elsif Pname
= Name_Import
then
10503 elsif Pname
= Name_Interface_Name
then
10506 elsif Pname
= Name_Linker_Alias
then
10509 elsif Pname
= Name_Linker_Section
then
10512 elsif Pname
= Name_Machine_Attribute
then
10515 elsif Pname
= Name_Source_File_Name
then
10518 elsif Pname
= Name_Source_Reference
then
10521 elsif Pname
= Name_Title
then
10524 elsif Pname
= Name_Subtitle
then
10530 end Is_Pragma_String_Literal
;
10532 --------------------------------------
10533 -- Process_Compilation_Unit_Pragmas --
10534 --------------------------------------
10536 procedure Process_Compilation_Unit_Pragmas
(N
: Node_Id
) is
10538 -- A special check for pragma Suppress_All. This is a strange DEC
10539 -- pragma, strange because it comes at the end of the unit. If we
10540 -- have a pragma Suppress_All in the Pragmas_After of the current
10541 -- unit, then we insert a pragma Suppress (All_Checks) at the start
10542 -- of the context clause to ensure the correct processing.
10545 PA
: constant List_Id
:= Pragmas_After
(Aux_Decls_Node
(N
));
10549 if Present
(PA
) then
10551 while Present
(P
) loop
10552 if Chars
(P
) = Name_Suppress_All
then
10553 Prepend_To
(Context_Items
(N
),
10554 Make_Pragma
(Sloc
(P
),
10555 Chars
=> Name_Suppress
,
10556 Pragma_Argument_Associations
=> New_List
(
10557 Make_Pragma_Argument_Association
(Sloc
(P
),
10559 Make_Identifier
(Sloc
(P
),
10560 Chars
=> Name_All_Checks
)))));
10568 end Process_Compilation_Unit_Pragmas
;
10570 --------------------------------
10571 -- Set_Encoded_Interface_Name --
10572 --------------------------------
10574 procedure Set_Encoded_Interface_Name
(E
: Entity_Id
; S
: Node_Id
) is
10575 Str
: constant String_Id
:= Strval
(S
);
10576 Len
: constant Int
:= String_Length
(Str
);
10581 Hex
: constant array (0 .. 15) of Character := "0123456789abcdef";
10584 -- Stores encoded value of character code CC. The encoding we
10585 -- use an underscore followed by four lower case hex digits.
10587 procedure Encode
is
10589 Store_String_Char
(Get_Char_Code
('_'));
10591 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 12))));
10593 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 8 and 16#
0F#
))));
10595 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 4 and 16#
0F#
))));
10597 (Get_Char_Code
(Hex
(Integer (CC
and 16#
0F#
))));
10600 -- Start of processing for Set_Encoded_Interface_Name
10603 -- If first character is asterisk, this is a link name, and we
10604 -- leave it completely unmodified. We also ignore null strings
10605 -- (the latter case happens only in error cases) and no encoding
10606 -- should occur for Java interface names.
10609 or else Get_String_Char
(Str
, 1) = Get_Char_Code
('*')
10612 Set_Interface_Name
(E
, S
);
10617 CC
:= Get_String_Char
(Str
, J
);
10619 exit when not In_Character_Range
(CC
);
10621 C
:= Get_Character
(CC
);
10623 exit when C
/= '_' and then C
/= '$'
10624 and then C
not in '0' .. '9'
10625 and then C
not in 'a' .. 'z'
10626 and then C
not in 'A' .. 'Z';
10629 Set_Interface_Name
(E
, S
);
10637 -- Here we need to encode. The encoding we use as follows:
10638 -- three underscores + four hex digits (lower case)
10642 for J
in 1 .. String_Length
(Str
) loop
10643 CC
:= Get_String_Char
(Str
, J
);
10645 if not In_Character_Range
(CC
) then
10648 C
:= Get_Character
(CC
);
10650 if C
= '_' or else C
= '$'
10651 or else C
in '0' .. '9'
10652 or else C
in 'a' .. 'z'
10653 or else C
in 'A' .. 'Z'
10655 Store_String_Char
(CC
);
10662 Set_Interface_Name
(E
,
10663 Make_String_Literal
(Sloc
(S
),
10664 Strval
=> End_String
));
10666 end Set_Encoded_Interface_Name
;
10668 -------------------
10669 -- Set_Unit_Name --
10670 -------------------
10672 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
) is
10677 if Nkind
(N
) = N_Identifier
10678 and then Nkind
(With_Item
) = N_Identifier
10680 Set_Entity
(N
, Entity
(With_Item
));
10682 elsif Nkind
(N
) = N_Selected_Component
then
10683 Change_Selected_Component_To_Expanded_Name
(N
);
10684 Set_Entity
(N
, Entity
(With_Item
));
10685 Set_Entity
(Selector_Name
(N
), Entity
(N
));
10687 Pref
:= Prefix
(N
);
10688 Scop
:= Scope
(Entity
(N
));
10690 while Nkind
(Pref
) = N_Selected_Component
loop
10691 Change_Selected_Component_To_Expanded_Name
(Pref
);
10692 Set_Entity
(Selector_Name
(Pref
), Scop
);
10693 Set_Entity
(Pref
, Scop
);
10694 Pref
:= Prefix
(Pref
);
10695 Scop
:= Scope
(Scop
);
10698 Set_Entity
(Pref
, Scop
);