1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2007, 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 3, 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 COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- This unit contains the semantic processing for all pragmas, both language
27 -- and implementation defined. For most pragmas, the parser only does the
28 -- most basic job of checking the syntax, so Sem_Prag also contains the code
29 -- to complete the syntax checks. Certain pragmas are handled partially or
30 -- completely by the parser (see Par.Prag for further details).
32 with Atree
; use Atree
;
33 with Casing
; use Casing
;
34 with Checks
; use Checks
;
35 with Csets
; use Csets
;
36 with Debug
; use Debug
;
37 with Einfo
; use Einfo
;
38 with Errout
; use Errout
;
39 with Exp_Dist
; use Exp_Dist
;
41 with Lib
.Writ
; use Lib
.Writ
;
42 with Lib
.Xref
; use Lib
.Xref
;
43 with Namet
; use Namet
;
44 with Nlists
; use Nlists
;
45 with Nmake
; use Nmake
;
47 with Output
; use Output
;
48 with Restrict
; use Restrict
;
49 with Rident
; use Rident
;
50 with Rtsfind
; use Rtsfind
;
52 with Sem_Ch3
; use Sem_Ch3
;
53 with Sem_Ch8
; use Sem_Ch8
;
54 with Sem_Ch13
; use Sem_Ch13
;
55 with Sem_Dist
; use Sem_Dist
;
56 with Sem_Elim
; use Sem_Elim
;
57 with Sem_Eval
; use Sem_Eval
;
58 with Sem_Intr
; use Sem_Intr
;
59 with Sem_Mech
; use Sem_Mech
;
60 with Sem_Res
; use Sem_Res
;
61 with Sem_Type
; use Sem_Type
;
62 with Sem_Util
; use Sem_Util
;
63 with Sem_VFpt
; use Sem_VFpt
;
64 with Sem_Warn
; use Sem_Warn
;
65 with Stand
; use Stand
;
66 with Sinfo
; use Sinfo
;
67 with Sinfo
.CN
; use Sinfo
.CN
;
68 with Sinput
; use Sinput
;
69 with Snames
; use Snames
;
70 with Stringt
; use Stringt
;
71 with Stylesw
; use Stylesw
;
73 with Targparm
; use Targparm
;
74 with Tbuild
; use Tbuild
;
76 with Uintp
; use Uintp
;
77 with Urealp
; use Urealp
;
78 with Validsw
; use Validsw
;
80 with GNAT
.Spelling_Checker
; use GNAT
.Spelling_Checker
;
82 package body Sem_Prag
is
84 ----------------------------------------------
85 -- Common Handling of Import-Export Pragmas --
86 ----------------------------------------------
88 -- In the following section, a number of Import_xxx and Export_xxx
89 -- pragmas are defined by GNAT. These are compatible with the DEC
90 -- pragmas of the same name, and all have the following common
91 -- form and processing:
94 -- [Internal =>] LOCAL_NAME,
95 -- [, [External =>] EXTERNAL_SYMBOL]
96 -- [, other optional parameters ]);
99 -- [Internal =>] LOCAL_NAME,
100 -- [, [External =>] EXTERNAL_SYMBOL]
101 -- [, other optional parameters ]);
103 -- EXTERNAL_SYMBOL ::=
105 -- | static_string_EXPRESSION
107 -- The internal LOCAL_NAME designates the entity that is imported or
108 -- exported, and must refer to an entity in the current declarative
109 -- part (as required by the rules for LOCAL_NAME).
111 -- The external linker name is designated by the External parameter
112 -- if given, or the Internal parameter if not (if there is no External
113 -- parameter, the External parameter is a copy of the Internal name).
115 -- If the External parameter is given as a string, then this string
116 -- is treated as an external name (exactly as though it had been given
117 -- as an External_Name parameter for a normal Import pragma).
119 -- If the External parameter is given as an identifier (or there is no
120 -- External parameter, so that the Internal identifier is used), then
121 -- the external name is the characters of the identifier, translated
122 -- to all upper case letters for OpenVMS versions of GNAT, and to all
123 -- lower case letters for all other versions
125 -- Note: the external name specified or implied by any of these special
126 -- Import_xxx or Export_xxx pragmas override an external or link name
127 -- specified in a previous Import or Export pragma.
129 -- Note: these and all other DEC-compatible GNAT pragmas allow full
130 -- use of named notation, following the standard rules for subprogram
131 -- calls, i.e. parameters can be given in any order if named notation
132 -- is used, and positional and named notation can be mixed, subject to
133 -- the rule that all positional parameters must appear first.
135 -- Note: All these pragmas are implemented exactly following the DEC
136 -- design and implementation and are intended to be fully compatible
137 -- with the use of these pragmas in the DEC Ada compiler.
139 --------------------------------------------
140 -- Checking for Duplicated External Names --
141 --------------------------------------------
143 -- It is suspicious if two separate Export pragmas use the same external
144 -- name. The following table is used to diagnose this situation so that
145 -- an appropriate warning can be issued.
147 -- The Node_Id stored is for the N_String_Literal node created to
148 -- hold the value of the external name. The Sloc of this node is
149 -- used to cross-reference the location of the duplication.
151 package Externals
is new Table
.Table
(
152 Table_Component_Type
=> Node_Id
,
153 Table_Index_Type
=> Int
,
154 Table_Low_Bound
=> 0,
155 Table_Initial
=> 100,
156 Table_Increment
=> 100,
157 Table_Name
=> "Name_Externals");
159 -------------------------------------
160 -- Local Subprograms and Variables --
161 -------------------------------------
163 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
;
164 -- This routine is used for possible casing adjustment of an explicit
165 -- external name supplied as a string literal (the node N), according
166 -- to the casing requirement of Opt.External_Name_Casing. If this is
167 -- set to As_Is, then the string literal is returned unchanged, but if
168 -- it is set to Uppercase or Lowercase, then a new string literal with
169 -- appropriate casing is constructed.
171 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
;
172 -- If Def_Id refers to a renamed subprogram, then the base subprogram
173 -- (the original one, following the renaming chain) is returned.
174 -- Otherwise the entity is returned unchanged. Should be in Einfo???
177 -- This is a dummy function called by the processing for pragma Reviewable.
178 -- It is there for assisting front end debugging. By placing a Reviewable
179 -- pragma in the source program, a breakpoint on rv catches this place in
180 -- the source, allowing convenient stepping to the point of interest.
182 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
);
183 -- Place semantic information on the argument of an Elaborate or
184 -- Elaborate_All pragma. Entity name for unit and its parents is
185 -- taken from item in previous with_clause that mentions the unit.
187 -------------------------------
188 -- Adjust_External_Name_Case --
189 -------------------------------
191 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
is
195 -- Adjust case of literal if required
197 if Opt
.External_Name_Exp_Casing
= As_Is
then
201 -- Copy existing string
207 for J
in 1 .. String_Length
(Strval
(N
)) loop
208 CC
:= Get_String_Char
(Strval
(N
), J
);
210 if Opt
.External_Name_Exp_Casing
= Uppercase
211 and then CC
>= Get_Char_Code
('a')
212 and then CC
<= Get_Char_Code
('z')
214 Store_String_Char
(CC
- 32);
216 elsif Opt
.External_Name_Exp_Casing
= Lowercase
217 and then CC
>= Get_Char_Code
('A')
218 and then CC
<= Get_Char_Code
('Z')
220 Store_String_Char
(CC
+ 32);
223 Store_String_Char
(CC
);
228 Make_String_Literal
(Sloc
(N
),
229 Strval
=> End_String
);
231 end Adjust_External_Name_Case
;
237 procedure Analyze_Pragma
(N
: Node_Id
) is
238 Loc
: constant Source_Ptr
:= Sloc
(N
);
241 Pragma_Exit
: exception;
242 -- This exception is used to exit pragma processing completely. It
243 -- is used when an error is detected, and no further processing is
244 -- required. It is also used if an earlier error has left the tree
245 -- in a state where the pragma should not be processed.
248 -- Number of pragma argument associations
254 -- First four pragma arguments (pragma argument association nodes,
255 -- or Empty if the corresponding argument does not exist).
257 type Name_List
is array (Natural range <>) of Name_Id
;
258 type Args_List
is array (Natural range <>) of Node_Id
;
259 -- Types used for arguments to Check_Arg_Order and Gather_Associations
261 procedure Ada_2005_Pragma
;
262 -- Called for pragmas defined in Ada 2005, that are not in Ada 95. In
263 -- Ada 95 mode, these are implementation defined pragmas, so should be
264 -- caught by the No_Implementation_Pragmas restriction
266 procedure Check_Ada_83_Warning
;
267 -- Issues a warning message for the current pragma if operating in Ada
268 -- 83 mode (used for language pragmas that are not a standard part of
269 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
272 procedure Check_Arg_Count
(Required
: Nat
);
273 -- Check argument count for pragma is equal to given parameter.
274 -- If not, then issue an error message and raise Pragma_Exit.
276 -- Note: all routines whose name is Check_Arg_Is_xxx take an
277 -- argument Arg which can either be a pragma argument association,
278 -- in which case the check is applied to the expression of the
279 -- association or an expression directly.
281 procedure Check_Arg_Is_External_Name
(Arg
: Node_Id
);
282 -- Check that an argument has the right form for an EXTERNAL_NAME
283 -- parameter of an extended import/export pragma. The rule is that
284 -- the name must be an identifier or string literal (in Ada 83 mode)
285 -- or a static string expression (in Ada 95 mode).
287 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
);
288 -- Check the specified argument Arg to make sure that it is an
289 -- identifier. If not give error and raise Pragma_Exit.
291 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
);
292 -- Check the specified argument Arg to make sure that it is an
293 -- integer literal. If not give error and raise Pragma_Exit.
295 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
);
296 -- Check the specified argument Arg to make sure that it has the
297 -- proper syntactic form for a local name and meets the semantic
298 -- requirements for a local name. The local name is analyzed as
299 -- part of the processing for this call. In addition, the local
300 -- name is required to represent an entity at the library level.
302 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
);
303 -- Check the specified argument Arg to make sure that it has the
304 -- proper syntactic form for a local name and meets the semantic
305 -- requirements for a local name. The local name is analyzed as
306 -- part of the processing for this call.
308 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
);
309 -- Check the specified argument Arg to make sure that it is a valid
310 -- locking policy name. If not give error and raise Pragma_Exit.
312 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
);
313 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
, N3
: Name_Id
);
314 -- Check the specified argument Arg to make sure that it is an
315 -- identifier whose name matches either N1 or N2 (or N3 if present).
316 -- If not then give error and raise Pragma_Exit.
318 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
);
319 -- Check the specified argument Arg to make sure that it is a valid
320 -- queuing policy name. If not give error and raise Pragma_Exit.
322 procedure Check_Arg_Is_Static_Expression
325 -- Check the specified argument Arg to make sure that it is a static
326 -- expression of the given type (i.e. it will be analyzed and resolved
327 -- using this type, which can be any valid argument to Resolve, e.g.
328 -- Any_Integer is OK). If not, given error and raise Pragma_Exit.
330 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
);
331 -- Check the specified argument Arg to make sure that it is a
332 -- string literal. If not give error and raise Pragma_Exit
334 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
);
335 -- Check the specified argument Arg to make sure that it is a valid
336 -- valid task dispatching policy name. If not give error and raise
339 procedure Check_Arg_Order
(Names
: Name_List
);
340 -- Checks for an instance of two arguments with identifiers for the
341 -- current pragma which are not in the sequence indicated by Names,
342 -- and if so, generates a fatal message about bad order of arguments.
344 procedure Check_At_Least_N_Arguments
(N
: Nat
);
345 -- Check there are at least N arguments present
347 procedure Check_At_Most_N_Arguments
(N
: Nat
);
348 -- Check there are no more than N arguments present
350 procedure Check_Component
(Comp
: Node_Id
);
351 -- Examine Unchecked_Union component for correct use of per-object
352 -- constrained subtypes, and for restrictions on finalizable components.
354 procedure Check_Duplicated_Export_Name
(Nam
: Node_Id
);
355 -- Nam is an N_String_Literal node containing the external name set
356 -- by an Import or Export pragma (or extended Import or Export pragma).
357 -- This procedure checks for possible duplications if this is the
358 -- export case, and if found, issues an appropriate error message.
360 procedure Check_First_Subtype
(Arg
: Node_Id
);
361 -- Checks that Arg, whose expression is an entity name referencing
362 -- a subtype, does not reference a type that is not a first subtype.
364 procedure Check_In_Main_Program
;
365 -- Common checks for pragmas that appear within a main program
366 -- (Priority, Main_Storage, Time_Slice).
368 procedure Check_Interrupt_Or_Attach_Handler
;
369 -- Common processing for first argument of pragma Interrupt_Handler
370 -- or pragma Attach_Handler.
372 procedure Check_Is_In_Decl_Part_Or_Package_Spec
;
373 -- Check that pragma appears in a declarative part, or in a package
374 -- specification, i.e. that it does not occur in a statement sequence
377 procedure Check_No_Identifier
(Arg
: Node_Id
);
378 -- Checks that the given argument does not have an identifier. If
379 -- an identifier is present, then an error message is issued, and
380 -- Pragma_Exit is raised.
382 procedure Check_No_Identifiers
;
383 -- Checks that none of the arguments to the pragma has an identifier.
384 -- If any argument has an identifier, then an error message is issued,
385 -- and Pragma_Exit is raised.
387 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
);
388 -- Checks if the given argument has an identifier, and if so, requires
389 -- it to match the given identifier name. If there is a non-matching
390 -- identifier, then an error message is given and Error_Pragmas raised.
392 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String);
393 -- Checks if the given argument has an identifier, and if so, requires
394 -- it to match the given identifier name. If there is a non-matching
395 -- identifier, then an error message is given and Error_Pragmas raised.
396 -- In this version of the procedure, the identifier name is given as
397 -- a string with lower case letters.
399 procedure Check_Static_Constraint
(Constr
: Node_Id
);
400 -- Constr is a constraint from an N_Subtype_Indication node from a
401 -- component constraint in an Unchecked_Union type. This routine checks
402 -- that the constraint is static as required by the restrictions for
405 procedure Check_Valid_Configuration_Pragma
;
406 -- Legality checks for placement of a configuration pragma
408 procedure Check_Valid_Library_Unit_Pragma
;
409 -- Legality checks for library unit pragmas. A special case arises for
410 -- pragmas in generic instances that come from copies of the original
411 -- library unit pragmas in the generic templates. In the case of other
412 -- than library level instantiations these can appear in contexts which
413 -- would normally be invalid (they only apply to the original template
414 -- and to library level instantiations), and they are simply ignored,
415 -- which is implemented by rewriting them as null statements.
417 procedure Check_Variant
(Variant
: Node_Id
);
418 -- Check Unchecked_Union variant for lack of nested variants and
419 -- presence of at least one component.
421 procedure Error_Pragma
(Msg
: String);
422 pragma No_Return
(Error_Pragma
);
423 -- Outputs error message for current pragma. The message contains an %
424 -- that will be replaced with the pragma name, and the flag is placed
425 -- on the pragma itself. Pragma_Exit is then raised.
427 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
);
428 pragma No_Return
(Error_Pragma_Arg
);
429 -- Outputs error message for current pragma. The message may contain
430 -- a % that will be replaced with the pragma name. The parameter Arg
431 -- may either be a pragma argument association, in which case the flag
432 -- is placed on the expression of this association, or an expression,
433 -- in which case the flag is placed directly on the expression. The
434 -- message is placed using Error_Msg_N, so the message may also contain
435 -- an & insertion character which will reference the given Arg value.
436 -- After placing the message, Pragma_Exit is raised.
438 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
);
439 pragma No_Return
(Error_Pragma_Arg
);
440 -- Similar to above form of Error_Pragma_Arg except that two messages
441 -- are provided, the second is a continuation comment starting with \.
443 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
);
444 pragma No_Return
(Error_Pragma_Arg_Ident
);
445 -- Outputs error message for current pragma. The message may contain
446 -- a % that will be replaced with the pragma name. The parameter Arg
447 -- must be a pragma argument association with a non-empty identifier
448 -- (i.e. its Chars field must be set), and the error message is placed
449 -- on the identifier. The message is placed using Error_Msg_N so
450 -- the message may also contain an & insertion character which will
451 -- reference the identifier. After placing the message, Pragma_Exit
454 function Find_Lib_Unit_Name
return Entity_Id
;
455 -- Used for a library unit pragma to find the entity to which the
456 -- library unit pragma applies, returns the entity found.
458 procedure Find_Program_Unit_Name
(Id
: Node_Id
);
459 -- If the pragma is a compilation unit pragma, the id must denote the
460 -- compilation unit in the same compilation, and the pragma must appear
461 -- in the list of preceding or trailing pragmas. If it is a program
462 -- unit pragma that is not a compilation unit pragma, then the
463 -- identifier must be visible.
465 function Find_Unique_Parameterless_Procedure
467 Arg
: Node_Id
) return Entity_Id
;
468 -- Used for a procedure pragma to find the unique parameterless
469 -- procedure identified by Name, returns it if it exists, otherwise
470 -- errors out and uses Arg as the pragma argument for the message.
472 procedure Gather_Associations
474 Args
: out Args_List
);
475 -- This procedure is used to gather the arguments for a pragma that
476 -- permits arbitrary ordering of parameters using the normal rules
477 -- for named and positional parameters. The Names argument is a list
478 -- of Name_Id values that corresponds to the allowed pragma argument
479 -- association identifiers in order. The result returned in Args is
480 -- a list of corresponding expressions that are the pragma arguments.
481 -- Note that this is a list of expressions, not of pragma argument
482 -- associations (Gather_Associations has completely checked all the
483 -- optional identifiers when it returns). An entry in Args is Empty
484 -- on return if the corresponding argument is not present.
486 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
;
487 -- All the routines that check pragma arguments take either a pragma
488 -- argument association (in which case the expression of the argument
489 -- association is checked), or the expression directly. The function
490 -- Get_Pragma_Arg is a utility used to deal with these two cases. If
491 -- Arg is a pragma argument association node, then its expression is
492 -- returned, otherwise Arg is returned unchanged.
494 procedure GNAT_Pragma
;
495 -- Called for all GNAT defined pragmas to check the relevant restriction
496 -- (No_Implementation_Pragmas).
498 function Is_Before_First_Decl
499 (Pragma_Node
: Node_Id
;
500 Decls
: List_Id
) return Boolean;
501 -- Return True if Pragma_Node is before the first declarative item in
502 -- Decls where Decls is the list of declarative items.
504 function Is_Configuration_Pragma
return Boolean;
505 -- Deterermines if the placement of the current pragma is appropriate
506 -- for a configuration pragma (precedes the current compilation unit).
508 function Is_In_Context_Clause
return Boolean;
509 -- Returns True if pragma appears within the context clause of a unit,
510 -- and False for any other placement (does not generate any messages).
512 function Is_Static_String_Expression
(Arg
: Node_Id
) return Boolean;
513 -- Analyzes the argument, and determines if it is a static string
514 -- expression, returns True if so, False if non-static or not String.
516 procedure Pragma_Misplaced
;
517 -- Issue fatal error message for misplaced pragma
519 procedure Process_Atomic_Shared_Volatile
;
520 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
521 -- Shared is an obsolete Ada 83 pragma, treated as being identical
522 -- in effect to pragma Atomic.
524 procedure Process_Compile_Time_Warning_Or_Error
;
525 -- Common processing for Compile_Time_Error and Compile_Time_Warning
527 procedure Process_Convention
(C
: out Convention_Id
; E
: out Entity_Id
);
528 -- Common procesing for Convention, Interface, Import and Export.
529 -- Checks first two arguments of pragma, and sets the appropriate
530 -- convention value in the specified entity or entities. On return
531 -- C is the convention, E is the referenced entity.
533 procedure Process_Extended_Import_Export_Exception_Pragma
534 (Arg_Internal
: Node_Id
;
535 Arg_External
: Node_Id
;
538 -- Common processing for the pragmas Import/Export_Exception.
539 -- The three arguments correspond to the three named parameters of
540 -- the pragma. An argument is empty if the corresponding parameter
541 -- is not present in the pragma.
543 procedure Process_Extended_Import_Export_Object_Pragma
544 (Arg_Internal
: Node_Id
;
545 Arg_External
: Node_Id
;
547 -- Common processing for the pragmass Import/Export_Object.
548 -- The three arguments correspond to the three named parameters
549 -- of the pragmas. An argument is empty if the corresponding
550 -- parameter is not present in the pragma.
552 procedure Process_Extended_Import_Export_Internal_Arg
553 (Arg_Internal
: Node_Id
:= Empty
);
554 -- Common processing for all extended Import and Export pragmas. The
555 -- argument is the pragma parameter for the Internal argument. If
556 -- Arg_Internal is empty or inappropriate, an error message is posted.
557 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
558 -- set to identify the referenced entity.
560 procedure Process_Extended_Import_Export_Subprogram_Pragma
561 (Arg_Internal
: Node_Id
;
562 Arg_External
: Node_Id
;
563 Arg_Parameter_Types
: Node_Id
;
564 Arg_Result_Type
: Node_Id
:= Empty
;
565 Arg_Mechanism
: Node_Id
;
566 Arg_Result_Mechanism
: Node_Id
:= Empty
;
567 Arg_First_Optional_Parameter
: Node_Id
:= Empty
);
568 -- Common processing for all extended Import and Export pragmas
569 -- applying to subprograms. The caller omits any arguments that do
570 -- bnot apply to the pragma in question (for example, Arg_Result_Type
571 -- can be non-Empty only in the Import_Function and Export_Function
572 -- cases). The argument names correspond to the allowed pragma
573 -- association identifiers.
575 procedure Process_Generic_List
;
576 -- Common processing for Share_Generic and Inline_Generic
578 procedure Process_Import_Or_Interface
;
579 -- Common processing for Import of Interface
581 procedure Process_Inline
(Active
: Boolean);
582 -- Common processing for Inline and Inline_Always. The parameter
583 -- indicates if the inline pragma is active, i.e. if it should
584 -- actually cause inlining to occur.
586 procedure Process_Interface_Name
587 (Subprogram_Def
: Entity_Id
;
590 -- Given the last two arguments of pragma Import, pragma Export, or
591 -- pragma Interface_Name, performs validity checks and sets the
592 -- Interface_Name field of the given subprogram entity to the
593 -- appropriate external or link name, depending on the arguments
594 -- given. Ext_Arg is always present, but Link_Arg may be missing.
595 -- Note that Ext_Arg may represent the Link_Name if Link_Arg is
596 -- missing, and appropriate named notation is used for Ext_Arg.
597 -- If neither Ext_Arg nor Link_Arg is present, the interface name
598 -- is set to the default from the subprogram name.
600 procedure Process_Interrupt_Or_Attach_Handler
;
601 -- Common processing for Interrupt and Attach_Handler pragmas
603 procedure Process_Restrictions_Or_Restriction_Warnings
(Warn
: Boolean);
604 -- Common processing for Restrictions and Restriction_Warnings pragmas.
605 -- Warn is False for Restrictions, True for Restriction_Warnings.
607 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean);
608 -- Common processing for Suppress and Unsuppress. The boolean parameter
609 -- Suppress_Case is True for the Suppress case, and False for the
612 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
);
613 -- This procedure sets the Is_Exported flag for the given entity,
614 -- checking that the entity was not previously imported. Arg is
615 -- the argument that specified the entity. A check is also made
616 -- for exporting inappropriate entities.
618 procedure Set_Extended_Import_Export_External_Name
619 (Internal_Ent
: Entity_Id
;
620 Arg_External
: Node_Id
);
621 -- Common processing for all extended import export pragmas. The first
622 -- argument, Internal_Ent, is the internal entity, which has already
623 -- been checked for validity by the caller. Arg_External is from the
624 -- Import or Export pragma, and may be null if no External parameter
625 -- was present. If Arg_External is present and is a non-null string
626 -- (a null string is treated as the default), then the Interface_Name
627 -- field of Internal_Ent is set appropriately.
629 procedure Set_Imported
(E
: Entity_Id
);
630 -- This procedure sets the Is_Imported flag for the given entity,
631 -- checking that it is not previously exported or imported.
633 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
);
634 -- Mech is a parameter passing mechanism (see Import_Function syntax
635 -- for MECHANISM_NAME). This routine checks that the mechanism argument
636 -- has the right form, and if not issues an error message. If the
637 -- argument has the right form then the Mechanism field of Ent is
638 -- set appropriately.
640 procedure Set_Ravenscar_Profile
(N
: Node_Id
);
641 -- Activate the set of configuration pragmas and restrictions that
642 -- make up the Ravenscar Profile. N is the corresponding pragma
643 -- node, which is used for error messages on any constructs
644 -- that violate the profile.
646 ---------------------
647 -- Ada_2005_Pragma --
648 ---------------------
650 procedure Ada_2005_Pragma
is
652 if Ada_Version
<= Ada_95
then
653 Check_Restriction
(No_Implementation_Pragmas
, N
);
657 --------------------------
658 -- Check_Ada_83_Warning --
659 --------------------------
661 procedure Check_Ada_83_Warning
is
663 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
664 Error_Msg_N
("(Ada 83) pragma& is non-standard?", N
);
666 end Check_Ada_83_Warning
;
668 ---------------------
669 -- Check_Arg_Count --
670 ---------------------
672 procedure Check_Arg_Count
(Required
: Nat
) is
674 if Arg_Count
/= Required
then
675 Error_Pragma
("wrong number of arguments for pragma%");
679 --------------------------------
680 -- Check_Arg_Is_External_Name --
681 --------------------------------
683 procedure Check_Arg_Is_External_Name
(Arg
: Node_Id
) is
684 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
687 if Nkind
(Argx
) = N_Identifier
then
691 Analyze_And_Resolve
(Argx
, Standard_String
);
693 if Is_OK_Static_Expression
(Argx
) then
696 elsif Etype
(Argx
) = Any_Type
then
699 -- An interesting special case, if we have a string literal and
700 -- we are in Ada 83 mode, then we allow it even though it will
701 -- not be flagged as static. This allows expected Ada 83 mode
702 -- use of external names which are string literals, even though
703 -- technically these are not static in Ada 83.
705 elsif Ada_Version
= Ada_83
706 and then Nkind
(Argx
) = N_String_Literal
710 -- Static expression that raises Constraint_Error. This has
711 -- already been flagged, so just exit from pragma processing.
713 elsif Is_Static_Expression
(Argx
) then
716 -- Here we have a real error (non-static expression)
719 Error_Msg_Name_1
:= Chars
(N
);
721 ("argument for pragma% must be a identifier or " &
722 "static string expression!", Argx
);
726 end Check_Arg_Is_External_Name
;
728 -----------------------------
729 -- Check_Arg_Is_Identifier --
730 -----------------------------
732 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
) is
733 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
735 if Nkind
(Argx
) /= N_Identifier
then
737 ("argument for pragma% must be identifier", Argx
);
739 end Check_Arg_Is_Identifier
;
741 ----------------------------------
742 -- Check_Arg_Is_Integer_Literal --
743 ----------------------------------
745 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
) is
746 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
748 if Nkind
(Argx
) /= N_Integer_Literal
then
750 ("argument for pragma% must be integer literal", Argx
);
752 end Check_Arg_Is_Integer_Literal
;
754 -------------------------------------------
755 -- Check_Arg_Is_Library_Level_Local_Name --
756 -------------------------------------------
760 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
761 -- | library_unit_NAME
763 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
) is
765 Check_Arg_Is_Local_Name
(Arg
);
767 if not Is_Library_Level_Entity
(Entity
(Expression
(Arg
)))
768 and then Comes_From_Source
(N
)
771 ("argument for pragma% must be library level entity", Arg
);
773 end Check_Arg_Is_Library_Level_Local_Name
;
775 -----------------------------
776 -- Check_Arg_Is_Local_Name --
777 -----------------------------
781 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
782 -- | library_unit_NAME
784 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
) is
785 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
790 if Nkind
(Argx
) not in N_Direct_Name
791 and then (Nkind
(Argx
) /= N_Attribute_Reference
792 or else Present
(Expressions
(Argx
))
793 or else Nkind
(Prefix
(Argx
)) /= N_Identifier
)
794 and then (not Is_Entity_Name
(Argx
)
795 or else not Is_Compilation_Unit
(Entity
(Argx
)))
797 Error_Pragma_Arg
("argument for pragma% must be local name", Argx
);
800 if Is_Entity_Name
(Argx
)
801 and then Scope
(Entity
(Argx
)) /= Current_Scope
804 ("pragma% argument must be in same declarative part", Arg
);
806 end Check_Arg_Is_Local_Name
;
808 ---------------------------------
809 -- Check_Arg_Is_Locking_Policy --
810 ---------------------------------
812 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
) is
813 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
816 Check_Arg_Is_Identifier
(Argx
);
818 if not Is_Locking_Policy_Name
(Chars
(Argx
)) then
820 ("& is not a valid locking policy name", Argx
);
822 end Check_Arg_Is_Locking_Policy
;
824 -------------------------
825 -- Check_Arg_Is_One_Of --
826 -------------------------
828 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
) is
829 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
832 Check_Arg_Is_Identifier
(Argx
);
834 if Chars
(Argx
) /= N1
and then Chars
(Argx
) /= N2
then
835 Error_Msg_Name_2
:= N1
;
836 Error_Msg_Name_3
:= N2
;
837 Error_Pragma_Arg
("argument for pragma% must be% or%", Argx
);
839 end Check_Arg_Is_One_Of
;
841 procedure Check_Arg_Is_One_Of
843 N1
, N2
, N3
: Name_Id
)
845 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
848 Check_Arg_Is_Identifier
(Argx
);
850 if Chars
(Argx
) /= N1
851 and then Chars
(Argx
) /= N2
852 and then Chars
(Argx
) /= N3
854 Error_Pragma_Arg
("invalid argument for pragma%", Argx
);
856 end Check_Arg_Is_One_Of
;
858 ---------------------------------
859 -- Check_Arg_Is_Queuing_Policy --
860 ---------------------------------
862 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
) is
863 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
866 Check_Arg_Is_Identifier
(Argx
);
868 if not Is_Queuing_Policy_Name
(Chars
(Argx
)) then
870 ("& is not a valid queuing policy name", Argx
);
872 end Check_Arg_Is_Queuing_Policy
;
874 ------------------------------------
875 -- Check_Arg_Is_Static_Expression --
876 ------------------------------------
878 procedure Check_Arg_Is_Static_Expression
882 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
885 Analyze_And_Resolve
(Argx
, Typ
);
887 if Is_OK_Static_Expression
(Argx
) then
890 elsif Etype
(Argx
) = Any_Type
then
893 -- An interesting special case, if we have a string literal and
894 -- we are in Ada 83 mode, then we allow it even though it will
895 -- not be flagged as static. This allows the use of Ada 95
896 -- pragmas like Import in Ada 83 mode. They will of course be
897 -- flagged with warnings as usual, but will not cause errors.
899 elsif Ada_Version
= Ada_83
900 and then Nkind
(Argx
) = N_String_Literal
904 -- Static expression that raises Constraint_Error. This has
905 -- already been flagged, so just exit from pragma processing.
907 elsif Is_Static_Expression
(Argx
) then
910 -- Finally, we have a real error
913 Error_Msg_Name_1
:= Chars
(N
);
915 ("argument for pragma% must be a static expression!", Argx
);
918 end Check_Arg_Is_Static_Expression
;
920 ---------------------------------
921 -- Check_Arg_Is_String_Literal --
922 ---------------------------------
924 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
) is
925 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
927 if Nkind
(Argx
) /= N_String_Literal
then
929 ("argument for pragma% must be string literal", Argx
);
931 end Check_Arg_Is_String_Literal
;
933 ------------------------------------------
934 -- Check_Arg_Is_Task_Dispatching_Policy --
935 ------------------------------------------
937 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
) is
938 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
941 Check_Arg_Is_Identifier
(Argx
);
943 if not Is_Task_Dispatching_Policy_Name
(Chars
(Argx
)) then
945 ("& is not a valid task dispatching policy name", Argx
);
947 end Check_Arg_Is_Task_Dispatching_Policy
;
949 ---------------------
950 -- Check_Arg_Order --
951 ---------------------
953 procedure Check_Arg_Order
(Names
: Name_List
) is
956 Highest_So_Far
: Natural := 0;
957 -- Highest index in Names seen do far
961 for J
in 1 .. Arg_Count
loop
962 if Chars
(Arg
) /= No_Name
then
963 for K
in Names
'Range loop
964 if Chars
(Arg
) = Names
(K
) then
965 if K
< Highest_So_Far
then
966 Error_Msg_Name_1
:= Chars
(N
);
968 ("parameters out of order for pragma%", Arg
);
969 Error_Msg_Name_1
:= Names
(K
);
970 Error_Msg_Name_2
:= Names
(Highest_So_Far
);
971 Error_Msg_N
("\% must appear before %", Arg
);
985 --------------------------------
986 -- Check_At_Least_N_Arguments --
987 --------------------------------
989 procedure Check_At_Least_N_Arguments
(N
: Nat
) is
991 if Arg_Count
< N
then
992 Error_Pragma
("too few arguments for pragma%");
994 end Check_At_Least_N_Arguments
;
996 -------------------------------
997 -- Check_At_Most_N_Arguments --
998 -------------------------------
1000 procedure Check_At_Most_N_Arguments
(N
: Nat
) is
1003 if Arg_Count
> N
then
1005 for J
in 1 .. N
loop
1007 Error_Pragma_Arg
("too many arguments for pragma%", Arg
);
1010 end Check_At_Most_N_Arguments
;
1012 ---------------------
1013 -- Check_Component --
1014 ---------------------
1016 procedure Check_Component
(Comp
: Node_Id
) is
1018 if Nkind
(Comp
) = N_Component_Declaration
then
1020 Sindic
: constant Node_Id
:=
1021 Subtype_Indication
(Component_Definition
(Comp
));
1022 Typ
: constant Entity_Id
:=
1023 Etype
(Defining_Identifier
(Comp
));
1025 if Nkind
(Sindic
) = N_Subtype_Indication
then
1027 -- Ada 2005 (AI-216): If a component subtype is subject to
1028 -- a per-object constraint, then the component type shall
1029 -- be an Unchecked_Union.
1031 if Has_Per_Object_Constraint
(Defining_Identifier
(Comp
))
1033 not Is_Unchecked_Union
(Etype
(Subtype_Mark
(Sindic
)))
1035 Error_Msg_N
("component subtype subject to per-object" &
1036 " constraint must be an Unchecked_Union", Comp
);
1040 if Is_Controlled
(Typ
) then
1042 ("component of unchecked union cannot be controlled", Comp
);
1044 elsif Has_Task
(Typ
) then
1046 ("component of unchecked union cannot have tasks", Comp
);
1050 end Check_Component
;
1052 ----------------------------------
1053 -- Check_Duplicated_Export_Name --
1054 ----------------------------------
1056 procedure Check_Duplicated_Export_Name
(Nam
: Node_Id
) is
1057 String_Val
: constant String_Id
:= Strval
(Nam
);
1060 -- We are only interested in the export case, and in the case of
1061 -- generics, it is the instance, not the template, that is the
1062 -- problem (the template will generate a warning in any case).
1064 if not Inside_A_Generic
1065 and then (Prag_Id
= Pragma_Export
1067 Prag_Id
= Pragma_Export_Procedure
1069 Prag_Id
= Pragma_Export_Valued_Procedure
1071 Prag_Id
= Pragma_Export_Function
)
1073 for J
in Externals
.First
.. Externals
.Last
loop
1074 if String_Equal
(String_Val
, Strval
(Externals
.Table
(J
))) then
1075 Error_Msg_Sloc
:= Sloc
(Externals
.Table
(J
));
1076 Error_Msg_N
("external name duplicates name given#", Nam
);
1081 Externals
.Append
(Nam
);
1083 end Check_Duplicated_Export_Name
;
1085 -------------------------
1086 -- Check_First_Subtype --
1087 -------------------------
1089 procedure Check_First_Subtype
(Arg
: Node_Id
) is
1090 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1092 if not Is_First_Subtype
(Entity
(Argx
)) then
1094 ("pragma% cannot apply to subtype", Argx
);
1096 end Check_First_Subtype
;
1098 ---------------------------
1099 -- Check_In_Main_Program --
1100 ---------------------------
1102 procedure Check_In_Main_Program
is
1103 P
: constant Node_Id
:= Parent
(N
);
1106 -- Must be at in subprogram body
1108 if Nkind
(P
) /= N_Subprogram_Body
then
1109 Error_Pragma
("% pragma allowed only in subprogram");
1111 -- Otherwise warn if obviously not main program
1113 elsif Present
(Parameter_Specifications
(Specification
(P
)))
1114 or else not Is_Compilation_Unit
(Defining_Entity
(P
))
1116 Error_Msg_Name_1
:= Chars
(N
);
1118 ("?pragma% is only effective in main program", N
);
1120 end Check_In_Main_Program
;
1122 ---------------------------------------
1123 -- Check_Interrupt_Or_Attach_Handler --
1124 ---------------------------------------
1126 procedure Check_Interrupt_Or_Attach_Handler
is
1127 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
1128 Handler_Proc
, Proc_Scope
: Entity_Id
;
1133 if Prag_Id
= Pragma_Interrupt_Handler
then
1134 Check_Restriction
(No_Dynamic_Attachment
, N
);
1137 Handler_Proc
:= Find_Unique_Parameterless_Procedure
(Arg1_X
, Arg1
);
1138 Proc_Scope
:= Scope
(Handler_Proc
);
1140 -- On AAMP only, a pragma Interrupt_Handler is supported for
1141 -- nonprotected parameterless procedures.
1143 if not AAMP_On_Target
1144 or else Prag_Id
= Pragma_Attach_Handler
1146 if Ekind
(Proc_Scope
) /= E_Protected_Type
then
1148 ("argument of pragma% must be protected procedure", Arg1
);
1151 if Parent
(N
) /= Protected_Definition
(Parent
(Proc_Scope
)) then
1152 Error_Pragma
("pragma% must be in protected definition");
1156 if not Is_Library_Level_Entity
(Proc_Scope
)
1157 or else (AAMP_On_Target
1158 and then not Is_Library_Level_Entity
(Handler_Proc
))
1161 ("argument for pragma% must be library level entity", Arg1
);
1163 end Check_Interrupt_Or_Attach_Handler
;
1165 -------------------------------------------
1166 -- Check_Is_In_Decl_Part_Or_Package_Spec --
1167 -------------------------------------------
1169 procedure Check_Is_In_Decl_Part_Or_Package_Spec
is
1178 elsif Nkind
(P
) = N_Handled_Sequence_Of_Statements
then
1181 elsif Nkind
(P
) = N_Package_Specification
then
1184 elsif Nkind
(P
) = N_Block_Statement
then
1187 -- Note: the following tests seem a little peculiar, because
1188 -- they test for bodies, but if we were in the statement part
1189 -- of the body, we would already have hit the handled statement
1190 -- sequence, so the only way we get here is by being in the
1191 -- declarative part of the body.
1193 elsif Nkind
(P
) = N_Subprogram_Body
1194 or else Nkind
(P
) = N_Package_Body
1195 or else Nkind
(P
) = N_Task_Body
1196 or else Nkind
(P
) = N_Entry_Body
1204 Error_Pragma
("pragma% is not in declarative part or package spec");
1205 end Check_Is_In_Decl_Part_Or_Package_Spec
;
1207 -------------------------
1208 -- Check_No_Identifier --
1209 -------------------------
1211 procedure Check_No_Identifier
(Arg
: Node_Id
) is
1213 if Chars
(Arg
) /= No_Name
then
1214 Error_Pragma_Arg_Ident
1215 ("pragma% does not permit identifier& here", Arg
);
1217 end Check_No_Identifier
;
1219 --------------------------
1220 -- Check_No_Identifiers --
1221 --------------------------
1223 procedure Check_No_Identifiers
is
1226 if Arg_Count
> 0 then
1228 while Present
(Arg_Node
) loop
1229 Check_No_Identifier
(Arg_Node
);
1233 end Check_No_Identifiers
;
1235 -------------------------------
1236 -- Check_Optional_Identifier --
1237 -------------------------------
1239 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
) is
1241 if Present
(Arg
) and then Chars
(Arg
) /= No_Name
then
1242 if Chars
(Arg
) /= Id
then
1243 Error_Msg_Name_1
:= Chars
(N
);
1244 Error_Msg_Name_2
:= Id
;
1245 Error_Msg_N
("pragma% argument expects identifier%", Arg
);
1249 end Check_Optional_Identifier
;
1251 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String) is
1253 Name_Buffer
(1 .. Id
'Length) := Id
;
1254 Name_Len
:= Id
'Length;
1255 Check_Optional_Identifier
(Arg
, Name_Find
);
1256 end Check_Optional_Identifier
;
1258 -----------------------------
1259 -- Check_Static_Constraint --
1260 -----------------------------
1262 -- Note: for convenience in writing this procedure, in addition to
1263 -- the officially (i.e. by spec) allowed argument which is always
1264 -- a constraint, it also allows ranges and discriminant associations.
1265 -- Above is not clear ???
1267 procedure Check_Static_Constraint
(Constr
: Node_Id
) is
1269 --------------------
1270 -- Require_Static --
1271 --------------------
1273 procedure Require_Static
(E
: Node_Id
);
1274 -- Require given expression to be static expression
1276 procedure Require_Static
(E
: Node_Id
) is
1278 if not Is_OK_Static_Expression
(E
) then
1279 Flag_Non_Static_Expr
1280 ("non-static constraint not allowed in Unchecked_Union!", E
);
1285 -- Start of processing for Check_Static_Constraint
1288 case Nkind
(Constr
) is
1289 when N_Discriminant_Association
=>
1290 Require_Static
(Expression
(Constr
));
1293 Require_Static
(Low_Bound
(Constr
));
1294 Require_Static
(High_Bound
(Constr
));
1296 when N_Attribute_Reference
=>
1297 Require_Static
(Type_Low_Bound
(Etype
(Prefix
(Constr
))));
1298 Require_Static
(Type_High_Bound
(Etype
(Prefix
(Constr
))));
1300 when N_Range_Constraint
=>
1301 Check_Static_Constraint
(Range_Expression
(Constr
));
1303 when N_Index_Or_Discriminant_Constraint
=>
1307 IDC
:= First
(Constraints
(Constr
));
1308 while Present
(IDC
) loop
1309 Check_Static_Constraint
(IDC
);
1317 end Check_Static_Constraint
;
1319 --------------------------------------
1320 -- Check_Valid_Configuration_Pragma --
1321 --------------------------------------
1323 -- A configuration pragma must appear in the context clause of
1324 -- a compilation unit, at the start of the list (i.e. only other
1325 -- pragmas may precede it).
1327 procedure Check_Valid_Configuration_Pragma
is
1329 if not Is_Configuration_Pragma
then
1330 Error_Pragma
("incorrect placement for configuration pragma%");
1332 end Check_Valid_Configuration_Pragma
;
1334 -------------------------------------
1335 -- Check_Valid_Library_Unit_Pragma --
1336 -------------------------------------
1338 procedure Check_Valid_Library_Unit_Pragma
is
1340 Parent_Node
: Node_Id
;
1341 Unit_Name
: Entity_Id
;
1342 Unit_Kind
: Node_Kind
;
1343 Unit_Node
: Node_Id
;
1344 Sindex
: Source_File_Index
;
1347 if not Is_List_Member
(N
) then
1351 Plist
:= List_Containing
(N
);
1352 Parent_Node
:= Parent
(Plist
);
1354 if Parent_Node
= Empty
then
1357 -- Case of pragma appearing after a compilation unit. In this
1358 -- case it must have an argument with the corresponding name
1359 -- and must be part of the following pragmas of its parent.
1361 elsif Nkind
(Parent_Node
) = N_Compilation_Unit_Aux
then
1362 if Plist
/= Pragmas_After
(Parent_Node
) then
1365 elsif Arg_Count
= 0 then
1367 ("argument required if outside compilation unit");
1370 Check_No_Identifiers
;
1371 Check_Arg_Count
(1);
1372 Unit_Node
:= Unit
(Parent
(Parent_Node
));
1373 Unit_Kind
:= Nkind
(Unit_Node
);
1375 Analyze
(Expression
(Arg1
));
1377 if Unit_Kind
= N_Generic_Subprogram_Declaration
1378 or else Unit_Kind
= N_Subprogram_Declaration
1380 Unit_Name
:= Defining_Entity
(Unit_Node
);
1382 elsif Unit_Kind
in N_Generic_Instantiation
then
1383 Unit_Name
:= Defining_Entity
(Unit_Node
);
1386 Unit_Name
:= Cunit_Entity
(Current_Sem_Unit
);
1389 if Chars
(Unit_Name
) /=
1390 Chars
(Entity
(Expression
(Arg1
)))
1393 ("pragma% argument is not current unit name", Arg1
);
1396 if Ekind
(Unit_Name
) = E_Package
1397 and then Present
(Renamed_Entity
(Unit_Name
))
1399 Error_Pragma
("pragma% not allowed for renamed package");
1403 -- Pragma appears other than after a compilation unit
1406 -- Here we check for the generic instantiation case and also
1407 -- for the case of processing a generic formal package. We
1408 -- detect these cases by noting that the Sloc on the node
1409 -- does not belong to the current compilation unit.
1411 Sindex
:= Source_Index
(Current_Sem_Unit
);
1413 if Loc
not in Source_First
(Sindex
) .. Source_Last
(Sindex
) then
1414 Rewrite
(N
, Make_Null_Statement
(Loc
));
1417 -- If before first declaration, the pragma applies to the
1418 -- enclosing unit, and the name if present must be this name.
1420 elsif Is_Before_First_Decl
(N
, Plist
) then
1421 Unit_Node
:= Unit_Declaration_Node
(Current_Scope
);
1422 Unit_Kind
:= Nkind
(Unit_Node
);
1424 if Nkind
(Parent
(Unit_Node
)) /= N_Compilation_Unit
then
1427 elsif Unit_Kind
= N_Subprogram_Body
1428 and then not Acts_As_Spec
(Unit_Node
)
1432 elsif Nkind
(Parent_Node
) = N_Package_Body
then
1435 elsif Nkind
(Parent_Node
) = N_Package_Specification
1436 and then Plist
= Private_Declarations
(Parent_Node
)
1440 elsif (Nkind
(Parent_Node
) = N_Generic_Package_Declaration
1441 or else Nkind
(Parent_Node
) =
1442 N_Generic_Subprogram_Declaration
)
1443 and then Plist
= Generic_Formal_Declarations
(Parent_Node
)
1447 elsif Arg_Count
> 0 then
1448 Analyze
(Expression
(Arg1
));
1450 if Entity
(Expression
(Arg1
)) /= Current_Scope
then
1452 ("name in pragma% must be enclosing unit", Arg1
);
1455 -- It is legal to have no argument in this context
1461 -- Error if not before first declaration. This is because a
1462 -- library unit pragma argument must be the name of a library
1463 -- unit (RM 10.1.5(7)), but the only names permitted in this
1464 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1465 -- generic subprogram declarations or generic instantiations.
1469 ("pragma% misplaced, must be before first declaration");
1473 end Check_Valid_Library_Unit_Pragma
;
1479 procedure Check_Variant
(Variant
: Node_Id
) is
1480 Clist
: constant Node_Id
:= Component_List
(Variant
);
1484 if not Is_Non_Empty_List
(Component_Items
(Clist
)) then
1486 ("Unchecked_Union may not have empty component list",
1491 Comp
:= First
(Component_Items
(Clist
));
1492 while Present
(Comp
) loop
1493 Check_Component
(Comp
);
1502 procedure Error_Pragma
(Msg
: String) is
1504 Error_Msg_Name_1
:= Chars
(N
);
1505 Error_Msg_N
(Msg
, N
);
1509 ----------------------
1510 -- Error_Pragma_Arg --
1511 ----------------------
1513 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
) is
1515 Error_Msg_Name_1
:= Chars
(N
);
1516 Error_Msg_N
(Msg
, Get_Pragma_Arg
(Arg
));
1518 end Error_Pragma_Arg
;
1520 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
) is
1522 Error_Msg_Name_1
:= Chars
(N
);
1523 Error_Msg_N
(Msg1
, Get_Pragma_Arg
(Arg
));
1524 Error_Pragma_Arg
(Msg2
, Arg
);
1525 end Error_Pragma_Arg
;
1527 ----------------------------
1528 -- Error_Pragma_Arg_Ident --
1529 ----------------------------
1531 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
) is
1533 Error_Msg_Name_1
:= Chars
(N
);
1534 Error_Msg_N
(Msg
, Arg
);
1536 end Error_Pragma_Arg_Ident
;
1538 ------------------------
1539 -- Find_Lib_Unit_Name --
1540 ------------------------
1542 function Find_Lib_Unit_Name
return Entity_Id
is
1544 -- Return inner compilation unit entity, for case of nested
1545 -- categorization pragmas. This happens in generic unit.
1547 if Nkind
(Parent
(N
)) = N_Package_Specification
1548 and then Defining_Entity
(Parent
(N
)) /= Current_Scope
1550 return Defining_Entity
(Parent
(N
));
1552 return Current_Scope
;
1554 end Find_Lib_Unit_Name
;
1556 ----------------------------
1557 -- Find_Program_Unit_Name --
1558 ----------------------------
1560 procedure Find_Program_Unit_Name
(Id
: Node_Id
) is
1561 Unit_Name
: Entity_Id
;
1562 Unit_Kind
: Node_Kind
;
1563 P
: constant Node_Id
:= Parent
(N
);
1566 if Nkind
(P
) = N_Compilation_Unit
then
1567 Unit_Kind
:= Nkind
(Unit
(P
));
1569 if Unit_Kind
= N_Subprogram_Declaration
1570 or else Unit_Kind
= N_Package_Declaration
1571 or else Unit_Kind
in N_Generic_Declaration
1573 Unit_Name
:= Defining_Entity
(Unit
(P
));
1575 if Chars
(Id
) = Chars
(Unit_Name
) then
1576 Set_Entity
(Id
, Unit_Name
);
1577 Set_Etype
(Id
, Etype
(Unit_Name
));
1579 Set_Etype
(Id
, Any_Type
);
1581 ("cannot find program unit referenced by pragma%");
1585 Set_Etype
(Id
, Any_Type
);
1586 Error_Pragma
("pragma% inapplicable to this unit");
1592 end Find_Program_Unit_Name
;
1594 -----------------------------------------
1595 -- Find_Unique_Parameterless_Procedure --
1596 -----------------------------------------
1598 function Find_Unique_Parameterless_Procedure
1600 Arg
: Node_Id
) return Entity_Id
1602 Proc
: Entity_Id
:= Empty
;
1605 -- The body of this procedure needs some comments ???
1607 if not Is_Entity_Name
(Name
) then
1609 ("argument of pragma% must be entity name", Arg
);
1611 elsif not Is_Overloaded
(Name
) then
1612 Proc
:= Entity
(Name
);
1614 if Ekind
(Proc
) /= E_Procedure
1615 or else Present
(First_Formal
(Proc
)) then
1617 ("argument of pragma% must be parameterless procedure", Arg
);
1622 Found
: Boolean := False;
1624 Index
: Interp_Index
;
1627 Get_First_Interp
(Name
, Index
, It
);
1628 while Present
(It
.Nam
) loop
1631 if Ekind
(Proc
) = E_Procedure
1632 and then No
(First_Formal
(Proc
))
1636 Set_Entity
(Name
, Proc
);
1637 Set_Is_Overloaded
(Name
, False);
1640 ("ambiguous handler name for pragma% ", Arg
);
1644 Get_Next_Interp
(Index
, It
);
1649 ("argument of pragma% must be parameterless procedure",
1652 Proc
:= Entity
(Name
);
1658 end Find_Unique_Parameterless_Procedure
;
1660 -------------------------
1661 -- Gather_Associations --
1662 -------------------------
1664 procedure Gather_Associations
1666 Args
: out Args_List
)
1671 -- Initialize all parameters to Empty
1673 for J
in Args
'Range loop
1677 -- That's all we have to do if there are no argument associations
1679 if No
(Pragma_Argument_Associations
(N
)) then
1683 -- Otherwise first deal with any positional parameters present
1685 Arg
:= First
(Pragma_Argument_Associations
(N
));
1686 for Index
in Args
'Range loop
1687 exit when No
(Arg
) or else Chars
(Arg
) /= No_Name
;
1688 Args
(Index
) := Expression
(Arg
);
1692 -- Positional parameters all processed, if any left, then we
1693 -- have too many positional parameters.
1695 if Present
(Arg
) and then Chars
(Arg
) = No_Name
then
1697 ("too many positional associations for pragma%", Arg
);
1700 -- Process named parameters if any are present
1702 while Present
(Arg
) loop
1703 if Chars
(Arg
) = No_Name
then
1705 ("positional association cannot follow named association",
1709 for Index
in Names
'Range loop
1710 if Names
(Index
) = Chars
(Arg
) then
1711 if Present
(Args
(Index
)) then
1713 ("duplicate argument association for pragma%", Arg
);
1715 Args
(Index
) := Expression
(Arg
);
1720 if Index
= Names
'Last then
1721 Error_Msg_Name_1
:= Chars
(N
);
1722 Error_Msg_N
("pragma% does not allow & argument", Arg
);
1724 -- Check for possible misspelling
1726 for Index1
in Names
'Range loop
1727 if Is_Bad_Spelling_Of
1728 (Get_Name_String
(Chars
(Arg
)),
1729 Get_Name_String
(Names
(Index1
)))
1731 Error_Msg_Name_1
:= Names
(Index1
);
1732 Error_Msg_N
("\possible misspelling of%", Arg
);
1744 end Gather_Associations
;
1746 --------------------
1747 -- Get_Pragma_Arg --
1748 --------------------
1750 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
is
1752 if Nkind
(Arg
) = N_Pragma_Argument_Association
then
1753 return Expression
(Arg
);
1763 procedure GNAT_Pragma
is
1765 Check_Restriction
(No_Implementation_Pragmas
, N
);
1768 --------------------------
1769 -- Is_Before_First_Decl --
1770 --------------------------
1772 function Is_Before_First_Decl
1773 (Pragma_Node
: Node_Id
;
1774 Decls
: List_Id
) return Boolean
1776 Item
: Node_Id
:= First
(Decls
);
1779 -- Only other pragmas can come before this pragma
1782 if No
(Item
) or else Nkind
(Item
) /= N_Pragma
then
1785 elsif Item
= Pragma_Node
then
1791 end Is_Before_First_Decl
;
1793 -----------------------------
1794 -- Is_Configuration_Pragma --
1795 -----------------------------
1797 -- A configuration pragma must appear in the context clause of
1798 -- a compilation unit, at the start of the list (i.e. only other
1799 -- pragmas may precede it).
1801 function Is_Configuration_Pragma
return Boolean is
1802 Lis
: constant List_Id
:= List_Containing
(N
);
1803 Par
: constant Node_Id
:= Parent
(N
);
1807 -- If no parent, then we are in the configuration pragma file,
1808 -- so the placement is definitely appropriate.
1813 -- Otherwise we must be in the context clause of a compilation unit
1814 -- and the only thing allowed before us in the context list is more
1815 -- configuration pragmas.
1817 elsif Nkind
(Par
) = N_Compilation_Unit
1818 and then Context_Items
(Par
) = Lis
1825 elsif Nkind
(Prg
) /= N_Pragma
then
1835 end Is_Configuration_Pragma
;
1837 --------------------------
1838 -- Is_In_Context_Clause --
1839 --------------------------
1841 function Is_In_Context_Clause
return Boolean is
1843 Parent_Node
: Node_Id
;
1846 if not Is_List_Member
(N
) then
1850 Plist
:= List_Containing
(N
);
1851 Parent_Node
:= Parent
(Plist
);
1853 if Parent_Node
= Empty
1854 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
1855 or else Context_Items
(Parent_Node
) /= Plist
1862 end Is_In_Context_Clause
;
1864 ---------------------------------
1865 -- Is_Static_String_Expression --
1866 ---------------------------------
1868 function Is_Static_String_Expression
(Arg
: Node_Id
) return Boolean is
1869 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1872 Analyze_And_Resolve
(Argx
);
1873 return Is_OK_Static_Expression
(Argx
)
1874 and then Nkind
(Argx
) = N_String_Literal
;
1875 end Is_Static_String_Expression
;
1877 ----------------------
1878 -- Pragma_Misplaced --
1879 ----------------------
1881 procedure Pragma_Misplaced
is
1883 Error_Pragma
("incorrect placement of pragma%");
1884 end Pragma_Misplaced
;
1886 ------------------------------------
1887 -- Process Atomic_Shared_Volatile --
1888 ------------------------------------
1890 procedure Process_Atomic_Shared_Volatile
is
1897 procedure Set_Atomic
(E
: Entity_Id
);
1898 -- Set given type as atomic, and if no explicit alignment was
1899 -- given, set alignment to unknown, since back end knows what
1900 -- the alignment requirements are for atomic arrays. Note that
1901 -- this step is necessary for derived types.
1907 procedure Set_Atomic
(E
: Entity_Id
) is
1911 if not Has_Alignment_Clause
(E
) then
1912 Set_Alignment
(E
, Uint_0
);
1916 -- Start of processing for Process_Atomic_Shared_Volatile
1919 Check_Ada_83_Warning
;
1920 Check_No_Identifiers
;
1921 Check_Arg_Count
(1);
1922 Check_Arg_Is_Local_Name
(Arg1
);
1923 E_Id
:= Expression
(Arg1
);
1925 if Etype
(E_Id
) = Any_Type
then
1930 D
:= Declaration_Node
(E
);
1934 if Rep_Item_Too_Early
(E
, N
)
1936 Rep_Item_Too_Late
(E
, N
)
1940 Check_First_Subtype
(Arg1
);
1943 if Prag_Id
/= Pragma_Volatile
then
1945 Set_Atomic
(Underlying_Type
(E
));
1946 Set_Atomic
(Base_Type
(E
));
1949 -- Attribute belongs on the base type. If the
1950 -- view of the type is currently private, it also
1951 -- belongs on the underlying type.
1953 Set_Is_Volatile
(Base_Type
(E
));
1954 Set_Is_Volatile
(Underlying_Type
(E
));
1956 Set_Treat_As_Volatile
(E
);
1957 Set_Treat_As_Volatile
(Underlying_Type
(E
));
1959 elsif K
= N_Object_Declaration
1960 or else (K
= N_Component_Declaration
1961 and then Original_Record_Component
(E
) = E
)
1963 if Rep_Item_Too_Late
(E
, N
) then
1967 if Prag_Id
/= Pragma_Volatile
then
1970 -- If the object declaration has an explicit
1971 -- initialization, a temporary may have to be
1972 -- created to hold the expression, to insure
1973 -- that access to the object remain atomic.
1975 if Nkind
(Parent
(E
)) = N_Object_Declaration
1976 and then Present
(Expression
(Parent
(E
)))
1978 Set_Has_Delayed_Freeze
(E
);
1981 -- An interesting improvement here. If an object of type X
1982 -- is declared atomic, and the type X is not atomic, that's
1983 -- a pity, since it may not have appropraite alignment etc.
1984 -- We can rescue this in the special case where the object
1985 -- and type are in the same unit by just setting the type
1986 -- as atomic, so that the back end will process it as atomic.
1988 Utyp
:= Underlying_Type
(Etype
(E
));
1991 and then Sloc
(E
) > No_Location
1992 and then Sloc
(Utyp
) > No_Location
1994 Get_Source_File_Index
(Sloc
(E
)) =
1995 Get_Source_File_Index
(Sloc
(Underlying_Type
(Etype
(E
))))
1997 Set_Is_Atomic
(Underlying_Type
(Etype
(E
)));
2001 Set_Is_Volatile
(E
);
2002 Set_Treat_As_Volatile
(E
);
2006 ("inappropriate entity for pragma%", Arg1
);
2008 end Process_Atomic_Shared_Volatile
;
2010 -------------------------------------------
2011 -- Process_Compile_Time_Warning_Or_Error --
2012 -------------------------------------------
2014 procedure Process_Compile_Time_Warning_Or_Error
is
2015 Arg1x
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
2019 Check_Arg_Count
(2);
2020 Check_No_Identifiers
;
2021 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
2022 Analyze_And_Resolve
(Arg1x
, Standard_Boolean
);
2024 if Compile_Time_Known_Value
(Arg1x
) then
2025 if Is_True
(Expr_Value
(Get_Pragma_Arg
(Arg1
))) then
2027 Str
: constant String_Id
:=
2028 Strval
(Get_Pragma_Arg
(Arg2
));
2029 Len
: constant Int
:= String_Length
(Str
);
2039 -- Loop through segments of message separated by line
2040 -- feeds. We output these segments as separate messages
2041 -- with continuation marks for all but the first.
2044 Error_Msg_Strlen
:= 0;
2046 -- Loop to copy characters from argument to error
2047 -- message string buffer.
2050 exit when Ptr
> Len
;
2051 CC
:= Get_String_Char
(Str
, Ptr
);
2054 -- Ignore wide chars ??? else store character
2056 if In_Character_Range
(CC
) then
2057 C
:= Get_Character
(CC
);
2058 exit when C
= ASCII
.LF
;
2059 Error_Msg_Strlen
:= Error_Msg_Strlen
+ 1;
2060 Error_Msg_String
(Error_Msg_Strlen
) := C
;
2064 -- Here with one line ready to go
2066 Error_Msg_Warn
:= Prag_Id
= Pragma_Compile_Time_Warning
;
2068 if Cont
= False then
2069 Error_Msg_N
("<~", Arg1
);
2072 Error_Msg_N
("\<~", Arg1
);
2075 exit when Ptr
> Len
;
2080 end Process_Compile_Time_Warning_Or_Error
;
2082 ------------------------
2083 -- Process_Convention --
2084 ------------------------
2086 procedure Process_Convention
2087 (C
: out Convention_Id
;
2093 Comp_Unit
: Unit_Number_Type
;
2095 procedure Set_Convention_From_Pragma
(E
: Entity_Id
);
2096 -- Set convention in entity E, and also flag that the entity has a
2097 -- convention pragma. If entity is for a private or incomplete type,
2098 -- also set convention and flag on underlying type. This procedure
2099 -- also deals with the special case of C_Pass_By_Copy convention.
2101 --------------------------------
2102 -- Set_Convention_From_Pragma --
2103 --------------------------------
2105 procedure Set_Convention_From_Pragma
(E
: Entity_Id
) is
2107 -- Ada 2005 (AI-430): Check invalid attempt to change convention
2108 -- for an overridden dispatching operation. Technically this is
2109 -- an amendment and should only be done in Ada 2005 mode. However,
2110 -- this is clearly a mistake, since the problem that is addressed
2111 -- by this AI is that there is a clear gap in the RM!
2113 if Is_Dispatching_Operation
(E
)
2114 and then Present
(Overridden_Operation
(E
))
2115 and then C
/= Convention
(Overridden_Operation
(E
))
2118 ("cannot change convention for " &
2119 "overridden dispatching operation",
2123 -- Set the convention
2125 Set_Convention
(E
, C
);
2126 Set_Has_Convention_Pragma
(E
);
2128 if Is_Incomplete_Or_Private_Type
(E
) then
2129 Set_Convention
(Underlying_Type
(E
), C
);
2130 Set_Has_Convention_Pragma
(Underlying_Type
(E
), True);
2133 -- A class-wide type should inherit the convention of
2134 -- the specific root type (although this isn't specified
2135 -- clearly by the RM).
2137 if Is_Type
(E
) and then Present
(Class_Wide_Type
(E
)) then
2138 Set_Convention
(Class_Wide_Type
(E
), C
);
2141 -- If the entity is a record type, then check for special case of
2142 -- C_Pass_By_Copy, which is treated the same as C except that the
2143 -- special record flag is set. This convention is only permitted
2144 -- on record types (see AI95-00131).
2146 if Cname
= Name_C_Pass_By_Copy
then
2147 if Is_Record_Type
(E
) then
2148 Set_C_Pass_By_Copy
(Base_Type
(E
));
2149 elsif Is_Incomplete_Or_Private_Type
(E
)
2150 and then Is_Record_Type
(Underlying_Type
(E
))
2152 Set_C_Pass_By_Copy
(Base_Type
(Underlying_Type
(E
)));
2155 ("C_Pass_By_Copy convention allowed only for record type",
2160 -- If the entity is a derived boolean type, check for the
2161 -- special case of convention C, C++, or Fortran, where we
2162 -- consider any nonzero value to represent true.
2164 if Is_Discrete_Type
(E
)
2165 and then Root_Type
(Etype
(E
)) = Standard_Boolean
2171 C
= Convention_Fortran
)
2173 Set_Nonzero_Is_True
(Base_Type
(E
));
2175 end Set_Convention_From_Pragma
;
2177 -- Start of processing for Process_Convention
2180 Check_At_Least_N_Arguments
(2);
2181 Check_Optional_Identifier
(Arg1
, Name_Convention
);
2182 Check_Arg_Is_Identifier
(Arg1
);
2183 Cname
:= Chars
(Expression
(Arg1
));
2185 -- C_Pass_By_Copy is treated as a synonym for convention C
2186 -- (this is tested again below to set the critical flag)
2188 if Cname
= Name_C_Pass_By_Copy
then
2191 -- Otherwise we must have something in the standard convention list
2193 elsif Is_Convention_Name
(Cname
) then
2194 C
:= Get_Convention_Id
(Chars
(Expression
(Arg1
)));
2196 -- In DEC VMS, it seems that there is an undocumented feature that
2197 -- any unrecognized convention is treated as the default, which for
2198 -- us is convention C. It does not seem so terrible to do this
2199 -- unconditionally, silently in the VMS case, and with a warning
2200 -- in the non-VMS case.
2203 if Warn_On_Export_Import
and not OpenVMS_On_Target
then
2205 ("?unrecognized convention name, C assumed",
2212 Check_Optional_Identifier
(Arg2
, Name_Entity
);
2213 Check_Arg_Is_Local_Name
(Arg2
);
2215 Id
:= Expression
(Arg2
);
2218 if not Is_Entity_Name
(Id
) then
2219 Error_Pragma_Arg
("entity name required", Arg2
);
2222 if Ekind
(Entity
(Id
)) = E_Enumeration_Literal
then
2223 Error_Pragma
("enumeration literal not allowed for pragma%");
2228 -- Go to renamed subprogram if present, since convention applies to
2229 -- the actual renamed entity, not to the renaming entity. If the
2230 -- subprogram is inherited, go to parent subprogram.
2232 if Is_Subprogram
(E
)
2233 and then Present
(Alias
(E
))
2235 if Nkind
(Parent
(Declaration_Node
(E
))) =
2236 N_Subprogram_Renaming_Declaration
2240 elsif Nkind
(Parent
(E
)) = N_Full_Type_Declaration
2241 and then Scope
(E
) = Scope
(Alias
(E
))
2247 -- Check that we are not applying this to a specless body
2249 if Is_Subprogram
(E
)
2250 and then Nkind
(Parent
(Declaration_Node
(E
))) = N_Subprogram_Body
2253 ("pragma% requires separate spec and must come before body");
2256 -- Check that we are not applying this to a named constant
2258 if Ekind
(E
) = E_Named_Integer
2260 Ekind
(E
) = E_Named_Real
2262 Error_Msg_Name_1
:= Chars
(N
);
2264 ("cannot apply pragma% to named constant!",
2265 Get_Pragma_Arg
(Arg2
));
2267 ("\supply appropriate type for&!", Arg2
);
2270 if Etype
(E
) = Any_Type
2271 or else Rep_Item_Too_Early
(E
, N
)
2275 E
:= Underlying_Type
(E
);
2278 if Rep_Item_Too_Late
(E
, N
) then
2282 if Has_Convention_Pragma
(E
) then
2284 ("at most one Convention/Export/Import pragma is allowed", Arg2
);
2286 elsif Convention
(E
) = Convention_Protected
2287 or else Ekind
(Scope
(E
)) = E_Protected_Type
2290 ("a protected operation cannot be given a different convention",
2294 -- For Intrinsic, a subprogram is required
2296 if C
= Convention_Intrinsic
2297 and then not Is_Subprogram
(E
)
2298 and then not Is_Generic_Subprogram
(E
)
2301 ("second argument of pragma% must be a subprogram", Arg2
);
2304 -- For Stdcall, a subprogram, variable or subprogram type is required
2306 if C
= Convention_Stdcall
2307 and then not Is_Subprogram
(E
)
2308 and then not Is_Generic_Subprogram
(E
)
2309 and then Ekind
(E
) /= E_Variable
2312 and then Ekind
(Designated_Type
(E
)) = E_Subprogram_Type
)
2315 ("second argument of pragma% must be subprogram (type)",
2319 if not Is_Subprogram
(E
)
2320 and then not Is_Generic_Subprogram
(E
)
2322 Set_Convention_From_Pragma
(E
);
2326 Check_First_Subtype
(Arg2
);
2327 Set_Convention_From_Pragma
(Base_Type
(E
));
2329 -- For subprograms, we must set the convention on the
2330 -- internally generated directly designated type as well.
2332 if Ekind
(E
) = E_Access_Subprogram_Type
then
2333 Set_Convention_From_Pragma
(Directly_Designated_Type
(E
));
2337 -- For the subprogram case, set proper convention for all homonyms
2338 -- in same scope and the same declarative part, i.e. the same
2339 -- compilation unit.
2342 Comp_Unit
:= Get_Source_Unit
(E
);
2343 Set_Convention_From_Pragma
(E
);
2345 -- Treat a pragma Import as an implicit body, for GPS use
2347 if Prag_Id
= Pragma_Import
then
2348 Generate_Reference
(E
, Id
, 'b');
2354 exit when No
(E1
) or else Scope
(E1
) /= Current_Scope
;
2356 -- Note: below we are missing a check for Rep_Item_Too_Late.
2357 -- That is deliberate, we cannot chain the rep item on more
2358 -- than one Rep_Item chain, to be fixed later ???
2360 if Comes_From_Source
(E1
)
2361 and then Comp_Unit
= Get_Source_Unit
(E1
)
2362 and then Nkind
(Original_Node
(Parent
(E1
))) /=
2363 N_Full_Type_Declaration
2365 Set_Convention_From_Pragma
(E1
);
2367 if Prag_Id
= Pragma_Import
then
2368 Generate_Reference
(E
, Id
, 'b');
2373 end Process_Convention
;
2375 -----------------------------------------------------
2376 -- Process_Extended_Import_Export_Exception_Pragma --
2377 -----------------------------------------------------
2379 procedure Process_Extended_Import_Export_Exception_Pragma
2380 (Arg_Internal
: Node_Id
;
2381 Arg_External
: Node_Id
;
2391 if not OpenVMS_On_Target
then
2393 ("?pragma% ignored (applies only to Open'V'M'S)");
2396 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2397 Def_Id
:= Entity
(Arg_Internal
);
2399 if Ekind
(Def_Id
) /= E_Exception
then
2401 ("pragma% must refer to declared exception", Arg_Internal
);
2404 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2406 if Present
(Arg_Form
) then
2407 Check_Arg_Is_One_Of
(Arg_Form
, Name_Ada
, Name_VMS
);
2410 if Present
(Arg_Form
)
2411 and then Chars
(Arg_Form
) = Name_Ada
2415 Set_Is_VMS_Exception
(Def_Id
);
2416 Set_Exception_Code
(Def_Id
, No_Uint
);
2419 if Present
(Arg_Code
) then
2420 if not Is_VMS_Exception
(Def_Id
) then
2422 ("Code option for pragma% not allowed for Ada case",
2426 Check_Arg_Is_Static_Expression
(Arg_Code
, Any_Integer
);
2427 Code_Val
:= Expr_Value
(Arg_Code
);
2429 if not UI_Is_In_Int_Range
(Code_Val
) then
2431 ("Code option for pragma% must be in 32-bit range",
2435 Set_Exception_Code
(Def_Id
, Code_Val
);
2438 end Process_Extended_Import_Export_Exception_Pragma
;
2440 -------------------------------------------------
2441 -- Process_Extended_Import_Export_Internal_Arg --
2442 -------------------------------------------------
2444 procedure Process_Extended_Import_Export_Internal_Arg
2445 (Arg_Internal
: Node_Id
:= Empty
)
2450 if No
(Arg_Internal
) then
2451 Error_Pragma
("Internal parameter required for pragma%");
2454 if Nkind
(Arg_Internal
) = N_Identifier
then
2457 elsif Nkind
(Arg_Internal
) = N_Operator_Symbol
2458 and then (Prag_Id
= Pragma_Import_Function
2460 Prag_Id
= Pragma_Export_Function
)
2466 ("wrong form for Internal parameter for pragma%", Arg_Internal
);
2469 Check_Arg_Is_Local_Name
(Arg_Internal
);
2470 end Process_Extended_Import_Export_Internal_Arg
;
2472 --------------------------------------------------
2473 -- Process_Extended_Import_Export_Object_Pragma --
2474 --------------------------------------------------
2476 procedure Process_Extended_Import_Export_Object_Pragma
2477 (Arg_Internal
: Node_Id
;
2478 Arg_External
: Node_Id
;
2484 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2485 Def_Id
:= Entity
(Arg_Internal
);
2487 if Ekind
(Def_Id
) /= E_Constant
2488 and then Ekind
(Def_Id
) /= E_Variable
2491 ("pragma% must designate an object", Arg_Internal
);
2494 if Has_Rep_Pragma
(Def_Id
, Name_Common_Object
)
2496 Has_Rep_Pragma
(Def_Id
, Name_Psect_Object
)
2499 ("previous Common/Psect_Object applies, pragma % not permitted",
2503 if Rep_Item_Too_Late
(Def_Id
, N
) then
2507 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2509 if Present
(Arg_Size
) then
2510 Check_Arg_Is_External_Name
(Arg_Size
);
2513 -- Export_Object case
2515 if Prag_Id
= Pragma_Export_Object
then
2516 if not Is_Library_Level_Entity
(Def_Id
) then
2518 ("argument for pragma% must be library level entity",
2522 if Ekind
(Current_Scope
) = E_Generic_Package
then
2523 Error_Pragma
("pragma& cannot appear in a generic unit");
2526 if not Size_Known_At_Compile_Time
(Etype
(Def_Id
)) then
2528 ("exported object must have compile time known size",
2532 if Warn_On_Export_Import
and then Is_Exported
(Def_Id
) then
2534 ("?duplicate Export_Object pragma", N
);
2536 Set_Exported
(Def_Id
, Arg_Internal
);
2539 -- Import_Object case
2542 if Is_Concurrent_Type
(Etype
(Def_Id
)) then
2544 ("cannot use pragma% for task/protected object",
2548 if Ekind
(Def_Id
) = E_Constant
then
2550 ("cannot import a constant", Arg_Internal
);
2553 if Warn_On_Export_Import
2554 and then Has_Discriminants
(Etype
(Def_Id
))
2557 ("imported value must be initialized?", Arg_Internal
);
2560 if Warn_On_Export_Import
2561 and then Is_Access_Type
(Etype
(Def_Id
))
2564 ("cannot import object of an access type?", Arg_Internal
);
2567 if Warn_On_Export_Import
2568 and then Is_Imported
(Def_Id
)
2571 ("?duplicate Import_Object pragma", N
);
2573 -- Check for explicit initialization present. Note that an
2574 -- initialization that generated by the code generator, e.g.
2575 -- for an access type, does not count here.
2577 elsif Present
(Expression
(Parent
(Def_Id
)))
2580 (Original_Node
(Expression
(Parent
(Def_Id
))))
2582 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2584 ("imported entities cannot be initialized (RM B.1(24))",
2585 "\no initialization allowed for & declared#", Arg1
);
2587 Set_Imported
(Def_Id
);
2588 Note_Possible_Modification
(Arg_Internal
);
2591 end Process_Extended_Import_Export_Object_Pragma
;
2593 ------------------------------------------------------
2594 -- Process_Extended_Import_Export_Subprogram_Pragma --
2595 ------------------------------------------------------
2597 procedure Process_Extended_Import_Export_Subprogram_Pragma
2598 (Arg_Internal
: Node_Id
;
2599 Arg_External
: Node_Id
;
2600 Arg_Parameter_Types
: Node_Id
;
2601 Arg_Result_Type
: Node_Id
:= Empty
;
2602 Arg_Mechanism
: Node_Id
;
2603 Arg_Result_Mechanism
: Node_Id
:= Empty
;
2604 Arg_First_Optional_Parameter
: Node_Id
:= Empty
)
2610 Ambiguous
: Boolean;
2614 function Same_Base_Type
2616 Formal
: Entity_Id
) return Boolean;
2617 -- Determines if Ptype references the type of Formal. Note that
2618 -- only the base types need to match according to the spec. Ptype
2619 -- here is the argument from the pragma, which is either a type
2620 -- name, or an access attribute.
2622 --------------------
2623 -- Same_Base_Type --
2624 --------------------
2626 function Same_Base_Type
2628 Formal
: Entity_Id
) return Boolean
2630 Ftyp
: constant Entity_Id
:= Base_Type
(Etype
(Formal
));
2634 -- Case where pragma argument is typ'Access
2636 if Nkind
(Ptype
) = N_Attribute_Reference
2637 and then Attribute_Name
(Ptype
) = Name_Access
2639 Pref
:= Prefix
(Ptype
);
2642 if not Is_Entity_Name
(Pref
)
2643 or else Entity
(Pref
) = Any_Type
2648 -- We have a match if the corresponding argument is of an
2649 -- anonymous access type, and its designicated type matches
2650 -- the type of the prefix of the access attribute
2652 return Ekind
(Ftyp
) = E_Anonymous_Access_Type
2653 and then Base_Type
(Entity
(Pref
)) =
2654 Base_Type
(Etype
(Designated_Type
(Ftyp
)));
2656 -- Case where pragma argument is a type name
2661 if not Is_Entity_Name
(Ptype
)
2662 or else Entity
(Ptype
) = Any_Type
2667 -- We have a match if the corresponding argument is of
2668 -- the type given in the pragma (comparing base types)
2670 return Base_Type
(Entity
(Ptype
)) = Ftyp
;
2674 -- Start of processing for
2675 -- Process_Extended_Import_Export_Subprogram_Pragma
2678 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2682 -- Loop through homonyms (overloadings) of the entity
2684 Hom_Id
:= Entity
(Arg_Internal
);
2685 while Present
(Hom_Id
) loop
2686 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
2688 -- We need a subprogram in the current scope
2690 if not Is_Subprogram
(Def_Id
)
2691 or else Scope
(Def_Id
) /= Current_Scope
2698 -- Pragma cannot apply to subprogram body
2700 if Is_Subprogram
(Def_Id
)
2703 (Declaration_Node
(Def_Id
))) = N_Subprogram_Body
2706 ("pragma% requires separate spec"
2707 & " and must come before body");
2710 -- Test result type if given, note that the result type
2711 -- parameter can only be present for the function cases.
2713 if Present
(Arg_Result_Type
)
2714 and then not Same_Base_Type
(Arg_Result_Type
, Def_Id
)
2718 elsif Etype
(Def_Id
) /= Standard_Void_Type
2720 (Chars
(N
) = Name_Export_Procedure
2721 or else Chars
(N
) = Name_Import_Procedure
)
2725 -- Test parameter types if given. Note that this parameter
2726 -- has not been analyzed (and must not be, since it is
2727 -- semantic nonsense), so we get it as the parser left it.
2729 elsif Present
(Arg_Parameter_Types
) then
2730 Check_Matching_Types
: declare
2735 Formal
:= First_Formal
(Def_Id
);
2737 if Nkind
(Arg_Parameter_Types
) = N_Null
then
2738 if Present
(Formal
) then
2742 -- A list of one type, e.g. (List) is parsed as
2743 -- a parenthesized expression.
2745 elsif Nkind
(Arg_Parameter_Types
) /= N_Aggregate
2746 and then Paren_Count
(Arg_Parameter_Types
) = 1
2749 or else Present
(Next_Formal
(Formal
))
2754 Same_Base_Type
(Arg_Parameter_Types
, Formal
);
2757 -- A list of more than one type is parsed as a aggregate
2759 elsif Nkind
(Arg_Parameter_Types
) = N_Aggregate
2760 and then Paren_Count
(Arg_Parameter_Types
) = 0
2762 Ptype
:= First
(Expressions
(Arg_Parameter_Types
));
2763 while Present
(Ptype
) or else Present
(Formal
) loop
2766 or else not Same_Base_Type
(Ptype
, Formal
)
2771 Next_Formal
(Formal
);
2776 -- Anything else is of the wrong form
2780 ("wrong form for Parameter_Types parameter",
2781 Arg_Parameter_Types
);
2783 end Check_Matching_Types
;
2786 -- Match is now False if the entry we found did not match
2787 -- either a supplied Parameter_Types or Result_Types argument
2793 -- Ambiguous case, the flag Ambiguous shows if we already
2794 -- detected this and output the initial messages.
2797 if not Ambiguous
then
2799 Error_Msg_Name_1
:= Chars
(N
);
2801 ("pragma% does not uniquely identify subprogram!",
2803 Error_Msg_Sloc
:= Sloc
(Ent
);
2804 Error_Msg_N
("matching subprogram #!", N
);
2808 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2809 Error_Msg_N
("matching subprogram #!", N
);
2814 Hom_Id
:= Homonym
(Hom_Id
);
2817 -- See if we found an entry
2820 if not Ambiguous
then
2821 if Is_Generic_Subprogram
(Entity
(Arg_Internal
)) then
2823 ("pragma% cannot be given for generic subprogram");
2827 ("pragma% does not identify local subprogram");
2834 -- Import pragmas must be be for imported entities
2836 if Prag_Id
= Pragma_Import_Function
2838 Prag_Id
= Pragma_Import_Procedure
2840 Prag_Id
= Pragma_Import_Valued_Procedure
2842 if not Is_Imported
(Ent
) then
2844 ("pragma Import or Interface must precede pragma%");
2847 -- Here we have the Export case which can set the entity as exported
2849 -- But does not do so if the specified external name is null, since
2850 -- that is taken as a signal in DEC Ada 83 (with which we want to be
2851 -- compatible) to request no external name.
2853 elsif Nkind
(Arg_External
) = N_String_Literal
2854 and then String_Length
(Strval
(Arg_External
)) = 0
2858 -- In all other cases, set entit as exported
2861 Set_Exported
(Ent
, Arg_Internal
);
2864 -- Special processing for Valued_Procedure cases
2866 if Prag_Id
= Pragma_Import_Valued_Procedure
2868 Prag_Id
= Pragma_Export_Valued_Procedure
2870 Formal
:= First_Formal
(Ent
);
2874 ("at least one parameter required for pragma%");
2876 elsif Ekind
(Formal
) /= E_Out_Parameter
then
2878 ("first parameter must have mode out for pragma%");
2881 Set_Is_Valued_Procedure
(Ent
);
2885 Set_Extended_Import_Export_External_Name
(Ent
, Arg_External
);
2887 -- Process Result_Mechanism argument if present. We have already
2888 -- checked that this is only allowed for the function case.
2890 if Present
(Arg_Result_Mechanism
) then
2891 Set_Mechanism_Value
(Ent
, Arg_Result_Mechanism
);
2894 -- Process Mechanism parameter if present. Note that this parameter
2895 -- is not analyzed, and must not be analyzed since it is semantic
2896 -- nonsense, so we get it in exactly as the parser left it.
2898 if Present
(Arg_Mechanism
) then
2906 -- A single mechanism association without a formal parameter
2907 -- name is parsed as a parenthesized expression. All other
2908 -- cases are parsed as aggregates, so we rewrite the single
2909 -- parameter case as an aggregate for consistency.
2911 if Nkind
(Arg_Mechanism
) /= N_Aggregate
2912 and then Paren_Count
(Arg_Mechanism
) = 1
2914 Rewrite
(Arg_Mechanism
,
2915 Make_Aggregate
(Sloc
(Arg_Mechanism
),
2916 Expressions
=> New_List
(
2917 Relocate_Node
(Arg_Mechanism
))));
2920 -- Case of only mechanism name given, applies to all formals
2922 if Nkind
(Arg_Mechanism
) /= N_Aggregate
then
2923 Formal
:= First_Formal
(Ent
);
2924 while Present
(Formal
) loop
2925 Set_Mechanism_Value
(Formal
, Arg_Mechanism
);
2926 Next_Formal
(Formal
);
2929 -- Case of list of mechanism associations given
2932 if Null_Record_Present
(Arg_Mechanism
) then
2934 ("inappropriate form for Mechanism parameter",
2938 -- Deal with positional ones first
2940 Formal
:= First_Formal
(Ent
);
2942 if Present
(Expressions
(Arg_Mechanism
)) then
2943 Mname
:= First
(Expressions
(Arg_Mechanism
));
2944 while Present
(Mname
) loop
2947 ("too many mechanism associations", Mname
);
2950 Set_Mechanism_Value
(Formal
, Mname
);
2951 Next_Formal
(Formal
);
2956 -- Deal with named entries
2958 if Present
(Component_Associations
(Arg_Mechanism
)) then
2959 Massoc
:= First
(Component_Associations
(Arg_Mechanism
));
2960 while Present
(Massoc
) loop
2961 Choice
:= First
(Choices
(Massoc
));
2963 if Nkind
(Choice
) /= N_Identifier
2964 or else Present
(Next
(Choice
))
2967 ("incorrect form for mechanism association",
2971 Formal
:= First_Formal
(Ent
);
2975 ("parameter name & not present", Choice
);
2978 if Chars
(Choice
) = Chars
(Formal
) then
2980 (Formal
, Expression
(Massoc
));
2984 Next_Formal
(Formal
);
2994 -- Process First_Optional_Parameter argument if present. We have
2995 -- already checked that this is only allowed for the Import case.
2997 if Present
(Arg_First_Optional_Parameter
) then
2998 if Nkind
(Arg_First_Optional_Parameter
) /= N_Identifier
then
3000 ("first optional parameter must be formal parameter name",
3001 Arg_First_Optional_Parameter
);
3004 Formal
:= First_Formal
(Ent
);
3008 ("specified formal parameter& not found",
3009 Arg_First_Optional_Parameter
);
3012 exit when Chars
(Formal
) =
3013 Chars
(Arg_First_Optional_Parameter
);
3015 Next_Formal
(Formal
);
3018 Set_First_Optional_Parameter
(Ent
, Formal
);
3020 -- Check specified and all remaining formals have right form
3022 while Present
(Formal
) loop
3023 if Ekind
(Formal
) /= E_In_Parameter
then
3025 ("optional formal& is not of mode in!",
3026 Arg_First_Optional_Parameter
, Formal
);
3029 Dval
:= Default_Value
(Formal
);
3033 ("optional formal& does not have default value!",
3034 Arg_First_Optional_Parameter
, Formal
);
3036 elsif Compile_Time_Known_Value_Or_Aggr
(Dval
) then
3041 ("default value for optional formal& is non-static!",
3042 Arg_First_Optional_Parameter
, Formal
);
3046 Set_Is_Optional_Parameter
(Formal
);
3047 Next_Formal
(Formal
);
3050 end Process_Extended_Import_Export_Subprogram_Pragma
;
3052 --------------------------
3053 -- Process_Generic_List --
3054 --------------------------
3056 procedure Process_Generic_List
is
3062 Check_No_Identifiers
;
3063 Check_At_Least_N_Arguments
(1);
3066 while Present
(Arg
) loop
3067 Exp
:= Expression
(Arg
);
3070 if not Is_Entity_Name
(Exp
)
3072 (not Is_Generic_Instance
(Entity
(Exp
))
3074 not Is_Generic_Unit
(Entity
(Exp
)))
3077 ("pragma% argument must be name of generic unit/instance",
3083 end Process_Generic_List
;
3085 ---------------------------------
3086 -- Process_Import_Or_Interface --
3087 ---------------------------------
3089 procedure Process_Import_Or_Interface
is
3095 Process_Convention
(C
, Def_Id
);
3096 Kill_Size_Check_Code
(Def_Id
);
3097 Note_Possible_Modification
(Expression
(Arg2
));
3099 if Ekind
(Def_Id
) = E_Variable
3101 Ekind
(Def_Id
) = E_Constant
3103 -- We do not permit Import to apply to a renaming declaration
3105 if Present
(Renamed_Object
(Def_Id
)) then
3107 ("pragma% not allowed for object renaming", Arg2
);
3109 -- User initialization is not allowed for imported object, but
3110 -- the object declaration may contain a default initialization,
3111 -- that will be discarded. Note that an explicit initialization
3112 -- only counts if it comes from source, otherwise it is simply
3113 -- the code generator making an implicit initialization explicit.
3115 elsif Present
(Expression
(Parent
(Def_Id
)))
3116 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
3118 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3120 ("no initialization allowed for declaration of& #",
3121 "\imported entities cannot be initialized (RM B.1(24))",
3125 Set_Imported
(Def_Id
);
3126 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3128 -- Note that we do not set Is_Public here. That's because we
3129 -- only want to set if if there is no address clause, and we
3130 -- don't know that yet, so we delay that processing till
3133 -- pragma Import completes deferred constants
3135 if Ekind
(Def_Id
) = E_Constant
then
3136 Set_Has_Completion
(Def_Id
);
3139 -- It is not possible to import a constant of an unconstrained
3140 -- array type (e.g. string) because there is no simple way to
3141 -- write a meaningful subtype for it.
3143 if Is_Array_Type
(Etype
(Def_Id
))
3144 and then not Is_Constrained
(Etype
(Def_Id
))
3147 ("imported constant& must have a constrained subtype",
3152 elsif Is_Subprogram
(Def_Id
)
3153 or else Is_Generic_Subprogram
(Def_Id
)
3155 -- If the name is overloaded, pragma applies to all of the
3156 -- denoted entities in the same declarative part.
3159 while Present
(Hom_Id
) loop
3160 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
3162 -- Ignore inherited subprograms because the pragma will
3163 -- apply to the parent operation, which is the one called.
3165 if Is_Overloadable
(Def_Id
)
3166 and then Present
(Alias
(Def_Id
))
3170 -- If it is not a subprogram, it must be in an outer
3171 -- scope and pragma does not apply.
3173 elsif not Is_Subprogram
(Def_Id
)
3174 and then not Is_Generic_Subprogram
(Def_Id
)
3178 -- Verify that the homonym is in the same declarative
3179 -- part (not just the same scope).
3181 elsif Parent
(Unit_Declaration_Node
(Def_Id
)) /= Parent
(N
)
3182 and then Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
3187 Set_Imported
(Def_Id
);
3189 -- Special processing for Convention_Intrinsic
3191 if C
= Convention_Intrinsic
then
3193 -- Link_Name argument not allowed for intrinsic
3196 and then Chars
(Arg3
) = Name_Link_Name
3201 if Present
(Arg4
) then
3203 ("Link_Name argument not allowed for " &
3208 Set_Is_Intrinsic_Subprogram
(Def_Id
);
3210 -- If no external name is present, then check that
3211 -- this is a valid intrinsic subprogram. If an external
3212 -- name is present, then this is handled by the back end.
3215 Check_Intrinsic_Subprogram
(Def_Id
, Expression
(Arg2
));
3219 -- All interfaced procedures need an external symbol
3220 -- created for them since they are always referenced
3221 -- from another object file.
3223 Set_Is_Public
(Def_Id
);
3225 -- Verify that the subprogram does not have a completion
3226 -- through a renaming declaration. For other completions
3227 -- the pragma appears as a too late representation.
3230 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Def_Id
);
3234 and then Nkind
(Decl
) = N_Subprogram_Declaration
3235 and then Present
(Corresponding_Body
(Decl
))
3238 (Unit_Declaration_Node
3239 (Corresponding_Body
(Decl
))) =
3240 N_Subprogram_Renaming_Declaration
3242 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3244 ("cannot import&, renaming already provided for " &
3245 "declaration #", N
, Def_Id
);
3249 Set_Has_Completion
(Def_Id
);
3250 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3253 if Is_Compilation_Unit
(Hom_Id
) then
3255 -- Its possible homonyms are not affected by the pragma.
3256 -- Such homonyms might be present in the context of other
3257 -- units being compiled.
3262 Hom_Id
:= Homonym
(Hom_Id
);
3266 -- When the convention is Java or CIL, we also allow Import to be
3267 -- given for packages, generic packages, exceptions, and record
3270 elsif (C
= Convention_Java
or else C
= Convention_CIL
)
3272 (Ekind
(Def_Id
) = E_Package
3273 or else Ekind
(Def_Id
) = E_Generic_Package
3274 or else Ekind
(Def_Id
) = E_Exception
3275 or else Nkind
(Parent
(Def_Id
)) = N_Component_Declaration
)
3277 Set_Imported
(Def_Id
);
3278 Set_Is_Public
(Def_Id
);
3279 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3281 -- Import a CPP class
3283 elsif Is_Record_Type
(Def_Id
)
3284 and then C
= Convention_CPP
3286 if not Is_Tagged_Type
(Def_Id
) then
3287 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3288 Error_Pragma_Arg
("imported 'C'P'P type must be tagged", Arg2
);
3291 -- Types treated as CPP classes are treated as limited, but we
3292 -- don't require them to be declared this way. A warning is
3293 -- issued to encourage the user to declare them as limited.
3294 -- This is not an error, for compatibility reasons, because
3295 -- these types have been supported this way for some time.
3297 if not Is_Limited_Type
(Def_Id
) then
3299 ("imported 'C'P'P type should be " &
3300 "explicitly declared limited?",
3301 Get_Pragma_Arg
(Arg2
));
3303 ("\type will be considered limited",
3304 Get_Pragma_Arg
(Arg2
));
3307 Set_Is_CPP_Class
(Def_Id
);
3308 Set_Is_Limited_Record
(Def_Id
);
3313 ("second argument of pragma% must be object or subprogram",
3317 -- If this pragma applies to a compilation unit, then the unit,
3318 -- which is a subprogram, does not require (or allow) a body.
3319 -- We also do not need to elaborate imported procedures.
3321 if Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
3323 Cunit
: constant Node_Id
:= Parent
(Parent
(N
));
3325 Set_Body_Required
(Cunit
, False);
3328 end Process_Import_Or_Interface
;
3330 --------------------
3331 -- Process_Inline --
3332 --------------------
3334 procedure Process_Inline
(Active
: Boolean) is
3340 Effective
: Boolean := False;
3342 procedure Make_Inline
(Subp
: Entity_Id
);
3343 -- Subp is the defining unit name of the subprogram
3344 -- declaration. Set the flag, as well as the flag in the
3345 -- corresponding body, if there is one present.
3347 procedure Set_Inline_Flags
(Subp
: Entity_Id
);
3348 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp
3350 function Inlining_Not_Possible
(Subp
: Entity_Id
) return Boolean;
3351 -- Returns True if it can be determined at this stage that inlining
3352 -- is not possible, for examle if the body is available and contains
3353 -- exception handlers, we prevent inlining, since otherwise we can
3354 -- get undefined symbols at link time. This function also emits a
3355 -- warning if front-end inlining is enabled and the pragma appears
3357 -- ??? is business with link symbols still valid, or does it relate
3358 -- to front end ZCX which is being phased out ???
3360 ---------------------------
3361 -- Inlining_Not_Possible --
3362 ---------------------------
3364 function Inlining_Not_Possible
(Subp
: Entity_Id
) return Boolean is
3365 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Subp
);
3369 if Nkind
(Decl
) = N_Subprogram_Body
then
3370 Stats
:= Handled_Statement_Sequence
(Decl
);
3371 return Present
(Exception_Handlers
(Stats
))
3372 or else Present
(At_End_Proc
(Stats
));
3374 elsif Nkind
(Decl
) = N_Subprogram_Declaration
3375 and then Present
(Corresponding_Body
(Decl
))
3377 if Front_End_Inlining
3378 and then Analyzed
(Corresponding_Body
(Decl
))
3380 Error_Msg_N
("pragma appears too late, ignored?", N
);
3383 -- If the subprogram is a renaming as body, the body is
3384 -- just a call to the renamed subprogram, and inlining is
3385 -- trivially possible.
3388 Nkind
(Unit_Declaration_Node
(Corresponding_Body
(Decl
))) =
3389 N_Subprogram_Renaming_Declaration
3395 Handled_Statement_Sequence
3396 (Unit_Declaration_Node
(Corresponding_Body
(Decl
)));
3399 Present
(Exception_Handlers
(Stats
))
3400 or else Present
(At_End_Proc
(Stats
));
3404 -- If body is not available, assume the best, the check is
3405 -- performed again when compiling enclosing package bodies.
3409 end Inlining_Not_Possible
;
3415 procedure Make_Inline
(Subp
: Entity_Id
) is
3416 Kind
: constant Entity_Kind
:= Ekind
(Subp
);
3417 Inner_Subp
: Entity_Id
:= Subp
;
3420 if Etype
(Subp
) = Any_Type
then
3423 -- If inlining is not possible, for now do not treat as an error
3425 elsif Inlining_Not_Possible
(Subp
) then
3429 -- Here we have a candidate for inlining, but we must exclude
3430 -- derived operations. Otherwise we will end up trying to
3431 -- inline a phantom declaration, and the result would be to
3432 -- drag in a body which has no direct inlining associated with
3433 -- it. That would not only be inefficient but would also result
3434 -- in the backend doing cross-unit inlining in cases where it
3435 -- was definitely inappropriate to do so.
3437 -- However, a simple Comes_From_Source test is insufficient,
3438 -- since we do want to allow inlining of generic instances,
3439 -- which also do not come from source. Predefined operators do
3440 -- not come from source but are not inlineable either.
3442 elsif not Comes_From_Source
(Subp
)
3443 and then not Is_Generic_Instance
(Subp
)
3444 and then Scope
(Subp
) /= Standard_Standard
3449 -- The referenced entity must either be the enclosing entity,
3450 -- or an entity declared within the current open scope.
3452 elsif Present
(Scope
(Subp
))
3453 and then Scope
(Subp
) /= Current_Scope
3454 and then Subp
/= Current_Scope
3457 ("argument of% must be entity in current scope", Assoc
);
3461 -- Processing for procedure, operator or function.
3462 -- If subprogram is aliased (as for an instance) indicate
3463 -- that the renamed entity (if declared in the same unit)
3466 if Is_Subprogram
(Subp
) then
3467 while Present
(Alias
(Inner_Subp
)) loop
3468 Inner_Subp
:= Alias
(Inner_Subp
);
3471 if In_Same_Source_Unit
(Subp
, Inner_Subp
) then
3472 Set_Inline_Flags
(Inner_Subp
);
3474 Decl
:= Parent
(Parent
(Inner_Subp
));
3476 if Nkind
(Decl
) = N_Subprogram_Declaration
3477 and then Present
(Corresponding_Body
(Decl
))
3479 Set_Inline_Flags
(Corresponding_Body
(Decl
));
3485 -- For a generic subprogram set flag as well, for use at
3486 -- the point of instantiation, to determine whether the
3487 -- body should be generated.
3489 elsif Is_Generic_Subprogram
(Subp
) then
3490 Set_Inline_Flags
(Subp
);
3493 -- Literals are by definition inlined
3495 elsif Kind
= E_Enumeration_Literal
then
3498 -- Anything else is an error
3502 ("expect subprogram name for pragma%", Assoc
);
3506 ----------------------
3507 -- Set_Inline_Flags --
3508 ----------------------
3510 procedure Set_Inline_Flags
(Subp
: Entity_Id
) is
3513 Set_Is_Inlined
(Subp
, True);
3516 if not Has_Pragma_Inline
(Subp
) then
3517 Set_Has_Pragma_Inline
(Subp
);
3518 Set_Next_Rep_Item
(N
, First_Rep_Item
(Subp
));
3519 Set_First_Rep_Item
(Subp
, N
);
3522 end Set_Inline_Flags
;
3524 -- Start of processing for Process_Inline
3527 Check_No_Identifiers
;
3528 Check_At_Least_N_Arguments
(1);
3531 Inline_Processing_Required
:= True;
3535 while Present
(Assoc
) loop
3536 Subp_Id
:= Expression
(Assoc
);
3540 if Is_Entity_Name
(Subp_Id
) then
3541 Subp
:= Entity
(Subp_Id
);
3543 if Subp
= Any_Id
then
3545 -- If previous error, avoid cascaded errors
3553 while Present
(Homonym
(Subp
))
3554 and then Scope
(Homonym
(Subp
)) = Current_Scope
3556 Make_Inline
(Homonym
(Subp
));
3557 Subp
:= Homonym
(Subp
);
3564 ("inappropriate argument for pragma%", Assoc
);
3567 and then Warn_On_Redundant_Constructs
3569 if Inlining_Not_Possible
(Subp
) then
3571 ("pragma Inline for& is ignored?", N
, Entity
(Subp_Id
));
3574 ("pragma Inline for& is redundant?", N
, Entity
(Subp_Id
));
3582 ----------------------------
3583 -- Process_Interface_Name --
3584 ----------------------------
3586 procedure Process_Interface_Name
3587 (Subprogram_Def
: Entity_Id
;
3593 String_Val
: String_Id
;
3595 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
);
3596 -- SN is a string literal node for an interface name. This routine
3597 -- performs some minimal checks that the name is reasonable. In
3598 -- particular that no spaces or other obviously incorrect characters
3599 -- appear. This is only a warning, since any characters are allowed.
3601 ----------------------------------
3602 -- Check_Form_Of_Interface_Name --
3603 ----------------------------------
3605 procedure Check_Form_Of_Interface_Name
(SN
: Node_Id
) is
3606 S
: constant String_Id
:= Strval
(Expr_Value_S
(SN
));
3607 SL
: constant Nat
:= String_Length
(S
);
3612 Error_Msg_N
("interface name cannot be null string", SN
);
3615 for J
in 1 .. SL
loop
3616 C
:= Get_String_Char
(S
, J
);
3618 if Warn_On_Export_Import
3620 (not In_Character_Range
(C
)
3621 or else (Get_Character
(C
) = ' '
3622 and then VM_Target
/= CLI_Target
)
3623 or else Get_Character
(C
) = ',')
3626 ("?interface name contains illegal character", SN
);
3629 end Check_Form_Of_Interface_Name
;
3631 -- Start of processing for Process_Interface_Name
3634 if No
(Link_Arg
) then
3635 if No
(Ext_Arg
) then
3636 if VM_Target
= CLI_Target
3637 and then Ekind
(Subprogram_Def
) = E_Package
3638 and then Nkind
(Parent
(Subprogram_Def
)) =
3639 N_Package_Specification
3640 and then Present
(Generic_Parent
(Parent
(Subprogram_Def
)))
3645 (Generic_Parent
(Parent
(Subprogram_Def
))));
3650 elsif Chars
(Ext_Arg
) = Name_Link_Name
then
3652 Link_Nam
:= Expression
(Ext_Arg
);
3655 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
3656 Ext_Nam
:= Expression
(Ext_Arg
);
3661 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
3662 Check_Optional_Identifier
(Link_Arg
, Name_Link_Name
);
3663 Ext_Nam
:= Expression
(Ext_Arg
);
3664 Link_Nam
:= Expression
(Link_Arg
);
3667 -- Check expressions for external name and link name are static
3669 if Present
(Ext_Nam
) then
3670 Check_Arg_Is_Static_Expression
(Ext_Nam
, Standard_String
);
3671 Check_Form_Of_Interface_Name
(Ext_Nam
);
3673 -- Verify that the external name is not the name of a local
3674 -- entity, which would hide the imported one and lead to
3675 -- run-time surprises. The problem can only arise for entities
3676 -- declared in a package body (otherwise the external name is
3677 -- fully qualified and won't conflict).
3685 if Prag_Id
= Pragma_Import
then
3686 String_To_Name_Buffer
(Strval
(Expr_Value_S
(Ext_Nam
)));
3688 E
:= Entity_Id
(Get_Name_Table_Info
(Nam
));
3690 if Nam
/= Chars
(Subprogram_Def
)
3691 and then Present
(E
)
3692 and then not Is_Overloadable
(E
)
3693 and then Is_Immediately_Visible
(E
)
3694 and then not Is_Imported
(E
)
3695 and then Ekind
(Scope
(E
)) = E_Package
3698 while Present
(Par
) loop
3699 if Nkind
(Par
) = N_Package_Body
then
3700 Error_Msg_Sloc
:= Sloc
(E
);
3702 ("imported entity is hidden by & declared#",
3707 Par
:= Parent
(Par
);
3714 if Present
(Link_Nam
) then
3715 Check_Arg_Is_Static_Expression
(Link_Nam
, Standard_String
);
3716 Check_Form_Of_Interface_Name
(Link_Nam
);
3719 -- If there is no link name, just set the external name
3721 if No
(Link_Nam
) then
3722 Link_Nam
:= Adjust_External_Name_Case
(Expr_Value_S
(Ext_Nam
));
3724 -- For the Link_Name case, the given literal is preceded by an
3725 -- asterisk, which indicates to GCC that the given name should
3726 -- be taken literally, and in particular that no prepending of
3727 -- underlines should occur, even in systems where this is the
3733 if VM_Target
= No_VM
then
3734 Store_String_Char
(Get_Char_Code
('*'));
3737 String_Val
:= Strval
(Expr_Value_S
(Link_Nam
));
3738 Store_String_Chars
(String_Val
);
3740 Make_String_Literal
(Sloc
(Link_Nam
),
3741 Strval
=> End_String
);
3744 Set_Encoded_Interface_Name
3745 (Get_Base_Subprogram
(Subprogram_Def
), Link_Nam
);
3746 Check_Duplicated_Export_Name
(Link_Nam
);
3747 end Process_Interface_Name
;
3749 -----------------------------------------
3750 -- Process_Interrupt_Or_Attach_Handler --
3751 -----------------------------------------
3753 procedure Process_Interrupt_Or_Attach_Handler
is
3754 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
3755 Handler_Proc
: constant Entity_Id
:= Entity
(Arg1_X
);
3756 Proc_Scope
: constant Entity_Id
:= Scope
(Handler_Proc
);
3759 Set_Is_Interrupt_Handler
(Handler_Proc
);
3761 -- If the pragma is not associated with a handler procedure
3762 -- within a protected type, then it must be for a nonprotected
3763 -- procedure for the AAMP target, in which case we don't
3764 -- associate a representation item with the procedure's scope.
3766 if Ekind
(Proc_Scope
) = E_Protected_Type
then
3767 if Prag_Id
= Pragma_Interrupt_Handler
3769 Prag_Id
= Pragma_Attach_Handler
3771 Record_Rep_Item
(Proc_Scope
, N
);
3774 end Process_Interrupt_Or_Attach_Handler
;
3776 --------------------------------------------------
3777 -- Process_Restrictions_Or_Restriction_Warnings --
3778 --------------------------------------------------
3780 -- Note: some of the simple identifier cases were handled in par-prag,
3781 -- but it is harmless (and more straightforward) to simply handle all
3782 -- cases here, even if it means we repeat a bit of work in some cases.
3784 procedure Process_Restrictions_Or_Restriction_Warnings
3788 R_Id
: Restriction_Id
;
3793 procedure Check_Unit_Name
(N
: Node_Id
);
3794 -- Checks unit name parameter for No_Dependence. Returns if it has
3795 -- an appropriate form, otherwise raises pragma argument error.
3797 ---------------------
3798 -- Check_Unit_Name --
3799 ---------------------
3801 procedure Check_Unit_Name
(N
: Node_Id
) is
3803 if Nkind
(N
) = N_Selected_Component
then
3804 Check_Unit_Name
(Prefix
(N
));
3805 Check_Unit_Name
(Selector_Name
(N
));
3807 elsif Nkind
(N
) = N_Identifier
then
3812 ("wrong form for unit name for No_Dependence", N
);
3814 end Check_Unit_Name
;
3816 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
3819 Check_Ada_83_Warning
;
3820 Check_At_Least_N_Arguments
(1);
3821 Check_Valid_Configuration_Pragma
;
3824 while Present
(Arg
) loop
3826 Expr
:= Expression
(Arg
);
3828 -- Case of no restriction identifier present
3830 if Id
= No_Name
then
3831 if Nkind
(Expr
) /= N_Identifier
then
3833 ("invalid form for restriction", Arg
);
3838 (Process_Restriction_Synonyms
(Expr
));
3840 if R_Id
not in All_Boolean_Restrictions
then
3842 ("invalid restriction identifier", Arg
);
3845 if Implementation_Restriction
(R_Id
) then
3847 (No_Implementation_Restrictions
, Arg
);
3850 -- If this is a warning, then set the warning unless we already
3851 -- have a real restriction active (we never want a warning to
3852 -- override a real restriction).
3855 if not Restriction_Active
(R_Id
) then
3856 Set_Restriction
(R_Id
, N
);
3857 Restriction_Warnings
(R_Id
) := True;
3860 -- If real restriction case, then set it and make sure that the
3861 -- restriction warning flag is off, since a real restriction
3862 -- always overrides a warning.
3865 Set_Restriction
(R_Id
, N
);
3866 Restriction_Warnings
(R_Id
) := False;
3869 -- A very special case that must be processed here: pragma
3870 -- Restrictions (No_Exceptions) turns off all run-time
3871 -- checking. This is a bit dubious in terms of the formal
3872 -- language definition, but it is what is intended by RM
3873 -- H.4(12). Restriction_Warnings never affects generated code
3874 -- so this is done only in the real restriction case.
3876 if R_Id
= No_Exceptions
and then not Warn
then
3877 Scope_Suppress
:= (others => True);
3880 -- Case of No_Dependence => unit-name. Note that the parser
3881 -- already made the necessary entry in the No_Dependence table.
3883 elsif Id
= Name_No_Dependence
then
3884 Check_Unit_Name
(Expr
);
3886 -- All other cases of restriction identifier present
3889 R_Id
:= Get_Restriction_Id
(Process_Restriction_Synonyms
(Arg
));
3890 Analyze_And_Resolve
(Expr
, Any_Integer
);
3892 if R_Id
not in All_Parameter_Restrictions
then
3894 ("invalid restriction parameter identifier", Arg
);
3896 elsif not Is_OK_Static_Expression
(Expr
) then
3897 Flag_Non_Static_Expr
3898 ("value must be static expression!", Expr
);
3901 elsif not Is_Integer_Type
(Etype
(Expr
))
3902 or else Expr_Value
(Expr
) < 0
3905 ("value must be non-negative integer", Arg
);
3908 -- Restriction pragma is active
3910 Val
:= Expr_Value
(Expr
);
3912 if not UI_Is_In_Int_Range
(Val
) then
3914 ("pragma ignored, value too large?", Arg
);
3917 -- Warning case. If the real restriction is active, then we
3918 -- ignore the request, since warning never overrides a real
3919 -- restriction. Otherwise we set the proper warning. Note that
3920 -- this circuit sets the warning again if it is already set,
3921 -- which is what we want, since the constant may have changed.
3924 if not Restriction_Active
(R_Id
) then
3926 (R_Id
, N
, Integer (UI_To_Int
(Val
)));
3927 Restriction_Warnings
(R_Id
) := True;
3930 -- Real restriction case, set restriction and make sure warning
3931 -- flag is off since real restriction always overrides warning.
3934 Set_Restriction
(R_Id
, N
, Integer (UI_To_Int
(Val
)));
3935 Restriction_Warnings
(R_Id
) := False;
3941 end Process_Restrictions_Or_Restriction_Warnings
;
3943 ---------------------------------
3944 -- Process_Suppress_Unsuppress --
3945 ---------------------------------
3947 -- Note: this procedure makes entries in the check suppress data
3948 -- structures managed by Sem. See spec of package Sem for full
3949 -- details on how we handle recording of check suppression.
3951 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean) is
3956 In_Package_Spec
: constant Boolean :=
3957 (Ekind
(Current_Scope
) = E_Package
3959 Ekind
(Current_Scope
) = E_Generic_Package
)
3960 and then not In_Package_Body
(Current_Scope
);
3962 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
);
3963 -- Used to suppress a single check on the given entity
3965 --------------------------------
3966 -- Suppress_Unsuppress_Echeck --
3967 --------------------------------
3969 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
) is
3971 Set_Checks_May_Be_Suppressed
(E
);
3973 if In_Package_Spec
then
3974 Push_Global_Suppress_Stack_Entry
3977 Suppress
=> Suppress_Case
);
3980 Push_Local_Suppress_Stack_Entry
3983 Suppress
=> Suppress_Case
);
3986 -- If this is a first subtype, and the base type is distinct,
3987 -- then also set the suppress flags on the base type.
3989 if Is_First_Subtype
(E
)
3990 and then Etype
(E
) /= E
3992 Suppress_Unsuppress_Echeck
(Etype
(E
), C
);
3994 end Suppress_Unsuppress_Echeck
;
3996 -- Start of processing for Process_Suppress_Unsuppress
3999 -- Suppress/Unsuppress can appear as a configuration pragma,
4000 -- or in a declarative part or a package spec (RM 11.5(5))
4002 if not Is_Configuration_Pragma
then
4003 Check_Is_In_Decl_Part_Or_Package_Spec
;
4006 Check_At_Least_N_Arguments
(1);
4007 Check_At_Most_N_Arguments
(2);
4008 Check_No_Identifier
(Arg1
);
4009 Check_Arg_Is_Identifier
(Arg1
);
4011 C
:= Get_Check_Id
(Chars
(Expression
(Arg1
)));
4013 if C
= No_Check_Id
then
4015 ("argument of pragma% is not valid check name", Arg1
);
4018 if not Suppress_Case
4019 and then (C
= All_Checks
or else C
= Overflow_Check
)
4021 Opt
.Overflow_Checks_Unsuppressed
:= True;
4024 if Arg_Count
= 1 then
4026 -- Make an entry in the local scope suppress table. This is the
4027 -- table that directly shows the current value of the scope
4028 -- suppress check for any check id value.
4030 if C
= All_Checks
then
4032 -- For All_Checks, we set all specific predefined checks with
4033 -- the exception of Elaboration_Check, which is handled
4034 -- specially because of not wanting All_Checks to have the
4035 -- effect of deactivating static elaboration order processing.
4037 for J
in Scope_Suppress
'Range loop
4038 if J
/= Elaboration_Check
then
4039 Scope_Suppress
(J
) := Suppress_Case
;
4043 -- If not All_Checks, and predefined check, then set appropriate
4044 -- scope entry. Note that we will set Elaboration_Check if this
4045 -- is explicitly specified.
4047 elsif C
in Predefined_Check_Id
then
4048 Scope_Suppress
(C
) := Suppress_Case
;
4051 -- Also make an entry in the Local_Entity_Suppress table
4053 Push_Local_Suppress_Stack_Entry
4056 Suppress
=> Suppress_Case
);
4058 -- Case of two arguments present, where the check is suppressed for
4059 -- a specified entity (given as the second argument of the pragma)
4062 Check_Optional_Identifier
(Arg2
, Name_On
);
4063 E_Id
:= Expression
(Arg2
);
4066 if not Is_Entity_Name
(E_Id
) then
4068 ("second argument of pragma% must be entity name", Arg2
);
4077 -- Enforce RM 11.5(7) which requires that for a pragma that
4078 -- appears within a package spec, the named entity must be
4079 -- within the package spec. We allow the package name itself
4080 -- to be mentioned since that makes sense, although it is not
4081 -- strictly allowed by 11.5(7).
4084 and then E
/= Current_Scope
4085 and then Scope
(E
) /= Current_Scope
4088 ("entity in pragma% is not in package spec (RM 11.5(7))",
4092 -- Loop through homonyms. As noted below, in the case of a package
4093 -- spec, only homonyms within the package spec are considered.
4096 Suppress_Unsuppress_Echeck
(E
, C
);
4098 if Is_Generic_Instance
(E
)
4099 and then Is_Subprogram
(E
)
4100 and then Present
(Alias
(E
))
4102 Suppress_Unsuppress_Echeck
(Alias
(E
), C
);
4105 -- Move to next homonym
4110 -- If we are within a package specification, the
4111 -- pragma only applies to homonyms in the same scope.
4113 exit when In_Package_Spec
4114 and then Scope
(E
) /= Current_Scope
;
4117 end Process_Suppress_Unsuppress
;
4123 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
) is
4125 if Is_Imported
(E
) then
4127 ("cannot export entity& that was previously imported", Arg
);
4129 elsif Present
(Address_Clause
(E
)) then
4131 ("cannot export entity& that has an address clause", Arg
);
4134 Set_Is_Exported
(E
);
4136 -- Generate a reference for entity explicitly, because the
4137 -- identifier may be overloaded and name resolution will not
4140 Generate_Reference
(E
, Arg
);
4142 -- Deal with exporting non-library level entity
4144 if not Is_Library_Level_Entity
(E
) then
4146 -- Not allowed at all for subprograms
4148 if Is_Subprogram
(E
) then
4149 Error_Pragma_Arg
("local subprogram& cannot be exported", Arg
);
4151 -- Otherwise set public and statically allocated
4155 Set_Is_Statically_Allocated
(E
);
4157 -- Warn if the corresponding W flag is set and the pragma
4158 -- comes from source. The latter may not be true e.g. on
4159 -- VMS where we expand export pragmas for exception codes
4160 -- associated with imported or exported exceptions. We do
4161 -- not want to generate a warning for something that the
4162 -- user did not write.
4164 if Warn_On_Export_Import
4165 and then Comes_From_Source
(Arg
)
4168 ("?& has been made static as a result of Export", Arg
, E
);
4170 ("\this usage is non-standard and non-portable", Arg
);
4175 if Warn_On_Export_Import
and then Is_Type
(E
) then
4177 ("exporting a type has no effect?", Arg
, E
);
4180 if Warn_On_Export_Import
and Inside_A_Generic
then
4182 ("all instances of& will have the same external name?", Arg
, E
);
4186 ----------------------------------------------
4187 -- Set_Extended_Import_Export_External_Name --
4188 ----------------------------------------------
4190 procedure Set_Extended_Import_Export_External_Name
4191 (Internal_Ent
: Entity_Id
;
4192 Arg_External
: Node_Id
)
4194 Old_Name
: constant Node_Id
:= Interface_Name
(Internal_Ent
);
4198 if No
(Arg_External
) then
4202 Check_Arg_Is_External_Name
(Arg_External
);
4204 if Nkind
(Arg_External
) = N_String_Literal
then
4205 if String_Length
(Strval
(Arg_External
)) = 0 then
4208 New_Name
:= Adjust_External_Name_Case
(Arg_External
);
4211 elsif Nkind
(Arg_External
) = N_Identifier
then
4212 New_Name
:= Get_Default_External_Name
(Arg_External
);
4214 -- Check_Arg_Is_External_Name should let through only
4215 -- identifiers and string literals or static string
4216 -- expressions (which are folded to string literals).
4219 raise Program_Error
;
4222 -- If we already have an external name set (by a prior normal
4223 -- Import or Export pragma), then the external names must match
4225 if Present
(Interface_Name
(Internal_Ent
)) then
4226 Check_Matching_Internal_Names
: declare
4227 S1
: constant String_Id
:= Strval
(Old_Name
);
4228 S2
: constant String_Id
:= Strval
(New_Name
);
4231 -- Called if names do not match
4237 procedure Mismatch
is
4239 Error_Msg_Sloc
:= Sloc
(Old_Name
);
4241 ("external name does not match that given #",
4245 -- Start of processing for Check_Matching_Internal_Names
4248 if String_Length
(S1
) /= String_Length
(S2
) then
4252 for J
in 1 .. String_Length
(S1
) loop
4253 if Get_String_Char
(S1
, J
) /= Get_String_Char
(S2
, J
) then
4258 end Check_Matching_Internal_Names
;
4260 -- Otherwise set the given name
4263 Set_Encoded_Interface_Name
(Internal_Ent
, New_Name
);
4264 Check_Duplicated_Export_Name
(New_Name
);
4266 end Set_Extended_Import_Export_External_Name
;
4272 procedure Set_Imported
(E
: Entity_Id
) is
4274 -- Error message if already imported or exported
4276 if Is_Exported
(E
) or else Is_Imported
(E
) then
4277 if Is_Exported
(E
) then
4278 Error_Msg_NE
("entity& was previously exported", N
, E
);
4280 Error_Msg_NE
("entity& was previously imported", N
, E
);
4283 Error_Msg_Name_1
:= Chars
(N
);
4285 ("\(pragma% applies to all previous entities)", N
);
4287 Error_Msg_Sloc
:= Sloc
(E
);
4288 Error_Msg_NE
("\import not allowed for& declared#", N
, E
);
4290 -- Here if not previously imported or exported, OK to import
4293 Set_Is_Imported
(E
);
4295 -- If the entity is an object that is not at the library
4296 -- level, then it is statically allocated. We do not worry
4297 -- about objects with address clauses in this context since
4298 -- they are not really imported in the linker sense.
4301 and then not Is_Library_Level_Entity
(E
)
4302 and then No
(Address_Clause
(E
))
4304 Set_Is_Statically_Allocated
(E
);
4309 -------------------------
4310 -- Set_Mechanism_Value --
4311 -------------------------
4313 -- Note: the mechanism name has not been analyzed (and cannot indeed
4314 -- be analyzed, since it is semantic nonsense), so we get it in the
4315 -- exact form created by the parser.
4317 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
) is
4321 procedure Bad_Class
;
4322 -- Signal bad descriptor class name
4324 procedure Bad_Mechanism
;
4325 -- Signal bad mechanism name
4331 procedure Bad_Class
is
4333 Error_Pragma_Arg
("unrecognized descriptor class name", Class
);
4336 -------------------------
4337 -- Bad_Mechanism_Value --
4338 -------------------------
4340 procedure Bad_Mechanism
is
4342 Error_Pragma_Arg
("unrecognized mechanism name", Mech_Name
);
4345 -- Start of processing for Set_Mechanism_Value
4348 if Mechanism
(Ent
) /= Default_Mechanism
then
4350 ("mechanism for & has already been set", Mech_Name
, Ent
);
4353 -- MECHANISM_NAME ::= value | reference | descriptor
4355 if Nkind
(Mech_Name
) = N_Identifier
then
4356 if Chars
(Mech_Name
) = Name_Value
then
4357 Set_Mechanism
(Ent
, By_Copy
);
4360 elsif Chars
(Mech_Name
) = Name_Reference
then
4361 Set_Mechanism
(Ent
, By_Reference
);
4364 elsif Chars
(Mech_Name
) = Name_Descriptor
then
4365 Check_VMS
(Mech_Name
);
4366 Set_Mechanism
(Ent
, By_Descriptor
);
4369 elsif Chars
(Mech_Name
) = Name_Copy
then
4371 ("bad mechanism name, Value assumed", Mech_Name
);
4377 -- MECHANISM_NAME ::= descriptor (CLASS_NAME)
4378 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4380 -- Note: this form is parsed as an indexed component
4382 elsif Nkind
(Mech_Name
) = N_Indexed_Component
then
4383 Class
:= First
(Expressions
(Mech_Name
));
4385 if Nkind
(Prefix
(Mech_Name
)) /= N_Identifier
4386 or else Chars
(Prefix
(Mech_Name
)) /= Name_Descriptor
4387 or else Present
(Next
(Class
))
4392 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME)
4393 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4395 -- Note: this form is parsed as a function call
4397 elsif Nkind
(Mech_Name
) = N_Function_Call
then
4399 Param
:= First
(Parameter_Associations
(Mech_Name
));
4401 if Nkind
(Name
(Mech_Name
)) /= N_Identifier
4402 or else Chars
(Name
(Mech_Name
)) /= Name_Descriptor
4403 or else Present
(Next
(Param
))
4404 or else No
(Selector_Name
(Param
))
4405 or else Chars
(Selector_Name
(Param
)) /= Name_Class
4409 Class
:= Explicit_Actual_Parameter
(Param
);
4416 -- Fall through here with Class set to descriptor class name
4418 Check_VMS
(Mech_Name
);
4420 if Nkind
(Class
) /= N_Identifier
then
4423 elsif Chars
(Class
) = Name_UBS
then
4424 Set_Mechanism
(Ent
, By_Descriptor_UBS
);
4426 elsif Chars
(Class
) = Name_UBSB
then
4427 Set_Mechanism
(Ent
, By_Descriptor_UBSB
);
4429 elsif Chars
(Class
) = Name_UBA
then
4430 Set_Mechanism
(Ent
, By_Descriptor_UBA
);
4432 elsif Chars
(Class
) = Name_S
then
4433 Set_Mechanism
(Ent
, By_Descriptor_S
);
4435 elsif Chars
(Class
) = Name_SB
then
4436 Set_Mechanism
(Ent
, By_Descriptor_SB
);
4438 elsif Chars
(Class
) = Name_A
then
4439 Set_Mechanism
(Ent
, By_Descriptor_A
);
4441 elsif Chars
(Class
) = Name_NCA
then
4442 Set_Mechanism
(Ent
, By_Descriptor_NCA
);
4447 end Set_Mechanism_Value
;
4449 ---------------------------
4450 -- Set_Ravenscar_Profile --
4451 ---------------------------
4453 -- The tasks to be done here are
4455 -- Set required policies
4457 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4458 -- pragma Locking_Policy (Ceiling_Locking)
4460 -- Set Detect_Blocking mode
4462 -- Set required restrictions (see System.Rident for detailed list)
4464 procedure Set_Ravenscar_Profile
(N
: Node_Id
) is
4466 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4468 if Task_Dispatching_Policy
/= ' '
4469 and then Task_Dispatching_Policy
/= 'F'
4471 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
4472 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4474 -- Set the FIFO_Within_Priorities policy, but always preserve
4475 -- System_Location since we like the error message with the run time
4479 Task_Dispatching_Policy
:= 'F';
4481 if Task_Dispatching_Policy_Sloc
/= System_Location
then
4482 Task_Dispatching_Policy_Sloc
:= Loc
;
4486 -- pragma Locking_Policy (Ceiling_Locking)
4488 if Locking_Policy
/= ' '
4489 and then Locking_Policy
/= 'C'
4491 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
4492 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4494 -- Set the Ceiling_Locking policy, but preserve System_Location since
4495 -- we like the error message with the run time name.
4498 Locking_Policy
:= 'C';
4500 if Locking_Policy_Sloc
/= System_Location
then
4501 Locking_Policy_Sloc
:= Loc
;
4505 -- pragma Detect_Blocking
4507 Detect_Blocking
:= True;
4509 -- Set the corresponding restrictions
4511 Set_Profile_Restrictions
(Ravenscar
, N
, Warn
=> False);
4512 end Set_Ravenscar_Profile
;
4514 -- Start of processing for Analyze_Pragma
4517 -- Deal with unrecognized pragma
4519 if not Is_Pragma_Name
(Chars
(N
)) then
4520 if Warn_On_Unrecognized_Pragma
then
4521 Error_Msg_Name_1
:= Chars
(N
);
4522 Error_Msg_N
("?unrecognized pragma%!", N
);
4524 for PN
in First_Pragma_Name
.. Last_Pragma_Name
loop
4525 if Is_Bad_Spelling_Of
4526 (Get_Name_String
(Chars
(N
)),
4527 Get_Name_String
(PN
))
4529 Error_Msg_Name_1
:= PN
;
4530 Error_Msg_N
("\?possible misspelling of %!", N
);
4539 -- Here to start processing for recognized pragma
4541 Prag_Id
:= Get_Pragma_Id
(Chars
(N
));
4550 if Present
(Pragma_Argument_Associations
(N
)) then
4551 Arg1
:= First
(Pragma_Argument_Associations
(N
));
4553 if Present
(Arg1
) then
4554 Arg2
:= Next
(Arg1
);
4556 if Present
(Arg2
) then
4557 Arg3
:= Next
(Arg2
);
4559 if Present
(Arg3
) then
4560 Arg4
:= Next
(Arg3
);
4566 -- Count number of arguments
4573 while Present
(Arg_Node
) loop
4574 Arg_Count
:= Arg_Count
+ 1;
4579 -- An enumeration type defines the pragmas that are supported by the
4580 -- implementation. Get_Pragma_Id (in package Prag) transorms a name
4581 -- into the corresponding enumeration value for the following case.
4589 -- pragma Abort_Defer;
4591 when Pragma_Abort_Defer
=>
4593 Check_Arg_Count
(0);
4595 -- The only required semantic processing is to check the
4596 -- placement. This pragma must appear at the start of the
4597 -- statement sequence of a handled sequence of statements.
4599 if Nkind
(Parent
(N
)) /= N_Handled_Sequence_Of_Statements
4600 or else N
/= First
(Statements
(Parent
(N
)))
4611 -- Note: this pragma also has some specific processing in Par.Prag
4612 -- because we want to set the Ada version mode during parsing.
4614 when Pragma_Ada_83
=>
4616 Check_Arg_Count
(0);
4618 -- We really should check unconditionally for proper configuration
4619 -- pragma placement, since we really don't want mixed Ada modes
4620 -- within a single unit, and the GNAT reference manual has always
4621 -- said this was a configuration pragma, but we did not check and
4622 -- are hesitant to add the check now.
4624 -- However, we really cannot tolerate mixing Ada 2005 with Ada 83
4625 -- or Ada 95, so we must check if we are in Ada 2005 mode.
4627 if Ada_Version
>= Ada_05
then
4628 Check_Valid_Configuration_Pragma
;
4631 -- Now set Ada 83 mode
4633 Ada_Version
:= Ada_83
;
4634 Ada_Version_Explicit
:= Ada_Version
;
4642 -- Note: this pragma also has some specific processing in Par.Prag
4643 -- because we want to set the Ada 83 version mode during parsing.
4645 when Pragma_Ada_95
=>
4647 Check_Arg_Count
(0);
4649 -- We really should check unconditionally for proper configuration
4650 -- pragma placement, since we really don't want mixed Ada modes
4651 -- within a single unit, and the GNAT reference manual has always
4652 -- said this was a configuration pragma, but we did not check and
4653 -- are hesitant to add the check now.
4655 -- However, we really cannot tolerate mixing Ada 2005 with Ada 83
4656 -- or Ada 95, so we must check if we are in Ada 2005 mode.
4658 if Ada_Version
>= Ada_05
then
4659 Check_Valid_Configuration_Pragma
;
4662 -- Now set Ada 95 mode
4664 Ada_Version
:= Ada_95
;
4665 Ada_Version_Explicit
:= Ada_Version
;
4667 ---------------------
4668 -- Ada_05/Ada_2005 --
4669 ---------------------
4672 -- pragma Ada_05 (LOCAL_NAME);
4675 -- pragma Ada_2005 (LOCAL_NAME):
4677 -- Note: these pragma also have some specific processing in Par.Prag
4678 -- because we want to set the Ada 2005 version mode during parsing.
4680 when Pragma_Ada_05 | Pragma_Ada_2005
=> declare
4686 if Arg_Count
= 1 then
4687 Check_Arg_Is_Local_Name
(Arg1
);
4688 E_Id
:= Expression
(Arg1
);
4690 if Etype
(E_Id
) = Any_Type
then
4694 Set_Is_Ada_2005_Only
(Entity
(E_Id
));
4697 Check_Arg_Count
(0);
4699 -- For Ada_2005 we unconditionally enforce the documented
4700 -- configuration pragma placement, since we do not want to
4701 -- tolerate mixed modes in a unit involving Ada 2005. That
4702 -- would cause real difficulties for those cases where there
4703 -- are incompatibilities between Ada 95 and Ada 2005.
4705 Check_Valid_Configuration_Pragma
;
4707 -- Now set Ada 2005 mode
4709 Ada_Version
:= Ada_05
;
4710 Ada_Version_Explicit
:= Ada_05
;
4714 ----------------------
4715 -- All_Calls_Remote --
4716 ----------------------
4718 -- pragma All_Calls_Remote [(library_package_NAME)];
4720 when Pragma_All_Calls_Remote
=> All_Calls_Remote
: declare
4721 Lib_Entity
: Entity_Id
;
4724 Check_Ada_83_Warning
;
4725 Check_Valid_Library_Unit_Pragma
;
4727 if Nkind
(N
) = N_Null_Statement
then
4731 Lib_Entity
:= Find_Lib_Unit_Name
;
4733 -- This pragma should only apply to a RCI unit (RM E.2.3(23))
4735 if Present
(Lib_Entity
)
4736 and then not Debug_Flag_U
4738 if not Is_Remote_Call_Interface
(Lib_Entity
) then
4739 Error_Pragma
("pragma% only apply to rci unit");
4741 -- Set flag for entity of the library unit
4744 Set_Has_All_Calls_Remote
(Lib_Entity
);
4748 end All_Calls_Remote
;
4754 -- pragma Annotate (IDENTIFIER {, ARG});
4755 -- ARG ::= NAME | EXPRESSION
4757 when Pragma_Annotate
=> Annotate
: begin
4759 Check_At_Least_N_Arguments
(1);
4760 Check_Arg_Is_Identifier
(Arg1
);
4768 while Present
(Arg
) loop
4769 Exp
:= Expression
(Arg
);
4772 if Is_Entity_Name
(Exp
) then
4775 elsif Nkind
(Exp
) = N_String_Literal
then
4776 Resolve
(Exp
, Standard_String
);
4778 elsif Is_Overloaded
(Exp
) then
4779 Error_Pragma_Arg
("ambiguous argument for pragma%", Exp
);
4794 -- pragma Assert ([Check =>] Boolean_EXPRESSION
4795 -- [, [Message =>] Static_String_EXPRESSION]);
4797 when Pragma_Assert
=> Assert
: declare
4802 Check_At_Least_N_Arguments
(1);
4803 Check_At_Most_N_Arguments
(2);
4804 Check_Arg_Order
((Name_Check
, Name_Message
));
4805 Check_Optional_Identifier
(Arg1
, Name_Check
);
4807 if Arg_Count
> 1 then
4808 Check_Optional_Identifier
(Arg2
, Name_Message
);
4809 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
4812 -- If expansion is active and assertions are inactive, then
4813 -- we rewrite the Assertion as:
4815 -- if False and then condition then
4819 -- The reason we do this rewriting during semantic analysis
4820 -- rather than as part of normal expansion is that we cannot
4821 -- analyze and expand the code for the boolean expression
4822 -- directly, or it may cause insertion of actions that would
4823 -- escape the attempt to suppress the assertion code.
4825 Expr
:= Expression
(Arg1
);
4827 if Expander_Active
and not Assertions_Enabled
then
4829 Make_If_Statement
(Loc
,
4832 Left_Opnd
=> New_Occurrence_Of
(Standard_False
, Loc
),
4833 Right_Opnd
=> Expr
),
4834 Then_Statements
=> New_List
(
4835 Make_Null_Statement
(Loc
))));
4839 -- Otherwise (if assertions are enabled, or if we are not
4840 -- operating with expansion active), then we just analyze
4841 -- and resolve the expression.
4844 Analyze_And_Resolve
(Expr
, Any_Boolean
);
4847 -- If assertion is of the form (X'First = literal), where X is
4848 -- formal parameter, then set Low_Bound_Known flag on this formal.
4850 if Nkind
(Expr
) = N_Op_Eq
then
4852 Right
: constant Node_Id
:= Right_Opnd
(Expr
);
4853 Left
: constant Node_Id
:= Left_Opnd
(Expr
);
4855 if Nkind
(Left
) = N_Attribute_Reference
4856 and then Attribute_Name
(Left
) = Name_First
4857 and then Is_Entity_Name
(Prefix
(Left
))
4858 and then Is_Formal
(Entity
(Prefix
(Left
)))
4859 and then Nkind
(Right
) = N_Integer_Literal
4861 Set_Low_Bound_Known
(Entity
(Prefix
(Left
)));
4867 ----------------------
4868 -- Assertion_Policy --
4869 ----------------------
4871 -- pragma Assertion_Policy (Check | Ignore)
4873 when Pragma_Assertion_Policy
=>
4875 Check_Arg_Count
(1);
4876 Check_Arg_Is_One_Of
(Arg1
, Name_Check
, Name_Ignore
);
4877 Assertions_Enabled
:= Chars
(Expression
(Arg1
)) = Name_Check
;
4883 -- pragma AST_Entry (entry_IDENTIFIER);
4885 when Pragma_AST_Entry
=> AST_Entry
: declare
4891 Check_Arg_Count
(1);
4892 Check_No_Identifiers
;
4893 Check_Arg_Is_Local_Name
(Arg1
);
4894 Ent
:= Entity
(Expression
(Arg1
));
4896 -- Note: the implementation of the AST_Entry pragma could handle
4897 -- the entry family case fine, but for now we are consistent with
4898 -- the DEC rules, and do not allow the pragma, which of course
4899 -- has the effect of also forbidding the attribute.
4901 if Ekind
(Ent
) /= E_Entry
then
4903 ("pragma% argument must be simple entry name", Arg1
);
4905 elsif Is_AST_Entry
(Ent
) then
4907 ("duplicate % pragma for entry", Arg1
);
4909 elsif Has_Homonym
(Ent
) then
4911 ("pragma% argument cannot specify overloaded entry", Arg1
);
4915 FF
: constant Entity_Id
:= First_Formal
(Ent
);
4918 if Present
(FF
) then
4919 if Present
(Next_Formal
(FF
)) then
4921 ("entry for pragma% can have only one argument",
4924 elsif Parameter_Mode
(FF
) /= E_In_Parameter
then
4926 ("entry parameter for pragma% must have mode IN",
4932 Set_Is_AST_Entry
(Ent
);
4940 -- pragma Asynchronous (LOCAL_NAME);
4942 when Pragma_Asynchronous
=> Asynchronous
: declare
4950 procedure Process_Async_Pragma
;
4951 -- Common processing for procedure and access-to-procedure case
4953 --------------------------
4954 -- Process_Async_Pragma --
4955 --------------------------
4957 procedure Process_Async_Pragma
is
4960 Set_Is_Asynchronous
(Nm
);
4964 -- The formals should be of mode IN (RM E.4.1(6))
4967 while Present
(S
) loop
4968 Formal
:= Defining_Identifier
(S
);
4970 if Nkind
(Formal
) = N_Defining_Identifier
4971 and then Ekind
(Formal
) /= E_In_Parameter
4974 ("pragma% procedure can only have IN parameter",
4981 Set_Is_Asynchronous
(Nm
);
4982 end Process_Async_Pragma
;
4984 -- Start of processing for pragma Asynchronous
4987 Check_Ada_83_Warning
;
4988 Check_No_Identifiers
;
4989 Check_Arg_Count
(1);
4990 Check_Arg_Is_Local_Name
(Arg1
);
4992 if Debug_Flag_U
then
4996 C_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
4997 Analyze
(Expression
(Arg1
));
4998 Nm
:= Entity
(Expression
(Arg1
));
5000 if not Is_Remote_Call_Interface
(C_Ent
)
5001 and then not Is_Remote_Types
(C_Ent
)
5003 -- This pragma should only appear in an RCI or Remote Types
5004 -- unit (RM E.4.1(4))
5007 ("pragma% not in Remote_Call_Interface or " &
5008 "Remote_Types unit");
5011 if Ekind
(Nm
) = E_Procedure
5012 and then Nkind
(Parent
(Nm
)) = N_Procedure_Specification
5014 if not Is_Remote_Call_Interface
(Nm
) then
5016 ("pragma% cannot be applied on non-remote procedure",
5020 L
:= Parameter_Specifications
(Parent
(Nm
));
5021 Process_Async_Pragma
;
5024 elsif Ekind
(Nm
) = E_Function
then
5026 ("pragma% cannot be applied to function", Arg1
);
5028 elsif Is_Remote_Access_To_Subprogram_Type
(Nm
) then
5030 if Is_Record_Type
(Nm
) then
5031 -- A record type that is the Equivalent_Type for
5032 -- a remote access-to-subprogram type.
5034 N
:= Declaration_Node
(Corresponding_Remote_Type
(Nm
));
5037 -- A non-expanded RAS type (case where distribution is
5040 N
:= Declaration_Node
(Nm
);
5043 if Nkind
(N
) = N_Full_Type_Declaration
5044 and then Nkind
(Type_Definition
(N
)) =
5045 N_Access_Procedure_Definition
5047 L
:= Parameter_Specifications
(Type_Definition
(N
));
5048 Process_Async_Pragma
;
5050 if Is_Asynchronous
(Nm
)
5051 and then Expander_Active
5052 and then Get_PCS_Name
/= Name_No_DSA
5054 RACW_Type_Is_Asynchronous
(Underlying_RACW_Type
(Nm
));
5059 ("pragma% cannot reference access-to-function type",
5063 -- Only other possibility is Access-to-class-wide type
5065 elsif Is_Access_Type
(Nm
)
5066 and then Is_Class_Wide_Type
(Designated_Type
(Nm
))
5068 Check_First_Subtype
(Arg1
);
5069 Set_Is_Asynchronous
(Nm
);
5070 if Expander_Active
then
5071 RACW_Type_Is_Asynchronous
(Nm
);
5075 Error_Pragma_Arg
("inappropriate argument for pragma%", Arg1
);
5083 -- pragma Atomic (LOCAL_NAME);
5085 when Pragma_Atomic
=>
5086 Process_Atomic_Shared_Volatile
;
5088 -----------------------
5089 -- Atomic_Components --
5090 -----------------------
5092 -- pragma Atomic_Components (array_LOCAL_NAME);
5094 -- This processing is shared by Volatile_Components
5096 when Pragma_Atomic_Components |
5097 Pragma_Volatile_Components
=>
5099 Atomic_Components
: declare
5106 Check_Ada_83_Warning
;
5107 Check_No_Identifiers
;
5108 Check_Arg_Count
(1);
5109 Check_Arg_Is_Local_Name
(Arg1
);
5110 E_Id
:= Expression
(Arg1
);
5112 if Etype
(E_Id
) = Any_Type
then
5118 if Rep_Item_Too_Early
(E
, N
)
5120 Rep_Item_Too_Late
(E
, N
)
5125 D
:= Declaration_Node
(E
);
5128 if (K
= N_Full_Type_Declaration
and then Is_Array_Type
(E
))
5130 ((Ekind
(E
) = E_Constant
or else Ekind
(E
) = E_Variable
)
5131 and then Nkind
(D
) = N_Object_Declaration
5132 and then Nkind
(Object_Definition
(D
)) =
5133 N_Constrained_Array_Definition
)
5135 -- The flag is set on the object, or on the base type
5137 if Nkind
(D
) /= N_Object_Declaration
then
5141 Set_Has_Volatile_Components
(E
);
5143 if Prag_Id
= Pragma_Atomic_Components
then
5144 Set_Has_Atomic_Components
(E
);
5146 if Is_Packed
(E
) then
5147 Set_Is_Packed
(E
, False);
5150 ("?Pack canceled, cannot pack atomic components",
5156 Error_Pragma_Arg
("inappropriate entity for pragma%", Arg1
);
5158 end Atomic_Components
;
5160 --------------------
5161 -- Attach_Handler --
5162 --------------------
5164 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
5166 when Pragma_Attach_Handler
=>
5167 Check_Ada_83_Warning
;
5168 Check_No_Identifiers
;
5169 Check_Arg_Count
(2);
5171 if No_Run_Time_Mode
then
5172 Error_Msg_CRT
("Attach_Handler pragma", N
);
5174 Check_Interrupt_Or_Attach_Handler
;
5176 -- The expression that designates the attribute may
5177 -- depend on a discriminant, and is therefore a per-
5178 -- object expression, to be expanded in the init proc.
5179 -- If expansion is enabled, perform semantic checks
5182 if Expander_Active
then
5184 Temp
: constant Node_Id
:=
5185 New_Copy_Tree
(Expression
(Arg2
));
5187 Set_Parent
(Temp
, N
);
5188 Pre_Analyze_And_Resolve
(Temp
, RTE
(RE_Interrupt_ID
));
5192 Analyze
(Expression
(Arg2
));
5193 Resolve
(Expression
(Arg2
), RTE
(RE_Interrupt_ID
));
5196 Process_Interrupt_Or_Attach_Handler
;
5199 --------------------
5200 -- C_Pass_By_Copy --
5201 --------------------
5203 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
5205 when Pragma_C_Pass_By_Copy
=> C_Pass_By_Copy
: declare
5211 Check_Valid_Configuration_Pragma
;
5212 Check_Arg_Count
(1);
5213 Check_Optional_Identifier
(Arg1
, "max_size");
5215 Arg
:= Expression
(Arg1
);
5216 Check_Arg_Is_Static_Expression
(Arg
, Any_Integer
);
5218 Val
:= Expr_Value
(Arg
);
5222 ("maximum size for pragma% must be positive", Arg1
);
5224 elsif UI_Is_In_Int_Range
(Val
) then
5225 Default_C_Record_Mechanism
:= UI_To_Int
(Val
);
5227 -- If a giant value is given, Int'Last will do well enough.
5228 -- If sometime someone complains that a record larger than
5229 -- two gigabytes is not copied, we will worry about it then!
5232 Default_C_Record_Mechanism
:= Mechanism_Type
'Last;
5240 -- pragma Check_Name (check_IDENTIFIER);
5242 when Pragma_Check_Name
=>
5243 Check_No_Identifiers
;
5245 Check_Valid_Configuration_Pragma
;
5246 Check_Arg_Count
(1);
5247 Check_Arg_Is_Identifier
(Arg1
);
5250 Nam
: constant Name_Id
:= Chars
(Expression
(Arg1
));
5253 for J
in Check_Names
.First
.. Check_Names
.Last
loop
5254 if Check_Names
.Table
(J
) = Nam
then
5259 Check_Names
.Append
(Nam
);
5262 ---------------------
5263 -- CIL_Constructor --
5264 ---------------------
5266 -- pragma CIL_Constructor ([Entity =>] LOCAL_NAME);
5268 -- Processing for this pragma is shared with Java_Constructor
5274 -- pragma Comment (static_string_EXPRESSION)
5276 -- Processing for pragma Comment shares the circuitry for
5277 -- pragma Ident. The only differences are that Ident enforces
5278 -- a limit of 31 characters on its argument, and also enforces
5279 -- limitations on placement for DEC compatibility. Pragma
5280 -- Comment shares neither of these restrictions.
5286 -- pragma Common_Object (
5287 -- [Internal =>] LOCAL_NAME,
5288 -- [, [External =>] EXTERNAL_SYMBOL]
5289 -- [, [Size =>] EXTERNAL_SYMBOL]);
5291 -- Processing for this pragma is shared with Psect_Object
5293 ------------------------
5294 -- Compile_Time_Error --
5295 ------------------------
5297 -- pragma Compile_Time_Error
5298 -- (boolean_EXPRESSION, static_string_EXPRESSION);
5300 when Pragma_Compile_Time_Error
=>
5301 Process_Compile_Time_Warning_Or_Error
;
5303 --------------------------
5304 -- Compile_Time_Warning --
5305 --------------------------
5307 -- pragma Compile_Time_Warning
5308 -- (boolean_EXPRESSION, static_string_EXPRESSION);
5310 when Pragma_Compile_Time_Warning
=>
5311 Process_Compile_Time_Warning_Or_Error
;
5317 when Pragma_Compiler_Unit
=>
5319 Check_Arg_Count
(0);
5320 Set_Is_Compiler_Unit
(Get_Source_Unit
(N
));
5322 -----------------------------
5323 -- Complete_Representation --
5324 -----------------------------
5326 -- pragma Complete_Representation;
5328 when Pragma_Complete_Representation
=>
5330 Check_Arg_Count
(0);
5332 if Nkind
(Parent
(N
)) /= N_Record_Representation_Clause
then
5334 ("pragma & must appear within record representation clause");
5337 ----------------------------
5338 -- Complex_Representation --
5339 ----------------------------
5341 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
5343 when Pragma_Complex_Representation
=> Complex_Representation
: declare
5350 Check_Arg_Count
(1);
5351 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5352 Check_Arg_Is_Local_Name
(Arg1
);
5353 E_Id
:= Expression
(Arg1
);
5355 if Etype
(E_Id
) = Any_Type
then
5361 if not Is_Record_Type
(E
) then
5363 ("argument for pragma% must be record type", Arg1
);
5366 Ent
:= First_Entity
(E
);
5369 or else No
(Next_Entity
(Ent
))
5370 or else Present
(Next_Entity
(Next_Entity
(Ent
)))
5371 or else not Is_Floating_Point_Type
(Etype
(Ent
))
5372 or else Etype
(Ent
) /= Etype
(Next_Entity
(Ent
))
5375 ("record for pragma% must have two fields of same fpt type",
5379 Set_Has_Complex_Representation
(Base_Type
(E
));
5381 -- We need to treat the type has having a non-standard
5382 -- representation, for back-end purposes, even though in
5383 -- general a complex will have the default representation
5384 -- of a record with two real components.
5386 Set_Has_Non_Standard_Rep
(Base_Type
(E
));
5388 end Complex_Representation
;
5390 -------------------------
5391 -- Component_Alignment --
5392 -------------------------
5394 -- pragma Component_Alignment (
5395 -- [Form =>] ALIGNMENT_CHOICE
5396 -- [, [Name =>] type_LOCAL_NAME]);
5398 -- ALIGNMENT_CHOICE ::=
5400 -- | Component_Size_4
5404 when Pragma_Component_Alignment
=> Component_AlignmentP
: declare
5405 Args
: Args_List
(1 .. 2);
5406 Names
: constant Name_List
(1 .. 2) := (
5410 Form
: Node_Id
renames Args
(1);
5411 Name
: Node_Id
renames Args
(2);
5413 Atype
: Component_Alignment_Kind
;
5418 Gather_Associations
(Names
, Args
);
5421 Error_Pragma
("missing Form argument for pragma%");
5424 Check_Arg_Is_Identifier
(Form
);
5426 -- Get proper alignment, note that Default = Component_Size
5427 -- on all machines we have so far, and we want to set this
5428 -- value rather than the default value to indicate that it
5429 -- has been explicitly set (and thus will not get overridden
5430 -- by the default component alignment for the current scope)
5432 if Chars
(Form
) = Name_Component_Size
then
5433 Atype
:= Calign_Component_Size
;
5435 elsif Chars
(Form
) = Name_Component_Size_4
then
5436 Atype
:= Calign_Component_Size_4
;
5438 elsif Chars
(Form
) = Name_Default
then
5439 Atype
:= Calign_Component_Size
;
5441 elsif Chars
(Form
) = Name_Storage_Unit
then
5442 Atype
:= Calign_Storage_Unit
;
5446 ("invalid Form parameter for pragma%", Form
);
5449 -- Case with no name, supplied, affects scope table entry
5453 (Scope_Stack
.Last
).Component_Alignment_Default
:= Atype
;
5455 -- Case of name supplied
5458 Check_Arg_Is_Local_Name
(Name
);
5460 Typ
:= Entity
(Name
);
5463 or else Rep_Item_Too_Early
(Typ
, N
)
5467 Typ
:= Underlying_Type
(Typ
);
5470 if not Is_Record_Type
(Typ
)
5471 and then not Is_Array_Type
(Typ
)
5474 ("Name parameter of pragma% must identify record or " &
5475 "array type", Name
);
5478 -- An explicit Component_Alignment pragma overrides an
5479 -- implicit pragma Pack, but not an explicit one.
5481 if not Has_Pragma_Pack
(Base_Type
(Typ
)) then
5482 Set_Is_Packed
(Base_Type
(Typ
), False);
5483 Set_Component_Alignment
(Base_Type
(Typ
), Atype
);
5486 end Component_AlignmentP
;
5492 -- pragma Controlled (first_subtype_LOCAL_NAME);
5494 when Pragma_Controlled
=> Controlled
: declare
5498 Check_No_Identifiers
;
5499 Check_Arg_Count
(1);
5500 Check_Arg_Is_Local_Name
(Arg1
);
5501 Arg
:= Expression
(Arg1
);
5503 if not Is_Entity_Name
(Arg
)
5504 or else not Is_Access_Type
(Entity
(Arg
))
5506 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
5508 Set_Has_Pragma_Controlled
(Base_Type
(Entity
(Arg
)));
5516 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
5517 -- [Entity =>] LOCAL_NAME);
5519 when Pragma_Convention
=> Convention
: declare
5522 pragma Warnings
(Off
, C
);
5523 pragma Warnings
(Off
, E
);
5525 Check_Arg_Order
((Name_Convention
, Name_Entity
));
5526 Check_Ada_83_Warning
;
5527 Check_Arg_Count
(2);
5528 Process_Convention
(C
, E
);
5531 ---------------------------
5532 -- Convention_Identifier --
5533 ---------------------------
5535 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
5536 -- [Convention =>] convention_IDENTIFIER);
5538 when Pragma_Convention_Identifier
=> Convention_Identifier
: declare
5544 Check_Arg_Order
((Name_Name
, Name_Convention
));
5545 Check_Arg_Count
(2);
5546 Check_Optional_Identifier
(Arg1
, Name_Name
);
5547 Check_Optional_Identifier
(Arg2
, Name_Convention
);
5548 Check_Arg_Is_Identifier
(Arg1
);
5549 Check_Arg_Is_Identifier
(Arg2
);
5550 Idnam
:= Chars
(Expression
(Arg1
));
5551 Cname
:= Chars
(Expression
(Arg2
));
5553 if Is_Convention_Name
(Cname
) then
5554 Record_Convention_Identifier
5555 (Idnam
, Get_Convention_Id
(Cname
));
5558 ("second arg for % pragma must be convention", Arg2
);
5560 end Convention_Identifier
;
5566 -- pragma CPP_Class ([Entity =>] local_NAME)
5568 when Pragma_CPP_Class
=> CPP_Class
: declare
5573 if Warn_On_Obsolescent_Feature
then
5575 ("'G'N'A'T pragma cpp'_class is now obsolete; replace it" &
5576 " by pragma import?", N
);
5580 Check_Arg_Count
(1);
5581 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5582 Check_Arg_Is_Local_Name
(Arg1
);
5584 Arg
:= Expression
(Arg1
);
5587 if Etype
(Arg
) = Any_Type
then
5591 if not Is_Entity_Name
(Arg
)
5592 or else not Is_Type
(Entity
(Arg
))
5594 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
5597 Typ
:= Entity
(Arg
);
5599 if not Is_Tagged_Type
(Typ
) then
5600 Error_Pragma_Arg
("pragma% applicable to tagged types ", Arg1
);
5603 -- Types treated as CPP classes are treated as limited, but we
5604 -- don't require them to be declared this way. A warning is issued
5605 -- to encourage the user to declare them as limited. This is not
5606 -- an error, for compatibility reasons, because these types have
5607 -- been supported this way for some time.
5609 if not Is_Limited_Type
(Typ
) then
5611 ("imported 'C'P'P type should be " &
5612 "explicitly declared limited?",
5613 Get_Pragma_Arg
(Arg1
));
5615 ("\type will be considered limited",
5616 Get_Pragma_Arg
(Arg1
));
5619 Set_Is_CPP_Class
(Typ
);
5620 Set_Is_Limited_Record
(Typ
);
5621 Set_Convention
(Typ
, Convention_CPP
);
5624 ---------------------
5625 -- CPP_Constructor --
5626 ---------------------
5628 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME
5629 -- [, [External_Name =>] static_string_EXPRESSION ]
5630 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5632 when Pragma_CPP_Constructor
=> CPP_Constructor
: declare
5638 Check_At_Least_N_Arguments
(1);
5639 Check_At_Most_N_Arguments
(3);
5640 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5641 Check_Arg_Is_Local_Name
(Arg1
);
5643 Id
:= Expression
(Arg1
);
5644 Find_Program_Unit_Name
(Id
);
5646 -- If we did not find the name, we are done
5648 if Etype
(Id
) = Any_Type
then
5652 Def_Id
:= Entity
(Id
);
5654 if Ekind
(Def_Id
) = E_Function
5655 and then Is_Class_Wide_Type
(Etype
(Def_Id
))
5656 and then Is_CPP_Class
(Etype
(Etype
(Def_Id
)))
5658 if Arg_Count
>= 2 then
5659 Set_Imported
(Def_Id
);
5660 Set_Is_Public
(Def_Id
);
5661 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
5664 if No
(Parameter_Specifications
(Parent
(Def_Id
))) then
5665 Set_Has_Completion
(Def_Id
);
5666 Set_Is_Constructor
(Def_Id
);
5669 ("non-default constructors not implemented", Arg1
);
5674 ("pragma% requires function returning a 'C'P'P_Class type",
5677 end CPP_Constructor
;
5683 when Pragma_CPP_Virtual
=> CPP_Virtual
: declare
5685 if Warn_On_Obsolescent_Feature
then
5687 ("'G'N'A'T pragma cpp'_virtual is now obsolete and has " &
5696 when Pragma_CPP_Vtable
=> CPP_Vtable
: declare
5698 if Warn_On_Obsolescent_Feature
then
5700 ("'G'N'A'T pragma cpp'_vtable is now obsolete and has " &
5709 -- pragma Debug ([boolean_EXPRESSION,] PROCEDURE_CALL_STATEMENT);
5711 when Pragma_Debug
=> Debug
: declare
5719 (Boolean_Literals
(Debug_Pragmas_Enabled
and Expander_Active
),
5722 if Arg_Count
= 2 then
5725 Left_Opnd
=> Relocate_Node
(Cond
),
5726 Right_Opnd
=> Expression
(Arg1
));
5729 -- Rewrite into a conditional with an appropriate condition. We
5730 -- wrap the procedure call in a block so that overhead from e.g.
5731 -- use of the secondary stack does not generate execution overhead
5732 -- for suppressed conditions.
5734 Rewrite
(N
, Make_Implicit_If_Statement
(N
,
5736 Then_Statements
=> New_List
(
5737 Make_Block_Statement
(Loc
,
5738 Handled_Statement_Sequence
=>
5739 Make_Handled_Sequence_Of_Statements
(Loc
,
5740 Statements
=> New_List
(
5741 Relocate_Node
(Debug_Statement
(N
))))))));
5749 -- pragma Debug_Policy (Check | Ignore)
5751 when Pragma_Debug_Policy
=>
5753 Check_Arg_Count
(1);
5754 Check_Arg_Is_One_Of
(Arg1
, Name_Check
, Name_Ignore
);
5755 Debug_Pragmas_Enabled
:= Chars
(Expression
(Arg1
)) = Name_Check
;
5757 ---------------------
5758 -- Detect_Blocking --
5759 ---------------------
5761 -- pragma Detect_Blocking;
5763 when Pragma_Detect_Blocking
=>
5765 Check_Arg_Count
(0);
5766 Check_Valid_Configuration_Pragma
;
5767 Detect_Blocking
:= True;
5773 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
5775 when Pragma_Discard_Names
=> Discard_Names
: declare
5780 Check_Ada_83_Warning
;
5782 -- Deal with configuration pragma case
5784 if Arg_Count
= 0 and then Is_Configuration_Pragma
then
5785 Global_Discard_Names
:= True;
5788 -- Otherwise, check correct appropriate context
5791 Check_Is_In_Decl_Part_Or_Package_Spec
;
5793 if Arg_Count
= 0 then
5795 -- If there is no parameter, then from now on this pragma
5796 -- applies to any enumeration, exception or tagged type
5797 -- defined in the current declarative part, and recursively
5798 -- to any nested scope.
5800 Set_Discard_Names
(Current_Scope
);
5804 Check_Arg_Count
(1);
5805 Check_Optional_Identifier
(Arg1
, Name_On
);
5806 Check_Arg_Is_Local_Name
(Arg1
);
5807 E_Id
:= Expression
(Arg1
);
5809 if Etype
(E_Id
) = Any_Type
then
5815 if (Is_First_Subtype
(E
)
5816 and then (Is_Enumeration_Type
(E
)
5817 or else Is_Tagged_Type
(E
)))
5818 or else Ekind
(E
) = E_Exception
5820 Set_Discard_Names
(E
);
5823 ("inappropriate entity for pragma%", Arg1
);
5833 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
5835 when Pragma_Elaborate
=> Elaborate
: declare
5840 -- Pragma must be in context items list of a compilation unit
5842 if not Is_In_Context_Clause
then
5846 -- Must be at least one argument
5848 if Arg_Count
= 0 then
5849 Error_Pragma
("pragma% requires at least one argument");
5852 -- In Ada 83 mode, there can be no items following it in the
5853 -- context list except other pragmas and implicit with clauses
5854 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
5855 -- placement rule does not apply.
5857 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
5859 while Present
(Citem
) loop
5860 if Nkind
(Citem
) = N_Pragma
5861 or else (Nkind
(Citem
) = N_With_Clause
5862 and then Implicit_With
(Citem
))
5867 ("(Ada 83) pragma% must be at end of context clause");
5874 -- Finally, the arguments must all be units mentioned in a with
5875 -- clause in the same context clause. Note we already checked (in
5876 -- Par.Prag) that the arguments are all identifiers or selected
5880 Outer
: while Present
(Arg
) loop
5881 Citem
:= First
(List_Containing
(N
));
5882 Inner
: while Citem
/= N
loop
5883 if Nkind
(Citem
) = N_With_Clause
5884 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
5886 Set_Elaborate_Present
(Citem
, True);
5887 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
5889 -- With the pragma present, elaboration calls on
5890 -- subprograms from the named unit need no further
5891 -- checks, as long as the pragma appears in the current
5892 -- compilation unit. If the pragma appears in some unit
5893 -- in the context, there might still be a need for an
5894 -- Elaborate_All_Desirable from the current compilation
5895 -- to the the named unit, so we keep the check enabled.
5897 if In_Extended_Main_Source_Unit
(N
) then
5898 Set_Suppress_Elaboration_Warnings
5899 (Entity
(Name
(Citem
)));
5910 ("argument of pragma% is not with'ed unit", Arg
);
5916 -- Give a warning if operating in static mode with -gnatwl
5917 -- (elaboration warnings eanbled) switch set.
5919 if Elab_Warnings
and not Dynamic_Elaboration_Checks
then
5921 ("?use of pragma Elaborate may not be safe", N
);
5923 ("?use pragma Elaborate_All instead if possible", N
);
5931 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
5933 when Pragma_Elaborate_All
=> Elaborate_All
: declare
5938 Check_Ada_83_Warning
;
5940 -- Pragma must be in context items list of a compilation unit
5942 if not Is_In_Context_Clause
then
5946 -- Must be at least one argument
5948 if Arg_Count
= 0 then
5949 Error_Pragma
("pragma% requires at least one argument");
5952 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
5953 -- have to appear at the end of the context clause, but may
5954 -- appear mixed in with other items, even in Ada 83 mode.
5956 -- Final check: the arguments must all be units mentioned in
5957 -- a with clause in the same context clause. Note that we
5958 -- already checked (in Par.Prag) that all the arguments are
5959 -- either identifiers or selected components.
5962 Outr
: while Present
(Arg
) loop
5963 Citem
:= First
(List_Containing
(N
));
5964 Innr
: while Citem
/= N
loop
5965 if Nkind
(Citem
) = N_With_Clause
5966 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
5968 Set_Elaborate_All_Present
(Citem
, True);
5969 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
5971 -- Suppress warnings and elaboration checks on the named
5972 -- unit if the pragma is in the current compilation, as
5973 -- for pragma Elaborate.
5975 if In_Extended_Main_Source_Unit
(N
) then
5976 Set_Suppress_Elaboration_Warnings
5977 (Entity
(Name
(Citem
)));
5986 Set_Error_Posted
(N
);
5988 ("argument of pragma% is not with'ed unit", Arg
);
5995 --------------------
5996 -- Elaborate_Body --
5997 --------------------
5999 -- pragma Elaborate_Body [( library_unit_NAME )];
6001 when Pragma_Elaborate_Body
=> Elaborate_Body
: declare
6002 Cunit_Node
: Node_Id
;
6003 Cunit_Ent
: Entity_Id
;
6006 Check_Ada_83_Warning
;
6007 Check_Valid_Library_Unit_Pragma
;
6009 if Nkind
(N
) = N_Null_Statement
then
6013 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
6014 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
6016 if Nkind
(Unit
(Cunit_Node
)) = N_Package_Body
6018 Nkind
(Unit
(Cunit_Node
)) = N_Subprogram_Body
6020 Error_Pragma
("pragma% must refer to a spec, not a body");
6022 Set_Body_Required
(Cunit_Node
, True);
6023 Set_Has_Pragma_Elaborate_Body
(Cunit_Ent
);
6025 -- If we are in dynamic elaboration mode, then we suppress
6026 -- elaboration warnings for the unit, since it is definitely
6027 -- fine NOT to do dynamic checks at the first level (and such
6028 -- checks will be suppressed because no elaboration boolean
6029 -- is created for Elaborate_Body packages).
6031 -- But in the static model of elaboration, Elaborate_Body is
6032 -- definitely NOT good enough to ensure elaboration safety on
6033 -- its own, since the body may WITH other units that are not
6034 -- safe from an elaboration point of view, so a client must
6035 -- still do an Elaborate_All on such units.
6037 -- Debug flag -gnatdD restores the old behavior of 3.13,
6038 -- where Elaborate_Body always suppressed elab warnings.
6040 if Dynamic_Elaboration_Checks
or Debug_Flag_DD
then
6041 Set_Suppress_Elaboration_Warnings
(Cunit_Ent
);
6046 ------------------------
6047 -- Elaboration_Checks --
6048 ------------------------
6050 -- pragma Elaboration_Checks (Static | Dynamic);
6052 when Pragma_Elaboration_Checks
=>
6054 Check_Arg_Count
(1);
6055 Check_Arg_Is_One_Of
(Arg1
, Name_Static
, Name_Dynamic
);
6056 Dynamic_Elaboration_Checks
:=
6057 (Chars
(Get_Pragma_Arg
(Arg1
)) = Name_Dynamic
);
6063 -- pragma Eliminate (
6064 -- [Unit_Name =>] IDENTIFIER |
6065 -- SELECTED_COMPONENT
6066 -- [,[Entity =>] IDENTIFIER |
6067 -- SELECTED_COMPONENT |
6069 -- [,]OVERLOADING_RESOLUTION);
6071 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
6074 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
6077 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
6079 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
6080 -- Result_Type => result_SUBTYPE_NAME]
6082 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
6083 -- SUBTYPE_NAME ::= STRING_LITERAL
6085 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
6086 -- SOURCE_TRACE ::= STRING_LITERAL
6088 when Pragma_Eliminate
=> Eliminate
: declare
6089 Args
: Args_List
(1 .. 5);
6090 Names
: constant Name_List
(1 .. 5) := (
6093 Name_Parameter_Types
,
6095 Name_Source_Location
);
6097 Unit_Name
: Node_Id
renames Args
(1);
6098 Entity
: Node_Id
renames Args
(2);
6099 Parameter_Types
: Node_Id
renames Args
(3);
6100 Result_Type
: Node_Id
renames Args
(4);
6101 Source_Location
: Node_Id
renames Args
(5);
6105 Check_Valid_Configuration_Pragma
;
6106 Gather_Associations
(Names
, Args
);
6108 if No
(Unit_Name
) then
6109 Error_Pragma
("missing Unit_Name argument for pragma%");
6113 and then (Present
(Parameter_Types
)
6115 Present
(Result_Type
)
6117 Present
(Source_Location
))
6119 Error_Pragma
("missing Entity argument for pragma%");
6122 if (Present
(Parameter_Types
)
6124 Present
(Result_Type
))
6126 Present
(Source_Location
)
6129 ("parameter profile and source location cannot " &
6130 "be used together in pragma%");
6133 Process_Eliminate_Pragma
6147 -- [ Convention =>] convention_IDENTIFIER,
6148 -- [ Entity =>] local_NAME
6149 -- [, [External_Name =>] static_string_EXPRESSION ]
6150 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6152 when Pragma_Export
=> Export
: declare
6156 pragma Warnings
(Off
, C
);
6159 Check_Ada_83_Warning
;
6165 Check_At_Least_N_Arguments
(2);
6166 Check_At_Most_N_Arguments
(4);
6167 Process_Convention
(C
, Def_Id
);
6169 if Ekind
(Def_Id
) /= E_Constant
then
6170 Note_Possible_Modification
(Expression
(Arg2
));
6173 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
6174 Set_Exported
(Def_Id
, Arg2
);
6177 ----------------------
6178 -- Export_Exception --
6179 ----------------------
6181 -- pragma Export_Exception (
6182 -- [Internal =>] LOCAL_NAME,
6183 -- [, [External =>] EXTERNAL_SYMBOL,]
6184 -- [, [Form =>] Ada | VMS]
6185 -- [, [Code =>] static_integer_EXPRESSION]);
6187 when Pragma_Export_Exception
=> Export_Exception
: declare
6188 Args
: Args_List
(1 .. 4);
6189 Names
: constant Name_List
(1 .. 4) := (
6195 Internal
: Node_Id
renames Args
(1);
6196 External
: Node_Id
renames Args
(2);
6197 Form
: Node_Id
renames Args
(3);
6198 Code
: Node_Id
renames Args
(4);
6201 if Inside_A_Generic
then
6202 Error_Pragma
("pragma% cannot be used for generic entities");
6205 Gather_Associations
(Names
, Args
);
6206 Process_Extended_Import_Export_Exception_Pragma
(
6207 Arg_Internal
=> Internal
,
6208 Arg_External
=> External
,
6212 if not Is_VMS_Exception
(Entity
(Internal
)) then
6213 Set_Exported
(Entity
(Internal
), Internal
);
6215 end Export_Exception
;
6217 ---------------------
6218 -- Export_Function --
6219 ---------------------
6221 -- pragma Export_Function (
6222 -- [Internal =>] LOCAL_NAME,
6223 -- [, [External =>] EXTERNAL_SYMBOL,]
6224 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6225 -- [, [Result_Type =>] TYPE_DESIGNATOR]
6226 -- [, [Mechanism =>] MECHANISM]
6227 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
6229 -- EXTERNAL_SYMBOL ::=
6231 -- | static_string_EXPRESSION
6233 -- PARAMETER_TYPES ::=
6235 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6237 -- TYPE_DESIGNATOR ::=
6239 -- | subtype_Name ' Access
6243 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6245 -- MECHANISM_ASSOCIATION ::=
6246 -- [formal_parameter_NAME =>] MECHANISM_NAME
6248 -- MECHANISM_NAME ::=
6251 -- | Descriptor [([Class =>] CLASS_NAME)]
6253 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6255 when Pragma_Export_Function
=> Export_Function
: declare
6256 Args
: Args_List
(1 .. 6);
6257 Names
: constant Name_List
(1 .. 6) := (
6260 Name_Parameter_Types
,
6263 Name_Result_Mechanism
);
6265 Internal
: Node_Id
renames Args
(1);
6266 External
: Node_Id
renames Args
(2);
6267 Parameter_Types
: Node_Id
renames Args
(3);
6268 Result_Type
: Node_Id
renames Args
(4);
6269 Mechanism
: Node_Id
renames Args
(5);
6270 Result_Mechanism
: Node_Id
renames Args
(6);
6274 Gather_Associations
(Names
, Args
);
6275 Process_Extended_Import_Export_Subprogram_Pragma
(
6276 Arg_Internal
=> Internal
,
6277 Arg_External
=> External
,
6278 Arg_Parameter_Types
=> Parameter_Types
,
6279 Arg_Result_Type
=> Result_Type
,
6280 Arg_Mechanism
=> Mechanism
,
6281 Arg_Result_Mechanism
=> Result_Mechanism
);
6282 end Export_Function
;
6288 -- pragma Export_Object (
6289 -- [Internal =>] LOCAL_NAME,
6290 -- [, [External =>] EXTERNAL_SYMBOL]
6291 -- [, [Size =>] EXTERNAL_SYMBOL]);
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_Object
=> Export_Object
: declare
6320 Args
: Args_List
(1 .. 3);
6321 Names
: constant Name_List
(1 .. 3) := (
6326 Internal
: Node_Id
renames Args
(1);
6327 External
: Node_Id
renames Args
(2);
6328 Size
: Node_Id
renames Args
(3);
6332 Gather_Associations
(Names
, Args
);
6333 Process_Extended_Import_Export_Object_Pragma
(
6334 Arg_Internal
=> Internal
,
6335 Arg_External
=> External
,
6339 ----------------------
6340 -- Export_Procedure --
6341 ----------------------
6343 -- pragma Export_Procedure (
6344 -- [Internal =>] LOCAL_NAME,
6345 -- [, [External =>] EXTERNAL_SYMBOL,]
6346 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6347 -- [, [Mechanism =>] MECHANISM]);
6349 -- EXTERNAL_SYMBOL ::=
6351 -- | static_string_EXPRESSION
6353 -- PARAMETER_TYPES ::=
6355 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6357 -- TYPE_DESIGNATOR ::=
6359 -- | subtype_Name ' Access
6363 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6365 -- MECHANISM_ASSOCIATION ::=
6366 -- [formal_parameter_NAME =>] MECHANISM_NAME
6368 -- MECHANISM_NAME ::=
6371 -- | Descriptor [([Class =>] CLASS_NAME)]
6373 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6375 when Pragma_Export_Procedure
=> Export_Procedure
: declare
6376 Args
: Args_List
(1 .. 4);
6377 Names
: constant Name_List
(1 .. 4) := (
6380 Name_Parameter_Types
,
6383 Internal
: Node_Id
renames Args
(1);
6384 External
: Node_Id
renames Args
(2);
6385 Parameter_Types
: Node_Id
renames Args
(3);
6386 Mechanism
: Node_Id
renames Args
(4);
6390 Gather_Associations
(Names
, Args
);
6391 Process_Extended_Import_Export_Subprogram_Pragma
(
6392 Arg_Internal
=> Internal
,
6393 Arg_External
=> External
,
6394 Arg_Parameter_Types
=> Parameter_Types
,
6395 Arg_Mechanism
=> Mechanism
);
6396 end Export_Procedure
;
6402 -- pragma Export_Value (
6403 -- [Value =>] static_integer_EXPRESSION,
6404 -- [Link_Name =>] static_string_EXPRESSION);
6406 when Pragma_Export_Value
=>
6408 Check_Arg_Order
((Name_Value
, Name_Link_Name
));
6409 Check_Arg_Count
(2);
6411 Check_Optional_Identifier
(Arg1
, Name_Value
);
6412 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
6414 Check_Optional_Identifier
(Arg2
, Name_Link_Name
);
6415 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
6417 -----------------------------
6418 -- Export_Valued_Procedure --
6419 -----------------------------
6421 -- pragma Export_Valued_Procedure (
6422 -- [Internal =>] LOCAL_NAME,
6423 -- [, [External =>] EXTERNAL_SYMBOL,]
6424 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6425 -- [, [Mechanism =>] MECHANISM]);
6427 -- EXTERNAL_SYMBOL ::=
6429 -- | static_string_EXPRESSION
6431 -- PARAMETER_TYPES ::=
6433 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6435 -- TYPE_DESIGNATOR ::=
6437 -- | subtype_Name ' Access
6441 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6443 -- MECHANISM_ASSOCIATION ::=
6444 -- [formal_parameter_NAME =>] MECHANISM_NAME
6446 -- MECHANISM_NAME ::=
6449 -- | Descriptor [([Class =>] CLASS_NAME)]
6451 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6453 when Pragma_Export_Valued_Procedure
=>
6454 Export_Valued_Procedure
: declare
6455 Args
: Args_List
(1 .. 4);
6456 Names
: constant Name_List
(1 .. 4) := (
6459 Name_Parameter_Types
,
6462 Internal
: Node_Id
renames Args
(1);
6463 External
: Node_Id
renames Args
(2);
6464 Parameter_Types
: Node_Id
renames Args
(3);
6465 Mechanism
: Node_Id
renames Args
(4);
6469 Gather_Associations
(Names
, Args
);
6470 Process_Extended_Import_Export_Subprogram_Pragma
(
6471 Arg_Internal
=> Internal
,
6472 Arg_External
=> External
,
6473 Arg_Parameter_Types
=> Parameter_Types
,
6474 Arg_Mechanism
=> Mechanism
);
6475 end Export_Valued_Procedure
;
6481 -- pragma Extend_System ([Name =>] Identifier);
6483 when Pragma_Extend_System
=> Extend_System
: declare
6486 Check_Valid_Configuration_Pragma
;
6487 Check_Arg_Count
(1);
6488 Check_Optional_Identifier
(Arg1
, Name_Name
);
6489 Check_Arg_Is_Identifier
(Arg1
);
6491 Get_Name_String
(Chars
(Expression
(Arg1
)));
6494 and then Name_Buffer
(1 .. 4) = "aux_"
6496 if Present
(System_Extend_Pragma_Arg
) then
6497 if Chars
(Expression
(Arg1
)) =
6498 Chars
(Expression
(System_Extend_Pragma_Arg
))
6502 Error_Msg_Sloc
:= Sloc
(System_Extend_Pragma_Arg
);
6503 Error_Pragma
("pragma% conflicts with that #");
6507 System_Extend_Pragma_Arg
:= Arg1
;
6509 if not GNAT_Mode
then
6510 System_Extend_Unit
:= Arg1
;
6514 Error_Pragma
("incorrect name for pragma%, must be Aux_xxx");
6518 ------------------------
6519 -- Extensions_Allowed --
6520 ------------------------
6522 -- pragma Extensions_Allowed (ON | OFF);
6524 when Pragma_Extensions_Allowed
=>
6526 Check_Arg_Count
(1);
6527 Check_No_Identifiers
;
6528 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
6530 if Chars
(Expression
(Arg1
)) = Name_On
then
6531 Extensions_Allowed
:= True;
6533 Extensions_Allowed
:= False;
6540 -- pragma External (
6541 -- [ Convention =>] convention_IDENTIFIER,
6542 -- [ Entity =>] local_NAME
6543 -- [, [External_Name =>] static_string_EXPRESSION ]
6544 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6546 when Pragma_External
=> External
: declare
6550 pragma Warnings
(Off
, C
);
6559 Check_At_Least_N_Arguments
(2);
6560 Check_At_Most_N_Arguments
(4);
6561 Process_Convention
(C
, Def_Id
);
6562 Note_Possible_Modification
(Expression
(Arg2
));
6563 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
6564 Set_Exported
(Def_Id
, Arg2
);
6567 --------------------------
6568 -- External_Name_Casing --
6569 --------------------------
6571 -- pragma External_Name_Casing (
6572 -- UPPERCASE | LOWERCASE
6573 -- [, AS_IS | UPPERCASE | LOWERCASE]);
6575 when Pragma_External_Name_Casing
=> External_Name_Casing
: declare
6578 Check_No_Identifiers
;
6580 if Arg_Count
= 2 then
6582 (Arg2
, Name_As_Is
, Name_Uppercase
, Name_Lowercase
);
6584 case Chars
(Get_Pragma_Arg
(Arg2
)) is
6586 Opt
.External_Name_Exp_Casing
:= As_Is
;
6588 when Name_Uppercase
=>
6589 Opt
.External_Name_Exp_Casing
:= Uppercase
;
6591 when Name_Lowercase
=>
6592 Opt
.External_Name_Exp_Casing
:= Lowercase
;
6599 Check_Arg_Count
(1);
6602 Check_Arg_Is_One_Of
(Arg1
, Name_Uppercase
, Name_Lowercase
);
6604 case Chars
(Get_Pragma_Arg
(Arg1
)) is
6605 when Name_Uppercase
=>
6606 Opt
.External_Name_Imp_Casing
:= Uppercase
;
6608 when Name_Lowercase
=>
6609 Opt
.External_Name_Imp_Casing
:= Lowercase
;
6614 end External_Name_Casing
;
6616 ---------------------------
6617 -- Finalize_Storage_Only --
6618 ---------------------------
6620 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
6622 when Pragma_Finalize_Storage_Only
=> Finalize_Storage
: declare
6623 Assoc
: constant Node_Id
:= Arg1
;
6624 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
6628 Check_No_Identifiers
;
6629 Check_Arg_Count
(1);
6630 Check_Arg_Is_Local_Name
(Arg1
);
6632 Find_Type
(Type_Id
);
6633 Typ
:= Entity
(Type_Id
);
6636 or else Rep_Item_Too_Early
(Typ
, N
)
6640 Typ
:= Underlying_Type
(Typ
);
6643 if not Is_Controlled
(Typ
) then
6644 Error_Pragma
("pragma% must specify controlled type");
6647 Check_First_Subtype
(Arg1
);
6649 if Finalize_Storage_Only
(Typ
) then
6650 Error_Pragma
("duplicate pragma%, only one allowed");
6652 elsif not Rep_Item_Too_Late
(Typ
, N
) then
6653 Set_Finalize_Storage_Only
(Base_Type
(Typ
), True);
6655 end Finalize_Storage
;
6657 --------------------------
6658 -- Float_Representation --
6659 --------------------------
6661 -- pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
6663 -- FLOAT_REP ::= VAX_Float | IEEE_Float
6665 when Pragma_Float_Representation
=> Float_Representation
: declare
6673 if Arg_Count
= 1 then
6674 Check_Valid_Configuration_Pragma
;
6676 Check_Arg_Count
(2);
6677 Check_Optional_Identifier
(Arg2
, Name_Entity
);
6678 Check_Arg_Is_Local_Name
(Arg2
);
6681 Check_No_Identifier
(Arg1
);
6682 Check_Arg_Is_One_Of
(Arg1
, Name_VAX_Float
, Name_IEEE_Float
);
6684 if not OpenVMS_On_Target
then
6685 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6687 ("?pragma% ignored (applies only to Open'V'M'S)");
6693 -- One argument case
6695 if Arg_Count
= 1 then
6696 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6697 if Opt
.Float_Format
= 'I' then
6698 Error_Pragma
("'I'E'E'E format previously specified");
6701 Opt
.Float_Format
:= 'V';
6704 if Opt
.Float_Format
= 'V' then
6705 Error_Pragma
("'V'A'X format previously specified");
6708 Opt
.Float_Format
:= 'I';
6711 Set_Standard_Fpt_Formats
;
6713 -- Two argument case
6716 Argx
:= Get_Pragma_Arg
(Arg2
);
6718 if not Is_Entity_Name
(Argx
)
6719 or else not Is_Floating_Point_Type
(Entity
(Argx
))
6722 ("second argument of% pragma must be floating-point type",
6726 Ent
:= Entity
(Argx
);
6727 Digs
:= UI_To_Int
(Digits_Value
(Ent
));
6729 -- Two arguments, VAX_Float case
6731 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
6733 when 6 => Set_F_Float
(Ent
);
6734 when 9 => Set_D_Float
(Ent
);
6735 when 15 => Set_G_Float
(Ent
);
6739 ("wrong digits value, must be 6,9 or 15", Arg2
);
6742 -- Two arguments, IEEE_Float case
6746 when 6 => Set_IEEE_Short
(Ent
);
6747 when 15 => Set_IEEE_Long
(Ent
);
6751 ("wrong digits value, must be 6 or 15", Arg2
);
6755 end Float_Representation
;
6761 -- pragma Ident (static_string_EXPRESSION)
6763 -- Note: pragma Comment shares this processing. Pragma Comment
6764 -- is identical to Ident, except that the restriction of the
6765 -- argument to 31 characters and the placement restrictions
6766 -- are not enforced for pragma Comment.
6768 when Pragma_Ident | Pragma_Comment
=> Ident
: declare
6773 Check_Arg_Count
(1);
6774 Check_No_Identifiers
;
6775 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
6777 -- For pragma Ident, preserve DEC compatibility by requiring
6778 -- the pragma to appear in a declarative part or package spec.
6780 if Prag_Id
= Pragma_Ident
then
6781 Check_Is_In_Decl_Part_Or_Package_Spec
;
6784 Str
:= Expr_Value_S
(Expression
(Arg1
));
6791 GP
:= Parent
(Parent
(N
));
6793 if Nkind
(GP
) = N_Package_Declaration
6795 Nkind
(GP
) = N_Generic_Package_Declaration
6800 -- If we have a compilation unit, then record the ident
6801 -- value, checking for improper duplication.
6803 if Nkind
(GP
) = N_Compilation_Unit
then
6804 CS
:= Ident_String
(Current_Sem_Unit
);
6806 if Present
(CS
) then
6808 -- For Ident, we do not permit multiple instances
6810 if Prag_Id
= Pragma_Ident
then
6811 Error_Pragma
("duplicate% pragma not permitted");
6813 -- For Comment, we concatenate the string, unless we
6814 -- want to preserve the tree structure for ASIS.
6816 elsif not ASIS_Mode
then
6817 Start_String
(Strval
(CS
));
6818 Store_String_Char
(' ');
6819 Store_String_Chars
(Strval
(Str
));
6820 Set_Strval
(CS
, End_String
);
6824 -- In VMS, the effect of IDENT is achieved by passing
6825 -- IDENTIFICATION=name as a --for-linker switch.
6827 if OpenVMS_On_Target
then
6830 ("--for-linker=IDENTIFICATION=");
6831 String_To_Name_Buffer
(Strval
(Str
));
6832 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
6834 -- Only the last processed IDENT is saved. The main
6835 -- purpose is so an IDENT associated with a main
6836 -- procedure will be used in preference to an IDENT
6837 -- associated with a with'd package.
6839 Replace_Linker_Option_String
6840 (End_String
, "--for-linker=IDENTIFICATION=");
6843 Set_Ident_String
(Current_Sem_Unit
, Str
);
6846 -- For subunits, we just ignore the Ident, since in GNAT
6847 -- these are not separate object files, and hence not
6848 -- separate units in the unit table.
6850 elsif Nkind
(GP
) = N_Subunit
then
6853 -- Otherwise we have a misplaced pragma Ident, but we ignore
6854 -- this if we are in an instantiation, since it comes from
6855 -- a generic, and has no relevance to the instantiation.
6857 elsif Prag_Id
= Pragma_Ident
then
6858 if Instantiation_Location
(Loc
) = No_Location
then
6859 Error_Pragma
("pragma% only allowed at outer level");
6865 -----------------------
6866 -- Implicit_Packing --
6867 -----------------------
6869 -- pragma Implicit_Packing;
6871 when Pragma_Implicit_Packing
=>
6873 Check_Arg_Count
(0);
6874 Implicit_Packing
:= True;
6881 -- [ Convention =>] convention_IDENTIFIER,
6882 -- [ Entity =>] local_NAME
6883 -- [, [External_Name =>] static_string_EXPRESSION ]
6884 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6886 when Pragma_Import
=>
6887 Check_Ada_83_Warning
;
6893 Check_At_Least_N_Arguments
(2);
6894 Check_At_Most_N_Arguments
(4);
6895 Process_Import_Or_Interface
;
6897 ----------------------
6898 -- Import_Exception --
6899 ----------------------
6901 -- pragma Import_Exception (
6902 -- [Internal =>] LOCAL_NAME,
6903 -- [, [External =>] EXTERNAL_SYMBOL,]
6904 -- [, [Form =>] Ada | VMS]
6905 -- [, [Code =>] static_integer_EXPRESSION]);
6907 when Pragma_Import_Exception
=> Import_Exception
: declare
6908 Args
: Args_List
(1 .. 4);
6909 Names
: constant Name_List
(1 .. 4) := (
6915 Internal
: Node_Id
renames Args
(1);
6916 External
: Node_Id
renames Args
(2);
6917 Form
: Node_Id
renames Args
(3);
6918 Code
: Node_Id
renames Args
(4);
6921 Gather_Associations
(Names
, Args
);
6923 if Present
(External
) and then Present
(Code
) then
6925 ("cannot give both External and Code options for pragma%");
6928 Process_Extended_Import_Export_Exception_Pragma
(
6929 Arg_Internal
=> Internal
,
6930 Arg_External
=> External
,
6934 if not Is_VMS_Exception
(Entity
(Internal
)) then
6935 Set_Imported
(Entity
(Internal
));
6937 end Import_Exception
;
6939 ---------------------
6940 -- Import_Function --
6941 ---------------------
6943 -- pragma Import_Function (
6944 -- [Internal =>] LOCAL_NAME,
6945 -- [, [External =>] EXTERNAL_SYMBOL]
6946 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6947 -- [, [Result_Type =>] SUBTYPE_MARK]
6948 -- [, [Mechanism =>] MECHANISM]
6949 -- [, [Result_Mechanism =>] MECHANISM_NAME]
6950 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6952 -- EXTERNAL_SYMBOL ::=
6954 -- | static_string_EXPRESSION
6956 -- PARAMETER_TYPES ::=
6958 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6960 -- TYPE_DESIGNATOR ::=
6962 -- | subtype_Name ' Access
6966 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6968 -- MECHANISM_ASSOCIATION ::=
6969 -- [formal_parameter_NAME =>] MECHANISM_NAME
6971 -- MECHANISM_NAME ::=
6974 -- | Descriptor [([Class =>] CLASS_NAME)]
6976 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6978 when Pragma_Import_Function
=> Import_Function
: declare
6979 Args
: Args_List
(1 .. 7);
6980 Names
: constant Name_List
(1 .. 7) := (
6983 Name_Parameter_Types
,
6986 Name_Result_Mechanism
,
6987 Name_First_Optional_Parameter
);
6989 Internal
: Node_Id
renames Args
(1);
6990 External
: Node_Id
renames Args
(2);
6991 Parameter_Types
: Node_Id
renames Args
(3);
6992 Result_Type
: Node_Id
renames Args
(4);
6993 Mechanism
: Node_Id
renames Args
(5);
6994 Result_Mechanism
: Node_Id
renames Args
(6);
6995 First_Optional_Parameter
: Node_Id
renames Args
(7);
6999 Gather_Associations
(Names
, Args
);
7000 Process_Extended_Import_Export_Subprogram_Pragma
(
7001 Arg_Internal
=> Internal
,
7002 Arg_External
=> External
,
7003 Arg_Parameter_Types
=> Parameter_Types
,
7004 Arg_Result_Type
=> Result_Type
,
7005 Arg_Mechanism
=> Mechanism
,
7006 Arg_Result_Mechanism
=> Result_Mechanism
,
7007 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
7008 end Import_Function
;
7014 -- pragma Import_Object (
7015 -- [Internal =>] LOCAL_NAME,
7016 -- [, [External =>] EXTERNAL_SYMBOL]
7017 -- [, [Size =>] EXTERNAL_SYMBOL]);
7019 -- EXTERNAL_SYMBOL ::=
7021 -- | static_string_EXPRESSION
7023 when Pragma_Import_Object
=> Import_Object
: declare
7024 Args
: Args_List
(1 .. 3);
7025 Names
: constant Name_List
(1 .. 3) := (
7030 Internal
: Node_Id
renames Args
(1);
7031 External
: Node_Id
renames Args
(2);
7032 Size
: Node_Id
renames Args
(3);
7036 Gather_Associations
(Names
, Args
);
7037 Process_Extended_Import_Export_Object_Pragma
(
7038 Arg_Internal
=> Internal
,
7039 Arg_External
=> External
,
7043 ----------------------
7044 -- Import_Procedure --
7045 ----------------------
7047 -- pragma Import_Procedure (
7048 -- [Internal =>] LOCAL_NAME,
7049 -- [, [External =>] EXTERNAL_SYMBOL]
7050 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7051 -- [, [Mechanism =>] MECHANISM]
7052 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
7054 -- EXTERNAL_SYMBOL ::=
7056 -- | static_string_EXPRESSION
7058 -- PARAMETER_TYPES ::=
7060 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7062 -- TYPE_DESIGNATOR ::=
7064 -- | subtype_Name ' Access
7068 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7070 -- MECHANISM_ASSOCIATION ::=
7071 -- [formal_parameter_NAME =>] MECHANISM_NAME
7073 -- MECHANISM_NAME ::=
7076 -- | Descriptor [([Class =>] CLASS_NAME)]
7078 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7080 when Pragma_Import_Procedure
=> Import_Procedure
: declare
7081 Args
: Args_List
(1 .. 5);
7082 Names
: constant Name_List
(1 .. 5) := (
7085 Name_Parameter_Types
,
7087 Name_First_Optional_Parameter
);
7089 Internal
: Node_Id
renames Args
(1);
7090 External
: Node_Id
renames Args
(2);
7091 Parameter_Types
: Node_Id
renames Args
(3);
7092 Mechanism
: Node_Id
renames Args
(4);
7093 First_Optional_Parameter
: Node_Id
renames Args
(5);
7097 Gather_Associations
(Names
, Args
);
7098 Process_Extended_Import_Export_Subprogram_Pragma
(
7099 Arg_Internal
=> Internal
,
7100 Arg_External
=> External
,
7101 Arg_Parameter_Types
=> Parameter_Types
,
7102 Arg_Mechanism
=> Mechanism
,
7103 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
7104 end Import_Procedure
;
7106 -----------------------------
7107 -- Import_Valued_Procedure --
7108 -----------------------------
7110 -- pragma Import_Valued_Procedure (
7111 -- [Internal =>] LOCAL_NAME,
7112 -- [, [External =>] EXTERNAL_SYMBOL]
7113 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7114 -- [, [Mechanism =>] MECHANISM]
7115 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
7117 -- EXTERNAL_SYMBOL ::=
7119 -- | static_string_EXPRESSION
7121 -- PARAMETER_TYPES ::=
7123 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7125 -- TYPE_DESIGNATOR ::=
7127 -- | subtype_Name ' Access
7131 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7133 -- MECHANISM_ASSOCIATION ::=
7134 -- [formal_parameter_NAME =>] MECHANISM_NAME
7136 -- MECHANISM_NAME ::=
7139 -- | Descriptor [([Class =>] CLASS_NAME)]
7141 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7143 when Pragma_Import_Valued_Procedure
=>
7144 Import_Valued_Procedure
: declare
7145 Args
: Args_List
(1 .. 5);
7146 Names
: constant Name_List
(1 .. 5) := (
7149 Name_Parameter_Types
,
7151 Name_First_Optional_Parameter
);
7153 Internal
: Node_Id
renames Args
(1);
7154 External
: Node_Id
renames Args
(2);
7155 Parameter_Types
: Node_Id
renames Args
(3);
7156 Mechanism
: Node_Id
renames Args
(4);
7157 First_Optional_Parameter
: Node_Id
renames Args
(5);
7161 Gather_Associations
(Names
, Args
);
7162 Process_Extended_Import_Export_Subprogram_Pragma
(
7163 Arg_Internal
=> Internal
,
7164 Arg_External
=> External
,
7165 Arg_Parameter_Types
=> Parameter_Types
,
7166 Arg_Mechanism
=> Mechanism
,
7167 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
7168 end Import_Valued_Procedure
;
7170 ------------------------
7171 -- Initialize_Scalars --
7172 ------------------------
7174 -- pragma Initialize_Scalars;
7176 when Pragma_Initialize_Scalars
=>
7178 Check_Arg_Count
(0);
7179 Check_Valid_Configuration_Pragma
;
7180 Check_Restriction
(No_Initialize_Scalars
, N
);
7182 if not Restriction_Active
(No_Initialize_Scalars
) then
7183 Init_Or_Norm_Scalars
:= True;
7184 Initialize_Scalars
:= True;
7191 -- pragma Inline ( NAME {, NAME} );
7193 when Pragma_Inline
=>
7195 -- Pragma is active if inlining option is active
7197 Process_Inline
(Inline_Active
);
7203 -- pragma Inline_Always ( NAME {, NAME} );
7205 when Pragma_Inline_Always
=>
7206 Process_Inline
(True);
7208 --------------------
7209 -- Inline_Generic --
7210 --------------------
7212 -- pragma Inline_Generic (NAME {, NAME});
7214 when Pragma_Inline_Generic
=>
7215 Process_Generic_List
;
7217 ----------------------
7218 -- Inspection_Point --
7219 ----------------------
7221 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
7223 when Pragma_Inspection_Point
=> Inspection_Point
: declare
7228 if Arg_Count
> 0 then
7231 Exp
:= Expression
(Arg
);
7234 if not Is_Entity_Name
(Exp
)
7235 or else not Is_Object
(Entity
(Exp
))
7237 Error_Pragma_Arg
("object name required", Arg
);
7244 end Inspection_Point
;
7250 -- pragma Interface (
7251 -- [ Convention =>] convention_IDENTIFIER,
7252 -- [ Entity =>] local_NAME
7253 -- [, [External_Name =>] static_string_EXPRESSION ]
7254 -- [, [Link_Name =>] static_string_EXPRESSION ]);
7256 when Pragma_Interface
=>
7263 Check_At_Least_N_Arguments
(2);
7264 Check_At_Most_N_Arguments
(4);
7265 Process_Import_Or_Interface
;
7267 --------------------
7268 -- Interface_Name --
7269 --------------------
7271 -- pragma Interface_Name (
7272 -- [ Entity =>] local_NAME
7273 -- [,[External_Name =>] static_string_EXPRESSION ]
7274 -- [,[Link_Name =>] static_string_EXPRESSION ]);
7276 when Pragma_Interface_Name
=> Interface_Name
: declare
7285 ((Name_Entity
, Name_External_Name
, Name_Link_Name
));
7286 Check_At_Least_N_Arguments
(2);
7287 Check_At_Most_N_Arguments
(3);
7288 Id
:= Expression
(Arg1
);
7291 if not Is_Entity_Name
(Id
) then
7293 ("first argument for pragma% must be entity name", Arg1
);
7294 elsif Etype
(Id
) = Any_Type
then
7297 Def_Id
:= Entity
(Id
);
7300 -- Special DEC-compatible processing for the object case,
7301 -- forces object to be imported.
7303 if Ekind
(Def_Id
) = E_Variable
then
7304 Kill_Size_Check_Code
(Def_Id
);
7305 Note_Possible_Modification
(Id
);
7307 -- Initialization is not allowed for imported variable
7309 if Present
(Expression
(Parent
(Def_Id
)))
7310 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
7312 Error_Msg_Sloc
:= Sloc
(Def_Id
);
7314 ("no initialization allowed for declaration of& #",
7318 -- For compatibility, support VADS usage of providing both
7319 -- pragmas Interface and Interface_Name to obtain the effect
7320 -- of a single Import pragma.
7322 if Is_Imported
(Def_Id
)
7323 and then Present
(First_Rep_Item
(Def_Id
))
7324 and then Nkind
(First_Rep_Item
(Def_Id
)) = N_Pragma
7325 and then Chars
(First_Rep_Item
(Def_Id
)) = Name_Interface
7329 Set_Imported
(Def_Id
);
7332 Set_Is_Public
(Def_Id
);
7333 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
7336 -- Otherwise must be subprogram
7338 elsif not Is_Subprogram
(Def_Id
) then
7340 ("argument of pragma% is not subprogram", Arg1
);
7343 Check_At_Most_N_Arguments
(3);
7347 -- Loop through homonyms
7350 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
7352 if Is_Imported
(Def_Id
) then
7353 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
7357 Hom_Id
:= Homonym
(Hom_Id
);
7359 exit when No
(Hom_Id
)
7360 or else Scope
(Hom_Id
) /= Current_Scope
;
7365 ("argument of pragma% is not imported subprogram",
7371 -----------------------
7372 -- Interrupt_Handler --
7373 -----------------------
7375 -- pragma Interrupt_Handler (handler_NAME);
7377 when Pragma_Interrupt_Handler
=>
7378 Check_Ada_83_Warning
;
7379 Check_Arg_Count
(1);
7380 Check_No_Identifiers
;
7382 if No_Run_Time_Mode
then
7383 Error_Msg_CRT
("Interrupt_Handler pragma", N
);
7385 Check_Interrupt_Or_Attach_Handler
;
7386 Process_Interrupt_Or_Attach_Handler
;
7389 ------------------------
7390 -- Interrupt_Priority --
7391 ------------------------
7393 -- pragma Interrupt_Priority [(EXPRESSION)];
7395 when Pragma_Interrupt_Priority
=> Interrupt_Priority
: declare
7396 P
: constant Node_Id
:= Parent
(N
);
7400 Check_Ada_83_Warning
;
7402 if Arg_Count
/= 0 then
7403 Arg
:= Expression
(Arg1
);
7404 Check_Arg_Count
(1);
7405 Check_No_Identifiers
;
7407 -- The expression must be analyzed in the special manner
7408 -- described in "Handling of Default and Per-Object
7409 -- Expressions" in sem.ads.
7411 Analyze_Per_Use_Expression
(Arg
, RTE
(RE_Interrupt_Priority
));
7414 if Nkind
(P
) /= N_Task_Definition
7415 and then Nkind
(P
) /= N_Protected_Definition
7420 elsif Has_Priority_Pragma
(P
) then
7421 Error_Pragma
("duplicate pragma% not allowed");
7424 Set_Has_Priority_Pragma
(P
, True);
7425 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
7427 end Interrupt_Priority
;
7429 ---------------------
7430 -- Interrupt_State --
7431 ---------------------
7433 -- pragma Interrupt_State (
7434 -- [Name =>] INTERRUPT_ID,
7435 -- [State =>] INTERRUPT_STATE);
7437 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
7438 -- INTERRUPT_STATE => System | Runtime | User
7440 -- Note: if the interrupt id is given as an identifier, then
7441 -- it must be one of the identifiers in Ada.Interrupts.Names.
7442 -- Otherwise it is given as a static integer expression which
7443 -- must be in the range of Ada.Interrupts.Interrupt_ID.
7445 when Pragma_Interrupt_State
=> Interrupt_State
: declare
7447 Int_Id
: constant Entity_Id
:= RTE
(RE_Interrupt_ID
);
7448 -- This is the entity Ada.Interrupts.Interrupt_ID;
7450 State_Type
: Character;
7451 -- Set to 's'/'r'/'u' for System/Runtime/User
7454 -- Index to entry in Interrupt_States table
7457 -- Value of interrupt
7459 Arg1X
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
7460 -- The first argument to the pragma
7462 Int_Ent
: Entity_Id
;
7463 -- Interrupt entity in Ada.Interrupts.Names
7467 Check_Arg_Order
((Name_Name
, Name_State
));
7468 Check_Arg_Count
(2);
7470 Check_Optional_Identifier
(Arg1
, Name_Name
);
7471 Check_Optional_Identifier
(Arg2
, Name_State
);
7472 Check_Arg_Is_Identifier
(Arg2
);
7474 -- First argument is identifier
7476 if Nkind
(Arg1X
) = N_Identifier
then
7478 -- Search list of names in Ada.Interrupts.Names
7480 Int_Ent
:= First_Entity
(RTE
(RE_Names
));
7482 if No
(Int_Ent
) then
7483 Error_Pragma_Arg
("invalid interrupt name", Arg1
);
7485 elsif Chars
(Int_Ent
) = Chars
(Arg1X
) then
7486 Int_Val
:= Expr_Value
(Constant_Value
(Int_Ent
));
7490 Next_Entity
(Int_Ent
);
7493 -- First argument is not an identifier, so it must be a
7494 -- static expression of type Ada.Interrupts.Interrupt_ID.
7497 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
7498 Int_Val
:= Expr_Value
(Arg1X
);
7500 if Int_Val
< Expr_Value
(Type_Low_Bound
(Int_Id
))
7502 Int_Val
> Expr_Value
(Type_High_Bound
(Int_Id
))
7505 ("value not in range of type " &
7506 """Ada.Interrupts.Interrupt_'I'D""", Arg1
);
7512 case Chars
(Get_Pragma_Arg
(Arg2
)) is
7513 when Name_Runtime
=> State_Type
:= 'r';
7514 when Name_System
=> State_Type
:= 's';
7515 when Name_User
=> State_Type
:= 'u';
7518 Error_Pragma_Arg
("invalid interrupt state", Arg2
);
7521 -- Check if entry is already stored
7523 IST_Num
:= Interrupt_States
.First
;
7525 -- If entry not found, add it
7527 if IST_Num
> Interrupt_States
.Last
then
7528 Interrupt_States
.Append
7529 ((Interrupt_Number
=> UI_To_Int
(Int_Val
),
7530 Interrupt_State
=> State_Type
,
7531 Pragma_Loc
=> Loc
));
7534 -- Case of entry for the same entry
7536 elsif Int_Val
= Interrupt_States
.Table
(IST_Num
).
7539 -- If state matches, done, no need to make redundant entry
7542 State_Type
= Interrupt_States
.Table
(IST_Num
).
7545 -- Otherwise if state does not match, error
7548 Interrupt_States
.Table
(IST_Num
).Pragma_Loc
;
7550 ("state conflicts with that given #", Arg2
);
7554 IST_Num
:= IST_Num
+ 1;
7556 end Interrupt_State
;
7558 ----------------------
7559 -- Java_Constructor --
7560 ----------------------
7562 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
7564 -- Also handles pragma CIL_Constructor
7566 when Pragma_CIL_Constructor | Pragma_Java_Constructor
=>
7567 Java_Constructor
: declare
7571 Convention
: Convention_Id
;
7575 Check_Arg_Count
(1);
7576 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7577 Check_Arg_Is_Local_Name
(Arg1
);
7579 Id
:= Expression
(Arg1
);
7580 Find_Program_Unit_Name
(Id
);
7582 -- If we did not find the name, we are done
7584 if Etype
(Id
) = Any_Type
then
7589 when Pragma_CIL_Constructor
=> Convention
:= Convention_CIL
;
7590 when Pragma_Java_Constructor
=> Convention
:= Convention_Java
;
7591 when others => null;
7594 Hom_Id
:= Entity
(Id
);
7596 -- Loop through homonyms
7599 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
7601 -- The constructor is required to be a function returning an
7602 -- access type whose designated type has convention Java/CIL.
7604 if Ekind
(Def_Id
) = E_Function
7606 (Is_Value_Type
(Etype
(Def_Id
))
7608 (Ekind
(Etype
(Def_Id
)) in Access_Kind
7611 (Designated_Type
(Etype
(Def_Id
))) = Convention
7614 (Root_Type
(Designated_Type
(Etype
(Def_Id
)))) =
7617 Set_Is_Constructor
(Def_Id
);
7618 Set_Convention
(Def_Id
, Convention
);
7619 Set_Is_Imported
(Def_Id
);
7622 if Convention
= Convention_Java
then
7624 ("pragma% requires function returning a " &
7625 "'Java access type", Arg1
);
7627 pragma Assert
(Convention
= Convention_CIL
);
7629 ("pragma% requires function returning a " &
7630 "'CIL access type", Arg1
);
7634 Hom_Id
:= Homonym
(Hom_Id
);
7636 exit when No
(Hom_Id
) or else Scope
(Hom_Id
) /= Current_Scope
;
7638 end Java_Constructor
;
7640 ----------------------
7641 -- Java_Interface --
7642 ----------------------
7644 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
7646 when Pragma_Java_Interface
=> Java_Interface
: declare
7652 Check_Arg_Count
(1);
7653 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7654 Check_Arg_Is_Local_Name
(Arg1
);
7656 Arg
:= Expression
(Arg1
);
7659 if Etype
(Arg
) = Any_Type
then
7663 if not Is_Entity_Name
(Arg
)
7664 or else not Is_Type
(Entity
(Arg
))
7666 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
7669 Typ
:= Underlying_Type
(Entity
(Arg
));
7671 -- For now we simply check some of the semantic constraints
7672 -- on the type. This currently leaves out some restrictions
7673 -- on interface types, namely that the parent type must be
7674 -- java.lang.Object.Typ and that all primitives of the type
7675 -- should be declared abstract. ???
7677 if not Is_Tagged_Type
(Typ
) or else not Is_Abstract_Type
(Typ
) then
7678 Error_Pragma_Arg
("pragma% requires an abstract "
7679 & "tagged type", Arg1
);
7681 elsif not Has_Discriminants
(Typ
)
7682 or else Ekind
(Etype
(First_Discriminant
(Typ
)))
7683 /= E_Anonymous_Access_Type
7685 not Is_Class_Wide_Type
7686 (Designated_Type
(Etype
(First_Discriminant
(Typ
))))
7689 ("type must have a class-wide access discriminant", Arg1
);
7697 -- pragma Keep_Names ([On => ] local_NAME);
7699 when Pragma_Keep_Names
=> Keep_Names
: declare
7704 Check_Arg_Count
(1);
7705 Check_Optional_Identifier
(Arg1
, Name_On
);
7706 Check_Arg_Is_Local_Name
(Arg1
);
7708 Arg
:= Expression
(Arg1
);
7711 if Etype
(Arg
) = Any_Type
then
7715 if not Is_Entity_Name
(Arg
)
7716 or else Ekind
(Entity
(Arg
)) /= E_Enumeration_Type
7719 ("pragma% requires a local enumeration type", Arg1
);
7722 Set_Discard_Names
(Entity
(Arg
), False);
7729 -- pragma License (RESTRICTED | UNRESTRICTED | GPL | MODIFIED_GPL);
7731 when Pragma_License
=>
7733 Check_Arg_Count
(1);
7734 Check_No_Identifiers
;
7735 Check_Valid_Configuration_Pragma
;
7736 Check_Arg_Is_Identifier
(Arg1
);
7739 Sind
: constant Source_File_Index
:=
7740 Source_Index
(Current_Sem_Unit
);
7743 case Chars
(Get_Pragma_Arg
(Arg1
)) is
7745 Set_License
(Sind
, GPL
);
7747 when Name_Modified_GPL
=>
7748 Set_License
(Sind
, Modified_GPL
);
7750 when Name_Restricted
=>
7751 Set_License
(Sind
, Restricted
);
7753 when Name_Unrestricted
=>
7754 Set_License
(Sind
, Unrestricted
);
7757 Error_Pragma_Arg
("invalid license name", Arg1
);
7765 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
7767 when Pragma_Link_With
=> Link_With
: declare
7773 if Operating_Mode
= Generate_Code
7774 and then In_Extended_Main_Source_Unit
(N
)
7776 Check_At_Least_N_Arguments
(1);
7777 Check_No_Identifiers
;
7778 Check_Is_In_Decl_Part_Or_Package_Spec
;
7779 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7783 while Present
(Arg
) loop
7784 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
7786 -- Store argument, converting sequences of spaces
7787 -- to a single null character (this is one of the
7788 -- differences in processing between Link_With
7789 -- and Linker_Options).
7792 C
: constant Char_Code
:= Get_Char_Code
(' ');
7793 S
: constant String_Id
:=
7794 Strval
(Expr_Value_S
(Expression
(Arg
)));
7795 L
: constant Nat
:= String_Length
(S
);
7798 procedure Skip_Spaces
;
7799 -- Advance F past any spaces
7805 procedure Skip_Spaces
is
7807 while F
<= L
and then Get_String_Char
(S
, F
) = C
loop
7812 -- Start of processing for Arg_Store
7815 Skip_Spaces
; -- skip leading spaces
7817 -- Loop through characters, changing any embedded
7818 -- sequence of spaces to a single null character
7819 -- (this is how Link_With/Linker_Options differ)
7822 if Get_String_Char
(S
, F
) = C
then
7825 Store_String_Char
(ASCII
.NUL
);
7828 Store_String_Char
(Get_String_Char
(S
, F
));
7836 if Present
(Arg
) then
7837 Store_String_Char
(ASCII
.NUL
);
7841 Store_Linker_Option_String
(End_String
);
7849 -- pragma Linker_Alias (
7850 -- [Entity =>] LOCAL_NAME
7851 -- [Target =>] static_string_EXPRESSION);
7853 when Pragma_Linker_Alias
=>
7855 Check_Arg_Order
((Name_Entity
, Name_Target
));
7856 Check_Arg_Count
(2);
7857 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7858 Check_Optional_Identifier
(Arg2
, Name_Target
);
7859 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
7860 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7862 -- The only processing required is to link this item on to the
7863 -- list of rep items for the given entity. This is accomplished
7864 -- by the call to Rep_Item_Too_Late (when no error is detected
7865 -- and False is returned).
7867 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
7870 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7873 ------------------------
7874 -- Linker_Constructor --
7875 ------------------------
7877 -- pragma Linker_Constructor (procedure_LOCAL_NAME);
7879 -- Code is shared with Linker_Destructor
7881 -----------------------
7882 -- Linker_Destructor --
7883 -----------------------
7885 -- pragma Linker_Destructor (procedure_LOCAL_NAME);
7887 when Pragma_Linker_Constructor |
7888 Pragma_Linker_Destructor
=>
7889 Linker_Constructor
: declare
7895 Check_Arg_Count
(1);
7896 Check_No_Identifiers
;
7897 Check_Arg_Is_Local_Name
(Arg1
);
7898 Arg1_X
:= Expression
(Arg1
);
7900 Proc
:= Find_Unique_Parameterless_Procedure
(Arg1_X
, Arg1
);
7902 if not Is_Library_Level_Entity
(Proc
) then
7904 ("argument for pragma% must be library level entity", Arg1
);
7907 -- The only processing required is to link this item on to the
7908 -- list of rep items for the given entity. This is accomplished
7909 -- by the call to Rep_Item_Too_Late (when no error is detected
7910 -- and False is returned).
7912 if Rep_Item_Too_Late
(Proc
, N
) then
7915 Set_Has_Gigi_Rep_Item
(Proc
);
7917 end Linker_Constructor
;
7919 --------------------
7920 -- Linker_Options --
7921 --------------------
7923 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
7925 when Pragma_Linker_Options
=> Linker_Options
: declare
7929 Check_Ada_83_Warning
;
7930 Check_No_Identifiers
;
7931 Check_Arg_Count
(1);
7932 Check_Is_In_Decl_Part_Or_Package_Spec
;
7934 if Operating_Mode
= Generate_Code
7935 and then In_Extended_Main_Source_Unit
(N
)
7937 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7938 Start_String
(Strval
(Expr_Value_S
(Expression
(Arg1
))));
7941 while Present
(Arg
) loop
7942 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
7943 Store_String_Char
(ASCII
.NUL
);
7945 (Strval
(Expr_Value_S
(Expression
(Arg
))));
7949 Store_Linker_Option_String
(End_String
);
7953 --------------------
7954 -- Linker_Section --
7955 --------------------
7957 -- pragma Linker_Section (
7958 -- [Entity =>] LOCAL_NAME
7959 -- [Section =>] static_string_EXPRESSION);
7961 when Pragma_Linker_Section
=>
7963 Check_Arg_Order
((Name_Entity
, Name_Section
));
7964 Check_Arg_Count
(2);
7965 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7966 Check_Optional_Identifier
(Arg2
, Name_Section
);
7967 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
7968 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7970 -- The only processing required is to link this item on to the
7971 -- list of rep items for the given entity. This is accomplished
7972 -- by the call to Rep_Item_Too_Late (when no error is detected
7973 -- and False is returned).
7975 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
7978 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
7985 -- pragma List (On | Off)
7987 -- There is nothing to do here, since we did all the processing
7988 -- for this pragma in Par.Prag (so that it works properly even in
7989 -- syntax only mode)
7994 --------------------
7995 -- Locking_Policy --
7996 --------------------
7998 -- pragma Locking_Policy (policy_IDENTIFIER);
8000 when Pragma_Locking_Policy
=> declare
8004 Check_Ada_83_Warning
;
8005 Check_Arg_Count
(1);
8006 Check_No_Identifiers
;
8007 Check_Arg_Is_Locking_Policy
(Arg1
);
8008 Check_Valid_Configuration_Pragma
;
8009 Get_Name_String
(Chars
(Expression
(Arg1
)));
8010 LP
:= Fold_Upper
(Name_Buffer
(1));
8012 if Locking_Policy
/= ' '
8013 and then Locking_Policy
/= LP
8015 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
8016 Error_Pragma
("locking policy incompatible with policy#");
8018 -- Set new policy, but always preserve System_Location since
8019 -- we like the error message with the run time name.
8022 Locking_Policy
:= LP
;
8024 if Locking_Policy_Sloc
/= System_Location
then
8025 Locking_Policy_Sloc
:= Loc
;
8034 -- pragma Long_Float (D_Float | G_Float);
8036 when Pragma_Long_Float
=>
8038 Check_Valid_Configuration_Pragma
;
8039 Check_Arg_Count
(1);
8040 Check_No_Identifier
(Arg1
);
8041 Check_Arg_Is_One_Of
(Arg1
, Name_D_Float
, Name_G_Float
);
8043 if not OpenVMS_On_Target
then
8044 Error_Pragma
("?pragma% ignored (applies only to Open'V'M'S)");
8049 if Chars
(Expression
(Arg1
)) = Name_D_Float
then
8050 if Opt
.Float_Format_Long
= 'G' then
8051 Error_Pragma
("G_Float previously specified");
8054 Opt
.Float_Format_Long
:= 'D';
8056 -- G_Float case (this is the default, does not need overriding)
8059 if Opt
.Float_Format_Long
= 'D' then
8060 Error_Pragma
("D_Float previously specified");
8063 Opt
.Float_Format_Long
:= 'G';
8066 Set_Standard_Fpt_Formats
;
8068 -----------------------
8069 -- Machine_Attribute --
8070 -----------------------
8072 -- pragma Machine_Attribute (
8073 -- [Entity =>] LOCAL_NAME,
8074 -- [Attribute_Name =>] static_string_EXPRESSION
8075 -- [,[Info =>] static_string_EXPRESSION] );
8077 when Pragma_Machine_Attribute
=> Machine_Attribute
: declare
8082 Check_Arg_Order
((Name_Entity
, Name_Attribute_Name
, Name_Info
));
8084 if Arg_Count
= 3 then
8085 Check_Optional_Identifier
(Arg3
, Name_Info
);
8086 Check_Arg_Is_Static_Expression
(Arg3
, Standard_String
);
8088 Check_Arg_Count
(2);
8091 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8092 Check_Optional_Identifier
(Arg2
, Name_Attribute_Name
);
8093 Check_Arg_Is_Local_Name
(Arg1
);
8094 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
8095 Def_Id
:= Entity
(Expression
(Arg1
));
8097 if Is_Access_Type
(Def_Id
) then
8098 Def_Id
:= Designated_Type
(Def_Id
);
8101 if Rep_Item_Too_Early
(Def_Id
, N
) then
8105 Def_Id
:= Underlying_Type
(Def_Id
);
8107 -- The only processing required is to link this item on to the
8108 -- list of rep items for the given entity. This is accomplished
8109 -- by the call to Rep_Item_Too_Late (when no error is detected
8110 -- and False is returned).
8112 if Rep_Item_Too_Late
(Def_Id
, N
) then
8115 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
8117 end Machine_Attribute
;
8124 -- (MAIN_OPTION [, MAIN_OPTION]);
8127 -- [STACK_SIZE =>] static_integer_EXPRESSION
8128 -- | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
8129 -- | [TIME_SLICING_ENABLED =>] static_boolean_EXPRESSION
8131 when Pragma_Main
=> Main
: declare
8132 Args
: Args_List
(1 .. 3);
8133 Names
: constant Name_List
(1 .. 3) := (
8135 Name_Task_Stack_Size_Default
,
8136 Name_Time_Slicing_Enabled
);
8142 Gather_Associations
(Names
, Args
);
8144 for J
in 1 .. 2 loop
8145 if Present
(Args
(J
)) then
8146 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
8150 if Present
(Args
(3)) then
8151 Check_Arg_Is_Static_Expression
(Args
(3), Standard_Boolean
);
8155 while Present
(Nod
) loop
8156 if Nkind
(Nod
) = N_Pragma
8157 and then Chars
(Nod
) = Name_Main
8159 Error_Msg_Name_1
:= Chars
(N
);
8160 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
8171 -- pragma Main_Storage
8172 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
8174 -- MAIN_STORAGE_OPTION ::=
8175 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
8176 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
8178 when Pragma_Main_Storage
=> Main_Storage
: declare
8179 Args
: Args_List
(1 .. 2);
8180 Names
: constant Name_List
(1 .. 2) := (
8181 Name_Working_Storage
,
8188 Gather_Associations
(Names
, Args
);
8190 for J
in 1 .. 2 loop
8191 if Present
(Args
(J
)) then
8192 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
8196 Check_In_Main_Program
;
8199 while Present
(Nod
) loop
8200 if Nkind
(Nod
) = N_Pragma
8201 and then Chars
(Nod
) = Name_Main_Storage
8203 Error_Msg_Name_1
:= Chars
(N
);
8204 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
8215 -- pragma Memory_Size (NUMERIC_LITERAL)
8217 when Pragma_Memory_Size
=>
8220 -- Memory size is simply ignored
8222 Check_No_Identifiers
;
8223 Check_Arg_Count
(1);
8224 Check_Arg_Is_Integer_Literal
(Arg1
);
8232 -- The only correct use of this pragma is on its own in a file, in
8233 -- which case it is specially processed (see Gnat1drv.Check_Bad_Body
8234 -- and Frontend, which use Sinput.L.Source_File_Is_Pragma_No_Body to
8235 -- check for a file containing nothing but a No_Body pragma). If we
8236 -- attempt to process it during normal semantics processing, it means
8237 -- it was misplaced.
8239 when Pragma_No_Body
=>
8240 Error_Pragma
("misplaced pragma %");
8246 -- pragma No_Return (procedure_LOCAL_NAME {, procedure_Local_Name});
8248 when Pragma_No_Return
=> No_Return
: declare
8256 Check_At_Least_N_Arguments
(1);
8258 -- Loop through arguments of pragma
8261 while Present
(Arg
) loop
8262 Check_Arg_Is_Local_Name
(Arg
);
8263 Id
:= Expression
(Arg
);
8266 if not Is_Entity_Name
(Id
) then
8267 Error_Pragma_Arg
("entity name required", Arg
);
8270 if Etype
(Id
) = Any_Type
then
8274 -- Loop to find matching procedures
8279 and then Scope
(E
) = Current_Scope
8281 if Ekind
(E
) = E_Procedure
8282 or else Ekind
(E
) = E_Generic_Procedure
8292 Error_Pragma_Arg
("no procedure & found for pragma%", Arg
);
8299 ------------------------
8300 -- No_Strict_Aliasing --
8301 ------------------------
8303 -- pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
8305 when Pragma_No_Strict_Aliasing
=> No_Strict_Alias
: declare
8310 Check_At_Most_N_Arguments
(1);
8312 if Arg_Count
= 0 then
8313 Check_Valid_Configuration_Pragma
;
8314 Opt
.No_Strict_Aliasing
:= True;
8317 Check_Optional_Identifier
(Arg2
, Name_Entity
);
8318 Check_Arg_Is_Local_Name
(Arg1
);
8319 E_Id
:= Entity
(Expression
(Arg1
));
8321 if E_Id
= Any_Type
then
8323 elsif No
(E_Id
) or else not Is_Access_Type
(E_Id
) then
8324 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
8327 Set_No_Strict_Aliasing
(Implementation_Base_Type
(E_Id
));
8329 end No_Strict_Alias
;
8335 -- pragma Obsolescent [(
8336 -- [Entity => NAME,]
8337 -- [(static_string_EXPRESSION [, Ada_05])];
8339 when Pragma_Obsolescent
=> Obsolescent
: declare
8343 procedure Set_Obsolescent
(E
: Entity_Id
);
8344 -- Given an entity Ent, mark it as obsolescent if appropriate
8346 ---------------------
8347 -- Set_Obsolescent --
8348 ---------------------
8350 procedure Set_Obsolescent
(E
: Entity_Id
) is
8359 -- Entity name was given
8361 if Present
(Ename
) then
8363 -- If entity name matches, we are fine
8365 if Chars
(Ename
) = Chars
(Ent
) then
8368 -- If entity name does not match, only possibility is an
8369 -- enumeration literal from an enumeration type declaration.
8371 elsif Ekind
(Ent
) /= E_Enumeration_Type
then
8373 ("pragma % entity name does not match declaration");
8376 Ent
:= First_Literal
(E
);
8380 ("pragma % entity name does not match any " &
8381 "enumeration literal");
8383 elsif Chars
(Ent
) = Chars
(Ename
) then
8387 Ent
:= Next_Literal
(Ent
);
8393 -- Ent points to entity to be marked
8395 if Arg_Count
>= 1 then
8397 -- Deal with static string argument
8399 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
8400 S
:= Strval
(Expression
(Arg1
));
8402 for J
in 1 .. String_Length
(S
) loop
8403 if not In_Character_Range
(Get_String_Char
(S
, J
)) then
8405 ("pragma% argument does not allow wide characters",
8410 Set_Obsolescent_Warning
(Ent
, Expression
(Arg1
));
8412 -- Check for Ada_05 parameter
8414 if Arg_Count
/= 1 then
8415 Check_Arg_Count
(2);
8418 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg2
);
8421 Check_Arg_Is_Identifier
(Argx
);
8423 if Chars
(Argx
) /= Name_Ada_05
then
8424 Error_Msg_Name_2
:= Name_Ada_05
;
8426 ("only allowed argument for pragma% is %", Argx
);
8429 if Ada_Version_Explicit
< Ada_05
8430 or else not Warn_On_Ada_2005_Compatibility
8438 -- Set flag if pragma active
8441 Set_Is_Obsolescent
(Ent
);
8445 end Set_Obsolescent
;
8447 -- Start of processing for pragma Obsolescent
8452 Check_At_Most_N_Arguments
(3);
8454 -- See if first argument specifies an entity name
8457 and then Chars
(Arg1
) = Name_Entity
8459 Ename
:= Get_Pragma_Arg
(Arg1
);
8461 if Nkind
(Ename
) /= N_Character_Literal
8463 Nkind
(Ename
) /= N_Identifier
8465 Nkind
(Ename
) /= N_Operator_Symbol
8467 Error_Pragma_Arg
("entity name expected for pragma%", Arg1
);
8470 -- Eliminate first argument, so we can share processing
8474 Arg_Count
:= Arg_Count
- 1;
8476 -- No Entity name argument given
8482 Check_No_Identifiers
;
8484 -- Get immediately preceding declaration
8487 while Present
(Decl
) and then Nkind
(Decl
) = N_Pragma
loop
8491 -- Cases where we do not follow anything other than another pragma
8495 -- First case: library level compilation unit declaration with
8496 -- the pragma immediately following the declaration.
8498 if Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
8500 (Defining_Entity
(Unit
(Parent
(Parent
(N
)))));
8503 -- Case 2: library unit placement for package
8507 Ent
: constant Entity_Id
:= Find_Lib_Unit_Name
;
8509 if Ekind
(Ent
) = E_Package
8510 or else Ekind
(Ent
) = E_Generic_Package
8512 Set_Obsolescent
(Ent
);
8518 -- Cases where we must follow a declaration
8521 if Nkind
(Decl
) not in N_Declaration
8522 and then Nkind
(Decl
) not in N_Later_Decl_Item
8523 and then Nkind
(Decl
) not in N_Generic_Declaration
8526 ("pragma% misplaced, " &
8527 "must immediately follow a declaration");
8530 Set_Obsolescent
(Defining_Entity
(Decl
));
8540 -- pragma No_Run_Time
8542 -- Note: this pragma is retained for backwards compatibiltiy.
8543 -- See body of Rtsfind for full details on its handling.
8545 when Pragma_No_Run_Time
=>
8547 Check_Valid_Configuration_Pragma
;
8548 Check_Arg_Count
(0);
8550 No_Run_Time_Mode
:= True;
8551 Configurable_Run_Time_Mode
:= True;
8554 Word32
: constant Boolean := Ttypes
.System_Word_Size
= 32;
8557 Duration_32_Bits_On_Target
:= True;
8561 Set_Restriction
(No_Finalization
, N
);
8562 Set_Restriction
(No_Exception_Handlers
, N
);
8563 Set_Restriction
(Max_Tasks
, N
, 0);
8564 Set_Restriction
(No_Tasking
, N
);
8566 -----------------------
8567 -- Normalize_Scalars --
8568 -----------------------
8570 -- pragma Normalize_Scalars;
8572 when Pragma_Normalize_Scalars
=>
8573 Check_Ada_83_Warning
;
8574 Check_Arg_Count
(0);
8575 Check_Valid_Configuration_Pragma
;
8576 Normalize_Scalars
:= True;
8577 Init_Or_Norm_Scalars
:= True;
8583 -- pragma Optimize (Time | Space);
8585 -- The actual check for optimize is done in Gigi. Note that this
8586 -- pragma does not actually change the optimization setting, it
8587 -- simply checks that it is consistent with the pragma.
8589 when Pragma_Optimize
=>
8590 Check_No_Identifiers
;
8591 Check_Arg_Count
(1);
8592 Check_Arg_Is_One_Of
(Arg1
, Name_Time
, Name_Space
, Name_Off
);
8598 -- pragma Pack (first_subtype_LOCAL_NAME);
8600 when Pragma_Pack
=> Pack
: declare
8601 Assoc
: constant Node_Id
:= Arg1
;
8606 Check_No_Identifiers
;
8607 Check_Arg_Count
(1);
8608 Check_Arg_Is_Local_Name
(Arg1
);
8610 Type_Id
:= Expression
(Assoc
);
8611 Find_Type
(Type_Id
);
8612 Typ
:= Entity
(Type_Id
);
8615 or else Rep_Item_Too_Early
(Typ
, N
)
8619 Typ
:= Underlying_Type
(Typ
);
8622 if not Is_Array_Type
(Typ
) and then not Is_Record_Type
(Typ
) then
8623 Error_Pragma
("pragma% must specify array or record type");
8626 Check_First_Subtype
(Arg1
);
8628 if Has_Pragma_Pack
(Typ
) then
8629 Error_Pragma
("duplicate pragma%, only one allowed");
8633 elsif Is_Array_Type
(Typ
) then
8635 -- Pack not allowed for aliased or atomic components
8637 if Has_Aliased_Components
(Base_Type
(Typ
)) then
8639 ("pragma% ignored, cannot pack aliased components?");
8641 elsif Has_Atomic_Components
(Typ
)
8642 or else Is_Atomic
(Component_Type
(Typ
))
8645 ("?pragma% ignored, cannot pack atomic components");
8648 -- If we had an explicit component size given, then we do not
8649 -- let Pack override this given size. We also give a warning
8650 -- that Pack is being ignored unless we can tell for sure that
8651 -- the Pack would not have had any effect anyway.
8653 if Has_Component_Size_Clause
(Typ
) then
8654 if Known_Static_RM_Size
(Component_Type
(Typ
))
8656 RM_Size
(Component_Type
(Typ
)) = Component_Size
(Typ
)
8661 ("?pragma% ignored, explicit component size given");
8664 -- If no prior array component size given, Pack is effective
8667 if not Rep_Item_Too_Late
(Typ
, N
) then
8668 if VM_Target
= No_VM
then
8669 Set_Is_Packed
(Base_Type
(Typ
));
8670 elsif not GNAT_Mode
then
8672 ("?pragma% ignored in this configuration");
8675 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
8676 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
8680 -- For record types, the pack is always effective
8682 else pragma Assert
(Is_Record_Type
(Typ
));
8683 if not Rep_Item_Too_Late
(Typ
, N
) then
8684 if VM_Target
= No_VM
then
8685 Set_Is_Packed
(Base_Type
(Typ
));
8686 elsif not GNAT_Mode
then
8687 Error_Pragma
("?pragma% ignored in this configuration");
8690 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
8691 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
8702 -- There is nothing to do here, since we did all the processing
8703 -- for this pragma in Par.Prag (so that it works properly even in
8704 -- syntax only mode)
8713 -- pragma Passive [(PASSIVE_FORM)];
8715 -- PASSIVE_FORM ::= Semaphore | No
8717 when Pragma_Passive
=>
8720 if Nkind
(Parent
(N
)) /= N_Task_Definition
then
8721 Error_Pragma
("pragma% must be within task definition");
8724 if Arg_Count
/= 0 then
8725 Check_Arg_Count
(1);
8726 Check_Arg_Is_One_Of
(Arg1
, Name_Semaphore
, Name_No
);
8729 ----------------------------------
8730 -- Preelaborable_Initialization --
8731 ----------------------------------
8733 -- pragma Preelaborable_Initialization (DIRECT_NAME);
8735 when Pragma_Preelaborable_Initialization
=> Preelab_Init
: declare
8740 Check_Arg_Count
(1);
8741 Check_No_Identifiers
;
8742 Check_Arg_Is_Identifier
(Arg1
);
8743 Check_Arg_Is_Local_Name
(Arg1
);
8744 Check_First_Subtype
(Arg1
);
8745 Ent
:= Entity
(Expression
(Arg1
));
8747 if not Is_Private_Type
(Ent
) then
8749 ("pragma % can only be applied to private type", Arg1
);
8752 Set_Known_To_Have_Preelab_Init
(Ent
);
8754 if Has_Pragma_Preelab_Init
(Ent
)
8755 and then Warn_On_Redundant_Constructs
8757 Error_Pragma
("?duplicate pragma%!");
8759 Set_Has_Pragma_Preelab_Init
(Ent
);
8767 -- pragma Polling (ON | OFF);
8769 when Pragma_Polling
=>
8771 Check_Arg_Count
(1);
8772 Check_No_Identifiers
;
8773 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
8774 Polling_Required
:= (Chars
(Expression
(Arg1
)) = Name_On
);
8776 --------------------
8777 -- Persistent_BSS --
8778 --------------------
8780 when Pragma_Persistent_BSS
=> Persistent_BSS
: declare
8787 Check_At_Most_N_Arguments
(1);
8789 -- Case of application to specific object (one argument)
8791 if Arg_Count
= 1 then
8792 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
8794 if not Is_Entity_Name
(Expression
(Arg1
))
8796 (Ekind
(Entity
(Expression
(Arg1
))) /= E_Variable
8797 and then Ekind
(Entity
(Expression
(Arg1
))) /= E_Constant
)
8799 Error_Pragma_Arg
("pragma% only applies to objects", Arg1
);
8802 Ent
:= Entity
(Expression
(Arg1
));
8803 Decl
:= Parent
(Ent
);
8805 if Rep_Item_Too_Late
(Ent
, N
) then
8809 if Present
(Expression
(Decl
)) then
8811 ("object for pragma% cannot have initialization", Arg1
);
8814 if not Is_Potentially_Persistent_Type
(Etype
(Ent
)) then
8816 ("object type for pragma% is not potentially persistent",
8821 Make_Linker_Section_Pragma
8822 (Ent
, Sloc
(N
), ".persistent.bss");
8823 Insert_After
(N
, Prag
);
8826 -- Case of use as configuration pragma with no arguments
8829 Check_Valid_Configuration_Pragma
;
8830 Persistent_BSS_Mode
:= True;
8838 -- pragma Preelaborate [(library_unit_NAME)];
8840 -- Set the flag Is_Preelaborated of program unit name entity
8842 when Pragma_Preelaborate
=> Preelaborate
: declare
8843 Pa
: constant Node_Id
:= Parent
(N
);
8844 Pk
: constant Node_Kind
:= Nkind
(Pa
);
8848 Check_Ada_83_Warning
;
8849 Check_Valid_Library_Unit_Pragma
;
8851 if Nkind
(N
) = N_Null_Statement
then
8855 Ent
:= Find_Lib_Unit_Name
;
8857 -- This filters out pragmas inside generic parent then
8858 -- show up inside instantiation
8861 and then not (Pk
= N_Package_Specification
8862 and then Present
(Generic_Parent
(Pa
)))
8864 if not Debug_Flag_U
then
8865 Set_Is_Preelaborated
(Ent
);
8866 Set_Suppress_Elaboration_Warnings
(Ent
);
8871 ---------------------
8872 -- Preelaborate_05 --
8873 ---------------------
8875 -- pragma Preelaborate_05 [(library_unit_NAME)];
8877 -- This pragma is useable only in GNAT_Mode, where it is used like
8878 -- pragma Preelaborate but it is only effective in Ada 2005 mode
8879 -- (otherwise it is ignored). This is used to implement AI-362 which
8880 -- recategorizes some run-time packages in Ada 2005 mode.
8882 when Pragma_Preelaborate_05
=> Preelaborate_05
: declare
8887 Check_Valid_Library_Unit_Pragma
;
8889 if not GNAT_Mode
then
8890 Error_Pragma
("pragma% only available in GNAT mode");
8893 if Nkind
(N
) = N_Null_Statement
then
8897 -- This is one of the few cases where we need to test the value of
8898 -- Ada_Version_Explicit rather than Ada_Version (which is always
8899 -- set to Ada_05 in a predefined unit), we need to know the
8900 -- explicit version set to know if this pragma is active.
8902 if Ada_Version_Explicit
>= Ada_05
then
8903 Ent
:= Find_Lib_Unit_Name
;
8904 Set_Is_Preelaborated
(Ent
);
8905 Set_Suppress_Elaboration_Warnings
(Ent
);
8907 end Preelaborate_05
;
8913 -- pragma Priority (EXPRESSION);
8915 when Pragma_Priority
=> Priority
: declare
8916 P
: constant Node_Id
:= Parent
(N
);
8920 Check_No_Identifiers
;
8921 Check_Arg_Count
(1);
8925 if Nkind
(P
) = N_Subprogram_Body
then
8926 Check_In_Main_Program
;
8928 Arg
:= Expression
(Arg1
);
8929 Analyze_And_Resolve
(Arg
, Standard_Integer
);
8933 if not Is_Static_Expression
(Arg
) then
8934 Flag_Non_Static_Expr
8935 ("main subprogram priority is not static!", Arg
);
8938 -- If constraint error, then we already signalled an error
8940 elsif Raises_Constraint_Error
(Arg
) then
8943 -- Otherwise check in range
8947 Val
: constant Uint
:= Expr_Value
(Arg
);
8951 or else Val
> Expr_Value
(Expression
8952 (Parent
(RTE
(RE_Max_Priority
))))
8955 ("main subprogram priority is out of range", Arg1
);
8961 (Current_Sem_Unit
, UI_To_Int
(Expr_Value
(Arg
)));
8963 -- Load an arbitrary entity from System.Tasking to make sure
8964 -- this package is implicitly with'ed, since we need to have
8965 -- the tasking run-time active for the pragma Priority to have
8969 Discard
: Entity_Id
;
8970 pragma Warnings
(Off
, Discard
);
8972 Discard
:= RTE
(RE_Task_List
);
8975 -- Task or Protected, must be of type Integer
8977 elsif Nkind
(P
) = N_Protected_Definition
8979 Nkind
(P
) = N_Task_Definition
8981 Arg
:= Expression
(Arg1
);
8983 -- The expression must be analyzed in the special manner
8984 -- described in "Handling of Default and Per-Object
8985 -- Expressions" in sem.ads.
8987 Analyze_Per_Use_Expression
(Arg
, Standard_Integer
);
8989 if not Is_Static_Expression
(Arg
) then
8990 Check_Restriction
(Static_Priorities
, Arg
);
8993 -- Anything else is incorrect
8999 if Has_Priority_Pragma
(P
) then
9000 Error_Pragma
("duplicate pragma% not allowed");
9002 Set_Has_Priority_Pragma
(P
, True);
9004 if Nkind
(P
) = N_Protected_Definition
9006 Nkind
(P
) = N_Task_Definition
9008 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
9009 -- exp_ch9 should use this ???
9014 -----------------------------------
9015 -- Priority_Specific_Dispatching --
9016 -----------------------------------
9018 -- pragma Priority_Specific_Dispatching (
9019 -- policy_IDENTIFIER,
9020 -- first_priority_EXPRESSION,
9021 -- last_priority_EXPRESSION);
9023 when Pragma_Priority_Specific_Dispatching
=>
9024 Priority_Specific_Dispatching
: declare
9025 Prio_Id
: constant Entity_Id
:= RTE
(RE_Any_Priority
);
9026 -- This is the entity System.Any_Priority;
9029 Lower_Bound
: Node_Id
;
9030 Upper_Bound
: Node_Id
;
9036 Check_Arg_Count
(3);
9037 Check_No_Identifiers
;
9038 Check_Arg_Is_Task_Dispatching_Policy
(Arg1
);
9039 Check_Valid_Configuration_Pragma
;
9040 Get_Name_String
(Chars
(Expression
(Arg1
)));
9041 DP
:= Fold_Upper
(Name_Buffer
(1));
9043 Lower_Bound
:= Expression
(Arg2
);
9044 Check_Arg_Is_Static_Expression
(Lower_Bound
, Standard_Integer
);
9045 Lower_Val
:= Expr_Value
(Lower_Bound
);
9047 Upper_Bound
:= Expression
(Arg3
);
9048 Check_Arg_Is_Static_Expression
(Upper_Bound
, Standard_Integer
);
9049 Upper_Val
:= Expr_Value
(Upper_Bound
);
9051 -- It is not allowed to use Task_Dispatching_Policy and
9052 -- Priority_Specific_Dispatching in the same partition.
9054 if Task_Dispatching_Policy
/= ' ' then
9055 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
9057 ("pragma% incompatible with Task_Dispatching_Policy#");
9059 -- Check lower bound in range
9061 elsif Lower_Val
< Expr_Value
(Type_Low_Bound
(Prio_Id
))
9063 Lower_Val
> Expr_Value
(Type_High_Bound
(Prio_Id
))
9066 ("first_priority is out of range", Arg2
);
9068 -- Check upper bound in range
9070 elsif Upper_Val
< Expr_Value
(Type_Low_Bound
(Prio_Id
))
9072 Upper_Val
> Expr_Value
(Type_High_Bound
(Prio_Id
))
9075 ("last_priority is out of range", Arg3
);
9077 -- Check that the priority range is valid
9079 elsif Lower_Val
> Upper_Val
then
9081 ("last_priority_expression must be greater than" &
9082 " or equal to first_priority_expression");
9084 -- Store the new policy, but always preserve System_Location since
9085 -- we like the error message with the run-time name.
9088 -- Check overlapping in the priority ranges specified in other
9089 -- Priority_Specific_Dispatching pragmas within the same
9090 -- partition. We can only check those we know about!
9093 Specific_Dispatching
.First
.. Specific_Dispatching
.Last
9095 if Specific_Dispatching
.Table
(J
).First_Priority
in
9096 UI_To_Int
(Lower_Val
) .. UI_To_Int
(Upper_Val
)
9097 or else Specific_Dispatching
.Table
(J
).Last_Priority
in
9098 UI_To_Int
(Lower_Val
) .. UI_To_Int
(Upper_Val
)
9101 Specific_Dispatching
.Table
(J
).Pragma_Loc
;
9103 ("priority range overlaps with "
9104 & "Priority_Specific_Dispatching#");
9108 -- The use of Priority_Specific_Dispatching is incompatible
9109 -- with Task_Dispatching_Policy.
9111 if Task_Dispatching_Policy
/= ' ' then
9112 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
9114 ("Priority_Specific_Dispatching incompatible "
9115 & "with Task_Dispatching_Policy#");
9118 -- The use of Priority_Specific_Dispatching forces ceiling
9121 if Locking_Policy
/= ' ' and then Locking_Policy
/= 'C' then
9122 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
9124 ("Priority_Specific_Dispatching incompatible "
9125 & "with Locking_Policy#");
9127 -- Set the Ceiling_Locking policy, but preserve System_Location
9128 -- since we like the error message with the run time name.
9131 Locking_Policy
:= 'C';
9133 if Locking_Policy_Sloc
/= System_Location
then
9134 Locking_Policy_Sloc
:= Loc
;
9138 -- Add entry in the table
9140 Specific_Dispatching
.Append
9141 ((Dispatching_Policy
=> DP
,
9142 First_Priority
=> UI_To_Int
(Lower_Val
),
9143 Last_Priority
=> UI_To_Int
(Upper_Val
),
9144 Pragma_Loc
=> Loc
));
9146 end Priority_Specific_Dispatching
;
9152 -- pragma Profile (profile_IDENTIFIER);
9154 -- profile_IDENTIFIER => Protected | Ravenscar
9156 when Pragma_Profile
=>
9158 Check_Arg_Count
(1);
9159 Check_Valid_Configuration_Pragma
;
9160 Check_No_Identifiers
;
9163 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
9165 if Chars
(Argx
) = Name_Ravenscar
then
9166 Set_Ravenscar_Profile
(N
);
9167 elsif Chars
(Argx
) = Name_Restricted
then
9168 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> False);
9170 Error_Pragma_Arg
("& is not a valid profile", Argx
);
9174 ----------------------
9175 -- Profile_Warnings --
9176 ----------------------
9178 -- pragma Profile_Warnings (profile_IDENTIFIER);
9180 -- profile_IDENTIFIER => Protected | Ravenscar
9182 when Pragma_Profile_Warnings
=>
9184 Check_Arg_Count
(1);
9185 Check_Valid_Configuration_Pragma
;
9186 Check_No_Identifiers
;
9189 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
9191 if Chars
(Argx
) = Name_Ravenscar
then
9192 Set_Profile_Restrictions
(Ravenscar
, N
, Warn
=> True);
9193 elsif Chars
(Argx
) = Name_Restricted
then
9194 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> True);
9196 Error_Pragma_Arg
("& is not a valid profile", Argx
);
9200 --------------------------
9201 -- Propagate_Exceptions --
9202 --------------------------
9204 -- pragma Propagate_Exceptions;
9206 -- Note: this pragma is obsolete and has no effect
9208 when Pragma_Propagate_Exceptions
=>
9210 Check_Arg_Count
(0);
9212 if In_Extended_Main_Source_Unit
(N
) then
9213 Propagate_Exceptions
:= True;
9220 -- pragma Psect_Object (
9221 -- [Internal =>] LOCAL_NAME,
9222 -- [, [External =>] EXTERNAL_SYMBOL]
9223 -- [, [Size =>] EXTERNAL_SYMBOL]);
9225 when Pragma_Psect_Object | Pragma_Common_Object
=>
9226 Psect_Object
: declare
9227 Args
: Args_List
(1 .. 3);
9228 Names
: constant Name_List
(1 .. 3) := (
9233 Internal
: Node_Id
renames Args
(1);
9234 External
: Node_Id
renames Args
(2);
9235 Size
: Node_Id
renames Args
(3);
9239 procedure Check_Too_Long
(Arg
: Node_Id
);
9240 -- Posts message if the argument is an identifier with more
9241 -- than 31 characters, or a string literal with more than
9242 -- 31 characters, and we are operating under VMS
9244 --------------------
9245 -- Check_Too_Long --
9246 --------------------
9248 procedure Check_Too_Long
(Arg
: Node_Id
) is
9249 X
: constant Node_Id
:= Original_Node
(Arg
);
9252 if Nkind
(X
) /= N_String_Literal
9254 Nkind
(X
) /= N_Identifier
9257 ("inappropriate argument for pragma %", Arg
);
9260 if OpenVMS_On_Target
then
9261 if (Nkind
(X
) = N_String_Literal
9262 and then String_Length
(Strval
(X
)) > 31)
9264 (Nkind
(X
) = N_Identifier
9265 and then Length_Of_Name
(Chars
(X
)) > 31)
9268 ("argument for pragma % is longer than 31 characters",
9274 -- Start of processing for Common_Object/Psect_Object
9278 Gather_Associations
(Names
, Args
);
9279 Process_Extended_Import_Export_Internal_Arg
(Internal
);
9281 Def_Id
:= Entity
(Internal
);
9283 if Ekind
(Def_Id
) /= E_Constant
9284 and then Ekind
(Def_Id
) /= E_Variable
9287 ("pragma% must designate an object", Internal
);
9290 Check_Too_Long
(Internal
);
9292 if Is_Imported
(Def_Id
) or else Is_Exported
(Def_Id
) then
9294 ("cannot use pragma% for imported/exported object",
9298 if Is_Concurrent_Type
(Etype
(Internal
)) then
9300 ("cannot specify pragma % for task/protected object",
9304 if Has_Rep_Pragma
(Def_Id
, Name_Common_Object
)
9306 Has_Rep_Pragma
(Def_Id
, Name_Psect_Object
)
9308 Error_Msg_N
("?duplicate Common/Psect_Object pragma", N
);
9311 if Ekind
(Def_Id
) = E_Constant
then
9313 ("cannot specify pragma % for a constant", Internal
);
9316 if Is_Record_Type
(Etype
(Internal
)) then
9322 Ent
:= First_Entity
(Etype
(Internal
));
9323 while Present
(Ent
) loop
9324 Decl
:= Declaration_Node
(Ent
);
9326 if Ekind
(Ent
) = E_Component
9327 and then Nkind
(Decl
) = N_Component_Declaration
9328 and then Present
(Expression
(Decl
))
9329 and then Warn_On_Export_Import
9332 ("?object for pragma % has defaults", Internal
);
9342 if Present
(Size
) then
9343 Check_Too_Long
(Size
);
9346 if Present
(External
) then
9347 Check_Arg_Is_External_Name
(External
);
9348 Check_Too_Long
(External
);
9351 -- If all error tests pass, link pragma on to the rep item chain
9353 Record_Rep_Item
(Def_Id
, N
);
9360 -- pragma Pure [(library_unit_NAME)];
9362 when Pragma_Pure
=> Pure
: declare
9366 Check_Ada_83_Warning
;
9367 Check_Valid_Library_Unit_Pragma
;
9369 if Nkind
(N
) = N_Null_Statement
then
9373 Ent
:= Find_Lib_Unit_Name
;
9375 Set_Has_Pragma_Pure
(Ent
);
9376 Set_Suppress_Elaboration_Warnings
(Ent
);
9383 -- pragma Pure_05 [(library_unit_NAME)];
9385 -- This pragma is useable only in GNAT_Mode, where it is used like
9386 -- pragma Pure but it is only effective in Ada 2005 mode (otherwise
9387 -- it is ignored). It may be used after a pragma Preelaborate, in
9388 -- which case it overrides the effect of the pragma Preelaborate.
9389 -- This is used to implement AI-362 which recategorizes some run-time
9390 -- packages in Ada 2005 mode.
9392 when Pragma_Pure_05
=> Pure_05
: declare
9397 Check_Valid_Library_Unit_Pragma
;
9399 if not GNAT_Mode
then
9400 Error_Pragma
("pragma% only available in GNAT mode");
9402 if Nkind
(N
) = N_Null_Statement
then
9406 -- This is one of the few cases where we need to test the value of
9407 -- Ada_Version_Explicit rather than Ada_Version (which is always
9408 -- set to Ada_05 in a predefined unit), we need to know the
9409 -- explicit version set to know if this pragma is active.
9411 if Ada_Version_Explicit
>= Ada_05
then
9412 Ent
:= Find_Lib_Unit_Name
;
9413 Set_Is_Preelaborated
(Ent
, False);
9415 Set_Suppress_Elaboration_Warnings
(Ent
);
9423 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
9425 when Pragma_Pure_Function
=> Pure_Function
: declare
9429 Effective
: Boolean := False;
9433 Check_Arg_Count
(1);
9434 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9435 Check_Arg_Is_Local_Name
(Arg1
);
9436 E_Id
:= Expression
(Arg1
);
9438 if Error_Posted
(E_Id
) then
9442 -- Loop through homonyms (overloadings) of referenced entity
9448 Def_Id
:= Get_Base_Subprogram
(E
);
9450 if Ekind
(Def_Id
) /= E_Function
9451 and then Ekind
(Def_Id
) /= E_Generic_Function
9452 and then Ekind
(Def_Id
) /= E_Operator
9455 ("pragma% requires a function name", Arg1
);
9458 Set_Is_Pure
(Def_Id
);
9460 if not Has_Pragma_Pure_Function
(Def_Id
) then
9461 Set_Has_Pragma_Pure_Function
(Def_Id
);
9466 exit when No
(E
) or else Scope
(E
) /= Current_Scope
;
9470 and then Warn_On_Redundant_Constructs
9472 Error_Msg_NE
("pragma Pure_Function on& is redundant?",
9478 --------------------
9479 -- Queuing_Policy --
9480 --------------------
9482 -- pragma Queuing_Policy (policy_IDENTIFIER);
9484 when Pragma_Queuing_Policy
=> declare
9488 Check_Ada_83_Warning
;
9489 Check_Arg_Count
(1);
9490 Check_No_Identifiers
;
9491 Check_Arg_Is_Queuing_Policy
(Arg1
);
9492 Check_Valid_Configuration_Pragma
;
9493 Get_Name_String
(Chars
(Expression
(Arg1
)));
9494 QP
:= Fold_Upper
(Name_Buffer
(1));
9496 if Queuing_Policy
/= ' '
9497 and then Queuing_Policy
/= QP
9499 Error_Msg_Sloc
:= Queuing_Policy_Sloc
;
9500 Error_Pragma
("queuing policy incompatible with policy#");
9502 -- Set new policy, but always preserve System_Location since
9503 -- we like the error message with the run time name.
9506 Queuing_Policy
:= QP
;
9508 if Queuing_Policy_Sloc
/= System_Location
then
9509 Queuing_Policy_Sloc
:= Loc
;
9514 ---------------------------
9515 -- Remote_Call_Interface --
9516 ---------------------------
9518 -- pragma Remote_Call_Interface [(library_unit_NAME)];
9520 when Pragma_Remote_Call_Interface
=> Remote_Call_Interface
: declare
9521 Cunit_Node
: Node_Id
;
9522 Cunit_Ent
: Entity_Id
;
9526 Check_Ada_83_Warning
;
9527 Check_Valid_Library_Unit_Pragma
;
9529 if Nkind
(N
) = N_Null_Statement
then
9533 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
9534 K
:= Nkind
(Unit
(Cunit_Node
));
9535 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
9537 if K
= N_Package_Declaration
9538 or else K
= N_Generic_Package_Declaration
9539 or else K
= N_Subprogram_Declaration
9540 or else K
= N_Generic_Subprogram_Declaration
9541 or else (K
= N_Subprogram_Body
9542 and then Acts_As_Spec
(Unit
(Cunit_Node
)))
9547 "pragma% must apply to package or subprogram declaration");
9550 Set_Is_Remote_Call_Interface
(Cunit_Ent
);
9551 end Remote_Call_Interface
;
9557 -- pragma Remote_Types [(library_unit_NAME)];
9559 when Pragma_Remote_Types
=> Remote_Types
: declare
9560 Cunit_Node
: Node_Id
;
9561 Cunit_Ent
: Entity_Id
;
9564 Check_Ada_83_Warning
;
9565 Check_Valid_Library_Unit_Pragma
;
9567 if Nkind
(N
) = N_Null_Statement
then
9571 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
9572 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
9574 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
9576 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
9579 "pragma% can only apply to a package declaration");
9582 Set_Is_Remote_Types
(Cunit_Ent
);
9589 -- pragma Ravenscar;
9591 when Pragma_Ravenscar
=>
9593 Check_Arg_Count
(0);
9594 Check_Valid_Configuration_Pragma
;
9595 Set_Ravenscar_Profile
(N
);
9597 if Warn_On_Obsolescent_Feature
then
9599 ("pragma Ravenscar is an obsolescent feature?", N
);
9601 ("|use pragma Profile (Ravenscar) instead", N
);
9604 -------------------------
9605 -- Restricted_Run_Time --
9606 -------------------------
9608 -- pragma Restricted_Run_Time;
9610 when Pragma_Restricted_Run_Time
=>
9612 Check_Arg_Count
(0);
9613 Check_Valid_Configuration_Pragma
;
9614 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> False);
9616 if Warn_On_Obsolescent_Feature
then
9618 ("pragma Restricted_Run_Time is an obsolescent feature?", N
);
9620 ("|use pragma Profile (Restricted) instead", N
);
9627 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
9630 -- restriction_IDENTIFIER
9631 -- | restriction_parameter_IDENTIFIER => EXPRESSION
9633 when Pragma_Restrictions
=>
9634 Process_Restrictions_Or_Restriction_Warnings
(Warn
=> False);
9636 --------------------------
9637 -- Restriction_Warnings --
9638 --------------------------
9640 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
9643 -- restriction_IDENTIFIER
9644 -- | restriction_parameter_IDENTIFIER => EXPRESSION
9646 when Pragma_Restriction_Warnings
=>
9647 Process_Restrictions_Or_Restriction_Warnings
(Warn
=> True);
9653 -- pragma Reviewable;
9655 when Pragma_Reviewable
=>
9656 Check_Ada_83_Warning
;
9657 Check_Arg_Count
(0);
9664 -- pragma Share_Generic (NAME {, NAME});
9666 when Pragma_Share_Generic
=>
9668 Process_Generic_List
;
9674 -- pragma Shared (LOCAL_NAME);
9676 when Pragma_Shared
=>
9678 Process_Atomic_Shared_Volatile
;
9680 --------------------
9681 -- Shared_Passive --
9682 --------------------
9684 -- pragma Shared_Passive [(library_unit_NAME)];
9686 -- Set the flag Is_Shared_Passive of program unit name entity
9688 when Pragma_Shared_Passive
=> Shared_Passive
: declare
9689 Cunit_Node
: Node_Id
;
9690 Cunit_Ent
: Entity_Id
;
9693 Check_Ada_83_Warning
;
9694 Check_Valid_Library_Unit_Pragma
;
9696 if Nkind
(N
) = N_Null_Statement
then
9700 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
9701 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
9703 if Nkind
(Unit
(Cunit_Node
)) /= N_Package_Declaration
9705 Nkind
(Unit
(Cunit_Node
)) /= N_Generic_Package_Declaration
9708 "pragma% can only apply to a package declaration");
9711 Set_Is_Shared_Passive
(Cunit_Ent
);
9714 ----------------------
9715 -- Source_File_Name --
9716 ----------------------
9718 -- There are five forms for this pragma:
9720 -- pragma Source_File_Name (
9721 -- [UNIT_NAME =>] unit_NAME,
9722 -- BODY_FILE_NAME => STRING_LITERAL
9723 -- [, [INDEX =>] INTEGER_LITERAL]);
9725 -- pragma Source_File_Name (
9726 -- [UNIT_NAME =>] unit_NAME,
9727 -- SPEC_FILE_NAME => STRING_LITERAL
9728 -- [, [INDEX =>] INTEGER_LITERAL]);
9730 -- pragma Source_File_Name (
9731 -- BODY_FILE_NAME => STRING_LITERAL
9732 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9733 -- [, CASING => CASING_SPEC]);
9735 -- pragma Source_File_Name (
9736 -- SPEC_FILE_NAME => STRING_LITERAL
9737 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9738 -- [, CASING => CASING_SPEC]);
9740 -- pragma Source_File_Name (
9741 -- SUBUNIT_FILE_NAME => STRING_LITERAL
9742 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9743 -- [, CASING => CASING_SPEC]);
9745 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
9747 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
9748 -- Source_File_Name (SFN), however their usage is exclusive:
9749 -- SFN can only be used when no project file is used, while
9750 -- SFNP can only be used when a project file is used.
9752 -- No processing here. Processing was completed during parsing,
9753 -- since we need to have file names set as early as possible.
9754 -- Units are loaded well before semantic processing starts.
9756 -- The only processing we defer to this point is the check
9757 -- for correct placement.
9759 when Pragma_Source_File_Name
=>
9761 Check_Valid_Configuration_Pragma
;
9763 ------------------------------
9764 -- Source_File_Name_Project --
9765 ------------------------------
9767 -- See Source_File_Name for syntax
9769 -- No processing here. Processing was completed during parsing,
9770 -- since we need to have file names set as early as possible.
9771 -- Units are loaded well before semantic processing starts.
9773 -- The only processing we defer to this point is the check
9774 -- for correct placement.
9776 when Pragma_Source_File_Name_Project
=>
9778 Check_Valid_Configuration_Pragma
;
9780 -- Check that a pragma Source_File_Name_Project is used only
9781 -- in a configuration pragmas file.
9783 -- Pragmas Source_File_Name_Project should only be generated
9784 -- by the Project Manager in configuration pragmas files.
9786 -- This is really an ugly test. It seems to depend on some
9787 -- accidental and undocumented property. At the very least
9788 -- it needs to be documented, but it would be better to have
9789 -- a clean way of testing if we are in a configuration file???
9791 if Present
(Parent
(N
)) then
9793 ("pragma% can only appear in a configuration pragmas file");
9796 ----------------------
9797 -- Source_Reference --
9798 ----------------------
9800 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
9802 -- Nothing to do, all processing completed in Par.Prag, since we
9803 -- need the information for possible parser messages that are output
9805 when Pragma_Source_Reference
=>
9808 --------------------------------
9809 -- Static_Elaboration_Desired --
9810 --------------------------------
9812 -- pragma Static_Elaboration_Desired (DIRECT_NAME);
9814 when Pragma_Static_Elaboration_Desired
=>
9816 Check_At_Most_N_Arguments
(1);
9818 if Is_Compilation_Unit
(Current_Scope
)
9819 and then Ekind
(Current_Scope
) = E_Package
9821 Set_Static_Elaboration_Desired
(Current_Scope
, True);
9823 Error_Pragma
("pragma% must apply to a library-level package");
9830 -- pragma Storage_Size (EXPRESSION);
9832 when Pragma_Storage_Size
=> Storage_Size
: declare
9833 P
: constant Node_Id
:= Parent
(N
);
9837 Check_No_Identifiers
;
9838 Check_Arg_Count
(1);
9840 -- The expression must be analyzed in the special manner
9841 -- described in "Handling of Default Expressions" in sem.ads.
9843 -- Set In_Default_Expression for per-object case ???
9845 Arg
:= Expression
(Arg1
);
9846 Analyze_Per_Use_Expression
(Arg
, Any_Integer
);
9848 if not Is_Static_Expression
(Arg
) then
9849 Check_Restriction
(Static_Storage_Size
, Arg
);
9852 if Nkind
(P
) /= N_Task_Definition
then
9857 if Has_Storage_Size_Pragma
(P
) then
9858 Error_Pragma
("duplicate pragma% not allowed");
9860 Set_Has_Storage_Size_Pragma
(P
, True);
9863 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
9864 -- ??? exp_ch9 should use this!
9872 -- pragma Storage_Unit (NUMERIC_LITERAL);
9874 -- Only permitted argument is System'Storage_Unit value
9876 when Pragma_Storage_Unit
=>
9877 Check_No_Identifiers
;
9878 Check_Arg_Count
(1);
9879 Check_Arg_Is_Integer_Literal
(Arg1
);
9881 if Intval
(Expression
(Arg1
)) /=
9882 UI_From_Int
(Ttypes
.System_Storage_Unit
)
9884 Error_Msg_Uint_1
:= UI_From_Int
(Ttypes
.System_Storage_Unit
);
9886 ("the only allowed argument for pragma% is ^", Arg1
);
9889 --------------------
9890 -- Stream_Convert --
9891 --------------------
9893 -- pragma Stream_Convert (
9894 -- [Entity =>] type_LOCAL_NAME,
9895 -- [Read =>] function_NAME,
9896 -- [Write =>] function NAME);
9898 when Pragma_Stream_Convert
=> Stream_Convert
: declare
9900 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
);
9901 -- Check that the given argument is the name of a local
9902 -- function of one argument that is not overloaded earlier
9903 -- in the current local scope. A check is also made that the
9904 -- argument is a function with one parameter.
9906 --------------------------------------
9907 -- Check_OK_Stream_Convert_Function --
9908 --------------------------------------
9910 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
) is
9914 Check_Arg_Is_Local_Name
(Arg
);
9915 Ent
:= Entity
(Expression
(Arg
));
9917 if Has_Homonym
(Ent
) then
9919 ("argument for pragma% may not be overloaded", Arg
);
9922 if Ekind
(Ent
) /= E_Function
9923 or else No
(First_Formal
(Ent
))
9924 or else Present
(Next_Formal
(First_Formal
(Ent
)))
9927 ("argument for pragma% must be" &
9928 " function of one argument", Arg
);
9930 end Check_OK_Stream_Convert_Function
;
9932 -- Start of procecessing for Stream_Convert
9936 Check_Arg_Order
((Name_Entity
, Name_Read
, Name_Write
));
9937 Check_Arg_Count
(3);
9938 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9939 Check_Optional_Identifier
(Arg2
, Name_Read
);
9940 Check_Optional_Identifier
(Arg3
, Name_Write
);
9941 Check_Arg_Is_Local_Name
(Arg1
);
9942 Check_OK_Stream_Convert_Function
(Arg2
);
9943 Check_OK_Stream_Convert_Function
(Arg3
);
9946 Typ
: constant Entity_Id
:=
9947 Underlying_Type
(Entity
(Expression
(Arg1
)));
9948 Read
: constant Entity_Id
:= Entity
(Expression
(Arg2
));
9949 Write
: constant Entity_Id
:= Entity
(Expression
(Arg3
));
9952 if Etype
(Typ
) = Any_Type
9954 Etype
(Read
) = Any_Type
9956 Etype
(Write
) = Any_Type
9961 Check_First_Subtype
(Arg1
);
9963 if Rep_Item_Too_Early
(Typ
, N
)
9965 Rep_Item_Too_Late
(Typ
, N
)
9970 if Underlying_Type
(Etype
(Read
)) /= Typ
then
9972 ("incorrect return type for function&", Arg2
);
9975 if Underlying_Type
(Etype
(First_Formal
(Write
))) /= Typ
then
9977 ("incorrect parameter type for function&", Arg3
);
9980 if Underlying_Type
(Etype
(First_Formal
(Read
))) /=
9981 Underlying_Type
(Etype
(Write
))
9984 ("result type of & does not match Read parameter type",
9990 -------------------------
9991 -- Style_Checks (GNAT) --
9992 -------------------------
9994 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
9996 -- This is processed by the parser since some of the style
9997 -- checks take place during source scanning and parsing. This
9998 -- means that we don't need to issue error messages here.
10000 when Pragma_Style_Checks
=> Style_Checks
: declare
10001 A
: constant Node_Id
:= Expression
(Arg1
);
10007 Check_No_Identifiers
;
10009 -- Two argument form
10011 if Arg_Count
= 2 then
10012 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
10019 E_Id
:= Expression
(Arg2
);
10022 if not Is_Entity_Name
(E_Id
) then
10024 ("second argument of pragma% must be entity name",
10028 E
:= Entity
(E_Id
);
10034 Set_Suppress_Style_Checks
(E
,
10035 (Chars
(Expression
(Arg1
)) = Name_Off
));
10036 exit when No
(Homonym
(E
));
10042 -- One argument form
10045 Check_Arg_Count
(1);
10047 if Nkind
(A
) = N_String_Literal
then
10051 Slen
: constant Natural := Natural (String_Length
(S
));
10052 Options
: String (1 .. Slen
);
10058 C
:= Get_String_Char
(S
, Int
(J
));
10059 exit when not In_Character_Range
(C
);
10060 Options
(J
) := Get_Character
(C
);
10062 -- If at end of string, set options. As per discussion
10063 -- above, no need to check for errors, since we issued
10064 -- them in the parser.
10067 Set_Style_Check_Options
(Options
);
10075 elsif Nkind
(A
) = N_Identifier
then
10076 if Chars
(A
) = Name_All_Checks
then
10077 Set_Default_Style_Check_Options
;
10079 elsif Chars
(A
) = Name_On
then
10080 Style_Check
:= True;
10082 elsif Chars
(A
) = Name_Off
then
10083 Style_Check
:= False;
10093 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
10095 when Pragma_Subtitle
=>
10097 Check_Arg_Count
(1);
10098 Check_Optional_Identifier
(Arg1
, Name_Subtitle
);
10099 Check_Arg_Is_String_Literal
(Arg1
);
10105 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
10107 when Pragma_Suppress
=>
10108 Process_Suppress_Unsuppress
(True);
10114 -- pragma Suppress_All;
10116 -- The only check made here is that the pragma appears in the
10117 -- proper place, i.e. following a compilation unit. If indeed
10118 -- it appears in this context, then the parser has already
10119 -- inserted an equivalent pragma Suppress (All_Checks) to get
10120 -- the required effect.
10122 when Pragma_Suppress_All
=>
10124 Check_Arg_Count
(0);
10126 if Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
10127 or else not Is_List_Member
(N
)
10128 or else List_Containing
(N
) /= Pragmas_After
(Parent
(N
))
10131 ("misplaced pragma%, must follow compilation unit");
10134 -------------------------
10135 -- Suppress_Debug_Info --
10136 -------------------------
10138 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
10140 when Pragma_Suppress_Debug_Info
=>
10142 Check_Arg_Count
(1);
10143 Check_Optional_Identifier
(Arg1
, Name_Entity
);
10144 Check_Arg_Is_Local_Name
(Arg1
);
10145 Set_Debug_Info_Off
(Entity
(Get_Pragma_Arg
(Arg1
)));
10147 ----------------------------------
10148 -- Suppress_Exception_Locations --
10149 ----------------------------------
10151 -- pragma Suppress_Exception_Locations;
10153 when Pragma_Suppress_Exception_Locations
=>
10155 Check_Arg_Count
(0);
10156 Check_Valid_Configuration_Pragma
;
10157 Exception_Locations_Suppressed
:= True;
10159 -----------------------------
10160 -- Suppress_Initialization --
10161 -----------------------------
10163 -- pragma Suppress_Initialization ([Entity =>] type_Name);
10165 when Pragma_Suppress_Initialization
=> Suppress_Init
: declare
10171 Check_Arg_Count
(1);
10172 Check_Optional_Identifier
(Arg1
, Name_Entity
);
10173 Check_Arg_Is_Local_Name
(Arg1
);
10175 E_Id
:= Expression
(Arg1
);
10177 if Etype
(E_Id
) = Any_Type
then
10181 E
:= Entity
(E_Id
);
10183 if Is_Type
(E
) then
10184 if Is_Incomplete_Or_Private_Type
(E
) then
10185 if No
(Full_View
(Base_Type
(E
))) then
10187 ("argument of pragma% cannot be an incomplete type",
10190 Set_Suppress_Init_Proc
(Full_View
(Base_Type
(E
)));
10193 Set_Suppress_Init_Proc
(Base_Type
(E
));
10198 ("pragma% requires argument that is a type name", Arg1
);
10206 -- pragma System_Name (DIRECT_NAME);
10208 -- Syntax check: one argument, which must be the identifier GNAT
10209 -- or the identifier GCC, no other identifiers are acceptable.
10211 when Pragma_System_Name
=>
10212 Check_No_Identifiers
;
10213 Check_Arg_Count
(1);
10214 Check_Arg_Is_One_Of
(Arg1
, Name_Gcc
, Name_Gnat
);
10216 -----------------------------
10217 -- Task_Dispatching_Policy --
10218 -----------------------------
10220 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
10222 when Pragma_Task_Dispatching_Policy
=> declare
10226 Check_Ada_83_Warning
;
10227 Check_Arg_Count
(1);
10228 Check_No_Identifiers
;
10229 Check_Arg_Is_Task_Dispatching_Policy
(Arg1
);
10230 Check_Valid_Configuration_Pragma
;
10231 Get_Name_String
(Chars
(Expression
(Arg1
)));
10232 DP
:= Fold_Upper
(Name_Buffer
(1));
10234 if Task_Dispatching_Policy
/= ' '
10235 and then Task_Dispatching_Policy
/= DP
10237 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
10239 ("task dispatching policy incompatible with policy#");
10241 -- Set new policy, but always preserve System_Location since
10242 -- we like the error message with the run time name.
10245 Task_Dispatching_Policy
:= DP
;
10247 if Task_Dispatching_Policy_Sloc
/= System_Location
then
10248 Task_Dispatching_Policy_Sloc
:= Loc
;
10257 -- pragma Task_Info (EXPRESSION);
10259 when Pragma_Task_Info
=> Task_Info
: declare
10260 P
: constant Node_Id
:= Parent
(N
);
10265 if Nkind
(P
) /= N_Task_Definition
then
10266 Error_Pragma
("pragma% must appear in task definition");
10269 Check_No_Identifiers
;
10270 Check_Arg_Count
(1);
10272 Analyze_And_Resolve
(Expression
(Arg1
), RTE
(RE_Task_Info_Type
));
10274 if Etype
(Expression
(Arg1
)) = Any_Type
then
10278 if Has_Task_Info_Pragma
(P
) then
10279 Error_Pragma
("duplicate pragma% not allowed");
10281 Set_Has_Task_Info_Pragma
(P
, True);
10289 -- pragma Task_Name (string_EXPRESSION);
10291 when Pragma_Task_Name
=> Task_Name
: declare
10292 -- pragma Priority (EXPRESSION);
10294 P
: constant Node_Id
:= Parent
(N
);
10298 Check_No_Identifiers
;
10299 Check_Arg_Count
(1);
10301 Arg
:= Expression
(Arg1
);
10302 Analyze_And_Resolve
(Arg
, Standard_String
);
10304 if Nkind
(P
) /= N_Task_Definition
then
10308 if Has_Task_Name_Pragma
(P
) then
10309 Error_Pragma
("duplicate pragma% not allowed");
10311 Set_Has_Task_Name_Pragma
(P
, True);
10312 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
10320 -- pragma Task_Storage (
10321 -- [Task_Type =>] LOCAL_NAME,
10322 -- [Top_Guard =>] static_integer_EXPRESSION);
10324 when Pragma_Task_Storage
=> Task_Storage
: declare
10325 Args
: Args_List
(1 .. 2);
10326 Names
: constant Name_List
(1 .. 2) := (
10330 Task_Type
: Node_Id
renames Args
(1);
10331 Top_Guard
: Node_Id
renames Args
(2);
10337 Gather_Associations
(Names
, Args
);
10339 if No
(Task_Type
) then
10341 ("missing task_type argument for pragma%");
10344 Check_Arg_Is_Local_Name
(Task_Type
);
10346 Ent
:= Entity
(Task_Type
);
10348 if not Is_Task_Type
(Ent
) then
10350 ("argument for pragma% must be task type", Task_Type
);
10353 if No
(Top_Guard
) then
10355 ("pragma% takes two arguments", Task_Type
);
10357 Check_Arg_Is_Static_Expression
(Top_Guard
, Any_Integer
);
10360 Check_First_Subtype
(Task_Type
);
10362 if Rep_Item_Too_Late
(Ent
, N
) then
10371 -- pragma Time_Slice (static_duration_EXPRESSION);
10373 when Pragma_Time_Slice
=> Time_Slice
: declare
10379 Check_Arg_Count
(1);
10380 Check_No_Identifiers
;
10381 Check_In_Main_Program
;
10382 Check_Arg_Is_Static_Expression
(Arg1
, Standard_Duration
);
10384 if not Error_Posted
(Arg1
) then
10386 while Present
(Nod
) loop
10387 if Nkind
(Nod
) = N_Pragma
10388 and then Chars
(Nod
) = Name_Time_Slice
10390 Error_Msg_Name_1
:= Chars
(N
);
10391 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
10398 -- Process only if in main unit
10400 if Get_Source_Unit
(Loc
) = Main_Unit
then
10401 Opt
.Time_Slice_Set
:= True;
10402 Val
:= Expr_Value_R
(Expression
(Arg1
));
10404 if Val
<= Ureal_0
then
10405 Opt
.Time_Slice_Value
:= 0;
10407 elsif Val
> UR_From_Uint
(UI_From_Int
(1000)) then
10408 Opt
.Time_Slice_Value
:= 1_000_000_000
;
10411 Opt
.Time_Slice_Value
:=
10412 UI_To_Int
(UR_To_Uint
(Val
* UI_From_Int
(1_000_000
)));
10421 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
10423 -- TITLING_OPTION ::=
10424 -- [Title =>] STRING_LITERAL
10425 -- | [Subtitle =>] STRING_LITERAL
10427 when Pragma_Title
=> Title
: declare
10428 Args
: Args_List
(1 .. 2);
10429 Names
: constant Name_List
(1 .. 2) := (
10435 Gather_Associations
(Names
, Args
);
10437 for J
in 1 .. 2 loop
10438 if Present
(Args
(J
)) then
10439 Check_Arg_Is_String_Literal
(Args
(J
));
10444 ---------------------
10445 -- Unchecked_Union --
10446 ---------------------
10448 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
10450 when Pragma_Unchecked_Union
=> Unchecked_Union
: declare
10451 Assoc
: constant Node_Id
:= Arg1
;
10452 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
10463 Check_No_Identifiers
;
10464 Check_Arg_Count
(1);
10465 Check_Arg_Is_Local_Name
(Arg1
);
10467 Find_Type
(Type_Id
);
10468 Typ
:= Entity
(Type_Id
);
10471 or else Rep_Item_Too_Early
(Typ
, N
)
10475 Typ
:= Underlying_Type
(Typ
);
10478 if Rep_Item_Too_Late
(Typ
, N
) then
10482 Check_First_Subtype
(Arg1
);
10484 -- Note remaining cases are references to a type in the current
10485 -- declarative part. If we find an error, we post the error on
10486 -- the relevant type declaration at an appropriate point.
10488 if not Is_Record_Type
(Typ
) then
10489 Error_Msg_N
("Unchecked_Union must be record type", Typ
);
10492 elsif Is_Tagged_Type
(Typ
) then
10493 Error_Msg_N
("Unchecked_Union must not be tagged", Typ
);
10496 elsif Is_Limited_Type
(Typ
) then
10498 ("Unchecked_Union must not be limited record type", Typ
);
10499 Explain_Limited_Type
(Typ
, Typ
);
10503 if not Has_Discriminants
(Typ
) then
10505 ("Unchecked_Union must have one discriminant", Typ
);
10509 Discr
:= First_Discriminant
(Typ
);
10510 while Present
(Discr
) loop
10511 if No
(Discriminant_Default_Value
(Discr
)) then
10513 ("Unchecked_Union discriminant must have default value",
10516 Next_Discriminant
(Discr
);
10519 Tdef
:= Type_Definition
(Declaration_Node
(Typ
));
10520 Clist
:= Component_List
(Tdef
);
10522 Comp
:= First
(Component_Items
(Clist
));
10523 while Present
(Comp
) loop
10524 Check_Component
(Comp
);
10528 if No
(Clist
) or else No
(Variant_Part
(Clist
)) then
10530 ("Unchecked_Union must have variant part",
10535 Vpart
:= Variant_Part
(Clist
);
10537 Variant
:= First
(Variants
(Vpart
));
10538 while Present
(Variant
) loop
10539 Check_Variant
(Variant
);
10544 Set_Is_Unchecked_Union
(Typ
, True);
10545 Set_Convention
(Typ
, Convention_C
);
10547 Set_Has_Unchecked_Union
(Base_Type
(Typ
), True);
10548 Set_Is_Unchecked_Union
(Base_Type
(Typ
), True);
10549 end Unchecked_Union
;
10551 ------------------------
10552 -- Unimplemented_Unit --
10553 ------------------------
10555 -- pragma Unimplemented_Unit;
10557 -- Note: this only gives an error if we are generating code,
10558 -- or if we are in a generic library unit (where the pragma
10559 -- appears in the body, not in the spec).
10561 when Pragma_Unimplemented_Unit
=> Unimplemented_Unit
: declare
10562 Cunitent
: constant Entity_Id
:=
10563 Cunit_Entity
(Get_Source_Unit
(Loc
));
10564 Ent_Kind
: constant Entity_Kind
:=
10569 Check_Arg_Count
(0);
10571 if Operating_Mode
= Generate_Code
10572 or else Ent_Kind
= E_Generic_Function
10573 or else Ent_Kind
= E_Generic_Procedure
10574 or else Ent_Kind
= E_Generic_Package
10576 Get_Name_String
(Chars
(Cunitent
));
10577 Set_Casing
(Mixed_Case
);
10578 Write_Str
(Name_Buffer
(1 .. Name_Len
));
10579 Write_Str
(" is not supported in this configuration");
10581 raise Unrecoverable_Error
;
10583 end Unimplemented_Unit
;
10585 ------------------------
10586 -- Universal_Aliasing --
10587 ------------------------
10589 -- pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
10591 when Pragma_Universal_Aliasing
=> Universal_Alias
: declare
10596 Check_Arg_Count
(1);
10597 Check_Optional_Identifier
(Arg2
, Name_Entity
);
10598 Check_Arg_Is_Local_Name
(Arg1
);
10599 E_Id
:= Entity
(Expression
(Arg1
));
10601 if E_Id
= Any_Type
then
10603 elsif No
(E_Id
) or else not Is_Type
(E_Id
) then
10604 Error_Pragma_Arg
("pragma% requires type", Arg1
);
10607 Set_Universal_Aliasing
(Implementation_Base_Type
(E_Id
));
10608 end Universal_Alias
;
10610 --------------------
10611 -- Universal_Data --
10612 --------------------
10614 -- pragma Universal_Data [(library_unit_NAME)];
10616 when Pragma_Universal_Data
=>
10619 -- If this is a configuration pragma, then set the universal
10620 -- addressing option, otherwise confirm that the pragma
10621 -- satisfies the requirements of library unit pragma placement
10622 -- and leave it to the GNAAMP back end to detect the pragma
10623 -- (avoids transitive setting of the option due to withed units).
10625 if Is_Configuration_Pragma
then
10626 Universal_Addressing_On_AAMP
:= True;
10628 Check_Valid_Library_Unit_Pragma
;
10631 if not AAMP_On_Target
then
10632 Error_Pragma
("?pragma% ignored (applies only to AAMP)");
10639 -- pragma Unreferenced (local_Name {, local_Name});
10641 -- or when used in a context clause:
10643 -- pragma Unreferenced (library_unit_NAME {, library_unit_NAME}
10645 when Pragma_Unreferenced
=> Unreferenced
: declare
10646 Arg_Node
: Node_Id
;
10647 Arg_Expr
: Node_Id
;
10648 Arg_Ent
: Entity_Id
;
10653 Check_At_Least_N_Arguments
(1);
10655 -- Check case of appearing within context clause
10657 if Is_In_Context_Clause
then
10659 -- The arguments must all be units mentioned in a with clause
10660 -- in the same context clause. Note we already checked (in
10661 -- Par.Prag) that the arguments are either identifiers or
10662 -- selected components.
10665 while Present
(Arg_Node
) loop
10666 Citem
:= First
(List_Containing
(N
));
10667 while Citem
/= N
loop
10668 if Nkind
(Citem
) = N_With_Clause
10669 and then Same_Name
(Name
(Citem
), Expression
(Arg_Node
))
10671 Set_Has_Pragma_Unreferenced
10674 (Library_Unit
(Citem
))));
10675 Set_Unit_Name
(Expression
(Arg_Node
), Name
(Citem
));
10684 ("argument of pragma% is not with'ed unit", Arg_Node
);
10690 -- Case of not in list of context items
10694 while Present
(Arg_Node
) loop
10695 Check_No_Identifier
(Arg_Node
);
10697 -- Note: the analyze call done by Check_Arg_Is_Local_Name
10698 -- will in fact generate reference, so that the entity will
10699 -- have a reference, which will inhibit any warnings about
10700 -- it not being referenced, and also properly show up in the
10701 -- ali file as a reference. But this reference is recorded
10702 -- before the Has_Pragma_Unreferenced flag is set, so that
10703 -- no warning is generated for this reference.
10705 Check_Arg_Is_Local_Name
(Arg_Node
);
10706 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
10708 if Is_Entity_Name
(Arg_Expr
) then
10709 Arg_Ent
:= Entity
(Arg_Expr
);
10711 -- If the entity is overloaded, the pragma applies to the
10712 -- most recent overloading, as documented. In this case,
10713 -- name resolution does not generate a reference, so it
10714 -- must be done here explicitly.
10716 if Is_Overloaded
(Arg_Expr
) then
10717 Generate_Reference
(Arg_Ent
, N
);
10720 Set_Has_Pragma_Unreferenced
(Arg_Ent
);
10728 --------------------------
10729 -- Unreferenced_Objects --
10730 --------------------------
10732 -- pragma Unreferenced_Objects (local_Name {, local_Name});
10734 when Pragma_Unreferenced_Objects
=> Unreferenced_Objects
: declare
10735 Arg_Node
: Node_Id
;
10736 Arg_Expr
: Node_Id
;
10740 Check_At_Least_N_Arguments
(1);
10743 while Present
(Arg_Node
) loop
10744 Check_No_Identifier
(Arg_Node
);
10745 Check_Arg_Is_Local_Name
(Arg_Node
);
10746 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
10748 if not Is_Entity_Name
(Arg_Expr
)
10749 or else not Is_Type
(Entity
(Arg_Expr
))
10752 ("argument for pragma% must be type or subtype", Arg_Node
);
10755 Set_Has_Pragma_Unreferenced_Objects
(Entity
(Arg_Expr
));
10758 end Unreferenced_Objects
;
10760 ------------------------------
10761 -- Unreserve_All_Interrupts --
10762 ------------------------------
10764 -- pragma Unreserve_All_Interrupts;
10766 when Pragma_Unreserve_All_Interrupts
=>
10768 Check_Arg_Count
(0);
10770 if In_Extended_Main_Code_Unit
(Main_Unit_Entity
) then
10771 Unreserve_All_Interrupts
:= True;
10778 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
10780 when Pragma_Unsuppress
=>
10782 Process_Suppress_Unsuppress
(False);
10784 -------------------
10785 -- Use_VADS_Size --
10786 -------------------
10788 -- pragma Use_VADS_Size;
10790 when Pragma_Use_VADS_Size
=>
10792 Check_Arg_Count
(0);
10793 Check_Valid_Configuration_Pragma
;
10794 Use_VADS_Size
:= True;
10796 ---------------------
10797 -- Validity_Checks --
10798 ---------------------
10800 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
10802 when Pragma_Validity_Checks
=> Validity_Checks
: declare
10803 A
: constant Node_Id
:= Expression
(Arg1
);
10809 Check_Arg_Count
(1);
10810 Check_No_Identifiers
;
10812 if Nkind
(A
) = N_String_Literal
then
10816 Slen
: constant Natural := Natural (String_Length
(S
));
10817 Options
: String (1 .. Slen
);
10823 C
:= Get_String_Char
(S
, Int
(J
));
10824 exit when not In_Character_Range
(C
);
10825 Options
(J
) := Get_Character
(C
);
10828 Set_Validity_Check_Options
(Options
);
10836 elsif Nkind
(A
) = N_Identifier
then
10838 if Chars
(A
) = Name_All_Checks
then
10839 Set_Validity_Check_Options
("a");
10841 elsif Chars
(A
) = Name_On
then
10842 Validity_Checks_On
:= True;
10844 elsif Chars
(A
) = Name_Off
then
10845 Validity_Checks_On
:= False;
10849 end Validity_Checks
;
10855 -- pragma Volatile (LOCAL_NAME);
10857 when Pragma_Volatile
=>
10858 Process_Atomic_Shared_Volatile
;
10860 -------------------------
10861 -- Volatile_Components --
10862 -------------------------
10864 -- pragma Volatile_Components (array_LOCAL_NAME);
10866 -- Volatile is handled by the same circuit as Atomic_Components
10872 -- pragma Warnings (On | Off);
10873 -- pragma Warnings (On | Off, LOCAL_NAME);
10874 -- pragma Warnings (static_string_EXPRESSION);
10875 -- pragma Warnings (On | Off, STRING_LITERAL);
10877 when Pragma_Warnings
=> Warnings
: begin
10879 Check_At_Least_N_Arguments
(1);
10880 Check_No_Identifiers
;
10883 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
10886 -- One argument case
10888 if Arg_Count
= 1 then
10890 -- On/Off one argument case was processed by parser
10892 if Nkind
(Argx
) = N_Identifier
10894 (Chars
(Argx
) = Name_On
10896 Chars
(Argx
) = Name_Off
)
10900 -- One argument case must be ON/OFF or static string expr
10902 elsif not Is_Static_String_Expression
(Arg1
) then
10904 ("argument of pragma% must be On/Off or " &
10905 "static string expression", Arg2
);
10907 -- One argument string expression case
10911 Lit
: constant Node_Id
:= Expr_Value_S
(Argx
);
10912 Str
: constant String_Id
:= Strval
(Lit
);
10913 Len
: constant Nat
:= String_Length
(Str
);
10921 while J
<= Len
loop
10922 C
:= Get_String_Char
(Str
, J
);
10923 OK
:= In_Character_Range
(C
);
10926 Chr
:= Get_Character
(C
);
10930 if J
< Len
and then Chr
= '.' then
10932 C
:= Get_String_Char
(Str
, J
);
10933 Chr
:= Get_Character
(C
);
10935 if not Set_Dot_Warning_Switch
(Chr
) then
10937 ("invalid warning switch character " &
10944 OK
:= Set_Warning_Switch
(Chr
);
10950 ("invalid warning switch character " & Chr
,
10959 -- Two or more arguments (must be two)
10962 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
10963 Check_At_Most_N_Arguments
(2);
10971 E_Id
:= Expression
(Arg2
);
10974 -- In the expansion of an inlined body, a reference to
10975 -- the formal may be wrapped in a conversion if the
10976 -- actual is a conversion. Retrieve the real entity name.
10978 if (In_Instance_Body
10979 or else In_Inlined_Body
)
10980 and then Nkind
(E_Id
) = N_Unchecked_Type_Conversion
10982 E_Id
:= Expression
(E_Id
);
10985 -- Entity name case
10987 if Is_Entity_Name
(E_Id
) then
10988 E
:= Entity
(E_Id
);
10995 (E
, (Chars
(Expression
(Arg1
)) = Name_Off
));
10997 if Is_Enumeration_Type
(E
) then
11001 Lit
:= First_Literal
(E
);
11002 while Present
(Lit
) loop
11003 Set_Warnings_Off
(Lit
);
11004 Next_Literal
(Lit
);
11009 exit when No
(Homonym
(E
));
11014 -- Error if not entity or static string literal case
11016 elsif not Is_Static_String_Expression
(Arg2
) then
11018 ("second argument of pragma% must be entity " &
11019 "name or static string expression", Arg2
);
11021 -- String literal case
11024 String_To_Name_Buffer
11025 (Strval
(Expr_Value_S
(Expression
(Arg2
))));
11027 -- Note on configuration pragma case: If this is a
11028 -- configuration pragma, then for an OFF pragma, we
11029 -- just set Config True in the call, which is all
11030 -- that needs to be done. For the case of ON, this
11031 -- is normally an error, unless it is canceling the
11032 -- effect of a previous OFF pragma in the same file.
11033 -- In any other case, an error will be signalled (ON
11034 -- with no matching OFF).
11036 if Chars
(Argx
) = Name_Off
then
11037 Set_Specific_Warning_Off
11038 (Loc
, Name_Buffer
(1 .. Name_Len
),
11039 Config
=> Is_Configuration_Pragma
);
11041 elsif Chars
(Argx
) = Name_On
then
11042 Set_Specific_Warning_On
11043 (Loc
, Name_Buffer
(1 .. Name_Len
), Err
);
11047 ("?pragma Warnings On with no " &
11048 "matching Warnings Off",
11058 -------------------
11059 -- Weak_External --
11060 -------------------
11062 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
11064 when Pragma_Weak_External
=> Weak_External
: declare
11069 Check_Arg_Count
(1);
11070 Check_Optional_Identifier
(Arg1
, Name_Entity
);
11071 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
11072 Ent
:= Entity
(Expression
(Arg1
));
11074 if Rep_Item_Too_Early
(Ent
, N
) then
11077 Ent
:= Underlying_Type
(Ent
);
11080 -- The only processing required is to link this item on to the
11081 -- list of rep items for the given entity. This is accomplished
11082 -- by the call to Rep_Item_Too_Late (when no error is detected
11083 -- and False is returned).
11085 if Rep_Item_Too_Late
(Ent
, N
) then
11088 Set_Has_Gigi_Rep_Item
(Ent
);
11092 -----------------------------
11093 -- Wide_Character_Encoding --
11094 -----------------------------
11096 -- pragma Wide_Character_Encoding (IDENTIFIER);
11098 when Pragma_Wide_Character_Encoding
=>
11100 -- Nothing to do, handled in parser. Note that we do not enforce
11101 -- configuration pragma placement, this pragma can appear at any
11102 -- place in the source, allowing mixed encodings within a single
11107 --------------------
11108 -- Unknown_Pragma --
11109 --------------------
11111 -- Should be impossible, since the case of an unknown pragma is
11112 -- separately processed before the case statement is entered.
11114 when Unknown_Pragma
=>
11115 raise Program_Error
;
11119 when Pragma_Exit
=> null;
11120 end Analyze_Pragma
;
11122 ---------------------------------
11123 -- Delay_Config_Pragma_Analyze --
11124 ---------------------------------
11126 function Delay_Config_Pragma_Analyze
(N
: Node_Id
) return Boolean is
11128 return Chars
(N
) = Name_Interrupt_State
11130 Chars
(N
) = Name_Priority_Specific_Dispatching
;
11131 end Delay_Config_Pragma_Analyze
;
11133 -------------------------
11134 -- Get_Base_Subprogram --
11135 -------------------------
11137 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
is
11138 Result
: Entity_Id
;
11141 -- Follow subprogram renaming chain
11144 while Is_Subprogram
(Result
)
11146 (Is_Generic_Instance
(Result
)
11147 or else Nkind
(Parent
(Declaration_Node
(Result
))) =
11148 N_Subprogram_Renaming_Declaration
)
11149 and then Present
(Alias
(Result
))
11151 Result
:= Alias
(Result
);
11155 end Get_Base_Subprogram
;
11157 -----------------------------
11158 -- Is_Config_Static_String --
11159 -----------------------------
11161 function Is_Config_Static_String
(Arg
: Node_Id
) return Boolean is
11163 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean;
11164 -- This is an internal recursive function that is just like the
11165 -- outer function except that it adds the string to the name buffer
11166 -- rather than placing the string in the name buffer.
11168 ------------------------------
11169 -- Add_Config_Static_String --
11170 ------------------------------
11172 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean is
11179 if Nkind
(N
) = N_Op_Concat
then
11180 if Add_Config_Static_String
(Left_Opnd
(N
)) then
11181 N
:= Right_Opnd
(N
);
11187 if Nkind
(N
) /= N_String_Literal
then
11188 Error_Msg_N
("string literal expected for pragma argument", N
);
11192 for J
in 1 .. String_Length
(Strval
(N
)) loop
11193 C
:= Get_String_Char
(Strval
(N
), J
);
11195 if not In_Character_Range
(C
) then
11197 ("string literal contains invalid wide character",
11198 Sloc
(N
) + 1 + Source_Ptr
(J
));
11202 Add_Char_To_Name_Buffer
(Get_Character
(C
));
11207 end Add_Config_Static_String
;
11209 -- Start of prorcessing for Is_Config_Static_String
11214 return Add_Config_Static_String
(Arg
);
11215 end Is_Config_Static_String
;
11217 -----------------------------------------
11218 -- Is_Non_Significant_Pragma_Reference --
11219 -----------------------------------------
11221 -- This function makes use of the following static table which indicates
11222 -- whether a given pragma is significant. A value of -1 in this table
11223 -- indicates that the reference is significant. A value of zero indicates
11224 -- than appearence as any argument is insignificant, a positive value
11225 -- indicates that appearence in that parameter position is significant.
11227 Sig_Flags
: constant array (Pragma_Id
) of Int
:=
11229 (Pragma_AST_Entry
=> -1,
11230 Pragma_Abort_Defer
=> -1,
11231 Pragma_Ada_83
=> -1,
11232 Pragma_Ada_95
=> -1,
11233 Pragma_Ada_05
=> -1,
11234 Pragma_Ada_2005
=> -1,
11235 Pragma_All_Calls_Remote
=> -1,
11236 Pragma_Annotate
=> -1,
11237 Pragma_Assert
=> -1,
11238 Pragma_Assertion_Policy
=> 0,
11239 Pragma_Asynchronous
=> -1,
11240 Pragma_Atomic
=> 0,
11241 Pragma_Atomic_Components
=> 0,
11242 Pragma_Attach_Handler
=> -1,
11243 Pragma_Check_Name
=> 0,
11244 Pragma_CIL_Constructor
=> -1,
11245 Pragma_CPP_Class
=> 0,
11246 Pragma_CPP_Constructor
=> 0,
11247 Pragma_CPP_Virtual
=> 0,
11248 Pragma_CPP_Vtable
=> 0,
11249 Pragma_C_Pass_By_Copy
=> 0,
11250 Pragma_Comment
=> 0,
11251 Pragma_Common_Object
=> -1,
11252 Pragma_Compile_Time_Error
=> -1,
11253 Pragma_Compile_Time_Warning
=> -1,
11254 Pragma_Compiler_Unit
=> 0,
11255 Pragma_Complete_Representation
=> 0,
11256 Pragma_Complex_Representation
=> 0,
11257 Pragma_Component_Alignment
=> -1,
11258 Pragma_Controlled
=> 0,
11259 Pragma_Convention
=> 0,
11260 Pragma_Convention_Identifier
=> 0,
11261 Pragma_Debug
=> -1,
11262 Pragma_Debug_Policy
=> 0,
11263 Pragma_Detect_Blocking
=> -1,
11264 Pragma_Discard_Names
=> 0,
11265 Pragma_Elaborate
=> -1,
11266 Pragma_Elaborate_All
=> -1,
11267 Pragma_Elaborate_Body
=> -1,
11268 Pragma_Elaboration_Checks
=> -1,
11269 Pragma_Eliminate
=> -1,
11270 Pragma_Export
=> -1,
11271 Pragma_Export_Exception
=> -1,
11272 Pragma_Export_Function
=> -1,
11273 Pragma_Export_Object
=> -1,
11274 Pragma_Export_Procedure
=> -1,
11275 Pragma_Export_Value
=> -1,
11276 Pragma_Export_Valued_Procedure
=> -1,
11277 Pragma_Extend_System
=> -1,
11278 Pragma_Extensions_Allowed
=> -1,
11279 Pragma_External
=> -1,
11280 Pragma_External_Name_Casing
=> -1,
11281 Pragma_Finalize_Storage_Only
=> 0,
11282 Pragma_Float_Representation
=> 0,
11283 Pragma_Ident
=> -1,
11284 Pragma_Implicit_Packing
=> 0,
11285 Pragma_Import
=> +2,
11286 Pragma_Import_Exception
=> 0,
11287 Pragma_Import_Function
=> 0,
11288 Pragma_Import_Object
=> 0,
11289 Pragma_Import_Procedure
=> 0,
11290 Pragma_Import_Valued_Procedure
=> 0,
11291 Pragma_Initialize_Scalars
=> -1,
11292 Pragma_Inline
=> 0,
11293 Pragma_Inline_Always
=> 0,
11294 Pragma_Inline_Generic
=> 0,
11295 Pragma_Inspection_Point
=> -1,
11296 Pragma_Interface
=> +2,
11297 Pragma_Interface_Name
=> +2,
11298 Pragma_Interrupt_Handler
=> -1,
11299 Pragma_Interrupt_Priority
=> -1,
11300 Pragma_Interrupt_State
=> -1,
11301 Pragma_Java_Constructor
=> -1,
11302 Pragma_Java_Interface
=> -1,
11303 Pragma_Keep_Names
=> 0,
11304 Pragma_License
=> -1,
11305 Pragma_Link_With
=> -1,
11306 Pragma_Linker_Alias
=> -1,
11307 Pragma_Linker_Constructor
=> -1,
11308 Pragma_Linker_Destructor
=> -1,
11309 Pragma_Linker_Options
=> -1,
11310 Pragma_Linker_Section
=> -1,
11312 Pragma_Locking_Policy
=> -1,
11313 Pragma_Long_Float
=> -1,
11314 Pragma_Machine_Attribute
=> -1,
11316 Pragma_Main_Storage
=> -1,
11317 Pragma_Memory_Size
=> -1,
11318 Pragma_No_Return
=> 0,
11319 Pragma_No_Body
=> 0,
11320 Pragma_No_Run_Time
=> -1,
11321 Pragma_No_Strict_Aliasing
=> -1,
11322 Pragma_Normalize_Scalars
=> -1,
11323 Pragma_Obsolescent
=> 0,
11324 Pragma_Optimize
=> -1,
11327 Pragma_Passive
=> -1,
11328 Pragma_Preelaborable_Initialization
=> -1,
11329 Pragma_Polling
=> -1,
11330 Pragma_Persistent_BSS
=> 0,
11331 Pragma_Preelaborate
=> -1,
11332 Pragma_Preelaborate_05
=> -1,
11333 Pragma_Priority
=> -1,
11334 Pragma_Priority_Specific_Dispatching
=> -1,
11335 Pragma_Profile
=> 0,
11336 Pragma_Profile_Warnings
=> 0,
11337 Pragma_Propagate_Exceptions
=> -1,
11338 Pragma_Psect_Object
=> -1,
11340 Pragma_Pure_05
=> -1,
11341 Pragma_Pure_Function
=> -1,
11342 Pragma_Queuing_Policy
=> -1,
11343 Pragma_Ravenscar
=> -1,
11344 Pragma_Remote_Call_Interface
=> -1,
11345 Pragma_Remote_Types
=> -1,
11346 Pragma_Restricted_Run_Time
=> -1,
11347 Pragma_Restriction_Warnings
=> -1,
11348 Pragma_Restrictions
=> -1,
11349 Pragma_Reviewable
=> -1,
11350 Pragma_Share_Generic
=> -1,
11351 Pragma_Shared
=> -1,
11352 Pragma_Shared_Passive
=> -1,
11353 Pragma_Source_File_Name
=> -1,
11354 Pragma_Source_File_Name_Project
=> -1,
11355 Pragma_Source_Reference
=> -1,
11356 Pragma_Storage_Size
=> -1,
11357 Pragma_Storage_Unit
=> -1,
11358 Pragma_Static_Elaboration_Desired
=> -1,
11359 Pragma_Stream_Convert
=> -1,
11360 Pragma_Style_Checks
=> -1,
11361 Pragma_Subtitle
=> -1,
11362 Pragma_Suppress
=> 0,
11363 Pragma_Suppress_Exception_Locations
=> 0,
11364 Pragma_Suppress_All
=> -1,
11365 Pragma_Suppress_Debug_Info
=> 0,
11366 Pragma_Suppress_Initialization
=> 0,
11367 Pragma_System_Name
=> -1,
11368 Pragma_Task_Dispatching_Policy
=> -1,
11369 Pragma_Task_Info
=> -1,
11370 Pragma_Task_Name
=> -1,
11371 Pragma_Task_Storage
=> 0,
11372 Pragma_Time_Slice
=> -1,
11373 Pragma_Title
=> -1,
11374 Pragma_Unchecked_Union
=> 0,
11375 Pragma_Unimplemented_Unit
=> -1,
11376 Pragma_Universal_Aliasing
=> -1,
11377 Pragma_Universal_Data
=> -1,
11378 Pragma_Unreferenced
=> -1,
11379 Pragma_Unreferenced_Objects
=> -1,
11380 Pragma_Unreserve_All_Interrupts
=> -1,
11381 Pragma_Unsuppress
=> 0,
11382 Pragma_Use_VADS_Size
=> -1,
11383 Pragma_Validity_Checks
=> -1,
11384 Pragma_Volatile
=> 0,
11385 Pragma_Volatile_Components
=> 0,
11386 Pragma_Warnings
=> -1,
11387 Pragma_Weak_External
=> -1,
11388 Pragma_Wide_Character_Encoding
=> 0,
11389 Unknown_Pragma
=> 0);
11391 function Is_Non_Significant_Pragma_Reference
(N
: Node_Id
) return Boolean is
11399 if Nkind
(P
) /= N_Pragma_Argument_Association
then
11403 C
:= Sig_Flags
(Get_Pragma_Id
(Chars
(Parent
(P
))));
11413 A
:= First
(Pragma_Argument_Associations
(Parent
(P
)));
11414 for J
in 1 .. C
- 1 loop
11425 end Is_Non_Significant_Pragma_Reference
;
11427 ------------------------------
11428 -- Is_Pragma_String_Literal --
11429 ------------------------------
11431 -- This function returns true if the corresponding pragma argument is
11432 -- a static string expression. These are the only cases in which string
11433 -- literals can appear as pragma arguments. We also allow a string
11434 -- literal as the first argument to pragma Assert (although it will
11435 -- of course always generate a type error).
11437 function Is_Pragma_String_Literal
(Par
: Node_Id
) return Boolean is
11438 Pragn
: constant Node_Id
:= Parent
(Par
);
11439 Assoc
: constant List_Id
:= Pragma_Argument_Associations
(Pragn
);
11440 Pname
: constant Name_Id
:= Chars
(Pragn
);
11446 N
:= First
(Assoc
);
11453 if Pname
= Name_Assert
then
11456 elsif Pname
= Name_Export
then
11459 elsif Pname
= Name_Ident
then
11462 elsif Pname
= Name_Import
then
11465 elsif Pname
= Name_Interface_Name
then
11468 elsif Pname
= Name_Linker_Alias
then
11471 elsif Pname
= Name_Linker_Section
then
11474 elsif Pname
= Name_Machine_Attribute
then
11477 elsif Pname
= Name_Source_File_Name
then
11480 elsif Pname
= Name_Source_Reference
then
11483 elsif Pname
= Name_Title
then
11486 elsif Pname
= Name_Subtitle
then
11492 end Is_Pragma_String_Literal
;
11494 --------------------------------------
11495 -- Process_Compilation_Unit_Pragmas --
11496 --------------------------------------
11498 procedure Process_Compilation_Unit_Pragmas
(N
: Node_Id
) is
11500 -- A special check for pragma Suppress_All. This is a strange DEC
11501 -- pragma, strange because it comes at the end of the unit. If we
11502 -- have a pragma Suppress_All in the Pragmas_After of the current
11503 -- unit, then we insert a pragma Suppress (All_Checks) at the start
11504 -- of the context clause to ensure the correct processing.
11507 PA
: constant List_Id
:= Pragmas_After
(Aux_Decls_Node
(N
));
11511 if Present
(PA
) then
11513 while Present
(P
) loop
11514 if Chars
(P
) = Name_Suppress_All
then
11515 Prepend_To
(Context_Items
(N
),
11516 Make_Pragma
(Sloc
(P
),
11517 Chars
=> Name_Suppress
,
11518 Pragma_Argument_Associations
=> New_List
(
11519 Make_Pragma_Argument_Association
(Sloc
(P
),
11521 Make_Identifier
(Sloc
(P
),
11522 Chars
=> Name_All_Checks
)))));
11530 end Process_Compilation_Unit_Pragmas
;
11541 --------------------------------
11542 -- Set_Encoded_Interface_Name --
11543 --------------------------------
11545 procedure Set_Encoded_Interface_Name
(E
: Entity_Id
; S
: Node_Id
) is
11546 Str
: constant String_Id
:= Strval
(S
);
11547 Len
: constant Int
:= String_Length
(Str
);
11552 Hex
: constant array (0 .. 15) of Character := "0123456789abcdef";
11555 -- Stores encoded value of character code CC. The encoding we
11556 -- use an underscore followed by four lower case hex digits.
11562 procedure Encode
is
11564 Store_String_Char
(Get_Char_Code
('_'));
11566 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 12))));
11568 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 8 and 16#
0F#
))));
11570 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 4 and 16#
0F#
))));
11572 (Get_Char_Code
(Hex
(Integer (CC
and 16#
0F#
))));
11575 -- Start of processing for Set_Encoded_Interface_Name
11578 -- If first character is asterisk, this is a link name, and we
11579 -- leave it completely unmodified. We also ignore null strings
11580 -- (the latter case happens only in error cases) and no encoding
11581 -- should occur for Java or AAMP interface names.
11584 or else Get_String_Char
(Str
, 1) = Get_Char_Code
('*')
11585 or else VM_Target
/= No_VM
11586 or else AAMP_On_Target
11588 Set_Interface_Name
(E
, S
);
11593 CC
:= Get_String_Char
(Str
, J
);
11595 exit when not In_Character_Range
(CC
);
11597 C
:= Get_Character
(CC
);
11599 exit when C
/= '_' and then C
/= '$'
11600 and then C
not in '0' .. '9'
11601 and then C
not in 'a' .. 'z'
11602 and then C
not in 'A' .. 'Z';
11605 Set_Interface_Name
(E
, S
);
11613 -- Here we need to encode. The encoding we use as follows:
11614 -- three underscores + four hex digits (lower case)
11618 for J
in 1 .. String_Length
(Str
) loop
11619 CC
:= Get_String_Char
(Str
, J
);
11621 if not In_Character_Range
(CC
) then
11624 C
:= Get_Character
(CC
);
11626 if C
= '_' or else C
= '$'
11627 or else C
in '0' .. '9'
11628 or else C
in 'a' .. 'z'
11629 or else C
in 'A' .. 'Z'
11631 Store_String_Char
(CC
);
11638 Set_Interface_Name
(E
,
11639 Make_String_Literal
(Sloc
(S
),
11640 Strval
=> End_String
));
11642 end Set_Encoded_Interface_Name
;
11644 -------------------
11645 -- Set_Unit_Name --
11646 -------------------
11648 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
) is
11653 if Nkind
(N
) = N_Identifier
11654 and then Nkind
(With_Item
) = N_Identifier
11656 Set_Entity
(N
, Entity
(With_Item
));
11658 elsif Nkind
(N
) = N_Selected_Component
then
11659 Change_Selected_Component_To_Expanded_Name
(N
);
11660 Set_Entity
(N
, Entity
(With_Item
));
11661 Set_Entity
(Selector_Name
(N
), Entity
(N
));
11663 Pref
:= Prefix
(N
);
11664 Scop
:= Scope
(Entity
(N
));
11665 while Nkind
(Pref
) = N_Selected_Component
loop
11666 Change_Selected_Component_To_Expanded_Name
(Pref
);
11667 Set_Entity
(Selector_Name
(Pref
), Scop
);
11668 Set_Entity
(Pref
, Scop
);
11669 Pref
:= Prefix
(Pref
);
11670 Scop
:= Scope
(Scop
);
11673 Set_Entity
(Pref
, Scop
);