1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2006, 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- This unit contains the semantic processing for all pragmas, both language
28 -- and implementation defined. For most pragmas, the parser only does the
29 -- most basic job of checking the syntax, so Sem_Prag also contains the code
30 -- to complete the syntax checks. Certain pragmas are handled partially or
31 -- completely by the parser (see Par.Prag for further details).
33 with Atree
; use Atree
;
34 with Casing
; use Casing
;
35 with Csets
; use Csets
;
36 with Debug
; use Debug
;
37 with Einfo
; use Einfo
;
38 with Elists
; use Elists
;
39 with Errout
; use Errout
;
40 with Exp_Dist
; use Exp_Dist
;
41 with Hostparm
; use Hostparm
;
43 with Lib
.Writ
; use Lib
.Writ
;
44 with Lib
.Xref
; use Lib
.Xref
;
45 with Namet
; use Namet
;
46 with Nlists
; use Nlists
;
47 with Nmake
; use Nmake
;
49 with Output
; use Output
;
50 with Restrict
; use Restrict
;
51 with Rident
; use Rident
;
52 with Rtsfind
; use Rtsfind
;
54 with Sem_Ch3
; use Sem_Ch3
;
55 with Sem_Ch8
; use Sem_Ch8
;
56 with Sem_Ch13
; use Sem_Ch13
;
57 with Sem_Disp
; use Sem_Disp
;
58 with Sem_Dist
; use Sem_Dist
;
59 with Sem_Elim
; use Sem_Elim
;
60 with Sem_Eval
; use Sem_Eval
;
61 with Sem_Intr
; use Sem_Intr
;
62 with Sem_Mech
; use Sem_Mech
;
63 with Sem_Res
; use Sem_Res
;
64 with Sem_Type
; use Sem_Type
;
65 with Sem_Util
; use Sem_Util
;
66 with Sem_VFpt
; use Sem_VFpt
;
67 with Sem_Warn
; use Sem_Warn
;
68 with Stand
; use Stand
;
69 with Sinfo
; use Sinfo
;
70 with Sinfo
.CN
; use Sinfo
.CN
;
71 with Sinput
; use Sinput
;
72 with Snames
; use Snames
;
73 with Stringt
; use Stringt
;
74 with Stylesw
; use Stylesw
;
76 with Targparm
; use Targparm
;
77 with Tbuild
; use Tbuild
;
79 with Uintp
; use Uintp
;
80 with Urealp
; use Urealp
;
81 with Validsw
; use Validsw
;
83 with GNAT
.Spelling_Checker
; use GNAT
.Spelling_Checker
;
85 package body Sem_Prag
is
87 ----------------------------------------------
88 -- Common Handling of Import-Export Pragmas --
89 ----------------------------------------------
91 -- In the following section, a number of Import_xxx and Export_xxx
92 -- pragmas are defined by GNAT. These are compatible with the DEC
93 -- pragmas of the same name, and all have the following common
94 -- form and processing:
97 -- [Internal =>] LOCAL_NAME,
98 -- [, [External =>] EXTERNAL_SYMBOL]
99 -- [, other optional parameters ]);
102 -- [Internal =>] LOCAL_NAME,
103 -- [, [External =>] EXTERNAL_SYMBOL]
104 -- [, other optional parameters ]);
106 -- EXTERNAL_SYMBOL ::=
108 -- | static_string_EXPRESSION
110 -- The internal LOCAL_NAME designates the entity that is imported or
111 -- exported, and must refer to an entity in the current declarative
112 -- part (as required by the rules for LOCAL_NAME).
114 -- The external linker name is designated by the External parameter
115 -- if given, or the Internal parameter if not (if there is no External
116 -- parameter, the External parameter is a copy of the Internal name).
118 -- If the External parameter is given as a string, then this string
119 -- is treated as an external name (exactly as though it had been given
120 -- as an External_Name parameter for a normal Import pragma).
122 -- If the External parameter is given as an identifier (or there is no
123 -- External parameter, so that the Internal identifier is used), then
124 -- the external name is the characters of the identifier, translated
125 -- to all upper case letters for OpenVMS versions of GNAT, and to all
126 -- lower case letters for all other versions
128 -- Note: the external name specified or implied by any of these special
129 -- Import_xxx or Export_xxx pragmas override an external or link name
130 -- specified in a previous Import or Export pragma.
132 -- Note: these and all other DEC-compatible GNAT pragmas allow full
133 -- use of named notation, following the standard rules for subprogram
134 -- calls, i.e. parameters can be given in any order if named notation
135 -- is used, and positional and named notation can be mixed, subject to
136 -- the rule that all positional parameters must appear first.
138 -- Note: All these pragmas are implemented exactly following the DEC
139 -- design and implementation and are intended to be fully compatible
140 -- with the use of these pragmas in the DEC Ada compiler.
142 --------------------------------------------
143 -- Checking for Duplicated External Names --
144 --------------------------------------------
146 -- It is suspicious if two separate Export pragmas use the same external
147 -- name. The following table is used to diagnose this situation so that
148 -- an appropriate warning can be issued.
150 -- The Node_Id stored is for the N_String_Literal node created to
151 -- hold the value of the external name. The Sloc of this node is
152 -- used to cross-reference the location of the duplication.
154 package Externals
is new Table
.Table
(
155 Table_Component_Type
=> Node_Id
,
156 Table_Index_Type
=> Int
,
157 Table_Low_Bound
=> 0,
158 Table_Initial
=> 100,
159 Table_Increment
=> 100,
160 Table_Name
=> "Name_Externals");
162 -------------------------------------
163 -- Local Subprograms and Variables --
164 -------------------------------------
166 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
;
167 -- This routine is used for possible casing adjustment of an explicit
168 -- external name supplied as a string literal (the node N), according
169 -- to the casing requirement of Opt.External_Name_Casing. If this is
170 -- set to As_Is, then the string literal is returned unchanged, but if
171 -- it is set to Uppercase or Lowercase, then a new string literal with
172 -- appropriate casing is constructed.
174 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
;
175 -- If Def_Id refers to a renamed subprogram, then the base subprogram
176 -- (the original one, following the renaming chain) is returned.
177 -- Otherwise the entity is returned unchanged. Should be in Einfo???
179 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
);
180 -- Place semantic information on the argument of an Elaborate or
181 -- Elaborate_All pragma. Entity name for unit and its parents is
182 -- taken from item in previous with_clause that mentions the unit.
184 -------------------------------
185 -- Adjust_External_Name_Case --
186 -------------------------------
188 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
is
192 -- Adjust case of literal if required
194 if Opt
.External_Name_Exp_Casing
= As_Is
then
198 -- Copy existing string
204 for J
in 1 .. String_Length
(Strval
(N
)) loop
205 CC
:= Get_String_Char
(Strval
(N
), J
);
207 if Opt
.External_Name_Exp_Casing
= Uppercase
208 and then CC
>= Get_Char_Code
('a')
209 and then CC
<= Get_Char_Code
('z')
211 Store_String_Char
(CC
- 32);
213 elsif Opt
.External_Name_Exp_Casing
= Lowercase
214 and then CC
>= Get_Char_Code
('A')
215 and then CC
<= Get_Char_Code
('Z')
217 Store_String_Char
(CC
+ 32);
220 Store_String_Char
(CC
);
225 Make_String_Literal
(Sloc
(N
),
226 Strval
=> End_String
);
228 end Adjust_External_Name_Case
;
234 procedure Analyze_Pragma
(N
: Node_Id
) is
235 Loc
: constant Source_Ptr
:= Sloc
(N
);
238 Pragma_Exit
: exception;
239 -- This exception is used to exit pragma processing completely. It
240 -- is used when an error is detected, and no further processing is
241 -- required. It is also used if an earlier error has left the tree
242 -- in a state where the pragma should not be processed.
245 -- Number of pragma argument associations
251 -- First four pragma arguments (pragma argument association nodes,
252 -- or Empty if the corresponding argument does not exist).
254 type Name_List
is array (Natural range <>) of Name_Id
;
255 type Args_List
is array (Natural range <>) of Node_Id
;
256 -- Types used for arguments to Check_Arg_Order and Gather_Associations
258 procedure Check_Ada_83_Warning
;
259 -- Issues a warning message for the current pragma if operating in Ada
260 -- 83 mode (used for language pragmas that are not a standard part of
261 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
264 procedure Check_Arg_Count
(Required
: Nat
);
265 -- Check argument count for pragma is equal to given parameter.
266 -- If not, then issue an error message and raise Pragma_Exit.
268 -- Note: all routines whose name is Check_Arg_Is_xxx take an
269 -- argument Arg which can either be a pragma argument association,
270 -- in which case the check is applied to the expression of the
271 -- association or an expression directly.
273 procedure Check_Arg_Is_External_Name
(Arg
: Node_Id
);
274 -- Check that an argument has the right form for an EXTERNAL_NAME
275 -- parameter of an extended import/export pragma. The rule is that
276 -- the name must be an identifier or string literal (in Ada 83 mode)
277 -- or a static string expression (in Ada 95 mode).
279 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
);
280 -- Check the specified argument Arg to make sure that it is an
281 -- identifier. If not give error and raise Pragma_Exit.
283 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
);
284 -- Check the specified argument Arg to make sure that it is an
285 -- integer literal. If not give error and raise Pragma_Exit.
287 procedure Check_Arg_Is_Library_Level_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. In addition, the local
292 -- name is required to represent an entity at the library level.
294 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
);
295 -- Check the specified argument Arg to make sure that it has the
296 -- proper syntactic form for a local name and meets the semantic
297 -- requirements for a local name. The local name is analyzed as
298 -- part of the processing for this call.
300 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
);
301 -- Check the specified argument Arg to make sure that it is a valid
302 -- locking policy name. If not give error and raise Pragma_Exit.
304 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
);
305 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
, N3
: Name_Id
);
306 -- Check the specified argument Arg to make sure that it is an
307 -- identifier whose name matches either N1 or N2 (or N3 if present).
308 -- If not then give error and raise Pragma_Exit.
310 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
);
311 -- Check the specified argument Arg to make sure that it is a valid
312 -- queuing policy name. If not give error and raise Pragma_Exit.
314 procedure Check_Arg_Is_Static_Expression
317 -- Check the specified argument Arg to make sure that it is a static
318 -- expression of the given type (i.e. it will be analyzed and resolved
319 -- using this type, which can be any valid argument to Resolve, e.g.
320 -- Any_Integer is OK). If not, given error and raise Pragma_Exit.
322 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
);
323 -- Check the specified argument Arg to make sure that it is a
324 -- string literal. If not give error and raise Pragma_Exit
326 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
);
327 -- Check the specified argument Arg to make sure that it is a valid
328 -- valid task dispatching policy name. If not give error and raise
331 procedure Check_Arg_Order
(Names
: Name_List
);
332 -- Checks for an instance of two arguments with identifiers for the
333 -- current pragma which are not in the sequence indicated by Names,
334 -- and if so, generates a fatal message about bad order of arguments.
336 procedure Check_At_Least_N_Arguments
(N
: Nat
);
337 -- Check there are at least N arguments present
339 procedure Check_At_Most_N_Arguments
(N
: Nat
);
340 -- Check there are no more than N arguments present
342 procedure Check_Component
(Comp
: Node_Id
);
343 -- Examine Unchecked_Union component for correct use of per-object
344 -- constrained subtypes, and for restrictions on finalizable components.
346 procedure Check_Duplicated_Export_Name
(Nam
: Node_Id
);
347 -- Nam is an N_String_Literal node containing the external name set
348 -- by an Import or Export pragma (or extended Import or Export pragma).
349 -- This procedure checks for possible duplications if this is the
350 -- export case, and if found, issues an appropriate error message.
352 procedure Check_First_Subtype
(Arg
: Node_Id
);
353 -- Checks that Arg, whose expression is an entity name referencing
354 -- a subtype, does not reference a type that is not a first subtype.
356 procedure Check_In_Main_Program
;
357 -- Common checks for pragmas that appear within a main program
358 -- (Priority, Main_Storage, Time_Slice).
360 procedure Check_Interrupt_Or_Attach_Handler
;
361 -- Common processing for first argument of pragma Interrupt_Handler
362 -- or pragma Attach_Handler.
364 procedure Check_Is_In_Decl_Part_Or_Package_Spec
;
365 -- Check that pragma appears in a declarative part, or in a package
366 -- specification, i.e. that it does not occur in a statement sequence
369 procedure Check_No_Identifier
(Arg
: Node_Id
);
370 -- Checks that the given argument does not have an identifier. If
371 -- an identifier is present, then an error message is issued, and
372 -- Pragma_Exit is raised.
374 procedure Check_No_Identifiers
;
375 -- Checks that none of the arguments to the pragma has an identifier.
376 -- If any argument has an identifier, then an error message is issued,
377 -- and Pragma_Exit is raised.
379 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
);
380 -- Checks if the given argument has an identifier, and if so, requires
381 -- it to match the given identifier name. If there is a non-matching
382 -- identifier, then an error message is given and Error_Pragmas raised.
384 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String);
385 -- Checks if the given argument has an identifier, and if so, requires
386 -- it to match the given identifier name. If there is a non-matching
387 -- identifier, then an error message is given and Error_Pragmas raised.
388 -- In this version of the procedure, the identifier name is given as
389 -- a string with lower case letters.
391 procedure Check_Static_Constraint
(Constr
: Node_Id
);
392 -- Constr is a constraint from an N_Subtype_Indication node from a
393 -- component constraint in an Unchecked_Union type. This routine checks
394 -- that the constraint is static as required by the restrictions for
397 procedure Check_Valid_Configuration_Pragma
;
398 -- Legality checks for placement of a configuration pragma
400 procedure Check_Valid_Library_Unit_Pragma
;
401 -- Legality checks for library unit pragmas. A special case arises for
402 -- pragmas in generic instances that come from copies of the original
403 -- library unit pragmas in the generic templates. In the case of other
404 -- than library level instantiations these can appear in contexts which
405 -- would normally be invalid (they only apply to the original template
406 -- and to library level instantiations), and they are simply ignored,
407 -- which is implemented by rewriting them as null statements.
409 procedure Check_Variant
(Variant
: Node_Id
);
410 -- Check Unchecked_Union variant for lack of nested variants and
411 -- presence of at least one component.
413 procedure Error_Pragma
(Msg
: String);
414 pragma No_Return
(Error_Pragma
);
415 -- Outputs error message for current pragma. The message contains an %
416 -- that will be replaced with the pragma name, and the flag is placed
417 -- on the pragma itself. Pragma_Exit is then raised.
419 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
);
420 pragma No_Return
(Error_Pragma_Arg
);
421 -- Outputs error message for current pragma. The message may contain
422 -- a % that will be replaced with the pragma name. The parameter Arg
423 -- may either be a pragma argument association, in which case the flag
424 -- is placed on the expression of this association, or an expression,
425 -- in which case the flag is placed directly on the expression. The
426 -- message is placed using Error_Msg_N, so the message may also contain
427 -- an & insertion character which will reference the given Arg value.
428 -- After placing the message, Pragma_Exit is raised.
430 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
);
431 pragma No_Return
(Error_Pragma_Arg
);
432 -- Similar to above form of Error_Pragma_Arg except that two messages
433 -- are provided, the second is a continuation comment starting with \.
435 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
);
436 pragma No_Return
(Error_Pragma_Arg_Ident
);
437 -- Outputs error message for current pragma. The message may contain
438 -- a % that will be replaced with the pragma name. The parameter Arg
439 -- must be a pragma argument association with a non-empty identifier
440 -- (i.e. its Chars field must be set), and the error message is placed
441 -- on the identifier. The message is placed using Error_Msg_N so
442 -- the message may also contain an & insertion character which will
443 -- reference the identifier. After placing the message, Pragma_Exit
446 function Find_Lib_Unit_Name
return Entity_Id
;
447 -- Used for a library unit pragma to find the entity to which the
448 -- library unit pragma applies, returns the entity found.
450 procedure Find_Program_Unit_Name
(Id
: Node_Id
);
451 -- If the pragma is a compilation unit pragma, the id must denote the
452 -- compilation unit in the same compilation, and the pragma must appear
453 -- in the list of preceding or trailing pragmas. If it is a program
454 -- unit pragma that is not a compilation unit pragma, then the
455 -- identifier must be visible.
457 function Find_Unique_Parameterless_Procedure
459 Arg
: Node_Id
) return Entity_Id
;
460 -- Used for a procedure pragma to find the unique parameterless
461 -- procedure identified by Name, returns it if it exists, otherwise
462 -- errors out and uses Arg as the pragma argument for the message.
464 procedure Gather_Associations
466 Args
: out Args_List
);
467 -- This procedure is used to gather the arguments for a pragma that
468 -- permits arbitrary ordering of parameters using the normal rules
469 -- for named and positional parameters. The Names argument is a list
470 -- of Name_Id values that corresponds to the allowed pragma argument
471 -- association identifiers in order. The result returned in Args is
472 -- a list of corresponding expressions that are the pragma arguments.
473 -- Note that this is a list of expressions, not of pragma argument
474 -- associations (Gather_Associations has completely checked all the
475 -- optional identifiers when it returns). An entry in Args is Empty
476 -- on return if the corresponding argument is not present.
478 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
;
479 -- All the routines that check pragma arguments take either a pragma
480 -- argument association (in which case the expression of the argument
481 -- association is checked), or the expression directly. The function
482 -- Get_Pragma_Arg is a utility used to deal with these two cases. If
483 -- Arg is a pragma argument association node, then its expression is
484 -- returned, otherwise Arg is returned unchanged.
486 procedure GNAT_Pragma
;
487 -- Called for all GNAT defined pragmas to note the use of the feature,
488 -- and also check the relevant restriction (No_Implementation_Pragmas).
490 function Is_Before_First_Decl
491 (Pragma_Node
: Node_Id
;
492 Decls
: List_Id
) return Boolean;
493 -- Return True if Pragma_Node is before the first declarative item in
494 -- Decls where Decls is the list of declarative items.
496 function Is_Configuration_Pragma
return Boolean;
497 -- Deterermines if the placement of the current pragma is appropriate
498 -- for a configuration pragma (precedes the current compilation unit)
500 procedure Pragma_Misplaced
;
501 -- Issue fatal error message for misplaced pragma
503 procedure Process_Atomic_Shared_Volatile
;
504 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
505 -- Shared is an obsolete Ada 83 pragma, treated as being identical
506 -- in effect to pragma Atomic.
508 procedure Process_Convention
(C
: out Convention_Id
; E
: out Entity_Id
);
509 -- Common procesing for Convention, Interface, Import and Export.
510 -- Checks first two arguments of pragma, and sets the appropriate
511 -- convention value in the specified entity or entities. On return
512 -- C is the convention, E is the referenced entity.
514 procedure Process_Extended_Import_Export_Exception_Pragma
515 (Arg_Internal
: Node_Id
;
516 Arg_External
: Node_Id
;
519 -- Common processing for the pragmas Import/Export_Exception.
520 -- The three arguments correspond to the three named parameters of
521 -- the pragma. An argument is empty if the corresponding parameter
522 -- is not present in the pragma.
524 procedure Process_Extended_Import_Export_Object_Pragma
525 (Arg_Internal
: Node_Id
;
526 Arg_External
: Node_Id
;
528 -- Common processing for the pragmass Import/Export_Object.
529 -- The three arguments correspond to the three named parameters
530 -- of the pragmas. An argument is empty if the corresponding
531 -- parameter is not present in the pragma.
533 procedure Process_Extended_Import_Export_Internal_Arg
534 (Arg_Internal
: Node_Id
:= Empty
);
535 -- Common processing for all extended Import and Export pragmas. The
536 -- argument is the pragma parameter for the Internal argument. If
537 -- Arg_Internal is empty or inappropriate, an error message is posted.
538 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
539 -- set to identify the referenced entity.
541 procedure Process_Extended_Import_Export_Subprogram_Pragma
542 (Arg_Internal
: Node_Id
;
543 Arg_External
: Node_Id
;
544 Arg_Parameter_Types
: Node_Id
;
545 Arg_Result_Type
: Node_Id
:= Empty
;
546 Arg_Mechanism
: Node_Id
;
547 Arg_Result_Mechanism
: Node_Id
:= Empty
;
548 Arg_First_Optional_Parameter
: Node_Id
:= Empty
);
549 -- Common processing for all extended Import and Export pragmas
550 -- applying to subprograms. The caller omits any arguments that do
551 -- bnot apply to the pragma in question (for example, Arg_Result_Type
552 -- can be non-Empty only in the Import_Function and Export_Function
553 -- cases). The argument names correspond to the allowed pragma
554 -- association identifiers.
556 procedure Process_Generic_List
;
557 -- Common processing for Share_Generic and Inline_Generic
559 procedure Process_Import_Or_Interface
;
560 -- Common processing for Import of Interface
562 procedure Process_Inline
(Active
: Boolean);
563 -- Common processing for Inline and Inline_Always. The parameter
564 -- indicates if the inline pragma is active, i.e. if it should
565 -- actually cause inlining to occur.
567 procedure Process_Interface_Name
568 (Subprogram_Def
: Entity_Id
;
571 -- Given the last two arguments of pragma Import, pragma Export, or
572 -- pragma Interface_Name, performs validity checks and sets the
573 -- Interface_Name field of the given subprogram entity to the
574 -- appropriate external or link name, depending on the arguments
575 -- given. Ext_Arg is always present, but Link_Arg may be missing.
576 -- Note that Ext_Arg may represent the Link_Name if Link_Arg is
577 -- missing, and appropriate named notation is used for Ext_Arg.
578 -- If neither Ext_Arg nor Link_Arg is present, the interface name
579 -- is set to the default from the subprogram name.
581 procedure Process_Interrupt_Or_Attach_Handler
;
582 -- Common processing for Interrupt and Attach_Handler pragmas
584 procedure Process_Restrictions_Or_Restriction_Warnings
;
585 -- Common processing for Restrictions and Restriction_Warnings pragmas
587 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean);
588 -- Common processing for Suppress and Unsuppress. The boolean parameter
589 -- Suppress_Case is True for the Suppress case, and False for the
592 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
);
593 -- This procedure sets the Is_Exported flag for the given entity,
594 -- checking that the entity was not previously imported. Arg is
595 -- the argument that specified the entity. A check is also made
596 -- for exporting inappropriate entities.
598 procedure Set_Extended_Import_Export_External_Name
599 (Internal_Ent
: Entity_Id
;
600 Arg_External
: Node_Id
);
601 -- Common processing for all extended import export pragmas. The first
602 -- argument, Internal_Ent, is the internal entity, which has already
603 -- been checked for validity by the caller. Arg_External is from the
604 -- Import or Export pragma, and may be null if no External parameter
605 -- was present. If Arg_External is present and is a non-null string
606 -- (a null string is treated as the default), then the Interface_Name
607 -- field of Internal_Ent is set appropriately.
609 procedure Set_Imported
(E
: Entity_Id
);
610 -- This procedure sets the Is_Imported flag for the given entity,
611 -- checking that it is not previously exported or imported.
613 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
);
614 -- Mech is a parameter passing mechanism (see Import_Function syntax
615 -- for MECHANISM_NAME). This routine checks that the mechanism argument
616 -- has the right form, and if not issues an error message. If the
617 -- argument has the right form then the Mechanism field of Ent is
618 -- set appropriately.
620 procedure Set_Ravenscar_Profile
(N
: Node_Id
);
621 -- Activate the set of configuration pragmas and restrictions that
622 -- make up the Ravenscar Profile. N is the corresponding pragma
623 -- node, which is used for error messages on any constructs
624 -- that violate the profile.
626 --------------------------
627 -- Check_Ada_83_Warning --
628 --------------------------
630 procedure Check_Ada_83_Warning
is
632 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
633 Error_Msg_N
("(Ada 83) pragma& is non-standard?", N
);
635 end Check_Ada_83_Warning
;
637 ---------------------
638 -- Check_Arg_Count --
639 ---------------------
641 procedure Check_Arg_Count
(Required
: Nat
) is
643 if Arg_Count
/= Required
then
644 Error_Pragma
("wrong number of arguments for pragma%");
648 --------------------------------
649 -- Check_Arg_Is_External_Name --
650 --------------------------------
652 procedure Check_Arg_Is_External_Name
(Arg
: Node_Id
) is
653 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
656 if Nkind
(Argx
) = N_Identifier
then
660 Analyze_And_Resolve
(Argx
, Standard_String
);
662 if Is_OK_Static_Expression
(Argx
) then
665 elsif Etype
(Argx
) = Any_Type
then
668 -- An interesting special case, if we have a string literal and
669 -- we are in Ada 83 mode, then we allow it even though it will
670 -- not be flagged as static. This allows expected Ada 83 mode
671 -- use of external names which are string literals, even though
672 -- technically these are not static in Ada 83.
674 elsif Ada_Version
= Ada_83
675 and then Nkind
(Argx
) = N_String_Literal
679 -- Static expression that raises Constraint_Error. This has
680 -- already been flagged, so just exit from pragma processing.
682 elsif Is_Static_Expression
(Argx
) then
685 -- Here we have a real error (non-static expression)
688 Error_Msg_Name_1
:= Chars
(N
);
690 ("argument for pragma% must be a identifier or " &
691 "static string expression!", Argx
);
695 end Check_Arg_Is_External_Name
;
697 -----------------------------
698 -- Check_Arg_Is_Identifier --
699 -----------------------------
701 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
) is
702 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
704 if Nkind
(Argx
) /= N_Identifier
then
706 ("argument for pragma% must be identifier", Argx
);
708 end Check_Arg_Is_Identifier
;
710 ----------------------------------
711 -- Check_Arg_Is_Integer_Literal --
712 ----------------------------------
714 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
) is
715 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
717 if Nkind
(Argx
) /= N_Integer_Literal
then
719 ("argument for pragma% must be integer literal", Argx
);
721 end Check_Arg_Is_Integer_Literal
;
723 -------------------------------------------
724 -- Check_Arg_Is_Library_Level_Local_Name --
725 -------------------------------------------
729 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
730 -- | library_unit_NAME
732 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
) is
734 Check_Arg_Is_Local_Name
(Arg
);
736 if not Is_Library_Level_Entity
(Entity
(Expression
(Arg
)))
737 and then Comes_From_Source
(N
)
740 ("argument for pragma% must be library level entity", Arg
);
742 end Check_Arg_Is_Library_Level_Local_Name
;
744 -----------------------------
745 -- Check_Arg_Is_Local_Name --
746 -----------------------------
750 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
751 -- | library_unit_NAME
753 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
) is
754 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
759 if Nkind
(Argx
) not in N_Direct_Name
760 and then (Nkind
(Argx
) /= N_Attribute_Reference
761 or else Present
(Expressions
(Argx
))
762 or else Nkind
(Prefix
(Argx
)) /= N_Identifier
)
763 and then (not Is_Entity_Name
(Argx
)
764 or else not Is_Compilation_Unit
(Entity
(Argx
)))
766 Error_Pragma_Arg
("argument for pragma% must be local name", Argx
);
769 if Is_Entity_Name
(Argx
)
770 and then Scope
(Entity
(Argx
)) /= Current_Scope
773 ("pragma% argument must be in same declarative part", Arg
);
775 end Check_Arg_Is_Local_Name
;
777 ---------------------------------
778 -- Check_Arg_Is_Locking_Policy --
779 ---------------------------------
781 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
) is
782 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
785 Check_Arg_Is_Identifier
(Argx
);
787 if not Is_Locking_Policy_Name
(Chars
(Argx
)) then
789 ("& is not a valid locking policy name", Argx
);
791 end Check_Arg_Is_Locking_Policy
;
793 -------------------------
794 -- Check_Arg_Is_One_Of --
795 -------------------------
797 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
) is
798 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
801 Check_Arg_Is_Identifier
(Argx
);
803 if Chars
(Argx
) /= N1
and then Chars
(Argx
) /= N2
then
804 Error_Msg_Name_2
:= N1
;
805 Error_Msg_Name_3
:= N2
;
806 Error_Pragma_Arg
("argument for pragma% must be% or%", Argx
);
808 end Check_Arg_Is_One_Of
;
810 procedure Check_Arg_Is_One_Of
812 N1
, N2
, N3
: Name_Id
)
814 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
817 Check_Arg_Is_Identifier
(Argx
);
819 if Chars
(Argx
) /= N1
820 and then Chars
(Argx
) /= N2
821 and then Chars
(Argx
) /= N3
823 Error_Pragma_Arg
("invalid argument for pragma%", Argx
);
825 end Check_Arg_Is_One_Of
;
827 ---------------------------------
828 -- Check_Arg_Is_Queuing_Policy --
829 ---------------------------------
831 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
) is
832 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
835 Check_Arg_Is_Identifier
(Argx
);
837 if not Is_Queuing_Policy_Name
(Chars
(Argx
)) then
839 ("& is not a valid queuing policy name", Argx
);
841 end Check_Arg_Is_Queuing_Policy
;
843 ------------------------------------
844 -- Check_Arg_Is_Static_Expression --
845 ------------------------------------
847 procedure Check_Arg_Is_Static_Expression
851 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
854 Analyze_And_Resolve
(Argx
, Typ
);
856 if Is_OK_Static_Expression
(Argx
) then
859 elsif Etype
(Argx
) = Any_Type
then
862 -- An interesting special case, if we have a string literal and
863 -- we are in Ada 83 mode, then we allow it even though it will
864 -- not be flagged as static. This allows the use of Ada 95
865 -- pragmas like Import in Ada 83 mode. They will of course be
866 -- flagged with warnings as usual, but will not cause errors.
868 elsif Ada_Version
= Ada_83
869 and then Nkind
(Argx
) = N_String_Literal
873 -- Static expression that raises Constraint_Error. This has
874 -- already been flagged, so just exit from pragma processing.
876 elsif Is_Static_Expression
(Argx
) then
879 -- Finally, we have a real error
882 Error_Msg_Name_1
:= Chars
(N
);
884 ("argument for pragma% must be a static expression!", Argx
);
887 end Check_Arg_Is_Static_Expression
;
889 ---------------------------------
890 -- Check_Arg_Is_String_Literal --
891 ---------------------------------
893 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
) is
894 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
896 if Nkind
(Argx
) /= N_String_Literal
then
898 ("argument for pragma% must be string literal", Argx
);
900 end Check_Arg_Is_String_Literal
;
902 ------------------------------------------
903 -- Check_Arg_Is_Task_Dispatching_Policy --
904 ------------------------------------------
906 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
) is
907 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
910 Check_Arg_Is_Identifier
(Argx
);
912 if not Is_Task_Dispatching_Policy_Name
(Chars
(Argx
)) then
914 ("& is not a valid task dispatching policy name", Argx
);
916 end Check_Arg_Is_Task_Dispatching_Policy
;
918 ---------------------
919 -- Check_Arg_Order --
920 ---------------------
922 procedure Check_Arg_Order
(Names
: Name_List
) is
925 Highest_So_Far
: Natural := 0;
926 -- Highest index in Names seen do far
930 for J
in 1 .. Arg_Count
loop
931 if Chars
(Arg
) /= No_Name
then
932 for K
in Names
'Range loop
933 if Chars
(Arg
) = Names
(K
) then
934 if K
< Highest_So_Far
then
935 Error_Msg_Name_1
:= Chars
(N
);
937 ("parameters out of order for pragma%", Arg
);
938 Error_Msg_Name_1
:= Names
(K
);
939 Error_Msg_Name_2
:= Names
(Highest_So_Far
);
940 Error_Msg_N
("\% must appear before %", Arg
);
954 --------------------------------
955 -- Check_At_Least_N_Arguments --
956 --------------------------------
958 procedure Check_At_Least_N_Arguments
(N
: Nat
) is
960 if Arg_Count
< N
then
961 Error_Pragma
("too few arguments for pragma%");
963 end Check_At_Least_N_Arguments
;
965 -------------------------------
966 -- Check_At_Most_N_Arguments --
967 -------------------------------
969 procedure Check_At_Most_N_Arguments
(N
: Nat
) is
972 if Arg_Count
> N
then
976 Error_Pragma_Arg
("too many arguments for pragma%", Arg
);
979 end Check_At_Most_N_Arguments
;
981 ---------------------
982 -- Check_Component --
983 ---------------------
985 procedure Check_Component
(Comp
: Node_Id
) is
987 if Nkind
(Comp
) = N_Component_Declaration
then
989 Sindic
: constant Node_Id
:=
990 Subtype_Indication
(Component_Definition
(Comp
));
991 Typ
: constant Entity_Id
:=
992 Etype
(Defining_Identifier
(Comp
));
994 if Nkind
(Sindic
) = N_Subtype_Indication
then
996 -- Ada 2005 (AI-216): If a component subtype is subject to
997 -- a per-object constraint, then the component type shall
998 -- be an Unchecked_Union.
1000 if Has_Per_Object_Constraint
(Defining_Identifier
(Comp
))
1002 not Is_Unchecked_Union
(Etype
(Subtype_Mark
(Sindic
)))
1004 Error_Msg_N
("component subtype subject to per-object" &
1005 " constraint must be an Unchecked_Union", Comp
);
1009 if Is_Controlled
(Typ
) then
1011 ("component of unchecked union cannot be controlled", Comp
);
1013 elsif Has_Task
(Typ
) then
1015 ("component of unchecked union cannot have tasks", Comp
);
1019 end Check_Component
;
1021 ----------------------------------
1022 -- Check_Duplicated_Export_Name --
1023 ----------------------------------
1025 procedure Check_Duplicated_Export_Name
(Nam
: Node_Id
) is
1026 String_Val
: constant String_Id
:= Strval
(Nam
);
1029 -- We are only interested in the export case, and in the case of
1030 -- generics, it is the instance, not the template, that is the
1031 -- problem (the template will generate a warning in any case).
1033 if not Inside_A_Generic
1034 and then (Prag_Id
= Pragma_Export
1036 Prag_Id
= Pragma_Export_Procedure
1038 Prag_Id
= Pragma_Export_Valued_Procedure
1040 Prag_Id
= Pragma_Export_Function
)
1042 for J
in Externals
.First
.. Externals
.Last
loop
1043 if String_Equal
(String_Val
, Strval
(Externals
.Table
(J
))) then
1044 Error_Msg_Sloc
:= Sloc
(Externals
.Table
(J
));
1045 Error_Msg_N
("external name duplicates name given#", Nam
);
1050 Externals
.Append
(Nam
);
1052 end Check_Duplicated_Export_Name
;
1054 -------------------------
1055 -- Check_First_Subtype --
1056 -------------------------
1058 procedure Check_First_Subtype
(Arg
: Node_Id
) is
1059 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1061 if not Is_First_Subtype
(Entity
(Argx
)) then
1063 ("pragma% cannot apply to subtype", Argx
);
1065 end Check_First_Subtype
;
1067 ---------------------------
1068 -- Check_In_Main_Program --
1069 ---------------------------
1071 procedure Check_In_Main_Program
is
1072 P
: constant Node_Id
:= Parent
(N
);
1075 -- Must be at in subprogram body
1077 if Nkind
(P
) /= N_Subprogram_Body
then
1078 Error_Pragma
("% pragma allowed only in subprogram");
1080 -- Otherwise warn if obviously not main program
1082 elsif Present
(Parameter_Specifications
(Specification
(P
)))
1083 or else not Is_Compilation_Unit
(Defining_Entity
(P
))
1085 Error_Msg_Name_1
:= Chars
(N
);
1087 ("?pragma% is only effective in main program", N
);
1089 end Check_In_Main_Program
;
1091 ---------------------------------------
1092 -- Check_Interrupt_Or_Attach_Handler --
1093 ---------------------------------------
1095 procedure Check_Interrupt_Or_Attach_Handler
is
1096 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
1097 Handler_Proc
, Proc_Scope
: Entity_Id
;
1102 if Prag_Id
= Pragma_Interrupt_Handler
then
1103 Check_Restriction
(No_Dynamic_Attachment
, N
);
1106 Handler_Proc
:= Find_Unique_Parameterless_Procedure
(Arg1_X
, Arg1
);
1107 Proc_Scope
:= Scope
(Handler_Proc
);
1109 -- On AAMP only, a pragma Interrupt_Handler is supported for
1110 -- nonprotected parameterless procedures.
1112 if not AAMP_On_Target
1113 or else Prag_Id
= Pragma_Attach_Handler
1115 if Ekind
(Proc_Scope
) /= E_Protected_Type
then
1117 ("argument of pragma% must be protected procedure", Arg1
);
1120 if Parent
(N
) /= Protected_Definition
(Parent
(Proc_Scope
)) then
1121 Error_Pragma
("pragma% must be in protected definition");
1125 if not Is_Library_Level_Entity
(Proc_Scope
)
1126 or else (AAMP_On_Target
1127 and then not Is_Library_Level_Entity
(Handler_Proc
))
1130 ("argument for pragma% must be library level entity", Arg1
);
1132 end Check_Interrupt_Or_Attach_Handler
;
1134 -------------------------------------------
1135 -- Check_Is_In_Decl_Part_Or_Package_Spec --
1136 -------------------------------------------
1138 procedure Check_Is_In_Decl_Part_Or_Package_Spec
is
1147 elsif Nkind
(P
) = N_Handled_Sequence_Of_Statements
then
1150 elsif Nkind
(P
) = N_Package_Specification
then
1153 elsif Nkind
(P
) = N_Block_Statement
then
1156 -- Note: the following tests seem a little peculiar, because
1157 -- they test for bodies, but if we were in the statement part
1158 -- of the body, we would already have hit the handled statement
1159 -- sequence, so the only way we get here is by being in the
1160 -- declarative part of the body.
1162 elsif Nkind
(P
) = N_Subprogram_Body
1163 or else Nkind
(P
) = N_Package_Body
1164 or else Nkind
(P
) = N_Task_Body
1165 or else Nkind
(P
) = N_Entry_Body
1173 Error_Pragma
("pragma% is not in declarative part or package spec");
1174 end Check_Is_In_Decl_Part_Or_Package_Spec
;
1176 -------------------------
1177 -- Check_No_Identifier --
1178 -------------------------
1180 procedure Check_No_Identifier
(Arg
: Node_Id
) is
1182 if Chars
(Arg
) /= No_Name
then
1183 Error_Pragma_Arg_Ident
1184 ("pragma% does not permit identifier& here", Arg
);
1186 end Check_No_Identifier
;
1188 --------------------------
1189 -- Check_No_Identifiers --
1190 --------------------------
1192 procedure Check_No_Identifiers
is
1195 if Arg_Count
> 0 then
1197 while Present
(Arg_Node
) loop
1198 Check_No_Identifier
(Arg_Node
);
1202 end Check_No_Identifiers
;
1204 -------------------------------
1205 -- Check_Optional_Identifier --
1206 -------------------------------
1208 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
) is
1210 if Present
(Arg
) and then Chars
(Arg
) /= No_Name
then
1211 if Chars
(Arg
) /= Id
then
1212 Error_Msg_Name_1
:= Chars
(N
);
1213 Error_Msg_Name_2
:= Id
;
1214 Error_Msg_N
("pragma% argument expects identifier%", Arg
);
1218 end Check_Optional_Identifier
;
1220 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String) is
1222 Name_Buffer
(1 .. Id
'Length) := Id
;
1223 Name_Len
:= Id
'Length;
1224 Check_Optional_Identifier
(Arg
, Name_Find
);
1225 end Check_Optional_Identifier
;
1227 -----------------------------
1228 -- Check_Static_Constraint --
1229 -----------------------------
1231 -- Note: for convenience in writing this procedure, in addition to
1232 -- the officially (i.e. by spec) allowed argument which is always
1233 -- a constraint, it also allows ranges and discriminant associations.
1234 -- Above is not clear ???
1236 procedure Check_Static_Constraint
(Constr
: Node_Id
) is
1238 --------------------
1239 -- Require_Static --
1240 --------------------
1242 procedure Require_Static
(E
: Node_Id
);
1243 -- Require given expression to be static expression
1245 procedure Require_Static
(E
: Node_Id
) is
1247 if not Is_OK_Static_Expression
(E
) then
1248 Flag_Non_Static_Expr
1249 ("non-static constraint not allowed in Unchecked_Union!", E
);
1254 -- Start of processing for Check_Static_Constraint
1257 case Nkind
(Constr
) is
1258 when N_Discriminant_Association
=>
1259 Require_Static
(Expression
(Constr
));
1262 Require_Static
(Low_Bound
(Constr
));
1263 Require_Static
(High_Bound
(Constr
));
1265 when N_Attribute_Reference
=>
1266 Require_Static
(Type_Low_Bound
(Etype
(Prefix
(Constr
))));
1267 Require_Static
(Type_High_Bound
(Etype
(Prefix
(Constr
))));
1269 when N_Range_Constraint
=>
1270 Check_Static_Constraint
(Range_Expression
(Constr
));
1272 when N_Index_Or_Discriminant_Constraint
=>
1276 IDC
:= First
(Constraints
(Constr
));
1277 while Present
(IDC
) loop
1278 Check_Static_Constraint
(IDC
);
1286 end Check_Static_Constraint
;
1288 --------------------------------------
1289 -- Check_Valid_Configuration_Pragma --
1290 --------------------------------------
1292 -- A configuration pragma must appear in the context clause of
1293 -- a compilation unit, at the start of the list (i.e. only other
1294 -- pragmas may precede it).
1296 procedure Check_Valid_Configuration_Pragma
is
1298 if not Is_Configuration_Pragma
then
1299 Error_Pragma
("incorrect placement for configuration pragma%");
1301 end Check_Valid_Configuration_Pragma
;
1303 -------------------------------------
1304 -- Check_Valid_Library_Unit_Pragma --
1305 -------------------------------------
1307 procedure Check_Valid_Library_Unit_Pragma
is
1309 Parent_Node
: Node_Id
;
1310 Unit_Name
: Entity_Id
;
1311 Unit_Kind
: Node_Kind
;
1312 Unit_Node
: Node_Id
;
1313 Sindex
: Source_File_Index
;
1316 if not Is_List_Member
(N
) then
1320 Plist
:= List_Containing
(N
);
1321 Parent_Node
:= Parent
(Plist
);
1323 if Parent_Node
= Empty
then
1326 -- Case of pragma appearing after a compilation unit. In this
1327 -- case it must have an argument with the corresponding name
1328 -- and must be part of the following pragmas of its parent.
1330 elsif Nkind
(Parent_Node
) = N_Compilation_Unit_Aux
then
1331 if Plist
/= Pragmas_After
(Parent_Node
) then
1334 elsif Arg_Count
= 0 then
1336 ("argument required if outside compilation unit");
1339 Check_No_Identifiers
;
1340 Check_Arg_Count
(1);
1341 Unit_Node
:= Unit
(Parent
(Parent_Node
));
1342 Unit_Kind
:= Nkind
(Unit_Node
);
1344 Analyze
(Expression
(Arg1
));
1346 if Unit_Kind
= N_Generic_Subprogram_Declaration
1347 or else Unit_Kind
= N_Subprogram_Declaration
1349 Unit_Name
:= Defining_Entity
(Unit_Node
);
1351 elsif Unit_Kind
in N_Generic_Instantiation
then
1352 Unit_Name
:= Defining_Entity
(Unit_Node
);
1355 Unit_Name
:= Cunit_Entity
(Current_Sem_Unit
);
1358 if Chars
(Unit_Name
) /=
1359 Chars
(Entity
(Expression
(Arg1
)))
1362 ("pragma% argument is not current unit name", Arg1
);
1365 if Ekind
(Unit_Name
) = E_Package
1366 and then Present
(Renamed_Entity
(Unit_Name
))
1368 Error_Pragma
("pragma% not allowed for renamed package");
1372 -- Pragma appears other than after a compilation unit
1375 -- Here we check for the generic instantiation case and also
1376 -- for the case of processing a generic formal package. We
1377 -- detect these cases by noting that the Sloc on the node
1378 -- does not belong to the current compilation unit.
1380 Sindex
:= Source_Index
(Current_Sem_Unit
);
1382 if Loc
not in Source_First
(Sindex
) .. Source_Last
(Sindex
) then
1383 Rewrite
(N
, Make_Null_Statement
(Loc
));
1386 -- If before first declaration, the pragma applies to the
1387 -- enclosing unit, and the name if present must be this name.
1389 elsif Is_Before_First_Decl
(N
, Plist
) then
1390 Unit_Node
:= Unit_Declaration_Node
(Current_Scope
);
1391 Unit_Kind
:= Nkind
(Unit_Node
);
1393 if Nkind
(Parent
(Unit_Node
)) /= N_Compilation_Unit
then
1396 elsif Unit_Kind
= N_Subprogram_Body
1397 and then not Acts_As_Spec
(Unit_Node
)
1401 elsif Nkind
(Parent_Node
) = N_Package_Body
then
1404 elsif Nkind
(Parent_Node
) = N_Package_Specification
1405 and then Plist
= Private_Declarations
(Parent_Node
)
1409 elsif (Nkind
(Parent_Node
) = N_Generic_Package_Declaration
1410 or else Nkind
(Parent_Node
)
1411 = N_Generic_Subprogram_Declaration
)
1412 and then Plist
= Generic_Formal_Declarations
(Parent_Node
)
1416 elsif Arg_Count
> 0 then
1417 Analyze
(Expression
(Arg1
));
1419 if Entity
(Expression
(Arg1
)) /= Current_Scope
then
1421 ("name in pragma% must be enclosing unit", Arg1
);
1424 -- It is legal to have no argument in this context
1430 -- Error if not before first declaration. This is because a
1431 -- library unit pragma argument must be the name of a library
1432 -- unit (RM 10.1.5(7)), but the only names permitted in this
1433 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1434 -- generic subprogram declarations or generic instantiations.
1438 ("pragma% misplaced, must be before first declaration");
1442 end Check_Valid_Library_Unit_Pragma
;
1448 procedure Check_Variant
(Variant
: Node_Id
) is
1449 Clist
: constant Node_Id
:= Component_List
(Variant
);
1453 if not Is_Non_Empty_List
(Component_Items
(Clist
)) then
1455 ("Unchecked_Union may not have empty component list",
1460 Comp
:= First
(Component_Items
(Clist
));
1461 while Present
(Comp
) loop
1462 Check_Component
(Comp
);
1471 procedure Error_Pragma
(Msg
: String) is
1473 Error_Msg_Name_1
:= Chars
(N
);
1474 Error_Msg_N
(Msg
, N
);
1478 ----------------------
1479 -- Error_Pragma_Arg --
1480 ----------------------
1482 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
) is
1484 Error_Msg_Name_1
:= Chars
(N
);
1485 Error_Msg_N
(Msg
, Get_Pragma_Arg
(Arg
));
1487 end Error_Pragma_Arg
;
1489 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
) is
1491 Error_Msg_Name_1
:= Chars
(N
);
1492 Error_Msg_N
(Msg1
, Get_Pragma_Arg
(Arg
));
1493 Error_Pragma_Arg
(Msg2
, Arg
);
1494 end Error_Pragma_Arg
;
1496 ----------------------------
1497 -- Error_Pragma_Arg_Ident --
1498 ----------------------------
1500 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
) is
1502 Error_Msg_Name_1
:= Chars
(N
);
1503 Error_Msg_N
(Msg
, Arg
);
1505 end Error_Pragma_Arg_Ident
;
1507 ------------------------
1508 -- Find_Lib_Unit_Name --
1509 ------------------------
1511 function Find_Lib_Unit_Name
return Entity_Id
is
1513 -- Return inner compilation unit entity, for case of nested
1514 -- categorization pragmas. This happens in generic unit.
1516 if Nkind
(Parent
(N
)) = N_Package_Specification
1517 and then Defining_Entity
(Parent
(N
)) /= Current_Scope
1519 return Defining_Entity
(Parent
(N
));
1521 return Current_Scope
;
1523 end Find_Lib_Unit_Name
;
1525 ----------------------------
1526 -- Find_Program_Unit_Name --
1527 ----------------------------
1529 procedure Find_Program_Unit_Name
(Id
: Node_Id
) is
1530 Unit_Name
: Entity_Id
;
1531 Unit_Kind
: Node_Kind
;
1532 P
: constant Node_Id
:= Parent
(N
);
1535 if Nkind
(P
) = N_Compilation_Unit
then
1536 Unit_Kind
:= Nkind
(Unit
(P
));
1538 if Unit_Kind
= N_Subprogram_Declaration
1539 or else Unit_Kind
= N_Package_Declaration
1540 or else Unit_Kind
in N_Generic_Declaration
1542 Unit_Name
:= Defining_Entity
(Unit
(P
));
1544 if Chars
(Id
) = Chars
(Unit_Name
) then
1545 Set_Entity
(Id
, Unit_Name
);
1546 Set_Etype
(Id
, Etype
(Unit_Name
));
1548 Set_Etype
(Id
, Any_Type
);
1550 ("cannot find program unit referenced by pragma%");
1554 Set_Etype
(Id
, Any_Type
);
1555 Error_Pragma
("pragma% inapplicable to this unit");
1561 end Find_Program_Unit_Name
;
1563 -----------------------------------------
1564 -- Find_Unique_Parameterless_Procedure --
1565 -----------------------------------------
1567 function Find_Unique_Parameterless_Procedure
1569 Arg
: Node_Id
) return Entity_Id
1571 Proc
: Entity_Id
:= Empty
;
1574 -- The body of this procedure needs some comments ???
1576 if not Is_Entity_Name
(Name
) then
1578 ("argument of pragma% must be entity name", Arg
);
1580 elsif not Is_Overloaded
(Name
) then
1581 Proc
:= Entity
(Name
);
1583 if Ekind
(Proc
) /= E_Procedure
1584 or else Present
(First_Formal
(Proc
)) then
1586 ("argument of pragma% must be parameterless procedure", Arg
);
1591 Found
: Boolean := False;
1593 Index
: Interp_Index
;
1596 Get_First_Interp
(Name
, Index
, It
);
1597 while Present
(It
.Nam
) loop
1600 if Ekind
(Proc
) = E_Procedure
1601 and then No
(First_Formal
(Proc
))
1605 Set_Entity
(Name
, Proc
);
1606 Set_Is_Overloaded
(Name
, False);
1609 ("ambiguous handler name for pragma% ", Arg
);
1613 Get_Next_Interp
(Index
, It
);
1618 ("argument of pragma% must be parameterless procedure",
1621 Proc
:= Entity
(Name
);
1627 end Find_Unique_Parameterless_Procedure
;
1629 -------------------------
1630 -- Gather_Associations --
1631 -------------------------
1633 procedure Gather_Associations
1635 Args
: out Args_List
)
1640 -- Initialize all parameters to Empty
1642 for J
in Args
'Range loop
1646 -- That's all we have to do if there are no argument associations
1648 if No
(Pragma_Argument_Associations
(N
)) then
1652 -- Otherwise first deal with any positional parameters present
1654 Arg
:= First
(Pragma_Argument_Associations
(N
));
1655 for Index
in Args
'Range loop
1656 exit when No
(Arg
) or else Chars
(Arg
) /= No_Name
;
1657 Args
(Index
) := Expression
(Arg
);
1661 -- Positional parameters all processed, if any left, then we
1662 -- have too many positional parameters.
1664 if Present
(Arg
) and then Chars
(Arg
) = No_Name
then
1666 ("too many positional associations for pragma%", Arg
);
1669 -- Process named parameters if any are present
1671 while Present
(Arg
) loop
1672 if Chars
(Arg
) = No_Name
then
1674 ("positional association cannot follow named association",
1678 for Index
in Names
'Range loop
1679 if Names
(Index
) = Chars
(Arg
) then
1680 if Present
(Args
(Index
)) then
1682 ("duplicate argument association for pragma%", Arg
);
1684 Args
(Index
) := Expression
(Arg
);
1689 if Index
= Names
'Last then
1690 Error_Msg_Name_1
:= Chars
(N
);
1691 Error_Msg_N
("pragma% does not allow & argument", Arg
);
1693 -- Check for possible misspelling
1695 for Index1
in Names
'Range loop
1696 if Is_Bad_Spelling_Of
1697 (Get_Name_String
(Chars
(Arg
)),
1698 Get_Name_String
(Names
(Index1
)))
1700 Error_Msg_Name_1
:= Names
(Index1
);
1701 Error_Msg_N
("\possible misspelling of%", Arg
);
1713 end Gather_Associations
;
1715 --------------------
1716 -- Get_Pragma_Arg --
1717 --------------------
1719 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
is
1721 if Nkind
(Arg
) = N_Pragma_Argument_Association
then
1722 return Expression
(Arg
);
1732 procedure GNAT_Pragma
is
1734 Check_Restriction
(No_Implementation_Pragmas
, N
);
1737 --------------------------
1738 -- Is_Before_First_Decl --
1739 --------------------------
1741 function Is_Before_First_Decl
1742 (Pragma_Node
: Node_Id
;
1743 Decls
: List_Id
) return Boolean
1745 Item
: Node_Id
:= First
(Decls
);
1748 -- Only other pragmas can come before this pragma
1751 if No
(Item
) or else Nkind
(Item
) /= N_Pragma
then
1754 elsif Item
= Pragma_Node
then
1760 end Is_Before_First_Decl
;
1762 -----------------------------
1763 -- Is_Configuration_Pragma --
1764 -----------------------------
1766 -- A configuration pragma must appear in the context clause of
1767 -- a compilation unit, at the start of the list (i.e. only other
1768 -- pragmas may precede it).
1770 function Is_Configuration_Pragma
return Boolean is
1771 Lis
: constant List_Id
:= List_Containing
(N
);
1772 Par
: constant Node_Id
:= Parent
(N
);
1776 -- If no parent, then we are in the configuration pragma file,
1777 -- so the placement is definitely appropriate.
1782 -- Otherwise we must be in the context clause of a compilation unit
1783 -- and the only thing allowed before us in the context list is more
1784 -- configuration pragmas.
1786 elsif Nkind
(Par
) = N_Compilation_Unit
1787 and then Context_Items
(Par
) = Lis
1794 elsif Nkind
(Prg
) /= N_Pragma
then
1804 end Is_Configuration_Pragma
;
1806 ----------------------
1807 -- Pragma_Misplaced --
1808 ----------------------
1810 procedure Pragma_Misplaced
is
1812 Error_Pragma
("incorrect placement of pragma%");
1813 end Pragma_Misplaced
;
1815 ------------------------------------
1816 -- Process Atomic_Shared_Volatile --
1817 ------------------------------------
1819 procedure Process_Atomic_Shared_Volatile
is
1826 procedure Set_Atomic
(E
: Entity_Id
);
1827 -- Set given type as atomic, and if no explicit alignment was
1828 -- given, set alignment to unknown, since back end knows what
1829 -- the alignment requirements are for atomic arrays. Note that
1830 -- this step is necessary for derived types.
1836 procedure Set_Atomic
(E
: Entity_Id
) is
1840 if not Has_Alignment_Clause
(E
) then
1841 Set_Alignment
(E
, Uint_0
);
1845 -- Start of processing for Process_Atomic_Shared_Volatile
1848 Check_Ada_83_Warning
;
1849 Check_No_Identifiers
;
1850 Check_Arg_Count
(1);
1851 Check_Arg_Is_Local_Name
(Arg1
);
1852 E_Id
:= Expression
(Arg1
);
1854 if Etype
(E_Id
) = Any_Type
then
1859 D
:= Declaration_Node
(E
);
1863 if Rep_Item_Too_Early
(E
, N
)
1865 Rep_Item_Too_Late
(E
, N
)
1869 Check_First_Subtype
(Arg1
);
1872 if Prag_Id
/= Pragma_Volatile
then
1874 Set_Atomic
(Underlying_Type
(E
));
1875 Set_Atomic
(Base_Type
(E
));
1878 -- Attribute belongs on the base type. If the
1879 -- view of the type is currently private, it also
1880 -- belongs on the underlying type.
1882 Set_Is_Volatile
(Base_Type
(E
));
1883 Set_Is_Volatile
(Underlying_Type
(E
));
1885 Set_Treat_As_Volatile
(E
);
1886 Set_Treat_As_Volatile
(Underlying_Type
(E
));
1888 elsif K
= N_Object_Declaration
1889 or else (K
= N_Component_Declaration
1890 and then Original_Record_Component
(E
) = E
)
1892 if Rep_Item_Too_Late
(E
, N
) then
1896 if Prag_Id
/= Pragma_Volatile
then
1899 -- If the object declaration has an explicit
1900 -- initialization, a temporary may have to be
1901 -- created to hold the expression, to insure
1902 -- that access to the object remain atomic.
1904 if Nkind
(Parent
(E
)) = N_Object_Declaration
1905 and then Present
(Expression
(Parent
(E
)))
1907 Set_Has_Delayed_Freeze
(E
);
1910 -- An interesting improvement here. If an object of type X
1911 -- is declared atomic, and the type X is not atomic, that's
1912 -- a pity, since it may not have appropraite alignment etc.
1913 -- We can rescue this in the special case where the object
1914 -- and type are in the same unit by just setting the type
1915 -- as atomic, so that the back end will process it as atomic.
1917 Utyp
:= Underlying_Type
(Etype
(E
));
1920 and then Sloc
(E
) > No_Location
1921 and then Sloc
(Utyp
) > No_Location
1923 Get_Source_File_Index
(Sloc
(E
)) =
1924 Get_Source_File_Index
(Sloc
(Underlying_Type
(Etype
(E
))))
1926 Set_Is_Atomic
(Underlying_Type
(Etype
(E
)));
1930 Set_Is_Volatile
(E
);
1931 Set_Treat_As_Volatile
(E
);
1935 ("inappropriate entity for pragma%", Arg1
);
1937 end Process_Atomic_Shared_Volatile
;
1939 ------------------------
1940 -- Process_Convention --
1941 ------------------------
1943 procedure Process_Convention
1944 (C
: out Convention_Id
;
1950 Comp_Unit
: Unit_Number_Type
;
1952 procedure Set_Convention_From_Pragma
(E
: Entity_Id
);
1953 -- Set convention in entity E, and also flag that the entity has a
1954 -- convention pragma. If entity is for a private or incomplete type,
1955 -- also set convention and flag on underlying type. This procedure
1956 -- also deals with the special case of C_Pass_By_Copy convention.
1958 --------------------------------
1959 -- Set_Convention_From_Pragma --
1960 --------------------------------
1962 procedure Set_Convention_From_Pragma
(E
: Entity_Id
) is
1964 -- Check invalid attempt to change convention for an overridden
1965 -- dispatching operation. This is Ada 2005 AI 430. Technically
1966 -- this is an amendment and should only be done in Ada 2005 mode.
1967 -- However, this is clearly a mistake, since the problem that is
1968 -- addressed by this AI is that there is a clear gap in the RM!
1970 if Is_Dispatching_Operation
(E
)
1971 and then Present
(Overridden_Operation
(E
))
1972 and then C
/= Convention
(Overridden_Operation
(E
))
1975 ("cannot change convention for " &
1976 "overridden dispatching operation",
1980 -- Set the convention
1982 Set_Convention
(E
, C
);
1983 Set_Has_Convention_Pragma
(E
);
1985 if Is_Incomplete_Or_Private_Type
(E
) then
1986 Set_Convention
(Underlying_Type
(E
), C
);
1987 Set_Has_Convention_Pragma
(Underlying_Type
(E
), True);
1990 -- A class-wide type should inherit the convention of
1991 -- the specific root type (although this isn't specified
1992 -- clearly by the RM).
1994 if Is_Type
(E
) and then Present
(Class_Wide_Type
(E
)) then
1995 Set_Convention
(Class_Wide_Type
(E
), C
);
1998 -- If the entity is a record type, then check for special case
1999 -- of C_Pass_By_Copy, which is treated the same as C except that
2000 -- the special record flag is set. This convention is also only
2001 -- permitted on record types (see AI95-00131).
2003 if Cname
= Name_C_Pass_By_Copy
then
2004 if Is_Record_Type
(E
) then
2005 Set_C_Pass_By_Copy
(Base_Type
(E
));
2006 elsif Is_Incomplete_Or_Private_Type
(E
)
2007 and then Is_Record_Type
(Underlying_Type
(E
))
2009 Set_C_Pass_By_Copy
(Base_Type
(Underlying_Type
(E
)));
2012 ("C_Pass_By_Copy convention allowed only for record type",
2017 -- If the entity is a derived boolean type, check for the
2018 -- special case of convention C, C++, or Fortran, where we
2019 -- consider any nonzero value to represent true.
2021 if Is_Discrete_Type
(E
)
2022 and then Root_Type
(Etype
(E
)) = Standard_Boolean
2028 C
= Convention_Fortran
)
2030 Set_Nonzero_Is_True
(Base_Type
(E
));
2032 end Set_Convention_From_Pragma
;
2034 -- Start of processing for Process_Convention
2037 Check_At_Least_N_Arguments
(2);
2038 Check_Optional_Identifier
(Arg1
, Name_Convention
);
2039 Check_Arg_Is_Identifier
(Arg1
);
2040 Cname
:= Chars
(Expression
(Arg1
));
2042 -- C_Pass_By_Copy is treated as a synonym for convention C
2043 -- (this is tested again below to set the critical flag)
2045 if Cname
= Name_C_Pass_By_Copy
then
2048 -- Otherwise we must have something in the standard convention list
2050 elsif Is_Convention_Name
(Cname
) then
2051 C
:= Get_Convention_Id
(Chars
(Expression
(Arg1
)));
2053 -- In DEC VMS, it seems that there is an undocumented feature
2054 -- that any unrecognized convention is treated as the default,
2055 -- which for us is convention C. It does not seem so terrible
2056 -- to do this unconditionally, silently in the VMS case, and
2057 -- with a warning in the non-VMS case.
2060 if Warn_On_Export_Import
and not OpenVMS_On_Target
then
2062 ("?unrecognized convention name, C assumed",
2069 Check_Optional_Identifier
(Arg2
, Name_Entity
);
2070 Check_Arg_Is_Local_Name
(Arg2
);
2072 Id
:= Expression
(Arg2
);
2075 if not Is_Entity_Name
(Id
) then
2076 Error_Pragma_Arg
("entity name required", Arg2
);
2081 -- Go to renamed subprogram if present, since convention applies
2082 -- to the actual renamed entity, not to the renaming entity.
2083 -- If subprogram is inherited, go to parent subprogram.
2085 if Is_Subprogram
(E
)
2086 and then Present
(Alias
(E
))
2088 if Nkind
(Parent
(Declaration_Node
(E
)))
2089 = N_Subprogram_Renaming_Declaration
2093 elsif Nkind
(Parent
(E
)) = N_Full_Type_Declaration
2094 and then Scope
(E
) = Scope
(Alias
(E
))
2100 -- Check that we are not applying this to a specless body
2102 if Is_Subprogram
(E
)
2103 and then Nkind
(Parent
(Declaration_Node
(E
))) = N_Subprogram_Body
2106 ("pragma% requires separate spec and must come before body");
2109 -- Check that we are not applying this to a named constant
2111 if Ekind
(E
) = E_Named_Integer
2113 Ekind
(E
) = E_Named_Real
2115 Error_Msg_Name_1
:= Chars
(N
);
2117 ("cannot apply pragma% to named constant!",
2118 Get_Pragma_Arg
(Arg2
));
2120 ("\supply appropriate type for&!", Arg2
);
2123 if Etype
(E
) = Any_Type
2124 or else Rep_Item_Too_Early
(E
, N
)
2128 E
:= Underlying_Type
(E
);
2131 if Rep_Item_Too_Late
(E
, N
) then
2135 if Has_Convention_Pragma
(E
) then
2137 ("at most one Convention/Export/Import pragma is allowed", Arg2
);
2139 elsif Convention
(E
) = Convention_Protected
2140 or else Ekind
(Scope
(E
)) = E_Protected_Type
2143 ("a protected operation cannot be given a different convention",
2147 -- For Intrinsic, a subprogram is required
2149 if C
= Convention_Intrinsic
2150 and then not Is_Subprogram
(E
)
2151 and then not Is_Generic_Subprogram
(E
)
2154 ("second argument of pragma% must be a subprogram", Arg2
);
2157 -- For Stdcall, a subprogram, variable or subprogram type is required
2159 if C
= Convention_Stdcall
2160 and then not Is_Subprogram
(E
)
2161 and then not Is_Generic_Subprogram
(E
)
2162 and then Ekind
(E
) /= E_Variable
2165 and then Ekind
(Designated_Type
(E
)) = E_Subprogram_Type
)
2168 ("second argument of pragma% must be subprogram (type)",
2172 if not Is_Subprogram
(E
)
2173 and then not Is_Generic_Subprogram
(E
)
2175 Set_Convention_From_Pragma
(E
);
2179 Check_First_Subtype
(Arg2
);
2180 Set_Convention_From_Pragma
(Base_Type
(E
));
2182 -- For subprograms, we must set the convention on the
2183 -- internally generated directly designated type as well.
2185 if Ekind
(E
) = E_Access_Subprogram_Type
then
2186 Set_Convention_From_Pragma
(Directly_Designated_Type
(E
));
2190 -- For the subprogram case, set proper convention for all homonyms
2191 -- in same scope and the same declarative part, i.e. the same
2192 -- compilation unit.
2195 Comp_Unit
:= Get_Source_Unit
(E
);
2196 Set_Convention_From_Pragma
(E
);
2198 -- Treat a pragma Import as an implicit body, for GPS use
2200 if Prag_Id
= Pragma_Import
then
2201 Generate_Reference
(E
, Id
, 'b');
2207 exit when No
(E1
) or else Scope
(E1
) /= Current_Scope
;
2209 -- Note: below we are missing a check for Rep_Item_Too_Late.
2210 -- That is deliberate, we cannot chain the rep item on more
2211 -- than one Rep_Item chain, to be fixed later ???
2213 if Comes_From_Source
(E1
)
2214 and then Comp_Unit
= Get_Source_Unit
(E1
)
2215 and then Nkind
(Original_Node
(Parent
(E1
))) /=
2216 N_Full_Type_Declaration
2218 Set_Convention_From_Pragma
(E1
);
2220 if Prag_Id
= Pragma_Import
then
2221 Generate_Reference
(E
, Id
, 'b');
2226 end Process_Convention
;
2228 -----------------------------------------------------
2229 -- Process_Extended_Import_Export_Exception_Pragma --
2230 -----------------------------------------------------
2232 procedure Process_Extended_Import_Export_Exception_Pragma
2233 (Arg_Internal
: Node_Id
;
2234 Arg_External
: Node_Id
;
2244 if not OpenVMS_On_Target
then
2246 ("?pragma% ignored (applies only to Open'V'M'S)");
2249 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2250 Def_Id
:= Entity
(Arg_Internal
);
2252 if Ekind
(Def_Id
) /= E_Exception
then
2254 ("pragma% must refer to declared exception", Arg_Internal
);
2257 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2259 if Present
(Arg_Form
) then
2260 Check_Arg_Is_One_Of
(Arg_Form
, Name_Ada
, Name_VMS
);
2263 if Present
(Arg_Form
)
2264 and then Chars
(Arg_Form
) = Name_Ada
2268 Set_Is_VMS_Exception
(Def_Id
);
2269 Set_Exception_Code
(Def_Id
, No_Uint
);
2272 if Present
(Arg_Code
) then
2273 if not Is_VMS_Exception
(Def_Id
) then
2275 ("Code option for pragma% not allowed for Ada case",
2279 Check_Arg_Is_Static_Expression
(Arg_Code
, Any_Integer
);
2280 Code_Val
:= Expr_Value
(Arg_Code
);
2282 if not UI_Is_In_Int_Range
(Code_Val
) then
2284 ("Code option for pragma% must be in 32-bit range",
2288 Set_Exception_Code
(Def_Id
, Code_Val
);
2291 end Process_Extended_Import_Export_Exception_Pragma
;
2293 -------------------------------------------------
2294 -- Process_Extended_Import_Export_Internal_Arg --
2295 -------------------------------------------------
2297 procedure Process_Extended_Import_Export_Internal_Arg
2298 (Arg_Internal
: Node_Id
:= Empty
)
2303 if No
(Arg_Internal
) then
2304 Error_Pragma
("Internal parameter required for pragma%");
2307 if Nkind
(Arg_Internal
) = N_Identifier
then
2310 elsif Nkind
(Arg_Internal
) = N_Operator_Symbol
2311 and then (Prag_Id
= Pragma_Import_Function
2313 Prag_Id
= Pragma_Export_Function
)
2319 ("wrong form for Internal parameter for pragma%", Arg_Internal
);
2322 Check_Arg_Is_Local_Name
(Arg_Internal
);
2323 end Process_Extended_Import_Export_Internal_Arg
;
2325 --------------------------------------------------
2326 -- Process_Extended_Import_Export_Object_Pragma --
2327 --------------------------------------------------
2329 procedure Process_Extended_Import_Export_Object_Pragma
2330 (Arg_Internal
: Node_Id
;
2331 Arg_External
: Node_Id
;
2337 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2338 Def_Id
:= Entity
(Arg_Internal
);
2340 if Ekind
(Def_Id
) /= E_Constant
2341 and then Ekind
(Def_Id
) /= E_Variable
2344 ("pragma% must designate an object", Arg_Internal
);
2347 if Has_Rep_Pragma
(Def_Id
, Name_Common_Object
)
2349 Has_Rep_Pragma
(Def_Id
, Name_Psect_Object
)
2352 ("previous Common/Psect_Object applies, pragma % not permitted",
2356 if Rep_Item_Too_Late
(Def_Id
, N
) then
2360 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2362 if Present
(Arg_Size
) then
2363 Check_Arg_Is_External_Name
(Arg_Size
);
2366 -- Export_Object case
2368 if Prag_Id
= Pragma_Export_Object
then
2369 if not Is_Library_Level_Entity
(Def_Id
) then
2371 ("argument for pragma% must be library level entity",
2375 if Ekind
(Current_Scope
) = E_Generic_Package
then
2376 Error_Pragma
("pragma& cannot appear in a generic unit");
2379 if not Size_Known_At_Compile_Time
(Etype
(Def_Id
)) then
2381 ("exported object must have compile time known size",
2385 if Warn_On_Export_Import
and then Is_Exported
(Def_Id
) then
2387 ("?duplicate Export_Object pragma", N
);
2389 Set_Exported
(Def_Id
, Arg_Internal
);
2392 -- Import_Object case
2395 if Is_Concurrent_Type
(Etype
(Def_Id
)) then
2397 ("cannot use pragma% for task/protected object",
2401 if Ekind
(Def_Id
) = E_Constant
then
2403 ("cannot import a constant", Arg_Internal
);
2406 if Warn_On_Export_Import
2407 and then Has_Discriminants
(Etype
(Def_Id
))
2410 ("imported value must be initialized?", Arg_Internal
);
2413 if Warn_On_Export_Import
2414 and then Is_Access_Type
(Etype
(Def_Id
))
2417 ("cannot import object of an access type?", Arg_Internal
);
2420 if Warn_On_Export_Import
2421 and then Is_Imported
(Def_Id
)
2424 ("?duplicate Import_Object pragma", N
);
2426 -- Check for explicit initialization present. Note that an
2427 -- initialization that generated by the code generator, e.g.
2428 -- for an access type, does not count here.
2430 elsif Present
(Expression
(Parent
(Def_Id
)))
2433 (Original_Node
(Expression
(Parent
(Def_Id
))))
2435 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2437 ("no initialization allowed for declaration of& #",
2438 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2441 Set_Imported
(Def_Id
);
2442 Note_Possible_Modification
(Arg_Internal
);
2445 end Process_Extended_Import_Export_Object_Pragma
;
2447 ------------------------------------------------------
2448 -- Process_Extended_Import_Export_Subprogram_Pragma --
2449 ------------------------------------------------------
2451 procedure Process_Extended_Import_Export_Subprogram_Pragma
2452 (Arg_Internal
: Node_Id
;
2453 Arg_External
: Node_Id
;
2454 Arg_Parameter_Types
: Node_Id
;
2455 Arg_Result_Type
: Node_Id
:= Empty
;
2456 Arg_Mechanism
: Node_Id
;
2457 Arg_Result_Mechanism
: Node_Id
:= Empty
;
2458 Arg_First_Optional_Parameter
: Node_Id
:= Empty
)
2464 Ambiguous
: Boolean;
2468 function Same_Base_Type
2470 Formal
: Entity_Id
) return Boolean;
2471 -- Determines if Ptype references the type of Formal. Note that
2472 -- only the base types need to match according to the spec. Ptype
2473 -- here is the argument from the pragma, which is either a type
2474 -- name, or an access attribute.
2476 --------------------
2477 -- Same_Base_Type --
2478 --------------------
2480 function Same_Base_Type
2482 Formal
: Entity_Id
) return Boolean
2484 Ftyp
: constant Entity_Id
:= Base_Type
(Etype
(Formal
));
2488 -- Case where pragma argument is typ'Access
2490 if Nkind
(Ptype
) = N_Attribute_Reference
2491 and then Attribute_Name
(Ptype
) = Name_Access
2493 Pref
:= Prefix
(Ptype
);
2496 if not Is_Entity_Name
(Pref
)
2497 or else Entity
(Pref
) = Any_Type
2502 -- We have a match if the corresponding argument is of an
2503 -- anonymous access type, and its designicated type matches
2504 -- the type of the prefix of the access attribute
2506 return Ekind
(Ftyp
) = E_Anonymous_Access_Type
2507 and then Base_Type
(Entity
(Pref
)) =
2508 Base_Type
(Etype
(Designated_Type
(Ftyp
)));
2510 -- Case where pragma argument is a type name
2515 if not Is_Entity_Name
(Ptype
)
2516 or else Entity
(Ptype
) = Any_Type
2521 -- We have a match if the corresponding argument is of
2522 -- the type given in the pragma (comparing base types)
2524 return Base_Type
(Entity
(Ptype
)) = Ftyp
;
2528 -- Start of processing for
2529 -- Process_Extended_Import_Export_Subprogram_Pragma
2532 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2536 -- Loop through homonyms (overloadings) of the entity
2538 Hom_Id
:= Entity
(Arg_Internal
);
2539 while Present
(Hom_Id
) loop
2540 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
2542 -- We need a subprogram in the current scope
2544 if not Is_Subprogram
(Def_Id
)
2545 or else Scope
(Def_Id
) /= Current_Scope
2552 -- Pragma cannot apply to subprogram body
2554 if Is_Subprogram
(Def_Id
)
2557 (Declaration_Node
(Def_Id
))) = N_Subprogram_Body
2560 ("pragma% requires separate spec"
2561 & " and must come before body");
2564 -- Test result type if given, note that the result type
2565 -- parameter can only be present for the function cases.
2567 if Present
(Arg_Result_Type
)
2568 and then not Same_Base_Type
(Arg_Result_Type
, Def_Id
)
2572 elsif Etype
(Def_Id
) /= Standard_Void_Type
2574 (Chars
(N
) = Name_Export_Procedure
2575 or else Chars
(N
) = Name_Import_Procedure
)
2579 -- Test parameter types if given. Note that this parameter
2580 -- has not been analyzed (and must not be, since it is
2581 -- semantic nonsense), so we get it as the parser left it.
2583 elsif Present
(Arg_Parameter_Types
) then
2584 Check_Matching_Types
: declare
2589 Formal
:= First_Formal
(Def_Id
);
2591 if Nkind
(Arg_Parameter_Types
) = N_Null
then
2592 if Present
(Formal
) then
2596 -- A list of one type, e.g. (List) is parsed as
2597 -- a parenthesized expression.
2599 elsif Nkind
(Arg_Parameter_Types
) /= N_Aggregate
2600 and then Paren_Count
(Arg_Parameter_Types
) = 1
2603 or else Present
(Next_Formal
(Formal
))
2608 Same_Base_Type
(Arg_Parameter_Types
, Formal
);
2611 -- A list of more than one type is parsed as a aggregate
2613 elsif Nkind
(Arg_Parameter_Types
) = N_Aggregate
2614 and then Paren_Count
(Arg_Parameter_Types
) = 0
2616 Ptype
:= First
(Expressions
(Arg_Parameter_Types
));
2617 while Present
(Ptype
) or else Present
(Formal
) loop
2620 or else not Same_Base_Type
(Ptype
, Formal
)
2625 Next_Formal
(Formal
);
2630 -- Anything else is of the wrong form
2634 ("wrong form for Parameter_Types parameter",
2635 Arg_Parameter_Types
);
2637 end Check_Matching_Types
;
2640 -- Match is now False if the entry we found did not match
2641 -- either a supplied Parameter_Types or Result_Types argument
2647 -- Ambiguous case, the flag Ambiguous shows if we already
2648 -- detected this and output the initial messages.
2651 if not Ambiguous
then
2653 Error_Msg_Name_1
:= Chars
(N
);
2655 ("pragma% does not uniquely identify subprogram!",
2657 Error_Msg_Sloc
:= Sloc
(Ent
);
2658 Error_Msg_N
("matching subprogram #!", N
);
2662 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2663 Error_Msg_N
("matching subprogram #!", N
);
2668 Hom_Id
:= Homonym
(Hom_Id
);
2671 -- See if we found an entry
2674 if not Ambiguous
then
2675 if Is_Generic_Subprogram
(Entity
(Arg_Internal
)) then
2677 ("pragma% cannot be given for generic subprogram");
2681 ("pragma% does not identify local subprogram");
2688 -- Import pragmas must be be for imported entities
2690 if Prag_Id
= Pragma_Import_Function
2692 Prag_Id
= Pragma_Import_Procedure
2694 Prag_Id
= Pragma_Import_Valued_Procedure
2696 if not Is_Imported
(Ent
) then
2698 ("pragma Import or Interface must precede pragma%");
2701 -- Here we have the Export case which can set the entity as exported
2703 -- But does not do so if the specified external name is null,
2704 -- since that is taken as a signal in DEC Ada 83 (with which
2705 -- we want to be compatible) to request no external name.
2707 elsif Nkind
(Arg_External
) = N_String_Literal
2708 and then String_Length
(Strval
(Arg_External
)) = 0
2712 -- In all other cases, set entit as exported
2715 Set_Exported
(Ent
, Arg_Internal
);
2718 -- Special processing for Valued_Procedure cases
2720 if Prag_Id
= Pragma_Import_Valued_Procedure
2722 Prag_Id
= Pragma_Export_Valued_Procedure
2724 Formal
:= First_Formal
(Ent
);
2728 ("at least one parameter required for pragma%");
2730 elsif Ekind
(Formal
) /= E_Out_Parameter
then
2732 ("first parameter must have mode out for pragma%");
2735 Set_Is_Valued_Procedure
(Ent
);
2739 Set_Extended_Import_Export_External_Name
(Ent
, Arg_External
);
2741 -- Process Result_Mechanism argument if present. We have already
2742 -- checked that this is only allowed for the function case.
2744 if Present
(Arg_Result_Mechanism
) then
2745 Set_Mechanism_Value
(Ent
, Arg_Result_Mechanism
);
2748 -- Process Mechanism parameter if present. Note that this parameter
2749 -- is not analyzed, and must not be analyzed since it is semantic
2750 -- nonsense, so we get it in exactly as the parser left it.
2752 if Present
(Arg_Mechanism
) then
2760 -- A single mechanism association without a formal parameter
2761 -- name is parsed as a parenthesized expression. All other
2762 -- cases are parsed as aggregates, so we rewrite the single
2763 -- parameter case as an aggregate for consistency.
2765 if Nkind
(Arg_Mechanism
) /= N_Aggregate
2766 and then Paren_Count
(Arg_Mechanism
) = 1
2768 Rewrite
(Arg_Mechanism
,
2769 Make_Aggregate
(Sloc
(Arg_Mechanism
),
2770 Expressions
=> New_List
(
2771 Relocate_Node
(Arg_Mechanism
))));
2774 -- Case of only mechanism name given, applies to all formals
2776 if Nkind
(Arg_Mechanism
) /= N_Aggregate
then
2777 Formal
:= First_Formal
(Ent
);
2778 while Present
(Formal
) loop
2779 Set_Mechanism_Value
(Formal
, Arg_Mechanism
);
2780 Next_Formal
(Formal
);
2783 -- Case of list of mechanism associations given
2786 if Null_Record_Present
(Arg_Mechanism
) then
2788 ("inappropriate form for Mechanism parameter",
2792 -- Deal with positional ones first
2794 Formal
:= First_Formal
(Ent
);
2796 if Present
(Expressions
(Arg_Mechanism
)) then
2797 Mname
:= First
(Expressions
(Arg_Mechanism
));
2799 while Present
(Mname
) loop
2802 ("too many mechanism associations", Mname
);
2805 Set_Mechanism_Value
(Formal
, Mname
);
2806 Next_Formal
(Formal
);
2811 -- Deal with named entries
2813 if Present
(Component_Associations
(Arg_Mechanism
)) then
2814 Massoc
:= First
(Component_Associations
(Arg_Mechanism
));
2816 while Present
(Massoc
) loop
2817 Choice
:= First
(Choices
(Massoc
));
2819 if Nkind
(Choice
) /= N_Identifier
2820 or else Present
(Next
(Choice
))
2823 ("incorrect form for mechanism association",
2827 Formal
:= First_Formal
(Ent
);
2831 ("parameter name & not present", Choice
);
2834 if Chars
(Choice
) = Chars
(Formal
) then
2836 (Formal
, Expression
(Massoc
));
2840 Next_Formal
(Formal
);
2850 -- Process First_Optional_Parameter argument if present. We have
2851 -- already checked that this is only allowed for the Import case.
2853 if Present
(Arg_First_Optional_Parameter
) then
2854 if Nkind
(Arg_First_Optional_Parameter
) /= N_Identifier
then
2856 ("first optional parameter must be formal parameter name",
2857 Arg_First_Optional_Parameter
);
2860 Formal
:= First_Formal
(Ent
);
2864 ("specified formal parameter& not found",
2865 Arg_First_Optional_Parameter
);
2868 exit when Chars
(Formal
) =
2869 Chars
(Arg_First_Optional_Parameter
);
2871 Next_Formal
(Formal
);
2874 Set_First_Optional_Parameter
(Ent
, Formal
);
2876 -- Check specified and all remaining formals have right form
2878 while Present
(Formal
) loop
2879 if Ekind
(Formal
) /= E_In_Parameter
then
2881 ("optional formal& is not of mode in!",
2882 Arg_First_Optional_Parameter
, Formal
);
2885 Dval
:= Default_Value
(Formal
);
2889 ("optional formal& does not have default value!",
2890 Arg_First_Optional_Parameter
, Formal
);
2892 elsif Compile_Time_Known_Value_Or_Aggr
(Dval
) then
2897 ("default value for optional formal& is non-static!",
2898 Arg_First_Optional_Parameter
, Formal
);
2902 Set_Is_Optional_Parameter
(Formal
);
2903 Next_Formal
(Formal
);
2906 end Process_Extended_Import_Export_Subprogram_Pragma
;
2908 --------------------------
2909 -- Process_Generic_List --
2910 --------------------------
2912 procedure Process_Generic_List
is
2918 Check_No_Identifiers
;
2919 Check_At_Least_N_Arguments
(1);
2922 while Present
(Arg
) loop
2923 Exp
:= Expression
(Arg
);
2926 if not Is_Entity_Name
(Exp
)
2928 (not Is_Generic_Instance
(Entity
(Exp
))
2930 not Is_Generic_Unit
(Entity
(Exp
)))
2933 ("pragma% argument must be name of generic unit/instance",
2939 end Process_Generic_List
;
2941 ---------------------------------
2942 -- Process_Import_Or_Interface --
2943 ---------------------------------
2945 procedure Process_Import_Or_Interface
is
2951 Process_Convention
(C
, Def_Id
);
2952 Kill_Size_Check_Code
(Def_Id
);
2953 Note_Possible_Modification
(Expression
(Arg2
));
2955 if Ekind
(Def_Id
) = E_Variable
2957 Ekind
(Def_Id
) = E_Constant
2959 -- User initialization is not allowed for imported object, but
2960 -- the object declaration may contain a default initialization,
2961 -- that will be discarded. Note that an explicit initialization
2962 -- only counts if it comes from source, otherwise it is simply
2963 -- the code generator making an implicit initialization explicit.
2965 if Present
(Expression
(Parent
(Def_Id
)))
2966 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
2968 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2970 ("no initialization allowed for declaration of& #",
2971 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2975 Set_Imported
(Def_Id
);
2976 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
2978 -- Note that we do not set Is_Public here. That's because we
2979 -- only want to set if if there is no address clause, and we
2980 -- don't know that yet, so we delay that processing till
2983 -- pragma Import completes deferred constants
2985 if Ekind
(Def_Id
) = E_Constant
then
2986 Set_Has_Completion
(Def_Id
);
2989 -- It is not possible to import a constant of an unconstrained
2990 -- array type (e.g. string) because there is no simple way to
2991 -- write a meaningful subtype for it.
2993 if Is_Array_Type
(Etype
(Def_Id
))
2994 and then not Is_Constrained
(Etype
(Def_Id
))
2997 ("imported constant& must have a constrained subtype",
3002 elsif Is_Subprogram
(Def_Id
)
3003 or else Is_Generic_Subprogram
(Def_Id
)
3005 -- If the name is overloaded, pragma applies to all of the
3006 -- denoted entities in the same declarative part.
3009 while Present
(Hom_Id
) loop
3010 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
3012 -- Ignore inherited subprograms because the pragma will
3013 -- apply to the parent operation, which is the one called.
3015 if Is_Overloadable
(Def_Id
)
3016 and then Present
(Alias
(Def_Id
))
3020 -- If it is not a subprogram, it must be in an outer
3021 -- scope and pragma does not apply.
3023 elsif not Is_Subprogram
(Def_Id
)
3024 and then not Is_Generic_Subprogram
(Def_Id
)
3028 -- Verify that the homonym is in the same declarative
3029 -- part (not just the same scope).
3031 elsif Parent
(Unit_Declaration_Node
(Def_Id
)) /= Parent
(N
)
3032 and then Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
3037 Set_Imported
(Def_Id
);
3039 -- Special processing for Convention_Intrinsic
3041 if C
= Convention_Intrinsic
then
3043 -- Link_Name argument not allowed for intrinsic
3046 and then Chars
(Arg3
) = Name_Link_Name
3051 if Present
(Arg4
) then
3053 ("Link_Name argument not allowed for " &
3058 Set_Is_Intrinsic_Subprogram
(Def_Id
);
3060 -- If no external name is present, then check that
3061 -- this is a valid intrinsic subprogram. If an external
3062 -- name is present, then this is handled by the back end.
3065 Check_Intrinsic_Subprogram
(Def_Id
, Expression
(Arg2
));
3069 -- All interfaced procedures need an external symbol
3070 -- created for them since they are always referenced
3071 -- from another object file.
3073 Set_Is_Public
(Def_Id
);
3075 -- Verify that the subprogram does not have a completion
3076 -- through a renaming declaration. For other completions
3077 -- the pragma appears as a too late representation.
3080 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Def_Id
);
3084 and then Nkind
(Decl
) = N_Subprogram_Declaration
3085 and then Present
(Corresponding_Body
(Decl
))
3088 (Unit_Declaration_Node
3089 (Corresponding_Body
(Decl
))) =
3090 N_Subprogram_Renaming_Declaration
3092 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3093 Error_Msg_NE
("cannot import&#," &
3094 " already completed by a renaming",
3099 Set_Has_Completion
(Def_Id
);
3100 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3103 if Is_Compilation_Unit
(Hom_Id
) then
3105 -- Its possible homonyms are not affected by the pragma.
3106 -- Such homonyms might be present in the context of other
3107 -- units being compiled.
3112 Hom_Id
:= Homonym
(Hom_Id
);
3116 -- When the convention is Java, we also allow Import to be given
3117 -- for packages, exceptions, and record components.
3119 elsif C
= Convention_Java
3121 (Ekind
(Def_Id
) = E_Package
3122 or else Ekind
(Def_Id
) = E_Exception
3123 or else Nkind
(Parent
(Def_Id
)) = N_Component_Declaration
)
3125 Set_Imported
(Def_Id
);
3126 Set_Is_Public
(Def_Id
);
3127 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3131 ("second argument of pragma% must be object or subprogram",
3135 -- If this pragma applies to a compilation unit, then the unit,
3136 -- which is a subprogram, does not require (or allow) a body.
3137 -- We also do not need to elaborate imported procedures.
3139 if Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
3141 Cunit
: constant Node_Id
:= Parent
(Parent
(N
));
3143 Set_Body_Required
(Cunit
, False);
3146 end Process_Import_Or_Interface
;
3148 --------------------
3149 -- Process_Inline --
3150 --------------------
3152 procedure Process_Inline
(Active
: Boolean) is
3158 Effective
: Boolean := False;
3160 procedure Make_Inline
(Subp
: Entity_Id
);
3161 -- Subp is the defining unit name of the subprogram
3162 -- declaration. Set the flag, as well as the flag in the
3163 -- corresponding body, if there is one present.
3165 procedure Set_Inline_Flags
(Subp
: Entity_Id
);
3166 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp
3168 function Inlining_Not_Possible
(Subp
: Entity_Id
) return Boolean;
3169 -- Returns True if it can be determined at this stage that inlining
3170 -- is not possible, for examle if the body is available and contains
3171 -- exception handlers, we prevent inlining, since otherwise we can
3172 -- get undefined symbols at link time. This function also emits a
3173 -- warning if front-end inlining is enabled and the pragma appears
3175 -- ??? is business with link symbols still valid, or does it relate
3176 -- to front end ZCX which is being phased out ???
3178 ---------------------------
3179 -- Inlining_Not_Possible --
3180 ---------------------------
3182 function Inlining_Not_Possible
(Subp
: Entity_Id
) return Boolean is
3183 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Subp
);
3187 if Nkind
(Decl
) = N_Subprogram_Body
then
3188 Stats
:= Handled_Statement_Sequence
(Decl
);
3189 return Present
(Exception_Handlers
(Stats
))
3190 or else Present
(At_End_Proc
(Stats
));
3192 elsif Nkind
(Decl
) = N_Subprogram_Declaration
3193 and then Present
(Corresponding_Body
(Decl
))
3195 if Front_End_Inlining
3196 and then Analyzed
(Corresponding_Body
(Decl
))
3198 Error_Msg_N
("pragma appears too late, ignored?", N
);
3201 -- If the subprogram is a renaming as body, the body is
3202 -- just a call to the renamed subprogram, and inlining is
3203 -- trivially possible.
3206 Nkind
(Unit_Declaration_Node
(Corresponding_Body
(Decl
)))
3207 = N_Subprogram_Renaming_Declaration
3213 Handled_Statement_Sequence
3214 (Unit_Declaration_Node
(Corresponding_Body
(Decl
)));
3217 Present
(Exception_Handlers
(Stats
))
3218 or else Present
(At_End_Proc
(Stats
));
3222 -- If body is not available, assume the best, the check is
3223 -- performed again when compiling enclosing package bodies.
3227 end Inlining_Not_Possible
;
3233 procedure Make_Inline
(Subp
: Entity_Id
) is
3234 Kind
: constant Entity_Kind
:= Ekind
(Subp
);
3235 Inner_Subp
: Entity_Id
:= Subp
;
3238 if Etype
(Subp
) = Any_Type
then
3241 -- If inlining is not possible, for now do not treat as an error
3243 elsif Inlining_Not_Possible
(Subp
) then
3247 -- Here we have a candidate for inlining, but we must exclude
3248 -- derived operations. Otherwise we will end up trying to
3249 -- inline a phantom declaration, and the result would be to
3250 -- drag in a body which has no direct inlining associated with
3251 -- it. That would not only be inefficient but would also result
3252 -- in the backend doing cross-unit inlining in cases where it
3253 -- was definitely inappropriate to do so.
3255 -- However, a simple Comes_From_Source test is insufficient,
3256 -- since we do want to allow inlining of generic instances,
3257 -- which also do not come from source. Predefined operators do
3258 -- not come from source but are not inlineable either.
3260 elsif not Comes_From_Source
(Subp
)
3261 and then not Is_Generic_Instance
(Subp
)
3262 and then Scope
(Subp
) /= Standard_Standard
3267 -- The referenced entity must either be the enclosing entity,
3268 -- or an entity declared within the current open scope.
3270 elsif Present
(Scope
(Subp
))
3271 and then Scope
(Subp
) /= Current_Scope
3272 and then Subp
/= Current_Scope
3275 ("argument of% must be entity in current scope", Assoc
);
3279 -- Processing for procedure, operator or function.
3280 -- If subprogram is aliased (as for an instance) indicate
3281 -- that the renamed entity (if declared in the same unit)
3284 if Is_Subprogram
(Subp
) then
3285 while Present
(Alias
(Inner_Subp
)) loop
3286 Inner_Subp
:= Alias
(Inner_Subp
);
3289 if In_Same_Source_Unit
(Subp
, Inner_Subp
) then
3290 Set_Inline_Flags
(Inner_Subp
);
3292 Decl
:= Parent
(Parent
(Inner_Subp
));
3294 if Nkind
(Decl
) = N_Subprogram_Declaration
3295 and then Present
(Corresponding_Body
(Decl
))
3297 Set_Inline_Flags
(Corresponding_Body
(Decl
));
3303 -- For a generic subprogram set flag as well, for use at
3304 -- the point of instantiation, to determine whether the
3305 -- body should be generated.
3307 elsif Is_Generic_Subprogram
(Subp
) then
3308 Set_Inline_Flags
(Subp
);
3311 -- Literals are by definition inlined
3313 elsif Kind
= E_Enumeration_Literal
then
3316 -- Anything else is an error
3320 ("expect subprogram name for pragma%", Assoc
);
3324 ----------------------
3325 -- Set_Inline_Flags --
3326 ----------------------
3328 procedure Set_Inline_Flags
(Subp
: Entity_Id
) is
3331 Set_Is_Inlined
(Subp
, True);
3334 if not Has_Pragma_Inline
(Subp
) then
3335 Set_Has_Pragma_Inline
(Subp
);
3336 Set_Next_Rep_Item
(N
, First_Rep_Item
(Subp
));
3337 Set_First_Rep_Item
(Subp
, N
);
3340 end Set_Inline_Flags
;
3342 -- Start of processing for Process_Inline
3345 Check_No_Identifiers
;
3346 Check_At_Least_N_Arguments
(1);
3349 Inline_Processing_Required
:= True;
3353 while Present
(Assoc
) loop
3354 Subp_Id
:= Expression
(Assoc
);
3358 if Is_Entity_Name
(Subp_Id
) then
3359 Subp
:= Entity
(Subp_Id
);
3361 if Subp
= Any_Id
then
3363 -- If previous error, avoid cascaded errors
3371 while Present
(Homonym
(Subp
))
3372 and then Scope
(Homonym
(Subp
)) = Current_Scope
3374 Make_Inline
(Homonym
(Subp
));
3375 Subp
:= Homonym
(Subp
);
3382 ("inappropriate argument for pragma%", Assoc
);
3385 and then Warn_On_Redundant_Constructs
3387 if Inlining_Not_Possible
(Subp
) then
3389 ("pragma Inline for& is ignored?", N
, Entity
(Subp_Id
));
3392 ("pragma Inline for& is redundant?", N
, Entity
(Subp_Id
));
3400 ----------------------------
3401 -- Process_Interface_Name --
3402 ----------------------------
3404 procedure Process_Interface_Name
3405 (Subprogram_Def
: Entity_Id
;
3411 String_Val
: String_Id
;
3413 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
);
3414 -- SN is a string literal node for an interface name. This routine
3415 -- performs some minimal checks that the name is reasonable. In
3416 -- particular that no spaces or other obviously incorrect characters
3417 -- appear. This is only a warning, since any characters are allowed.
3419 ----------------------------------
3420 -- Check_Form_Of_Interface_Name --
3421 ----------------------------------
3423 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
) is
3424 S
: constant String_Id
:= Strval
(Expr_Value_S
(SN
));
3425 SL
: constant Nat
:= String_Length
(S
);
3430 Error_Msg_N
("interface name cannot be null string", SN
);
3433 for J
in 1 .. SL
loop
3434 C
:= Get_String_Char
(S
, J
);
3436 if Warn_On_Export_Import
3437 and then (not In_Character_Range
(C
)
3438 or else Get_Character
(C
) = ' '
3439 or else Get_Character
(C
) = ',')
3442 ("?interface name contains illegal character", SN
);
3445 end Check_Form_Of_Interface_Name
;
3447 -- Start of processing for Process_Interface_Name
3450 if No
(Link_Arg
) then
3451 if No
(Ext_Arg
) then
3454 elsif Chars
(Ext_Arg
) = Name_Link_Name
then
3456 Link_Nam
:= Expression
(Ext_Arg
);
3459 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
3460 Ext_Nam
:= Expression
(Ext_Arg
);
3465 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
3466 Check_Optional_Identifier
(Link_Arg
, Name_Link_Name
);
3467 Ext_Nam
:= Expression
(Ext_Arg
);
3468 Link_Nam
:= Expression
(Link_Arg
);
3471 -- Check expressions for external name and link name are static
3473 if Present
(Ext_Nam
) then
3474 Check_Arg_Is_Static_Expression
(Ext_Nam
, Standard_String
);
3475 Check_Form_Of_Interface_Name
(Ext_Nam
);
3477 -- Verify that the external name is not the name of a local
3478 -- entity, which would hide the imported one and lead to
3479 -- run-time surprises. The problem can only arise for entities
3480 -- declared in a package body (otherwise the external name is
3481 -- fully qualified and won't conflict).
3489 if Prag_Id
= Pragma_Import
then
3490 String_To_Name_Buffer
(Strval
(Expr_Value_S
(Ext_Nam
)));
3492 E
:= Entity_Id
(Get_Name_Table_Info
(Nam
));
3494 if Nam
/= Chars
(Subprogram_Def
)
3495 and then Present
(E
)
3496 and then not Is_Overloadable
(E
)
3497 and then Is_Immediately_Visible
(E
)
3498 and then not Is_Imported
(E
)
3499 and then Ekind
(Scope
(E
)) = E_Package
3503 while Present
(Par
) loop
3504 if Nkind
(Par
) = N_Package_Body
then
3505 Error_Msg_Sloc
:= Sloc
(E
);
3507 ("imported entity is hidden by & declared#",
3512 Par
:= Parent
(Par
);
3519 if Present
(Link_Nam
) then
3520 Check_Arg_Is_Static_Expression
(Link_Nam
, Standard_String
);
3521 Check_Form_Of_Interface_Name
(Link_Nam
);
3524 -- If there is no link name, just set the external name
3526 if No
(Link_Nam
) then
3527 Link_Nam
:= Adjust_External_Name_Case
(Expr_Value_S
(Ext_Nam
));
3529 -- For the Link_Name case, the given literal is preceded by an
3530 -- asterisk, which indicates to GCC that the given name should
3531 -- be taken literally, and in particular that no prepending of
3532 -- underlines should occur, even in systems where this is the
3537 Store_String_Char
(Get_Char_Code
('*'));
3538 String_Val
:= Strval
(Expr_Value_S
(Link_Nam
));
3540 for J
in 1 .. String_Length
(String_Val
) loop
3541 Store_String_Char
(Get_String_Char
(String_Val
, J
));
3545 Make_String_Literal
(Sloc
(Link_Nam
), End_String
);
3548 Set_Encoded_Interface_Name
3549 (Get_Base_Subprogram
(Subprogram_Def
), Link_Nam
);
3550 Check_Duplicated_Export_Name
(Link_Nam
);
3551 end Process_Interface_Name
;
3553 -----------------------------------------
3554 -- Process_Interrupt_Or_Attach_Handler --
3555 -----------------------------------------
3557 procedure Process_Interrupt_Or_Attach_Handler
is
3558 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
3559 Handler_Proc
: constant Entity_Id
:= Entity
(Arg1_X
);
3560 Proc_Scope
: constant Entity_Id
:= Scope
(Handler_Proc
);
3563 Set_Is_Interrupt_Handler
(Handler_Proc
);
3565 -- If the pragma is not associated with a handler procedure
3566 -- within a protected type, then it must be for a nonprotected
3567 -- procedure for the AAMP target, in which case we don't
3568 -- associate a representation item with the procedure's scope.
3570 if Ekind
(Proc_Scope
) = E_Protected_Type
then
3571 if Prag_Id
= Pragma_Interrupt_Handler
3573 Prag_Id
= Pragma_Attach_Handler
3575 Record_Rep_Item
(Proc_Scope
, N
);
3578 end Process_Interrupt_Or_Attach_Handler
;
3580 --------------------------------------------------
3581 -- Process_Restrictions_Or_Restriction_Warnings --
3582 --------------------------------------------------
3584 -- Note: some of the simple identifier cases were handled in par-prag,
3585 -- but it is harmless (and more straightforward) to simply handle all
3586 -- cases here, even if it means we repeat a bit of work in some cases.
3588 procedure Process_Restrictions_Or_Restriction_Warnings
is
3590 R_Id
: Restriction_Id
;
3595 procedure Check_Unit_Name
(N
: Node_Id
);
3596 -- Checks unit name parameter for No_Dependence. Returns if it has
3597 -- an appropriate form, otherwise raises pragma argument error.
3599 procedure Set_Warning
(R
: All_Restrictions
);
3600 -- If this is a Restriction_Warnings pragma, set warning flag,
3601 -- otherwise reset the flag.
3603 ---------------------
3604 -- Check_Unit_Name --
3605 ---------------------
3607 procedure Check_Unit_Name
(N
: Node_Id
) is
3609 if Nkind
(N
) = N_Selected_Component
then
3610 Check_Unit_Name
(Prefix
(N
));
3611 Check_Unit_Name
(Selector_Name
(N
));
3613 elsif Nkind
(N
) = N_Identifier
then
3618 ("wrong form for unit name for No_Dependence", N
);
3620 end Check_Unit_Name
;
3626 procedure Set_Warning
(R
: All_Restrictions
) is
3628 if Prag_Id
= Pragma_Restriction_Warnings
then
3629 Restriction_Warnings
(R
) := True;
3631 Restriction_Warnings
(R
) := False;
3635 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
3638 Check_Ada_83_Warning
;
3639 Check_At_Least_N_Arguments
(1);
3640 Check_Valid_Configuration_Pragma
;
3643 while Present
(Arg
) loop
3645 Expr
:= Expression
(Arg
);
3647 -- Case of no restriction identifier present
3649 if Id
= No_Name
then
3650 if Nkind
(Expr
) /= N_Identifier
then
3652 ("invalid form for restriction", Arg
);
3657 (Process_Restriction_Synonyms
(Expr
));
3659 if R_Id
not in All_Boolean_Restrictions
then
3661 ("invalid restriction identifier", Arg
);
3664 if Implementation_Restriction
(R_Id
) then
3666 (No_Implementation_Restrictions
, Arg
);
3669 Set_Restriction
(R_Id
, N
);
3672 -- A very special case that must be processed here:
3673 -- pragma Restrictions (No_Exceptions) turns off
3674 -- all run-time checking. This is a bit dubious in
3675 -- terms of the formal language definition, but it
3676 -- is what is intended by RM H.4(12).
3678 if R_Id
= No_Exceptions
then
3679 Scope_Suppress
:= (others => True);
3682 -- Case of No_Dependence => unit-name. Note that the parser
3683 -- already made the necessary entry in the No_Dependence table.
3685 elsif Id
= Name_No_Dependence
then
3686 Check_Unit_Name
(Expr
);
3688 -- All other cases of restriction identifier present
3691 R_Id
:= Get_Restriction_Id
(Process_Restriction_Synonyms
(Arg
));
3692 Analyze_And_Resolve
(Expr
, Any_Integer
);
3694 if R_Id
not in All_Parameter_Restrictions
then
3696 ("invalid restriction parameter identifier", Arg
);
3698 elsif not Is_OK_Static_Expression
(Expr
) then
3699 Flag_Non_Static_Expr
3700 ("value must be static expression!", Expr
);
3703 elsif not Is_Integer_Type
(Etype
(Expr
))
3704 or else Expr_Value
(Expr
) < 0
3707 ("value must be non-negative integer", Arg
);
3709 -- Restriction pragma is active
3712 Val
:= Expr_Value
(Expr
);
3714 if not UI_Is_In_Int_Range
(Val
) then
3716 ("pragma ignored, value too large?", Arg
);
3718 Set_Restriction
(R_Id
, N
, Integer (UI_To_Int
(Val
)));
3726 end Process_Restrictions_Or_Restriction_Warnings
;
3728 ---------------------------------
3729 -- Process_Suppress_Unsuppress --
3730 ---------------------------------
3732 -- Note: this procedure makes entries in the check suppress data
3733 -- structures managed by Sem. See spec of package Sem for full
3734 -- details on how we handle recording of check suppression.
3736 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean) is
3741 In_Package_Spec
: constant Boolean :=
3742 (Ekind
(Current_Scope
) = E_Package
3744 Ekind
(Current_Scope
) = E_Generic_Package
)
3745 and then not In_Package_Body
(Current_Scope
);
3747 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
);
3748 -- Used to suppress a single check on the given entity
3750 --------------------------------
3751 -- Suppress_Unsuppress_Echeck --
3752 --------------------------------
3754 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
) is
3755 ESR
: constant Entity_Check_Suppress_Record
:=
3758 Suppress
=> Suppress_Case
);
3761 Set_Checks_May_Be_Suppressed
(E
);
3763 if In_Package_Spec
then
3764 Global_Entity_Suppress
.Append
(ESR
);
3766 Local_Entity_Suppress
.Append
(ESR
);
3769 -- If this is a first subtype, and the base type is distinct,
3770 -- then also set the suppress flags on the base type.
3772 if Is_First_Subtype
(E
)
3773 and then Etype
(E
) /= E
3775 Suppress_Unsuppress_Echeck
(Etype
(E
), C
);
3777 end Suppress_Unsuppress_Echeck
;
3779 -- Start of processing for Process_Suppress_Unsuppress
3782 -- Suppress/Unsuppress can appear as a configuration pragma,
3783 -- or in a declarative part or a package spec (RM 11.5(5))
3785 if not Is_Configuration_Pragma
then
3786 Check_Is_In_Decl_Part_Or_Package_Spec
;
3789 Check_At_Least_N_Arguments
(1);
3790 Check_At_Most_N_Arguments
(2);
3791 Check_No_Identifier
(Arg1
);
3792 Check_Arg_Is_Identifier
(Arg1
);
3794 if not Is_Check_Name
(Chars
(Expression
(Arg1
))) then
3796 ("argument of pragma% is not valid check name", Arg1
);
3798 C
:= Get_Check_Id
(Chars
(Expression
(Arg1
)));
3801 if Arg_Count
= 1 then
3803 -- Make an entry in the local scope suppress table. This is the
3804 -- table that directly shows the current value of the scope
3805 -- suppress check for any check id value.
3807 if C
= All_Checks
then
3809 -- For All_Checks, we set all specific checks with the
3810 -- exception of Elaboration_Check, which is handled specially
3811 -- because of not wanting All_Checks to have the effect of
3812 -- deactivating static elaboration order processing.
3814 for J
in Scope_Suppress
'Range loop
3815 if J
/= Elaboration_Check
then
3816 Scope_Suppress
(J
) := Suppress_Case
;
3820 -- If not All_Checks, just set appropriate entry. Note that we
3821 -- will set Elaboration_Check if this is explicitly specified.
3824 Scope_Suppress
(C
) := Suppress_Case
;
3827 -- Also make an entry in the Local_Entity_Suppress table. See
3828 -- extended description in the package spec of Sem for details.
3830 Local_Entity_Suppress
.Append
3833 Suppress
=> Suppress_Case
));
3835 -- Case of two arguments present, where the check is
3836 -- suppressed for a specified entity (given as the second
3837 -- argument of the pragma)
3840 Check_Optional_Identifier
(Arg2
, Name_On
);
3841 E_Id
:= Expression
(Arg2
);
3844 if not Is_Entity_Name
(E_Id
) then
3846 ("second argument of pragma% must be entity name", Arg2
);
3855 -- Enforce RM 11.5(7) which requires that for a pragma that
3856 -- appears within a package spec, the named entity must be
3857 -- within the package spec. We allow the package name itself
3858 -- to be mentioned since that makes sense, although it is not
3859 -- strictly allowed by 11.5(7).
3862 and then E
/= Current_Scope
3863 and then Scope
(E
) /= Current_Scope
3866 ("entity in pragma% is not in package spec ('R'M 11.5(7))",
3870 -- Loop through homonyms. As noted below, in the case of a package
3871 -- spec, only homonyms within the package spec are considered.
3874 Suppress_Unsuppress_Echeck
(E
, C
);
3876 if Is_Generic_Instance
(E
)
3877 and then Is_Subprogram
(E
)
3878 and then Present
(Alias
(E
))
3880 Suppress_Unsuppress_Echeck
(Alias
(E
), C
);
3883 -- Move to next homonym
3888 -- If we are within a package specification, the
3889 -- pragma only applies to homonyms in the same scope.
3891 exit when In_Package_Spec
3892 and then Scope
(E
) /= Current_Scope
;
3895 end Process_Suppress_Unsuppress
;
3901 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
) is
3903 if Is_Imported
(E
) then
3905 ("cannot export entity& that was previously imported", Arg
);
3907 elsif Present
(Address_Clause
(E
)) then
3909 ("cannot export entity& that has an address clause", Arg
);
3912 Set_Is_Exported
(E
);
3914 -- Generate a reference for entity explicitly, because the
3915 -- identifier may be overloaded and name resolution will not
3918 Generate_Reference
(E
, Arg
);
3920 -- Deal with exporting non-library level entity
3922 if not Is_Library_Level_Entity
(E
) then
3924 -- Not allowed at all for subprograms
3926 if Is_Subprogram
(E
) then
3927 Error_Pragma_Arg
("local subprogram& cannot be exported", Arg
);
3929 -- Otherwise set public and statically allocated
3933 Set_Is_Statically_Allocated
(E
);
3935 -- Warn if the corresponding W flag is set and the pragma
3936 -- comes from source. The latter may not be true e.g. on
3937 -- VMS where we expand export pragmas for exception codes
3938 -- associated with imported or exported exceptions. We do
3939 -- not want to generate a warning for something that the
3940 -- user did not write.
3942 if Warn_On_Export_Import
3943 and then Comes_From_Source
(Arg
)
3946 ("?& has been made static as a result of Export", Arg
, E
);
3948 ("\this usage is non-standard and non-portable", Arg
);
3953 if Warn_On_Export_Import
and then Is_Type
(E
) then
3955 ("exporting a type has no effect?", Arg
, E
);
3958 if Warn_On_Export_Import
and Inside_A_Generic
then
3960 ("all instances of& will have the same external name?", Arg
, E
);
3964 ----------------------------------------------
3965 -- Set_Extended_Import_Export_External_Name --
3966 ----------------------------------------------
3968 procedure Set_Extended_Import_Export_External_Name
3969 (Internal_Ent
: Entity_Id
;
3970 Arg_External
: Node_Id
)
3972 Old_Name
: constant Node_Id
:= Interface_Name
(Internal_Ent
);
3976 if No
(Arg_External
) then
3980 Check_Arg_Is_External_Name
(Arg_External
);
3982 if Nkind
(Arg_External
) = N_String_Literal
then
3983 if String_Length
(Strval
(Arg_External
)) = 0 then
3986 New_Name
:= Adjust_External_Name_Case
(Arg_External
);
3989 elsif Nkind
(Arg_External
) = N_Identifier
then
3990 New_Name
:= Get_Default_External_Name
(Arg_External
);
3992 -- Check_Arg_Is_External_Name should let through only
3993 -- identifiers and string literals or static string
3994 -- expressions (which are folded to string literals).
3997 raise Program_Error
;
4000 -- If we already have an external name set (by a prior normal
4001 -- Import or Export pragma), then the external names must match
4003 if Present
(Interface_Name
(Internal_Ent
)) then
4004 Check_Matching_Internal_Names
: declare
4005 S1
: constant String_Id
:= Strval
(Old_Name
);
4006 S2
: constant String_Id
:= Strval
(New_Name
);
4009 -- Called if names do not match
4015 procedure Mismatch
is
4017 Error_Msg_Sloc
:= Sloc
(Old_Name
);
4019 ("external name does not match that given #",
4023 -- Start of processing for Check_Matching_Internal_Names
4026 if String_Length
(S1
) /= String_Length
(S2
) then
4030 for J
in 1 .. String_Length
(S1
) loop
4031 if Get_String_Char
(S1
, J
) /= Get_String_Char
(S2
, J
) then
4036 end Check_Matching_Internal_Names
;
4038 -- Otherwise set the given name
4041 Set_Encoded_Interface_Name
(Internal_Ent
, New_Name
);
4042 Check_Duplicated_Export_Name
(New_Name
);
4044 end Set_Extended_Import_Export_External_Name
;
4050 procedure Set_Imported
(E
: Entity_Id
) is
4052 Error_Msg_Sloc
:= Sloc
(E
);
4054 if Is_Exported
(E
) or else Is_Imported
(E
) then
4055 Error_Msg_NE
("import of& declared# not allowed", N
, E
);
4057 if Is_Exported
(E
) then
4058 Error_Msg_N
("\entity was previously exported", N
);
4060 Error_Msg_N
("\entity was previously imported", N
);
4063 Error_Pragma
("\(pragma% applies to all previous entities)");
4066 Set_Is_Imported
(E
);
4068 -- If the entity is an object that is not at the library
4069 -- level, then it is statically allocated. We do not worry
4070 -- about objects with address clauses in this context since
4071 -- they are not really imported in the linker sense.
4074 and then not Is_Library_Level_Entity
(E
)
4075 and then No
(Address_Clause
(E
))
4077 Set_Is_Statically_Allocated
(E
);
4082 -------------------------
4083 -- Set_Mechanism_Value --
4084 -------------------------
4086 -- Note: the mechanism name has not been analyzed (and cannot indeed
4087 -- be analyzed, since it is semantic nonsense), so we get it in the
4088 -- exact form created by the parser.
4090 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
) is
4094 procedure Bad_Class
;
4095 -- Signal bad descriptor class name
4097 procedure Bad_Mechanism
;
4098 -- Signal bad mechanism name
4104 procedure Bad_Class
is
4106 Error_Pragma_Arg
("unrecognized descriptor class name", Class
);
4109 -------------------------
4110 -- Bad_Mechanism_Value --
4111 -------------------------
4113 procedure Bad_Mechanism
is
4115 Error_Pragma_Arg
("unrecognized mechanism name", Mech_Name
);
4118 -- Start of processing for Set_Mechanism_Value
4121 if Mechanism
(Ent
) /= Default_Mechanism
then
4123 ("mechanism for & has already been set", Mech_Name
, Ent
);
4126 -- MECHANISM_NAME ::= value | reference | descriptor
4128 if Nkind
(Mech_Name
) = N_Identifier
then
4129 if Chars
(Mech_Name
) = Name_Value
then
4130 Set_Mechanism
(Ent
, By_Copy
);
4133 elsif Chars
(Mech_Name
) = Name_Reference
then
4134 Set_Mechanism
(Ent
, By_Reference
);
4137 elsif Chars
(Mech_Name
) = Name_Descriptor
then
4138 Check_VMS
(Mech_Name
);
4139 Set_Mechanism
(Ent
, By_Descriptor
);
4142 elsif Chars
(Mech_Name
) = Name_Copy
then
4144 ("bad mechanism name, Value assumed", Mech_Name
);
4150 -- MECHANISM_NAME ::= descriptor (CLASS_NAME)
4151 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4153 -- Note: this form is parsed as an indexed component
4155 elsif Nkind
(Mech_Name
) = N_Indexed_Component
then
4156 Class
:= First
(Expressions
(Mech_Name
));
4158 if Nkind
(Prefix
(Mech_Name
)) /= N_Identifier
4159 or else Chars
(Prefix
(Mech_Name
)) /= Name_Descriptor
4160 or else Present
(Next
(Class
))
4165 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME)
4166 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4168 -- Note: this form is parsed as a function call
4170 elsif Nkind
(Mech_Name
) = N_Function_Call
then
4172 Param
:= First
(Parameter_Associations
(Mech_Name
));
4174 if Nkind
(Name
(Mech_Name
)) /= N_Identifier
4175 or else Chars
(Name
(Mech_Name
)) /= Name_Descriptor
4176 or else Present
(Next
(Param
))
4177 or else No
(Selector_Name
(Param
))
4178 or else Chars
(Selector_Name
(Param
)) /= Name_Class
4182 Class
:= Explicit_Actual_Parameter
(Param
);
4189 -- Fall through here with Class set to descriptor class name
4191 Check_VMS
(Mech_Name
);
4193 if Nkind
(Class
) /= N_Identifier
then
4196 elsif Chars
(Class
) = Name_UBS
then
4197 Set_Mechanism
(Ent
, By_Descriptor_UBS
);
4199 elsif Chars
(Class
) = Name_UBSB
then
4200 Set_Mechanism
(Ent
, By_Descriptor_UBSB
);
4202 elsif Chars
(Class
) = Name_UBA
then
4203 Set_Mechanism
(Ent
, By_Descriptor_UBA
);
4205 elsif Chars
(Class
) = Name_S
then
4206 Set_Mechanism
(Ent
, By_Descriptor_S
);
4208 elsif Chars
(Class
) = Name_SB
then
4209 Set_Mechanism
(Ent
, By_Descriptor_SB
);
4211 elsif Chars
(Class
) = Name_A
then
4212 Set_Mechanism
(Ent
, By_Descriptor_A
);
4214 elsif Chars
(Class
) = Name_NCA
then
4215 Set_Mechanism
(Ent
, By_Descriptor_NCA
);
4220 end Set_Mechanism_Value
;
4222 ---------------------------
4223 -- Set_Ravenscar_Profile --
4224 ---------------------------
4226 -- The tasks to be done here are
4228 -- Set required policies
4230 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4231 -- pragma Locking_Policy (Ceiling_Locking)
4233 -- Set Detect_Blocking mode
4235 -- Set required restrictions (see System.Rident for detailed list)
4237 procedure Set_Ravenscar_Profile
(N
: Node_Id
) is
4239 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4241 if Task_Dispatching_Policy
/= ' '
4242 and then Task_Dispatching_Policy
/= 'F'
4244 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
4245 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4247 -- Set the FIFO_Within_Priorities policy, but always preserve
4248 -- System_Location since we like the error message with the run time
4252 Task_Dispatching_Policy
:= 'F';
4254 if Task_Dispatching_Policy_Sloc
/= System_Location
then
4255 Task_Dispatching_Policy_Sloc
:= Loc
;
4259 -- pragma Locking_Policy (Ceiling_Locking)
4261 if Locking_Policy
/= ' '
4262 and then Locking_Policy
/= 'C'
4264 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
4265 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4267 -- Set the Ceiling_Locking policy, but preserve System_Location since
4268 -- we like the error message with the run time name.
4271 Locking_Policy
:= 'C';
4273 if Locking_Policy_Sloc
/= System_Location
then
4274 Locking_Policy_Sloc
:= Loc
;
4278 -- pragma Detect_Blocking
4280 Detect_Blocking
:= True;
4282 -- Set the corresponding restrictions
4284 Set_Profile_Restrictions
(Ravenscar
, N
, Warn
=> False);
4285 end Set_Ravenscar_Profile
;
4287 -- Start of processing for Analyze_Pragma
4290 if not Is_Pragma_Name
(Chars
(N
)) then
4291 if Warn_On_Unrecognized_Pragma
then
4292 Error_Pragma
("unrecognized pragma%?");
4297 Prag_Id
:= Get_Pragma_Id
(Chars
(N
));
4307 if Present
(Pragma_Argument_Associations
(N
)) then
4308 Arg1
:= First
(Pragma_Argument_Associations
(N
));
4310 if Present
(Arg1
) then
4311 Arg2
:= Next
(Arg1
);
4313 if Present
(Arg2
) then
4314 Arg3
:= Next
(Arg2
);
4316 if Present
(Arg3
) then
4317 Arg4
:= Next
(Arg3
);
4323 -- Count number of arguments
4330 while Present
(Arg_Node
) loop
4331 Arg_Count
:= Arg_Count
+ 1;
4336 -- An enumeration type defines the pragmas that are supported by the
4337 -- implementation. Get_Pragma_Id (in package Prag) transorms a name
4338 -- into the corresponding enumeration value for the following case.
4346 -- pragma Abort_Defer;
4348 when Pragma_Abort_Defer
=>
4350 Check_Arg_Count
(0);
4352 -- The only required semantic processing is to check the
4353 -- placement. This pragma must appear at the start of the
4354 -- statement sequence of a handled sequence of statements.
4356 if Nkind
(Parent
(N
)) /= N_Handled_Sequence_Of_Statements
4357 or else N
/= First
(Statements
(Parent
(N
)))
4368 -- Note: this pragma also has some specific processing in Par.Prag
4369 -- because we want to set the Ada version mode during parsing.
4371 when Pragma_Ada_83
=>
4373 Ada_Version
:= Ada_83
;
4374 Ada_Version_Explicit
:= Ada_Version
;
4375 Check_Arg_Count
(0);
4383 -- Note: this pragma also has some specific processing in Par.Prag
4384 -- because we want to set the Ada 83 version mode during parsing.
4386 when Pragma_Ada_95
=>
4388 Ada_Version
:= Ada_95
;
4389 Ada_Version_Explicit
:= Ada_Version
;
4390 Check_Arg_Count
(0);
4392 ---------------------
4393 -- Ada_05/Ada_2005 --
4394 ---------------------
4397 -- pragma Ada_05 (LOCAL_NAME);
4400 -- pragma Ada_2005 (LOCAL_NAME):
4402 -- Note: these pragma also have some specific processing in Par.Prag
4403 -- because we want to set the Ada 2005 version mode during parsing.
4405 when Pragma_Ada_05 | Pragma_Ada_2005
=> declare
4411 if Arg_Count
= 1 then
4412 Check_Arg_Is_Local_Name
(Arg1
);
4413 E_Id
:= Expression
(Arg1
);
4415 if Etype
(E_Id
) = Any_Type
then
4419 Set_Is_Ada_2005
(Entity
(E_Id
));
4422 Check_Arg_Count
(0);
4423 Ada_Version
:= Ada_05
;
4424 Ada_Version_Explicit
:= Ada_05
;
4428 ----------------------
4429 -- All_Calls_Remote --
4430 ----------------------
4432 -- pragma All_Calls_Remote [(library_package_NAME)];
4434 when Pragma_All_Calls_Remote
=> All_Calls_Remote
: declare
4435 Lib_Entity
: Entity_Id
;
4438 Check_Ada_83_Warning
;
4439 Check_Valid_Library_Unit_Pragma
;
4441 if Nkind
(N
) = N_Null_Statement
then
4445 Lib_Entity
:= Find_Lib_Unit_Name
;
4447 -- This pragma should only apply to a RCI unit (RM E.2.3(23))
4449 if Present
(Lib_Entity
)
4450 and then not Debug_Flag_U
4452 if not Is_Remote_Call_Interface
(Lib_Entity
) then
4453 Error_Pragma
("pragma% only apply to rci unit");
4455 -- Set flag for entity of the library unit
4458 Set_Has_All_Calls_Remote
(Lib_Entity
);
4462 end All_Calls_Remote
;
4468 -- pragma Annotate (IDENTIFIER {, ARG});
4469 -- ARG ::= NAME | EXPRESSION
4471 when Pragma_Annotate
=> Annotate
: begin
4473 Check_At_Least_N_Arguments
(1);
4474 Check_Arg_Is_Identifier
(Arg1
);
4477 Arg
: Node_Id
:= Arg2
;
4481 while Present
(Arg
) loop
4482 Exp
:= Expression
(Arg
);
4485 if Is_Entity_Name
(Exp
) then
4488 elsif Nkind
(Exp
) = N_String_Literal
then
4489 Resolve
(Exp
, Standard_String
);
4491 elsif Is_Overloaded
(Exp
) then
4492 Error_Pragma_Arg
("ambiguous argument for pragma%", Exp
);
4507 -- pragma Assert ([Check =>] Boolean_EXPRESSION
4508 -- [, [Message =>] Static_String_EXPRESSION]);
4510 when Pragma_Assert
=>
4511 Check_At_Least_N_Arguments
(1);
4512 Check_At_Most_N_Arguments
(2);
4513 Check_Arg_Order
((Name_Check
, Name_Message
));
4514 Check_Optional_Identifier
(Arg1
, Name_Check
);
4516 if Arg_Count
> 1 then
4517 Check_Optional_Identifier
(Arg2
, Name_Message
);
4518 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
4521 -- If expansion is active and assertions are inactive, then
4522 -- we rewrite the Assertion as:
4524 -- if False and then condition then
4528 -- The reason we do this rewriting during semantic analysis
4529 -- rather than as part of normal expansion is that we cannot
4530 -- analyze and expand the code for the boolean expression
4531 -- directly, or it may cause insertion of actions that would
4532 -- escape the attempt to suppress the assertion code.
4534 if Expander_Active
and not Assertions_Enabled
then
4536 Make_If_Statement
(Loc
,
4539 Left_Opnd
=> New_Occurrence_Of
(Standard_False
, Loc
),
4540 Right_Opnd
=> Get_Pragma_Arg
(Arg1
)),
4541 Then_Statements
=> New_List
(
4542 Make_Null_Statement
(Loc
))));
4546 -- Otherwise (if assertions are enabled, or if we are not
4547 -- operating with expansion active), then we just analyze
4548 -- and resolve the expression.
4551 Analyze_And_Resolve
(Expression
(Arg1
), Any_Boolean
);
4554 ----------------------
4555 -- Assertion_Policy --
4556 ----------------------
4558 -- pragma Assertion_Policy (Check | Ignore)
4560 when Pragma_Assertion_Policy
=>
4561 Check_Arg_Count
(1);
4562 Check_Arg_Is_One_Of
(Arg1
, Name_Check
, Name_Ignore
);
4563 Assertions_Enabled
:= Chars
(Expression
(Arg1
)) = Name_Check
;
4569 -- pragma AST_Entry (entry_IDENTIFIER);
4571 when Pragma_AST_Entry
=> AST_Entry
: declare
4577 Check_Arg_Count
(1);
4578 Check_No_Identifiers
;
4579 Check_Arg_Is_Local_Name
(Arg1
);
4580 Ent
:= Entity
(Expression
(Arg1
));
4582 -- Note: the implementation of the AST_Entry pragma could handle
4583 -- the entry family case fine, but for now we are consistent with
4584 -- the DEC rules, and do not allow the pragma, which of course
4585 -- has the effect of also forbidding the attribute.
4587 if Ekind
(Ent
) /= E_Entry
then
4589 ("pragma% argument must be simple entry name", Arg1
);
4591 elsif Is_AST_Entry
(Ent
) then
4593 ("duplicate % pragma for entry", Arg1
);
4595 elsif Has_Homonym
(Ent
) then
4597 ("pragma% argument cannot specify overloaded entry", Arg1
);
4601 FF
: constant Entity_Id
:= First_Formal
(Ent
);
4604 if Present
(FF
) then
4605 if Present
(Next_Formal
(FF
)) then
4607 ("entry for pragma% can have only one argument",
4610 elsif Parameter_Mode
(FF
) /= E_In_Parameter
then
4612 ("entry parameter for pragma% must have mode IN",
4618 Set_Is_AST_Entry
(Ent
);
4626 -- pragma Asynchronous (LOCAL_NAME);
4628 when Pragma_Asynchronous
=> Asynchronous
: declare
4636 procedure Process_Async_Pragma
;
4637 -- Common processing for procedure and access-to-procedure case
4639 --------------------------
4640 -- Process_Async_Pragma --
4641 --------------------------
4643 procedure Process_Async_Pragma
is
4646 Set_Is_Asynchronous
(Nm
);
4650 -- The formals should be of mode IN (RM E.4.1(6))
4653 while Present
(S
) loop
4654 Formal
:= Defining_Identifier
(S
);
4656 if Nkind
(Formal
) = N_Defining_Identifier
4657 and then Ekind
(Formal
) /= E_In_Parameter
4660 ("pragma% procedure can only have IN parameter",
4667 Set_Is_Asynchronous
(Nm
);
4668 end Process_Async_Pragma
;
4670 -- Start of processing for pragma Asynchronous
4673 Check_Ada_83_Warning
;
4674 Check_No_Identifiers
;
4675 Check_Arg_Count
(1);
4676 Check_Arg_Is_Local_Name
(Arg1
);
4678 if Debug_Flag_U
then
4682 C_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
4683 Analyze
(Expression
(Arg1
));
4684 Nm
:= Entity
(Expression
(Arg1
));
4686 if not Is_Remote_Call_Interface
(C_Ent
)
4687 and then not Is_Remote_Types
(C_Ent
)
4689 -- This pragma should only appear in an RCI or Remote Types
4690 -- unit (RM E.4.1(4))
4693 ("pragma% not in Remote_Call_Interface or " &
4694 "Remote_Types unit");
4697 if Ekind
(Nm
) = E_Procedure
4698 and then Nkind
(Parent
(Nm
)) = N_Procedure_Specification
4700 if not Is_Remote_Call_Interface
(Nm
) then
4702 ("pragma% cannot be applied on non-remote procedure",
4706 L
:= Parameter_Specifications
(Parent
(Nm
));
4707 Process_Async_Pragma
;
4710 elsif Ekind
(Nm
) = E_Function
then
4712 ("pragma% cannot be applied to function", Arg1
);
4714 elsif Is_Remote_Access_To_Subprogram_Type
(Nm
) then
4716 if Is_Record_Type
(Nm
) then
4717 -- A record type that is the Equivalent_Type for
4718 -- a remote access-to-subprogram type.
4720 N
:= Declaration_Node
(Corresponding_Remote_Type
(Nm
));
4723 -- A non-expanded RAS type (case where distribution is
4726 N
:= Declaration_Node
(Nm
);
4729 if Nkind
(N
) = N_Full_Type_Declaration
4730 and then Nkind
(Type_Definition
(N
)) =
4731 N_Access_Procedure_Definition
4733 L
:= Parameter_Specifications
(Type_Definition
(N
));
4734 Process_Async_Pragma
;
4736 if Is_Asynchronous
(Nm
)
4737 and then Expander_Active
4738 and then Get_PCS_Name
/= Name_No_DSA
4740 RACW_Type_Is_Asynchronous
(Underlying_RACW_Type
(Nm
));
4745 ("pragma% cannot reference access-to-function type",
4749 -- Only other possibility is Access-to-class-wide type
4751 elsif Is_Access_Type
(Nm
)
4752 and then Is_Class_Wide_Type
(Designated_Type
(Nm
))
4754 Check_First_Subtype
(Arg1
);
4755 Set_Is_Asynchronous
(Nm
);
4756 if Expander_Active
then
4757 RACW_Type_Is_Asynchronous
(Nm
);
4761 Error_Pragma_Arg
("inappropriate argument for pragma%", Arg1
);
4769 -- pragma Atomic (LOCAL_NAME);
4771 when Pragma_Atomic
=>
4772 Process_Atomic_Shared_Volatile
;
4774 -----------------------
4775 -- Atomic_Components --
4776 -----------------------
4778 -- pragma Atomic_Components (array_LOCAL_NAME);
4780 -- This processing is shared by Volatile_Components
4782 when Pragma_Atomic_Components |
4783 Pragma_Volatile_Components
=>
4785 Atomic_Components
: declare
4792 Check_Ada_83_Warning
;
4793 Check_No_Identifiers
;
4794 Check_Arg_Count
(1);
4795 Check_Arg_Is_Local_Name
(Arg1
);
4796 E_Id
:= Expression
(Arg1
);
4798 if Etype
(E_Id
) = Any_Type
then
4804 if Rep_Item_Too_Early
(E
, N
)
4806 Rep_Item_Too_Late
(E
, N
)
4811 D
:= Declaration_Node
(E
);
4814 if (K
= N_Full_Type_Declaration
and then Is_Array_Type
(E
))
4816 ((Ekind
(E
) = E_Constant
or else Ekind
(E
) = E_Variable
)
4817 and then Nkind
(D
) = N_Object_Declaration
4818 and then Nkind
(Object_Definition
(D
)) =
4819 N_Constrained_Array_Definition
)
4821 -- The flag is set on the object, or on the base type
4823 if Nkind
(D
) /= N_Object_Declaration
then
4827 Set_Has_Volatile_Components
(E
);
4829 if Prag_Id
= Pragma_Atomic_Components
then
4830 Set_Has_Atomic_Components
(E
);
4832 if Is_Packed
(E
) then
4833 Set_Is_Packed
(E
, False);
4836 ("?Pack canceled, cannot pack atomic components",
4842 Error_Pragma_Arg
("inappropriate entity for pragma%", Arg1
);
4844 end Atomic_Components
;
4846 --------------------
4847 -- Attach_Handler --
4848 --------------------
4850 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
4852 when Pragma_Attach_Handler
=>
4853 Check_Ada_83_Warning
;
4854 Check_No_Identifiers
;
4855 Check_Arg_Count
(2);
4857 if No_Run_Time_Mode
then
4858 Error_Msg_CRT
("Attach_Handler pragma", N
);
4860 Check_Interrupt_Or_Attach_Handler
;
4862 -- The expression that designates the attribute may
4863 -- depend on a discriminant, and is therefore a per-
4864 -- object expression, to be expanded in the init proc.
4865 -- If expansion is enabled, perform semantic checks
4868 if Expander_Active
then
4870 Temp
: constant Node_Id
:=
4871 New_Copy_Tree
(Expression
(Arg2
));
4873 Set_Parent
(Temp
, N
);
4874 Pre_Analyze_And_Resolve
(Temp
, RTE
(RE_Interrupt_ID
));
4878 Analyze
(Expression
(Arg2
));
4879 Resolve
(Expression
(Arg2
), RTE
(RE_Interrupt_ID
));
4882 Process_Interrupt_Or_Attach_Handler
;
4885 --------------------
4886 -- C_Pass_By_Copy --
4887 --------------------
4889 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
4891 when Pragma_C_Pass_By_Copy
=> C_Pass_By_Copy
: declare
4897 Check_Valid_Configuration_Pragma
;
4898 Check_Arg_Count
(1);
4899 Check_Optional_Identifier
(Arg1
, "max_size");
4901 Arg
:= Expression
(Arg1
);
4902 Check_Arg_Is_Static_Expression
(Arg
, Any_Integer
);
4904 Val
:= Expr_Value
(Arg
);
4908 ("maximum size for pragma% must be positive", Arg1
);
4910 elsif UI_Is_In_Int_Range
(Val
) then
4911 Default_C_Record_Mechanism
:= UI_To_Int
(Val
);
4913 -- If a giant value is given, Int'Last will do well enough.
4914 -- If sometime someone complains that a record larger than
4915 -- two gigabytes is not copied, we will worry about it then!
4918 Default_C_Record_Mechanism
:= Mechanism_Type
'Last;
4926 -- pragma Comment (static_string_EXPRESSION)
4928 -- Processing for pragma Comment shares the circuitry for
4929 -- pragma Ident. The only differences are that Ident enforces
4930 -- a limit of 31 characters on its argument, and also enforces
4931 -- limitations on placement for DEC compatibility. Pragma
4932 -- Comment shares neither of these restrictions.
4938 -- pragma Common_Object (
4939 -- [Internal =>] LOCAL_NAME,
4940 -- [, [External =>] EXTERNAL_SYMBOL]
4941 -- [, [Size =>] EXTERNAL_SYMBOL]);
4943 -- Processing for this pragma is shared with Psect_Object
4945 --------------------------
4946 -- Compile_Time_Warning --
4947 --------------------------
4949 -- pragma Compile_Time_Warning
4950 -- (boolean_EXPRESSION, static_string_EXPRESSION);
4952 when Pragma_Compile_Time_Warning
=> Compile_Time_Warning
: declare
4953 Arg1x
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
4957 Check_Arg_Count
(2);
4958 Check_No_Identifiers
;
4959 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
4960 Analyze_And_Resolve
(Arg1x
, Standard_Boolean
);
4962 if Compile_Time_Known_Value
(Arg1x
) then
4963 if Is_True
(Expr_Value
(Get_Pragma_Arg
(Arg1
))) then
4964 String_To_Name_Buffer
(Strval
(Get_Pragma_Arg
(Arg2
)));
4965 Add_Char_To_Name_Buffer
('?');
4968 Msg
: String (1 .. Name_Len
) :=
4969 Name_Buffer
(1 .. Name_Len
);
4974 -- This loop looks for multiple lines separated by
4975 -- ASCII.LF and breaks them into continuation error
4976 -- messages marked with the usual back slash.
4979 for S
in 2 .. Msg
'Length - 1 loop
4980 if Msg
(S
) = ASCII
.LF
then
4982 Error_Msg_N
(Msg
(B
.. S
), Arg1
);
4988 Error_Msg_N
(Msg
(B
.. Msg
'Length), Arg1
);
4992 end Compile_Time_Warning
;
4994 -----------------------------
4995 -- Complete_Representation --
4996 -----------------------------
4998 -- pragma Complete_Representation;
5000 when Pragma_Complete_Representation
=>
5002 Check_Arg_Count
(0);
5004 if Nkind
(Parent
(N
)) /= N_Record_Representation_Clause
then
5006 ("pragma & must appear within record representation clause");
5009 ----------------------------
5010 -- Complex_Representation --
5011 ----------------------------
5013 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
5015 when Pragma_Complex_Representation
=> Complex_Representation
: declare
5022 Check_Arg_Count
(1);
5023 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5024 Check_Arg_Is_Local_Name
(Arg1
);
5025 E_Id
:= Expression
(Arg1
);
5027 if Etype
(E_Id
) = Any_Type
then
5033 if not Is_Record_Type
(E
) then
5035 ("argument for pragma% must be record type", Arg1
);
5038 Ent
:= First_Entity
(E
);
5041 or else No
(Next_Entity
(Ent
))
5042 or else Present
(Next_Entity
(Next_Entity
(Ent
)))
5043 or else not Is_Floating_Point_Type
(Etype
(Ent
))
5044 or else Etype
(Ent
) /= Etype
(Next_Entity
(Ent
))
5047 ("record for pragma% must have two fields of same fpt type",
5051 Set_Has_Complex_Representation
(Base_Type
(E
));
5053 end Complex_Representation
;
5055 -------------------------
5056 -- Component_Alignment --
5057 -------------------------
5059 -- pragma Component_Alignment (
5060 -- [Form =>] ALIGNMENT_CHOICE
5061 -- [, [Name =>] type_LOCAL_NAME]);
5063 -- ALIGNMENT_CHOICE ::=
5065 -- | Component_Size_4
5069 when Pragma_Component_Alignment
=> Component_AlignmentP
: declare
5070 Args
: Args_List
(1 .. 2);
5071 Names
: constant Name_List
(1 .. 2) := (
5075 Form
: Node_Id
renames Args
(1);
5076 Name
: Node_Id
renames Args
(2);
5078 Atype
: Component_Alignment_Kind
;
5083 Gather_Associations
(Names
, Args
);
5086 Error_Pragma
("missing Form argument for pragma%");
5089 Check_Arg_Is_Identifier
(Form
);
5091 -- Get proper alignment, note that Default = Component_Size
5092 -- on all machines we have so far, and we want to set this
5093 -- value rather than the default value to indicate that it
5094 -- has been explicitly set (and thus will not get overridden
5095 -- by the default component alignment for the current scope)
5097 if Chars
(Form
) = Name_Component_Size
then
5098 Atype
:= Calign_Component_Size
;
5100 elsif Chars
(Form
) = Name_Component_Size_4
then
5101 Atype
:= Calign_Component_Size_4
;
5103 elsif Chars
(Form
) = Name_Default
then
5104 Atype
:= Calign_Component_Size
;
5106 elsif Chars
(Form
) = Name_Storage_Unit
then
5107 Atype
:= Calign_Storage_Unit
;
5111 ("invalid Form parameter for pragma%", Form
);
5114 -- Case with no name, supplied, affects scope table entry
5118 (Scope_Stack
.Last
).Component_Alignment_Default
:= Atype
;
5120 -- Case of name supplied
5123 Check_Arg_Is_Local_Name
(Name
);
5125 Typ
:= Entity
(Name
);
5128 or else Rep_Item_Too_Early
(Typ
, N
)
5132 Typ
:= Underlying_Type
(Typ
);
5135 if not Is_Record_Type
(Typ
)
5136 and then not Is_Array_Type
(Typ
)
5139 ("Name parameter of pragma% must identify record or " &
5140 "array type", Name
);
5143 -- An explicit Component_Alignment pragma overrides an
5144 -- implicit pragma Pack, but not an explicit one.
5146 if not Has_Pragma_Pack
(Base_Type
(Typ
)) then
5147 Set_Is_Packed
(Base_Type
(Typ
), False);
5148 Set_Component_Alignment
(Base_Type
(Typ
), Atype
);
5151 end Component_AlignmentP
;
5157 -- pragma Controlled (first_subtype_LOCAL_NAME);
5159 when Pragma_Controlled
=> Controlled
: declare
5163 Check_No_Identifiers
;
5164 Check_Arg_Count
(1);
5165 Check_Arg_Is_Local_Name
(Arg1
);
5166 Arg
:= Expression
(Arg1
);
5168 if not Is_Entity_Name
(Arg
)
5169 or else not Is_Access_Type
(Entity
(Arg
))
5171 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
5173 Set_Has_Pragma_Controlled
(Base_Type
(Entity
(Arg
)));
5181 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
5182 -- [Entity =>] LOCAL_NAME);
5184 when Pragma_Convention
=> Convention
: declare
5188 Check_Arg_Order
((Name_Convention
, Name_Entity
));
5189 Check_Ada_83_Warning
;
5190 Check_Arg_Count
(2);
5191 Process_Convention
(C
, E
);
5194 ---------------------------
5195 -- Convention_Identifier --
5196 ---------------------------
5198 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
5199 -- [Convention =>] convention_IDENTIFIER);
5201 when Pragma_Convention_Identifier
=> Convention_Identifier
: declare
5207 Check_Arg_Order
((Name_Name
, Name_Convention
));
5208 Check_Arg_Count
(2);
5209 Check_Optional_Identifier
(Arg1
, Name_Name
);
5210 Check_Optional_Identifier
(Arg2
, Name_Convention
);
5211 Check_Arg_Is_Identifier
(Arg1
);
5212 Check_Arg_Is_Identifier
(Arg1
);
5213 Idnam
:= Chars
(Expression
(Arg1
));
5214 Cname
:= Chars
(Expression
(Arg2
));
5216 if Is_Convention_Name
(Cname
) then
5217 Record_Convention_Identifier
5218 (Idnam
, Get_Convention_Id
(Cname
));
5221 ("second arg for % pragma must be convention", Arg2
);
5223 end Convention_Identifier
;
5229 -- pragma CPP_Class ([Entity =>] local_NAME)
5231 when Pragma_CPP_Class
=> CPP_Class
: declare
5234 Default_DTC
: Entity_Id
:= Empty
;
5235 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
5241 Check_Arg_Count
(1);
5242 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5243 Check_Arg_Is_Local_Name
(Arg1
);
5245 Arg
:= Expression
(Arg1
);
5248 if Etype
(Arg
) = Any_Type
then
5252 if not Is_Entity_Name
(Arg
)
5253 or else not Is_Type
(Entity
(Arg
))
5255 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
5258 Typ
:= Entity
(Arg
);
5260 if not Is_Record_Type
(Typ
) then
5261 Error_Pragma_Arg
("pragma% applicable to a record, "
5262 & "tagged record or record extension", Arg1
);
5265 Default_DTC
:= First_Component
(Typ
);
5266 while Present
(Default_DTC
)
5267 and then Etype
(Default_DTC
) /= VTP_Type
5269 Next_Component
(Default_DTC
);
5272 -- Case of non tagged type
5274 if not Is_Tagged_Type
(Typ
) then
5275 Set_Is_CPP_Class
(Typ
);
5277 if Present
(Default_DTC
) then
5279 ("only tagged records can contain vtable pointers", Arg1
);
5282 -- Case of tagged type with no user-defined vtable ptr. In this
5283 -- case, because of our C++ ABI compatibility, the programmer
5284 -- does not need to specify the tag component.
5286 elsif Is_Tagged_Type
(Typ
)
5287 and then No
(Default_DTC
)
5289 Set_Is_CPP_Class
(Typ
);
5290 Set_Is_Limited_Record
(Typ
);
5292 -- Tagged type that has a vtable ptr
5294 elsif Present
(Default_DTC
) then
5295 Set_Is_CPP_Class
(Typ
);
5296 Set_Is_Limited_Record
(Typ
);
5297 Set_Is_Tag
(Default_DTC
);
5298 Set_DT_Entry_Count
(Default_DTC
, No_Uint
);
5300 -- Since a CPP type has no direct link to its associated tag
5301 -- most tags checks cannot be performed
5303 Set_Kill_Tag_Checks
(Typ
);
5304 Set_Kill_Tag_Checks
(Class_Wide_Type
(Typ
));
5306 -- Get rid of the _tag component when there was one.
5307 -- It is only useful for regular tagged types
5309 if Expander_Active
and then Typ
= Root_Type
(Typ
) then
5311 Tag_C
:= First_Tag_Component
(Typ
);
5312 C
:= First_Entity
(Typ
);
5315 Set_First_Entity
(Typ
, Next_Entity
(Tag_C
));
5318 while Next_Entity
(C
) /= Tag_C
loop
5322 Set_Next_Entity
(C
, Next_Entity
(Tag_C
));
5328 ---------------------
5329 -- CPP_Constructor --
5330 ---------------------
5332 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
5334 when Pragma_CPP_Constructor
=> CPP_Constructor
: declare
5340 Check_Arg_Count
(1);
5341 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5342 Check_Arg_Is_Local_Name
(Arg1
);
5344 Id
:= Expression
(Arg1
);
5345 Find_Program_Unit_Name
(Id
);
5347 -- If we did not find the name, we are done
5349 if Etype
(Id
) = Any_Type
then
5353 Def_Id
:= Entity
(Id
);
5355 if Ekind
(Def_Id
) = E_Function
5356 and then Is_Class_Wide_Type
(Etype
(Def_Id
))
5357 and then Is_CPP_Class
(Etype
(Etype
(Def_Id
)))
5359 -- What the heck is this??? this pragma allows only 1 arg
5361 if Arg_Count
>= 2 then
5362 Check_At_Most_N_Arguments
(3);
5363 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
5366 if No
(Parameter_Specifications
(Parent
(Def_Id
))) then
5367 Set_Has_Completion
(Def_Id
);
5368 Set_Is_Constructor
(Def_Id
);
5371 ("non-default constructors not implemented", Arg1
);
5376 ("pragma% requires function returning a 'C'P'P_Class type",
5379 end CPP_Constructor
;
5385 -- pragma CPP_Virtual
5386 -- [Entity =>] LOCAL_NAME
5387 -- [ [Vtable_Ptr =>] LOCAL_NAME,
5388 -- [Position =>] static_integer_EXPRESSION]);
5390 when Pragma_CPP_Virtual
=> CPP_Virtual
: declare
5394 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
5400 Check_Arg_Order
((Name_Entity
, Name_Vtable_Ptr
, Name_Position
));
5402 if Arg_Count
= 3 then
5403 Check_Optional_Identifier
(Arg2
, Name_Vtable_Ptr
);
5405 -- We allow Entry_Count as well as Position for the third
5406 -- parameter for back compatibility with versions of GNAT
5407 -- before version 3.12. The documentation has always said
5408 -- Position, but the code up to 3.12 said Entry_Count.
5410 if Chars
(Arg3
) /= Name_Entry_Count
then
5411 Check_Optional_Identifier
(Arg3
, Name_Position
);
5415 Check_Arg_Count
(1);
5418 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5419 Check_Arg_Is_Local_Name
(Arg1
);
5421 -- First argument must be a subprogram name
5423 Arg
:= Expression
(Arg1
);
5424 Find_Program_Unit_Name
(Arg
);
5426 if Etype
(Arg
) = Any_Type
then
5429 Subp
:= Entity
(Arg
);
5432 if not (Is_Subprogram
(Subp
)
5433 and then Is_Dispatching_Operation
(Subp
))
5436 ("pragma% must reference a primitive operation", Arg1
);
5439 Typ
:= Find_Dispatching_Type
(Subp
);
5441 -- If only one Argument defaults are :
5442 -- . DTC_Entity is the default Vtable pointer
5443 -- . DT_Position will be set at the freezing point
5445 if Arg_Count
= 1 then
5446 Set_DTC_Entity
(Subp
, First_Tag_Component
(Typ
));
5450 -- Second argument is a component name of type Vtable_Ptr
5452 Arg
:= Expression
(Arg2
);
5454 if Nkind
(Arg
) /= N_Identifier
then
5455 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5459 DTC
:= First_Component
(Typ
);
5460 while Present
(DTC
) and then Chars
(DTC
) /= Chars
(Arg
) loop
5461 Next_Component
(DTC
);
5464 -- Case of tagged type with no user-defined vtable ptr
5467 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5470 elsif Etype
(DTC
) /= VTP_Type
then
5471 Wrong_Type
(Arg
, VTP_Type
);
5475 -- Third argument is an integer (DT_Position)
5477 Arg
:= Expression
(Arg3
);
5478 Analyze_And_Resolve
(Arg
, Any_Integer
);
5480 if not Is_Static_Expression
(Arg
) then
5481 Flag_Non_Static_Expr
5482 ("third argument of pragma CPP_Virtual must be static!",
5487 V
:= Expr_Value
(Expression
(Arg3
));
5491 ("third argument of pragma% must be positive",
5495 Set_DTC_Entity
(Subp
, DTC
);
5496 Set_DT_Position
(Subp
, V
);
5505 -- pragma CPP_Vtable (
5506 -- [Entity =>] LOCAL_NAME
5507 -- [Vtable_Ptr =>] LOCAL_NAME,
5508 -- [Entry_Count =>] static_integer_EXPRESSION);
5510 when Pragma_CPP_Vtable
=> CPP_Vtable
: declare
5513 VTP_Type
: constant Entity_Id
:= RTE
(RE_Vtable_Ptr
);
5520 Check_Arg_Order
((Name_Entity
, Name_Vtable_Ptr
, Name_Entry_Count
));
5521 Check_Arg_Count
(3);
5522 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5523 Check_Optional_Identifier
(Arg2
, Name_Vtable_Ptr
);
5524 Check_Optional_Identifier
(Arg3
, Name_Entry_Count
);
5525 Check_Arg_Is_Local_Name
(Arg1
);
5527 -- First argument is a record type name
5529 Arg
:= Expression
(Arg1
);
5532 if Etype
(Arg
) = Any_Type
then
5535 Typ
:= Entity
(Arg
);
5538 if not (Is_Tagged_Type
(Typ
) and then Is_CPP_Class
(Typ
)) then
5539 Error_Pragma_Arg
("'C'P'P_Class tagged type expected", Arg1
);
5542 -- Second argument is a component name of type Vtable_Ptr
5544 Arg
:= Expression
(Arg2
);
5546 if Nkind
(Arg
) /= N_Identifier
then
5547 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5551 DTC
:= First_Component
(Typ
);
5552 while Present
(DTC
) and then Chars
(DTC
) /= Chars
(Arg
) loop
5553 Next_Component
(DTC
);
5557 Error_Msg_NE
("must be a& component name", Arg
, Typ
);
5560 elsif Etype
(DTC
) /= VTP_Type
then
5561 Wrong_Type
(DTC
, VTP_Type
);
5564 -- If it is the first pragma Vtable, This becomes the default tag
5566 elsif (not Is_Tag
(DTC
))
5567 and then DT_Entry_Count
(First_Tag_Component
(Typ
)) = No_Uint
5569 Set_Is_Tag
(First_Tag_Component
(Typ
), False);
5570 Set_Is_Tag
(DTC
, True);
5571 Set_DT_Entry_Count
(DTC
, No_Uint
);
5574 -- Those pragmas must appear before any primitive operation
5575 -- definition (except inherited ones) otherwise the default
5578 Elmt
:= First_Elmt
(Primitive_Operations
(Typ
));
5579 while Present
(Elmt
) loop
5580 if No
(Alias
(Node
(Elmt
))) then
5581 Error_Msg_Sloc
:= Sloc
(Node
(Elmt
));
5583 ("pragma% must appear before this primitive operation");
5589 -- Third argument is an integer (DT_Entry_Count)
5591 Arg
:= Expression
(Arg3
);
5592 Analyze_And_Resolve
(Arg
, Any_Integer
);
5594 if not Is_Static_Expression
(Arg
) then
5595 Flag_Non_Static_Expr
5596 ("entry count for pragma CPP_Vtable must be a static " &
5597 "expression!", Arg3
);
5601 V
:= Expr_Value
(Expression
(Arg3
));
5605 ("entry count for pragma% must be positive", Arg3
);
5607 Set_DT_Entry_Count
(DTC
, V
);
5616 -- pragma Debug ([boolean_EXPRESSION,] PROCEDURE_CALL_STATEMENT);
5618 when Pragma_Debug
=> Debug
: declare
5626 (Boolean_Literals
(Debug_Pragmas_Enabled
and Expander_Active
),
5629 if Arg_Count
= 2 then
5632 Left_Opnd
=> Relocate_Node
(Cond
),
5633 Right_Opnd
=> Expression
(Arg1
));
5636 -- Rewrite into a conditional with an appropriate condition. We
5637 -- wrap the procedure call in a block so that overhead from e.g.
5638 -- use of the secondary stack does not generate execution overhead
5639 -- for suppressed conditions.
5641 Rewrite
(N
, Make_Implicit_If_Statement
(N
,
5643 Then_Statements
=> New_List
(
5644 Make_Block_Statement
(Loc
,
5645 Handled_Statement_Sequence
=>
5646 Make_Handled_Sequence_Of_Statements
(Loc
,
5647 Statements
=> New_List
(
5648 Relocate_Node
(Debug_Statement
(N
))))))));
5656 -- pragma Debug_Policy (Check | Ignore)
5658 when Pragma_Debug_Policy
=>
5660 Check_Arg_Count
(1);
5661 Check_Arg_Is_One_Of
(Arg1
, Name_Check
, Name_Ignore
);
5662 Debug_Pragmas_Enabled
:= Chars
(Expression
(Arg1
)) = Name_Check
;
5664 ---------------------
5665 -- Detect_Blocking --
5666 ---------------------
5668 -- pragma Detect_Blocking;
5670 when Pragma_Detect_Blocking
=>
5672 Check_Arg_Count
(0);
5673 Check_Valid_Configuration_Pragma
;
5674 Detect_Blocking
:= True;
5680 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
5682 when Pragma_Discard_Names
=> Discard_Names
: declare
5687 Check_Ada_83_Warning
;
5689 -- Deal with configuration pragma case
5691 if Arg_Count
= 0 and then Is_Configuration_Pragma
then
5692 Global_Discard_Names
:= True;
5695 -- Otherwise, check correct appropriate context
5698 Check_Is_In_Decl_Part_Or_Package_Spec
;
5700 if Arg_Count
= 0 then
5702 -- If there is no parameter, then from now on this pragma
5703 -- applies to any enumeration, exception or tagged type
5704 -- defined in the current declarative part.
5706 Set_Discard_Names
(Current_Scope
);
5710 Check_Arg_Count
(1);
5711 Check_Optional_Identifier
(Arg1
, Name_On
);
5712 Check_Arg_Is_Local_Name
(Arg1
);
5713 E_Id
:= Expression
(Arg1
);
5715 if Etype
(E_Id
) = Any_Type
then
5721 if (Is_First_Subtype
(E
)
5722 and then (Is_Enumeration_Type
(E
)
5723 or else Is_Tagged_Type
(E
)))
5724 or else Ekind
(E
) = E_Exception
5726 Set_Discard_Names
(E
);
5729 ("inappropriate entity for pragma%", Arg1
);
5739 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
5741 when Pragma_Elaborate
=> Elaborate
: declare
5743 Parent_Node
: Node_Id
;
5748 -- Pragma must be in context items list of a compilation unit
5750 if not Is_List_Member
(N
) then
5755 Plist
:= List_Containing
(N
);
5756 Parent_Node
:= Parent
(Plist
);
5758 if Parent_Node
= Empty
5759 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
5760 or else Context_Items
(Parent_Node
) /= Plist
5767 -- Must be at least one argument
5769 if Arg_Count
= 0 then
5770 Error_Pragma
("pragma% requires at least one argument");
5773 -- In Ada 83 mode, there can be no items following it in the
5774 -- context list except other pragmas and implicit with clauses
5775 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
5776 -- placement rule does not apply.
5778 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
5781 while Present
(Citem
) loop
5782 if Nkind
(Citem
) = N_Pragma
5783 or else (Nkind
(Citem
) = N_With_Clause
5784 and then Implicit_With
(Citem
))
5789 ("(Ada 83) pragma% must be at end of context clause");
5796 -- Finally, the arguments must all be units mentioned in a with
5797 -- clause in the same context clause. Note we already checked
5798 -- (in Par.Prag) that the arguments are either identifiers or
5801 Outer
: while Present
(Arg
) loop
5802 Citem
:= First
(Plist
);
5804 Inner
: while Citem
/= N
loop
5805 if Nkind
(Citem
) = N_With_Clause
5806 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
5808 Set_Elaborate_Present
(Citem
, True);
5809 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
5811 -- With the pragma present, elaboration calls on
5812 -- subprograms from the named unit need no further
5813 -- checks, as long as the pragma appears in the current
5814 -- compilation unit. If the pragma appears in some unit
5815 -- in the context, there might still be a need for an
5816 -- Elaborate_All_Desirable from the current compilation
5817 -- to the the named unit, so we keep the check enabled.
5819 if In_Extended_Main_Source_Unit
(N
) then
5820 Set_Suppress_Elaboration_Warnings
5821 (Entity
(Name
(Citem
)));
5831 ("argument of pragma% is not with'ed unit", Arg
);
5837 -- Give a warning if operating in static mode with -gnatwl
5838 -- (elaboration warnings eanbled) switch set.
5840 if Elab_Warnings
and not Dynamic_Elaboration_Checks
then
5842 ("?use of pragma Elaborate may not be safe", N
);
5844 ("?use pragma Elaborate_All instead if possible", N
);
5852 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
5854 when Pragma_Elaborate_All
=> Elaborate_All
: declare
5856 Parent_Node
: Node_Id
;
5861 Check_Ada_83_Warning
;
5863 -- Pragma must be in context items list of a compilation unit
5865 if not Is_List_Member
(N
) then
5870 Plist
:= List_Containing
(N
);
5871 Parent_Node
:= Parent
(Plist
);
5873 if Parent_Node
= Empty
5874 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
5875 or else Context_Items
(Parent_Node
) /= Plist
5882 -- Must be at least one argument
5884 if Arg_Count
= 0 then
5885 Error_Pragma
("pragma% requires at least one argument");
5888 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
5889 -- have to appear at the end of the context clause, but may
5890 -- appear mixed in with other items, even in Ada 83 mode.
5892 -- Final check: the arguments must all be units mentioned in
5893 -- a with clause in the same context clause. Note that we
5894 -- already checked (in Par.Prag) that all the arguments are
5895 -- either identifiers or selected components.
5898 Outr
: while Present
(Arg
) loop
5899 Citem
:= First
(Plist
);
5901 Innr
: while Citem
/= N
loop
5902 if Nkind
(Citem
) = N_With_Clause
5903 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
5905 Set_Elaborate_All_Present
(Citem
, True);
5906 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
5908 -- Suppress warnings and elaboration checks on the named
5909 -- unit if the pragma is in the current compilation, as
5910 -- for pragma Elaborate.
5912 if In_Extended_Main_Source_Unit
(N
) then
5913 Set_Suppress_Elaboration_Warnings
5914 (Entity
(Name
(Citem
)));
5923 Set_Error_Posted
(N
);
5925 ("argument of pragma% is not with'ed unit", Arg
);
5932 --------------------
5933 -- Elaborate_Body --
5934 --------------------
5936 -- pragma Elaborate_Body [( library_unit_NAME )];
5938 when Pragma_Elaborate_Body
=> Elaborate_Body
: declare
5939 Cunit_Node
: Node_Id
;
5940 Cunit_Ent
: Entity_Id
;
5943 Check_Ada_83_Warning
;
5944 Check_Valid_Library_Unit_Pragma
;
5946 if Nkind
(N
) = N_Null_Statement
then
5950 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
5951 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
5953 if Nkind
(Unit
(Cunit_Node
)) = N_Package_Body
5955 Nkind
(Unit
(Cunit_Node
)) = N_Subprogram_Body
5957 Error_Pragma
("pragma% must refer to a spec, not a body");
5959 Set_Body_Required
(Cunit_Node
, True);
5960 Set_Has_Pragma_Elaborate_Body
(Cunit_Ent
);
5962 -- If we are in dynamic elaboration mode, then we suppress
5963 -- elaboration warnings for the unit, since it is definitely
5964 -- fine NOT to do dynamic checks at the first level (and such
5965 -- checks will be suppressed because no elaboration boolean
5966 -- is created for Elaborate_Body packages).
5968 -- But in the static model of elaboration, Elaborate_Body is
5969 -- definitely NOT good enough to ensure elaboration safety on
5970 -- its own, since the body may WITH other units that are not
5971 -- safe from an elaboration point of view, so a client must
5972 -- still do an Elaborate_All on such units.
5974 -- Debug flag -gnatdD restores the old behavior of 3.13,
5975 -- where Elaborate_Body always suppressed elab warnings.
5977 if Dynamic_Elaboration_Checks
or Debug_Flag_DD
then
5978 Set_Suppress_Elaboration_Warnings
(Cunit_Ent
);
5983 ------------------------
5984 -- Elaboration_Checks --
5985 ------------------------
5987 -- pragma Elaboration_Checks (Static | Dynamic);
5989 when Pragma_Elaboration_Checks
=>
5991 Check_Arg_Count
(1);
5992 Check_Arg_Is_One_Of
(Arg1
, Name_Static
, Name_Dynamic
);
5993 Dynamic_Elaboration_Checks
:=
5994 (Chars
(Get_Pragma_Arg
(Arg1
)) = Name_Dynamic
);
6000 -- pragma Eliminate (
6001 -- [Unit_Name =>] IDENTIFIER |
6002 -- SELECTED_COMPONENT
6003 -- [,[Entity =>] IDENTIFIER |
6004 -- SELECTED_COMPONENT |
6006 -- [,]OVERLOADING_RESOLUTION);
6008 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
6011 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
6014 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
6016 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
6017 -- Result_Type => result_SUBTYPE_NAME]
6019 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
6020 -- SUBTYPE_NAME ::= STRING_LITERAL
6022 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
6023 -- SOURCE_TRACE ::= STRING_LITERAL
6025 when Pragma_Eliminate
=> Eliminate
: declare
6026 Args
: Args_List
(1 .. 5);
6027 Names
: constant Name_List
(1 .. 5) := (
6030 Name_Parameter_Types
,
6032 Name_Source_Location
);
6034 Unit_Name
: Node_Id
renames Args
(1);
6035 Entity
: Node_Id
renames Args
(2);
6036 Parameter_Types
: Node_Id
renames Args
(3);
6037 Result_Type
: Node_Id
renames Args
(4);
6038 Source_Location
: Node_Id
renames Args
(5);
6042 Check_Valid_Configuration_Pragma
;
6043 Gather_Associations
(Names
, Args
);
6045 if No
(Unit_Name
) then
6046 Error_Pragma
("missing Unit_Name argument for pragma%");
6050 and then (Present
(Parameter_Types
)
6052 Present
(Result_Type
)
6054 Present
(Source_Location
))
6056 Error_Pragma
("missing Entity argument for pragma%");
6059 if (Present
(Parameter_Types
)
6061 Present
(Result_Type
))
6063 Present
(Source_Location
)
6066 ("parameter profile and source location cannot " &
6067 "be used together in pragma%");
6070 Process_Eliminate_Pragma
6079 -------------------------
6080 -- Explicit_Overriding --
6081 -------------------------
6083 when Pragma_Explicit_Overriding
=>
6084 Check_Valid_Configuration_Pragma
;
6085 Check_Arg_Count
(0);
6086 Explicit_Overriding
:= True;
6093 -- [ Convention =>] convention_IDENTIFIER,
6094 -- [ Entity =>] local_NAME
6095 -- [, [External_Name =>] static_string_EXPRESSION ]
6096 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6098 when Pragma_Export
=> Export
: declare
6103 Check_Ada_83_Warning
;
6109 Check_At_Least_N_Arguments
(2);
6110 Check_At_Most_N_Arguments
(4);
6111 Process_Convention
(C
, Def_Id
);
6113 if Ekind
(Def_Id
) /= E_Constant
then
6114 Note_Possible_Modification
(Expression
(Arg2
));
6117 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
6118 Set_Exported
(Def_Id
, Arg2
);
6121 ----------------------
6122 -- Export_Exception --
6123 ----------------------
6125 -- pragma Export_Exception (
6126 -- [Internal =>] LOCAL_NAME,
6127 -- [, [External =>] EXTERNAL_SYMBOL,]
6128 -- [, [Form =>] Ada | VMS]
6129 -- [, [Code =>] static_integer_EXPRESSION]);
6131 when Pragma_Export_Exception
=> Export_Exception
: declare
6132 Args
: Args_List
(1 .. 4);
6133 Names
: constant Name_List
(1 .. 4) := (
6139 Internal
: Node_Id
renames Args
(1);
6140 External
: Node_Id
renames Args
(2);
6141 Form
: Node_Id
renames Args
(3);
6142 Code
: Node_Id
renames Args
(4);
6145 if Inside_A_Generic
then
6146 Error_Pragma
("pragma% cannot be used for generic entities");
6149 Gather_Associations
(Names
, Args
);
6150 Process_Extended_Import_Export_Exception_Pragma
(
6151 Arg_Internal
=> Internal
,
6152 Arg_External
=> External
,
6156 if not Is_VMS_Exception
(Entity
(Internal
)) then
6157 Set_Exported
(Entity
(Internal
), Internal
);
6159 end Export_Exception
;
6161 ---------------------
6162 -- Export_Function --
6163 ---------------------
6165 -- pragma Export_Function (
6166 -- [Internal =>] LOCAL_NAME,
6167 -- [, [External =>] EXTERNAL_SYMBOL,]
6168 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6169 -- [, [Result_Type =>] TYPE_DESIGNATOR]
6170 -- [, [Mechanism =>] MECHANISM]
6171 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
6173 -- EXTERNAL_SYMBOL ::=
6175 -- | static_string_EXPRESSION
6177 -- PARAMETER_TYPES ::=
6179 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6181 -- TYPE_DESIGNATOR ::=
6183 -- | subtype_Name ' Access
6187 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6189 -- MECHANISM_ASSOCIATION ::=
6190 -- [formal_parameter_NAME =>] MECHANISM_NAME
6192 -- MECHANISM_NAME ::=
6195 -- | Descriptor [([Class =>] CLASS_NAME)]
6197 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6199 when Pragma_Export_Function
=> Export_Function
: declare
6200 Args
: Args_List
(1 .. 6);
6201 Names
: constant Name_List
(1 .. 6) := (
6204 Name_Parameter_Types
,
6207 Name_Result_Mechanism
);
6209 Internal
: Node_Id
renames Args
(1);
6210 External
: Node_Id
renames Args
(2);
6211 Parameter_Types
: Node_Id
renames Args
(3);
6212 Result_Type
: Node_Id
renames Args
(4);
6213 Mechanism
: Node_Id
renames Args
(5);
6214 Result_Mechanism
: Node_Id
renames Args
(6);
6218 Gather_Associations
(Names
, Args
);
6219 Process_Extended_Import_Export_Subprogram_Pragma
(
6220 Arg_Internal
=> Internal
,
6221 Arg_External
=> External
,
6222 Arg_Parameter_Types
=> Parameter_Types
,
6223 Arg_Result_Type
=> Result_Type
,
6224 Arg_Mechanism
=> Mechanism
,
6225 Arg_Result_Mechanism
=> Result_Mechanism
);
6226 end Export_Function
;
6232 -- pragma Export_Object (
6233 -- [Internal =>] LOCAL_NAME,
6234 -- [, [External =>] EXTERNAL_SYMBOL]
6235 -- [, [Size =>] EXTERNAL_SYMBOL]);
6237 -- EXTERNAL_SYMBOL ::=
6239 -- | static_string_EXPRESSION
6241 -- PARAMETER_TYPES ::=
6243 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6245 -- TYPE_DESIGNATOR ::=
6247 -- | subtype_Name ' Access
6251 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6253 -- MECHANISM_ASSOCIATION ::=
6254 -- [formal_parameter_NAME =>] MECHANISM_NAME
6256 -- MECHANISM_NAME ::=
6259 -- | Descriptor [([Class =>] CLASS_NAME)]
6261 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6263 when Pragma_Export_Object
=> Export_Object
: declare
6264 Args
: Args_List
(1 .. 3);
6265 Names
: constant Name_List
(1 .. 3) := (
6270 Internal
: Node_Id
renames Args
(1);
6271 External
: Node_Id
renames Args
(2);
6272 Size
: Node_Id
renames Args
(3);
6276 Gather_Associations
(Names
, Args
);
6277 Process_Extended_Import_Export_Object_Pragma
(
6278 Arg_Internal
=> Internal
,
6279 Arg_External
=> External
,
6283 ----------------------
6284 -- Export_Procedure --
6285 ----------------------
6287 -- pragma Export_Procedure (
6288 -- [Internal =>] LOCAL_NAME,
6289 -- [, [External =>] EXTERNAL_SYMBOL,]
6290 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6291 -- [, [Mechanism =>] MECHANISM]);
6293 -- EXTERNAL_SYMBOL ::=
6295 -- | static_string_EXPRESSION
6297 -- PARAMETER_TYPES ::=
6299 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6301 -- TYPE_DESIGNATOR ::=
6303 -- | subtype_Name ' Access
6307 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6309 -- MECHANISM_ASSOCIATION ::=
6310 -- [formal_parameter_NAME =>] MECHANISM_NAME
6312 -- MECHANISM_NAME ::=
6315 -- | Descriptor [([Class =>] CLASS_NAME)]
6317 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6319 when Pragma_Export_Procedure
=> Export_Procedure
: declare
6320 Args
: Args_List
(1 .. 4);
6321 Names
: constant Name_List
(1 .. 4) := (
6324 Name_Parameter_Types
,
6327 Internal
: Node_Id
renames Args
(1);
6328 External
: Node_Id
renames Args
(2);
6329 Parameter_Types
: Node_Id
renames Args
(3);
6330 Mechanism
: Node_Id
renames Args
(4);
6334 Gather_Associations
(Names
, Args
);
6335 Process_Extended_Import_Export_Subprogram_Pragma
(
6336 Arg_Internal
=> Internal
,
6337 Arg_External
=> External
,
6338 Arg_Parameter_Types
=> Parameter_Types
,
6339 Arg_Mechanism
=> Mechanism
);
6340 end Export_Procedure
;
6346 -- pragma Export_Value (
6347 -- [Value =>] static_integer_EXPRESSION,
6348 -- [Link_Name =>] static_string_EXPRESSION);
6350 when Pragma_Export_Value
=>
6352 Check_Arg_Order
((Name_Value
, Name_Link_Name
));
6353 Check_Arg_Count
(2);
6355 Check_Optional_Identifier
(Arg1
, Name_Value
);
6356 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
6358 Check_Optional_Identifier
(Arg2
, Name_Link_Name
);
6359 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
6361 -----------------------------
6362 -- Export_Valued_Procedure --
6363 -----------------------------
6365 -- pragma Export_Valued_Procedure (
6366 -- [Internal =>] LOCAL_NAME,
6367 -- [, [External =>] EXTERNAL_SYMBOL,]
6368 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6369 -- [, [Mechanism =>] MECHANISM]);
6371 -- EXTERNAL_SYMBOL ::=
6373 -- | static_string_EXPRESSION
6375 -- PARAMETER_TYPES ::=
6377 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6379 -- TYPE_DESIGNATOR ::=
6381 -- | subtype_Name ' Access
6385 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6387 -- MECHANISM_ASSOCIATION ::=
6388 -- [formal_parameter_NAME =>] MECHANISM_NAME
6390 -- MECHANISM_NAME ::=
6393 -- | Descriptor [([Class =>] CLASS_NAME)]
6395 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6397 when Pragma_Export_Valued_Procedure
=>
6398 Export_Valued_Procedure
: declare
6399 Args
: Args_List
(1 .. 4);
6400 Names
: constant Name_List
(1 .. 4) := (
6403 Name_Parameter_Types
,
6406 Internal
: Node_Id
renames Args
(1);
6407 External
: Node_Id
renames Args
(2);
6408 Parameter_Types
: Node_Id
renames Args
(3);
6409 Mechanism
: Node_Id
renames Args
(4);
6413 Gather_Associations
(Names
, Args
);
6414 Process_Extended_Import_Export_Subprogram_Pragma
(
6415 Arg_Internal
=> Internal
,
6416 Arg_External
=> External
,
6417 Arg_Parameter_Types
=> Parameter_Types
,
6418 Arg_Mechanism
=> Mechanism
);
6419 end Export_Valued_Procedure
;
6425 -- pragma Extend_System ([Name =>] Identifier);
6427 when Pragma_Extend_System
=> Extend_System
: declare
6430 Check_Valid_Configuration_Pragma
;
6431 Check_Arg_Count
(1);
6432 Check_Optional_Identifier
(Arg1
, Name_Name
);
6433 Check_Arg_Is_Identifier
(Arg1
);
6435 Get_Name_String
(Chars
(Expression
(Arg1
)));
6438 and then Name_Buffer
(1 .. 4) = "aux_"
6440 if Present
(System_Extend_Pragma_Arg
) then
6441 if Chars
(Expression
(Arg1
)) =
6442 Chars
(Expression
(System_Extend_Pragma_Arg
))
6446 Error_Msg_Sloc
:= Sloc
(System_Extend_Pragma_Arg
);
6447 Error_Pragma
("pragma% conflicts with that at#");
6451 System_Extend_Pragma_Arg
:= Arg1
;
6453 if not GNAT_Mode
then
6454 System_Extend_Unit
:= Arg1
;
6458 Error_Pragma
("incorrect name for pragma%, must be Aux_xxx");
6462 ------------------------
6463 -- Extensions_Allowed --
6464 ------------------------
6466 -- pragma Extensions_Allowed (ON | OFF);
6468 when Pragma_Extensions_Allowed
=>
6470 Check_Arg_Count
(1);
6471 Check_No_Identifiers
;
6472 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
6474 if Chars
(Expression
(Arg1
)) = Name_On
then
6475 Extensions_Allowed
:= True;
6476 Ada_Version
:= Ada_Version_Type
'Last;
6478 Extensions_Allowed
:= False;
6479 Ada_Version
:= Ada_Version_Type
'Min (Ada_Version
, Ada_95
);
6482 Ada_Version_Explicit
:= Ada_Version
;
6488 -- pragma External (
6489 -- [ Convention =>] convention_IDENTIFIER,
6490 -- [ Entity =>] local_NAME
6491 -- [, [External_Name =>] static_string_EXPRESSION ]
6492 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6494 when Pragma_External
=> External
: declare
6504 Check_At_Least_N_Arguments
(2);
6505 Check_At_Most_N_Arguments
(4);
6506 Process_Convention
(C
, Def_Id
);
6507 Note_Possible_Modification
(Expression
(Arg2
));
6508 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
6509 Set_Exported
(Def_Id
, Arg2
);
6512 --------------------------
6513 -- External_Name_Casing --
6514 --------------------------
6516 -- pragma External_Name_Casing (
6517 -- UPPERCASE | LOWERCASE
6518 -- [, AS_IS | UPPERCASE | LOWERCASE]);
6520 when Pragma_External_Name_Casing
=> External_Name_Casing
: declare
6523 Check_No_Identifiers
;
6525 if Arg_Count
= 2 then
6527 (Arg2
, Name_As_Is
, Name_Uppercase
, Name_Lowercase
);
6529 case Chars
(Get_Pragma_Arg
(Arg2
)) is
6531 Opt
.External_Name_Exp_Casing
:= As_Is
;
6533 when Name_Uppercase
=>
6534 Opt
.External_Name_Exp_Casing
:= Uppercase
;
6536 when Name_Lowercase
=>
6537 Opt
.External_Name_Exp_Casing
:= Lowercase
;
6544 Check_Arg_Count
(1);
6547 Check_Arg_Is_One_Of
(Arg1
, Name_Uppercase
, Name_Lowercase
);
6549 case Chars
(Get_Pragma_Arg
(Arg1
)) is
6550 when Name_Uppercase
=>
6551 Opt
.External_Name_Imp_Casing
:= Uppercase
;
6553 when Name_Lowercase
=>
6554 Opt
.External_Name_Imp_Casing
:= Lowercase
;
6559 end External_Name_Casing
;
6561 ---------------------------
6562 -- Finalize_Storage_Only --
6563 ---------------------------
6565 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
6567 when Pragma_Finalize_Storage_Only
=> Finalize_Storage
: declare
6568 Assoc
: constant Node_Id
:= Arg1
;
6569 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
6573 Check_No_Identifiers
;
6574 Check_Arg_Count
(1);
6575 Check_Arg_Is_Local_Name
(Arg1
);
6577 Find_Type
(Type_Id
);
6578 Typ
:= Entity
(Type_Id
);
6581 or else Rep_Item_Too_Early
(Typ
, N
)
6585 Typ
:= Underlying_Type
(Typ
);
6588 if not Is_Controlled
(Typ
) then
6589 Error_Pragma
("pragma% must specify controlled type");
6592 Check_First_Subtype
(Arg1
);
6594 if Finalize_Storage_Only
(Typ
) then
6595 Error_Pragma
("duplicate pragma%, only one allowed");
6597 elsif not Rep_Item_Too_Late
(Typ
, N
) then
6598 Set_Finalize_Storage_Only
(Base_Type
(Typ
), True);
6600 end Finalize_Storage
;
6602 --------------------------
6603 -- Float_Representation --
6604 --------------------------
6606 -- pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
6608 -- FLOAT_REP ::= VAX_Float | IEEE_Float
6610 when Pragma_Float_Representation
=> Float_Representation
: declare
6618 if Arg_Count
= 1 then
6619 Check_Valid_Configuration_Pragma
;
6621 Check_Arg_Count
(2);
6622 Check_Optional_Identifier
(Arg2
, Name_Entity
);
6623 Check_Arg_Is_Local_Name
(Arg2
);
6626 Check_No_Identifier
(Arg1
);
6627 Check_Arg_Is_One_Of
(Arg1
, Name_VAX_Float
, Name_IEEE_Float
);
6629 if not OpenVMS_On_Target
then
6630 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6632 ("?pragma% ignored (applies only to Open'V'M'S)");
6638 -- One argument case
6640 if Arg_Count
= 1 then
6641 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6642 if Opt
.Float_Format
= 'I' then
6643 Error_Pragma
("'I'E'E'E format previously specified");
6646 Opt
.Float_Format
:= 'V';
6649 if Opt
.Float_Format
= 'V' then
6650 Error_Pragma
("'V'A'X format previously specified");
6653 Opt
.Float_Format
:= 'I';
6656 Set_Standard_Fpt_Formats
;
6658 -- Two argument case
6661 Argx
:= Get_Pragma_Arg
(Arg2
);
6663 if not Is_Entity_Name
(Argx
)
6664 or else not Is_Floating_Point_Type
(Entity
(Argx
))
6667 ("second argument of% pragma must be floating-point type",
6671 Ent
:= Entity
(Argx
);
6672 Digs
:= UI_To_Int
(Digits_Value
(Ent
));
6674 -- Two arguments, VAX_Float case
6676 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6678 when 6 => Set_F_Float
(Ent
);
6679 when 9 => Set_D_Float
(Ent
);
6680 when 15 => Set_G_Float
(Ent
);
6684 ("wrong digits value, must be 6,9 or 15", Arg2
);
6687 -- Two arguments, IEEE_Float case
6691 when 6 => Set_IEEE_Short
(Ent
);
6692 when 15 => Set_IEEE_Long
(Ent
);
6696 ("wrong digits value, must be 6 or 15", Arg2
);
6700 end Float_Representation
;
6706 -- pragma Ident (static_string_EXPRESSION)
6708 -- Note: pragma Comment shares this processing. Pragma Comment
6709 -- is identical to Ident, except that the restriction of the
6710 -- argument to 31 characters and the placement restrictions
6711 -- are not enforced for pragma Comment.
6713 when Pragma_Ident | Pragma_Comment
=> Ident
: declare
6718 Check_Arg_Count
(1);
6719 Check_No_Identifiers
;
6720 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
6722 -- For pragma Ident, preserve DEC compatibility by requiring
6723 -- the pragma to appear in a declarative part or package spec.
6725 if Prag_Id
= Pragma_Ident
then
6726 Check_Is_In_Decl_Part_Or_Package_Spec
;
6729 Str
:= Expr_Value_S
(Expression
(Arg1
));
6736 GP
:= Parent
(Parent
(N
));
6738 if Nkind
(GP
) = N_Package_Declaration
6740 Nkind
(GP
) = N_Generic_Package_Declaration
6745 -- If we have a compilation unit, then record the ident
6746 -- value, checking for improper duplication.
6748 if Nkind
(GP
) = N_Compilation_Unit
then
6749 CS
:= Ident_String
(Current_Sem_Unit
);
6751 if Present
(CS
) then
6753 -- For Ident, we do not permit multiple instances
6755 if Prag_Id
= Pragma_Ident
then
6756 Error_Pragma
("duplicate% pragma not permitted");
6758 -- For Comment, we concatenate the string, unless we
6759 -- want to preserve the tree structure for ASIS.
6761 elsif not ASIS_Mode
then
6762 Start_String
(Strval
(CS
));
6763 Store_String_Char
(' ');
6764 Store_String_Chars
(Strval
(Str
));
6765 Set_Strval
(CS
, End_String
);
6769 -- In VMS, the effect of IDENT is achieved by passing
6770 -- IDENTIFICATION=name as a --for-linker switch.
6772 if OpenVMS_On_Target
then
6775 ("--for-linker=IDENTIFICATION=");
6776 String_To_Name_Buffer
(Strval
(Str
));
6777 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
6779 -- Only the last processed IDENT is saved. The main
6780 -- purpose is so an IDENT associated with a main
6781 -- procedure will be used in preference to an IDENT
6782 -- associated with a with'd package.
6784 Replace_Linker_Option_String
6785 (End_String
, "--for-linker=IDENTIFICATION=");
6788 Set_Ident_String
(Current_Sem_Unit
, Str
);
6791 -- For subunits, we just ignore the Ident, since in GNAT
6792 -- these are not separate object files, and hence not
6793 -- separate units in the unit table.
6795 elsif Nkind
(GP
) = N_Subunit
then
6798 -- Otherwise we have a misplaced pragma Ident, but we ignore
6799 -- this if we are in an instantiation, since it comes from
6800 -- a generic, and has no relevance to the instantiation.
6802 elsif Prag_Id
= Pragma_Ident
then
6803 if Instantiation_Location
(Loc
) = No_Location
then
6804 Error_Pragma
("pragma% only allowed at outer level");
6815 -- [ Convention =>] convention_IDENTIFIER,
6816 -- [ Entity =>] local_NAME
6817 -- [, [External_Name =>] static_string_EXPRESSION ]
6818 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6820 when Pragma_Import
=>
6821 Check_Ada_83_Warning
;
6827 Check_At_Least_N_Arguments
(2);
6828 Check_At_Most_N_Arguments
(4);
6829 Process_Import_Or_Interface
;
6831 ----------------------
6832 -- Import_Exception --
6833 ----------------------
6835 -- pragma Import_Exception (
6836 -- [Internal =>] LOCAL_NAME,
6837 -- [, [External =>] EXTERNAL_SYMBOL,]
6838 -- [, [Form =>] Ada | VMS]
6839 -- [, [Code =>] static_integer_EXPRESSION]);
6841 when Pragma_Import_Exception
=> Import_Exception
: declare
6842 Args
: Args_List
(1 .. 4);
6843 Names
: constant Name_List
(1 .. 4) := (
6849 Internal
: Node_Id
renames Args
(1);
6850 External
: Node_Id
renames Args
(2);
6851 Form
: Node_Id
renames Args
(3);
6852 Code
: Node_Id
renames Args
(4);
6855 Gather_Associations
(Names
, Args
);
6857 if Present
(External
) and then Present
(Code
) then
6859 ("cannot give both External and Code options for pragma%");
6862 Process_Extended_Import_Export_Exception_Pragma
(
6863 Arg_Internal
=> Internal
,
6864 Arg_External
=> External
,
6868 if not Is_VMS_Exception
(Entity
(Internal
)) then
6869 Set_Imported
(Entity
(Internal
));
6871 end Import_Exception
;
6873 ---------------------
6874 -- Import_Function --
6875 ---------------------
6877 -- pragma Import_Function (
6878 -- [Internal =>] LOCAL_NAME,
6879 -- [, [External =>] EXTERNAL_SYMBOL]
6880 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6881 -- [, [Result_Type =>] SUBTYPE_MARK]
6882 -- [, [Mechanism =>] MECHANISM]
6883 -- [, [Result_Mechanism =>] MECHANISM_NAME]
6884 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6886 -- EXTERNAL_SYMBOL ::=
6888 -- | static_string_EXPRESSION
6890 -- PARAMETER_TYPES ::=
6892 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6894 -- TYPE_DESIGNATOR ::=
6896 -- | subtype_Name ' Access
6900 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6902 -- MECHANISM_ASSOCIATION ::=
6903 -- [formal_parameter_NAME =>] MECHANISM_NAME
6905 -- MECHANISM_NAME ::=
6908 -- | Descriptor [([Class =>] CLASS_NAME)]
6910 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6912 when Pragma_Import_Function
=> Import_Function
: declare
6913 Args
: Args_List
(1 .. 7);
6914 Names
: constant Name_List
(1 .. 7) := (
6917 Name_Parameter_Types
,
6920 Name_Result_Mechanism
,
6921 Name_First_Optional_Parameter
);
6923 Internal
: Node_Id
renames Args
(1);
6924 External
: Node_Id
renames Args
(2);
6925 Parameter_Types
: Node_Id
renames Args
(3);
6926 Result_Type
: Node_Id
renames Args
(4);
6927 Mechanism
: Node_Id
renames Args
(5);
6928 Result_Mechanism
: Node_Id
renames Args
(6);
6929 First_Optional_Parameter
: Node_Id
renames Args
(7);
6933 Gather_Associations
(Names
, Args
);
6934 Process_Extended_Import_Export_Subprogram_Pragma
(
6935 Arg_Internal
=> Internal
,
6936 Arg_External
=> External
,
6937 Arg_Parameter_Types
=> Parameter_Types
,
6938 Arg_Result_Type
=> Result_Type
,
6939 Arg_Mechanism
=> Mechanism
,
6940 Arg_Result_Mechanism
=> Result_Mechanism
,
6941 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
6942 end Import_Function
;
6948 -- pragma Import_Object (
6949 -- [Internal =>] LOCAL_NAME,
6950 -- [, [External =>] EXTERNAL_SYMBOL]
6951 -- [, [Size =>] EXTERNAL_SYMBOL]);
6953 -- EXTERNAL_SYMBOL ::=
6955 -- | static_string_EXPRESSION
6957 when Pragma_Import_Object
=> Import_Object
: declare
6958 Args
: Args_List
(1 .. 3);
6959 Names
: constant Name_List
(1 .. 3) := (
6964 Internal
: Node_Id
renames Args
(1);
6965 External
: Node_Id
renames Args
(2);
6966 Size
: Node_Id
renames Args
(3);
6970 Gather_Associations
(Names
, Args
);
6971 Process_Extended_Import_Export_Object_Pragma
(
6972 Arg_Internal
=> Internal
,
6973 Arg_External
=> External
,
6977 ----------------------
6978 -- Import_Procedure --
6979 ----------------------
6981 -- pragma Import_Procedure (
6982 -- [Internal =>] LOCAL_NAME,
6983 -- [, [External =>] EXTERNAL_SYMBOL]
6984 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6985 -- [, [Mechanism =>] MECHANISM]
6986 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6988 -- EXTERNAL_SYMBOL ::=
6990 -- | static_string_EXPRESSION
6992 -- PARAMETER_TYPES ::=
6994 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6996 -- TYPE_DESIGNATOR ::=
6998 -- | subtype_Name ' Access
7002 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7004 -- MECHANISM_ASSOCIATION ::=
7005 -- [formal_parameter_NAME =>] MECHANISM_NAME
7007 -- MECHANISM_NAME ::=
7010 -- | Descriptor [([Class =>] CLASS_NAME)]
7012 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7014 when Pragma_Import_Procedure
=> Import_Procedure
: declare
7015 Args
: Args_List
(1 .. 5);
7016 Names
: constant Name_List
(1 .. 5) := (
7019 Name_Parameter_Types
,
7021 Name_First_Optional_Parameter
);
7023 Internal
: Node_Id
renames Args
(1);
7024 External
: Node_Id
renames Args
(2);
7025 Parameter_Types
: Node_Id
renames Args
(3);
7026 Mechanism
: Node_Id
renames Args
(4);
7027 First_Optional_Parameter
: Node_Id
renames Args
(5);
7031 Gather_Associations
(Names
, Args
);
7032 Process_Extended_Import_Export_Subprogram_Pragma
(
7033 Arg_Internal
=> Internal
,
7034 Arg_External
=> External
,
7035 Arg_Parameter_Types
=> Parameter_Types
,
7036 Arg_Mechanism
=> Mechanism
,
7037 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
7038 end Import_Procedure
;
7040 -----------------------------
7041 -- Import_Valued_Procedure --
7042 -----------------------------
7044 -- pragma Import_Valued_Procedure (
7045 -- [Internal =>] LOCAL_NAME,
7046 -- [, [External =>] EXTERNAL_SYMBOL]
7047 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7048 -- [, [Mechanism =>] MECHANISM]
7049 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
7051 -- EXTERNAL_SYMBOL ::=
7053 -- | static_string_EXPRESSION
7055 -- PARAMETER_TYPES ::=
7057 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7059 -- TYPE_DESIGNATOR ::=
7061 -- | subtype_Name ' Access
7065 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7067 -- MECHANISM_ASSOCIATION ::=
7068 -- [formal_parameter_NAME =>] MECHANISM_NAME
7070 -- MECHANISM_NAME ::=
7073 -- | Descriptor [([Class =>] CLASS_NAME)]
7075 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7077 when Pragma_Import_Valued_Procedure
=>
7078 Import_Valued_Procedure
: declare
7079 Args
: Args_List
(1 .. 5);
7080 Names
: constant Name_List
(1 .. 5) := (
7083 Name_Parameter_Types
,
7085 Name_First_Optional_Parameter
);
7087 Internal
: Node_Id
renames Args
(1);
7088 External
: Node_Id
renames Args
(2);
7089 Parameter_Types
: Node_Id
renames Args
(3);
7090 Mechanism
: Node_Id
renames Args
(4);
7091 First_Optional_Parameter
: Node_Id
renames Args
(5);
7095 Gather_Associations
(Names
, Args
);
7096 Process_Extended_Import_Export_Subprogram_Pragma
(
7097 Arg_Internal
=> Internal
,
7098 Arg_External
=> External
,
7099 Arg_Parameter_Types
=> Parameter_Types
,
7100 Arg_Mechanism
=> Mechanism
,
7101 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
7102 end Import_Valued_Procedure
;
7104 ------------------------
7105 -- Initialize_Scalars --
7106 ------------------------
7108 -- pragma Initialize_Scalars;
7110 when Pragma_Initialize_Scalars
=>
7112 Check_Arg_Count
(0);
7113 Check_Valid_Configuration_Pragma
;
7114 Check_Restriction
(No_Initialize_Scalars
, N
);
7116 if not Restriction_Active
(No_Initialize_Scalars
) then
7117 Init_Or_Norm_Scalars
:= True;
7118 Initialize_Scalars
:= True;
7125 -- pragma Inline ( NAME {, NAME} );
7127 when Pragma_Inline
=>
7129 -- Pragma is active if inlining option is active
7131 Process_Inline
(Inline_Active
);
7137 -- pragma Inline_Always ( NAME {, NAME} );
7139 when Pragma_Inline_Always
=>
7140 Process_Inline
(True);
7142 --------------------
7143 -- Inline_Generic --
7144 --------------------
7146 -- pragma Inline_Generic (NAME {, NAME});
7148 when Pragma_Inline_Generic
=>
7149 Process_Generic_List
;
7151 ----------------------
7152 -- Inspection_Point --
7153 ----------------------
7155 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
7157 when Pragma_Inspection_Point
=> Inspection_Point
: declare
7162 if Arg_Count
> 0 then
7165 Exp
:= Expression
(Arg
);
7168 if not Is_Entity_Name
(Exp
)
7169 or else not Is_Object
(Entity
(Exp
))
7171 Error_Pragma_Arg
("object name required", Arg
);
7178 end Inspection_Point
;
7184 -- pragma Interface (
7185 -- convention_IDENTIFIER,
7188 when Pragma_Interface
=>
7190 Check_Arg_Count
(2);
7191 Check_No_Identifiers
;
7192 Process_Import_Or_Interface
;
7194 --------------------
7195 -- Interface_Name --
7196 --------------------
7198 -- pragma Interface_Name (
7199 -- [ Entity =>] local_NAME
7200 -- [,[External_Name =>] static_string_EXPRESSION ]
7201 -- [,[Link_Name =>] static_string_EXPRESSION ]);
7203 when Pragma_Interface_Name
=> Interface_Name
: declare
7212 ((Name_Entity
, Name_External_Name
, Name_Link_Name
));
7213 Check_At_Least_N_Arguments
(2);
7214 Check_At_Most_N_Arguments
(3);
7215 Id
:= Expression
(Arg1
);
7218 if not Is_Entity_Name
(Id
) then
7220 ("first argument for pragma% must be entity name", Arg1
);
7221 elsif Etype
(Id
) = Any_Type
then
7224 Def_Id
:= Entity
(Id
);
7227 -- Special DEC-compatible processing for the object case,
7228 -- forces object to be imported.
7230 if Ekind
(Def_Id
) = E_Variable
then
7231 Kill_Size_Check_Code
(Def_Id
);
7232 Note_Possible_Modification
(Id
);
7234 -- Initialization is not allowed for imported variable
7236 if Present
(Expression
(Parent
(Def_Id
)))
7237 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
7239 Error_Msg_Sloc
:= Sloc
(Def_Id
);
7241 ("no initialization allowed for declaration of& #",
7245 -- For compatibility, support VADS usage of providing both
7246 -- pragmas Interface and Interface_Name to obtain the effect
7247 -- of a single Import pragma.
7249 if Is_Imported
(Def_Id
)
7250 and then Present
(First_Rep_Item
(Def_Id
))
7251 and then Nkind
(First_Rep_Item
(Def_Id
)) = N_Pragma
7252 and then Chars
(First_Rep_Item
(Def_Id
)) = Name_Interface
7256 Set_Imported
(Def_Id
);
7259 Set_Is_Public
(Def_Id
);
7260 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
7263 -- Otherwise must be subprogram
7265 elsif not Is_Subprogram
(Def_Id
) then
7267 ("argument of pragma% is not subprogram", Arg1
);
7270 Check_At_Most_N_Arguments
(3);
7274 -- Loop through homonyms
7277 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
7279 if Is_Imported
(Def_Id
) then
7280 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
7284 Hom_Id
:= Homonym
(Hom_Id
);
7286 exit when No
(Hom_Id
)
7287 or else Scope
(Hom_Id
) /= Current_Scope
;
7292 ("argument of pragma% is not imported subprogram",
7298 -----------------------
7299 -- Interrupt_Handler --
7300 -----------------------
7302 -- pragma Interrupt_Handler (handler_NAME);
7304 when Pragma_Interrupt_Handler
=>
7305 Check_Ada_83_Warning
;
7306 Check_Arg_Count
(1);
7307 Check_No_Identifiers
;
7309 if No_Run_Time_Mode
then
7310 Error_Msg_CRT
("Interrupt_Handler pragma", N
);
7312 Check_Interrupt_Or_Attach_Handler
;
7313 Process_Interrupt_Or_Attach_Handler
;
7316 ------------------------
7317 -- Interrupt_Priority --
7318 ------------------------
7320 -- pragma Interrupt_Priority [(EXPRESSION)];
7322 when Pragma_Interrupt_Priority
=> Interrupt_Priority
: declare
7323 P
: constant Node_Id
:= Parent
(N
);
7327 Check_Ada_83_Warning
;
7329 if Arg_Count
/= 0 then
7330 Arg
:= Expression
(Arg1
);
7331 Check_Arg_Count
(1);
7332 Check_No_Identifiers
;
7334 -- The expression must be analyzed in the special manner
7335 -- described in "Handling of Default and Per-Object
7336 -- Expressions" in sem.ads.
7338 Analyze_Per_Use_Expression
(Arg
, RTE
(RE_Interrupt_Priority
));
7341 if Nkind
(P
) /= N_Task_Definition
7342 and then Nkind
(P
) /= N_Protected_Definition
7347 elsif Has_Priority_Pragma
(P
) then
7348 Error_Pragma
("duplicate pragma% not allowed");
7351 Set_Has_Priority_Pragma
(P
, True);
7352 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
7354 end Interrupt_Priority
;
7356 ---------------------
7357 -- Interrupt_State --
7358 ---------------------
7360 -- pragma Interrupt_State (
7361 -- [Name =>] INTERRUPT_ID,
7362 -- [State =>] INTERRUPT_STATE);
7364 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
7365 -- INTERRUPT_STATE => System | Runtime | User
7367 -- Note: if the interrupt id is given as an identifier, then
7368 -- it must be one of the identifiers in Ada.Interrupts.Names.
7369 -- Otherwise it is given as a static integer expression which
7370 -- must be in the range of Ada.Interrupts.Interrupt_ID.
7372 when Pragma_Interrupt_State
=> Interrupt_State
: declare
7374 Int_Id
: constant Entity_Id
:= RTE
(RE_Interrupt_ID
);
7375 -- This is the entity Ada.Interrupts.Interrupt_ID;
7377 State_Type
: Character;
7378 -- Set to 's'/'r'/'u' for System/Runtime/User
7381 -- Index to entry in Interrupt_States table
7384 -- Value of interrupt
7386 Arg1X
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
7387 -- The first argument to the pragma
7389 Int_Ent
: Entity_Id
;
7390 -- Interrupt entity in Ada.Interrupts.Names
7394 Check_Arg_Order
((Name_Name
, Name_State
));
7395 Check_Arg_Count
(2);
7397 Check_Optional_Identifier
(Arg1
, Name_Name
);
7398 Check_Optional_Identifier
(Arg2
, Name_State
);
7399 Check_Arg_Is_Identifier
(Arg2
);
7401 -- First argument is identifier
7403 if Nkind
(Arg1X
) = N_Identifier
then
7405 -- Search list of names in Ada.Interrupts.Names
7407 Int_Ent
:= First_Entity
(RTE
(RE_Names
));
7409 if No
(Int_Ent
) then
7410 Error_Pragma_Arg
("invalid interrupt name", Arg1
);
7412 elsif Chars
(Int_Ent
) = Chars
(Arg1X
) then
7413 Int_Val
:= Expr_Value
(Constant_Value
(Int_Ent
));
7417 Next_Entity
(Int_Ent
);
7420 -- First argument is not an identifier, so it must be a
7421 -- static expression of type Ada.Interrupts.Interrupt_ID.
7424 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
7425 Int_Val
:= Expr_Value
(Arg1X
);
7427 if Int_Val
< Expr_Value
(Type_Low_Bound
(Int_Id
))
7429 Int_Val
> Expr_Value
(Type_High_Bound
(Int_Id
))
7432 ("value not in range of type " &
7433 """Ada.Interrupts.Interrupt_'I'D""", Arg1
);
7439 case Chars
(Get_Pragma_Arg
(Arg2
)) is
7440 when Name_Runtime
=> State_Type
:= 'r';
7441 when Name_System
=> State_Type
:= 's';
7442 when Name_User
=> State_Type
:= 'u';
7445 Error_Pragma_Arg
("invalid interrupt state", Arg2
);
7448 -- Check if entry is already stored
7450 IST_Num
:= Interrupt_States
.First
;
7452 -- If entry not found, add it
7454 if IST_Num
> Interrupt_States
.Last
then
7455 Interrupt_States
.Append
7456 ((Interrupt_Number
=> UI_To_Int
(Int_Val
),
7457 Interrupt_State
=> State_Type
,
7458 Pragma_Loc
=> Loc
));
7461 -- Case of entry for the same entry
7463 elsif Int_Val
= Interrupt_States
.Table
(IST_Num
).
7466 -- If state matches, done, no need to make redundant entry
7469 State_Type
= Interrupt_States
.Table
(IST_Num
).
7472 -- Otherwise if state does not match, error
7475 Interrupt_States
.Table
(IST_Num
).Pragma_Loc
;
7477 ("state conflicts with that given at #", Arg2
);
7481 IST_Num
:= IST_Num
+ 1;
7483 end Interrupt_State
;
7485 ----------------------
7486 -- Java_Constructor --
7487 ----------------------
7489 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
7491 when Pragma_Java_Constructor
=> Java_Constructor
: declare
7498 Check_Arg_Count
(1);
7499 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7500 Check_Arg_Is_Local_Name
(Arg1
);
7502 Id
:= Expression
(Arg1
);
7503 Find_Program_Unit_Name
(Id
);
7505 -- If we did not find the name, we are done
7507 if Etype
(Id
) = Any_Type
then
7511 Hom_Id
:= Entity
(Id
);
7513 -- Loop through homonyms
7516 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
7518 -- The constructor is required to be a function returning
7519 -- an access type whose designated type has convention Java.
7521 if Ekind
(Def_Id
) = E_Function
7522 and then Ekind
(Etype
(Def_Id
)) in Access_Kind
7525 (Designated_Type
(Etype
(Def_Id
))) = Convention_Java
7528 (Root_Type
(Designated_Type
(Etype
(Def_Id
))))
7531 Set_Is_Constructor
(Def_Id
);
7532 Set_Convention
(Def_Id
, Convention_Java
);
7536 ("pragma% requires function returning a 'Java access type",
7540 Hom_Id
:= Homonym
(Hom_Id
);
7542 exit when No
(Hom_Id
) or else Scope
(Hom_Id
) /= Current_Scope
;
7544 end Java_Constructor
;
7546 ----------------------
7547 -- Java_Interface --
7548 ----------------------
7550 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
7552 when Pragma_Java_Interface
=> Java_Interface
: declare
7558 Check_Arg_Count
(1);
7559 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7560 Check_Arg_Is_Local_Name
(Arg1
);
7562 Arg
:= Expression
(Arg1
);
7565 if Etype
(Arg
) = Any_Type
then
7569 if not Is_Entity_Name
(Arg
)
7570 or else not Is_Type
(Entity
(Arg
))
7572 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
7575 Typ
:= Underlying_Type
(Entity
(Arg
));
7577 -- For now we simply check some of the semantic constraints
7578 -- on the type. This currently leaves out some restrictions
7579 -- on interface types, namely that the parent type must be
7580 -- java.lang.Object.Typ and that all primitives of the type
7581 -- should be declared abstract. ???
7583 if not Is_Tagged_Type
(Typ
) or else not Is_Abstract
(Typ
) then
7584 Error_Pragma_Arg
("pragma% requires an abstract "
7585 & "tagged type", Arg1
);
7587 elsif not Has_Discriminants
(Typ
)
7588 or else Ekind
(Etype
(First_Discriminant
(Typ
)))
7589 /= E_Anonymous_Access_Type
7591 not Is_Class_Wide_Type
7592 (Designated_Type
(Etype
(First_Discriminant
(Typ
))))
7595 ("type must have a class-wide access discriminant", Arg1
);
7603 -- pragma Keep_Names ([On => ] local_NAME);
7605 when Pragma_Keep_Names
=> Keep_Names
: declare
7610 Check_Arg_Count
(1);
7611 Check_Optional_Identifier
(Arg1
, Name_On
);
7612 Check_Arg_Is_Local_Name
(Arg1
);
7614 Arg
:= Expression
(Arg1
);
7617 if Etype
(Arg
) = Any_Type
then
7621 if not Is_Entity_Name
(Arg
)
7622 or else Ekind
(Entity
(Arg
)) /= E_Enumeration_Type
7625 ("pragma% requires a local enumeration type", Arg1
);
7628 Set_Discard_Names
(Entity
(Arg
), False);
7635 -- pragma License (RESTRICTED | UNRESTRICTED | GPL | MODIFIED_GPL);
7637 when Pragma_License
=>
7639 Check_Arg_Count
(1);
7640 Check_No_Identifiers
;
7641 Check_Valid_Configuration_Pragma
;
7642 Check_Arg_Is_Identifier
(Arg1
);
7645 Sind
: constant Source_File_Index
:=
7646 Source_Index
(Current_Sem_Unit
);
7649 case Chars
(Get_Pragma_Arg
(Arg1
)) is
7651 Set_License
(Sind
, GPL
);
7653 when Name_Modified_GPL
=>
7654 Set_License
(Sind
, Modified_GPL
);
7656 when Name_Restricted
=>
7657 Set_License
(Sind
, Restricted
);
7659 when Name_Unrestricted
=>
7660 Set_License
(Sind
, Unrestricted
);
7663 Error_Pragma_Arg
("invalid license name", Arg1
);
7671 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
7673 when Pragma_Link_With
=> Link_With
: declare
7679 if Operating_Mode
= Generate_Code
7680 and then In_Extended_Main_Source_Unit
(N
)
7682 Check_At_Least_N_Arguments
(1);
7683 Check_No_Identifiers
;
7684 Check_Is_In_Decl_Part_Or_Package_Spec
;
7685 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7689 while Present
(Arg
) loop
7690 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
7692 -- Store argument, converting sequences of spaces
7693 -- to a single null character (this is one of the
7694 -- differences in processing between Link_With
7695 -- and Linker_Options).
7698 C
: constant Char_Code
:= Get_Char_Code
(' ');
7699 S
: constant String_Id
:=
7700 Strval
(Expr_Value_S
(Expression
(Arg
)));
7701 L
: constant Nat
:= String_Length
(S
);
7704 procedure Skip_Spaces
;
7705 -- Advance F past any spaces
7707 procedure Skip_Spaces
is
7709 while F
<= L
and then Get_String_Char
(S
, F
) = C
loop
7715 Skip_Spaces
; -- skip leading spaces
7717 -- Loop through characters, changing any embedded
7718 -- sequence of spaces to a single null character
7719 -- (this is how Link_With/Linker_Options differ)
7722 if Get_String_Char
(S
, F
) = C
then
7725 Store_String_Char
(ASCII
.NUL
);
7728 Store_String_Char
(Get_String_Char
(S
, F
));
7736 if Present
(Arg
) then
7737 Store_String_Char
(ASCII
.NUL
);
7741 Store_Linker_Option_String
(End_String
);
7749 -- pragma Linker_Alias (
7750 -- [Entity =>] LOCAL_NAME
7751 -- [Target =>] static_string_EXPRESSION);
7753 when Pragma_Linker_Alias
=>
7755 Check_Arg_Order
((Name_Entity
, Name_Target
));
7756 Check_Arg_Count
(2);
7757 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7758 Check_Optional_Identifier
(Arg2
, Name_Target
);
7759 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
7760 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7762 -- The only processing required is to link this item on to the
7763 -- list of rep items for the given entity. This is accomplished
7764 -- by the call to Rep_Item_Too_Late (when no error is detected
7765 -- and False is returned).
7767 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
7770 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7773 ------------------------
7774 -- Linker_Constructor --
7775 ------------------------
7777 -- pragma Linker_Constructor (procedure_LOCAL_NAME);
7779 -- Code is shared with Linker_Destructor
7781 -----------------------
7782 -- Linker_Destructor --
7783 -----------------------
7785 -- pragma Linker_Destructor (procedure_LOCAL_NAME);
7787 when Pragma_Linker_Constructor |
7788 Pragma_Linker_Destructor
=>
7789 Linker_Constructor
: declare
7795 Check_Arg_Count
(1);
7796 Check_No_Identifiers
;
7797 Check_Arg_Is_Local_Name
(Arg1
);
7798 Arg1_X
:= Expression
(Arg1
);
7800 Proc
:= Find_Unique_Parameterless_Procedure
(Arg1_X
, Arg1
);
7802 if not Is_Library_Level_Entity
(Proc
) then
7804 ("argument for pragma% must be library level entity", Arg1
);
7807 -- The only processing required is to link this item on to the
7808 -- list of rep items for the given entity. This is accomplished
7809 -- by the call to Rep_Item_Too_Late (when no error is detected
7810 -- and False is returned).
7812 if Rep_Item_Too_Late
(Proc
, N
) then
7815 Set_Has_Gigi_Rep_Item
(Proc
);
7817 end Linker_Constructor
;
7819 --------------------
7820 -- Linker_Options --
7821 --------------------
7823 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
7825 when Pragma_Linker_Options
=> Linker_Options
: declare
7829 Check_Ada_83_Warning
;
7830 Check_No_Identifiers
;
7831 Check_Arg_Count
(1);
7832 Check_Is_In_Decl_Part_Or_Package_Spec
;
7834 if Operating_Mode
= Generate_Code
7835 and then In_Extended_Main_Source_Unit
(N
)
7837 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7838 Start_String
(Strval
(Expr_Value_S
(Expression
(Arg1
))));
7841 while Present
(Arg
) loop
7842 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
7843 Store_String_Char
(ASCII
.NUL
);
7845 (Strval
(Expr_Value_S
(Expression
(Arg
))));
7849 Store_Linker_Option_String
(End_String
);
7853 --------------------
7854 -- Linker_Section --
7855 --------------------
7857 -- pragma Linker_Section (
7858 -- [Entity =>] LOCAL_NAME
7859 -- [Section =>] static_string_EXPRESSION);
7861 when Pragma_Linker_Section
=>
7863 Check_Arg_Order
((Name_Entity
, Name_Section
));
7864 Check_Arg_Count
(2);
7865 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7866 Check_Optional_Identifier
(Arg2
, Name_Section
);
7867 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
7868 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7870 -- The only processing required is to link this item on to the
7871 -- list of rep items for the given entity. This is accomplished
7872 -- by the call to Rep_Item_Too_Late (when no error is detected
7873 -- and False is returned).
7875 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
7878 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7885 -- pragma List (On | Off)
7887 -- There is nothing to do here, since we did all the processing
7888 -- for this pragma in Par.Prag (so that it works properly even in
7889 -- syntax only mode)
7894 --------------------
7895 -- Locking_Policy --
7896 --------------------
7898 -- pragma Locking_Policy (policy_IDENTIFIER);
7900 when Pragma_Locking_Policy
=> declare
7904 Check_Ada_83_Warning
;
7905 Check_Arg_Count
(1);
7906 Check_No_Identifiers
;
7907 Check_Arg_Is_Locking_Policy
(Arg1
);
7908 Check_Valid_Configuration_Pragma
;
7909 Get_Name_String
(Chars
(Expression
(Arg1
)));
7910 LP
:= Fold_Upper
(Name_Buffer
(1));
7912 if Locking_Policy
/= ' '
7913 and then Locking_Policy
/= LP
7915 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
7916 Error_Pragma
("locking policy incompatible with policy#");
7918 -- Set new policy, but always preserve System_Location since
7919 -- we like the error message with the run time name.
7922 Locking_Policy
:= LP
;
7924 if Locking_Policy_Sloc
/= System_Location
then
7925 Locking_Policy_Sloc
:= Loc
;
7934 -- pragma Long_Float (D_Float | G_Float);
7936 when Pragma_Long_Float
=>
7938 Check_Valid_Configuration_Pragma
;
7939 Check_Arg_Count
(1);
7940 Check_No_Identifier
(Arg1
);
7941 Check_Arg_Is_One_Of
(Arg1
, Name_D_Float
, Name_G_Float
);
7943 if not OpenVMS_On_Target
then
7944 Error_Pragma
("?pragma% ignored (applies only to Open'V'M'S)");
7949 if Chars
(Expression
(Arg1
)) = Name_D_Float
then
7950 if Opt
.Float_Format_Long
= 'G' then
7951 Error_Pragma
("G_Float previously specified");
7954 Opt
.Float_Format_Long
:= 'D';
7956 -- G_Float case (this is the default, does not need overriding)
7959 if Opt
.Float_Format_Long
= 'D' then
7960 Error_Pragma
("D_Float previously specified");
7963 Opt
.Float_Format_Long
:= 'G';
7966 Set_Standard_Fpt_Formats
;
7968 -----------------------
7969 -- Machine_Attribute --
7970 -----------------------
7972 -- pragma Machine_Attribute (
7973 -- [Entity =>] LOCAL_NAME,
7974 -- [Attribute_Name =>] static_string_EXPRESSION
7975 -- [,[Info =>] static_string_EXPRESSION] );
7977 when Pragma_Machine_Attribute
=> Machine_Attribute
: declare
7982 Check_Arg_Order
((Name_Entity
, Name_Attribute_Name
, Name_Info
));
7984 if Arg_Count
= 3 then
7985 Check_Optional_Identifier
(Arg3
, Name_Info
);
7986 Check_Arg_Is_Static_Expression
(Arg3
, Standard_String
);
7988 Check_Arg_Count
(2);
7991 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7992 Check_Optional_Identifier
(Arg2
, Name_Attribute_Name
);
7993 Check_Arg_Is_Local_Name
(Arg1
);
7994 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7995 Def_Id
:= Entity
(Expression
(Arg1
));
7997 if Is_Access_Type
(Def_Id
) then
7998 Def_Id
:= Designated_Type
(Def_Id
);
8001 if Rep_Item_Too_Early
(Def_Id
, N
) then
8005 Def_Id
:= Underlying_Type
(Def_Id
);
8007 -- The only processing required is to link this item on to the
8008 -- list of rep items for the given entity. This is accomplished
8009 -- by the call to Rep_Item_Too_Late (when no error is detected
8010 -- and False is returned).
8012 if Rep_Item_Too_Late
(Def_Id
, N
) then
8015 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
8017 end Machine_Attribute
;
8023 -- pragma Main_Storage
8024 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
8026 -- MAIN_STORAGE_OPTION ::=
8027 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
8028 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
8030 when Pragma_Main
=> Main
: declare
8031 Args
: Args_List
(1 .. 3);
8032 Names
: constant Name_List
(1 .. 3) := (
8034 Name_Task_Stack_Size_Default
,
8035 Name_Time_Slicing_Enabled
);
8041 Gather_Associations
(Names
, Args
);
8043 for J
in 1 .. 2 loop
8044 if Present
(Args
(J
)) then
8045 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
8049 if Present
(Args
(3)) then
8050 Check_Arg_Is_Static_Expression
(Args
(3), Standard_Boolean
);
8054 while Present
(Nod
) loop
8055 if Nkind
(Nod
) = N_Pragma
8056 and then Chars
(Nod
) = Name_Main
8058 Error_Msg_Name_1
:= Chars
(N
);
8059 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
8070 -- pragma Main_Storage
8071 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
8073 -- MAIN_STORAGE_OPTION ::=
8074 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
8075 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
8077 when Pragma_Main_Storage
=> Main_Storage
: declare
8078 Args
: Args_List
(1 .. 2);
8079 Names
: constant Name_List
(1 .. 2) := (
8080 Name_Working_Storage
,
8087 Gather_Associations
(Names
, Args
);
8089 for J
in 1 .. 2 loop
8090 if Present
(Args
(J
)) then
8091 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
8095 Check_In_Main_Program
;
8098 while Present
(Nod
) loop
8099 if Nkind
(Nod
) = N_Pragma
8100 and then Chars
(Nod
) = Name_Main_Storage
8102 Error_Msg_Name_1
:= Chars
(N
);
8103 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
8114 -- pragma Memory_Size (NUMERIC_LITERAL)
8116 when Pragma_Memory_Size
=>
8119 -- Memory size is simply ignored
8121 Check_No_Identifiers
;
8122 Check_Arg_Count
(1);
8123 Check_Arg_Is_Integer_Literal
(Arg1
);
8129 -- pragma No_Return (procedure_LOCAL_NAME {, procedure_Local_Name});
8131 when Pragma_No_Return
=> No_Return
: declare
8139 Check_At_Least_N_Arguments
(1);
8141 -- Loop through arguments of pragma
8144 while Present
(Arg
) loop
8145 Check_Arg_Is_Local_Name
(Arg
);
8146 Id
:= Expression
(Arg
);
8149 if not Is_Entity_Name
(Id
) then
8150 Error_Pragma_Arg
("entity name required", Arg
);
8153 if Etype
(Id
) = Any_Type
then
8157 -- Loop to find matching procedures
8162 and then Scope
(E
) = Current_Scope
8164 if Ekind
(E
) = E_Procedure
8165 or else Ekind
(E
) = E_Generic_Procedure
8175 Error_Pragma_Arg
("no procedure & found for pragma%", Arg
);
8182 ------------------------
8183 -- No_Strict_Aliasing --
8184 ------------------------
8186 -- pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
8188 when Pragma_No_Strict_Aliasing
=> No_Strict_Alias
: declare
8193 Check_At_Most_N_Arguments
(1);
8195 if Arg_Count
= 0 then
8196 Check_Valid_Configuration_Pragma
;
8197 Opt
.No_Strict_Aliasing
:= True;
8200 Check_Optional_Identifier
(Arg2
, Name_Entity
);
8201 Check_Arg_Is_Local_Name
(Arg1
);
8202 E_Id
:= Entity
(Expression
(Arg1
));
8204 if E_Id
= Any_Type
then
8206 elsif No
(E_Id
) or else not Is_Access_Type
(E_Id
) then
8207 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
8210 Set_No_Strict_Aliasing
(Implementation_Base_Type
(E_Id
));
8212 end No_Strict_Alias
;
8218 -- pragma Obsolescent [(static_string_EXPRESSION [, Ada_05])];
8220 when Pragma_Obsolescent
=> Obsolescent
: declare
8221 Subp
: Node_Or_Entity_Id
;
8223 Active
: Boolean := True;
8225 procedure Check_Obsolete_Subprogram
;
8226 -- Checks if Subp is a subprogram declaration node, and if so
8227 -- replaces Subp by the defining entity of the subprogram. If not,
8228 -- issues an error message
8230 ------------------------------
8231 -- Check_Obsolete_Subprogram--
8232 ------------------------------
8234 procedure Check_Obsolete_Subprogram
is
8236 if Nkind
(Subp
) /= N_Subprogram_Declaration
then
8238 ("pragma% misplaced, must immediately " &
8239 "follow subprogram/package declaration");
8241 Subp
:= Defining_Entity
(Subp
);
8243 end Check_Obsolete_Subprogram
;
8245 -- Start of processing for pragma Obsolescent
8249 Check_At_Most_N_Arguments
(2);
8250 Check_No_Identifiers
;
8252 -- Check OK placement
8254 -- First possibility is within a declarative region, where the
8255 -- pragma immediately follows a subprogram declaration.
8257 if Present
(Prev
(N
)) then
8259 Check_Obsolete_Subprogram
;
8261 -- Second possibility, stand alone subprogram declaration with the
8262 -- pragma immediately following the declaration.
8265 and then Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
8267 Subp
:= Unit
(Parent
(Parent
(N
)));
8268 Check_Obsolete_Subprogram
;
8270 -- Only other possibility is library unit placement for package
8273 Subp
:= Find_Lib_Unit_Name
;
8275 if Ekind
(Subp
) /= E_Package
8276 and then Ekind
(Subp
) /= E_Generic_Package
8278 Check_Obsolete_Subprogram
;
8282 -- If OK placement, acquire arguments
8284 if Arg_Count
>= 1 then
8286 -- Deal with static string argument
8288 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
8289 S
:= Strval
(Expression
(Arg1
));
8291 for J
in 1 .. String_Length
(S
) loop
8292 if not In_Character_Range
(Get_String_Char
(S
, J
)) then
8294 ("pragma% argument does not allow wide characters",
8299 Set_Obsolescent_Warning
(Subp
, Expression
(Arg1
));
8301 -- Check for Ada_05 parameter
8303 if Arg_Count
/= 1 then
8304 Check_Arg_Count
(2);
8307 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg2
);
8310 Check_Arg_Is_Identifier
(Argx
);
8312 if Chars
(Argx
) /= Name_Ada_05
then
8313 Error_Msg_Name_2
:= Name_Ada_05
;
8315 ("only allowed argument for pragma% is %", Argx
);
8318 if Ada_Version_Explicit
< Ada_05
8319 or else not Warn_On_Ada_2005_Compatibility
8327 -- Set flag if pragma active
8330 Set_Is_Obsolescent
(Subp
);
8338 -- pragma No_Run_Time
8340 -- Note: this pragma is retained for backwards compatibiltiy.
8341 -- See body of Rtsfind for full details on its handling.
8343 when Pragma_No_Run_Time
=>
8345 Check_Valid_Configuration_Pragma
;
8346 Check_Arg_Count
(0);
8348 No_Run_Time_Mode
:= True;
8349 Configurable_Run_Time_Mode
:= True;
8352 Word32
: constant Boolean := Ttypes
.System_Word_Size
= 32;
8355 Duration_32_Bits_On_Target
:= True;
8359 Set_Restriction
(No_Finalization
, N
);
8360 Set_Restriction
(No_Exception_Handlers
, N
);
8361 Set_Restriction
(Max_Tasks
, N
, 0);
8362 Set_Restriction
(No_Tasking
, N
);
8364 -----------------------
8365 -- Normalize_Scalars --
8366 -----------------------
8368 -- pragma Normalize_Scalars;
8370 when Pragma_Normalize_Scalars
=>
8371 Check_Ada_83_Warning
;
8372 Check_Arg_Count
(0);
8373 Check_Valid_Configuration_Pragma
;
8374 Normalize_Scalars
:= True;
8375 Init_Or_Norm_Scalars
:= True;
8381 -- pragma Optimize (Time | Space);
8383 -- The actual check for optimize is done in Gigi. Note that this
8384 -- pragma does not actually change the optimization setting, it
8385 -- simply checks that it is consistent with the pragma.
8387 when Pragma_Optimize
=>
8388 Check_No_Identifiers
;
8389 Check_Arg_Count
(1);
8390 Check_Arg_Is_One_Of
(Arg1
, Name_Time
, Name_Space
, Name_Off
);
8392 -------------------------
8393 -- Optional_Overriding --
8394 -------------------------
8396 -- These pragmas are treated as part of the previous subprogram
8397 -- declaration, and analyzed immediately after it (see sem_ch6,
8398 -- Check_Overriding_Operation). If the pragma has not been analyzed
8399 -- yet, it appears in the wrong place.
8401 when Pragma_Optional_Overriding
=>
8402 Error_Msg_N
("pragma must appear immediately after subprogram", N
);
8408 -- pragma Pack (first_subtype_LOCAL_NAME);
8410 when Pragma_Pack
=> Pack
: declare
8411 Assoc
: constant Node_Id
:= Arg1
;
8416 Check_No_Identifiers
;
8417 Check_Arg_Count
(1);
8418 Check_Arg_Is_Local_Name
(Arg1
);
8420 Type_Id
:= Expression
(Assoc
);
8421 Find_Type
(Type_Id
);
8422 Typ
:= Entity
(Type_Id
);
8425 or else Rep_Item_Too_Early
(Typ
, N
)
8429 Typ
:= Underlying_Type
(Typ
);
8432 if not Is_Array_Type
(Typ
) and then not Is_Record_Type
(Typ
) then
8433 Error_Pragma
("pragma% must specify array or record type");
8436 Check_First_Subtype
(Arg1
);
8438 if Has_Pragma_Pack
(Typ
) then
8439 Error_Pragma
("duplicate pragma%, only one allowed");
8443 elsif Is_Array_Type
(Typ
) then
8445 -- Pack not allowed for aliased or atomic components
8447 if Has_Aliased_Components
(Base_Type
(Typ
)) then
8449 ("pragma% ignored, cannot pack aliased components?");
8451 elsif Has_Atomic_Components
(Typ
)
8452 or else Is_Atomic
(Component_Type
(Typ
))
8455 ("?pragma% ignored, cannot pack atomic components");
8458 -- If we had an explicit component size given, then we do not
8459 -- let Pack override this given size. We also give a warning
8460 -- that Pack is being ignored unless we can tell for sure that
8461 -- the Pack would not have had any effect anyway.
8463 if Has_Component_Size_Clause
(Typ
) then
8464 if Known_Static_RM_Size
(Component_Type
(Typ
))
8466 RM_Size
(Component_Type
(Typ
)) = Component_Size
(Typ
)
8471 ("?pragma% ignored, explicit component size given");
8474 -- If no prior array component size given, Pack is effective
8477 if not Rep_Item_Too_Late
(Typ
, N
) then
8478 Set_Is_Packed
(Base_Type
(Typ
));
8479 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
8480 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
8484 -- For record types, the pack is always effective
8486 else pragma Assert
(Is_Record_Type
(Typ
));
8487 if not Rep_Item_Too_Late
(Typ
, N
) then
8488 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
8489 Set_Is_Packed
(Base_Type
(Typ
));
8490 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
8501 -- There is nothing to do here, since we did all the processing
8502 -- for this pragma in Par.Prag (so that it works properly even in
8503 -- syntax only mode)
8512 -- pragma Passive [(PASSIVE_FORM)];
8514 -- PASSIVE_FORM ::= Semaphore | No
8516 when Pragma_Passive
=>
8519 if Nkind
(Parent
(N
)) /= N_Task_Definition
then
8520 Error_Pragma
("pragma% must be within task definition");
8523 if Arg_Count
/= 0 then
8524 Check_Arg_Count
(1);
8525 Check_Arg_Is_One_Of
(Arg1
, Name_Semaphore
, Name_No
);
8532 -- pragma Polling (ON | OFF);
8534 when Pragma_Polling
=>
8536 Check_Arg_Count
(1);
8537 Check_No_Identifiers
;
8538 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
8539 Polling_Required
:= (Chars
(Expression
(Arg1
)) = Name_On
);
8541 --------------------
8542 -- Persistent_BSS --
8543 --------------------
8545 when Pragma_Persistent_BSS
=> Persistent_BSS
: declare
8552 Check_At_Most_N_Arguments
(1);
8554 -- Case of application to specific object (one argument)
8556 if Arg_Count
= 1 then
8557 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
8559 if not Is_Entity_Name
(Expression
(Arg1
))
8561 (Ekind
(Entity
(Expression
(Arg1
))) /= E_Variable
8562 and then Ekind
(Entity
(Expression
(Arg1
))) /= E_Constant
)
8564 Error_Pragma_Arg
("pragma% only applies to objects", Arg1
);
8567 Ent
:= Entity
(Expression
(Arg1
));
8568 Decl
:= Parent
(Ent
);
8570 if Rep_Item_Too_Late
(Ent
, N
) then
8574 if Present
(Expression
(Decl
)) then
8576 ("object for pragma% cannot have initialization", Arg1
);
8579 if not Is_Potentially_Persistent_Type
(Etype
(Ent
)) then
8581 ("object type for pragma% is not potentially persistent",
8586 Make_Linker_Section_Pragma
8587 (Ent
, Sloc
(N
), ".persistent.bss");
8588 Insert_After
(N
, Prag
);
8591 -- Case of use as configuration pragma with no arguments
8594 Check_Valid_Configuration_Pragma
;
8595 Persistent_BSS_Mode
:= True;
8603 -- pragma Preelaborate [(library_unit_NAME)];
8605 -- Set the flag Is_Preelaborated of program unit name entity
8607 when Pragma_Preelaborate
=> Preelaborate
: declare
8608 Pa
: constant Node_Id
:= Parent
(N
);
8609 Pk
: constant Node_Kind
:= Nkind
(Pa
);
8613 Check_Ada_83_Warning
;
8614 Check_Valid_Library_Unit_Pragma
;
8616 if Nkind
(N
) = N_Null_Statement
then
8620 Ent
:= Find_Lib_Unit_Name
;
8622 -- This filters out pragmas inside generic parent then
8623 -- show up inside instantiation
8626 and then not (Pk
= N_Package_Specification
8627 and then Present
(Generic_Parent
(Pa
)))
8629 if not Debug_Flag_U
then
8630 Set_Is_Preelaborated
(Ent
);
8631 Set_Suppress_Elaboration_Warnings
(Ent
);
8636 ---------------------
8637 -- Preelaborate_05 --
8638 ---------------------
8640 -- pragma Preelaborate_05 [(library_unit_NAME)];
8642 -- This pragma is useable only in GNAT_Mode, where it is used like
8643 -- pragma Preelaborate but it is only effective in Ada 2005 mode
8644 -- (otherwise it is ignored). This is used to implement AI-362 which
8645 -- recategorizes some run-time packages in Ada 2005 mode.
8647 when Pragma_Preelaborate_05
=> Preelaborate_05
: declare
8652 Check_Valid_Library_Unit_Pragma
;
8654 if not GNAT_Mode
then
8655 Error_Pragma
("pragma% only available in GNAT mode");
8658 if Nkind
(N
) = N_Null_Statement
then
8662 -- This is one of the few cases where we need to test the value of
8663 -- Ada_Version_Explicit rather than Ada_Version (which is always
8664 -- set to Ada_05 in a predefined unit), we need to know the
8665 -- explicit version set to know if this pragma is active.
8667 if Ada_Version_Explicit
>= Ada_05
then
8668 Ent
:= Find_Lib_Unit_Name
;
8669 Set_Is_Preelaborated
(Ent
);
8670 Set_Suppress_Elaboration_Warnings
(Ent
);
8672 end Preelaborate_05
;
8678 -- pragma Priority (EXPRESSION);
8680 when Pragma_Priority
=> Priority
: declare
8681 P
: constant Node_Id
:= Parent
(N
);
8685 Check_No_Identifiers
;
8686 Check_Arg_Count
(1);
8690 if Nkind
(P
) = N_Subprogram_Body
then
8691 Check_In_Main_Program
;
8693 Arg
:= Expression
(Arg1
);
8694 Analyze_And_Resolve
(Arg
, Standard_Integer
);
8698 if not Is_Static_Expression
(Arg
) then
8699 Flag_Non_Static_Expr
8700 ("main subprogram priority is not static!", Arg
);
8703 -- If constraint error, then we already signalled an error
8705 elsif Raises_Constraint_Error
(Arg
) then
8708 -- Otherwise check in range
8712 Val
: constant Uint
:= Expr_Value
(Arg
);
8716 or else Val
> Expr_Value
(Expression
8717 (Parent
(RTE
(RE_Max_Priority
))))
8720 ("main subprogram priority is out of range", Arg1
);
8726 (Current_Sem_Unit
, UI_To_Int
(Expr_Value
(Arg
)));
8728 -- Task or Protected, must be of type Integer
8730 elsif Nkind
(P
) = N_Protected_Definition
8732 Nkind
(P
) = N_Task_Definition
8734 Arg
:= Expression
(Arg1
);
8736 -- The expression must be analyzed in the special manner
8737 -- described in "Handling of Default and Per-Object
8738 -- Expressions" in sem.ads.
8740 Analyze_Per_Use_Expression
(Arg
, Standard_Integer
);
8742 if not Is_Static_Expression
(Arg
) then
8743 Check_Restriction
(Static_Priorities
, Arg
);
8746 -- Anything else is incorrect
8752 if Has_Priority_Pragma
(P
) then
8753 Error_Pragma
("duplicate pragma% not allowed");
8755 Set_Has_Priority_Pragma
(P
, True);
8757 if Nkind
(P
) = N_Protected_Definition
8759 Nkind
(P
) = N_Task_Definition
8761 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
8762 -- exp_ch9 should use this ???
8771 -- pragma Profile (profile_IDENTIFIER);
8773 -- profile_IDENTIFIER => Protected | Ravenscar
8775 when Pragma_Profile
=>
8776 Check_Arg_Count
(1);
8777 Check_Valid_Configuration_Pragma
;
8778 Check_No_Identifiers
;
8781 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
8783 if Chars
(Argx
) = Name_Ravenscar
then
8784 Set_Ravenscar_Profile
(N
);
8786 elsif Chars
(Argx
) = Name_Restricted
then
8787 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> False);
8789 Error_Pragma_Arg
("& is not a valid profile", Argx
);
8793 ----------------------
8794 -- Profile_Warnings --
8795 ----------------------
8797 -- pragma Profile_Warnings (profile_IDENTIFIER);
8799 -- profile_IDENTIFIER => Protected | Ravenscar
8801 when Pragma_Profile_Warnings
=>
8803 Check_Arg_Count
(1);
8804 Check_Valid_Configuration_Pragma
;
8805 Check_No_Identifiers
;
8808 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
8810 if Chars
(Argx
) = Name_Ravenscar
then
8811 Set_Profile_Restrictions
(Ravenscar
, N
, Warn
=> True);
8813 elsif Chars
(Argx
) = Name_Restricted
then
8814 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> True);
8816 Error_Pragma_Arg
("& is not a valid profile", Argx
);
8820 --------------------------
8821 -- Propagate_Exceptions --
8822 --------------------------
8824 -- pragma Propagate_Exceptions;
8826 -- Note: this pragma is obsolete and has no effect
8828 when Pragma_Propagate_Exceptions
=>
8830 Check_Arg_Count
(0);
8832 if In_Extended_Main_Source_Unit
(N
) then
8833 Propagate_Exceptions
:= True;
8840 -- pragma Psect_Object (
8841 -- [Internal =>] LOCAL_NAME,
8842 -- [, [External =>] EXTERNAL_SYMBOL]
8843 -- [, [Size =>] EXTERNAL_SYMBOL]);
8845 when Pragma_Psect_Object | Pragma_Common_Object
=>
8846 Psect_Object
: declare
8847 Args
: Args_List
(1 .. 3);
8848 Names
: constant Name_List
(1 .. 3) := (
8853 Internal
: Node_Id
renames Args
(1);
8854 External
: Node_Id
renames Args
(2);
8855 Size
: Node_Id
renames Args
(3);
8859 procedure Check_Too_Long
(Arg
: Node_Id
);
8860 -- Posts message if the argument is an identifier with more
8861 -- than 31 characters, or a string literal with more than
8862 -- 31 characters, and we are operating under VMS
8864 --------------------
8865 -- Check_Too_Long --
8866 --------------------
8868 procedure Check_Too_Long
(Arg
: Node_Id
) is
8869 X
: constant Node_Id
:= Original_Node
(Arg
);
8872 if Nkind
(X
) /= N_String_Literal
8874 Nkind
(X
) /= N_Identifier
8877 ("inappropriate argument for pragma %", Arg
);
8880 if OpenVMS_On_Target
then
8881 if (Nkind
(X
) = N_String_Literal
8882 and then String_Length
(Strval
(X
)) > 31)
8884 (Nkind
(X
) = N_Identifier
8885 and then Length_Of_Name
(Chars
(X
)) > 31)
8888 ("argument for pragma % is longer than 31 characters",
8894 -- Start of processing for Common_Object/Psect_Object
8898 Gather_Associations
(Names
, Args
);
8899 Process_Extended_Import_Export_Internal_Arg
(Internal
);
8901 Def_Id
:= Entity
(Internal
);
8903 if Ekind
(Def_Id
) /= E_Constant
8904 and then Ekind
(Def_Id
) /= E_Variable
8907 ("pragma% must designate an object", Internal
);
8910 Check_Too_Long
(Internal
);
8912 if Is_Imported
(Def_Id
) or else Is_Exported
(Def_Id
) then
8914 ("cannot use pragma% for imported/exported object",
8918 if Is_Concurrent_Type
(Etype
(Internal
)) then
8920 ("cannot specify pragma % for task/protected object",
8924 if Has_Rep_Pragma
(Def_Id
, Name_Common_Object
)
8926 Has_Rep_Pragma
(Def_Id
, Name_Psect_Object
)
8928 Error_Msg_N
("?duplicate Common/Psect_Object pragma", N
);
8931 if Ekind
(Def_Id
) = E_Constant
then
8933 ("cannot specify pragma % for a constant", Internal
);
8936 if Is_Record_Type
(Etype
(Internal
)) then
8942 Ent
:= First_Entity
(Etype
(Internal
));
8943 while Present
(Ent
) loop
8944 Decl
:= Declaration_Node
(Ent
);
8946 if Ekind
(Ent
) = E_Component
8947 and then Nkind
(Decl
) = N_Component_Declaration
8948 and then Present
(Expression
(Decl
))
8949 and then Warn_On_Export_Import
8952 ("?object for pragma % has defaults", Internal
);
8962 if Present
(Size
) then
8963 Check_Too_Long
(Size
);
8966 if Present
(External
) then
8967 Check_Arg_Is_External_Name
(External
);
8968 Check_Too_Long
(External
);
8971 -- If all error tests pass, link pragma on to the rep item chain
8973 Record_Rep_Item
(Def_Id
, N
);
8980 -- pragma Pure [(library_unit_NAME)];
8982 when Pragma_Pure
=> Pure
: declare
8986 Check_Ada_83_Warning
;
8987 Check_Valid_Library_Unit_Pragma
;
8989 if Nkind
(N
) = N_Null_Statement
then
8993 Ent
:= Find_Lib_Unit_Name
;
8995 Set_Has_Pragma_Pure
(Ent
);
8996 Set_Suppress_Elaboration_Warnings
(Ent
);
9003 -- pragma Pure_05 [(library_unit_NAME)];
9005 -- This pragma is useable only in GNAT_Mode, where it is used like
9006 -- pragma Pure but it is only effective in Ada 2005 mode (otherwise
9007 -- it is ignored). It may be used after a pragma Preelaborate, in
9008 -- which case it overrides the effect of the pragma Preelaborate.
9009 -- This is used to implement AI-362 which recategorizes some run-time
9010 -- packages in Ada 2005 mode.
9012 when Pragma_Pure_05
=> Pure_05
: declare
9017 Check_Valid_Library_Unit_Pragma
;
9019 if not GNAT_Mode
then
9020 Error_Pragma
("pragma% only available in GNAT mode");
9022 if Nkind
(N
) = N_Null_Statement
then
9026 -- This is one of the few cases where we need to test the value of
9027 -- Ada_Version_Explicit rather than Ada_Version (which is always
9028 -- set to Ada_05 in a predefined unit), we need to know the
9029 -- explicit version set to know if this pragma is active.
9031 if Ada_Version_Explicit
>= Ada_05
then
9032 Ent
:= Find_Lib_Unit_Name
;
9033 Set_Is_Preelaborated
(Ent
, False);
9035 Set_Suppress_Elaboration_Warnings
(Ent
);
9043 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
9045 when Pragma_Pure_Function
=> Pure_Function
: declare
9049 Effective
: Boolean := False;
9053 Check_Arg_Count
(1);
9054 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9055 Check_Arg_Is_Local_Name
(Arg1
);
9056 E_Id
:= Expression
(Arg1
);
9058 if Error_Posted
(E_Id
) then
9062 -- Loop through homonyms (overloadings) of referenced entity
9068 Def_Id
:= Get_Base_Subprogram
(E
);
9070 if Ekind
(Def_Id
) /= E_Function
9071 and then Ekind
(Def_Id
) /= E_Generic_Function
9072 and then Ekind
(Def_Id
) /= E_Operator
9075 ("pragma% requires a function name", Arg1
);
9078 Set_Is_Pure
(Def_Id
);
9080 if not Has_Pragma_Pure_Function
(Def_Id
) then
9081 Set_Has_Pragma_Pure_Function
(Def_Id
);
9086 exit when No
(E
) or else Scope
(E
) /= Current_Scope
;
9090 and then Warn_On_Redundant_Constructs
9092 Error_Msg_NE
("pragma Pure_Function on& is redundant?",
9098 --------------------
9099 -- Queuing_Policy --
9100 --------------------
9102 -- pragma Queuing_Policy (policy_IDENTIFIER);
9104 when Pragma_Queuing_Policy
=> declare
9108 Check_Ada_83_Warning
;
9109 Check_Arg_Count
(1);
9110 Check_No_Identifiers
;
9111 Check_Arg_Is_Queuing_Policy
(Arg1
);
9112 Check_Valid_Configuration_Pragma
;
9113 Get_Name_String
(Chars
(Expression
(Arg1
)));
9114 QP
:= Fold_Upper
(Name_Buffer
(1));
9116 if Queuing_Policy
/= ' '
9117 and then Queuing_Policy
/= QP
9119 Error_Msg_Sloc
:= Queuing_Policy_Sloc
;
9120 Error_Pragma
("queuing policy incompatible with policy#");
9122 -- Set new policy, but always preserve System_Location since
9123 -- we like the error message with the run time name.
9126 Queuing_Policy
:= QP
;
9128 if Queuing_Policy_Sloc
/= System_Location
then
9129 Queuing_Policy_Sloc
:= Loc
;
9134 ---------------------------
9135 -- Remote_Call_Interface --
9136 ---------------------------
9138 -- pragma Remote_Call_Interface [(library_unit_NAME)];
9140 when Pragma_Remote_Call_Interface
=> Remote_Call_Interface
: declare
9141 Cunit_Node
: Node_Id
;
9142 Cunit_Ent
: Entity_Id
;
9146 Check_Ada_83_Warning
;
9147 Check_Valid_Library_Unit_Pragma
;
9149 if Nkind
(N
) = N_Null_Statement
then
9153 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
9154 K
:= Nkind
(Unit
(Cunit_Node
));
9155 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
9157 if K
= N_Package_Declaration
9158 or else K
= N_Generic_Package_Declaration
9159 or else K
= N_Subprogram_Declaration
9160 or else K
= N_Generic_Subprogram_Declaration
9161 or else (K
= N_Subprogram_Body
9162 and then Acts_As_Spec
(Unit
(Cunit_Node
)))
9167 "pragma% must apply to package or subprogram declaration");
9170 Set_Is_Remote_Call_Interface
(Cunit_Ent
);
9171 end Remote_Call_Interface
;
9177 -- pragma Remote_Types [(library_unit_NAME)];
9179 when Pragma_Remote_Types
=> Remote_Types
: declare
9180 Cunit_Node
: Node_Id
;
9181 Cunit_Ent
: Entity_Id
;
9184 Check_Ada_83_Warning
;
9185 Check_Valid_Library_Unit_Pragma
;
9187 if Nkind
(N
) = N_Null_Statement
then
9191 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
9192 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
9194 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
9196 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
9199 "pragma% can only apply to a package declaration");
9202 Set_Is_Remote_Types
(Cunit_Ent
);
9209 -- pragma Ravenscar;
9211 when Pragma_Ravenscar
=>
9213 Check_Arg_Count
(0);
9214 Check_Valid_Configuration_Pragma
;
9215 Set_Ravenscar_Profile
(N
);
9217 if Warn_On_Obsolescent_Feature
then
9219 ("pragma Ravenscar is an obsolescent feature?", N
);
9221 ("|use pragma Profile (Ravenscar) instead", N
);
9224 -------------------------
9225 -- Restricted_Run_Time --
9226 -------------------------
9228 -- pragma Restricted_Run_Time;
9230 when Pragma_Restricted_Run_Time
=>
9232 Check_Arg_Count
(0);
9233 Check_Valid_Configuration_Pragma
;
9234 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> False);
9236 if Warn_On_Obsolescent_Feature
then
9238 ("pragma Restricted_Run_Time is an obsolescent feature?", N
);
9240 ("|use pragma Profile (Restricted) instead", N
);
9247 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
9250 -- restriction_IDENTIFIER
9251 -- | restriction_parameter_IDENTIFIER => EXPRESSION
9253 when Pragma_Restrictions
=>
9254 Process_Restrictions_Or_Restriction_Warnings
;
9256 --------------------------
9257 -- Restriction_Warnings --
9258 --------------------------
9260 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
9263 -- restriction_IDENTIFIER
9264 -- | restriction_parameter_IDENTIFIER => EXPRESSION
9266 when Pragma_Restriction_Warnings
=>
9267 Process_Restrictions_Or_Restriction_Warnings
;
9273 -- pragma Reviewable;
9275 when Pragma_Reviewable
=>
9276 Check_Ada_83_Warning
;
9277 Check_Arg_Count
(0);
9283 -- pragma Share_Generic (NAME {, NAME});
9285 when Pragma_Share_Generic
=>
9287 Process_Generic_List
;
9293 -- pragma Shared (LOCAL_NAME);
9295 when Pragma_Shared
=>
9297 Process_Atomic_Shared_Volatile
;
9299 --------------------
9300 -- Shared_Passive --
9301 --------------------
9303 -- pragma Shared_Passive [(library_unit_NAME)];
9305 -- Set the flag Is_Shared_Passive of program unit name entity
9307 when Pragma_Shared_Passive
=> Shared_Passive
: declare
9308 Cunit_Node
: Node_Id
;
9309 Cunit_Ent
: Entity_Id
;
9312 Check_Ada_83_Warning
;
9313 Check_Valid_Library_Unit_Pragma
;
9315 if Nkind
(N
) = N_Null_Statement
then
9319 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
9320 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
9322 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
9324 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
9327 "pragma% can only apply to a package declaration");
9330 Set_Is_Shared_Passive
(Cunit_Ent
);
9333 ----------------------
9334 -- Source_File_Name --
9335 ----------------------
9337 -- There are five forms for this pragma:
9339 -- pragma Source_File_Name (
9340 -- [UNIT_NAME =>] unit_NAME,
9341 -- BODY_FILE_NAME => STRING_LITERAL
9342 -- [, [INDEX =>] INTEGER_LITERAL]);
9344 -- pragma Source_File_Name (
9345 -- [UNIT_NAME =>] unit_NAME,
9346 -- SPEC_FILE_NAME => STRING_LITERAL
9347 -- [, [INDEX =>] INTEGER_LITERAL]);
9349 -- pragma Source_File_Name (
9350 -- BODY_FILE_NAME => STRING_LITERAL
9351 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9352 -- [, CASING => CASING_SPEC]);
9354 -- pragma Source_File_Name (
9355 -- SPEC_FILE_NAME => STRING_LITERAL
9356 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9357 -- [, CASING => CASING_SPEC]);
9359 -- pragma Source_File_Name (
9360 -- SUBUNIT_FILE_NAME => STRING_LITERAL
9361 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9362 -- [, CASING => CASING_SPEC]);
9364 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
9366 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
9367 -- Source_File_Name (SFN), however their usage is exclusive:
9368 -- SFN can only be used when no project file is used, while
9369 -- SFNP can only be used when a project file is used.
9371 -- No processing here. Processing was completed during parsing,
9372 -- since we need to have file names set as early as possible.
9373 -- Units are loaded well before semantic processing starts.
9375 -- The only processing we defer to this point is the check
9376 -- for correct placement.
9378 when Pragma_Source_File_Name
=>
9380 Check_Valid_Configuration_Pragma
;
9382 ------------------------------
9383 -- Source_File_Name_Project --
9384 ------------------------------
9386 -- See Source_File_Name for syntax
9388 -- No processing here. Processing was completed during parsing,
9389 -- since we need to have file names set as early as possible.
9390 -- Units are loaded well before semantic processing starts.
9392 -- The only processing we defer to this point is the check
9393 -- for correct placement.
9395 when Pragma_Source_File_Name_Project
=>
9397 Check_Valid_Configuration_Pragma
;
9399 -- Check that a pragma Source_File_Name_Project is used only
9400 -- in a configuration pragmas file.
9402 -- Pragmas Source_File_Name_Project should only be generated
9403 -- by the Project Manager in configuration pragmas files.
9405 -- This is really an ugly test. It seems to depend on some
9406 -- accidental and undocumented property. At the very least
9407 -- it needs to be documented, but it would be better to have
9408 -- a clean way of testing if we are in a configuration file???
9410 if Present
(Parent
(N
)) then
9412 ("pragma% can only appear in a configuration pragmas file");
9415 ----------------------
9416 -- Source_Reference --
9417 ----------------------
9419 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
9421 -- Nothing to do, all processing completed in Par.Prag, since we
9422 -- need the information for possible parser messages that are output
9424 when Pragma_Source_Reference
=>
9431 -- pragma Storage_Size (EXPRESSION);
9433 when Pragma_Storage_Size
=> Storage_Size
: declare
9434 P
: constant Node_Id
:= Parent
(N
);
9438 Check_No_Identifiers
;
9439 Check_Arg_Count
(1);
9441 -- The expression must be analyzed in the special manner
9442 -- described in "Handling of Default Expressions" in sem.ads.
9444 -- Set In_Default_Expression for per-object case ???
9446 Arg
:= Expression
(Arg1
);
9447 Analyze_Per_Use_Expression
(Arg
, Any_Integer
);
9449 if not Is_Static_Expression
(Arg
) then
9450 Check_Restriction
(Static_Storage_Size
, Arg
);
9453 if Nkind
(P
) /= N_Task_Definition
then
9458 if Has_Storage_Size_Pragma
(P
) then
9459 Error_Pragma
("duplicate pragma% not allowed");
9461 Set_Has_Storage_Size_Pragma
(P
, True);
9464 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
9465 -- ??? exp_ch9 should use this!
9473 -- pragma Storage_Unit (NUMERIC_LITERAL);
9475 -- Only permitted argument is System'Storage_Unit value
9477 when Pragma_Storage_Unit
=>
9478 Check_No_Identifiers
;
9479 Check_Arg_Count
(1);
9480 Check_Arg_Is_Integer_Literal
(Arg1
);
9482 if Intval
(Expression
(Arg1
)) /=
9483 UI_From_Int
(Ttypes
.System_Storage_Unit
)
9485 Error_Msg_Uint_1
:= UI_From_Int
(Ttypes
.System_Storage_Unit
);
9487 ("the only allowed argument for pragma% is ^", Arg1
);
9490 --------------------
9491 -- Stream_Convert --
9492 --------------------
9494 -- pragma Stream_Convert (
9495 -- [Entity =>] type_LOCAL_NAME,
9496 -- [Read =>] function_NAME,
9497 -- [Write =>] function NAME);
9499 when Pragma_Stream_Convert
=> Stream_Convert
: declare
9501 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
);
9502 -- Check that the given argument is the name of a local
9503 -- function of one argument that is not overloaded earlier
9504 -- in the current local scope. A check is also made that the
9505 -- argument is a function with one parameter.
9507 --------------------------------------
9508 -- Check_OK_Stream_Convert_Function --
9509 --------------------------------------
9511 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
) is
9515 Check_Arg_Is_Local_Name
(Arg
);
9516 Ent
:= Entity
(Expression
(Arg
));
9518 if Has_Homonym
(Ent
) then
9520 ("argument for pragma% may not be overloaded", Arg
);
9523 if Ekind
(Ent
) /= E_Function
9524 or else No
(First_Formal
(Ent
))
9525 or else Present
(Next_Formal
(First_Formal
(Ent
)))
9528 ("argument for pragma% must be" &
9529 " function of one argument", Arg
);
9531 end Check_OK_Stream_Convert_Function
;
9533 -- Start of procecessing for Stream_Convert
9537 Check_Arg_Order
((Name_Entity
, Name_Read
, Name_Write
));
9538 Check_Arg_Count
(3);
9539 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9540 Check_Optional_Identifier
(Arg2
, Name_Read
);
9541 Check_Optional_Identifier
(Arg3
, Name_Write
);
9542 Check_Arg_Is_Local_Name
(Arg1
);
9543 Check_OK_Stream_Convert_Function
(Arg2
);
9544 Check_OK_Stream_Convert_Function
(Arg3
);
9547 Typ
: constant Entity_Id
:=
9548 Underlying_Type
(Entity
(Expression
(Arg1
)));
9549 Read
: constant Entity_Id
:= Entity
(Expression
(Arg2
));
9550 Write
: constant Entity_Id
:= Entity
(Expression
(Arg3
));
9553 if Etype
(Typ
) = Any_Type
9555 Etype
(Read
) = Any_Type
9557 Etype
(Write
) = Any_Type
9562 Check_First_Subtype
(Arg1
);
9564 if Rep_Item_Too_Early
(Typ
, N
)
9566 Rep_Item_Too_Late
(Typ
, N
)
9571 if Underlying_Type
(Etype
(Read
)) /= Typ
then
9573 ("incorrect return type for function&", Arg2
);
9576 if Underlying_Type
(Etype
(First_Formal
(Write
))) /= Typ
then
9578 ("incorrect parameter type for function&", Arg3
);
9581 if Underlying_Type
(Etype
(First_Formal
(Read
))) /=
9582 Underlying_Type
(Etype
(Write
))
9585 ("result type of & does not match Read parameter type",
9591 -------------------------
9592 -- Style_Checks (GNAT) --
9593 -------------------------
9595 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
9597 -- This is processed by the parser since some of the style
9598 -- checks take place during source scanning and parsing. This
9599 -- means that we don't need to issue error messages here.
9601 when Pragma_Style_Checks
=> Style_Checks
: declare
9602 A
: constant Node_Id
:= Expression
(Arg1
);
9608 Check_No_Identifiers
;
9610 -- Two argument form
9612 if Arg_Count
= 2 then
9613 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
9620 E_Id
:= Expression
(Arg2
);
9623 if not Is_Entity_Name
(E_Id
) then
9625 ("second argument of pragma% must be entity name",
9635 Set_Suppress_Style_Checks
(E
,
9636 (Chars
(Expression
(Arg1
)) = Name_Off
));
9637 exit when No
(Homonym
(E
));
9643 -- One argument form
9646 Check_Arg_Count
(1);
9648 if Nkind
(A
) = N_String_Literal
then
9652 Slen
: constant Natural := Natural (String_Length
(S
));
9653 Options
: String (1 .. Slen
);
9659 C
:= Get_String_Char
(S
, Int
(J
));
9660 exit when not In_Character_Range
(C
);
9661 Options
(J
) := Get_Character
(C
);
9663 -- If at end of string, set options. As per discussion
9664 -- above, no need to check for errors, since we issued
9665 -- them in the parser.
9668 Set_Style_Check_Options
(Options
);
9676 elsif Nkind
(A
) = N_Identifier
then
9677 if Chars
(A
) = Name_All_Checks
then
9678 Set_Default_Style_Check_Options
;
9680 elsif Chars
(A
) = Name_On
then
9681 Style_Check
:= True;
9683 elsif Chars
(A
) = Name_Off
then
9684 Style_Check
:= False;
9694 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
9696 when Pragma_Subtitle
=>
9698 Check_Arg_Count
(1);
9699 Check_Optional_Identifier
(Arg1
, Name_Subtitle
);
9700 Check_Arg_Is_String_Literal
(Arg1
);
9706 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
9708 when Pragma_Suppress
=>
9709 Process_Suppress_Unsuppress
(True);
9715 -- pragma Suppress_All;
9717 -- The only check made here is that the pragma appears in the
9718 -- proper place, i.e. following a compilation unit. If indeed
9719 -- it appears in this context, then the parser has already
9720 -- inserted an equivalent pragma Suppress (All_Checks) to get
9721 -- the required effect.
9723 when Pragma_Suppress_All
=>
9725 Check_Arg_Count
(0);
9727 if Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
9728 or else not Is_List_Member
(N
)
9729 or else List_Containing
(N
) /= Pragmas_After
(Parent
(N
))
9732 ("misplaced pragma%, must follow compilation unit");
9735 -------------------------
9736 -- Suppress_Debug_Info --
9737 -------------------------
9739 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
9741 when Pragma_Suppress_Debug_Info
=>
9743 Check_Arg_Count
(1);
9744 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9745 Check_Arg_Is_Local_Name
(Arg1
);
9746 Set_Debug_Info_Off
(Entity
(Get_Pragma_Arg
(Arg1
)));
9748 ----------------------------------
9749 -- Suppress_Exception_Locations --
9750 ----------------------------------
9752 -- pragma Suppress_Exception_Locations;
9754 when Pragma_Suppress_Exception_Locations
=>
9756 Check_Arg_Count
(0);
9757 Check_Valid_Configuration_Pragma
;
9758 Exception_Locations_Suppressed
:= True;
9760 -----------------------------
9761 -- Suppress_Initialization --
9762 -----------------------------
9764 -- pragma Suppress_Initialization ([Entity =>] type_Name);
9766 when Pragma_Suppress_Initialization
=> Suppress_Init
: declare
9772 Check_Arg_Count
(1);
9773 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9774 Check_Arg_Is_Local_Name
(Arg1
);
9776 E_Id
:= Expression
(Arg1
);
9778 if Etype
(E_Id
) = Any_Type
then
9785 if Is_Incomplete_Or_Private_Type
(E
) then
9786 if No
(Full_View
(Base_Type
(E
))) then
9788 ("argument of pragma% cannot be an incomplete type",
9791 Set_Suppress_Init_Proc
(Full_View
(Base_Type
(E
)));
9794 Set_Suppress_Init_Proc
(Base_Type
(E
));
9799 ("pragma% requires argument that is a type name", Arg1
);
9807 -- pragma System_Name (DIRECT_NAME);
9809 -- Syntax check: one argument, which must be the identifier GNAT
9810 -- or the identifier GCC, no other identifiers are acceptable.
9812 when Pragma_System_Name
=>
9813 Check_No_Identifiers
;
9814 Check_Arg_Count
(1);
9815 Check_Arg_Is_One_Of
(Arg1
, Name_Gcc
, Name_Gnat
);
9817 -----------------------------
9818 -- Task_Dispatching_Policy --
9819 -----------------------------
9821 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
9823 when Pragma_Task_Dispatching_Policy
=> declare
9827 Check_Ada_83_Warning
;
9828 Check_Arg_Count
(1);
9829 Check_No_Identifiers
;
9830 Check_Arg_Is_Task_Dispatching_Policy
(Arg1
);
9831 Check_Valid_Configuration_Pragma
;
9832 Get_Name_String
(Chars
(Expression
(Arg1
)));
9833 DP
:= Fold_Upper
(Name_Buffer
(1));
9835 if Task_Dispatching_Policy
/= ' '
9836 and then Task_Dispatching_Policy
/= DP
9838 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
9840 ("task dispatching policy incompatible with policy#");
9842 -- Set new policy, but always preserve System_Location since
9843 -- we like the error message with the run time name.
9846 Task_Dispatching_Policy
:= DP
;
9848 if Task_Dispatching_Policy_Sloc
/= System_Location
then
9849 Task_Dispatching_Policy_Sloc
:= Loc
;
9858 -- pragma Task_Info (EXPRESSION);
9860 when Pragma_Task_Info
=> Task_Info
: declare
9861 P
: constant Node_Id
:= Parent
(N
);
9866 if Nkind
(P
) /= N_Task_Definition
then
9867 Error_Pragma
("pragma% must appear in task definition");
9870 Check_No_Identifiers
;
9871 Check_Arg_Count
(1);
9873 Analyze_And_Resolve
(Expression
(Arg1
), RTE
(RE_Task_Info_Type
));
9875 if Etype
(Expression
(Arg1
)) = Any_Type
then
9879 if Has_Task_Info_Pragma
(P
) then
9880 Error_Pragma
("duplicate pragma% not allowed");
9882 Set_Has_Task_Info_Pragma
(P
, True);
9890 -- pragma Task_Name (string_EXPRESSION);
9892 when Pragma_Task_Name
=> Task_Name
: declare
9893 -- pragma Priority (EXPRESSION);
9895 P
: constant Node_Id
:= Parent
(N
);
9899 Check_No_Identifiers
;
9900 Check_Arg_Count
(1);
9902 Arg
:= Expression
(Arg1
);
9903 Analyze_And_Resolve
(Arg
, Standard_String
);
9905 if Nkind
(P
) /= N_Task_Definition
then
9909 if Has_Task_Name_Pragma
(P
) then
9910 Error_Pragma
("duplicate pragma% not allowed");
9912 Set_Has_Task_Name_Pragma
(P
, True);
9913 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
9921 -- pragma Task_Storage (
9922 -- [Task_Type =>] LOCAL_NAME,
9923 -- [Top_Guard =>] static_integer_EXPRESSION);
9925 when Pragma_Task_Storage
=> Task_Storage
: declare
9926 Args
: Args_List
(1 .. 2);
9927 Names
: constant Name_List
(1 .. 2) := (
9931 Task_Type
: Node_Id
renames Args
(1);
9932 Top_Guard
: Node_Id
renames Args
(2);
9938 Gather_Associations
(Names
, Args
);
9940 if No
(Task_Type
) then
9942 ("missing task_type argument for pragma%");
9945 Check_Arg_Is_Local_Name
(Task_Type
);
9947 Ent
:= Entity
(Task_Type
);
9949 if not Is_Task_Type
(Ent
) then
9951 ("argument for pragma% must be task type", Task_Type
);
9954 if No
(Top_Guard
) then
9956 ("pragma% takes two arguments", Task_Type
);
9958 Check_Arg_Is_Static_Expression
(Top_Guard
, Any_Integer
);
9961 Check_First_Subtype
(Task_Type
);
9963 if Rep_Item_Too_Late
(Ent
, N
) then
9972 -- pragma Thread_Body
9973 -- ( [Entity =>] LOCAL_NAME
9974 -- [,[Secondary_Stack_Size =>] static_integer_EXPRESSION]);
9976 when Pragma_Thread_Body
=> Thread_Body
: declare
9983 Check_Arg_Order
((Name_Entity
, Name_Secondary_Stack_Size
));
9984 Check_At_Least_N_Arguments
(1);
9985 Check_At_Most_N_Arguments
(2);
9986 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9987 Check_Arg_Is_Local_Name
(Arg1
);
9989 Id
:= Expression
(Arg1
);
9991 if not Is_Entity_Name
(Id
)
9992 or else not Is_Subprogram
(Entity
(Id
))
9994 Error_Pragma_Arg
("subprogram name required", Arg1
);
9999 -- Go to renamed subprogram if present, since Thread_Body applies
10000 -- to the actual renamed entity, not to the renaming entity.
10002 if Present
(Alias
(E
))
10003 and then Nkind
(Parent
(Declaration_Node
(E
))) =
10004 N_Subprogram_Renaming_Declaration
10009 -- Various error checks
10011 if Nkind
(Parent
(Declaration_Node
(E
))) = N_Subprogram_Body
then
10013 ("pragma% requires separate spec and must come before body");
10015 elsif Rep_Item_Too_Early
(E
, N
)
10016 or else Rep_Item_Too_Late
(E
, N
)
10020 elsif Is_Thread_Body
(E
) then
10022 ("only one thread body pragma allowed", Arg1
);
10024 elsif Present
(Homonym
(E
))
10025 and then Scope
(Homonym
(E
)) = Current_Scope
10028 ("thread body subprogram must not be overloaded", Arg1
);
10031 Set_Is_Thread_Body
(E
);
10033 -- Deal with secondary stack argument
10035 if Arg_Count
= 2 then
10036 Check_Optional_Identifier
(Arg2
, Name_Secondary_Stack_Size
);
10037 SS
:= Expression
(Arg2
);
10038 Analyze_And_Resolve
(SS
, Any_Integer
);
10046 -- pragma Time_Slice (static_duration_EXPRESSION);
10048 when Pragma_Time_Slice
=> Time_Slice
: declare
10054 Check_Arg_Count
(1);
10055 Check_No_Identifiers
;
10056 Check_In_Main_Program
;
10057 Check_Arg_Is_Static_Expression
(Arg1
, Standard_Duration
);
10059 if not Error_Posted
(Arg1
) then
10061 while Present
(Nod
) loop
10062 if Nkind
(Nod
) = N_Pragma
10063 and then Chars
(Nod
) = Name_Time_Slice
10065 Error_Msg_Name_1
:= Chars
(N
);
10066 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
10073 -- Process only if in main unit
10075 if Get_Source_Unit
(Loc
) = Main_Unit
then
10076 Opt
.Time_Slice_Set
:= True;
10077 Val
:= Expr_Value_R
(Expression
(Arg1
));
10079 if Val
<= Ureal_0
then
10080 Opt
.Time_Slice_Value
:= 0;
10082 elsif Val
> UR_From_Uint
(UI_From_Int
(1000)) then
10083 Opt
.Time_Slice_Value
:= 1_000_000_000
;
10086 Opt
.Time_Slice_Value
:=
10087 UI_To_Int
(UR_To_Uint
(Val
* UI_From_Int
(1_000_000
)));
10096 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
10098 -- TITLING_OPTION ::=
10099 -- [Title =>] STRING_LITERAL
10100 -- | [Subtitle =>] STRING_LITERAL
10102 when Pragma_Title
=> Title
: declare
10103 Args
: Args_List
(1 .. 2);
10104 Names
: constant Name_List
(1 .. 2) := (
10110 Gather_Associations
(Names
, Args
);
10112 for J
in 1 .. 2 loop
10113 if Present
(Args
(J
)) then
10114 Check_Arg_Is_String_Literal
(Args
(J
));
10119 ---------------------
10120 -- Unchecked_Union --
10121 ---------------------
10123 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
10125 when Pragma_Unchecked_Union
=> Unchecked_Union
: declare
10126 Assoc
: constant Node_Id
:= Arg1
;
10127 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
10138 Check_No_Identifiers
;
10139 Check_Arg_Count
(1);
10140 Check_Arg_Is_Local_Name
(Arg1
);
10142 Find_Type
(Type_Id
);
10143 Typ
:= Entity
(Type_Id
);
10146 or else Rep_Item_Too_Early
(Typ
, N
)
10150 Typ
:= Underlying_Type
(Typ
);
10153 if Rep_Item_Too_Late
(Typ
, N
) then
10157 Check_First_Subtype
(Arg1
);
10159 -- Note remaining cases are references to a type in the current
10160 -- declarative part. If we find an error, we post the error on
10161 -- the relevant type declaration at an appropriate point.
10163 if not Is_Record_Type
(Typ
) then
10164 Error_Msg_N
("Unchecked_Union must be record type", Typ
);
10167 elsif Is_Tagged_Type
(Typ
) then
10168 Error_Msg_N
("Unchecked_Union must not be tagged", Typ
);
10171 elsif Is_Limited_Type
(Typ
) then
10173 ("Unchecked_Union must not be limited record type", Typ
);
10174 Explain_Limited_Type
(Typ
, Typ
);
10178 if not Has_Discriminants
(Typ
) then
10180 ("Unchecked_Union must have one discriminant", Typ
);
10184 Discr
:= First_Discriminant
(Typ
);
10186 while Present
(Discr
) loop
10187 if No
(Discriminant_Default_Value
(Discr
)) then
10189 ("Unchecked_Union discriminant must have default value",
10192 Next_Discriminant
(Discr
);
10195 Tdef
:= Type_Definition
(Declaration_Node
(Typ
));
10196 Clist
:= Component_List
(Tdef
);
10198 Comp
:= First
(Component_Items
(Clist
));
10199 while Present
(Comp
) loop
10201 Check_Component
(Comp
);
10206 if No
(Clist
) or else No
(Variant_Part
(Clist
)) then
10208 ("Unchecked_Union must have variant part",
10213 Vpart
:= Variant_Part
(Clist
);
10215 Variant
:= First
(Variants
(Vpart
));
10216 while Present
(Variant
) loop
10217 Check_Variant
(Variant
);
10222 Set_Is_Unchecked_Union
(Typ
, True);
10223 Set_Convention
(Typ
, Convention_C
);
10225 Set_Has_Unchecked_Union
(Base_Type
(Typ
), True);
10226 Set_Is_Unchecked_Union
(Base_Type
(Typ
), True);
10227 end Unchecked_Union
;
10229 ------------------------
10230 -- Unimplemented_Unit --
10231 ------------------------
10233 -- pragma Unimplemented_Unit;
10235 -- Note: this only gives an error if we are generating code,
10236 -- or if we are in a generic library unit (where the pragma
10237 -- appears in the body, not in the spec).
10239 when Pragma_Unimplemented_Unit
=> Unimplemented_Unit
: declare
10240 Cunitent
: constant Entity_Id
:=
10241 Cunit_Entity
(Get_Source_Unit
(Loc
));
10242 Ent_Kind
: constant Entity_Kind
:=
10247 Check_Arg_Count
(0);
10249 if Operating_Mode
= Generate_Code
10250 or else Ent_Kind
= E_Generic_Function
10251 or else Ent_Kind
= E_Generic_Procedure
10252 or else Ent_Kind
= E_Generic_Package
10254 Get_Name_String
(Chars
(Cunitent
));
10255 Set_Casing
(Mixed_Case
);
10256 Write_Str
(Name_Buffer
(1 .. Name_Len
));
10257 Write_Str
(" is not implemented");
10259 raise Unrecoverable_Error
;
10261 end Unimplemented_Unit
;
10263 --------------------
10264 -- Universal_Data --
10265 --------------------
10267 -- pragma Universal_Data [(library_unit_NAME)];
10269 when Pragma_Universal_Data
=>
10272 -- If this is a configuration pragma, then set the universal
10273 -- addressing option, otherwise confirm that the pragma
10274 -- satisfies the requirements of library unit pragma placement
10275 -- and leave it to the GNAAMP back end to detect the pragma
10276 -- (avoids transitive setting of the option due to withed units).
10278 if Is_Configuration_Pragma
then
10279 Universal_Addressing_On_AAMP
:= True;
10281 Check_Valid_Library_Unit_Pragma
;
10284 if not AAMP_On_Target
then
10285 Error_Pragma
("?pragma% ignored (applies only to AAMP)");
10292 -- pragma Unreferenced (local_Name {, local_Name});
10294 when Pragma_Unreferenced
=> Unreferenced
: declare
10295 Arg_Node
: Node_Id
;
10296 Arg_Expr
: Node_Id
;
10297 Arg_Ent
: Entity_Id
;
10301 Check_At_Least_N_Arguments
(1);
10304 while Present
(Arg_Node
) loop
10305 Check_No_Identifier
(Arg_Node
);
10307 -- Note that the analyze call done by Check_Arg_Is_Local_Name
10308 -- will in fact generate a reference, so that the entity will
10309 -- have a reference, which will inhibit any warnings about it
10310 -- not being referenced, and also properly show up in the ali
10311 -- file as a reference. But this reference is recorded before
10312 -- the Has_Pragma_Unreferenced flag is set, so that no warning
10313 -- is generated for this reference.
10315 Check_Arg_Is_Local_Name
(Arg_Node
);
10316 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
10318 if Is_Entity_Name
(Arg_Expr
) then
10319 Arg_Ent
:= Entity
(Arg_Expr
);
10321 -- If the entity is overloaded, the pragma applies to the
10322 -- most recent overloading, as documented. In this case,
10323 -- name resolution does not generate a reference, so it
10324 -- must be done here explicitly.
10326 if Is_Overloaded
(Arg_Expr
) then
10327 Generate_Reference
(Arg_Ent
, N
);
10330 Set_Has_Pragma_Unreferenced
(Arg_Ent
);
10337 ------------------------------
10338 -- Unreserve_All_Interrupts --
10339 ------------------------------
10341 -- pragma Unreserve_All_Interrupts;
10343 when Pragma_Unreserve_All_Interrupts
=>
10345 Check_Arg_Count
(0);
10347 if In_Extended_Main_Code_Unit
(Main_Unit_Entity
) then
10348 Unreserve_All_Interrupts
:= True;
10355 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
10357 when Pragma_Unsuppress
=>
10359 Process_Suppress_Unsuppress
(False);
10361 -------------------
10362 -- Use_VADS_Size --
10363 -------------------
10365 -- pragma Use_VADS_Size;
10367 when Pragma_Use_VADS_Size
=>
10369 Check_Arg_Count
(0);
10370 Check_Valid_Configuration_Pragma
;
10371 Use_VADS_Size
:= True;
10373 ---------------------
10374 -- Validity_Checks --
10375 ---------------------
10377 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
10379 when Pragma_Validity_Checks
=> Validity_Checks
: declare
10380 A
: constant Node_Id
:= Expression
(Arg1
);
10386 Check_Arg_Count
(1);
10387 Check_No_Identifiers
;
10389 if Nkind
(A
) = N_String_Literal
then
10393 Slen
: constant Natural := Natural (String_Length
(S
));
10394 Options
: String (1 .. Slen
);
10400 C
:= Get_String_Char
(S
, Int
(J
));
10401 exit when not In_Character_Range
(C
);
10402 Options
(J
) := Get_Character
(C
);
10405 Set_Validity_Check_Options
(Options
);
10413 elsif Nkind
(A
) = N_Identifier
then
10415 if Chars
(A
) = Name_All_Checks
then
10416 Set_Validity_Check_Options
("a");
10418 elsif Chars
(A
) = Name_On
then
10419 Validity_Checks_On
:= True;
10421 elsif Chars
(A
) = Name_Off
then
10422 Validity_Checks_On
:= False;
10426 end Validity_Checks
;
10432 -- pragma Volatile (LOCAL_NAME);
10434 when Pragma_Volatile
=>
10435 Process_Atomic_Shared_Volatile
;
10437 -------------------------
10438 -- Volatile_Components --
10439 -------------------------
10441 -- pragma Volatile_Components (array_LOCAL_NAME);
10443 -- Volatile is handled by the same circuit as Atomic_Components
10449 -- pragma Warnings (On | Off, [LOCAL_NAME])
10450 -- pragma Warnings (static_string_EXPRESSION);
10452 when Pragma_Warnings
=> Warnings
: begin
10454 Check_At_Least_N_Arguments
(1);
10455 Check_No_Identifiers
;
10457 -- One argument case
10459 if Arg_Count
= 1 then
10461 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
10464 -- On/Off one argument case was processed by parser
10466 if Nkind
(Argx
) = N_Identifier
10468 (Chars
(Argx
) = Name_On
10470 Chars
(Argx
) = Name_Off
)
10475 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
10478 Lit
: constant Node_Id
:= Expr_Value_S
(Argx
);
10479 Str
: constant String_Id
:= Strval
(Lit
);
10483 for J
in 1 .. String_Length
(Str
) loop
10484 C
:= Get_String_Char
(Str
, J
);
10486 if In_Character_Range
(C
)
10487 and then Set_Warning_Switch
(Get_Character
(C
))
10492 ("invalid warning switch character", Arg1
);
10499 -- Two argument case
10501 elsif Arg_Count
/= 1 then
10502 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
10503 Check_Arg_Count
(2);
10510 E_Id
:= Expression
(Arg2
);
10513 -- In the expansion of an inlined body, a reference to
10514 -- the formal may be wrapped in a conversion if the actual
10515 -- is a conversion. Retrieve the real entity name.
10517 if (In_Instance_Body
10518 or else In_Inlined_Body
)
10519 and then Nkind
(E_Id
) = N_Unchecked_Type_Conversion
10521 E_Id
:= Expression
(E_Id
);
10524 if not Is_Entity_Name
(E_Id
) then
10526 ("second argument of pragma% must be entity name",
10530 E
:= Entity
(E_Id
);
10537 (E
, (Chars
(Expression
(Arg1
)) = Name_Off
));
10539 if Is_Enumeration_Type
(E
) then
10543 Lit
:= First_Literal
(E
);
10544 while Present
(Lit
) loop
10545 Set_Warnings_Off
(Lit
);
10546 Next_Literal
(Lit
);
10551 exit when No
(Homonym
(E
));
10557 -- More than two arguments
10559 Check_At_Most_N_Arguments
(2);
10563 -------------------
10564 -- Weak_External --
10565 -------------------
10567 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
10569 when Pragma_Weak_External
=> Weak_External
: declare
10574 Check_Arg_Count
(1);
10575 Check_Optional_Identifier
(Arg1
, Name_Entity
);
10576 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
10577 Ent
:= Entity
(Expression
(Arg1
));
10579 if Rep_Item_Too_Early
(Ent
, N
) then
10582 Ent
:= Underlying_Type
(Ent
);
10585 -- The only processing required is to link this item on to the
10586 -- list of rep items for the given entity. This is accomplished
10587 -- by the call to Rep_Item_Too_Late (when no error is detected
10588 -- and False is returned).
10590 if Rep_Item_Too_Late
(Ent
, N
) then
10593 Set_Has_Gigi_Rep_Item
(Ent
);
10597 --------------------
10598 -- Unknown_Pragma --
10599 --------------------
10601 -- Should be impossible, since the case of an unknown pragma is
10602 -- separately processed before the case statement is entered.
10604 when Unknown_Pragma
=>
10605 raise Program_Error
;
10609 when Pragma_Exit
=> null;
10610 end Analyze_Pragma
;
10612 ---------------------------------
10613 -- Delay_Config_Pragma_Analyze --
10614 ---------------------------------
10616 function Delay_Config_Pragma_Analyze
(N
: Node_Id
) return Boolean is
10618 return Chars
(N
) = Name_Interrupt_State
;
10619 end Delay_Config_Pragma_Analyze
;
10621 -------------------------
10622 -- Get_Base_Subprogram --
10623 -------------------------
10625 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
is
10626 Result
: Entity_Id
;
10629 -- Follow subprogram renaming chain
10632 while Is_Subprogram
(Result
)
10634 (Is_Generic_Instance
(Result
)
10635 or else Nkind
(Parent
(Declaration_Node
(Result
))) =
10636 N_Subprogram_Renaming_Declaration
)
10637 and then Present
(Alias
(Result
))
10639 Result
:= Alias
(Result
);
10643 end Get_Base_Subprogram
;
10645 -----------------------------
10646 -- Is_Config_Static_String --
10647 -----------------------------
10649 function Is_Config_Static_String
(Arg
: Node_Id
) return Boolean is
10651 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean;
10652 -- This is an internal recursive function that is just like the
10653 -- outer function except that it adds the string to the name buffer
10654 -- rather than placing the string in the name buffer.
10656 ------------------------------
10657 -- Add_Config_Static_String --
10658 ------------------------------
10660 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean is
10667 if Nkind
(N
) = N_Op_Concat
then
10668 if Add_Config_Static_String
(Left_Opnd
(N
)) then
10669 N
:= Right_Opnd
(N
);
10675 if Nkind
(N
) /= N_String_Literal
then
10676 Error_Msg_N
("string literal expected for pragma argument", N
);
10680 for J
in 1 .. String_Length
(Strval
(N
)) loop
10681 C
:= Get_String_Char
(Strval
(N
), J
);
10683 if not In_Character_Range
(C
) then
10685 ("string literal contains invalid wide character",
10686 Sloc
(N
) + 1 + Source_Ptr
(J
));
10690 Add_Char_To_Name_Buffer
(Get_Character
(C
));
10695 end Add_Config_Static_String
;
10697 -- Start of prorcessing for Is_Config_Static_String
10702 return Add_Config_Static_String
(Arg
);
10703 end Is_Config_Static_String
;
10705 -----------------------------------------
10706 -- Is_Non_Significant_Pragma_Reference --
10707 -----------------------------------------
10709 -- This function makes use of the following static table which indicates
10710 -- whether a given pragma is significant. A value of -1 in this table
10711 -- indicates that the reference is significant. A value of zero indicates
10712 -- than appearence as any argument is insignificant, a positive value
10713 -- indicates that appearence in that parameter position is significant.
10715 Sig_Flags
: constant array (Pragma_Id
) of Int
:=
10717 (Pragma_AST_Entry
=> -1,
10718 Pragma_Abort_Defer
=> -1,
10719 Pragma_Ada_83
=> -1,
10720 Pragma_Ada_95
=> -1,
10721 Pragma_Ada_05
=> -1,
10722 Pragma_Ada_2005
=> -1,
10723 Pragma_All_Calls_Remote
=> -1,
10724 Pragma_Annotate
=> -1,
10725 Pragma_Assert
=> -1,
10726 Pragma_Assertion_Policy
=> 0,
10727 Pragma_Asynchronous
=> -1,
10728 Pragma_Atomic
=> 0,
10729 Pragma_Atomic_Components
=> 0,
10730 Pragma_Attach_Handler
=> -1,
10731 Pragma_CPP_Class
=> 0,
10732 Pragma_CPP_Constructor
=> 0,
10733 Pragma_CPP_Virtual
=> 0,
10734 Pragma_CPP_Vtable
=> 0,
10735 Pragma_C_Pass_By_Copy
=> 0,
10736 Pragma_Comment
=> 0,
10737 Pragma_Common_Object
=> -1,
10738 Pragma_Compile_Time_Warning
=> -1,
10739 Pragma_Complete_Representation
=> 0,
10740 Pragma_Complex_Representation
=> 0,
10741 Pragma_Component_Alignment
=> -1,
10742 Pragma_Controlled
=> 0,
10743 Pragma_Convention
=> 0,
10744 Pragma_Convention_Identifier
=> 0,
10745 Pragma_Debug
=> -1,
10746 Pragma_Debug_Policy
=> 0,
10747 Pragma_Detect_Blocking
=> -1,
10748 Pragma_Discard_Names
=> 0,
10749 Pragma_Elaborate
=> -1,
10750 Pragma_Elaborate_All
=> -1,
10751 Pragma_Elaborate_Body
=> -1,
10752 Pragma_Elaboration_Checks
=> -1,
10753 Pragma_Eliminate
=> -1,
10754 Pragma_Explicit_Overriding
=> -1,
10755 Pragma_Export
=> -1,
10756 Pragma_Export_Exception
=> -1,
10757 Pragma_Export_Function
=> -1,
10758 Pragma_Export_Object
=> -1,
10759 Pragma_Export_Procedure
=> -1,
10760 Pragma_Export_Value
=> -1,
10761 Pragma_Export_Valued_Procedure
=> -1,
10762 Pragma_Extend_System
=> -1,
10763 Pragma_Extensions_Allowed
=> -1,
10764 Pragma_External
=> -1,
10765 Pragma_External_Name_Casing
=> -1,
10766 Pragma_Finalize_Storage_Only
=> 0,
10767 Pragma_Float_Representation
=> 0,
10768 Pragma_Ident
=> -1,
10769 Pragma_Import
=> +2,
10770 Pragma_Import_Exception
=> 0,
10771 Pragma_Import_Function
=> 0,
10772 Pragma_Import_Object
=> 0,
10773 Pragma_Import_Procedure
=> 0,
10774 Pragma_Import_Valued_Procedure
=> 0,
10775 Pragma_Initialize_Scalars
=> -1,
10776 Pragma_Inline
=> 0,
10777 Pragma_Inline_Always
=> 0,
10778 Pragma_Inline_Generic
=> 0,
10779 Pragma_Inspection_Point
=> -1,
10780 Pragma_Interface
=> +2,
10781 Pragma_Interface_Name
=> +2,
10782 Pragma_Interrupt_Handler
=> -1,
10783 Pragma_Interrupt_Priority
=> -1,
10784 Pragma_Interrupt_State
=> -1,
10785 Pragma_Java_Constructor
=> -1,
10786 Pragma_Java_Interface
=> -1,
10787 Pragma_Keep_Names
=> 0,
10788 Pragma_License
=> -1,
10789 Pragma_Link_With
=> -1,
10790 Pragma_Linker_Alias
=> -1,
10791 Pragma_Linker_Constructor
=> -1,
10792 Pragma_Linker_Destructor
=> -1,
10793 Pragma_Linker_Options
=> -1,
10794 Pragma_Linker_Section
=> -1,
10796 Pragma_Locking_Policy
=> -1,
10797 Pragma_Long_Float
=> -1,
10798 Pragma_Machine_Attribute
=> -1,
10800 Pragma_Main_Storage
=> -1,
10801 Pragma_Memory_Size
=> -1,
10802 Pragma_No_Return
=> 0,
10803 Pragma_No_Run_Time
=> -1,
10804 Pragma_No_Strict_Aliasing
=> -1,
10805 Pragma_Normalize_Scalars
=> -1,
10806 Pragma_Obsolescent
=> 0,
10807 Pragma_Optimize
=> -1,
10808 Pragma_Optional_Overriding
=> -1,
10811 Pragma_Passive
=> -1,
10812 Pragma_Polling
=> -1,
10813 Pragma_Persistent_BSS
=> 0,
10814 Pragma_Preelaborate
=> -1,
10815 Pragma_Preelaborate_05
=> -1,
10816 Pragma_Priority
=> -1,
10817 Pragma_Profile
=> 0,
10818 Pragma_Profile_Warnings
=> 0,
10819 Pragma_Propagate_Exceptions
=> -1,
10820 Pragma_Psect_Object
=> -1,
10822 Pragma_Pure_05
=> -1,
10823 Pragma_Pure_Function
=> -1,
10824 Pragma_Queuing_Policy
=> -1,
10825 Pragma_Ravenscar
=> -1,
10826 Pragma_Remote_Call_Interface
=> -1,
10827 Pragma_Remote_Types
=> -1,
10828 Pragma_Restricted_Run_Time
=> -1,
10829 Pragma_Restriction_Warnings
=> -1,
10830 Pragma_Restrictions
=> -1,
10831 Pragma_Reviewable
=> -1,
10832 Pragma_Share_Generic
=> -1,
10833 Pragma_Shared
=> -1,
10834 Pragma_Shared_Passive
=> -1,
10835 Pragma_Source_File_Name
=> -1,
10836 Pragma_Source_File_Name_Project
=> -1,
10837 Pragma_Source_Reference
=> -1,
10838 Pragma_Storage_Size
=> -1,
10839 Pragma_Storage_Unit
=> -1,
10840 Pragma_Stream_Convert
=> -1,
10841 Pragma_Style_Checks
=> -1,
10842 Pragma_Subtitle
=> -1,
10843 Pragma_Suppress
=> 0,
10844 Pragma_Suppress_Exception_Locations
=> 0,
10845 Pragma_Suppress_All
=> -1,
10846 Pragma_Suppress_Debug_Info
=> 0,
10847 Pragma_Suppress_Initialization
=> 0,
10848 Pragma_System_Name
=> -1,
10849 Pragma_Task_Dispatching_Policy
=> -1,
10850 Pragma_Task_Info
=> -1,
10851 Pragma_Task_Name
=> -1,
10852 Pragma_Task_Storage
=> 0,
10853 Pragma_Thread_Body
=> +2,
10854 Pragma_Time_Slice
=> -1,
10855 Pragma_Title
=> -1,
10856 Pragma_Unchecked_Union
=> 0,
10857 Pragma_Unimplemented_Unit
=> -1,
10858 Pragma_Universal_Data
=> -1,
10859 Pragma_Unreferenced
=> -1,
10860 Pragma_Unreserve_All_Interrupts
=> -1,
10861 Pragma_Unsuppress
=> 0,
10862 Pragma_Use_VADS_Size
=> -1,
10863 Pragma_Validity_Checks
=> -1,
10864 Pragma_Volatile
=> 0,
10865 Pragma_Volatile_Components
=> 0,
10866 Pragma_Warnings
=> -1,
10867 Pragma_Weak_External
=> 0,
10868 Unknown_Pragma
=> 0);
10870 function Is_Non_Significant_Pragma_Reference
(N
: Node_Id
) return Boolean is
10878 if Nkind
(P
) /= N_Pragma_Argument_Association
then
10882 C
:= Sig_Flags
(Get_Pragma_Id
(Chars
(Parent
(P
))));
10892 A
:= First
(Pragma_Argument_Associations
(Parent
(P
)));
10893 for J
in 1 .. C
- 1 loop
10904 end Is_Non_Significant_Pragma_Reference
;
10906 ------------------------------
10907 -- Is_Pragma_String_Literal --
10908 ------------------------------
10910 -- This function returns true if the corresponding pragma argument is
10911 -- a static string expression. These are the only cases in which string
10912 -- literals can appear as pragma arguments. We also allow a string
10913 -- literal as the first argument to pragma Assert (although it will
10914 -- of course always generate a type error).
10916 function Is_Pragma_String_Literal
(Par
: Node_Id
) return Boolean is
10917 Pragn
: constant Node_Id
:= Parent
(Par
);
10918 Assoc
: constant List_Id
:= Pragma_Argument_Associations
(Pragn
);
10919 Pname
: constant Name_Id
:= Chars
(Pragn
);
10925 N
:= First
(Assoc
);
10932 if Pname
= Name_Assert
then
10935 elsif Pname
= Name_Export
then
10938 elsif Pname
= Name_Ident
then
10941 elsif Pname
= Name_Import
then
10944 elsif Pname
= Name_Interface_Name
then
10947 elsif Pname
= Name_Linker_Alias
then
10950 elsif Pname
= Name_Linker_Section
then
10953 elsif Pname
= Name_Machine_Attribute
then
10956 elsif Pname
= Name_Source_File_Name
then
10959 elsif Pname
= Name_Source_Reference
then
10962 elsif Pname
= Name_Title
then
10965 elsif Pname
= Name_Subtitle
then
10971 end Is_Pragma_String_Literal
;
10973 --------------------------------------
10974 -- Process_Compilation_Unit_Pragmas --
10975 --------------------------------------
10977 procedure Process_Compilation_Unit_Pragmas
(N
: Node_Id
) is
10979 -- A special check for pragma Suppress_All. This is a strange DEC
10980 -- pragma, strange because it comes at the end of the unit. If we
10981 -- have a pragma Suppress_All in the Pragmas_After of the current
10982 -- unit, then we insert a pragma Suppress (All_Checks) at the start
10983 -- of the context clause to ensure the correct processing.
10986 PA
: constant List_Id
:= Pragmas_After
(Aux_Decls_Node
(N
));
10990 if Present
(PA
) then
10992 while Present
(P
) loop
10993 if Chars
(P
) = Name_Suppress_All
then
10994 Prepend_To
(Context_Items
(N
),
10995 Make_Pragma
(Sloc
(P
),
10996 Chars
=> Name_Suppress
,
10997 Pragma_Argument_Associations
=> New_List
(
10998 Make_Pragma_Argument_Association
(Sloc
(P
),
11000 Make_Identifier
(Sloc
(P
),
11001 Chars
=> Name_All_Checks
)))));
11009 end Process_Compilation_Unit_Pragmas
;
11011 --------------------------------
11012 -- Set_Encoded_Interface_Name --
11013 --------------------------------
11015 procedure Set_Encoded_Interface_Name
(E
: Entity_Id
; S
: Node_Id
) is
11016 Str
: constant String_Id
:= Strval
(S
);
11017 Len
: constant Int
:= String_Length
(Str
);
11022 Hex
: constant array (0 .. 15) of Character := "0123456789abcdef";
11025 -- Stores encoded value of character code CC. The encoding we
11026 -- use an underscore followed by four lower case hex digits.
11032 procedure Encode
is
11034 Store_String_Char
(Get_Char_Code
('_'));
11036 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 12))));
11038 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 8 and 16#
0F#
))));
11040 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 4 and 16#
0F#
))));
11042 (Get_Char_Code
(Hex
(Integer (CC
and 16#
0F#
))));
11045 -- Start of processing for Set_Encoded_Interface_Name
11048 -- If first character is asterisk, this is a link name, and we
11049 -- leave it completely unmodified. We also ignore null strings
11050 -- (the latter case happens only in error cases) and no encoding
11051 -- should occur for Java interface names.
11054 or else Get_String_Char
(Str
, 1) = Get_Char_Code
('*')
11057 Set_Interface_Name
(E
, S
);
11062 CC
:= Get_String_Char
(Str
, J
);
11064 exit when not In_Character_Range
(CC
);
11066 C
:= Get_Character
(CC
);
11068 exit when C
/= '_' and then C
/= '$'
11069 and then C
not in '0' .. '9'
11070 and then C
not in 'a' .. 'z'
11071 and then C
not in 'A' .. 'Z';
11074 Set_Interface_Name
(E
, S
);
11082 -- Here we need to encode. The encoding we use as follows:
11083 -- three underscores + four hex digits (lower case)
11087 for J
in 1 .. String_Length
(Str
) loop
11088 CC
:= Get_String_Char
(Str
, J
);
11090 if not In_Character_Range
(CC
) then
11093 C
:= Get_Character
(CC
);
11095 if C
= '_' or else C
= '$'
11096 or else C
in '0' .. '9'
11097 or else C
in 'a' .. 'z'
11098 or else C
in 'A' .. 'Z'
11100 Store_String_Char
(CC
);
11107 Set_Interface_Name
(E
,
11108 Make_String_Literal
(Sloc
(S
),
11109 Strval
=> End_String
));
11111 end Set_Encoded_Interface_Name
;
11113 -------------------
11114 -- Set_Unit_Name --
11115 -------------------
11117 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
) is
11122 if Nkind
(N
) = N_Identifier
11123 and then Nkind
(With_Item
) = N_Identifier
11125 Set_Entity
(N
, Entity
(With_Item
));
11127 elsif Nkind
(N
) = N_Selected_Component
then
11128 Change_Selected_Component_To_Expanded_Name
(N
);
11129 Set_Entity
(N
, Entity
(With_Item
));
11130 Set_Entity
(Selector_Name
(N
), Entity
(N
));
11132 Pref
:= Prefix
(N
);
11133 Scop
:= Scope
(Entity
(N
));
11134 while Nkind
(Pref
) = N_Selected_Component
loop
11135 Change_Selected_Component_To_Expanded_Name
(Pref
);
11136 Set_Entity
(Selector_Name
(Pref
), Scop
);
11137 Set_Entity
(Pref
, Scop
);
11138 Pref
:= Prefix
(Pref
);
11139 Scop
:= Scope
(Scop
);
11142 Set_Entity
(Pref
, Scop
);