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.
2933 while Present
(Hom_Id
) loop
2934 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
2936 -- Ignore inherited subprograms because the pragma will
2937 -- apply to the parent operation, which is the one called.
2939 if Is_Overloadable
(Def_Id
)
2940 and then Present
(Alias
(Def_Id
))
2944 -- If it is not a subprogram, it must be in an outer
2945 -- scope and pragma does not apply.
2947 elsif not Is_Subprogram
(Def_Id
)
2948 and then not Is_Generic_Subprogram
(Def_Id
)
2952 -- Verify that the homonym is in the same declarative
2953 -- part (not just the same scope).
2955 elsif Parent
(Unit_Declaration_Node
(Def_Id
)) /= Parent
(N
)
2956 and then Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
2961 Set_Imported
(Def_Id
);
2963 -- If Import intrinsic, set intrinsic flag
2964 -- and verify that it is known as such.
2966 if C
= Convention_Intrinsic
then
2967 Set_Is_Intrinsic_Subprogram
(Def_Id
);
2968 Check_Intrinsic_Subprogram
2969 (Def_Id
, Expression
(Arg2
));
2972 -- All interfaced procedures need an external
2973 -- symbol created for them since they are
2974 -- always referenced from another object file.
2976 Set_Is_Public
(Def_Id
);
2978 -- Verify that the subprogram does not have a completion
2979 -- through a renaming declaration. For other completions
2980 -- the pragma appears as a too late representation.
2983 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Def_Id
);
2987 and then Nkind
(Decl
) = N_Subprogram_Declaration
2988 and then Present
(Corresponding_Body
(Decl
))
2991 (Unit_Declaration_Node
2992 (Corresponding_Body
(Decl
))) =
2993 N_Subprogram_Renaming_Declaration
2995 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2996 Error_Msg_NE
("cannot import&#," &
2997 " already completed by a renaming",
3002 Set_Has_Completion
(Def_Id
);
3003 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3006 if Is_Compilation_Unit
(Hom_Id
) then
3008 -- Its possible homonyms are not affected by the pragma.
3009 -- Such homonyms might be present in the context of other
3010 -- units being compiled.
3015 Hom_Id
:= Homonym
(Hom_Id
);
3019 -- When the convention is Java, we also allow Import to be given
3020 -- for packages, exceptions, and record components.
3022 elsif C
= Convention_Java
3024 (Ekind
(Def_Id
) = E_Package
3025 or else Ekind
(Def_Id
) = E_Exception
3026 or else Nkind
(Parent
(Def_Id
)) = N_Component_Declaration
)
3028 Set_Imported
(Def_Id
);
3029 Set_Is_Public
(Def_Id
);
3030 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3034 ("second argument of pragma% must be object or subprogram",
3038 -- If this pragma applies to a compilation unit, then the unit,
3039 -- which is a subprogram, does not require (or allow) a body.
3040 -- We also do not need to elaborate imported procedures.
3042 if Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
3044 Cunit
: constant Node_Id
:= Parent
(Parent
(N
));
3046 Set_Body_Required
(Cunit
, False);
3049 end Process_Import_Or_Interface
;
3051 --------------------
3052 -- Process_Inline --
3053 --------------------
3055 procedure Process_Inline
(Active
: Boolean) is
3061 Effective
: Boolean := False;
3063 procedure Make_Inline
(Subp
: Entity_Id
);
3064 -- Subp is the defining unit name of the subprogram
3065 -- declaration. Set the flag, as well as the flag in the
3066 -- corresponding body, if there is one present.
3068 procedure Set_Inline_Flags
(Subp
: Entity_Id
);
3069 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp
3071 function Cannot_Inline
(Subp
: Entity_Id
) return Boolean;
3072 -- Do not set the inline flag if body is available and contains
3073 -- exception handlers, to prevent undefined symbols at link time.
3074 -- Emit warning if front-end inlining is enabled and the pragma
3075 -- appears too late.
3081 function Cannot_Inline
(Subp
: Entity_Id
) return Boolean is
3082 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Subp
);
3085 if Nkind
(Decl
) = N_Subprogram_Body
then
3088 (Exception_Handlers
(Handled_Statement_Sequence
(Decl
)));
3090 elsif Nkind
(Decl
) = N_Subprogram_Declaration
3091 and then Present
(Corresponding_Body
(Decl
))
3093 if Front_End_Inlining
3094 and then Analyzed
(Corresponding_Body
(Decl
))
3096 Error_Msg_N
("pragma appears too late, ignored?", N
);
3099 -- If the subprogram is a renaming as body, the body is
3100 -- just a call to the renamed subprogram, and inlining is
3101 -- trivially possible.
3104 Nkind
(Unit_Declaration_Node
(Corresponding_Body
(Decl
)))
3105 = N_Subprogram_Renaming_Declaration
3111 Present
(Exception_Handlers
3112 (Handled_Statement_Sequence
3113 (Unit_Declaration_Node
(Corresponding_Body
(Decl
)))));
3116 -- If body is not available, assume the best, the check is
3117 -- performed again when compiling enclosing package bodies.
3127 procedure Make_Inline
(Subp
: Entity_Id
) is
3128 Kind
: constant Entity_Kind
:= Ekind
(Subp
);
3129 Inner_Subp
: Entity_Id
:= Subp
;
3132 if Etype
(Subp
) = Any_Type
then
3135 elsif Cannot_Inline
(Subp
) then
3136 Applies
:= True; -- Do not treat as an error.
3139 -- Here we have a candidate for inlining, but we must exclude
3140 -- derived operations. Otherwise we will end up trying to
3141 -- inline a phantom declaration, and the result would be to
3142 -- drag in a body which has no direct inlining associated with
3143 -- it. That would not only be inefficient but would also result
3144 -- in the backend doing cross-unit inlining in cases where it
3145 -- was definitely inappropriate to do so.
3147 -- However, a simple Comes_From_Source test is insufficient,
3148 -- since we do want to allow inlining of generic instances,
3149 -- which also do not come from source. Predefined operators do
3150 -- not come from source but are not inlineable either.
3152 elsif not Comes_From_Source
(Subp
)
3153 and then not Is_Generic_Instance
(Subp
)
3154 and then Scope
(Subp
) /= Standard_Standard
3159 -- The referenced entity must either be the enclosing entity,
3160 -- or an entity declared within the current open scope.
3162 elsif Present
(Scope
(Subp
))
3163 and then Scope
(Subp
) /= Current_Scope
3164 and then Subp
/= Current_Scope
3167 ("argument of% must be entity in current scope", Assoc
);
3171 -- Processing for procedure, operator or function.
3172 -- If subprogram is aliased (as for an instance) indicate
3173 -- that the renamed entity (if declared in the same unit)
3176 if Is_Subprogram
(Subp
) then
3177 while Present
(Alias
(Inner_Subp
)) loop
3178 Inner_Subp
:= Alias
(Inner_Subp
);
3181 if In_Same_Source_Unit
(Subp
, Inner_Subp
) then
3182 Set_Inline_Flags
(Inner_Subp
);
3184 Decl
:= Parent
(Parent
(Inner_Subp
));
3186 if Nkind
(Decl
) = N_Subprogram_Declaration
3187 and then Present
(Corresponding_Body
(Decl
))
3189 Set_Inline_Flags
(Corresponding_Body
(Decl
));
3195 -- For a generic subprogram set flag as well, for use at
3196 -- the point of instantiation, to determine whether the
3197 -- body should be generated.
3199 elsif Is_Generic_Subprogram
(Subp
) then
3200 Set_Inline_Flags
(Subp
);
3203 -- Literals are by definition inlined
3205 elsif Kind
= E_Enumeration_Literal
then
3208 -- Anything else is an error
3212 ("expect subprogram name for pragma%", Assoc
);
3216 ----------------------
3217 -- Set_Inline_Flags --
3218 ----------------------
3220 procedure Set_Inline_Flags
(Subp
: Entity_Id
) is
3223 Set_Is_Inlined
(Subp
, True);
3226 if not Has_Pragma_Inline
(Subp
) then
3227 Set_Has_Pragma_Inline
(Subp
);
3228 Set_Next_Rep_Item
(N
, First_Rep_Item
(Subp
));
3229 Set_First_Rep_Item
(Subp
, N
);
3232 end Set_Inline_Flags
;
3234 -- Start of processing for Process_Inline
3237 Check_No_Identifiers
;
3238 Check_At_Least_N_Arguments
(1);
3241 Inline_Processing_Required
:= True;
3245 while Present
(Assoc
) loop
3246 Subp_Id
:= Expression
(Assoc
);
3250 if Is_Entity_Name
(Subp_Id
) then
3251 Subp
:= Entity
(Subp_Id
);
3253 if Subp
= Any_Id
then
3259 while Present
(Homonym
(Subp
))
3260 and then Scope
(Homonym
(Subp
)) = Current_Scope
3262 Make_Inline
(Homonym
(Subp
));
3263 Subp
:= Homonym
(Subp
);
3270 ("inappropriate argument for pragma%", Assoc
);
3273 and then Warn_On_Redundant_Constructs
3275 Error_Msg_NE
("pragma inline on& is redundant?",
3276 N
, Entity
(Subp_Id
));
3283 ----------------------------
3284 -- Process_Interface_Name --
3285 ----------------------------
3287 procedure Process_Interface_Name
3288 (Subprogram_Def
: Entity_Id
;
3294 String_Val
: String_Id
;
3296 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
);
3297 -- SN is a string literal node for an interface name. This routine
3298 -- performs some minimal checks that the name is reasonable. In
3299 -- particular that no spaces or other obviously incorrect characters
3300 -- appear. This is only a warning, since any characters are allowed.
3302 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
) is
3303 S
: constant String_Id
:= Strval
(Expr_Value_S
(SN
));
3304 SL
: constant Nat
:= String_Length
(S
);
3309 Error_Msg_N
("interface name cannot be null string", SN
);
3312 for J
in 1 .. SL
loop
3313 C
:= Get_String_Char
(S
, J
);
3315 if Warn_On_Export_Import
3316 and then (not In_Character_Range
(C
)
3317 or else Get_Character
(C
) = ' '
3318 or else Get_Character
(C
) = ',')
3321 ("?interface name contains illegal character", SN
);
3324 end Check_Form_Of_Interface_Name
;
3326 -- Start of processing for Process_Interface_Name
3329 if No
(Link_Arg
) then
3330 if No
(Ext_Arg
) then
3333 elsif Chars
(Ext_Arg
) = Name_Link_Name
then
3335 Link_Nam
:= Expression
(Ext_Arg
);
3338 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
3339 Ext_Nam
:= Expression
(Ext_Arg
);
3344 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
3345 Check_Optional_Identifier
(Link_Arg
, Name_Link_Name
);
3346 Ext_Nam
:= Expression
(Ext_Arg
);
3347 Link_Nam
:= Expression
(Link_Arg
);
3350 -- Check expressions for external name and link name are static
3352 if Present
(Ext_Nam
) then
3353 Check_Arg_Is_Static_Expression
(Ext_Nam
, Standard_String
);
3354 Check_Form_Of_Interface_Name
(Ext_Nam
);
3356 -- Verify that the external name is not the name of a local
3357 -- entity, which would hide the imported one and lead to
3358 -- run-time surprises. The problem can only arise for entities
3359 -- declared in a package body (otherwise the external name is
3360 -- fully qualified and won't conflict).
3368 if Prag_Id
= Pragma_Import
then
3369 String_To_Name_Buffer
(Strval
(Expr_Value_S
(Ext_Nam
)));
3371 E
:= Entity_Id
(Get_Name_Table_Info
(Nam
));
3373 if Nam
/= Chars
(Subprogram_Def
)
3374 and then Present
(E
)
3375 and then not Is_Overloadable
(E
)
3376 and then Is_Immediately_Visible
(E
)
3377 and then not Is_Imported
(E
)
3378 and then Ekind
(Scope
(E
)) = E_Package
3382 while Present
(Par
) loop
3383 if Nkind
(Par
) = N_Package_Body
then
3384 Error_Msg_Sloc
:= Sloc
(E
);
3386 ("imported entity is hidden by & declared#",
3391 Par
:= Parent
(Par
);
3398 if Present
(Link_Nam
) then
3399 Check_Arg_Is_Static_Expression
(Link_Nam
, Standard_String
);
3400 Check_Form_Of_Interface_Name
(Link_Nam
);
3403 -- If there is no link name, just set the external name
3405 if No
(Link_Nam
) then
3406 Link_Nam
:= Adjust_External_Name_Case
(Expr_Value_S
(Ext_Nam
));
3408 -- For the Link_Name case, the given literal is preceded by an
3409 -- asterisk, which indicates to GCC that the given name should
3410 -- be taken literally, and in particular that no prepending of
3411 -- underlines should occur, even in systems where this is the
3416 Store_String_Char
(Get_Char_Code
('*'));
3417 String_Val
:= Strval
(Expr_Value_S
(Link_Nam
));
3419 for J
in 1 .. String_Length
(String_Val
) loop
3420 Store_String_Char
(Get_String_Char
(String_Val
, J
));
3424 Make_String_Literal
(Sloc
(Link_Nam
), End_String
);
3427 Set_Encoded_Interface_Name
3428 (Get_Base_Subprogram
(Subprogram_Def
), Link_Nam
);
3429 Check_Duplicated_Export_Name
(Link_Nam
);
3430 end Process_Interface_Name
;
3432 -----------------------------------------
3433 -- Process_Interrupt_Or_Attach_Handler --
3434 -----------------------------------------
3436 procedure Process_Interrupt_Or_Attach_Handler
is
3437 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
3438 Handler_Proc
: constant Entity_Id
:= Entity
(Arg1_X
);
3439 Proc_Scope
: constant Entity_Id
:= Scope
(Handler_Proc
);
3442 Set_Is_Interrupt_Handler
(Handler_Proc
);
3444 -- If the pragma is not associated with a handler procedure
3445 -- within a protected type, then it must be for a nonprotected
3446 -- procedure for the AAMP target, in which case we don't
3447 -- associate a representation item with the procedure's scope.
3449 if Ekind
(Proc_Scope
) = E_Protected_Type
then
3450 if Prag_Id
= Pragma_Interrupt_Handler
3452 Prag_Id
= Pragma_Attach_Handler
3454 Record_Rep_Item
(Proc_Scope
, N
);
3457 end Process_Interrupt_Or_Attach_Handler
;
3459 --------------------------------------------------
3460 -- Process_Restrictions_Or_Restriction_Warnings --
3461 --------------------------------------------------
3463 procedure Process_Restrictions_Or_Restriction_Warnings
is
3465 R_Id
: Restriction_Id
;
3470 procedure Set_Warning
(R
: All_Restrictions
);
3471 -- If this is a Restriction_Warnings pragma, set warning flag,
3472 -- otherwise reset the flag.
3478 procedure Set_Warning
(R
: All_Restrictions
) is
3480 if Prag_Id
= Pragma_Restriction_Warnings
then
3481 Restriction_Warnings
(R
) := True;
3483 Restriction_Warnings
(R
) := False;
3487 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
3490 Check_Ada_83_Warning
;
3491 Check_At_Least_N_Arguments
(1);
3492 Check_Valid_Configuration_Pragma
;
3495 while Present
(Arg
) loop
3497 Expr
:= Expression
(Arg
);
3499 -- Case of no restriction identifier present
3501 if Id
= No_Name
then
3502 if Nkind
(Expr
) /= N_Identifier
then
3504 ("invalid form for restriction", Arg
);
3509 (Process_Restriction_Synonyms
(Expr
));
3511 if R_Id
not in All_Boolean_Restrictions
then
3513 ("invalid restriction identifier", Arg
);
3516 if Implementation_Restriction
(R_Id
) then
3518 (No_Implementation_Restrictions
, Arg
);
3521 Set_Restriction
(R_Id
, N
);
3524 -- A very special case that must be processed here:
3525 -- pragma Restrictions (No_Exceptions) turns off
3526 -- all run-time checking. This is a bit dubious in
3527 -- terms of the formal language definition, but it
3528 -- is what is intended by RM H.4(12).
3530 if R_Id
= No_Exceptions
then
3531 Scope_Suppress
:= (others => True);
3534 -- Case of restriction identifier present
3537 R_Id
:= Get_Restriction_Id
(Process_Restriction_Synonyms
(Arg
));
3538 Analyze_And_Resolve
(Expr
, Any_Integer
);
3540 if R_Id
not in All_Parameter_Restrictions
then
3542 ("invalid restriction parameter identifier", Arg
);
3544 elsif not Is_OK_Static_Expression
(Expr
) then
3545 Flag_Non_Static_Expr
3546 ("value must be static expression!", Expr
);
3549 elsif not Is_Integer_Type
(Etype
(Expr
))
3550 or else Expr_Value
(Expr
) < 0
3553 ("value must be non-negative integer", Arg
);
3555 -- Restriction pragma is active
3558 Val
:= Expr_Value
(Expr
);
3560 if not UI_Is_In_Int_Range
(Val
) then
3562 ("pragma ignored, value too large?", Arg
);
3564 Set_Restriction
(R_Id
, N
, Integer (UI_To_Int
(Val
)));
3572 end Process_Restrictions_Or_Restriction_Warnings
;
3574 ---------------------------------
3575 -- Process_Suppress_Unsuppress --
3576 ---------------------------------
3578 -- Note: this procedure makes entries in the check suppress data
3579 -- structures managed by Sem. See spec of package Sem for full
3580 -- details on how we handle recording of check suppression.
3582 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean) is
3587 In_Package_Spec
: constant Boolean :=
3588 (Ekind
(Current_Scope
) = E_Package
3590 Ekind
(Current_Scope
) = E_Generic_Package
)
3591 and then not In_Package_Body
(Current_Scope
);
3593 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
);
3594 -- Used to suppress a single check on the given entity
3596 --------------------------------
3597 -- Suppress_Unsuppress_Echeck --
3598 --------------------------------
3600 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
) is
3601 ESR
: constant Entity_Check_Suppress_Record
:=
3604 Suppress
=> Suppress_Case
);
3607 Set_Checks_May_Be_Suppressed
(E
);
3609 if In_Package_Spec
then
3610 Global_Entity_Suppress
.Append
(ESR
);
3612 Local_Entity_Suppress
.Append
(ESR
);
3615 -- If this is a first subtype, and the base type is distinct,
3616 -- then also set the suppress flags on the base type.
3618 if Is_First_Subtype
(E
)
3619 and then Etype
(E
) /= E
3621 Suppress_Unsuppress_Echeck
(Etype
(E
), C
);
3623 end Suppress_Unsuppress_Echeck
;
3625 -- Start of processing for Process_Suppress_Unsuppress
3628 -- Suppress/Unsuppress can appear as a configuration pragma,
3629 -- or in a declarative part or a package spec (RM 11.5(5))
3631 if not Is_Configuration_Pragma
then
3632 Check_Is_In_Decl_Part_Or_Package_Spec
;
3635 Check_At_Least_N_Arguments
(1);
3636 Check_At_Most_N_Arguments
(2);
3637 Check_No_Identifier
(Arg1
);
3638 Check_Arg_Is_Identifier
(Arg1
);
3640 if not Is_Check_Name
(Chars
(Expression
(Arg1
))) then
3642 ("argument of pragma% is not valid check name", Arg1
);
3644 C
:= Get_Check_Id
(Chars
(Expression
(Arg1
)));
3647 if Arg_Count
= 1 then
3649 -- Make an entry in the local scope suppress table. This is the
3650 -- table that directly shows the current value of the scope
3651 -- suppress check for any check id value.
3653 if C
= All_Checks
then
3654 for J
in Scope_Suppress
'Range loop
3655 Scope_Suppress
(J
) := Suppress_Case
;
3658 Scope_Suppress
(C
) := Suppress_Case
;
3661 -- Also make an entry in the Local_Entity_Suppress table. See
3662 -- extended description in the package spec of Sem for details.
3664 Local_Entity_Suppress
.Append
3667 Suppress
=> Suppress_Case
));
3669 -- Case of two arguments present, where the check is
3670 -- suppressed for a specified entity (given as the second
3671 -- argument of the pragma)
3674 Check_Optional_Identifier
(Arg2
, Name_On
);
3675 E_Id
:= Expression
(Arg2
);
3678 if not Is_Entity_Name
(E_Id
) then
3680 ("second argument of pragma% must be entity name", Arg2
);
3689 -- Enforce RM 11.5(7) which requires that for a pragma that
3690 -- appears within a package spec, the named entity must be
3691 -- within the package spec. We allow the package name itself
3692 -- to be mentioned since that makes sense, although it is not
3693 -- strictly allowed by 11.5(7).
3696 and then E
/= Current_Scope
3697 and then Scope
(E
) /= Current_Scope
3700 ("entity in pragma% is not in package spec ('R'M 11.5(7))",
3704 -- Loop through homonyms. As noted below, in the case of a package
3705 -- spec, only homonyms within the package spec are considered.
3708 Suppress_Unsuppress_Echeck
(E
, C
);
3710 if Is_Generic_Instance
(E
)
3711 and then Is_Subprogram
(E
)
3712 and then Present
(Alias
(E
))
3714 Suppress_Unsuppress_Echeck
(Alias
(E
), C
);
3717 -- Move to next homonym
3722 -- If we are within a package specification, the
3723 -- pragma only applies to homonyms in the same scope.
3725 exit when In_Package_Spec
3726 and then Scope
(E
) /= Current_Scope
;
3729 end Process_Suppress_Unsuppress
;
3735 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
) is
3737 if Is_Imported
(E
) then
3739 ("cannot export entity& that was previously imported", Arg
);
3741 elsif Present
(Address_Clause
(E
)) then
3743 ("cannot export entity& that has an address clause", Arg
);
3746 Set_Is_Exported
(E
);
3748 -- Generate a reference for entity explicitly, because the
3749 -- identifier may be overloaded and name resolution will not
3752 Generate_Reference
(E
, Arg
);
3754 -- Deal with exporting non-library level entity
3756 if not Is_Library_Level_Entity
(E
) then
3758 -- Not allowed at all for subprograms
3760 if Is_Subprogram
(E
) then
3761 Error_Pragma_Arg
("local subprogram& cannot be exported", Arg
);
3763 -- Otherwise set public and statically allocated
3767 Set_Is_Statically_Allocated
(E
);
3769 -- Warn if the corresponding W flag is set and the pragma
3770 -- comes from source. The latter may not be true e.g. on
3771 -- VMS where we expand export pragmas for exception codes
3772 -- associated with imported or exported exceptions. We do
3773 -- not want to generate a warning for something that the
3774 -- user did not write.
3776 if Warn_On_Export_Import
3777 and then Comes_From_Source
(Arg
)
3780 ("?& has been made static as a result of Export", Arg
, E
);
3782 ("\this usage is non-standard and non-portable", Arg
);
3787 if Warn_On_Export_Import
and then Is_Type
(E
) then
3789 ("exporting a type has no effect?", Arg
, E
);
3792 if Warn_On_Export_Import
and Inside_A_Generic
then
3794 ("all instances of& will have the same external name?", Arg
, E
);
3798 ----------------------------------------------
3799 -- Set_Extended_Import_Export_External_Name --
3800 ----------------------------------------------
3802 procedure Set_Extended_Import_Export_External_Name
3803 (Internal_Ent
: Entity_Id
;
3804 Arg_External
: Node_Id
)
3806 Old_Name
: constant Node_Id
:= Interface_Name
(Internal_Ent
);
3810 if No
(Arg_External
) then
3814 Check_Arg_Is_External_Name
(Arg_External
);
3816 if Nkind
(Arg_External
) = N_String_Literal
then
3817 if String_Length
(Strval
(Arg_External
)) = 0 then
3820 New_Name
:= Adjust_External_Name_Case
(Arg_External
);
3823 elsif Nkind
(Arg_External
) = N_Identifier
then
3824 New_Name
:= Get_Default_External_Name
(Arg_External
);
3826 -- Check_Arg_Is_External_Name should let through only
3827 -- identifiers and string literals or static string
3828 -- expressions (which are folded to string literals).
3831 raise Program_Error
;
3834 -- If we already have an external name set (by a prior normal
3835 -- Import or Export pragma), then the external names must match
3837 if Present
(Interface_Name
(Internal_Ent
)) then
3839 S1
: constant String_Id
:= Strval
(Old_Name
);
3840 S2
: constant String_Id
:= Strval
(New_Name
);
3843 -- Called if names do not match
3845 procedure Mismatch
is
3847 Error_Msg_Sloc
:= Sloc
(Old_Name
);
3849 ("external name does not match that given #",
3854 if String_Length
(S1
) /= String_Length
(S2
) then
3858 for J
in 1 .. String_Length
(S1
) loop
3859 if Get_String_Char
(S1
, J
) /= Get_String_Char
(S2
, J
) then
3866 -- Otherwise set the given name
3869 Set_Encoded_Interface_Name
(Internal_Ent
, New_Name
);
3870 Check_Duplicated_Export_Name
(New_Name
);
3872 end Set_Extended_Import_Export_External_Name
;
3878 procedure Set_Imported
(E
: Entity_Id
) is
3880 Error_Msg_Sloc
:= Sloc
(E
);
3882 if Is_Exported
(E
) or else Is_Imported
(E
) then
3883 Error_Msg_NE
("import of& declared# not allowed", N
, E
);
3885 if Is_Exported
(E
) then
3886 Error_Msg_N
("\entity was previously exported", N
);
3888 Error_Msg_N
("\entity was previously imported", N
);
3891 Error_Pragma
("\(pragma% applies to all previous entities)");
3894 Set_Is_Imported
(E
);
3896 -- If the entity is an object that is not at the library
3897 -- level, then it is statically allocated. We do not worry
3898 -- about objects with address clauses in this context since
3899 -- they are not really imported in the linker sense.
3902 and then not Is_Library_Level_Entity
(E
)
3903 and then No
(Address_Clause
(E
))
3905 Set_Is_Statically_Allocated
(E
);
3910 -------------------------
3911 -- Set_Mechanism_Value --
3912 -------------------------
3914 -- Note: the mechanism name has not been analyzed (and cannot indeed
3915 -- be analyzed, since it is semantic nonsense), so we get it in the
3916 -- exact form created by the parser.
3918 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
) is
3922 procedure Bad_Class
;
3923 -- Signal bad descriptor class name
3925 procedure Bad_Mechanism
;
3926 -- Signal bad mechanism name
3928 procedure Bad_Class
is
3930 Error_Pragma_Arg
("unrecognized descriptor class name", Class
);
3933 procedure Bad_Mechanism
is
3935 Error_Pragma_Arg
("unrecognized mechanism name", Mech_Name
);
3938 -- Start of processing for Set_Mechanism_Value
3941 if Mechanism
(Ent
) /= Default_Mechanism
then
3943 ("mechanism for & has already been set", Mech_Name
, Ent
);
3946 -- MECHANISM_NAME ::= value | reference | descriptor
3948 if Nkind
(Mech_Name
) = N_Identifier
then
3949 if Chars
(Mech_Name
) = Name_Value
then
3950 Set_Mechanism
(Ent
, By_Copy
);
3953 elsif Chars
(Mech_Name
) = Name_Reference
then
3954 Set_Mechanism
(Ent
, By_Reference
);
3957 elsif Chars
(Mech_Name
) = Name_Descriptor
then
3958 Check_VMS
(Mech_Name
);
3959 Set_Mechanism
(Ent
, By_Descriptor
);
3962 elsif Chars
(Mech_Name
) = Name_Copy
then
3964 ("bad mechanism name, Value assumed", Mech_Name
);
3970 -- MECHANISM_NAME ::= descriptor (CLASS_NAME)
3971 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3973 -- Note: this form is parsed as an indexed component
3975 elsif Nkind
(Mech_Name
) = N_Indexed_Component
then
3976 Class
:= First
(Expressions
(Mech_Name
));
3978 if Nkind
(Prefix
(Mech_Name
)) /= N_Identifier
3979 or else Chars
(Prefix
(Mech_Name
)) /= Name_Descriptor
3980 or else Present
(Next
(Class
))
3985 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME)
3986 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3988 -- Note: this form is parsed as a function call
3990 elsif Nkind
(Mech_Name
) = N_Function_Call
then
3992 Param
:= First
(Parameter_Associations
(Mech_Name
));
3994 if Nkind
(Name
(Mech_Name
)) /= N_Identifier
3995 or else Chars
(Name
(Mech_Name
)) /= Name_Descriptor
3996 or else Present
(Next
(Param
))
3997 or else No
(Selector_Name
(Param
))
3998 or else Chars
(Selector_Name
(Param
)) /= Name_Class
4002 Class
:= Explicit_Actual_Parameter
(Param
);
4009 -- Fall through here with Class set to descriptor class name
4011 Check_VMS
(Mech_Name
);
4013 if Nkind
(Class
) /= N_Identifier
then
4016 elsif Chars
(Class
) = Name_UBS
then
4017 Set_Mechanism
(Ent
, By_Descriptor_UBS
);
4019 elsif Chars
(Class
) = Name_UBSB
then
4020 Set_Mechanism
(Ent
, By_Descriptor_UBSB
);
4022 elsif Chars
(Class
) = Name_UBA
then
4023 Set_Mechanism
(Ent
, By_Descriptor_UBA
);
4025 elsif Chars
(Class
) = Name_S
then
4026 Set_Mechanism
(Ent
, By_Descriptor_S
);
4028 elsif Chars
(Class
) = Name_SB
then
4029 Set_Mechanism
(Ent
, By_Descriptor_SB
);
4031 elsif Chars
(Class
) = Name_A
then
4032 Set_Mechanism
(Ent
, By_Descriptor_A
);
4034 elsif Chars
(Class
) = Name_NCA
then
4035 Set_Mechanism
(Ent
, By_Descriptor_NCA
);
4041 end Set_Mechanism_Value
;
4043 ---------------------------
4044 -- Set_Ravenscar_Profile --
4045 ---------------------------
4047 -- The tasks to be done here are
4049 -- Set required policies
4051 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4052 -- pragma Locking_Policy (Ceiling_Locking)
4054 -- Set Detect_Blocking mode
4056 -- Set required restrictions (see System.Rident for detailed list)
4058 procedure Set_Ravenscar_Profile
(N
: Node_Id
) is
4060 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4062 if Task_Dispatching_Policy
/= ' '
4063 and then Task_Dispatching_Policy
/= 'F'
4065 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
4066 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4068 -- Set the FIFO_Within_Priorities policy, but always
4069 -- preserve System_Location since we like the error
4070 -- message with the run time name.
4073 Task_Dispatching_Policy
:= 'F';
4075 if Task_Dispatching_Policy_Sloc
/= System_Location
then
4076 Task_Dispatching_Policy_Sloc
:= Loc
;
4080 -- pragma Locking_Policy (Ceiling_Locking)
4082 if Locking_Policy
/= ' '
4083 and then Locking_Policy
/= 'C'
4085 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
4086 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4088 -- Set the Ceiling_Locking policy, but always preserve
4089 -- System_Location since we like the error message with the
4093 Locking_Policy
:= 'C';
4095 if Locking_Policy_Sloc
/= System_Location
then
4096 Locking_Policy_Sloc
:= Loc
;
4100 -- pragma Detect_Blocking
4102 Detect_Blocking
:= True;
4104 -- Set the corresponding restrictions
4106 Set_Profile_Restrictions
(Ravenscar
, N
, Warn
=> False);
4107 end Set_Ravenscar_Profile
;
4109 -- Start of processing for Analyze_Pragma
4112 if not Is_Pragma_Name
(Chars
(N
)) then
4113 if Warn_On_Unrecognized_Pragma
then
4114 Error_Pragma
("unrecognized pragma%!?");
4119 Prag_Id
:= Get_Pragma_Id
(Chars
(N
));
4129 if Present
(Pragma_Argument_Associations
(N
)) then
4130 Arg1
:= First
(Pragma_Argument_Associations
(N
));
4132 if Present
(Arg1
) then
4133 Arg2
:= Next
(Arg1
);
4135 if Present
(Arg2
) then
4136 Arg3
:= Next
(Arg2
);
4138 if Present
(Arg3
) then
4139 Arg4
:= Next
(Arg3
);
4145 -- Count number of arguments
4152 while Present
(Arg_Node
) loop
4153 Arg_Count
:= Arg_Count
+ 1;
4158 -- An enumeration type defines the pragmas that are supported by the
4159 -- implementation. Get_Pragma_Id (in package Prag) transorms a name
4160 -- into the corresponding enumeration value for the following case.
4168 -- pragma Abort_Defer;
4170 when Pragma_Abort_Defer
=>
4172 Check_Arg_Count
(0);
4174 -- The only required semantic processing is to check the
4175 -- placement. This pragma must appear at the start of the
4176 -- statement sequence of a handled sequence of statements.
4178 if Nkind
(Parent
(N
)) /= N_Handled_Sequence_Of_Statements
4179 or else N
/= First
(Statements
(Parent
(N
)))
4190 -- Note: this pragma also has some specific processing in Par.Prag
4191 -- because we want to set the Ada version mode during parsing.
4193 when Pragma_Ada_83
=>
4195 Ada_Version
:= Ada_83
;
4196 Check_Arg_Count
(0);
4204 -- Note: this pragma also has some specific processing in Par.Prag
4205 -- because we want to set the Ada 83 version mode during parsing.
4207 when Pragma_Ada_95
=>
4209 Ada_Version
:= Ada_95
;
4210 Check_Arg_Count
(0);
4218 -- Note: this pragma also has some specific processing in Par.Prag
4219 -- because we want to set the Ada 83 version mode during parsing.
4221 when Pragma_Ada_05
=>
4223 Ada_Version
:= Ada_05
;
4224 Check_Arg_Count
(0);
4226 ----------------------
4227 -- All_Calls_Remote --
4228 ----------------------
4230 -- pragma All_Calls_Remote [(library_package_NAME)];
4232 when Pragma_All_Calls_Remote
=> All_Calls_Remote
: declare
4233 Lib_Entity
: Entity_Id
;
4236 Check_Ada_83_Warning
;
4237 Check_Valid_Library_Unit_Pragma
;
4239 if Nkind
(N
) = N_Null_Statement
then
4243 Lib_Entity
:= Find_Lib_Unit_Name
;
4245 -- This pragma should only apply to a RCI unit (RM E.2.3(23)).
4247 if Present
(Lib_Entity
)
4248 and then not Debug_Flag_U
4250 if not Is_Remote_Call_Interface
(Lib_Entity
) then
4251 Error_Pragma
("pragma% only apply to rci unit");
4253 -- Set flag for entity of the library unit
4256 Set_Has_All_Calls_Remote
(Lib_Entity
);
4260 end All_Calls_Remote
;
4266 -- pragma Annotate (IDENTIFIER {, ARG});
4267 -- ARG ::= NAME | EXPRESSION
4269 when Pragma_Annotate
=> Annotate
: begin
4271 Check_At_Least_N_Arguments
(1);
4272 Check_Arg_Is_Identifier
(Arg1
);
4275 Arg
: Node_Id
:= Arg2
;
4279 while Present
(Arg
) loop
4280 Exp
:= Expression
(Arg
);
4283 if Is_Entity_Name
(Exp
) then
4286 elsif Nkind
(Exp
) = N_String_Literal
then
4287 Resolve
(Exp
, Standard_String
);
4289 elsif Is_Overloaded
(Exp
) then
4290 Error_Pragma_Arg
("ambiguous argument for pragma%", Exp
);
4305 -- pragma Assert (Boolean_EXPRESSION [, static_string_EXPRESSION]);
4307 when Pragma_Assert
=>
4309 Check_No_Identifiers
;
4311 if Arg_Count
> 1 then
4312 Check_Arg_Count
(2);
4313 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
4316 -- If expansion is active and assertions are inactive, then
4317 -- we rewrite the Assertion as:
4319 -- if False and then condition then
4323 -- The reason we do this rewriting during semantic analysis
4324 -- rather than as part of normal expansion is that we cannot
4325 -- analyze and expand the code for the boolean expression
4326 -- directly, or it may cause insertion of actions that would
4327 -- escape the attempt to suppress the assertion code.
4329 if Expander_Active
and not Assertions_Enabled
then
4331 Make_If_Statement
(Loc
,
4334 Left_Opnd
=> New_Occurrence_Of
(Standard_False
, Loc
),
4335 Right_Opnd
=> Get_Pragma_Arg
(Arg1
)),
4336 Then_Statements
=> New_List
(
4337 Make_Null_Statement
(Loc
))));
4341 -- Otherwise (if assertions are enabled, or if we are not
4342 -- operating with expansion active), then we just analyze
4343 -- and resolve the expression.
4346 Analyze_And_Resolve
(Expression
(Arg1
), Any_Boolean
);
4353 -- pragma AST_Entry (entry_IDENTIFIER);
4355 when Pragma_AST_Entry
=> AST_Entry
: declare
4361 Check_Arg_Count
(1);
4362 Check_No_Identifiers
;
4363 Check_Arg_Is_Local_Name
(Arg1
);
4364 Ent
:= Entity
(Expression
(Arg1
));
4366 -- Note: the implementation of the AST_Entry pragma could handle
4367 -- the entry family case fine, but for now we are consistent with
4368 -- the DEC rules, and do not allow the pragma, which of course
4369 -- has the effect of also forbidding the attribute.
4371 if Ekind
(Ent
) /= E_Entry
then
4373 ("pragma% argument must be simple entry name", Arg1
);
4375 elsif Is_AST_Entry
(Ent
) then
4377 ("duplicate % pragma for entry", Arg1
);
4379 elsif Has_Homonym
(Ent
) then
4381 ("pragma% argument cannot specify overloaded entry", Arg1
);
4385 FF
: constant Entity_Id
:= First_Formal
(Ent
);
4388 if Present
(FF
) then
4389 if Present
(Next_Formal
(FF
)) then
4391 ("entry for pragma% can have only one argument",
4394 elsif Parameter_Mode
(FF
) /= E_In_Parameter
then
4396 ("entry parameter for pragma% must have mode IN",
4402 Set_Is_AST_Entry
(Ent
);
4410 -- pragma Asynchronous (LOCAL_NAME);
4412 when Pragma_Asynchronous
=> Asynchronous
: declare
4420 procedure Process_Async_Pragma
;
4421 -- Common processing for procedure and access-to-procedure case
4423 --------------------------
4424 -- Process_Async_Pragma --
4425 --------------------------
4427 procedure Process_Async_Pragma
is
4429 if not Present
(L
) then
4430 Set_Is_Asynchronous
(Nm
);
4434 -- The formals should be of mode IN (RM E.4.1(6))
4437 while Present
(S
) loop
4438 Formal
:= Defining_Identifier
(S
);
4440 if Nkind
(Formal
) = N_Defining_Identifier
4441 and then Ekind
(Formal
) /= E_In_Parameter
4444 ("pragma% procedure can only have IN parameter",
4451 Set_Is_Asynchronous
(Nm
);
4452 end Process_Async_Pragma
;
4454 -- Start of processing for pragma Asynchronous
4457 Check_Ada_83_Warning
;
4458 Check_No_Identifiers
;
4459 Check_Arg_Count
(1);
4460 Check_Arg_Is_Local_Name
(Arg1
);
4462 if Debug_Flag_U
then
4466 C_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
4467 Analyze
(Expression
(Arg1
));
4468 Nm
:= Entity
(Expression
(Arg1
));
4470 if not Is_Remote_Call_Interface
(C_Ent
)
4471 and then not Is_Remote_Types
(C_Ent
)
4473 -- This pragma should only appear in an RCI or Remote Types
4474 -- unit (RM E.4.1(4))
4477 ("pragma% not in Remote_Call_Interface or " &
4478 "Remote_Types unit");
4481 if Ekind
(Nm
) = E_Procedure
4482 and then Nkind
(Parent
(Nm
)) = N_Procedure_Specification
4484 if not Is_Remote_Call_Interface
(Nm
) then
4486 ("pragma% cannot be applied on non-remote procedure",
4490 L
:= Parameter_Specifications
(Parent
(Nm
));
4491 Process_Async_Pragma
;
4494 elsif Ekind
(Nm
) = E_Function
then
4496 ("pragma% cannot be applied to function", Arg1
);
4498 elsif Ekind
(Nm
) = E_Record_Type
4499 and then Present
(Corresponding_Remote_Type
(Nm
))
4501 N
:= Declaration_Node
(Corresponding_Remote_Type
(Nm
));
4503 if Nkind
(N
) = N_Full_Type_Declaration
4504 and then Nkind
(Type_Definition
(N
)) =
4505 N_Access_Procedure_Definition
4507 L
:= Parameter_Specifications
(Type_Definition
(N
));
4508 Process_Async_Pragma
;
4512 ("pragma% cannot reference access-to-function type",
4516 -- Only other possibility is Access-to-class-wide type
4518 elsif Is_Access_Type
(Nm
)
4519 and then Is_Class_Wide_Type
(Designated_Type
(Nm
))
4521 Check_First_Subtype
(Arg1
);
4522 Set_Is_Asynchronous
(Nm
);
4523 if Expander_Active
then
4524 RACW_Type_Is_Asynchronous
(Nm
);
4528 Error_Pragma_Arg
("inappropriate argument for pragma%", Arg1
);
4536 -- pragma Atomic (LOCAL_NAME);
4538 when Pragma_Atomic
=>
4539 Process_Atomic_Shared_Volatile
;
4541 -----------------------
4542 -- Atomic_Components --
4543 -----------------------
4545 -- pragma Atomic_Components (array_LOCAL_NAME);
4547 -- This processing is shared by Volatile_Components
4549 when Pragma_Atomic_Components |
4550 Pragma_Volatile_Components
=>
4552 Atomic_Components
: declare
4559 Check_Ada_83_Warning
;
4560 Check_No_Identifiers
;
4561 Check_Arg_Count
(1);
4562 Check_Arg_Is_Local_Name
(Arg1
);
4563 E_Id
:= Expression
(Arg1
);
4565 if Etype
(E_Id
) = Any_Type
then
4571 if Rep_Item_Too_Early
(E
, N
)
4573 Rep_Item_Too_Late
(E
, N
)
4578 D
:= Declaration_Node
(E
);
4581 if (K
= N_Full_Type_Declaration
and then Is_Array_Type
(E
))
4583 ((Ekind
(E
) = E_Constant
or else Ekind
(E
) = E_Variable
)
4584 and then Nkind
(D
) = N_Object_Declaration
4585 and then Nkind
(Object_Definition
(D
)) =
4586 N_Constrained_Array_Definition
)
4588 -- The flag is set on the object, or on the base type
4590 if Nkind
(D
) /= N_Object_Declaration
then
4594 Set_Has_Volatile_Components
(E
);
4596 if Prag_Id
= Pragma_Atomic_Components
then
4597 Set_Has_Atomic_Components
(E
);
4599 if Is_Packed
(E
) then
4600 Set_Is_Packed
(E
, False);
4603 ("?Pack canceled, cannot pack atomic components",
4609 Error_Pragma_Arg
("inappropriate entity for pragma%", Arg1
);
4611 end Atomic_Components
;
4613 --------------------
4614 -- Attach_Handler --
4615 --------------------
4617 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
4619 when Pragma_Attach_Handler
=>
4620 Check_Ada_83_Warning
;
4621 Check_No_Identifiers
;
4622 Check_Arg_Count
(2);
4624 if No_Run_Time_Mode
then
4625 Error_Msg_CRT
("Attach_Handler pragma", N
);
4627 Check_Interrupt_Or_Attach_Handler
;
4629 -- The expression that designates the attribute may
4630 -- depend on a discriminant, and is therefore a per-
4631 -- object expression, to be expanded in the init proc.
4632 -- If expansion is enabled, perform semantic checks
4635 if Expander_Active
then
4637 Temp
: constant Node_Id
:=
4638 New_Copy_Tree
(Expression
(Arg2
));
4640 Set_Parent
(Temp
, N
);
4641 Pre_Analyze_And_Resolve
(Temp
, RTE
(RE_Interrupt_ID
));
4645 Analyze
(Expression
(Arg2
));
4646 Resolve
(Expression
(Arg2
), RTE
(RE_Interrupt_ID
));
4649 Process_Interrupt_Or_Attach_Handler
;
4652 --------------------
4653 -- C_Pass_By_Copy --
4654 --------------------
4656 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
4658 when Pragma_C_Pass_By_Copy
=> C_Pass_By_Copy
: declare
4664 Check_Valid_Configuration_Pragma
;
4665 Check_Arg_Count
(1);
4666 Check_Optional_Identifier
(Arg1
, "max_size");
4668 Arg
:= Expression
(Arg1
);
4669 Check_Arg_Is_Static_Expression
(Arg
, Any_Integer
);
4671 Val
:= Expr_Value
(Arg
);
4675 ("maximum size for pragma% must be positive", Arg1
);
4677 elsif UI_Is_In_Int_Range
(Val
) then
4678 Default_C_Record_Mechanism
:= UI_To_Int
(Val
);
4680 -- If a giant value is given, Int'Last will do well enough.
4681 -- If sometime someone complains that a record larger than
4682 -- two gigabytes is not copied, we will worry about it then!
4685 Default_C_Record_Mechanism
:= Mechanism_Type
'Last;
4693 -- pragma Comment (static_string_EXPRESSION)
4695 -- Processing for pragma Comment shares the circuitry for
4696 -- pragma Ident. The only differences are that Ident enforces
4697 -- a limit of 31 characters on its argument, and also enforces
4698 -- limitations on placement for DEC compatibility. Pragma
4699 -- Comment shares neither of these restrictions.
4705 -- pragma Common_Object (
4706 -- [Internal =>] LOCAL_NAME,
4707 -- [, [External =>] EXTERNAL_SYMBOL]
4708 -- [, [Size =>] EXTERNAL_SYMBOL]);
4710 -- Processing for this pragma is shared with Psect_Object
4712 --------------------------
4713 -- Compile_Time_Warning --
4714 --------------------------
4716 -- pragma Compile_Time_Warning
4717 -- (boolean_EXPRESSION, static_string_EXPRESSION);
4719 when Pragma_Compile_Time_Warning
=> Compile_Time_Warning
: declare
4720 Arg1x
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
4724 Check_Arg_Count
(2);
4725 Check_No_Identifiers
;
4726 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
4727 Analyze_And_Resolve
(Arg1x
, Standard_Boolean
);
4729 if Compile_Time_Known_Value
(Arg1x
) then
4730 if Is_True
(Expr_Value
(Get_Pragma_Arg
(Arg1
))) then
4731 String_To_Name_Buffer
(Strval
(Get_Pragma_Arg
(Arg2
)));
4732 Add_Char_To_Name_Buffer
('?');
4735 Msg
: String (1 .. Name_Len
) :=
4736 Name_Buffer
(1 .. Name_Len
);
4741 -- This loop looks for multiple lines separated by
4742 -- ASCII.LF and breaks them into continuation error
4743 -- messages marked with the usual back slash.
4746 for S
in 2 .. Msg
'Length - 1 loop
4747 if Msg
(S
) = ASCII
.LF
then
4749 Error_Msg_N
(Msg
(B
.. S
), Arg1
);
4755 Error_Msg_N
(Msg
(B
.. Msg
'Length), Arg1
);
4759 end Compile_Time_Warning
;
4761 ----------------------------
4762 -- Complex_Representation --
4763 ----------------------------
4765 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
4767 when Pragma_Complex_Representation
=> Complex_Representation
: declare
4774 Check_Arg_Count
(1);
4775 Check_Optional_Identifier
(Arg1
, Name_Entity
);
4776 Check_Arg_Is_Local_Name
(Arg1
);
4777 E_Id
:= Expression
(Arg1
);
4779 if Etype
(E_Id
) = Any_Type
then
4785 if not Is_Record_Type
(E
) then
4787 ("argument for pragma% must be record type", Arg1
);
4790 Ent
:= First_Entity
(E
);
4793 or else No
(Next_Entity
(Ent
))
4794 or else Present
(Next_Entity
(Next_Entity
(Ent
)))
4795 or else not Is_Floating_Point_Type
(Etype
(Ent
))
4796 or else Etype
(Ent
) /= Etype
(Next_Entity
(Ent
))
4799 ("record for pragma% must have two fields of same fpt type",
4803 Set_Has_Complex_Representation
(Base_Type
(E
));
4805 end Complex_Representation
;
4807 -------------------------
4808 -- Component_Alignment --
4809 -------------------------
4811 -- pragma Component_Alignment (
4812 -- [Form =>] ALIGNMENT_CHOICE
4813 -- [, [Name =>] type_LOCAL_NAME]);
4815 -- ALIGNMENT_CHOICE ::=
4817 -- | Component_Size_4
4821 when Pragma_Component_Alignment
=> Component_AlignmentP
: declare
4822 Args
: Args_List
(1 .. 2);
4823 Names
: constant Name_List
(1 .. 2) := (
4827 Form
: Node_Id
renames Args
(1);
4828 Name
: Node_Id
renames Args
(2);
4830 Atype
: Component_Alignment_Kind
;
4835 Gather_Associations
(Names
, Args
);
4838 Error_Pragma
("missing Form argument for pragma%");
4841 Check_Arg_Is_Identifier
(Form
);
4843 -- Get proper alignment, note that Default = Component_Size
4844 -- on all machines we have so far, and we want to set this
4845 -- value rather than the default value to indicate that it
4846 -- has been explicitly set (and thus will not get overridden
4847 -- by the default component alignment for the current scope)
4849 if Chars
(Form
) = Name_Component_Size
then
4850 Atype
:= Calign_Component_Size
;
4852 elsif Chars
(Form
) = Name_Component_Size_4
then
4853 Atype
:= Calign_Component_Size_4
;
4855 elsif Chars
(Form
) = Name_Default
then
4856 Atype
:= Calign_Component_Size
;
4858 elsif Chars
(Form
) = Name_Storage_Unit
then
4859 Atype
:= Calign_Storage_Unit
;
4863 ("invalid Form parameter for pragma%", Form
);
4866 -- Case with no name, supplied, affects scope table entry
4870 (Scope_Stack
.Last
).Component_Alignment_Default
:= Atype
;
4872 -- Case of name supplied
4875 Check_Arg_Is_Local_Name
(Name
);
4877 Typ
:= Entity
(Name
);
4880 or else Rep_Item_Too_Early
(Typ
, N
)
4884 Typ
:= Underlying_Type
(Typ
);
4887 if not Is_Record_Type
(Typ
)
4888 and then not Is_Array_Type
(Typ
)
4891 ("Name parameter of pragma% must identify record or " &
4892 "array type", Name
);
4895 -- An explicit Component_Alignment pragma overrides an
4896 -- implicit pragma Pack, but not an explicit one.
4898 if not Has_Pragma_Pack
(Base_Type
(Typ
)) then
4899 Set_Is_Packed
(Base_Type
(Typ
), False);
4900 Set_Component_Alignment
(Base_Type
(Typ
), Atype
);
4903 end Component_AlignmentP
;
4909 -- pragma Controlled (first_subtype_LOCAL_NAME);
4911 when Pragma_Controlled
=> Controlled
: declare
4915 Check_No_Identifiers
;
4916 Check_Arg_Count
(1);
4917 Check_Arg_Is_Local_Name
(Arg1
);
4918 Arg
:= Expression
(Arg1
);
4920 if not Is_Entity_Name
(Arg
)
4921 or else not Is_Access_Type
(Entity
(Arg
))
4923 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
4925 Set_Has_Pragma_Controlled
(Base_Type
(Entity
(Arg
)));
4933 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
4934 -- [Entity =>] LOCAL_NAME);
4936 when Pragma_Convention
=> Convention
: declare
4940 Check_Ada_83_Warning
;
4941 Check_Arg_Count
(2);
4942 Process_Convention
(C
, E
);
4945 ---------------------------
4946 -- Convention_Identifier --
4947 ---------------------------
4949 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
4950 -- [Convention =>] convention_IDENTIFIER);
4952 when Pragma_Convention_Identifier
=> Convention_Identifier
: declare
4958 Check_Arg_Count
(2);
4959 Check_Optional_Identifier
(Arg1
, Name_Name
);
4960 Check_Optional_Identifier
(Arg2
, Name_Convention
);
4961 Check_Arg_Is_Identifier
(Arg1
);
4962 Check_Arg_Is_Identifier
(Arg1
);
4963 Idnam
:= Chars
(Expression
(Arg1
));
4964 Cname
:= Chars
(Expression
(Arg2
));
4966 if Is_Convention_Name
(Cname
) then
4967 Record_Convention_Identifier
4968 (Idnam
, Get_Convention_Id
(Cname
));
4971 ("second arg for % pragma must be convention", Arg2
);
4973 end Convention_Identifier
;
4979 -- pragma CPP_Class ([Entity =>] local_NAME)
4981 when Pragma_CPP_Class
=> CPP_Class
: declare
4984 Default_DTC
: Entity_Id
:= Empty
;
4985 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
4991 Check_Arg_Count
(1);
4992 Check_Optional_Identifier
(Arg1
, Name_Entity
);
4993 Check_Arg_Is_Local_Name
(Arg1
);
4995 Arg
:= Expression
(Arg1
);
4998 if Etype
(Arg
) = Any_Type
then
5002 if not Is_Entity_Name
(Arg
)
5003 or else not Is_Type
(Entity
(Arg
))
5005 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
5008 Typ
:= Entity
(Arg
);
5010 if not Is_Record_Type
(Typ
) then
5011 Error_Pragma_Arg
("pragma% applicable to a record, "
5012 & "tagged record or record extension", Arg1
);
5015 Default_DTC
:= First_Component
(Typ
);
5016 while Present
(Default_DTC
)
5017 and then Etype
(Default_DTC
) /= VTP_Type
5019 Next_Component
(Default_DTC
);
5022 -- Case of non tagged type
5024 if not Is_Tagged_Type
(Typ
) then
5025 Set_Is_CPP_Class
(Typ
);
5027 if Present
(Default_DTC
) then
5029 ("only tagged records can contain vtable pointers", Arg1
);
5032 -- Case of tagged type with no vtable ptr
5034 -- What is test for Typ = Root_Typ (Typ) about here ???
5036 elsif Is_Tagged_Type
(Typ
)
5037 and then Typ
= Root_Type
(Typ
)
5038 and then No
(Default_DTC
)
5041 ("a cpp_class must contain a vtable pointer", Arg1
);
5043 -- Tagged type that has a vtable ptr
5045 elsif Present
(Default_DTC
) then
5046 Set_Is_CPP_Class
(Typ
);
5047 Set_Is_Limited_Record
(Typ
);
5048 Set_Is_Tag
(Default_DTC
);
5049 Set_DT_Entry_Count
(Default_DTC
, No_Uint
);
5051 -- Since a CPP type has no direct link to its associated tag
5052 -- most tags checks cannot be performed
5054 Set_Kill_Tag_Checks
(Typ
);
5055 Set_Kill_Tag_Checks
(Class_Wide_Type
(Typ
));
5057 -- Get rid of the _tag component when there was one.
5058 -- It is only useful for regular tagged types
5060 if Expander_Active
and then Typ
= Root_Type
(Typ
) then
5062 Tag_C
:= Tag_Component
(Typ
);
5063 C
:= First_Entity
(Typ
);
5066 Set_First_Entity
(Typ
, Next_Entity
(Tag_C
));
5069 while Next_Entity
(C
) /= Tag_C
loop
5073 Set_Next_Entity
(C
, Next_Entity
(Tag_C
));
5079 ---------------------
5080 -- CPP_Constructor --
5081 ---------------------
5083 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
5085 when Pragma_CPP_Constructor
=> CPP_Constructor
: declare
5091 Check_Arg_Count
(1);
5092 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5093 Check_Arg_Is_Local_Name
(Arg1
);
5095 Id
:= Expression
(Arg1
);
5096 Find_Program_Unit_Name
(Id
);
5098 -- If we did not find the name, we are done
5100 if Etype
(Id
) = Any_Type
then
5104 Def_Id
:= Entity
(Id
);
5106 if Ekind
(Def_Id
) = E_Function
5107 and then Is_Class_Wide_Type
(Etype
(Def_Id
))
5108 and then Is_CPP_Class
(Etype
(Etype
(Def_Id
)))
5110 -- What the heck is this??? this pragma allows only 1 arg
5112 if Arg_Count
>= 2 then
5113 Check_At_Most_N_Arguments
(3);
5114 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
5117 if No
(Parameter_Specifications
(Parent
(Def_Id
))) then
5118 Set_Has_Completion
(Def_Id
);
5119 Set_Is_Constructor
(Def_Id
);
5122 ("non-default constructors not implemented", Arg1
);
5127 ("pragma% requires function returning a 'C'P'P_Class type",
5130 end CPP_Constructor
;
5136 -- pragma CPP_Virtual
5137 -- [Entity =>] LOCAL_NAME
5138 -- [ [Vtable_Ptr =>] LOCAL_NAME,
5139 -- [Position =>] static_integer_EXPRESSION]);
5141 when Pragma_CPP_Virtual
=> CPP_Virtual
: declare
5145 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
5152 if Arg_Count
= 3 then
5153 Check_Optional_Identifier
(Arg2
, "vtable_ptr");
5155 -- We allow Entry_Count as well as Position for the third
5156 -- parameter for back compatibility with versions of GNAT
5157 -- before version 3.12. The documentation has always said
5158 -- Position, but the code up to 3.12 said Entry_Count.
5160 if Chars
(Arg3
) /= Name_Position
then
5161 Check_Optional_Identifier
(Arg3
, "entry_count");
5165 Check_Arg_Count
(1);
5168 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5169 Check_Arg_Is_Local_Name
(Arg1
);
5171 -- First argument must be a subprogram name
5173 Arg
:= Expression
(Arg1
);
5174 Find_Program_Unit_Name
(Arg
);
5176 if Etype
(Arg
) = Any_Type
then
5179 Subp
:= Entity
(Arg
);
5182 if not (Is_Subprogram
(Subp
)
5183 and then Is_Dispatching_Operation
(Subp
))
5186 ("pragma% must reference a primitive operation", Arg1
);
5189 Typ
:= Find_Dispatching_Type
(Subp
);
5191 -- If only one Argument defaults are :
5192 -- . DTC_Entity is the default Vtable pointer
5193 -- . DT_Position will be set at the freezing point
5195 if Arg_Count
= 1 then
5196 Set_DTC_Entity
(Subp
, Tag_Component
(Typ
));
5200 -- Second argument is a component name of type Vtable_Ptr
5202 Arg
:= Expression
(Arg2
);
5204 if Nkind
(Arg
) /= N_Identifier
then
5205 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5209 DTC
:= First_Component
(Typ
);
5210 while Present
(DTC
) and then Chars
(DTC
) /= Chars
(Arg
) loop
5211 Next_Component
(DTC
);
5215 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5218 elsif Etype
(DTC
) /= VTP_Type
then
5219 Wrong_Type
(Arg
, VTP_Type
);
5223 -- Third argument is an integer (DT_Position)
5225 Arg
:= Expression
(Arg3
);
5226 Analyze_And_Resolve
(Arg
, Any_Integer
);
5228 if not Is_Static_Expression
(Arg
) then
5229 Flag_Non_Static_Expr
5230 ("third argument of pragma CPP_Virtual must be static!",
5235 V
:= Expr_Value
(Expression
(Arg3
));
5239 ("third argument of pragma% must be positive",
5243 Set_DTC_Entity
(Subp
, DTC
);
5244 Set_DT_Position
(Subp
, V
);
5253 -- pragma CPP_Vtable (
5254 -- [Entity =>] LOCAL_NAME
5255 -- [Vtable_Ptr =>] LOCAL_NAME,
5256 -- [Entry_Count =>] static_integer_EXPRESSION);
5258 when Pragma_CPP_Vtable
=> CPP_Vtable
: declare
5261 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
5268 Check_Arg_Count
(3);
5269 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5270 Check_Optional_Identifier
(Arg2
, "vtable_ptr");
5271 Check_Optional_Identifier
(Arg3
, "entry_count");
5272 Check_Arg_Is_Local_Name
(Arg1
);
5274 -- First argument is a record type name
5276 Arg
:= Expression
(Arg1
);
5279 if Etype
(Arg
) = Any_Type
then
5282 Typ
:= Entity
(Arg
);
5285 if not (Is_Tagged_Type
(Typ
) and then Is_CPP_Class
(Typ
)) then
5286 Error_Pragma_Arg
("'C'P'P_Class tagged type expected", Arg1
);
5289 -- Second argument is a component name of type Vtable_Ptr
5291 Arg
:= Expression
(Arg2
);
5293 if Nkind
(Arg
) /= N_Identifier
then
5294 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5298 DTC
:= First_Component
(Typ
);
5299 while Present
(DTC
) and then Chars
(DTC
) /= Chars
(Arg
) loop
5300 Next_Component
(DTC
);
5304 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5307 elsif Etype
(DTC
) /= VTP_Type
then
5308 Wrong_Type
(DTC
, VTP_Type
);
5311 -- If it is the first pragma Vtable, This becomes the default tag
5313 elsif (not Is_Tag
(DTC
))
5314 and then DT_Entry_Count
(Tag_Component
(Typ
)) = No_Uint
5316 Set_Is_Tag
(Tag_Component
(Typ
), False);
5317 Set_Is_Tag
(DTC
, True);
5318 Set_DT_Entry_Count
(DTC
, No_Uint
);
5321 -- Those pragmas must appear before any primitive operation
5322 -- definition (except inherited ones) otherwise the default
5325 Elmt
:= First_Elmt
(Primitive_Operations
(Typ
));
5326 while Present
(Elmt
) loop
5327 if No
(Alias
(Node
(Elmt
))) then
5328 Error_Msg_Sloc
:= Sloc
(Node
(Elmt
));
5330 ("pragma% must appear before this primitive operation");
5336 -- Third argument is an integer (DT_Entry_Count)
5338 Arg
:= Expression
(Arg3
);
5339 Analyze_And_Resolve
(Arg
, Any_Integer
);
5341 if not Is_Static_Expression
(Arg
) then
5342 Flag_Non_Static_Expr
5343 ("entry count for pragma CPP_Vtable must be a static " &
5344 "expression!", Arg3
);
5348 V
:= Expr_Value
(Expression
(Arg3
));
5352 ("entry count for pragma% must be positive", Arg3
);
5354 Set_DT_Entry_Count
(DTC
, V
);
5363 -- pragma Debug (PROCEDURE_CALL_STATEMENT);
5365 when Pragma_Debug
=> Debug
: begin
5368 -- Rewrite into a conditional with a static condition
5370 Rewrite
(N
, Make_Implicit_If_Statement
(N
,
5371 Condition
=> New_Occurrence_Of
(Boolean_Literals
(
5372 Assertions_Enabled
and Expander_Active
), Loc
),
5373 Then_Statements
=> New_List
(
5374 Relocate_Node
(Debug_Statement
(N
)))));
5378 ---------------------
5379 -- Detect_Blocking --
5380 ---------------------
5382 -- pragma Detect_Blocking;
5384 when Pragma_Detect_Blocking
=>
5386 Check_Arg_Count
(0);
5387 Check_Valid_Configuration_Pragma
;
5388 Detect_Blocking
:= True;
5394 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
5396 when Pragma_Discard_Names
=> Discard_Names
: declare
5401 Check_Ada_83_Warning
;
5403 -- Deal with configuration pragma case
5405 if Arg_Count
= 0 and then Is_Configuration_Pragma
then
5406 Global_Discard_Names
:= True;
5409 -- Otherwise, check correct appropriate context
5412 Check_Is_In_Decl_Part_Or_Package_Spec
;
5414 if Arg_Count
= 0 then
5416 -- If there is no parameter, then from now on this pragma
5417 -- applies to any enumeration, exception or tagged type
5418 -- defined in the current declarative part.
5420 Set_Discard_Names
(Current_Scope
);
5424 Check_Arg_Count
(1);
5425 Check_Optional_Identifier
(Arg1
, Name_On
);
5426 Check_Arg_Is_Local_Name
(Arg1
);
5427 E_Id
:= Expression
(Arg1
);
5429 if Etype
(E_Id
) = Any_Type
then
5435 if (Is_First_Subtype
(E
)
5436 and then (Is_Enumeration_Type
(E
)
5437 or else Is_Tagged_Type
(E
)))
5438 or else Ekind
(E
) = E_Exception
5440 Set_Discard_Names
(E
);
5443 ("inappropriate entity for pragma%", Arg1
);
5453 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
5455 when Pragma_Elaborate
=> Elaborate
: declare
5457 Parent_Node
: Node_Id
;
5462 -- Pragma must be in context items list of a compilation unit
5464 if not Is_List_Member
(N
) then
5469 Plist
:= List_Containing
(N
);
5470 Parent_Node
:= Parent
(Plist
);
5472 if Parent_Node
= Empty
5473 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
5474 or else Context_Items
(Parent_Node
) /= Plist
5481 -- Must be at least one argument
5483 if Arg_Count
= 0 then
5484 Error_Pragma
("pragma% requires at least one argument");
5487 -- In Ada 83 mode, there can be no items following it in the
5488 -- context list except other pragmas and implicit with clauses
5489 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
5490 -- placement rule does not apply.
5492 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
5495 while Present
(Citem
) loop
5496 if Nkind
(Citem
) = N_Pragma
5497 or else (Nkind
(Citem
) = N_With_Clause
5498 and then Implicit_With
(Citem
))
5503 ("(Ada 83) pragma% must be at end of context clause");
5510 -- Finally, the arguments must all be units mentioned in a with
5511 -- clause in the same context clause. Note we already checked
5512 -- (in Par.Prag) that the arguments are either identifiers or
5515 Outer
: while Present
(Arg
) loop
5516 Citem
:= First
(Plist
);
5518 Inner
: while Citem
/= N
loop
5519 if Nkind
(Citem
) = N_With_Clause
5520 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
5522 Set_Elaborate_Present
(Citem
, True);
5523 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
5524 Set_Suppress_Elaboration_Warnings
(Entity
(Name
(Citem
)));
5533 ("argument of pragma% is not with'ed unit", Arg
);
5539 -- Give a warning if operating in static mode with -gnatwl
5540 -- (elaboration warnings eanbled) switch set.
5542 if Elab_Warnings
and not Dynamic_Elaboration_Checks
then
5544 ("?use of pragma Elaborate may not be safe", N
);
5546 ("?use pragma Elaborate_All instead if possible", N
);
5554 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
5556 when Pragma_Elaborate_All
=> Elaborate_All
: declare
5558 Parent_Node
: Node_Id
;
5563 Check_Ada_83_Warning
;
5565 -- Pragma must be in context items list of a compilation unit
5567 if not Is_List_Member
(N
) then
5572 Plist
:= List_Containing
(N
);
5573 Parent_Node
:= Parent
(Plist
);
5575 if Parent_Node
= Empty
5576 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
5577 or else Context_Items
(Parent_Node
) /= Plist
5584 -- Must be at least one argument
5586 if Arg_Count
= 0 then
5587 Error_Pragma
("pragma% requires at least one argument");
5590 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
5591 -- have to appear at the end of the context clause, but may
5592 -- appear mixed in with other items, even in Ada 83 mode.
5594 -- Final check: the arguments must all be units mentioned in
5595 -- a with clause in the same context clause. Note that we
5596 -- already checked (in Par.Prag) that all the arguments are
5597 -- either identifiers or selected components.
5600 Outr
: while Present
(Arg
) loop
5601 Citem
:= First
(Plist
);
5603 Innr
: while Citem
/= N
loop
5604 if Nkind
(Citem
) = N_With_Clause
5605 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
5607 Set_Elaborate_All_Present
(Citem
, True);
5608 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
5609 Set_Suppress_Elaboration_Warnings
(Entity
(Name
(Citem
)));
5617 Set_Error_Posted
(N
);
5619 ("argument of pragma% is not with'ed unit", Arg
);
5626 --------------------
5627 -- Elaborate_Body --
5628 --------------------
5630 -- pragma Elaborate_Body [( library_unit_NAME )];
5632 when Pragma_Elaborate_Body
=> Elaborate_Body
: declare
5633 Cunit_Node
: Node_Id
;
5634 Cunit_Ent
: Entity_Id
;
5637 Check_Ada_83_Warning
;
5638 Check_Valid_Library_Unit_Pragma
;
5640 if Nkind
(N
) = N_Null_Statement
then
5644 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
5645 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
5647 if Nkind
(Unit
(Cunit_Node
)) = N_Package_Body
5649 Nkind
(Unit
(Cunit_Node
)) = N_Subprogram_Body
5651 Error_Pragma
("pragma% must refer to a spec, not a body");
5653 Set_Body_Required
(Cunit_Node
, True);
5654 Set_Has_Pragma_Elaborate_Body
(Cunit_Ent
);
5656 -- If we are in dynamic elaboration mode, then we suppress
5657 -- elaboration warnings for the unit, since it is definitely
5658 -- fine NOT to do dynamic checks at the first level (and such
5659 -- checks will be suppressed because no elaboration boolean
5660 -- is created for Elaborate_Body packages).
5662 -- But in the static model of elaboration, Elaborate_Body is
5663 -- definitely NOT good enough to ensure elaboration safety on
5664 -- its own, since the body may WITH other units that are not
5665 -- safe from an elaboration point of view, so a client must
5666 -- still do an Elaborate_All on such units.
5668 -- Debug flag -gnatdD restores the old behavior of 3.13,
5669 -- where Elaborate_Body always suppressed elab warnings.
5671 if Dynamic_Elaboration_Checks
or Debug_Flag_DD
then
5672 Set_Suppress_Elaboration_Warnings
(Cunit_Ent
);
5677 ------------------------
5678 -- Elaboration_Checks --
5679 ------------------------
5681 -- pragma Elaboration_Checks (Static | Dynamic);
5683 when Pragma_Elaboration_Checks
=>
5685 Check_Arg_Count
(1);
5686 Check_Arg_Is_One_Of
(Arg1
, Name_Static
, Name_Dynamic
);
5687 Dynamic_Elaboration_Checks
:=
5688 (Chars
(Get_Pragma_Arg
(Arg1
)) = Name_Dynamic
);
5694 -- pragma Eliminate (
5695 -- [Unit_Name =>] IDENTIFIER |
5696 -- SELECTED_COMPONENT
5697 -- [,[Entity =>] IDENTIFIER |
5698 -- SELECTED_COMPONENT |
5700 -- [,]OVERLOADING_RESOLUTION);
5702 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
5705 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
5708 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
5710 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
5711 -- Result_Type => result_SUBTYPE_NAME]
5713 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
5714 -- SUBTYPE_NAME ::= STRING_LITERAL
5716 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
5717 -- SOURCE_TRACE ::= STRING_LITERAL
5719 when Pragma_Eliminate
=> Eliminate
: declare
5720 Args
: Args_List
(1 .. 5);
5721 Names
: constant Name_List
(1 .. 5) := (
5724 Name_Parameter_Types
,
5726 Name_Source_Location
);
5728 Unit_Name
: Node_Id
renames Args
(1);
5729 Entity
: Node_Id
renames Args
(2);
5730 Parameter_Types
: Node_Id
renames Args
(3);
5731 Result_Type
: Node_Id
renames Args
(4);
5732 Source_Location
: Node_Id
renames Args
(5);
5736 Check_Valid_Configuration_Pragma
;
5737 Gather_Associations
(Names
, Args
);
5739 if No
(Unit_Name
) then
5740 Error_Pragma
("missing Unit_Name argument for pragma%");
5744 and then (Present
(Parameter_Types
)
5746 Present
(Result_Type
)
5748 Present
(Source_Location
))
5750 Error_Pragma
("missing Entity argument for pragma%");
5753 if (Present
(Parameter_Types
)
5755 Present
(Result_Type
))
5757 Present
(Source_Location
)
5760 ("parameter profile and source location can not " &
5761 "be used together in pragma%");
5764 Process_Eliminate_Pragma
5773 -------------------------
5774 -- Explicit_Overriding --
5775 -------------------------
5777 when Pragma_Explicit_Overriding
=>
5778 Check_Valid_Configuration_Pragma
;
5779 Check_Arg_Count
(0);
5780 Explicit_Overriding
:= True;
5787 -- [ Convention =>] convention_IDENTIFIER,
5788 -- [ Entity =>] local_NAME
5789 -- [, [External_Name =>] static_string_EXPRESSION ]
5790 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5792 when Pragma_Export
=> Export
: declare
5797 Check_Ada_83_Warning
;
5798 Check_At_Least_N_Arguments
(2);
5799 Check_At_Most_N_Arguments
(4);
5800 Process_Convention
(C
, Def_Id
);
5802 if Ekind
(Def_Id
) /= E_Constant
then
5803 Note_Possible_Modification
(Expression
(Arg2
));
5806 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
5807 Set_Exported
(Def_Id
, Arg2
);
5810 ----------------------
5811 -- Export_Exception --
5812 ----------------------
5814 -- pragma Export_Exception (
5815 -- [Internal =>] LOCAL_NAME,
5816 -- [, [External =>] EXTERNAL_SYMBOL,]
5817 -- [, [Form =>] Ada | VMS]
5818 -- [, [Code =>] static_integer_EXPRESSION]);
5820 when Pragma_Export_Exception
=> Export_Exception
: declare
5821 Args
: Args_List
(1 .. 4);
5822 Names
: constant Name_List
(1 .. 4) := (
5828 Internal
: Node_Id
renames Args
(1);
5829 External
: Node_Id
renames Args
(2);
5830 Form
: Node_Id
renames Args
(3);
5831 Code
: Node_Id
renames Args
(4);
5834 if Inside_A_Generic
then
5835 Error_Pragma
("pragma% cannot be used for generic entities");
5838 Gather_Associations
(Names
, Args
);
5839 Process_Extended_Import_Export_Exception_Pragma
(
5840 Arg_Internal
=> Internal
,
5841 Arg_External
=> External
,
5845 if not Is_VMS_Exception
(Entity
(Internal
)) then
5846 Set_Exported
(Entity
(Internal
), Internal
);
5848 end Export_Exception
;
5850 ---------------------
5851 -- Export_Function --
5852 ---------------------
5854 -- pragma Export_Function (
5855 -- [Internal =>] LOCAL_NAME,
5856 -- [, [External =>] EXTERNAL_SYMBOL,]
5857 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5858 -- [, [Result_Type =>] TYPE_DESIGNATOR]
5859 -- [, [Mechanism =>] MECHANISM]
5860 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
5862 -- EXTERNAL_SYMBOL ::=
5864 -- | static_string_EXPRESSION
5866 -- PARAMETER_TYPES ::=
5868 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
5870 -- TYPE_DESIGNATOR ::=
5872 -- | subtype_Name ' Access
5876 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
5878 -- MECHANISM_ASSOCIATION ::=
5879 -- [formal_parameter_NAME =>] MECHANISM_NAME
5881 -- MECHANISM_NAME ::=
5884 -- | Descriptor [([Class =>] CLASS_NAME)]
5886 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
5888 when Pragma_Export_Function
=> Export_Function
: declare
5889 Args
: Args_List
(1 .. 6);
5890 Names
: constant Name_List
(1 .. 6) := (
5893 Name_Parameter_Types
,
5896 Name_Result_Mechanism
);
5898 Internal
: Node_Id
renames Args
(1);
5899 External
: Node_Id
renames Args
(2);
5900 Parameter_Types
: Node_Id
renames Args
(3);
5901 Result_Type
: Node_Id
renames Args
(4);
5902 Mechanism
: Node_Id
renames Args
(5);
5903 Result_Mechanism
: Node_Id
renames Args
(6);
5907 Gather_Associations
(Names
, Args
);
5908 Process_Extended_Import_Export_Subprogram_Pragma
(
5909 Arg_Internal
=> Internal
,
5910 Arg_External
=> External
,
5911 Arg_Parameter_Types
=> Parameter_Types
,
5912 Arg_Result_Type
=> Result_Type
,
5913 Arg_Mechanism
=> Mechanism
,
5914 Arg_Result_Mechanism
=> Result_Mechanism
);
5915 end Export_Function
;
5921 -- pragma Export_Object (
5922 -- [Internal =>] LOCAL_NAME,
5923 -- [, [External =>] EXTERNAL_SYMBOL]
5924 -- [, [Size =>] EXTERNAL_SYMBOL]);
5926 -- EXTERNAL_SYMBOL ::=
5928 -- | static_string_EXPRESSION
5930 -- PARAMETER_TYPES ::=
5932 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
5934 -- TYPE_DESIGNATOR ::=
5936 -- | subtype_Name ' Access
5940 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
5942 -- MECHANISM_ASSOCIATION ::=
5943 -- [formal_parameter_NAME =>] MECHANISM_NAME
5945 -- MECHANISM_NAME ::=
5948 -- | Descriptor [([Class =>] CLASS_NAME)]
5950 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
5952 when Pragma_Export_Object
=> Export_Object
: declare
5953 Args
: Args_List
(1 .. 3);
5954 Names
: constant Name_List
(1 .. 3) := (
5959 Internal
: Node_Id
renames Args
(1);
5960 External
: Node_Id
renames Args
(2);
5961 Size
: Node_Id
renames Args
(3);
5965 Gather_Associations
(Names
, Args
);
5966 Process_Extended_Import_Export_Object_Pragma
(
5967 Arg_Internal
=> Internal
,
5968 Arg_External
=> External
,
5972 ----------------------
5973 -- Export_Procedure --
5974 ----------------------
5976 -- pragma Export_Procedure (
5977 -- [Internal =>] LOCAL_NAME,
5978 -- [, [External =>] EXTERNAL_SYMBOL,]
5979 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5980 -- [, [Mechanism =>] MECHANISM]);
5982 -- EXTERNAL_SYMBOL ::=
5984 -- | static_string_EXPRESSION
5986 -- PARAMETER_TYPES ::=
5988 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
5990 -- TYPE_DESIGNATOR ::=
5992 -- | subtype_Name ' Access
5996 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
5998 -- MECHANISM_ASSOCIATION ::=
5999 -- [formal_parameter_NAME =>] MECHANISM_NAME
6001 -- MECHANISM_NAME ::=
6004 -- | Descriptor [([Class =>] CLASS_NAME)]
6006 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6008 when Pragma_Export_Procedure
=> Export_Procedure
: declare
6009 Args
: Args_List
(1 .. 4);
6010 Names
: constant Name_List
(1 .. 4) := (
6013 Name_Parameter_Types
,
6016 Internal
: Node_Id
renames Args
(1);
6017 External
: Node_Id
renames Args
(2);
6018 Parameter_Types
: Node_Id
renames Args
(3);
6019 Mechanism
: Node_Id
renames Args
(4);
6023 Gather_Associations
(Names
, Args
);
6024 Process_Extended_Import_Export_Subprogram_Pragma
(
6025 Arg_Internal
=> Internal
,
6026 Arg_External
=> External
,
6027 Arg_Parameter_Types
=> Parameter_Types
,
6028 Arg_Mechanism
=> Mechanism
);
6029 end Export_Procedure
;
6035 -- pragma Export_Value (
6036 -- [Value =>] static_integer_EXPRESSION,
6037 -- [Link_Name =>] static_string_EXPRESSION);
6039 when Pragma_Export_Value
=>
6041 Check_Arg_Count
(2);
6043 Check_Optional_Identifier
(Arg1
, Name_Value
);
6044 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
6046 Check_Optional_Identifier
(Arg2
, Name_Link_Name
);
6047 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
6049 -----------------------------
6050 -- Export_Valued_Procedure --
6051 -----------------------------
6053 -- pragma Export_Valued_Procedure (
6054 -- [Internal =>] LOCAL_NAME,
6055 -- [, [External =>] EXTERNAL_SYMBOL,]
6056 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6057 -- [, [Mechanism =>] MECHANISM]);
6059 -- EXTERNAL_SYMBOL ::=
6061 -- | static_string_EXPRESSION
6063 -- PARAMETER_TYPES ::=
6065 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6067 -- TYPE_DESIGNATOR ::=
6069 -- | subtype_Name ' Access
6073 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6075 -- MECHANISM_ASSOCIATION ::=
6076 -- [formal_parameter_NAME =>] MECHANISM_NAME
6078 -- MECHANISM_NAME ::=
6081 -- | Descriptor [([Class =>] CLASS_NAME)]
6083 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6085 when Pragma_Export_Valued_Procedure
=>
6086 Export_Valued_Procedure
: declare
6087 Args
: Args_List
(1 .. 4);
6088 Names
: constant Name_List
(1 .. 4) := (
6091 Name_Parameter_Types
,
6094 Internal
: Node_Id
renames Args
(1);
6095 External
: Node_Id
renames Args
(2);
6096 Parameter_Types
: Node_Id
renames Args
(3);
6097 Mechanism
: Node_Id
renames Args
(4);
6101 Gather_Associations
(Names
, Args
);
6102 Process_Extended_Import_Export_Subprogram_Pragma
(
6103 Arg_Internal
=> Internal
,
6104 Arg_External
=> External
,
6105 Arg_Parameter_Types
=> Parameter_Types
,
6106 Arg_Mechanism
=> Mechanism
);
6107 end Export_Valued_Procedure
;
6113 -- pragma Extend_System ([Name =>] Identifier);
6115 when Pragma_Extend_System
=> Extend_System
: declare
6118 Check_Valid_Configuration_Pragma
;
6119 Check_Arg_Count
(1);
6120 Check_Optional_Identifier
(Arg1
, Name_Name
);
6121 Check_Arg_Is_Identifier
(Arg1
);
6123 Get_Name_String
(Chars
(Expression
(Arg1
)));
6126 and then Name_Buffer
(1 .. 4) = "aux_"
6128 if Present
(System_Extend_Pragma_Arg
) then
6129 if Chars
(Expression
(Arg1
)) =
6130 Chars
(Expression
(System_Extend_Pragma_Arg
))
6134 Error_Msg_Sloc
:= Sloc
(System_Extend_Pragma_Arg
);
6135 Error_Pragma
("pragma% conflicts with that at#");
6139 System_Extend_Pragma_Arg
:= Arg1
;
6141 if not GNAT_Mode
then
6142 System_Extend_Unit
:= Arg1
;
6146 Error_Pragma
("incorrect name for pragma%, must be Aux_xxx");
6150 ------------------------
6151 -- Extensions_Allowed --
6152 ------------------------
6154 -- pragma Extensions_Allowed (ON | OFF);
6156 when Pragma_Extensions_Allowed
=>
6158 Check_Arg_Count
(1);
6159 Check_No_Identifiers
;
6160 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
6162 if Chars
(Expression
(Arg1
)) = Name_On
then
6163 Extensions_Allowed
:= True;
6164 Ada_Version
:= Ada_Version_Type
'Last;
6166 Extensions_Allowed
:= False;
6167 Ada_Version
:= Ada_Version_Type
'Min (Ada_Version
, Ada_95
);
6174 -- pragma External (
6175 -- [ Convention =>] convention_IDENTIFIER,
6176 -- [ Entity =>] local_NAME
6177 -- [, [External_Name =>] static_string_EXPRESSION ]
6178 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6180 when Pragma_External
=> External
: declare
6186 Check_At_Least_N_Arguments
(2);
6187 Check_At_Most_N_Arguments
(4);
6188 Process_Convention
(C
, Def_Id
);
6189 Note_Possible_Modification
(Expression
(Arg2
));
6190 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
6191 Set_Exported
(Def_Id
, Arg2
);
6194 --------------------------
6195 -- External_Name_Casing --
6196 --------------------------
6198 -- pragma External_Name_Casing (
6199 -- UPPERCASE | LOWERCASE
6200 -- [, AS_IS | UPPERCASE | LOWERCASE]);
6202 when Pragma_External_Name_Casing
=>
6204 External_Name_Casing
: declare
6207 Check_No_Identifiers
;
6209 if Arg_Count
= 2 then
6211 (Arg2
, Name_As_Is
, Name_Uppercase
, Name_Lowercase
);
6213 case Chars
(Get_Pragma_Arg
(Arg2
)) is
6215 Opt
.External_Name_Exp_Casing
:= As_Is
;
6217 when Name_Uppercase
=>
6218 Opt
.External_Name_Exp_Casing
:= Uppercase
;
6220 when Name_Lowercase
=>
6221 Opt
.External_Name_Exp_Casing
:= Lowercase
;
6228 Check_Arg_Count
(1);
6231 Check_Arg_Is_One_Of
(Arg1
, Name_Uppercase
, Name_Lowercase
);
6233 case Chars
(Get_Pragma_Arg
(Arg1
)) is
6234 when Name_Uppercase
=>
6235 Opt
.External_Name_Imp_Casing
:= Uppercase
;
6237 when Name_Lowercase
=>
6238 Opt
.External_Name_Imp_Casing
:= Lowercase
;
6243 end External_Name_Casing
;
6245 ---------------------------
6246 -- Finalize_Storage_Only --
6247 ---------------------------
6249 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
6251 when Pragma_Finalize_Storage_Only
=> Finalize_Storage
: declare
6252 Assoc
: constant Node_Id
:= Arg1
;
6253 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
6257 Check_No_Identifiers
;
6258 Check_Arg_Count
(1);
6259 Check_Arg_Is_Local_Name
(Arg1
);
6261 Find_Type
(Type_Id
);
6262 Typ
:= Entity
(Type_Id
);
6265 or else Rep_Item_Too_Early
(Typ
, N
)
6269 Typ
:= Underlying_Type
(Typ
);
6272 if not Is_Controlled
(Typ
) then
6273 Error_Pragma
("pragma% must specify controlled type");
6276 Check_First_Subtype
(Arg1
);
6278 if Finalize_Storage_Only
(Typ
) then
6279 Error_Pragma
("duplicate pragma%, only one allowed");
6281 elsif not Rep_Item_Too_Late
(Typ
, N
) then
6282 Set_Finalize_Storage_Only
(Base_Type
(Typ
), True);
6284 end Finalize_Storage
;
6286 --------------------------
6287 -- Float_Representation --
6288 --------------------------
6290 -- pragma Float_Representation (VAX_Float | IEEE_Float);
6292 when Pragma_Float_Representation
=> Float_Representation
: declare
6300 if Arg_Count
= 1 then
6301 Check_Valid_Configuration_Pragma
;
6303 Check_Arg_Count
(2);
6304 Check_Optional_Identifier
(Arg2
, Name_Entity
);
6305 Check_Arg_Is_Local_Name
(Arg2
);
6308 Check_No_Identifier
(Arg1
);
6309 Check_Arg_Is_One_Of
(Arg1
, Name_VAX_Float
, Name_IEEE_Float
);
6311 if not OpenVMS_On_Target
then
6312 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6314 ("?pragma% ignored (applies only to Open'V'M'S)");
6320 -- One argument case
6322 if Arg_Count
= 1 then
6324 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6326 if Opt
.Float_Format
= 'I' then
6327 Error_Pragma
("'I'E'E'E format previously specified");
6330 Opt
.Float_Format
:= 'V';
6333 if Opt
.Float_Format
= 'V' then
6334 Error_Pragma
("'V'A'X format previously specified");
6337 Opt
.Float_Format
:= 'I';
6340 Set_Standard_Fpt_Formats
;
6342 -- Two argument case
6345 Argx
:= Get_Pragma_Arg
(Arg2
);
6347 if not Is_Entity_Name
(Argx
)
6348 or else not Is_Floating_Point_Type
(Entity
(Argx
))
6351 ("second argument of% pragma must be floating-point type",
6355 Ent
:= Entity
(Argx
);
6356 Digs
:= UI_To_Int
(Digits_Value
(Ent
));
6358 -- Two arguments, VAX_Float case
6360 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6363 when 6 => Set_F_Float
(Ent
);
6364 when 9 => Set_D_Float
(Ent
);
6365 when 15 => Set_G_Float
(Ent
);
6369 ("wrong digits value, must be 6,9 or 15", Arg2
);
6372 -- Two arguments, IEEE_Float case
6376 when 6 => Set_IEEE_Short
(Ent
);
6377 when 15 => Set_IEEE_Long
(Ent
);
6381 ("wrong digits value, must be 6 or 15", Arg2
);
6385 end Float_Representation
;
6391 -- pragma Ident (static_string_EXPRESSION)
6393 -- Note: pragma Comment shares this processing. Pragma Comment
6394 -- is identical to Ident, except that the restriction of the
6395 -- argument to 31 characters and the placement restrictions
6396 -- are not enforced for pragma Comment.
6398 when Pragma_Ident | Pragma_Comment
=> Ident
: declare
6403 Check_Arg_Count
(1);
6404 Check_No_Identifiers
;
6405 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
6407 -- For pragma Ident, preserve DEC compatibility by requiring
6408 -- the pragma to appear in a declarative part or package spec.
6410 if Prag_Id
= Pragma_Ident
then
6411 Check_Is_In_Decl_Part_Or_Package_Spec
;
6414 Str
:= Expr_Value_S
(Expression
(Arg1
));
6421 GP
:= Parent
(Parent
(N
));
6423 if Nkind
(GP
) = N_Package_Declaration
6425 Nkind
(GP
) = N_Generic_Package_Declaration
6430 -- If we have a compilation unit, then record the ident
6431 -- value, checking for improper duplication.
6433 if Nkind
(GP
) = N_Compilation_Unit
then
6434 CS
:= Ident_String
(Current_Sem_Unit
);
6436 if Present
(CS
) then
6438 -- For Ident, we do not permit multiple instances
6440 if Prag_Id
= Pragma_Ident
then
6441 Error_Pragma
("duplicate% pragma not permitted");
6443 -- For Comment, we concatenate the string, unless we
6444 -- want to preserve the tree structure for ASIS.
6446 elsif not ASIS_Mode
then
6447 Start_String
(Strval
(CS
));
6448 Store_String_Char
(' ');
6449 Store_String_Chars
(Strval
(Str
));
6450 Set_Strval
(CS
, End_String
);
6454 -- In VMS, the effect of IDENT is achieved by passing
6455 -- IDENTIFICATION=name as a --for-linker switch.
6457 if OpenVMS_On_Target
then
6460 ("--for-linker=IDENTIFICATION=");
6461 String_To_Name_Buffer
(Strval
(Str
));
6462 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
6464 -- Only the last processed IDENT is saved. The main
6465 -- purpose is so an IDENT associated with a main
6466 -- procedure will be used in preference to an IDENT
6467 -- associated with a with'd package.
6469 Replace_Linker_Option_String
6470 (End_String
, "--for-linker=IDENTIFICATION=");
6473 Set_Ident_String
(Current_Sem_Unit
, Str
);
6476 -- For subunits, we just ignore the Ident, since in GNAT
6477 -- these are not separate object files, and hence not
6478 -- separate units in the unit table.
6480 elsif Nkind
(GP
) = N_Subunit
then
6483 -- Otherwise we have a misplaced pragma Ident, but we ignore
6484 -- this if we are in an instantiation, since it comes from
6485 -- a generic, and has no relevance to the instantiation.
6487 elsif Prag_Id
= Pragma_Ident
then
6488 if Instantiation_Location
(Loc
) = No_Location
then
6489 Error_Pragma
("pragma% only allowed at outer level");
6500 -- [ Convention =>] convention_IDENTIFIER,
6501 -- [ Entity =>] local_NAME
6502 -- [, [External_Name =>] static_string_EXPRESSION ]
6503 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6505 when Pragma_Import
=>
6506 Check_Ada_83_Warning
;
6507 Check_At_Least_N_Arguments
(2);
6508 Check_At_Most_N_Arguments
(4);
6509 Process_Import_Or_Interface
;
6511 ----------------------
6512 -- Import_Exception --
6513 ----------------------
6515 -- pragma Import_Exception (
6516 -- [Internal =>] LOCAL_NAME,
6517 -- [, [External =>] EXTERNAL_SYMBOL,]
6518 -- [, [Form =>] Ada | VMS]
6519 -- [, [Code =>] static_integer_EXPRESSION]);
6521 when Pragma_Import_Exception
=> Import_Exception
: declare
6522 Args
: Args_List
(1 .. 4);
6523 Names
: constant Name_List
(1 .. 4) := (
6529 Internal
: Node_Id
renames Args
(1);
6530 External
: Node_Id
renames Args
(2);
6531 Form
: Node_Id
renames Args
(3);
6532 Code
: Node_Id
renames Args
(4);
6535 Gather_Associations
(Names
, Args
);
6537 if Present
(External
) and then Present
(Code
) then
6539 ("cannot give both External and Code options for pragma%");
6542 Process_Extended_Import_Export_Exception_Pragma
(
6543 Arg_Internal
=> Internal
,
6544 Arg_External
=> External
,
6548 if not Is_VMS_Exception
(Entity
(Internal
)) then
6549 Set_Imported
(Entity
(Internal
));
6551 end Import_Exception
;
6553 ---------------------
6554 -- Import_Function --
6555 ---------------------
6557 -- pragma Import_Function (
6558 -- [Internal =>] LOCAL_NAME,
6559 -- [, [External =>] EXTERNAL_SYMBOL]
6560 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6561 -- [, [Result_Type =>] SUBTYPE_MARK]
6562 -- [, [Mechanism =>] MECHANISM]
6563 -- [, [Result_Mechanism =>] MECHANISM_NAME]
6564 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6566 -- EXTERNAL_SYMBOL ::=
6568 -- | static_string_EXPRESSION
6570 -- PARAMETER_TYPES ::=
6572 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6574 -- TYPE_DESIGNATOR ::=
6576 -- | subtype_Name ' Access
6580 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6582 -- MECHANISM_ASSOCIATION ::=
6583 -- [formal_parameter_NAME =>] MECHANISM_NAME
6585 -- MECHANISM_NAME ::=
6588 -- | Descriptor [([Class =>] CLASS_NAME)]
6590 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6592 when Pragma_Import_Function
=> Import_Function
: declare
6593 Args
: Args_List
(1 .. 7);
6594 Names
: constant Name_List
(1 .. 7) := (
6597 Name_Parameter_Types
,
6600 Name_Result_Mechanism
,
6601 Name_First_Optional_Parameter
);
6603 Internal
: Node_Id
renames Args
(1);
6604 External
: Node_Id
renames Args
(2);
6605 Parameter_Types
: Node_Id
renames Args
(3);
6606 Result_Type
: Node_Id
renames Args
(4);
6607 Mechanism
: Node_Id
renames Args
(5);
6608 Result_Mechanism
: Node_Id
renames Args
(6);
6609 First_Optional_Parameter
: Node_Id
renames Args
(7);
6613 Gather_Associations
(Names
, Args
);
6614 Process_Extended_Import_Export_Subprogram_Pragma
(
6615 Arg_Internal
=> Internal
,
6616 Arg_External
=> External
,
6617 Arg_Parameter_Types
=> Parameter_Types
,
6618 Arg_Result_Type
=> Result_Type
,
6619 Arg_Mechanism
=> Mechanism
,
6620 Arg_Result_Mechanism
=> Result_Mechanism
,
6621 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
6622 end Import_Function
;
6628 -- pragma Import_Object (
6629 -- [Internal =>] LOCAL_NAME,
6630 -- [, [External =>] EXTERNAL_SYMBOL]
6631 -- [, [Size =>] EXTERNAL_SYMBOL]);
6633 -- EXTERNAL_SYMBOL ::=
6635 -- | static_string_EXPRESSION
6637 when Pragma_Import_Object
=> Import_Object
: declare
6638 Args
: Args_List
(1 .. 3);
6639 Names
: constant Name_List
(1 .. 3) := (
6644 Internal
: Node_Id
renames Args
(1);
6645 External
: Node_Id
renames Args
(2);
6646 Size
: Node_Id
renames Args
(3);
6650 Gather_Associations
(Names
, Args
);
6651 Process_Extended_Import_Export_Object_Pragma
(
6652 Arg_Internal
=> Internal
,
6653 Arg_External
=> External
,
6657 ----------------------
6658 -- Import_Procedure --
6659 ----------------------
6661 -- pragma Import_Procedure (
6662 -- [Internal =>] LOCAL_NAME,
6663 -- [, [External =>] EXTERNAL_SYMBOL]
6664 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6665 -- [, [Mechanism =>] MECHANISM]
6666 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6668 -- EXTERNAL_SYMBOL ::=
6670 -- | static_string_EXPRESSION
6672 -- PARAMETER_TYPES ::=
6674 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6676 -- TYPE_DESIGNATOR ::=
6678 -- | subtype_Name ' Access
6682 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6684 -- MECHANISM_ASSOCIATION ::=
6685 -- [formal_parameter_NAME =>] MECHANISM_NAME
6687 -- MECHANISM_NAME ::=
6690 -- | Descriptor [([Class =>] CLASS_NAME)]
6692 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6694 when Pragma_Import_Procedure
=> Import_Procedure
: declare
6695 Args
: Args_List
(1 .. 5);
6696 Names
: constant Name_List
(1 .. 5) := (
6699 Name_Parameter_Types
,
6701 Name_First_Optional_Parameter
);
6703 Internal
: Node_Id
renames Args
(1);
6704 External
: Node_Id
renames Args
(2);
6705 Parameter_Types
: Node_Id
renames Args
(3);
6706 Mechanism
: Node_Id
renames Args
(4);
6707 First_Optional_Parameter
: Node_Id
renames Args
(5);
6711 Gather_Associations
(Names
, Args
);
6712 Process_Extended_Import_Export_Subprogram_Pragma
(
6713 Arg_Internal
=> Internal
,
6714 Arg_External
=> External
,
6715 Arg_Parameter_Types
=> Parameter_Types
,
6716 Arg_Mechanism
=> Mechanism
,
6717 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
6718 end Import_Procedure
;
6720 -----------------------------
6721 -- Import_Valued_Procedure --
6722 -----------------------------
6724 -- pragma Import_Valued_Procedure (
6725 -- [Internal =>] LOCAL_NAME,
6726 -- [, [External =>] EXTERNAL_SYMBOL]
6727 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6728 -- [, [Mechanism =>] MECHANISM]
6729 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6731 -- EXTERNAL_SYMBOL ::=
6733 -- | static_string_EXPRESSION
6735 -- PARAMETER_TYPES ::=
6737 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6739 -- TYPE_DESIGNATOR ::=
6741 -- | subtype_Name ' Access
6745 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6747 -- MECHANISM_ASSOCIATION ::=
6748 -- [formal_parameter_NAME =>] MECHANISM_NAME
6750 -- MECHANISM_NAME ::=
6753 -- | Descriptor [([Class =>] CLASS_NAME)]
6755 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6757 when Pragma_Import_Valued_Procedure
=>
6758 Import_Valued_Procedure
: declare
6759 Args
: Args_List
(1 .. 5);
6760 Names
: constant Name_List
(1 .. 5) := (
6763 Name_Parameter_Types
,
6765 Name_First_Optional_Parameter
);
6767 Internal
: Node_Id
renames Args
(1);
6768 External
: Node_Id
renames Args
(2);
6769 Parameter_Types
: Node_Id
renames Args
(3);
6770 Mechanism
: Node_Id
renames Args
(4);
6771 First_Optional_Parameter
: Node_Id
renames Args
(5);
6775 Gather_Associations
(Names
, Args
);
6776 Process_Extended_Import_Export_Subprogram_Pragma
(
6777 Arg_Internal
=> Internal
,
6778 Arg_External
=> External
,
6779 Arg_Parameter_Types
=> Parameter_Types
,
6780 Arg_Mechanism
=> Mechanism
,
6781 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
6782 end Import_Valued_Procedure
;
6784 ------------------------
6785 -- Initialize_Scalars --
6786 ------------------------
6788 -- pragma Initialize_Scalars;
6790 when Pragma_Initialize_Scalars
=>
6792 Check_Arg_Count
(0);
6793 Check_Valid_Configuration_Pragma
;
6794 Check_Restriction
(No_Initialize_Scalars
, N
);
6796 if not Restriction_Active
(No_Initialize_Scalars
) then
6797 Init_Or_Norm_Scalars
:= True;
6798 Initialize_Scalars
:= True;
6805 -- pragma Inline ( NAME {, NAME} );
6807 when Pragma_Inline
=>
6809 -- Pragma is active if inlining option is active
6811 if Inline_Active
then
6812 Process_Inline
(True);
6814 -- Pragma is active in a predefined file in config run time mode
6816 elsif Configurable_Run_Time_Mode
6818 Is_Predefined_File_Name
(Unit_File_Name
(Current_Sem_Unit
))
6820 Process_Inline
(True);
6822 -- Otherwise inlining is not active
6825 Process_Inline
(False);
6832 -- pragma Inline_Always ( NAME {, NAME} );
6834 when Pragma_Inline_Always
=>
6835 Process_Inline
(True);
6837 --------------------
6838 -- Inline_Generic --
6839 --------------------
6841 -- pragma Inline_Generic (NAME {, NAME});
6843 when Pragma_Inline_Generic
=>
6844 Process_Generic_List
;
6846 ----------------------
6847 -- Inspection_Point --
6848 ----------------------
6850 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
6852 when Pragma_Inspection_Point
=> Inspection_Point
: declare
6857 if Arg_Count
> 0 then
6860 Exp
:= Expression
(Arg
);
6863 if not Is_Entity_Name
(Exp
)
6864 or else not Is_Object
(Entity
(Exp
))
6866 Error_Pragma_Arg
("object name required", Arg
);
6873 end Inspection_Point
;
6879 -- pragma Interface (
6880 -- convention_IDENTIFIER,
6883 when Pragma_Interface
=>
6885 Check_Arg_Count
(2);
6886 Check_No_Identifiers
;
6887 Process_Import_Or_Interface
;
6889 --------------------
6890 -- Interface_Name --
6891 --------------------
6893 -- pragma Interface_Name (
6894 -- [ Entity =>] local_NAME
6895 -- [,[External_Name =>] static_string_EXPRESSION ]
6896 -- [,[Link_Name =>] static_string_EXPRESSION ]);
6898 when Pragma_Interface_Name
=> Interface_Name
: declare
6906 Check_At_Least_N_Arguments
(2);
6907 Check_At_Most_N_Arguments
(3);
6908 Id
:= Expression
(Arg1
);
6911 if not Is_Entity_Name
(Id
) then
6913 ("first argument for pragma% must be entity name", Arg1
);
6914 elsif Etype
(Id
) = Any_Type
then
6917 Def_Id
:= Entity
(Id
);
6920 -- Special DEC-compatible processing for the object case,
6921 -- forces object to be imported.
6923 if Ekind
(Def_Id
) = E_Variable
then
6924 Kill_Size_Check_Code
(Def_Id
);
6925 Note_Possible_Modification
(Id
);
6927 -- Initialization is not allowed for imported variable
6929 if Present
(Expression
(Parent
(Def_Id
)))
6930 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
6932 Error_Msg_Sloc
:= Sloc
(Def_Id
);
6934 ("no initialization allowed for declaration of& #",
6938 -- For compatibility, support VADS usage of providing both
6939 -- pragmas Interface and Interface_Name to obtain the effect
6940 -- of a single Import pragma.
6942 if Is_Imported
(Def_Id
)
6943 and then Present
(First_Rep_Item
(Def_Id
))
6944 and then Nkind
(First_Rep_Item
(Def_Id
)) = N_Pragma
6945 and then Chars
(First_Rep_Item
(Def_Id
)) = Name_Interface
6949 Set_Imported
(Def_Id
);
6952 Set_Is_Public
(Def_Id
);
6953 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
6956 -- Otherwise must be subprogram
6958 elsif not Is_Subprogram
(Def_Id
) then
6960 ("argument of pragma% is not subprogram", Arg1
);
6963 Check_At_Most_N_Arguments
(3);
6967 -- Loop through homonyms
6970 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
6972 if Is_Imported
(Def_Id
) then
6973 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
6977 Hom_Id
:= Homonym
(Hom_Id
);
6979 exit when No
(Hom_Id
)
6980 or else Scope
(Hom_Id
) /= Current_Scope
;
6985 ("argument of pragma% is not imported subprogram",
6991 -----------------------
6992 -- Interrupt_Handler --
6993 -----------------------
6995 -- pragma Interrupt_Handler (handler_NAME);
6997 when Pragma_Interrupt_Handler
=>
6998 Check_Ada_83_Warning
;
6999 Check_Arg_Count
(1);
7000 Check_No_Identifiers
;
7002 if No_Run_Time_Mode
then
7003 Error_Msg_CRT
("Interrupt_Handler pragma", N
);
7005 Check_Interrupt_Or_Attach_Handler
;
7006 Process_Interrupt_Or_Attach_Handler
;
7009 ------------------------
7010 -- Interrupt_Priority --
7011 ------------------------
7013 -- pragma Interrupt_Priority [(EXPRESSION)];
7015 when Pragma_Interrupt_Priority
=> Interrupt_Priority
: declare
7016 P
: constant Node_Id
:= Parent
(N
);
7020 Check_Ada_83_Warning
;
7022 if Arg_Count
/= 0 then
7023 Arg
:= Expression
(Arg1
);
7024 Check_Arg_Count
(1);
7025 Check_No_Identifiers
;
7027 -- The expression must be analyzed in the special manner
7028 -- described in "Handling of Default and Per-Object
7029 -- Expressions" in sem.ads.
7031 Analyze_Per_Use_Expression
(Arg
, RTE
(RE_Interrupt_Priority
));
7034 if Nkind
(P
) /= N_Task_Definition
7035 and then Nkind
(P
) /= N_Protected_Definition
7040 elsif Has_Priority_Pragma
(P
) then
7041 Error_Pragma
("duplicate pragma% not allowed");
7044 Set_Has_Priority_Pragma
(P
, True);
7045 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
7047 end Interrupt_Priority
;
7049 ---------------------
7050 -- Interrupt_State --
7051 ---------------------
7053 -- pragma Interrupt_State (
7054 -- [Name =>] INTERRUPT_ID,
7055 -- [State =>] INTERRUPT_STATE);
7057 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
7058 -- INTERRUPT_STATE => System | Runtime | User
7060 -- Note: if the interrupt id is given as an identifier, then
7061 -- it must be one of the identifiers in Ada.Interrupts.Names.
7062 -- Otherwise it is given as a static integer expression which
7063 -- must be in the range of Ada.Interrupts.Interrupt_ID.
7065 when Pragma_Interrupt_State
=> Interrupt_State
: declare
7067 Int_Id
: constant Entity_Id
:= RTE
(RE_Interrupt_ID
);
7068 -- This is the entity Ada.Interrupts.Interrupt_ID;
7070 State_Type
: Character;
7071 -- Set to 's'/'r'/'u' for System/Runtime/User
7074 -- Index to entry in Interrupt_States table
7077 -- Value of interrupt
7079 Arg1X
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
7080 -- The first argument to the pragma
7082 Int_Ent
: Entity_Id
;
7083 -- Interrupt entity in Ada.Interrupts.Names
7087 Check_Arg_Count
(2);
7089 Check_Optional_Identifier
(Arg1
, Name_Name
);
7090 Check_Optional_Identifier
(Arg2
, "state");
7091 Check_Arg_Is_Identifier
(Arg2
);
7093 -- First argument is identifier
7095 if Nkind
(Arg1X
) = N_Identifier
then
7097 -- Search list of names in Ada.Interrupts.Names
7099 Int_Ent
:= First_Entity
(RTE
(RE_Names
));
7101 if No
(Int_Ent
) then
7102 Error_Pragma_Arg
("invalid interrupt name", Arg1
);
7104 elsif Chars
(Int_Ent
) = Chars
(Arg1X
) then
7105 Int_Val
:= Expr_Value
(Constant_Value
(Int_Ent
));
7109 Next_Entity
(Int_Ent
);
7112 -- First argument is not an identifier, so it must be a
7113 -- static expression of type Ada.Interrupts.Interrupt_ID.
7116 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
7117 Int_Val
:= Expr_Value
(Arg1X
);
7119 if Int_Val
< Expr_Value
(Type_Low_Bound
(Int_Id
))
7121 Int_Val
> Expr_Value
(Type_High_Bound
(Int_Id
))
7124 ("value not in range of type " &
7125 """Ada.Interrupts.Interrupt_'I'D""", Arg1
);
7131 case Chars
(Get_Pragma_Arg
(Arg2
)) is
7132 when Name_Runtime
=> State_Type
:= 'r';
7133 when Name_System
=> State_Type
:= 's';
7134 when Name_User
=> State_Type
:= 'u';
7137 Error_Pragma_Arg
("invalid interrupt state", Arg2
);
7140 -- Check if entry is already stored
7142 IST_Num
:= Interrupt_States
.First
;
7144 -- If entry not found, add it
7146 if IST_Num
> Interrupt_States
.Last
then
7147 Interrupt_States
.Append
7148 ((Interrupt_Number
=> UI_To_Int
(Int_Val
),
7149 Interrupt_State
=> State_Type
,
7150 Pragma_Loc
=> Loc
));
7153 -- Case of entry for the same entry
7155 elsif Int_Val
= Interrupt_States
.Table
(IST_Num
).
7158 -- If state matches, done, no need to make redundant entry
7161 State_Type
= Interrupt_States
.Table
(IST_Num
).
7164 -- Otherwise if state does not match, error
7167 Interrupt_States
.Table
(IST_Num
).Pragma_Loc
;
7169 ("state conflicts with that given at #", Arg2
);
7173 IST_Num
:= IST_Num
+ 1;
7175 end Interrupt_State
;
7177 ----------------------
7178 -- Java_Constructor --
7179 ----------------------
7181 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
7183 when Pragma_Java_Constructor
=> Java_Constructor
: declare
7190 Check_Arg_Count
(1);
7191 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7192 Check_Arg_Is_Local_Name
(Arg1
);
7194 Id
:= Expression
(Arg1
);
7195 Find_Program_Unit_Name
(Id
);
7197 -- If we did not find the name, we are done
7199 if Etype
(Id
) = Any_Type
then
7203 Hom_Id
:= Entity
(Id
);
7205 -- Loop through homonyms
7208 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
7210 -- The constructor is required to be a function returning
7211 -- an access type whose designated type has convention Java.
7213 if Ekind
(Def_Id
) = E_Function
7214 and then Ekind
(Etype
(Def_Id
)) in Access_Kind
7217 (Designated_Type
(Etype
(Def_Id
))) = Convention_Java
7220 (Root_Type
(Designated_Type
(Etype
(Def_Id
))))
7223 Set_Is_Constructor
(Def_Id
);
7224 Set_Convention
(Def_Id
, Convention_Java
);
7228 ("pragma% requires function returning a 'Java access type",
7232 Hom_Id
:= Homonym
(Hom_Id
);
7234 exit when No
(Hom_Id
) or else Scope
(Hom_Id
) /= Current_Scope
;
7236 end Java_Constructor
;
7238 ----------------------
7239 -- Java_Interface --
7240 ----------------------
7242 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
7244 when Pragma_Java_Interface
=> Java_Interface
: declare
7250 Check_Arg_Count
(1);
7251 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7252 Check_Arg_Is_Local_Name
(Arg1
);
7254 Arg
:= Expression
(Arg1
);
7257 if Etype
(Arg
) = Any_Type
then
7261 if not Is_Entity_Name
(Arg
)
7262 or else not Is_Type
(Entity
(Arg
))
7264 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
7267 Typ
:= Underlying_Type
(Entity
(Arg
));
7269 -- For now we simply check some of the semantic constraints
7270 -- on the type. This currently leaves out some restrictions
7271 -- on interface types, namely that the parent type must be
7272 -- java.lang.Object.Typ and that all primitives of the type
7273 -- should be declared abstract. ???
7275 if not Is_Tagged_Type
(Typ
) or else not Is_Abstract
(Typ
) then
7276 Error_Pragma_Arg
("pragma% requires an abstract "
7277 & "tagged type", Arg1
);
7279 elsif not Has_Discriminants
(Typ
)
7280 or else Ekind
(Etype
(First_Discriminant
(Typ
)))
7281 /= E_Anonymous_Access_Type
7283 not Is_Class_Wide_Type
7284 (Designated_Type
(Etype
(First_Discriminant
(Typ
))))
7287 ("type must have a class-wide access discriminant", Arg1
);
7295 -- pragma Keep_Names ([On => ] local_NAME);
7297 when Pragma_Keep_Names
=> Keep_Names
: declare
7302 Check_Arg_Count
(1);
7303 Check_Optional_Identifier
(Arg1
, Name_On
);
7304 Check_Arg_Is_Local_Name
(Arg1
);
7306 Arg
:= Expression
(Arg1
);
7309 if Etype
(Arg
) = Any_Type
then
7313 if not Is_Entity_Name
(Arg
)
7314 or else Ekind
(Entity
(Arg
)) /= E_Enumeration_Type
7317 ("pragma% requires a local enumeration type", Arg1
);
7320 Set_Discard_Names
(Entity
(Arg
), False);
7327 -- pragma License (RESTRICTED | UNRESRICTED | GPL | MODIFIED_GPL);
7329 when Pragma_License
=>
7331 Check_Arg_Count
(1);
7332 Check_No_Identifiers
;
7333 Check_Valid_Configuration_Pragma
;
7334 Check_Arg_Is_Identifier
(Arg1
);
7337 Sind
: constant Source_File_Index
:=
7338 Source_Index
(Current_Sem_Unit
);
7341 case Chars
(Get_Pragma_Arg
(Arg1
)) is
7343 Set_License
(Sind
, GPL
);
7345 when Name_Modified_GPL
=>
7346 Set_License
(Sind
, Modified_GPL
);
7348 when Name_Restricted
=>
7349 Set_License
(Sind
, Restricted
);
7351 when Name_Unrestricted
=>
7352 Set_License
(Sind
, Unrestricted
);
7355 Error_Pragma_Arg
("invalid license name", Arg1
);
7363 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
7365 when Pragma_Link_With
=> Link_With
: declare
7371 if Operating_Mode
= Generate_Code
7372 and then In_Extended_Main_Source_Unit
(N
)
7374 Check_At_Least_N_Arguments
(1);
7375 Check_No_Identifiers
;
7376 Check_Is_In_Decl_Part_Or_Package_Spec
;
7377 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7381 while Present
(Arg
) loop
7382 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
7384 -- Store argument, converting sequences of spaces
7385 -- to a single null character (this is one of the
7386 -- differences in processing between Link_With
7387 -- and Linker_Options).
7390 C
: constant Char_Code
:= Get_Char_Code
(' ');
7391 S
: constant String_Id
:=
7392 Strval
(Expr_Value_S
(Expression
(Arg
)));
7393 L
: constant Nat
:= String_Length
(S
);
7396 procedure Skip_Spaces
;
7397 -- Advance F past any spaces
7399 procedure Skip_Spaces
is
7401 while F
<= L
and then Get_String_Char
(S
, F
) = C
loop
7407 Skip_Spaces
; -- skip leading spaces
7409 -- Loop through characters, changing any embedded
7410 -- sequence of spaces to a single null character
7411 -- (this is how Link_With/Linker_Options differ)
7414 if Get_String_Char
(S
, F
) = C
then
7417 Store_String_Char
(ASCII
.NUL
);
7420 Store_String_Char
(Get_String_Char
(S
, F
));
7428 if Present
(Arg
) then
7429 Store_String_Char
(ASCII
.NUL
);
7433 Store_Linker_Option_String
(End_String
);
7441 -- pragma Linker_Alias (
7442 -- [Entity =>] LOCAL_NAME
7443 -- [Alias =>] static_string_EXPRESSION);
7445 when Pragma_Linker_Alias
=>
7447 Check_Arg_Count
(2);
7448 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7449 Check_Optional_Identifier
(Arg2
, "alias");
7450 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
7451 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7453 -- The only processing required is to link this item on to the
7454 -- list of rep items for the given entity. This is accomplished
7455 -- by the call to Rep_Item_Too_Late (when no error is detected
7456 -- and False is returned).
7458 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
7461 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7464 --------------------
7465 -- Linker_Options --
7466 --------------------
7468 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
7470 when Pragma_Linker_Options
=> Linker_Options
: declare
7474 Check_Ada_83_Warning
;
7475 Check_No_Identifiers
;
7476 Check_Arg_Count
(1);
7477 Check_Is_In_Decl_Part_Or_Package_Spec
;
7479 if Operating_Mode
= Generate_Code
7480 and then In_Extended_Main_Source_Unit
(N
)
7482 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7483 Start_String
(Strval
(Expr_Value_S
(Expression
(Arg1
))));
7486 while Present
(Arg
) loop
7487 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
7488 Store_String_Char
(ASCII
.NUL
);
7490 (Strval
(Expr_Value_S
(Expression
(Arg
))));
7494 Store_Linker_Option_String
(End_String
);
7498 --------------------
7499 -- Linker_Section --
7500 --------------------
7502 -- pragma Linker_Section (
7503 -- [Entity =>] LOCAL_NAME
7504 -- [Section =>] static_string_EXPRESSION);
7506 when Pragma_Linker_Section
=>
7508 Check_Arg_Count
(2);
7509 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7510 Check_Optional_Identifier
(Arg2
, Name_Section
);
7511 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
7512 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7514 -- The only processing required is to link this item on to the
7515 -- list of rep items for the given entity. This is accomplished
7516 -- by the call to Rep_Item_Too_Late (when no error is detected
7517 -- and False is returned).
7519 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
7522 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7529 -- pragma List (On | Off)
7531 -- There is nothing to do here, since we did all the processing
7532 -- for this pragma in Par.Prag (so that it works properly even in
7533 -- syntax only mode)
7538 --------------------
7539 -- Locking_Policy --
7540 --------------------
7542 -- pragma Locking_Policy (policy_IDENTIFIER);
7544 when Pragma_Locking_Policy
=> declare
7548 Check_Ada_83_Warning
;
7549 Check_Arg_Count
(1);
7550 Check_No_Identifiers
;
7551 Check_Arg_Is_Locking_Policy
(Arg1
);
7552 Check_Valid_Configuration_Pragma
;
7553 Get_Name_String
(Chars
(Expression
(Arg1
)));
7554 LP
:= Fold_Upper
(Name_Buffer
(1));
7556 if Locking_Policy
/= ' '
7557 and then Locking_Policy
/= LP
7559 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
7560 Error_Pragma
("locking policy incompatible with policy#");
7562 -- Set new policy, but always preserve System_Location since
7563 -- we like the error message with the run time name.
7566 Locking_Policy
:= LP
;
7568 if Locking_Policy_Sloc
/= System_Location
then
7569 Locking_Policy_Sloc
:= Loc
;
7578 -- pragma Long_Float (D_Float | G_Float);
7580 when Pragma_Long_Float
=>
7582 Check_Valid_Configuration_Pragma
;
7583 Check_Arg_Count
(1);
7584 Check_No_Identifier
(Arg1
);
7585 Check_Arg_Is_One_Of
(Arg1
, Name_D_Float
, Name_G_Float
);
7587 if not OpenVMS_On_Target
then
7588 Error_Pragma
("?pragma% ignored (applies only to Open'V'M'S)");
7593 if Chars
(Expression
(Arg1
)) = Name_D_Float
then
7594 if Opt
.Float_Format_Long
= 'G' then
7595 Error_Pragma
("G_Float previously specified");
7598 Opt
.Float_Format_Long
:= 'D';
7600 -- G_Float case (this is the default, does not need overriding)
7603 if Opt
.Float_Format_Long
= 'D' then
7604 Error_Pragma
("D_Float previously specified");
7607 Opt
.Float_Format_Long
:= 'G';
7610 Set_Standard_Fpt_Formats
;
7612 -----------------------
7613 -- Machine_Attribute --
7614 -----------------------
7616 -- pragma Machine_Attribute (
7617 -- [Entity =>] LOCAL_NAME,
7618 -- [Attribute_Name =>] static_string_EXPRESSION
7619 -- [,[Info =>] static_string_EXPRESSION] );
7621 when Pragma_Machine_Attribute
=> Machine_Attribute
: declare
7627 if Arg_Count
= 3 then
7628 Check_Optional_Identifier
(Arg3
, "info");
7629 Check_Arg_Is_Static_Expression
(Arg3
, Standard_String
);
7631 Check_Arg_Count
(2);
7634 Check_Arg_Is_Local_Name
(Arg1
);
7635 Check_Optional_Identifier
(Arg2
, "attribute_name");
7636 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7637 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7638 Def_Id
:= Entity
(Expression
(Arg1
));
7640 if Is_Access_Type
(Def_Id
) then
7641 Def_Id
:= Designated_Type
(Def_Id
);
7644 if Rep_Item_Too_Early
(Def_Id
, N
) then
7648 Def_Id
:= Underlying_Type
(Def_Id
);
7650 -- The only processing required is to link this item on to the
7651 -- list of rep items for the given entity. This is accomplished
7652 -- by the call to Rep_Item_Too_Late (when no error is detected
7653 -- and False is returned).
7655 if Rep_Item_Too_Late
(Def_Id
, N
) then
7658 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7660 end Machine_Attribute
;
7666 -- pragma Main_Storage
7667 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
7669 -- MAIN_STORAGE_OPTION ::=
7670 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
7671 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
7673 when Pragma_Main
=> Main
: declare
7674 Args
: Args_List
(1 .. 3);
7675 Names
: constant Name_List
(1 .. 3) := (
7677 Name_Task_Stack_Size_Default
,
7678 Name_Time_Slicing_Enabled
);
7684 Gather_Associations
(Names
, Args
);
7686 for J
in 1 .. 2 loop
7687 if Present
(Args
(J
)) then
7688 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
7692 if Present
(Args
(3)) then
7693 Check_Arg_Is_Static_Expression
(Args
(3), Standard_Boolean
);
7697 while Present
(Nod
) loop
7698 if Nkind
(Nod
) = N_Pragma
7699 and then Chars
(Nod
) = Name_Main
7701 Error_Msg_Name_1
:= Chars
(N
);
7702 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
7713 -- pragma Main_Storage
7714 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
7716 -- MAIN_STORAGE_OPTION ::=
7717 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
7718 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
7720 when Pragma_Main_Storage
=> Main_Storage
: declare
7721 Args
: Args_List
(1 .. 2);
7722 Names
: constant Name_List
(1 .. 2) := (
7723 Name_Working_Storage
,
7730 Gather_Associations
(Names
, Args
);
7732 for J
in 1 .. 2 loop
7733 if Present
(Args
(J
)) then
7734 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
7738 Check_In_Main_Program
;
7741 while Present
(Nod
) loop
7742 if Nkind
(Nod
) = N_Pragma
7743 and then Chars
(Nod
) = Name_Main_Storage
7745 Error_Msg_Name_1
:= Chars
(N
);
7746 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
7757 -- pragma Memory_Size (NUMERIC_LITERAL)
7759 when Pragma_Memory_Size
=>
7762 -- Memory size is simply ignored
7764 Check_No_Identifiers
;
7765 Check_Arg_Count
(1);
7766 Check_Arg_Is_Integer_Literal
(Arg1
);
7772 -- pragma No_Return (procedure_LOCAL_NAME);
7774 when Pragma_No_Return
=> No_Return
: declare
7781 Check_Arg_Count
(1);
7782 Check_No_Identifiers
;
7783 Check_Arg_Is_Local_Name
(Arg1
);
7784 Id
:= Expression
(Arg1
);
7787 if not Is_Entity_Name
(Id
) then
7788 Error_Pragma_Arg
("entity name required", Arg1
);
7791 if Etype
(Id
) = Any_Type
then
7799 and then Scope
(E
) = Current_Scope
7801 if Ekind
(E
) = E_Procedure
7802 or else Ekind
(E
) = E_Generic_Procedure
7812 Error_Pragma
("no procedures found for pragma%");
7816 ------------------------
7817 -- No_Strict_Aliasing --
7818 ------------------------
7820 when Pragma_No_Strict_Aliasing
=> No_Strict_Alias
: declare
7825 Check_At_Most_N_Arguments
(1);
7827 if Arg_Count
= 0 then
7828 Check_Valid_Configuration_Pragma
;
7829 Opt
.No_Strict_Aliasing
:= True;
7832 Check_Optional_Identifier
(Arg2
, Name_Entity
);
7833 Check_Arg_Is_Local_Name
(Arg1
);
7834 E_Id
:= Entity
(Expression
(Arg1
));
7836 if E_Id
= Any_Type
then
7838 elsif No
(E_Id
) or else not Is_Access_Type
(E_Id
) then
7839 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
7842 Set_No_Strict_Aliasing
(Implementation_Base_Type
(E_Id
));
7844 end No_Strict_Alias
;
7850 -- pragma Obsolescent [(static_string_EXPRESSION)];
7852 when Pragma_Obsolescent
=> Obsolescent
: declare
7855 Check_At_Most_N_Arguments
(1);
7856 Check_No_Identifiers
;
7858 if Arg_Count
= 1 then
7859 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7863 or else (Nkind
(Prev
(N
))) /= N_Subprogram_Declaration
7866 ("pragma% misplaced, must immediately " &
7867 "follow subprogram spec");
7875 -- pragma No_Run_Time
7877 -- Note: this pragma is retained for backwards compatibiltiy.
7878 -- See body of Rtsfind for full details on its handling.
7880 when Pragma_No_Run_Time
=>
7882 Check_Valid_Configuration_Pragma
;
7883 Check_Arg_Count
(0);
7885 No_Run_Time_Mode
:= True;
7886 Configurable_Run_Time_Mode
:= True;
7889 Word32
: constant Boolean := Ttypes
.System_Word_Size
= 32;
7892 Duration_32_Bits_On_Target
:= True;
7896 Set_Restriction
(No_Finalization
, N
);
7897 Set_Restriction
(No_Exception_Handlers
, N
);
7898 Set_Restriction
(Max_Tasks
, N
, 0);
7899 Set_Restriction
(No_Tasking
, N
);
7901 -----------------------
7902 -- Normalize_Scalars --
7903 -----------------------
7905 -- pragma Normalize_Scalars;
7907 when Pragma_Normalize_Scalars
=>
7908 Check_Ada_83_Warning
;
7909 Check_Arg_Count
(0);
7910 Check_Valid_Configuration_Pragma
;
7911 Normalize_Scalars
:= True;
7912 Init_Or_Norm_Scalars
:= True;
7918 -- pragma Optimize (Time | Space);
7920 -- The actual check for optimize is done in Gigi. Note that this
7921 -- pragma does not actually change the optimization setting, it
7922 -- simply checks that it is consistent with the pragma.
7924 when Pragma_Optimize
=>
7925 Check_No_Identifiers
;
7926 Check_Arg_Count
(1);
7927 Check_Arg_Is_One_Of
(Arg1
, Name_Time
, Name_Space
, Name_Off
);
7929 -------------------------
7930 -- Optional_Overriding --
7931 -------------------------
7933 -- These pragmas are treated as part of the previous subprogram
7934 -- declaration, and analyzed immediately after it (see sem_ch6,
7935 -- Check_Overriding_Operation). If the pragma has not been analyzed
7936 -- yet, it appears in the wrong place.
7938 when Pragma_Optional_Overriding
=>
7939 Error_Msg_N
("pragma must appear immediately after subprogram", N
);
7945 when Pragma_Overriding
=>
7946 Error_Msg_N
("pragma must appear immediately after subprogram", N
);
7952 -- pragma Pack (first_subtype_LOCAL_NAME);
7954 when Pragma_Pack
=> Pack
: declare
7955 Assoc
: constant Node_Id
:= Arg1
;
7960 Check_No_Identifiers
;
7961 Check_Arg_Count
(1);
7962 Check_Arg_Is_Local_Name
(Arg1
);
7964 Type_Id
:= Expression
(Assoc
);
7965 Find_Type
(Type_Id
);
7966 Typ
:= Entity
(Type_Id
);
7969 or else Rep_Item_Too_Early
(Typ
, N
)
7973 Typ
:= Underlying_Type
(Typ
);
7976 if not Is_Array_Type
(Typ
) and then not Is_Record_Type
(Typ
) then
7977 Error_Pragma
("pragma% must specify array or record type");
7980 Check_First_Subtype
(Arg1
);
7982 if Has_Pragma_Pack
(Typ
) then
7983 Error_Pragma
("duplicate pragma%, only one allowed");
7985 -- Array type. We set the Has_Pragma_Pack flag, and Is_Packed,
7986 -- but not Has_Non_Standard_Rep, because we don't actually know
7987 -- till freeze time if the array can have packed representation.
7988 -- That's because in the general case we do not know enough about
7989 -- the component type until it in turn is frozen, which certainly
7990 -- happens before the array type is frozen, but not necessarily
7991 -- till that point (i.e. right now it may be unfrozen).
7993 elsif Is_Array_Type
(Typ
) then
7994 if Has_Aliased_Components
(Base_Type
(Typ
)) then
7996 ("pragma% ignored, cannot pack aliased components?");
7998 elsif Has_Atomic_Components
(Typ
)
7999 or else Is_Atomic
(Component_Type
(Typ
))
8002 ("?pragma% ignored, cannot pack atomic components");
8004 elsif not Rep_Item_Too_Late
(Typ
, N
) then
8005 Set_Is_Packed
(Base_Type
(Typ
));
8006 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
8007 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
8010 -- Record type. For record types, the pack is always effective
8012 else pragma Assert
(Is_Record_Type
(Typ
));
8013 if not Rep_Item_Too_Late
(Typ
, N
) then
8014 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
8015 Set_Is_Packed
(Base_Type
(Typ
));
8016 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
8027 -- There is nothing to do here, since we did all the processing
8028 -- for this pragma in Par.Prag (so that it works properly even in
8029 -- syntax only mode)
8038 -- pragma Passive [(PASSIVE_FORM)];
8040 -- PASSIVE_FORM ::= Semaphore | No
8042 when Pragma_Passive
=>
8045 if Nkind
(Parent
(N
)) /= N_Task_Definition
then
8046 Error_Pragma
("pragma% must be within task definition");
8049 if Arg_Count
/= 0 then
8050 Check_Arg_Count
(1);
8051 Check_Arg_Is_One_Of
(Arg1
, Name_Semaphore
, Name_No
);
8058 -- pragma Polling (ON | OFF);
8060 when Pragma_Polling
=>
8062 Check_Arg_Count
(1);
8063 Check_No_Identifiers
;
8064 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
8065 Polling_Required
:= (Chars
(Expression
(Arg1
)) = Name_On
);
8067 ---------------------
8068 -- Persistent_Data --
8069 ---------------------
8071 when Pragma_Persistent_Data
=> declare
8075 -- Register the pragma as applying to the compilation unit.
8076 -- Individual Persistent_Object pragmas for relevant objects
8077 -- are generated the end of the compilation.
8080 Check_Valid_Configuration_Pragma
;
8081 Check_Arg_Count
(0);
8082 Ent
:= Find_Lib_Unit_Name
;
8083 Set_Is_Preelaborated
(Ent
);
8086 -----------------------
8087 -- Persistent_Object --
8088 -----------------------
8090 when Pragma_Persistent_Object
=> declare
8098 Check_Arg_Count
(1);
8099 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
8101 if not Is_Entity_Name
(Expression
(Arg1
))
8103 (Ekind
(Entity
(Expression
(Arg1
))) /= E_Variable
8104 and then Ekind
(Entity
(Expression
(Arg1
))) /= E_Constant
)
8106 Error_Pragma_Arg
("pragma only applies to objects", Arg1
);
8109 Ent
:= Entity
(Expression
(Arg1
));
8110 Decl
:= Parent
(Ent
);
8112 if Nkind
(Decl
) /= N_Object_Declaration
then
8116 -- Placement of the object depends on whether there is
8117 -- an initial value or none. If the No_Initialization flag
8118 -- is set, the initialization has been transformed into
8119 -- assignments, which is disallowed elaboration code.
8121 if No_Initialization
(Decl
) then
8123 ("initialization for persistent object"
8124 & "must be static expression", Decl
);
8128 if No
(Expression
(Decl
)) then
8130 Store_String_Chars
("section ("".persistent.bss"")");
8134 if not Is_OK_Static_Expression
(Expression
(Decl
)) then
8135 Flag_Non_Static_Expr
8136 ("initialization for persistent object"
8137 & "must be static expression!", Expression
(Decl
));
8142 Store_String_Chars
("section ("".persistent.data"")");
8149 Name_Machine_Attribute
,
8151 (Make_Pragma_Argument_Association
8152 (Sloc
=> Sloc
(Arg1
),
8153 Expression
=> New_Occurrence_Of
(Ent
, Sloc
(Ent
))),
8154 Make_Pragma_Argument_Association
8155 (Sloc
=> Sloc
(Arg1
),
8158 (Sloc
=> Sloc
(Arg1
),
8161 Insert_After
(N
, MA
);
8163 Set_Has_Gigi_Rep_Item
(Ent
);
8170 -- pragma Preelaborate [(library_unit_NAME)];
8172 -- Set the flag Is_Preelaborated of program unit name entity
8174 when Pragma_Preelaborate
=> Preelaborate
: declare
8175 Pa
: constant Node_Id
:= Parent
(N
);
8176 Pk
: constant Node_Kind
:= Nkind
(Pa
);
8180 Check_Ada_83_Warning
;
8181 Check_Valid_Library_Unit_Pragma
;
8183 if Nkind
(N
) = N_Null_Statement
then
8187 Ent
:= Find_Lib_Unit_Name
;
8189 -- This filters out pragmas inside generic parent then
8190 -- show up inside instantiation
8193 and then not (Pk
= N_Package_Specification
8194 and then Present
(Generic_Parent
(Pa
)))
8196 if not Debug_Flag_U
then
8197 Set_Is_Preelaborated
(Ent
);
8198 Set_Suppress_Elaboration_Warnings
(Ent
);
8207 -- pragma Priority (EXPRESSION);
8209 when Pragma_Priority
=> Priority
: declare
8210 P
: constant Node_Id
:= Parent
(N
);
8214 Check_No_Identifiers
;
8215 Check_Arg_Count
(1);
8219 if Nkind
(P
) = N_Subprogram_Body
then
8220 Check_In_Main_Program
;
8222 Arg
:= Expression
(Arg1
);
8223 Analyze_And_Resolve
(Arg
, Standard_Integer
);
8227 if not Is_Static_Expression
(Arg
) then
8228 Flag_Non_Static_Expr
8229 ("main subprogram priority is not static!", Arg
);
8232 -- If constraint error, then we already signalled an error
8234 elsif Raises_Constraint_Error
(Arg
) then
8237 -- Otherwise check in range
8241 Val
: constant Uint
:= Expr_Value
(Arg
);
8245 or else Val
> Expr_Value
(Expression
8246 (Parent
(RTE
(RE_Max_Priority
))))
8249 ("main subprogram priority is out of range", Arg1
);
8255 (Current_Sem_Unit
, UI_To_Int
(Expr_Value
(Arg
)));
8257 -- Task or Protected, must be of type Integer
8259 elsif Nkind
(P
) = N_Protected_Definition
8261 Nkind
(P
) = N_Task_Definition
8263 Arg
:= Expression
(Arg1
);
8265 -- The expression must be analyzed in the special manner
8266 -- described in "Handling of Default and Per-Object
8267 -- Expressions" in sem.ads.
8269 Analyze_Per_Use_Expression
(Arg
, Standard_Integer
);
8271 if not Is_Static_Expression
(Arg
) then
8272 Check_Restriction
(Static_Priorities
, Arg
);
8275 -- Anything else is incorrect
8281 if Has_Priority_Pragma
(P
) then
8282 Error_Pragma
("duplicate pragma% not allowed");
8284 Set_Has_Priority_Pragma
(P
, True);
8286 if Nkind
(P
) = N_Protected_Definition
8288 Nkind
(P
) = N_Task_Definition
8290 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
8291 -- exp_ch9 should use this ???
8300 -- pragma Profile (profile_IDENTIFIER);
8302 -- profile_IDENTIFIER => Protected | Ravenscar
8304 when Pragma_Profile
=>
8305 Check_Arg_Count
(1);
8306 Check_Valid_Configuration_Pragma
;
8307 Check_No_Identifiers
;
8310 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
8312 if Chars
(Argx
) = Name_Ravenscar
then
8313 Set_Ravenscar_Profile
(N
);
8315 elsif Chars
(Argx
) = Name_Restricted
then
8316 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> False);
8318 Error_Pragma_Arg
("& is not a valid profile", Argx
);
8322 ----------------------
8323 -- Profile_Warnings --
8324 ----------------------
8326 -- pragma Profile_Warnings (profile_IDENTIFIER);
8328 -- profile_IDENTIFIER => Protected | Ravenscar
8330 when Pragma_Profile_Warnings
=>
8332 Check_Arg_Count
(1);
8333 Check_Valid_Configuration_Pragma
;
8334 Check_No_Identifiers
;
8337 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
8339 if Chars
(Argx
) = Name_Ravenscar
then
8340 Set_Profile_Restrictions
(Ravenscar
, N
, Warn
=> True);
8342 elsif Chars
(Argx
) = Name_Restricted
then
8343 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> True);
8345 Error_Pragma_Arg
("& is not a valid profile", Argx
);
8349 --------------------------
8350 -- Propagate_Exceptions --
8351 --------------------------
8353 -- pragma Propagate_Exceptions;
8355 when Pragma_Propagate_Exceptions
=>
8357 Check_Arg_Count
(0);
8359 if In_Extended_Main_Source_Unit
(N
) then
8360 Propagate_Exceptions
:= True;
8367 -- pragma Psect_Object (
8368 -- [Internal =>] LOCAL_NAME,
8369 -- [, [External =>] EXTERNAL_SYMBOL]
8370 -- [, [Size =>] EXTERNAL_SYMBOL]);
8372 when Pragma_Psect_Object | Pragma_Common_Object
=>
8373 Psect_Object
: declare
8374 Args
: Args_List
(1 .. 3);
8375 Names
: constant Name_List
(1 .. 3) := (
8380 Internal
: Node_Id
renames Args
(1);
8381 External
: Node_Id
renames Args
(2);
8382 Size
: Node_Id
renames Args
(3);
8384 R_Internal
: Node_Id
;
8385 R_External
: Node_Id
;
8392 procedure Check_Too_Long
(Arg
: Node_Id
);
8393 -- Posts message if the argument is an identifier with more
8394 -- than 31 characters, or a string literal with more than
8395 -- 31 characters, and we are operating under VMS
8397 --------------------
8398 -- Check_Too_Long --
8399 --------------------
8401 procedure Check_Too_Long
(Arg
: Node_Id
) is
8402 X
: constant Node_Id
:= Original_Node
(Arg
);
8405 if Nkind
(X
) /= N_String_Literal
8407 Nkind
(X
) /= N_Identifier
8410 ("inappropriate argument for pragma %", Arg
);
8413 if OpenVMS_On_Target
then
8414 if (Nkind
(X
) = N_String_Literal
8415 and then String_Length
(Strval
(X
)) > 31)
8417 (Nkind
(X
) = N_Identifier
8418 and then Length_Of_Name
(Chars
(X
)) > 31)
8421 ("argument for pragma % is longer than 31 characters",
8427 -- Start of processing for Common_Object/Psect_Object
8431 Gather_Associations
(Names
, Args
);
8432 Process_Extended_Import_Export_Internal_Arg
(Internal
);
8434 R_Internal
:= Relocate_Node
(Internal
);
8436 Def_Id
:= Entity
(R_Internal
);
8438 if Ekind
(Def_Id
) /= E_Constant
8439 and then Ekind
(Def_Id
) /= E_Variable
8442 ("pragma% must designate an object", Internal
);
8445 Check_Too_Long
(R_Internal
);
8447 if Is_Imported
(Def_Id
) or else Is_Exported
(Def_Id
) then
8449 ("cannot use pragma% for imported/exported object",
8453 if Is_Concurrent_Type
(Etype
(R_Internal
)) then
8455 ("cannot specify pragma % for task/protected object",
8459 if Is_Psected
(Def_Id
) then
8460 Error_Msg_N
("?duplicate Psect_Object pragma", N
);
8462 Set_Is_Psected
(Def_Id
);
8465 if Ekind
(Def_Id
) = E_Constant
then
8467 ("cannot specify pragma % for a constant", R_Internal
);
8470 if Is_Record_Type
(Etype
(R_Internal
)) then
8476 Ent
:= First_Entity
(Etype
(R_Internal
));
8477 while Present
(Ent
) loop
8478 Decl
:= Declaration_Node
(Ent
);
8480 if Ekind
(Ent
) = E_Component
8481 and then Nkind
(Decl
) = N_Component_Declaration
8482 and then Present
(Expression
(Decl
))
8483 and then Warn_On_Export_Import
8486 ("?object for pragma % has defaults", R_Internal
);
8496 if Present
(Size
) then
8497 Check_Too_Long
(Size
);
8500 -- Make Psect case-insensitive.
8502 if Present
(External
) then
8503 Check_Too_Long
(External
);
8505 if Nkind
(External
) = N_String_Literal
then
8506 String_To_Name_Buffer
(Strval
(External
));
8508 Get_Name_String
(Chars
(External
));
8513 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
8515 R_External
:= Make_String_Literal
8516 (Sloc
=> Sloc
(External
), Strval
=> Str
);
8518 Get_Name_String
(Chars
(Internal
));
8521 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
8523 R_External
:= Make_String_Literal
8524 (Sloc
=> Sloc
(Internal
), Strval
=> Str
);
8527 -- Transform into pragma Linker_Section, add attributes to
8528 -- match what DEC Ada does. Ignore size for now?
8533 Name_Linker_Section
,
8535 (Make_Pragma_Argument_Association
8536 (Sloc
=> Sloc
(R_Internal
),
8537 Expression
=> R_Internal
),
8538 Make_Pragma_Argument_Association
8539 (Sloc
=> Sloc
(R_External
),
8540 Expression
=> R_External
))));
8544 -- Add Machine_Attribute of "overlaid", so the section overlays
8545 -- other sections of the same name.
8548 Store_String_Chars
("overlaid");
8554 Name_Machine_Attribute
,
8556 (Make_Pragma_Argument_Association
8557 (Sloc
=> Sloc
(R_Internal
),
8558 Expression
=> R_Internal
),
8559 Make_Pragma_Argument_Association
8560 (Sloc
=> Sloc
(R_External
),
8563 (Sloc
=> Sloc
(R_External
),
8567 -- Add Machine_Attribute of "global", so the section is visible
8571 Store_String_Chars
("global");
8577 Name_Machine_Attribute
,
8579 (Make_Pragma_Argument_Association
8580 (Sloc
=> Sloc
(R_Internal
),
8581 Expression
=> R_Internal
),
8583 Make_Pragma_Argument_Association
8584 (Sloc
=> Sloc
(R_External
),
8587 (Sloc
=> Sloc
(R_External
),
8591 -- Add Machine_Attribute of "initialize", so the section is
8595 Store_String_Chars
("initialize");
8601 Name_Machine_Attribute
,
8603 (Make_Pragma_Argument_Association
8604 (Sloc
=> Sloc
(R_Internal
),
8605 Expression
=> R_Internal
),
8607 Make_Pragma_Argument_Association
8608 (Sloc
=> Sloc
(R_External
),
8611 (Sloc
=> Sloc
(R_External
),
8620 -- pragma Pure [(library_unit_NAME)];
8622 when Pragma_Pure
=> Pure
: declare
8625 Check_Ada_83_Warning
;
8626 Check_Valid_Library_Unit_Pragma
;
8628 if Nkind
(N
) = N_Null_Statement
then
8632 Ent
:= Find_Lib_Unit_Name
;
8634 Set_Suppress_Elaboration_Warnings
(Ent
);
8641 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
8643 when Pragma_Pure_Function
=> Pure_Function
: declare
8647 Effective
: Boolean := False;
8651 Check_Arg_Count
(1);
8652 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8653 Check_Arg_Is_Local_Name
(Arg1
);
8654 E_Id
:= Expression
(Arg1
);
8656 if Error_Posted
(E_Id
) then
8660 -- Loop through homonyms (overloadings) of referenced entity
8666 Def_Id
:= Get_Base_Subprogram
(E
);
8668 if Ekind
(Def_Id
) /= E_Function
8669 and then Ekind
(Def_Id
) /= E_Generic_Function
8670 and then Ekind
(Def_Id
) /= E_Operator
8673 ("pragma% requires a function name", Arg1
);
8676 Set_Is_Pure
(Def_Id
);
8678 if not Has_Pragma_Pure_Function
(Def_Id
) then
8679 Set_Has_Pragma_Pure_Function
(Def_Id
);
8684 exit when No
(E
) or else Scope
(E
) /= Current_Scope
;
8688 and then Warn_On_Redundant_Constructs
8690 Error_Msg_NE
("pragma Pure_Function on& is redundant?",
8696 --------------------
8697 -- Queuing_Policy --
8698 --------------------
8700 -- pragma Queuing_Policy (policy_IDENTIFIER);
8702 when Pragma_Queuing_Policy
=> declare
8706 Check_Ada_83_Warning
;
8707 Check_Arg_Count
(1);
8708 Check_No_Identifiers
;
8709 Check_Arg_Is_Queuing_Policy
(Arg1
);
8710 Check_Valid_Configuration_Pragma
;
8711 Get_Name_String
(Chars
(Expression
(Arg1
)));
8712 QP
:= Fold_Upper
(Name_Buffer
(1));
8714 if Queuing_Policy
/= ' '
8715 and then Queuing_Policy
/= QP
8717 Error_Msg_Sloc
:= Queuing_Policy_Sloc
;
8718 Error_Pragma
("queuing policy incompatible with policy#");
8720 -- Set new policy, but always preserve System_Location since
8721 -- we like the error message with the run time name.
8724 Queuing_Policy
:= QP
;
8726 if Queuing_Policy_Sloc
/= System_Location
then
8727 Queuing_Policy_Sloc
:= Loc
;
8732 ---------------------------
8733 -- Remote_Call_Interface --
8734 ---------------------------
8736 -- pragma Remote_Call_Interface [(library_unit_NAME)];
8738 when Pragma_Remote_Call_Interface
=> Remote_Call_Interface
: declare
8739 Cunit_Node
: Node_Id
;
8740 Cunit_Ent
: Entity_Id
;
8744 Check_Ada_83_Warning
;
8745 Check_Valid_Library_Unit_Pragma
;
8747 if Nkind
(N
) = N_Null_Statement
then
8751 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
8752 K
:= Nkind
(Unit
(Cunit_Node
));
8753 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
8755 if K
= N_Package_Declaration
8756 or else K
= N_Generic_Package_Declaration
8757 or else K
= N_Subprogram_Declaration
8758 or else K
= N_Generic_Subprogram_Declaration
8759 or else (K
= N_Subprogram_Body
8760 and then Acts_As_Spec
(Unit
(Cunit_Node
)))
8765 "pragma% must apply to package or subprogram declaration");
8768 Set_Is_Remote_Call_Interface
(Cunit_Ent
);
8769 end Remote_Call_Interface
;
8775 -- pragma Remote_Types [(library_unit_NAME)];
8777 when Pragma_Remote_Types
=> Remote_Types
: declare
8778 Cunit_Node
: Node_Id
;
8779 Cunit_Ent
: Entity_Id
;
8782 Check_Ada_83_Warning
;
8783 Check_Valid_Library_Unit_Pragma
;
8785 if Nkind
(N
) = N_Null_Statement
then
8789 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
8790 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
8792 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
8794 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
8797 "pragma% can only apply to a package declaration");
8800 Set_Is_Remote_Types
(Cunit_Ent
);
8807 -- pragma Ravenscar;
8809 when Pragma_Ravenscar
=>
8811 Check_Arg_Count
(0);
8812 Check_Valid_Configuration_Pragma
;
8813 Set_Ravenscar_Profile
(N
);
8815 if Warn_On_Obsolescent_Feature
then
8817 ("pragma Ravenscar is an obsolescent feature?", N
);
8819 ("|use pragma Profile (Ravenscar) instead", N
);
8822 -------------------------
8823 -- Restricted_Run_Time --
8824 -------------------------
8826 -- pragma Restricted_Run_Time;
8828 when Pragma_Restricted_Run_Time
=>
8830 Check_Arg_Count
(0);
8831 Check_Valid_Configuration_Pragma
;
8832 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> False);
8834 if Warn_On_Obsolescent_Feature
then
8836 ("pragma Restricted_Run_Time is an obsolescent feature?", N
);
8838 ("|use pragma Profile (Restricted) instead", N
);
8845 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
8848 -- restriction_IDENTIFIER
8849 -- | restriction_parameter_IDENTIFIER => EXPRESSION
8851 when Pragma_Restrictions
=>
8852 Process_Restrictions_Or_Restriction_Warnings
;
8854 --------------------------
8855 -- Restriction_Warnings --
8856 --------------------------
8858 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
8861 -- restriction_IDENTIFIER
8862 -- | restriction_parameter_IDENTIFIER => EXPRESSION
8864 when Pragma_Restriction_Warnings
=>
8865 Process_Restrictions_Or_Restriction_Warnings
;
8871 -- pragma Reviewable;
8873 when Pragma_Reviewable
=>
8874 Check_Ada_83_Warning
;
8875 Check_Arg_Count
(0);
8881 -- pragma Share_Generic (NAME {, NAME});
8883 when Pragma_Share_Generic
=>
8885 Process_Generic_List
;
8891 -- pragma Shared (LOCAL_NAME);
8893 when Pragma_Shared
=>
8895 Process_Atomic_Shared_Volatile
;
8897 --------------------
8898 -- Shared_Passive --
8899 --------------------
8901 -- pragma Shared_Passive [(library_unit_NAME)];
8903 -- Set the flag Is_Shared_Passive of program unit name entity
8905 when Pragma_Shared_Passive
=> Shared_Passive
: declare
8906 Cunit_Node
: Node_Id
;
8907 Cunit_Ent
: Entity_Id
;
8910 Check_Ada_83_Warning
;
8911 Check_Valid_Library_Unit_Pragma
;
8913 if Nkind
(N
) = N_Null_Statement
then
8917 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
8918 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
8920 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
8922 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
8925 "pragma% can only apply to a package declaration");
8928 Set_Is_Shared_Passive
(Cunit_Ent
);
8931 ----------------------
8932 -- Source_File_Name --
8933 ----------------------
8935 -- There are five forms for this pragma:
8937 -- pragma Source_File_Name (
8938 -- [UNIT_NAME =>] unit_NAME,
8939 -- BODY_FILE_NAME => STRING_LITERAL
8940 -- [, [INDEX =>] INTEGER_LITERAL]);
8942 -- pragma Source_File_Name (
8943 -- [UNIT_NAME =>] unit_NAME,
8944 -- SPEC_FILE_NAME => STRING_LITERAL
8945 -- [, [INDEX =>] INTEGER_LITERAL]);
8947 -- pragma Source_File_Name (
8948 -- BODY_FILE_NAME => STRING_LITERAL
8949 -- [, DOT_REPLACEMENT => STRING_LITERAL]
8950 -- [, CASING => CASING_SPEC]);
8952 -- pragma Source_File_Name (
8953 -- SPEC_FILE_NAME => STRING_LITERAL
8954 -- [, DOT_REPLACEMENT => STRING_LITERAL]
8955 -- [, CASING => CASING_SPEC]);
8957 -- pragma Source_File_Name (
8958 -- SUBUNIT_FILE_NAME => STRING_LITERAL
8959 -- [, DOT_REPLACEMENT => STRING_LITERAL]
8960 -- [, CASING => CASING_SPEC]);
8962 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
8964 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
8965 -- Source_File_Name (SFN), however their usage is exclusive:
8966 -- SFN can only be used when no project file is used, while
8967 -- SFNP can only be used when a project file is used.
8969 -- No processing here. Processing was completed during parsing,
8970 -- since we need to have file names set as early as possible.
8971 -- Units are loaded well before semantic processing starts.
8973 -- The only processing we defer to this point is the check
8974 -- for correct placement.
8976 when Pragma_Source_File_Name
=>
8978 Check_Valid_Configuration_Pragma
;
8980 ------------------------------
8981 -- Source_File_Name_Project --
8982 ------------------------------
8984 -- See Source_File_Name for syntax
8986 -- No processing here. Processing was completed during parsing,
8987 -- since we need to have file names set as early as possible.
8988 -- Units are loaded well before semantic processing starts.
8990 -- The only processing we defer to this point is the check
8991 -- for correct placement.
8993 when Pragma_Source_File_Name_Project
=>
8995 Check_Valid_Configuration_Pragma
;
8997 -- Check that a pragma Source_File_Name_Project is used only
8998 -- in a configuration pragmas file.
9000 -- Pragmas Source_File_Name_Project should only be generated
9001 -- by the Project Manager in configuration pragmas files.
9003 -- This is really an ugly test. It seems to depend on some
9004 -- accidental and undocumented property. At the very least
9005 -- it needs to be documented, but it would be better to have
9006 -- a clean way of testing if we are in a configuration file???
9008 if Present
(Parent
(N
)) then
9010 ("pragma% can only appear in a configuration pragmas file");
9013 ----------------------
9014 -- Source_Reference --
9015 ----------------------
9017 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
9019 -- Nothing to do, all processing completed in Par.Prag, since we
9020 -- need the information for possible parser messages that are output
9022 when Pragma_Source_Reference
=>
9029 -- pragma Storage_Size (EXPRESSION);
9031 when Pragma_Storage_Size
=> Storage_Size
: declare
9032 P
: constant Node_Id
:= Parent
(N
);
9036 Check_No_Identifiers
;
9037 Check_Arg_Count
(1);
9039 -- The expression must be analyzed in the special manner
9040 -- described in "Handling of Default Expressions" in sem.ads.
9042 -- Set In_Default_Expression for per-object case ???
9044 Arg
:= Expression
(Arg1
);
9045 Analyze_Per_Use_Expression
(Arg
, Any_Integer
);
9047 if not Is_Static_Expression
(Arg
) then
9048 Check_Restriction
(Static_Storage_Size
, Arg
);
9051 if Nkind
(P
) /= N_Task_Definition
then
9056 if Has_Storage_Size_Pragma
(P
) then
9057 Error_Pragma
("duplicate pragma% not allowed");
9059 Set_Has_Storage_Size_Pragma
(P
, True);
9062 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
9063 -- ??? exp_ch9 should use this!
9071 -- pragma Storage_Unit (NUMERIC_LITERAL);
9073 -- Only permitted argument is System'Storage_Unit value
9075 when Pragma_Storage_Unit
=>
9076 Check_No_Identifiers
;
9077 Check_Arg_Count
(1);
9078 Check_Arg_Is_Integer_Literal
(Arg1
);
9080 if Intval
(Expression
(Arg1
)) /=
9081 UI_From_Int
(Ttypes
.System_Storage_Unit
)
9083 Error_Msg_Uint_1
:= UI_From_Int
(Ttypes
.System_Storage_Unit
);
9085 ("the only allowed argument for pragma% is ^", Arg1
);
9088 --------------------
9089 -- Stream_Convert --
9090 --------------------
9092 -- pragma Stream_Convert (
9093 -- [Entity =>] type_LOCAL_NAME,
9094 -- [Read =>] function_NAME,
9095 -- [Write =>] function NAME);
9097 when Pragma_Stream_Convert
=> Stream_Convert
: declare
9099 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
);
9100 -- Check that the given argument is the name of a local
9101 -- function of one argument that is not overloaded earlier
9102 -- in the current local scope. A check is also made that the
9103 -- argument is a function with one parameter.
9105 --------------------------------------
9106 -- Check_OK_Stream_Convert_Function --
9107 --------------------------------------
9109 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
) is
9113 Check_Arg_Is_Local_Name
(Arg
);
9114 Ent
:= Entity
(Expression
(Arg
));
9116 if Has_Homonym
(Ent
) then
9118 ("argument for pragma% may not be overloaded", Arg
);
9121 if Ekind
(Ent
) /= E_Function
9122 or else No
(First_Formal
(Ent
))
9123 or else Present
(Next_Formal
(First_Formal
(Ent
)))
9126 ("argument for pragma% must be" &
9127 " function of one argument", Arg
);
9129 end Check_OK_Stream_Convert_Function
;
9131 -- Start of procecessing for Stream_Convert
9135 Check_Arg_Count
(3);
9136 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9137 Check_Optional_Identifier
(Arg2
, Name_Read
);
9138 Check_Optional_Identifier
(Arg3
, Name_Write
);
9139 Check_Arg_Is_Local_Name
(Arg1
);
9140 Check_OK_Stream_Convert_Function
(Arg2
);
9141 Check_OK_Stream_Convert_Function
(Arg3
);
9144 Typ
: constant Entity_Id
:=
9145 Underlying_Type
(Entity
(Expression
(Arg1
)));
9146 Read
: constant Entity_Id
:= Entity
(Expression
(Arg2
));
9147 Write
: constant Entity_Id
:= Entity
(Expression
(Arg3
));
9150 if Etype
(Typ
) = Any_Type
9152 Etype
(Read
) = Any_Type
9154 Etype
(Write
) = Any_Type
9159 Check_First_Subtype
(Arg1
);
9161 if Rep_Item_Too_Early
(Typ
, N
)
9163 Rep_Item_Too_Late
(Typ
, N
)
9168 if Underlying_Type
(Etype
(Read
)) /= Typ
then
9170 ("incorrect return type for function&", Arg2
);
9173 if Underlying_Type
(Etype
(First_Formal
(Write
))) /= Typ
then
9175 ("incorrect parameter type for function&", Arg3
);
9178 if Underlying_Type
(Etype
(First_Formal
(Read
))) /=
9179 Underlying_Type
(Etype
(Write
))
9182 ("result type of & does not match Read parameter type",
9188 -------------------------
9189 -- Style_Checks (GNAT) --
9190 -------------------------
9192 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
9194 -- This is processed by the parser since some of the style
9195 -- checks take place during source scanning and parsing. This
9196 -- means that we don't need to issue error messages here.
9198 when Pragma_Style_Checks
=> Style_Checks
: declare
9199 A
: constant Node_Id
:= Expression
(Arg1
);
9205 Check_No_Identifiers
;
9207 -- Two argument form
9209 if Arg_Count
= 2 then
9210 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
9217 E_Id
:= Expression
(Arg2
);
9220 if not Is_Entity_Name
(E_Id
) then
9222 ("second argument of pragma% must be entity name",
9232 Set_Suppress_Style_Checks
(E
,
9233 (Chars
(Expression
(Arg1
)) = Name_Off
));
9234 exit when No
(Homonym
(E
));
9240 -- One argument form
9243 Check_Arg_Count
(1);
9245 if Nkind
(A
) = N_String_Literal
then
9249 Slen
: constant Natural := Natural (String_Length
(S
));
9250 Options
: String (1 .. Slen
);
9256 C
:= Get_String_Char
(S
, Int
(J
));
9257 exit when not In_Character_Range
(C
);
9258 Options
(J
) := Get_Character
(C
);
9261 Set_Style_Check_Options
(Options
);
9269 elsif Nkind
(A
) = N_Identifier
then
9271 if Chars
(A
) = Name_All_Checks
then
9272 Set_Default_Style_Check_Options
;
9274 elsif Chars
(A
) = Name_On
then
9275 Style_Check
:= True;
9277 elsif Chars
(A
) = Name_Off
then
9278 Style_Check
:= False;
9289 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
9291 when Pragma_Subtitle
=>
9293 Check_Arg_Count
(1);
9294 Check_Optional_Identifier
(Arg1
, Name_Subtitle
);
9295 Check_Arg_Is_String_Literal
(Arg1
);
9301 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
9303 when Pragma_Suppress
=>
9304 Process_Suppress_Unsuppress
(True);
9310 -- pragma Suppress_All;
9312 -- The only check made here is that the pragma appears in the
9313 -- proper place, i.e. following a compilation unit. If indeed
9314 -- it appears in this context, then the parser has already
9315 -- inserted an equivalent pragma Suppress (All_Checks) to get
9316 -- the required effect.
9318 when Pragma_Suppress_All
=>
9320 Check_Arg_Count
(0);
9322 if Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
9323 or else not Is_List_Member
(N
)
9324 or else List_Containing
(N
) /= Pragmas_After
(Parent
(N
))
9327 ("misplaced pragma%, must follow compilation unit");
9330 -------------------------
9331 -- Suppress_Debug_Info --
9332 -------------------------
9334 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
9336 when Pragma_Suppress_Debug_Info
=>
9338 Check_Arg_Count
(1);
9339 Check_Arg_Is_Local_Name
(Arg1
);
9340 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9341 Set_Debug_Info_Off
(Entity
(Get_Pragma_Arg
(Arg1
)));
9343 ----------------------------------
9344 -- Suppress_Exception_Locations --
9345 ----------------------------------
9347 -- pragma Suppress_Exception_Locations;
9349 when Pragma_Suppress_Exception_Locations
=>
9351 Check_Arg_Count
(0);
9352 Check_Valid_Configuration_Pragma
;
9353 Exception_Locations_Suppressed
:= True;
9355 -----------------------------
9356 -- Suppress_Initialization --
9357 -----------------------------
9359 -- pragma Suppress_Initialization ([Entity =>] type_Name);
9361 when Pragma_Suppress_Initialization
=> Suppress_Init
: declare
9367 Check_Arg_Count
(1);
9368 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9369 Check_Arg_Is_Local_Name
(Arg1
);
9371 E_Id
:= Expression
(Arg1
);
9373 if Etype
(E_Id
) = Any_Type
then
9380 if Is_Incomplete_Or_Private_Type
(E
) then
9381 if No
(Full_View
(Base_Type
(E
))) then
9383 ("argument of pragma% cannot be an incomplete type",
9386 Set_Suppress_Init_Proc
(Full_View
(Base_Type
(E
)));
9389 Set_Suppress_Init_Proc
(Base_Type
(E
));
9394 ("pragma% requires argument that is a type name", Arg1
);
9402 -- pragma System_Name (DIRECT_NAME);
9404 -- Syntax check: one argument, which must be the identifier GNAT
9405 -- or the identifier GCC, no other identifiers are acceptable.
9407 when Pragma_System_Name
=>
9408 Check_No_Identifiers
;
9409 Check_Arg_Count
(1);
9410 Check_Arg_Is_One_Of
(Arg1
, Name_Gcc
, Name_Gnat
);
9412 -----------------------------
9413 -- Task_Dispatching_Policy --
9414 -----------------------------
9416 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
9418 when Pragma_Task_Dispatching_Policy
=> declare
9422 Check_Ada_83_Warning
;
9423 Check_Arg_Count
(1);
9424 Check_No_Identifiers
;
9425 Check_Arg_Is_Task_Dispatching_Policy
(Arg1
);
9426 Check_Valid_Configuration_Pragma
;
9427 Get_Name_String
(Chars
(Expression
(Arg1
)));
9428 DP
:= Fold_Upper
(Name_Buffer
(1));
9430 if Task_Dispatching_Policy
/= ' '
9431 and then Task_Dispatching_Policy
/= DP
9433 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
9435 ("task dispatching policy incompatible with policy#");
9437 -- Set new policy, but always preserve System_Location since
9438 -- we like the error message with the run time name.
9441 Task_Dispatching_Policy
:= DP
;
9443 if Task_Dispatching_Policy_Sloc
/= System_Location
then
9444 Task_Dispatching_Policy_Sloc
:= Loc
;
9453 -- pragma Task_Info (EXPRESSION);
9455 when Pragma_Task_Info
=> Task_Info
: declare
9456 P
: constant Node_Id
:= Parent
(N
);
9461 if Nkind
(P
) /= N_Task_Definition
then
9462 Error_Pragma
("pragma% must appear in task definition");
9465 Check_No_Identifiers
;
9466 Check_Arg_Count
(1);
9468 Analyze_And_Resolve
(Expression
(Arg1
), RTE
(RE_Task_Info_Type
));
9470 if Etype
(Expression
(Arg1
)) = Any_Type
then
9474 if Has_Task_Info_Pragma
(P
) then
9475 Error_Pragma
("duplicate pragma% not allowed");
9477 Set_Has_Task_Info_Pragma
(P
, True);
9485 -- pragma Task_Name (string_EXPRESSION);
9487 when Pragma_Task_Name
=> Task_Name
: declare
9488 -- pragma Priority (EXPRESSION);
9490 P
: constant Node_Id
:= Parent
(N
);
9494 Check_No_Identifiers
;
9495 Check_Arg_Count
(1);
9497 Arg
:= Expression
(Arg1
);
9498 Analyze_And_Resolve
(Arg
, Standard_String
);
9500 if Nkind
(P
) /= N_Task_Definition
then
9504 if Has_Task_Name_Pragma
(P
) then
9505 Error_Pragma
("duplicate pragma% not allowed");
9507 Set_Has_Task_Name_Pragma
(P
, True);
9508 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
9516 -- pragma Task_Storage (
9517 -- [Task_Type =>] LOCAL_NAME,
9518 -- [Top_Guard =>] static_integer_EXPRESSION);
9520 when Pragma_Task_Storage
=> Task_Storage
: declare
9521 Args
: Args_List
(1 .. 2);
9522 Names
: constant Name_List
(1 .. 2) := (
9526 Task_Type
: Node_Id
renames Args
(1);
9527 Top_Guard
: Node_Id
renames Args
(2);
9533 Gather_Associations
(Names
, Args
);
9535 if No
(Task_Type
) then
9537 ("missing task_type argument for pragma%");
9540 Check_Arg_Is_Local_Name
(Task_Type
);
9542 Ent
:= Entity
(Task_Type
);
9544 if not Is_Task_Type
(Ent
) then
9546 ("argument for pragma% must be task type", Task_Type
);
9549 if No
(Top_Guard
) then
9551 ("pragma% takes two arguments", Task_Type
);
9553 Check_Arg_Is_Static_Expression
(Top_Guard
, Any_Integer
);
9556 Check_First_Subtype
(Task_Type
);
9558 if Rep_Item_Too_Late
(Ent
, N
) then
9567 -- pragma Thread_Body
9568 -- ( [Entity =>] LOCAL_NAME
9569 -- [,[Secondary_Stack_Size =>] static_integer_EXPRESSION]);
9571 when Pragma_Thread_Body
=> Thread_Body
: declare
9578 Check_At_Least_N_Arguments
(1);
9579 Check_At_Most_N_Arguments
(2);
9580 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9581 Check_Arg_Is_Local_Name
(Arg1
);
9583 Id
:= Expression
(Arg1
);
9585 if not Is_Entity_Name
(Id
)
9586 or else not Is_Subprogram
(Entity
(Id
))
9588 Error_Pragma_Arg
("subprogram name required", Arg1
);
9593 -- Go to renamed subprogram if present, since Thread_Body applies
9594 -- to the actual renamed entity, not to the renaming entity.
9596 if Present
(Alias
(E
))
9597 and then Nkind
(Parent
(Declaration_Node
(E
))) =
9598 N_Subprogram_Renaming_Declaration
9603 -- Various error checks
9605 if Nkind
(Parent
(Declaration_Node
(E
))) = N_Subprogram_Body
then
9607 ("pragma% requires separate spec and must come before body");
9609 elsif Rep_Item_Too_Early
(E
, N
)
9611 Rep_Item_Too_Late
(E
, N
)
9615 elsif Is_Thread_Body
(E
) then
9617 ("only one thread body pragma allowed", Arg1
);
9619 elsif Present
(Homonym
(E
))
9620 and then Scope
(Homonym
(E
)) = Current_Scope
9623 ("thread body subprogram must not be overloaded", Arg1
);
9626 Set_Is_Thread_Body
(E
);
9628 -- Deal with secondary stack argument
9630 if Arg_Count
= 2 then
9631 Check_Optional_Identifier
(Arg2
, Name_Secondary_Stack_Size
);
9632 SS
:= Expression
(Arg2
);
9633 Analyze_And_Resolve
(SS
, Any_Integer
);
9641 -- pragma Time_Slice (static_duration_EXPRESSION);
9643 when Pragma_Time_Slice
=> Time_Slice
: declare
9649 Check_Arg_Count
(1);
9650 Check_No_Identifiers
;
9651 Check_In_Main_Program
;
9652 Check_Arg_Is_Static_Expression
(Arg1
, Standard_Duration
);
9654 if not Error_Posted
(Arg1
) then
9656 while Present
(Nod
) loop
9657 if Nkind
(Nod
) = N_Pragma
9658 and then Chars
(Nod
) = Name_Time_Slice
9660 Error_Msg_Name_1
:= Chars
(N
);
9661 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
9668 -- Process only if in main unit
9670 if Get_Source_Unit
(Loc
) = Main_Unit
then
9671 Opt
.Time_Slice_Set
:= True;
9672 Val
:= Expr_Value_R
(Expression
(Arg1
));
9674 if Val
<= Ureal_0
then
9675 Opt
.Time_Slice_Value
:= 0;
9677 elsif Val
> UR_From_Uint
(UI_From_Int
(1000)) then
9678 Opt
.Time_Slice_Value
:= 1_000_000_000
;
9681 Opt
.Time_Slice_Value
:=
9682 UI_To_Int
(UR_To_Uint
(Val
* UI_From_Int
(1_000_000
)));
9691 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
9693 -- TITLING_OPTION ::=
9694 -- [Title =>] STRING_LITERAL
9695 -- | [Subtitle =>] STRING_LITERAL
9697 when Pragma_Title
=> Title
: declare
9698 Args
: Args_List
(1 .. 2);
9699 Names
: constant Name_List
(1 .. 2) := (
9705 Gather_Associations
(Names
, Args
);
9707 for J
in 1 .. 2 loop
9708 if Present
(Args
(J
)) then
9709 Check_Arg_Is_String_Literal
(Args
(J
));
9714 ---------------------
9715 -- Unchecked_Union --
9716 ---------------------
9718 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
9720 when Pragma_Unchecked_Union
=> Unchecked_Union
: declare
9721 Assoc
: constant Node_Id
:= Arg1
;
9722 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
9733 Check_No_Identifiers
;
9734 Check_Arg_Count
(1);
9735 Check_Arg_Is_Local_Name
(Arg1
);
9737 Find_Type
(Type_Id
);
9738 Typ
:= Entity
(Type_Id
);
9741 or else Rep_Item_Too_Early
(Typ
, N
)
9745 Typ
:= Underlying_Type
(Typ
);
9748 if Rep_Item_Too_Late
(Typ
, N
) then
9752 Check_First_Subtype
(Arg1
);
9754 -- Note remaining cases are references to a type in the current
9755 -- declarative part. If we find an error, we post the error on
9756 -- the relevant type declaration at an appropriate point.
9758 if not Is_Record_Type
(Typ
) then
9759 Error_Msg_N
("Unchecked_Union must be record type", Typ
);
9762 elsif Is_Tagged_Type
(Typ
) then
9763 Error_Msg_N
("Unchecked_Union must not be tagged", Typ
);
9766 elsif Is_Limited_Type
(Typ
) then
9768 ("Unchecked_Union must not be limited record type", Typ
);
9769 Explain_Limited_Type
(Typ
, Typ
);
9773 if not Has_Discriminants
(Typ
) then
9775 ("Unchecked_Union must have one discriminant", Typ
);
9779 Discr
:= First_Discriminant
(Typ
);
9781 if Present
(Next_Discriminant
(Discr
)) then
9783 ("Unchecked_Union must have exactly one discriminant",
9784 Next_Discriminant
(Discr
));
9788 if No
(Discriminant_Default_Value
(Discr
)) then
9790 ("Unchecked_Union discriminant must have default value",
9794 Tdef
:= Type_Definition
(Declaration_Node
(Typ
));
9795 Clist
:= Component_List
(Tdef
);
9797 Comp
:= First
(Component_Items
(Clist
));
9798 while Present
(Comp
) loop
9800 Check_Component
(Comp
);
9805 if No
(Clist
) or else No
(Variant_Part
(Clist
)) then
9807 ("Unchecked_Union must have variant part",
9812 Vpart
:= Variant_Part
(Clist
);
9813 Variant
:= First
(Variants
(Vpart
));
9814 while Present
(Variant
) loop
9816 Check_Variant
(Variant
);
9822 Set_Is_Unchecked_Union
(Typ
, True);
9823 Set_Convention
(Typ
, Convention_C
);
9825 Set_Has_Unchecked_Union
(Base_Type
(Typ
), True);
9826 Set_Is_Unchecked_Union
(Base_Type
(Typ
), True);
9827 end Unchecked_Union
;
9829 ------------------------
9830 -- Unimplemented_Unit --
9831 ------------------------
9833 -- pragma Unimplemented_Unit;
9835 -- Note: this only gives an error if we are generating code,
9836 -- or if we are in a generic library unit (where the pragma
9837 -- appears in the body, not in the spec).
9839 when Pragma_Unimplemented_Unit
=> Unimplemented_Unit
: declare
9840 Cunitent
: constant Entity_Id
:=
9841 Cunit_Entity
(Get_Source_Unit
(Loc
));
9842 Ent_Kind
: constant Entity_Kind
:=
9847 Check_Arg_Count
(0);
9849 if Operating_Mode
= Generate_Code
9850 or else Ent_Kind
= E_Generic_Function
9851 or else Ent_Kind
= E_Generic_Procedure
9852 or else Ent_Kind
= E_Generic_Package
9854 Get_Name_String
(Chars
(Cunitent
));
9855 Set_Casing
(Mixed_Case
);
9856 Write_Str
(Name_Buffer
(1 .. Name_Len
));
9857 Write_Str
(" is not implemented");
9859 raise Unrecoverable_Error
;
9861 end Unimplemented_Unit
;
9863 --------------------
9864 -- Universal_Data --
9865 --------------------
9867 -- pragma Universal_Data [(library_unit_NAME)];
9869 when Pragma_Universal_Data
=>
9872 -- If this is a configuration pragma, then set the universal
9873 -- addressing option, otherwise confirm that the pragma
9874 -- satisfies the requirements of library unit pragma placement
9875 -- and leave it to the GNAAMP back end to detect the pragma
9876 -- (avoids transitive setting of the option due to withed units).
9878 if Is_Configuration_Pragma
then
9879 Universal_Addressing_On_AAMP
:= True;
9881 Check_Valid_Library_Unit_Pragma
;
9884 if not AAMP_On_Target
then
9885 Error_Pragma
("?pragma% ignored (applies only to AAMP)");
9892 -- pragma Unreferenced (local_Name {, local_Name});
9894 when Pragma_Unreferenced
=> Unreferenced
: declare
9897 Arg_Ent
: Entity_Id
;
9901 Check_At_Least_N_Arguments
(1);
9905 while Present
(Arg_Node
) loop
9906 Check_No_Identifier
(Arg_Node
);
9908 -- Note that the analyze call done by Check_Arg_Is_Local_Name
9909 -- will in fact generate a reference, so that the entity will
9910 -- have a reference, which will inhibit any warnings about it
9911 -- not being referenced, and also properly show up in the ali
9912 -- file as a reference. But this reference is recorded before
9913 -- the Has_Pragma_Unreferenced flag is set, so that no warning
9914 -- is generated for this reference.
9916 Check_Arg_Is_Local_Name
(Arg_Node
);
9917 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
9919 if Is_Entity_Name
(Arg_Expr
) then
9920 Arg_Ent
:= Entity
(Arg_Expr
);
9922 -- If the entity is overloaded, the pragma applies to the
9923 -- most recent overloading, as documented. In this case,
9924 -- name resolution does not generate a reference, so it
9925 -- must be done here explicitly.
9927 if Is_Overloaded
(Arg_Expr
) then
9928 Generate_Reference
(Arg_Ent
, N
);
9931 Set_Has_Pragma_Unreferenced
(Arg_Ent
);
9938 ------------------------------
9939 -- Unreserve_All_Interrupts --
9940 ------------------------------
9942 -- pragma Unreserve_All_Interrupts;
9944 when Pragma_Unreserve_All_Interrupts
=>
9946 Check_Arg_Count
(0);
9948 if In_Extended_Main_Code_Unit
(Main_Unit_Entity
) then
9949 Unreserve_All_Interrupts
:= True;
9956 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
9958 when Pragma_Unsuppress
=>
9960 Process_Suppress_Unsuppress
(False);
9966 -- pragma Use_VADS_Size;
9968 when Pragma_Use_VADS_Size
=>
9970 Check_Arg_Count
(0);
9971 Check_Valid_Configuration_Pragma
;
9972 Use_VADS_Size
:= True;
9974 ---------------------
9975 -- Validity_Checks --
9976 ---------------------
9978 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
9980 when Pragma_Validity_Checks
=> Validity_Checks
: declare
9981 A
: constant Node_Id
:= Expression
(Arg1
);
9987 Check_Arg_Count
(1);
9988 Check_No_Identifiers
;
9990 if Nkind
(A
) = N_String_Literal
then
9994 Slen
: constant Natural := Natural (String_Length
(S
));
9995 Options
: String (1 .. Slen
);
10001 C
:= Get_String_Char
(S
, Int
(J
));
10002 exit when not In_Character_Range
(C
);
10003 Options
(J
) := Get_Character
(C
);
10006 Set_Validity_Check_Options
(Options
);
10014 elsif Nkind
(A
) = N_Identifier
then
10016 if Chars
(A
) = Name_All_Checks
then
10017 Set_Validity_Check_Options
("a");
10019 elsif Chars
(A
) = Name_On
then
10020 Validity_Checks_On
:= True;
10022 elsif Chars
(A
) = Name_Off
then
10023 Validity_Checks_On
:= False;
10027 end Validity_Checks
;
10033 -- pragma Volatile (LOCAL_NAME);
10035 when Pragma_Volatile
=>
10036 Process_Atomic_Shared_Volatile
;
10038 -------------------------
10039 -- Volatile_Components --
10040 -------------------------
10042 -- pragma Volatile_Components (array_LOCAL_NAME);
10044 -- Volatile is handled by the same circuit as Atomic_Components
10050 -- pragma Warnings (On | Off, [LOCAL_NAME])
10052 when Pragma_Warnings
=> Warnings
: begin
10054 Check_At_Least_N_Arguments
(1);
10055 Check_At_Most_N_Arguments
(2);
10056 Check_No_Identifiers
;
10058 -- One argument case was processed by parser in Par.Prag
10060 if Arg_Count
/= 1 then
10061 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
10062 Check_Arg_Count
(2);
10069 E_Id
:= Expression
(Arg2
);
10072 -- In the expansion of an inlined body, a reference to
10073 -- the formal may be wrapped in a conversion if the actual
10074 -- is a conversion. Retrieve the real entity name.
10076 if (In_Instance_Body
10077 or else In_Inlined_Body
)
10078 and then Nkind
(E_Id
) = N_Unchecked_Type_Conversion
10080 E_Id
:= Expression
(E_Id
);
10083 if not Is_Entity_Name
(E_Id
) then
10085 ("second argument of pragma% must be entity name",
10089 E
:= Entity
(E_Id
);
10095 Set_Warnings_Off
(E
,
10096 (Chars
(Expression
(Arg1
)) = Name_Off
));
10098 if Is_Enumeration_Type
(E
) then
10100 Lit
: Entity_Id
:= First_Literal
(E
);
10103 while Present
(Lit
) loop
10104 Set_Warnings_Off
(Lit
);
10105 Next_Literal
(Lit
);
10110 exit when No
(Homonym
(E
));
10118 -------------------
10119 -- Weak_External --
10120 -------------------
10122 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
10124 when Pragma_Weak_External
=> Weak_External
: declare
10129 Check_Arg_Count
(1);
10130 Check_Optional_Identifier
(Arg1
, Name_Entity
);
10131 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
10132 Ent
:= Entity
(Expression
(Arg1
));
10134 if Rep_Item_Too_Early
(Ent
, N
) then
10137 Ent
:= Underlying_Type
(Ent
);
10140 -- The only processing required is to link this item on to the
10141 -- list of rep items for the given entity. This is accomplished
10142 -- by the call to Rep_Item_Too_Late (when no error is detected
10143 -- and False is returned).
10145 if Rep_Item_Too_Late
(Ent
, N
) then
10148 Set_Has_Gigi_Rep_Item
(Ent
);
10152 --------------------
10153 -- Unknown_Pragma --
10154 --------------------
10156 -- Should be impossible, since the case of an unknown pragma is
10157 -- separately processed before the case statement is entered.
10159 when Unknown_Pragma
=>
10160 raise Program_Error
;
10164 when Pragma_Exit
=> null;
10165 end Analyze_Pragma
;
10167 ---------------------------------
10168 -- Delay_Config_Pragma_Analyze --
10169 ---------------------------------
10171 function Delay_Config_Pragma_Analyze
(N
: Node_Id
) return Boolean is
10173 return Chars
(N
) = Name_Interrupt_State
;
10174 end Delay_Config_Pragma_Analyze
;
10176 -------------------------
10177 -- Get_Base_Subprogram --
10178 -------------------------
10180 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
is
10181 Result
: Entity_Id
;
10186 -- Follow subprogram renaming chain
10188 while Is_Subprogram
(Result
)
10190 (Is_Generic_Instance
(Result
)
10191 or else Nkind
(Parent
(Declaration_Node
(Result
))) =
10192 N_Subprogram_Renaming_Declaration
)
10193 and then Present
(Alias
(Result
))
10195 Result
:= Alias
(Result
);
10199 end Get_Base_Subprogram
;
10201 -----------------------------
10202 -- Is_Config_Static_String --
10203 -----------------------------
10205 function Is_Config_Static_String
(Arg
: Node_Id
) return Boolean is
10207 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean;
10208 -- This is an internal recursive function that is just like the
10209 -- outer function except that it adds the string to the name buffer
10210 -- rather than placing the string in the name buffer.
10212 ------------------------------
10213 -- Add_Config_Static_String --
10214 ------------------------------
10216 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean is
10223 if Nkind
(N
) = N_Op_Concat
then
10224 if Add_Config_Static_String
(Left_Opnd
(N
)) then
10225 N
:= Right_Opnd
(N
);
10231 if Nkind
(N
) /= N_String_Literal
then
10232 Error_Msg_N
("string literal expected for pragma argument", N
);
10236 for J
in 1 .. String_Length
(Strval
(N
)) loop
10237 C
:= Get_String_Char
(Strval
(N
), J
);
10239 if not In_Character_Range
(C
) then
10241 ("string literal contains invalid wide character",
10242 Sloc
(N
) + 1 + Source_Ptr
(J
));
10246 Add_Char_To_Name_Buffer
(Get_Character
(C
));
10251 end Add_Config_Static_String
;
10253 -- Start of prorcessing for Is_Config_Static_String
10258 return Add_Config_Static_String
(Arg
);
10259 end Is_Config_Static_String
;
10261 -----------------------------------------
10262 -- Is_Non_Significant_Pragma_Reference --
10263 -----------------------------------------
10265 -- This function makes use of the following static table which indicates
10266 -- whether a given pragma is significant. A value of -1 in this table
10267 -- indicates that the reference is significant. A value of zero indicates
10268 -- than appearence as any argument is insignificant, a positive value
10269 -- indicates that appearence in that parameter position is significant.
10271 Sig_Flags
: constant array (Pragma_Id
) of Int
:=
10273 (Pragma_AST_Entry
=> -1,
10274 Pragma_Abort_Defer
=> -1,
10275 Pragma_Ada_83
=> -1,
10276 Pragma_Ada_95
=> -1,
10277 Pragma_Ada_05
=> -1,
10278 Pragma_All_Calls_Remote
=> -1,
10279 Pragma_Annotate
=> -1,
10280 Pragma_Assert
=> -1,
10281 Pragma_Asynchronous
=> -1,
10282 Pragma_Atomic
=> 0,
10283 Pragma_Atomic_Components
=> 0,
10284 Pragma_Attach_Handler
=> -1,
10285 Pragma_CPP_Class
=> 0,
10286 Pragma_CPP_Constructor
=> 0,
10287 Pragma_CPP_Virtual
=> 0,
10288 Pragma_CPP_Vtable
=> 0,
10289 Pragma_C_Pass_By_Copy
=> 0,
10290 Pragma_Comment
=> 0,
10291 Pragma_Common_Object
=> -1,
10292 Pragma_Compile_Time_Warning
=> -1,
10293 Pragma_Complex_Representation
=> 0,
10294 Pragma_Component_Alignment
=> -1,
10295 Pragma_Controlled
=> 0,
10296 Pragma_Convention
=> 0,
10297 Pragma_Convention_Identifier
=> 0,
10298 Pragma_Debug
=> -1,
10299 Pragma_Detect_Blocking
=> -1,
10300 Pragma_Discard_Names
=> 0,
10301 Pragma_Elaborate
=> -1,
10302 Pragma_Elaborate_All
=> -1,
10303 Pragma_Elaborate_Body
=> -1,
10304 Pragma_Elaboration_Checks
=> -1,
10305 Pragma_Eliminate
=> -1,
10306 Pragma_Explicit_Overriding
=> -1,
10307 Pragma_Export
=> -1,
10308 Pragma_Export_Exception
=> -1,
10309 Pragma_Export_Function
=> -1,
10310 Pragma_Export_Object
=> -1,
10311 Pragma_Export_Procedure
=> -1,
10312 Pragma_Export_Value
=> -1,
10313 Pragma_Export_Valued_Procedure
=> -1,
10314 Pragma_Extend_System
=> -1,
10315 Pragma_Extensions_Allowed
=> -1,
10316 Pragma_External
=> -1,
10317 Pragma_External_Name_Casing
=> -1,
10318 Pragma_Finalize_Storage_Only
=> 0,
10319 Pragma_Float_Representation
=> 0,
10320 Pragma_Ident
=> -1,
10321 Pragma_Import
=> +2,
10322 Pragma_Import_Exception
=> 0,
10323 Pragma_Import_Function
=> 0,
10324 Pragma_Import_Object
=> 0,
10325 Pragma_Import_Procedure
=> 0,
10326 Pragma_Import_Valued_Procedure
=> 0,
10327 Pragma_Initialize_Scalars
=> -1,
10328 Pragma_Inline
=> 0,
10329 Pragma_Inline_Always
=> 0,
10330 Pragma_Inline_Generic
=> 0,
10331 Pragma_Inspection_Point
=> -1,
10332 Pragma_Interface
=> +2,
10333 Pragma_Interface_Name
=> +2,
10334 Pragma_Interrupt_Handler
=> -1,
10335 Pragma_Interrupt_Priority
=> -1,
10336 Pragma_Interrupt_State
=> -1,
10337 Pragma_Java_Constructor
=> -1,
10338 Pragma_Java_Interface
=> -1,
10339 Pragma_Keep_Names
=> 0,
10340 Pragma_License
=> -1,
10341 Pragma_Link_With
=> -1,
10342 Pragma_Linker_Alias
=> -1,
10343 Pragma_Linker_Options
=> -1,
10344 Pragma_Linker_Section
=> -1,
10346 Pragma_Locking_Policy
=> -1,
10347 Pragma_Long_Float
=> -1,
10348 Pragma_Machine_Attribute
=> -1,
10350 Pragma_Main_Storage
=> -1,
10351 Pragma_Memory_Size
=> -1,
10352 Pragma_No_Return
=> 0,
10353 Pragma_No_Run_Time
=> -1,
10354 Pragma_No_Strict_Aliasing
=> -1,
10355 Pragma_Normalize_Scalars
=> -1,
10356 Pragma_Obsolescent
=> 0,
10357 Pragma_Optimize
=> -1,
10358 Pragma_Optional_Overriding
=> -1,
10359 Pragma_Overriding
=> -1,
10362 Pragma_Passive
=> -1,
10363 Pragma_Polling
=> -1,
10364 Pragma_Persistent_Data
=> -1,
10365 Pragma_Persistent_Object
=> -1,
10366 Pragma_Preelaborate
=> -1,
10367 Pragma_Priority
=> -1,
10368 Pragma_Profile
=> 0,
10369 Pragma_Profile_Warnings
=> 0,
10370 Pragma_Propagate_Exceptions
=> -1,
10371 Pragma_Psect_Object
=> -1,
10373 Pragma_Pure_Function
=> 0,
10374 Pragma_Queuing_Policy
=> -1,
10375 Pragma_Ravenscar
=> -1,
10376 Pragma_Remote_Call_Interface
=> -1,
10377 Pragma_Remote_Types
=> -1,
10378 Pragma_Restricted_Run_Time
=> -1,
10379 Pragma_Restriction_Warnings
=> -1,
10380 Pragma_Restrictions
=> -1,
10381 Pragma_Reviewable
=> -1,
10382 Pragma_Share_Generic
=> -1,
10383 Pragma_Shared
=> -1,
10384 Pragma_Shared_Passive
=> -1,
10385 Pragma_Source_File_Name
=> -1,
10386 Pragma_Source_File_Name_Project
=> -1,
10387 Pragma_Source_Reference
=> -1,
10388 Pragma_Storage_Size
=> -1,
10389 Pragma_Storage_Unit
=> -1,
10390 Pragma_Stream_Convert
=> -1,
10391 Pragma_Style_Checks
=> -1,
10392 Pragma_Subtitle
=> -1,
10393 Pragma_Suppress
=> 0,
10394 Pragma_Suppress_Exception_Locations
=> 0,
10395 Pragma_Suppress_All
=> -1,
10396 Pragma_Suppress_Debug_Info
=> 0,
10397 Pragma_Suppress_Initialization
=> 0,
10398 Pragma_System_Name
=> -1,
10399 Pragma_Task_Dispatching_Policy
=> -1,
10400 Pragma_Task_Info
=> -1,
10401 Pragma_Task_Name
=> -1,
10402 Pragma_Task_Storage
=> 0,
10403 Pragma_Thread_Body
=> +2,
10404 Pragma_Time_Slice
=> -1,
10405 Pragma_Title
=> -1,
10406 Pragma_Unchecked_Union
=> 0,
10407 Pragma_Unimplemented_Unit
=> -1,
10408 Pragma_Universal_Data
=> -1,
10409 Pragma_Unreferenced
=> -1,
10410 Pragma_Unreserve_All_Interrupts
=> -1,
10411 Pragma_Unsuppress
=> 0,
10412 Pragma_Use_VADS_Size
=> -1,
10413 Pragma_Validity_Checks
=> -1,
10414 Pragma_Volatile
=> 0,
10415 Pragma_Volatile_Components
=> 0,
10416 Pragma_Warnings
=> -1,
10417 Pragma_Weak_External
=> 0,
10418 Unknown_Pragma
=> 0);
10420 function Is_Non_Significant_Pragma_Reference
(N
: Node_Id
) return Boolean is
10428 if Nkind
(P
) /= N_Pragma_Argument_Association
then
10432 C
:= Sig_Flags
(Get_Pragma_Id
(Chars
(Parent
(P
))));
10442 A
:= First
(Pragma_Argument_Associations
(Parent
(P
)));
10443 for J
in 1 .. C
- 1 loop
10454 end Is_Non_Significant_Pragma_Reference
;
10456 ------------------------------
10457 -- Is_Pragma_String_Literal --
10458 ------------------------------
10460 -- This function returns true if the corresponding pragma argument is
10461 -- a static string expression. These are the only cases in which string
10462 -- literals can appear as pragma arguments. We also allow a string
10463 -- literal as the first argument to pragma Assert (although it will
10464 -- of course always generate a type error).
10466 function Is_Pragma_String_Literal
(Par
: Node_Id
) return Boolean is
10467 Pragn
: constant Node_Id
:= Parent
(Par
);
10468 Assoc
: constant List_Id
:= Pragma_Argument_Associations
(Pragn
);
10469 Pname
: constant Name_Id
:= Chars
(Pragn
);
10475 N
:= First
(Assoc
);
10482 if Pname
= Name_Assert
then
10485 elsif Pname
= Name_Export
then
10488 elsif Pname
= Name_Ident
then
10491 elsif Pname
= Name_Import
then
10494 elsif Pname
= Name_Interface_Name
then
10497 elsif Pname
= Name_Linker_Alias
then
10500 elsif Pname
= Name_Linker_Section
then
10503 elsif Pname
= Name_Machine_Attribute
then
10506 elsif Pname
= Name_Source_File_Name
then
10509 elsif Pname
= Name_Source_Reference
then
10512 elsif Pname
= Name_Title
then
10515 elsif Pname
= Name_Subtitle
then
10521 end Is_Pragma_String_Literal
;
10523 --------------------------------------
10524 -- Process_Compilation_Unit_Pragmas --
10525 --------------------------------------
10527 procedure Process_Compilation_Unit_Pragmas
(N
: Node_Id
) is
10529 -- A special check for pragma Suppress_All. This is a strange DEC
10530 -- pragma, strange because it comes at the end of the unit. If we
10531 -- have a pragma Suppress_All in the Pragmas_After of the current
10532 -- unit, then we insert a pragma Suppress (All_Checks) at the start
10533 -- of the context clause to ensure the correct processing.
10536 PA
: constant List_Id
:= Pragmas_After
(Aux_Decls_Node
(N
));
10540 if Present
(PA
) then
10542 while Present
(P
) loop
10543 if Chars
(P
) = Name_Suppress_All
then
10544 Prepend_To
(Context_Items
(N
),
10545 Make_Pragma
(Sloc
(P
),
10546 Chars
=> Name_Suppress
,
10547 Pragma_Argument_Associations
=> New_List
(
10548 Make_Pragma_Argument_Association
(Sloc
(P
),
10550 Make_Identifier
(Sloc
(P
),
10551 Chars
=> Name_All_Checks
)))));
10559 end Process_Compilation_Unit_Pragmas
;
10561 --------------------------------
10562 -- Set_Encoded_Interface_Name --
10563 --------------------------------
10565 procedure Set_Encoded_Interface_Name
(E
: Entity_Id
; S
: Node_Id
) is
10566 Str
: constant String_Id
:= Strval
(S
);
10567 Len
: constant Int
:= String_Length
(Str
);
10572 Hex
: constant array (0 .. 15) of Character := "0123456789abcdef";
10575 -- Stores encoded value of character code CC. The encoding we
10576 -- use an underscore followed by four lower case hex digits.
10578 procedure Encode
is
10580 Store_String_Char
(Get_Char_Code
('_'));
10582 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 12))));
10584 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 8 and 16#
0F#
))));
10586 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 4 and 16#
0F#
))));
10588 (Get_Char_Code
(Hex
(Integer (CC
and 16#
0F#
))));
10591 -- Start of processing for Set_Encoded_Interface_Name
10594 -- If first character is asterisk, this is a link name, and we
10595 -- leave it completely unmodified. We also ignore null strings
10596 -- (the latter case happens only in error cases) and no encoding
10597 -- should occur for Java interface names.
10600 or else Get_String_Char
(Str
, 1) = Get_Char_Code
('*')
10603 Set_Interface_Name
(E
, S
);
10608 CC
:= Get_String_Char
(Str
, J
);
10610 exit when not In_Character_Range
(CC
);
10612 C
:= Get_Character
(CC
);
10614 exit when C
/= '_' and then C
/= '$'
10615 and then C
not in '0' .. '9'
10616 and then C
not in 'a' .. 'z'
10617 and then C
not in 'A' .. 'Z';
10620 Set_Interface_Name
(E
, S
);
10628 -- Here we need to encode. The encoding we use as follows:
10629 -- three underscores + four hex digits (lower case)
10633 for J
in 1 .. String_Length
(Str
) loop
10634 CC
:= Get_String_Char
(Str
, J
);
10636 if not In_Character_Range
(CC
) then
10639 C
:= Get_Character
(CC
);
10641 if C
= '_' or else C
= '$'
10642 or else C
in '0' .. '9'
10643 or else C
in 'a' .. 'z'
10644 or else C
in 'A' .. 'Z'
10646 Store_String_Char
(CC
);
10653 Set_Interface_Name
(E
,
10654 Make_String_Literal
(Sloc
(S
),
10655 Strval
=> End_String
));
10657 end Set_Encoded_Interface_Name
;
10659 -------------------
10660 -- Set_Unit_Name --
10661 -------------------
10663 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
) is
10668 if Nkind
(N
) = N_Identifier
10669 and then Nkind
(With_Item
) = N_Identifier
10671 Set_Entity
(N
, Entity
(With_Item
));
10673 elsif Nkind
(N
) = N_Selected_Component
then
10674 Change_Selected_Component_To_Expanded_Name
(N
);
10675 Set_Entity
(N
, Entity
(With_Item
));
10676 Set_Entity
(Selector_Name
(N
), Entity
(N
));
10678 Pref
:= Prefix
(N
);
10679 Scop
:= Scope
(Entity
(N
));
10681 while Nkind
(Pref
) = N_Selected_Component
loop
10682 Change_Selected_Component_To_Expanded_Name
(Pref
);
10683 Set_Entity
(Selector_Name
(Pref
), Scop
);
10684 Set_Entity
(Pref
, Scop
);
10685 Pref
:= Prefix
(Pref
);
10686 Scop
:= Scope
(Scop
);
10689 Set_Entity
(Pref
, Scop
);