1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2005, 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 Hostparm
; use Hostparm
;
43 with Lib
.Writ
; use Lib
.Writ
;
44 with Lib
.Xref
; use Lib
.Xref
;
45 with Namet
; use Namet
;
46 with Nlists
; use Nlists
;
47 with Nmake
; use Nmake
;
49 with Output
; use Output
;
50 with Restrict
; use Restrict
;
51 with Rident
; use Rident
;
52 with Rtsfind
; use Rtsfind
;
54 with Sem_Ch3
; use Sem_Ch3
;
55 with Sem_Ch8
; use Sem_Ch8
;
56 with Sem_Ch13
; use Sem_Ch13
;
57 with Sem_Disp
; use Sem_Disp
;
58 with Sem_Dist
; use Sem_Dist
;
59 with Sem_Elim
; use Sem_Elim
;
60 with Sem_Eval
; use Sem_Eval
;
61 with Sem_Intr
; use Sem_Intr
;
62 with Sem_Mech
; use Sem_Mech
;
63 with Sem_Res
; use Sem_Res
;
64 with Sem_Type
; use Sem_Type
;
65 with Sem_Util
; use Sem_Util
;
66 with Sem_VFpt
; use Sem_VFpt
;
67 with 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
);
880 if Nkind
(Argx
) /= N_String_Literal
then
882 ("argument for pragma% must be string literal", Argx
);
884 end Check_Arg_Is_String_Literal
;
886 ------------------------------------------
887 -- Check_Arg_Is_Task_Dispatching_Policy --
888 ------------------------------------------
890 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
) is
891 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
894 Check_Arg_Is_Identifier
(Argx
);
896 if not Is_Task_Dispatching_Policy_Name
(Chars
(Argx
)) then
898 ("& is not a valid task dispatching policy name", Argx
);
900 end Check_Arg_Is_Task_Dispatching_Policy
;
902 --------------------------------
903 -- Check_At_Least_N_Arguments --
904 --------------------------------
906 procedure Check_At_Least_N_Arguments
(N
: Nat
) is
908 if Arg_Count
< N
then
909 Error_Pragma
("too few arguments for pragma%");
911 end Check_At_Least_N_Arguments
;
913 -------------------------------
914 -- Check_At_Most_N_Arguments --
915 -------------------------------
917 procedure Check_At_Most_N_Arguments
(N
: Nat
) is
920 if Arg_Count
> N
then
924 Error_Pragma_Arg
("too many arguments for pragma%", Arg
);
927 end Check_At_Most_N_Arguments
;
929 ---------------------
930 -- Check_Component --
931 ---------------------
933 procedure Check_Component
(Comp
: Node_Id
) is
935 if Nkind
(Comp
) = N_Component_Declaration
then
937 Sindic
: constant Node_Id
:=
938 Subtype_Indication
(Component_Definition
(Comp
));
941 if Nkind
(Sindic
) = N_Subtype_Indication
then
943 -- Ada 2005 (AI-216): If a component subtype is subject to
944 -- a per-object constraint, then the component type shall
945 -- be an Unchecked_Union.
947 if Has_Per_Object_Constraint
(Defining_Identifier
(Comp
))
949 not Is_Unchecked_Union
(Etype
(Subtype_Mark
(Sindic
)))
951 Error_Msg_N
("component subtype subject to per-object" &
952 " constraint must be an Unchecked_Union", Comp
);
959 ----------------------------------
960 -- Check_Duplicated_Export_Name --
961 ----------------------------------
963 procedure Check_Duplicated_Export_Name
(Nam
: Node_Id
) is
964 String_Val
: constant String_Id
:= Strval
(Nam
);
967 -- We are only interested in the export case, and in the case of
968 -- generics, it is the instance, not the template, that is the
969 -- problem (the template will generate a warning in any case).
971 if not Inside_A_Generic
972 and then (Prag_Id
= Pragma_Export
974 Prag_Id
= Pragma_Export_Procedure
976 Prag_Id
= Pragma_Export_Valued_Procedure
978 Prag_Id
= Pragma_Export_Function
)
980 for J
in Externals
.First
.. Externals
.Last
loop
981 if String_Equal
(String_Val
, Strval
(Externals
.Table
(J
))) then
982 Error_Msg_Sloc
:= Sloc
(Externals
.Table
(J
));
983 Error_Msg_N
("external name duplicates name given#", Nam
);
988 Externals
.Append
(Nam
);
990 end Check_Duplicated_Export_Name
;
992 -------------------------
993 -- Check_First_Subtype --
994 -------------------------
996 procedure Check_First_Subtype
(Arg
: Node_Id
) is
997 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
999 if not Is_First_Subtype
(Entity
(Argx
)) then
1001 ("pragma% cannot apply to subtype", Argx
);
1003 end Check_First_Subtype
;
1005 ---------------------------
1006 -- Check_In_Main_Program --
1007 ---------------------------
1009 procedure Check_In_Main_Program
is
1010 P
: constant Node_Id
:= Parent
(N
);
1013 -- Must be at in subprogram body
1015 if Nkind
(P
) /= N_Subprogram_Body
then
1016 Error_Pragma
("% pragma allowed only in subprogram");
1018 -- Otherwise warn if obviously not main program
1020 elsif Present
(Parameter_Specifications
(Specification
(P
)))
1021 or else not Is_Compilation_Unit
(Defining_Entity
(P
))
1023 Error_Msg_Name_1
:= Chars
(N
);
1025 ("?pragma% is only effective in main program", N
);
1027 end Check_In_Main_Program
;
1029 ---------------------------------------
1030 -- Check_Interrupt_Or_Attach_Handler --
1031 ---------------------------------------
1033 procedure Check_Interrupt_Or_Attach_Handler
is
1034 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
1039 if not Is_Entity_Name
(Arg1_X
) then
1041 ("argument of pragma% must be entity name", Arg1
);
1043 elsif Prag_Id
= Pragma_Interrupt_Handler
then
1044 Check_Restriction
(No_Dynamic_Attachment
, N
);
1048 Handler_Proc
: Entity_Id
:= Empty
;
1049 Proc_Scope
: Entity_Id
;
1050 Found
: Boolean := False;
1053 if not Is_Overloaded
(Arg1_X
) then
1054 Handler_Proc
:= Entity
(Arg1_X
);
1059 Index
: Interp_Index
;
1062 Get_First_Interp
(Arg1_X
, Index
, It
);
1063 while Present
(It
.Nam
) loop
1064 Handler_Proc
:= It
.Nam
;
1066 if Ekind
(Handler_Proc
) = E_Procedure
1067 and then No
(First_Formal
(Handler_Proc
))
1071 Set_Entity
(Arg1_X
, Handler_Proc
);
1072 Set_Is_Overloaded
(Arg1_X
, False);
1075 ("ambiguous handler name for pragma% ", Arg1
);
1079 Get_Next_Interp
(Index
, It
);
1084 ("argument of pragma% must be parameterless procedure",
1087 Handler_Proc
:= Entity
(Arg1_X
);
1092 Proc_Scope
:= Scope
(Handler_Proc
);
1094 -- On AAMP only, a pragma Interrupt_Handler is supported for
1095 -- nonprotected parameterless procedures.
1098 and then Prag_Id
= Pragma_Interrupt_Handler
1100 if Ekind
(Handler_Proc
) /= E_Procedure
then
1102 ("argument of pragma% must be a procedure", Arg1
);
1105 elsif Ekind
(Handler_Proc
) /= E_Procedure
1106 or else Ekind
(Proc_Scope
) /= E_Protected_Type
1109 ("argument of pragma% must be protected procedure", Arg1
);
1112 if (not AAMP_On_Target
or else Prag_Id
= Pragma_Attach_Handler
)
1113 and then Ekind
(Proc_Scope
) = E_Protected_Type
1116 Protected_Definition
(Parent
(Proc_Scope
))
1118 Error_Pragma
("pragma% must be in protected definition");
1122 if not Is_Library_Level_Entity
(Proc_Scope
)
1123 or else (AAMP_On_Target
1124 and then not Is_Library_Level_Entity
(Handler_Proc
))
1127 ("pragma% requires library-level entity", Arg1
);
1130 if Present
(First_Formal
(Handler_Proc
)) then
1132 ("argument of pragma% must be parameterless procedure",
1136 end Check_Interrupt_Or_Attach_Handler
;
1138 -------------------------------------------
1139 -- Check_Is_In_Decl_Part_Or_Package_Spec --
1140 -------------------------------------------
1142 procedure Check_Is_In_Decl_Part_Or_Package_Spec
is
1151 elsif Nkind
(P
) = N_Handled_Sequence_Of_Statements
then
1154 elsif Nkind
(P
) = N_Package_Specification
then
1157 elsif Nkind
(P
) = N_Block_Statement
then
1160 -- Note: the following tests seem a little peculiar, because
1161 -- they test for bodies, but if we were in the statement part
1162 -- of the body, we would already have hit the handled statement
1163 -- sequence, so the only way we get here is by being in the
1164 -- declarative part of the body.
1166 elsif Nkind
(P
) = N_Subprogram_Body
1167 or else Nkind
(P
) = N_Package_Body
1168 or else Nkind
(P
) = N_Task_Body
1169 or else Nkind
(P
) = N_Entry_Body
1177 Error_Pragma
("pragma% is not in declarative part or package spec");
1178 end Check_Is_In_Decl_Part_Or_Package_Spec
;
1180 -------------------------
1181 -- Check_No_Identifier --
1182 -------------------------
1184 procedure Check_No_Identifier
(Arg
: Node_Id
) is
1186 if Chars
(Arg
) /= No_Name
then
1187 Error_Pragma_Arg_Ident
1188 ("pragma% does not permit identifier& here", Arg
);
1190 end Check_No_Identifier
;
1192 --------------------------
1193 -- Check_No_Identifiers --
1194 --------------------------
1196 procedure Check_No_Identifiers
is
1199 if Arg_Count
> 0 then
1201 while Present
(Arg_Node
) loop
1202 Check_No_Identifier
(Arg_Node
);
1206 end Check_No_Identifiers
;
1208 -------------------------------
1209 -- Check_Optional_Identifier --
1210 -------------------------------
1212 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
) is
1214 if Present
(Arg
) and then Chars
(Arg
) /= No_Name
then
1215 if Chars
(Arg
) /= Id
then
1216 Error_Msg_Name_1
:= Chars
(N
);
1217 Error_Msg_Name_2
:= Id
;
1218 Error_Msg_N
("pragma% argument expects identifier%", Arg
);
1222 end Check_Optional_Identifier
;
1224 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String) is
1226 Name_Buffer
(1 .. Id
'Length) := Id
;
1227 Name_Len
:= Id
'Length;
1228 Check_Optional_Identifier
(Arg
, Name_Find
);
1229 end Check_Optional_Identifier
;
1231 -----------------------------
1232 -- Check_Static_Constraint --
1233 -----------------------------
1235 -- Note: for convenience in writing this procedure, in addition to
1236 -- the officially (i.e. by spec) allowed argument which is always
1237 -- a constraint, it also allows ranges and discriminant associations.
1238 -- Above is not clear ???
1240 procedure Check_Static_Constraint
(Constr
: Node_Id
) is
1242 --------------------
1243 -- Require_Static --
1244 --------------------
1246 procedure Require_Static
(E
: Node_Id
);
1247 -- Require given expression to be static expression
1249 procedure Require_Static
(E
: Node_Id
) is
1251 if not Is_OK_Static_Expression
(E
) then
1252 Flag_Non_Static_Expr
1253 ("non-static constraint not allowed in Unchecked_Union!", E
);
1258 -- Start of processing for Check_Static_Constraint
1261 case Nkind
(Constr
) is
1262 when N_Discriminant_Association
=>
1263 Require_Static
(Expression
(Constr
));
1266 Require_Static
(Low_Bound
(Constr
));
1267 Require_Static
(High_Bound
(Constr
));
1269 when N_Attribute_Reference
=>
1270 Require_Static
(Type_Low_Bound
(Etype
(Prefix
(Constr
))));
1271 Require_Static
(Type_High_Bound
(Etype
(Prefix
(Constr
))));
1273 when N_Range_Constraint
=>
1274 Check_Static_Constraint
(Range_Expression
(Constr
));
1276 when N_Index_Or_Discriminant_Constraint
=>
1280 IDC
:= First
(Constraints
(Constr
));
1281 while Present
(IDC
) loop
1282 Check_Static_Constraint
(IDC
);
1290 end Check_Static_Constraint
;
1292 --------------------------------------
1293 -- Check_Valid_Configuration_Pragma --
1294 --------------------------------------
1296 -- A configuration pragma must appear in the context clause of
1297 -- a compilation unit, at the start of the list (i.e. only other
1298 -- pragmas may precede it).
1300 procedure Check_Valid_Configuration_Pragma
is
1302 if not Is_Configuration_Pragma
then
1303 Error_Pragma
("incorrect placement for configuration pragma%");
1305 end Check_Valid_Configuration_Pragma
;
1307 -------------------------------------
1308 -- Check_Valid_Library_Unit_Pragma --
1309 -------------------------------------
1311 procedure Check_Valid_Library_Unit_Pragma
is
1313 Parent_Node
: Node_Id
;
1314 Unit_Name
: Entity_Id
;
1315 Unit_Kind
: Node_Kind
;
1316 Unit_Node
: Node_Id
;
1317 Sindex
: Source_File_Index
;
1320 if not Is_List_Member
(N
) then
1324 Plist
:= List_Containing
(N
);
1325 Parent_Node
:= Parent
(Plist
);
1327 if Parent_Node
= Empty
then
1330 -- Case of pragma appearing after a compilation unit. In this
1331 -- case it must have an argument with the corresponding name
1332 -- and must be part of the following pragmas of its parent.
1334 elsif Nkind
(Parent_Node
) = N_Compilation_Unit_Aux
then
1335 if Plist
/= Pragmas_After
(Parent_Node
) then
1338 elsif Arg_Count
= 0 then
1340 ("argument required if outside compilation unit");
1343 Check_No_Identifiers
;
1344 Check_Arg_Count
(1);
1345 Unit_Node
:= Unit
(Parent
(Parent_Node
));
1346 Unit_Kind
:= Nkind
(Unit_Node
);
1348 Analyze
(Expression
(Arg1
));
1350 if Unit_Kind
= N_Generic_Subprogram_Declaration
1351 or else Unit_Kind
= N_Subprogram_Declaration
1353 Unit_Name
:= Defining_Entity
(Unit_Node
);
1355 elsif Unit_Kind
= N_Function_Instantiation
1356 or else Unit_Kind
= N_Package_Instantiation
1357 or else Unit_Kind
= N_Procedure_Instantiation
1359 Unit_Name
:= Defining_Entity
(Unit_Node
);
1362 Unit_Name
:= Cunit_Entity
(Current_Sem_Unit
);
1365 if Chars
(Unit_Name
) /=
1366 Chars
(Entity
(Expression
(Arg1
)))
1369 ("pragma% argument is not current unit name", Arg1
);
1372 if Ekind
(Unit_Name
) = E_Package
1373 and then Present
(Renamed_Entity
(Unit_Name
))
1375 Error_Pragma
("pragma% not allowed for renamed package");
1379 -- Pragma appears other than after a compilation unit
1382 -- Here we check for the generic instantiation case and also
1383 -- for the case of processing a generic formal package. We
1384 -- detect these cases by noting that the Sloc on the node
1385 -- does not belong to the current compilation unit.
1387 Sindex
:= Source_Index
(Current_Sem_Unit
);
1389 if Loc
not in Source_First
(Sindex
) .. Source_Last
(Sindex
) then
1390 Rewrite
(N
, Make_Null_Statement
(Loc
));
1393 -- If before first declaration, the pragma applies to the
1394 -- enclosing unit, and the name if present must be this name.
1396 elsif Is_Before_First_Decl
(N
, Plist
) then
1397 Unit_Node
:= Unit_Declaration_Node
(Current_Scope
);
1398 Unit_Kind
:= Nkind
(Unit_Node
);
1400 if Nkind
(Parent
(Unit_Node
)) /= N_Compilation_Unit
then
1403 elsif Unit_Kind
= N_Subprogram_Body
1404 and then not Acts_As_Spec
(Unit_Node
)
1408 elsif Nkind
(Parent_Node
) = N_Package_Body
then
1411 elsif Nkind
(Parent_Node
) = N_Package_Specification
1412 and then Plist
= Private_Declarations
(Parent_Node
)
1416 elsif (Nkind
(Parent_Node
) = N_Generic_Package_Declaration
1417 or else Nkind
(Parent_Node
)
1418 = N_Generic_Subprogram_Declaration
)
1419 and then Plist
= Generic_Formal_Declarations
(Parent_Node
)
1423 elsif Arg_Count
> 0 then
1424 Analyze
(Expression
(Arg1
));
1426 if Entity
(Expression
(Arg1
)) /= Current_Scope
then
1428 ("name in pragma% must be enclosing unit", Arg1
);
1431 -- It is legal to have no argument in this context
1437 -- Error if not before first declaration. This is because a
1438 -- library unit pragma argument must be the name of a library
1439 -- unit (RM 10.1.5(7)), but the only names permitted in this
1440 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1441 -- generic subprogram declarations or generic instantiations.
1445 ("pragma% misplaced, must be before first declaration");
1449 end Check_Valid_Library_Unit_Pragma
;
1455 procedure Check_Variant
(Variant
: Node_Id
) is
1456 Clist
: constant Node_Id
:= Component_List
(Variant
);
1460 if Present
(Variant_Part
(Clist
)) then
1462 ("Unchecked_Union may not have nested variants",
1463 Variant_Part
(Clist
));
1466 if not Is_Non_Empty_List
(Component_Items
(Clist
)) then
1468 ("Unchecked_Union may not have empty component list",
1473 Comp
:= First
(Component_Items
(Clist
));
1474 while Present
(Comp
) loop
1475 Check_Component
(Comp
);
1484 procedure Error_Pragma
(Msg
: String) is
1486 Error_Msg_Name_1
:= Chars
(N
);
1487 Error_Msg_N
(Msg
, N
);
1491 ----------------------
1492 -- Error_Pragma_Arg --
1493 ----------------------
1495 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
) is
1497 Error_Msg_Name_1
:= Chars
(N
);
1498 Error_Msg_N
(Msg
, Get_Pragma_Arg
(Arg
));
1500 end Error_Pragma_Arg
;
1502 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
) is
1504 Error_Msg_Name_1
:= Chars
(N
);
1505 Error_Msg_N
(Msg1
, Get_Pragma_Arg
(Arg
));
1506 Error_Pragma_Arg
(Msg2
, Arg
);
1507 end Error_Pragma_Arg
;
1509 ----------------------------
1510 -- Error_Pragma_Arg_Ident --
1511 ----------------------------
1513 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
) is
1515 Error_Msg_Name_1
:= Chars
(N
);
1516 Error_Msg_N
(Msg
, Arg
);
1518 end Error_Pragma_Arg_Ident
;
1520 ------------------------
1521 -- Find_Lib_Unit_Name --
1522 ------------------------
1524 function Find_Lib_Unit_Name
return Entity_Id
is
1526 -- Return inner compilation unit entity, for case of nested
1527 -- categorization pragmas. This happens in generic unit.
1529 if Nkind
(Parent
(N
)) = N_Package_Specification
1530 and then Defining_Entity
(Parent
(N
)) /= Current_Scope
1532 return Defining_Entity
(Parent
(N
));
1534 return Current_Scope
;
1536 end Find_Lib_Unit_Name
;
1538 ----------------------------
1539 -- Find_Program_Unit_Name --
1540 ----------------------------
1542 procedure Find_Program_Unit_Name
(Id
: Node_Id
) is
1543 Unit_Name
: Entity_Id
;
1544 Unit_Kind
: Node_Kind
;
1545 P
: constant Node_Id
:= Parent
(N
);
1548 if Nkind
(P
) = N_Compilation_Unit
then
1549 Unit_Kind
:= Nkind
(Unit
(P
));
1551 if Unit_Kind
= N_Subprogram_Declaration
1552 or else Unit_Kind
= N_Package_Declaration
1553 or else Unit_Kind
in N_Generic_Declaration
1555 Unit_Name
:= Defining_Entity
(Unit
(P
));
1557 if Chars
(Id
) = Chars
(Unit_Name
) then
1558 Set_Entity
(Id
, Unit_Name
);
1559 Set_Etype
(Id
, Etype
(Unit_Name
));
1561 Set_Etype
(Id
, Any_Type
);
1563 ("cannot find program unit referenced by pragma%");
1567 Set_Etype
(Id
, Any_Type
);
1568 Error_Pragma
("pragma% inapplicable to this unit");
1575 end Find_Program_Unit_Name
;
1577 -------------------------
1578 -- Gather_Associations --
1579 -------------------------
1581 procedure Gather_Associations
1583 Args
: out Args_List
)
1588 -- Initialize all parameters to Empty
1590 for J
in Args
'Range loop
1594 -- That's all we have to do if there are no argument associations
1596 if No
(Pragma_Argument_Associations
(N
)) then
1600 -- Otherwise first deal with any positional parameters present
1602 Arg
:= First
(Pragma_Argument_Associations
(N
));
1603 for Index
in Args
'Range loop
1604 exit when No
(Arg
) or else Chars
(Arg
) /= No_Name
;
1605 Args
(Index
) := Expression
(Arg
);
1609 -- Positional parameters all processed, if any left, then we
1610 -- have too many positional parameters.
1612 if Present
(Arg
) and then Chars
(Arg
) = No_Name
then
1614 ("too many positional associations for pragma%", Arg
);
1617 -- Process named parameters if any are present
1619 while Present
(Arg
) loop
1620 if Chars
(Arg
) = No_Name
then
1622 ("positional association cannot follow named association",
1626 for Index
in Names
'Range loop
1627 if Names
(Index
) = Chars
(Arg
) then
1628 if Present
(Args
(Index
)) then
1630 ("duplicate argument association for pragma%", Arg
);
1632 Args
(Index
) := Expression
(Arg
);
1637 if Index
= Names
'Last then
1638 Error_Msg_Name_1
:= Chars
(N
);
1639 Error_Msg_N
("pragma% does not allow & argument", Arg
);
1641 -- Check for possible misspelling
1643 for Index1
in Names
'Range loop
1644 if Is_Bad_Spelling_Of
1645 (Get_Name_String
(Chars
(Arg
)),
1646 Get_Name_String
(Names
(Index1
)))
1648 Error_Msg_Name_1
:= Names
(Index1
);
1649 Error_Msg_N
("\possible misspelling of%", Arg
);
1661 end Gather_Associations
;
1663 --------------------
1664 -- Get_Pragma_Arg --
1665 --------------------
1667 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
is
1669 if Nkind
(Arg
) = N_Pragma_Argument_Association
then
1670 return Expression
(Arg
);
1680 procedure GNAT_Pragma
is
1682 Check_Restriction
(No_Implementation_Pragmas
, N
);
1685 --------------------------
1686 -- Is_Before_First_Decl --
1687 --------------------------
1689 function Is_Before_First_Decl
1690 (Pragma_Node
: Node_Id
;
1691 Decls
: List_Id
) return Boolean
1693 Item
: Node_Id
:= First
(Decls
);
1696 -- Only other pragmas can come before this pragma
1699 if No
(Item
) or else Nkind
(Item
) /= N_Pragma
then
1702 elsif Item
= Pragma_Node
then
1708 end Is_Before_First_Decl
;
1710 -----------------------------
1711 -- Is_Configuration_Pragma --
1712 -----------------------------
1714 -- A configuration pragma must appear in the context clause of
1715 -- a compilation unit, at the start of the list (i.e. only other
1716 -- pragmas may precede it).
1718 function Is_Configuration_Pragma
return Boolean is
1719 Lis
: constant List_Id
:= List_Containing
(N
);
1720 Par
: constant Node_Id
:= Parent
(N
);
1724 -- If no parent, then we are in the configuration pragma file,
1725 -- so the placement is definitely appropriate.
1730 -- Otherwise we must be in the context clause of a compilation unit
1731 -- and the only thing allowed before us in the context list is more
1732 -- configuration pragmas.
1734 elsif Nkind
(Par
) = N_Compilation_Unit
1735 and then Context_Items
(Par
) = Lis
1742 elsif Nkind
(Prg
) /= N_Pragma
then
1752 end Is_Configuration_Pragma
;
1754 ----------------------
1755 -- Pragma_Misplaced --
1756 ----------------------
1758 procedure Pragma_Misplaced
is
1760 Error_Pragma
("incorrect placement of pragma%");
1761 end Pragma_Misplaced
;
1763 ------------------------------------
1764 -- Process Atomic_Shared_Volatile --
1765 ------------------------------------
1767 procedure Process_Atomic_Shared_Volatile
is
1774 procedure Set_Atomic
(E
: Entity_Id
);
1775 -- Set given type as atomic, and if no explicit alignment was
1776 -- given, set alignment to unknown, since back end knows what
1777 -- the alignment requirements are for atomic arrays. Note that
1778 -- this step is necessary for derived types.
1784 procedure Set_Atomic
(E
: Entity_Id
) is
1788 if not Has_Alignment_Clause
(E
) then
1789 Set_Alignment
(E
, Uint_0
);
1793 -- Start of processing for Process_Atomic_Shared_Volatile
1796 Check_Ada_83_Warning
;
1797 Check_No_Identifiers
;
1798 Check_Arg_Count
(1);
1799 Check_Arg_Is_Local_Name
(Arg1
);
1800 E_Id
:= Expression
(Arg1
);
1802 if Etype
(E_Id
) = Any_Type
then
1807 D
:= Declaration_Node
(E
);
1811 if Rep_Item_Too_Early
(E
, N
)
1813 Rep_Item_Too_Late
(E
, N
)
1817 Check_First_Subtype
(Arg1
);
1820 if Prag_Id
/= Pragma_Volatile
then
1822 Set_Atomic
(Underlying_Type
(E
));
1823 Set_Atomic
(Base_Type
(E
));
1826 -- Attribute belongs on the base type. If the
1827 -- view of the type is currently private, it also
1828 -- belongs on the underlying type.
1830 Set_Is_Volatile
(Base_Type
(E
));
1831 Set_Is_Volatile
(Underlying_Type
(E
));
1833 Set_Treat_As_Volatile
(E
);
1834 Set_Treat_As_Volatile
(Underlying_Type
(E
));
1836 elsif K
= N_Object_Declaration
1837 or else (K
= N_Component_Declaration
1838 and then Original_Record_Component
(E
) = E
)
1840 if Rep_Item_Too_Late
(E
, N
) then
1844 if Prag_Id
/= Pragma_Volatile
then
1847 -- If the object declaration has an explicit
1848 -- initialization, a temporary may have to be
1849 -- created to hold the expression, to insure
1850 -- that access to the object remain atomic.
1852 if Nkind
(Parent
(E
)) = N_Object_Declaration
1853 and then Present
(Expression
(Parent
(E
)))
1855 Set_Has_Delayed_Freeze
(E
);
1858 -- An interesting improvement here. If an object of type X
1859 -- is declared atomic, and the type X is not atomic, that's
1860 -- a pity, since it may not have appropraite alignment etc.
1861 -- We can rescue this in the special case where the object
1862 -- and type are in the same unit by just setting the type
1863 -- as atomic, so that the back end will process it as atomic.
1865 Utyp
:= Underlying_Type
(Etype
(E
));
1868 and then Sloc
(E
) > No_Location
1869 and then Sloc
(Utyp
) > No_Location
1871 Get_Source_File_Index
(Sloc
(E
)) =
1872 Get_Source_File_Index
(Sloc
(Underlying_Type
(Etype
(E
))))
1874 Set_Is_Atomic
(Underlying_Type
(Etype
(E
)));
1878 Set_Is_Volatile
(E
);
1879 Set_Treat_As_Volatile
(E
);
1883 ("inappropriate entity for pragma%", Arg1
);
1885 end Process_Atomic_Shared_Volatile
;
1887 ------------------------
1888 -- Process_Convention --
1889 ------------------------
1891 procedure Process_Convention
1892 (C
: out Convention_Id
;
1898 Comp_Unit
: Unit_Number_Type
;
1900 procedure Set_Convention_From_Pragma
(E
: Entity_Id
);
1901 -- Set convention in entity E, and also flag that the entity has a
1902 -- convention pragma. If entity is for a private or incomplete type,
1903 -- also set convention and flag on underlying type. This procedure
1904 -- also deals with the special case of C_Pass_By_Copy convention.
1906 --------------------------------
1907 -- Set_Convention_From_Pragma --
1908 --------------------------------
1910 procedure Set_Convention_From_Pragma
(E
: Entity_Id
) is
1912 Set_Convention
(E
, C
);
1913 Set_Has_Convention_Pragma
(E
);
1915 if Is_Incomplete_Or_Private_Type
(E
) then
1916 Set_Convention
(Underlying_Type
(E
), C
);
1917 Set_Has_Convention_Pragma
(Underlying_Type
(E
), True);
1920 -- A class-wide type should inherit the convention of
1921 -- the specific root type (although this isn't specified
1922 -- clearly by the RM).
1924 if Is_Type
(E
) and then Present
(Class_Wide_Type
(E
)) then
1925 Set_Convention
(Class_Wide_Type
(E
), C
);
1928 -- If the entity is a record type, then check for special case
1929 -- of C_Pass_By_Copy, which is treated the same as C except that
1930 -- the special record flag is set. This convention is also only
1931 -- permitted on record types (see AI95-00131).
1933 if Cname
= Name_C_Pass_By_Copy
then
1934 if Is_Record_Type
(E
) then
1935 Set_C_Pass_By_Copy
(Base_Type
(E
));
1936 elsif Is_Incomplete_Or_Private_Type
(E
)
1937 and then Is_Record_Type
(Underlying_Type
(E
))
1939 Set_C_Pass_By_Copy
(Base_Type
(Underlying_Type
(E
)));
1942 ("C_Pass_By_Copy convention allowed only for record type",
1947 -- If the entity is a derived boolean type, check for the
1948 -- special case of convention C, C++, or Fortran, where we
1949 -- consider any nonzero value to represent true.
1951 if Is_Discrete_Type
(E
)
1952 and then Root_Type
(Etype
(E
)) = Standard_Boolean
1958 C
= Convention_Fortran
)
1960 Set_Nonzero_Is_True
(Base_Type
(E
));
1962 end Set_Convention_From_Pragma
;
1964 -- Start of processing for Process_Convention
1967 Check_At_Least_N_Arguments
(2);
1968 Check_Arg_Is_Identifier
(Arg1
);
1969 Check_Optional_Identifier
(Arg1
, Name_Convention
);
1970 Cname
:= Chars
(Expression
(Arg1
));
1972 -- C_Pass_By_Copy is treated as a synonym for convention C
1973 -- (this is tested again below to set the critical flag)
1975 if Cname
= Name_C_Pass_By_Copy
then
1978 -- Otherwise we must have something in the standard convention list
1980 elsif Is_Convention_Name
(Cname
) then
1981 C
:= Get_Convention_Id
(Chars
(Expression
(Arg1
)));
1983 -- In DEC VMS, it seems that there is an undocumented feature
1984 -- that any unrecognized convention is treated as the default,
1985 -- which for us is convention C. It does not seem so terrible
1986 -- to do this unconditionally, silently in the VMS case, and
1987 -- with a warning in the non-VMS case.
1990 if Warn_On_Export_Import
and not OpenVMS_On_Target
then
1992 ("?unrecognized convention name, C assumed",
1999 Check_Arg_Is_Local_Name
(Arg2
);
2000 Check_Optional_Identifier
(Arg2
, Name_Entity
);
2002 Id
:= Expression
(Arg2
);
2005 if not Is_Entity_Name
(Id
) then
2006 Error_Pragma_Arg
("entity name required", Arg2
);
2011 -- Go to renamed subprogram if present, since convention applies
2012 -- to the actual renamed entity, not to the renaming entity.
2013 -- If subprogram is inherited, go to parent subprogram.
2015 if Is_Subprogram
(E
)
2016 and then Present
(Alias
(E
))
2018 if Nkind
(Parent
(Declaration_Node
(E
)))
2019 = N_Subprogram_Renaming_Declaration
2023 elsif Nkind
(Parent
(E
)) = N_Full_Type_Declaration
2024 and then Scope
(E
) = Scope
(Alias
(E
))
2030 -- Check that we are not applying this to a specless body
2032 if Is_Subprogram
(E
)
2033 and then Nkind
(Parent
(Declaration_Node
(E
))) = N_Subprogram_Body
2036 ("pragma% requires separate spec and must come before body");
2039 -- Check that we are not applying this to a named constant
2041 if Ekind
(E
) = E_Named_Integer
2043 Ekind
(E
) = E_Named_Real
2045 Error_Msg_Name_1
:= Chars
(N
);
2047 ("cannot apply pragma% to named constant!",
2048 Get_Pragma_Arg
(Arg2
));
2050 ("\supply appropriate type for&!", Arg2
);
2053 if Etype
(E
) = Any_Type
2054 or else Rep_Item_Too_Early
(E
, N
)
2058 E
:= Underlying_Type
(E
);
2061 if Rep_Item_Too_Late
(E
, N
) then
2065 if Has_Convention_Pragma
(E
) then
2067 ("at most one Convention/Export/Import pragma is allowed", Arg2
);
2069 elsif Convention
(E
) = Convention_Protected
2070 or else Ekind
(Scope
(E
)) = E_Protected_Type
2073 ("a protected operation cannot be given a different convention",
2077 -- For Intrinsic, a subprogram is required
2079 if C
= Convention_Intrinsic
2080 and then not Is_Subprogram
(E
)
2081 and then not Is_Generic_Subprogram
(E
)
2084 ("second argument of pragma% must be a subprogram", Arg2
);
2087 -- For Stdcall, a subprogram, variable or subprogram type is required
2089 if C
= Convention_Stdcall
2090 and then not Is_Subprogram
(E
)
2091 and then not Is_Generic_Subprogram
(E
)
2092 and then Ekind
(E
) /= E_Variable
2095 and then Ekind
(Designated_Type
(E
)) = E_Subprogram_Type
)
2098 ("second argument of pragma% must be subprogram (type)",
2102 if not Is_Subprogram
(E
)
2103 and then not Is_Generic_Subprogram
(E
)
2105 Set_Convention_From_Pragma
(E
);
2109 Check_First_Subtype
(Arg2
);
2110 Set_Convention_From_Pragma
(Base_Type
(E
));
2112 -- For subprograms, we must set the convention on the
2113 -- internally generated directly designated type as well.
2115 if Ekind
(E
) = E_Access_Subprogram_Type
then
2116 Set_Convention_From_Pragma
(Directly_Designated_Type
(E
));
2120 -- For the subprogram case, set proper convention for all homonyms
2121 -- in same scope and the same declarative part, i.e. the same
2122 -- compilation unit.
2125 Comp_Unit
:= Get_Source_Unit
(E
);
2126 Set_Convention_From_Pragma
(E
);
2128 -- Treat a pragma Import as an implicit body, for GPS use.
2130 if Prag_Id
= Pragma_Import
then
2131 Generate_Reference
(E
, Id
, 'b');
2137 exit when No
(E1
) or else Scope
(E1
) /= Current_Scope
;
2139 -- Note: below we are missing a check for Rep_Item_Too_Late.
2140 -- That is deliberate, we cannot chain the rep item on more
2141 -- than one Rep_Item chain, to be fixed later ???
2143 if Comes_From_Source
(E1
)
2144 and then Comp_Unit
= Get_Source_Unit
(E1
)
2145 and then Nkind
(Original_Node
(Parent
(E1
))) /=
2146 N_Full_Type_Declaration
2148 Set_Convention_From_Pragma
(E1
);
2150 if Prag_Id
= Pragma_Import
then
2151 Generate_Reference
(E
, Id
, 'b');
2156 end Process_Convention
;
2158 -----------------------------------------------------
2159 -- Process_Extended_Import_Export_Exception_Pragma --
2160 -----------------------------------------------------
2162 procedure Process_Extended_Import_Export_Exception_Pragma
2163 (Arg_Internal
: Node_Id
;
2164 Arg_External
: Node_Id
;
2174 if not OpenVMS_On_Target
then
2176 ("?pragma% ignored (applies only to Open'V'M'S)");
2179 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2180 Def_Id
:= Entity
(Arg_Internal
);
2182 if Ekind
(Def_Id
) /= E_Exception
then
2184 ("pragma% must refer to declared exception", Arg_Internal
);
2187 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2189 if Present
(Arg_Form
) then
2190 Check_Arg_Is_One_Of
(Arg_Form
, Name_Ada
, Name_VMS
);
2193 if Present
(Arg_Form
)
2194 and then Chars
(Arg_Form
) = Name_Ada
2198 Set_Is_VMS_Exception
(Def_Id
);
2199 Set_Exception_Code
(Def_Id
, No_Uint
);
2202 if Present
(Arg_Code
) then
2203 if not Is_VMS_Exception
(Def_Id
) then
2205 ("Code option for pragma% not allowed for Ada case",
2209 Check_Arg_Is_Static_Expression
(Arg_Code
, Any_Integer
);
2210 Code_Val
:= Expr_Value
(Arg_Code
);
2212 if not UI_Is_In_Int_Range
(Code_Val
) then
2214 ("Code option for pragma% must be in 32-bit range",
2218 Set_Exception_Code
(Def_Id
, Code_Val
);
2221 end Process_Extended_Import_Export_Exception_Pragma
;
2223 -------------------------------------------------
2224 -- Process_Extended_Import_Export_Internal_Arg --
2225 -------------------------------------------------
2227 procedure Process_Extended_Import_Export_Internal_Arg
2228 (Arg_Internal
: Node_Id
:= Empty
)
2233 if No
(Arg_Internal
) then
2234 Error_Pragma
("Internal parameter required for pragma%");
2237 if Nkind
(Arg_Internal
) = N_Identifier
then
2240 elsif Nkind
(Arg_Internal
) = N_Operator_Symbol
2241 and then (Prag_Id
= Pragma_Import_Function
2243 Prag_Id
= Pragma_Export_Function
)
2249 ("wrong form for Internal parameter for pragma%", Arg_Internal
);
2252 Check_Arg_Is_Local_Name
(Arg_Internal
);
2253 end Process_Extended_Import_Export_Internal_Arg
;
2255 --------------------------------------------------
2256 -- Process_Extended_Import_Export_Object_Pragma --
2257 --------------------------------------------------
2259 procedure Process_Extended_Import_Export_Object_Pragma
2260 (Arg_Internal
: Node_Id
;
2261 Arg_External
: Node_Id
;
2267 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2268 Def_Id
:= Entity
(Arg_Internal
);
2270 if Ekind
(Def_Id
) /= E_Constant
2271 and then Ekind
(Def_Id
) /= E_Variable
2274 ("pragma% must designate an object", Arg_Internal
);
2277 if Has_Rep_Pragma
(Def_Id
, Name_Common_Object
)
2279 Has_Rep_Pragma
(Def_Id
, Name_Psect_Object
)
2282 ("previous Common/Psect_Object applies, pragma % not permitted",
2286 if Rep_Item_Too_Late
(Def_Id
, N
) then
2290 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2292 if Present
(Arg_Size
) then
2293 Check_Arg_Is_External_Name
(Arg_Size
);
2296 -- Export_Object case
2298 if Prag_Id
= Pragma_Export_Object
then
2299 if not Is_Library_Level_Entity
(Def_Id
) then
2301 ("argument for pragma% must be library level entity",
2305 if Ekind
(Current_Scope
) = E_Generic_Package
then
2306 Error_Pragma
("pragma& cannot appear in a generic unit");
2309 if not Size_Known_At_Compile_Time
(Etype
(Def_Id
)) then
2311 ("exported object must have compile time known size",
2315 if Warn_On_Export_Import
and then Is_Exported
(Def_Id
) then
2317 ("?duplicate Export_Object pragma", N
);
2319 Set_Exported
(Def_Id
, Arg_Internal
);
2322 -- Import_Object case
2325 if Is_Concurrent_Type
(Etype
(Def_Id
)) then
2327 ("cannot use pragma% for task/protected object",
2331 if Ekind
(Def_Id
) = E_Constant
then
2333 ("cannot import a constant", Arg_Internal
);
2336 if Warn_On_Export_Import
2337 and then Has_Discriminants
(Etype
(Def_Id
))
2340 ("imported value must be initialized?", Arg_Internal
);
2343 if Warn_On_Export_Import
2344 and then Is_Access_Type
(Etype
(Def_Id
))
2347 ("cannot import object of an access type?", Arg_Internal
);
2350 if Warn_On_Export_Import
2351 and then Is_Imported
(Def_Id
)
2354 ("?duplicate Import_Object pragma", N
);
2356 -- Check for explicit initialization present. Note that an
2357 -- initialization that generated by the code generator, e.g.
2358 -- for an access type, does not count here.
2360 elsif Present
(Expression
(Parent
(Def_Id
)))
2363 (Original_Node
(Expression
(Parent
(Def_Id
))))
2365 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2367 ("no initialization allowed for declaration of& #",
2368 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2371 Set_Imported
(Def_Id
);
2372 Note_Possible_Modification
(Arg_Internal
);
2375 end Process_Extended_Import_Export_Object_Pragma
;
2377 ------------------------------------------------------
2378 -- Process_Extended_Import_Export_Subprogram_Pragma --
2379 ------------------------------------------------------
2381 procedure Process_Extended_Import_Export_Subprogram_Pragma
2382 (Arg_Internal
: Node_Id
;
2383 Arg_External
: Node_Id
;
2384 Arg_Parameter_Types
: Node_Id
;
2385 Arg_Result_Type
: Node_Id
:= Empty
;
2386 Arg_Mechanism
: Node_Id
;
2387 Arg_Result_Mechanism
: Node_Id
:= Empty
;
2388 Arg_First_Optional_Parameter
: Node_Id
:= Empty
)
2394 Ambiguous
: Boolean;
2398 function Same_Base_Type
2400 Formal
: Entity_Id
) return Boolean;
2401 -- Determines if Ptype references the type of Formal. Note that
2402 -- only the base types need to match according to the spec. Ptype
2403 -- here is the argument from the pragma, which is either a type
2404 -- name, or an access attribute.
2406 --------------------
2407 -- Same_Base_Type --
2408 --------------------
2410 function Same_Base_Type
2412 Formal
: Entity_Id
) return Boolean
2414 Ftyp
: constant Entity_Id
:= Base_Type
(Etype
(Formal
));
2418 -- Case where pragma argument is typ'Access
2420 if Nkind
(Ptype
) = N_Attribute_Reference
2421 and then Attribute_Name
(Ptype
) = Name_Access
2423 Pref
:= Prefix
(Ptype
);
2426 if not Is_Entity_Name
(Pref
)
2427 or else Entity
(Pref
) = Any_Type
2432 -- We have a match if the corresponding argument is of an
2433 -- anonymous access type, and its designicated type matches
2434 -- the type of the prefix of the access attribute
2436 return Ekind
(Ftyp
) = E_Anonymous_Access_Type
2437 and then Base_Type
(Entity
(Pref
)) =
2438 Base_Type
(Etype
(Designated_Type
(Ftyp
)));
2440 -- Case where pragma argument is a type name
2445 if not Is_Entity_Name
(Ptype
)
2446 or else Entity
(Ptype
) = Any_Type
2451 -- We have a match if the corresponding argument is of
2452 -- the type given in the pragma (comparing base types)
2454 return Base_Type
(Entity
(Ptype
)) = Ftyp
;
2458 -- Start of processing for
2459 -- Process_Extended_Import_Export_Subprogram_Pragma
2462 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2466 -- Loop through homonyms (overloadings) of the entity
2468 Hom_Id
:= Entity
(Arg_Internal
);
2469 while Present
(Hom_Id
) loop
2470 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
2472 -- We need a subprogram in the current scope
2474 if not Is_Subprogram
(Def_Id
)
2475 or else Scope
(Def_Id
) /= Current_Scope
2482 -- Pragma cannot apply to subprogram body
2484 if Is_Subprogram
(Def_Id
)
2487 (Declaration_Node
(Def_Id
))) = N_Subprogram_Body
2490 ("pragma% requires separate spec"
2491 & " and must come before body");
2494 -- Test result type if given, note that the result type
2495 -- parameter can only be present for the function cases.
2497 if Present
(Arg_Result_Type
)
2498 and then not Same_Base_Type
(Arg_Result_Type
, Def_Id
)
2502 elsif Etype
(Def_Id
) /= Standard_Void_Type
2504 (Chars
(N
) = Name_Export_Procedure
2505 or else Chars
(N
) = Name_Import_Procedure
)
2509 -- Test parameter types if given. Note that this parameter
2510 -- has not been analyzed (and must not be, since it is
2511 -- semantic nonsense), so we get it as the parser left it.
2513 elsif Present
(Arg_Parameter_Types
) then
2514 Check_Matching_Types
: declare
2519 Formal
:= First_Formal
(Def_Id
);
2521 if Nkind
(Arg_Parameter_Types
) = N_Null
then
2522 if Present
(Formal
) then
2526 -- A list of one type, e.g. (List) is parsed as
2527 -- a parenthesized expression.
2529 elsif Nkind
(Arg_Parameter_Types
) /= N_Aggregate
2530 and then Paren_Count
(Arg_Parameter_Types
) = 1
2533 or else Present
(Next_Formal
(Formal
))
2538 Same_Base_Type
(Arg_Parameter_Types
, Formal
);
2541 -- A list of more than one type is parsed as a aggregate
2543 elsif Nkind
(Arg_Parameter_Types
) = N_Aggregate
2544 and then Paren_Count
(Arg_Parameter_Types
) = 0
2546 Ptype
:= First
(Expressions
(Arg_Parameter_Types
));
2547 while Present
(Ptype
) or else Present
(Formal
) loop
2550 or else not Same_Base_Type
(Ptype
, Formal
)
2555 Next_Formal
(Formal
);
2560 -- Anything else is of the wrong form
2564 ("wrong form for Parameter_Types parameter",
2565 Arg_Parameter_Types
);
2567 end Check_Matching_Types
;
2570 -- Match is now False if the entry we found did not match
2571 -- either a supplied Parameter_Types or Result_Types argument
2577 -- Ambiguous case, the flag Ambiguous shows if we already
2578 -- detected this and output the initial messages.
2581 if not Ambiguous
then
2583 Error_Msg_Name_1
:= Chars
(N
);
2585 ("pragma% does not uniquely identify subprogram!",
2587 Error_Msg_Sloc
:= Sloc
(Ent
);
2588 Error_Msg_N
("matching subprogram #!", N
);
2592 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2593 Error_Msg_N
("matching subprogram #!", N
);
2598 Hom_Id
:= Homonym
(Hom_Id
);
2601 -- See if we found an entry
2604 if not Ambiguous
then
2605 if Is_Generic_Subprogram
(Entity
(Arg_Internal
)) then
2607 ("pragma% cannot be given for generic subprogram");
2611 ("pragma% does not identify local subprogram");
2618 -- Import pragmas must be be for imported entities
2620 if Prag_Id
= Pragma_Import_Function
2622 Prag_Id
= Pragma_Import_Procedure
2624 Prag_Id
= Pragma_Import_Valued_Procedure
2626 if not Is_Imported
(Ent
) then
2628 ("pragma Import or Interface must precede pragma%");
2631 -- Here we have the Export case which can set the entity as exported
2633 -- But does not do so if the specified external name is null,
2634 -- since that is taken as a signal in DEC Ada 83 (with which
2635 -- we want to be compatible) to request no external name.
2637 elsif Nkind
(Arg_External
) = N_String_Literal
2638 and then String_Length
(Strval
(Arg_External
)) = 0
2642 -- In all other cases, set entit as exported
2645 Set_Exported
(Ent
, Arg_Internal
);
2648 -- Special processing for Valued_Procedure cases
2650 if Prag_Id
= Pragma_Import_Valued_Procedure
2652 Prag_Id
= Pragma_Export_Valued_Procedure
2654 Formal
:= First_Formal
(Ent
);
2658 ("at least one parameter required for pragma%");
2660 elsif Ekind
(Formal
) /= E_Out_Parameter
then
2662 ("first parameter must have mode out for pragma%");
2665 Set_Is_Valued_Procedure
(Ent
);
2669 Set_Extended_Import_Export_External_Name
(Ent
, Arg_External
);
2671 -- Process Result_Mechanism argument if present. We have already
2672 -- checked that this is only allowed for the function case.
2674 if Present
(Arg_Result_Mechanism
) then
2675 Set_Mechanism_Value
(Ent
, Arg_Result_Mechanism
);
2678 -- Process Mechanism parameter if present. Note that this parameter
2679 -- is not analyzed, and must not be analyzed since it is semantic
2680 -- nonsense, so we get it in exactly as the parser left it.
2682 if Present
(Arg_Mechanism
) then
2690 -- A single mechanism association without a formal parameter
2691 -- name is parsed as a parenthesized expression. All other
2692 -- cases are parsed as aggregates, so we rewrite the single
2693 -- parameter case as an aggregate for consistency.
2695 if Nkind
(Arg_Mechanism
) /= N_Aggregate
2696 and then Paren_Count
(Arg_Mechanism
) = 1
2698 Rewrite
(Arg_Mechanism
,
2699 Make_Aggregate
(Sloc
(Arg_Mechanism
),
2700 Expressions
=> New_List
(
2701 Relocate_Node
(Arg_Mechanism
))));
2704 -- Case of only mechanism name given, applies to all formals
2706 if Nkind
(Arg_Mechanism
) /= N_Aggregate
then
2707 Formal
:= First_Formal
(Ent
);
2708 while Present
(Formal
) loop
2709 Set_Mechanism_Value
(Formal
, Arg_Mechanism
);
2710 Next_Formal
(Formal
);
2713 -- Case of list of mechanism associations given
2716 if Null_Record_Present
(Arg_Mechanism
) then
2718 ("inappropriate form for Mechanism parameter",
2722 -- Deal with positional ones first
2724 Formal
:= First_Formal
(Ent
);
2726 if Present
(Expressions
(Arg_Mechanism
)) then
2727 Mname
:= First
(Expressions
(Arg_Mechanism
));
2729 while Present
(Mname
) loop
2732 ("too many mechanism associations", Mname
);
2735 Set_Mechanism_Value
(Formal
, Mname
);
2736 Next_Formal
(Formal
);
2741 -- Deal with named entries
2743 if Present
(Component_Associations
(Arg_Mechanism
)) then
2744 Massoc
:= First
(Component_Associations
(Arg_Mechanism
));
2746 while Present
(Massoc
) loop
2747 Choice
:= First
(Choices
(Massoc
));
2749 if Nkind
(Choice
) /= N_Identifier
2750 or else Present
(Next
(Choice
))
2753 ("incorrect form for mechanism association",
2757 Formal
:= First_Formal
(Ent
);
2761 ("parameter name & not present", Choice
);
2764 if Chars
(Choice
) = Chars
(Formal
) then
2766 (Formal
, Expression
(Massoc
));
2770 Next_Formal
(Formal
);
2780 -- Process First_Optional_Parameter argument if present. We have
2781 -- already checked that this is only allowed for the Import case.
2783 if Present
(Arg_First_Optional_Parameter
) then
2784 if Nkind
(Arg_First_Optional_Parameter
) /= N_Identifier
then
2786 ("first optional parameter must be formal parameter name",
2787 Arg_First_Optional_Parameter
);
2790 Formal
:= First_Formal
(Ent
);
2794 ("specified formal parameter& not found",
2795 Arg_First_Optional_Parameter
);
2798 exit when Chars
(Formal
) =
2799 Chars
(Arg_First_Optional_Parameter
);
2801 Next_Formal
(Formal
);
2804 Set_First_Optional_Parameter
(Ent
, Formal
);
2806 -- Check specified and all remaining formals have right form
2808 while Present
(Formal
) loop
2809 if Ekind
(Formal
) /= E_In_Parameter
then
2811 ("optional formal& is not of mode in!",
2812 Arg_First_Optional_Parameter
, Formal
);
2815 Dval
:= Default_Value
(Formal
);
2817 if not Present
(Dval
) then
2819 ("optional formal& does not have default value!",
2820 Arg_First_Optional_Parameter
, Formal
);
2822 elsif Compile_Time_Known_Value_Or_Aggr
(Dval
) then
2827 ("default value for optional formal& is non-static!",
2828 Arg_First_Optional_Parameter
, Formal
);
2832 Set_Is_Optional_Parameter
(Formal
);
2833 Next_Formal
(Formal
);
2836 end Process_Extended_Import_Export_Subprogram_Pragma
;
2838 --------------------------
2839 -- Process_Generic_List --
2840 --------------------------
2842 procedure Process_Generic_List
is
2848 Check_No_Identifiers
;
2849 Check_At_Least_N_Arguments
(1);
2852 while Present
(Arg
) loop
2853 Exp
:= Expression
(Arg
);
2856 if not Is_Entity_Name
(Exp
)
2858 (not Is_Generic_Instance
(Entity
(Exp
))
2860 not Is_Generic_Unit
(Entity
(Exp
)))
2863 ("pragma% argument must be name of generic unit/instance",
2869 end Process_Generic_List
;
2871 ---------------------------------
2872 -- Process_Import_Or_Interface --
2873 ---------------------------------
2875 procedure Process_Import_Or_Interface
is
2881 Process_Convention
(C
, Def_Id
);
2882 Kill_Size_Check_Code
(Def_Id
);
2883 Note_Possible_Modification
(Expression
(Arg2
));
2885 if Ekind
(Def_Id
) = E_Variable
2887 Ekind
(Def_Id
) = E_Constant
2889 -- User initialization is not allowed for imported object, but
2890 -- the object declaration may contain a default initialization,
2891 -- that will be discarded. Note that an explicit initialization
2892 -- only counts if it comes from source, otherwise it is simply
2893 -- the code generator making an implicit initialization explicit.
2895 if Present
(Expression
(Parent
(Def_Id
)))
2896 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
2898 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2900 ("no initialization allowed for declaration of& #",
2901 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2905 Set_Imported
(Def_Id
);
2906 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
2908 -- Note that we do not set Is_Public here. That's because we
2909 -- only want to set if if there is no address clause, and we
2910 -- don't know that yet, so we delay that processing till
2913 -- pragma Import completes deferred constants
2915 if Ekind
(Def_Id
) = E_Constant
then
2916 Set_Has_Completion
(Def_Id
);
2919 -- It is not possible to import a constant of an unconstrained
2920 -- array type (e.g. string) because there is no simple way to
2921 -- write a meaningful subtype for it.
2923 if Is_Array_Type
(Etype
(Def_Id
))
2924 and then not Is_Constrained
(Etype
(Def_Id
))
2927 ("imported constant& must have a constrained subtype",
2932 elsif Is_Subprogram
(Def_Id
)
2933 or else Is_Generic_Subprogram
(Def_Id
)
2935 -- If the name is overloaded, pragma applies to all of the
2936 -- denoted entities in the same declarative part.
2939 while Present
(Hom_Id
) loop
2940 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
2942 -- Ignore inherited subprograms because the pragma will
2943 -- apply to the parent operation, which is the one called.
2945 if Is_Overloadable
(Def_Id
)
2946 and then Present
(Alias
(Def_Id
))
2950 -- If it is not a subprogram, it must be in an outer
2951 -- scope and pragma does not apply.
2953 elsif not Is_Subprogram
(Def_Id
)
2954 and then not Is_Generic_Subprogram
(Def_Id
)
2958 -- Verify that the homonym is in the same declarative
2959 -- part (not just the same scope).
2961 elsif Parent
(Unit_Declaration_Node
(Def_Id
)) /= Parent
(N
)
2962 and then Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
2967 Set_Imported
(Def_Id
);
2969 -- Special processing for Convention_Intrinsic
2971 if C
= Convention_Intrinsic
then
2973 -- Link_Name argument not allowed for intrinsic
2976 and then Chars
(Arg3
) = Name_Link_Name
2981 if Present
(Arg4
) then
2983 ("Link_Name argument not allowed for " &
2988 Set_Is_Intrinsic_Subprogram
(Def_Id
);
2990 -- If no external name is present, then check that
2991 -- this is a valid intrinsic subprogram. If an external
2992 -- name is present, then this is handled by the back end.
2995 Check_Intrinsic_Subprogram
(Def_Id
, Expression
(Arg2
));
2999 -- All interfaced procedures need an external symbol
3000 -- created for them since they are always referenced
3001 -- from another object file.
3003 Set_Is_Public
(Def_Id
);
3005 -- Verify that the subprogram does not have a completion
3006 -- through a renaming declaration. For other completions
3007 -- the pragma appears as a too late representation.
3010 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Def_Id
);
3014 and then Nkind
(Decl
) = N_Subprogram_Declaration
3015 and then Present
(Corresponding_Body
(Decl
))
3018 (Unit_Declaration_Node
3019 (Corresponding_Body
(Decl
))) =
3020 N_Subprogram_Renaming_Declaration
3022 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3023 Error_Msg_NE
("cannot import&#," &
3024 " already completed by a renaming",
3029 Set_Has_Completion
(Def_Id
);
3030 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3033 if Is_Compilation_Unit
(Hom_Id
) then
3035 -- Its possible homonyms are not affected by the pragma.
3036 -- Such homonyms might be present in the context of other
3037 -- units being compiled.
3042 Hom_Id
:= Homonym
(Hom_Id
);
3046 -- When the convention is Java, we also allow Import to be given
3047 -- for packages, exceptions, and record components.
3049 elsif C
= Convention_Java
3051 (Ekind
(Def_Id
) = E_Package
3052 or else Ekind
(Def_Id
) = E_Exception
3053 or else Nkind
(Parent
(Def_Id
)) = N_Component_Declaration
)
3055 Set_Imported
(Def_Id
);
3056 Set_Is_Public
(Def_Id
);
3057 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3061 ("second argument of pragma% must be object or subprogram",
3065 -- If this pragma applies to a compilation unit, then the unit,
3066 -- which is a subprogram, does not require (or allow) a body.
3067 -- We also do not need to elaborate imported procedures.
3069 if Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
3071 Cunit
: constant Node_Id
:= Parent
(Parent
(N
));
3073 Set_Body_Required
(Cunit
, False);
3076 end Process_Import_Or_Interface
;
3078 --------------------
3079 -- Process_Inline --
3080 --------------------
3082 procedure Process_Inline
(Active
: Boolean) is
3088 Effective
: Boolean := False;
3090 procedure Make_Inline
(Subp
: Entity_Id
);
3091 -- Subp is the defining unit name of the subprogram
3092 -- declaration. Set the flag, as well as the flag in the
3093 -- corresponding body, if there is one present.
3095 procedure Set_Inline_Flags
(Subp
: Entity_Id
);
3096 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp
3098 function Inlining_Not_Possible
(Subp
: Entity_Id
) return Boolean;
3099 -- Returns True if it can be determined at this stage that inlining
3100 -- is not possible, for examle if the body is available and contains
3101 -- exception handlers, we prevent inlining, since otherwise we can
3102 -- get undefined symbols at link time. This function also emits a
3103 -- warning if front-end inlining is enabled and the pragma appears
3105 -- ??? is business with link symbols still valid, or does it relate
3106 -- to front end ZCX which is being phased out ???
3108 ---------------------------
3109 -- Inlining_Not_Possible --
3110 ---------------------------
3112 function Inlining_Not_Possible
(Subp
: Entity_Id
) return Boolean is
3113 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Subp
);
3117 if Nkind
(Decl
) = N_Subprogram_Body
then
3118 Stats
:= Handled_Statement_Sequence
(Decl
);
3119 return Present
(Exception_Handlers
(Stats
))
3120 or else Present
(At_End_Proc
(Stats
));
3122 elsif Nkind
(Decl
) = N_Subprogram_Declaration
3123 and then Present
(Corresponding_Body
(Decl
))
3125 if Front_End_Inlining
3126 and then Analyzed
(Corresponding_Body
(Decl
))
3128 Error_Msg_N
("pragma appears too late, ignored?", N
);
3131 -- If the subprogram is a renaming as body, the body is
3132 -- just a call to the renamed subprogram, and inlining is
3133 -- trivially possible.
3136 Nkind
(Unit_Declaration_Node
(Corresponding_Body
(Decl
)))
3137 = N_Subprogram_Renaming_Declaration
3143 Handled_Statement_Sequence
3144 (Unit_Declaration_Node
(Corresponding_Body
(Decl
)));
3147 Present
(Exception_Handlers
(Stats
))
3148 or else Present
(At_End_Proc
(Stats
));
3152 -- If body is not available, assume the best, the check is
3153 -- performed again when compiling enclosing package bodies.
3157 end Inlining_Not_Possible
;
3163 procedure Make_Inline
(Subp
: Entity_Id
) is
3164 Kind
: constant Entity_Kind
:= Ekind
(Subp
);
3165 Inner_Subp
: Entity_Id
:= Subp
;
3168 if Etype
(Subp
) = Any_Type
then
3171 -- If inlining is not possible, for now do not treat as an error
3173 elsif Inlining_Not_Possible
(Subp
) then
3177 -- Here we have a candidate for inlining, but we must exclude
3178 -- derived operations. Otherwise we will end up trying to
3179 -- inline a phantom declaration, and the result would be to
3180 -- drag in a body which has no direct inlining associated with
3181 -- it. That would not only be inefficient but would also result
3182 -- in the backend doing cross-unit inlining in cases where it
3183 -- was definitely inappropriate to do so.
3185 -- However, a simple Comes_From_Source test is insufficient,
3186 -- since we do want to allow inlining of generic instances,
3187 -- which also do not come from source. Predefined operators do
3188 -- not come from source but are not inlineable either.
3190 elsif not Comes_From_Source
(Subp
)
3191 and then not Is_Generic_Instance
(Subp
)
3192 and then Scope
(Subp
) /= Standard_Standard
3197 -- The referenced entity must either be the enclosing entity,
3198 -- or an entity declared within the current open scope.
3200 elsif Present
(Scope
(Subp
))
3201 and then Scope
(Subp
) /= Current_Scope
3202 and then Subp
/= Current_Scope
3205 ("argument of% must be entity in current scope", Assoc
);
3209 -- Processing for procedure, operator or function.
3210 -- If subprogram is aliased (as for an instance) indicate
3211 -- that the renamed entity (if declared in the same unit)
3214 if Is_Subprogram
(Subp
) then
3215 while Present
(Alias
(Inner_Subp
)) loop
3216 Inner_Subp
:= Alias
(Inner_Subp
);
3219 if In_Same_Source_Unit
(Subp
, Inner_Subp
) then
3220 Set_Inline_Flags
(Inner_Subp
);
3222 Decl
:= Parent
(Parent
(Inner_Subp
));
3224 if Nkind
(Decl
) = N_Subprogram_Declaration
3225 and then Present
(Corresponding_Body
(Decl
))
3227 Set_Inline_Flags
(Corresponding_Body
(Decl
));
3233 -- For a generic subprogram set flag as well, for use at
3234 -- the point of instantiation, to determine whether the
3235 -- body should be generated.
3237 elsif Is_Generic_Subprogram
(Subp
) then
3238 Set_Inline_Flags
(Subp
);
3241 -- Literals are by definition inlined
3243 elsif Kind
= E_Enumeration_Literal
then
3246 -- Anything else is an error
3250 ("expect subprogram name for pragma%", Assoc
);
3254 ----------------------
3255 -- Set_Inline_Flags --
3256 ----------------------
3258 procedure Set_Inline_Flags
(Subp
: Entity_Id
) is
3261 Set_Is_Inlined
(Subp
, True);
3264 if not Has_Pragma_Inline
(Subp
) then
3265 Set_Has_Pragma_Inline
(Subp
);
3266 Set_Next_Rep_Item
(N
, First_Rep_Item
(Subp
));
3267 Set_First_Rep_Item
(Subp
, N
);
3270 end Set_Inline_Flags
;
3272 -- Start of processing for Process_Inline
3275 Check_No_Identifiers
;
3276 Check_At_Least_N_Arguments
(1);
3279 Inline_Processing_Required
:= True;
3283 while Present
(Assoc
) loop
3284 Subp_Id
:= Expression
(Assoc
);
3288 if Is_Entity_Name
(Subp_Id
) then
3289 Subp
:= Entity
(Subp_Id
);
3291 if Subp
= Any_Id
then
3297 while Present
(Homonym
(Subp
))
3298 and then Scope
(Homonym
(Subp
)) = Current_Scope
3300 Make_Inline
(Homonym
(Subp
));
3301 Subp
:= Homonym
(Subp
);
3308 ("inappropriate argument for pragma%", Assoc
);
3311 and then Warn_On_Redundant_Constructs
3313 if Inlining_Not_Possible
(Subp
) then
3315 ("pragma Inline for& is ignored?", N
, Entity
(Subp_Id
));
3318 ("pragma Inline for& is redundant?", N
, Entity
(Subp_Id
));
3326 ----------------------------
3327 -- Process_Interface_Name --
3328 ----------------------------
3330 procedure Process_Interface_Name
3331 (Subprogram_Def
: Entity_Id
;
3337 String_Val
: String_Id
;
3339 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
);
3340 -- SN is a string literal node for an interface name. This routine
3341 -- performs some minimal checks that the name is reasonable. In
3342 -- particular that no spaces or other obviously incorrect characters
3343 -- appear. This is only a warning, since any characters are allowed.
3345 ----------------------------------
3346 -- Check_Form_Of_Interface_Name --
3347 ----------------------------------
3349 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
) is
3350 S
: constant String_Id
:= Strval
(Expr_Value_S
(SN
));
3351 SL
: constant Nat
:= String_Length
(S
);
3356 Error_Msg_N
("interface name cannot be null string", SN
);
3359 for J
in 1 .. SL
loop
3360 C
:= Get_String_Char
(S
, J
);
3362 if Warn_On_Export_Import
3363 and then (not In_Character_Range
(C
)
3364 or else Get_Character
(C
) = ' '
3365 or else Get_Character
(C
) = ',')
3368 ("?interface name contains illegal character", SN
);
3371 end Check_Form_Of_Interface_Name
;
3373 -- Start of processing for Process_Interface_Name
3376 if No
(Link_Arg
) then
3377 if No
(Ext_Arg
) then
3380 elsif Chars
(Ext_Arg
) = Name_Link_Name
then
3382 Link_Nam
:= Expression
(Ext_Arg
);
3385 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
3386 Ext_Nam
:= Expression
(Ext_Arg
);
3391 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
3392 Check_Optional_Identifier
(Link_Arg
, Name_Link_Name
);
3393 Ext_Nam
:= Expression
(Ext_Arg
);
3394 Link_Nam
:= Expression
(Link_Arg
);
3397 -- Check expressions for external name and link name are static
3399 if Present
(Ext_Nam
) then
3400 Check_Arg_Is_Static_Expression
(Ext_Nam
, Standard_String
);
3401 Check_Form_Of_Interface_Name
(Ext_Nam
);
3403 -- Verify that the external name is not the name of a local
3404 -- entity, which would hide the imported one and lead to
3405 -- run-time surprises. The problem can only arise for entities
3406 -- declared in a package body (otherwise the external name is
3407 -- fully qualified and won't conflict).
3415 if Prag_Id
= Pragma_Import
then
3416 String_To_Name_Buffer
(Strval
(Expr_Value_S
(Ext_Nam
)));
3418 E
:= Entity_Id
(Get_Name_Table_Info
(Nam
));
3420 if Nam
/= Chars
(Subprogram_Def
)
3421 and then Present
(E
)
3422 and then not Is_Overloadable
(E
)
3423 and then Is_Immediately_Visible
(E
)
3424 and then not Is_Imported
(E
)
3425 and then Ekind
(Scope
(E
)) = E_Package
3429 while Present
(Par
) loop
3430 if Nkind
(Par
) = N_Package_Body
then
3431 Error_Msg_Sloc
:= Sloc
(E
);
3433 ("imported entity is hidden by & declared#",
3438 Par
:= Parent
(Par
);
3445 if Present
(Link_Nam
) then
3446 Check_Arg_Is_Static_Expression
(Link_Nam
, Standard_String
);
3447 Check_Form_Of_Interface_Name
(Link_Nam
);
3450 -- If there is no link name, just set the external name
3452 if No
(Link_Nam
) then
3453 Link_Nam
:= Adjust_External_Name_Case
(Expr_Value_S
(Ext_Nam
));
3455 -- For the Link_Name case, the given literal is preceded by an
3456 -- asterisk, which indicates to GCC that the given name should
3457 -- be taken literally, and in particular that no prepending of
3458 -- underlines should occur, even in systems where this is the
3463 Store_String_Char
(Get_Char_Code
('*'));
3464 String_Val
:= Strval
(Expr_Value_S
(Link_Nam
));
3466 for J
in 1 .. String_Length
(String_Val
) loop
3467 Store_String_Char
(Get_String_Char
(String_Val
, J
));
3471 Make_String_Literal
(Sloc
(Link_Nam
), End_String
);
3474 Set_Encoded_Interface_Name
3475 (Get_Base_Subprogram
(Subprogram_Def
), Link_Nam
);
3476 Check_Duplicated_Export_Name
(Link_Nam
);
3477 end Process_Interface_Name
;
3479 -----------------------------------------
3480 -- Process_Interrupt_Or_Attach_Handler --
3481 -----------------------------------------
3483 procedure Process_Interrupt_Or_Attach_Handler
is
3484 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
3485 Handler_Proc
: constant Entity_Id
:= Entity
(Arg1_X
);
3486 Proc_Scope
: constant Entity_Id
:= Scope
(Handler_Proc
);
3489 Set_Is_Interrupt_Handler
(Handler_Proc
);
3491 -- If the pragma is not associated with a handler procedure
3492 -- within a protected type, then it must be for a nonprotected
3493 -- procedure for the AAMP target, in which case we don't
3494 -- associate a representation item with the procedure's scope.
3496 if Ekind
(Proc_Scope
) = E_Protected_Type
then
3497 if Prag_Id
= Pragma_Interrupt_Handler
3499 Prag_Id
= Pragma_Attach_Handler
3501 Record_Rep_Item
(Proc_Scope
, N
);
3504 end Process_Interrupt_Or_Attach_Handler
;
3506 --------------------------------------------------
3507 -- Process_Restrictions_Or_Restriction_Warnings --
3508 --------------------------------------------------
3510 -- Note: some of the simple identifier cases were handled in par-prag,
3511 -- but it is harmless (and more straightforward) to simply handle all
3512 -- cases here, even if it means we repeat a bit of work in some cases.
3514 procedure Process_Restrictions_Or_Restriction_Warnings
is
3516 R_Id
: Restriction_Id
;
3521 procedure Check_Unit_Name
(N
: Node_Id
);
3522 -- Checks unit name parameter for No_Dependence. Returns if it has
3523 -- an appropriate form, otherwise raises pragma argument error.
3525 procedure Set_Warning
(R
: All_Restrictions
);
3526 -- If this is a Restriction_Warnings pragma, set warning flag,
3527 -- otherwise reset the flag.
3529 ---------------------
3530 -- Check_Unit_Name --
3531 ---------------------
3533 procedure Check_Unit_Name
(N
: Node_Id
) is
3535 if Nkind
(N
) = N_Selected_Component
then
3536 Check_Unit_Name
(Prefix
(N
));
3537 Check_Unit_Name
(Selector_Name
(N
));
3539 elsif Nkind
(N
) = N_Identifier
then
3544 ("wrong form for unit name for No_Dependence", N
);
3546 end Check_Unit_Name
;
3552 procedure Set_Warning
(R
: All_Restrictions
) is
3554 if Prag_Id
= Pragma_Restriction_Warnings
then
3555 Restriction_Warnings
(R
) := True;
3557 Restriction_Warnings
(R
) := False;
3561 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
3564 Check_Ada_83_Warning
;
3565 Check_At_Least_N_Arguments
(1);
3566 Check_Valid_Configuration_Pragma
;
3569 while Present
(Arg
) loop
3571 Expr
:= Expression
(Arg
);
3573 -- Case of no restriction identifier present
3575 if Id
= No_Name
then
3576 if Nkind
(Expr
) /= N_Identifier
then
3578 ("invalid form for restriction", Arg
);
3583 (Process_Restriction_Synonyms
(Expr
));
3585 if R_Id
not in All_Boolean_Restrictions
then
3587 ("invalid restriction identifier", Arg
);
3590 if Implementation_Restriction
(R_Id
) then
3592 (No_Implementation_Restrictions
, Arg
);
3595 Set_Restriction
(R_Id
, N
);
3598 -- A very special case that must be processed here:
3599 -- pragma Restrictions (No_Exceptions) turns off
3600 -- all run-time checking. This is a bit dubious in
3601 -- terms of the formal language definition, but it
3602 -- is what is intended by RM H.4(12).
3604 if R_Id
= No_Exceptions
then
3605 Scope_Suppress
:= (others => True);
3608 -- Case of No_Dependence => unit-name. Note that the parser
3609 -- already made the necessary entry in the No_Dependence table.
3611 elsif Id
= Name_No_Dependence
then
3612 Check_Unit_Name
(Expr
);
3614 -- All other cases of restriction identifier present
3617 R_Id
:= Get_Restriction_Id
(Process_Restriction_Synonyms
(Arg
));
3618 Analyze_And_Resolve
(Expr
, Any_Integer
);
3620 if R_Id
not in All_Parameter_Restrictions
then
3622 ("invalid restriction parameter identifier", Arg
);
3624 elsif not Is_OK_Static_Expression
(Expr
) then
3625 Flag_Non_Static_Expr
3626 ("value must be static expression!", Expr
);
3629 elsif not Is_Integer_Type
(Etype
(Expr
))
3630 or else Expr_Value
(Expr
) < 0
3633 ("value must be non-negative integer", Arg
);
3635 -- Restriction pragma is active
3638 Val
:= Expr_Value
(Expr
);
3640 if not UI_Is_In_Int_Range
(Val
) then
3642 ("pragma ignored, value too large?", Arg
);
3644 Set_Restriction
(R_Id
, N
, Integer (UI_To_Int
(Val
)));
3652 end Process_Restrictions_Or_Restriction_Warnings
;
3654 ---------------------------------
3655 -- Process_Suppress_Unsuppress --
3656 ---------------------------------
3658 -- Note: this procedure makes entries in the check suppress data
3659 -- structures managed by Sem. See spec of package Sem for full
3660 -- details on how we handle recording of check suppression.
3662 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean) is
3667 In_Package_Spec
: constant Boolean :=
3668 (Ekind
(Current_Scope
) = E_Package
3670 Ekind
(Current_Scope
) = E_Generic_Package
)
3671 and then not In_Package_Body
(Current_Scope
);
3673 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
);
3674 -- Used to suppress a single check on the given entity
3676 --------------------------------
3677 -- Suppress_Unsuppress_Echeck --
3678 --------------------------------
3680 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
) is
3681 ESR
: constant Entity_Check_Suppress_Record
:=
3684 Suppress
=> Suppress_Case
);
3687 Set_Checks_May_Be_Suppressed
(E
);
3689 if In_Package_Spec
then
3690 Global_Entity_Suppress
.Append
(ESR
);
3692 Local_Entity_Suppress
.Append
(ESR
);
3695 -- If this is a first subtype, and the base type is distinct,
3696 -- then also set the suppress flags on the base type.
3698 if Is_First_Subtype
(E
)
3699 and then Etype
(E
) /= E
3701 Suppress_Unsuppress_Echeck
(Etype
(E
), C
);
3703 end Suppress_Unsuppress_Echeck
;
3705 -- Start of processing for Process_Suppress_Unsuppress
3708 -- Suppress/Unsuppress can appear as a configuration pragma,
3709 -- or in a declarative part or a package spec (RM 11.5(5))
3711 if not Is_Configuration_Pragma
then
3712 Check_Is_In_Decl_Part_Or_Package_Spec
;
3715 Check_At_Least_N_Arguments
(1);
3716 Check_At_Most_N_Arguments
(2);
3717 Check_No_Identifier
(Arg1
);
3718 Check_Arg_Is_Identifier
(Arg1
);
3720 if not Is_Check_Name
(Chars
(Expression
(Arg1
))) then
3722 ("argument of pragma% is not valid check name", Arg1
);
3724 C
:= Get_Check_Id
(Chars
(Expression
(Arg1
)));
3727 if Arg_Count
= 1 then
3729 -- Make an entry in the local scope suppress table. This is the
3730 -- table that directly shows the current value of the scope
3731 -- suppress check for any check id value.
3733 if C
= All_Checks
then
3734 for J
in Scope_Suppress
'Range loop
3735 Scope_Suppress
(J
) := Suppress_Case
;
3738 Scope_Suppress
(C
) := Suppress_Case
;
3741 -- Also make an entry in the Local_Entity_Suppress table. See
3742 -- extended description in the package spec of Sem for details.
3744 Local_Entity_Suppress
.Append
3747 Suppress
=> Suppress_Case
));
3749 -- Case of two arguments present, where the check is
3750 -- suppressed for a specified entity (given as the second
3751 -- argument of the pragma)
3754 Check_Optional_Identifier
(Arg2
, Name_On
);
3755 E_Id
:= Expression
(Arg2
);
3758 if not Is_Entity_Name
(E_Id
) then
3760 ("second argument of pragma% must be entity name", Arg2
);
3769 -- Enforce RM 11.5(7) which requires that for a pragma that
3770 -- appears within a package spec, the named entity must be
3771 -- within the package spec. We allow the package name itself
3772 -- to be mentioned since that makes sense, although it is not
3773 -- strictly allowed by 11.5(7).
3776 and then E
/= Current_Scope
3777 and then Scope
(E
) /= Current_Scope
3780 ("entity in pragma% is not in package spec ('R'M 11.5(7))",
3784 -- Loop through homonyms. As noted below, in the case of a package
3785 -- spec, only homonyms within the package spec are considered.
3788 Suppress_Unsuppress_Echeck
(E
, C
);
3790 if Is_Generic_Instance
(E
)
3791 and then Is_Subprogram
(E
)
3792 and then Present
(Alias
(E
))
3794 Suppress_Unsuppress_Echeck
(Alias
(E
), C
);
3797 -- Move to next homonym
3802 -- If we are within a package specification, the
3803 -- pragma only applies to homonyms in the same scope.
3805 exit when In_Package_Spec
3806 and then Scope
(E
) /= Current_Scope
;
3809 end Process_Suppress_Unsuppress
;
3815 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
) is
3817 if Is_Imported
(E
) then
3819 ("cannot export entity& that was previously imported", Arg
);
3821 elsif Present
(Address_Clause
(E
)) then
3823 ("cannot export entity& that has an address clause", Arg
);
3826 Set_Is_Exported
(E
);
3828 -- Generate a reference for entity explicitly, because the
3829 -- identifier may be overloaded and name resolution will not
3832 Generate_Reference
(E
, Arg
);
3834 -- Deal with exporting non-library level entity
3836 if not Is_Library_Level_Entity
(E
) then
3838 -- Not allowed at all for subprograms
3840 if Is_Subprogram
(E
) then
3841 Error_Pragma_Arg
("local subprogram& cannot be exported", Arg
);
3843 -- Otherwise set public and statically allocated
3847 Set_Is_Statically_Allocated
(E
);
3849 -- Warn if the corresponding W flag is set and the pragma
3850 -- comes from source. The latter may not be true e.g. on
3851 -- VMS where we expand export pragmas for exception codes
3852 -- associated with imported or exported exceptions. We do
3853 -- not want to generate a warning for something that the
3854 -- user did not write.
3856 if Warn_On_Export_Import
3857 and then Comes_From_Source
(Arg
)
3860 ("?& has been made static as a result of Export", Arg
, E
);
3862 ("\this usage is non-standard and non-portable", Arg
);
3867 if Warn_On_Export_Import
and then Is_Type
(E
) then
3869 ("exporting a type has no effect?", Arg
, E
);
3872 if Warn_On_Export_Import
and Inside_A_Generic
then
3874 ("all instances of& will have the same external name?", Arg
, E
);
3878 ----------------------------------------------
3879 -- Set_Extended_Import_Export_External_Name --
3880 ----------------------------------------------
3882 procedure Set_Extended_Import_Export_External_Name
3883 (Internal_Ent
: Entity_Id
;
3884 Arg_External
: Node_Id
)
3886 Old_Name
: constant Node_Id
:= Interface_Name
(Internal_Ent
);
3890 if No
(Arg_External
) then
3894 Check_Arg_Is_External_Name
(Arg_External
);
3896 if Nkind
(Arg_External
) = N_String_Literal
then
3897 if String_Length
(Strval
(Arg_External
)) = 0 then
3900 New_Name
:= Adjust_External_Name_Case
(Arg_External
);
3903 elsif Nkind
(Arg_External
) = N_Identifier
then
3904 New_Name
:= Get_Default_External_Name
(Arg_External
);
3906 -- Check_Arg_Is_External_Name should let through only
3907 -- identifiers and string literals or static string
3908 -- expressions (which are folded to string literals).
3911 raise Program_Error
;
3914 -- If we already have an external name set (by a prior normal
3915 -- Import or Export pragma), then the external names must match
3917 if Present
(Interface_Name
(Internal_Ent
)) then
3918 Check_Matching_Internal_Names
: declare
3919 S1
: constant String_Id
:= Strval
(Old_Name
);
3920 S2
: constant String_Id
:= Strval
(New_Name
);
3923 -- Called if names do not match
3929 procedure Mismatch
is
3931 Error_Msg_Sloc
:= Sloc
(Old_Name
);
3933 ("external name does not match that given #",
3937 -- Start of processing for Check_Matching_Internal_Names
3940 if String_Length
(S1
) /= String_Length
(S2
) then
3944 for J
in 1 .. String_Length
(S1
) loop
3945 if Get_String_Char
(S1
, J
) /= Get_String_Char
(S2
, J
) then
3950 end Check_Matching_Internal_Names
;
3952 -- Otherwise set the given name
3955 Set_Encoded_Interface_Name
(Internal_Ent
, New_Name
);
3956 Check_Duplicated_Export_Name
(New_Name
);
3958 end Set_Extended_Import_Export_External_Name
;
3964 procedure Set_Imported
(E
: Entity_Id
) is
3966 Error_Msg_Sloc
:= Sloc
(E
);
3968 if Is_Exported
(E
) or else Is_Imported
(E
) then
3969 Error_Msg_NE
("import of& declared# not allowed", N
, E
);
3971 if Is_Exported
(E
) then
3972 Error_Msg_N
("\entity was previously exported", N
);
3974 Error_Msg_N
("\entity was previously imported", N
);
3977 Error_Pragma
("\(pragma% applies to all previous entities)");
3980 Set_Is_Imported
(E
);
3982 -- If the entity is an object that is not at the library
3983 -- level, then it is statically allocated. We do not worry
3984 -- about objects with address clauses in this context since
3985 -- they are not really imported in the linker sense.
3988 and then not Is_Library_Level_Entity
(E
)
3989 and then No
(Address_Clause
(E
))
3991 Set_Is_Statically_Allocated
(E
);
3996 -------------------------
3997 -- Set_Mechanism_Value --
3998 -------------------------
4000 -- Note: the mechanism name has not been analyzed (and cannot indeed
4001 -- be analyzed, since it is semantic nonsense), so we get it in the
4002 -- exact form created by the parser.
4004 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
) is
4008 procedure Bad_Class
;
4009 -- Signal bad descriptor class name
4011 procedure Bad_Mechanism
;
4012 -- Signal bad mechanism name
4018 procedure Bad_Class
is
4020 Error_Pragma_Arg
("unrecognized descriptor class name", Class
);
4023 -------------------------
4024 -- Bad_Mechanism_Value --
4025 -------------------------
4027 procedure Bad_Mechanism
is
4029 Error_Pragma_Arg
("unrecognized mechanism name", Mech_Name
);
4032 -- Start of processing for Set_Mechanism_Value
4035 if Mechanism
(Ent
) /= Default_Mechanism
then
4037 ("mechanism for & has already been set", Mech_Name
, Ent
);
4040 -- MECHANISM_NAME ::= value | reference | descriptor
4042 if Nkind
(Mech_Name
) = N_Identifier
then
4043 if Chars
(Mech_Name
) = Name_Value
then
4044 Set_Mechanism
(Ent
, By_Copy
);
4047 elsif Chars
(Mech_Name
) = Name_Reference
then
4048 Set_Mechanism
(Ent
, By_Reference
);
4051 elsif Chars
(Mech_Name
) = Name_Descriptor
then
4052 Check_VMS
(Mech_Name
);
4053 Set_Mechanism
(Ent
, By_Descriptor
);
4056 elsif Chars
(Mech_Name
) = Name_Copy
then
4058 ("bad mechanism name, Value assumed", Mech_Name
);
4064 -- MECHANISM_NAME ::= descriptor (CLASS_NAME)
4065 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4067 -- Note: this form is parsed as an indexed component
4069 elsif Nkind
(Mech_Name
) = N_Indexed_Component
then
4070 Class
:= First
(Expressions
(Mech_Name
));
4072 if Nkind
(Prefix
(Mech_Name
)) /= N_Identifier
4073 or else Chars
(Prefix
(Mech_Name
)) /= Name_Descriptor
4074 or else Present
(Next
(Class
))
4079 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME)
4080 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4082 -- Note: this form is parsed as a function call
4084 elsif Nkind
(Mech_Name
) = N_Function_Call
then
4086 Param
:= First
(Parameter_Associations
(Mech_Name
));
4088 if Nkind
(Name
(Mech_Name
)) /= N_Identifier
4089 or else Chars
(Name
(Mech_Name
)) /= Name_Descriptor
4090 or else Present
(Next
(Param
))
4091 or else No
(Selector_Name
(Param
))
4092 or else Chars
(Selector_Name
(Param
)) /= Name_Class
4096 Class
:= Explicit_Actual_Parameter
(Param
);
4103 -- Fall through here with Class set to descriptor class name
4105 Check_VMS
(Mech_Name
);
4107 if Nkind
(Class
) /= N_Identifier
then
4110 elsif Chars
(Class
) = Name_UBS
then
4111 Set_Mechanism
(Ent
, By_Descriptor_UBS
);
4113 elsif Chars
(Class
) = Name_UBSB
then
4114 Set_Mechanism
(Ent
, By_Descriptor_UBSB
);
4116 elsif Chars
(Class
) = Name_UBA
then
4117 Set_Mechanism
(Ent
, By_Descriptor_UBA
);
4119 elsif Chars
(Class
) = Name_S
then
4120 Set_Mechanism
(Ent
, By_Descriptor_S
);
4122 elsif Chars
(Class
) = Name_SB
then
4123 Set_Mechanism
(Ent
, By_Descriptor_SB
);
4125 elsif Chars
(Class
) = Name_A
then
4126 Set_Mechanism
(Ent
, By_Descriptor_A
);
4128 elsif Chars
(Class
) = Name_NCA
then
4129 Set_Mechanism
(Ent
, By_Descriptor_NCA
);
4134 end Set_Mechanism_Value
;
4136 ---------------------------
4137 -- Set_Ravenscar_Profile --
4138 ---------------------------
4140 -- The tasks to be done here are
4142 -- Set required policies
4144 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4145 -- pragma Locking_Policy (Ceiling_Locking)
4147 -- Set Detect_Blocking mode
4149 -- Set required restrictions (see System.Rident for detailed list)
4151 procedure Set_Ravenscar_Profile
(N
: Node_Id
) is
4153 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4155 if Task_Dispatching_Policy
/= ' '
4156 and then Task_Dispatching_Policy
/= 'F'
4158 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
4159 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4161 -- Set the FIFO_Within_Priorities policy, but always
4162 -- preserve System_Location since we like the error
4163 -- message with the run time name.
4166 Task_Dispatching_Policy
:= 'F';
4168 if Task_Dispatching_Policy_Sloc
/= System_Location
then
4169 Task_Dispatching_Policy_Sloc
:= Loc
;
4173 -- pragma Locking_Policy (Ceiling_Locking)
4175 if Locking_Policy
/= ' '
4176 and then Locking_Policy
/= 'C'
4178 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
4179 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4181 -- Set the Ceiling_Locking policy, but always preserve
4182 -- System_Location since we like the error message with the
4186 Locking_Policy
:= 'C';
4188 if Locking_Policy_Sloc
/= System_Location
then
4189 Locking_Policy_Sloc
:= Loc
;
4193 -- pragma Detect_Blocking
4195 Detect_Blocking
:= True;
4197 -- Set the corresponding restrictions
4199 Set_Profile_Restrictions
(Ravenscar
, N
, Warn
=> False);
4200 end Set_Ravenscar_Profile
;
4202 -- Start of processing for Analyze_Pragma
4205 if not Is_Pragma_Name
(Chars
(N
)) then
4206 if Warn_On_Unrecognized_Pragma
then
4207 Error_Pragma
("unrecognized pragma%!?");
4212 Prag_Id
:= Get_Pragma_Id
(Chars
(N
));
4222 if Present
(Pragma_Argument_Associations
(N
)) then
4223 Arg1
:= First
(Pragma_Argument_Associations
(N
));
4225 if Present
(Arg1
) then
4226 Arg2
:= Next
(Arg1
);
4228 if Present
(Arg2
) then
4229 Arg3
:= Next
(Arg2
);
4231 if Present
(Arg3
) then
4232 Arg4
:= Next
(Arg3
);
4238 -- Count number of arguments
4245 while Present
(Arg_Node
) loop
4246 Arg_Count
:= Arg_Count
+ 1;
4251 -- An enumeration type defines the pragmas that are supported by the
4252 -- implementation. Get_Pragma_Id (in package Prag) transorms a name
4253 -- into the corresponding enumeration value for the following case.
4261 -- pragma Abort_Defer;
4263 when Pragma_Abort_Defer
=>
4265 Check_Arg_Count
(0);
4267 -- The only required semantic processing is to check the
4268 -- placement. This pragma must appear at the start of the
4269 -- statement sequence of a handled sequence of statements.
4271 if Nkind
(Parent
(N
)) /= N_Handled_Sequence_Of_Statements
4272 or else N
/= First
(Statements
(Parent
(N
)))
4283 -- Note: this pragma also has some specific processing in Par.Prag
4284 -- because we want to set the Ada version mode during parsing.
4286 when Pragma_Ada_83
=>
4288 Ada_Version
:= Ada_83
;
4289 Check_Arg_Count
(0);
4297 -- Note: this pragma also has some specific processing in Par.Prag
4298 -- because we want to set the Ada 83 version mode during parsing.
4300 when Pragma_Ada_95
=>
4302 Ada_Version
:= Ada_95
;
4303 Check_Arg_Count
(0);
4310 -- pragma Ada_05 (LOCAL_NAME);
4312 -- Note: this pragma also has some specific processing in Par.Prag
4313 -- because we want to set the Ada 2005 version mode during parsing.
4315 when Pragma_Ada_05
=> declare
4321 if Arg_Count
= 1 then
4322 Check_Arg_Is_Local_Name
(Arg1
);
4323 E_Id
:= Expression
(Arg1
);
4325 if Etype
(E_Id
) = Any_Type
then
4329 Set_Is_Ada_2005
(Entity
(E_Id
));
4332 Ada_Version
:= Ada_05
;
4333 Check_Arg_Count
(0);
4337 ----------------------
4338 -- All_Calls_Remote --
4339 ----------------------
4341 -- pragma All_Calls_Remote [(library_package_NAME)];
4343 when Pragma_All_Calls_Remote
=> All_Calls_Remote
: declare
4344 Lib_Entity
: Entity_Id
;
4347 Check_Ada_83_Warning
;
4348 Check_Valid_Library_Unit_Pragma
;
4350 if Nkind
(N
) = N_Null_Statement
then
4354 Lib_Entity
:= Find_Lib_Unit_Name
;
4356 -- This pragma should only apply to a RCI unit (RM E.2.3(23)).
4358 if Present
(Lib_Entity
)
4359 and then not Debug_Flag_U
4361 if not Is_Remote_Call_Interface
(Lib_Entity
) then
4362 Error_Pragma
("pragma% only apply to rci unit");
4364 -- Set flag for entity of the library unit
4367 Set_Has_All_Calls_Remote
(Lib_Entity
);
4371 end All_Calls_Remote
;
4377 -- pragma Annotate (IDENTIFIER {, ARG});
4378 -- ARG ::= NAME | EXPRESSION
4380 when Pragma_Annotate
=> Annotate
: begin
4382 Check_At_Least_N_Arguments
(1);
4383 Check_Arg_Is_Identifier
(Arg1
);
4386 Arg
: Node_Id
:= Arg2
;
4390 while Present
(Arg
) loop
4391 Exp
:= Expression
(Arg
);
4394 if Is_Entity_Name
(Exp
) then
4397 elsif Nkind
(Exp
) = N_String_Literal
then
4398 Resolve
(Exp
, Standard_String
);
4400 elsif Is_Overloaded
(Exp
) then
4401 Error_Pragma_Arg
("ambiguous argument for pragma%", Exp
);
4416 -- pragma Assert (Boolean_EXPRESSION [, static_string_EXPRESSION]);
4418 when Pragma_Assert
=>
4420 Check_No_Identifiers
;
4422 if Arg_Count
> 1 then
4423 Check_Arg_Count
(2);
4424 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
4427 -- If expansion is active and assertions are inactive, then
4428 -- we rewrite the Assertion as:
4430 -- if False and then condition then
4434 -- The reason we do this rewriting during semantic analysis
4435 -- rather than as part of normal expansion is that we cannot
4436 -- analyze and expand the code for the boolean expression
4437 -- directly, or it may cause insertion of actions that would
4438 -- escape the attempt to suppress the assertion code.
4440 if Expander_Active
and not Assertions_Enabled
then
4442 Make_If_Statement
(Loc
,
4445 Left_Opnd
=> New_Occurrence_Of
(Standard_False
, Loc
),
4446 Right_Opnd
=> Get_Pragma_Arg
(Arg1
)),
4447 Then_Statements
=> New_List
(
4448 Make_Null_Statement
(Loc
))));
4452 -- Otherwise (if assertions are enabled, or if we are not
4453 -- operating with expansion active), then we just analyze
4454 -- and resolve the expression.
4457 Analyze_And_Resolve
(Expression
(Arg1
), Any_Boolean
);
4464 -- pragma AST_Entry (entry_IDENTIFIER);
4466 when Pragma_AST_Entry
=> AST_Entry
: declare
4472 Check_Arg_Count
(1);
4473 Check_No_Identifiers
;
4474 Check_Arg_Is_Local_Name
(Arg1
);
4475 Ent
:= Entity
(Expression
(Arg1
));
4477 -- Note: the implementation of the AST_Entry pragma could handle
4478 -- the entry family case fine, but for now we are consistent with
4479 -- the DEC rules, and do not allow the pragma, which of course
4480 -- has the effect of also forbidding the attribute.
4482 if Ekind
(Ent
) /= E_Entry
then
4484 ("pragma% argument must be simple entry name", Arg1
);
4486 elsif Is_AST_Entry
(Ent
) then
4488 ("duplicate % pragma for entry", Arg1
);
4490 elsif Has_Homonym
(Ent
) then
4492 ("pragma% argument cannot specify overloaded entry", Arg1
);
4496 FF
: constant Entity_Id
:= First_Formal
(Ent
);
4499 if Present
(FF
) then
4500 if Present
(Next_Formal
(FF
)) then
4502 ("entry for pragma% can have only one argument",
4505 elsif Parameter_Mode
(FF
) /= E_In_Parameter
then
4507 ("entry parameter for pragma% must have mode IN",
4513 Set_Is_AST_Entry
(Ent
);
4521 -- pragma Asynchronous (LOCAL_NAME);
4523 when Pragma_Asynchronous
=> Asynchronous
: declare
4531 procedure Process_Async_Pragma
;
4532 -- Common processing for procedure and access-to-procedure case
4534 --------------------------
4535 -- Process_Async_Pragma --
4536 --------------------------
4538 procedure Process_Async_Pragma
is
4540 if not Present
(L
) then
4541 Set_Is_Asynchronous
(Nm
);
4545 -- The formals should be of mode IN (RM E.4.1(6))
4548 while Present
(S
) loop
4549 Formal
:= Defining_Identifier
(S
);
4551 if Nkind
(Formal
) = N_Defining_Identifier
4552 and then Ekind
(Formal
) /= E_In_Parameter
4555 ("pragma% procedure can only have IN parameter",
4562 Set_Is_Asynchronous
(Nm
);
4563 end Process_Async_Pragma
;
4565 -- Start of processing for pragma Asynchronous
4568 Check_Ada_83_Warning
;
4569 Check_No_Identifiers
;
4570 Check_Arg_Count
(1);
4571 Check_Arg_Is_Local_Name
(Arg1
);
4573 if Debug_Flag_U
then
4577 C_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
4578 Analyze
(Expression
(Arg1
));
4579 Nm
:= Entity
(Expression
(Arg1
));
4581 if not Is_Remote_Call_Interface
(C_Ent
)
4582 and then not Is_Remote_Types
(C_Ent
)
4584 -- This pragma should only appear in an RCI or Remote Types
4585 -- unit (RM E.4.1(4))
4588 ("pragma% not in Remote_Call_Interface or " &
4589 "Remote_Types unit");
4592 if Ekind
(Nm
) = E_Procedure
4593 and then Nkind
(Parent
(Nm
)) = N_Procedure_Specification
4595 if not Is_Remote_Call_Interface
(Nm
) then
4597 ("pragma% cannot be applied on non-remote procedure",
4601 L
:= Parameter_Specifications
(Parent
(Nm
));
4602 Process_Async_Pragma
;
4605 elsif Ekind
(Nm
) = E_Function
then
4607 ("pragma% cannot be applied to function", Arg1
);
4609 elsif Is_Remote_Access_To_Subprogram_Type
(Nm
) then
4611 if Is_Record_Type
(Nm
) then
4612 -- A record type that is the Equivalent_Type for
4613 -- a remote access-to-subprogram type.
4615 N
:= Declaration_Node
(Corresponding_Remote_Type
(Nm
));
4618 -- A non-expanded RAS type (case where distribution is
4621 N
:= Declaration_Node
(Nm
);
4624 if Nkind
(N
) = N_Full_Type_Declaration
4625 and then Nkind
(Type_Definition
(N
)) =
4626 N_Access_Procedure_Definition
4628 L
:= Parameter_Specifications
(Type_Definition
(N
));
4629 Process_Async_Pragma
;
4631 if Is_Asynchronous
(Nm
)
4632 and then Expander_Active
4633 and then Get_PCS_Name
/= Name_No_DSA
4635 RACW_Type_Is_Asynchronous
(Underlying_RACW_Type
(Nm
));
4640 ("pragma% cannot reference access-to-function type",
4644 -- Only other possibility is Access-to-class-wide type
4646 elsif Is_Access_Type
(Nm
)
4647 and then Is_Class_Wide_Type
(Designated_Type
(Nm
))
4649 Check_First_Subtype
(Arg1
);
4650 Set_Is_Asynchronous
(Nm
);
4651 if Expander_Active
then
4652 RACW_Type_Is_Asynchronous
(Nm
);
4656 Error_Pragma_Arg
("inappropriate argument for pragma%", Arg1
);
4664 -- pragma Atomic (LOCAL_NAME);
4666 when Pragma_Atomic
=>
4667 Process_Atomic_Shared_Volatile
;
4669 -----------------------
4670 -- Atomic_Components --
4671 -----------------------
4673 -- pragma Atomic_Components (array_LOCAL_NAME);
4675 -- This processing is shared by Volatile_Components
4677 when Pragma_Atomic_Components |
4678 Pragma_Volatile_Components
=>
4680 Atomic_Components
: declare
4687 Check_Ada_83_Warning
;
4688 Check_No_Identifiers
;
4689 Check_Arg_Count
(1);
4690 Check_Arg_Is_Local_Name
(Arg1
);
4691 E_Id
:= Expression
(Arg1
);
4693 if Etype
(E_Id
) = Any_Type
then
4699 if Rep_Item_Too_Early
(E
, N
)
4701 Rep_Item_Too_Late
(E
, N
)
4706 D
:= Declaration_Node
(E
);
4709 if (K
= N_Full_Type_Declaration
and then Is_Array_Type
(E
))
4711 ((Ekind
(E
) = E_Constant
or else Ekind
(E
) = E_Variable
)
4712 and then Nkind
(D
) = N_Object_Declaration
4713 and then Nkind
(Object_Definition
(D
)) =
4714 N_Constrained_Array_Definition
)
4716 -- The flag is set on the object, or on the base type
4718 if Nkind
(D
) /= N_Object_Declaration
then
4722 Set_Has_Volatile_Components
(E
);
4724 if Prag_Id
= Pragma_Atomic_Components
then
4725 Set_Has_Atomic_Components
(E
);
4727 if Is_Packed
(E
) then
4728 Set_Is_Packed
(E
, False);
4731 ("?Pack canceled, cannot pack atomic components",
4737 Error_Pragma_Arg
("inappropriate entity for pragma%", Arg1
);
4739 end Atomic_Components
;
4741 --------------------
4742 -- Attach_Handler --
4743 --------------------
4745 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
4747 when Pragma_Attach_Handler
=>
4748 Check_Ada_83_Warning
;
4749 Check_No_Identifiers
;
4750 Check_Arg_Count
(2);
4752 if No_Run_Time_Mode
then
4753 Error_Msg_CRT
("Attach_Handler pragma", N
);
4755 Check_Interrupt_Or_Attach_Handler
;
4757 -- The expression that designates the attribute may
4758 -- depend on a discriminant, and is therefore a per-
4759 -- object expression, to be expanded in the init proc.
4760 -- If expansion is enabled, perform semantic checks
4763 if Expander_Active
then
4765 Temp
: constant Node_Id
:=
4766 New_Copy_Tree
(Expression
(Arg2
));
4768 Set_Parent
(Temp
, N
);
4769 Pre_Analyze_And_Resolve
(Temp
, RTE
(RE_Interrupt_ID
));
4773 Analyze
(Expression
(Arg2
));
4774 Resolve
(Expression
(Arg2
), RTE
(RE_Interrupt_ID
));
4777 Process_Interrupt_Or_Attach_Handler
;
4780 --------------------
4781 -- C_Pass_By_Copy --
4782 --------------------
4784 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
4786 when Pragma_C_Pass_By_Copy
=> C_Pass_By_Copy
: declare
4792 Check_Valid_Configuration_Pragma
;
4793 Check_Arg_Count
(1);
4794 Check_Optional_Identifier
(Arg1
, "max_size");
4796 Arg
:= Expression
(Arg1
);
4797 Check_Arg_Is_Static_Expression
(Arg
, Any_Integer
);
4799 Val
:= Expr_Value
(Arg
);
4803 ("maximum size for pragma% must be positive", Arg1
);
4805 elsif UI_Is_In_Int_Range
(Val
) then
4806 Default_C_Record_Mechanism
:= UI_To_Int
(Val
);
4808 -- If a giant value is given, Int'Last will do well enough.
4809 -- If sometime someone complains that a record larger than
4810 -- two gigabytes is not copied, we will worry about it then!
4813 Default_C_Record_Mechanism
:= Mechanism_Type
'Last;
4821 -- pragma Comment (static_string_EXPRESSION)
4823 -- Processing for pragma Comment shares the circuitry for
4824 -- pragma Ident. The only differences are that Ident enforces
4825 -- a limit of 31 characters on its argument, and also enforces
4826 -- limitations on placement for DEC compatibility. Pragma
4827 -- Comment shares neither of these restrictions.
4833 -- pragma Common_Object (
4834 -- [Internal =>] LOCAL_NAME,
4835 -- [, [External =>] EXTERNAL_SYMBOL]
4836 -- [, [Size =>] EXTERNAL_SYMBOL]);
4838 -- Processing for this pragma is shared with Psect_Object
4840 --------------------------
4841 -- Compile_Time_Warning --
4842 --------------------------
4844 -- pragma Compile_Time_Warning
4845 -- (boolean_EXPRESSION, static_string_EXPRESSION);
4847 when Pragma_Compile_Time_Warning
=> Compile_Time_Warning
: declare
4848 Arg1x
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
4852 Check_Arg_Count
(2);
4853 Check_No_Identifiers
;
4854 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
4855 Analyze_And_Resolve
(Arg1x
, Standard_Boolean
);
4857 if Compile_Time_Known_Value
(Arg1x
) then
4858 if Is_True
(Expr_Value
(Get_Pragma_Arg
(Arg1
))) then
4859 String_To_Name_Buffer
(Strval
(Get_Pragma_Arg
(Arg2
)));
4860 Add_Char_To_Name_Buffer
('?');
4863 Msg
: String (1 .. Name_Len
) :=
4864 Name_Buffer
(1 .. Name_Len
);
4869 -- This loop looks for multiple lines separated by
4870 -- ASCII.LF and breaks them into continuation error
4871 -- messages marked with the usual back slash.
4874 for S
in 2 .. Msg
'Length - 1 loop
4875 if Msg
(S
) = ASCII
.LF
then
4877 Error_Msg_N
(Msg
(B
.. S
), Arg1
);
4883 Error_Msg_N
(Msg
(B
.. Msg
'Length), Arg1
);
4887 end Compile_Time_Warning
;
4889 ----------------------------
4890 -- Complex_Representation --
4891 ----------------------------
4893 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
4895 when Pragma_Complex_Representation
=> Complex_Representation
: declare
4902 Check_Arg_Count
(1);
4903 Check_Optional_Identifier
(Arg1
, Name_Entity
);
4904 Check_Arg_Is_Local_Name
(Arg1
);
4905 E_Id
:= Expression
(Arg1
);
4907 if Etype
(E_Id
) = Any_Type
then
4913 if not Is_Record_Type
(E
) then
4915 ("argument for pragma% must be record type", Arg1
);
4918 Ent
:= First_Entity
(E
);
4921 or else No
(Next_Entity
(Ent
))
4922 or else Present
(Next_Entity
(Next_Entity
(Ent
)))
4923 or else not Is_Floating_Point_Type
(Etype
(Ent
))
4924 or else Etype
(Ent
) /= Etype
(Next_Entity
(Ent
))
4927 ("record for pragma% must have two fields of same fpt type",
4931 Set_Has_Complex_Representation
(Base_Type
(E
));
4933 end Complex_Representation
;
4935 -------------------------
4936 -- Component_Alignment --
4937 -------------------------
4939 -- pragma Component_Alignment (
4940 -- [Form =>] ALIGNMENT_CHOICE
4941 -- [, [Name =>] type_LOCAL_NAME]);
4943 -- ALIGNMENT_CHOICE ::=
4945 -- | Component_Size_4
4949 when Pragma_Component_Alignment
=> Component_AlignmentP
: declare
4950 Args
: Args_List
(1 .. 2);
4951 Names
: constant Name_List
(1 .. 2) := (
4955 Form
: Node_Id
renames Args
(1);
4956 Name
: Node_Id
renames Args
(2);
4958 Atype
: Component_Alignment_Kind
;
4963 Gather_Associations
(Names
, Args
);
4966 Error_Pragma
("missing Form argument for pragma%");
4969 Check_Arg_Is_Identifier
(Form
);
4971 -- Get proper alignment, note that Default = Component_Size
4972 -- on all machines we have so far, and we want to set this
4973 -- value rather than the default value to indicate that it
4974 -- has been explicitly set (and thus will not get overridden
4975 -- by the default component alignment for the current scope)
4977 if Chars
(Form
) = Name_Component_Size
then
4978 Atype
:= Calign_Component_Size
;
4980 elsif Chars
(Form
) = Name_Component_Size_4
then
4981 Atype
:= Calign_Component_Size_4
;
4983 elsif Chars
(Form
) = Name_Default
then
4984 Atype
:= Calign_Component_Size
;
4986 elsif Chars
(Form
) = Name_Storage_Unit
then
4987 Atype
:= Calign_Storage_Unit
;
4991 ("invalid Form parameter for pragma%", Form
);
4994 -- Case with no name, supplied, affects scope table entry
4998 (Scope_Stack
.Last
).Component_Alignment_Default
:= Atype
;
5000 -- Case of name supplied
5003 Check_Arg_Is_Local_Name
(Name
);
5005 Typ
:= Entity
(Name
);
5008 or else Rep_Item_Too_Early
(Typ
, N
)
5012 Typ
:= Underlying_Type
(Typ
);
5015 if not Is_Record_Type
(Typ
)
5016 and then not Is_Array_Type
(Typ
)
5019 ("Name parameter of pragma% must identify record or " &
5020 "array type", Name
);
5023 -- An explicit Component_Alignment pragma overrides an
5024 -- implicit pragma Pack, but not an explicit one.
5026 if not Has_Pragma_Pack
(Base_Type
(Typ
)) then
5027 Set_Is_Packed
(Base_Type
(Typ
), False);
5028 Set_Component_Alignment
(Base_Type
(Typ
), Atype
);
5031 end Component_AlignmentP
;
5037 -- pragma Controlled (first_subtype_LOCAL_NAME);
5039 when Pragma_Controlled
=> Controlled
: declare
5043 Check_No_Identifiers
;
5044 Check_Arg_Count
(1);
5045 Check_Arg_Is_Local_Name
(Arg1
);
5046 Arg
:= Expression
(Arg1
);
5048 if not Is_Entity_Name
(Arg
)
5049 or else not Is_Access_Type
(Entity
(Arg
))
5051 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
5053 Set_Has_Pragma_Controlled
(Base_Type
(Entity
(Arg
)));
5061 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
5062 -- [Entity =>] LOCAL_NAME);
5064 when Pragma_Convention
=> Convention
: declare
5068 Check_Ada_83_Warning
;
5069 Check_Arg_Count
(2);
5070 Process_Convention
(C
, E
);
5073 ---------------------------
5074 -- Convention_Identifier --
5075 ---------------------------
5077 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
5078 -- [Convention =>] convention_IDENTIFIER);
5080 when Pragma_Convention_Identifier
=> Convention_Identifier
: declare
5086 Check_Arg_Count
(2);
5087 Check_Optional_Identifier
(Arg1
, Name_Name
);
5088 Check_Optional_Identifier
(Arg2
, Name_Convention
);
5089 Check_Arg_Is_Identifier
(Arg1
);
5090 Check_Arg_Is_Identifier
(Arg1
);
5091 Idnam
:= Chars
(Expression
(Arg1
));
5092 Cname
:= Chars
(Expression
(Arg2
));
5094 if Is_Convention_Name
(Cname
) then
5095 Record_Convention_Identifier
5096 (Idnam
, Get_Convention_Id
(Cname
));
5099 ("second arg for % pragma must be convention", Arg2
);
5101 end Convention_Identifier
;
5107 -- pragma CPP_Class ([Entity =>] local_NAME)
5109 when Pragma_CPP_Class
=> CPP_Class
: declare
5112 Default_DTC
: Entity_Id
:= Empty
;
5113 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
5119 Check_Arg_Count
(1);
5120 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5121 Check_Arg_Is_Local_Name
(Arg1
);
5123 Arg
:= Expression
(Arg1
);
5126 if Etype
(Arg
) = Any_Type
then
5130 if not Is_Entity_Name
(Arg
)
5131 or else not Is_Type
(Entity
(Arg
))
5133 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
5136 Typ
:= Entity
(Arg
);
5138 if not Is_Record_Type
(Typ
) then
5139 Error_Pragma_Arg
("pragma% applicable to a record, "
5140 & "tagged record or record extension", Arg1
);
5143 Default_DTC
:= First_Component
(Typ
);
5144 while Present
(Default_DTC
)
5145 and then Etype
(Default_DTC
) /= VTP_Type
5147 Next_Component
(Default_DTC
);
5150 -- Case of non tagged type
5152 if not Is_Tagged_Type
(Typ
) then
5153 Set_Is_CPP_Class
(Typ
);
5155 if Present
(Default_DTC
) then
5157 ("only tagged records can contain vtable pointers", Arg1
);
5160 -- Case of tagged type with no vtable ptr
5162 -- What is test for Typ = Root_Typ (Typ) about here ???
5164 elsif Is_Tagged_Type
(Typ
)
5165 and then Typ
= Root_Type
(Typ
)
5166 and then No
(Default_DTC
)
5169 ("a cpp_class must contain a vtable pointer", Arg1
);
5171 -- Tagged type that has a vtable ptr
5173 elsif Present
(Default_DTC
) then
5174 Set_Is_CPP_Class
(Typ
);
5175 Set_Is_Limited_Record
(Typ
);
5176 Set_Is_Tag
(Default_DTC
);
5177 Set_DT_Entry_Count
(Default_DTC
, No_Uint
);
5179 -- Since a CPP type has no direct link to its associated tag
5180 -- most tags checks cannot be performed
5182 Set_Kill_Tag_Checks
(Typ
);
5183 Set_Kill_Tag_Checks
(Class_Wide_Type
(Typ
));
5185 -- Get rid of the _tag component when there was one.
5186 -- It is only useful for regular tagged types
5188 if Expander_Active
and then Typ
= Root_Type
(Typ
) then
5190 Tag_C
:= First_Tag_Component
(Typ
);
5191 C
:= First_Entity
(Typ
);
5194 Set_First_Entity
(Typ
, Next_Entity
(Tag_C
));
5197 while Next_Entity
(C
) /= Tag_C
loop
5201 Set_Next_Entity
(C
, Next_Entity
(Tag_C
));
5207 ---------------------
5208 -- CPP_Constructor --
5209 ---------------------
5211 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
5213 when Pragma_CPP_Constructor
=> CPP_Constructor
: declare
5219 Check_Arg_Count
(1);
5220 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5221 Check_Arg_Is_Local_Name
(Arg1
);
5223 Id
:= Expression
(Arg1
);
5224 Find_Program_Unit_Name
(Id
);
5226 -- If we did not find the name, we are done
5228 if Etype
(Id
) = Any_Type
then
5232 Def_Id
:= Entity
(Id
);
5234 if Ekind
(Def_Id
) = E_Function
5235 and then Is_Class_Wide_Type
(Etype
(Def_Id
))
5236 and then Is_CPP_Class
(Etype
(Etype
(Def_Id
)))
5238 -- What the heck is this??? this pragma allows only 1 arg
5240 if Arg_Count
>= 2 then
5241 Check_At_Most_N_Arguments
(3);
5242 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
5245 if No
(Parameter_Specifications
(Parent
(Def_Id
))) then
5246 Set_Has_Completion
(Def_Id
);
5247 Set_Is_Constructor
(Def_Id
);
5250 ("non-default constructors not implemented", Arg1
);
5255 ("pragma% requires function returning a 'C'P'P_Class type",
5258 end CPP_Constructor
;
5264 -- pragma CPP_Virtual
5265 -- [Entity =>] LOCAL_NAME
5266 -- [ [Vtable_Ptr =>] LOCAL_NAME,
5267 -- [Position =>] static_integer_EXPRESSION]);
5269 when Pragma_CPP_Virtual
=> CPP_Virtual
: declare
5273 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
5280 if Arg_Count
= 3 then
5281 Check_Optional_Identifier
(Arg2
, "vtable_ptr");
5283 -- We allow Entry_Count as well as Position for the third
5284 -- parameter for back compatibility with versions of GNAT
5285 -- before version 3.12. The documentation has always said
5286 -- Position, but the code up to 3.12 said Entry_Count.
5288 if Chars
(Arg3
) /= Name_Position
then
5289 Check_Optional_Identifier
(Arg3
, "entry_count");
5293 Check_Arg_Count
(1);
5296 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5297 Check_Arg_Is_Local_Name
(Arg1
);
5299 -- First argument must be a subprogram name
5301 Arg
:= Expression
(Arg1
);
5302 Find_Program_Unit_Name
(Arg
);
5304 if Etype
(Arg
) = Any_Type
then
5307 Subp
:= Entity
(Arg
);
5310 if not (Is_Subprogram
(Subp
)
5311 and then Is_Dispatching_Operation
(Subp
))
5314 ("pragma% must reference a primitive operation", Arg1
);
5317 Typ
:= Find_Dispatching_Type
(Subp
);
5319 -- If only one Argument defaults are :
5320 -- . DTC_Entity is the default Vtable pointer
5321 -- . DT_Position will be set at the freezing point
5323 if Arg_Count
= 1 then
5324 Set_DTC_Entity
(Subp
, First_Tag_Component
(Typ
));
5328 -- Second argument is a component name of type Vtable_Ptr
5330 Arg
:= Expression
(Arg2
);
5332 if Nkind
(Arg
) /= N_Identifier
then
5333 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5337 DTC
:= First_Component
(Typ
);
5338 while Present
(DTC
) and then Chars
(DTC
) /= Chars
(Arg
) loop
5339 Next_Component
(DTC
);
5343 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5346 elsif Etype
(DTC
) /= VTP_Type
then
5347 Wrong_Type
(Arg
, VTP_Type
);
5351 -- Third argument is an integer (DT_Position)
5353 Arg
:= Expression
(Arg3
);
5354 Analyze_And_Resolve
(Arg
, Any_Integer
);
5356 if not Is_Static_Expression
(Arg
) then
5357 Flag_Non_Static_Expr
5358 ("third argument of pragma CPP_Virtual must be static!",
5363 V
:= Expr_Value
(Expression
(Arg3
));
5367 ("third argument of pragma% must be positive",
5371 Set_DTC_Entity
(Subp
, DTC
);
5372 Set_DT_Position
(Subp
, V
);
5381 -- pragma CPP_Vtable (
5382 -- [Entity =>] LOCAL_NAME
5383 -- [Vtable_Ptr =>] LOCAL_NAME,
5384 -- [Entry_Count =>] static_integer_EXPRESSION);
5386 when Pragma_CPP_Vtable
=> CPP_Vtable
: declare
5389 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
5396 Check_Arg_Count
(3);
5397 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5398 Check_Optional_Identifier
(Arg2
, "vtable_ptr");
5399 Check_Optional_Identifier
(Arg3
, "entry_count");
5400 Check_Arg_Is_Local_Name
(Arg1
);
5402 -- First argument is a record type name
5404 Arg
:= Expression
(Arg1
);
5407 if Etype
(Arg
) = Any_Type
then
5410 Typ
:= Entity
(Arg
);
5413 if not (Is_Tagged_Type
(Typ
) and then Is_CPP_Class
(Typ
)) then
5414 Error_Pragma_Arg
("'C'P'P_Class tagged type expected", Arg1
);
5417 -- Second argument is a component name of type Vtable_Ptr
5419 Arg
:= Expression
(Arg2
);
5421 if Nkind
(Arg
) /= N_Identifier
then
5422 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5426 DTC
:= First_Component
(Typ
);
5427 while Present
(DTC
) and then Chars
(DTC
) /= Chars
(Arg
) loop
5428 Next_Component
(DTC
);
5432 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5435 elsif Etype
(DTC
) /= VTP_Type
then
5436 Wrong_Type
(DTC
, VTP_Type
);
5439 -- If it is the first pragma Vtable, This becomes the default tag
5441 elsif (not Is_Tag
(DTC
))
5442 and then DT_Entry_Count
(First_Tag_Component
(Typ
)) = No_Uint
5444 Set_Is_Tag
(First_Tag_Component
(Typ
), False);
5445 Set_Is_Tag
(DTC
, True);
5446 Set_DT_Entry_Count
(DTC
, No_Uint
);
5449 -- Those pragmas must appear before any primitive operation
5450 -- definition (except inherited ones) otherwise the default
5453 Elmt
:= First_Elmt
(Primitive_Operations
(Typ
));
5454 while Present
(Elmt
) loop
5455 if No
(Alias
(Node
(Elmt
))) then
5456 Error_Msg_Sloc
:= Sloc
(Node
(Elmt
));
5458 ("pragma% must appear before this primitive operation");
5464 -- Third argument is an integer (DT_Entry_Count)
5466 Arg
:= Expression
(Arg3
);
5467 Analyze_And_Resolve
(Arg
, Any_Integer
);
5469 if not Is_Static_Expression
(Arg
) then
5470 Flag_Non_Static_Expr
5471 ("entry count for pragma CPP_Vtable must be a static " &
5472 "expression!", Arg3
);
5476 V
:= Expr_Value
(Expression
(Arg3
));
5480 ("entry count for pragma% must be positive", Arg3
);
5482 Set_DT_Entry_Count
(DTC
, V
);
5491 -- pragma Debug (PROCEDURE_CALL_STATEMENT);
5493 when Pragma_Debug
=> Debug
: begin
5496 -- Rewrite into a conditional with a static condition
5498 Rewrite
(N
, Make_Implicit_If_Statement
(N
,
5499 Condition
=> New_Occurrence_Of
(Boolean_Literals
(
5500 Assertions_Enabled
and Expander_Active
), Loc
),
5501 Then_Statements
=> New_List
(
5502 Relocate_Node
(Debug_Statement
(N
)))));
5506 ---------------------
5507 -- Detect_Blocking --
5508 ---------------------
5510 -- pragma Detect_Blocking;
5512 when Pragma_Detect_Blocking
=>
5514 Check_Arg_Count
(0);
5515 Check_Valid_Configuration_Pragma
;
5516 Detect_Blocking
:= True;
5522 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
5524 when Pragma_Discard_Names
=> Discard_Names
: declare
5529 Check_Ada_83_Warning
;
5531 -- Deal with configuration pragma case
5533 if Arg_Count
= 0 and then Is_Configuration_Pragma
then
5534 Global_Discard_Names
:= True;
5537 -- Otherwise, check correct appropriate context
5540 Check_Is_In_Decl_Part_Or_Package_Spec
;
5542 if Arg_Count
= 0 then
5544 -- If there is no parameter, then from now on this pragma
5545 -- applies to any enumeration, exception or tagged type
5546 -- defined in the current declarative part.
5548 Set_Discard_Names
(Current_Scope
);
5552 Check_Arg_Count
(1);
5553 Check_Optional_Identifier
(Arg1
, Name_On
);
5554 Check_Arg_Is_Local_Name
(Arg1
);
5555 E_Id
:= Expression
(Arg1
);
5557 if Etype
(E_Id
) = Any_Type
then
5563 if (Is_First_Subtype
(E
)
5564 and then (Is_Enumeration_Type
(E
)
5565 or else Is_Tagged_Type
(E
)))
5566 or else Ekind
(E
) = E_Exception
5568 Set_Discard_Names
(E
);
5571 ("inappropriate entity for pragma%", Arg1
);
5581 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
5583 when Pragma_Elaborate
=> Elaborate
: declare
5585 Parent_Node
: Node_Id
;
5590 -- Pragma must be in context items list of a compilation unit
5592 if not Is_List_Member
(N
) then
5597 Plist
:= List_Containing
(N
);
5598 Parent_Node
:= Parent
(Plist
);
5600 if Parent_Node
= Empty
5601 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
5602 or else Context_Items
(Parent_Node
) /= Plist
5609 -- Must be at least one argument
5611 if Arg_Count
= 0 then
5612 Error_Pragma
("pragma% requires at least one argument");
5615 -- In Ada 83 mode, there can be no items following it in the
5616 -- context list except other pragmas and implicit with clauses
5617 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
5618 -- placement rule does not apply.
5620 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
5623 while Present
(Citem
) loop
5624 if Nkind
(Citem
) = N_Pragma
5625 or else (Nkind
(Citem
) = N_With_Clause
5626 and then Implicit_With
(Citem
))
5631 ("(Ada 83) pragma% must be at end of context clause");
5638 -- Finally, the arguments must all be units mentioned in a with
5639 -- clause in the same context clause. Note we already checked
5640 -- (in Par.Prag) that the arguments are either identifiers or
5643 Outer
: while Present
(Arg
) loop
5644 Citem
:= First
(Plist
);
5646 Inner
: while Citem
/= N
loop
5647 if Nkind
(Citem
) = N_With_Clause
5648 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
5650 Set_Elaborate_Present
(Citem
, True);
5651 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
5653 -- With the pragma present, elaboration calls on
5654 -- subprograms from the named unit need no further
5655 -- checks, as long as the pragma appears in the current
5656 -- compilation unit. If the pragma appears in some unit
5657 -- in the context, there might still be a need for an
5658 -- Elaborate_All_Desirable from the current compilation
5659 -- to the the named unit, so we keep the check enabled.
5661 if In_Extended_Main_Source_Unit
(N
) then
5662 Set_Suppress_Elaboration_Warnings
5663 (Entity
(Name
(Citem
)));
5673 ("argument of pragma% is not with'ed unit", Arg
);
5679 -- Give a warning if operating in static mode with -gnatwl
5680 -- (elaboration warnings eanbled) switch set.
5682 if Elab_Warnings
and not Dynamic_Elaboration_Checks
then
5684 ("?use of pragma Elaborate may not be safe", N
);
5686 ("?use pragma Elaborate_All instead if possible", N
);
5694 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
5696 when Pragma_Elaborate_All
=> Elaborate_All
: declare
5698 Parent_Node
: Node_Id
;
5703 Check_Ada_83_Warning
;
5705 -- Pragma must be in context items list of a compilation unit
5707 if not Is_List_Member
(N
) then
5712 Plist
:= List_Containing
(N
);
5713 Parent_Node
:= Parent
(Plist
);
5715 if Parent_Node
= Empty
5716 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
5717 or else Context_Items
(Parent_Node
) /= Plist
5724 -- Must be at least one argument
5726 if Arg_Count
= 0 then
5727 Error_Pragma
("pragma% requires at least one argument");
5730 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
5731 -- have to appear at the end of the context clause, but may
5732 -- appear mixed in with other items, even in Ada 83 mode.
5734 -- Final check: the arguments must all be units mentioned in
5735 -- a with clause in the same context clause. Note that we
5736 -- already checked (in Par.Prag) that all the arguments are
5737 -- either identifiers or selected components.
5740 Outr
: while Present
(Arg
) loop
5741 Citem
:= First
(Plist
);
5743 Innr
: while Citem
/= N
loop
5744 if Nkind
(Citem
) = N_With_Clause
5745 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
5747 Set_Elaborate_All_Present
(Citem
, True);
5748 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
5750 -- Suppress warnings and elaboration checks on the named
5751 -- unit if the pragma is in the current compilation, as
5752 -- for pragma Elaborate.
5754 if In_Extended_Main_Source_Unit
(N
) then
5755 Set_Suppress_Elaboration_Warnings
5756 (Entity
(Name
(Citem
)));
5765 Set_Error_Posted
(N
);
5767 ("argument of pragma% is not with'ed unit", Arg
);
5774 --------------------
5775 -- Elaborate_Body --
5776 --------------------
5778 -- pragma Elaborate_Body [( library_unit_NAME )];
5780 when Pragma_Elaborate_Body
=> Elaborate_Body
: declare
5781 Cunit_Node
: Node_Id
;
5782 Cunit_Ent
: Entity_Id
;
5785 Check_Ada_83_Warning
;
5786 Check_Valid_Library_Unit_Pragma
;
5788 if Nkind
(N
) = N_Null_Statement
then
5792 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
5793 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
5795 if Nkind
(Unit
(Cunit_Node
)) = N_Package_Body
5797 Nkind
(Unit
(Cunit_Node
)) = N_Subprogram_Body
5799 Error_Pragma
("pragma% must refer to a spec, not a body");
5801 Set_Body_Required
(Cunit_Node
, True);
5802 Set_Has_Pragma_Elaborate_Body
(Cunit_Ent
);
5804 -- If we are in dynamic elaboration mode, then we suppress
5805 -- elaboration warnings for the unit, since it is definitely
5806 -- fine NOT to do dynamic checks at the first level (and such
5807 -- checks will be suppressed because no elaboration boolean
5808 -- is created for Elaborate_Body packages).
5810 -- But in the static model of elaboration, Elaborate_Body is
5811 -- definitely NOT good enough to ensure elaboration safety on
5812 -- its own, since the body may WITH other units that are not
5813 -- safe from an elaboration point of view, so a client must
5814 -- still do an Elaborate_All on such units.
5816 -- Debug flag -gnatdD restores the old behavior of 3.13,
5817 -- where Elaborate_Body always suppressed elab warnings.
5819 if Dynamic_Elaboration_Checks
or Debug_Flag_DD
then
5820 Set_Suppress_Elaboration_Warnings
(Cunit_Ent
);
5825 ------------------------
5826 -- Elaboration_Checks --
5827 ------------------------
5829 -- pragma Elaboration_Checks (Static | Dynamic);
5831 when Pragma_Elaboration_Checks
=>
5833 Check_Arg_Count
(1);
5834 Check_Arg_Is_One_Of
(Arg1
, Name_Static
, Name_Dynamic
);
5835 Dynamic_Elaboration_Checks
:=
5836 (Chars
(Get_Pragma_Arg
(Arg1
)) = Name_Dynamic
);
5842 -- pragma Eliminate (
5843 -- [Unit_Name =>] IDENTIFIER |
5844 -- SELECTED_COMPONENT
5845 -- [,[Entity =>] IDENTIFIER |
5846 -- SELECTED_COMPONENT |
5848 -- [,]OVERLOADING_RESOLUTION);
5850 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
5853 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
5856 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
5858 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
5859 -- Result_Type => result_SUBTYPE_NAME]
5861 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
5862 -- SUBTYPE_NAME ::= STRING_LITERAL
5864 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
5865 -- SOURCE_TRACE ::= STRING_LITERAL
5867 when Pragma_Eliminate
=> Eliminate
: declare
5868 Args
: Args_List
(1 .. 5);
5869 Names
: constant Name_List
(1 .. 5) := (
5872 Name_Parameter_Types
,
5874 Name_Source_Location
);
5876 Unit_Name
: Node_Id
renames Args
(1);
5877 Entity
: Node_Id
renames Args
(2);
5878 Parameter_Types
: Node_Id
renames Args
(3);
5879 Result_Type
: Node_Id
renames Args
(4);
5880 Source_Location
: Node_Id
renames Args
(5);
5884 Check_Valid_Configuration_Pragma
;
5885 Gather_Associations
(Names
, Args
);
5887 if No
(Unit_Name
) then
5888 Error_Pragma
("missing Unit_Name argument for pragma%");
5892 and then (Present
(Parameter_Types
)
5894 Present
(Result_Type
)
5896 Present
(Source_Location
))
5898 Error_Pragma
("missing Entity argument for pragma%");
5901 if (Present
(Parameter_Types
)
5903 Present
(Result_Type
))
5905 Present
(Source_Location
)
5908 ("parameter profile and source location can not " &
5909 "be used together in pragma%");
5912 Process_Eliminate_Pragma
5921 -------------------------
5922 -- Explicit_Overriding --
5923 -------------------------
5925 when Pragma_Explicit_Overriding
=>
5926 Check_Valid_Configuration_Pragma
;
5927 Check_Arg_Count
(0);
5928 Explicit_Overriding
:= True;
5935 -- [ Convention =>] convention_IDENTIFIER,
5936 -- [ Entity =>] local_NAME
5937 -- [, [External_Name =>] static_string_EXPRESSION ]
5938 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5940 when Pragma_Export
=> Export
: declare
5945 Check_Ada_83_Warning
;
5946 Check_At_Least_N_Arguments
(2);
5947 Check_At_Most_N_Arguments
(4);
5948 Process_Convention
(C
, Def_Id
);
5950 if Ekind
(Def_Id
) /= E_Constant
then
5951 Note_Possible_Modification
(Expression
(Arg2
));
5954 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
5955 Set_Exported
(Def_Id
, Arg2
);
5958 ----------------------
5959 -- Export_Exception --
5960 ----------------------
5962 -- pragma Export_Exception (
5963 -- [Internal =>] LOCAL_NAME,
5964 -- [, [External =>] EXTERNAL_SYMBOL,]
5965 -- [, [Form =>] Ada | VMS]
5966 -- [, [Code =>] static_integer_EXPRESSION]);
5968 when Pragma_Export_Exception
=> Export_Exception
: declare
5969 Args
: Args_List
(1 .. 4);
5970 Names
: constant Name_List
(1 .. 4) := (
5976 Internal
: Node_Id
renames Args
(1);
5977 External
: Node_Id
renames Args
(2);
5978 Form
: Node_Id
renames Args
(3);
5979 Code
: Node_Id
renames Args
(4);
5982 if Inside_A_Generic
then
5983 Error_Pragma
("pragma% cannot be used for generic entities");
5986 Gather_Associations
(Names
, Args
);
5987 Process_Extended_Import_Export_Exception_Pragma
(
5988 Arg_Internal
=> Internal
,
5989 Arg_External
=> External
,
5993 if not Is_VMS_Exception
(Entity
(Internal
)) then
5994 Set_Exported
(Entity
(Internal
), Internal
);
5996 end Export_Exception
;
5998 ---------------------
5999 -- Export_Function --
6000 ---------------------
6002 -- pragma Export_Function (
6003 -- [Internal =>] LOCAL_NAME,
6004 -- [, [External =>] EXTERNAL_SYMBOL,]
6005 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6006 -- [, [Result_Type =>] TYPE_DESIGNATOR]
6007 -- [, [Mechanism =>] MECHANISM]
6008 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
6010 -- EXTERNAL_SYMBOL ::=
6012 -- | static_string_EXPRESSION
6014 -- PARAMETER_TYPES ::=
6016 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6018 -- TYPE_DESIGNATOR ::=
6020 -- | subtype_Name ' Access
6024 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6026 -- MECHANISM_ASSOCIATION ::=
6027 -- [formal_parameter_NAME =>] MECHANISM_NAME
6029 -- MECHANISM_NAME ::=
6032 -- | Descriptor [([Class =>] CLASS_NAME)]
6034 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6036 when Pragma_Export_Function
=> Export_Function
: declare
6037 Args
: Args_List
(1 .. 6);
6038 Names
: constant Name_List
(1 .. 6) := (
6041 Name_Parameter_Types
,
6044 Name_Result_Mechanism
);
6046 Internal
: Node_Id
renames Args
(1);
6047 External
: Node_Id
renames Args
(2);
6048 Parameter_Types
: Node_Id
renames Args
(3);
6049 Result_Type
: Node_Id
renames Args
(4);
6050 Mechanism
: Node_Id
renames Args
(5);
6051 Result_Mechanism
: Node_Id
renames Args
(6);
6055 Gather_Associations
(Names
, Args
);
6056 Process_Extended_Import_Export_Subprogram_Pragma
(
6057 Arg_Internal
=> Internal
,
6058 Arg_External
=> External
,
6059 Arg_Parameter_Types
=> Parameter_Types
,
6060 Arg_Result_Type
=> Result_Type
,
6061 Arg_Mechanism
=> Mechanism
,
6062 Arg_Result_Mechanism
=> Result_Mechanism
);
6063 end Export_Function
;
6069 -- pragma Export_Object (
6070 -- [Internal =>] LOCAL_NAME,
6071 -- [, [External =>] EXTERNAL_SYMBOL]
6072 -- [, [Size =>] EXTERNAL_SYMBOL]);
6074 -- EXTERNAL_SYMBOL ::=
6076 -- | static_string_EXPRESSION
6078 -- PARAMETER_TYPES ::=
6080 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6082 -- TYPE_DESIGNATOR ::=
6084 -- | subtype_Name ' Access
6088 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6090 -- MECHANISM_ASSOCIATION ::=
6091 -- [formal_parameter_NAME =>] MECHANISM_NAME
6093 -- MECHANISM_NAME ::=
6096 -- | Descriptor [([Class =>] CLASS_NAME)]
6098 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6100 when Pragma_Export_Object
=> Export_Object
: declare
6101 Args
: Args_List
(1 .. 3);
6102 Names
: constant Name_List
(1 .. 3) := (
6107 Internal
: Node_Id
renames Args
(1);
6108 External
: Node_Id
renames Args
(2);
6109 Size
: Node_Id
renames Args
(3);
6113 Gather_Associations
(Names
, Args
);
6114 Process_Extended_Import_Export_Object_Pragma
(
6115 Arg_Internal
=> Internal
,
6116 Arg_External
=> External
,
6120 ----------------------
6121 -- Export_Procedure --
6122 ----------------------
6124 -- pragma Export_Procedure (
6125 -- [Internal =>] LOCAL_NAME,
6126 -- [, [External =>] EXTERNAL_SYMBOL,]
6127 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6128 -- [, [Mechanism =>] MECHANISM]);
6130 -- EXTERNAL_SYMBOL ::=
6132 -- | static_string_EXPRESSION
6134 -- PARAMETER_TYPES ::=
6136 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6138 -- TYPE_DESIGNATOR ::=
6140 -- | subtype_Name ' Access
6144 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6146 -- MECHANISM_ASSOCIATION ::=
6147 -- [formal_parameter_NAME =>] MECHANISM_NAME
6149 -- MECHANISM_NAME ::=
6152 -- | Descriptor [([Class =>] CLASS_NAME)]
6154 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6156 when Pragma_Export_Procedure
=> Export_Procedure
: declare
6157 Args
: Args_List
(1 .. 4);
6158 Names
: constant Name_List
(1 .. 4) := (
6161 Name_Parameter_Types
,
6164 Internal
: Node_Id
renames Args
(1);
6165 External
: Node_Id
renames Args
(2);
6166 Parameter_Types
: Node_Id
renames Args
(3);
6167 Mechanism
: Node_Id
renames Args
(4);
6171 Gather_Associations
(Names
, Args
);
6172 Process_Extended_Import_Export_Subprogram_Pragma
(
6173 Arg_Internal
=> Internal
,
6174 Arg_External
=> External
,
6175 Arg_Parameter_Types
=> Parameter_Types
,
6176 Arg_Mechanism
=> Mechanism
);
6177 end Export_Procedure
;
6183 -- pragma Export_Value (
6184 -- [Value =>] static_integer_EXPRESSION,
6185 -- [Link_Name =>] static_string_EXPRESSION);
6187 when Pragma_Export_Value
=>
6189 Check_Arg_Count
(2);
6191 Check_Optional_Identifier
(Arg1
, Name_Value
);
6192 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
6194 Check_Optional_Identifier
(Arg2
, Name_Link_Name
);
6195 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
6197 -----------------------------
6198 -- Export_Valued_Procedure --
6199 -----------------------------
6201 -- pragma Export_Valued_Procedure (
6202 -- [Internal =>] LOCAL_NAME,
6203 -- [, [External =>] EXTERNAL_SYMBOL,]
6204 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6205 -- [, [Mechanism =>] MECHANISM]);
6207 -- EXTERNAL_SYMBOL ::=
6209 -- | static_string_EXPRESSION
6211 -- PARAMETER_TYPES ::=
6213 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6215 -- TYPE_DESIGNATOR ::=
6217 -- | subtype_Name ' Access
6221 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6223 -- MECHANISM_ASSOCIATION ::=
6224 -- [formal_parameter_NAME =>] MECHANISM_NAME
6226 -- MECHANISM_NAME ::=
6229 -- | Descriptor [([Class =>] CLASS_NAME)]
6231 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6233 when Pragma_Export_Valued_Procedure
=>
6234 Export_Valued_Procedure
: declare
6235 Args
: Args_List
(1 .. 4);
6236 Names
: constant Name_List
(1 .. 4) := (
6239 Name_Parameter_Types
,
6242 Internal
: Node_Id
renames Args
(1);
6243 External
: Node_Id
renames Args
(2);
6244 Parameter_Types
: Node_Id
renames Args
(3);
6245 Mechanism
: Node_Id
renames Args
(4);
6249 Gather_Associations
(Names
, Args
);
6250 Process_Extended_Import_Export_Subprogram_Pragma
(
6251 Arg_Internal
=> Internal
,
6252 Arg_External
=> External
,
6253 Arg_Parameter_Types
=> Parameter_Types
,
6254 Arg_Mechanism
=> Mechanism
);
6255 end Export_Valued_Procedure
;
6261 -- pragma Extend_System ([Name =>] Identifier);
6263 when Pragma_Extend_System
=> Extend_System
: declare
6266 Check_Valid_Configuration_Pragma
;
6267 Check_Arg_Count
(1);
6268 Check_Optional_Identifier
(Arg1
, Name_Name
);
6269 Check_Arg_Is_Identifier
(Arg1
);
6271 Get_Name_String
(Chars
(Expression
(Arg1
)));
6274 and then Name_Buffer
(1 .. 4) = "aux_"
6276 if Present
(System_Extend_Pragma_Arg
) then
6277 if Chars
(Expression
(Arg1
)) =
6278 Chars
(Expression
(System_Extend_Pragma_Arg
))
6282 Error_Msg_Sloc
:= Sloc
(System_Extend_Pragma_Arg
);
6283 Error_Pragma
("pragma% conflicts with that at#");
6287 System_Extend_Pragma_Arg
:= Arg1
;
6289 if not GNAT_Mode
then
6290 System_Extend_Unit
:= Arg1
;
6294 Error_Pragma
("incorrect name for pragma%, must be Aux_xxx");
6298 ------------------------
6299 -- Extensions_Allowed --
6300 ------------------------
6302 -- pragma Extensions_Allowed (ON | OFF);
6304 when Pragma_Extensions_Allowed
=>
6306 Check_Arg_Count
(1);
6307 Check_No_Identifiers
;
6308 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
6310 if Chars
(Expression
(Arg1
)) = Name_On
then
6311 Extensions_Allowed
:= True;
6312 Ada_Version
:= Ada_Version_Type
'Last;
6314 Extensions_Allowed
:= False;
6315 Ada_Version
:= Ada_Version_Type
'Min (Ada_Version
, Ada_95
);
6322 -- pragma External (
6323 -- [ Convention =>] convention_IDENTIFIER,
6324 -- [ Entity =>] local_NAME
6325 -- [, [External_Name =>] static_string_EXPRESSION ]
6326 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6328 when Pragma_External
=> External
: declare
6334 Check_At_Least_N_Arguments
(2);
6335 Check_At_Most_N_Arguments
(4);
6336 Process_Convention
(C
, Def_Id
);
6337 Note_Possible_Modification
(Expression
(Arg2
));
6338 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
6339 Set_Exported
(Def_Id
, Arg2
);
6342 --------------------------
6343 -- External_Name_Casing --
6344 --------------------------
6346 -- pragma External_Name_Casing (
6347 -- UPPERCASE | LOWERCASE
6348 -- [, AS_IS | UPPERCASE | LOWERCASE]);
6350 when Pragma_External_Name_Casing
=> External_Name_Casing
: declare
6353 Check_No_Identifiers
;
6355 if Arg_Count
= 2 then
6357 (Arg2
, Name_As_Is
, Name_Uppercase
, Name_Lowercase
);
6359 case Chars
(Get_Pragma_Arg
(Arg2
)) is
6361 Opt
.External_Name_Exp_Casing
:= As_Is
;
6363 when Name_Uppercase
=>
6364 Opt
.External_Name_Exp_Casing
:= Uppercase
;
6366 when Name_Lowercase
=>
6367 Opt
.External_Name_Exp_Casing
:= Lowercase
;
6374 Check_Arg_Count
(1);
6377 Check_Arg_Is_One_Of
(Arg1
, Name_Uppercase
, Name_Lowercase
);
6379 case Chars
(Get_Pragma_Arg
(Arg1
)) is
6380 when Name_Uppercase
=>
6381 Opt
.External_Name_Imp_Casing
:= Uppercase
;
6383 when Name_Lowercase
=>
6384 Opt
.External_Name_Imp_Casing
:= Lowercase
;
6389 end External_Name_Casing
;
6391 ---------------------------
6392 -- Finalize_Storage_Only --
6393 ---------------------------
6395 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
6397 when Pragma_Finalize_Storage_Only
=> Finalize_Storage
: declare
6398 Assoc
: constant Node_Id
:= Arg1
;
6399 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
6403 Check_No_Identifiers
;
6404 Check_Arg_Count
(1);
6405 Check_Arg_Is_Local_Name
(Arg1
);
6407 Find_Type
(Type_Id
);
6408 Typ
:= Entity
(Type_Id
);
6411 or else Rep_Item_Too_Early
(Typ
, N
)
6415 Typ
:= Underlying_Type
(Typ
);
6418 if not Is_Controlled
(Typ
) then
6419 Error_Pragma
("pragma% must specify controlled type");
6422 Check_First_Subtype
(Arg1
);
6424 if Finalize_Storage_Only
(Typ
) then
6425 Error_Pragma
("duplicate pragma%, only one allowed");
6427 elsif not Rep_Item_Too_Late
(Typ
, N
) then
6428 Set_Finalize_Storage_Only
(Base_Type
(Typ
), True);
6430 end Finalize_Storage
;
6432 --------------------------
6433 -- Float_Representation --
6434 --------------------------
6436 -- pragma Float_Representation (VAX_Float | IEEE_Float);
6438 when Pragma_Float_Representation
=> Float_Representation
: declare
6446 if Arg_Count
= 1 then
6447 Check_Valid_Configuration_Pragma
;
6449 Check_Arg_Count
(2);
6450 Check_Optional_Identifier
(Arg2
, Name_Entity
);
6451 Check_Arg_Is_Local_Name
(Arg2
);
6454 Check_No_Identifier
(Arg1
);
6455 Check_Arg_Is_One_Of
(Arg1
, Name_VAX_Float
, Name_IEEE_Float
);
6457 if not OpenVMS_On_Target
then
6458 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6460 ("?pragma% ignored (applies only to Open'V'M'S)");
6466 -- One argument case
6468 if Arg_Count
= 1 then
6470 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6472 if Opt
.Float_Format
= 'I' then
6473 Error_Pragma
("'I'E'E'E format previously specified");
6476 Opt
.Float_Format
:= 'V';
6479 if Opt
.Float_Format
= 'V' then
6480 Error_Pragma
("'V'A'X format previously specified");
6483 Opt
.Float_Format
:= 'I';
6486 Set_Standard_Fpt_Formats
;
6488 -- Two argument case
6491 Argx
:= Get_Pragma_Arg
(Arg2
);
6493 if not Is_Entity_Name
(Argx
)
6494 or else not Is_Floating_Point_Type
(Entity
(Argx
))
6497 ("second argument of% pragma must be floating-point type",
6501 Ent
:= Entity
(Argx
);
6502 Digs
:= UI_To_Int
(Digits_Value
(Ent
));
6504 -- Two arguments, VAX_Float case
6506 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6509 when 6 => Set_F_Float
(Ent
);
6510 when 9 => Set_D_Float
(Ent
);
6511 when 15 => Set_G_Float
(Ent
);
6515 ("wrong digits value, must be 6,9 or 15", Arg2
);
6518 -- Two arguments, IEEE_Float case
6522 when 6 => Set_IEEE_Short
(Ent
);
6523 when 15 => Set_IEEE_Long
(Ent
);
6527 ("wrong digits value, must be 6 or 15", Arg2
);
6531 end Float_Representation
;
6537 -- pragma Ident (static_string_EXPRESSION)
6539 -- Note: pragma Comment shares this processing. Pragma Comment
6540 -- is identical to Ident, except that the restriction of the
6541 -- argument to 31 characters and the placement restrictions
6542 -- are not enforced for pragma Comment.
6544 when Pragma_Ident | Pragma_Comment
=> Ident
: declare
6549 Check_Arg_Count
(1);
6550 Check_No_Identifiers
;
6551 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
6553 -- For pragma Ident, preserve DEC compatibility by requiring
6554 -- the pragma to appear in a declarative part or package spec.
6556 if Prag_Id
= Pragma_Ident
then
6557 Check_Is_In_Decl_Part_Or_Package_Spec
;
6560 Str
:= Expr_Value_S
(Expression
(Arg1
));
6567 GP
:= Parent
(Parent
(N
));
6569 if Nkind
(GP
) = N_Package_Declaration
6571 Nkind
(GP
) = N_Generic_Package_Declaration
6576 -- If we have a compilation unit, then record the ident
6577 -- value, checking for improper duplication.
6579 if Nkind
(GP
) = N_Compilation_Unit
then
6580 CS
:= Ident_String
(Current_Sem_Unit
);
6582 if Present
(CS
) then
6584 -- For Ident, we do not permit multiple instances
6586 if Prag_Id
= Pragma_Ident
then
6587 Error_Pragma
("duplicate% pragma not permitted");
6589 -- For Comment, we concatenate the string, unless we
6590 -- want to preserve the tree structure for ASIS.
6592 elsif not ASIS_Mode
then
6593 Start_String
(Strval
(CS
));
6594 Store_String_Char
(' ');
6595 Store_String_Chars
(Strval
(Str
));
6596 Set_Strval
(CS
, End_String
);
6600 -- In VMS, the effect of IDENT is achieved by passing
6601 -- IDENTIFICATION=name as a --for-linker switch.
6603 if OpenVMS_On_Target
then
6606 ("--for-linker=IDENTIFICATION=");
6607 String_To_Name_Buffer
(Strval
(Str
));
6608 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
6610 -- Only the last processed IDENT is saved. The main
6611 -- purpose is so an IDENT associated with a main
6612 -- procedure will be used in preference to an IDENT
6613 -- associated with a with'd package.
6615 Replace_Linker_Option_String
6616 (End_String
, "--for-linker=IDENTIFICATION=");
6619 Set_Ident_String
(Current_Sem_Unit
, Str
);
6622 -- For subunits, we just ignore the Ident, since in GNAT
6623 -- these are not separate object files, and hence not
6624 -- separate units in the unit table.
6626 elsif Nkind
(GP
) = N_Subunit
then
6629 -- Otherwise we have a misplaced pragma Ident, but we ignore
6630 -- this if we are in an instantiation, since it comes from
6631 -- a generic, and has no relevance to the instantiation.
6633 elsif Prag_Id
= Pragma_Ident
then
6634 if Instantiation_Location
(Loc
) = No_Location
then
6635 Error_Pragma
("pragma% only allowed at outer level");
6646 -- [ Convention =>] convention_IDENTIFIER,
6647 -- [ Entity =>] local_NAME
6648 -- [, [External_Name =>] static_string_EXPRESSION ]
6649 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6651 when Pragma_Import
=>
6652 Check_Ada_83_Warning
;
6653 Check_At_Least_N_Arguments
(2);
6654 Check_At_Most_N_Arguments
(4);
6655 Process_Import_Or_Interface
;
6657 ----------------------
6658 -- Import_Exception --
6659 ----------------------
6661 -- pragma Import_Exception (
6662 -- [Internal =>] LOCAL_NAME,
6663 -- [, [External =>] EXTERNAL_SYMBOL,]
6664 -- [, [Form =>] Ada | VMS]
6665 -- [, [Code =>] static_integer_EXPRESSION]);
6667 when Pragma_Import_Exception
=> Import_Exception
: declare
6668 Args
: Args_List
(1 .. 4);
6669 Names
: constant Name_List
(1 .. 4) := (
6675 Internal
: Node_Id
renames Args
(1);
6676 External
: Node_Id
renames Args
(2);
6677 Form
: Node_Id
renames Args
(3);
6678 Code
: Node_Id
renames Args
(4);
6681 Gather_Associations
(Names
, Args
);
6683 if Present
(External
) and then Present
(Code
) then
6685 ("cannot give both External and Code options for pragma%");
6688 Process_Extended_Import_Export_Exception_Pragma
(
6689 Arg_Internal
=> Internal
,
6690 Arg_External
=> External
,
6694 if not Is_VMS_Exception
(Entity
(Internal
)) then
6695 Set_Imported
(Entity
(Internal
));
6697 end Import_Exception
;
6699 ---------------------
6700 -- Import_Function --
6701 ---------------------
6703 -- pragma Import_Function (
6704 -- [Internal =>] LOCAL_NAME,
6705 -- [, [External =>] EXTERNAL_SYMBOL]
6706 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6707 -- [, [Result_Type =>] SUBTYPE_MARK]
6708 -- [, [Mechanism =>] MECHANISM]
6709 -- [, [Result_Mechanism =>] MECHANISM_NAME]
6710 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6712 -- EXTERNAL_SYMBOL ::=
6714 -- | static_string_EXPRESSION
6716 -- PARAMETER_TYPES ::=
6718 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6720 -- TYPE_DESIGNATOR ::=
6722 -- | subtype_Name ' Access
6726 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6728 -- MECHANISM_ASSOCIATION ::=
6729 -- [formal_parameter_NAME =>] MECHANISM_NAME
6731 -- MECHANISM_NAME ::=
6734 -- | Descriptor [([Class =>] CLASS_NAME)]
6736 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6738 when Pragma_Import_Function
=> Import_Function
: declare
6739 Args
: Args_List
(1 .. 7);
6740 Names
: constant Name_List
(1 .. 7) := (
6743 Name_Parameter_Types
,
6746 Name_Result_Mechanism
,
6747 Name_First_Optional_Parameter
);
6749 Internal
: Node_Id
renames Args
(1);
6750 External
: Node_Id
renames Args
(2);
6751 Parameter_Types
: Node_Id
renames Args
(3);
6752 Result_Type
: Node_Id
renames Args
(4);
6753 Mechanism
: Node_Id
renames Args
(5);
6754 Result_Mechanism
: Node_Id
renames Args
(6);
6755 First_Optional_Parameter
: Node_Id
renames Args
(7);
6759 Gather_Associations
(Names
, Args
);
6760 Process_Extended_Import_Export_Subprogram_Pragma
(
6761 Arg_Internal
=> Internal
,
6762 Arg_External
=> External
,
6763 Arg_Parameter_Types
=> Parameter_Types
,
6764 Arg_Result_Type
=> Result_Type
,
6765 Arg_Mechanism
=> Mechanism
,
6766 Arg_Result_Mechanism
=> Result_Mechanism
,
6767 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
6768 end Import_Function
;
6774 -- pragma Import_Object (
6775 -- [Internal =>] LOCAL_NAME,
6776 -- [, [External =>] EXTERNAL_SYMBOL]
6777 -- [, [Size =>] EXTERNAL_SYMBOL]);
6779 -- EXTERNAL_SYMBOL ::=
6781 -- | static_string_EXPRESSION
6783 when Pragma_Import_Object
=> Import_Object
: declare
6784 Args
: Args_List
(1 .. 3);
6785 Names
: constant Name_List
(1 .. 3) := (
6790 Internal
: Node_Id
renames Args
(1);
6791 External
: Node_Id
renames Args
(2);
6792 Size
: Node_Id
renames Args
(3);
6796 Gather_Associations
(Names
, Args
);
6797 Process_Extended_Import_Export_Object_Pragma
(
6798 Arg_Internal
=> Internal
,
6799 Arg_External
=> External
,
6803 ----------------------
6804 -- Import_Procedure --
6805 ----------------------
6807 -- pragma Import_Procedure (
6808 -- [Internal =>] LOCAL_NAME,
6809 -- [, [External =>] EXTERNAL_SYMBOL]
6810 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6811 -- [, [Mechanism =>] MECHANISM]
6812 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6814 -- EXTERNAL_SYMBOL ::=
6816 -- | static_string_EXPRESSION
6818 -- PARAMETER_TYPES ::=
6820 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6822 -- TYPE_DESIGNATOR ::=
6824 -- | subtype_Name ' Access
6828 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6830 -- MECHANISM_ASSOCIATION ::=
6831 -- [formal_parameter_NAME =>] MECHANISM_NAME
6833 -- MECHANISM_NAME ::=
6836 -- | Descriptor [([Class =>] CLASS_NAME)]
6838 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6840 when Pragma_Import_Procedure
=> Import_Procedure
: declare
6841 Args
: Args_List
(1 .. 5);
6842 Names
: constant Name_List
(1 .. 5) := (
6845 Name_Parameter_Types
,
6847 Name_First_Optional_Parameter
);
6849 Internal
: Node_Id
renames Args
(1);
6850 External
: Node_Id
renames Args
(2);
6851 Parameter_Types
: Node_Id
renames Args
(3);
6852 Mechanism
: Node_Id
renames Args
(4);
6853 First_Optional_Parameter
: Node_Id
renames Args
(5);
6857 Gather_Associations
(Names
, Args
);
6858 Process_Extended_Import_Export_Subprogram_Pragma
(
6859 Arg_Internal
=> Internal
,
6860 Arg_External
=> External
,
6861 Arg_Parameter_Types
=> Parameter_Types
,
6862 Arg_Mechanism
=> Mechanism
,
6863 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
6864 end Import_Procedure
;
6866 -----------------------------
6867 -- Import_Valued_Procedure --
6868 -----------------------------
6870 -- pragma Import_Valued_Procedure (
6871 -- [Internal =>] LOCAL_NAME,
6872 -- [, [External =>] EXTERNAL_SYMBOL]
6873 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6874 -- [, [Mechanism =>] MECHANISM]
6875 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6877 -- EXTERNAL_SYMBOL ::=
6879 -- | static_string_EXPRESSION
6881 -- PARAMETER_TYPES ::=
6883 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6885 -- TYPE_DESIGNATOR ::=
6887 -- | subtype_Name ' Access
6891 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6893 -- MECHANISM_ASSOCIATION ::=
6894 -- [formal_parameter_NAME =>] MECHANISM_NAME
6896 -- MECHANISM_NAME ::=
6899 -- | Descriptor [([Class =>] CLASS_NAME)]
6901 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6903 when Pragma_Import_Valued_Procedure
=>
6904 Import_Valued_Procedure
: declare
6905 Args
: Args_List
(1 .. 5);
6906 Names
: constant Name_List
(1 .. 5) := (
6909 Name_Parameter_Types
,
6911 Name_First_Optional_Parameter
);
6913 Internal
: Node_Id
renames Args
(1);
6914 External
: Node_Id
renames Args
(2);
6915 Parameter_Types
: Node_Id
renames Args
(3);
6916 Mechanism
: Node_Id
renames Args
(4);
6917 First_Optional_Parameter
: Node_Id
renames Args
(5);
6921 Gather_Associations
(Names
, Args
);
6922 Process_Extended_Import_Export_Subprogram_Pragma
(
6923 Arg_Internal
=> Internal
,
6924 Arg_External
=> External
,
6925 Arg_Parameter_Types
=> Parameter_Types
,
6926 Arg_Mechanism
=> Mechanism
,
6927 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
6928 end Import_Valued_Procedure
;
6930 ------------------------
6931 -- Initialize_Scalars --
6932 ------------------------
6934 -- pragma Initialize_Scalars;
6936 when Pragma_Initialize_Scalars
=>
6938 Check_Arg_Count
(0);
6939 Check_Valid_Configuration_Pragma
;
6940 Check_Restriction
(No_Initialize_Scalars
, N
);
6942 if not Restriction_Active
(No_Initialize_Scalars
) then
6943 Init_Or_Norm_Scalars
:= True;
6944 Initialize_Scalars
:= True;
6951 -- pragma Inline ( NAME {, NAME} );
6953 when Pragma_Inline
=>
6955 -- Pragma is active if inlining option is active
6957 Process_Inline
(Inline_Active
);
6963 -- pragma Inline_Always ( NAME {, NAME} );
6965 when Pragma_Inline_Always
=>
6966 Process_Inline
(True);
6968 --------------------
6969 -- Inline_Generic --
6970 --------------------
6972 -- pragma Inline_Generic (NAME {, NAME});
6974 when Pragma_Inline_Generic
=>
6975 Process_Generic_List
;
6977 ----------------------
6978 -- Inspection_Point --
6979 ----------------------
6981 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
6983 when Pragma_Inspection_Point
=> Inspection_Point
: declare
6988 if Arg_Count
> 0 then
6991 Exp
:= Expression
(Arg
);
6994 if not Is_Entity_Name
(Exp
)
6995 or else not Is_Object
(Entity
(Exp
))
6997 Error_Pragma_Arg
("object name required", Arg
);
7004 end Inspection_Point
;
7010 -- pragma Interface (
7011 -- convention_IDENTIFIER,
7014 when Pragma_Interface
=>
7016 Check_Arg_Count
(2);
7017 Check_No_Identifiers
;
7018 Process_Import_Or_Interface
;
7020 --------------------
7021 -- Interface_Name --
7022 --------------------
7024 -- pragma Interface_Name (
7025 -- [ Entity =>] local_NAME
7026 -- [,[External_Name =>] static_string_EXPRESSION ]
7027 -- [,[Link_Name =>] static_string_EXPRESSION ]);
7029 when Pragma_Interface_Name
=> Interface_Name
: declare
7037 Check_At_Least_N_Arguments
(2);
7038 Check_At_Most_N_Arguments
(3);
7039 Id
:= Expression
(Arg1
);
7042 if not Is_Entity_Name
(Id
) then
7044 ("first argument for pragma% must be entity name", Arg1
);
7045 elsif Etype
(Id
) = Any_Type
then
7048 Def_Id
:= Entity
(Id
);
7051 -- Special DEC-compatible processing for the object case,
7052 -- forces object to be imported.
7054 if Ekind
(Def_Id
) = E_Variable
then
7055 Kill_Size_Check_Code
(Def_Id
);
7056 Note_Possible_Modification
(Id
);
7058 -- Initialization is not allowed for imported variable
7060 if Present
(Expression
(Parent
(Def_Id
)))
7061 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
7063 Error_Msg_Sloc
:= Sloc
(Def_Id
);
7065 ("no initialization allowed for declaration of& #",
7069 -- For compatibility, support VADS usage of providing both
7070 -- pragmas Interface and Interface_Name to obtain the effect
7071 -- of a single Import pragma.
7073 if Is_Imported
(Def_Id
)
7074 and then Present
(First_Rep_Item
(Def_Id
))
7075 and then Nkind
(First_Rep_Item
(Def_Id
)) = N_Pragma
7076 and then Chars
(First_Rep_Item
(Def_Id
)) = Name_Interface
7080 Set_Imported
(Def_Id
);
7083 Set_Is_Public
(Def_Id
);
7084 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
7087 -- Otherwise must be subprogram
7089 elsif not Is_Subprogram
(Def_Id
) then
7091 ("argument of pragma% is not subprogram", Arg1
);
7094 Check_At_Most_N_Arguments
(3);
7098 -- Loop through homonyms
7101 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
7103 if Is_Imported
(Def_Id
) then
7104 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
7108 Hom_Id
:= Homonym
(Hom_Id
);
7110 exit when No
(Hom_Id
)
7111 or else Scope
(Hom_Id
) /= Current_Scope
;
7116 ("argument of pragma% is not imported subprogram",
7122 -----------------------
7123 -- Interrupt_Handler --
7124 -----------------------
7126 -- pragma Interrupt_Handler (handler_NAME);
7128 when Pragma_Interrupt_Handler
=>
7129 Check_Ada_83_Warning
;
7130 Check_Arg_Count
(1);
7131 Check_No_Identifiers
;
7133 if No_Run_Time_Mode
then
7134 Error_Msg_CRT
("Interrupt_Handler pragma", N
);
7136 Check_Interrupt_Or_Attach_Handler
;
7137 Process_Interrupt_Or_Attach_Handler
;
7140 ------------------------
7141 -- Interrupt_Priority --
7142 ------------------------
7144 -- pragma Interrupt_Priority [(EXPRESSION)];
7146 when Pragma_Interrupt_Priority
=> Interrupt_Priority
: declare
7147 P
: constant Node_Id
:= Parent
(N
);
7151 Check_Ada_83_Warning
;
7153 if Arg_Count
/= 0 then
7154 Arg
:= Expression
(Arg1
);
7155 Check_Arg_Count
(1);
7156 Check_No_Identifiers
;
7158 -- The expression must be analyzed in the special manner
7159 -- described in "Handling of Default and Per-Object
7160 -- Expressions" in sem.ads.
7162 Analyze_Per_Use_Expression
(Arg
, RTE
(RE_Interrupt_Priority
));
7165 if Nkind
(P
) /= N_Task_Definition
7166 and then Nkind
(P
) /= N_Protected_Definition
7171 elsif Has_Priority_Pragma
(P
) then
7172 Error_Pragma
("duplicate pragma% not allowed");
7175 Set_Has_Priority_Pragma
(P
, True);
7176 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
7178 end Interrupt_Priority
;
7180 ---------------------
7181 -- Interrupt_State --
7182 ---------------------
7184 -- pragma Interrupt_State (
7185 -- [Name =>] INTERRUPT_ID,
7186 -- [State =>] INTERRUPT_STATE);
7188 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
7189 -- INTERRUPT_STATE => System | Runtime | User
7191 -- Note: if the interrupt id is given as an identifier, then
7192 -- it must be one of the identifiers in Ada.Interrupts.Names.
7193 -- Otherwise it is given as a static integer expression which
7194 -- must be in the range of Ada.Interrupts.Interrupt_ID.
7196 when Pragma_Interrupt_State
=> Interrupt_State
: declare
7198 Int_Id
: constant Entity_Id
:= RTE
(RE_Interrupt_ID
);
7199 -- This is the entity Ada.Interrupts.Interrupt_ID;
7201 State_Type
: Character;
7202 -- Set to 's'/'r'/'u' for System/Runtime/User
7205 -- Index to entry in Interrupt_States table
7208 -- Value of interrupt
7210 Arg1X
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
7211 -- The first argument to the pragma
7213 Int_Ent
: Entity_Id
;
7214 -- Interrupt entity in Ada.Interrupts.Names
7218 Check_Arg_Count
(2);
7220 Check_Optional_Identifier
(Arg1
, Name_Name
);
7221 Check_Optional_Identifier
(Arg2
, "state");
7222 Check_Arg_Is_Identifier
(Arg2
);
7224 -- First argument is identifier
7226 if Nkind
(Arg1X
) = N_Identifier
then
7228 -- Search list of names in Ada.Interrupts.Names
7230 Int_Ent
:= First_Entity
(RTE
(RE_Names
));
7232 if No
(Int_Ent
) then
7233 Error_Pragma_Arg
("invalid interrupt name", Arg1
);
7235 elsif Chars
(Int_Ent
) = Chars
(Arg1X
) then
7236 Int_Val
:= Expr_Value
(Constant_Value
(Int_Ent
));
7240 Next_Entity
(Int_Ent
);
7243 -- First argument is not an identifier, so it must be a
7244 -- static expression of type Ada.Interrupts.Interrupt_ID.
7247 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
7248 Int_Val
:= Expr_Value
(Arg1X
);
7250 if Int_Val
< Expr_Value
(Type_Low_Bound
(Int_Id
))
7252 Int_Val
> Expr_Value
(Type_High_Bound
(Int_Id
))
7255 ("value not in range of type " &
7256 """Ada.Interrupts.Interrupt_'I'D""", Arg1
);
7262 case Chars
(Get_Pragma_Arg
(Arg2
)) is
7263 when Name_Runtime
=> State_Type
:= 'r';
7264 when Name_System
=> State_Type
:= 's';
7265 when Name_User
=> State_Type
:= 'u';
7268 Error_Pragma_Arg
("invalid interrupt state", Arg2
);
7271 -- Check if entry is already stored
7273 IST_Num
:= Interrupt_States
.First
;
7275 -- If entry not found, add it
7277 if IST_Num
> Interrupt_States
.Last
then
7278 Interrupt_States
.Append
7279 ((Interrupt_Number
=> UI_To_Int
(Int_Val
),
7280 Interrupt_State
=> State_Type
,
7281 Pragma_Loc
=> Loc
));
7284 -- Case of entry for the same entry
7286 elsif Int_Val
= Interrupt_States
.Table
(IST_Num
).
7289 -- If state matches, done, no need to make redundant entry
7292 State_Type
= Interrupt_States
.Table
(IST_Num
).
7295 -- Otherwise if state does not match, error
7298 Interrupt_States
.Table
(IST_Num
).Pragma_Loc
;
7300 ("state conflicts with that given at #", Arg2
);
7304 IST_Num
:= IST_Num
+ 1;
7306 end Interrupt_State
;
7308 ----------------------
7309 -- Java_Constructor --
7310 ----------------------
7312 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
7314 when Pragma_Java_Constructor
=> Java_Constructor
: declare
7321 Check_Arg_Count
(1);
7322 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7323 Check_Arg_Is_Local_Name
(Arg1
);
7325 Id
:= Expression
(Arg1
);
7326 Find_Program_Unit_Name
(Id
);
7328 -- If we did not find the name, we are done
7330 if Etype
(Id
) = Any_Type
then
7334 Hom_Id
:= Entity
(Id
);
7336 -- Loop through homonyms
7339 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
7341 -- The constructor is required to be a function returning
7342 -- an access type whose designated type has convention Java.
7344 if Ekind
(Def_Id
) = E_Function
7345 and then Ekind
(Etype
(Def_Id
)) in Access_Kind
7348 (Designated_Type
(Etype
(Def_Id
))) = Convention_Java
7351 (Root_Type
(Designated_Type
(Etype
(Def_Id
))))
7354 Set_Is_Constructor
(Def_Id
);
7355 Set_Convention
(Def_Id
, Convention_Java
);
7359 ("pragma% requires function returning a 'Java access type",
7363 Hom_Id
:= Homonym
(Hom_Id
);
7365 exit when No
(Hom_Id
) or else Scope
(Hom_Id
) /= Current_Scope
;
7367 end Java_Constructor
;
7369 ----------------------
7370 -- Java_Interface --
7371 ----------------------
7373 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
7375 when Pragma_Java_Interface
=> Java_Interface
: declare
7381 Check_Arg_Count
(1);
7382 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7383 Check_Arg_Is_Local_Name
(Arg1
);
7385 Arg
:= Expression
(Arg1
);
7388 if Etype
(Arg
) = Any_Type
then
7392 if not Is_Entity_Name
(Arg
)
7393 or else not Is_Type
(Entity
(Arg
))
7395 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
7398 Typ
:= Underlying_Type
(Entity
(Arg
));
7400 -- For now we simply check some of the semantic constraints
7401 -- on the type. This currently leaves out some restrictions
7402 -- on interface types, namely that the parent type must be
7403 -- java.lang.Object.Typ and that all primitives of the type
7404 -- should be declared abstract. ???
7406 if not Is_Tagged_Type
(Typ
) or else not Is_Abstract
(Typ
) then
7407 Error_Pragma_Arg
("pragma% requires an abstract "
7408 & "tagged type", Arg1
);
7410 elsif not Has_Discriminants
(Typ
)
7411 or else Ekind
(Etype
(First_Discriminant
(Typ
)))
7412 /= E_Anonymous_Access_Type
7414 not Is_Class_Wide_Type
7415 (Designated_Type
(Etype
(First_Discriminant
(Typ
))))
7418 ("type must have a class-wide access discriminant", Arg1
);
7426 -- pragma Keep_Names ([On => ] local_NAME);
7428 when Pragma_Keep_Names
=> Keep_Names
: declare
7433 Check_Arg_Count
(1);
7434 Check_Optional_Identifier
(Arg1
, Name_On
);
7435 Check_Arg_Is_Local_Name
(Arg1
);
7437 Arg
:= Expression
(Arg1
);
7440 if Etype
(Arg
) = Any_Type
then
7444 if not Is_Entity_Name
(Arg
)
7445 or else Ekind
(Entity
(Arg
)) /= E_Enumeration_Type
7448 ("pragma% requires a local enumeration type", Arg1
);
7451 Set_Discard_Names
(Entity
(Arg
), False);
7458 -- pragma License (RESTRICTED | UNRESRICTED | GPL | MODIFIED_GPL);
7460 when Pragma_License
=>
7462 Check_Arg_Count
(1);
7463 Check_No_Identifiers
;
7464 Check_Valid_Configuration_Pragma
;
7465 Check_Arg_Is_Identifier
(Arg1
);
7468 Sind
: constant Source_File_Index
:=
7469 Source_Index
(Current_Sem_Unit
);
7472 case Chars
(Get_Pragma_Arg
(Arg1
)) is
7474 Set_License
(Sind
, GPL
);
7476 when Name_Modified_GPL
=>
7477 Set_License
(Sind
, Modified_GPL
);
7479 when Name_Restricted
=>
7480 Set_License
(Sind
, Restricted
);
7482 when Name_Unrestricted
=>
7483 Set_License
(Sind
, Unrestricted
);
7486 Error_Pragma_Arg
("invalid license name", Arg1
);
7494 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
7496 when Pragma_Link_With
=> Link_With
: declare
7502 if Operating_Mode
= Generate_Code
7503 and then In_Extended_Main_Source_Unit
(N
)
7505 Check_At_Least_N_Arguments
(1);
7506 Check_No_Identifiers
;
7507 Check_Is_In_Decl_Part_Or_Package_Spec
;
7508 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7512 while Present
(Arg
) loop
7513 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
7515 -- Store argument, converting sequences of spaces
7516 -- to a single null character (this is one of the
7517 -- differences in processing between Link_With
7518 -- and Linker_Options).
7521 C
: constant Char_Code
:= Get_Char_Code
(' ');
7522 S
: constant String_Id
:=
7523 Strval
(Expr_Value_S
(Expression
(Arg
)));
7524 L
: constant Nat
:= String_Length
(S
);
7527 procedure Skip_Spaces
;
7528 -- Advance F past any spaces
7530 procedure Skip_Spaces
is
7532 while F
<= L
and then Get_String_Char
(S
, F
) = C
loop
7538 Skip_Spaces
; -- skip leading spaces
7540 -- Loop through characters, changing any embedded
7541 -- sequence of spaces to a single null character
7542 -- (this is how Link_With/Linker_Options differ)
7545 if Get_String_Char
(S
, F
) = C
then
7548 Store_String_Char
(ASCII
.NUL
);
7551 Store_String_Char
(Get_String_Char
(S
, F
));
7559 if Present
(Arg
) then
7560 Store_String_Char
(ASCII
.NUL
);
7564 Store_Linker_Option_String
(End_String
);
7572 -- pragma Linker_Alias (
7573 -- [Entity =>] LOCAL_NAME
7574 -- [Alias =>] static_string_EXPRESSION);
7576 when Pragma_Linker_Alias
=>
7578 Check_Arg_Count
(2);
7579 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7580 Check_Optional_Identifier
(Arg2
, "alias");
7581 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
7582 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7584 -- The only processing required is to link this item on to the
7585 -- list of rep items for the given entity. This is accomplished
7586 -- by the call to Rep_Item_Too_Late (when no error is detected
7587 -- and False is returned).
7589 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
7592 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7595 --------------------
7596 -- Linker_Options --
7597 --------------------
7599 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
7601 when Pragma_Linker_Options
=> Linker_Options
: declare
7605 Check_Ada_83_Warning
;
7606 Check_No_Identifiers
;
7607 Check_Arg_Count
(1);
7608 Check_Is_In_Decl_Part_Or_Package_Spec
;
7610 if Operating_Mode
= Generate_Code
7611 and then In_Extended_Main_Source_Unit
(N
)
7613 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7614 Start_String
(Strval
(Expr_Value_S
(Expression
(Arg1
))));
7617 while Present
(Arg
) loop
7618 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
7619 Store_String_Char
(ASCII
.NUL
);
7621 (Strval
(Expr_Value_S
(Expression
(Arg
))));
7625 Store_Linker_Option_String
(End_String
);
7629 --------------------
7630 -- Linker_Section --
7631 --------------------
7633 -- pragma Linker_Section (
7634 -- [Entity =>] LOCAL_NAME
7635 -- [Section =>] static_string_EXPRESSION);
7637 when Pragma_Linker_Section
=>
7639 Check_Arg_Count
(2);
7640 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7641 Check_Optional_Identifier
(Arg2
, Name_Section
);
7642 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
7643 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7645 -- The only processing required is to link this item on to the
7646 -- list of rep items for the given entity. This is accomplished
7647 -- by the call to Rep_Item_Too_Late (when no error is detected
7648 -- and False is returned).
7650 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
7653 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7660 -- pragma List (On | Off)
7662 -- There is nothing to do here, since we did all the processing
7663 -- for this pragma in Par.Prag (so that it works properly even in
7664 -- syntax only mode)
7669 --------------------
7670 -- Locking_Policy --
7671 --------------------
7673 -- pragma Locking_Policy (policy_IDENTIFIER);
7675 when Pragma_Locking_Policy
=> declare
7679 Check_Ada_83_Warning
;
7680 Check_Arg_Count
(1);
7681 Check_No_Identifiers
;
7682 Check_Arg_Is_Locking_Policy
(Arg1
);
7683 Check_Valid_Configuration_Pragma
;
7684 Get_Name_String
(Chars
(Expression
(Arg1
)));
7685 LP
:= Fold_Upper
(Name_Buffer
(1));
7687 if Locking_Policy
/= ' '
7688 and then Locking_Policy
/= LP
7690 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
7691 Error_Pragma
("locking policy incompatible with policy#");
7693 -- Set new policy, but always preserve System_Location since
7694 -- we like the error message with the run time name.
7697 Locking_Policy
:= LP
;
7699 if Locking_Policy_Sloc
/= System_Location
then
7700 Locking_Policy_Sloc
:= Loc
;
7709 -- pragma Long_Float (D_Float | G_Float);
7711 when Pragma_Long_Float
=>
7713 Check_Valid_Configuration_Pragma
;
7714 Check_Arg_Count
(1);
7715 Check_No_Identifier
(Arg1
);
7716 Check_Arg_Is_One_Of
(Arg1
, Name_D_Float
, Name_G_Float
);
7718 if not OpenVMS_On_Target
then
7719 Error_Pragma
("?pragma% ignored (applies only to Open'V'M'S)");
7724 if Chars
(Expression
(Arg1
)) = Name_D_Float
then
7725 if Opt
.Float_Format_Long
= 'G' then
7726 Error_Pragma
("G_Float previously specified");
7729 Opt
.Float_Format_Long
:= 'D';
7731 -- G_Float case (this is the default, does not need overriding)
7734 if Opt
.Float_Format_Long
= 'D' then
7735 Error_Pragma
("D_Float previously specified");
7738 Opt
.Float_Format_Long
:= 'G';
7741 Set_Standard_Fpt_Formats
;
7743 -----------------------
7744 -- Machine_Attribute --
7745 -----------------------
7747 -- pragma Machine_Attribute (
7748 -- [Entity =>] LOCAL_NAME,
7749 -- [Attribute_Name =>] static_string_EXPRESSION
7750 -- [,[Info =>] static_string_EXPRESSION] );
7752 when Pragma_Machine_Attribute
=> Machine_Attribute
: declare
7758 if Arg_Count
= 3 then
7759 Check_Optional_Identifier
(Arg3
, "info");
7760 Check_Arg_Is_Static_Expression
(Arg3
, Standard_String
);
7762 Check_Arg_Count
(2);
7765 Check_Arg_Is_Local_Name
(Arg1
);
7766 Check_Optional_Identifier
(Arg2
, "attribute_name");
7767 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7768 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7769 Def_Id
:= Entity
(Expression
(Arg1
));
7771 if Is_Access_Type
(Def_Id
) then
7772 Def_Id
:= Designated_Type
(Def_Id
);
7775 if Rep_Item_Too_Early
(Def_Id
, N
) then
7779 Def_Id
:= Underlying_Type
(Def_Id
);
7781 -- The only processing required is to link this item on to the
7782 -- list of rep items for the given entity. This is accomplished
7783 -- by the call to Rep_Item_Too_Late (when no error is detected
7784 -- and False is returned).
7786 if Rep_Item_Too_Late
(Def_Id
, N
) then
7789 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7791 end Machine_Attribute
;
7797 -- pragma Main_Storage
7798 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
7800 -- MAIN_STORAGE_OPTION ::=
7801 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
7802 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
7804 when Pragma_Main
=> Main
: declare
7805 Args
: Args_List
(1 .. 3);
7806 Names
: constant Name_List
(1 .. 3) := (
7808 Name_Task_Stack_Size_Default
,
7809 Name_Time_Slicing_Enabled
);
7815 Gather_Associations
(Names
, Args
);
7817 for J
in 1 .. 2 loop
7818 if Present
(Args
(J
)) then
7819 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
7823 if Present
(Args
(3)) then
7824 Check_Arg_Is_Static_Expression
(Args
(3), Standard_Boolean
);
7828 while Present
(Nod
) loop
7829 if Nkind
(Nod
) = N_Pragma
7830 and then Chars
(Nod
) = Name_Main
7832 Error_Msg_Name_1
:= Chars
(N
);
7833 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
7844 -- pragma Main_Storage
7845 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
7847 -- MAIN_STORAGE_OPTION ::=
7848 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
7849 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
7851 when Pragma_Main_Storage
=> Main_Storage
: declare
7852 Args
: Args_List
(1 .. 2);
7853 Names
: constant Name_List
(1 .. 2) := (
7854 Name_Working_Storage
,
7861 Gather_Associations
(Names
, Args
);
7863 for J
in 1 .. 2 loop
7864 if Present
(Args
(J
)) then
7865 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
7869 Check_In_Main_Program
;
7872 while Present
(Nod
) loop
7873 if Nkind
(Nod
) = N_Pragma
7874 and then Chars
(Nod
) = Name_Main_Storage
7876 Error_Msg_Name_1
:= Chars
(N
);
7877 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
7888 -- pragma Memory_Size (NUMERIC_LITERAL)
7890 when Pragma_Memory_Size
=>
7893 -- Memory size is simply ignored
7895 Check_No_Identifiers
;
7896 Check_Arg_Count
(1);
7897 Check_Arg_Is_Integer_Literal
(Arg1
);
7903 -- pragma No_Return (procedure_LOCAL_NAME);
7905 when Pragma_No_Return
=> No_Return
: declare
7912 Check_Arg_Count
(1);
7913 Check_No_Identifiers
;
7914 Check_Arg_Is_Local_Name
(Arg1
);
7915 Id
:= Expression
(Arg1
);
7918 if not Is_Entity_Name
(Id
) then
7919 Error_Pragma_Arg
("entity name required", Arg1
);
7922 if Etype
(Id
) = Any_Type
then
7930 and then Scope
(E
) = Current_Scope
7932 if Ekind
(E
) = E_Procedure
7933 or else Ekind
(E
) = E_Generic_Procedure
7943 Error_Pragma
("no procedures found for pragma%");
7947 ------------------------
7948 -- No_Strict_Aliasing --
7949 ------------------------
7951 when Pragma_No_Strict_Aliasing
=> No_Strict_Alias
: declare
7956 Check_At_Most_N_Arguments
(1);
7958 if Arg_Count
= 0 then
7959 Check_Valid_Configuration_Pragma
;
7960 Opt
.No_Strict_Aliasing
:= True;
7963 Check_Optional_Identifier
(Arg2
, Name_Entity
);
7964 Check_Arg_Is_Local_Name
(Arg1
);
7965 E_Id
:= Entity
(Expression
(Arg1
));
7967 if E_Id
= Any_Type
then
7969 elsif No
(E_Id
) or else not Is_Access_Type
(E_Id
) then
7970 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
7973 Set_No_Strict_Aliasing
(Implementation_Base_Type
(E_Id
));
7975 end No_Strict_Alias
;
7981 -- pragma Obsolescent [(static_string_EXPRESSION)];
7983 when Pragma_Obsolescent
=> Obsolescent
: declare
7984 Subp
: Node_Or_Entity_Id
;
7989 Check_At_Most_N_Arguments
(1);
7990 Check_No_Identifiers
;
7992 -- Check OK placement
7994 -- First possibility is within a declarative region, where the
7995 -- pragma immediately follows a subprogram declaration.
7997 if Present
(Prev
(N
)) then
8000 -- Second possibility, stand alone subprogram declaration with the
8001 -- pragma immediately following the declaration.
8004 and then Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
8006 Subp
:= Unit
(Parent
(Parent
(N
)));
8008 -- Any other possibility is a misplacement
8014 -- Check correct placement
8016 if Nkind
(Subp
) /= N_Subprogram_Declaration
then
8018 ("pragma% misplaced, must immediately " &
8019 "follow subprogram spec");
8021 -- If OK placement, set flag and acquire argument
8024 Subp
:= Defining_Entity
(Subp
);
8025 Set_Is_Obsolescent
(Subp
);
8027 if Arg_Count
= 1 then
8028 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
8029 S
:= Strval
(Expression
(Arg1
));
8031 for J
in 1 .. String_Length
(S
) loop
8032 if not In_Character_Range
(Get_String_Char
(S
, J
)) then
8034 ("pragma% argument does not allow wide characters",
8039 Set_Obsolescent_Warning
(Subp
, Expression
(Arg1
));
8048 -- pragma No_Run_Time
8050 -- Note: this pragma is retained for backwards compatibiltiy.
8051 -- See body of Rtsfind for full details on its handling.
8053 when Pragma_No_Run_Time
=>
8055 Check_Valid_Configuration_Pragma
;
8056 Check_Arg_Count
(0);
8058 No_Run_Time_Mode
:= True;
8059 Configurable_Run_Time_Mode
:= True;
8062 Word32
: constant Boolean := Ttypes
.System_Word_Size
= 32;
8065 Duration_32_Bits_On_Target
:= True;
8069 Set_Restriction
(No_Finalization
, N
);
8070 Set_Restriction
(No_Exception_Handlers
, N
);
8071 Set_Restriction
(Max_Tasks
, N
, 0);
8072 Set_Restriction
(No_Tasking
, N
);
8074 -----------------------
8075 -- Normalize_Scalars --
8076 -----------------------
8078 -- pragma Normalize_Scalars;
8080 when Pragma_Normalize_Scalars
=>
8081 Check_Ada_83_Warning
;
8082 Check_Arg_Count
(0);
8083 Check_Valid_Configuration_Pragma
;
8084 Normalize_Scalars
:= True;
8085 Init_Or_Norm_Scalars
:= True;
8091 -- pragma Optimize (Time | Space);
8093 -- The actual check for optimize is done in Gigi. Note that this
8094 -- pragma does not actually change the optimization setting, it
8095 -- simply checks that it is consistent with the pragma.
8097 when Pragma_Optimize
=>
8098 Check_No_Identifiers
;
8099 Check_Arg_Count
(1);
8100 Check_Arg_Is_One_Of
(Arg1
, Name_Time
, Name_Space
, Name_Off
);
8102 -------------------------
8103 -- Optional_Overriding --
8104 -------------------------
8106 -- These pragmas are treated as part of the previous subprogram
8107 -- declaration, and analyzed immediately after it (see sem_ch6,
8108 -- Check_Overriding_Operation). If the pragma has not been analyzed
8109 -- yet, it appears in the wrong place.
8111 when Pragma_Optional_Overriding
=>
8112 Error_Msg_N
("pragma must appear immediately after subprogram", N
);
8118 -- pragma Pack (first_subtype_LOCAL_NAME);
8120 when Pragma_Pack
=> Pack
: declare
8121 Assoc
: constant Node_Id
:= Arg1
;
8126 Check_No_Identifiers
;
8127 Check_Arg_Count
(1);
8128 Check_Arg_Is_Local_Name
(Arg1
);
8130 Type_Id
:= Expression
(Assoc
);
8131 Find_Type
(Type_Id
);
8132 Typ
:= Entity
(Type_Id
);
8135 or else Rep_Item_Too_Early
(Typ
, N
)
8139 Typ
:= Underlying_Type
(Typ
);
8142 if not Is_Array_Type
(Typ
) and then not Is_Record_Type
(Typ
) then
8143 Error_Pragma
("pragma% must specify array or record type");
8146 Check_First_Subtype
(Arg1
);
8148 if Has_Pragma_Pack
(Typ
) then
8149 Error_Pragma
("duplicate pragma%, only one allowed");
8151 -- Array type. We set the Has_Pragma_Pack flag, and Is_Packed,
8152 -- but not Has_Non_Standard_Rep, because we don't actually know
8153 -- till freeze time if the array can have packed representation.
8154 -- That's because in the general case we do not know enough about
8155 -- the component type until it in turn is frozen, which certainly
8156 -- happens before the array type is frozen, but not necessarily
8157 -- till that point (i.e. right now it may be unfrozen).
8159 elsif Is_Array_Type
(Typ
) then
8160 if Has_Aliased_Components
(Base_Type
(Typ
)) then
8162 ("pragma% ignored, cannot pack aliased components?");
8164 elsif Has_Atomic_Components
(Typ
)
8165 or else Is_Atomic
(Component_Type
(Typ
))
8168 ("?pragma% ignored, cannot pack atomic components");
8170 elsif not Rep_Item_Too_Late
(Typ
, N
) then
8171 Set_Is_Packed
(Base_Type
(Typ
));
8172 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
8173 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
8176 -- Record type. For record types, the pack is always effective
8178 else pragma Assert
(Is_Record_Type
(Typ
));
8179 if not Rep_Item_Too_Late
(Typ
, N
) then
8180 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
8181 Set_Is_Packed
(Base_Type
(Typ
));
8182 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
8193 -- There is nothing to do here, since we did all the processing
8194 -- for this pragma in Par.Prag (so that it works properly even in
8195 -- syntax only mode)
8204 -- pragma Passive [(PASSIVE_FORM)];
8206 -- PASSIVE_FORM ::= Semaphore | No
8208 when Pragma_Passive
=>
8211 if Nkind
(Parent
(N
)) /= N_Task_Definition
then
8212 Error_Pragma
("pragma% must be within task definition");
8215 if Arg_Count
/= 0 then
8216 Check_Arg_Count
(1);
8217 Check_Arg_Is_One_Of
(Arg1
, Name_Semaphore
, Name_No
);
8224 -- pragma Polling (ON | OFF);
8226 when Pragma_Polling
=>
8228 Check_Arg_Count
(1);
8229 Check_No_Identifiers
;
8230 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
8231 Polling_Required
:= (Chars
(Expression
(Arg1
)) = Name_On
);
8233 ---------------------
8234 -- Persistent_Data --
8235 ---------------------
8237 when Pragma_Persistent_Data
=> declare
8241 -- Register the pragma as applying to the compilation unit.
8242 -- Individual Persistent_Object pragmas for relevant objects
8243 -- are generated the end of the compilation.
8246 Check_Valid_Configuration_Pragma
;
8247 Check_Arg_Count
(0);
8248 Ent
:= Find_Lib_Unit_Name
;
8249 Set_Is_Preelaborated
(Ent
);
8252 -----------------------
8253 -- Persistent_Object --
8254 -----------------------
8256 when Pragma_Persistent_Object
=> declare
8264 Check_Arg_Count
(1);
8265 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
8267 if not Is_Entity_Name
(Expression
(Arg1
))
8269 (Ekind
(Entity
(Expression
(Arg1
))) /= E_Variable
8270 and then Ekind
(Entity
(Expression
(Arg1
))) /= E_Constant
)
8272 Error_Pragma_Arg
("pragma only applies to objects", Arg1
);
8275 Ent
:= Entity
(Expression
(Arg1
));
8276 Decl
:= Parent
(Ent
);
8278 if Nkind
(Decl
) /= N_Object_Declaration
then
8282 -- Placement of the object depends on whether there is
8283 -- an initial value or none. If the No_Initialization flag
8284 -- is set, the initialization has been transformed into
8285 -- assignments, which is disallowed elaboration code.
8287 if No_Initialization
(Decl
) then
8289 ("initialization for persistent object"
8290 & "must be static expression", Decl
);
8294 if No
(Expression
(Decl
)) then
8296 Store_String_Chars
("section ("".persistent.bss"")");
8300 if not Is_OK_Static_Expression
(Expression
(Decl
)) then
8301 Flag_Non_Static_Expr
8302 ("initialization for persistent object"
8303 & "must be static expression!", Expression
(Decl
));
8308 Store_String_Chars
("section ("".persistent.data"")");
8315 Name_Machine_Attribute
,
8317 (Make_Pragma_Argument_Association
8318 (Sloc
=> Sloc
(Arg1
),
8319 Expression
=> New_Occurrence_Of
(Ent
, Sloc
(Ent
))),
8320 Make_Pragma_Argument_Association
8321 (Sloc
=> Sloc
(Arg1
),
8324 (Sloc
=> Sloc
(Arg1
),
8327 Insert_After
(N
, MA
);
8329 Set_Has_Gigi_Rep_Item
(Ent
);
8336 -- pragma Preelaborate [(library_unit_NAME)];
8338 -- Set the flag Is_Preelaborated of program unit name entity
8340 when Pragma_Preelaborate
=> Preelaborate
: declare
8341 Pa
: constant Node_Id
:= Parent
(N
);
8342 Pk
: constant Node_Kind
:= Nkind
(Pa
);
8346 Check_Ada_83_Warning
;
8347 Check_Valid_Library_Unit_Pragma
;
8349 if Nkind
(N
) = N_Null_Statement
then
8353 Ent
:= Find_Lib_Unit_Name
;
8355 -- This filters out pragmas inside generic parent then
8356 -- show up inside instantiation
8359 and then not (Pk
= N_Package_Specification
8360 and then Present
(Generic_Parent
(Pa
)))
8362 if not Debug_Flag_U
then
8363 Set_Is_Preelaborated
(Ent
);
8364 Set_Suppress_Elaboration_Warnings
(Ent
);
8373 -- pragma Priority (EXPRESSION);
8375 when Pragma_Priority
=> Priority
: declare
8376 P
: constant Node_Id
:= Parent
(N
);
8380 Check_No_Identifiers
;
8381 Check_Arg_Count
(1);
8385 if Nkind
(P
) = N_Subprogram_Body
then
8386 Check_In_Main_Program
;
8388 Arg
:= Expression
(Arg1
);
8389 Analyze_And_Resolve
(Arg
, Standard_Integer
);
8393 if not Is_Static_Expression
(Arg
) then
8394 Flag_Non_Static_Expr
8395 ("main subprogram priority is not static!", Arg
);
8398 -- If constraint error, then we already signalled an error
8400 elsif Raises_Constraint_Error
(Arg
) then
8403 -- Otherwise check in range
8407 Val
: constant Uint
:= Expr_Value
(Arg
);
8411 or else Val
> Expr_Value
(Expression
8412 (Parent
(RTE
(RE_Max_Priority
))))
8415 ("main subprogram priority is out of range", Arg1
);
8421 (Current_Sem_Unit
, UI_To_Int
(Expr_Value
(Arg
)));
8423 -- Task or Protected, must be of type Integer
8425 elsif Nkind
(P
) = N_Protected_Definition
8427 Nkind
(P
) = N_Task_Definition
8429 Arg
:= Expression
(Arg1
);
8431 -- The expression must be analyzed in the special manner
8432 -- described in "Handling of Default and Per-Object
8433 -- Expressions" in sem.ads.
8435 Analyze_Per_Use_Expression
(Arg
, Standard_Integer
);
8437 if not Is_Static_Expression
(Arg
) then
8438 Check_Restriction
(Static_Priorities
, Arg
);
8441 -- Anything else is incorrect
8447 if Has_Priority_Pragma
(P
) then
8448 Error_Pragma
("duplicate pragma% not allowed");
8450 Set_Has_Priority_Pragma
(P
, True);
8452 if Nkind
(P
) = N_Protected_Definition
8454 Nkind
(P
) = N_Task_Definition
8456 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
8457 -- exp_ch9 should use this ???
8466 -- pragma Profile (profile_IDENTIFIER);
8468 -- profile_IDENTIFIER => Protected | Ravenscar
8470 when Pragma_Profile
=>
8471 Check_Arg_Count
(1);
8472 Check_Valid_Configuration_Pragma
;
8473 Check_No_Identifiers
;
8476 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
8478 if Chars
(Argx
) = Name_Ravenscar
then
8479 Set_Ravenscar_Profile
(N
);
8481 elsif Chars
(Argx
) = Name_Restricted
then
8482 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> False);
8484 Error_Pragma_Arg
("& is not a valid profile", Argx
);
8488 ----------------------
8489 -- Profile_Warnings --
8490 ----------------------
8492 -- pragma Profile_Warnings (profile_IDENTIFIER);
8494 -- profile_IDENTIFIER => Protected | Ravenscar
8496 when Pragma_Profile_Warnings
=>
8498 Check_Arg_Count
(1);
8499 Check_Valid_Configuration_Pragma
;
8500 Check_No_Identifiers
;
8503 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
8505 if Chars
(Argx
) = Name_Ravenscar
then
8506 Set_Profile_Restrictions
(Ravenscar
, N
, Warn
=> True);
8508 elsif Chars
(Argx
) = Name_Restricted
then
8509 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> True);
8511 Error_Pragma_Arg
("& is not a valid profile", Argx
);
8515 --------------------------
8516 -- Propagate_Exceptions --
8517 --------------------------
8519 -- pragma Propagate_Exceptions;
8521 when Pragma_Propagate_Exceptions
=>
8523 Check_Arg_Count
(0);
8525 if In_Extended_Main_Source_Unit
(N
) then
8526 Propagate_Exceptions
:= True;
8533 -- pragma Psect_Object (
8534 -- [Internal =>] LOCAL_NAME,
8535 -- [, [External =>] EXTERNAL_SYMBOL]
8536 -- [, [Size =>] EXTERNAL_SYMBOL]);
8538 when Pragma_Psect_Object | Pragma_Common_Object
=>
8539 Psect_Object
: declare
8540 Args
: Args_List
(1 .. 3);
8541 Names
: constant Name_List
(1 .. 3) := (
8546 Internal
: Node_Id
renames Args
(1);
8547 External
: Node_Id
renames Args
(2);
8548 Size
: Node_Id
renames Args
(3);
8552 procedure Check_Too_Long
(Arg
: Node_Id
);
8553 -- Posts message if the argument is an identifier with more
8554 -- than 31 characters, or a string literal with more than
8555 -- 31 characters, and we are operating under VMS
8557 --------------------
8558 -- Check_Too_Long --
8559 --------------------
8561 procedure Check_Too_Long
(Arg
: Node_Id
) is
8562 X
: constant Node_Id
:= Original_Node
(Arg
);
8565 if Nkind
(X
) /= N_String_Literal
8567 Nkind
(X
) /= N_Identifier
8570 ("inappropriate argument for pragma %", Arg
);
8573 if OpenVMS_On_Target
then
8574 if (Nkind
(X
) = N_String_Literal
8575 and then String_Length
(Strval
(X
)) > 31)
8577 (Nkind
(X
) = N_Identifier
8578 and then Length_Of_Name
(Chars
(X
)) > 31)
8581 ("argument for pragma % is longer than 31 characters",
8587 -- Start of processing for Common_Object/Psect_Object
8591 Gather_Associations
(Names
, Args
);
8592 Process_Extended_Import_Export_Internal_Arg
(Internal
);
8594 Def_Id
:= Entity
(Internal
);
8596 if Ekind
(Def_Id
) /= E_Constant
8597 and then Ekind
(Def_Id
) /= E_Variable
8600 ("pragma% must designate an object", Internal
);
8603 Check_Too_Long
(Internal
);
8605 if Is_Imported
(Def_Id
) or else Is_Exported
(Def_Id
) then
8607 ("cannot use pragma% for imported/exported object",
8611 if Is_Concurrent_Type
(Etype
(Internal
)) then
8613 ("cannot specify pragma % for task/protected object",
8617 if Has_Rep_Pragma
(Def_Id
, Name_Common_Object
)
8619 Has_Rep_Pragma
(Def_Id
, Name_Psect_Object
)
8621 Error_Msg_N
("?duplicate Common/Psect_Object pragma", N
);
8624 if Ekind
(Def_Id
) = E_Constant
then
8626 ("cannot specify pragma % for a constant", Internal
);
8629 if Is_Record_Type
(Etype
(Internal
)) then
8635 Ent
:= First_Entity
(Etype
(Internal
));
8636 while Present
(Ent
) loop
8637 Decl
:= Declaration_Node
(Ent
);
8639 if Ekind
(Ent
) = E_Component
8640 and then Nkind
(Decl
) = N_Component_Declaration
8641 and then Present
(Expression
(Decl
))
8642 and then Warn_On_Export_Import
8645 ("?object for pragma % has defaults", Internal
);
8655 if Present
(Size
) then
8656 Check_Too_Long
(Size
);
8659 if Present
(External
) then
8660 Check_Arg_Is_External_Name
(External
);
8661 Check_Too_Long
(External
);
8664 -- If all error tests pass, link pragma on to the rep item chain
8666 Record_Rep_Item
(Def_Id
, N
);
8673 -- pragma Pure [(library_unit_NAME)];
8675 when Pragma_Pure
=> Pure
: declare
8678 Check_Ada_83_Warning
;
8679 Check_Valid_Library_Unit_Pragma
;
8681 if Nkind
(N
) = N_Null_Statement
then
8685 Ent
:= Find_Lib_Unit_Name
;
8687 Set_Suppress_Elaboration_Warnings
(Ent
);
8694 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
8696 when Pragma_Pure_Function
=> Pure_Function
: declare
8700 Effective
: Boolean := False;
8704 Check_Arg_Count
(1);
8705 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8706 Check_Arg_Is_Local_Name
(Arg1
);
8707 E_Id
:= Expression
(Arg1
);
8709 if Error_Posted
(E_Id
) then
8713 -- Loop through homonyms (overloadings) of referenced entity
8719 Def_Id
:= Get_Base_Subprogram
(E
);
8721 if Ekind
(Def_Id
) /= E_Function
8722 and then Ekind
(Def_Id
) /= E_Generic_Function
8723 and then Ekind
(Def_Id
) /= E_Operator
8726 ("pragma% requires a function name", Arg1
);
8729 Set_Is_Pure
(Def_Id
);
8731 if not Has_Pragma_Pure_Function
(Def_Id
) then
8732 Set_Has_Pragma_Pure_Function
(Def_Id
);
8737 exit when No
(E
) or else Scope
(E
) /= Current_Scope
;
8741 and then Warn_On_Redundant_Constructs
8743 Error_Msg_NE
("pragma Pure_Function on& is redundant?",
8749 --------------------
8750 -- Queuing_Policy --
8751 --------------------
8753 -- pragma Queuing_Policy (policy_IDENTIFIER);
8755 when Pragma_Queuing_Policy
=> declare
8759 Check_Ada_83_Warning
;
8760 Check_Arg_Count
(1);
8761 Check_No_Identifiers
;
8762 Check_Arg_Is_Queuing_Policy
(Arg1
);
8763 Check_Valid_Configuration_Pragma
;
8764 Get_Name_String
(Chars
(Expression
(Arg1
)));
8765 QP
:= Fold_Upper
(Name_Buffer
(1));
8767 if Queuing_Policy
/= ' '
8768 and then Queuing_Policy
/= QP
8770 Error_Msg_Sloc
:= Queuing_Policy_Sloc
;
8771 Error_Pragma
("queuing policy incompatible with policy#");
8773 -- Set new policy, but always preserve System_Location since
8774 -- we like the error message with the run time name.
8777 Queuing_Policy
:= QP
;
8779 if Queuing_Policy_Sloc
/= System_Location
then
8780 Queuing_Policy_Sloc
:= Loc
;
8785 ---------------------------
8786 -- Remote_Call_Interface --
8787 ---------------------------
8789 -- pragma Remote_Call_Interface [(library_unit_NAME)];
8791 when Pragma_Remote_Call_Interface
=> Remote_Call_Interface
: declare
8792 Cunit_Node
: Node_Id
;
8793 Cunit_Ent
: Entity_Id
;
8797 Check_Ada_83_Warning
;
8798 Check_Valid_Library_Unit_Pragma
;
8800 if Nkind
(N
) = N_Null_Statement
then
8804 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
8805 K
:= Nkind
(Unit
(Cunit_Node
));
8806 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
8808 if K
= N_Package_Declaration
8809 or else K
= N_Generic_Package_Declaration
8810 or else K
= N_Subprogram_Declaration
8811 or else K
= N_Generic_Subprogram_Declaration
8812 or else (K
= N_Subprogram_Body
8813 and then Acts_As_Spec
(Unit
(Cunit_Node
)))
8818 "pragma% must apply to package or subprogram declaration");
8821 Set_Is_Remote_Call_Interface
(Cunit_Ent
);
8822 end Remote_Call_Interface
;
8828 -- pragma Remote_Types [(library_unit_NAME)];
8830 when Pragma_Remote_Types
=> Remote_Types
: declare
8831 Cunit_Node
: Node_Id
;
8832 Cunit_Ent
: Entity_Id
;
8835 Check_Ada_83_Warning
;
8836 Check_Valid_Library_Unit_Pragma
;
8838 if Nkind
(N
) = N_Null_Statement
then
8842 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
8843 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
8845 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
8847 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
8850 "pragma% can only apply to a package declaration");
8853 Set_Is_Remote_Types
(Cunit_Ent
);
8860 -- pragma Ravenscar;
8862 when Pragma_Ravenscar
=>
8864 Check_Arg_Count
(0);
8865 Check_Valid_Configuration_Pragma
;
8866 Set_Ravenscar_Profile
(N
);
8868 if Warn_On_Obsolescent_Feature
then
8870 ("pragma Ravenscar is an obsolescent feature?", N
);
8872 ("|use pragma Profile (Ravenscar) instead", N
);
8875 -------------------------
8876 -- Restricted_Run_Time --
8877 -------------------------
8879 -- pragma Restricted_Run_Time;
8881 when Pragma_Restricted_Run_Time
=>
8883 Check_Arg_Count
(0);
8884 Check_Valid_Configuration_Pragma
;
8885 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> False);
8887 if Warn_On_Obsolescent_Feature
then
8889 ("pragma Restricted_Run_Time is an obsolescent feature?", N
);
8891 ("|use pragma Profile (Restricted) instead", N
);
8898 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
8901 -- restriction_IDENTIFIER
8902 -- | restriction_parameter_IDENTIFIER => EXPRESSION
8904 when Pragma_Restrictions
=>
8905 Process_Restrictions_Or_Restriction_Warnings
;
8907 --------------------------
8908 -- Restriction_Warnings --
8909 --------------------------
8911 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
8914 -- restriction_IDENTIFIER
8915 -- | restriction_parameter_IDENTIFIER => EXPRESSION
8917 when Pragma_Restriction_Warnings
=>
8918 Process_Restrictions_Or_Restriction_Warnings
;
8924 -- pragma Reviewable;
8926 when Pragma_Reviewable
=>
8927 Check_Ada_83_Warning
;
8928 Check_Arg_Count
(0);
8934 -- pragma Share_Generic (NAME {, NAME});
8936 when Pragma_Share_Generic
=>
8938 Process_Generic_List
;
8944 -- pragma Shared (LOCAL_NAME);
8946 when Pragma_Shared
=>
8948 Process_Atomic_Shared_Volatile
;
8950 --------------------
8951 -- Shared_Passive --
8952 --------------------
8954 -- pragma Shared_Passive [(library_unit_NAME)];
8956 -- Set the flag Is_Shared_Passive of program unit name entity
8958 when Pragma_Shared_Passive
=> Shared_Passive
: declare
8959 Cunit_Node
: Node_Id
;
8960 Cunit_Ent
: Entity_Id
;
8963 Check_Ada_83_Warning
;
8964 Check_Valid_Library_Unit_Pragma
;
8966 if Nkind
(N
) = N_Null_Statement
then
8970 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
8971 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
8973 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
8975 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
8978 "pragma% can only apply to a package declaration");
8981 Set_Is_Shared_Passive
(Cunit_Ent
);
8984 ----------------------
8985 -- Source_File_Name --
8986 ----------------------
8988 -- There are five forms for this pragma:
8990 -- pragma Source_File_Name (
8991 -- [UNIT_NAME =>] unit_NAME,
8992 -- BODY_FILE_NAME => STRING_LITERAL
8993 -- [, [INDEX =>] INTEGER_LITERAL]);
8995 -- pragma Source_File_Name (
8996 -- [UNIT_NAME =>] unit_NAME,
8997 -- SPEC_FILE_NAME => STRING_LITERAL
8998 -- [, [INDEX =>] INTEGER_LITERAL]);
9000 -- pragma Source_File_Name (
9001 -- BODY_FILE_NAME => STRING_LITERAL
9002 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9003 -- [, CASING => CASING_SPEC]);
9005 -- pragma Source_File_Name (
9006 -- SPEC_FILE_NAME => STRING_LITERAL
9007 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9008 -- [, CASING => CASING_SPEC]);
9010 -- pragma Source_File_Name (
9011 -- SUBUNIT_FILE_NAME => STRING_LITERAL
9012 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9013 -- [, CASING => CASING_SPEC]);
9015 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
9017 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
9018 -- Source_File_Name (SFN), however their usage is exclusive:
9019 -- SFN can only be used when no project file is used, while
9020 -- SFNP can only be used when a project file is used.
9022 -- No processing here. Processing was completed during parsing,
9023 -- since we need to have file names set as early as possible.
9024 -- Units are loaded well before semantic processing starts.
9026 -- The only processing we defer to this point is the check
9027 -- for correct placement.
9029 when Pragma_Source_File_Name
=>
9031 Check_Valid_Configuration_Pragma
;
9033 ------------------------------
9034 -- Source_File_Name_Project --
9035 ------------------------------
9037 -- See Source_File_Name for syntax
9039 -- No processing here. Processing was completed during parsing,
9040 -- since we need to have file names set as early as possible.
9041 -- Units are loaded well before semantic processing starts.
9043 -- The only processing we defer to this point is the check
9044 -- for correct placement.
9046 when Pragma_Source_File_Name_Project
=>
9048 Check_Valid_Configuration_Pragma
;
9050 -- Check that a pragma Source_File_Name_Project is used only
9051 -- in a configuration pragmas file.
9053 -- Pragmas Source_File_Name_Project should only be generated
9054 -- by the Project Manager in configuration pragmas files.
9056 -- This is really an ugly test. It seems to depend on some
9057 -- accidental and undocumented property. At the very least
9058 -- it needs to be documented, but it would be better to have
9059 -- a clean way of testing if we are in a configuration file???
9061 if Present
(Parent
(N
)) then
9063 ("pragma% can only appear in a configuration pragmas file");
9066 ----------------------
9067 -- Source_Reference --
9068 ----------------------
9070 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
9072 -- Nothing to do, all processing completed in Par.Prag, since we
9073 -- need the information for possible parser messages that are output
9075 when Pragma_Source_Reference
=>
9082 -- pragma Storage_Size (EXPRESSION);
9084 when Pragma_Storage_Size
=> Storage_Size
: declare
9085 P
: constant Node_Id
:= Parent
(N
);
9089 Check_No_Identifiers
;
9090 Check_Arg_Count
(1);
9092 -- The expression must be analyzed in the special manner
9093 -- described in "Handling of Default Expressions" in sem.ads.
9095 -- Set In_Default_Expression for per-object case ???
9097 Arg
:= Expression
(Arg1
);
9098 Analyze_Per_Use_Expression
(Arg
, Any_Integer
);
9100 if not Is_Static_Expression
(Arg
) then
9101 Check_Restriction
(Static_Storage_Size
, Arg
);
9104 if Nkind
(P
) /= N_Task_Definition
then
9109 if Has_Storage_Size_Pragma
(P
) then
9110 Error_Pragma
("duplicate pragma% not allowed");
9112 Set_Has_Storage_Size_Pragma
(P
, True);
9115 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
9116 -- ??? exp_ch9 should use this!
9124 -- pragma Storage_Unit (NUMERIC_LITERAL);
9126 -- Only permitted argument is System'Storage_Unit value
9128 when Pragma_Storage_Unit
=>
9129 Check_No_Identifiers
;
9130 Check_Arg_Count
(1);
9131 Check_Arg_Is_Integer_Literal
(Arg1
);
9133 if Intval
(Expression
(Arg1
)) /=
9134 UI_From_Int
(Ttypes
.System_Storage_Unit
)
9136 Error_Msg_Uint_1
:= UI_From_Int
(Ttypes
.System_Storage_Unit
);
9138 ("the only allowed argument for pragma% is ^", Arg1
);
9141 --------------------
9142 -- Stream_Convert --
9143 --------------------
9145 -- pragma Stream_Convert (
9146 -- [Entity =>] type_LOCAL_NAME,
9147 -- [Read =>] function_NAME,
9148 -- [Write =>] function NAME);
9150 when Pragma_Stream_Convert
=> Stream_Convert
: declare
9152 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
);
9153 -- Check that the given argument is the name of a local
9154 -- function of one argument that is not overloaded earlier
9155 -- in the current local scope. A check is also made that the
9156 -- argument is a function with one parameter.
9158 --------------------------------------
9159 -- Check_OK_Stream_Convert_Function --
9160 --------------------------------------
9162 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
) is
9166 Check_Arg_Is_Local_Name
(Arg
);
9167 Ent
:= Entity
(Expression
(Arg
));
9169 if Has_Homonym
(Ent
) then
9171 ("argument for pragma% may not be overloaded", Arg
);
9174 if Ekind
(Ent
) /= E_Function
9175 or else No
(First_Formal
(Ent
))
9176 or else Present
(Next_Formal
(First_Formal
(Ent
)))
9179 ("argument for pragma% must be" &
9180 " function of one argument", Arg
);
9182 end Check_OK_Stream_Convert_Function
;
9184 -- Start of procecessing for Stream_Convert
9188 Check_Arg_Count
(3);
9189 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9190 Check_Optional_Identifier
(Arg2
, Name_Read
);
9191 Check_Optional_Identifier
(Arg3
, Name_Write
);
9192 Check_Arg_Is_Local_Name
(Arg1
);
9193 Check_OK_Stream_Convert_Function
(Arg2
);
9194 Check_OK_Stream_Convert_Function
(Arg3
);
9197 Typ
: constant Entity_Id
:=
9198 Underlying_Type
(Entity
(Expression
(Arg1
)));
9199 Read
: constant Entity_Id
:= Entity
(Expression
(Arg2
));
9200 Write
: constant Entity_Id
:= Entity
(Expression
(Arg3
));
9203 if Etype
(Typ
) = Any_Type
9205 Etype
(Read
) = Any_Type
9207 Etype
(Write
) = Any_Type
9212 Check_First_Subtype
(Arg1
);
9214 if Rep_Item_Too_Early
(Typ
, N
)
9216 Rep_Item_Too_Late
(Typ
, N
)
9221 if Underlying_Type
(Etype
(Read
)) /= Typ
then
9223 ("incorrect return type for function&", Arg2
);
9226 if Underlying_Type
(Etype
(First_Formal
(Write
))) /= Typ
then
9228 ("incorrect parameter type for function&", Arg3
);
9231 if Underlying_Type
(Etype
(First_Formal
(Read
))) /=
9232 Underlying_Type
(Etype
(Write
))
9235 ("result type of & does not match Read parameter type",
9241 -------------------------
9242 -- Style_Checks (GNAT) --
9243 -------------------------
9245 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
9247 -- This is processed by the parser since some of the style
9248 -- checks take place during source scanning and parsing. This
9249 -- means that we don't need to issue error messages here.
9251 when Pragma_Style_Checks
=> Style_Checks
: declare
9252 A
: constant Node_Id
:= Expression
(Arg1
);
9258 Check_No_Identifiers
;
9260 -- Two argument form
9262 if Arg_Count
= 2 then
9263 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
9270 E_Id
:= Expression
(Arg2
);
9273 if not Is_Entity_Name
(E_Id
) then
9275 ("second argument of pragma% must be entity name",
9285 Set_Suppress_Style_Checks
(E
,
9286 (Chars
(Expression
(Arg1
)) = Name_Off
));
9287 exit when No
(Homonym
(E
));
9293 -- One argument form
9296 Check_Arg_Count
(1);
9298 if Nkind
(A
) = N_String_Literal
then
9302 Slen
: constant Natural := Natural (String_Length
(S
));
9303 Options
: String (1 .. Slen
);
9309 C
:= Get_String_Char
(S
, Int
(J
));
9310 exit when not In_Character_Range
(C
);
9311 Options
(J
) := Get_Character
(C
);
9314 Set_Style_Check_Options
(Options
);
9322 elsif Nkind
(A
) = N_Identifier
then
9324 if Chars
(A
) = Name_All_Checks
then
9325 Set_Default_Style_Check_Options
;
9327 elsif Chars
(A
) = Name_On
then
9328 Style_Check
:= True;
9330 elsif Chars
(A
) = Name_Off
then
9331 Style_Check
:= False;
9342 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
9344 when Pragma_Subtitle
=>
9346 Check_Arg_Count
(1);
9347 Check_Optional_Identifier
(Arg1
, Name_Subtitle
);
9348 Check_Arg_Is_String_Literal
(Arg1
);
9354 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
9356 when Pragma_Suppress
=>
9357 Process_Suppress_Unsuppress
(True);
9363 -- pragma Suppress_All;
9365 -- The only check made here is that the pragma appears in the
9366 -- proper place, i.e. following a compilation unit. If indeed
9367 -- it appears in this context, then the parser has already
9368 -- inserted an equivalent pragma Suppress (All_Checks) to get
9369 -- the required effect.
9371 when Pragma_Suppress_All
=>
9373 Check_Arg_Count
(0);
9375 if Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
9376 or else not Is_List_Member
(N
)
9377 or else List_Containing
(N
) /= Pragmas_After
(Parent
(N
))
9380 ("misplaced pragma%, must follow compilation unit");
9383 -------------------------
9384 -- Suppress_Debug_Info --
9385 -------------------------
9387 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
9389 when Pragma_Suppress_Debug_Info
=>
9391 Check_Arg_Count
(1);
9392 Check_Arg_Is_Local_Name
(Arg1
);
9393 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9394 Set_Debug_Info_Off
(Entity
(Get_Pragma_Arg
(Arg1
)));
9396 ----------------------------------
9397 -- Suppress_Exception_Locations --
9398 ----------------------------------
9400 -- pragma Suppress_Exception_Locations;
9402 when Pragma_Suppress_Exception_Locations
=>
9404 Check_Arg_Count
(0);
9405 Check_Valid_Configuration_Pragma
;
9406 Exception_Locations_Suppressed
:= True;
9408 -----------------------------
9409 -- Suppress_Initialization --
9410 -----------------------------
9412 -- pragma Suppress_Initialization ([Entity =>] type_Name);
9414 when Pragma_Suppress_Initialization
=> Suppress_Init
: declare
9420 Check_Arg_Count
(1);
9421 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9422 Check_Arg_Is_Local_Name
(Arg1
);
9424 E_Id
:= Expression
(Arg1
);
9426 if Etype
(E_Id
) = Any_Type
then
9433 if Is_Incomplete_Or_Private_Type
(E
) then
9434 if No
(Full_View
(Base_Type
(E
))) then
9436 ("argument of pragma% cannot be an incomplete type",
9439 Set_Suppress_Init_Proc
(Full_View
(Base_Type
(E
)));
9442 Set_Suppress_Init_Proc
(Base_Type
(E
));
9447 ("pragma% requires argument that is a type name", Arg1
);
9455 -- pragma System_Name (DIRECT_NAME);
9457 -- Syntax check: one argument, which must be the identifier GNAT
9458 -- or the identifier GCC, no other identifiers are acceptable.
9460 when Pragma_System_Name
=>
9461 Check_No_Identifiers
;
9462 Check_Arg_Count
(1);
9463 Check_Arg_Is_One_Of
(Arg1
, Name_Gcc
, Name_Gnat
);
9465 -----------------------------
9466 -- Task_Dispatching_Policy --
9467 -----------------------------
9469 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
9471 when Pragma_Task_Dispatching_Policy
=> declare
9475 Check_Ada_83_Warning
;
9476 Check_Arg_Count
(1);
9477 Check_No_Identifiers
;
9478 Check_Arg_Is_Task_Dispatching_Policy
(Arg1
);
9479 Check_Valid_Configuration_Pragma
;
9480 Get_Name_String
(Chars
(Expression
(Arg1
)));
9481 DP
:= Fold_Upper
(Name_Buffer
(1));
9483 if Task_Dispatching_Policy
/= ' '
9484 and then Task_Dispatching_Policy
/= DP
9486 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
9488 ("task dispatching policy incompatible with policy#");
9490 -- Set new policy, but always preserve System_Location since
9491 -- we like the error message with the run time name.
9494 Task_Dispatching_Policy
:= DP
;
9496 if Task_Dispatching_Policy_Sloc
/= System_Location
then
9497 Task_Dispatching_Policy_Sloc
:= Loc
;
9506 -- pragma Task_Info (EXPRESSION);
9508 when Pragma_Task_Info
=> Task_Info
: declare
9509 P
: constant Node_Id
:= Parent
(N
);
9514 if Nkind
(P
) /= N_Task_Definition
then
9515 Error_Pragma
("pragma% must appear in task definition");
9518 Check_No_Identifiers
;
9519 Check_Arg_Count
(1);
9521 Analyze_And_Resolve
(Expression
(Arg1
), RTE
(RE_Task_Info_Type
));
9523 if Etype
(Expression
(Arg1
)) = Any_Type
then
9527 if Has_Task_Info_Pragma
(P
) then
9528 Error_Pragma
("duplicate pragma% not allowed");
9530 Set_Has_Task_Info_Pragma
(P
, True);
9538 -- pragma Task_Name (string_EXPRESSION);
9540 when Pragma_Task_Name
=> Task_Name
: declare
9541 -- pragma Priority (EXPRESSION);
9543 P
: constant Node_Id
:= Parent
(N
);
9547 Check_No_Identifiers
;
9548 Check_Arg_Count
(1);
9550 Arg
:= Expression
(Arg1
);
9551 Analyze_And_Resolve
(Arg
, Standard_String
);
9553 if Nkind
(P
) /= N_Task_Definition
then
9557 if Has_Task_Name_Pragma
(P
) then
9558 Error_Pragma
("duplicate pragma% not allowed");
9560 Set_Has_Task_Name_Pragma
(P
, True);
9561 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
9569 -- pragma Task_Storage (
9570 -- [Task_Type =>] LOCAL_NAME,
9571 -- [Top_Guard =>] static_integer_EXPRESSION);
9573 when Pragma_Task_Storage
=> Task_Storage
: declare
9574 Args
: Args_List
(1 .. 2);
9575 Names
: constant Name_List
(1 .. 2) := (
9579 Task_Type
: Node_Id
renames Args
(1);
9580 Top_Guard
: Node_Id
renames Args
(2);
9586 Gather_Associations
(Names
, Args
);
9588 if No
(Task_Type
) then
9590 ("missing task_type argument for pragma%");
9593 Check_Arg_Is_Local_Name
(Task_Type
);
9595 Ent
:= Entity
(Task_Type
);
9597 if not Is_Task_Type
(Ent
) then
9599 ("argument for pragma% must be task type", Task_Type
);
9602 if No
(Top_Guard
) then
9604 ("pragma% takes two arguments", Task_Type
);
9606 Check_Arg_Is_Static_Expression
(Top_Guard
, Any_Integer
);
9609 Check_First_Subtype
(Task_Type
);
9611 if Rep_Item_Too_Late
(Ent
, N
) then
9620 -- pragma Thread_Body
9621 -- ( [Entity =>] LOCAL_NAME
9622 -- [,[Secondary_Stack_Size =>] static_integer_EXPRESSION]);
9624 when Pragma_Thread_Body
=> Thread_Body
: declare
9631 Check_At_Least_N_Arguments
(1);
9632 Check_At_Most_N_Arguments
(2);
9633 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9634 Check_Arg_Is_Local_Name
(Arg1
);
9636 Id
:= Expression
(Arg1
);
9638 if not Is_Entity_Name
(Id
)
9639 or else not Is_Subprogram
(Entity
(Id
))
9641 Error_Pragma_Arg
("subprogram name required", Arg1
);
9646 -- Go to renamed subprogram if present, since Thread_Body applies
9647 -- to the actual renamed entity, not to the renaming entity.
9649 if Present
(Alias
(E
))
9650 and then Nkind
(Parent
(Declaration_Node
(E
))) =
9651 N_Subprogram_Renaming_Declaration
9656 -- Various error checks
9658 if Nkind
(Parent
(Declaration_Node
(E
))) = N_Subprogram_Body
then
9660 ("pragma% requires separate spec and must come before body");
9662 elsif Rep_Item_Too_Early
(E
, N
)
9664 Rep_Item_Too_Late
(E
, N
)
9668 elsif Is_Thread_Body
(E
) then
9670 ("only one thread body pragma allowed", Arg1
);
9672 elsif Present
(Homonym
(E
))
9673 and then Scope
(Homonym
(E
)) = Current_Scope
9676 ("thread body subprogram must not be overloaded", Arg1
);
9679 Set_Is_Thread_Body
(E
);
9681 -- Deal with secondary stack argument
9683 if Arg_Count
= 2 then
9684 Check_Optional_Identifier
(Arg2
, Name_Secondary_Stack_Size
);
9685 SS
:= Expression
(Arg2
);
9686 Analyze_And_Resolve
(SS
, Any_Integer
);
9694 -- pragma Time_Slice (static_duration_EXPRESSION);
9696 when Pragma_Time_Slice
=> Time_Slice
: declare
9702 Check_Arg_Count
(1);
9703 Check_No_Identifiers
;
9704 Check_In_Main_Program
;
9705 Check_Arg_Is_Static_Expression
(Arg1
, Standard_Duration
);
9707 if not Error_Posted
(Arg1
) then
9709 while Present
(Nod
) loop
9710 if Nkind
(Nod
) = N_Pragma
9711 and then Chars
(Nod
) = Name_Time_Slice
9713 Error_Msg_Name_1
:= Chars
(N
);
9714 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
9721 -- Process only if in main unit
9723 if Get_Source_Unit
(Loc
) = Main_Unit
then
9724 Opt
.Time_Slice_Set
:= True;
9725 Val
:= Expr_Value_R
(Expression
(Arg1
));
9727 if Val
<= Ureal_0
then
9728 Opt
.Time_Slice_Value
:= 0;
9730 elsif Val
> UR_From_Uint
(UI_From_Int
(1000)) then
9731 Opt
.Time_Slice_Value
:= 1_000_000_000
;
9734 Opt
.Time_Slice_Value
:=
9735 UI_To_Int
(UR_To_Uint
(Val
* UI_From_Int
(1_000_000
)));
9744 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
9746 -- TITLING_OPTION ::=
9747 -- [Title =>] STRING_LITERAL
9748 -- | [Subtitle =>] STRING_LITERAL
9750 when Pragma_Title
=> Title
: declare
9751 Args
: Args_List
(1 .. 2);
9752 Names
: constant Name_List
(1 .. 2) := (
9758 Gather_Associations
(Names
, Args
);
9760 for J
in 1 .. 2 loop
9761 if Present
(Args
(J
)) then
9762 Check_Arg_Is_String_Literal
(Args
(J
));
9767 ---------------------
9768 -- Unchecked_Union --
9769 ---------------------
9771 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
9773 when Pragma_Unchecked_Union
=> Unchecked_Union
: declare
9774 Assoc
: constant Node_Id
:= Arg1
;
9775 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
9786 Check_No_Identifiers
;
9787 Check_Arg_Count
(1);
9788 Check_Arg_Is_Local_Name
(Arg1
);
9790 Find_Type
(Type_Id
);
9791 Typ
:= Entity
(Type_Id
);
9794 or else Rep_Item_Too_Early
(Typ
, N
)
9798 Typ
:= Underlying_Type
(Typ
);
9801 if Rep_Item_Too_Late
(Typ
, N
) then
9805 Check_First_Subtype
(Arg1
);
9807 -- Note remaining cases are references to a type in the current
9808 -- declarative part. If we find an error, we post the error on
9809 -- the relevant type declaration at an appropriate point.
9811 if not Is_Record_Type
(Typ
) then
9812 Error_Msg_N
("Unchecked_Union must be record type", Typ
);
9815 elsif Is_Tagged_Type
(Typ
) then
9816 Error_Msg_N
("Unchecked_Union must not be tagged", Typ
);
9819 elsif Is_Limited_Type
(Typ
) then
9821 ("Unchecked_Union must not be limited record type", Typ
);
9822 Explain_Limited_Type
(Typ
, Typ
);
9826 if not Has_Discriminants
(Typ
) then
9828 ("Unchecked_Union must have one discriminant", Typ
);
9832 Discr
:= First_Discriminant
(Typ
);
9834 if Present
(Next_Discriminant
(Discr
)) then
9836 ("Unchecked_Union must have exactly one discriminant",
9837 Next_Discriminant
(Discr
));
9841 if No
(Discriminant_Default_Value
(Discr
)) then
9843 ("Unchecked_Union discriminant must have default value",
9847 Tdef
:= Type_Definition
(Declaration_Node
(Typ
));
9848 Clist
:= Component_List
(Tdef
);
9850 Comp
:= First
(Component_Items
(Clist
));
9851 while Present
(Comp
) loop
9853 Check_Component
(Comp
);
9858 if No
(Clist
) or else No
(Variant_Part
(Clist
)) then
9860 ("Unchecked_Union must have variant part",
9865 Vpart
:= Variant_Part
(Clist
);
9867 Variant
:= First
(Variants
(Vpart
));
9868 while Present
(Variant
) loop
9869 Check_Variant
(Variant
);
9874 Set_Is_Unchecked_Union
(Typ
, True);
9875 Set_Convention
(Typ
, Convention_C
);
9877 Set_Has_Unchecked_Union
(Base_Type
(Typ
), True);
9878 Set_Is_Unchecked_Union
(Base_Type
(Typ
), True);
9879 end Unchecked_Union
;
9881 ------------------------
9882 -- Unimplemented_Unit --
9883 ------------------------
9885 -- pragma Unimplemented_Unit;
9887 -- Note: this only gives an error if we are generating code,
9888 -- or if we are in a generic library unit (where the pragma
9889 -- appears in the body, not in the spec).
9891 when Pragma_Unimplemented_Unit
=> Unimplemented_Unit
: declare
9892 Cunitent
: constant Entity_Id
:=
9893 Cunit_Entity
(Get_Source_Unit
(Loc
));
9894 Ent_Kind
: constant Entity_Kind
:=
9899 Check_Arg_Count
(0);
9901 if Operating_Mode
= Generate_Code
9902 or else Ent_Kind
= E_Generic_Function
9903 or else Ent_Kind
= E_Generic_Procedure
9904 or else Ent_Kind
= E_Generic_Package
9906 Get_Name_String
(Chars
(Cunitent
));
9907 Set_Casing
(Mixed_Case
);
9908 Write_Str
(Name_Buffer
(1 .. Name_Len
));
9909 Write_Str
(" is not implemented");
9911 raise Unrecoverable_Error
;
9913 end Unimplemented_Unit
;
9915 --------------------
9916 -- Universal_Data --
9917 --------------------
9919 -- pragma Universal_Data [(library_unit_NAME)];
9921 when Pragma_Universal_Data
=>
9924 -- If this is a configuration pragma, then set the universal
9925 -- addressing option, otherwise confirm that the pragma
9926 -- satisfies the requirements of library unit pragma placement
9927 -- and leave it to the GNAAMP back end to detect the pragma
9928 -- (avoids transitive setting of the option due to withed units).
9930 if Is_Configuration_Pragma
then
9931 Universal_Addressing_On_AAMP
:= True;
9933 Check_Valid_Library_Unit_Pragma
;
9936 if not AAMP_On_Target
then
9937 Error_Pragma
("?pragma% ignored (applies only to AAMP)");
9944 -- pragma Unreferenced (local_Name {, local_Name});
9946 when Pragma_Unreferenced
=> Unreferenced
: declare
9949 Arg_Ent
: Entity_Id
;
9953 Check_At_Least_N_Arguments
(1);
9956 while Present
(Arg_Node
) loop
9957 Check_No_Identifier
(Arg_Node
);
9959 -- Note that the analyze call done by Check_Arg_Is_Local_Name
9960 -- will in fact generate a reference, so that the entity will
9961 -- have a reference, which will inhibit any warnings about it
9962 -- not being referenced, and also properly show up in the ali
9963 -- file as a reference. But this reference is recorded before
9964 -- the Has_Pragma_Unreferenced flag is set, so that no warning
9965 -- is generated for this reference.
9967 Check_Arg_Is_Local_Name
(Arg_Node
);
9968 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
9970 if Is_Entity_Name
(Arg_Expr
) then
9971 Arg_Ent
:= Entity
(Arg_Expr
);
9973 -- If the entity is overloaded, the pragma applies to the
9974 -- most recent overloading, as documented. In this case,
9975 -- name resolution does not generate a reference, so it
9976 -- must be done here explicitly.
9978 if Is_Overloaded
(Arg_Expr
) then
9979 Generate_Reference
(Arg_Ent
, N
);
9982 Set_Has_Pragma_Unreferenced
(Arg_Ent
);
9989 ------------------------------
9990 -- Unreserve_All_Interrupts --
9991 ------------------------------
9993 -- pragma Unreserve_All_Interrupts;
9995 when Pragma_Unreserve_All_Interrupts
=>
9997 Check_Arg_Count
(0);
9999 if In_Extended_Main_Code_Unit
(Main_Unit_Entity
) then
10000 Unreserve_All_Interrupts
:= True;
10007 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
10009 when Pragma_Unsuppress
=>
10011 Process_Suppress_Unsuppress
(False);
10013 -------------------
10014 -- Use_VADS_Size --
10015 -------------------
10017 -- pragma Use_VADS_Size;
10019 when Pragma_Use_VADS_Size
=>
10021 Check_Arg_Count
(0);
10022 Check_Valid_Configuration_Pragma
;
10023 Use_VADS_Size
:= True;
10025 ---------------------
10026 -- Validity_Checks --
10027 ---------------------
10029 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
10031 when Pragma_Validity_Checks
=> Validity_Checks
: declare
10032 A
: constant Node_Id
:= Expression
(Arg1
);
10038 Check_Arg_Count
(1);
10039 Check_No_Identifiers
;
10041 if Nkind
(A
) = N_String_Literal
then
10045 Slen
: constant Natural := Natural (String_Length
(S
));
10046 Options
: String (1 .. Slen
);
10052 C
:= Get_String_Char
(S
, Int
(J
));
10053 exit when not In_Character_Range
(C
);
10054 Options
(J
) := Get_Character
(C
);
10057 Set_Validity_Check_Options
(Options
);
10065 elsif Nkind
(A
) = N_Identifier
then
10067 if Chars
(A
) = Name_All_Checks
then
10068 Set_Validity_Check_Options
("a");
10070 elsif Chars
(A
) = Name_On
then
10071 Validity_Checks_On
:= True;
10073 elsif Chars
(A
) = Name_Off
then
10074 Validity_Checks_On
:= False;
10078 end Validity_Checks
;
10084 -- pragma Volatile (LOCAL_NAME);
10086 when Pragma_Volatile
=>
10087 Process_Atomic_Shared_Volatile
;
10089 -------------------------
10090 -- Volatile_Components --
10091 -------------------------
10093 -- pragma Volatile_Components (array_LOCAL_NAME);
10095 -- Volatile is handled by the same circuit as Atomic_Components
10101 -- pragma Warnings (On | Off, [LOCAL_NAME])
10103 when Pragma_Warnings
=> Warnings
: begin
10105 Check_At_Least_N_Arguments
(1);
10106 Check_At_Most_N_Arguments
(2);
10107 Check_No_Identifiers
;
10109 -- One argument case was processed by parser in Par.Prag
10111 if Arg_Count
/= 1 then
10112 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
10113 Check_Arg_Count
(2);
10120 E_Id
:= Expression
(Arg2
);
10123 -- In the expansion of an inlined body, a reference to
10124 -- the formal may be wrapped in a conversion if the actual
10125 -- is a conversion. Retrieve the real entity name.
10127 if (In_Instance_Body
10128 or else In_Inlined_Body
)
10129 and then Nkind
(E_Id
) = N_Unchecked_Type_Conversion
10131 E_Id
:= Expression
(E_Id
);
10134 if not Is_Entity_Name
(E_Id
) then
10136 ("second argument of pragma% must be entity name",
10140 E
:= Entity
(E_Id
);
10146 Set_Warnings_Off
(E
,
10147 (Chars
(Expression
(Arg1
)) = Name_Off
));
10149 if Is_Enumeration_Type
(E
) then
10153 Lit
:= First_Literal
(E
);
10154 while Present
(Lit
) loop
10155 Set_Warnings_Off
(Lit
);
10156 Next_Literal
(Lit
);
10161 exit when No
(Homonym
(E
));
10169 -------------------
10170 -- Weak_External --
10171 -------------------
10173 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
10175 when Pragma_Weak_External
=> Weak_External
: declare
10180 Check_Arg_Count
(1);
10181 Check_Optional_Identifier
(Arg1
, Name_Entity
);
10182 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
10183 Ent
:= Entity
(Expression
(Arg1
));
10185 if Rep_Item_Too_Early
(Ent
, N
) then
10188 Ent
:= Underlying_Type
(Ent
);
10191 -- The only processing required is to link this item on to the
10192 -- list of rep items for the given entity. This is accomplished
10193 -- by the call to Rep_Item_Too_Late (when no error is detected
10194 -- and False is returned).
10196 if Rep_Item_Too_Late
(Ent
, N
) then
10199 Set_Has_Gigi_Rep_Item
(Ent
);
10203 --------------------
10204 -- Unknown_Pragma --
10205 --------------------
10207 -- Should be impossible, since the case of an unknown pragma is
10208 -- separately processed before the case statement is entered.
10210 when Unknown_Pragma
=>
10211 raise Program_Error
;
10215 when Pragma_Exit
=> null;
10216 end Analyze_Pragma
;
10218 ---------------------------------
10219 -- Delay_Config_Pragma_Analyze --
10220 ---------------------------------
10222 function Delay_Config_Pragma_Analyze
(N
: Node_Id
) return Boolean is
10224 return Chars
(N
) = Name_Interrupt_State
;
10225 end Delay_Config_Pragma_Analyze
;
10227 -------------------------
10228 -- Get_Base_Subprogram --
10229 -------------------------
10231 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
is
10232 Result
: Entity_Id
;
10235 -- Follow subprogram renaming chain
10238 while Is_Subprogram
(Result
)
10240 (Is_Generic_Instance
(Result
)
10241 or else Nkind
(Parent
(Declaration_Node
(Result
))) =
10242 N_Subprogram_Renaming_Declaration
)
10243 and then Present
(Alias
(Result
))
10245 Result
:= Alias
(Result
);
10249 end Get_Base_Subprogram
;
10251 -----------------------------
10252 -- Is_Config_Static_String --
10253 -----------------------------
10255 function Is_Config_Static_String
(Arg
: Node_Id
) return Boolean is
10257 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean;
10258 -- This is an internal recursive function that is just like the
10259 -- outer function except that it adds the string to the name buffer
10260 -- rather than placing the string in the name buffer.
10262 ------------------------------
10263 -- Add_Config_Static_String --
10264 ------------------------------
10266 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean is
10273 if Nkind
(N
) = N_Op_Concat
then
10274 if Add_Config_Static_String
(Left_Opnd
(N
)) then
10275 N
:= Right_Opnd
(N
);
10281 if Nkind
(N
) /= N_String_Literal
then
10282 Error_Msg_N
("string literal expected for pragma argument", N
);
10286 for J
in 1 .. String_Length
(Strval
(N
)) loop
10287 C
:= Get_String_Char
(Strval
(N
), J
);
10289 if not In_Character_Range
(C
) then
10291 ("string literal contains invalid wide character",
10292 Sloc
(N
) + 1 + Source_Ptr
(J
));
10296 Add_Char_To_Name_Buffer
(Get_Character
(C
));
10301 end Add_Config_Static_String
;
10303 -- Start of prorcessing for Is_Config_Static_String
10308 return Add_Config_Static_String
(Arg
);
10309 end Is_Config_Static_String
;
10311 -----------------------------------------
10312 -- Is_Non_Significant_Pragma_Reference --
10313 -----------------------------------------
10315 -- This function makes use of the following static table which indicates
10316 -- whether a given pragma is significant. A value of -1 in this table
10317 -- indicates that the reference is significant. A value of zero indicates
10318 -- than appearence as any argument is insignificant, a positive value
10319 -- indicates that appearence in that parameter position is significant.
10321 Sig_Flags
: constant array (Pragma_Id
) of Int
:=
10323 (Pragma_AST_Entry
=> -1,
10324 Pragma_Abort_Defer
=> -1,
10325 Pragma_Ada_83
=> -1,
10326 Pragma_Ada_95
=> -1,
10327 Pragma_Ada_05
=> -1,
10328 Pragma_All_Calls_Remote
=> -1,
10329 Pragma_Annotate
=> -1,
10330 Pragma_Assert
=> -1,
10331 Pragma_Asynchronous
=> -1,
10332 Pragma_Atomic
=> 0,
10333 Pragma_Atomic_Components
=> 0,
10334 Pragma_Attach_Handler
=> -1,
10335 Pragma_CPP_Class
=> 0,
10336 Pragma_CPP_Constructor
=> 0,
10337 Pragma_CPP_Virtual
=> 0,
10338 Pragma_CPP_Vtable
=> 0,
10339 Pragma_C_Pass_By_Copy
=> 0,
10340 Pragma_Comment
=> 0,
10341 Pragma_Common_Object
=> -1,
10342 Pragma_Compile_Time_Warning
=> -1,
10343 Pragma_Complex_Representation
=> 0,
10344 Pragma_Component_Alignment
=> -1,
10345 Pragma_Controlled
=> 0,
10346 Pragma_Convention
=> 0,
10347 Pragma_Convention_Identifier
=> 0,
10348 Pragma_Debug
=> -1,
10349 Pragma_Detect_Blocking
=> -1,
10350 Pragma_Discard_Names
=> 0,
10351 Pragma_Elaborate
=> -1,
10352 Pragma_Elaborate_All
=> -1,
10353 Pragma_Elaborate_Body
=> -1,
10354 Pragma_Elaboration_Checks
=> -1,
10355 Pragma_Eliminate
=> -1,
10356 Pragma_Explicit_Overriding
=> -1,
10357 Pragma_Export
=> -1,
10358 Pragma_Export_Exception
=> -1,
10359 Pragma_Export_Function
=> -1,
10360 Pragma_Export_Object
=> -1,
10361 Pragma_Export_Procedure
=> -1,
10362 Pragma_Export_Value
=> -1,
10363 Pragma_Export_Valued_Procedure
=> -1,
10364 Pragma_Extend_System
=> -1,
10365 Pragma_Extensions_Allowed
=> -1,
10366 Pragma_External
=> -1,
10367 Pragma_External_Name_Casing
=> -1,
10368 Pragma_Finalize_Storage_Only
=> 0,
10369 Pragma_Float_Representation
=> 0,
10370 Pragma_Ident
=> -1,
10371 Pragma_Import
=> +2,
10372 Pragma_Import_Exception
=> 0,
10373 Pragma_Import_Function
=> 0,
10374 Pragma_Import_Object
=> 0,
10375 Pragma_Import_Procedure
=> 0,
10376 Pragma_Import_Valued_Procedure
=> 0,
10377 Pragma_Initialize_Scalars
=> -1,
10378 Pragma_Inline
=> 0,
10379 Pragma_Inline_Always
=> 0,
10380 Pragma_Inline_Generic
=> 0,
10381 Pragma_Inspection_Point
=> -1,
10382 Pragma_Interface
=> +2,
10383 Pragma_Interface_Name
=> +2,
10384 Pragma_Interrupt_Handler
=> -1,
10385 Pragma_Interrupt_Priority
=> -1,
10386 Pragma_Interrupt_State
=> -1,
10387 Pragma_Java_Constructor
=> -1,
10388 Pragma_Java_Interface
=> -1,
10389 Pragma_Keep_Names
=> 0,
10390 Pragma_License
=> -1,
10391 Pragma_Link_With
=> -1,
10392 Pragma_Linker_Alias
=> -1,
10393 Pragma_Linker_Options
=> -1,
10394 Pragma_Linker_Section
=> -1,
10396 Pragma_Locking_Policy
=> -1,
10397 Pragma_Long_Float
=> -1,
10398 Pragma_Machine_Attribute
=> -1,
10400 Pragma_Main_Storage
=> -1,
10401 Pragma_Memory_Size
=> -1,
10402 Pragma_No_Return
=> 0,
10403 Pragma_No_Run_Time
=> -1,
10404 Pragma_No_Strict_Aliasing
=> -1,
10405 Pragma_Normalize_Scalars
=> -1,
10406 Pragma_Obsolescent
=> 0,
10407 Pragma_Optimize
=> -1,
10408 Pragma_Optional_Overriding
=> -1,
10411 Pragma_Passive
=> -1,
10412 Pragma_Polling
=> -1,
10413 Pragma_Persistent_Data
=> -1,
10414 Pragma_Persistent_Object
=> -1,
10415 Pragma_Preelaborate
=> -1,
10416 Pragma_Priority
=> -1,
10417 Pragma_Profile
=> 0,
10418 Pragma_Profile_Warnings
=> 0,
10419 Pragma_Propagate_Exceptions
=> -1,
10420 Pragma_Psect_Object
=> -1,
10422 Pragma_Pure_Function
=> 0,
10423 Pragma_Queuing_Policy
=> -1,
10424 Pragma_Ravenscar
=> -1,
10425 Pragma_Remote_Call_Interface
=> -1,
10426 Pragma_Remote_Types
=> -1,
10427 Pragma_Restricted_Run_Time
=> -1,
10428 Pragma_Restriction_Warnings
=> -1,
10429 Pragma_Restrictions
=> -1,
10430 Pragma_Reviewable
=> -1,
10431 Pragma_Share_Generic
=> -1,
10432 Pragma_Shared
=> -1,
10433 Pragma_Shared_Passive
=> -1,
10434 Pragma_Source_File_Name
=> -1,
10435 Pragma_Source_File_Name_Project
=> -1,
10436 Pragma_Source_Reference
=> -1,
10437 Pragma_Storage_Size
=> -1,
10438 Pragma_Storage_Unit
=> -1,
10439 Pragma_Stream_Convert
=> -1,
10440 Pragma_Style_Checks
=> -1,
10441 Pragma_Subtitle
=> -1,
10442 Pragma_Suppress
=> 0,
10443 Pragma_Suppress_Exception_Locations
=> 0,
10444 Pragma_Suppress_All
=> -1,
10445 Pragma_Suppress_Debug_Info
=> 0,
10446 Pragma_Suppress_Initialization
=> 0,
10447 Pragma_System_Name
=> -1,
10448 Pragma_Task_Dispatching_Policy
=> -1,
10449 Pragma_Task_Info
=> -1,
10450 Pragma_Task_Name
=> -1,
10451 Pragma_Task_Storage
=> 0,
10452 Pragma_Thread_Body
=> +2,
10453 Pragma_Time_Slice
=> -1,
10454 Pragma_Title
=> -1,
10455 Pragma_Unchecked_Union
=> 0,
10456 Pragma_Unimplemented_Unit
=> -1,
10457 Pragma_Universal_Data
=> -1,
10458 Pragma_Unreferenced
=> -1,
10459 Pragma_Unreserve_All_Interrupts
=> -1,
10460 Pragma_Unsuppress
=> 0,
10461 Pragma_Use_VADS_Size
=> -1,
10462 Pragma_Validity_Checks
=> -1,
10463 Pragma_Volatile
=> 0,
10464 Pragma_Volatile_Components
=> 0,
10465 Pragma_Warnings
=> -1,
10466 Pragma_Weak_External
=> 0,
10467 Unknown_Pragma
=> 0);
10469 function Is_Non_Significant_Pragma_Reference
(N
: Node_Id
) return Boolean is
10477 if Nkind
(P
) /= N_Pragma_Argument_Association
then
10481 C
:= Sig_Flags
(Get_Pragma_Id
(Chars
(Parent
(P
))));
10491 A
:= First
(Pragma_Argument_Associations
(Parent
(P
)));
10492 for J
in 1 .. C
- 1 loop
10503 end Is_Non_Significant_Pragma_Reference
;
10505 ------------------------------
10506 -- Is_Pragma_String_Literal --
10507 ------------------------------
10509 -- This function returns true if the corresponding pragma argument is
10510 -- a static string expression. These are the only cases in which string
10511 -- literals can appear as pragma arguments. We also allow a string
10512 -- literal as the first argument to pragma Assert (although it will
10513 -- of course always generate a type error).
10515 function Is_Pragma_String_Literal
(Par
: Node_Id
) return Boolean is
10516 Pragn
: constant Node_Id
:= Parent
(Par
);
10517 Assoc
: constant List_Id
:= Pragma_Argument_Associations
(Pragn
);
10518 Pname
: constant Name_Id
:= Chars
(Pragn
);
10524 N
:= First
(Assoc
);
10531 if Pname
= Name_Assert
then
10534 elsif Pname
= Name_Export
then
10537 elsif Pname
= Name_Ident
then
10540 elsif Pname
= Name_Import
then
10543 elsif Pname
= Name_Interface_Name
then
10546 elsif Pname
= Name_Linker_Alias
then
10549 elsif Pname
= Name_Linker_Section
then
10552 elsif Pname
= Name_Machine_Attribute
then
10555 elsif Pname
= Name_Source_File_Name
then
10558 elsif Pname
= Name_Source_Reference
then
10561 elsif Pname
= Name_Title
then
10564 elsif Pname
= Name_Subtitle
then
10570 end Is_Pragma_String_Literal
;
10572 --------------------------------------
10573 -- Process_Compilation_Unit_Pragmas --
10574 --------------------------------------
10576 procedure Process_Compilation_Unit_Pragmas
(N
: Node_Id
) is
10578 -- A special check for pragma Suppress_All. This is a strange DEC
10579 -- pragma, strange because it comes at the end of the unit. If we
10580 -- have a pragma Suppress_All in the Pragmas_After of the current
10581 -- unit, then we insert a pragma Suppress (All_Checks) at the start
10582 -- of the context clause to ensure the correct processing.
10585 PA
: constant List_Id
:= Pragmas_After
(Aux_Decls_Node
(N
));
10589 if Present
(PA
) then
10591 while Present
(P
) loop
10592 if Chars
(P
) = Name_Suppress_All
then
10593 Prepend_To
(Context_Items
(N
),
10594 Make_Pragma
(Sloc
(P
),
10595 Chars
=> Name_Suppress
,
10596 Pragma_Argument_Associations
=> New_List
(
10597 Make_Pragma_Argument_Association
(Sloc
(P
),
10599 Make_Identifier
(Sloc
(P
),
10600 Chars
=> Name_All_Checks
)))));
10608 end Process_Compilation_Unit_Pragmas
;
10610 --------------------------------
10611 -- Set_Encoded_Interface_Name --
10612 --------------------------------
10614 procedure Set_Encoded_Interface_Name
(E
: Entity_Id
; S
: Node_Id
) is
10615 Str
: constant String_Id
:= Strval
(S
);
10616 Len
: constant Int
:= String_Length
(Str
);
10621 Hex
: constant array (0 .. 15) of Character := "0123456789abcdef";
10624 -- Stores encoded value of character code CC. The encoding we
10625 -- use an underscore followed by four lower case hex digits.
10631 procedure Encode
is
10633 Store_String_Char
(Get_Char_Code
('_'));
10635 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 12))));
10637 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 8 and 16#
0F#
))));
10639 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 4 and 16#
0F#
))));
10641 (Get_Char_Code
(Hex
(Integer (CC
and 16#
0F#
))));
10644 -- Start of processing for Set_Encoded_Interface_Name
10647 -- If first character is asterisk, this is a link name, and we
10648 -- leave it completely unmodified. We also ignore null strings
10649 -- (the latter case happens only in error cases) and no encoding
10650 -- should occur for Java interface names.
10653 or else Get_String_Char
(Str
, 1) = Get_Char_Code
('*')
10656 Set_Interface_Name
(E
, S
);
10661 CC
:= Get_String_Char
(Str
, J
);
10663 exit when not In_Character_Range
(CC
);
10665 C
:= Get_Character
(CC
);
10667 exit when C
/= '_' and then C
/= '$'
10668 and then C
not in '0' .. '9'
10669 and then C
not in 'a' .. 'z'
10670 and then C
not in 'A' .. 'Z';
10673 Set_Interface_Name
(E
, S
);
10681 -- Here we need to encode. The encoding we use as follows:
10682 -- three underscores + four hex digits (lower case)
10686 for J
in 1 .. String_Length
(Str
) loop
10687 CC
:= Get_String_Char
(Str
, J
);
10689 if not In_Character_Range
(CC
) then
10692 C
:= Get_Character
(CC
);
10694 if C
= '_' or else C
= '$'
10695 or else C
in '0' .. '9'
10696 or else C
in 'a' .. 'z'
10697 or else C
in 'A' .. 'Z'
10699 Store_String_Char
(CC
);
10706 Set_Interface_Name
(E
,
10707 Make_String_Literal
(Sloc
(S
),
10708 Strval
=> End_String
));
10710 end Set_Encoded_Interface_Name
;
10712 -------------------
10713 -- Set_Unit_Name --
10714 -------------------
10716 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
) is
10721 if Nkind
(N
) = N_Identifier
10722 and then Nkind
(With_Item
) = N_Identifier
10724 Set_Entity
(N
, Entity
(With_Item
));
10726 elsif Nkind
(N
) = N_Selected_Component
then
10727 Change_Selected_Component_To_Expanded_Name
(N
);
10728 Set_Entity
(N
, Entity
(With_Item
));
10729 Set_Entity
(Selector_Name
(N
), Entity
(N
));
10731 Pref
:= Prefix
(N
);
10732 Scop
:= Scope
(Entity
(N
));
10733 while Nkind
(Pref
) = N_Selected_Component
loop
10734 Change_Selected_Component_To_Expanded_Name
(Pref
);
10735 Set_Entity
(Selector_Name
(Pref
), Scop
);
10736 Set_Entity
(Pref
, Scop
);
10737 Pref
:= Prefix
(Pref
);
10738 Scop
:= Scope
(Scop
);
10741 Set_Entity
(Pref
, Scop
);