1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- This unit contains the semantic processing for all pragmas, both language
28 -- and implementation defined. For most pragmas, the parser only does the
29 -- most basic job of checking the syntax, so Sem_Prag also contains the code
30 -- to complete the syntax checks. Certain pragmas are handled partially or
31 -- completely by the parser (see Par.Prag for further details).
33 with Atree
; use Atree
;
34 with Casing
; use Casing
;
35 with Csets
; use Csets
;
36 with Debug
; use Debug
;
37 with Einfo
; use Einfo
;
38 with Elists
; use Elists
;
39 with Errout
; use Errout
;
40 with Exp_Dist
; use Exp_Dist
;
41 with 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_Elim
; use Sem_Elim
;
59 with Sem_Eval
; use Sem_Eval
;
60 with Sem_Intr
; use Sem_Intr
;
61 with Sem_Mech
; use Sem_Mech
;
62 with Sem_Res
; use Sem_Res
;
63 with Sem_Type
; use Sem_Type
;
64 with Sem_Util
; use Sem_Util
;
65 with Sem_VFpt
; use Sem_VFpt
;
66 with Stand
; use Stand
;
67 with Sinfo
; use Sinfo
;
68 with Sinfo
.CN
; use Sinfo
.CN
;
69 with Sinput
; use Sinput
;
70 with Snames
; use Snames
;
71 with Stringt
; use Stringt
;
72 with Stylesw
; use Stylesw
;
74 with Targparm
; use Targparm
;
75 with Tbuild
; use Tbuild
;
77 with Uintp
; use Uintp
;
78 with Urealp
; use Urealp
;
79 with Validsw
; use Validsw
;
81 with GNAT
.Spelling_Checker
; use GNAT
.Spelling_Checker
;
83 package body Sem_Prag
is
85 ----------------------------------------------
86 -- Common Handling of Import-Export Pragmas --
87 ----------------------------------------------
89 -- In the following section, a number of Import_xxx and Export_xxx
90 -- pragmas are defined by GNAT. These are compatible with the DEC
91 -- pragmas of the same name, and all have the following common
92 -- form and processing:
95 -- [Internal =>] LOCAL_NAME,
96 -- [, [External =>] EXTERNAL_SYMBOL]
97 -- [, other optional parameters ]);
100 -- [Internal =>] LOCAL_NAME,
101 -- [, [External =>] EXTERNAL_SYMBOL]
102 -- [, other optional parameters ]);
104 -- EXTERNAL_SYMBOL ::=
106 -- | static_string_EXPRESSION
108 -- The internal LOCAL_NAME designates the entity that is imported or
109 -- exported, and must refer to an entity in the current declarative
110 -- part (as required by the rules for LOCAL_NAME).
112 -- The external linker name is designated by the External parameter
113 -- if given, or the Internal parameter if not (if there is no External
114 -- parameter, the External parameter is a copy of the Internal name).
116 -- If the External parameter is given as a string, then this string
117 -- is treated as an external name (exactly as though it had been given
118 -- as an External_Name parameter for a normal Import pragma).
120 -- If the External parameter is given as an identifier (or there is no
121 -- External parameter, so that the Internal identifier is used), then
122 -- the external name is the characters of the identifier, translated
123 -- to all upper case letters for OpenVMS versions of GNAT, and to all
124 -- lower case letters for all other versions
126 -- Note: the external name specified or implied by any of these special
127 -- Import_xxx or Export_xxx pragmas override an external or link name
128 -- specified in a previous Import or Export pragma.
130 -- Note: these and all other DEC-compatible GNAT pragmas allow full
131 -- use of named notation, following the standard rules for subprogram
132 -- calls, i.e. parameters can be given in any order if named notation
133 -- is used, and positional and named notation can be mixed, subject to
134 -- the rule that all positional parameters must appear first.
136 -- Note: All these pragmas are implemented exactly following the DEC
137 -- design and implementation and are intended to be fully compatible
138 -- with the use of these pragmas in the DEC Ada compiler.
140 --------------------------------------------
141 -- Checking for Duplicated External Names --
142 --------------------------------------------
144 -- It is suspicious if two separate Export pragmas use the same external
145 -- name. The following table is used to diagnose this situation so that
146 -- an appropriate warning can be issued.
148 -- The Node_Id stored is for the N_String_Literal node created to
149 -- hold the value of the external name. The Sloc of this node is
150 -- used to cross-reference the location of the duplication.
152 package Externals
is new Table
.Table
(
153 Table_Component_Type
=> Node_Id
,
154 Table_Index_Type
=> Int
,
155 Table_Low_Bound
=> 0,
156 Table_Initial
=> 100,
157 Table_Increment
=> 100,
158 Table_Name
=> "Name_Externals");
160 -------------------------------------
161 -- Local Subprograms and Variables --
162 -------------------------------------
164 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
;
165 -- This routine is used for possible casing adjustment of an explicit
166 -- external name supplied as a string literal (the node N), according
167 -- to the casing requirement of Opt.External_Name_Casing. If this is
168 -- set to As_Is, then the string literal is returned unchanged, but if
169 -- it is set to Uppercase or Lowercase, then a new string literal with
170 -- appropriate casing is constructed.
172 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
;
173 -- If Def_Id refers to a renamed subprogram, then the base subprogram
174 -- (the original one, following the renaming chain) is returned.
175 -- Otherwise the entity is returned unchanged. Should be in Einfo???
177 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
);
178 -- Place semantic information on the argument of an Elaborate or
179 -- Elaborate_All pragma. Entity name for unit and its parents is
180 -- taken from item in previous with_clause that mentions the unit.
182 -------------------------------
183 -- Adjust_External_Name_Case --
184 -------------------------------
186 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
is
190 -- Adjust case of literal if required
192 if Opt
.External_Name_Exp_Casing
= As_Is
then
196 -- Copy existing string
202 for J
in 1 .. String_Length
(Strval
(N
)) loop
203 CC
:= Get_String_Char
(Strval
(N
), J
);
205 if Opt
.External_Name_Exp_Casing
= Uppercase
206 and then CC
>= Get_Char_Code
('a')
207 and then CC
<= Get_Char_Code
('z')
209 Store_String_Char
(CC
- 32);
211 elsif Opt
.External_Name_Exp_Casing
= Lowercase
212 and then CC
>= Get_Char_Code
('A')
213 and then CC
<= Get_Char_Code
('Z')
215 Store_String_Char
(CC
+ 32);
218 Store_String_Char
(CC
);
223 Make_String_Literal
(Sloc
(N
),
224 Strval
=> End_String
);
226 end Adjust_External_Name_Case
;
232 procedure Analyze_Pragma
(N
: Node_Id
) is
233 Loc
: constant Source_Ptr
:= Sloc
(N
);
236 Pragma_Exit
: exception;
237 -- This exception is used to exit pragma processing completely. It
238 -- is used when an error is detected, and in other situations where
239 -- it is known that no further processing is required.
242 -- Number of pragma argument associations
248 -- First four pragma arguments (pragma argument association nodes,
249 -- or Empty if the corresponding argument does not exist).
251 procedure Check_Ada_83_Warning
;
252 -- Issues a warning message for the current pragma if operating in Ada
253 -- 83 mode (used for language pragmas that are not a standard part of
254 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
257 procedure Check_Arg_Count
(Required
: Nat
);
258 -- Check argument count for pragma is equal to given parameter.
259 -- If not, then issue an error message and raise Pragma_Exit.
261 -- Note: all routines whose name is Check_Arg_Is_xxx take an
262 -- argument Arg which can either be a pragma argument association,
263 -- in which case the check is applied to the expression of the
264 -- association or an expression directly.
266 procedure Check_Arg_Is_External_Name
(Arg
: Node_Id
);
267 -- Check that an argument has the right form for an EXTERNAL_NAME
268 -- parameter of an extended import/export pragma. The rule is that
269 -- the name must be an identifier or string literal (in Ada 83 mode)
270 -- or a static string expression (in Ada 95 mode).
272 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
);
273 -- Check the specified argument Arg to make sure that it is an
274 -- identifier. If not give error and raise Pragma_Exit.
276 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
);
277 -- Check the specified argument Arg to make sure that it is an
278 -- integer literal. If not give error and raise Pragma_Exit.
280 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
);
281 -- Check the specified argument Arg to make sure that it has the
282 -- proper syntactic form for a local name and meets the semantic
283 -- requirements for a local name. The local name is analyzed as
284 -- part of the processing for this call. In addition, the local
285 -- name is required to represent an entity at the library level.
287 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
);
288 -- Check the specified argument Arg to make sure that it has the
289 -- proper syntactic form for a local name and meets the semantic
290 -- requirements for a local name. The local name is analyzed as
291 -- part of the processing for this call.
293 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
);
294 -- Check the specified argument Arg to make sure that it is a valid
295 -- locking policy name. If not give error and raise Pragma_Exit.
297 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
);
298 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
, N3
: Name_Id
);
299 -- Check the specified argument Arg to make sure that it is an
300 -- identifier whose name matches either N1 or N2 (or N3 if present).
301 -- If not then give error and raise Pragma_Exit.
303 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
);
304 -- Check the specified argument Arg to make sure that it is a valid
305 -- queuing policy name. If not give error and raise Pragma_Exit.
307 procedure Check_Arg_Is_Static_Expression
310 -- Check the specified argument Arg to make sure that it is a static
311 -- expression of the given type (i.e. it will be analyzed and resolved
312 -- using this type, which can be any valid argument to Resolve, e.g.
313 -- Any_Integer is OK). If not, given error and raise Pragma_Exit.
315 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
);
316 -- Check the specified argument Arg to make sure that it is a
317 -- string literal. If not give error and raise Pragma_Exit
319 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
);
320 -- Check the specified argument Arg to make sure that it is a valid
321 -- valid task dispatching policy name. If not give error and raise
324 procedure Check_At_Least_N_Arguments
(N
: Nat
);
325 -- Check there are at least N arguments present
327 procedure Check_At_Most_N_Arguments
(N
: Nat
);
328 -- Check there are no more than N arguments present
330 procedure Check_Component
(Comp
: Node_Id
);
331 -- Examine Unchecked_Union component for correct use of per-object
332 -- constrained subtypes.
334 procedure Check_Duplicated_Export_Name
(Nam
: Node_Id
);
335 -- Nam is an N_String_Literal node containing the external name set
336 -- by an Import or Export pragma (or extended Import or Export pragma).
337 -- This procedure checks for possible duplications if this is the
338 -- export case, and if found, issues an appropriate error message.
340 procedure Check_First_Subtype
(Arg
: Node_Id
);
341 -- Checks that Arg, whose expression is an entity name referencing
342 -- a subtype, does not reference a type that is not a first subtype.
344 procedure Check_In_Main_Program
;
345 -- Common checks for pragmas that appear within a main program
346 -- (Priority, Main_Storage, Time_Slice).
348 procedure Check_Interrupt_Or_Attach_Handler
;
349 -- Common processing for first argument of pragma Interrupt_Handler
350 -- or pragma Attach_Handler.
352 procedure Check_Is_In_Decl_Part_Or_Package_Spec
;
353 -- Check that pragma appears in a declarative part, or in a package
354 -- specification, i.e. that it does not occur in a statement sequence
357 procedure Check_No_Identifier
(Arg
: Node_Id
);
358 -- Checks that the given argument does not have an identifier. If
359 -- an identifier is present, then an error message is issued, and
360 -- Pragma_Exit is raised.
362 procedure Check_No_Identifiers
;
363 -- Checks that none of the arguments to the pragma has an identifier.
364 -- If any argument has an identifier, then an error message is issued,
365 -- and Pragma_Exit is raised.
367 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
);
368 -- Checks if the given argument has an identifier, and if so, requires
369 -- it to match the given identifier name. If there is a non-matching
370 -- identifier, then an error message is given and Error_Pragmas raised.
372 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String);
373 -- Checks if the given argument has an identifier, and if so, requires
374 -- it to match the given identifier name. If there is a non-matching
375 -- identifier, then an error message is given and Error_Pragmas raised.
376 -- In this version of the procedure, the identifier name is given as
377 -- a string with lower case letters.
379 procedure Check_Static_Constraint
(Constr
: Node_Id
);
380 -- Constr is a constraint from an N_Subtype_Indication node from a
381 -- component constraint in an Unchecked_Union type. This routine checks
382 -- that the constraint is static as required by the restrictions for
385 procedure Check_Valid_Configuration_Pragma
;
386 -- Legality checks for placement of a configuration pragma
388 procedure Check_Valid_Library_Unit_Pragma
;
389 -- Legality checks for library unit pragmas. A special case arises for
390 -- pragmas in generic instances that come from copies of the original
391 -- library unit pragmas in the generic templates. In the case of other
392 -- than library level instantiations these can appear in contexts which
393 -- would normally be invalid (they only apply to the original template
394 -- and to library level instantiations), and they are simply ignored,
395 -- which is implemented by rewriting them as null statements.
397 procedure Check_Variant
(Variant
: Node_Id
);
398 -- Check Unchecked_Union variant for lack of nested variants and
399 -- presence of at least one component.
401 procedure Error_Pragma
(Msg
: String);
402 pragma No_Return
(Error_Pragma
);
403 -- Outputs error message for current pragma. The message contains an %
404 -- that will be replaced with the pragma name, and the flag is placed
405 -- on the pragma itself. Pragma_Exit is then raised.
407 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
);
408 pragma No_Return
(Error_Pragma_Arg
);
409 -- Outputs error message for current pragma. The message may contain
410 -- a % that will be replaced with the pragma name. The parameter Arg
411 -- may either be a pragma argument association, in which case the flag
412 -- is placed on the expression of this association, or an expression,
413 -- in which case the flag is placed directly on the expression. The
414 -- message is placed using Error_Msg_N, so the message may also contain
415 -- an & insertion character which will reference the given Arg value.
416 -- After placing the message, Pragma_Exit is raised.
418 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
);
419 pragma No_Return
(Error_Pragma_Arg
);
420 -- Similar to above form of Error_Pragma_Arg except that two messages
421 -- are provided, the second is a continuation comment starting with \.
423 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
);
424 pragma No_Return
(Error_Pragma_Arg_Ident
);
425 -- Outputs error message for current pragma. The message may contain
426 -- a % that will be replaced with the pragma name. The parameter Arg
427 -- must be a pragma argument association with a non-empty identifier
428 -- (i.e. its Chars field must be set), and the error message is placed
429 -- on the identifier. The message is placed using Error_Msg_N so
430 -- the message may also contain an & insertion character which will
431 -- reference the identifier. After placing the message, Pragma_Exit
434 function Find_Lib_Unit_Name
return Entity_Id
;
435 -- Used for a library unit pragma to find the entity to which the
436 -- library unit pragma applies, returns the entity found.
438 procedure Find_Program_Unit_Name
(Id
: Node_Id
);
439 -- If the pragma is a compilation unit pragma, the id must denote the
440 -- compilation unit in the same compilation, and the pragma must appear
441 -- in the list of preceding or trailing pragmas. If it is a program
442 -- unit pragma that is not a compilation unit pragma, then the
443 -- identifier must be visible.
445 type Name_List
is array (Natural range <>) of Name_Id
;
446 type Args_List
is array (Natural range <>) of Node_Id
;
447 procedure Gather_Associations
449 Args
: out Args_List
);
450 -- This procedure is used to gather the arguments for a pragma that
451 -- permits arbitrary ordering of parameters using the normal rules
452 -- for named and positional parameters. The Names argument is a list
453 -- of Name_Id values that corresponds to the allowed pragma argument
454 -- association identifiers in order. The result returned in Args is
455 -- a list of corresponding expressions that are the pragma arguments.
456 -- Note that this is a list of expressions, not of pragma argument
457 -- associations (Gather_Associations has completely checked all the
458 -- optional identifiers when it returns). An entry in Args is Empty
459 -- on return if the corresponding argument is not present.
461 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
;
462 -- All the routines that check pragma arguments take either a pragma
463 -- argument association (in which case the expression of the argument
464 -- association is checked), or the expression directly. The function
465 -- Get_Pragma_Arg is a utility used to deal with these two cases. If
466 -- Arg is a pragma argument association node, then its expression is
467 -- returned, otherwise Arg is returned unchanged.
469 procedure GNAT_Pragma
;
470 -- Called for all GNAT defined pragmas to note the use of the feature,
471 -- and also check the relevant restriction (No_Implementation_Pragmas).
473 function Is_Before_First_Decl
474 (Pragma_Node
: Node_Id
;
475 Decls
: List_Id
) return Boolean;
476 -- Return True if Pragma_Node is before the first declarative item in
477 -- Decls where Decls is the list of declarative items.
479 function Is_Configuration_Pragma
return Boolean;
480 -- Deterermines if the placement of the current pragma is appropriate
481 -- for a configuration pragma (precedes the current compilation unit)
483 procedure Pragma_Misplaced
;
484 -- Issue fatal error message for misplaced pragma
486 procedure Process_Atomic_Shared_Volatile
;
487 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
488 -- Shared is an obsolete Ada 83 pragma, treated as being identical
489 -- in effect to pragma Atomic.
491 procedure Process_Convention
(C
: out Convention_Id
; E
: out Entity_Id
);
492 -- Common procesing for Convention, Interface, Import and Export.
493 -- Checks first two arguments of pragma, and sets the appropriate
494 -- convention value in the specified entity or entities. On return
495 -- C is the convention, E is the referenced entity.
497 procedure Process_Extended_Import_Export_Exception_Pragma
498 (Arg_Internal
: Node_Id
;
499 Arg_External
: Node_Id
;
502 -- Common processing for the pragmas Import/Export_Exception.
503 -- The three arguments correspond to the three named parameters of
504 -- the pragma. An argument is empty if the corresponding parameter
505 -- is not present in the pragma.
507 procedure Process_Extended_Import_Export_Object_Pragma
508 (Arg_Internal
: Node_Id
;
509 Arg_External
: Node_Id
;
511 -- Common processing for the pragmass Import/Export_Object.
512 -- The three arguments correspond to the three named parameters
513 -- of the pragmas. An argument is empty if the corresponding
514 -- parameter is not present in the pragma.
516 procedure Process_Extended_Import_Export_Internal_Arg
517 (Arg_Internal
: Node_Id
:= Empty
);
518 -- Common processing for all extended Import and Export pragmas. The
519 -- argument is the pragma parameter for the Internal argument. If
520 -- Arg_Internal is empty or inappropriate, an error message is posted.
521 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
522 -- set to identify the referenced entity.
524 procedure Process_Extended_Import_Export_Subprogram_Pragma
525 (Arg_Internal
: Node_Id
;
526 Arg_External
: Node_Id
;
527 Arg_Parameter_Types
: Node_Id
;
528 Arg_Result_Type
: Node_Id
:= Empty
;
529 Arg_Mechanism
: Node_Id
;
530 Arg_Result_Mechanism
: Node_Id
:= Empty
;
531 Arg_First_Optional_Parameter
: Node_Id
:= Empty
);
532 -- Common processing for all extended Import and Export pragmas
533 -- applying to subprograms. The caller omits any arguments that do
534 -- bnot apply to the pragma in question (for example, Arg_Result_Type
535 -- can be non-Empty only in the Import_Function and Export_Function
536 -- cases). The argument names correspond to the allowed pragma
537 -- association identifiers.
539 procedure Process_Generic_List
;
540 -- Common processing for Share_Generic and Inline_Generic
542 procedure Process_Import_Or_Interface
;
543 -- Common processing for Import of Interface
545 procedure Process_Inline
(Active
: Boolean);
546 -- Common processing for Inline and Inline_Always. The parameter
547 -- indicates if the inline pragma is active, i.e. if it should
548 -- actually cause inlining to occur.
550 procedure Process_Interface_Name
551 (Subprogram_Def
: Entity_Id
;
554 -- Given the last two arguments of pragma Import, pragma Export, or
555 -- pragma Interface_Name, performs validity checks and sets the
556 -- Interface_Name field of the given subprogram entity to the
557 -- appropriate external or link name, depending on the arguments
558 -- given. Ext_Arg is always present, but Link_Arg may be missing.
559 -- Note that Ext_Arg may represent the Link_Name if Link_Arg is
560 -- missing, and appropriate named notation is used for Ext_Arg.
561 -- If neither Ext_Arg nor Link_Arg is present, the interface name
562 -- is set to the default from the subprogram name.
564 procedure Process_Interrupt_Or_Attach_Handler
;
565 -- Common processing for Interrupt and Attach_Handler pragmas
567 procedure Process_Restrictions_Or_Restriction_Warnings
;
568 -- Common processing for Restrictions and Restriction_Warnings pragmas
570 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean);
571 -- Common processing for Suppress and Unsuppress. The boolean parameter
572 -- Suppress_Case is True for the Suppress case, and False for the
575 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
);
576 -- This procedure sets the Is_Exported flag for the given entity,
577 -- checking that the entity was not previously imported. Arg is
578 -- the argument that specified the entity. A check is also made
579 -- for exporting inappropriate entities.
581 procedure Set_Extended_Import_Export_External_Name
582 (Internal_Ent
: Entity_Id
;
583 Arg_External
: Node_Id
);
584 -- Common processing for all extended import export pragmas. The first
585 -- argument, Internal_Ent, is the internal entity, which has already
586 -- been checked for validity by the caller. Arg_External is from the
587 -- Import or Export pragma, and may be null if no External parameter
588 -- was present. If Arg_External is present and is a non-null string
589 -- (a null string is treated as the default), then the Interface_Name
590 -- field of Internal_Ent is set appropriately.
592 procedure Set_Imported
(E
: Entity_Id
);
593 -- This procedure sets the Is_Imported flag for the given entity,
594 -- checking that it is not previously exported or imported.
596 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
);
597 -- Mech is a parameter passing mechanism (see Import_Function syntax
598 -- for MECHANISM_NAME). This routine checks that the mechanism argument
599 -- has the right form, and if not issues an error message. If the
600 -- argument has the right form then the Mechanism field of Ent is
601 -- set appropriately.
603 procedure Set_Ravenscar_Profile
(N
: Node_Id
);
604 -- Activate the set of configuration pragmas and restrictions that
605 -- make up the Ravenscar Profile. N is the corresponding pragma
606 -- node, which is used for error messages on any constructs
607 -- that violate the profile.
609 --------------------------
610 -- Check_Ada_83_Warning --
611 --------------------------
613 procedure Check_Ada_83_Warning
is
615 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
616 Error_Msg_N
("(Ada 83) pragma& is non-standard?", N
);
618 end Check_Ada_83_Warning
;
620 ---------------------
621 -- Check_Arg_Count --
622 ---------------------
624 procedure Check_Arg_Count
(Required
: Nat
) is
626 if Arg_Count
/= Required
then
627 Error_Pragma
("wrong number of arguments for pragma%");
631 --------------------------------
632 -- Check_Arg_Is_External_Name --
633 --------------------------------
635 procedure Check_Arg_Is_External_Name
(Arg
: Node_Id
) is
636 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
639 if Nkind
(Argx
) = N_Identifier
then
643 Analyze_And_Resolve
(Argx
, Standard_String
);
645 if Is_OK_Static_Expression
(Argx
) then
648 elsif Etype
(Argx
) = Any_Type
then
651 -- An interesting special case, if we have a string literal and
652 -- we are in Ada 83 mode, then we allow it even though it will
653 -- not be flagged as static. This allows expected Ada 83 mode
654 -- use of external names which are string literals, even though
655 -- technically these are not static in Ada 83.
657 elsif Ada_Version
= Ada_83
658 and then Nkind
(Argx
) = N_String_Literal
662 -- Static expression that raises Constraint_Error. This has
663 -- already been flagged, so just exit from pragma processing.
665 elsif Is_Static_Expression
(Argx
) then
668 -- Here we have a real error (non-static expression)
671 Error_Msg_Name_1
:= Chars
(N
);
673 ("argument for pragma% must be a identifier or " &
674 "static string expression!", Argx
);
678 end Check_Arg_Is_External_Name
;
680 -----------------------------
681 -- Check_Arg_Is_Identifier --
682 -----------------------------
684 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
) is
685 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
687 if Nkind
(Argx
) /= N_Identifier
then
689 ("argument for pragma% must be identifier", Argx
);
691 end Check_Arg_Is_Identifier
;
693 ----------------------------------
694 -- Check_Arg_Is_Integer_Literal --
695 ----------------------------------
697 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
) is
698 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
700 if Nkind
(Argx
) /= N_Integer_Literal
then
702 ("argument for pragma% must be integer literal", Argx
);
704 end Check_Arg_Is_Integer_Literal
;
706 -------------------------------------------
707 -- Check_Arg_Is_Library_Level_Local_Name --
708 -------------------------------------------
712 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
713 -- | library_unit_NAME
715 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
) is
717 Check_Arg_Is_Local_Name
(Arg
);
719 if not Is_Library_Level_Entity
(Entity
(Expression
(Arg
)))
720 and then Comes_From_Source
(N
)
723 ("argument for pragma% must be library level entity", Arg
);
725 end Check_Arg_Is_Library_Level_Local_Name
;
727 -----------------------------
728 -- Check_Arg_Is_Local_Name --
729 -----------------------------
733 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
734 -- | library_unit_NAME
736 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
) is
737 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
742 if Nkind
(Argx
) not in N_Direct_Name
743 and then (Nkind
(Argx
) /= N_Attribute_Reference
744 or else Present
(Expressions
(Argx
))
745 or else Nkind
(Prefix
(Argx
)) /= N_Identifier
)
746 and then (not Is_Entity_Name
(Argx
)
747 or else not Is_Compilation_Unit
(Entity
(Argx
)))
749 Error_Pragma_Arg
("argument for pragma% must be local name", Argx
);
752 if Is_Entity_Name
(Argx
)
753 and then Scope
(Entity
(Argx
)) /= Current_Scope
756 ("pragma% argument must be in same declarative part", Arg
);
758 end Check_Arg_Is_Local_Name
;
760 ---------------------------------
761 -- Check_Arg_Is_Locking_Policy --
762 ---------------------------------
764 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
) is
765 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
768 Check_Arg_Is_Identifier
(Argx
);
770 if not Is_Locking_Policy_Name
(Chars
(Argx
)) then
772 ("& is not a valid locking policy name", Argx
);
774 end Check_Arg_Is_Locking_Policy
;
776 -------------------------
777 -- Check_Arg_Is_One_Of --
778 -------------------------
780 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
) is
781 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
784 Check_Arg_Is_Identifier
(Argx
);
786 if Chars
(Argx
) /= N1
and then Chars
(Argx
) /= N2
then
787 Error_Msg_Name_2
:= N1
;
788 Error_Msg_Name_3
:= N2
;
789 Error_Pragma_Arg
("argument for pragma% must be% or%", Argx
);
791 end Check_Arg_Is_One_Of
;
793 procedure Check_Arg_Is_One_Of
795 N1
, N2
, N3
: Name_Id
)
797 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
800 Check_Arg_Is_Identifier
(Argx
);
802 if Chars
(Argx
) /= N1
803 and then Chars
(Argx
) /= N2
804 and then Chars
(Argx
) /= N3
806 Error_Pragma_Arg
("invalid argument for pragma%", Argx
);
808 end Check_Arg_Is_One_Of
;
810 ---------------------------------
811 -- Check_Arg_Is_Queuing_Policy --
812 ---------------------------------
814 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
) is
815 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
818 Check_Arg_Is_Identifier
(Argx
);
820 if not Is_Queuing_Policy_Name
(Chars
(Argx
)) then
822 ("& is not a valid queuing policy name", Argx
);
824 end Check_Arg_Is_Queuing_Policy
;
826 ------------------------------------
827 -- Check_Arg_Is_Static_Expression --
828 ------------------------------------
830 procedure Check_Arg_Is_Static_Expression
834 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
837 Analyze_And_Resolve
(Argx
, Typ
);
839 if Is_OK_Static_Expression
(Argx
) then
842 elsif Etype
(Argx
) = Any_Type
then
845 -- An interesting special case, if we have a string literal and
846 -- we are in Ada 83 mode, then we allow it even though it will
847 -- not be flagged as static. This allows the use of Ada 95
848 -- pragmas like Import in Ada 83 mode. They will of course be
849 -- flagged with warnings as usual, but will not cause errors.
851 elsif Ada_Version
= Ada_83
852 and then Nkind
(Argx
) = N_String_Literal
856 -- Static expression that raises Constraint_Error. This has
857 -- already been flagged, so just exit from pragma processing.
859 elsif Is_Static_Expression
(Argx
) then
862 -- Finally, we have a real error
865 Error_Msg_Name_1
:= Chars
(N
);
867 ("argument for pragma% must be a static expression!", Argx
);
870 end Check_Arg_Is_Static_Expression
;
872 ---------------------------------
873 -- Check_Arg_Is_String_Literal --
874 ---------------------------------
876 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
) is
877 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
879 if Nkind
(Argx
) /= N_String_Literal
then
881 ("argument for pragma% must be string literal", Argx
);
883 end Check_Arg_Is_String_Literal
;
885 ------------------------------------------
886 -- Check_Arg_Is_Task_Dispatching_Policy --
887 ------------------------------------------
889 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
) is
890 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
893 Check_Arg_Is_Identifier
(Argx
);
895 if not Is_Task_Dispatching_Policy_Name
(Chars
(Argx
)) then
897 ("& is not a valid task dispatching policy name", Argx
);
899 end Check_Arg_Is_Task_Dispatching_Policy
;
901 --------------------------------
902 -- Check_At_Least_N_Arguments --
903 --------------------------------
905 procedure Check_At_Least_N_Arguments
(N
: Nat
) is
907 if Arg_Count
< N
then
908 Error_Pragma
("too few arguments for pragma%");
910 end Check_At_Least_N_Arguments
;
912 -------------------------------
913 -- Check_At_Most_N_Arguments --
914 -------------------------------
916 procedure Check_At_Most_N_Arguments
(N
: Nat
) is
919 if Arg_Count
> N
then
923 Error_Pragma_Arg
("too many arguments for pragma%", Arg
);
926 end Check_At_Most_N_Arguments
;
928 ---------------------
929 -- Check_Component --
930 ---------------------
932 procedure Check_Component
(Comp
: Node_Id
) is
934 if Nkind
(Comp
) = N_Component_Declaration
then
936 Sindic
: constant Node_Id
:=
937 Subtype_Indication
(Component_Definition
(Comp
));
940 if Nkind
(Sindic
) = N_Subtype_Indication
then
942 -- Ada 2005 (AI-216): If a component subtype is subject to
943 -- a per-object constraint, then the component type shall
944 -- be an Unchecked_Union.
946 if Has_Per_Object_Constraint
(Defining_Identifier
(Comp
))
948 not Is_Unchecked_Union
(Etype
(Subtype_Mark
(Sindic
)))
950 Error_Msg_N
("component subtype subject to per-object" &
951 " constraint must be an Unchecked_Union", Comp
);
958 ----------------------------------
959 -- Check_Duplicated_Export_Name --
960 ----------------------------------
962 procedure Check_Duplicated_Export_Name
(Nam
: Node_Id
) is
963 String_Val
: constant String_Id
:= Strval
(Nam
);
966 -- We are only interested in the export case, and in the case of
967 -- generics, it is the instance, not the template, that is the
968 -- problem (the template will generate a warning in any case).
970 if not Inside_A_Generic
971 and then (Prag_Id
= Pragma_Export
973 Prag_Id
= Pragma_Export_Procedure
975 Prag_Id
= Pragma_Export_Valued_Procedure
977 Prag_Id
= Pragma_Export_Function
)
979 for J
in Externals
.First
.. Externals
.Last
loop
980 if String_Equal
(String_Val
, Strval
(Externals
.Table
(J
))) then
981 Error_Msg_Sloc
:= Sloc
(Externals
.Table
(J
));
982 Error_Msg_N
("external name duplicates name given#", Nam
);
987 Externals
.Append
(Nam
);
989 end Check_Duplicated_Export_Name
;
991 -------------------------
992 -- Check_First_Subtype --
993 -------------------------
995 procedure Check_First_Subtype
(Arg
: Node_Id
) is
996 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
998 if not Is_First_Subtype
(Entity
(Argx
)) then
1000 ("pragma% cannot apply to subtype", Argx
);
1002 end Check_First_Subtype
;
1004 ---------------------------
1005 -- Check_In_Main_Program --
1006 ---------------------------
1008 procedure Check_In_Main_Program
is
1009 P
: constant Node_Id
:= Parent
(N
);
1012 -- Must be at in subprogram body
1014 if Nkind
(P
) /= N_Subprogram_Body
then
1015 Error_Pragma
("% pragma allowed only in subprogram");
1017 -- Otherwise warn if obviously not main program
1019 elsif Present
(Parameter_Specifications
(Specification
(P
)))
1020 or else not Is_Compilation_Unit
(Defining_Entity
(P
))
1022 Error_Msg_Name_1
:= Chars
(N
);
1024 ("?pragma% is only effective in main program", N
);
1026 end Check_In_Main_Program
;
1028 ---------------------------------------
1029 -- Check_Interrupt_Or_Attach_Handler --
1030 ---------------------------------------
1032 procedure Check_Interrupt_Or_Attach_Handler
is
1033 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
1038 if not Is_Entity_Name
(Arg1_X
) then
1040 ("argument of pragma% must be entity name", Arg1
);
1042 elsif Prag_Id
= Pragma_Interrupt_Handler
then
1043 Check_Restriction
(No_Dynamic_Attachment
, N
);
1047 Handler_Proc
: Entity_Id
:= Empty
;
1048 Proc_Scope
: Entity_Id
;
1049 Found
: Boolean := False;
1052 if not Is_Overloaded
(Arg1_X
) then
1053 Handler_Proc
:= Entity
(Arg1_X
);
1058 Index
: Interp_Index
;
1061 Get_First_Interp
(Arg1_X
, Index
, It
);
1062 while Present
(It
.Nam
) loop
1063 Handler_Proc
:= It
.Nam
;
1065 if Ekind
(Handler_Proc
) = E_Procedure
1066 and then No
(First_Formal
(Handler_Proc
))
1070 Set_Entity
(Arg1_X
, Handler_Proc
);
1071 Set_Is_Overloaded
(Arg1_X
, False);
1074 ("ambiguous handler name for pragma% ", Arg1
);
1078 Get_Next_Interp
(Index
, It
);
1083 ("argument of pragma% must be parameterless procedure",
1086 Handler_Proc
:= Entity
(Arg1_X
);
1091 Proc_Scope
:= Scope
(Handler_Proc
);
1093 -- On AAMP only, a pragma Interrupt_Handler is supported for
1094 -- nonprotected parameterless procedures.
1097 and then Prag_Id
= Pragma_Interrupt_Handler
1099 if Ekind
(Handler_Proc
) /= E_Procedure
then
1101 ("argument of pragma% must be a procedure", Arg1
);
1104 elsif Ekind
(Handler_Proc
) /= E_Procedure
1105 or else Ekind
(Proc_Scope
) /= E_Protected_Type
1108 ("argument of pragma% must be protected procedure", Arg1
);
1111 if (not AAMP_On_Target
or else Prag_Id
= Pragma_Attach_Handler
)
1112 and then Ekind
(Proc_Scope
) = E_Protected_Type
1115 Protected_Definition
(Parent
(Proc_Scope
))
1117 Error_Pragma
("pragma% must be in protected definition");
1121 if not Is_Library_Level_Entity
(Proc_Scope
)
1122 or else (AAMP_On_Target
1123 and then not Is_Library_Level_Entity
(Handler_Proc
))
1126 ("pragma% requires library-level entity", Arg1
);
1129 if Present
(First_Formal
(Handler_Proc
)) then
1131 ("argument of pragma% must be parameterless procedure",
1135 end Check_Interrupt_Or_Attach_Handler
;
1137 -------------------------------------------
1138 -- Check_Is_In_Decl_Part_Or_Package_Spec --
1139 -------------------------------------------
1141 procedure Check_Is_In_Decl_Part_Or_Package_Spec
is
1150 elsif Nkind
(P
) = N_Handled_Sequence_Of_Statements
then
1153 elsif Nkind
(P
) = N_Package_Specification
then
1156 elsif Nkind
(P
) = N_Block_Statement
then
1159 -- Note: the following tests seem a little peculiar, because
1160 -- they test for bodies, but if we were in the statement part
1161 -- of the body, we would already have hit the handled statement
1162 -- sequence, so the only way we get here is by being in the
1163 -- declarative part of the body.
1165 elsif Nkind
(P
) = N_Subprogram_Body
1166 or else Nkind
(P
) = N_Package_Body
1167 or else Nkind
(P
) = N_Task_Body
1168 or else Nkind
(P
) = N_Entry_Body
1176 Error_Pragma
("pragma% is not in declarative part or package spec");
1177 end Check_Is_In_Decl_Part_Or_Package_Spec
;
1179 -------------------------
1180 -- Check_No_Identifier --
1181 -------------------------
1183 procedure Check_No_Identifier
(Arg
: Node_Id
) is
1185 if Chars
(Arg
) /= No_Name
then
1186 Error_Pragma_Arg_Ident
1187 ("pragma% does not permit identifier& here", Arg
);
1189 end Check_No_Identifier
;
1191 --------------------------
1192 -- Check_No_Identifiers --
1193 --------------------------
1195 procedure Check_No_Identifiers
is
1198 if Arg_Count
> 0 then
1200 while Present
(Arg_Node
) loop
1201 Check_No_Identifier
(Arg_Node
);
1205 end Check_No_Identifiers
;
1207 -------------------------------
1208 -- Check_Optional_Identifier --
1209 -------------------------------
1211 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
) is
1213 if Present
(Arg
) and then Chars
(Arg
) /= No_Name
then
1214 if Chars
(Arg
) /= Id
then
1215 Error_Msg_Name_1
:= Chars
(N
);
1216 Error_Msg_Name_2
:= Id
;
1217 Error_Msg_N
("pragma% argument expects identifier%", Arg
);
1221 end Check_Optional_Identifier
;
1223 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String) is
1225 Name_Buffer
(1 .. Id
'Length) := Id
;
1226 Name_Len
:= Id
'Length;
1227 Check_Optional_Identifier
(Arg
, Name_Find
);
1228 end Check_Optional_Identifier
;
1230 -----------------------------
1231 -- Check_Static_Constraint --
1232 -----------------------------
1234 -- Note: for convenience in writing this procedure, in addition to
1235 -- the officially (i.e. by spec) allowed argument which is always
1236 -- a constraint, it also allows ranges and discriminant associations.
1237 -- Above is not clear ???
1239 procedure Check_Static_Constraint
(Constr
: Node_Id
) is
1241 --------------------
1242 -- Require_Static --
1243 --------------------
1245 procedure Require_Static
(E
: Node_Id
);
1246 -- Require given expression to be static expression
1248 procedure Require_Static
(E
: Node_Id
) is
1250 if not Is_OK_Static_Expression
(E
) then
1251 Flag_Non_Static_Expr
1252 ("non-static constraint not allowed in Unchecked_Union!", E
);
1257 -- Start of processing for Check_Static_Constraint
1260 case Nkind
(Constr
) is
1261 when N_Discriminant_Association
=>
1262 Require_Static
(Expression
(Constr
));
1265 Require_Static
(Low_Bound
(Constr
));
1266 Require_Static
(High_Bound
(Constr
));
1268 when N_Attribute_Reference
=>
1269 Require_Static
(Type_Low_Bound
(Etype
(Prefix
(Constr
))));
1270 Require_Static
(Type_High_Bound
(Etype
(Prefix
(Constr
))));
1272 when N_Range_Constraint
=>
1273 Check_Static_Constraint
(Range_Expression
(Constr
));
1275 when N_Index_Or_Discriminant_Constraint
=>
1279 IDC
:= First
(Constraints
(Constr
));
1280 while Present
(IDC
) loop
1281 Check_Static_Constraint
(IDC
);
1289 end Check_Static_Constraint
;
1291 --------------------------------------
1292 -- Check_Valid_Configuration_Pragma --
1293 --------------------------------------
1295 -- A configuration pragma must appear in the context clause of
1296 -- a compilation unit, at the start of the list (i.e. only other
1297 -- pragmas may precede it).
1299 procedure Check_Valid_Configuration_Pragma
is
1301 if not Is_Configuration_Pragma
then
1302 Error_Pragma
("incorrect placement for configuration pragma%");
1304 end Check_Valid_Configuration_Pragma
;
1306 -------------------------------------
1307 -- Check_Valid_Library_Unit_Pragma --
1308 -------------------------------------
1310 procedure Check_Valid_Library_Unit_Pragma
is
1312 Parent_Node
: Node_Id
;
1313 Unit_Name
: Entity_Id
;
1314 Unit_Kind
: Node_Kind
;
1315 Unit_Node
: Node_Id
;
1316 Sindex
: Source_File_Index
;
1319 if not Is_List_Member
(N
) then
1323 Plist
:= List_Containing
(N
);
1324 Parent_Node
:= Parent
(Plist
);
1326 if Parent_Node
= Empty
then
1329 -- Case of pragma appearing after a compilation unit. In this
1330 -- case it must have an argument with the corresponding name
1331 -- and must be part of the following pragmas of its parent.
1333 elsif Nkind
(Parent_Node
) = N_Compilation_Unit_Aux
then
1334 if Plist
/= Pragmas_After
(Parent_Node
) then
1337 elsif Arg_Count
= 0 then
1339 ("argument required if outside compilation unit");
1342 Check_No_Identifiers
;
1343 Check_Arg_Count
(1);
1344 Unit_Node
:= Unit
(Parent
(Parent_Node
));
1345 Unit_Kind
:= Nkind
(Unit_Node
);
1347 Analyze
(Expression
(Arg1
));
1349 if Unit_Kind
= N_Generic_Subprogram_Declaration
1350 or else Unit_Kind
= N_Subprogram_Declaration
1352 Unit_Name
:= Defining_Entity
(Unit_Node
);
1354 elsif Unit_Kind
= N_Function_Instantiation
1355 or else Unit_Kind
= N_Package_Instantiation
1356 or else Unit_Kind
= N_Procedure_Instantiation
1358 Unit_Name
:= Defining_Entity
(Unit_Node
);
1361 Unit_Name
:= Cunit_Entity
(Current_Sem_Unit
);
1364 if Chars
(Unit_Name
) /=
1365 Chars
(Entity
(Expression
(Arg1
)))
1368 ("pragma% argument is not current unit name", Arg1
);
1371 if Ekind
(Unit_Name
) = E_Package
1372 and then Present
(Renamed_Entity
(Unit_Name
))
1374 Error_Pragma
("pragma% not allowed for renamed package");
1378 -- Pragma appears other than after a compilation unit
1381 -- Here we check for the generic instantiation case and also
1382 -- for the case of processing a generic formal package. We
1383 -- detect these cases by noting that the Sloc on the node
1384 -- does not belong to the current compilation unit.
1386 Sindex
:= Source_Index
(Current_Sem_Unit
);
1388 if Loc
not in Source_First
(Sindex
) .. Source_Last
(Sindex
) then
1389 Rewrite
(N
, Make_Null_Statement
(Loc
));
1392 -- If before first declaration, the pragma applies to the
1393 -- enclosing unit, and the name if present must be this name.
1395 elsif Is_Before_First_Decl
(N
, Plist
) then
1396 Unit_Node
:= Unit_Declaration_Node
(Current_Scope
);
1397 Unit_Kind
:= Nkind
(Unit_Node
);
1399 if Nkind
(Parent
(Unit_Node
)) /= N_Compilation_Unit
then
1402 elsif Unit_Kind
= N_Subprogram_Body
1403 and then not Acts_As_Spec
(Unit_Node
)
1407 elsif Nkind
(Parent_Node
) = N_Package_Body
then
1410 elsif Nkind
(Parent_Node
) = N_Package_Specification
1411 and then Plist
= Private_Declarations
(Parent_Node
)
1415 elsif (Nkind
(Parent_Node
) = N_Generic_Package_Declaration
1416 or else Nkind
(Parent_Node
)
1417 = N_Generic_Subprogram_Declaration
)
1418 and then Plist
= Generic_Formal_Declarations
(Parent_Node
)
1422 elsif Arg_Count
> 0 then
1423 Analyze
(Expression
(Arg1
));
1425 if Entity
(Expression
(Arg1
)) /= Current_Scope
then
1427 ("name in pragma% must be enclosing unit", Arg1
);
1430 -- It is legal to have no argument in this context
1436 -- Error if not before first declaration. This is because a
1437 -- library unit pragma argument must be the name of a library
1438 -- unit (RM 10.1.5(7)), but the only names permitted in this
1439 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1440 -- generic subprogram declarations or generic instantiations.
1444 ("pragma% misplaced, must be before first declaration");
1448 end Check_Valid_Library_Unit_Pragma
;
1454 procedure Check_Variant
(Variant
: Node_Id
) is
1455 Clist
: constant Node_Id
:= Component_List
(Variant
);
1459 if Present
(Variant_Part
(Clist
)) then
1461 ("Unchecked_Union may not have nested variants",
1462 Variant_Part
(Clist
));
1465 if not Is_Non_Empty_List
(Component_Items
(Clist
)) then
1467 ("Unchecked_Union may not have empty component list",
1472 Comp
:= First
(Component_Items
(Clist
));
1473 while Present
(Comp
) loop
1474 Check_Component
(Comp
);
1483 procedure Error_Pragma
(Msg
: String) is
1485 Error_Msg_Name_1
:= Chars
(N
);
1486 Error_Msg_N
(Msg
, N
);
1490 ----------------------
1491 -- Error_Pragma_Arg --
1492 ----------------------
1494 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
) is
1496 Error_Msg_Name_1
:= Chars
(N
);
1497 Error_Msg_N
(Msg
, Get_Pragma_Arg
(Arg
));
1499 end Error_Pragma_Arg
;
1501 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
) is
1503 Error_Msg_Name_1
:= Chars
(N
);
1504 Error_Msg_N
(Msg1
, Get_Pragma_Arg
(Arg
));
1505 Error_Pragma_Arg
(Msg2
, Arg
);
1506 end Error_Pragma_Arg
;
1508 ----------------------------
1509 -- Error_Pragma_Arg_Ident --
1510 ----------------------------
1512 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
) is
1514 Error_Msg_Name_1
:= Chars
(N
);
1515 Error_Msg_N
(Msg
, Arg
);
1517 end Error_Pragma_Arg_Ident
;
1519 ------------------------
1520 -- Find_Lib_Unit_Name --
1521 ------------------------
1523 function Find_Lib_Unit_Name
return Entity_Id
is
1525 -- Return inner compilation unit entity, for case of nested
1526 -- categorization pragmas. This happens in generic unit.
1528 if Nkind
(Parent
(N
)) = N_Package_Specification
1529 and then Defining_Entity
(Parent
(N
)) /= Current_Scope
1531 return Defining_Entity
(Parent
(N
));
1533 return Current_Scope
;
1535 end Find_Lib_Unit_Name
;
1537 ----------------------------
1538 -- Find_Program_Unit_Name --
1539 ----------------------------
1541 procedure Find_Program_Unit_Name
(Id
: Node_Id
) is
1542 Unit_Name
: Entity_Id
;
1543 Unit_Kind
: Node_Kind
;
1544 P
: constant Node_Id
:= Parent
(N
);
1547 if Nkind
(P
) = N_Compilation_Unit
then
1548 Unit_Kind
:= Nkind
(Unit
(P
));
1550 if Unit_Kind
= N_Subprogram_Declaration
1551 or else Unit_Kind
= N_Package_Declaration
1552 or else Unit_Kind
in N_Generic_Declaration
1554 Unit_Name
:= Defining_Entity
(Unit
(P
));
1556 if Chars
(Id
) = Chars
(Unit_Name
) then
1557 Set_Entity
(Id
, Unit_Name
);
1558 Set_Etype
(Id
, Etype
(Unit_Name
));
1560 Set_Etype
(Id
, Any_Type
);
1562 ("cannot find program unit referenced by pragma%");
1566 Set_Etype
(Id
, Any_Type
);
1567 Error_Pragma
("pragma% inapplicable to this unit");
1574 end Find_Program_Unit_Name
;
1576 -------------------------
1577 -- Gather_Associations --
1578 -------------------------
1580 procedure Gather_Associations
1582 Args
: out Args_List
)
1587 -- Initialize all parameters to Empty
1589 for J
in Args
'Range loop
1593 -- That's all we have to do if there are no argument associations
1595 if No
(Pragma_Argument_Associations
(N
)) then
1599 -- Otherwise first deal with any positional parameters present
1601 Arg
:= First
(Pragma_Argument_Associations
(N
));
1602 for Index
in Args
'Range loop
1603 exit when No
(Arg
) or else Chars
(Arg
) /= No_Name
;
1604 Args
(Index
) := Expression
(Arg
);
1608 -- Positional parameters all processed, if any left, then we
1609 -- have too many positional parameters.
1611 if Present
(Arg
) and then Chars
(Arg
) = No_Name
then
1613 ("too many positional associations for pragma%", Arg
);
1616 -- Process named parameters if any are present
1618 while Present
(Arg
) loop
1619 if Chars
(Arg
) = No_Name
then
1621 ("positional association cannot follow named association",
1625 for Index
in Names
'Range loop
1626 if Names
(Index
) = Chars
(Arg
) then
1627 if Present
(Args
(Index
)) then
1629 ("duplicate argument association for pragma%", Arg
);
1631 Args
(Index
) := Expression
(Arg
);
1636 if Index
= Names
'Last then
1637 Error_Msg_Name_1
:= Chars
(N
);
1638 Error_Msg_N
("pragma% does not allow & argument", Arg
);
1640 -- Check for possible misspelling
1642 for Index1
in Names
'Range loop
1643 if Is_Bad_Spelling_Of
1644 (Get_Name_String
(Chars
(Arg
)),
1645 Get_Name_String
(Names
(Index1
)))
1647 Error_Msg_Name_1
:= Names
(Index1
);
1648 Error_Msg_N
("\possible misspelling of%", Arg
);
1660 end Gather_Associations
;
1662 --------------------
1663 -- Get_Pragma_Arg --
1664 --------------------
1666 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
is
1668 if Nkind
(Arg
) = N_Pragma_Argument_Association
then
1669 return Expression
(Arg
);
1679 procedure GNAT_Pragma
is
1681 Check_Restriction
(No_Implementation_Pragmas
, N
);
1684 --------------------------
1685 -- Is_Before_First_Decl --
1686 --------------------------
1688 function Is_Before_First_Decl
1689 (Pragma_Node
: Node_Id
;
1690 Decls
: List_Id
) return Boolean
1692 Item
: Node_Id
:= First
(Decls
);
1695 -- Only other pragmas can come before this pragma
1698 if No
(Item
) or else Nkind
(Item
) /= N_Pragma
then
1701 elsif Item
= Pragma_Node
then
1707 end Is_Before_First_Decl
;
1709 -----------------------------
1710 -- Is_Configuration_Pragma --
1711 -----------------------------
1713 -- A configuration pragma must appear in the context clause of
1714 -- a compilation unit, at the start of the list (i.e. only other
1715 -- pragmas may precede it).
1717 function Is_Configuration_Pragma
return Boolean is
1718 Lis
: constant List_Id
:= List_Containing
(N
);
1719 Par
: constant Node_Id
:= Parent
(N
);
1723 -- If no parent, then we are in the configuration pragma file,
1724 -- so the placement is definitely appropriate.
1729 -- Otherwise we must be in the context clause of a compilation unit
1730 -- and the only thing allowed before us in the context list is more
1731 -- configuration pragmas.
1733 elsif Nkind
(Par
) = N_Compilation_Unit
1734 and then Context_Items
(Par
) = Lis
1741 elsif Nkind
(Prg
) /= N_Pragma
then
1751 end Is_Configuration_Pragma
;
1753 ----------------------
1754 -- Pragma_Misplaced --
1755 ----------------------
1757 procedure Pragma_Misplaced
is
1759 Error_Pragma
("incorrect placement of pragma%");
1760 end Pragma_Misplaced
;
1762 ------------------------------------
1763 -- Process Atomic_Shared_Volatile --
1764 ------------------------------------
1766 procedure Process_Atomic_Shared_Volatile
is
1773 procedure Set_Atomic
(E
: Entity_Id
);
1774 -- Set given type as atomic, and if no explicit alignment was
1775 -- given, set alignment to unknown, since back end knows what
1776 -- the alignment requirements are for atomic arrays. Note that
1777 -- this step is necessary for derived types.
1783 procedure Set_Atomic
(E
: Entity_Id
) is
1787 if not Has_Alignment_Clause
(E
) then
1788 Set_Alignment
(E
, Uint_0
);
1792 -- Start of processing for Process_Atomic_Shared_Volatile
1795 Check_Ada_83_Warning
;
1796 Check_No_Identifiers
;
1797 Check_Arg_Count
(1);
1798 Check_Arg_Is_Local_Name
(Arg1
);
1799 E_Id
:= Expression
(Arg1
);
1801 if Etype
(E_Id
) = Any_Type
then
1806 D
:= Declaration_Node
(E
);
1810 if Rep_Item_Too_Early
(E
, N
)
1812 Rep_Item_Too_Late
(E
, N
)
1816 Check_First_Subtype
(Arg1
);
1819 if Prag_Id
/= Pragma_Volatile
then
1821 Set_Atomic
(Underlying_Type
(E
));
1822 Set_Atomic
(Base_Type
(E
));
1825 -- Attribute belongs on the base type. If the
1826 -- view of the type is currently private, it also
1827 -- belongs on the underlying type.
1829 Set_Is_Volatile
(Base_Type
(E
));
1830 Set_Is_Volatile
(Underlying_Type
(E
));
1832 Set_Treat_As_Volatile
(E
);
1833 Set_Treat_As_Volatile
(Underlying_Type
(E
));
1835 elsif K
= N_Object_Declaration
1836 or else (K
= N_Component_Declaration
1837 and then Original_Record_Component
(E
) = E
)
1839 if Rep_Item_Too_Late
(E
, N
) then
1843 if Prag_Id
/= Pragma_Volatile
then
1846 -- If the object declaration has an explicit
1847 -- initialization, a temporary may have to be
1848 -- created to hold the expression, to insure
1849 -- that access to the object remain atomic.
1851 if Nkind
(Parent
(E
)) = N_Object_Declaration
1852 and then Present
(Expression
(Parent
(E
)))
1854 Set_Has_Delayed_Freeze
(E
);
1857 -- An interesting improvement here. If an object of type X
1858 -- is declared atomic, and the type X is not atomic, that's
1859 -- a pity, since it may not have appropraite alignment etc.
1860 -- We can rescue this in the special case where the object
1861 -- and type are in the same unit by just setting the type
1862 -- as atomic, so that the back end will process it as atomic.
1864 Utyp
:= Underlying_Type
(Etype
(E
));
1867 and then Sloc
(E
) > No_Location
1868 and then Sloc
(Utyp
) > No_Location
1870 Get_Source_File_Index
(Sloc
(E
)) =
1871 Get_Source_File_Index
(Sloc
(Underlying_Type
(Etype
(E
))))
1873 Set_Is_Atomic
(Underlying_Type
(Etype
(E
)));
1877 Set_Is_Volatile
(E
);
1878 Set_Treat_As_Volatile
(E
);
1882 ("inappropriate entity for pragma%", Arg1
);
1884 end Process_Atomic_Shared_Volatile
;
1886 ------------------------
1887 -- Process_Convention --
1888 ------------------------
1890 procedure Process_Convention
1891 (C
: out Convention_Id
;
1897 Comp_Unit
: Unit_Number_Type
;
1899 procedure Set_Convention_From_Pragma
(E
: Entity_Id
);
1900 -- Set convention in entity E, and also flag that the entity has a
1901 -- convention pragma. If entity is for a private or incomplete type,
1902 -- also set convention and flag on underlying type. This procedure
1903 -- also deals with the special case of C_Pass_By_Copy convention.
1905 --------------------------------
1906 -- Set_Convention_From_Pragma --
1907 --------------------------------
1909 procedure Set_Convention_From_Pragma
(E
: Entity_Id
) is
1911 Set_Convention
(E
, C
);
1912 Set_Has_Convention_Pragma
(E
);
1914 if Is_Incomplete_Or_Private_Type
(E
) then
1915 Set_Convention
(Underlying_Type
(E
), C
);
1916 Set_Has_Convention_Pragma
(Underlying_Type
(E
), True);
1919 -- A class-wide type should inherit the convention of
1920 -- the specific root type (although this isn't specified
1921 -- clearly by the RM).
1923 if Is_Type
(E
) and then Present
(Class_Wide_Type
(E
)) then
1924 Set_Convention
(Class_Wide_Type
(E
), C
);
1927 -- If the entity is a record type, then check for special case
1928 -- of C_Pass_By_Copy, which is treated the same as C except that
1929 -- the special record flag is set. This convention is also only
1930 -- permitted on record types (see AI95-00131).
1932 if Cname
= Name_C_Pass_By_Copy
then
1933 if Is_Record_Type
(E
) then
1934 Set_C_Pass_By_Copy
(Base_Type
(E
));
1935 elsif Is_Incomplete_Or_Private_Type
(E
)
1936 and then Is_Record_Type
(Underlying_Type
(E
))
1938 Set_C_Pass_By_Copy
(Base_Type
(Underlying_Type
(E
)));
1941 ("C_Pass_By_Copy convention allowed only for record type",
1946 -- If the entity is a derived boolean type, check for the
1947 -- special case of convention C, C++, or Fortran, where we
1948 -- consider any nonzero value to represent true.
1950 if Is_Discrete_Type
(E
)
1951 and then Root_Type
(Etype
(E
)) = Standard_Boolean
1957 C
= Convention_Fortran
)
1959 Set_Nonzero_Is_True
(Base_Type
(E
));
1961 end Set_Convention_From_Pragma
;
1963 -- Start of processing for Process_Convention
1966 Check_At_Least_N_Arguments
(2);
1967 Check_Arg_Is_Identifier
(Arg1
);
1968 Check_Optional_Identifier
(Arg1
, Name_Convention
);
1969 Cname
:= Chars
(Expression
(Arg1
));
1971 -- C_Pass_By_Copy is treated as a synonym for convention C
1972 -- (this is tested again below to set the critical flag)
1974 if Cname
= Name_C_Pass_By_Copy
then
1977 -- Otherwise we must have something in the standard convention list
1979 elsif Is_Convention_Name
(Cname
) then
1980 C
:= Get_Convention_Id
(Chars
(Expression
(Arg1
)));
1982 -- In DEC VMS, it seems that there is an undocumented feature
1983 -- that any unrecognized convention is treated as the default,
1984 -- which for us is convention C. It does not seem so terrible
1985 -- to do this unconditionally, silently in the VMS case, and
1986 -- with a warning in the non-VMS case.
1989 if Warn_On_Export_Import
and not OpenVMS_On_Target
then
1991 ("?unrecognized convention name, C assumed",
1998 Check_Arg_Is_Local_Name
(Arg2
);
1999 Check_Optional_Identifier
(Arg2
, Name_Entity
);
2001 Id
:= Expression
(Arg2
);
2004 if not Is_Entity_Name
(Id
) then
2005 Error_Pragma_Arg
("entity name required", Arg2
);
2010 -- Go to renamed subprogram if present, since convention applies
2011 -- to the actual renamed entity, not to the renaming entity.
2012 -- If subprogram is inherited, go to parent subprogram.
2014 if Is_Subprogram
(E
)
2015 and then Present
(Alias
(E
))
2017 if Nkind
(Parent
(Declaration_Node
(E
)))
2018 = N_Subprogram_Renaming_Declaration
2022 elsif Nkind
(Parent
(E
)) = N_Full_Type_Declaration
2023 and then Scope
(E
) = Scope
(Alias
(E
))
2029 -- Check that we are not applying this to a specless body
2031 if Is_Subprogram
(E
)
2032 and then Nkind
(Parent
(Declaration_Node
(E
))) = N_Subprogram_Body
2035 ("pragma% requires separate spec and must come before body");
2038 -- Check that we are not applying this to a named constant
2040 if Ekind
(E
) = E_Named_Integer
2042 Ekind
(E
) = E_Named_Real
2044 Error_Msg_Name_1
:= Chars
(N
);
2046 ("cannot apply pragma% to named constant!",
2047 Get_Pragma_Arg
(Arg2
));
2049 ("\supply appropriate type for&!", Arg2
);
2052 if Etype
(E
) = Any_Type
2053 or else Rep_Item_Too_Early
(E
, N
)
2057 E
:= Underlying_Type
(E
);
2060 if Rep_Item_Too_Late
(E
, N
) then
2064 if Has_Convention_Pragma
(E
) then
2066 ("at most one Convention/Export/Import pragma is allowed", Arg2
);
2068 elsif Convention
(E
) = Convention_Protected
2069 or else Ekind
(Scope
(E
)) = E_Protected_Type
2072 ("a protected operation cannot be given a different convention",
2076 -- For Intrinsic, a subprogram is required
2078 if C
= Convention_Intrinsic
2079 and then not Is_Subprogram
(E
)
2080 and then not Is_Generic_Subprogram
(E
)
2083 ("second argument of pragma% must be a subprogram", Arg2
);
2086 -- For Stdcall, a subprogram, variable or subprogram type is required
2088 if C
= Convention_Stdcall
2089 and then not Is_Subprogram
(E
)
2090 and then not Is_Generic_Subprogram
(E
)
2091 and then Ekind
(E
) /= E_Variable
2094 and then Ekind
(Designated_Type
(E
)) = E_Subprogram_Type
)
2097 ("second argument of pragma% must be subprogram (type)",
2101 if not Is_Subprogram
(E
)
2102 and then not Is_Generic_Subprogram
(E
)
2104 Set_Convention_From_Pragma
(E
);
2108 Check_First_Subtype
(Arg2
);
2109 Set_Convention_From_Pragma
(Base_Type
(E
));
2111 -- For subprograms, we must set the convention on the
2112 -- internally generated directly designated type as well.
2114 if Ekind
(E
) = E_Access_Subprogram_Type
then
2115 Set_Convention_From_Pragma
(Directly_Designated_Type
(E
));
2119 -- For the subprogram case, set proper convention for all homonyms
2120 -- in same scope and the same declarative part, i.e. the same
2121 -- compilation unit.
2124 Comp_Unit
:= Get_Source_Unit
(E
);
2125 Set_Convention_From_Pragma
(E
);
2127 -- Treat a pragma Import as an implicit body, for GPS use.
2129 if Prag_Id
= Pragma_Import
then
2130 Generate_Reference
(E
, Id
, 'b');
2136 exit when No
(E1
) or else Scope
(E1
) /= Current_Scope
;
2138 -- Note: below we are missing a check for Rep_Item_Too_Late.
2139 -- That is deliberate, we cannot chain the rep item on more
2140 -- than one Rep_Item chain, to be fixed later ???
2142 if Comes_From_Source
(E1
)
2143 and then Comp_Unit
= Get_Source_Unit
(E1
)
2144 and then Nkind
(Original_Node
(Parent
(E1
))) /=
2145 N_Full_Type_Declaration
2147 Set_Convention_From_Pragma
(E1
);
2149 if Prag_Id
= Pragma_Import
then
2150 Generate_Reference
(E
, Id
, 'b');
2155 end Process_Convention
;
2157 -----------------------------------------------------
2158 -- Process_Extended_Import_Export_Exception_Pragma --
2159 -----------------------------------------------------
2161 procedure Process_Extended_Import_Export_Exception_Pragma
2162 (Arg_Internal
: Node_Id
;
2163 Arg_External
: Node_Id
;
2173 if not OpenVMS_On_Target
then
2175 ("?pragma% ignored (applies only to Open'V'M'S)");
2178 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2179 Def_Id
:= Entity
(Arg_Internal
);
2181 if Ekind
(Def_Id
) /= E_Exception
then
2183 ("pragma% must refer to declared exception", Arg_Internal
);
2186 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2188 if Present
(Arg_Form
) then
2189 Check_Arg_Is_One_Of
(Arg_Form
, Name_Ada
, Name_VMS
);
2192 if Present
(Arg_Form
)
2193 and then Chars
(Arg_Form
) = Name_Ada
2197 Set_Is_VMS_Exception
(Def_Id
);
2198 Set_Exception_Code
(Def_Id
, No_Uint
);
2201 if Present
(Arg_Code
) then
2202 if not Is_VMS_Exception
(Def_Id
) then
2204 ("Code option for pragma% not allowed for Ada case",
2208 Check_Arg_Is_Static_Expression
(Arg_Code
, Any_Integer
);
2209 Code_Val
:= Expr_Value
(Arg_Code
);
2211 if not UI_Is_In_Int_Range
(Code_Val
) then
2213 ("Code option for pragma% must be in 32-bit range",
2217 Set_Exception_Code
(Def_Id
, Code_Val
);
2220 end Process_Extended_Import_Export_Exception_Pragma
;
2222 -------------------------------------------------
2223 -- Process_Extended_Import_Export_Internal_Arg --
2224 -------------------------------------------------
2226 procedure Process_Extended_Import_Export_Internal_Arg
2227 (Arg_Internal
: Node_Id
:= Empty
)
2232 if No
(Arg_Internal
) then
2233 Error_Pragma
("Internal parameter required for pragma%");
2236 if Nkind
(Arg_Internal
) = N_Identifier
then
2239 elsif Nkind
(Arg_Internal
) = N_Operator_Symbol
2240 and then (Prag_Id
= Pragma_Import_Function
2242 Prag_Id
= Pragma_Export_Function
)
2248 ("wrong form for Internal parameter for pragma%", Arg_Internal
);
2251 Check_Arg_Is_Local_Name
(Arg_Internal
);
2252 end Process_Extended_Import_Export_Internal_Arg
;
2254 --------------------------------------------------
2255 -- Process_Extended_Import_Export_Object_Pragma --
2256 --------------------------------------------------
2258 procedure Process_Extended_Import_Export_Object_Pragma
2259 (Arg_Internal
: Node_Id
;
2260 Arg_External
: Node_Id
;
2266 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2267 Def_Id
:= Entity
(Arg_Internal
);
2269 if Ekind
(Def_Id
) /= E_Constant
2270 and then Ekind
(Def_Id
) /= E_Variable
2273 ("pragma% must designate an object", Arg_Internal
);
2276 if Has_Rep_Pragma
(Def_Id
, Name_Common_Object
)
2278 Has_Rep_Pragma
(Def_Id
, Name_Psect_Object
)
2281 ("previous Common/Psect_Object applies, pragma % not permitted",
2285 if Rep_Item_Too_Late
(Def_Id
, N
) then
2289 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2291 if Present
(Arg_Size
) then
2292 Check_Arg_Is_External_Name
(Arg_Size
);
2295 -- Export_Object case
2297 if Prag_Id
= Pragma_Export_Object
then
2298 if not Is_Library_Level_Entity
(Def_Id
) then
2300 ("argument for pragma% must be library level entity",
2304 if Ekind
(Current_Scope
) = E_Generic_Package
then
2305 Error_Pragma
("pragma& cannot appear in a generic unit");
2308 if not Size_Known_At_Compile_Time
(Etype
(Def_Id
)) then
2310 ("exported object must have compile time known size",
2314 if Warn_On_Export_Import
and then Is_Exported
(Def_Id
) then
2316 ("?duplicate Export_Object pragma", N
);
2318 Set_Exported
(Def_Id
, Arg_Internal
);
2321 -- Import_Object case
2324 if Is_Concurrent_Type
(Etype
(Def_Id
)) then
2326 ("cannot use pragma% for task/protected object",
2330 if Ekind
(Def_Id
) = E_Constant
then
2332 ("cannot import a constant", Arg_Internal
);
2335 if Warn_On_Export_Import
2336 and then Has_Discriminants
(Etype
(Def_Id
))
2339 ("imported value must be initialized?", Arg_Internal
);
2342 if Warn_On_Export_Import
2343 and then Is_Access_Type
(Etype
(Def_Id
))
2346 ("cannot import object of an access type?", Arg_Internal
);
2349 if Warn_On_Export_Import
2350 and then Is_Imported
(Def_Id
)
2353 ("?duplicate Import_Object pragma", N
);
2355 -- Check for explicit initialization present. Note that an
2356 -- initialization that generated by the code generator, e.g.
2357 -- for an access type, does not count here.
2359 elsif Present
(Expression
(Parent
(Def_Id
)))
2362 (Original_Node
(Expression
(Parent
(Def_Id
))))
2364 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2366 ("no initialization allowed for declaration of& #",
2367 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2370 Set_Imported
(Def_Id
);
2371 Note_Possible_Modification
(Arg_Internal
);
2374 end Process_Extended_Import_Export_Object_Pragma
;
2376 ------------------------------------------------------
2377 -- Process_Extended_Import_Export_Subprogram_Pragma --
2378 ------------------------------------------------------
2380 procedure Process_Extended_Import_Export_Subprogram_Pragma
2381 (Arg_Internal
: Node_Id
;
2382 Arg_External
: Node_Id
;
2383 Arg_Parameter_Types
: Node_Id
;
2384 Arg_Result_Type
: Node_Id
:= Empty
;
2385 Arg_Mechanism
: Node_Id
;
2386 Arg_Result_Mechanism
: Node_Id
:= Empty
;
2387 Arg_First_Optional_Parameter
: Node_Id
:= Empty
)
2393 Ambiguous
: Boolean;
2397 function Same_Base_Type
2399 Formal
: Entity_Id
) return Boolean;
2400 -- Determines if Ptype references the type of Formal. Note that
2401 -- only the base types need to match according to the spec. Ptype
2402 -- here is the argument from the pragma, which is either a type
2403 -- name, or an access attribute.
2405 --------------------
2406 -- Same_Base_Type --
2407 --------------------
2409 function Same_Base_Type
2411 Formal
: Entity_Id
) return Boolean
2413 Ftyp
: constant Entity_Id
:= Base_Type
(Etype
(Formal
));
2417 -- Case where pragma argument is typ'Access
2419 if Nkind
(Ptype
) = N_Attribute_Reference
2420 and then Attribute_Name
(Ptype
) = Name_Access
2422 Pref
:= Prefix
(Ptype
);
2425 if not Is_Entity_Name
(Pref
)
2426 or else Entity
(Pref
) = Any_Type
2431 -- We have a match if the corresponding argument is of an
2432 -- anonymous access type, and its designicated type matches
2433 -- the type of the prefix of the access attribute
2435 return Ekind
(Ftyp
) = E_Anonymous_Access_Type
2436 and then Base_Type
(Entity
(Pref
)) =
2437 Base_Type
(Etype
(Designated_Type
(Ftyp
)));
2439 -- Case where pragma argument is a type name
2444 if not Is_Entity_Name
(Ptype
)
2445 or else Entity
(Ptype
) = Any_Type
2450 -- We have a match if the corresponding argument is of
2451 -- the type given in the pragma (comparing base types)
2453 return Base_Type
(Entity
(Ptype
)) = Ftyp
;
2457 -- Start of processing for
2458 -- Process_Extended_Import_Export_Subprogram_Pragma
2461 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2465 -- Loop through homonyms (overloadings) of the entity
2467 Hom_Id
:= Entity
(Arg_Internal
);
2468 while Present
(Hom_Id
) loop
2469 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
2471 -- We need a subprogram in the current scope
2473 if not Is_Subprogram
(Def_Id
)
2474 or else Scope
(Def_Id
) /= Current_Scope
2481 -- Pragma cannot apply to subprogram body
2483 if Is_Subprogram
(Def_Id
)
2486 (Declaration_Node
(Def_Id
))) = N_Subprogram_Body
2489 ("pragma% requires separate spec"
2490 & " and must come before body");
2493 -- Test result type if given, note that the result type
2494 -- parameter can only be present for the function cases.
2496 if Present
(Arg_Result_Type
)
2497 and then not Same_Base_Type
(Arg_Result_Type
, Def_Id
)
2501 elsif Etype
(Def_Id
) /= Standard_Void_Type
2503 (Chars
(N
) = Name_Export_Procedure
2504 or else Chars
(N
) = Name_Import_Procedure
)
2508 -- Test parameter types if given. Note that this parameter
2509 -- has not been analyzed (and must not be, since it is
2510 -- semantic nonsense), so we get it as the parser left it.
2512 elsif Present
(Arg_Parameter_Types
) then
2513 Check_Matching_Types
: declare
2518 Formal
:= First_Formal
(Def_Id
);
2520 if Nkind
(Arg_Parameter_Types
) = N_Null
then
2521 if Present
(Formal
) then
2525 -- A list of one type, e.g. (List) is parsed as
2526 -- a parenthesized expression.
2528 elsif Nkind
(Arg_Parameter_Types
) /= N_Aggregate
2529 and then Paren_Count
(Arg_Parameter_Types
) = 1
2532 or else Present
(Next_Formal
(Formal
))
2537 Same_Base_Type
(Arg_Parameter_Types
, Formal
);
2540 -- A list of more than one type is parsed as a aggregate
2542 elsif Nkind
(Arg_Parameter_Types
) = N_Aggregate
2543 and then Paren_Count
(Arg_Parameter_Types
) = 0
2545 Ptype
:= First
(Expressions
(Arg_Parameter_Types
));
2546 while Present
(Ptype
) or else Present
(Formal
) loop
2549 or else not Same_Base_Type
(Ptype
, Formal
)
2554 Next_Formal
(Formal
);
2559 -- Anything else is of the wrong form
2563 ("wrong form for Parameter_Types parameter",
2564 Arg_Parameter_Types
);
2566 end Check_Matching_Types
;
2569 -- Match is now False if the entry we found did not match
2570 -- either a supplied Parameter_Types or Result_Types argument
2576 -- Ambiguous case, the flag Ambiguous shows if we already
2577 -- detected this and output the initial messages.
2580 if not Ambiguous
then
2582 Error_Msg_Name_1
:= Chars
(N
);
2584 ("pragma% does not uniquely identify subprogram!",
2586 Error_Msg_Sloc
:= Sloc
(Ent
);
2587 Error_Msg_N
("matching subprogram #!", N
);
2591 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2592 Error_Msg_N
("matching subprogram #!", N
);
2597 Hom_Id
:= Homonym
(Hom_Id
);
2600 -- See if we found an entry
2603 if not Ambiguous
then
2604 if Is_Generic_Subprogram
(Entity
(Arg_Internal
)) then
2606 ("pragma% cannot be given for generic subprogram");
2610 ("pragma% does not identify local subprogram");
2617 -- Import pragmas must be be for imported entities
2619 if Prag_Id
= Pragma_Import_Function
2621 Prag_Id
= Pragma_Import_Procedure
2623 Prag_Id
= Pragma_Import_Valued_Procedure
2625 if not Is_Imported
(Ent
) then
2627 ("pragma Import or Interface must precede pragma%");
2630 -- Here we have the Export case which can set the entity as exported
2632 -- But does not do so if the specified external name is null,
2633 -- since that is taken as a signal in DEC Ada 83 (with which
2634 -- we want to be compatible) to request no external name.
2636 elsif Nkind
(Arg_External
) = N_String_Literal
2637 and then String_Length
(Strval
(Arg_External
)) = 0
2641 -- In all other cases, set entit as exported
2644 Set_Exported
(Ent
, Arg_Internal
);
2647 -- Special processing for Valued_Procedure cases
2649 if Prag_Id
= Pragma_Import_Valued_Procedure
2651 Prag_Id
= Pragma_Export_Valued_Procedure
2653 Formal
:= First_Formal
(Ent
);
2657 ("at least one parameter required for pragma%");
2659 elsif Ekind
(Formal
) /= E_Out_Parameter
then
2661 ("first parameter must have mode out for pragma%");
2664 Set_Is_Valued_Procedure
(Ent
);
2668 Set_Extended_Import_Export_External_Name
(Ent
, Arg_External
);
2670 -- Process Result_Mechanism argument if present. We have already
2671 -- checked that this is only allowed for the function case.
2673 if Present
(Arg_Result_Mechanism
) then
2674 Set_Mechanism_Value
(Ent
, Arg_Result_Mechanism
);
2677 -- Process Mechanism parameter if present. Note that this parameter
2678 -- is not analyzed, and must not be analyzed since it is semantic
2679 -- nonsense, so we get it in exactly as the parser left it.
2681 if Present
(Arg_Mechanism
) then
2689 -- A single mechanism association without a formal parameter
2690 -- name is parsed as a parenthesized expression. All other
2691 -- cases are parsed as aggregates, so we rewrite the single
2692 -- parameter case as an aggregate for consistency.
2694 if Nkind
(Arg_Mechanism
) /= N_Aggregate
2695 and then Paren_Count
(Arg_Mechanism
) = 1
2697 Rewrite
(Arg_Mechanism
,
2698 Make_Aggregate
(Sloc
(Arg_Mechanism
),
2699 Expressions
=> New_List
(
2700 Relocate_Node
(Arg_Mechanism
))));
2703 -- Case of only mechanism name given, applies to all formals
2705 if Nkind
(Arg_Mechanism
) /= N_Aggregate
then
2706 Formal
:= First_Formal
(Ent
);
2707 while Present
(Formal
) loop
2708 Set_Mechanism_Value
(Formal
, Arg_Mechanism
);
2709 Next_Formal
(Formal
);
2712 -- Case of list of mechanism associations given
2715 if Null_Record_Present
(Arg_Mechanism
) then
2717 ("inappropriate form for Mechanism parameter",
2721 -- Deal with positional ones first
2723 Formal
:= First_Formal
(Ent
);
2725 if Present
(Expressions
(Arg_Mechanism
)) then
2726 Mname
:= First
(Expressions
(Arg_Mechanism
));
2728 while Present
(Mname
) loop
2731 ("too many mechanism associations", Mname
);
2734 Set_Mechanism_Value
(Formal
, Mname
);
2735 Next_Formal
(Formal
);
2740 -- Deal with named entries
2742 if Present
(Component_Associations
(Arg_Mechanism
)) then
2743 Massoc
:= First
(Component_Associations
(Arg_Mechanism
));
2745 while Present
(Massoc
) loop
2746 Choice
:= First
(Choices
(Massoc
));
2748 if Nkind
(Choice
) /= N_Identifier
2749 or else Present
(Next
(Choice
))
2752 ("incorrect form for mechanism association",
2756 Formal
:= First_Formal
(Ent
);
2760 ("parameter name & not present", Choice
);
2763 if Chars
(Choice
) = Chars
(Formal
) then
2765 (Formal
, Expression
(Massoc
));
2769 Next_Formal
(Formal
);
2779 -- Process First_Optional_Parameter argument if present. We have
2780 -- already checked that this is only allowed for the Import case.
2782 if Present
(Arg_First_Optional_Parameter
) then
2783 if Nkind
(Arg_First_Optional_Parameter
) /= N_Identifier
then
2785 ("first optional parameter must be formal parameter name",
2786 Arg_First_Optional_Parameter
);
2789 Formal
:= First_Formal
(Ent
);
2793 ("specified formal parameter& not found",
2794 Arg_First_Optional_Parameter
);
2797 exit when Chars
(Formal
) =
2798 Chars
(Arg_First_Optional_Parameter
);
2800 Next_Formal
(Formal
);
2803 Set_First_Optional_Parameter
(Ent
, Formal
);
2805 -- Check specified and all remaining formals have right form
2807 while Present
(Formal
) loop
2808 if Ekind
(Formal
) /= E_In_Parameter
then
2810 ("optional formal& is not of mode in!",
2811 Arg_First_Optional_Parameter
, Formal
);
2814 Dval
:= Default_Value
(Formal
);
2816 if not Present
(Dval
) then
2818 ("optional formal& does not have default value!",
2819 Arg_First_Optional_Parameter
, Formal
);
2821 elsif Compile_Time_Known_Value_Or_Aggr
(Dval
) then
2826 ("default value for optional formal& is non-static!",
2827 Arg_First_Optional_Parameter
, Formal
);
2831 Set_Is_Optional_Parameter
(Formal
);
2832 Next_Formal
(Formal
);
2835 end Process_Extended_Import_Export_Subprogram_Pragma
;
2837 --------------------------
2838 -- Process_Generic_List --
2839 --------------------------
2841 procedure Process_Generic_List
is
2847 Check_No_Identifiers
;
2848 Check_At_Least_N_Arguments
(1);
2851 while Present
(Arg
) loop
2852 Exp
:= Expression
(Arg
);
2855 if not Is_Entity_Name
(Exp
)
2857 (not Is_Generic_Instance
(Entity
(Exp
))
2859 not Is_Generic_Unit
(Entity
(Exp
)))
2862 ("pragma% argument must be name of generic unit/instance",
2868 end Process_Generic_List
;
2870 ---------------------------------
2871 -- Process_Import_Or_Interface --
2872 ---------------------------------
2874 procedure Process_Import_Or_Interface
is
2880 Process_Convention
(C
, Def_Id
);
2881 Kill_Size_Check_Code
(Def_Id
);
2882 Note_Possible_Modification
(Expression
(Arg2
));
2884 if Ekind
(Def_Id
) = E_Variable
2886 Ekind
(Def_Id
) = E_Constant
2888 -- User initialization is not allowed for imported object, but
2889 -- the object declaration may contain a default initialization,
2890 -- that will be discarded. Note that an explicit initialization
2891 -- only counts if it comes from source, otherwise it is simply
2892 -- the code generator making an implicit initialization explicit.
2894 if Present
(Expression
(Parent
(Def_Id
)))
2895 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
2897 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2899 ("no initialization allowed for declaration of& #",
2900 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2904 Set_Imported
(Def_Id
);
2905 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
2907 -- Note that we do not set Is_Public here. That's because we
2908 -- only want to set if if there is no address clause, and we
2909 -- don't know that yet, so we delay that processing till
2912 -- pragma Import completes deferred constants
2914 if Ekind
(Def_Id
) = E_Constant
then
2915 Set_Has_Completion
(Def_Id
);
2918 -- It is not possible to import a constant of an unconstrained
2919 -- array type (e.g. string) because there is no simple way to
2920 -- write a meaningful subtype for it.
2922 if Is_Array_Type
(Etype
(Def_Id
))
2923 and then not Is_Constrained
(Etype
(Def_Id
))
2926 ("imported constant& must have a constrained subtype",
2931 elsif Is_Subprogram
(Def_Id
)
2932 or else Is_Generic_Subprogram
(Def_Id
)
2934 -- If the name is overloaded, pragma applies to all of the
2935 -- denoted entities in the same declarative part.
2938 while Present
(Hom_Id
) loop
2939 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
2941 -- Ignore inherited subprograms because the pragma will
2942 -- apply to the parent operation, which is the one called.
2944 if Is_Overloadable
(Def_Id
)
2945 and then Present
(Alias
(Def_Id
))
2949 -- If it is not a subprogram, it must be in an outer
2950 -- scope and pragma does not apply.
2952 elsif not Is_Subprogram
(Def_Id
)
2953 and then not Is_Generic_Subprogram
(Def_Id
)
2957 -- Verify that the homonym is in the same declarative
2958 -- part (not just the same scope).
2960 elsif Parent
(Unit_Declaration_Node
(Def_Id
)) /= Parent
(N
)
2961 and then Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
2966 Set_Imported
(Def_Id
);
2968 -- Special processing for Convention_Intrinsic
2970 if C
= Convention_Intrinsic
then
2972 -- Link_Name argument not allowed for intrinsic
2975 and then Chars
(Arg3
) = Name_Link_Name
2980 if Present
(Arg4
) then
2982 ("Link_Name argument not allowed for " &
2987 Set_Is_Intrinsic_Subprogram
(Def_Id
);
2989 -- If no external name is present, then check that
2990 -- this is a valid intrinsic subprogram. If an external
2991 -- name is present, then this is handled by the back end.
2994 Check_Intrinsic_Subprogram
(Def_Id
, Expression
(Arg2
));
2998 -- All interfaced procedures need an external symbol
2999 -- created for them since they are always referenced
3000 -- from another object file.
3002 Set_Is_Public
(Def_Id
);
3004 -- Verify that the subprogram does not have a completion
3005 -- through a renaming declaration. For other completions
3006 -- the pragma appears as a too late representation.
3009 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Def_Id
);
3013 and then Nkind
(Decl
) = N_Subprogram_Declaration
3014 and then Present
(Corresponding_Body
(Decl
))
3017 (Unit_Declaration_Node
3018 (Corresponding_Body
(Decl
))) =
3019 N_Subprogram_Renaming_Declaration
3021 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3022 Error_Msg_NE
("cannot import&#," &
3023 " already completed by a renaming",
3028 Set_Has_Completion
(Def_Id
);
3029 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3032 if Is_Compilation_Unit
(Hom_Id
) then
3034 -- Its possible homonyms are not affected by the pragma.
3035 -- Such homonyms might be present in the context of other
3036 -- units being compiled.
3041 Hom_Id
:= Homonym
(Hom_Id
);
3045 -- When the convention is Java, we also allow Import to be given
3046 -- for packages, exceptions, and record components.
3048 elsif C
= Convention_Java
3050 (Ekind
(Def_Id
) = E_Package
3051 or else Ekind
(Def_Id
) = E_Exception
3052 or else Nkind
(Parent
(Def_Id
)) = N_Component_Declaration
)
3054 Set_Imported
(Def_Id
);
3055 Set_Is_Public
(Def_Id
);
3056 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3060 ("second argument of pragma% must be object or subprogram",
3064 -- If this pragma applies to a compilation unit, then the unit,
3065 -- which is a subprogram, does not require (or allow) a body.
3066 -- We also do not need to elaborate imported procedures.
3068 if Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
3070 Cunit
: constant Node_Id
:= Parent
(Parent
(N
));
3072 Set_Body_Required
(Cunit
, False);
3075 end Process_Import_Or_Interface
;
3077 --------------------
3078 -- Process_Inline --
3079 --------------------
3081 procedure Process_Inline
(Active
: Boolean) is
3087 Effective
: Boolean := False;
3089 procedure Make_Inline
(Subp
: Entity_Id
);
3090 -- Subp is the defining unit name of the subprogram
3091 -- declaration. Set the flag, as well as the flag in the
3092 -- corresponding body, if there is one present.
3094 procedure Set_Inline_Flags
(Subp
: Entity_Id
);
3095 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp
3097 function Inlining_Not_Possible
(Subp
: Entity_Id
) return Boolean;
3098 -- Returns True if it can be determined at this stage that inlining
3099 -- is not possible, for examle if the body is available and contains
3100 -- exception handlers, we prevent inlining, since otherwise we can
3101 -- get undefined symbols at link time. This function also emits a
3102 -- warning if front-end inlining is enabled and the pragma appears
3104 -- ??? is business with link symbols still valid, or does it relate
3105 -- to front end ZCX which is being phased out ???
3107 ---------------------------
3108 -- Inlining_Not_Possible --
3109 ---------------------------
3111 function Inlining_Not_Possible
(Subp
: Entity_Id
) return Boolean is
3112 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Subp
);
3116 if Nkind
(Decl
) = N_Subprogram_Body
then
3117 Stats
:= Handled_Statement_Sequence
(Decl
);
3118 return Present
(Exception_Handlers
(Stats
))
3119 or else Present
(At_End_Proc
(Stats
));
3121 elsif Nkind
(Decl
) = N_Subprogram_Declaration
3122 and then Present
(Corresponding_Body
(Decl
))
3124 if Front_End_Inlining
3125 and then Analyzed
(Corresponding_Body
(Decl
))
3127 Error_Msg_N
("pragma appears too late, ignored?", N
);
3130 -- If the subprogram is a renaming as body, the body is
3131 -- just a call to the renamed subprogram, and inlining is
3132 -- trivially possible.
3135 Nkind
(Unit_Declaration_Node
(Corresponding_Body
(Decl
)))
3136 = N_Subprogram_Renaming_Declaration
3142 Handled_Statement_Sequence
3143 (Unit_Declaration_Node
(Corresponding_Body
(Decl
)));
3146 Present
(Exception_Handlers
(Stats
))
3147 or else Present
(At_End_Proc
(Stats
));
3151 -- If body is not available, assume the best, the check is
3152 -- performed again when compiling enclosing package bodies.
3156 end Inlining_Not_Possible
;
3162 procedure Make_Inline
(Subp
: Entity_Id
) is
3163 Kind
: constant Entity_Kind
:= Ekind
(Subp
);
3164 Inner_Subp
: Entity_Id
:= Subp
;
3167 if Etype
(Subp
) = Any_Type
then
3170 -- If inlining is not possible, for now do not treat as an error
3172 elsif Inlining_Not_Possible
(Subp
) then
3176 -- Here we have a candidate for inlining, but we must exclude
3177 -- derived operations. Otherwise we will end up trying to
3178 -- inline a phantom declaration, and the result would be to
3179 -- drag in a body which has no direct inlining associated with
3180 -- it. That would not only be inefficient but would also result
3181 -- in the backend doing cross-unit inlining in cases where it
3182 -- was definitely inappropriate to do so.
3184 -- However, a simple Comes_From_Source test is insufficient,
3185 -- since we do want to allow inlining of generic instances,
3186 -- which also do not come from source. Predefined operators do
3187 -- not come from source but are not inlineable either.
3189 elsif not Comes_From_Source
(Subp
)
3190 and then not Is_Generic_Instance
(Subp
)
3191 and then Scope
(Subp
) /= Standard_Standard
3196 -- The referenced entity must either be the enclosing entity,
3197 -- or an entity declared within the current open scope.
3199 elsif Present
(Scope
(Subp
))
3200 and then Scope
(Subp
) /= Current_Scope
3201 and then Subp
/= Current_Scope
3204 ("argument of% must be entity in current scope", Assoc
);
3208 -- Processing for procedure, operator or function.
3209 -- If subprogram is aliased (as for an instance) indicate
3210 -- that the renamed entity (if declared in the same unit)
3213 if Is_Subprogram
(Subp
) then
3214 while Present
(Alias
(Inner_Subp
)) loop
3215 Inner_Subp
:= Alias
(Inner_Subp
);
3218 if In_Same_Source_Unit
(Subp
, Inner_Subp
) then
3219 Set_Inline_Flags
(Inner_Subp
);
3221 Decl
:= Parent
(Parent
(Inner_Subp
));
3223 if Nkind
(Decl
) = N_Subprogram_Declaration
3224 and then Present
(Corresponding_Body
(Decl
))
3226 Set_Inline_Flags
(Corresponding_Body
(Decl
));
3232 -- For a generic subprogram set flag as well, for use at
3233 -- the point of instantiation, to determine whether the
3234 -- body should be generated.
3236 elsif Is_Generic_Subprogram
(Subp
) then
3237 Set_Inline_Flags
(Subp
);
3240 -- Literals are by definition inlined
3242 elsif Kind
= E_Enumeration_Literal
then
3245 -- Anything else is an error
3249 ("expect subprogram name for pragma%", Assoc
);
3253 ----------------------
3254 -- Set_Inline_Flags --
3255 ----------------------
3257 procedure Set_Inline_Flags
(Subp
: Entity_Id
) is
3260 Set_Is_Inlined
(Subp
, True);
3263 if not Has_Pragma_Inline
(Subp
) then
3264 Set_Has_Pragma_Inline
(Subp
);
3265 Set_Next_Rep_Item
(N
, First_Rep_Item
(Subp
));
3266 Set_First_Rep_Item
(Subp
, N
);
3269 end Set_Inline_Flags
;
3271 -- Start of processing for Process_Inline
3274 Check_No_Identifiers
;
3275 Check_At_Least_N_Arguments
(1);
3278 Inline_Processing_Required
:= True;
3282 while Present
(Assoc
) loop
3283 Subp_Id
:= Expression
(Assoc
);
3287 if Is_Entity_Name
(Subp_Id
) then
3288 Subp
:= Entity
(Subp_Id
);
3290 if Subp
= Any_Id
then
3296 while Present
(Homonym
(Subp
))
3297 and then Scope
(Homonym
(Subp
)) = Current_Scope
3299 Make_Inline
(Homonym
(Subp
));
3300 Subp
:= Homonym
(Subp
);
3307 ("inappropriate argument for pragma%", Assoc
);
3310 and then Warn_On_Redundant_Constructs
3312 if Inlining_Not_Possible
(Subp
) then
3314 ("pragma Inline for& is ignored?", N
, Entity
(Subp_Id
));
3317 ("pragma Inline for& is redundant?", N
, Entity
(Subp_Id
));
3325 ----------------------------
3326 -- Process_Interface_Name --
3327 ----------------------------
3329 procedure Process_Interface_Name
3330 (Subprogram_Def
: Entity_Id
;
3336 String_Val
: String_Id
;
3338 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
);
3339 -- SN is a string literal node for an interface name. This routine
3340 -- performs some minimal checks that the name is reasonable. In
3341 -- particular that no spaces or other obviously incorrect characters
3342 -- appear. This is only a warning, since any characters are allowed.
3344 ----------------------------------
3345 -- Check_Form_Of_Interface_Name --
3346 ----------------------------------
3348 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
) is
3349 S
: constant String_Id
:= Strval
(Expr_Value_S
(SN
));
3350 SL
: constant Nat
:= String_Length
(S
);
3355 Error_Msg_N
("interface name cannot be null string", SN
);
3358 for J
in 1 .. SL
loop
3359 C
:= Get_String_Char
(S
, J
);
3361 if Warn_On_Export_Import
3362 and then (not In_Character_Range
(C
)
3363 or else Get_Character
(C
) = ' '
3364 or else Get_Character
(C
) = ',')
3367 ("?interface name contains illegal character", SN
);
3370 end Check_Form_Of_Interface_Name
;
3372 -- Start of processing for Process_Interface_Name
3375 if No
(Link_Arg
) then
3376 if No
(Ext_Arg
) then
3379 elsif Chars
(Ext_Arg
) = Name_Link_Name
then
3381 Link_Nam
:= Expression
(Ext_Arg
);
3384 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
3385 Ext_Nam
:= Expression
(Ext_Arg
);
3390 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
3391 Check_Optional_Identifier
(Link_Arg
, Name_Link_Name
);
3392 Ext_Nam
:= Expression
(Ext_Arg
);
3393 Link_Nam
:= Expression
(Link_Arg
);
3396 -- Check expressions for external name and link name are static
3398 if Present
(Ext_Nam
) then
3399 Check_Arg_Is_Static_Expression
(Ext_Nam
, Standard_String
);
3400 Check_Form_Of_Interface_Name
(Ext_Nam
);
3402 -- Verify that the external name is not the name of a local
3403 -- entity, which would hide the imported one and lead to
3404 -- run-time surprises. The problem can only arise for entities
3405 -- declared in a package body (otherwise the external name is
3406 -- fully qualified and won't conflict).
3414 if Prag_Id
= Pragma_Import
then
3415 String_To_Name_Buffer
(Strval
(Expr_Value_S
(Ext_Nam
)));
3417 E
:= Entity_Id
(Get_Name_Table_Info
(Nam
));
3419 if Nam
/= Chars
(Subprogram_Def
)
3420 and then Present
(E
)
3421 and then not Is_Overloadable
(E
)
3422 and then Is_Immediately_Visible
(E
)
3423 and then not Is_Imported
(E
)
3424 and then Ekind
(Scope
(E
)) = E_Package
3428 while Present
(Par
) loop
3429 if Nkind
(Par
) = N_Package_Body
then
3430 Error_Msg_Sloc
:= Sloc
(E
);
3432 ("imported entity is hidden by & declared#",
3437 Par
:= Parent
(Par
);
3444 if Present
(Link_Nam
) then
3445 Check_Arg_Is_Static_Expression
(Link_Nam
, Standard_String
);
3446 Check_Form_Of_Interface_Name
(Link_Nam
);
3449 -- If there is no link name, just set the external name
3451 if No
(Link_Nam
) then
3452 Link_Nam
:= Adjust_External_Name_Case
(Expr_Value_S
(Ext_Nam
));
3454 -- For the Link_Name case, the given literal is preceded by an
3455 -- asterisk, which indicates to GCC that the given name should
3456 -- be taken literally, and in particular that no prepending of
3457 -- underlines should occur, even in systems where this is the
3462 Store_String_Char
(Get_Char_Code
('*'));
3463 String_Val
:= Strval
(Expr_Value_S
(Link_Nam
));
3465 for J
in 1 .. String_Length
(String_Val
) loop
3466 Store_String_Char
(Get_String_Char
(String_Val
, J
));
3470 Make_String_Literal
(Sloc
(Link_Nam
), End_String
);
3473 Set_Encoded_Interface_Name
3474 (Get_Base_Subprogram
(Subprogram_Def
), Link_Nam
);
3475 Check_Duplicated_Export_Name
(Link_Nam
);
3476 end Process_Interface_Name
;
3478 -----------------------------------------
3479 -- Process_Interrupt_Or_Attach_Handler --
3480 -----------------------------------------
3482 procedure Process_Interrupt_Or_Attach_Handler
is
3483 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
3484 Handler_Proc
: constant Entity_Id
:= Entity
(Arg1_X
);
3485 Proc_Scope
: constant Entity_Id
:= Scope
(Handler_Proc
);
3488 Set_Is_Interrupt_Handler
(Handler_Proc
);
3490 -- If the pragma is not associated with a handler procedure
3491 -- within a protected type, then it must be for a nonprotected
3492 -- procedure for the AAMP target, in which case we don't
3493 -- associate a representation item with the procedure's scope.
3495 if Ekind
(Proc_Scope
) = E_Protected_Type
then
3496 if Prag_Id
= Pragma_Interrupt_Handler
3498 Prag_Id
= Pragma_Attach_Handler
3500 Record_Rep_Item
(Proc_Scope
, N
);
3503 end Process_Interrupt_Or_Attach_Handler
;
3505 --------------------------------------------------
3506 -- Process_Restrictions_Or_Restriction_Warnings --
3507 --------------------------------------------------
3509 -- Note: some of the simple identifier cases were handled in par-prag,
3510 -- but it is harmless (and more straightforward) to simply handle all
3511 -- cases here, even if it means we repeat a bit of work in some cases.
3513 procedure Process_Restrictions_Or_Restriction_Warnings
is
3515 R_Id
: Restriction_Id
;
3520 procedure Check_Unit_Name
(N
: Node_Id
);
3521 -- Checks unit name parameter for No_Dependence. Returns if it has
3522 -- an appropriate form, otherwise raises pragma argument error.
3524 procedure Set_Warning
(R
: All_Restrictions
);
3525 -- If this is a Restriction_Warnings pragma, set warning flag,
3526 -- otherwise reset the flag.
3528 ---------------------
3529 -- Check_Unit_Name --
3530 ---------------------
3532 procedure Check_Unit_Name
(N
: Node_Id
) is
3534 if Nkind
(N
) = N_Selected_Component
then
3535 Check_Unit_Name
(Prefix
(N
));
3536 Check_Unit_Name
(Selector_Name
(N
));
3538 elsif Nkind
(N
) = N_Identifier
then
3543 ("wrong form for unit name for No_Dependence", N
);
3545 end Check_Unit_Name
;
3551 procedure Set_Warning
(R
: All_Restrictions
) is
3553 if Prag_Id
= Pragma_Restriction_Warnings
then
3554 Restriction_Warnings
(R
) := True;
3556 Restriction_Warnings
(R
) := False;
3560 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
3563 Check_Ada_83_Warning
;
3564 Check_At_Least_N_Arguments
(1);
3565 Check_Valid_Configuration_Pragma
;
3568 while Present
(Arg
) loop
3570 Expr
:= Expression
(Arg
);
3572 -- Case of no restriction identifier present
3574 if Id
= No_Name
then
3575 if Nkind
(Expr
) /= N_Identifier
then
3577 ("invalid form for restriction", Arg
);
3582 (Process_Restriction_Synonyms
(Expr
));
3584 if R_Id
not in All_Boolean_Restrictions
then
3586 ("invalid restriction identifier", Arg
);
3589 if Implementation_Restriction
(R_Id
) then
3591 (No_Implementation_Restrictions
, Arg
);
3594 Set_Restriction
(R_Id
, N
);
3597 -- A very special case that must be processed here:
3598 -- pragma Restrictions (No_Exceptions) turns off
3599 -- all run-time checking. This is a bit dubious in
3600 -- terms of the formal language definition, but it
3601 -- is what is intended by RM H.4(12).
3603 if R_Id
= No_Exceptions
then
3604 Scope_Suppress
:= (others => True);
3607 -- Case of No_Dependence => unit-name. Note that the parser
3608 -- already made the necessary entry in the No_Dependence table.
3610 elsif Id
= Name_No_Dependence
then
3611 Check_Unit_Name
(Expr
);
3613 -- All other cases of restriction identifier present
3616 R_Id
:= Get_Restriction_Id
(Process_Restriction_Synonyms
(Arg
));
3617 Analyze_And_Resolve
(Expr
, Any_Integer
);
3619 if R_Id
not in All_Parameter_Restrictions
then
3621 ("invalid restriction parameter identifier", Arg
);
3623 elsif not Is_OK_Static_Expression
(Expr
) then
3624 Flag_Non_Static_Expr
3625 ("value must be static expression!", Expr
);
3628 elsif not Is_Integer_Type
(Etype
(Expr
))
3629 or else Expr_Value
(Expr
) < 0
3632 ("value must be non-negative integer", Arg
);
3634 -- Restriction pragma is active
3637 Val
:= Expr_Value
(Expr
);
3639 if not UI_Is_In_Int_Range
(Val
) then
3641 ("pragma ignored, value too large?", Arg
);
3643 Set_Restriction
(R_Id
, N
, Integer (UI_To_Int
(Val
)));
3651 end Process_Restrictions_Or_Restriction_Warnings
;
3653 ---------------------------------
3654 -- Process_Suppress_Unsuppress --
3655 ---------------------------------
3657 -- Note: this procedure makes entries in the check suppress data
3658 -- structures managed by Sem. See spec of package Sem for full
3659 -- details on how we handle recording of check suppression.
3661 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean) is
3666 In_Package_Spec
: constant Boolean :=
3667 (Ekind
(Current_Scope
) = E_Package
3669 Ekind
(Current_Scope
) = E_Generic_Package
)
3670 and then not In_Package_Body
(Current_Scope
);
3672 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
);
3673 -- Used to suppress a single check on the given entity
3675 --------------------------------
3676 -- Suppress_Unsuppress_Echeck --
3677 --------------------------------
3679 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
) is
3680 ESR
: constant Entity_Check_Suppress_Record
:=
3683 Suppress
=> Suppress_Case
);
3686 Set_Checks_May_Be_Suppressed
(E
);
3688 if In_Package_Spec
then
3689 Global_Entity_Suppress
.Append
(ESR
);
3691 Local_Entity_Suppress
.Append
(ESR
);
3694 -- If this is a first subtype, and the base type is distinct,
3695 -- then also set the suppress flags on the base type.
3697 if Is_First_Subtype
(E
)
3698 and then Etype
(E
) /= E
3700 Suppress_Unsuppress_Echeck
(Etype
(E
), C
);
3702 end Suppress_Unsuppress_Echeck
;
3704 -- Start of processing for Process_Suppress_Unsuppress
3707 -- Suppress/Unsuppress can appear as a configuration pragma,
3708 -- or in a declarative part or a package spec (RM 11.5(5))
3710 if not Is_Configuration_Pragma
then
3711 Check_Is_In_Decl_Part_Or_Package_Spec
;
3714 Check_At_Least_N_Arguments
(1);
3715 Check_At_Most_N_Arguments
(2);
3716 Check_No_Identifier
(Arg1
);
3717 Check_Arg_Is_Identifier
(Arg1
);
3719 if not Is_Check_Name
(Chars
(Expression
(Arg1
))) then
3721 ("argument of pragma% is not valid check name", Arg1
);
3723 C
:= Get_Check_Id
(Chars
(Expression
(Arg1
)));
3726 if Arg_Count
= 1 then
3728 -- Make an entry in the local scope suppress table. This is the
3729 -- table that directly shows the current value of the scope
3730 -- suppress check for any check id value.
3732 if C
= All_Checks
then
3733 for J
in Scope_Suppress
'Range loop
3734 Scope_Suppress
(J
) := Suppress_Case
;
3737 Scope_Suppress
(C
) := Suppress_Case
;
3740 -- Also make an entry in the Local_Entity_Suppress table. See
3741 -- extended description in the package spec of Sem for details.
3743 Local_Entity_Suppress
.Append
3746 Suppress
=> Suppress_Case
));
3748 -- Case of two arguments present, where the check is
3749 -- suppressed for a specified entity (given as the second
3750 -- argument of the pragma)
3753 Check_Optional_Identifier
(Arg2
, Name_On
);
3754 E_Id
:= Expression
(Arg2
);
3757 if not Is_Entity_Name
(E_Id
) then
3759 ("second argument of pragma% must be entity name", Arg2
);
3768 -- Enforce RM 11.5(7) which requires that for a pragma that
3769 -- appears within a package spec, the named entity must be
3770 -- within the package spec. We allow the package name itself
3771 -- to be mentioned since that makes sense, although it is not
3772 -- strictly allowed by 11.5(7).
3775 and then E
/= Current_Scope
3776 and then Scope
(E
) /= Current_Scope
3779 ("entity in pragma% is not in package spec ('R'M 11.5(7))",
3783 -- Loop through homonyms. As noted below, in the case of a package
3784 -- spec, only homonyms within the package spec are considered.
3787 Suppress_Unsuppress_Echeck
(E
, C
);
3789 if Is_Generic_Instance
(E
)
3790 and then Is_Subprogram
(E
)
3791 and then Present
(Alias
(E
))
3793 Suppress_Unsuppress_Echeck
(Alias
(E
), C
);
3796 -- Move to next homonym
3801 -- If we are within a package specification, the
3802 -- pragma only applies to homonyms in the same scope.
3804 exit when In_Package_Spec
3805 and then Scope
(E
) /= Current_Scope
;
3808 end Process_Suppress_Unsuppress
;
3814 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
) is
3816 if Is_Imported
(E
) then
3818 ("cannot export entity& that was previously imported", Arg
);
3820 elsif Present
(Address_Clause
(E
)) then
3822 ("cannot export entity& that has an address clause", Arg
);
3825 Set_Is_Exported
(E
);
3827 -- Generate a reference for entity explicitly, because the
3828 -- identifier may be overloaded and name resolution will not
3831 Generate_Reference
(E
, Arg
);
3833 -- Deal with exporting non-library level entity
3835 if not Is_Library_Level_Entity
(E
) then
3837 -- Not allowed at all for subprograms
3839 if Is_Subprogram
(E
) then
3840 Error_Pragma_Arg
("local subprogram& cannot be exported", Arg
);
3842 -- Otherwise set public and statically allocated
3846 Set_Is_Statically_Allocated
(E
);
3848 -- Warn if the corresponding W flag is set and the pragma
3849 -- comes from source. The latter may not be true e.g. on
3850 -- VMS where we expand export pragmas for exception codes
3851 -- associated with imported or exported exceptions. We do
3852 -- not want to generate a warning for something that the
3853 -- user did not write.
3855 if Warn_On_Export_Import
3856 and then Comes_From_Source
(Arg
)
3859 ("?& has been made static as a result of Export", Arg
, E
);
3861 ("\this usage is non-standard and non-portable", Arg
);
3866 if Warn_On_Export_Import
and then Is_Type
(E
) then
3868 ("exporting a type has no effect?", Arg
, E
);
3871 if Warn_On_Export_Import
and Inside_A_Generic
then
3873 ("all instances of& will have the same external name?", Arg
, E
);
3877 ----------------------------------------------
3878 -- Set_Extended_Import_Export_External_Name --
3879 ----------------------------------------------
3881 procedure Set_Extended_Import_Export_External_Name
3882 (Internal_Ent
: Entity_Id
;
3883 Arg_External
: Node_Id
)
3885 Old_Name
: constant Node_Id
:= Interface_Name
(Internal_Ent
);
3889 if No
(Arg_External
) then
3893 Check_Arg_Is_External_Name
(Arg_External
);
3895 if Nkind
(Arg_External
) = N_String_Literal
then
3896 if String_Length
(Strval
(Arg_External
)) = 0 then
3899 New_Name
:= Adjust_External_Name_Case
(Arg_External
);
3902 elsif Nkind
(Arg_External
) = N_Identifier
then
3903 New_Name
:= Get_Default_External_Name
(Arg_External
);
3905 -- Check_Arg_Is_External_Name should let through only
3906 -- identifiers and string literals or static string
3907 -- expressions (which are folded to string literals).
3910 raise Program_Error
;
3913 -- If we already have an external name set (by a prior normal
3914 -- Import or Export pragma), then the external names must match
3916 if Present
(Interface_Name
(Internal_Ent
)) then
3917 Check_Matching_Internal_Names
: declare
3918 S1
: constant String_Id
:= Strval
(Old_Name
);
3919 S2
: constant String_Id
:= Strval
(New_Name
);
3922 -- Called if names do not match
3928 procedure Mismatch
is
3930 Error_Msg_Sloc
:= Sloc
(Old_Name
);
3932 ("external name does not match that given #",
3936 -- Start of processing for Check_Matching_Internal_Names
3939 if String_Length
(S1
) /= String_Length
(S2
) then
3943 for J
in 1 .. String_Length
(S1
) loop
3944 if Get_String_Char
(S1
, J
) /= Get_String_Char
(S2
, J
) then
3949 end Check_Matching_Internal_Names
;
3951 -- Otherwise set the given name
3954 Set_Encoded_Interface_Name
(Internal_Ent
, New_Name
);
3955 Check_Duplicated_Export_Name
(New_Name
);
3957 end Set_Extended_Import_Export_External_Name
;
3963 procedure Set_Imported
(E
: Entity_Id
) is
3965 Error_Msg_Sloc
:= Sloc
(E
);
3967 if Is_Exported
(E
) or else Is_Imported
(E
) then
3968 Error_Msg_NE
("import of& declared# not allowed", N
, E
);
3970 if Is_Exported
(E
) then
3971 Error_Msg_N
("\entity was previously exported", N
);
3973 Error_Msg_N
("\entity was previously imported", N
);
3976 Error_Pragma
("\(pragma% applies to all previous entities)");
3979 Set_Is_Imported
(E
);
3981 -- If the entity is an object that is not at the library
3982 -- level, then it is statically allocated. We do not worry
3983 -- about objects with address clauses in this context since
3984 -- they are not really imported in the linker sense.
3987 and then not Is_Library_Level_Entity
(E
)
3988 and then No
(Address_Clause
(E
))
3990 Set_Is_Statically_Allocated
(E
);
3995 -------------------------
3996 -- Set_Mechanism_Value --
3997 -------------------------
3999 -- Note: the mechanism name has not been analyzed (and cannot indeed
4000 -- be analyzed, since it is semantic nonsense), so we get it in the
4001 -- exact form created by the parser.
4003 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
) is
4007 procedure Bad_Class
;
4008 -- Signal bad descriptor class name
4010 procedure Bad_Mechanism
;
4011 -- Signal bad mechanism name
4017 procedure Bad_Class
is
4019 Error_Pragma_Arg
("unrecognized descriptor class name", Class
);
4022 -------------------------
4023 -- Bad_Mechanism_Value --
4024 -------------------------
4026 procedure Bad_Mechanism
is
4028 Error_Pragma_Arg
("unrecognized mechanism name", Mech_Name
);
4031 -- Start of processing for Set_Mechanism_Value
4034 if Mechanism
(Ent
) /= Default_Mechanism
then
4036 ("mechanism for & has already been set", Mech_Name
, Ent
);
4039 -- MECHANISM_NAME ::= value | reference | descriptor
4041 if Nkind
(Mech_Name
) = N_Identifier
then
4042 if Chars
(Mech_Name
) = Name_Value
then
4043 Set_Mechanism
(Ent
, By_Copy
);
4046 elsif Chars
(Mech_Name
) = Name_Reference
then
4047 Set_Mechanism
(Ent
, By_Reference
);
4050 elsif Chars
(Mech_Name
) = Name_Descriptor
then
4051 Check_VMS
(Mech_Name
);
4052 Set_Mechanism
(Ent
, By_Descriptor
);
4055 elsif Chars
(Mech_Name
) = Name_Copy
then
4057 ("bad mechanism name, Value assumed", Mech_Name
);
4063 -- MECHANISM_NAME ::= descriptor (CLASS_NAME)
4064 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4066 -- Note: this form is parsed as an indexed component
4068 elsif Nkind
(Mech_Name
) = N_Indexed_Component
then
4069 Class
:= First
(Expressions
(Mech_Name
));
4071 if Nkind
(Prefix
(Mech_Name
)) /= N_Identifier
4072 or else Chars
(Prefix
(Mech_Name
)) /= Name_Descriptor
4073 or else Present
(Next
(Class
))
4078 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME)
4079 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4081 -- Note: this form is parsed as a function call
4083 elsif Nkind
(Mech_Name
) = N_Function_Call
then
4085 Param
:= First
(Parameter_Associations
(Mech_Name
));
4087 if Nkind
(Name
(Mech_Name
)) /= N_Identifier
4088 or else Chars
(Name
(Mech_Name
)) /= Name_Descriptor
4089 or else Present
(Next
(Param
))
4090 or else No
(Selector_Name
(Param
))
4091 or else Chars
(Selector_Name
(Param
)) /= Name_Class
4095 Class
:= Explicit_Actual_Parameter
(Param
);
4102 -- Fall through here with Class set to descriptor class name
4104 Check_VMS
(Mech_Name
);
4106 if Nkind
(Class
) /= N_Identifier
then
4109 elsif Chars
(Class
) = Name_UBS
then
4110 Set_Mechanism
(Ent
, By_Descriptor_UBS
);
4112 elsif Chars
(Class
) = Name_UBSB
then
4113 Set_Mechanism
(Ent
, By_Descriptor_UBSB
);
4115 elsif Chars
(Class
) = Name_UBA
then
4116 Set_Mechanism
(Ent
, By_Descriptor_UBA
);
4118 elsif Chars
(Class
) = Name_S
then
4119 Set_Mechanism
(Ent
, By_Descriptor_S
);
4121 elsif Chars
(Class
) = Name_SB
then
4122 Set_Mechanism
(Ent
, By_Descriptor_SB
);
4124 elsif Chars
(Class
) = Name_A
then
4125 Set_Mechanism
(Ent
, By_Descriptor_A
);
4127 elsif Chars
(Class
) = Name_NCA
then
4128 Set_Mechanism
(Ent
, By_Descriptor_NCA
);
4133 end Set_Mechanism_Value
;
4135 ---------------------------
4136 -- Set_Ravenscar_Profile --
4137 ---------------------------
4139 -- The tasks to be done here are
4141 -- Set required policies
4143 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4144 -- pragma Locking_Policy (Ceiling_Locking)
4146 -- Set Detect_Blocking mode
4148 -- Set required restrictions (see System.Rident for detailed list)
4150 procedure Set_Ravenscar_Profile
(N
: Node_Id
) is
4152 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4154 if Task_Dispatching_Policy
/= ' '
4155 and then Task_Dispatching_Policy
/= 'F'
4157 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
4158 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4160 -- Set the FIFO_Within_Priorities policy, but always
4161 -- preserve System_Location since we like the error
4162 -- message with the run time name.
4165 Task_Dispatching_Policy
:= 'F';
4167 if Task_Dispatching_Policy_Sloc
/= System_Location
then
4168 Task_Dispatching_Policy_Sloc
:= Loc
;
4172 -- pragma Locking_Policy (Ceiling_Locking)
4174 if Locking_Policy
/= ' '
4175 and then Locking_Policy
/= 'C'
4177 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
4178 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4180 -- Set the Ceiling_Locking policy, but always preserve
4181 -- System_Location since we like the error message with the
4185 Locking_Policy
:= 'C';
4187 if Locking_Policy_Sloc
/= System_Location
then
4188 Locking_Policy_Sloc
:= Loc
;
4192 -- pragma Detect_Blocking
4194 Detect_Blocking
:= True;
4196 -- Set the corresponding restrictions
4198 Set_Profile_Restrictions
(Ravenscar
, N
, Warn
=> False);
4199 end Set_Ravenscar_Profile
;
4201 -- Start of processing for Analyze_Pragma
4204 if not Is_Pragma_Name
(Chars
(N
)) then
4205 if Warn_On_Unrecognized_Pragma
then
4206 Error_Pragma
("unrecognized pragma%!?");
4211 Prag_Id
:= Get_Pragma_Id
(Chars
(N
));
4221 if Present
(Pragma_Argument_Associations
(N
)) then
4222 Arg1
:= First
(Pragma_Argument_Associations
(N
));
4224 if Present
(Arg1
) then
4225 Arg2
:= Next
(Arg1
);
4227 if Present
(Arg2
) then
4228 Arg3
:= Next
(Arg2
);
4230 if Present
(Arg3
) then
4231 Arg4
:= Next
(Arg3
);
4237 -- Count number of arguments
4244 while Present
(Arg_Node
) loop
4245 Arg_Count
:= Arg_Count
+ 1;
4250 -- An enumeration type defines the pragmas that are supported by the
4251 -- implementation. Get_Pragma_Id (in package Prag) transorms a name
4252 -- into the corresponding enumeration value for the following case.
4260 -- pragma Abort_Defer;
4262 when Pragma_Abort_Defer
=>
4264 Check_Arg_Count
(0);
4266 -- The only required semantic processing is to check the
4267 -- placement. This pragma must appear at the start of the
4268 -- statement sequence of a handled sequence of statements.
4270 if Nkind
(Parent
(N
)) /= N_Handled_Sequence_Of_Statements
4271 or else N
/= First
(Statements
(Parent
(N
)))
4282 -- Note: this pragma also has some specific processing in Par.Prag
4283 -- because we want to set the Ada version mode during parsing.
4285 when Pragma_Ada_83
=>
4287 Ada_Version
:= Ada_83
;
4288 Check_Arg_Count
(0);
4296 -- Note: this pragma also has some specific processing in Par.Prag
4297 -- because we want to set the Ada 83 version mode during parsing.
4299 when Pragma_Ada_95
=>
4301 Ada_Version
:= Ada_95
;
4302 Check_Arg_Count
(0);
4310 -- Note: this pragma also has some specific processing in Par.Prag
4311 -- because we want to set the Ada 83 version mode during parsing.
4313 when Pragma_Ada_05
=>
4315 Ada_Version
:= Ada_05
;
4316 Check_Arg_Count
(0);
4318 ----------------------
4319 -- All_Calls_Remote --
4320 ----------------------
4322 -- pragma All_Calls_Remote [(library_package_NAME)];
4324 when Pragma_All_Calls_Remote
=> All_Calls_Remote
: declare
4325 Lib_Entity
: Entity_Id
;
4328 Check_Ada_83_Warning
;
4329 Check_Valid_Library_Unit_Pragma
;
4331 if Nkind
(N
) = N_Null_Statement
then
4335 Lib_Entity
:= Find_Lib_Unit_Name
;
4337 -- This pragma should only apply to a RCI unit (RM E.2.3(23)).
4339 if Present
(Lib_Entity
)
4340 and then not Debug_Flag_U
4342 if not Is_Remote_Call_Interface
(Lib_Entity
) then
4343 Error_Pragma
("pragma% only apply to rci unit");
4345 -- Set flag for entity of the library unit
4348 Set_Has_All_Calls_Remote
(Lib_Entity
);
4352 end All_Calls_Remote
;
4358 -- pragma Annotate (IDENTIFIER {, ARG});
4359 -- ARG ::= NAME | EXPRESSION
4361 when Pragma_Annotate
=> Annotate
: begin
4363 Check_At_Least_N_Arguments
(1);
4364 Check_Arg_Is_Identifier
(Arg1
);
4367 Arg
: Node_Id
:= Arg2
;
4371 while Present
(Arg
) loop
4372 Exp
:= Expression
(Arg
);
4375 if Is_Entity_Name
(Exp
) then
4378 elsif Nkind
(Exp
) = N_String_Literal
then
4379 Resolve
(Exp
, Standard_String
);
4381 elsif Is_Overloaded
(Exp
) then
4382 Error_Pragma_Arg
("ambiguous argument for pragma%", Exp
);
4397 -- pragma Assert (Boolean_EXPRESSION [, static_string_EXPRESSION]);
4399 when Pragma_Assert
=>
4401 Check_No_Identifiers
;
4403 if Arg_Count
> 1 then
4404 Check_Arg_Count
(2);
4405 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
4408 -- If expansion is active and assertions are inactive, then
4409 -- we rewrite the Assertion as:
4411 -- if False and then condition then
4415 -- The reason we do this rewriting during semantic analysis
4416 -- rather than as part of normal expansion is that we cannot
4417 -- analyze and expand the code for the boolean expression
4418 -- directly, or it may cause insertion of actions that would
4419 -- escape the attempt to suppress the assertion code.
4421 if Expander_Active
and not Assertions_Enabled
then
4423 Make_If_Statement
(Loc
,
4426 Left_Opnd
=> New_Occurrence_Of
(Standard_False
, Loc
),
4427 Right_Opnd
=> Get_Pragma_Arg
(Arg1
)),
4428 Then_Statements
=> New_List
(
4429 Make_Null_Statement
(Loc
))));
4433 -- Otherwise (if assertions are enabled, or if we are not
4434 -- operating with expansion active), then we just analyze
4435 -- and resolve the expression.
4438 Analyze_And_Resolve
(Expression
(Arg1
), Any_Boolean
);
4445 -- pragma AST_Entry (entry_IDENTIFIER);
4447 when Pragma_AST_Entry
=> AST_Entry
: declare
4453 Check_Arg_Count
(1);
4454 Check_No_Identifiers
;
4455 Check_Arg_Is_Local_Name
(Arg1
);
4456 Ent
:= Entity
(Expression
(Arg1
));
4458 -- Note: the implementation of the AST_Entry pragma could handle
4459 -- the entry family case fine, but for now we are consistent with
4460 -- the DEC rules, and do not allow the pragma, which of course
4461 -- has the effect of also forbidding the attribute.
4463 if Ekind
(Ent
) /= E_Entry
then
4465 ("pragma% argument must be simple entry name", Arg1
);
4467 elsif Is_AST_Entry
(Ent
) then
4469 ("duplicate % pragma for entry", Arg1
);
4471 elsif Has_Homonym
(Ent
) then
4473 ("pragma% argument cannot specify overloaded entry", Arg1
);
4477 FF
: constant Entity_Id
:= First_Formal
(Ent
);
4480 if Present
(FF
) then
4481 if Present
(Next_Formal
(FF
)) then
4483 ("entry for pragma% can have only one argument",
4486 elsif Parameter_Mode
(FF
) /= E_In_Parameter
then
4488 ("entry parameter for pragma% must have mode IN",
4494 Set_Is_AST_Entry
(Ent
);
4502 -- pragma Asynchronous (LOCAL_NAME);
4504 when Pragma_Asynchronous
=> Asynchronous
: declare
4512 procedure Process_Async_Pragma
;
4513 -- Common processing for procedure and access-to-procedure case
4515 --------------------------
4516 -- Process_Async_Pragma --
4517 --------------------------
4519 procedure Process_Async_Pragma
is
4521 if not Present
(L
) then
4522 Set_Is_Asynchronous
(Nm
);
4526 -- The formals should be of mode IN (RM E.4.1(6))
4529 while Present
(S
) loop
4530 Formal
:= Defining_Identifier
(S
);
4532 if Nkind
(Formal
) = N_Defining_Identifier
4533 and then Ekind
(Formal
) /= E_In_Parameter
4536 ("pragma% procedure can only have IN parameter",
4543 Set_Is_Asynchronous
(Nm
);
4544 end Process_Async_Pragma
;
4546 -- Start of processing for pragma Asynchronous
4549 Check_Ada_83_Warning
;
4550 Check_No_Identifiers
;
4551 Check_Arg_Count
(1);
4552 Check_Arg_Is_Local_Name
(Arg1
);
4554 if Debug_Flag_U
then
4558 C_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
4559 Analyze
(Expression
(Arg1
));
4560 Nm
:= Entity
(Expression
(Arg1
));
4562 if not Is_Remote_Call_Interface
(C_Ent
)
4563 and then not Is_Remote_Types
(C_Ent
)
4565 -- This pragma should only appear in an RCI or Remote Types
4566 -- unit (RM E.4.1(4))
4569 ("pragma% not in Remote_Call_Interface or " &
4570 "Remote_Types unit");
4573 if Ekind
(Nm
) = E_Procedure
4574 and then Nkind
(Parent
(Nm
)) = N_Procedure_Specification
4576 if not Is_Remote_Call_Interface
(Nm
) then
4578 ("pragma% cannot be applied on non-remote procedure",
4582 L
:= Parameter_Specifications
(Parent
(Nm
));
4583 Process_Async_Pragma
;
4586 elsif Ekind
(Nm
) = E_Function
then
4588 ("pragma% cannot be applied to function", Arg1
);
4590 elsif Ekind
(Nm
) = E_Record_Type
4591 and then Present
(Corresponding_Remote_Type
(Nm
))
4593 -- A record type that is the Equivalent_Type for
4594 -- a remote access-to-subprogram type.
4596 N
:= Declaration_Node
(Corresponding_Remote_Type
(Nm
));
4598 if Nkind
(N
) = N_Full_Type_Declaration
4599 and then Nkind
(Type_Definition
(N
)) =
4600 N_Access_Procedure_Definition
4602 L
:= Parameter_Specifications
(Type_Definition
(N
));
4603 Process_Async_Pragma
;
4605 if Is_Asynchronous
(Nm
)
4606 and then Expander_Active
4608 RACW_Type_Is_Asynchronous
(
4609 Underlying_RACW_Type
(Nm
));
4614 ("pragma% cannot reference access-to-function type",
4618 -- Only other possibility is Access-to-class-wide type
4620 elsif Is_Access_Type
(Nm
)
4621 and then Is_Class_Wide_Type
(Designated_Type
(Nm
))
4623 Check_First_Subtype
(Arg1
);
4624 Set_Is_Asynchronous
(Nm
);
4625 if Expander_Active
then
4626 RACW_Type_Is_Asynchronous
(Nm
);
4630 Error_Pragma_Arg
("inappropriate argument for pragma%", Arg1
);
4638 -- pragma Atomic (LOCAL_NAME);
4640 when Pragma_Atomic
=>
4641 Process_Atomic_Shared_Volatile
;
4643 -----------------------
4644 -- Atomic_Components --
4645 -----------------------
4647 -- pragma Atomic_Components (array_LOCAL_NAME);
4649 -- This processing is shared by Volatile_Components
4651 when Pragma_Atomic_Components |
4652 Pragma_Volatile_Components
=>
4654 Atomic_Components
: declare
4661 Check_Ada_83_Warning
;
4662 Check_No_Identifiers
;
4663 Check_Arg_Count
(1);
4664 Check_Arg_Is_Local_Name
(Arg1
);
4665 E_Id
:= Expression
(Arg1
);
4667 if Etype
(E_Id
) = Any_Type
then
4673 if Rep_Item_Too_Early
(E
, N
)
4675 Rep_Item_Too_Late
(E
, N
)
4680 D
:= Declaration_Node
(E
);
4683 if (K
= N_Full_Type_Declaration
and then Is_Array_Type
(E
))
4685 ((Ekind
(E
) = E_Constant
or else Ekind
(E
) = E_Variable
)
4686 and then Nkind
(D
) = N_Object_Declaration
4687 and then Nkind
(Object_Definition
(D
)) =
4688 N_Constrained_Array_Definition
)
4690 -- The flag is set on the object, or on the base type
4692 if Nkind
(D
) /= N_Object_Declaration
then
4696 Set_Has_Volatile_Components
(E
);
4698 if Prag_Id
= Pragma_Atomic_Components
then
4699 Set_Has_Atomic_Components
(E
);
4701 if Is_Packed
(E
) then
4702 Set_Is_Packed
(E
, False);
4705 ("?Pack canceled, cannot pack atomic components",
4711 Error_Pragma_Arg
("inappropriate entity for pragma%", Arg1
);
4713 end Atomic_Components
;
4715 --------------------
4716 -- Attach_Handler --
4717 --------------------
4719 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
4721 when Pragma_Attach_Handler
=>
4722 Check_Ada_83_Warning
;
4723 Check_No_Identifiers
;
4724 Check_Arg_Count
(2);
4726 if No_Run_Time_Mode
then
4727 Error_Msg_CRT
("Attach_Handler pragma", N
);
4729 Check_Interrupt_Or_Attach_Handler
;
4731 -- The expression that designates the attribute may
4732 -- depend on a discriminant, and is therefore a per-
4733 -- object expression, to be expanded in the init proc.
4734 -- If expansion is enabled, perform semantic checks
4737 if Expander_Active
then
4739 Temp
: constant Node_Id
:=
4740 New_Copy_Tree
(Expression
(Arg2
));
4742 Set_Parent
(Temp
, N
);
4743 Pre_Analyze_And_Resolve
(Temp
, RTE
(RE_Interrupt_ID
));
4747 Analyze
(Expression
(Arg2
));
4748 Resolve
(Expression
(Arg2
), RTE
(RE_Interrupt_ID
));
4751 Process_Interrupt_Or_Attach_Handler
;
4754 --------------------
4755 -- C_Pass_By_Copy --
4756 --------------------
4758 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
4760 when Pragma_C_Pass_By_Copy
=> C_Pass_By_Copy
: declare
4766 Check_Valid_Configuration_Pragma
;
4767 Check_Arg_Count
(1);
4768 Check_Optional_Identifier
(Arg1
, "max_size");
4770 Arg
:= Expression
(Arg1
);
4771 Check_Arg_Is_Static_Expression
(Arg
, Any_Integer
);
4773 Val
:= Expr_Value
(Arg
);
4777 ("maximum size for pragma% must be positive", Arg1
);
4779 elsif UI_Is_In_Int_Range
(Val
) then
4780 Default_C_Record_Mechanism
:= UI_To_Int
(Val
);
4782 -- If a giant value is given, Int'Last will do well enough.
4783 -- If sometime someone complains that a record larger than
4784 -- two gigabytes is not copied, we will worry about it then!
4787 Default_C_Record_Mechanism
:= Mechanism_Type
'Last;
4795 -- pragma Comment (static_string_EXPRESSION)
4797 -- Processing for pragma Comment shares the circuitry for
4798 -- pragma Ident. The only differences are that Ident enforces
4799 -- a limit of 31 characters on its argument, and also enforces
4800 -- limitations on placement for DEC compatibility. Pragma
4801 -- Comment shares neither of these restrictions.
4807 -- pragma Common_Object (
4808 -- [Internal =>] LOCAL_NAME,
4809 -- [, [External =>] EXTERNAL_SYMBOL]
4810 -- [, [Size =>] EXTERNAL_SYMBOL]);
4812 -- Processing for this pragma is shared with Psect_Object
4814 --------------------------
4815 -- Compile_Time_Warning --
4816 --------------------------
4818 -- pragma Compile_Time_Warning
4819 -- (boolean_EXPRESSION, static_string_EXPRESSION);
4821 when Pragma_Compile_Time_Warning
=> Compile_Time_Warning
: declare
4822 Arg1x
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
4826 Check_Arg_Count
(2);
4827 Check_No_Identifiers
;
4828 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
4829 Analyze_And_Resolve
(Arg1x
, Standard_Boolean
);
4831 if Compile_Time_Known_Value
(Arg1x
) then
4832 if Is_True
(Expr_Value
(Get_Pragma_Arg
(Arg1
))) then
4833 String_To_Name_Buffer
(Strval
(Get_Pragma_Arg
(Arg2
)));
4834 Add_Char_To_Name_Buffer
('?');
4837 Msg
: String (1 .. Name_Len
) :=
4838 Name_Buffer
(1 .. Name_Len
);
4843 -- This loop looks for multiple lines separated by
4844 -- ASCII.LF and breaks them into continuation error
4845 -- messages marked with the usual back slash.
4848 for S
in 2 .. Msg
'Length - 1 loop
4849 if Msg
(S
) = ASCII
.LF
then
4851 Error_Msg_N
(Msg
(B
.. S
), Arg1
);
4857 Error_Msg_N
(Msg
(B
.. Msg
'Length), Arg1
);
4861 end Compile_Time_Warning
;
4863 ----------------------------
4864 -- Complex_Representation --
4865 ----------------------------
4867 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
4869 when Pragma_Complex_Representation
=> Complex_Representation
: declare
4876 Check_Arg_Count
(1);
4877 Check_Optional_Identifier
(Arg1
, Name_Entity
);
4878 Check_Arg_Is_Local_Name
(Arg1
);
4879 E_Id
:= Expression
(Arg1
);
4881 if Etype
(E_Id
) = Any_Type
then
4887 if not Is_Record_Type
(E
) then
4889 ("argument for pragma% must be record type", Arg1
);
4892 Ent
:= First_Entity
(E
);
4895 or else No
(Next_Entity
(Ent
))
4896 or else Present
(Next_Entity
(Next_Entity
(Ent
)))
4897 or else not Is_Floating_Point_Type
(Etype
(Ent
))
4898 or else Etype
(Ent
) /= Etype
(Next_Entity
(Ent
))
4901 ("record for pragma% must have two fields of same fpt type",
4905 Set_Has_Complex_Representation
(Base_Type
(E
));
4907 end Complex_Representation
;
4909 -------------------------
4910 -- Component_Alignment --
4911 -------------------------
4913 -- pragma Component_Alignment (
4914 -- [Form =>] ALIGNMENT_CHOICE
4915 -- [, [Name =>] type_LOCAL_NAME]);
4917 -- ALIGNMENT_CHOICE ::=
4919 -- | Component_Size_4
4923 when Pragma_Component_Alignment
=> Component_AlignmentP
: declare
4924 Args
: Args_List
(1 .. 2);
4925 Names
: constant Name_List
(1 .. 2) := (
4929 Form
: Node_Id
renames Args
(1);
4930 Name
: Node_Id
renames Args
(2);
4932 Atype
: Component_Alignment_Kind
;
4937 Gather_Associations
(Names
, Args
);
4940 Error_Pragma
("missing Form argument for pragma%");
4943 Check_Arg_Is_Identifier
(Form
);
4945 -- Get proper alignment, note that Default = Component_Size
4946 -- on all machines we have so far, and we want to set this
4947 -- value rather than the default value to indicate that it
4948 -- has been explicitly set (and thus will not get overridden
4949 -- by the default component alignment for the current scope)
4951 if Chars
(Form
) = Name_Component_Size
then
4952 Atype
:= Calign_Component_Size
;
4954 elsif Chars
(Form
) = Name_Component_Size_4
then
4955 Atype
:= Calign_Component_Size_4
;
4957 elsif Chars
(Form
) = Name_Default
then
4958 Atype
:= Calign_Component_Size
;
4960 elsif Chars
(Form
) = Name_Storage_Unit
then
4961 Atype
:= Calign_Storage_Unit
;
4965 ("invalid Form parameter for pragma%", Form
);
4968 -- Case with no name, supplied, affects scope table entry
4972 (Scope_Stack
.Last
).Component_Alignment_Default
:= Atype
;
4974 -- Case of name supplied
4977 Check_Arg_Is_Local_Name
(Name
);
4979 Typ
:= Entity
(Name
);
4982 or else Rep_Item_Too_Early
(Typ
, N
)
4986 Typ
:= Underlying_Type
(Typ
);
4989 if not Is_Record_Type
(Typ
)
4990 and then not Is_Array_Type
(Typ
)
4993 ("Name parameter of pragma% must identify record or " &
4994 "array type", Name
);
4997 -- An explicit Component_Alignment pragma overrides an
4998 -- implicit pragma Pack, but not an explicit one.
5000 if not Has_Pragma_Pack
(Base_Type
(Typ
)) then
5001 Set_Is_Packed
(Base_Type
(Typ
), False);
5002 Set_Component_Alignment
(Base_Type
(Typ
), Atype
);
5005 end Component_AlignmentP
;
5011 -- pragma Controlled (first_subtype_LOCAL_NAME);
5013 when Pragma_Controlled
=> Controlled
: declare
5017 Check_No_Identifiers
;
5018 Check_Arg_Count
(1);
5019 Check_Arg_Is_Local_Name
(Arg1
);
5020 Arg
:= Expression
(Arg1
);
5022 if not Is_Entity_Name
(Arg
)
5023 or else not Is_Access_Type
(Entity
(Arg
))
5025 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
5027 Set_Has_Pragma_Controlled
(Base_Type
(Entity
(Arg
)));
5035 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
5036 -- [Entity =>] LOCAL_NAME);
5038 when Pragma_Convention
=> Convention
: declare
5042 Check_Ada_83_Warning
;
5043 Check_Arg_Count
(2);
5044 Process_Convention
(C
, E
);
5047 ---------------------------
5048 -- Convention_Identifier --
5049 ---------------------------
5051 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
5052 -- [Convention =>] convention_IDENTIFIER);
5054 when Pragma_Convention_Identifier
=> Convention_Identifier
: declare
5060 Check_Arg_Count
(2);
5061 Check_Optional_Identifier
(Arg1
, Name_Name
);
5062 Check_Optional_Identifier
(Arg2
, Name_Convention
);
5063 Check_Arg_Is_Identifier
(Arg1
);
5064 Check_Arg_Is_Identifier
(Arg1
);
5065 Idnam
:= Chars
(Expression
(Arg1
));
5066 Cname
:= Chars
(Expression
(Arg2
));
5068 if Is_Convention_Name
(Cname
) then
5069 Record_Convention_Identifier
5070 (Idnam
, Get_Convention_Id
(Cname
));
5073 ("second arg for % pragma must be convention", Arg2
);
5075 end Convention_Identifier
;
5081 -- pragma CPP_Class ([Entity =>] local_NAME)
5083 when Pragma_CPP_Class
=> CPP_Class
: declare
5086 Default_DTC
: Entity_Id
:= Empty
;
5087 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
5093 Check_Arg_Count
(1);
5094 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5095 Check_Arg_Is_Local_Name
(Arg1
);
5097 Arg
:= Expression
(Arg1
);
5100 if Etype
(Arg
) = Any_Type
then
5104 if not Is_Entity_Name
(Arg
)
5105 or else not Is_Type
(Entity
(Arg
))
5107 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
5110 Typ
:= Entity
(Arg
);
5112 if not Is_Record_Type
(Typ
) then
5113 Error_Pragma_Arg
("pragma% applicable to a record, "
5114 & "tagged record or record extension", Arg1
);
5117 Default_DTC
:= First_Component
(Typ
);
5118 while Present
(Default_DTC
)
5119 and then Etype
(Default_DTC
) /= VTP_Type
5121 Next_Component
(Default_DTC
);
5124 -- Case of non tagged type
5126 if not Is_Tagged_Type
(Typ
) then
5127 Set_Is_CPP_Class
(Typ
);
5129 if Present
(Default_DTC
) then
5131 ("only tagged records can contain vtable pointers", Arg1
);
5134 -- Case of tagged type with no vtable ptr
5136 -- What is test for Typ = Root_Typ (Typ) about here ???
5138 elsif Is_Tagged_Type
(Typ
)
5139 and then Typ
= Root_Type
(Typ
)
5140 and then No
(Default_DTC
)
5143 ("a cpp_class must contain a vtable pointer", Arg1
);
5145 -- Tagged type that has a vtable ptr
5147 elsif Present
(Default_DTC
) then
5148 Set_Is_CPP_Class
(Typ
);
5149 Set_Is_Limited_Record
(Typ
);
5150 Set_Is_Tag
(Default_DTC
);
5151 Set_DT_Entry_Count
(Default_DTC
, No_Uint
);
5153 -- Since a CPP type has no direct link to its associated tag
5154 -- most tags checks cannot be performed
5156 Set_Kill_Tag_Checks
(Typ
);
5157 Set_Kill_Tag_Checks
(Class_Wide_Type
(Typ
));
5159 -- Get rid of the _tag component when there was one.
5160 -- It is only useful for regular tagged types
5162 if Expander_Active
and then Typ
= Root_Type
(Typ
) then
5164 Tag_C
:= Tag_Component
(Typ
);
5165 C
:= First_Entity
(Typ
);
5168 Set_First_Entity
(Typ
, Next_Entity
(Tag_C
));
5171 while Next_Entity
(C
) /= Tag_C
loop
5175 Set_Next_Entity
(C
, Next_Entity
(Tag_C
));
5181 ---------------------
5182 -- CPP_Constructor --
5183 ---------------------
5185 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
5187 when Pragma_CPP_Constructor
=> CPP_Constructor
: declare
5193 Check_Arg_Count
(1);
5194 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5195 Check_Arg_Is_Local_Name
(Arg1
);
5197 Id
:= Expression
(Arg1
);
5198 Find_Program_Unit_Name
(Id
);
5200 -- If we did not find the name, we are done
5202 if Etype
(Id
) = Any_Type
then
5206 Def_Id
:= Entity
(Id
);
5208 if Ekind
(Def_Id
) = E_Function
5209 and then Is_Class_Wide_Type
(Etype
(Def_Id
))
5210 and then Is_CPP_Class
(Etype
(Etype
(Def_Id
)))
5212 -- What the heck is this??? this pragma allows only 1 arg
5214 if Arg_Count
>= 2 then
5215 Check_At_Most_N_Arguments
(3);
5216 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
5219 if No
(Parameter_Specifications
(Parent
(Def_Id
))) then
5220 Set_Has_Completion
(Def_Id
);
5221 Set_Is_Constructor
(Def_Id
);
5224 ("non-default constructors not implemented", Arg1
);
5229 ("pragma% requires function returning a 'C'P'P_Class type",
5232 end CPP_Constructor
;
5238 -- pragma CPP_Virtual
5239 -- [Entity =>] LOCAL_NAME
5240 -- [ [Vtable_Ptr =>] LOCAL_NAME,
5241 -- [Position =>] static_integer_EXPRESSION]);
5243 when Pragma_CPP_Virtual
=> CPP_Virtual
: declare
5247 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
5254 if Arg_Count
= 3 then
5255 Check_Optional_Identifier
(Arg2
, "vtable_ptr");
5257 -- We allow Entry_Count as well as Position for the third
5258 -- parameter for back compatibility with versions of GNAT
5259 -- before version 3.12. The documentation has always said
5260 -- Position, but the code up to 3.12 said Entry_Count.
5262 if Chars
(Arg3
) /= Name_Position
then
5263 Check_Optional_Identifier
(Arg3
, "entry_count");
5267 Check_Arg_Count
(1);
5270 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5271 Check_Arg_Is_Local_Name
(Arg1
);
5273 -- First argument must be a subprogram name
5275 Arg
:= Expression
(Arg1
);
5276 Find_Program_Unit_Name
(Arg
);
5278 if Etype
(Arg
) = Any_Type
then
5281 Subp
:= Entity
(Arg
);
5284 if not (Is_Subprogram
(Subp
)
5285 and then Is_Dispatching_Operation
(Subp
))
5288 ("pragma% must reference a primitive operation", Arg1
);
5291 Typ
:= Find_Dispatching_Type
(Subp
);
5293 -- If only one Argument defaults are :
5294 -- . DTC_Entity is the default Vtable pointer
5295 -- . DT_Position will be set at the freezing point
5297 if Arg_Count
= 1 then
5298 Set_DTC_Entity
(Subp
, Tag_Component
(Typ
));
5302 -- Second argument is a component name of type Vtable_Ptr
5304 Arg
:= Expression
(Arg2
);
5306 if Nkind
(Arg
) /= N_Identifier
then
5307 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5311 DTC
:= First_Component
(Typ
);
5312 while Present
(DTC
) and then Chars
(DTC
) /= Chars
(Arg
) loop
5313 Next_Component
(DTC
);
5317 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5320 elsif Etype
(DTC
) /= VTP_Type
then
5321 Wrong_Type
(Arg
, VTP_Type
);
5325 -- Third argument is an integer (DT_Position)
5327 Arg
:= Expression
(Arg3
);
5328 Analyze_And_Resolve
(Arg
, Any_Integer
);
5330 if not Is_Static_Expression
(Arg
) then
5331 Flag_Non_Static_Expr
5332 ("third argument of pragma CPP_Virtual must be static!",
5337 V
:= Expr_Value
(Expression
(Arg3
));
5341 ("third argument of pragma% must be positive",
5345 Set_DTC_Entity
(Subp
, DTC
);
5346 Set_DT_Position
(Subp
, V
);
5355 -- pragma CPP_Vtable (
5356 -- [Entity =>] LOCAL_NAME
5357 -- [Vtable_Ptr =>] LOCAL_NAME,
5358 -- [Entry_Count =>] static_integer_EXPRESSION);
5360 when Pragma_CPP_Vtable
=> CPP_Vtable
: declare
5363 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
5370 Check_Arg_Count
(3);
5371 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5372 Check_Optional_Identifier
(Arg2
, "vtable_ptr");
5373 Check_Optional_Identifier
(Arg3
, "entry_count");
5374 Check_Arg_Is_Local_Name
(Arg1
);
5376 -- First argument is a record type name
5378 Arg
:= Expression
(Arg1
);
5381 if Etype
(Arg
) = Any_Type
then
5384 Typ
:= Entity
(Arg
);
5387 if not (Is_Tagged_Type
(Typ
) and then Is_CPP_Class
(Typ
)) then
5388 Error_Pragma_Arg
("'C'P'P_Class tagged type expected", Arg1
);
5391 -- Second argument is a component name of type Vtable_Ptr
5393 Arg
:= Expression
(Arg2
);
5395 if Nkind
(Arg
) /= N_Identifier
then
5396 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5400 DTC
:= First_Component
(Typ
);
5401 while Present
(DTC
) and then Chars
(DTC
) /= Chars
(Arg
) loop
5402 Next_Component
(DTC
);
5406 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5409 elsif Etype
(DTC
) /= VTP_Type
then
5410 Wrong_Type
(DTC
, VTP_Type
);
5413 -- If it is the first pragma Vtable, This becomes the default tag
5415 elsif (not Is_Tag
(DTC
))
5416 and then DT_Entry_Count
(Tag_Component
(Typ
)) = No_Uint
5418 Set_Is_Tag
(Tag_Component
(Typ
), False);
5419 Set_Is_Tag
(DTC
, True);
5420 Set_DT_Entry_Count
(DTC
, No_Uint
);
5423 -- Those pragmas must appear before any primitive operation
5424 -- definition (except inherited ones) otherwise the default
5427 Elmt
:= First_Elmt
(Primitive_Operations
(Typ
));
5428 while Present
(Elmt
) loop
5429 if No
(Alias
(Node
(Elmt
))) then
5430 Error_Msg_Sloc
:= Sloc
(Node
(Elmt
));
5432 ("pragma% must appear before this primitive operation");
5438 -- Third argument is an integer (DT_Entry_Count)
5440 Arg
:= Expression
(Arg3
);
5441 Analyze_And_Resolve
(Arg
, Any_Integer
);
5443 if not Is_Static_Expression
(Arg
) then
5444 Flag_Non_Static_Expr
5445 ("entry count for pragma CPP_Vtable must be a static " &
5446 "expression!", Arg3
);
5450 V
:= Expr_Value
(Expression
(Arg3
));
5454 ("entry count for pragma% must be positive", Arg3
);
5456 Set_DT_Entry_Count
(DTC
, V
);
5465 -- pragma Debug (PROCEDURE_CALL_STATEMENT);
5467 when Pragma_Debug
=> Debug
: begin
5470 -- Rewrite into a conditional with a static condition
5472 Rewrite
(N
, Make_Implicit_If_Statement
(N
,
5473 Condition
=> New_Occurrence_Of
(Boolean_Literals
(
5474 Assertions_Enabled
and Expander_Active
), Loc
),
5475 Then_Statements
=> New_List
(
5476 Relocate_Node
(Debug_Statement
(N
)))));
5480 ---------------------
5481 -- Detect_Blocking --
5482 ---------------------
5484 -- pragma Detect_Blocking;
5486 when Pragma_Detect_Blocking
=>
5488 Check_Arg_Count
(0);
5489 Check_Valid_Configuration_Pragma
;
5490 Detect_Blocking
:= True;
5496 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
5498 when Pragma_Discard_Names
=> Discard_Names
: declare
5503 Check_Ada_83_Warning
;
5505 -- Deal with configuration pragma case
5507 if Arg_Count
= 0 and then Is_Configuration_Pragma
then
5508 Global_Discard_Names
:= True;
5511 -- Otherwise, check correct appropriate context
5514 Check_Is_In_Decl_Part_Or_Package_Spec
;
5516 if Arg_Count
= 0 then
5518 -- If there is no parameter, then from now on this pragma
5519 -- applies to any enumeration, exception or tagged type
5520 -- defined in the current declarative part.
5522 Set_Discard_Names
(Current_Scope
);
5526 Check_Arg_Count
(1);
5527 Check_Optional_Identifier
(Arg1
, Name_On
);
5528 Check_Arg_Is_Local_Name
(Arg1
);
5529 E_Id
:= Expression
(Arg1
);
5531 if Etype
(E_Id
) = Any_Type
then
5537 if (Is_First_Subtype
(E
)
5538 and then (Is_Enumeration_Type
(E
)
5539 or else Is_Tagged_Type
(E
)))
5540 or else Ekind
(E
) = E_Exception
5542 Set_Discard_Names
(E
);
5545 ("inappropriate entity for pragma%", Arg1
);
5555 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
5557 when Pragma_Elaborate
=> Elaborate
: declare
5559 Parent_Node
: Node_Id
;
5564 -- Pragma must be in context items list of a compilation unit
5566 if not Is_List_Member
(N
) then
5571 Plist
:= List_Containing
(N
);
5572 Parent_Node
:= Parent
(Plist
);
5574 if Parent_Node
= Empty
5575 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
5576 or else Context_Items
(Parent_Node
) /= Plist
5583 -- Must be at least one argument
5585 if Arg_Count
= 0 then
5586 Error_Pragma
("pragma% requires at least one argument");
5589 -- In Ada 83 mode, there can be no items following it in the
5590 -- context list except other pragmas and implicit with clauses
5591 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
5592 -- placement rule does not apply.
5594 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
5597 while Present
(Citem
) loop
5598 if Nkind
(Citem
) = N_Pragma
5599 or else (Nkind
(Citem
) = N_With_Clause
5600 and then Implicit_With
(Citem
))
5605 ("(Ada 83) pragma% must be at end of context clause");
5612 -- Finally, the arguments must all be units mentioned in a with
5613 -- clause in the same context clause. Note we already checked
5614 -- (in Par.Prag) that the arguments are either identifiers or
5617 Outer
: while Present
(Arg
) loop
5618 Citem
:= First
(Plist
);
5620 Inner
: while Citem
/= N
loop
5621 if Nkind
(Citem
) = N_With_Clause
5622 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
5624 Set_Elaborate_Present
(Citem
, True);
5625 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
5626 Set_Suppress_Elaboration_Warnings
(Entity
(Name
(Citem
)));
5635 ("argument of pragma% is not with'ed unit", Arg
);
5641 -- Give a warning if operating in static mode with -gnatwl
5642 -- (elaboration warnings eanbled) switch set.
5644 if Elab_Warnings
and not Dynamic_Elaboration_Checks
then
5646 ("?use of pragma Elaborate may not be safe", N
);
5648 ("?use pragma Elaborate_All instead if possible", N
);
5656 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
5658 when Pragma_Elaborate_All
=> Elaborate_All
: declare
5660 Parent_Node
: Node_Id
;
5665 Check_Ada_83_Warning
;
5667 -- Pragma must be in context items list of a compilation unit
5669 if not Is_List_Member
(N
) then
5674 Plist
:= List_Containing
(N
);
5675 Parent_Node
:= Parent
(Plist
);
5677 if Parent_Node
= Empty
5678 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
5679 or else Context_Items
(Parent_Node
) /= Plist
5686 -- Must be at least one argument
5688 if Arg_Count
= 0 then
5689 Error_Pragma
("pragma% requires at least one argument");
5692 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
5693 -- have to appear at the end of the context clause, but may
5694 -- appear mixed in with other items, even in Ada 83 mode.
5696 -- Final check: the arguments must all be units mentioned in
5697 -- a with clause in the same context clause. Note that we
5698 -- already checked (in Par.Prag) that all the arguments are
5699 -- either identifiers or selected components.
5702 Outr
: while Present
(Arg
) loop
5703 Citem
:= First
(Plist
);
5705 Innr
: while Citem
/= N
loop
5706 if Nkind
(Citem
) = N_With_Clause
5707 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
5709 Set_Elaborate_All_Present
(Citem
, True);
5710 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
5711 Set_Suppress_Elaboration_Warnings
(Entity
(Name
(Citem
)));
5719 Set_Error_Posted
(N
);
5721 ("argument of pragma% is not with'ed unit", Arg
);
5728 --------------------
5729 -- Elaborate_Body --
5730 --------------------
5732 -- pragma Elaborate_Body [( library_unit_NAME )];
5734 when Pragma_Elaborate_Body
=> Elaborate_Body
: declare
5735 Cunit_Node
: Node_Id
;
5736 Cunit_Ent
: Entity_Id
;
5739 Check_Ada_83_Warning
;
5740 Check_Valid_Library_Unit_Pragma
;
5742 if Nkind
(N
) = N_Null_Statement
then
5746 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
5747 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
5749 if Nkind
(Unit
(Cunit_Node
)) = N_Package_Body
5751 Nkind
(Unit
(Cunit_Node
)) = N_Subprogram_Body
5753 Error_Pragma
("pragma% must refer to a spec, not a body");
5755 Set_Body_Required
(Cunit_Node
, True);
5756 Set_Has_Pragma_Elaborate_Body
(Cunit_Ent
);
5758 -- If we are in dynamic elaboration mode, then we suppress
5759 -- elaboration warnings for the unit, since it is definitely
5760 -- fine NOT to do dynamic checks at the first level (and such
5761 -- checks will be suppressed because no elaboration boolean
5762 -- is created for Elaborate_Body packages).
5764 -- But in the static model of elaboration, Elaborate_Body is
5765 -- definitely NOT good enough to ensure elaboration safety on
5766 -- its own, since the body may WITH other units that are not
5767 -- safe from an elaboration point of view, so a client must
5768 -- still do an Elaborate_All on such units.
5770 -- Debug flag -gnatdD restores the old behavior of 3.13,
5771 -- where Elaborate_Body always suppressed elab warnings.
5773 if Dynamic_Elaboration_Checks
or Debug_Flag_DD
then
5774 Set_Suppress_Elaboration_Warnings
(Cunit_Ent
);
5779 ------------------------
5780 -- Elaboration_Checks --
5781 ------------------------
5783 -- pragma Elaboration_Checks (Static | Dynamic);
5785 when Pragma_Elaboration_Checks
=>
5787 Check_Arg_Count
(1);
5788 Check_Arg_Is_One_Of
(Arg1
, Name_Static
, Name_Dynamic
);
5789 Dynamic_Elaboration_Checks
:=
5790 (Chars
(Get_Pragma_Arg
(Arg1
)) = Name_Dynamic
);
5796 -- pragma Eliminate (
5797 -- [Unit_Name =>] IDENTIFIER |
5798 -- SELECTED_COMPONENT
5799 -- [,[Entity =>] IDENTIFIER |
5800 -- SELECTED_COMPONENT |
5802 -- [,]OVERLOADING_RESOLUTION);
5804 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
5807 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
5810 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
5812 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
5813 -- Result_Type => result_SUBTYPE_NAME]
5815 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
5816 -- SUBTYPE_NAME ::= STRING_LITERAL
5818 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
5819 -- SOURCE_TRACE ::= STRING_LITERAL
5821 when Pragma_Eliminate
=> Eliminate
: declare
5822 Args
: Args_List
(1 .. 5);
5823 Names
: constant Name_List
(1 .. 5) := (
5826 Name_Parameter_Types
,
5828 Name_Source_Location
);
5830 Unit_Name
: Node_Id
renames Args
(1);
5831 Entity
: Node_Id
renames Args
(2);
5832 Parameter_Types
: Node_Id
renames Args
(3);
5833 Result_Type
: Node_Id
renames Args
(4);
5834 Source_Location
: Node_Id
renames Args
(5);
5838 Check_Valid_Configuration_Pragma
;
5839 Gather_Associations
(Names
, Args
);
5841 if No
(Unit_Name
) then
5842 Error_Pragma
("missing Unit_Name argument for pragma%");
5846 and then (Present
(Parameter_Types
)
5848 Present
(Result_Type
)
5850 Present
(Source_Location
))
5852 Error_Pragma
("missing Entity argument for pragma%");
5855 if (Present
(Parameter_Types
)
5857 Present
(Result_Type
))
5859 Present
(Source_Location
)
5862 ("parameter profile and source location can not " &
5863 "be used together in pragma%");
5866 Process_Eliminate_Pragma
5875 -------------------------
5876 -- Explicit_Overriding --
5877 -------------------------
5879 when Pragma_Explicit_Overriding
=>
5880 Check_Valid_Configuration_Pragma
;
5881 Check_Arg_Count
(0);
5882 Explicit_Overriding
:= True;
5889 -- [ Convention =>] convention_IDENTIFIER,
5890 -- [ Entity =>] local_NAME
5891 -- [, [External_Name =>] static_string_EXPRESSION ]
5892 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5894 when Pragma_Export
=> Export
: declare
5899 Check_Ada_83_Warning
;
5900 Check_At_Least_N_Arguments
(2);
5901 Check_At_Most_N_Arguments
(4);
5902 Process_Convention
(C
, Def_Id
);
5904 if Ekind
(Def_Id
) /= E_Constant
then
5905 Note_Possible_Modification
(Expression
(Arg2
));
5908 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
5909 Set_Exported
(Def_Id
, Arg2
);
5912 ----------------------
5913 -- Export_Exception --
5914 ----------------------
5916 -- pragma Export_Exception (
5917 -- [Internal =>] LOCAL_NAME,
5918 -- [, [External =>] EXTERNAL_SYMBOL,]
5919 -- [, [Form =>] Ada | VMS]
5920 -- [, [Code =>] static_integer_EXPRESSION]);
5922 when Pragma_Export_Exception
=> Export_Exception
: declare
5923 Args
: Args_List
(1 .. 4);
5924 Names
: constant Name_List
(1 .. 4) := (
5930 Internal
: Node_Id
renames Args
(1);
5931 External
: Node_Id
renames Args
(2);
5932 Form
: Node_Id
renames Args
(3);
5933 Code
: Node_Id
renames Args
(4);
5936 if Inside_A_Generic
then
5937 Error_Pragma
("pragma% cannot be used for generic entities");
5940 Gather_Associations
(Names
, Args
);
5941 Process_Extended_Import_Export_Exception_Pragma
(
5942 Arg_Internal
=> Internal
,
5943 Arg_External
=> External
,
5947 if not Is_VMS_Exception
(Entity
(Internal
)) then
5948 Set_Exported
(Entity
(Internal
), Internal
);
5950 end Export_Exception
;
5952 ---------------------
5953 -- Export_Function --
5954 ---------------------
5956 -- pragma Export_Function (
5957 -- [Internal =>] LOCAL_NAME,
5958 -- [, [External =>] EXTERNAL_SYMBOL,]
5959 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5960 -- [, [Result_Type =>] TYPE_DESIGNATOR]
5961 -- [, [Mechanism =>] MECHANISM]
5962 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
5964 -- EXTERNAL_SYMBOL ::=
5966 -- | static_string_EXPRESSION
5968 -- PARAMETER_TYPES ::=
5970 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
5972 -- TYPE_DESIGNATOR ::=
5974 -- | subtype_Name ' Access
5978 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
5980 -- MECHANISM_ASSOCIATION ::=
5981 -- [formal_parameter_NAME =>] MECHANISM_NAME
5983 -- MECHANISM_NAME ::=
5986 -- | Descriptor [([Class =>] CLASS_NAME)]
5988 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
5990 when Pragma_Export_Function
=> Export_Function
: declare
5991 Args
: Args_List
(1 .. 6);
5992 Names
: constant Name_List
(1 .. 6) := (
5995 Name_Parameter_Types
,
5998 Name_Result_Mechanism
);
6000 Internal
: Node_Id
renames Args
(1);
6001 External
: Node_Id
renames Args
(2);
6002 Parameter_Types
: Node_Id
renames Args
(3);
6003 Result_Type
: Node_Id
renames Args
(4);
6004 Mechanism
: Node_Id
renames Args
(5);
6005 Result_Mechanism
: Node_Id
renames Args
(6);
6009 Gather_Associations
(Names
, Args
);
6010 Process_Extended_Import_Export_Subprogram_Pragma
(
6011 Arg_Internal
=> Internal
,
6012 Arg_External
=> External
,
6013 Arg_Parameter_Types
=> Parameter_Types
,
6014 Arg_Result_Type
=> Result_Type
,
6015 Arg_Mechanism
=> Mechanism
,
6016 Arg_Result_Mechanism
=> Result_Mechanism
);
6017 end Export_Function
;
6023 -- pragma Export_Object (
6024 -- [Internal =>] LOCAL_NAME,
6025 -- [, [External =>] EXTERNAL_SYMBOL]
6026 -- [, [Size =>] EXTERNAL_SYMBOL]);
6028 -- EXTERNAL_SYMBOL ::=
6030 -- | static_string_EXPRESSION
6032 -- PARAMETER_TYPES ::=
6034 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6036 -- TYPE_DESIGNATOR ::=
6038 -- | subtype_Name ' Access
6042 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6044 -- MECHANISM_ASSOCIATION ::=
6045 -- [formal_parameter_NAME =>] MECHANISM_NAME
6047 -- MECHANISM_NAME ::=
6050 -- | Descriptor [([Class =>] CLASS_NAME)]
6052 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6054 when Pragma_Export_Object
=> Export_Object
: declare
6055 Args
: Args_List
(1 .. 3);
6056 Names
: constant Name_List
(1 .. 3) := (
6061 Internal
: Node_Id
renames Args
(1);
6062 External
: Node_Id
renames Args
(2);
6063 Size
: Node_Id
renames Args
(3);
6067 Gather_Associations
(Names
, Args
);
6068 Process_Extended_Import_Export_Object_Pragma
(
6069 Arg_Internal
=> Internal
,
6070 Arg_External
=> External
,
6074 ----------------------
6075 -- Export_Procedure --
6076 ----------------------
6078 -- pragma Export_Procedure (
6079 -- [Internal =>] LOCAL_NAME,
6080 -- [, [External =>] EXTERNAL_SYMBOL,]
6081 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6082 -- [, [Mechanism =>] MECHANISM]);
6084 -- EXTERNAL_SYMBOL ::=
6086 -- | static_string_EXPRESSION
6088 -- PARAMETER_TYPES ::=
6090 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6092 -- TYPE_DESIGNATOR ::=
6094 -- | subtype_Name ' Access
6098 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6100 -- MECHANISM_ASSOCIATION ::=
6101 -- [formal_parameter_NAME =>] MECHANISM_NAME
6103 -- MECHANISM_NAME ::=
6106 -- | Descriptor [([Class =>] CLASS_NAME)]
6108 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6110 when Pragma_Export_Procedure
=> Export_Procedure
: declare
6111 Args
: Args_List
(1 .. 4);
6112 Names
: constant Name_List
(1 .. 4) := (
6115 Name_Parameter_Types
,
6118 Internal
: Node_Id
renames Args
(1);
6119 External
: Node_Id
renames Args
(2);
6120 Parameter_Types
: Node_Id
renames Args
(3);
6121 Mechanism
: Node_Id
renames Args
(4);
6125 Gather_Associations
(Names
, Args
);
6126 Process_Extended_Import_Export_Subprogram_Pragma
(
6127 Arg_Internal
=> Internal
,
6128 Arg_External
=> External
,
6129 Arg_Parameter_Types
=> Parameter_Types
,
6130 Arg_Mechanism
=> Mechanism
);
6131 end Export_Procedure
;
6137 -- pragma Export_Value (
6138 -- [Value =>] static_integer_EXPRESSION,
6139 -- [Link_Name =>] static_string_EXPRESSION);
6141 when Pragma_Export_Value
=>
6143 Check_Arg_Count
(2);
6145 Check_Optional_Identifier
(Arg1
, Name_Value
);
6146 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
6148 Check_Optional_Identifier
(Arg2
, Name_Link_Name
);
6149 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
6151 -----------------------------
6152 -- Export_Valued_Procedure --
6153 -----------------------------
6155 -- pragma Export_Valued_Procedure (
6156 -- [Internal =>] LOCAL_NAME,
6157 -- [, [External =>] EXTERNAL_SYMBOL,]
6158 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6159 -- [, [Mechanism =>] MECHANISM]);
6161 -- EXTERNAL_SYMBOL ::=
6163 -- | static_string_EXPRESSION
6165 -- PARAMETER_TYPES ::=
6167 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6169 -- TYPE_DESIGNATOR ::=
6171 -- | subtype_Name ' Access
6175 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6177 -- MECHANISM_ASSOCIATION ::=
6178 -- [formal_parameter_NAME =>] MECHANISM_NAME
6180 -- MECHANISM_NAME ::=
6183 -- | Descriptor [([Class =>] CLASS_NAME)]
6185 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6187 when Pragma_Export_Valued_Procedure
=>
6188 Export_Valued_Procedure
: declare
6189 Args
: Args_List
(1 .. 4);
6190 Names
: constant Name_List
(1 .. 4) := (
6193 Name_Parameter_Types
,
6196 Internal
: Node_Id
renames Args
(1);
6197 External
: Node_Id
renames Args
(2);
6198 Parameter_Types
: Node_Id
renames Args
(3);
6199 Mechanism
: Node_Id
renames Args
(4);
6203 Gather_Associations
(Names
, Args
);
6204 Process_Extended_Import_Export_Subprogram_Pragma
(
6205 Arg_Internal
=> Internal
,
6206 Arg_External
=> External
,
6207 Arg_Parameter_Types
=> Parameter_Types
,
6208 Arg_Mechanism
=> Mechanism
);
6209 end Export_Valued_Procedure
;
6215 -- pragma Extend_System ([Name =>] Identifier);
6217 when Pragma_Extend_System
=> Extend_System
: declare
6220 Check_Valid_Configuration_Pragma
;
6221 Check_Arg_Count
(1);
6222 Check_Optional_Identifier
(Arg1
, Name_Name
);
6223 Check_Arg_Is_Identifier
(Arg1
);
6225 Get_Name_String
(Chars
(Expression
(Arg1
)));
6228 and then Name_Buffer
(1 .. 4) = "aux_"
6230 if Present
(System_Extend_Pragma_Arg
) then
6231 if Chars
(Expression
(Arg1
)) =
6232 Chars
(Expression
(System_Extend_Pragma_Arg
))
6236 Error_Msg_Sloc
:= Sloc
(System_Extend_Pragma_Arg
);
6237 Error_Pragma
("pragma% conflicts with that at#");
6241 System_Extend_Pragma_Arg
:= Arg1
;
6243 if not GNAT_Mode
then
6244 System_Extend_Unit
:= Arg1
;
6248 Error_Pragma
("incorrect name for pragma%, must be Aux_xxx");
6252 ------------------------
6253 -- Extensions_Allowed --
6254 ------------------------
6256 -- pragma Extensions_Allowed (ON | OFF);
6258 when Pragma_Extensions_Allowed
=>
6260 Check_Arg_Count
(1);
6261 Check_No_Identifiers
;
6262 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
6264 if Chars
(Expression
(Arg1
)) = Name_On
then
6265 Extensions_Allowed
:= True;
6266 Ada_Version
:= Ada_Version_Type
'Last;
6268 Extensions_Allowed
:= False;
6269 Ada_Version
:= Ada_Version_Type
'Min (Ada_Version
, Ada_95
);
6276 -- pragma External (
6277 -- [ Convention =>] convention_IDENTIFIER,
6278 -- [ Entity =>] local_NAME
6279 -- [, [External_Name =>] static_string_EXPRESSION ]
6280 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6282 when Pragma_External
=> External
: declare
6288 Check_At_Least_N_Arguments
(2);
6289 Check_At_Most_N_Arguments
(4);
6290 Process_Convention
(C
, Def_Id
);
6291 Note_Possible_Modification
(Expression
(Arg2
));
6292 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
6293 Set_Exported
(Def_Id
, Arg2
);
6296 --------------------------
6297 -- External_Name_Casing --
6298 --------------------------
6300 -- pragma External_Name_Casing (
6301 -- UPPERCASE | LOWERCASE
6302 -- [, AS_IS | UPPERCASE | LOWERCASE]);
6304 when Pragma_External_Name_Casing
=> External_Name_Casing
: declare
6307 Check_No_Identifiers
;
6309 if Arg_Count
= 2 then
6311 (Arg2
, Name_As_Is
, Name_Uppercase
, Name_Lowercase
);
6313 case Chars
(Get_Pragma_Arg
(Arg2
)) is
6315 Opt
.External_Name_Exp_Casing
:= As_Is
;
6317 when Name_Uppercase
=>
6318 Opt
.External_Name_Exp_Casing
:= Uppercase
;
6320 when Name_Lowercase
=>
6321 Opt
.External_Name_Exp_Casing
:= Lowercase
;
6328 Check_Arg_Count
(1);
6331 Check_Arg_Is_One_Of
(Arg1
, Name_Uppercase
, Name_Lowercase
);
6333 case Chars
(Get_Pragma_Arg
(Arg1
)) is
6334 when Name_Uppercase
=>
6335 Opt
.External_Name_Imp_Casing
:= Uppercase
;
6337 when Name_Lowercase
=>
6338 Opt
.External_Name_Imp_Casing
:= Lowercase
;
6343 end External_Name_Casing
;
6345 ---------------------------
6346 -- Finalize_Storage_Only --
6347 ---------------------------
6349 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
6351 when Pragma_Finalize_Storage_Only
=> Finalize_Storage
: declare
6352 Assoc
: constant Node_Id
:= Arg1
;
6353 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
6357 Check_No_Identifiers
;
6358 Check_Arg_Count
(1);
6359 Check_Arg_Is_Local_Name
(Arg1
);
6361 Find_Type
(Type_Id
);
6362 Typ
:= Entity
(Type_Id
);
6365 or else Rep_Item_Too_Early
(Typ
, N
)
6369 Typ
:= Underlying_Type
(Typ
);
6372 if not Is_Controlled
(Typ
) then
6373 Error_Pragma
("pragma% must specify controlled type");
6376 Check_First_Subtype
(Arg1
);
6378 if Finalize_Storage_Only
(Typ
) then
6379 Error_Pragma
("duplicate pragma%, only one allowed");
6381 elsif not Rep_Item_Too_Late
(Typ
, N
) then
6382 Set_Finalize_Storage_Only
(Base_Type
(Typ
), True);
6384 end Finalize_Storage
;
6386 --------------------------
6387 -- Float_Representation --
6388 --------------------------
6390 -- pragma Float_Representation (VAX_Float | IEEE_Float);
6392 when Pragma_Float_Representation
=> Float_Representation
: declare
6400 if Arg_Count
= 1 then
6401 Check_Valid_Configuration_Pragma
;
6403 Check_Arg_Count
(2);
6404 Check_Optional_Identifier
(Arg2
, Name_Entity
);
6405 Check_Arg_Is_Local_Name
(Arg2
);
6408 Check_No_Identifier
(Arg1
);
6409 Check_Arg_Is_One_Of
(Arg1
, Name_VAX_Float
, Name_IEEE_Float
);
6411 if not OpenVMS_On_Target
then
6412 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6414 ("?pragma% ignored (applies only to Open'V'M'S)");
6420 -- One argument case
6422 if Arg_Count
= 1 then
6424 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6426 if Opt
.Float_Format
= 'I' then
6427 Error_Pragma
("'I'E'E'E format previously specified");
6430 Opt
.Float_Format
:= 'V';
6433 if Opt
.Float_Format
= 'V' then
6434 Error_Pragma
("'V'A'X format previously specified");
6437 Opt
.Float_Format
:= 'I';
6440 Set_Standard_Fpt_Formats
;
6442 -- Two argument case
6445 Argx
:= Get_Pragma_Arg
(Arg2
);
6447 if not Is_Entity_Name
(Argx
)
6448 or else not Is_Floating_Point_Type
(Entity
(Argx
))
6451 ("second argument of% pragma must be floating-point type",
6455 Ent
:= Entity
(Argx
);
6456 Digs
:= UI_To_Int
(Digits_Value
(Ent
));
6458 -- Two arguments, VAX_Float case
6460 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6463 when 6 => Set_F_Float
(Ent
);
6464 when 9 => Set_D_Float
(Ent
);
6465 when 15 => Set_G_Float
(Ent
);
6469 ("wrong digits value, must be 6,9 or 15", Arg2
);
6472 -- Two arguments, IEEE_Float case
6476 when 6 => Set_IEEE_Short
(Ent
);
6477 when 15 => Set_IEEE_Long
(Ent
);
6481 ("wrong digits value, must be 6 or 15", Arg2
);
6485 end Float_Representation
;
6491 -- pragma Ident (static_string_EXPRESSION)
6493 -- Note: pragma Comment shares this processing. Pragma Comment
6494 -- is identical to Ident, except that the restriction of the
6495 -- argument to 31 characters and the placement restrictions
6496 -- are not enforced for pragma Comment.
6498 when Pragma_Ident | Pragma_Comment
=> Ident
: declare
6503 Check_Arg_Count
(1);
6504 Check_No_Identifiers
;
6505 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
6507 -- For pragma Ident, preserve DEC compatibility by requiring
6508 -- the pragma to appear in a declarative part or package spec.
6510 if Prag_Id
= Pragma_Ident
then
6511 Check_Is_In_Decl_Part_Or_Package_Spec
;
6514 Str
:= Expr_Value_S
(Expression
(Arg1
));
6521 GP
:= Parent
(Parent
(N
));
6523 if Nkind
(GP
) = N_Package_Declaration
6525 Nkind
(GP
) = N_Generic_Package_Declaration
6530 -- If we have a compilation unit, then record the ident
6531 -- value, checking for improper duplication.
6533 if Nkind
(GP
) = N_Compilation_Unit
then
6534 CS
:= Ident_String
(Current_Sem_Unit
);
6536 if Present
(CS
) then
6538 -- For Ident, we do not permit multiple instances
6540 if Prag_Id
= Pragma_Ident
then
6541 Error_Pragma
("duplicate% pragma not permitted");
6543 -- For Comment, we concatenate the string, unless we
6544 -- want to preserve the tree structure for ASIS.
6546 elsif not ASIS_Mode
then
6547 Start_String
(Strval
(CS
));
6548 Store_String_Char
(' ');
6549 Store_String_Chars
(Strval
(Str
));
6550 Set_Strval
(CS
, End_String
);
6554 -- In VMS, the effect of IDENT is achieved by passing
6555 -- IDENTIFICATION=name as a --for-linker switch.
6557 if OpenVMS_On_Target
then
6560 ("--for-linker=IDENTIFICATION=");
6561 String_To_Name_Buffer
(Strval
(Str
));
6562 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
6564 -- Only the last processed IDENT is saved. The main
6565 -- purpose is so an IDENT associated with a main
6566 -- procedure will be used in preference to an IDENT
6567 -- associated with a with'd package.
6569 Replace_Linker_Option_String
6570 (End_String
, "--for-linker=IDENTIFICATION=");
6573 Set_Ident_String
(Current_Sem_Unit
, Str
);
6576 -- For subunits, we just ignore the Ident, since in GNAT
6577 -- these are not separate object files, and hence not
6578 -- separate units in the unit table.
6580 elsif Nkind
(GP
) = N_Subunit
then
6583 -- Otherwise we have a misplaced pragma Ident, but we ignore
6584 -- this if we are in an instantiation, since it comes from
6585 -- a generic, and has no relevance to the instantiation.
6587 elsif Prag_Id
= Pragma_Ident
then
6588 if Instantiation_Location
(Loc
) = No_Location
then
6589 Error_Pragma
("pragma% only allowed at outer level");
6600 -- [ Convention =>] convention_IDENTIFIER,
6601 -- [ Entity =>] local_NAME
6602 -- [, [External_Name =>] static_string_EXPRESSION ]
6603 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6605 when Pragma_Import
=>
6606 Check_Ada_83_Warning
;
6607 Check_At_Least_N_Arguments
(2);
6608 Check_At_Most_N_Arguments
(4);
6609 Process_Import_Or_Interface
;
6611 ----------------------
6612 -- Import_Exception --
6613 ----------------------
6615 -- pragma Import_Exception (
6616 -- [Internal =>] LOCAL_NAME,
6617 -- [, [External =>] EXTERNAL_SYMBOL,]
6618 -- [, [Form =>] Ada | VMS]
6619 -- [, [Code =>] static_integer_EXPRESSION]);
6621 when Pragma_Import_Exception
=> Import_Exception
: declare
6622 Args
: Args_List
(1 .. 4);
6623 Names
: constant Name_List
(1 .. 4) := (
6629 Internal
: Node_Id
renames Args
(1);
6630 External
: Node_Id
renames Args
(2);
6631 Form
: Node_Id
renames Args
(3);
6632 Code
: Node_Id
renames Args
(4);
6635 Gather_Associations
(Names
, Args
);
6637 if Present
(External
) and then Present
(Code
) then
6639 ("cannot give both External and Code options for pragma%");
6642 Process_Extended_Import_Export_Exception_Pragma
(
6643 Arg_Internal
=> Internal
,
6644 Arg_External
=> External
,
6648 if not Is_VMS_Exception
(Entity
(Internal
)) then
6649 Set_Imported
(Entity
(Internal
));
6651 end Import_Exception
;
6653 ---------------------
6654 -- Import_Function --
6655 ---------------------
6657 -- pragma Import_Function (
6658 -- [Internal =>] LOCAL_NAME,
6659 -- [, [External =>] EXTERNAL_SYMBOL]
6660 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6661 -- [, [Result_Type =>] SUBTYPE_MARK]
6662 -- [, [Mechanism =>] MECHANISM]
6663 -- [, [Result_Mechanism =>] MECHANISM_NAME]
6664 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6666 -- EXTERNAL_SYMBOL ::=
6668 -- | static_string_EXPRESSION
6670 -- PARAMETER_TYPES ::=
6672 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6674 -- TYPE_DESIGNATOR ::=
6676 -- | subtype_Name ' Access
6680 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6682 -- MECHANISM_ASSOCIATION ::=
6683 -- [formal_parameter_NAME =>] MECHANISM_NAME
6685 -- MECHANISM_NAME ::=
6688 -- | Descriptor [([Class =>] CLASS_NAME)]
6690 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6692 when Pragma_Import_Function
=> Import_Function
: declare
6693 Args
: Args_List
(1 .. 7);
6694 Names
: constant Name_List
(1 .. 7) := (
6697 Name_Parameter_Types
,
6700 Name_Result_Mechanism
,
6701 Name_First_Optional_Parameter
);
6703 Internal
: Node_Id
renames Args
(1);
6704 External
: Node_Id
renames Args
(2);
6705 Parameter_Types
: Node_Id
renames Args
(3);
6706 Result_Type
: Node_Id
renames Args
(4);
6707 Mechanism
: Node_Id
renames Args
(5);
6708 Result_Mechanism
: Node_Id
renames Args
(6);
6709 First_Optional_Parameter
: Node_Id
renames Args
(7);
6713 Gather_Associations
(Names
, Args
);
6714 Process_Extended_Import_Export_Subprogram_Pragma
(
6715 Arg_Internal
=> Internal
,
6716 Arg_External
=> External
,
6717 Arg_Parameter_Types
=> Parameter_Types
,
6718 Arg_Result_Type
=> Result_Type
,
6719 Arg_Mechanism
=> Mechanism
,
6720 Arg_Result_Mechanism
=> Result_Mechanism
,
6721 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
6722 end Import_Function
;
6728 -- pragma Import_Object (
6729 -- [Internal =>] LOCAL_NAME,
6730 -- [, [External =>] EXTERNAL_SYMBOL]
6731 -- [, [Size =>] EXTERNAL_SYMBOL]);
6733 -- EXTERNAL_SYMBOL ::=
6735 -- | static_string_EXPRESSION
6737 when Pragma_Import_Object
=> Import_Object
: declare
6738 Args
: Args_List
(1 .. 3);
6739 Names
: constant Name_List
(1 .. 3) := (
6744 Internal
: Node_Id
renames Args
(1);
6745 External
: Node_Id
renames Args
(2);
6746 Size
: Node_Id
renames Args
(3);
6750 Gather_Associations
(Names
, Args
);
6751 Process_Extended_Import_Export_Object_Pragma
(
6752 Arg_Internal
=> Internal
,
6753 Arg_External
=> External
,
6757 ----------------------
6758 -- Import_Procedure --
6759 ----------------------
6761 -- pragma Import_Procedure (
6762 -- [Internal =>] LOCAL_NAME,
6763 -- [, [External =>] EXTERNAL_SYMBOL]
6764 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6765 -- [, [Mechanism =>] MECHANISM]
6766 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6768 -- EXTERNAL_SYMBOL ::=
6770 -- | static_string_EXPRESSION
6772 -- PARAMETER_TYPES ::=
6774 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6776 -- TYPE_DESIGNATOR ::=
6778 -- | subtype_Name ' Access
6782 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6784 -- MECHANISM_ASSOCIATION ::=
6785 -- [formal_parameter_NAME =>] MECHANISM_NAME
6787 -- MECHANISM_NAME ::=
6790 -- | Descriptor [([Class =>] CLASS_NAME)]
6792 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6794 when Pragma_Import_Procedure
=> Import_Procedure
: declare
6795 Args
: Args_List
(1 .. 5);
6796 Names
: constant Name_List
(1 .. 5) := (
6799 Name_Parameter_Types
,
6801 Name_First_Optional_Parameter
);
6803 Internal
: Node_Id
renames Args
(1);
6804 External
: Node_Id
renames Args
(2);
6805 Parameter_Types
: Node_Id
renames Args
(3);
6806 Mechanism
: Node_Id
renames Args
(4);
6807 First_Optional_Parameter
: Node_Id
renames Args
(5);
6811 Gather_Associations
(Names
, Args
);
6812 Process_Extended_Import_Export_Subprogram_Pragma
(
6813 Arg_Internal
=> Internal
,
6814 Arg_External
=> External
,
6815 Arg_Parameter_Types
=> Parameter_Types
,
6816 Arg_Mechanism
=> Mechanism
,
6817 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
6818 end Import_Procedure
;
6820 -----------------------------
6821 -- Import_Valued_Procedure --
6822 -----------------------------
6824 -- pragma Import_Valued_Procedure (
6825 -- [Internal =>] LOCAL_NAME,
6826 -- [, [External =>] EXTERNAL_SYMBOL]
6827 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6828 -- [, [Mechanism =>] MECHANISM]
6829 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6831 -- EXTERNAL_SYMBOL ::=
6833 -- | static_string_EXPRESSION
6835 -- PARAMETER_TYPES ::=
6837 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6839 -- TYPE_DESIGNATOR ::=
6841 -- | subtype_Name ' Access
6845 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6847 -- MECHANISM_ASSOCIATION ::=
6848 -- [formal_parameter_NAME =>] MECHANISM_NAME
6850 -- MECHANISM_NAME ::=
6853 -- | Descriptor [([Class =>] CLASS_NAME)]
6855 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6857 when Pragma_Import_Valued_Procedure
=>
6858 Import_Valued_Procedure
: declare
6859 Args
: Args_List
(1 .. 5);
6860 Names
: constant Name_List
(1 .. 5) := (
6863 Name_Parameter_Types
,
6865 Name_First_Optional_Parameter
);
6867 Internal
: Node_Id
renames Args
(1);
6868 External
: Node_Id
renames Args
(2);
6869 Parameter_Types
: Node_Id
renames Args
(3);
6870 Mechanism
: Node_Id
renames Args
(4);
6871 First_Optional_Parameter
: Node_Id
renames Args
(5);
6875 Gather_Associations
(Names
, Args
);
6876 Process_Extended_Import_Export_Subprogram_Pragma
(
6877 Arg_Internal
=> Internal
,
6878 Arg_External
=> External
,
6879 Arg_Parameter_Types
=> Parameter_Types
,
6880 Arg_Mechanism
=> Mechanism
,
6881 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
6882 end Import_Valued_Procedure
;
6884 ------------------------
6885 -- Initialize_Scalars --
6886 ------------------------
6888 -- pragma Initialize_Scalars;
6890 when Pragma_Initialize_Scalars
=>
6892 Check_Arg_Count
(0);
6893 Check_Valid_Configuration_Pragma
;
6894 Check_Restriction
(No_Initialize_Scalars
, N
);
6896 if not Restriction_Active
(No_Initialize_Scalars
) then
6897 Init_Or_Norm_Scalars
:= True;
6898 Initialize_Scalars
:= True;
6905 -- pragma Inline ( NAME {, NAME} );
6907 when Pragma_Inline
=>
6909 -- Pragma is active if inlining option is active
6911 Process_Inline
(Inline_Active
);
6917 -- pragma Inline_Always ( NAME {, NAME} );
6919 when Pragma_Inline_Always
=>
6920 Process_Inline
(True);
6922 --------------------
6923 -- Inline_Generic --
6924 --------------------
6926 -- pragma Inline_Generic (NAME {, NAME});
6928 when Pragma_Inline_Generic
=>
6929 Process_Generic_List
;
6931 ----------------------
6932 -- Inspection_Point --
6933 ----------------------
6935 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
6937 when Pragma_Inspection_Point
=> Inspection_Point
: declare
6942 if Arg_Count
> 0 then
6945 Exp
:= Expression
(Arg
);
6948 if not Is_Entity_Name
(Exp
)
6949 or else not Is_Object
(Entity
(Exp
))
6951 Error_Pragma_Arg
("object name required", Arg
);
6958 end Inspection_Point
;
6964 -- pragma Interface (
6965 -- convention_IDENTIFIER,
6968 when Pragma_Interface
=>
6970 Check_Arg_Count
(2);
6971 Check_No_Identifiers
;
6972 Process_Import_Or_Interface
;
6974 --------------------
6975 -- Interface_Name --
6976 --------------------
6978 -- pragma Interface_Name (
6979 -- [ Entity =>] local_NAME
6980 -- [,[External_Name =>] static_string_EXPRESSION ]
6981 -- [,[Link_Name =>] static_string_EXPRESSION ]);
6983 when Pragma_Interface_Name
=> Interface_Name
: declare
6991 Check_At_Least_N_Arguments
(2);
6992 Check_At_Most_N_Arguments
(3);
6993 Id
:= Expression
(Arg1
);
6996 if not Is_Entity_Name
(Id
) then
6998 ("first argument for pragma% must be entity name", Arg1
);
6999 elsif Etype
(Id
) = Any_Type
then
7002 Def_Id
:= Entity
(Id
);
7005 -- Special DEC-compatible processing for the object case,
7006 -- forces object to be imported.
7008 if Ekind
(Def_Id
) = E_Variable
then
7009 Kill_Size_Check_Code
(Def_Id
);
7010 Note_Possible_Modification
(Id
);
7012 -- Initialization is not allowed for imported variable
7014 if Present
(Expression
(Parent
(Def_Id
)))
7015 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
7017 Error_Msg_Sloc
:= Sloc
(Def_Id
);
7019 ("no initialization allowed for declaration of& #",
7023 -- For compatibility, support VADS usage of providing both
7024 -- pragmas Interface and Interface_Name to obtain the effect
7025 -- of a single Import pragma.
7027 if Is_Imported
(Def_Id
)
7028 and then Present
(First_Rep_Item
(Def_Id
))
7029 and then Nkind
(First_Rep_Item
(Def_Id
)) = N_Pragma
7030 and then Chars
(First_Rep_Item
(Def_Id
)) = Name_Interface
7034 Set_Imported
(Def_Id
);
7037 Set_Is_Public
(Def_Id
);
7038 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
7041 -- Otherwise must be subprogram
7043 elsif not Is_Subprogram
(Def_Id
) then
7045 ("argument of pragma% is not subprogram", Arg1
);
7048 Check_At_Most_N_Arguments
(3);
7052 -- Loop through homonyms
7055 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
7057 if Is_Imported
(Def_Id
) then
7058 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
7062 Hom_Id
:= Homonym
(Hom_Id
);
7064 exit when No
(Hom_Id
)
7065 or else Scope
(Hom_Id
) /= Current_Scope
;
7070 ("argument of pragma% is not imported subprogram",
7076 -----------------------
7077 -- Interrupt_Handler --
7078 -----------------------
7080 -- pragma Interrupt_Handler (handler_NAME);
7082 when Pragma_Interrupt_Handler
=>
7083 Check_Ada_83_Warning
;
7084 Check_Arg_Count
(1);
7085 Check_No_Identifiers
;
7087 if No_Run_Time_Mode
then
7088 Error_Msg_CRT
("Interrupt_Handler pragma", N
);
7090 Check_Interrupt_Or_Attach_Handler
;
7091 Process_Interrupt_Or_Attach_Handler
;
7094 ------------------------
7095 -- Interrupt_Priority --
7096 ------------------------
7098 -- pragma Interrupt_Priority [(EXPRESSION)];
7100 when Pragma_Interrupt_Priority
=> Interrupt_Priority
: declare
7101 P
: constant Node_Id
:= Parent
(N
);
7105 Check_Ada_83_Warning
;
7107 if Arg_Count
/= 0 then
7108 Arg
:= Expression
(Arg1
);
7109 Check_Arg_Count
(1);
7110 Check_No_Identifiers
;
7112 -- The expression must be analyzed in the special manner
7113 -- described in "Handling of Default and Per-Object
7114 -- Expressions" in sem.ads.
7116 Analyze_Per_Use_Expression
(Arg
, RTE
(RE_Interrupt_Priority
));
7119 if Nkind
(P
) /= N_Task_Definition
7120 and then Nkind
(P
) /= N_Protected_Definition
7125 elsif Has_Priority_Pragma
(P
) then
7126 Error_Pragma
("duplicate pragma% not allowed");
7129 Set_Has_Priority_Pragma
(P
, True);
7130 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
7132 end Interrupt_Priority
;
7134 ---------------------
7135 -- Interrupt_State --
7136 ---------------------
7138 -- pragma Interrupt_State (
7139 -- [Name =>] INTERRUPT_ID,
7140 -- [State =>] INTERRUPT_STATE);
7142 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
7143 -- INTERRUPT_STATE => System | Runtime | User
7145 -- Note: if the interrupt id is given as an identifier, then
7146 -- it must be one of the identifiers in Ada.Interrupts.Names.
7147 -- Otherwise it is given as a static integer expression which
7148 -- must be in the range of Ada.Interrupts.Interrupt_ID.
7150 when Pragma_Interrupt_State
=> Interrupt_State
: declare
7152 Int_Id
: constant Entity_Id
:= RTE
(RE_Interrupt_ID
);
7153 -- This is the entity Ada.Interrupts.Interrupt_ID;
7155 State_Type
: Character;
7156 -- Set to 's'/'r'/'u' for System/Runtime/User
7159 -- Index to entry in Interrupt_States table
7162 -- Value of interrupt
7164 Arg1X
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
7165 -- The first argument to the pragma
7167 Int_Ent
: Entity_Id
;
7168 -- Interrupt entity in Ada.Interrupts.Names
7172 Check_Arg_Count
(2);
7174 Check_Optional_Identifier
(Arg1
, Name_Name
);
7175 Check_Optional_Identifier
(Arg2
, "state");
7176 Check_Arg_Is_Identifier
(Arg2
);
7178 -- First argument is identifier
7180 if Nkind
(Arg1X
) = N_Identifier
then
7182 -- Search list of names in Ada.Interrupts.Names
7184 Int_Ent
:= First_Entity
(RTE
(RE_Names
));
7186 if No
(Int_Ent
) then
7187 Error_Pragma_Arg
("invalid interrupt name", Arg1
);
7189 elsif Chars
(Int_Ent
) = Chars
(Arg1X
) then
7190 Int_Val
:= Expr_Value
(Constant_Value
(Int_Ent
));
7194 Next_Entity
(Int_Ent
);
7197 -- First argument is not an identifier, so it must be a
7198 -- static expression of type Ada.Interrupts.Interrupt_ID.
7201 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
7202 Int_Val
:= Expr_Value
(Arg1X
);
7204 if Int_Val
< Expr_Value
(Type_Low_Bound
(Int_Id
))
7206 Int_Val
> Expr_Value
(Type_High_Bound
(Int_Id
))
7209 ("value not in range of type " &
7210 """Ada.Interrupts.Interrupt_'I'D""", Arg1
);
7216 case Chars
(Get_Pragma_Arg
(Arg2
)) is
7217 when Name_Runtime
=> State_Type
:= 'r';
7218 when Name_System
=> State_Type
:= 's';
7219 when Name_User
=> State_Type
:= 'u';
7222 Error_Pragma_Arg
("invalid interrupt state", Arg2
);
7225 -- Check if entry is already stored
7227 IST_Num
:= Interrupt_States
.First
;
7229 -- If entry not found, add it
7231 if IST_Num
> Interrupt_States
.Last
then
7232 Interrupt_States
.Append
7233 ((Interrupt_Number
=> UI_To_Int
(Int_Val
),
7234 Interrupt_State
=> State_Type
,
7235 Pragma_Loc
=> Loc
));
7238 -- Case of entry for the same entry
7240 elsif Int_Val
= Interrupt_States
.Table
(IST_Num
).
7243 -- If state matches, done, no need to make redundant entry
7246 State_Type
= Interrupt_States
.Table
(IST_Num
).
7249 -- Otherwise if state does not match, error
7252 Interrupt_States
.Table
(IST_Num
).Pragma_Loc
;
7254 ("state conflicts with that given at #", Arg2
);
7258 IST_Num
:= IST_Num
+ 1;
7260 end Interrupt_State
;
7262 ----------------------
7263 -- Java_Constructor --
7264 ----------------------
7266 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
7268 when Pragma_Java_Constructor
=> Java_Constructor
: declare
7275 Check_Arg_Count
(1);
7276 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7277 Check_Arg_Is_Local_Name
(Arg1
);
7279 Id
:= Expression
(Arg1
);
7280 Find_Program_Unit_Name
(Id
);
7282 -- If we did not find the name, we are done
7284 if Etype
(Id
) = Any_Type
then
7288 Hom_Id
:= Entity
(Id
);
7290 -- Loop through homonyms
7293 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
7295 -- The constructor is required to be a function returning
7296 -- an access type whose designated type has convention Java.
7298 if Ekind
(Def_Id
) = E_Function
7299 and then Ekind
(Etype
(Def_Id
)) in Access_Kind
7302 (Designated_Type
(Etype
(Def_Id
))) = Convention_Java
7305 (Root_Type
(Designated_Type
(Etype
(Def_Id
))))
7308 Set_Is_Constructor
(Def_Id
);
7309 Set_Convention
(Def_Id
, Convention_Java
);
7313 ("pragma% requires function returning a 'Java access type",
7317 Hom_Id
:= Homonym
(Hom_Id
);
7319 exit when No
(Hom_Id
) or else Scope
(Hom_Id
) /= Current_Scope
;
7321 end Java_Constructor
;
7323 ----------------------
7324 -- Java_Interface --
7325 ----------------------
7327 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
7329 when Pragma_Java_Interface
=> Java_Interface
: declare
7335 Check_Arg_Count
(1);
7336 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7337 Check_Arg_Is_Local_Name
(Arg1
);
7339 Arg
:= Expression
(Arg1
);
7342 if Etype
(Arg
) = Any_Type
then
7346 if not Is_Entity_Name
(Arg
)
7347 or else not Is_Type
(Entity
(Arg
))
7349 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
7352 Typ
:= Underlying_Type
(Entity
(Arg
));
7354 -- For now we simply check some of the semantic constraints
7355 -- on the type. This currently leaves out some restrictions
7356 -- on interface types, namely that the parent type must be
7357 -- java.lang.Object.Typ and that all primitives of the type
7358 -- should be declared abstract. ???
7360 if not Is_Tagged_Type
(Typ
) or else not Is_Abstract
(Typ
) then
7361 Error_Pragma_Arg
("pragma% requires an abstract "
7362 & "tagged type", Arg1
);
7364 elsif not Has_Discriminants
(Typ
)
7365 or else Ekind
(Etype
(First_Discriminant
(Typ
)))
7366 /= E_Anonymous_Access_Type
7368 not Is_Class_Wide_Type
7369 (Designated_Type
(Etype
(First_Discriminant
(Typ
))))
7372 ("type must have a class-wide access discriminant", Arg1
);
7380 -- pragma Keep_Names ([On => ] local_NAME);
7382 when Pragma_Keep_Names
=> Keep_Names
: declare
7387 Check_Arg_Count
(1);
7388 Check_Optional_Identifier
(Arg1
, Name_On
);
7389 Check_Arg_Is_Local_Name
(Arg1
);
7391 Arg
:= Expression
(Arg1
);
7394 if Etype
(Arg
) = Any_Type
then
7398 if not Is_Entity_Name
(Arg
)
7399 or else Ekind
(Entity
(Arg
)) /= E_Enumeration_Type
7402 ("pragma% requires a local enumeration type", Arg1
);
7405 Set_Discard_Names
(Entity
(Arg
), False);
7412 -- pragma License (RESTRICTED | UNRESRICTED | GPL | MODIFIED_GPL);
7414 when Pragma_License
=>
7416 Check_Arg_Count
(1);
7417 Check_No_Identifiers
;
7418 Check_Valid_Configuration_Pragma
;
7419 Check_Arg_Is_Identifier
(Arg1
);
7422 Sind
: constant Source_File_Index
:=
7423 Source_Index
(Current_Sem_Unit
);
7426 case Chars
(Get_Pragma_Arg
(Arg1
)) is
7428 Set_License
(Sind
, GPL
);
7430 when Name_Modified_GPL
=>
7431 Set_License
(Sind
, Modified_GPL
);
7433 when Name_Restricted
=>
7434 Set_License
(Sind
, Restricted
);
7436 when Name_Unrestricted
=>
7437 Set_License
(Sind
, Unrestricted
);
7440 Error_Pragma_Arg
("invalid license name", Arg1
);
7448 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
7450 when Pragma_Link_With
=> Link_With
: declare
7456 if Operating_Mode
= Generate_Code
7457 and then In_Extended_Main_Source_Unit
(N
)
7459 Check_At_Least_N_Arguments
(1);
7460 Check_No_Identifiers
;
7461 Check_Is_In_Decl_Part_Or_Package_Spec
;
7462 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7466 while Present
(Arg
) loop
7467 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
7469 -- Store argument, converting sequences of spaces
7470 -- to a single null character (this is one of the
7471 -- differences in processing between Link_With
7472 -- and Linker_Options).
7475 C
: constant Char_Code
:= Get_Char_Code
(' ');
7476 S
: constant String_Id
:=
7477 Strval
(Expr_Value_S
(Expression
(Arg
)));
7478 L
: constant Nat
:= String_Length
(S
);
7481 procedure Skip_Spaces
;
7482 -- Advance F past any spaces
7484 procedure Skip_Spaces
is
7486 while F
<= L
and then Get_String_Char
(S
, F
) = C
loop
7492 Skip_Spaces
; -- skip leading spaces
7494 -- Loop through characters, changing any embedded
7495 -- sequence of spaces to a single null character
7496 -- (this is how Link_With/Linker_Options differ)
7499 if Get_String_Char
(S
, F
) = C
then
7502 Store_String_Char
(ASCII
.NUL
);
7505 Store_String_Char
(Get_String_Char
(S
, F
));
7513 if Present
(Arg
) then
7514 Store_String_Char
(ASCII
.NUL
);
7518 Store_Linker_Option_String
(End_String
);
7526 -- pragma Linker_Alias (
7527 -- [Entity =>] LOCAL_NAME
7528 -- [Alias =>] static_string_EXPRESSION);
7530 when Pragma_Linker_Alias
=>
7532 Check_Arg_Count
(2);
7533 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7534 Check_Optional_Identifier
(Arg2
, "alias");
7535 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
7536 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7538 -- The only processing required is to link this item on to the
7539 -- list of rep items for the given entity. This is accomplished
7540 -- by the call to Rep_Item_Too_Late (when no error is detected
7541 -- and False is returned).
7543 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
7546 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7549 --------------------
7550 -- Linker_Options --
7551 --------------------
7553 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
7555 when Pragma_Linker_Options
=> Linker_Options
: declare
7559 Check_Ada_83_Warning
;
7560 Check_No_Identifiers
;
7561 Check_Arg_Count
(1);
7562 Check_Is_In_Decl_Part_Or_Package_Spec
;
7564 if Operating_Mode
= Generate_Code
7565 and then In_Extended_Main_Source_Unit
(N
)
7567 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7568 Start_String
(Strval
(Expr_Value_S
(Expression
(Arg1
))));
7571 while Present
(Arg
) loop
7572 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
7573 Store_String_Char
(ASCII
.NUL
);
7575 (Strval
(Expr_Value_S
(Expression
(Arg
))));
7579 Store_Linker_Option_String
(End_String
);
7583 --------------------
7584 -- Linker_Section --
7585 --------------------
7587 -- pragma Linker_Section (
7588 -- [Entity =>] LOCAL_NAME
7589 -- [Section =>] static_string_EXPRESSION);
7591 when Pragma_Linker_Section
=>
7593 Check_Arg_Count
(2);
7594 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7595 Check_Optional_Identifier
(Arg2
, Name_Section
);
7596 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
7597 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7599 -- The only processing required is to link this item on to the
7600 -- list of rep items for the given entity. This is accomplished
7601 -- by the call to Rep_Item_Too_Late (when no error is detected
7602 -- and False is returned).
7604 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
7607 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7614 -- pragma List (On | Off)
7616 -- There is nothing to do here, since we did all the processing
7617 -- for this pragma in Par.Prag (so that it works properly even in
7618 -- syntax only mode)
7623 --------------------
7624 -- Locking_Policy --
7625 --------------------
7627 -- pragma Locking_Policy (policy_IDENTIFIER);
7629 when Pragma_Locking_Policy
=> declare
7633 Check_Ada_83_Warning
;
7634 Check_Arg_Count
(1);
7635 Check_No_Identifiers
;
7636 Check_Arg_Is_Locking_Policy
(Arg1
);
7637 Check_Valid_Configuration_Pragma
;
7638 Get_Name_String
(Chars
(Expression
(Arg1
)));
7639 LP
:= Fold_Upper
(Name_Buffer
(1));
7641 if Locking_Policy
/= ' '
7642 and then Locking_Policy
/= LP
7644 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
7645 Error_Pragma
("locking policy incompatible with policy#");
7647 -- Set new policy, but always preserve System_Location since
7648 -- we like the error message with the run time name.
7651 Locking_Policy
:= LP
;
7653 if Locking_Policy_Sloc
/= System_Location
then
7654 Locking_Policy_Sloc
:= Loc
;
7663 -- pragma Long_Float (D_Float | G_Float);
7665 when Pragma_Long_Float
=>
7667 Check_Valid_Configuration_Pragma
;
7668 Check_Arg_Count
(1);
7669 Check_No_Identifier
(Arg1
);
7670 Check_Arg_Is_One_Of
(Arg1
, Name_D_Float
, Name_G_Float
);
7672 if not OpenVMS_On_Target
then
7673 Error_Pragma
("?pragma% ignored (applies only to Open'V'M'S)");
7678 if Chars
(Expression
(Arg1
)) = Name_D_Float
then
7679 if Opt
.Float_Format_Long
= 'G' then
7680 Error_Pragma
("G_Float previously specified");
7683 Opt
.Float_Format_Long
:= 'D';
7685 -- G_Float case (this is the default, does not need overriding)
7688 if Opt
.Float_Format_Long
= 'D' then
7689 Error_Pragma
("D_Float previously specified");
7692 Opt
.Float_Format_Long
:= 'G';
7695 Set_Standard_Fpt_Formats
;
7697 -----------------------
7698 -- Machine_Attribute --
7699 -----------------------
7701 -- pragma Machine_Attribute (
7702 -- [Entity =>] LOCAL_NAME,
7703 -- [Attribute_Name =>] static_string_EXPRESSION
7704 -- [,[Info =>] static_string_EXPRESSION] );
7706 when Pragma_Machine_Attribute
=> Machine_Attribute
: declare
7712 if Arg_Count
= 3 then
7713 Check_Optional_Identifier
(Arg3
, "info");
7714 Check_Arg_Is_Static_Expression
(Arg3
, Standard_String
);
7716 Check_Arg_Count
(2);
7719 Check_Arg_Is_Local_Name
(Arg1
);
7720 Check_Optional_Identifier
(Arg2
, "attribute_name");
7721 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7722 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7723 Def_Id
:= Entity
(Expression
(Arg1
));
7725 if Is_Access_Type
(Def_Id
) then
7726 Def_Id
:= Designated_Type
(Def_Id
);
7729 if Rep_Item_Too_Early
(Def_Id
, N
) then
7733 Def_Id
:= Underlying_Type
(Def_Id
);
7735 -- The only processing required is to link this item on to the
7736 -- list of rep items for the given entity. This is accomplished
7737 -- by the call to Rep_Item_Too_Late (when no error is detected
7738 -- and False is returned).
7740 if Rep_Item_Too_Late
(Def_Id
, N
) then
7743 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7745 end Machine_Attribute
;
7751 -- pragma Main_Storage
7752 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
7754 -- MAIN_STORAGE_OPTION ::=
7755 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
7756 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
7758 when Pragma_Main
=> Main
: declare
7759 Args
: Args_List
(1 .. 3);
7760 Names
: constant Name_List
(1 .. 3) := (
7762 Name_Task_Stack_Size_Default
,
7763 Name_Time_Slicing_Enabled
);
7769 Gather_Associations
(Names
, Args
);
7771 for J
in 1 .. 2 loop
7772 if Present
(Args
(J
)) then
7773 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
7777 if Present
(Args
(3)) then
7778 Check_Arg_Is_Static_Expression
(Args
(3), Standard_Boolean
);
7782 while Present
(Nod
) loop
7783 if Nkind
(Nod
) = N_Pragma
7784 and then Chars
(Nod
) = Name_Main
7786 Error_Msg_Name_1
:= Chars
(N
);
7787 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
7798 -- pragma Main_Storage
7799 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
7801 -- MAIN_STORAGE_OPTION ::=
7802 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
7803 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
7805 when Pragma_Main_Storage
=> Main_Storage
: declare
7806 Args
: Args_List
(1 .. 2);
7807 Names
: constant Name_List
(1 .. 2) := (
7808 Name_Working_Storage
,
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 Check_In_Main_Program
;
7826 while Present
(Nod
) loop
7827 if Nkind
(Nod
) = N_Pragma
7828 and then Chars
(Nod
) = Name_Main_Storage
7830 Error_Msg_Name_1
:= Chars
(N
);
7831 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
7842 -- pragma Memory_Size (NUMERIC_LITERAL)
7844 when Pragma_Memory_Size
=>
7847 -- Memory size is simply ignored
7849 Check_No_Identifiers
;
7850 Check_Arg_Count
(1);
7851 Check_Arg_Is_Integer_Literal
(Arg1
);
7857 -- pragma No_Return (procedure_LOCAL_NAME);
7859 when Pragma_No_Return
=> No_Return
: declare
7866 Check_Arg_Count
(1);
7867 Check_No_Identifiers
;
7868 Check_Arg_Is_Local_Name
(Arg1
);
7869 Id
:= Expression
(Arg1
);
7872 if not Is_Entity_Name
(Id
) then
7873 Error_Pragma_Arg
("entity name required", Arg1
);
7876 if Etype
(Id
) = Any_Type
then
7884 and then Scope
(E
) = Current_Scope
7886 if Ekind
(E
) = E_Procedure
7887 or else Ekind
(E
) = E_Generic_Procedure
7897 Error_Pragma
("no procedures found for pragma%");
7901 ------------------------
7902 -- No_Strict_Aliasing --
7903 ------------------------
7905 when Pragma_No_Strict_Aliasing
=> No_Strict_Alias
: declare
7910 Check_At_Most_N_Arguments
(1);
7912 if Arg_Count
= 0 then
7913 Check_Valid_Configuration_Pragma
;
7914 Opt
.No_Strict_Aliasing
:= True;
7917 Check_Optional_Identifier
(Arg2
, Name_Entity
);
7918 Check_Arg_Is_Local_Name
(Arg1
);
7919 E_Id
:= Entity
(Expression
(Arg1
));
7921 if E_Id
= Any_Type
then
7923 elsif No
(E_Id
) or else not Is_Access_Type
(E_Id
) then
7924 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
7927 Set_No_Strict_Aliasing
(Implementation_Base_Type
(E_Id
));
7929 end No_Strict_Alias
;
7935 -- pragma Obsolescent [(static_string_EXPRESSION)];
7937 when Pragma_Obsolescent
=> Obsolescent
: declare
7940 Check_At_Most_N_Arguments
(1);
7941 Check_No_Identifiers
;
7943 if Arg_Count
= 1 then
7944 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7948 or else (Nkind
(Prev
(N
))) /= N_Subprogram_Declaration
7951 ("pragma% misplaced, must immediately " &
7952 "follow subprogram spec");
7960 -- pragma No_Run_Time
7962 -- Note: this pragma is retained for backwards compatibiltiy.
7963 -- See body of Rtsfind for full details on its handling.
7965 when Pragma_No_Run_Time
=>
7967 Check_Valid_Configuration_Pragma
;
7968 Check_Arg_Count
(0);
7970 No_Run_Time_Mode
:= True;
7971 Configurable_Run_Time_Mode
:= True;
7974 Word32
: constant Boolean := Ttypes
.System_Word_Size
= 32;
7977 Duration_32_Bits_On_Target
:= True;
7981 Set_Restriction
(No_Finalization
, N
);
7982 Set_Restriction
(No_Exception_Handlers
, N
);
7983 Set_Restriction
(Max_Tasks
, N
, 0);
7984 Set_Restriction
(No_Tasking
, N
);
7986 -----------------------
7987 -- Normalize_Scalars --
7988 -----------------------
7990 -- pragma Normalize_Scalars;
7992 when Pragma_Normalize_Scalars
=>
7993 Check_Ada_83_Warning
;
7994 Check_Arg_Count
(0);
7995 Check_Valid_Configuration_Pragma
;
7996 Normalize_Scalars
:= True;
7997 Init_Or_Norm_Scalars
:= True;
8003 -- pragma Optimize (Time | Space);
8005 -- The actual check for optimize is done in Gigi. Note that this
8006 -- pragma does not actually change the optimization setting, it
8007 -- simply checks that it is consistent with the pragma.
8009 when Pragma_Optimize
=>
8010 Check_No_Identifiers
;
8011 Check_Arg_Count
(1);
8012 Check_Arg_Is_One_Of
(Arg1
, Name_Time
, Name_Space
, Name_Off
);
8014 -------------------------
8015 -- Optional_Overriding --
8016 -------------------------
8018 -- These pragmas are treated as part of the previous subprogram
8019 -- declaration, and analyzed immediately after it (see sem_ch6,
8020 -- Check_Overriding_Operation). If the pragma has not been analyzed
8021 -- yet, it appears in the wrong place.
8023 when Pragma_Optional_Overriding
=>
8024 Error_Msg_N
("pragma must appear immediately after subprogram", N
);
8030 when Pragma_Overriding
=>
8031 Error_Msg_N
("pragma must appear immediately after subprogram", N
);
8037 -- pragma Pack (first_subtype_LOCAL_NAME);
8039 when Pragma_Pack
=> Pack
: declare
8040 Assoc
: constant Node_Id
:= Arg1
;
8045 Check_No_Identifiers
;
8046 Check_Arg_Count
(1);
8047 Check_Arg_Is_Local_Name
(Arg1
);
8049 Type_Id
:= Expression
(Assoc
);
8050 Find_Type
(Type_Id
);
8051 Typ
:= Entity
(Type_Id
);
8054 or else Rep_Item_Too_Early
(Typ
, N
)
8058 Typ
:= Underlying_Type
(Typ
);
8061 if not Is_Array_Type
(Typ
) and then not Is_Record_Type
(Typ
) then
8062 Error_Pragma
("pragma% must specify array or record type");
8065 Check_First_Subtype
(Arg1
);
8067 if Has_Pragma_Pack
(Typ
) then
8068 Error_Pragma
("duplicate pragma%, only one allowed");
8070 -- Array type. We set the Has_Pragma_Pack flag, and Is_Packed,
8071 -- but not Has_Non_Standard_Rep, because we don't actually know
8072 -- till freeze time if the array can have packed representation.
8073 -- That's because in the general case we do not know enough about
8074 -- the component type until it in turn is frozen, which certainly
8075 -- happens before the array type is frozen, but not necessarily
8076 -- till that point (i.e. right now it may be unfrozen).
8078 elsif Is_Array_Type
(Typ
) then
8079 if Has_Aliased_Components
(Base_Type
(Typ
)) then
8081 ("pragma% ignored, cannot pack aliased components?");
8083 elsif Has_Atomic_Components
(Typ
)
8084 or else Is_Atomic
(Component_Type
(Typ
))
8087 ("?pragma% ignored, cannot pack atomic components");
8089 elsif not Rep_Item_Too_Late
(Typ
, N
) then
8090 Set_Is_Packed
(Base_Type
(Typ
));
8091 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
8092 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
8095 -- Record type. For record types, the pack is always effective
8097 else pragma Assert
(Is_Record_Type
(Typ
));
8098 if not Rep_Item_Too_Late
(Typ
, N
) then
8099 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
8100 Set_Is_Packed
(Base_Type
(Typ
));
8101 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
8112 -- There is nothing to do here, since we did all the processing
8113 -- for this pragma in Par.Prag (so that it works properly even in
8114 -- syntax only mode)
8123 -- pragma Passive [(PASSIVE_FORM)];
8125 -- PASSIVE_FORM ::= Semaphore | No
8127 when Pragma_Passive
=>
8130 if Nkind
(Parent
(N
)) /= N_Task_Definition
then
8131 Error_Pragma
("pragma% must be within task definition");
8134 if Arg_Count
/= 0 then
8135 Check_Arg_Count
(1);
8136 Check_Arg_Is_One_Of
(Arg1
, Name_Semaphore
, Name_No
);
8143 -- pragma Polling (ON | OFF);
8145 when Pragma_Polling
=>
8147 Check_Arg_Count
(1);
8148 Check_No_Identifiers
;
8149 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
8150 Polling_Required
:= (Chars
(Expression
(Arg1
)) = Name_On
);
8152 ---------------------
8153 -- Persistent_Data --
8154 ---------------------
8156 when Pragma_Persistent_Data
=> declare
8160 -- Register the pragma as applying to the compilation unit.
8161 -- Individual Persistent_Object pragmas for relevant objects
8162 -- are generated the end of the compilation.
8165 Check_Valid_Configuration_Pragma
;
8166 Check_Arg_Count
(0);
8167 Ent
:= Find_Lib_Unit_Name
;
8168 Set_Is_Preelaborated
(Ent
);
8171 -----------------------
8172 -- Persistent_Object --
8173 -----------------------
8175 when Pragma_Persistent_Object
=> declare
8183 Check_Arg_Count
(1);
8184 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
8186 if not Is_Entity_Name
(Expression
(Arg1
))
8188 (Ekind
(Entity
(Expression
(Arg1
))) /= E_Variable
8189 and then Ekind
(Entity
(Expression
(Arg1
))) /= E_Constant
)
8191 Error_Pragma_Arg
("pragma only applies to objects", Arg1
);
8194 Ent
:= Entity
(Expression
(Arg1
));
8195 Decl
:= Parent
(Ent
);
8197 if Nkind
(Decl
) /= N_Object_Declaration
then
8201 -- Placement of the object depends on whether there is
8202 -- an initial value or none. If the No_Initialization flag
8203 -- is set, the initialization has been transformed into
8204 -- assignments, which is disallowed elaboration code.
8206 if No_Initialization
(Decl
) then
8208 ("initialization for persistent object"
8209 & "must be static expression", Decl
);
8213 if No
(Expression
(Decl
)) then
8215 Store_String_Chars
("section ("".persistent.bss"")");
8219 if not Is_OK_Static_Expression
(Expression
(Decl
)) then
8220 Flag_Non_Static_Expr
8221 ("initialization for persistent object"
8222 & "must be static expression!", Expression
(Decl
));
8227 Store_String_Chars
("section ("".persistent.data"")");
8234 Name_Machine_Attribute
,
8236 (Make_Pragma_Argument_Association
8237 (Sloc
=> Sloc
(Arg1
),
8238 Expression
=> New_Occurrence_Of
(Ent
, Sloc
(Ent
))),
8239 Make_Pragma_Argument_Association
8240 (Sloc
=> Sloc
(Arg1
),
8243 (Sloc
=> Sloc
(Arg1
),
8246 Insert_After
(N
, MA
);
8248 Set_Has_Gigi_Rep_Item
(Ent
);
8255 -- pragma Preelaborate [(library_unit_NAME)];
8257 -- Set the flag Is_Preelaborated of program unit name entity
8259 when Pragma_Preelaborate
=> Preelaborate
: declare
8260 Pa
: constant Node_Id
:= Parent
(N
);
8261 Pk
: constant Node_Kind
:= Nkind
(Pa
);
8265 Check_Ada_83_Warning
;
8266 Check_Valid_Library_Unit_Pragma
;
8268 if Nkind
(N
) = N_Null_Statement
then
8272 Ent
:= Find_Lib_Unit_Name
;
8274 -- This filters out pragmas inside generic parent then
8275 -- show up inside instantiation
8278 and then not (Pk
= N_Package_Specification
8279 and then Present
(Generic_Parent
(Pa
)))
8281 if not Debug_Flag_U
then
8282 Set_Is_Preelaborated
(Ent
);
8283 Set_Suppress_Elaboration_Warnings
(Ent
);
8292 -- pragma Priority (EXPRESSION);
8294 when Pragma_Priority
=> Priority
: declare
8295 P
: constant Node_Id
:= Parent
(N
);
8299 Check_No_Identifiers
;
8300 Check_Arg_Count
(1);
8304 if Nkind
(P
) = N_Subprogram_Body
then
8305 Check_In_Main_Program
;
8307 Arg
:= Expression
(Arg1
);
8308 Analyze_And_Resolve
(Arg
, Standard_Integer
);
8312 if not Is_Static_Expression
(Arg
) then
8313 Flag_Non_Static_Expr
8314 ("main subprogram priority is not static!", Arg
);
8317 -- If constraint error, then we already signalled an error
8319 elsif Raises_Constraint_Error
(Arg
) then
8322 -- Otherwise check in range
8326 Val
: constant Uint
:= Expr_Value
(Arg
);
8330 or else Val
> Expr_Value
(Expression
8331 (Parent
(RTE
(RE_Max_Priority
))))
8334 ("main subprogram priority is out of range", Arg1
);
8340 (Current_Sem_Unit
, UI_To_Int
(Expr_Value
(Arg
)));
8342 -- Task or Protected, must be of type Integer
8344 elsif Nkind
(P
) = N_Protected_Definition
8346 Nkind
(P
) = N_Task_Definition
8348 Arg
:= Expression
(Arg1
);
8350 -- The expression must be analyzed in the special manner
8351 -- described in "Handling of Default and Per-Object
8352 -- Expressions" in sem.ads.
8354 Analyze_Per_Use_Expression
(Arg
, Standard_Integer
);
8356 if not Is_Static_Expression
(Arg
) then
8357 Check_Restriction
(Static_Priorities
, Arg
);
8360 -- Anything else is incorrect
8366 if Has_Priority_Pragma
(P
) then
8367 Error_Pragma
("duplicate pragma% not allowed");
8369 Set_Has_Priority_Pragma
(P
, True);
8371 if Nkind
(P
) = N_Protected_Definition
8373 Nkind
(P
) = N_Task_Definition
8375 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
8376 -- exp_ch9 should use this ???
8385 -- pragma Profile (profile_IDENTIFIER);
8387 -- profile_IDENTIFIER => Protected | Ravenscar
8389 when Pragma_Profile
=>
8390 Check_Arg_Count
(1);
8391 Check_Valid_Configuration_Pragma
;
8392 Check_No_Identifiers
;
8395 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
8397 if Chars
(Argx
) = Name_Ravenscar
then
8398 Set_Ravenscar_Profile
(N
);
8400 elsif Chars
(Argx
) = Name_Restricted
then
8401 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> False);
8403 Error_Pragma_Arg
("& is not a valid profile", Argx
);
8407 ----------------------
8408 -- Profile_Warnings --
8409 ----------------------
8411 -- pragma Profile_Warnings (profile_IDENTIFIER);
8413 -- profile_IDENTIFIER => Protected | Ravenscar
8415 when Pragma_Profile_Warnings
=>
8417 Check_Arg_Count
(1);
8418 Check_Valid_Configuration_Pragma
;
8419 Check_No_Identifiers
;
8422 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
8424 if Chars
(Argx
) = Name_Ravenscar
then
8425 Set_Profile_Restrictions
(Ravenscar
, N
, Warn
=> True);
8427 elsif Chars
(Argx
) = Name_Restricted
then
8428 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> True);
8430 Error_Pragma_Arg
("& is not a valid profile", Argx
);
8434 --------------------------
8435 -- Propagate_Exceptions --
8436 --------------------------
8438 -- pragma Propagate_Exceptions;
8440 when Pragma_Propagate_Exceptions
=>
8442 Check_Arg_Count
(0);
8444 if In_Extended_Main_Source_Unit
(N
) then
8445 Propagate_Exceptions
:= True;
8452 -- pragma Psect_Object (
8453 -- [Internal =>] LOCAL_NAME,
8454 -- [, [External =>] EXTERNAL_SYMBOL]
8455 -- [, [Size =>] EXTERNAL_SYMBOL]);
8457 when Pragma_Psect_Object | Pragma_Common_Object
=>
8458 Psect_Object
: declare
8459 Args
: Args_List
(1 .. 3);
8460 Names
: constant Name_List
(1 .. 3) := (
8465 Internal
: Node_Id
renames Args
(1);
8466 External
: Node_Id
renames Args
(2);
8467 Size
: Node_Id
renames Args
(3);
8471 procedure Check_Too_Long
(Arg
: Node_Id
);
8472 -- Posts message if the argument is an identifier with more
8473 -- than 31 characters, or a string literal with more than
8474 -- 31 characters, and we are operating under VMS
8476 --------------------
8477 -- Check_Too_Long --
8478 --------------------
8480 procedure Check_Too_Long
(Arg
: Node_Id
) is
8481 X
: constant Node_Id
:= Original_Node
(Arg
);
8484 if Nkind
(X
) /= N_String_Literal
8486 Nkind
(X
) /= N_Identifier
8489 ("inappropriate argument for pragma %", Arg
);
8492 if OpenVMS_On_Target
then
8493 if (Nkind
(X
) = N_String_Literal
8494 and then String_Length
(Strval
(X
)) > 31)
8496 (Nkind
(X
) = N_Identifier
8497 and then Length_Of_Name
(Chars
(X
)) > 31)
8500 ("argument for pragma % is longer than 31 characters",
8506 -- Start of processing for Common_Object/Psect_Object
8510 Gather_Associations
(Names
, Args
);
8511 Process_Extended_Import_Export_Internal_Arg
(Internal
);
8513 Def_Id
:= Entity
(Internal
);
8515 if Ekind
(Def_Id
) /= E_Constant
8516 and then Ekind
(Def_Id
) /= E_Variable
8519 ("pragma% must designate an object", Internal
);
8522 Check_Too_Long
(Internal
);
8524 if Is_Imported
(Def_Id
) or else Is_Exported
(Def_Id
) then
8526 ("cannot use pragma% for imported/exported object",
8530 if Is_Concurrent_Type
(Etype
(Internal
)) then
8532 ("cannot specify pragma % for task/protected object",
8536 if Has_Rep_Pragma
(Def_Id
, Name_Common_Object
)
8538 Has_Rep_Pragma
(Def_Id
, Name_Psect_Object
)
8540 Error_Msg_N
("?duplicate Common/Psect_Object pragma", N
);
8543 if Ekind
(Def_Id
) = E_Constant
then
8545 ("cannot specify pragma % for a constant", Internal
);
8548 if Is_Record_Type
(Etype
(Internal
)) then
8554 Ent
:= First_Entity
(Etype
(Internal
));
8555 while Present
(Ent
) loop
8556 Decl
:= Declaration_Node
(Ent
);
8558 if Ekind
(Ent
) = E_Component
8559 and then Nkind
(Decl
) = N_Component_Declaration
8560 and then Present
(Expression
(Decl
))
8561 and then Warn_On_Export_Import
8564 ("?object for pragma % has defaults", Internal
);
8574 if Present
(Size
) then
8575 Check_Too_Long
(Size
);
8578 if Present
(External
) then
8579 Check_Arg_Is_External_Name
(External
);
8580 Check_Too_Long
(External
);
8583 -- If all error tests pass, link pragma on to the rep item chain
8585 Record_Rep_Item
(Def_Id
, N
);
8592 -- pragma Pure [(library_unit_NAME)];
8594 when Pragma_Pure
=> Pure
: declare
8597 Check_Ada_83_Warning
;
8598 Check_Valid_Library_Unit_Pragma
;
8600 if Nkind
(N
) = N_Null_Statement
then
8604 Ent
:= Find_Lib_Unit_Name
;
8606 Set_Suppress_Elaboration_Warnings
(Ent
);
8613 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
8615 when Pragma_Pure_Function
=> Pure_Function
: declare
8619 Effective
: Boolean := False;
8623 Check_Arg_Count
(1);
8624 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8625 Check_Arg_Is_Local_Name
(Arg1
);
8626 E_Id
:= Expression
(Arg1
);
8628 if Error_Posted
(E_Id
) then
8632 -- Loop through homonyms (overloadings) of referenced entity
8638 Def_Id
:= Get_Base_Subprogram
(E
);
8640 if Ekind
(Def_Id
) /= E_Function
8641 and then Ekind
(Def_Id
) /= E_Generic_Function
8642 and then Ekind
(Def_Id
) /= E_Operator
8645 ("pragma% requires a function name", Arg1
);
8648 Set_Is_Pure
(Def_Id
);
8650 if not Has_Pragma_Pure_Function
(Def_Id
) then
8651 Set_Has_Pragma_Pure_Function
(Def_Id
);
8656 exit when No
(E
) or else Scope
(E
) /= Current_Scope
;
8660 and then Warn_On_Redundant_Constructs
8662 Error_Msg_NE
("pragma Pure_Function on& is redundant?",
8668 --------------------
8669 -- Queuing_Policy --
8670 --------------------
8672 -- pragma Queuing_Policy (policy_IDENTIFIER);
8674 when Pragma_Queuing_Policy
=> declare
8678 Check_Ada_83_Warning
;
8679 Check_Arg_Count
(1);
8680 Check_No_Identifiers
;
8681 Check_Arg_Is_Queuing_Policy
(Arg1
);
8682 Check_Valid_Configuration_Pragma
;
8683 Get_Name_String
(Chars
(Expression
(Arg1
)));
8684 QP
:= Fold_Upper
(Name_Buffer
(1));
8686 if Queuing_Policy
/= ' '
8687 and then Queuing_Policy
/= QP
8689 Error_Msg_Sloc
:= Queuing_Policy_Sloc
;
8690 Error_Pragma
("queuing policy incompatible with policy#");
8692 -- Set new policy, but always preserve System_Location since
8693 -- we like the error message with the run time name.
8696 Queuing_Policy
:= QP
;
8698 if Queuing_Policy_Sloc
/= System_Location
then
8699 Queuing_Policy_Sloc
:= Loc
;
8704 ---------------------------
8705 -- Remote_Call_Interface --
8706 ---------------------------
8708 -- pragma Remote_Call_Interface [(library_unit_NAME)];
8710 when Pragma_Remote_Call_Interface
=> Remote_Call_Interface
: declare
8711 Cunit_Node
: Node_Id
;
8712 Cunit_Ent
: Entity_Id
;
8716 Check_Ada_83_Warning
;
8717 Check_Valid_Library_Unit_Pragma
;
8719 if Nkind
(N
) = N_Null_Statement
then
8723 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
8724 K
:= Nkind
(Unit
(Cunit_Node
));
8725 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
8727 if K
= N_Package_Declaration
8728 or else K
= N_Generic_Package_Declaration
8729 or else K
= N_Subprogram_Declaration
8730 or else K
= N_Generic_Subprogram_Declaration
8731 or else (K
= N_Subprogram_Body
8732 and then Acts_As_Spec
(Unit
(Cunit_Node
)))
8737 "pragma% must apply to package or subprogram declaration");
8740 Set_Is_Remote_Call_Interface
(Cunit_Ent
);
8741 end Remote_Call_Interface
;
8747 -- pragma Remote_Types [(library_unit_NAME)];
8749 when Pragma_Remote_Types
=> Remote_Types
: declare
8750 Cunit_Node
: Node_Id
;
8751 Cunit_Ent
: Entity_Id
;
8754 Check_Ada_83_Warning
;
8755 Check_Valid_Library_Unit_Pragma
;
8757 if Nkind
(N
) = N_Null_Statement
then
8761 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
8762 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
8764 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
8766 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
8769 "pragma% can only apply to a package declaration");
8772 Set_Is_Remote_Types
(Cunit_Ent
);
8779 -- pragma Ravenscar;
8781 when Pragma_Ravenscar
=>
8783 Check_Arg_Count
(0);
8784 Check_Valid_Configuration_Pragma
;
8785 Set_Ravenscar_Profile
(N
);
8787 if Warn_On_Obsolescent_Feature
then
8789 ("pragma Ravenscar is an obsolescent feature?", N
);
8791 ("|use pragma Profile (Ravenscar) instead", N
);
8794 -------------------------
8795 -- Restricted_Run_Time --
8796 -------------------------
8798 -- pragma Restricted_Run_Time;
8800 when Pragma_Restricted_Run_Time
=>
8802 Check_Arg_Count
(0);
8803 Check_Valid_Configuration_Pragma
;
8804 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> False);
8806 if Warn_On_Obsolescent_Feature
then
8808 ("pragma Restricted_Run_Time is an obsolescent feature?", N
);
8810 ("|use pragma Profile (Restricted) instead", N
);
8817 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
8820 -- restriction_IDENTIFIER
8821 -- | restriction_parameter_IDENTIFIER => EXPRESSION
8823 when Pragma_Restrictions
=>
8824 Process_Restrictions_Or_Restriction_Warnings
;
8826 --------------------------
8827 -- Restriction_Warnings --
8828 --------------------------
8830 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
8833 -- restriction_IDENTIFIER
8834 -- | restriction_parameter_IDENTIFIER => EXPRESSION
8836 when Pragma_Restriction_Warnings
=>
8837 Process_Restrictions_Or_Restriction_Warnings
;
8843 -- pragma Reviewable;
8845 when Pragma_Reviewable
=>
8846 Check_Ada_83_Warning
;
8847 Check_Arg_Count
(0);
8853 -- pragma Share_Generic (NAME {, NAME});
8855 when Pragma_Share_Generic
=>
8857 Process_Generic_List
;
8863 -- pragma Shared (LOCAL_NAME);
8865 when Pragma_Shared
=>
8867 Process_Atomic_Shared_Volatile
;
8869 --------------------
8870 -- Shared_Passive --
8871 --------------------
8873 -- pragma Shared_Passive [(library_unit_NAME)];
8875 -- Set the flag Is_Shared_Passive of program unit name entity
8877 when Pragma_Shared_Passive
=> Shared_Passive
: declare
8878 Cunit_Node
: Node_Id
;
8879 Cunit_Ent
: Entity_Id
;
8882 Check_Ada_83_Warning
;
8883 Check_Valid_Library_Unit_Pragma
;
8885 if Nkind
(N
) = N_Null_Statement
then
8889 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
8890 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
8892 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
8894 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
8897 "pragma% can only apply to a package declaration");
8900 Set_Is_Shared_Passive
(Cunit_Ent
);
8903 ----------------------
8904 -- Source_File_Name --
8905 ----------------------
8907 -- There are five forms for this pragma:
8909 -- pragma Source_File_Name (
8910 -- [UNIT_NAME =>] unit_NAME,
8911 -- BODY_FILE_NAME => STRING_LITERAL
8912 -- [, [INDEX =>] INTEGER_LITERAL]);
8914 -- pragma Source_File_Name (
8915 -- [UNIT_NAME =>] unit_NAME,
8916 -- SPEC_FILE_NAME => STRING_LITERAL
8917 -- [, [INDEX =>] INTEGER_LITERAL]);
8919 -- pragma Source_File_Name (
8920 -- BODY_FILE_NAME => STRING_LITERAL
8921 -- [, DOT_REPLACEMENT => STRING_LITERAL]
8922 -- [, CASING => CASING_SPEC]);
8924 -- pragma Source_File_Name (
8925 -- SPEC_FILE_NAME => STRING_LITERAL
8926 -- [, DOT_REPLACEMENT => STRING_LITERAL]
8927 -- [, CASING => CASING_SPEC]);
8929 -- pragma Source_File_Name (
8930 -- SUBUNIT_FILE_NAME => STRING_LITERAL
8931 -- [, DOT_REPLACEMENT => STRING_LITERAL]
8932 -- [, CASING => CASING_SPEC]);
8934 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
8936 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
8937 -- Source_File_Name (SFN), however their usage is exclusive:
8938 -- SFN can only be used when no project file is used, while
8939 -- SFNP can only be used when a project file is used.
8941 -- No processing here. Processing was completed during parsing,
8942 -- since we need to have file names set as early as possible.
8943 -- Units are loaded well before semantic processing starts.
8945 -- The only processing we defer to this point is the check
8946 -- for correct placement.
8948 when Pragma_Source_File_Name
=>
8950 Check_Valid_Configuration_Pragma
;
8952 ------------------------------
8953 -- Source_File_Name_Project --
8954 ------------------------------
8956 -- See Source_File_Name for syntax
8958 -- No processing here. Processing was completed during parsing,
8959 -- since we need to have file names set as early as possible.
8960 -- Units are loaded well before semantic processing starts.
8962 -- The only processing we defer to this point is the check
8963 -- for correct placement.
8965 when Pragma_Source_File_Name_Project
=>
8967 Check_Valid_Configuration_Pragma
;
8969 -- Check that a pragma Source_File_Name_Project is used only
8970 -- in a configuration pragmas file.
8972 -- Pragmas Source_File_Name_Project should only be generated
8973 -- by the Project Manager in configuration pragmas files.
8975 -- This is really an ugly test. It seems to depend on some
8976 -- accidental and undocumented property. At the very least
8977 -- it needs to be documented, but it would be better to have
8978 -- a clean way of testing if we are in a configuration file???
8980 if Present
(Parent
(N
)) then
8982 ("pragma% can only appear in a configuration pragmas file");
8985 ----------------------
8986 -- Source_Reference --
8987 ----------------------
8989 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
8991 -- Nothing to do, all processing completed in Par.Prag, since we
8992 -- need the information for possible parser messages that are output
8994 when Pragma_Source_Reference
=>
9001 -- pragma Storage_Size (EXPRESSION);
9003 when Pragma_Storage_Size
=> Storage_Size
: declare
9004 P
: constant Node_Id
:= Parent
(N
);
9008 Check_No_Identifiers
;
9009 Check_Arg_Count
(1);
9011 -- The expression must be analyzed in the special manner
9012 -- described in "Handling of Default Expressions" in sem.ads.
9014 -- Set In_Default_Expression for per-object case ???
9016 Arg
:= Expression
(Arg1
);
9017 Analyze_Per_Use_Expression
(Arg
, Any_Integer
);
9019 if not Is_Static_Expression
(Arg
) then
9020 Check_Restriction
(Static_Storage_Size
, Arg
);
9023 if Nkind
(P
) /= N_Task_Definition
then
9028 if Has_Storage_Size_Pragma
(P
) then
9029 Error_Pragma
("duplicate pragma% not allowed");
9031 Set_Has_Storage_Size_Pragma
(P
, True);
9034 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
9035 -- ??? exp_ch9 should use this!
9043 -- pragma Storage_Unit (NUMERIC_LITERAL);
9045 -- Only permitted argument is System'Storage_Unit value
9047 when Pragma_Storage_Unit
=>
9048 Check_No_Identifiers
;
9049 Check_Arg_Count
(1);
9050 Check_Arg_Is_Integer_Literal
(Arg1
);
9052 if Intval
(Expression
(Arg1
)) /=
9053 UI_From_Int
(Ttypes
.System_Storage_Unit
)
9055 Error_Msg_Uint_1
:= UI_From_Int
(Ttypes
.System_Storage_Unit
);
9057 ("the only allowed argument for pragma% is ^", Arg1
);
9060 --------------------
9061 -- Stream_Convert --
9062 --------------------
9064 -- pragma Stream_Convert (
9065 -- [Entity =>] type_LOCAL_NAME,
9066 -- [Read =>] function_NAME,
9067 -- [Write =>] function NAME);
9069 when Pragma_Stream_Convert
=> Stream_Convert
: declare
9071 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
);
9072 -- Check that the given argument is the name of a local
9073 -- function of one argument that is not overloaded earlier
9074 -- in the current local scope. A check is also made that the
9075 -- argument is a function with one parameter.
9077 --------------------------------------
9078 -- Check_OK_Stream_Convert_Function --
9079 --------------------------------------
9081 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
) is
9085 Check_Arg_Is_Local_Name
(Arg
);
9086 Ent
:= Entity
(Expression
(Arg
));
9088 if Has_Homonym
(Ent
) then
9090 ("argument for pragma% may not be overloaded", Arg
);
9093 if Ekind
(Ent
) /= E_Function
9094 or else No
(First_Formal
(Ent
))
9095 or else Present
(Next_Formal
(First_Formal
(Ent
)))
9098 ("argument for pragma% must be" &
9099 " function of one argument", Arg
);
9101 end Check_OK_Stream_Convert_Function
;
9103 -- Start of procecessing for Stream_Convert
9107 Check_Arg_Count
(3);
9108 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9109 Check_Optional_Identifier
(Arg2
, Name_Read
);
9110 Check_Optional_Identifier
(Arg3
, Name_Write
);
9111 Check_Arg_Is_Local_Name
(Arg1
);
9112 Check_OK_Stream_Convert_Function
(Arg2
);
9113 Check_OK_Stream_Convert_Function
(Arg3
);
9116 Typ
: constant Entity_Id
:=
9117 Underlying_Type
(Entity
(Expression
(Arg1
)));
9118 Read
: constant Entity_Id
:= Entity
(Expression
(Arg2
));
9119 Write
: constant Entity_Id
:= Entity
(Expression
(Arg3
));
9122 if Etype
(Typ
) = Any_Type
9124 Etype
(Read
) = Any_Type
9126 Etype
(Write
) = Any_Type
9131 Check_First_Subtype
(Arg1
);
9133 if Rep_Item_Too_Early
(Typ
, N
)
9135 Rep_Item_Too_Late
(Typ
, N
)
9140 if Underlying_Type
(Etype
(Read
)) /= Typ
then
9142 ("incorrect return type for function&", Arg2
);
9145 if Underlying_Type
(Etype
(First_Formal
(Write
))) /= Typ
then
9147 ("incorrect parameter type for function&", Arg3
);
9150 if Underlying_Type
(Etype
(First_Formal
(Read
))) /=
9151 Underlying_Type
(Etype
(Write
))
9154 ("result type of & does not match Read parameter type",
9160 -------------------------
9161 -- Style_Checks (GNAT) --
9162 -------------------------
9164 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
9166 -- This is processed by the parser since some of the style
9167 -- checks take place during source scanning and parsing. This
9168 -- means that we don't need to issue error messages here.
9170 when Pragma_Style_Checks
=> Style_Checks
: declare
9171 A
: constant Node_Id
:= Expression
(Arg1
);
9177 Check_No_Identifiers
;
9179 -- Two argument form
9181 if Arg_Count
= 2 then
9182 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
9189 E_Id
:= Expression
(Arg2
);
9192 if not Is_Entity_Name
(E_Id
) then
9194 ("second argument of pragma% must be entity name",
9204 Set_Suppress_Style_Checks
(E
,
9205 (Chars
(Expression
(Arg1
)) = Name_Off
));
9206 exit when No
(Homonym
(E
));
9212 -- One argument form
9215 Check_Arg_Count
(1);
9217 if Nkind
(A
) = N_String_Literal
then
9221 Slen
: constant Natural := Natural (String_Length
(S
));
9222 Options
: String (1 .. Slen
);
9228 C
:= Get_String_Char
(S
, Int
(J
));
9229 exit when not In_Character_Range
(C
);
9230 Options
(J
) := Get_Character
(C
);
9233 Set_Style_Check_Options
(Options
);
9241 elsif Nkind
(A
) = N_Identifier
then
9243 if Chars
(A
) = Name_All_Checks
then
9244 Set_Default_Style_Check_Options
;
9246 elsif Chars
(A
) = Name_On
then
9247 Style_Check
:= True;
9249 elsif Chars
(A
) = Name_Off
then
9250 Style_Check
:= False;
9261 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
9263 when Pragma_Subtitle
=>
9265 Check_Arg_Count
(1);
9266 Check_Optional_Identifier
(Arg1
, Name_Subtitle
);
9267 Check_Arg_Is_String_Literal
(Arg1
);
9273 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
9275 when Pragma_Suppress
=>
9276 Process_Suppress_Unsuppress
(True);
9282 -- pragma Suppress_All;
9284 -- The only check made here is that the pragma appears in the
9285 -- proper place, i.e. following a compilation unit. If indeed
9286 -- it appears in this context, then the parser has already
9287 -- inserted an equivalent pragma Suppress (All_Checks) to get
9288 -- the required effect.
9290 when Pragma_Suppress_All
=>
9292 Check_Arg_Count
(0);
9294 if Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
9295 or else not Is_List_Member
(N
)
9296 or else List_Containing
(N
) /= Pragmas_After
(Parent
(N
))
9299 ("misplaced pragma%, must follow compilation unit");
9302 -------------------------
9303 -- Suppress_Debug_Info --
9304 -------------------------
9306 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
9308 when Pragma_Suppress_Debug_Info
=>
9310 Check_Arg_Count
(1);
9311 Check_Arg_Is_Local_Name
(Arg1
);
9312 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9313 Set_Debug_Info_Off
(Entity
(Get_Pragma_Arg
(Arg1
)));
9315 ----------------------------------
9316 -- Suppress_Exception_Locations --
9317 ----------------------------------
9319 -- pragma Suppress_Exception_Locations;
9321 when Pragma_Suppress_Exception_Locations
=>
9323 Check_Arg_Count
(0);
9324 Check_Valid_Configuration_Pragma
;
9325 Exception_Locations_Suppressed
:= True;
9327 -----------------------------
9328 -- Suppress_Initialization --
9329 -----------------------------
9331 -- pragma Suppress_Initialization ([Entity =>] type_Name);
9333 when Pragma_Suppress_Initialization
=> Suppress_Init
: declare
9339 Check_Arg_Count
(1);
9340 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9341 Check_Arg_Is_Local_Name
(Arg1
);
9343 E_Id
:= Expression
(Arg1
);
9345 if Etype
(E_Id
) = Any_Type
then
9352 if Is_Incomplete_Or_Private_Type
(E
) then
9353 if No
(Full_View
(Base_Type
(E
))) then
9355 ("argument of pragma% cannot be an incomplete type",
9358 Set_Suppress_Init_Proc
(Full_View
(Base_Type
(E
)));
9361 Set_Suppress_Init_Proc
(Base_Type
(E
));
9366 ("pragma% requires argument that is a type name", Arg1
);
9374 -- pragma System_Name (DIRECT_NAME);
9376 -- Syntax check: one argument, which must be the identifier GNAT
9377 -- or the identifier GCC, no other identifiers are acceptable.
9379 when Pragma_System_Name
=>
9380 Check_No_Identifiers
;
9381 Check_Arg_Count
(1);
9382 Check_Arg_Is_One_Of
(Arg1
, Name_Gcc
, Name_Gnat
);
9384 -----------------------------
9385 -- Task_Dispatching_Policy --
9386 -----------------------------
9388 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
9390 when Pragma_Task_Dispatching_Policy
=> declare
9394 Check_Ada_83_Warning
;
9395 Check_Arg_Count
(1);
9396 Check_No_Identifiers
;
9397 Check_Arg_Is_Task_Dispatching_Policy
(Arg1
);
9398 Check_Valid_Configuration_Pragma
;
9399 Get_Name_String
(Chars
(Expression
(Arg1
)));
9400 DP
:= Fold_Upper
(Name_Buffer
(1));
9402 if Task_Dispatching_Policy
/= ' '
9403 and then Task_Dispatching_Policy
/= DP
9405 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
9407 ("task dispatching policy incompatible with policy#");
9409 -- Set new policy, but always preserve System_Location since
9410 -- we like the error message with the run time name.
9413 Task_Dispatching_Policy
:= DP
;
9415 if Task_Dispatching_Policy_Sloc
/= System_Location
then
9416 Task_Dispatching_Policy_Sloc
:= Loc
;
9425 -- pragma Task_Info (EXPRESSION);
9427 when Pragma_Task_Info
=> Task_Info
: declare
9428 P
: constant Node_Id
:= Parent
(N
);
9433 if Nkind
(P
) /= N_Task_Definition
then
9434 Error_Pragma
("pragma% must appear in task definition");
9437 Check_No_Identifiers
;
9438 Check_Arg_Count
(1);
9440 Analyze_And_Resolve
(Expression
(Arg1
), RTE
(RE_Task_Info_Type
));
9442 if Etype
(Expression
(Arg1
)) = Any_Type
then
9446 if Has_Task_Info_Pragma
(P
) then
9447 Error_Pragma
("duplicate pragma% not allowed");
9449 Set_Has_Task_Info_Pragma
(P
, True);
9457 -- pragma Task_Name (string_EXPRESSION);
9459 when Pragma_Task_Name
=> Task_Name
: declare
9460 -- pragma Priority (EXPRESSION);
9462 P
: constant Node_Id
:= Parent
(N
);
9466 Check_No_Identifiers
;
9467 Check_Arg_Count
(1);
9469 Arg
:= Expression
(Arg1
);
9470 Analyze_And_Resolve
(Arg
, Standard_String
);
9472 if Nkind
(P
) /= N_Task_Definition
then
9476 if Has_Task_Name_Pragma
(P
) then
9477 Error_Pragma
("duplicate pragma% not allowed");
9479 Set_Has_Task_Name_Pragma
(P
, True);
9480 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
9488 -- pragma Task_Storage (
9489 -- [Task_Type =>] LOCAL_NAME,
9490 -- [Top_Guard =>] static_integer_EXPRESSION);
9492 when Pragma_Task_Storage
=> Task_Storage
: declare
9493 Args
: Args_List
(1 .. 2);
9494 Names
: constant Name_List
(1 .. 2) := (
9498 Task_Type
: Node_Id
renames Args
(1);
9499 Top_Guard
: Node_Id
renames Args
(2);
9505 Gather_Associations
(Names
, Args
);
9507 if No
(Task_Type
) then
9509 ("missing task_type argument for pragma%");
9512 Check_Arg_Is_Local_Name
(Task_Type
);
9514 Ent
:= Entity
(Task_Type
);
9516 if not Is_Task_Type
(Ent
) then
9518 ("argument for pragma% must be task type", Task_Type
);
9521 if No
(Top_Guard
) then
9523 ("pragma% takes two arguments", Task_Type
);
9525 Check_Arg_Is_Static_Expression
(Top_Guard
, Any_Integer
);
9528 Check_First_Subtype
(Task_Type
);
9530 if Rep_Item_Too_Late
(Ent
, N
) then
9539 -- pragma Thread_Body
9540 -- ( [Entity =>] LOCAL_NAME
9541 -- [,[Secondary_Stack_Size =>] static_integer_EXPRESSION]);
9543 when Pragma_Thread_Body
=> Thread_Body
: declare
9550 Check_At_Least_N_Arguments
(1);
9551 Check_At_Most_N_Arguments
(2);
9552 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9553 Check_Arg_Is_Local_Name
(Arg1
);
9555 Id
:= Expression
(Arg1
);
9557 if not Is_Entity_Name
(Id
)
9558 or else not Is_Subprogram
(Entity
(Id
))
9560 Error_Pragma_Arg
("subprogram name required", Arg1
);
9565 -- Go to renamed subprogram if present, since Thread_Body applies
9566 -- to the actual renamed entity, not to the renaming entity.
9568 if Present
(Alias
(E
))
9569 and then Nkind
(Parent
(Declaration_Node
(E
))) =
9570 N_Subprogram_Renaming_Declaration
9575 -- Various error checks
9577 if Nkind
(Parent
(Declaration_Node
(E
))) = N_Subprogram_Body
then
9579 ("pragma% requires separate spec and must come before body");
9581 elsif Rep_Item_Too_Early
(E
, N
)
9583 Rep_Item_Too_Late
(E
, N
)
9587 elsif Is_Thread_Body
(E
) then
9589 ("only one thread body pragma allowed", Arg1
);
9591 elsif Present
(Homonym
(E
))
9592 and then Scope
(Homonym
(E
)) = Current_Scope
9595 ("thread body subprogram must not be overloaded", Arg1
);
9598 Set_Is_Thread_Body
(E
);
9600 -- Deal with secondary stack argument
9602 if Arg_Count
= 2 then
9603 Check_Optional_Identifier
(Arg2
, Name_Secondary_Stack_Size
);
9604 SS
:= Expression
(Arg2
);
9605 Analyze_And_Resolve
(SS
, Any_Integer
);
9613 -- pragma Time_Slice (static_duration_EXPRESSION);
9615 when Pragma_Time_Slice
=> Time_Slice
: declare
9621 Check_Arg_Count
(1);
9622 Check_No_Identifiers
;
9623 Check_In_Main_Program
;
9624 Check_Arg_Is_Static_Expression
(Arg1
, Standard_Duration
);
9626 if not Error_Posted
(Arg1
) then
9628 while Present
(Nod
) loop
9629 if Nkind
(Nod
) = N_Pragma
9630 and then Chars
(Nod
) = Name_Time_Slice
9632 Error_Msg_Name_1
:= Chars
(N
);
9633 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
9640 -- Process only if in main unit
9642 if Get_Source_Unit
(Loc
) = Main_Unit
then
9643 Opt
.Time_Slice_Set
:= True;
9644 Val
:= Expr_Value_R
(Expression
(Arg1
));
9646 if Val
<= Ureal_0
then
9647 Opt
.Time_Slice_Value
:= 0;
9649 elsif Val
> UR_From_Uint
(UI_From_Int
(1000)) then
9650 Opt
.Time_Slice_Value
:= 1_000_000_000
;
9653 Opt
.Time_Slice_Value
:=
9654 UI_To_Int
(UR_To_Uint
(Val
* UI_From_Int
(1_000_000
)));
9663 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
9665 -- TITLING_OPTION ::=
9666 -- [Title =>] STRING_LITERAL
9667 -- | [Subtitle =>] STRING_LITERAL
9669 when Pragma_Title
=> Title
: declare
9670 Args
: Args_List
(1 .. 2);
9671 Names
: constant Name_List
(1 .. 2) := (
9677 Gather_Associations
(Names
, Args
);
9679 for J
in 1 .. 2 loop
9680 if Present
(Args
(J
)) then
9681 Check_Arg_Is_String_Literal
(Args
(J
));
9686 ---------------------
9687 -- Unchecked_Union --
9688 ---------------------
9690 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
9692 when Pragma_Unchecked_Union
=> Unchecked_Union
: declare
9693 Assoc
: constant Node_Id
:= Arg1
;
9694 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
9705 Check_No_Identifiers
;
9706 Check_Arg_Count
(1);
9707 Check_Arg_Is_Local_Name
(Arg1
);
9709 Find_Type
(Type_Id
);
9710 Typ
:= Entity
(Type_Id
);
9713 or else Rep_Item_Too_Early
(Typ
, N
)
9717 Typ
:= Underlying_Type
(Typ
);
9720 if Rep_Item_Too_Late
(Typ
, N
) then
9724 Check_First_Subtype
(Arg1
);
9726 -- Note remaining cases are references to a type in the current
9727 -- declarative part. If we find an error, we post the error on
9728 -- the relevant type declaration at an appropriate point.
9730 if not Is_Record_Type
(Typ
) then
9731 Error_Msg_N
("Unchecked_Union must be record type", Typ
);
9734 elsif Is_Tagged_Type
(Typ
) then
9735 Error_Msg_N
("Unchecked_Union must not be tagged", Typ
);
9738 elsif Is_Limited_Type
(Typ
) then
9740 ("Unchecked_Union must not be limited record type", Typ
);
9741 Explain_Limited_Type
(Typ
, Typ
);
9745 if not Has_Discriminants
(Typ
) then
9747 ("Unchecked_Union must have one discriminant", Typ
);
9751 Discr
:= First_Discriminant
(Typ
);
9753 if Present
(Next_Discriminant
(Discr
)) then
9755 ("Unchecked_Union must have exactly one discriminant",
9756 Next_Discriminant
(Discr
));
9760 if No
(Discriminant_Default_Value
(Discr
)) then
9762 ("Unchecked_Union discriminant must have default value",
9766 Tdef
:= Type_Definition
(Declaration_Node
(Typ
));
9767 Clist
:= Component_List
(Tdef
);
9769 Comp
:= First
(Component_Items
(Clist
));
9770 while Present
(Comp
) loop
9772 Check_Component
(Comp
);
9777 if No
(Clist
) or else No
(Variant_Part
(Clist
)) then
9779 ("Unchecked_Union must have variant part",
9784 Vpart
:= Variant_Part
(Clist
);
9786 Variant
:= First
(Variants
(Vpart
));
9787 while Present
(Variant
) loop
9788 Check_Variant
(Variant
);
9793 Set_Is_Unchecked_Union
(Typ
, True);
9794 Set_Convention
(Typ
, Convention_C
);
9796 Set_Has_Unchecked_Union
(Base_Type
(Typ
), True);
9797 Set_Is_Unchecked_Union
(Base_Type
(Typ
), True);
9798 end Unchecked_Union
;
9800 ------------------------
9801 -- Unimplemented_Unit --
9802 ------------------------
9804 -- pragma Unimplemented_Unit;
9806 -- Note: this only gives an error if we are generating code,
9807 -- or if we are in a generic library unit (where the pragma
9808 -- appears in the body, not in the spec).
9810 when Pragma_Unimplemented_Unit
=> Unimplemented_Unit
: declare
9811 Cunitent
: constant Entity_Id
:=
9812 Cunit_Entity
(Get_Source_Unit
(Loc
));
9813 Ent_Kind
: constant Entity_Kind
:=
9818 Check_Arg_Count
(0);
9820 if Operating_Mode
= Generate_Code
9821 or else Ent_Kind
= E_Generic_Function
9822 or else Ent_Kind
= E_Generic_Procedure
9823 or else Ent_Kind
= E_Generic_Package
9825 Get_Name_String
(Chars
(Cunitent
));
9826 Set_Casing
(Mixed_Case
);
9827 Write_Str
(Name_Buffer
(1 .. Name_Len
));
9828 Write_Str
(" is not implemented");
9830 raise Unrecoverable_Error
;
9832 end Unimplemented_Unit
;
9834 --------------------
9835 -- Universal_Data --
9836 --------------------
9838 -- pragma Universal_Data [(library_unit_NAME)];
9840 when Pragma_Universal_Data
=>
9843 -- If this is a configuration pragma, then set the universal
9844 -- addressing option, otherwise confirm that the pragma
9845 -- satisfies the requirements of library unit pragma placement
9846 -- and leave it to the GNAAMP back end to detect the pragma
9847 -- (avoids transitive setting of the option due to withed units).
9849 if Is_Configuration_Pragma
then
9850 Universal_Addressing_On_AAMP
:= True;
9852 Check_Valid_Library_Unit_Pragma
;
9855 if not AAMP_On_Target
then
9856 Error_Pragma
("?pragma% ignored (applies only to AAMP)");
9863 -- pragma Unreferenced (local_Name {, local_Name});
9865 when Pragma_Unreferenced
=> Unreferenced
: declare
9868 Arg_Ent
: Entity_Id
;
9872 Check_At_Least_N_Arguments
(1);
9875 while Present
(Arg_Node
) loop
9876 Check_No_Identifier
(Arg_Node
);
9878 -- Note that the analyze call done by Check_Arg_Is_Local_Name
9879 -- will in fact generate a reference, so that the entity will
9880 -- have a reference, which will inhibit any warnings about it
9881 -- not being referenced, and also properly show up in the ali
9882 -- file as a reference. But this reference is recorded before
9883 -- the Has_Pragma_Unreferenced flag is set, so that no warning
9884 -- is generated for this reference.
9886 Check_Arg_Is_Local_Name
(Arg_Node
);
9887 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
9889 if Is_Entity_Name
(Arg_Expr
) then
9890 Arg_Ent
:= Entity
(Arg_Expr
);
9892 -- If the entity is overloaded, the pragma applies to the
9893 -- most recent overloading, as documented. In this case,
9894 -- name resolution does not generate a reference, so it
9895 -- must be done here explicitly.
9897 if Is_Overloaded
(Arg_Expr
) then
9898 Generate_Reference
(Arg_Ent
, N
);
9901 Set_Has_Pragma_Unreferenced
(Arg_Ent
);
9908 ------------------------------
9909 -- Unreserve_All_Interrupts --
9910 ------------------------------
9912 -- pragma Unreserve_All_Interrupts;
9914 when Pragma_Unreserve_All_Interrupts
=>
9916 Check_Arg_Count
(0);
9918 if In_Extended_Main_Code_Unit
(Main_Unit_Entity
) then
9919 Unreserve_All_Interrupts
:= True;
9926 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
9928 when Pragma_Unsuppress
=>
9930 Process_Suppress_Unsuppress
(False);
9936 -- pragma Use_VADS_Size;
9938 when Pragma_Use_VADS_Size
=>
9940 Check_Arg_Count
(0);
9941 Check_Valid_Configuration_Pragma
;
9942 Use_VADS_Size
:= True;
9944 ---------------------
9945 -- Validity_Checks --
9946 ---------------------
9948 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
9950 when Pragma_Validity_Checks
=> Validity_Checks
: declare
9951 A
: constant Node_Id
:= Expression
(Arg1
);
9957 Check_Arg_Count
(1);
9958 Check_No_Identifiers
;
9960 if Nkind
(A
) = N_String_Literal
then
9964 Slen
: constant Natural := Natural (String_Length
(S
));
9965 Options
: String (1 .. Slen
);
9971 C
:= Get_String_Char
(S
, Int
(J
));
9972 exit when not In_Character_Range
(C
);
9973 Options
(J
) := Get_Character
(C
);
9976 Set_Validity_Check_Options
(Options
);
9984 elsif Nkind
(A
) = N_Identifier
then
9986 if Chars
(A
) = Name_All_Checks
then
9987 Set_Validity_Check_Options
("a");
9989 elsif Chars
(A
) = Name_On
then
9990 Validity_Checks_On
:= True;
9992 elsif Chars
(A
) = Name_Off
then
9993 Validity_Checks_On
:= False;
9997 end Validity_Checks
;
10003 -- pragma Volatile (LOCAL_NAME);
10005 when Pragma_Volatile
=>
10006 Process_Atomic_Shared_Volatile
;
10008 -------------------------
10009 -- Volatile_Components --
10010 -------------------------
10012 -- pragma Volatile_Components (array_LOCAL_NAME);
10014 -- Volatile is handled by the same circuit as Atomic_Components
10020 -- pragma Warnings (On | Off, [LOCAL_NAME])
10022 when Pragma_Warnings
=> Warnings
: begin
10024 Check_At_Least_N_Arguments
(1);
10025 Check_At_Most_N_Arguments
(2);
10026 Check_No_Identifiers
;
10028 -- One argument case was processed by parser in Par.Prag
10030 if Arg_Count
/= 1 then
10031 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
10032 Check_Arg_Count
(2);
10039 E_Id
:= Expression
(Arg2
);
10042 -- In the expansion of an inlined body, a reference to
10043 -- the formal may be wrapped in a conversion if the actual
10044 -- is a conversion. Retrieve the real entity name.
10046 if (In_Instance_Body
10047 or else In_Inlined_Body
)
10048 and then Nkind
(E_Id
) = N_Unchecked_Type_Conversion
10050 E_Id
:= Expression
(E_Id
);
10053 if not Is_Entity_Name
(E_Id
) then
10055 ("second argument of pragma% must be entity name",
10059 E
:= Entity
(E_Id
);
10065 Set_Warnings_Off
(E
,
10066 (Chars
(Expression
(Arg1
)) = Name_Off
));
10068 if Is_Enumeration_Type
(E
) then
10072 Lit
:= First_Literal
(E
);
10073 while Present
(Lit
) loop
10074 Set_Warnings_Off
(Lit
);
10075 Next_Literal
(Lit
);
10080 exit when No
(Homonym
(E
));
10088 -------------------
10089 -- Weak_External --
10090 -------------------
10092 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
10094 when Pragma_Weak_External
=> Weak_External
: declare
10099 Check_Arg_Count
(1);
10100 Check_Optional_Identifier
(Arg1
, Name_Entity
);
10101 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
10102 Ent
:= Entity
(Expression
(Arg1
));
10104 if Rep_Item_Too_Early
(Ent
, N
) then
10107 Ent
:= Underlying_Type
(Ent
);
10110 -- The only processing required is to link this item on to the
10111 -- list of rep items for the given entity. This is accomplished
10112 -- by the call to Rep_Item_Too_Late (when no error is detected
10113 -- and False is returned).
10115 if Rep_Item_Too_Late
(Ent
, N
) then
10118 Set_Has_Gigi_Rep_Item
(Ent
);
10122 --------------------
10123 -- Unknown_Pragma --
10124 --------------------
10126 -- Should be impossible, since the case of an unknown pragma is
10127 -- separately processed before the case statement is entered.
10129 when Unknown_Pragma
=>
10130 raise Program_Error
;
10134 when Pragma_Exit
=> null;
10135 end Analyze_Pragma
;
10137 ---------------------------------
10138 -- Delay_Config_Pragma_Analyze --
10139 ---------------------------------
10141 function Delay_Config_Pragma_Analyze
(N
: Node_Id
) return Boolean is
10143 return Chars
(N
) = Name_Interrupt_State
;
10144 end Delay_Config_Pragma_Analyze
;
10146 -------------------------
10147 -- Get_Base_Subprogram --
10148 -------------------------
10150 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
is
10151 Result
: Entity_Id
;
10154 -- Follow subprogram renaming chain
10157 while Is_Subprogram
(Result
)
10159 (Is_Generic_Instance
(Result
)
10160 or else Nkind
(Parent
(Declaration_Node
(Result
))) =
10161 N_Subprogram_Renaming_Declaration
)
10162 and then Present
(Alias
(Result
))
10164 Result
:= Alias
(Result
);
10168 end Get_Base_Subprogram
;
10170 -----------------------------
10171 -- Is_Config_Static_String --
10172 -----------------------------
10174 function Is_Config_Static_String
(Arg
: Node_Id
) return Boolean is
10176 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean;
10177 -- This is an internal recursive function that is just like the
10178 -- outer function except that it adds the string to the name buffer
10179 -- rather than placing the string in the name buffer.
10181 ------------------------------
10182 -- Add_Config_Static_String --
10183 ------------------------------
10185 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean is
10192 if Nkind
(N
) = N_Op_Concat
then
10193 if Add_Config_Static_String
(Left_Opnd
(N
)) then
10194 N
:= Right_Opnd
(N
);
10200 if Nkind
(N
) /= N_String_Literal
then
10201 Error_Msg_N
("string literal expected for pragma argument", N
);
10205 for J
in 1 .. String_Length
(Strval
(N
)) loop
10206 C
:= Get_String_Char
(Strval
(N
), J
);
10208 if not In_Character_Range
(C
) then
10210 ("string literal contains invalid wide character",
10211 Sloc
(N
) + 1 + Source_Ptr
(J
));
10215 Add_Char_To_Name_Buffer
(Get_Character
(C
));
10220 end Add_Config_Static_String
;
10222 -- Start of prorcessing for Is_Config_Static_String
10227 return Add_Config_Static_String
(Arg
);
10228 end Is_Config_Static_String
;
10230 -----------------------------------------
10231 -- Is_Non_Significant_Pragma_Reference --
10232 -----------------------------------------
10234 -- This function makes use of the following static table which indicates
10235 -- whether a given pragma is significant. A value of -1 in this table
10236 -- indicates that the reference is significant. A value of zero indicates
10237 -- than appearence as any argument is insignificant, a positive value
10238 -- indicates that appearence in that parameter position is significant.
10240 Sig_Flags
: constant array (Pragma_Id
) of Int
:=
10242 (Pragma_AST_Entry
=> -1,
10243 Pragma_Abort_Defer
=> -1,
10244 Pragma_Ada_83
=> -1,
10245 Pragma_Ada_95
=> -1,
10246 Pragma_Ada_05
=> -1,
10247 Pragma_All_Calls_Remote
=> -1,
10248 Pragma_Annotate
=> -1,
10249 Pragma_Assert
=> -1,
10250 Pragma_Asynchronous
=> -1,
10251 Pragma_Atomic
=> 0,
10252 Pragma_Atomic_Components
=> 0,
10253 Pragma_Attach_Handler
=> -1,
10254 Pragma_CPP_Class
=> 0,
10255 Pragma_CPP_Constructor
=> 0,
10256 Pragma_CPP_Virtual
=> 0,
10257 Pragma_CPP_Vtable
=> 0,
10258 Pragma_C_Pass_By_Copy
=> 0,
10259 Pragma_Comment
=> 0,
10260 Pragma_Common_Object
=> -1,
10261 Pragma_Compile_Time_Warning
=> -1,
10262 Pragma_Complex_Representation
=> 0,
10263 Pragma_Component_Alignment
=> -1,
10264 Pragma_Controlled
=> 0,
10265 Pragma_Convention
=> 0,
10266 Pragma_Convention_Identifier
=> 0,
10267 Pragma_Debug
=> -1,
10268 Pragma_Detect_Blocking
=> -1,
10269 Pragma_Discard_Names
=> 0,
10270 Pragma_Elaborate
=> -1,
10271 Pragma_Elaborate_All
=> -1,
10272 Pragma_Elaborate_Body
=> -1,
10273 Pragma_Elaboration_Checks
=> -1,
10274 Pragma_Eliminate
=> -1,
10275 Pragma_Explicit_Overriding
=> -1,
10276 Pragma_Export
=> -1,
10277 Pragma_Export_Exception
=> -1,
10278 Pragma_Export_Function
=> -1,
10279 Pragma_Export_Object
=> -1,
10280 Pragma_Export_Procedure
=> -1,
10281 Pragma_Export_Value
=> -1,
10282 Pragma_Export_Valued_Procedure
=> -1,
10283 Pragma_Extend_System
=> -1,
10284 Pragma_Extensions_Allowed
=> -1,
10285 Pragma_External
=> -1,
10286 Pragma_External_Name_Casing
=> -1,
10287 Pragma_Finalize_Storage_Only
=> 0,
10288 Pragma_Float_Representation
=> 0,
10289 Pragma_Ident
=> -1,
10290 Pragma_Import
=> +2,
10291 Pragma_Import_Exception
=> 0,
10292 Pragma_Import_Function
=> 0,
10293 Pragma_Import_Object
=> 0,
10294 Pragma_Import_Procedure
=> 0,
10295 Pragma_Import_Valued_Procedure
=> 0,
10296 Pragma_Initialize_Scalars
=> -1,
10297 Pragma_Inline
=> 0,
10298 Pragma_Inline_Always
=> 0,
10299 Pragma_Inline_Generic
=> 0,
10300 Pragma_Inspection_Point
=> -1,
10301 Pragma_Interface
=> +2,
10302 Pragma_Interface_Name
=> +2,
10303 Pragma_Interrupt_Handler
=> -1,
10304 Pragma_Interrupt_Priority
=> -1,
10305 Pragma_Interrupt_State
=> -1,
10306 Pragma_Java_Constructor
=> -1,
10307 Pragma_Java_Interface
=> -1,
10308 Pragma_Keep_Names
=> 0,
10309 Pragma_License
=> -1,
10310 Pragma_Link_With
=> -1,
10311 Pragma_Linker_Alias
=> -1,
10312 Pragma_Linker_Options
=> -1,
10313 Pragma_Linker_Section
=> -1,
10315 Pragma_Locking_Policy
=> -1,
10316 Pragma_Long_Float
=> -1,
10317 Pragma_Machine_Attribute
=> -1,
10319 Pragma_Main_Storage
=> -1,
10320 Pragma_Memory_Size
=> -1,
10321 Pragma_No_Return
=> 0,
10322 Pragma_No_Run_Time
=> -1,
10323 Pragma_No_Strict_Aliasing
=> -1,
10324 Pragma_Normalize_Scalars
=> -1,
10325 Pragma_Obsolescent
=> 0,
10326 Pragma_Optimize
=> -1,
10327 Pragma_Optional_Overriding
=> -1,
10328 Pragma_Overriding
=> -1,
10331 Pragma_Passive
=> -1,
10332 Pragma_Polling
=> -1,
10333 Pragma_Persistent_Data
=> -1,
10334 Pragma_Persistent_Object
=> -1,
10335 Pragma_Preelaborate
=> -1,
10336 Pragma_Priority
=> -1,
10337 Pragma_Profile
=> 0,
10338 Pragma_Profile_Warnings
=> 0,
10339 Pragma_Propagate_Exceptions
=> -1,
10340 Pragma_Psect_Object
=> -1,
10342 Pragma_Pure_Function
=> 0,
10343 Pragma_Queuing_Policy
=> -1,
10344 Pragma_Ravenscar
=> -1,
10345 Pragma_Remote_Call_Interface
=> -1,
10346 Pragma_Remote_Types
=> -1,
10347 Pragma_Restricted_Run_Time
=> -1,
10348 Pragma_Restriction_Warnings
=> -1,
10349 Pragma_Restrictions
=> -1,
10350 Pragma_Reviewable
=> -1,
10351 Pragma_Share_Generic
=> -1,
10352 Pragma_Shared
=> -1,
10353 Pragma_Shared_Passive
=> -1,
10354 Pragma_Source_File_Name
=> -1,
10355 Pragma_Source_File_Name_Project
=> -1,
10356 Pragma_Source_Reference
=> -1,
10357 Pragma_Storage_Size
=> -1,
10358 Pragma_Storage_Unit
=> -1,
10359 Pragma_Stream_Convert
=> -1,
10360 Pragma_Style_Checks
=> -1,
10361 Pragma_Subtitle
=> -1,
10362 Pragma_Suppress
=> 0,
10363 Pragma_Suppress_Exception_Locations
=> 0,
10364 Pragma_Suppress_All
=> -1,
10365 Pragma_Suppress_Debug_Info
=> 0,
10366 Pragma_Suppress_Initialization
=> 0,
10367 Pragma_System_Name
=> -1,
10368 Pragma_Task_Dispatching_Policy
=> -1,
10369 Pragma_Task_Info
=> -1,
10370 Pragma_Task_Name
=> -1,
10371 Pragma_Task_Storage
=> 0,
10372 Pragma_Thread_Body
=> +2,
10373 Pragma_Time_Slice
=> -1,
10374 Pragma_Title
=> -1,
10375 Pragma_Unchecked_Union
=> 0,
10376 Pragma_Unimplemented_Unit
=> -1,
10377 Pragma_Universal_Data
=> -1,
10378 Pragma_Unreferenced
=> -1,
10379 Pragma_Unreserve_All_Interrupts
=> -1,
10380 Pragma_Unsuppress
=> 0,
10381 Pragma_Use_VADS_Size
=> -1,
10382 Pragma_Validity_Checks
=> -1,
10383 Pragma_Volatile
=> 0,
10384 Pragma_Volatile_Components
=> 0,
10385 Pragma_Warnings
=> -1,
10386 Pragma_Weak_External
=> 0,
10387 Unknown_Pragma
=> 0);
10389 function Is_Non_Significant_Pragma_Reference
(N
: Node_Id
) return Boolean is
10397 if Nkind
(P
) /= N_Pragma_Argument_Association
then
10401 C
:= Sig_Flags
(Get_Pragma_Id
(Chars
(Parent
(P
))));
10411 A
:= First
(Pragma_Argument_Associations
(Parent
(P
)));
10412 for J
in 1 .. C
- 1 loop
10423 end Is_Non_Significant_Pragma_Reference
;
10425 ------------------------------
10426 -- Is_Pragma_String_Literal --
10427 ------------------------------
10429 -- This function returns true if the corresponding pragma argument is
10430 -- a static string expression. These are the only cases in which string
10431 -- literals can appear as pragma arguments. We also allow a string
10432 -- literal as the first argument to pragma Assert (although it will
10433 -- of course always generate a type error).
10435 function Is_Pragma_String_Literal
(Par
: Node_Id
) return Boolean is
10436 Pragn
: constant Node_Id
:= Parent
(Par
);
10437 Assoc
: constant List_Id
:= Pragma_Argument_Associations
(Pragn
);
10438 Pname
: constant Name_Id
:= Chars
(Pragn
);
10444 N
:= First
(Assoc
);
10451 if Pname
= Name_Assert
then
10454 elsif Pname
= Name_Export
then
10457 elsif Pname
= Name_Ident
then
10460 elsif Pname
= Name_Import
then
10463 elsif Pname
= Name_Interface_Name
then
10466 elsif Pname
= Name_Linker_Alias
then
10469 elsif Pname
= Name_Linker_Section
then
10472 elsif Pname
= Name_Machine_Attribute
then
10475 elsif Pname
= Name_Source_File_Name
then
10478 elsif Pname
= Name_Source_Reference
then
10481 elsif Pname
= Name_Title
then
10484 elsif Pname
= Name_Subtitle
then
10490 end Is_Pragma_String_Literal
;
10492 --------------------------------------
10493 -- Process_Compilation_Unit_Pragmas --
10494 --------------------------------------
10496 procedure Process_Compilation_Unit_Pragmas
(N
: Node_Id
) is
10498 -- A special check for pragma Suppress_All. This is a strange DEC
10499 -- pragma, strange because it comes at the end of the unit. If we
10500 -- have a pragma Suppress_All in the Pragmas_After of the current
10501 -- unit, then we insert a pragma Suppress (All_Checks) at the start
10502 -- of the context clause to ensure the correct processing.
10505 PA
: constant List_Id
:= Pragmas_After
(Aux_Decls_Node
(N
));
10509 if Present
(PA
) then
10511 while Present
(P
) loop
10512 if Chars
(P
) = Name_Suppress_All
then
10513 Prepend_To
(Context_Items
(N
),
10514 Make_Pragma
(Sloc
(P
),
10515 Chars
=> Name_Suppress
,
10516 Pragma_Argument_Associations
=> New_List
(
10517 Make_Pragma_Argument_Association
(Sloc
(P
),
10519 Make_Identifier
(Sloc
(P
),
10520 Chars
=> Name_All_Checks
)))));
10528 end Process_Compilation_Unit_Pragmas
;
10530 --------------------------------
10531 -- Set_Encoded_Interface_Name --
10532 --------------------------------
10534 procedure Set_Encoded_Interface_Name
(E
: Entity_Id
; S
: Node_Id
) is
10535 Str
: constant String_Id
:= Strval
(S
);
10536 Len
: constant Int
:= String_Length
(Str
);
10541 Hex
: constant array (0 .. 15) of Character := "0123456789abcdef";
10544 -- Stores encoded value of character code CC. The encoding we
10545 -- use an underscore followed by four lower case hex digits.
10551 procedure Encode
is
10553 Store_String_Char
(Get_Char_Code
('_'));
10555 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 12))));
10557 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 8 and 16#
0F#
))));
10559 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 4 and 16#
0F#
))));
10561 (Get_Char_Code
(Hex
(Integer (CC
and 16#
0F#
))));
10564 -- Start of processing for Set_Encoded_Interface_Name
10567 -- If first character is asterisk, this is a link name, and we
10568 -- leave it completely unmodified. We also ignore null strings
10569 -- (the latter case happens only in error cases) and no encoding
10570 -- should occur for Java interface names.
10573 or else Get_String_Char
(Str
, 1) = Get_Char_Code
('*')
10576 Set_Interface_Name
(E
, S
);
10581 CC
:= Get_String_Char
(Str
, J
);
10583 exit when not In_Character_Range
(CC
);
10585 C
:= Get_Character
(CC
);
10587 exit when C
/= '_' and then C
/= '$'
10588 and then C
not in '0' .. '9'
10589 and then C
not in 'a' .. 'z'
10590 and then C
not in 'A' .. 'Z';
10593 Set_Interface_Name
(E
, S
);
10601 -- Here we need to encode. The encoding we use as follows:
10602 -- three underscores + four hex digits (lower case)
10606 for J
in 1 .. String_Length
(Str
) loop
10607 CC
:= Get_String_Char
(Str
, J
);
10609 if not In_Character_Range
(CC
) then
10612 C
:= Get_Character
(CC
);
10614 if C
= '_' or else C
= '$'
10615 or else C
in '0' .. '9'
10616 or else C
in 'a' .. 'z'
10617 or else C
in 'A' .. 'Z'
10619 Store_String_Char
(CC
);
10626 Set_Interface_Name
(E
,
10627 Make_String_Literal
(Sloc
(S
),
10628 Strval
=> End_String
));
10630 end Set_Encoded_Interface_Name
;
10632 -------------------
10633 -- Set_Unit_Name --
10634 -------------------
10636 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
) is
10641 if Nkind
(N
) = N_Identifier
10642 and then Nkind
(With_Item
) = N_Identifier
10644 Set_Entity
(N
, Entity
(With_Item
));
10646 elsif Nkind
(N
) = N_Selected_Component
then
10647 Change_Selected_Component_To_Expanded_Name
(N
);
10648 Set_Entity
(N
, Entity
(With_Item
));
10649 Set_Entity
(Selector_Name
(N
), Entity
(N
));
10651 Pref
:= Prefix
(N
);
10652 Scop
:= Scope
(Entity
(N
));
10653 while Nkind
(Pref
) = N_Selected_Component
loop
10654 Change_Selected_Component_To_Expanded_Name
(Pref
);
10655 Set_Entity
(Selector_Name
(Pref
), Scop
);
10656 Set_Entity
(Pref
, Scop
);
10657 Pref
:= Prefix
(Pref
);
10658 Scop
:= Scope
(Scop
);
10661 Set_Entity
(Pref
, Scop
);