1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- This unit contains the semantic processing for all pragmas, both language
28 -- and implementation defined. For most pragmas, the parser only does the
29 -- most basic job of checking the syntax, so Sem_Prag also contains the code
30 -- to complete the syntax checks. Certain pragmas are handled partially or
31 -- completely by the parser (see Par.Prag for further details).
33 with Atree; use Atree;
34 with Casing; use Casing;
35 with Csets; use Csets;
36 with Debug; use Debug;
37 with Einfo; use Einfo;
38 with Elists; use Elists;
39 with Errout; use Errout;
40 with Exp_Dist; use Exp_Dist;
41 with Hostparm; use Hostparm;
43 with Lib.Writ; use Lib.Writ;
44 with Lib.Xref; use Lib.Xref;
45 with Namet; use Namet;
46 with Nlists; use Nlists;
47 with Nmake; use Nmake;
49 with Output; use Output;
50 with Restrict; use Restrict;
51 with Rident; use Rident;
52 with Rtsfind; use Rtsfind;
54 with Sem_Ch3; use Sem_Ch3;
55 with Sem_Ch8; use Sem_Ch8;
56 with Sem_Ch13; use Sem_Ch13;
57 with Sem_Disp; use Sem_Disp;
58 with Sem_Dist; use Sem_Dist;
59 with Sem_Elim; use Sem_Elim;
60 with Sem_Eval; use Sem_Eval;
61 with Sem_Intr; use Sem_Intr;
62 with Sem_Mech; use Sem_Mech;
63 with Sem_Res; use Sem_Res;
64 with Sem_Type; use Sem_Type;
65 with Sem_Util; use Sem_Util;
66 with Sem_VFpt; use Sem_VFpt;
67 with Stand; use Stand;
68 with Sinfo; use Sinfo;
69 with Sinfo.CN; use Sinfo.CN;
70 with Sinput; use Sinput;
71 with Snames; use Snames;
72 with Stringt; use Stringt;
73 with Stylesw; use Stylesw;
75 with Targparm; use Targparm;
76 with Tbuild; use Tbuild;
78 with Uintp; use Uintp;
79 with Urealp; use Urealp;
80 with Validsw; use Validsw;
82 with GNAT.Spelling_Checker; use GNAT.Spelling_Checker;
84 package body Sem_Prag is
86 ----------------------------------------------
87 -- Common Handling of Import-Export Pragmas --
88 ----------------------------------------------
90 -- In the following section, a number of Import_xxx and Export_xxx
91 -- pragmas are defined by GNAT. These are compatible with the DEC
92 -- pragmas of the same name, and all have the following common
93 -- form and processing:
96 -- [Internal =>] LOCAL_NAME,
97 -- [, [External =>] EXTERNAL_SYMBOL]
98 -- [, other optional parameters ]);
101 -- [Internal =>] LOCAL_NAME,
102 -- [, [External =>] EXTERNAL_SYMBOL]
103 -- [, other optional parameters ]);
105 -- EXTERNAL_SYMBOL ::=
107 -- | static_string_EXPRESSION
109 -- The internal LOCAL_NAME designates the entity that is imported or
110 -- exported, and must refer to an entity in the current declarative
111 -- part (as required by the rules for LOCAL_NAME).
113 -- The external linker name is designated by the External parameter
114 -- if given, or the Internal parameter if not (if there is no External
115 -- parameter, the External parameter is a copy of the Internal name).
117 -- If the External parameter is given as a string, then this string
118 -- is treated as an external name (exactly as though it had been given
119 -- as an External_Name parameter for a normal Import pragma).
121 -- If the External parameter is given as an identifier (or there is no
122 -- External parameter, so that the Internal identifier is used), then
123 -- the external name is the characters of the identifier, translated
124 -- to all upper case letters for OpenVMS versions of GNAT, and to all
125 -- lower case letters for all other versions
127 -- Note: the external name specified or implied by any of these special
128 -- Import_xxx or Export_xxx pragmas override an external or link name
129 -- specified in a previous Import or Export pragma.
131 -- Note: these and all other DEC-compatible GNAT pragmas allow full
132 -- use of named notation, following the standard rules for subprogram
133 -- calls, i.e. parameters can be given in any order if named notation
134 -- is used, and positional and named notation can be mixed, subject to
135 -- the rule that all positional parameters must appear first.
137 -- Note: All these pragmas are implemented exactly following the DEC
138 -- design and implementation and are intended to be fully compatible
139 -- with the use of these pragmas in the DEC Ada compiler.
141 --------------------------------------------
142 -- Checking for Duplicated External Names --
143 --------------------------------------------
145 -- It is suspicious if two separate Export pragmas use the same external
146 -- name. The following table is used to diagnose this situation so that
147 -- an appropriate warning can be issued.
149 -- The Node_Id stored is for the N_String_Literal node created to
150 -- hold the value of the external name. The Sloc of this node is
151 -- used to cross-reference the location of the duplication.
153 package Externals is new Table.Table (
154 Table_Component_Type => Node_Id,
155 Table_Index_Type => Int,
156 Table_Low_Bound => 0,
157 Table_Initial => 100,
158 Table_Increment => 100,
159 Table_Name => "Name_Externals");
161 -------------------------------------
162 -- Local Subprograms and Variables --
163 -------------------------------------
165 function Adjust_External_Name_Case (N : Node_Id) return Node_Id;
166 -- This routine is used for possible casing adjustment of an explicit
167 -- external name supplied as a string literal (the node N), according
168 -- to the casing requirement of Opt.External_Name_Casing. If this is
169 -- set to As_Is, then the string literal is returned unchanged, but if
170 -- it is set to Uppercase or Lowercase, then a new string literal with
171 -- appropriate casing is constructed.
173 function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id;
174 -- If Def_Id refers to a renamed subprogram, then the base subprogram
175 -- (the original one, following the renaming chain) is returned.
176 -- Otherwise the entity is returned unchanged. Should be in Einfo???
178 procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id);
179 -- Place semantic information on the argument of an Elaborate or
180 -- Elaborate_All pragma. Entity name for unit and its parents is
181 -- taken from item in previous with_clause that mentions the unit.
183 -------------------------------
184 -- Adjust_External_Name_Case --
185 -------------------------------
187 function Adjust_External_Name_Case (N : Node_Id) return Node_Id is
191 -- Adjust case of literal if required
193 if Opt.External_Name_Exp_Casing = As_Is then
197 -- Copy existing string
203 for J in 1 .. String_Length (Strval (N)) loop
204 CC := Get_String_Char (Strval (N), J);
206 if Opt.External_Name_Exp_Casing = Uppercase
207 and then CC >= Get_Char_Code ('a')
208 and then CC <= Get_Char_Code ('z')
210 Store_String_Char (CC - 32);
212 elsif Opt.External_Name_Exp_Casing = Lowercase
213 and then CC >= Get_Char_Code ('A')
214 and then CC <= Get_Char_Code ('Z')
216 Store_String_Char (CC + 32);
219 Store_String_Char (CC);
224 Make_String_Literal (Sloc (N),
225 Strval => End_String);
227 end Adjust_External_Name_Case;
233 procedure Analyze_Pragma (N : Node_Id) is
234 Loc : constant Source_Ptr := Sloc (N);
237 Pragma_Exit : exception;
238 -- This exception is used to exit pragma processing completely. It
239 -- is used when an error is detected, and in other situations where
240 -- it is known that no further processing is required.
243 -- Number of pragma argument associations
249 -- First four pragma arguments (pragma argument association nodes,
250 -- or Empty if the corresponding argument does not exist).
252 type Name_List is array (Natural range <>) of Name_Id;
253 type Args_List is array (Natural range <>) of Node_Id;
254 -- Types used for arguments to Check_Arg_Order and Gather_Associations
256 procedure Check_Ada_83_Warning;
257 -- Issues a warning message for the current pragma if operating in Ada
258 -- 83 mode (used for language pragmas that are not a standard part of
259 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
262 procedure Check_Arg_Count (Required : Nat);
263 -- Check argument count for pragma is equal to given parameter.
264 -- If not, then issue an error message and raise Pragma_Exit.
266 -- Note: all routines whose name is Check_Arg_Is_xxx take an
267 -- argument Arg which can either be a pragma argument association,
268 -- in which case the check is applied to the expression of the
269 -- association or an expression directly.
271 procedure Check_Arg_Is_External_Name (Arg : Node_Id);
272 -- Check that an argument has the right form for an EXTERNAL_NAME
273 -- parameter of an extended import/export pragma. The rule is that
274 -- the name must be an identifier or string literal (in Ada 83 mode)
275 -- or a static string expression (in Ada 95 mode).
277 procedure Check_Arg_Is_Identifier (Arg : Node_Id);
278 -- Check the specified argument Arg to make sure that it is an
279 -- identifier. If not give error and raise Pragma_Exit.
281 procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id);
282 -- Check the specified argument Arg to make sure that it is an
283 -- integer literal. If not give error and raise Pragma_Exit.
285 procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id);
286 -- Check the specified argument Arg to make sure that it has the
287 -- proper syntactic form for a local name and meets the semantic
288 -- requirements for a local name. The local name is analyzed as
289 -- part of the processing for this call. In addition, the local
290 -- name is required to represent an entity at the library level.
292 procedure Check_Arg_Is_Local_Name (Arg : Node_Id);
293 -- Check the specified argument Arg to make sure that it has the
294 -- proper syntactic form for a local name and meets the semantic
295 -- requirements for a local name. The local name is analyzed as
296 -- part of the processing for this call.
298 procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id);
299 -- Check the specified argument Arg to make sure that it is a valid
300 -- locking policy name. If not give error and raise Pragma_Exit.
302 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id);
303 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2, N3 : Name_Id);
304 -- Check the specified argument Arg to make sure that it is an
305 -- identifier whose name matches either N1 or N2 (or N3 if present).
306 -- If not then give error and raise Pragma_Exit.
308 procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id);
309 -- Check the specified argument Arg to make sure that it is a valid
310 -- queuing policy name. If not give error and raise Pragma_Exit.
312 procedure Check_Arg_Is_Static_Expression
315 -- Check the specified argument Arg to make sure that it is a static
316 -- expression of the given type (i.e. it will be analyzed and resolved
317 -- using this type, which can be any valid argument to Resolve, e.g.
318 -- Any_Integer is OK). If not, given error and raise Pragma_Exit.
320 procedure Check_Arg_Is_String_Literal (Arg : Node_Id);
321 -- Check the specified argument Arg to make sure that it is a
322 -- string literal. If not give error and raise Pragma_Exit
324 procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id);
325 -- Check the specified argument Arg to make sure that it is a valid
326 -- valid task dispatching policy name. If not give error and raise
329 procedure Check_Arg_Order (Names : Name_List);
330 -- Checks for an instance of two arguments with identifiers for the
331 -- current pragma which are not in the sequence indicated by Names,
332 -- and if so, generates a fatal message about bad order of arguments.
334 procedure Check_At_Least_N_Arguments (N : Nat);
335 -- Check there are at least N arguments present
337 procedure Check_At_Most_N_Arguments (N : Nat);
338 -- Check there are no more than N arguments present
340 procedure Check_Component (Comp : Node_Id);
341 -- Examine Unchecked_Union component for correct use of per-object
342 -- constrained subtypes.
344 procedure Check_Duplicated_Export_Name (Nam : Node_Id);
345 -- Nam is an N_String_Literal node containing the external name set
346 -- by an Import or Export pragma (or extended Import or Export pragma).
347 -- This procedure checks for possible duplications if this is the
348 -- export case, and if found, issues an appropriate error message.
350 procedure Check_First_Subtype (Arg : Node_Id);
351 -- Checks that Arg, whose expression is an entity name referencing
352 -- a subtype, does not reference a type that is not a first subtype.
354 procedure Check_In_Main_Program;
355 -- Common checks for pragmas that appear within a main program
356 -- (Priority, Main_Storage, Time_Slice).
358 procedure Check_Interrupt_Or_Attach_Handler;
359 -- Common processing for first argument of pragma Interrupt_Handler
360 -- or pragma Attach_Handler.
362 procedure Check_Is_In_Decl_Part_Or_Package_Spec;
363 -- Check that pragma appears in a declarative part, or in a package
364 -- specification, i.e. that it does not occur in a statement sequence
367 procedure Check_No_Identifier (Arg : Node_Id);
368 -- Checks that the given argument does not have an identifier. If
369 -- an identifier is present, then an error message is issued, and
370 -- Pragma_Exit is raised.
372 procedure Check_No_Identifiers;
373 -- Checks that none of the arguments to the pragma has an identifier.
374 -- If any argument has an identifier, then an error message is issued,
375 -- and Pragma_Exit is raised.
377 procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id);
378 -- Checks if the given argument has an identifier, and if so, requires
379 -- it to match the given identifier name. If there is a non-matching
380 -- identifier, then an error message is given and Error_Pragmas raised.
382 procedure Check_Optional_Identifier (Arg : Node_Id; Id : String);
383 -- Checks if the given argument has an identifier, and if so, requires
384 -- it to match the given identifier name. If there is a non-matching
385 -- identifier, then an error message is given and Error_Pragmas raised.
386 -- In this version of the procedure, the identifier name is given as
387 -- a string with lower case letters.
389 procedure Check_Static_Constraint (Constr : Node_Id);
390 -- Constr is a constraint from an N_Subtype_Indication node from a
391 -- component constraint in an Unchecked_Union type. This routine checks
392 -- that the constraint is static as required by the restrictions for
395 procedure Check_Valid_Configuration_Pragma;
396 -- Legality checks for placement of a configuration pragma
398 procedure Check_Valid_Library_Unit_Pragma;
399 -- Legality checks for library unit pragmas. A special case arises for
400 -- pragmas in generic instances that come from copies of the original
401 -- library unit pragmas in the generic templates. In the case of other
402 -- than library level instantiations these can appear in contexts which
403 -- would normally be invalid (they only apply to the original template
404 -- and to library level instantiations), and they are simply ignored,
405 -- which is implemented by rewriting them as null statements.
407 procedure Check_Variant (Variant : Node_Id);
408 -- Check Unchecked_Union variant for lack of nested variants and
409 -- presence of at least one component.
411 procedure Error_Pragma (Msg : String);
412 pragma No_Return (Error_Pragma);
413 -- Outputs error message for current pragma. The message contains an %
414 -- that will be replaced with the pragma name, and the flag is placed
415 -- on the pragma itself. Pragma_Exit is then raised.
417 procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id);
418 pragma No_Return (Error_Pragma_Arg);
419 -- Outputs error message for current pragma. The message may contain
420 -- a % that will be replaced with the pragma name. The parameter Arg
421 -- may either be a pragma argument association, in which case the flag
422 -- is placed on the expression of this association, or an expression,
423 -- in which case the flag is placed directly on the expression. The
424 -- message is placed using Error_Msg_N, so the message may also contain
425 -- an & insertion character which will reference the given Arg value.
426 -- After placing the message, Pragma_Exit is raised.
428 procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id);
429 pragma No_Return (Error_Pragma_Arg);
430 -- Similar to above form of Error_Pragma_Arg except that two messages
431 -- are provided, the second is a continuation comment starting with \.
433 procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id);
434 pragma No_Return (Error_Pragma_Arg_Ident);
435 -- Outputs error message for current pragma. The message may contain
436 -- a % that will be replaced with the pragma name. The parameter Arg
437 -- must be a pragma argument association with a non-empty identifier
438 -- (i.e. its Chars field must be set), and the error message is placed
439 -- on the identifier. The message is placed using Error_Msg_N so
440 -- the message may also contain an & insertion character which will
441 -- reference the identifier. After placing the message, Pragma_Exit
444 function Find_Lib_Unit_Name return Entity_Id;
445 -- Used for a library unit pragma to find the entity to which the
446 -- library unit pragma applies, returns the entity found.
448 procedure Find_Program_Unit_Name (Id : Node_Id);
449 -- If the pragma is a compilation unit pragma, the id must denote the
450 -- compilation unit in the same compilation, and the pragma must appear
451 -- in the list of preceding or trailing pragmas. If it is a program
452 -- unit pragma that is not a compilation unit pragma, then the
453 -- identifier must be visible.
455 function Find_Unique_Parameterless_Procedure
457 Arg : Node_Id) return Entity_Id;
458 -- Used for a procedure pragma to find the unique parameterless
459 -- procedure identified by Name, returns it if it exists, otherwise
460 -- errors out and uses Arg as the pragma argument for the message.
462 procedure Gather_Associations
464 Args : out Args_List);
465 -- This procedure is used to gather the arguments for a pragma that
466 -- permits arbitrary ordering of parameters using the normal rules
467 -- for named and positional parameters. The Names argument is a list
468 -- of Name_Id values that corresponds to the allowed pragma argument
469 -- association identifiers in order. The result returned in Args is
470 -- a list of corresponding expressions that are the pragma arguments.
471 -- Note that this is a list of expressions, not of pragma argument
472 -- associations (Gather_Associations has completely checked all the
473 -- optional identifiers when it returns). An entry in Args is Empty
474 -- on return if the corresponding argument is not present.
476 function Get_Pragma_Arg (Arg : Node_Id) return Node_Id;
477 -- All the routines that check pragma arguments take either a pragma
478 -- argument association (in which case the expression of the argument
479 -- association is checked), or the expression directly. The function
480 -- Get_Pragma_Arg is a utility used to deal with these two cases. If
481 -- Arg is a pragma argument association node, then its expression is
482 -- returned, otherwise Arg is returned unchanged.
484 procedure GNAT_Pragma;
485 -- Called for all GNAT defined pragmas to note the use of the feature,
486 -- and also check the relevant restriction (No_Implementation_Pragmas).
488 function Is_Before_First_Decl
489 (Pragma_Node : Node_Id;
490 Decls : List_Id) return Boolean;
491 -- Return True if Pragma_Node is before the first declarative item in
492 -- Decls where Decls is the list of declarative items.
494 function Is_Configuration_Pragma return Boolean;
495 -- Deterermines if the placement of the current pragma is appropriate
496 -- for a configuration pragma (precedes the current compilation unit)
498 procedure Pragma_Misplaced;
499 -- Issue fatal error message for misplaced pragma
501 procedure Process_Atomic_Shared_Volatile;
502 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
503 -- Shared is an obsolete Ada 83 pragma, treated as being identical
504 -- in effect to pragma Atomic.
506 procedure Process_Convention (C : out Convention_Id; E : out Entity_Id);
507 -- Common procesing for Convention, Interface, Import and Export.
508 -- Checks first two arguments of pragma, and sets the appropriate
509 -- convention value in the specified entity or entities. On return
510 -- C is the convention, E is the referenced entity.
512 procedure Process_Extended_Import_Export_Exception_Pragma
513 (Arg_Internal : Node_Id;
514 Arg_External : Node_Id;
517 -- Common processing for the pragmas Import/Export_Exception.
518 -- The three arguments correspond to the three named parameters of
519 -- the pragma. An argument is empty if the corresponding parameter
520 -- is not present in the pragma.
522 procedure Process_Extended_Import_Export_Object_Pragma
523 (Arg_Internal : Node_Id;
524 Arg_External : Node_Id;
526 -- Common processing for the pragmass Import/Export_Object.
527 -- The three arguments correspond to the three named parameters
528 -- of the pragmas. An argument is empty if the corresponding
529 -- parameter is not present in the pragma.
531 procedure Process_Extended_Import_Export_Internal_Arg
532 (Arg_Internal : Node_Id := Empty);
533 -- Common processing for all extended Import and Export pragmas. The
534 -- argument is the pragma parameter for the Internal argument. If
535 -- Arg_Internal is empty or inappropriate, an error message is posted.
536 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
537 -- set to identify the referenced entity.
539 procedure Process_Extended_Import_Export_Subprogram_Pragma
540 (Arg_Internal : Node_Id;
541 Arg_External : Node_Id;
542 Arg_Parameter_Types : Node_Id;
543 Arg_Result_Type : Node_Id := Empty;
544 Arg_Mechanism : Node_Id;
545 Arg_Result_Mechanism : Node_Id := Empty;
546 Arg_First_Optional_Parameter : Node_Id := Empty);
547 -- Common processing for all extended Import and Export pragmas
548 -- applying to subprograms. The caller omits any arguments that do
549 -- bnot apply to the pragma in question (for example, Arg_Result_Type
550 -- can be non-Empty only in the Import_Function and Export_Function
551 -- cases). The argument names correspond to the allowed pragma
552 -- association identifiers.
554 procedure Process_Generic_List;
555 -- Common processing for Share_Generic and Inline_Generic
557 procedure Process_Import_Or_Interface;
558 -- Common processing for Import of Interface
560 procedure Process_Inline (Active : Boolean);
561 -- Common processing for Inline and Inline_Always. The parameter
562 -- indicates if the inline pragma is active, i.e. if it should
563 -- actually cause inlining to occur.
565 procedure Process_Interface_Name
566 (Subprogram_Def : Entity_Id;
569 -- Given the last two arguments of pragma Import, pragma Export, or
570 -- pragma Interface_Name, performs validity checks and sets the
571 -- Interface_Name field of the given subprogram entity to the
572 -- appropriate external or link name, depending on the arguments
573 -- given. Ext_Arg is always present, but Link_Arg may be missing.
574 -- Note that Ext_Arg may represent the Link_Name if Link_Arg is
575 -- missing, and appropriate named notation is used for Ext_Arg.
576 -- If neither Ext_Arg nor Link_Arg is present, the interface name
577 -- is set to the default from the subprogram name.
579 procedure Process_Interrupt_Or_Attach_Handler;
580 -- Common processing for Interrupt and Attach_Handler pragmas
582 procedure Process_Restrictions_Or_Restriction_Warnings;
583 -- Common processing for Restrictions and Restriction_Warnings pragmas
585 procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean);
586 -- Common processing for Suppress and Unsuppress. The boolean parameter
587 -- Suppress_Case is True for the Suppress case, and False for the
590 procedure Set_Exported (E : Entity_Id; Arg : Node_Id);
591 -- This procedure sets the Is_Exported flag for the given entity,
592 -- checking that the entity was not previously imported. Arg is
593 -- the argument that specified the entity. A check is also made
594 -- for exporting inappropriate entities.
596 procedure Set_Extended_Import_Export_External_Name
597 (Internal_Ent : Entity_Id;
598 Arg_External : Node_Id);
599 -- Common processing for all extended import export pragmas. The first
600 -- argument, Internal_Ent, is the internal entity, which has already
601 -- been checked for validity by the caller. Arg_External is from the
602 -- Import or Export pragma, and may be null if no External parameter
603 -- was present. If Arg_External is present and is a non-null string
604 -- (a null string is treated as the default), then the Interface_Name
605 -- field of Internal_Ent is set appropriately.
607 procedure Set_Imported (E : Entity_Id);
608 -- This procedure sets the Is_Imported flag for the given entity,
609 -- checking that it is not previously exported or imported.
611 procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id);
612 -- Mech is a parameter passing mechanism (see Import_Function syntax
613 -- for MECHANISM_NAME). This routine checks that the mechanism argument
614 -- has the right form, and if not issues an error message. If the
615 -- argument has the right form then the Mechanism field of Ent is
616 -- set appropriately.
618 procedure Set_Ravenscar_Profile (N : Node_Id);
619 -- Activate the set of configuration pragmas and restrictions that
620 -- make up the Ravenscar Profile. N is the corresponding pragma
621 -- node, which is used for error messages on any constructs
622 -- that violate the profile.
624 --------------------------
625 -- Check_Ada_83_Warning --
626 --------------------------
628 procedure Check_Ada_83_Warning is
630 if Ada_Version = Ada_83 and then Comes_From_Source (N) then
631 Error_Msg_N ("(Ada 83) pragma& is non-standard?", N);
633 end Check_Ada_83_Warning;
635 ---------------------
636 -- Check_Arg_Count --
637 ---------------------
639 procedure Check_Arg_Count (Required : Nat) is
641 if Arg_Count /= Required then
642 Error_Pragma ("wrong number of arguments for pragma%");
646 --------------------------------
647 -- Check_Arg_Is_External_Name --
648 --------------------------------
650 procedure Check_Arg_Is_External_Name (Arg : Node_Id) is
651 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
654 if Nkind (Argx) = N_Identifier then
658 Analyze_And_Resolve (Argx, Standard_String);
660 if Is_OK_Static_Expression (Argx) then
663 elsif Etype (Argx) = Any_Type then
666 -- An interesting special case, if we have a string literal and
667 -- we are in Ada 83 mode, then we allow it even though it will
668 -- not be flagged as static. This allows expected Ada 83 mode
669 -- use of external names which are string literals, even though
670 -- technically these are not static in Ada 83.
672 elsif Ada_Version = Ada_83
673 and then Nkind (Argx) = N_String_Literal
677 -- Static expression that raises Constraint_Error. This has
678 -- already been flagged, so just exit from pragma processing.
680 elsif Is_Static_Expression (Argx) then
683 -- Here we have a real error (non-static expression)
686 Error_Msg_Name_1 := Chars (N);
688 ("argument for pragma% must be a identifier or " &
689 "static string expression!", Argx);
693 end Check_Arg_Is_External_Name;
695 -----------------------------
696 -- Check_Arg_Is_Identifier --
697 -----------------------------
699 procedure Check_Arg_Is_Identifier (Arg : Node_Id) is
700 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
702 if Nkind (Argx) /= N_Identifier then
704 ("argument for pragma% must be identifier", Argx);
706 end Check_Arg_Is_Identifier;
708 ----------------------------------
709 -- Check_Arg_Is_Integer_Literal --
710 ----------------------------------
712 procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id) is
713 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
715 if Nkind (Argx) /= N_Integer_Literal then
717 ("argument for pragma% must be integer literal", Argx);
719 end Check_Arg_Is_Integer_Literal;
721 -------------------------------------------
722 -- Check_Arg_Is_Library_Level_Local_Name --
723 -------------------------------------------
727 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
728 -- | library_unit_NAME
730 procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id) is
732 Check_Arg_Is_Local_Name (Arg);
734 if not Is_Library_Level_Entity (Entity (Expression (Arg)))
735 and then Comes_From_Source (N)
738 ("argument for pragma% must be library level entity", Arg);
740 end Check_Arg_Is_Library_Level_Local_Name;
742 -----------------------------
743 -- Check_Arg_Is_Local_Name --
744 -----------------------------
748 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
749 -- | library_unit_NAME
751 procedure Check_Arg_Is_Local_Name (Arg : Node_Id) is
752 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
757 if Nkind (Argx) not in N_Direct_Name
758 and then (Nkind (Argx) /= N_Attribute_Reference
759 or else Present (Expressions (Argx))
760 or else Nkind (Prefix (Argx)) /= N_Identifier)
761 and then (not Is_Entity_Name (Argx)
762 or else not Is_Compilation_Unit (Entity (Argx)))
764 Error_Pragma_Arg ("argument for pragma% must be local name", Argx);
767 if Is_Entity_Name (Argx)
768 and then Scope (Entity (Argx)) /= Current_Scope
771 ("pragma% argument must be in same declarative part", Arg);
773 end Check_Arg_Is_Local_Name;
775 ---------------------------------
776 -- Check_Arg_Is_Locking_Policy --
777 ---------------------------------
779 procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id) is
780 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
783 Check_Arg_Is_Identifier (Argx);
785 if not Is_Locking_Policy_Name (Chars (Argx)) then
787 ("& is not a valid locking policy name", Argx);
789 end Check_Arg_Is_Locking_Policy;
791 -------------------------
792 -- Check_Arg_Is_One_Of --
793 -------------------------
795 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id) is
796 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
799 Check_Arg_Is_Identifier (Argx);
801 if Chars (Argx) /= N1 and then Chars (Argx) /= N2 then
802 Error_Msg_Name_2 := N1;
803 Error_Msg_Name_3 := N2;
804 Error_Pragma_Arg ("argument for pragma% must be% or%", Argx);
806 end Check_Arg_Is_One_Of;
808 procedure Check_Arg_Is_One_Of
810 N1, N2, N3 : Name_Id)
812 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
815 Check_Arg_Is_Identifier (Argx);
817 if Chars (Argx) /= N1
818 and then Chars (Argx) /= N2
819 and then Chars (Argx) /= N3
821 Error_Pragma_Arg ("invalid argument for pragma%", Argx);
823 end Check_Arg_Is_One_Of;
825 ---------------------------------
826 -- Check_Arg_Is_Queuing_Policy --
827 ---------------------------------
829 procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id) is
830 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
833 Check_Arg_Is_Identifier (Argx);
835 if not Is_Queuing_Policy_Name (Chars (Argx)) then
837 ("& is not a valid queuing policy name", Argx);
839 end Check_Arg_Is_Queuing_Policy;
841 ------------------------------------
842 -- Check_Arg_Is_Static_Expression --
843 ------------------------------------
845 procedure Check_Arg_Is_Static_Expression
849 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
852 Analyze_And_Resolve (Argx, Typ);
854 if Is_OK_Static_Expression (Argx) then
857 elsif Etype (Argx) = Any_Type then
860 -- An interesting special case, if we have a string literal and
861 -- we are in Ada 83 mode, then we allow it even though it will
862 -- not be flagged as static. This allows the use of Ada 95
863 -- pragmas like Import in Ada 83 mode. They will of course be
864 -- flagged with warnings as usual, but will not cause errors.
866 elsif Ada_Version = Ada_83
867 and then Nkind (Argx) = N_String_Literal
871 -- Static expression that raises Constraint_Error. This has
872 -- already been flagged, so just exit from pragma processing.
874 elsif Is_Static_Expression (Argx) then
877 -- Finally, we have a real error
880 Error_Msg_Name_1 := Chars (N);
882 ("argument for pragma% must be a static expression!", Argx);
885 end Check_Arg_Is_Static_Expression;
887 ---------------------------------
888 -- Check_Arg_Is_String_Literal --
889 ---------------------------------
891 procedure Check_Arg_Is_String_Literal (Arg : Node_Id) is
892 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
894 if Nkind (Argx) /= N_String_Literal then
896 ("argument for pragma% must be string literal", Argx);
898 end Check_Arg_Is_String_Literal;
900 ------------------------------------------
901 -- Check_Arg_Is_Task_Dispatching_Policy --
902 ------------------------------------------
904 procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id) is
905 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
908 Check_Arg_Is_Identifier (Argx);
910 if not Is_Task_Dispatching_Policy_Name (Chars (Argx)) then
912 ("& is not a valid task dispatching policy name", Argx);
914 end Check_Arg_Is_Task_Dispatching_Policy;
916 ---------------------
917 -- Check_Arg_Order --
918 ---------------------
920 procedure Check_Arg_Order (Names : Name_List) is
923 Highest_So_Far : Natural := 0;
924 -- Highest index in Names seen do far
928 for J in 1 .. Arg_Count loop
929 if Chars (Arg) /= No_Name then
930 for K in Names'Range loop
931 if Chars (Arg) = Names (K) then
932 if K < Highest_So_Far then
933 Error_Msg_Name_1 := Chars (N);
935 ("parameters out of order for pragma%", Arg);
936 Error_Msg_Name_1 := Names (K);
937 Error_Msg_Name_2 := Names (Highest_So_Far);
938 Error_Msg_N ("\% must appear before %", Arg);
952 --------------------------------
953 -- Check_At_Least_N_Arguments --
954 --------------------------------
956 procedure Check_At_Least_N_Arguments (N : Nat) is
958 if Arg_Count < N then
959 Error_Pragma ("too few arguments for pragma%");
961 end Check_At_Least_N_Arguments;
963 -------------------------------
964 -- Check_At_Most_N_Arguments --
965 -------------------------------
967 procedure Check_At_Most_N_Arguments (N : Nat) is
970 if Arg_Count > N then
974 Error_Pragma_Arg ("too many arguments for pragma%", Arg);
977 end Check_At_Most_N_Arguments;
979 ---------------------
980 -- Check_Component --
981 ---------------------
983 procedure Check_Component (Comp : Node_Id) is
985 if Nkind (Comp) = N_Component_Declaration then
987 Sindic : constant Node_Id :=
988 Subtype_Indication (Component_Definition (Comp));
991 if Nkind (Sindic) = N_Subtype_Indication then
993 -- Ada 2005 (AI-216): If a component subtype is subject to
994 -- a per-object constraint, then the component type shall
995 -- be an Unchecked_Union.
997 if Has_Per_Object_Constraint (Defining_Identifier (Comp))
999 not Is_Unchecked_Union (Etype (Subtype_Mark (Sindic)))
1001 Error_Msg_N ("component subtype subject to per-object" &
1002 " constraint must be an Unchecked_Union", Comp);
1007 end Check_Component;
1009 ----------------------------------
1010 -- Check_Duplicated_Export_Name --
1011 ----------------------------------
1013 procedure Check_Duplicated_Export_Name (Nam : Node_Id) is
1014 String_Val : constant String_Id := Strval (Nam);
1017 -- We are only interested in the export case, and in the case of
1018 -- generics, it is the instance, not the template, that is the
1019 -- problem (the template will generate a warning in any case).
1021 if not Inside_A_Generic
1022 and then (Prag_Id = Pragma_Export
1024 Prag_Id = Pragma_Export_Procedure
1026 Prag_Id = Pragma_Export_Valued_Procedure
1028 Prag_Id = Pragma_Export_Function)
1030 for J in Externals.First .. Externals.Last loop
1031 if String_Equal (String_Val, Strval (Externals.Table (J))) then
1032 Error_Msg_Sloc := Sloc (Externals.Table (J));
1033 Error_Msg_N ("external name duplicates name given#", Nam);
1038 Externals.Append (Nam);
1040 end Check_Duplicated_Export_Name;
1042 -------------------------
1043 -- Check_First_Subtype --
1044 -------------------------
1046 procedure Check_First_Subtype (Arg : Node_Id) is
1047 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1049 if not Is_First_Subtype (Entity (Argx)) then
1051 ("pragma% cannot apply to subtype", Argx);
1053 end Check_First_Subtype;
1055 ---------------------------
1056 -- Check_In_Main_Program --
1057 ---------------------------
1059 procedure Check_In_Main_Program is
1060 P : constant Node_Id := Parent (N);
1063 -- Must be at in subprogram body
1065 if Nkind (P) /= N_Subprogram_Body then
1066 Error_Pragma ("% pragma allowed only in subprogram");
1068 -- Otherwise warn if obviously not main program
1070 elsif Present (Parameter_Specifications (Specification (P)))
1071 or else not Is_Compilation_Unit (Defining_Entity (P))
1073 Error_Msg_Name_1 := Chars (N);
1075 ("?pragma% is only effective in main program", N);
1077 end Check_In_Main_Program;
1079 ---------------------------------------
1080 -- Check_Interrupt_Or_Attach_Handler --
1081 ---------------------------------------
1083 procedure Check_Interrupt_Or_Attach_Handler is
1084 Arg1_X : constant Node_Id := Expression (Arg1);
1085 Handler_Proc, Proc_Scope : Entity_Id;
1090 if Prag_Id = Pragma_Interrupt_Handler then
1091 Check_Restriction (No_Dynamic_Attachment, N);
1094 Handler_Proc := Find_Unique_Parameterless_Procedure (Arg1_X, Arg1);
1095 Proc_Scope := Scope (Handler_Proc);
1097 -- On AAMP only, a pragma Interrupt_Handler is supported for
1098 -- nonprotected parameterless procedures.
1100 if not AAMP_On_Target
1101 or else Prag_Id = Pragma_Attach_Handler
1103 if Ekind (Proc_Scope) /= E_Protected_Type then
1105 ("argument of pragma% must be protected procedure", Arg1);
1108 if Parent (N) /= Protected_Definition (Parent (Proc_Scope)) then
1109 Error_Pragma ("pragma% must be in protected definition");
1113 if not Is_Library_Level_Entity (Proc_Scope)
1114 or else (AAMP_On_Target
1115 and then not Is_Library_Level_Entity (Handler_Proc))
1118 ("argument for pragma% must be library level entity", Arg1);
1120 end Check_Interrupt_Or_Attach_Handler;
1122 -------------------------------------------
1123 -- Check_Is_In_Decl_Part_Or_Package_Spec --
1124 -------------------------------------------
1126 procedure Check_Is_In_Decl_Part_Or_Package_Spec is
1135 elsif Nkind (P) = N_Handled_Sequence_Of_Statements then
1138 elsif Nkind (P) = N_Package_Specification then
1141 elsif Nkind (P) = N_Block_Statement then
1144 -- Note: the following tests seem a little peculiar, because
1145 -- they test for bodies, but if we were in the statement part
1146 -- of the body, we would already have hit the handled statement
1147 -- sequence, so the only way we get here is by being in the
1148 -- declarative part of the body.
1150 elsif Nkind (P) = N_Subprogram_Body
1151 or else Nkind (P) = N_Package_Body
1152 or else Nkind (P) = N_Task_Body
1153 or else Nkind (P) = N_Entry_Body
1161 Error_Pragma ("pragma% is not in declarative part or package spec");
1162 end Check_Is_In_Decl_Part_Or_Package_Spec;
1164 -------------------------
1165 -- Check_No_Identifier --
1166 -------------------------
1168 procedure Check_No_Identifier (Arg : Node_Id) is
1170 if Chars (Arg) /= No_Name then
1171 Error_Pragma_Arg_Ident
1172 ("pragma% does not permit identifier& here", Arg);
1174 end Check_No_Identifier;
1176 --------------------------
1177 -- Check_No_Identifiers --
1178 --------------------------
1180 procedure Check_No_Identifiers is
1183 if Arg_Count > 0 then
1185 while Present (Arg_Node) loop
1186 Check_No_Identifier (Arg_Node);
1190 end Check_No_Identifiers;
1192 -------------------------------
1193 -- Check_Optional_Identifier --
1194 -------------------------------
1196 procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id) is
1198 if Present (Arg) and then Chars (Arg) /= No_Name then
1199 if Chars (Arg) /= Id then
1200 Error_Msg_Name_1 := Chars (N);
1201 Error_Msg_Name_2 := Id;
1202 Error_Msg_N ("pragma% argument expects identifier%", Arg);
1206 end Check_Optional_Identifier;
1208 procedure Check_Optional_Identifier (Arg : Node_Id; Id : String) is
1210 Name_Buffer (1 .. Id'Length) := Id;
1211 Name_Len := Id'Length;
1212 Check_Optional_Identifier (Arg, Name_Find);
1213 end Check_Optional_Identifier;
1215 -----------------------------
1216 -- Check_Static_Constraint --
1217 -----------------------------
1219 -- Note: for convenience in writing this procedure, in addition to
1220 -- the officially (i.e. by spec) allowed argument which is always
1221 -- a constraint, it also allows ranges and discriminant associations.
1222 -- Above is not clear ???
1224 procedure Check_Static_Constraint (Constr : Node_Id) is
1226 --------------------
1227 -- Require_Static --
1228 --------------------
1230 procedure Require_Static (E : Node_Id);
1231 -- Require given expression to be static expression
1233 procedure Require_Static (E : Node_Id) is
1235 if not Is_OK_Static_Expression (E) then
1236 Flag_Non_Static_Expr
1237 ("non-static constraint not allowed in Unchecked_Union!", E);
1242 -- Start of processing for Check_Static_Constraint
1245 case Nkind (Constr) is
1246 when N_Discriminant_Association =>
1247 Require_Static (Expression (Constr));
1250 Require_Static (Low_Bound (Constr));
1251 Require_Static (High_Bound (Constr));
1253 when N_Attribute_Reference =>
1254 Require_Static (Type_Low_Bound (Etype (Prefix (Constr))));
1255 Require_Static (Type_High_Bound (Etype (Prefix (Constr))));
1257 when N_Range_Constraint =>
1258 Check_Static_Constraint (Range_Expression (Constr));
1260 when N_Index_Or_Discriminant_Constraint =>
1264 IDC := First (Constraints (Constr));
1265 while Present (IDC) loop
1266 Check_Static_Constraint (IDC);
1274 end Check_Static_Constraint;
1276 --------------------------------------
1277 -- Check_Valid_Configuration_Pragma --
1278 --------------------------------------
1280 -- A configuration pragma must appear in the context clause of
1281 -- a compilation unit, at the start of the list (i.e. only other
1282 -- pragmas may precede it).
1284 procedure Check_Valid_Configuration_Pragma is
1286 if not Is_Configuration_Pragma then
1287 Error_Pragma ("incorrect placement for configuration pragma%");
1289 end Check_Valid_Configuration_Pragma;
1291 -------------------------------------
1292 -- Check_Valid_Library_Unit_Pragma --
1293 -------------------------------------
1295 procedure Check_Valid_Library_Unit_Pragma is
1297 Parent_Node : Node_Id;
1298 Unit_Name : Entity_Id;
1299 Unit_Kind : Node_Kind;
1300 Unit_Node : Node_Id;
1301 Sindex : Source_File_Index;
1304 if not Is_List_Member (N) then
1308 Plist := List_Containing (N);
1309 Parent_Node := Parent (Plist);
1311 if Parent_Node = Empty then
1314 -- Case of pragma appearing after a compilation unit. In this
1315 -- case it must have an argument with the corresponding name
1316 -- and must be part of the following pragmas of its parent.
1318 elsif Nkind (Parent_Node) = N_Compilation_Unit_Aux then
1319 if Plist /= Pragmas_After (Parent_Node) then
1322 elsif Arg_Count = 0 then
1324 ("argument required if outside compilation unit");
1327 Check_No_Identifiers;
1328 Check_Arg_Count (1);
1329 Unit_Node := Unit (Parent (Parent_Node));
1330 Unit_Kind := Nkind (Unit_Node);
1332 Analyze (Expression (Arg1));
1334 if Unit_Kind = N_Generic_Subprogram_Declaration
1335 or else Unit_Kind = N_Subprogram_Declaration
1337 Unit_Name := Defining_Entity (Unit_Node);
1339 elsif Unit_Kind = N_Function_Instantiation
1340 or else Unit_Kind = N_Package_Instantiation
1341 or else Unit_Kind = N_Procedure_Instantiation
1343 Unit_Name := Defining_Entity (Unit_Node);
1346 Unit_Name := Cunit_Entity (Current_Sem_Unit);
1349 if Chars (Unit_Name) /=
1350 Chars (Entity (Expression (Arg1)))
1353 ("pragma% argument is not current unit name", Arg1);
1356 if Ekind (Unit_Name) = E_Package
1357 and then Present (Renamed_Entity (Unit_Name))
1359 Error_Pragma ("pragma% not allowed for renamed package");
1363 -- Pragma appears other than after a compilation unit
1366 -- Here we check for the generic instantiation case and also
1367 -- for the case of processing a generic formal package. We
1368 -- detect these cases by noting that the Sloc on the node
1369 -- does not belong to the current compilation unit.
1371 Sindex := Source_Index (Current_Sem_Unit);
1373 if Loc not in Source_First (Sindex) .. Source_Last (Sindex) then
1374 Rewrite (N, Make_Null_Statement (Loc));
1377 -- If before first declaration, the pragma applies to the
1378 -- enclosing unit, and the name if present must be this name.
1380 elsif Is_Before_First_Decl (N, Plist) then
1381 Unit_Node := Unit_Declaration_Node (Current_Scope);
1382 Unit_Kind := Nkind (Unit_Node);
1384 if Nkind (Parent (Unit_Node)) /= N_Compilation_Unit then
1387 elsif Unit_Kind = N_Subprogram_Body
1388 and then not Acts_As_Spec (Unit_Node)
1392 elsif Nkind (Parent_Node) = N_Package_Body then
1395 elsif Nkind (Parent_Node) = N_Package_Specification
1396 and then Plist = Private_Declarations (Parent_Node)
1400 elsif (Nkind (Parent_Node) = N_Generic_Package_Declaration
1401 or else Nkind (Parent_Node)
1402 = N_Generic_Subprogram_Declaration)
1403 and then Plist = Generic_Formal_Declarations (Parent_Node)
1407 elsif Arg_Count > 0 then
1408 Analyze (Expression (Arg1));
1410 if Entity (Expression (Arg1)) /= Current_Scope then
1412 ("name in pragma% must be enclosing unit", Arg1);
1415 -- It is legal to have no argument in this context
1421 -- Error if not before first declaration. This is because a
1422 -- library unit pragma argument must be the name of a library
1423 -- unit (RM 10.1.5(7)), but the only names permitted in this
1424 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1425 -- generic subprogram declarations or generic instantiations.
1429 ("pragma% misplaced, must be before first declaration");
1433 end Check_Valid_Library_Unit_Pragma;
1439 procedure Check_Variant (Variant : Node_Id) is
1440 Clist : constant Node_Id := Component_List (Variant);
1444 if Present (Variant_Part (Clist)) then
1446 ("Unchecked_Union may not have nested variants",
1447 Variant_Part (Clist));
1450 if not Is_Non_Empty_List (Component_Items (Clist)) then
1452 ("Unchecked_Union may not have empty component list",
1457 Comp := First (Component_Items (Clist));
1458 while Present (Comp) loop
1459 Check_Component (Comp);
1468 procedure Error_Pragma (Msg : String) is
1470 Error_Msg_Name_1 := Chars (N);
1471 Error_Msg_N (Msg, N);
1475 ----------------------
1476 -- Error_Pragma_Arg --
1477 ----------------------
1479 procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id) is
1481 Error_Msg_Name_1 := Chars (N);
1482 Error_Msg_N (Msg, Get_Pragma_Arg (Arg));
1484 end Error_Pragma_Arg;
1486 procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id) is
1488 Error_Msg_Name_1 := Chars (N);
1489 Error_Msg_N (Msg1, Get_Pragma_Arg (Arg));
1490 Error_Pragma_Arg (Msg2, Arg);
1491 end Error_Pragma_Arg;
1493 ----------------------------
1494 -- Error_Pragma_Arg_Ident --
1495 ----------------------------
1497 procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id) is
1499 Error_Msg_Name_1 := Chars (N);
1500 Error_Msg_N (Msg, Arg);
1502 end Error_Pragma_Arg_Ident;
1504 ------------------------
1505 -- Find_Lib_Unit_Name --
1506 ------------------------
1508 function Find_Lib_Unit_Name return Entity_Id is
1510 -- Return inner compilation unit entity, for case of nested
1511 -- categorization pragmas. This happens in generic unit.
1513 if Nkind (Parent (N)) = N_Package_Specification
1514 and then Defining_Entity (Parent (N)) /= Current_Scope
1516 return Defining_Entity (Parent (N));
1518 return Current_Scope;
1520 end Find_Lib_Unit_Name;
1522 ----------------------------
1523 -- Find_Program_Unit_Name --
1524 ----------------------------
1526 procedure Find_Program_Unit_Name (Id : Node_Id) is
1527 Unit_Name : Entity_Id;
1528 Unit_Kind : Node_Kind;
1529 P : constant Node_Id := Parent (N);
1532 if Nkind (P) = N_Compilation_Unit then
1533 Unit_Kind := Nkind (Unit (P));
1535 if Unit_Kind = N_Subprogram_Declaration
1536 or else Unit_Kind = N_Package_Declaration
1537 or else Unit_Kind in N_Generic_Declaration
1539 Unit_Name := Defining_Entity (Unit (P));
1541 if Chars (Id) = Chars (Unit_Name) then
1542 Set_Entity (Id, Unit_Name);
1543 Set_Etype (Id, Etype (Unit_Name));
1545 Set_Etype (Id, Any_Type);
1547 ("cannot find program unit referenced by pragma%");
1551 Set_Etype (Id, Any_Type);
1552 Error_Pragma ("pragma% inapplicable to this unit");
1558 end Find_Program_Unit_Name;
1560 -----------------------------------------
1561 -- Find_Unique_Parameterless_Procedure --
1562 -----------------------------------------
1564 function Find_Unique_Parameterless_Procedure
1566 Arg : Node_Id) return Entity_Id
1568 Proc : Entity_Id := Empty;
1571 -- The body of this procedure needs some comments ???
1573 if not Is_Entity_Name (Name) then
1575 ("argument of pragma% must be entity name", Arg);
1577 elsif not Is_Overloaded (Name) then
1578 Proc := Entity (Name);
1580 if Ekind (Proc) /= E_Procedure
1581 or else Present (First_Formal (Proc)) then
1583 ("argument of pragma% must be parameterless procedure", Arg);
1588 Found : Boolean := False;
1590 Index : Interp_Index;
1593 Get_First_Interp (Name, Index, It);
1594 while Present (It.Nam) loop
1597 if Ekind (Proc) = E_Procedure
1598 and then No (First_Formal (Proc))
1602 Set_Entity (Name, Proc);
1603 Set_Is_Overloaded (Name, False);
1606 ("ambiguous handler name for pragma% ", Arg);
1610 Get_Next_Interp (Index, It);
1615 ("argument of pragma% must be parameterless procedure",
1618 Proc := Entity (Name);
1624 end Find_Unique_Parameterless_Procedure;
1626 -------------------------
1627 -- Gather_Associations --
1628 -------------------------
1630 procedure Gather_Associations
1632 Args : out Args_List)
1637 -- Initialize all parameters to Empty
1639 for J in Args'Range loop
1643 -- That's all we have to do if there are no argument associations
1645 if No (Pragma_Argument_Associations (N)) then
1649 -- Otherwise first deal with any positional parameters present
1651 Arg := First (Pragma_Argument_Associations (N));
1652 for Index in Args'Range loop
1653 exit when No (Arg) or else Chars (Arg) /= No_Name;
1654 Args (Index) := Expression (Arg);
1658 -- Positional parameters all processed, if any left, then we
1659 -- have too many positional parameters.
1661 if Present (Arg) and then Chars (Arg) = No_Name then
1663 ("too many positional associations for pragma%", Arg);
1666 -- Process named parameters if any are present
1668 while Present (Arg) loop
1669 if Chars (Arg) = No_Name then
1671 ("positional association cannot follow named association",
1675 for Index in Names'Range loop
1676 if Names (Index) = Chars (Arg) then
1677 if Present (Args (Index)) then
1679 ("duplicate argument association for pragma%", Arg);
1681 Args (Index) := Expression (Arg);
1686 if Index = Names'Last then
1687 Error_Msg_Name_1 := Chars (N);
1688 Error_Msg_N ("pragma% does not allow & argument", Arg);
1690 -- Check for possible misspelling
1692 for Index1 in Names'Range loop
1693 if Is_Bad_Spelling_Of
1694 (Get_Name_String (Chars (Arg)),
1695 Get_Name_String (Names (Index1)))
1697 Error_Msg_Name_1 := Names (Index1);
1698 Error_Msg_N ("\possible misspelling of%", Arg);
1710 end Gather_Associations;
1712 --------------------
1713 -- Get_Pragma_Arg --
1714 --------------------
1716 function Get_Pragma_Arg (Arg : Node_Id) return Node_Id is
1718 if Nkind (Arg) = N_Pragma_Argument_Association then
1719 return Expression (Arg);
1729 procedure GNAT_Pragma is
1731 Check_Restriction (No_Implementation_Pragmas, N);
1734 --------------------------
1735 -- Is_Before_First_Decl --
1736 --------------------------
1738 function Is_Before_First_Decl
1739 (Pragma_Node : Node_Id;
1740 Decls : List_Id) return Boolean
1742 Item : Node_Id := First (Decls);
1745 -- Only other pragmas can come before this pragma
1748 if No (Item) or else Nkind (Item) /= N_Pragma then
1751 elsif Item = Pragma_Node then
1757 end Is_Before_First_Decl;
1759 -----------------------------
1760 -- Is_Configuration_Pragma --
1761 -----------------------------
1763 -- A configuration pragma must appear in the context clause of
1764 -- a compilation unit, at the start of the list (i.e. only other
1765 -- pragmas may precede it).
1767 function Is_Configuration_Pragma return Boolean is
1768 Lis : constant List_Id := List_Containing (N);
1769 Par : constant Node_Id := Parent (N);
1773 -- If no parent, then we are in the configuration pragma file,
1774 -- so the placement is definitely appropriate.
1779 -- Otherwise we must be in the context clause of a compilation unit
1780 -- and the only thing allowed before us in the context list is more
1781 -- configuration pragmas.
1783 elsif Nkind (Par) = N_Compilation_Unit
1784 and then Context_Items (Par) = Lis
1791 elsif Nkind (Prg) /= N_Pragma then
1801 end Is_Configuration_Pragma;
1803 ----------------------
1804 -- Pragma_Misplaced --
1805 ----------------------
1807 procedure Pragma_Misplaced is
1809 Error_Pragma ("incorrect placement of pragma%");
1810 end Pragma_Misplaced;
1812 ------------------------------------
1813 -- Process Atomic_Shared_Volatile --
1814 ------------------------------------
1816 procedure Process_Atomic_Shared_Volatile is
1823 procedure Set_Atomic (E : Entity_Id);
1824 -- Set given type as atomic, and if no explicit alignment was
1825 -- given, set alignment to unknown, since back end knows what
1826 -- the alignment requirements are for atomic arrays. Note that
1827 -- this step is necessary for derived types.
1833 procedure Set_Atomic (E : Entity_Id) is
1837 if not Has_Alignment_Clause (E) then
1838 Set_Alignment (E, Uint_0);
1842 -- Start of processing for Process_Atomic_Shared_Volatile
1845 Check_Ada_83_Warning;
1846 Check_No_Identifiers;
1847 Check_Arg_Count (1);
1848 Check_Arg_Is_Local_Name (Arg1);
1849 E_Id := Expression (Arg1);
1851 if Etype (E_Id) = Any_Type then
1856 D := Declaration_Node (E);
1860 if Rep_Item_Too_Early (E, N)
1862 Rep_Item_Too_Late (E, N)
1866 Check_First_Subtype (Arg1);
1869 if Prag_Id /= Pragma_Volatile then
1871 Set_Atomic (Underlying_Type (E));
1872 Set_Atomic (Base_Type (E));
1875 -- Attribute belongs on the base type. If the
1876 -- view of the type is currently private, it also
1877 -- belongs on the underlying type.
1879 Set_Is_Volatile (Base_Type (E));
1880 Set_Is_Volatile (Underlying_Type (E));
1882 Set_Treat_As_Volatile (E);
1883 Set_Treat_As_Volatile (Underlying_Type (E));
1885 elsif K = N_Object_Declaration
1886 or else (K = N_Component_Declaration
1887 and then Original_Record_Component (E) = E)
1889 if Rep_Item_Too_Late (E, N) then
1893 if Prag_Id /= Pragma_Volatile then
1896 -- If the object declaration has an explicit
1897 -- initialization, a temporary may have to be
1898 -- created to hold the expression, to insure
1899 -- that access to the object remain atomic.
1901 if Nkind (Parent (E)) = N_Object_Declaration
1902 and then Present (Expression (Parent (E)))
1904 Set_Has_Delayed_Freeze (E);
1907 -- An interesting improvement here. If an object of type X
1908 -- is declared atomic, and the type X is not atomic, that's
1909 -- a pity, since it may not have appropraite alignment etc.
1910 -- We can rescue this in the special case where the object
1911 -- and type are in the same unit by just setting the type
1912 -- as atomic, so that the back end will process it as atomic.
1914 Utyp := Underlying_Type (Etype (E));
1917 and then Sloc (E) > No_Location
1918 and then Sloc (Utyp) > No_Location
1920 Get_Source_File_Index (Sloc (E)) =
1921 Get_Source_File_Index (Sloc (Underlying_Type (Etype (E))))
1923 Set_Is_Atomic (Underlying_Type (Etype (E)));
1927 Set_Is_Volatile (E);
1928 Set_Treat_As_Volatile (E);
1932 ("inappropriate entity for pragma%", Arg1);
1934 end Process_Atomic_Shared_Volatile;
1936 ------------------------
1937 -- Process_Convention --
1938 ------------------------
1940 procedure Process_Convention
1941 (C : out Convention_Id;
1947 Comp_Unit : Unit_Number_Type;
1949 procedure Set_Convention_From_Pragma (E : Entity_Id);
1950 -- Set convention in entity E, and also flag that the entity has a
1951 -- convention pragma. If entity is for a private or incomplete type,
1952 -- also set convention and flag on underlying type. This procedure
1953 -- also deals with the special case of C_Pass_By_Copy convention.
1955 --------------------------------
1956 -- Set_Convention_From_Pragma --
1957 --------------------------------
1959 procedure Set_Convention_From_Pragma (E : Entity_Id) is
1961 Set_Convention (E, C);
1962 Set_Has_Convention_Pragma (E);
1964 if Is_Incomplete_Or_Private_Type (E) then
1965 Set_Convention (Underlying_Type (E), C);
1966 Set_Has_Convention_Pragma (Underlying_Type (E), True);
1969 -- A class-wide type should inherit the convention of
1970 -- the specific root type (although this isn't specified
1971 -- clearly by the RM).
1973 if Is_Type (E) and then Present (Class_Wide_Type (E)) then
1974 Set_Convention (Class_Wide_Type (E), C);
1977 -- If the entity is a record type, then check for special case
1978 -- of C_Pass_By_Copy, which is treated the same as C except that
1979 -- the special record flag is set. This convention is also only
1980 -- permitted on record types (see AI95-00131).
1982 if Cname = Name_C_Pass_By_Copy then
1983 if Is_Record_Type (E) then
1984 Set_C_Pass_By_Copy (Base_Type (E));
1985 elsif Is_Incomplete_Or_Private_Type (E)
1986 and then Is_Record_Type (Underlying_Type (E))
1988 Set_C_Pass_By_Copy (Base_Type (Underlying_Type (E)));
1991 ("C_Pass_By_Copy convention allowed only for record type",
1996 -- If the entity is a derived boolean type, check for the
1997 -- special case of convention C, C++, or Fortran, where we
1998 -- consider any nonzero value to represent true.
2000 if Is_Discrete_Type (E)
2001 and then Root_Type (Etype (E)) = Standard_Boolean
2007 C = Convention_Fortran)
2009 Set_Nonzero_Is_True (Base_Type (E));
2011 end Set_Convention_From_Pragma;
2013 -- Start of processing for Process_Convention
2016 Check_At_Least_N_Arguments (2);
2017 Check_Optional_Identifier (Arg1, Name_Convention);
2018 Check_Arg_Is_Identifier (Arg1);
2019 Cname := Chars (Expression (Arg1));
2021 -- C_Pass_By_Copy is treated as a synonym for convention C
2022 -- (this is tested again below to set the critical flag)
2024 if Cname = Name_C_Pass_By_Copy then
2027 -- Otherwise we must have something in the standard convention list
2029 elsif Is_Convention_Name (Cname) then
2030 C := Get_Convention_Id (Chars (Expression (Arg1)));
2032 -- In DEC VMS, it seems that there is an undocumented feature
2033 -- that any unrecognized convention is treated as the default,
2034 -- which for us is convention C. It does not seem so terrible
2035 -- to do this unconditionally, silently in the VMS case, and
2036 -- with a warning in the non-VMS case.
2039 if Warn_On_Export_Import and not OpenVMS_On_Target then
2041 ("?unrecognized convention name, C assumed",
2048 Check_Optional_Identifier (Arg2, Name_Entity);
2049 Check_Arg_Is_Local_Name (Arg2);
2051 Id := Expression (Arg2);
2054 if not Is_Entity_Name (Id) then
2055 Error_Pragma_Arg ("entity name required", Arg2);
2060 -- Go to renamed subprogram if present, since convention applies
2061 -- to the actual renamed entity, not to the renaming entity.
2062 -- If subprogram is inherited, go to parent subprogram.
2064 if Is_Subprogram (E)
2065 and then Present (Alias (E))
2067 if Nkind (Parent (Declaration_Node (E)))
2068 = N_Subprogram_Renaming_Declaration
2072 elsif Nkind (Parent (E)) = N_Full_Type_Declaration
2073 and then Scope (E) = Scope (Alias (E))
2079 -- Check that we are not applying this to a specless body
2081 if Is_Subprogram (E)
2082 and then Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Body
2085 ("pragma% requires separate spec and must come before body");
2088 -- Check that we are not applying this to a named constant
2090 if Ekind (E) = E_Named_Integer
2092 Ekind (E) = E_Named_Real
2094 Error_Msg_Name_1 := Chars (N);
2096 ("cannot apply pragma% to named constant!",
2097 Get_Pragma_Arg (Arg2));
2099 ("\supply appropriate type for&!", Arg2);
2102 if Etype (E) = Any_Type
2103 or else Rep_Item_Too_Early (E, N)
2107 E := Underlying_Type (E);
2110 if Rep_Item_Too_Late (E, N) then
2114 if Has_Convention_Pragma (E) then
2116 ("at most one Convention/Export/Import pragma is allowed", Arg2);
2118 elsif Convention (E) = Convention_Protected
2119 or else Ekind (Scope (E)) = E_Protected_Type
2122 ("a protected operation cannot be given a different convention",
2126 -- For Intrinsic, a subprogram is required
2128 if C = Convention_Intrinsic
2129 and then not Is_Subprogram (E)
2130 and then not Is_Generic_Subprogram (E)
2133 ("second argument of pragma% must be a subprogram", Arg2);
2136 -- For Stdcall, a subprogram, variable or subprogram type is required
2138 if C = Convention_Stdcall
2139 and then not Is_Subprogram (E)
2140 and then not Is_Generic_Subprogram (E)
2141 and then Ekind (E) /= E_Variable
2144 and then Ekind (Designated_Type (E)) = E_Subprogram_Type)
2147 ("second argument of pragma% must be subprogram (type)",
2151 if not Is_Subprogram (E)
2152 and then not Is_Generic_Subprogram (E)
2154 Set_Convention_From_Pragma (E);
2158 Check_First_Subtype (Arg2);
2159 Set_Convention_From_Pragma (Base_Type (E));
2161 -- For subprograms, we must set the convention on the
2162 -- internally generated directly designated type as well.
2164 if Ekind (E) = E_Access_Subprogram_Type then
2165 Set_Convention_From_Pragma (Directly_Designated_Type (E));
2169 -- For the subprogram case, set proper convention for all homonyms
2170 -- in same scope and the same declarative part, i.e. the same
2171 -- compilation unit.
2174 Comp_Unit := Get_Source_Unit (E);
2175 Set_Convention_From_Pragma (E);
2177 -- Treat a pragma Import as an implicit body, for GPS use
2179 if Prag_Id = Pragma_Import then
2180 Generate_Reference (E, Id, 'b');
2186 exit when No (E1) or else Scope (E1) /= Current_Scope;
2188 -- Note: below we are missing a check for Rep_Item_Too_Late.
2189 -- That is deliberate, we cannot chain the rep item on more
2190 -- than one Rep_Item chain, to be fixed later ???
2192 if Comes_From_Source (E1)
2193 and then Comp_Unit = Get_Source_Unit (E1)
2194 and then Nkind (Original_Node (Parent (E1))) /=
2195 N_Full_Type_Declaration
2197 Set_Convention_From_Pragma (E1);
2199 if Prag_Id = Pragma_Import then
2200 Generate_Reference (E, Id, 'b');
2205 end Process_Convention;
2207 -----------------------------------------------------
2208 -- Process_Extended_Import_Export_Exception_Pragma --
2209 -----------------------------------------------------
2211 procedure Process_Extended_Import_Export_Exception_Pragma
2212 (Arg_Internal : Node_Id;
2213 Arg_External : Node_Id;
2223 if not OpenVMS_On_Target then
2225 ("?pragma% ignored (applies only to Open'V'M'S)");
2228 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2229 Def_Id := Entity (Arg_Internal);
2231 if Ekind (Def_Id) /= E_Exception then
2233 ("pragma% must refer to declared exception", Arg_Internal);
2236 Set_Extended_Import_Export_External_Name (Def_Id, Arg_External);
2238 if Present (Arg_Form) then
2239 Check_Arg_Is_One_Of (Arg_Form, Name_Ada, Name_VMS);
2242 if Present (Arg_Form)
2243 and then Chars (Arg_Form) = Name_Ada
2247 Set_Is_VMS_Exception (Def_Id);
2248 Set_Exception_Code (Def_Id, No_Uint);
2251 if Present (Arg_Code) then
2252 if not Is_VMS_Exception (Def_Id) then
2254 ("Code option for pragma% not allowed for Ada case",
2258 Check_Arg_Is_Static_Expression (Arg_Code, Any_Integer);
2259 Code_Val := Expr_Value (Arg_Code);
2261 if not UI_Is_In_Int_Range (Code_Val) then
2263 ("Code option for pragma% must be in 32-bit range",
2267 Set_Exception_Code (Def_Id, Code_Val);
2270 end Process_Extended_Import_Export_Exception_Pragma;
2272 -------------------------------------------------
2273 -- Process_Extended_Import_Export_Internal_Arg --
2274 -------------------------------------------------
2276 procedure Process_Extended_Import_Export_Internal_Arg
2277 (Arg_Internal : Node_Id := Empty)
2282 if No (Arg_Internal) then
2283 Error_Pragma ("Internal parameter required for pragma%");
2286 if Nkind (Arg_Internal) = N_Identifier then
2289 elsif Nkind (Arg_Internal) = N_Operator_Symbol
2290 and then (Prag_Id = Pragma_Import_Function
2292 Prag_Id = Pragma_Export_Function)
2298 ("wrong form for Internal parameter for pragma%", Arg_Internal);
2301 Check_Arg_Is_Local_Name (Arg_Internal);
2302 end Process_Extended_Import_Export_Internal_Arg;
2304 --------------------------------------------------
2305 -- Process_Extended_Import_Export_Object_Pragma --
2306 --------------------------------------------------
2308 procedure Process_Extended_Import_Export_Object_Pragma
2309 (Arg_Internal : Node_Id;
2310 Arg_External : Node_Id;
2316 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2317 Def_Id := Entity (Arg_Internal);
2319 if Ekind (Def_Id) /= E_Constant
2320 and then Ekind (Def_Id) /= E_Variable
2323 ("pragma% must designate an object", Arg_Internal);
2326 if Has_Rep_Pragma (Def_Id, Name_Common_Object)
2328 Has_Rep_Pragma (Def_Id, Name_Psect_Object)
2331 ("previous Common/Psect_Object applies, pragma % not permitted",
2335 if Rep_Item_Too_Late (Def_Id, N) then
2339 Set_Extended_Import_Export_External_Name (Def_Id, Arg_External);
2341 if Present (Arg_Size) then
2342 Check_Arg_Is_External_Name (Arg_Size);
2345 -- Export_Object case
2347 if Prag_Id = Pragma_Export_Object then
2348 if not Is_Library_Level_Entity (Def_Id) then
2350 ("argument for pragma% must be library level entity",
2354 if Ekind (Current_Scope) = E_Generic_Package then
2355 Error_Pragma ("pragma& cannot appear in a generic unit");
2358 if not Size_Known_At_Compile_Time (Etype (Def_Id)) then
2360 ("exported object must have compile time known size",
2364 if Warn_On_Export_Import and then Is_Exported (Def_Id) then
2366 ("?duplicate Export_Object pragma", N);
2368 Set_Exported (Def_Id, Arg_Internal);
2371 -- Import_Object case
2374 if Is_Concurrent_Type (Etype (Def_Id)) then
2376 ("cannot use pragma% for task/protected object",
2380 if Ekind (Def_Id) = E_Constant then
2382 ("cannot import a constant", Arg_Internal);
2385 if Warn_On_Export_Import
2386 and then Has_Discriminants (Etype (Def_Id))
2389 ("imported value must be initialized?", Arg_Internal);
2392 if Warn_On_Export_Import
2393 and then Is_Access_Type (Etype (Def_Id))
2396 ("cannot import object of an access type?", Arg_Internal);
2399 if Warn_On_Export_Import
2400 and then Is_Imported (Def_Id)
2403 ("?duplicate Import_Object pragma", N);
2405 -- Check for explicit initialization present. Note that an
2406 -- initialization that generated by the code generator, e.g.
2407 -- for an access type, does not count here.
2409 elsif Present (Expression (Parent (Def_Id)))
2412 (Original_Node (Expression (Parent (Def_Id))))
2414 Error_Msg_Sloc := Sloc (Def_Id);
2416 ("no initialization allowed for declaration of& #",
2417 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2420 Set_Imported (Def_Id);
2421 Note_Possible_Modification (Arg_Internal);
2424 end Process_Extended_Import_Export_Object_Pragma;
2426 ------------------------------------------------------
2427 -- Process_Extended_Import_Export_Subprogram_Pragma --
2428 ------------------------------------------------------
2430 procedure Process_Extended_Import_Export_Subprogram_Pragma
2431 (Arg_Internal : Node_Id;
2432 Arg_External : Node_Id;
2433 Arg_Parameter_Types : Node_Id;
2434 Arg_Result_Type : Node_Id := Empty;
2435 Arg_Mechanism : Node_Id;
2436 Arg_Result_Mechanism : Node_Id := Empty;
2437 Arg_First_Optional_Parameter : Node_Id := Empty)
2443 Ambiguous : Boolean;
2447 function Same_Base_Type
2449 Formal : Entity_Id) return Boolean;
2450 -- Determines if Ptype references the type of Formal. Note that
2451 -- only the base types need to match according to the spec. Ptype
2452 -- here is the argument from the pragma, which is either a type
2453 -- name, or an access attribute.
2455 --------------------
2456 -- Same_Base_Type --
2457 --------------------
2459 function Same_Base_Type
2461 Formal : Entity_Id) return Boolean
2463 Ftyp : constant Entity_Id := Base_Type (Etype (Formal));
2467 -- Case where pragma argument is typ'Access
2469 if Nkind (Ptype) = N_Attribute_Reference
2470 and then Attribute_Name (Ptype) = Name_Access
2472 Pref := Prefix (Ptype);
2475 if not Is_Entity_Name (Pref)
2476 or else Entity (Pref) = Any_Type
2481 -- We have a match if the corresponding argument is of an
2482 -- anonymous access type, and its designicated type matches
2483 -- the type of the prefix of the access attribute
2485 return Ekind (Ftyp) = E_Anonymous_Access_Type
2486 and then Base_Type (Entity (Pref)) =
2487 Base_Type (Etype (Designated_Type (Ftyp)));
2489 -- Case where pragma argument is a type name
2494 if not Is_Entity_Name (Ptype)
2495 or else Entity (Ptype) = Any_Type
2500 -- We have a match if the corresponding argument is of
2501 -- the type given in the pragma (comparing base types)
2503 return Base_Type (Entity (Ptype)) = Ftyp;
2507 -- Start of processing for
2508 -- Process_Extended_Import_Export_Subprogram_Pragma
2511 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2515 -- Loop through homonyms (overloadings) of the entity
2517 Hom_Id := Entity (Arg_Internal);
2518 while Present (Hom_Id) loop
2519 Def_Id := Get_Base_Subprogram (Hom_Id);
2521 -- We need a subprogram in the current scope
2523 if not Is_Subprogram (Def_Id)
2524 or else Scope (Def_Id) /= Current_Scope
2531 -- Pragma cannot apply to subprogram body
2533 if Is_Subprogram (Def_Id)
2536 (Declaration_Node (Def_Id))) = N_Subprogram_Body
2539 ("pragma% requires separate spec"
2540 & " and must come before body");
2543 -- Test result type if given, note that the result type
2544 -- parameter can only be present for the function cases.
2546 if Present (Arg_Result_Type)
2547 and then not Same_Base_Type (Arg_Result_Type, Def_Id)
2551 elsif Etype (Def_Id) /= Standard_Void_Type
2553 (Chars (N) = Name_Export_Procedure
2554 or else Chars (N) = Name_Import_Procedure)
2558 -- Test parameter types if given. Note that this parameter
2559 -- has not been analyzed (and must not be, since it is
2560 -- semantic nonsense), so we get it as the parser left it.
2562 elsif Present (Arg_Parameter_Types) then
2563 Check_Matching_Types : declare
2568 Formal := First_Formal (Def_Id);
2570 if Nkind (Arg_Parameter_Types) = N_Null then
2571 if Present (Formal) then
2575 -- A list of one type, e.g. (List) is parsed as
2576 -- a parenthesized expression.
2578 elsif Nkind (Arg_Parameter_Types) /= N_Aggregate
2579 and then Paren_Count (Arg_Parameter_Types) = 1
2582 or else Present (Next_Formal (Formal))
2587 Same_Base_Type (Arg_Parameter_Types, Formal);
2590 -- A list of more than one type is parsed as a aggregate
2592 elsif Nkind (Arg_Parameter_Types) = N_Aggregate
2593 and then Paren_Count (Arg_Parameter_Types) = 0
2595 Ptype := First (Expressions (Arg_Parameter_Types));
2596 while Present (Ptype) or else Present (Formal) loop
2599 or else not Same_Base_Type (Ptype, Formal)
2604 Next_Formal (Formal);
2609 -- Anything else is of the wrong form
2613 ("wrong form for Parameter_Types parameter",
2614 Arg_Parameter_Types);
2616 end Check_Matching_Types;
2619 -- Match is now False if the entry we found did not match
2620 -- either a supplied Parameter_Types or Result_Types argument
2626 -- Ambiguous case, the flag Ambiguous shows if we already
2627 -- detected this and output the initial messages.
2630 if not Ambiguous then
2632 Error_Msg_Name_1 := Chars (N);
2634 ("pragma% does not uniquely identify subprogram!",
2636 Error_Msg_Sloc := Sloc (Ent);
2637 Error_Msg_N ("matching subprogram #!", N);
2641 Error_Msg_Sloc := Sloc (Def_Id);
2642 Error_Msg_N ("matching subprogram #!", N);
2647 Hom_Id := Homonym (Hom_Id);
2650 -- See if we found an entry
2653 if not Ambiguous then
2654 if Is_Generic_Subprogram (Entity (Arg_Internal)) then
2656 ("pragma% cannot be given for generic subprogram");
2660 ("pragma% does not identify local subprogram");
2667 -- Import pragmas must be be for imported entities
2669 if Prag_Id = Pragma_Import_Function
2671 Prag_Id = Pragma_Import_Procedure
2673 Prag_Id = Pragma_Import_Valued_Procedure
2675 if not Is_Imported (Ent) then
2677 ("pragma Import or Interface must precede pragma%");
2680 -- Here we have the Export case which can set the entity as exported
2682 -- But does not do so if the specified external name is null,
2683 -- since that is taken as a signal in DEC Ada 83 (with which
2684 -- we want to be compatible) to request no external name.
2686 elsif Nkind (Arg_External) = N_String_Literal
2687 and then String_Length (Strval (Arg_External)) = 0
2691 -- In all other cases, set entit as exported
2694 Set_Exported (Ent, Arg_Internal);
2697 -- Special processing for Valued_Procedure cases
2699 if Prag_Id = Pragma_Import_Valued_Procedure
2701 Prag_Id = Pragma_Export_Valued_Procedure
2703 Formal := First_Formal (Ent);
2707 ("at least one parameter required for pragma%");
2709 elsif Ekind (Formal) /= E_Out_Parameter then
2711 ("first parameter must have mode out for pragma%");
2714 Set_Is_Valued_Procedure (Ent);
2718 Set_Extended_Import_Export_External_Name (Ent, Arg_External);
2720 -- Process Result_Mechanism argument if present. We have already
2721 -- checked that this is only allowed for the function case.
2723 if Present (Arg_Result_Mechanism) then
2724 Set_Mechanism_Value (Ent, Arg_Result_Mechanism);
2727 -- Process Mechanism parameter if present. Note that this parameter
2728 -- is not analyzed, and must not be analyzed since it is semantic
2729 -- nonsense, so we get it in exactly as the parser left it.
2731 if Present (Arg_Mechanism) then
2739 -- A single mechanism association without a formal parameter
2740 -- name is parsed as a parenthesized expression. All other
2741 -- cases are parsed as aggregates, so we rewrite the single
2742 -- parameter case as an aggregate for consistency.
2744 if Nkind (Arg_Mechanism) /= N_Aggregate
2745 and then Paren_Count (Arg_Mechanism) = 1
2747 Rewrite (Arg_Mechanism,
2748 Make_Aggregate (Sloc (Arg_Mechanism),
2749 Expressions => New_List (
2750 Relocate_Node (Arg_Mechanism))));
2753 -- Case of only mechanism name given, applies to all formals
2755 if Nkind (Arg_Mechanism) /= N_Aggregate then
2756 Formal := First_Formal (Ent);
2757 while Present (Formal) loop
2758 Set_Mechanism_Value (Formal, Arg_Mechanism);
2759 Next_Formal (Formal);
2762 -- Case of list of mechanism associations given
2765 if Null_Record_Present (Arg_Mechanism) then
2767 ("inappropriate form for Mechanism parameter",
2771 -- Deal with positional ones first
2773 Formal := First_Formal (Ent);
2775 if Present (Expressions (Arg_Mechanism)) then
2776 Mname := First (Expressions (Arg_Mechanism));
2778 while Present (Mname) loop
2781 ("too many mechanism associations", Mname);
2784 Set_Mechanism_Value (Formal, Mname);
2785 Next_Formal (Formal);
2790 -- Deal with named entries
2792 if Present (Component_Associations (Arg_Mechanism)) then
2793 Massoc := First (Component_Associations (Arg_Mechanism));
2795 while Present (Massoc) loop
2796 Choice := First (Choices (Massoc));
2798 if Nkind (Choice) /= N_Identifier
2799 or else Present (Next (Choice))
2802 ("incorrect form for mechanism association",
2806 Formal := First_Formal (Ent);
2810 ("parameter name & not present", Choice);
2813 if Chars (Choice) = Chars (Formal) then
2815 (Formal, Expression (Massoc));
2819 Next_Formal (Formal);
2829 -- Process First_Optional_Parameter argument if present. We have
2830 -- already checked that this is only allowed for the Import case.
2832 if Present (Arg_First_Optional_Parameter) then
2833 if Nkind (Arg_First_Optional_Parameter) /= N_Identifier then
2835 ("first optional parameter must be formal parameter name",
2836 Arg_First_Optional_Parameter);
2839 Formal := First_Formal (Ent);
2843 ("specified formal parameter& not found",
2844 Arg_First_Optional_Parameter);
2847 exit when Chars (Formal) =
2848 Chars (Arg_First_Optional_Parameter);
2850 Next_Formal (Formal);
2853 Set_First_Optional_Parameter (Ent, Formal);
2855 -- Check specified and all remaining formals have right form
2857 while Present (Formal) loop
2858 if Ekind (Formal) /= E_In_Parameter then
2860 ("optional formal& is not of mode in!",
2861 Arg_First_Optional_Parameter, Formal);
2864 Dval := Default_Value (Formal);
2866 if not Present (Dval) then
2868 ("optional formal& does not have default value!",
2869 Arg_First_Optional_Parameter, Formal);
2871 elsif Compile_Time_Known_Value_Or_Aggr (Dval) then
2876 ("default value for optional formal& is non-static!",
2877 Arg_First_Optional_Parameter, Formal);
2881 Set_Is_Optional_Parameter (Formal);
2882 Next_Formal (Formal);
2885 end Process_Extended_Import_Export_Subprogram_Pragma;
2887 --------------------------
2888 -- Process_Generic_List --
2889 --------------------------
2891 procedure Process_Generic_List is
2897 Check_No_Identifiers;
2898 Check_At_Least_N_Arguments (1);
2901 while Present (Arg) loop
2902 Exp := Expression (Arg);
2905 if not Is_Entity_Name (Exp)
2907 (not Is_Generic_Instance (Entity (Exp))
2909 not Is_Generic_Unit (Entity (Exp)))
2912 ("pragma% argument must be name of generic unit/instance",
2918 end Process_Generic_List;
2920 ---------------------------------
2921 -- Process_Import_Or_Interface --
2922 ---------------------------------
2924 procedure Process_Import_Or_Interface is
2930 Process_Convention (C, Def_Id);
2931 Kill_Size_Check_Code (Def_Id);
2932 Note_Possible_Modification (Expression (Arg2));
2934 if Ekind (Def_Id) = E_Variable
2936 Ekind (Def_Id) = E_Constant
2938 -- User initialization is not allowed for imported object, but
2939 -- the object declaration may contain a default initialization,
2940 -- that will be discarded. Note that an explicit initialization
2941 -- only counts if it comes from source, otherwise it is simply
2942 -- the code generator making an implicit initialization explicit.
2944 if Present (Expression (Parent (Def_Id)))
2945 and then Comes_From_Source (Expression (Parent (Def_Id)))
2947 Error_Msg_Sloc := Sloc (Def_Id);
2949 ("no initialization allowed for declaration of& #",
2950 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2954 Set_Imported (Def_Id);
2955 Process_Interface_Name (Def_Id, Arg3, Arg4);
2957 -- Note that we do not set Is_Public here. That's because we
2958 -- only want to set if if there is no address clause, and we
2959 -- don't know that yet, so we delay that processing till
2962 -- pragma Import completes deferred constants
2964 if Ekind (Def_Id) = E_Constant then
2965 Set_Has_Completion (Def_Id);
2968 -- It is not possible to import a constant of an unconstrained
2969 -- array type (e.g. string) because there is no simple way to
2970 -- write a meaningful subtype for it.
2972 if Is_Array_Type (Etype (Def_Id))
2973 and then not Is_Constrained (Etype (Def_Id))
2976 ("imported constant& must have a constrained subtype",
2981 elsif Is_Subprogram (Def_Id)
2982 or else Is_Generic_Subprogram (Def_Id)
2984 -- If the name is overloaded, pragma applies to all of the
2985 -- denoted entities in the same declarative part.
2988 while Present (Hom_Id) loop
2989 Def_Id := Get_Base_Subprogram (Hom_Id);
2991 -- Ignore inherited subprograms because the pragma will
2992 -- apply to the parent operation, which is the one called.
2994 if Is_Overloadable (Def_Id)
2995 and then Present (Alias (Def_Id))
2999 -- If it is not a subprogram, it must be in an outer
3000 -- scope and pragma does not apply.
3002 elsif not Is_Subprogram (Def_Id)
3003 and then not Is_Generic_Subprogram (Def_Id)
3007 -- Verify that the homonym is in the same declarative
3008 -- part (not just the same scope).
3010 elsif Parent (Unit_Declaration_Node (Def_Id)) /= Parent (N)
3011 and then Nkind (Parent (N)) /= N_Compilation_Unit_Aux
3016 Set_Imported (Def_Id);
3018 -- Special processing for Convention_Intrinsic
3020 if C = Convention_Intrinsic then
3022 -- Link_Name argument not allowed for intrinsic
3025 and then Chars (Arg3) = Name_Link_Name
3030 if Present (Arg4) then
3032 ("Link_Name argument not allowed for " &
3037 Set_Is_Intrinsic_Subprogram (Def_Id);
3039 -- If no external name is present, then check that
3040 -- this is a valid intrinsic subprogram. If an external
3041 -- name is present, then this is handled by the back end.
3044 Check_Intrinsic_Subprogram (Def_Id, Expression (Arg2));
3048 -- All interfaced procedures need an external symbol
3049 -- created for them since they are always referenced
3050 -- from another object file.
3052 Set_Is_Public (Def_Id);
3054 -- Verify that the subprogram does not have a completion
3055 -- through a renaming declaration. For other completions
3056 -- the pragma appears as a too late representation.
3059 Decl : constant Node_Id := Unit_Declaration_Node (Def_Id);
3063 and then Nkind (Decl) = N_Subprogram_Declaration
3064 and then Present (Corresponding_Body (Decl))
3067 (Unit_Declaration_Node
3068 (Corresponding_Body (Decl))) =
3069 N_Subprogram_Renaming_Declaration
3071 Error_Msg_Sloc := Sloc (Def_Id);
3072 Error_Msg_NE ("cannot import&#," &
3073 " already completed by a renaming",
3078 Set_Has_Completion (Def_Id);
3079 Process_Interface_Name (Def_Id, Arg3, Arg4);
3082 if Is_Compilation_Unit (Hom_Id) then
3084 -- Its possible homonyms are not affected by the pragma.
3085 -- Such homonyms might be present in the context of other
3086 -- units being compiled.
3091 Hom_Id := Homonym (Hom_Id);
3095 -- When the convention is Java, we also allow Import to be given
3096 -- for packages, exceptions, and record components.
3098 elsif C = Convention_Java
3100 (Ekind (Def_Id) = E_Package
3101 or else Ekind (Def_Id) = E_Exception
3102 or else Nkind (Parent (Def_Id)) = N_Component_Declaration)
3104 Set_Imported (Def_Id);
3105 Set_Is_Public (Def_Id);
3106 Process_Interface_Name (Def_Id, Arg3, Arg4);
3110 ("second argument of pragma% must be object or subprogram",
3114 -- If this pragma applies to a compilation unit, then the unit,
3115 -- which is a subprogram, does not require (or allow) a body.
3116 -- We also do not need to elaborate imported procedures.
3118 if Nkind (Parent (N)) = N_Compilation_Unit_Aux then
3120 Cunit : constant Node_Id := Parent (Parent (N));
3122 Set_Body_Required (Cunit, False);
3125 end Process_Import_Or_Interface;
3127 --------------------
3128 -- Process_Inline --
3129 --------------------
3131 procedure Process_Inline (Active : Boolean) is
3137 Effective : Boolean := False;
3139 procedure Make_Inline (Subp : Entity_Id);
3140 -- Subp is the defining unit name of the subprogram
3141 -- declaration. Set the flag, as well as the flag in the
3142 -- corresponding body, if there is one present.
3144 procedure Set_Inline_Flags (Subp : Entity_Id);
3145 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp
3147 function Inlining_Not_Possible (Subp : Entity_Id) return Boolean;
3148 -- Returns True if it can be determined at this stage that inlining
3149 -- is not possible, for examle if the body is available and contains
3150 -- exception handlers, we prevent inlining, since otherwise we can
3151 -- get undefined symbols at link time. This function also emits a
3152 -- warning if front-end inlining is enabled and the pragma appears
3154 -- ??? is business with link symbols still valid, or does it relate
3155 -- to front end ZCX which is being phased out ???
3157 ---------------------------
3158 -- Inlining_Not_Possible --
3159 ---------------------------
3161 function Inlining_Not_Possible (Subp : Entity_Id) return Boolean is
3162 Decl : constant Node_Id := Unit_Declaration_Node (Subp);
3166 if Nkind (Decl) = N_Subprogram_Body then
3167 Stats := Handled_Statement_Sequence (Decl);
3168 return Present (Exception_Handlers (Stats))
3169 or else Present (At_End_Proc (Stats));
3171 elsif Nkind (Decl) = N_Subprogram_Declaration
3172 and then Present (Corresponding_Body (Decl))
3174 if Front_End_Inlining
3175 and then Analyzed (Corresponding_Body (Decl))
3177 Error_Msg_N ("pragma appears too late, ignored?", N);
3180 -- If the subprogram is a renaming as body, the body is
3181 -- just a call to the renamed subprogram, and inlining is
3182 -- trivially possible.
3185 Nkind (Unit_Declaration_Node (Corresponding_Body (Decl)))
3186 = N_Subprogram_Renaming_Declaration
3192 Handled_Statement_Sequence
3193 (Unit_Declaration_Node (Corresponding_Body (Decl)));
3196 Present (Exception_Handlers (Stats))
3197 or else Present (At_End_Proc (Stats));
3201 -- If body is not available, assume the best, the check is
3202 -- performed again when compiling enclosing package bodies.
3206 end Inlining_Not_Possible;
3212 procedure Make_Inline (Subp : Entity_Id) is
3213 Kind : constant Entity_Kind := Ekind (Subp);
3214 Inner_Subp : Entity_Id := Subp;
3217 if Etype (Subp) = Any_Type then
3220 -- If inlining is not possible, for now do not treat as an error
3222 elsif Inlining_Not_Possible (Subp) then
3226 -- Here we have a candidate for inlining, but we must exclude
3227 -- derived operations. Otherwise we will end up trying to
3228 -- inline a phantom declaration, and the result would be to
3229 -- drag in a body which has no direct inlining associated with
3230 -- it. That would not only be inefficient but would also result
3231 -- in the backend doing cross-unit inlining in cases where it
3232 -- was definitely inappropriate to do so.
3234 -- However, a simple Comes_From_Source test is insufficient,
3235 -- since we do want to allow inlining of generic instances,
3236 -- which also do not come from source. Predefined operators do
3237 -- not come from source but are not inlineable either.
3239 elsif not Comes_From_Source (Subp)
3240 and then not Is_Generic_Instance (Subp)
3241 and then Scope (Subp) /= Standard_Standard
3246 -- The referenced entity must either be the enclosing entity,
3247 -- or an entity declared within the current open scope.
3249 elsif Present (Scope (Subp))
3250 and then Scope (Subp) /= Current_Scope
3251 and then Subp /= Current_Scope
3254 ("argument of% must be entity in current scope", Assoc);
3258 -- Processing for procedure, operator or function.
3259 -- If subprogram is aliased (as for an instance) indicate
3260 -- that the renamed entity (if declared in the same unit)
3263 if Is_Subprogram (Subp) then
3264 while Present (Alias (Inner_Subp)) loop
3265 Inner_Subp := Alias (Inner_Subp);
3268 if In_Same_Source_Unit (Subp, Inner_Subp) then
3269 Set_Inline_Flags (Inner_Subp);
3271 Decl := Parent (Parent (Inner_Subp));
3273 if Nkind (Decl) = N_Subprogram_Declaration
3274 and then Present (Corresponding_Body (Decl))
3276 Set_Inline_Flags (Corresponding_Body (Decl));
3282 -- For a generic subprogram set flag as well, for use at
3283 -- the point of instantiation, to determine whether the
3284 -- body should be generated.
3286 elsif Is_Generic_Subprogram (Subp) then
3287 Set_Inline_Flags (Subp);
3290 -- Literals are by definition inlined
3292 elsif Kind = E_Enumeration_Literal then
3295 -- Anything else is an error
3299 ("expect subprogram name for pragma%", Assoc);
3303 ----------------------
3304 -- Set_Inline_Flags --
3305 ----------------------
3307 procedure Set_Inline_Flags (Subp : Entity_Id) is
3310 Set_Is_Inlined (Subp, True);
3313 if not Has_Pragma_Inline (Subp) then
3314 Set_Has_Pragma_Inline (Subp);
3315 Set_Next_Rep_Item (N, First_Rep_Item (Subp));
3316 Set_First_Rep_Item (Subp, N);
3319 end Set_Inline_Flags;
3321 -- Start of processing for Process_Inline
3324 Check_No_Identifiers;
3325 Check_At_Least_N_Arguments (1);
3328 Inline_Processing_Required := True;
3332 while Present (Assoc) loop
3333 Subp_Id := Expression (Assoc);
3337 if Is_Entity_Name (Subp_Id) then
3338 Subp := Entity (Subp_Id);
3340 if Subp = Any_Id then
3342 -- If previous error, avoid cascaded errors
3350 while Present (Homonym (Subp))
3351 and then Scope (Homonym (Subp)) = Current_Scope
3353 Make_Inline (Homonym (Subp));
3354 Subp := Homonym (Subp);
3361 ("inappropriate argument for pragma%", Assoc);
3364 and then Warn_On_Redundant_Constructs
3366 if Inlining_Not_Possible (Subp) then
3368 ("pragma Inline for& is ignored?", N, Entity (Subp_Id));
3371 ("pragma Inline for& is redundant?", N, Entity (Subp_Id));
3379 ----------------------------
3380 -- Process_Interface_Name --
3381 ----------------------------
3383 procedure Process_Interface_Name
3384 (Subprogram_Def : Entity_Id;
3390 String_Val : String_Id;
3392 procedure Check_Form_Of_Interface_Name (SN : Node_Id);
3393 -- SN is a string literal node for an interface name. This routine
3394 -- performs some minimal checks that the name is reasonable. In
3395 -- particular that no spaces or other obviously incorrect characters
3396 -- appear. This is only a warning, since any characters are allowed.
3398 ----------------------------------
3399 -- Check_Form_Of_Interface_Name --
3400 ----------------------------------
3402 procedure Check_Form_Of_Interface_Name (SN : Node_Id) is
3403 S : constant String_Id := Strval (Expr_Value_S (SN));
3404 SL : constant Nat := String_Length (S);
3409 Error_Msg_N ("interface name cannot be null string", SN);
3412 for J in 1 .. SL loop
3413 C := Get_String_Char (S, J);
3415 if Warn_On_Export_Import
3416 and then (not In_Character_Range (C)
3417 or else Get_Character (C) = ' '
3418 or else Get_Character (C) = ',')
3421 ("?interface name contains illegal character", SN);
3424 end Check_Form_Of_Interface_Name;
3426 -- Start of processing for Process_Interface_Name
3429 if No (Link_Arg) then
3430 if No (Ext_Arg) then
3433 elsif Chars (Ext_Arg) = Name_Link_Name then
3435 Link_Nam := Expression (Ext_Arg);
3438 Check_Optional_Identifier (Ext_Arg, Name_External_Name);
3439 Ext_Nam := Expression (Ext_Arg);
3444 Check_Optional_Identifier (Ext_Arg, Name_External_Name);
3445 Check_Optional_Identifier (Link_Arg, Name_Link_Name);
3446 Ext_Nam := Expression (Ext_Arg);
3447 Link_Nam := Expression (Link_Arg);
3450 -- Check expressions for external name and link name are static
3452 if Present (Ext_Nam) then
3453 Check_Arg_Is_Static_Expression (Ext_Nam, Standard_String);
3454 Check_Form_Of_Interface_Name (Ext_Nam);
3456 -- Verify that the external name is not the name of a local
3457 -- entity, which would hide the imported one and lead to
3458 -- run-time surprises. The problem can only arise for entities
3459 -- declared in a package body (otherwise the external name is
3460 -- fully qualified and won't conflict).
3468 if Prag_Id = Pragma_Import then
3469 String_To_Name_Buffer (Strval (Expr_Value_S (Ext_Nam)));
3471 E := Entity_Id (Get_Name_Table_Info (Nam));
3473 if Nam /= Chars (Subprogram_Def)
3474 and then Present (E)
3475 and then not Is_Overloadable (E)
3476 and then Is_Immediately_Visible (E)
3477 and then not Is_Imported (E)
3478 and then Ekind (Scope (E)) = E_Package
3482 while Present (Par) loop
3483 if Nkind (Par) = N_Package_Body then
3484 Error_Msg_Sloc := Sloc (E);
3486 ("imported entity is hidden by & declared#",
3491 Par := Parent (Par);
3498 if Present (Link_Nam) then
3499 Check_Arg_Is_Static_Expression (Link_Nam, Standard_String);
3500 Check_Form_Of_Interface_Name (Link_Nam);
3503 -- If there is no link name, just set the external name
3505 if No (Link_Nam) then
3506 Link_Nam := Adjust_External_Name_Case (Expr_Value_S (Ext_Nam));
3508 -- For the Link_Name case, the given literal is preceded by an
3509 -- asterisk, which indicates to GCC that the given name should
3510 -- be taken literally, and in particular that no prepending of
3511 -- underlines should occur, even in systems where this is the
3516 Store_String_Char (Get_Char_Code ('*'));
3517 String_Val := Strval (Expr_Value_S (Link_Nam));
3519 for J in 1 .. String_Length (String_Val) loop
3520 Store_String_Char (Get_String_Char (String_Val, J));
3524 Make_String_Literal (Sloc (Link_Nam), End_String);
3527 Set_Encoded_Interface_Name
3528 (Get_Base_Subprogram (Subprogram_Def), Link_Nam);
3529 Check_Duplicated_Export_Name (Link_Nam);
3530 end Process_Interface_Name;
3532 -----------------------------------------
3533 -- Process_Interrupt_Or_Attach_Handler --
3534 -----------------------------------------
3536 procedure Process_Interrupt_Or_Attach_Handler is
3537 Arg1_X : constant Node_Id := Expression (Arg1);
3538 Handler_Proc : constant Entity_Id := Entity (Arg1_X);
3539 Proc_Scope : constant Entity_Id := Scope (Handler_Proc);
3542 Set_Is_Interrupt_Handler (Handler_Proc);
3544 -- If the pragma is not associated with a handler procedure
3545 -- within a protected type, then it must be for a nonprotected
3546 -- procedure for the AAMP target, in which case we don't
3547 -- associate a representation item with the procedure's scope.
3549 if Ekind (Proc_Scope) = E_Protected_Type then
3550 if Prag_Id = Pragma_Interrupt_Handler
3552 Prag_Id = Pragma_Attach_Handler
3554 Record_Rep_Item (Proc_Scope, N);
3557 end Process_Interrupt_Or_Attach_Handler;
3559 --------------------------------------------------
3560 -- Process_Restrictions_Or_Restriction_Warnings --
3561 --------------------------------------------------
3563 -- Note: some of the simple identifier cases were handled in par-prag,
3564 -- but it is harmless (and more straightforward) to simply handle all
3565 -- cases here, even if it means we repeat a bit of work in some cases.
3567 procedure Process_Restrictions_Or_Restriction_Warnings is
3569 R_Id : Restriction_Id;
3574 procedure Check_Unit_Name (N : Node_Id);
3575 -- Checks unit name parameter for No_Dependence. Returns if it has
3576 -- an appropriate form, otherwise raises pragma argument error.
3578 procedure Set_Warning (R : All_Restrictions);
3579 -- If this is a Restriction_Warnings pragma, set warning flag,
3580 -- otherwise reset the flag.
3582 ---------------------
3583 -- Check_Unit_Name --
3584 ---------------------
3586 procedure Check_Unit_Name (N : Node_Id) is
3588 if Nkind (N) = N_Selected_Component then
3589 Check_Unit_Name (Prefix (N));
3590 Check_Unit_Name (Selector_Name (N));
3592 elsif Nkind (N) = N_Identifier then
3597 ("wrong form for unit name for No_Dependence", N);
3599 end Check_Unit_Name;
3605 procedure Set_Warning (R : All_Restrictions) is
3607 if Prag_Id = Pragma_Restriction_Warnings then
3608 Restriction_Warnings (R) := True;
3610 Restriction_Warnings (R) := False;
3614 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
3617 Check_Ada_83_Warning;
3618 Check_At_Least_N_Arguments (1);
3619 Check_Valid_Configuration_Pragma;
3622 while Present (Arg) loop
3624 Expr := Expression (Arg);
3626 -- Case of no restriction identifier present
3628 if Id = No_Name then
3629 if Nkind (Expr) /= N_Identifier then
3631 ("invalid form for restriction", Arg);
3636 (Process_Restriction_Synonyms (Expr));
3638 if R_Id not in All_Boolean_Restrictions then
3640 ("invalid restriction identifier", Arg);
3643 if Implementation_Restriction (R_Id) then
3645 (No_Implementation_Restrictions, Arg);
3648 Set_Restriction (R_Id, N);
3651 -- A very special case that must be processed here:
3652 -- pragma Restrictions (No_Exceptions) turns off
3653 -- all run-time checking. This is a bit dubious in
3654 -- terms of the formal language definition, but it
3655 -- is what is intended by RM H.4(12).
3657 if R_Id = No_Exceptions then
3658 Scope_Suppress := (others => True);
3661 -- Case of No_Dependence => unit-name. Note that the parser
3662 -- already made the necessary entry in the No_Dependence table.
3664 elsif Id = Name_No_Dependence then
3665 Check_Unit_Name (Expr);
3667 -- All other cases of restriction identifier present
3670 R_Id := Get_Restriction_Id (Process_Restriction_Synonyms (Arg));
3671 Analyze_And_Resolve (Expr, Any_Integer);
3673 if R_Id not in All_Parameter_Restrictions then
3675 ("invalid restriction parameter identifier", Arg);
3677 elsif not Is_OK_Static_Expression (Expr) then
3678 Flag_Non_Static_Expr
3679 ("value must be static expression!", Expr);
3682 elsif not Is_Integer_Type (Etype (Expr))
3683 or else Expr_Value (Expr) < 0
3686 ("value must be non-negative integer", Arg);
3688 -- Restriction pragma is active
3691 Val := Expr_Value (Expr);
3693 if not UI_Is_In_Int_Range (Val) then
3695 ("pragma ignored, value too large?", Arg);
3697 Set_Restriction (R_Id, N, Integer (UI_To_Int (Val)));
3705 end Process_Restrictions_Or_Restriction_Warnings;
3707 ---------------------------------
3708 -- Process_Suppress_Unsuppress --
3709 ---------------------------------
3711 -- Note: this procedure makes entries in the check suppress data
3712 -- structures managed by Sem. See spec of package Sem for full
3713 -- details on how we handle recording of check suppression.
3715 procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean) is
3720 In_Package_Spec : constant Boolean :=
3721 (Ekind (Current_Scope) = E_Package
3723 Ekind (Current_Scope) = E_Generic_Package)
3724 and then not In_Package_Body (Current_Scope);
3726 procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id);
3727 -- Used to suppress a single check on the given entity
3729 --------------------------------
3730 -- Suppress_Unsuppress_Echeck --
3731 --------------------------------
3733 procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id) is
3734 ESR : constant Entity_Check_Suppress_Record :=
3737 Suppress => Suppress_Case);
3740 Set_Checks_May_Be_Suppressed (E);
3742 if In_Package_Spec then
3743 Global_Entity_Suppress.Append (ESR);
3745 Local_Entity_Suppress.Append (ESR);
3748 -- If this is a first subtype, and the base type is distinct,
3749 -- then also set the suppress flags on the base type.
3751 if Is_First_Subtype (E)
3752 and then Etype (E) /= E
3754 Suppress_Unsuppress_Echeck (Etype (E), C);
3756 end Suppress_Unsuppress_Echeck;
3758 -- Start of processing for Process_Suppress_Unsuppress
3761 -- Suppress/Unsuppress can appear as a configuration pragma,
3762 -- or in a declarative part or a package spec (RM 11.5(5))
3764 if not Is_Configuration_Pragma then
3765 Check_Is_In_Decl_Part_Or_Package_Spec;
3768 Check_At_Least_N_Arguments (1);
3769 Check_At_Most_N_Arguments (2);
3770 Check_No_Identifier (Arg1);
3771 Check_Arg_Is_Identifier (Arg1);
3773 if not Is_Check_Name (Chars (Expression (Arg1))) then
3775 ("argument of pragma% is not valid check name", Arg1);
3777 C := Get_Check_Id (Chars (Expression (Arg1)));
3780 if Arg_Count = 1 then
3782 -- Make an entry in the local scope suppress table. This is the
3783 -- table that directly shows the current value of the scope
3784 -- suppress check for any check id value.
3786 if C = All_Checks then
3787 for J in Scope_Suppress'Range loop
3788 Scope_Suppress (J) := Suppress_Case;
3791 Scope_Suppress (C) := Suppress_Case;
3794 -- Also make an entry in the Local_Entity_Suppress table. See
3795 -- extended description in the package spec of Sem for details.
3797 Local_Entity_Suppress.Append
3800 Suppress => Suppress_Case));
3802 -- Case of two arguments present, where the check is
3803 -- suppressed for a specified entity (given as the second
3804 -- argument of the pragma)
3807 Check_Optional_Identifier (Arg2, Name_On);
3808 E_Id := Expression (Arg2);
3811 if not Is_Entity_Name (E_Id) then
3813 ("second argument of pragma% must be entity name", Arg2);
3822 -- Enforce RM 11.5(7) which requires that for a pragma that
3823 -- appears within a package spec, the named entity must be
3824 -- within the package spec. We allow the package name itself
3825 -- to be mentioned since that makes sense, although it is not
3826 -- strictly allowed by 11.5(7).
3829 and then E /= Current_Scope
3830 and then Scope (E) /= Current_Scope
3833 ("entity in pragma% is not in package spec ('R'M 11.5(7))",
3837 -- Loop through homonyms. As noted below, in the case of a package
3838 -- spec, only homonyms within the package spec are considered.
3841 Suppress_Unsuppress_Echeck (E, C);
3843 if Is_Generic_Instance (E)
3844 and then Is_Subprogram (E)
3845 and then Present (Alias (E))
3847 Suppress_Unsuppress_Echeck (Alias (E), C);
3850 -- Move to next homonym
3855 -- If we are within a package specification, the
3856 -- pragma only applies to homonyms in the same scope.
3858 exit when In_Package_Spec
3859 and then Scope (E) /= Current_Scope;
3862 end Process_Suppress_Unsuppress;
3868 procedure Set_Exported (E : Entity_Id; Arg : Node_Id) is
3870 if Is_Imported (E) then
3872 ("cannot export entity& that was previously imported", Arg);
3874 elsif Present (Address_Clause (E)) then
3876 ("cannot export entity& that has an address clause", Arg);
3879 Set_Is_Exported (E);
3881 -- Generate a reference for entity explicitly, because the
3882 -- identifier may be overloaded and name resolution will not
3885 Generate_Reference (E, Arg);
3887 -- Deal with exporting non-library level entity
3889 if not Is_Library_Level_Entity (E) then
3891 -- Not allowed at all for subprograms
3893 if Is_Subprogram (E) then
3894 Error_Pragma_Arg ("local subprogram& cannot be exported", Arg);
3896 -- Otherwise set public and statically allocated
3900 Set_Is_Statically_Allocated (E);
3902 -- Warn if the corresponding W flag is set and the pragma
3903 -- comes from source. The latter may not be true e.g. on
3904 -- VMS where we expand export pragmas for exception codes
3905 -- associated with imported or exported exceptions. We do
3906 -- not want to generate a warning for something that the
3907 -- user did not write.
3909 if Warn_On_Export_Import
3910 and then Comes_From_Source (Arg)
3913 ("?& has been made static as a result of Export", Arg, E);
3915 ("\this usage is non-standard and non-portable", Arg);
3920 if Warn_On_Export_Import and then Is_Type (E) then
3922 ("exporting a type has no effect?", Arg, E);
3925 if Warn_On_Export_Import and Inside_A_Generic then
3927 ("all instances of& will have the same external name?", Arg, E);
3931 ----------------------------------------------
3932 -- Set_Extended_Import_Export_External_Name --
3933 ----------------------------------------------
3935 procedure Set_Extended_Import_Export_External_Name
3936 (Internal_Ent : Entity_Id;
3937 Arg_External : Node_Id)
3939 Old_Name : constant Node_Id := Interface_Name (Internal_Ent);
3943 if No (Arg_External) then
3947 Check_Arg_Is_External_Name (Arg_External);
3949 if Nkind (Arg_External) = N_String_Literal then
3950 if String_Length (Strval (Arg_External)) = 0 then
3953 New_Name := Adjust_External_Name_Case (Arg_External);
3956 elsif Nkind (Arg_External) = N_Identifier then
3957 New_Name := Get_Default_External_Name (Arg_External);
3959 -- Check_Arg_Is_External_Name should let through only
3960 -- identifiers and string literals or static string
3961 -- expressions (which are folded to string literals).
3964 raise Program_Error;
3967 -- If we already have an external name set (by a prior normal
3968 -- Import or Export pragma), then the external names must match
3970 if Present (Interface_Name (Internal_Ent)) then
3971 Check_Matching_Internal_Names : declare
3972 S1 : constant String_Id := Strval (Old_Name);
3973 S2 : constant String_Id := Strval (New_Name);
3976 -- Called if names do not match
3982 procedure Mismatch is
3984 Error_Msg_Sloc := Sloc (Old_Name);
3986 ("external name does not match that given #",
3990 -- Start of processing for Check_Matching_Internal_Names
3993 if String_Length (S1) /= String_Length (S2) then
3997 for J in 1 .. String_Length (S1) loop
3998 if Get_String_Char (S1, J) /= Get_String_Char (S2, J) then
4003 end Check_Matching_Internal_Names;
4005 -- Otherwise set the given name
4008 Set_Encoded_Interface_Name (Internal_Ent, New_Name);
4009 Check_Duplicated_Export_Name (New_Name);
4011 end Set_Extended_Import_Export_External_Name;
4017 procedure Set_Imported (E : Entity_Id) is
4019 Error_Msg_Sloc := Sloc (E);
4021 if Is_Exported (E) or else Is_Imported (E) then
4022 Error_Msg_NE ("import of& declared# not allowed", N, E);
4024 if Is_Exported (E) then
4025 Error_Msg_N ("\entity was previously exported", N);
4027 Error_Msg_N ("\entity was previously imported", N);
4030 Error_Pragma ("\(pragma% applies to all previous entities)");
4033 Set_Is_Imported (E);
4035 -- If the entity is an object that is not at the library
4036 -- level, then it is statically allocated. We do not worry
4037 -- about objects with address clauses in this context since
4038 -- they are not really imported in the linker sense.
4041 and then not Is_Library_Level_Entity (E)
4042 and then No (Address_Clause (E))
4044 Set_Is_Statically_Allocated (E);
4049 -------------------------
4050 -- Set_Mechanism_Value --
4051 -------------------------
4053 -- Note: the mechanism name has not been analyzed (and cannot indeed
4054 -- be analyzed, since it is semantic nonsense), so we get it in the
4055 -- exact form created by the parser.
4057 procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id) is
4061 procedure Bad_Class;
4062 -- Signal bad descriptor class name
4064 procedure Bad_Mechanism;
4065 -- Signal bad mechanism name
4071 procedure Bad_Class is
4073 Error_Pragma_Arg ("unrecognized descriptor class name", Class);
4076 -------------------------
4077 -- Bad_Mechanism_Value --
4078 -------------------------
4080 procedure Bad_Mechanism is
4082 Error_Pragma_Arg ("unrecognized mechanism name", Mech_Name);
4085 -- Start of processing for Set_Mechanism_Value
4088 if Mechanism (Ent) /= Default_Mechanism then
4090 ("mechanism for & has already been set", Mech_Name, Ent);
4093 -- MECHANISM_NAME ::= value | reference | descriptor
4095 if Nkind (Mech_Name) = N_Identifier then
4096 if Chars (Mech_Name) = Name_Value then
4097 Set_Mechanism (Ent, By_Copy);
4100 elsif Chars (Mech_Name) = Name_Reference then
4101 Set_Mechanism (Ent, By_Reference);
4104 elsif Chars (Mech_Name) = Name_Descriptor then
4105 Check_VMS (Mech_Name);
4106 Set_Mechanism (Ent, By_Descriptor);
4109 elsif Chars (Mech_Name) = Name_Copy then
4111 ("bad mechanism name, Value assumed", Mech_Name);
4117 -- MECHANISM_NAME ::= descriptor (CLASS_NAME)
4118 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4120 -- Note: this form is parsed as an indexed component
4122 elsif Nkind (Mech_Name) = N_Indexed_Component then
4123 Class := First (Expressions (Mech_Name));
4125 if Nkind (Prefix (Mech_Name)) /= N_Identifier
4126 or else Chars (Prefix (Mech_Name)) /= Name_Descriptor
4127 or else Present (Next (Class))
4132 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME)
4133 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4135 -- Note: this form is parsed as a function call
4137 elsif Nkind (Mech_Name) = N_Function_Call then
4139 Param := First (Parameter_Associations (Mech_Name));
4141 if Nkind (Name (Mech_Name)) /= N_Identifier
4142 or else Chars (Name (Mech_Name)) /= Name_Descriptor
4143 or else Present (Next (Param))
4144 or else No (Selector_Name (Param))
4145 or else Chars (Selector_Name (Param)) /= Name_Class
4149 Class := Explicit_Actual_Parameter (Param);
4156 -- Fall through here with Class set to descriptor class name
4158 Check_VMS (Mech_Name);
4160 if Nkind (Class) /= N_Identifier then
4163 elsif Chars (Class) = Name_UBS then
4164 Set_Mechanism (Ent, By_Descriptor_UBS);
4166 elsif Chars (Class) = Name_UBSB then
4167 Set_Mechanism (Ent, By_Descriptor_UBSB);
4169 elsif Chars (Class) = Name_UBA then
4170 Set_Mechanism (Ent, By_Descriptor_UBA);
4172 elsif Chars (Class) = Name_S then
4173 Set_Mechanism (Ent, By_Descriptor_S);
4175 elsif Chars (Class) = Name_SB then
4176 Set_Mechanism (Ent, By_Descriptor_SB);
4178 elsif Chars (Class) = Name_A then
4179 Set_Mechanism (Ent, By_Descriptor_A);
4181 elsif Chars (Class) = Name_NCA then
4182 Set_Mechanism (Ent, By_Descriptor_NCA);
4187 end Set_Mechanism_Value;
4189 ---------------------------
4190 -- Set_Ravenscar_Profile --
4191 ---------------------------
4193 -- The tasks to be done here are
4195 -- Set required policies
4197 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4198 -- pragma Locking_Policy (Ceiling_Locking)
4200 -- Set Detect_Blocking mode
4202 -- Set required restrictions (see System.Rident for detailed list)
4204 procedure Set_Ravenscar_Profile (N : Node_Id) is
4206 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4208 if Task_Dispatching_Policy /= ' '
4209 and then Task_Dispatching_Policy /= 'F'
4211 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
4212 Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
4214 -- Set the FIFO_Within_Priorities policy, but always
4215 -- preserve System_Location since we like the error
4216 -- message with the run time name.
4219 Task_Dispatching_Policy := 'F';
4221 if Task_Dispatching_Policy_Sloc /= System_Location then
4222 Task_Dispatching_Policy_Sloc := Loc;
4226 -- pragma Locking_Policy (Ceiling_Locking)
4228 if Locking_Policy /= ' '
4229 and then Locking_Policy /= 'C'
4231 Error_Msg_Sloc := Locking_Policy_Sloc;
4232 Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
4234 -- Set the Ceiling_Locking policy, but always preserve
4235 -- System_Location since we like the error message with the
4239 Locking_Policy := 'C';
4241 if Locking_Policy_Sloc /= System_Location then
4242 Locking_Policy_Sloc := Loc;
4246 -- pragma Detect_Blocking
4248 Detect_Blocking := True;
4250 -- Set the corresponding restrictions
4252 Set_Profile_Restrictions (Ravenscar, N, Warn => False);
4253 end Set_Ravenscar_Profile;
4255 -- Start of processing for Analyze_Pragma
4258 if not Is_Pragma_Name (Chars (N)) then
4259 if Warn_On_Unrecognized_Pragma then
4260 Error_Pragma ("unrecognized pragma%!?");
4265 Prag_Id := Get_Pragma_Id (Chars (N));
4275 if Present (Pragma_Argument_Associations (N)) then
4276 Arg1 := First (Pragma_Argument_Associations (N));
4278 if Present (Arg1) then
4279 Arg2 := Next (Arg1);
4281 if Present (Arg2) then
4282 Arg3 := Next (Arg2);
4284 if Present (Arg3) then
4285 Arg4 := Next (Arg3);
4291 -- Count number of arguments
4298 while Present (Arg_Node) loop
4299 Arg_Count := Arg_Count + 1;
4304 -- An enumeration type defines the pragmas that are supported by the
4305 -- implementation. Get_Pragma_Id (in package Prag) transorms a name
4306 -- into the corresponding enumeration value for the following case.
4314 -- pragma Abort_Defer;
4316 when Pragma_Abort_Defer =>
4318 Check_Arg_Count (0);
4320 -- The only required semantic processing is to check the
4321 -- placement. This pragma must appear at the start of the
4322 -- statement sequence of a handled sequence of statements.
4324 if Nkind (Parent (N)) /= N_Handled_Sequence_Of_Statements
4325 or else N /= First (Statements (Parent (N)))
4336 -- Note: this pragma also has some specific processing in Par.Prag
4337 -- because we want to set the Ada version mode during parsing.
4339 when Pragma_Ada_83 =>
4341 Ada_Version := Ada_83;
4342 Ada_Version_Explicit := Ada_Version;
4343 Check_Arg_Count (0);
4351 -- Note: this pragma also has some specific processing in Par.Prag
4352 -- because we want to set the Ada 83 version mode during parsing.
4354 when Pragma_Ada_95 =>
4356 Ada_Version := Ada_95;
4357 Ada_Version_Explicit := Ada_Version;
4358 Check_Arg_Count (0);
4365 -- pragma Ada_05 (LOCAL_NAME);
4367 -- Note: this pragma also has some specific processing in Par.Prag
4368 -- because we want to set the Ada 2005 version mode during parsing.
4370 when Pragma_Ada_05 => declare
4376 if Arg_Count = 1 then
4377 Check_Arg_Is_Local_Name (Arg1);
4378 E_Id := Expression (Arg1);
4380 if Etype (E_Id) = Any_Type then
4384 Set_Is_Ada_2005 (Entity (E_Id));
4387 Check_Arg_Count (0);
4388 Ada_Version := Ada_05;
4389 Ada_Version_Explicit := Ada_Version;
4393 ----------------------
4394 -- All_Calls_Remote --
4395 ----------------------
4397 -- pragma All_Calls_Remote [(library_package_NAME)];
4399 when Pragma_All_Calls_Remote => All_Calls_Remote : declare
4400 Lib_Entity : Entity_Id;
4403 Check_Ada_83_Warning;
4404 Check_Valid_Library_Unit_Pragma;
4406 if Nkind (N) = N_Null_Statement then
4410 Lib_Entity := Find_Lib_Unit_Name;
4412 -- This pragma should only apply to a RCI unit (RM E.2.3(23))
4414 if Present (Lib_Entity)
4415 and then not Debug_Flag_U
4417 if not Is_Remote_Call_Interface (Lib_Entity) then
4418 Error_Pragma ("pragma% only apply to rci unit");
4420 -- Set flag for entity of the library unit
4423 Set_Has_All_Calls_Remote (Lib_Entity);
4427 end All_Calls_Remote;
4433 -- pragma Annotate (IDENTIFIER {, ARG});
4434 -- ARG ::= NAME | EXPRESSION
4436 when Pragma_Annotate => Annotate : begin
4438 Check_At_Least_N_Arguments (1);
4439 Check_Arg_Is_Identifier (Arg1);
4442 Arg : Node_Id := Arg2;
4446 while Present (Arg) loop
4447 Exp := Expression (Arg);
4450 if Is_Entity_Name (Exp) then
4453 elsif Nkind (Exp) = N_String_Literal then
4454 Resolve (Exp, Standard_String);
4456 elsif Is_Overloaded (Exp) then
4457 Error_Pragma_Arg ("ambiguous argument for pragma%", Exp);
4472 -- pragma Assert ([Check =>] Boolean_EXPRESSION
4473 -- [, [Message =>] Static_String_EXPRESSION]);
4475 when Pragma_Assert =>
4476 Check_At_Least_N_Arguments (1);
4477 Check_At_Most_N_Arguments (2);
4478 Check_Arg_Order ((Name_Check, Name_Message));
4479 Check_Optional_Identifier (Arg1, Name_Check);
4481 if Arg_Count > 1 then
4482 Check_Optional_Identifier (Arg2, Name_Message);
4483 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
4486 -- If expansion is active and assertions are inactive, then
4487 -- we rewrite the Assertion as:
4489 -- if False and then condition then
4493 -- The reason we do this rewriting during semantic analysis
4494 -- rather than as part of normal expansion is that we cannot
4495 -- analyze and expand the code for the boolean expression
4496 -- directly, or it may cause insertion of actions that would
4497 -- escape the attempt to suppress the assertion code.
4499 if Expander_Active and not Assertions_Enabled then
4501 Make_If_Statement (Loc,
4504 Left_Opnd => New_Occurrence_Of (Standard_False, Loc),
4505 Right_Opnd => Get_Pragma_Arg (Arg1)),
4506 Then_Statements => New_List (
4507 Make_Null_Statement (Loc))));
4511 -- Otherwise (if assertions are enabled, or if we are not
4512 -- operating with expansion active), then we just analyze
4513 -- and resolve the expression.
4516 Analyze_And_Resolve (Expression (Arg1), Any_Boolean);
4519 ----------------------
4520 -- Assertion_Policy --
4521 ----------------------
4523 -- pragma Assertion_Policy (Check | Ignore)
4525 when Pragma_Assertion_Policy =>
4526 Check_Arg_Count (1);
4527 Check_Arg_Is_One_Of (Arg1, Name_Check, Name_Ignore);
4528 Assertions_Enabled := Chars (Expression (Arg1)) = Name_Check;
4534 -- pragma AST_Entry (entry_IDENTIFIER);
4536 when Pragma_AST_Entry => AST_Entry : declare
4542 Check_Arg_Count (1);
4543 Check_No_Identifiers;
4544 Check_Arg_Is_Local_Name (Arg1);
4545 Ent := Entity (Expression (Arg1));
4547 -- Note: the implementation of the AST_Entry pragma could handle
4548 -- the entry family case fine, but for now we are consistent with
4549 -- the DEC rules, and do not allow the pragma, which of course
4550 -- has the effect of also forbidding the attribute.
4552 if Ekind (Ent) /= E_Entry then
4554 ("pragma% argument must be simple entry name", Arg1);
4556 elsif Is_AST_Entry (Ent) then
4558 ("duplicate % pragma for entry", Arg1);
4560 elsif Has_Homonym (Ent) then
4562 ("pragma% argument cannot specify overloaded entry", Arg1);
4566 FF : constant Entity_Id := First_Formal (Ent);
4569 if Present (FF) then
4570 if Present (Next_Formal (FF)) then
4572 ("entry for pragma% can have only one argument",
4575 elsif Parameter_Mode (FF) /= E_In_Parameter then
4577 ("entry parameter for pragma% must have mode IN",
4583 Set_Is_AST_Entry (Ent);
4591 -- pragma Asynchronous (LOCAL_NAME);
4593 when Pragma_Asynchronous => Asynchronous : declare
4601 procedure Process_Async_Pragma;
4602 -- Common processing for procedure and access-to-procedure case
4604 --------------------------
4605 -- Process_Async_Pragma --
4606 --------------------------
4608 procedure Process_Async_Pragma is
4610 if not Present (L) then
4611 Set_Is_Asynchronous (Nm);
4615 -- The formals should be of mode IN (RM E.4.1(6))
4618 while Present (S) loop
4619 Formal := Defining_Identifier (S);
4621 if Nkind (Formal) = N_Defining_Identifier
4622 and then Ekind (Formal) /= E_In_Parameter
4625 ("pragma% procedure can only have IN parameter",
4632 Set_Is_Asynchronous (Nm);
4633 end Process_Async_Pragma;
4635 -- Start of processing for pragma Asynchronous
4638 Check_Ada_83_Warning;
4639 Check_No_Identifiers;
4640 Check_Arg_Count (1);
4641 Check_Arg_Is_Local_Name (Arg1);
4643 if Debug_Flag_U then
4647 C_Ent := Cunit_Entity (Current_Sem_Unit);
4648 Analyze (Expression (Arg1));
4649 Nm := Entity (Expression (Arg1));
4651 if not Is_Remote_Call_Interface (C_Ent)
4652 and then not Is_Remote_Types (C_Ent)
4654 -- This pragma should only appear in an RCI or Remote Types
4655 -- unit (RM E.4.1(4))
4658 ("pragma% not in Remote_Call_Interface or " &
4659 "Remote_Types unit");
4662 if Ekind (Nm) = E_Procedure
4663 and then Nkind (Parent (Nm)) = N_Procedure_Specification
4665 if not Is_Remote_Call_Interface (Nm) then
4667 ("pragma% cannot be applied on non-remote procedure",
4671 L := Parameter_Specifications (Parent (Nm));
4672 Process_Async_Pragma;
4675 elsif Ekind (Nm) = E_Function then
4677 ("pragma% cannot be applied to function", Arg1);
4679 elsif Is_Remote_Access_To_Subprogram_Type (Nm) then
4681 if Is_Record_Type (Nm) then
4682 -- A record type that is the Equivalent_Type for
4683 -- a remote access-to-subprogram type.
4685 N := Declaration_Node (Corresponding_Remote_Type (Nm));
4688 -- A non-expanded RAS type (case where distribution is
4691 N := Declaration_Node (Nm);
4694 if Nkind (N) = N_Full_Type_Declaration
4695 and then Nkind (Type_Definition (N)) =
4696 N_Access_Procedure_Definition
4698 L := Parameter_Specifications (Type_Definition (N));
4699 Process_Async_Pragma;
4701 if Is_Asynchronous (Nm)
4702 and then Expander_Active
4703 and then Get_PCS_Name /= Name_No_DSA
4705 RACW_Type_Is_Asynchronous (Underlying_RACW_Type (Nm));
4710 ("pragma% cannot reference access-to-function type",
4714 -- Only other possibility is Access-to-class-wide type
4716 elsif Is_Access_Type (Nm)
4717 and then Is_Class_Wide_Type (Designated_Type (Nm))
4719 Check_First_Subtype (Arg1);
4720 Set_Is_Asynchronous (Nm);
4721 if Expander_Active then
4722 RACW_Type_Is_Asynchronous (Nm);
4726 Error_Pragma_Arg ("inappropriate argument for pragma%", Arg1);
4734 -- pragma Atomic (LOCAL_NAME);
4736 when Pragma_Atomic =>
4737 Process_Atomic_Shared_Volatile;
4739 -----------------------
4740 -- Atomic_Components --
4741 -----------------------
4743 -- pragma Atomic_Components (array_LOCAL_NAME);
4745 -- This processing is shared by Volatile_Components
4747 when Pragma_Atomic_Components |
4748 Pragma_Volatile_Components =>
4750 Atomic_Components : declare
4757 Check_Ada_83_Warning;
4758 Check_No_Identifiers;
4759 Check_Arg_Count (1);
4760 Check_Arg_Is_Local_Name (Arg1);
4761 E_Id := Expression (Arg1);
4763 if Etype (E_Id) = Any_Type then
4769 if Rep_Item_Too_Early (E, N)
4771 Rep_Item_Too_Late (E, N)
4776 D := Declaration_Node (E);
4779 if (K = N_Full_Type_Declaration and then Is_Array_Type (E))
4781 ((Ekind (E) = E_Constant or else Ekind (E) = E_Variable)
4782 and then Nkind (D) = N_Object_Declaration
4783 and then Nkind (Object_Definition (D)) =
4784 N_Constrained_Array_Definition)
4786 -- The flag is set on the object, or on the base type
4788 if Nkind (D) /= N_Object_Declaration then
4792 Set_Has_Volatile_Components (E);
4794 if Prag_Id = Pragma_Atomic_Components then
4795 Set_Has_Atomic_Components (E);
4797 if Is_Packed (E) then
4798 Set_Is_Packed (E, False);
4801 ("?Pack canceled, cannot pack atomic components",
4807 Error_Pragma_Arg ("inappropriate entity for pragma%", Arg1);
4809 end Atomic_Components;
4811 --------------------
4812 -- Attach_Handler --
4813 --------------------
4815 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
4817 when Pragma_Attach_Handler =>
4818 Check_Ada_83_Warning;
4819 Check_No_Identifiers;
4820 Check_Arg_Count (2);
4822 if No_Run_Time_Mode then
4823 Error_Msg_CRT ("Attach_Handler pragma", N);
4825 Check_Interrupt_Or_Attach_Handler;
4827 -- The expression that designates the attribute may
4828 -- depend on a discriminant, and is therefore a per-
4829 -- object expression, to be expanded in the init proc.
4830 -- If expansion is enabled, perform semantic checks
4833 if Expander_Active then
4835 Temp : constant Node_Id :=
4836 New_Copy_Tree (Expression (Arg2));
4838 Set_Parent (Temp, N);
4839 Pre_Analyze_And_Resolve (Temp, RTE (RE_Interrupt_ID));
4843 Analyze (Expression (Arg2));
4844 Resolve (Expression (Arg2), RTE (RE_Interrupt_ID));
4847 Process_Interrupt_Or_Attach_Handler;
4850 --------------------
4851 -- C_Pass_By_Copy --
4852 --------------------
4854 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
4856 when Pragma_C_Pass_By_Copy => C_Pass_By_Copy : declare
4862 Check_Valid_Configuration_Pragma;
4863 Check_Arg_Count (1);
4864 Check_Optional_Identifier (Arg1, "max_size");
4866 Arg := Expression (Arg1);
4867 Check_Arg_Is_Static_Expression (Arg, Any_Integer);
4869 Val := Expr_Value (Arg);
4873 ("maximum size for pragma% must be positive", Arg1);
4875 elsif UI_Is_In_Int_Range (Val) then
4876 Default_C_Record_Mechanism := UI_To_Int (Val);
4878 -- If a giant value is given, Int'Last will do well enough.
4879 -- If sometime someone complains that a record larger than
4880 -- two gigabytes is not copied, we will worry about it then!
4883 Default_C_Record_Mechanism := Mechanism_Type'Last;
4891 -- pragma Comment (static_string_EXPRESSION)
4893 -- Processing for pragma Comment shares the circuitry for
4894 -- pragma Ident. The only differences are that Ident enforces
4895 -- a limit of 31 characters on its argument, and also enforces
4896 -- limitations on placement for DEC compatibility. Pragma
4897 -- Comment shares neither of these restrictions.
4903 -- pragma Common_Object (
4904 -- [Internal =>] LOCAL_NAME,
4905 -- [, [External =>] EXTERNAL_SYMBOL]
4906 -- [, [Size =>] EXTERNAL_SYMBOL]);
4908 -- Processing for this pragma is shared with Psect_Object
4910 --------------------------
4911 -- Compile_Time_Warning --
4912 --------------------------
4914 -- pragma Compile_Time_Warning
4915 -- (boolean_EXPRESSION, static_string_EXPRESSION);
4917 when Pragma_Compile_Time_Warning => Compile_Time_Warning : declare
4918 Arg1x : constant Node_Id := Get_Pragma_Arg (Arg1);
4922 Check_Arg_Count (2);
4923 Check_No_Identifiers;
4924 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
4925 Analyze_And_Resolve (Arg1x, Standard_Boolean);
4927 if Compile_Time_Known_Value (Arg1x) then
4928 if Is_True (Expr_Value (Get_Pragma_Arg (Arg1))) then
4929 String_To_Name_Buffer (Strval (Get_Pragma_Arg (Arg2)));
4930 Add_Char_To_Name_Buffer ('?');
4933 Msg : String (1 .. Name_Len) :=
4934 Name_Buffer (1 .. Name_Len);
4939 -- This loop looks for multiple lines separated by
4940 -- ASCII.LF and breaks them into continuation error
4941 -- messages marked with the usual back slash.
4944 for S in 2 .. Msg'Length - 1 loop
4945 if Msg (S) = ASCII.LF then
4947 Error_Msg_N (Msg (B .. S), Arg1);
4953 Error_Msg_N (Msg (B .. Msg'Length), Arg1);
4957 end Compile_Time_Warning;
4959 ----------------------------
4960 -- Complex_Representation --
4961 ----------------------------
4963 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
4965 when Pragma_Complex_Representation => Complex_Representation : declare
4972 Check_Arg_Count (1);
4973 Check_Optional_Identifier (Arg1, Name_Entity);
4974 Check_Arg_Is_Local_Name (Arg1);
4975 E_Id := Expression (Arg1);
4977 if Etype (E_Id) = Any_Type then
4983 if not Is_Record_Type (E) then
4985 ("argument for pragma% must be record type", Arg1);
4988 Ent := First_Entity (E);
4991 or else No (Next_Entity (Ent))
4992 or else Present (Next_Entity (Next_Entity (Ent)))
4993 or else not Is_Floating_Point_Type (Etype (Ent))
4994 or else Etype (Ent) /= Etype (Next_Entity (Ent))
4997 ("record for pragma% must have two fields of same fpt type",
5001 Set_Has_Complex_Representation (Base_Type (E));
5003 end Complex_Representation;
5005 -------------------------
5006 -- Component_Alignment --
5007 -------------------------
5009 -- pragma Component_Alignment (
5010 -- [Form =>] ALIGNMENT_CHOICE
5011 -- [, [Name =>] type_LOCAL_NAME]);
5013 -- ALIGNMENT_CHOICE ::=
5015 -- | Component_Size_4
5019 when Pragma_Component_Alignment => Component_AlignmentP : declare
5020 Args : Args_List (1 .. 2);
5021 Names : constant Name_List (1 .. 2) := (
5025 Form : Node_Id renames Args (1);
5026 Name : Node_Id renames Args (2);
5028 Atype : Component_Alignment_Kind;
5033 Gather_Associations (Names, Args);
5036 Error_Pragma ("missing Form argument for pragma%");
5039 Check_Arg_Is_Identifier (Form);
5041 -- Get proper alignment, note that Default = Component_Size
5042 -- on all machines we have so far, and we want to set this
5043 -- value rather than the default value to indicate that it
5044 -- has been explicitly set (and thus will not get overridden
5045 -- by the default component alignment for the current scope)
5047 if Chars (Form) = Name_Component_Size then
5048 Atype := Calign_Component_Size;
5050 elsif Chars (Form) = Name_Component_Size_4 then
5051 Atype := Calign_Component_Size_4;
5053 elsif Chars (Form) = Name_Default then
5054 Atype := Calign_Component_Size;
5056 elsif Chars (Form) = Name_Storage_Unit then
5057 Atype := Calign_Storage_Unit;
5061 ("invalid Form parameter for pragma%", Form);
5064 -- Case with no name, supplied, affects scope table entry
5068 (Scope_Stack.Last).Component_Alignment_Default := Atype;
5070 -- Case of name supplied
5073 Check_Arg_Is_Local_Name (Name);
5075 Typ := Entity (Name);
5078 or else Rep_Item_Too_Early (Typ, N)
5082 Typ := Underlying_Type (Typ);
5085 if not Is_Record_Type (Typ)
5086 and then not Is_Array_Type (Typ)
5089 ("Name parameter of pragma% must identify record or " &
5090 "array type", Name);
5093 -- An explicit Component_Alignment pragma overrides an
5094 -- implicit pragma Pack, but not an explicit one.
5096 if not Has_Pragma_Pack (Base_Type (Typ)) then
5097 Set_Is_Packed (Base_Type (Typ), False);
5098 Set_Component_Alignment (Base_Type (Typ), Atype);
5101 end Component_AlignmentP;
5107 -- pragma Controlled (first_subtype_LOCAL_NAME);
5109 when Pragma_Controlled => Controlled : declare
5113 Check_No_Identifiers;
5114 Check_Arg_Count (1);
5115 Check_Arg_Is_Local_Name (Arg1);
5116 Arg := Expression (Arg1);
5118 if not Is_Entity_Name (Arg)
5119 or else not Is_Access_Type (Entity (Arg))
5121 Error_Pragma_Arg ("pragma% requires access type", Arg1);
5123 Set_Has_Pragma_Controlled (Base_Type (Entity (Arg)));
5131 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
5132 -- [Entity =>] LOCAL_NAME);
5134 when Pragma_Convention => Convention : declare
5138 Check_Arg_Order ((Name_Convention, Name_Entity));
5139 Check_Ada_83_Warning;
5140 Check_Arg_Count (2);
5141 Process_Convention (C, E);
5144 ---------------------------
5145 -- Convention_Identifier --
5146 ---------------------------
5148 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
5149 -- [Convention =>] convention_IDENTIFIER);
5151 when Pragma_Convention_Identifier => Convention_Identifier : declare
5157 Check_Arg_Order ((Name_Name, Name_Convention));
5158 Check_Arg_Count (2);
5159 Check_Optional_Identifier (Arg1, Name_Name);
5160 Check_Optional_Identifier (Arg2, Name_Convention);
5161 Check_Arg_Is_Identifier (Arg1);
5162 Check_Arg_Is_Identifier (Arg1);
5163 Idnam := Chars (Expression (Arg1));
5164 Cname := Chars (Expression (Arg2));
5166 if Is_Convention_Name (Cname) then
5167 Record_Convention_Identifier
5168 (Idnam, Get_Convention_Id (Cname));
5171 ("second arg for % pragma must be convention", Arg2);
5173 end Convention_Identifier;
5179 -- pragma CPP_Class ([Entity =>] local_NAME)
5181 when Pragma_CPP_Class => CPP_Class : declare
5184 Default_DTC : Entity_Id := Empty;
5185 VTP_Type : constant Entity_Id := RTE (RE_Vtable_Ptr);
5191 Check_Arg_Count (1);
5192 Check_Optional_Identifier (Arg1, Name_Entity);
5193 Check_Arg_Is_Local_Name (Arg1);
5195 Arg := Expression (Arg1);
5198 if Etype (Arg) = Any_Type then
5202 if not Is_Entity_Name (Arg)
5203 or else not Is_Type (Entity (Arg))
5205 Error_Pragma_Arg ("pragma% requires a type mark", Arg1);
5208 Typ := Entity (Arg);
5210 if not Is_Record_Type (Typ) then
5211 Error_Pragma_Arg ("pragma% applicable to a record, "
5212 & "tagged record or record extension", Arg1);
5215 Default_DTC := First_Component (Typ);
5216 while Present (Default_DTC)
5217 and then Etype (Default_DTC) /= VTP_Type
5219 Next_Component (Default_DTC);
5222 -- Case of non tagged type
5224 if not Is_Tagged_Type (Typ) then
5225 Set_Is_CPP_Class (Typ);
5227 if Present (Default_DTC) then
5229 ("only tagged records can contain vtable pointers", Arg1);
5232 -- Case of tagged type with no vtable ptr
5234 -- What is test for Typ = Root_Typ (Typ) about here ???
5236 elsif Is_Tagged_Type (Typ)
5237 and then Typ = Root_Type (Typ)
5238 and then No (Default_DTC)
5241 ("a cpp_class must contain a vtable pointer", Arg1);
5243 -- Tagged type that has a vtable ptr
5245 elsif Present (Default_DTC) then
5246 Set_Is_CPP_Class (Typ);
5247 Set_Is_Limited_Record (Typ);
5248 Set_Is_Tag (Default_DTC);
5249 Set_DT_Entry_Count (Default_DTC, No_Uint);
5251 -- Since a CPP type has no direct link to its associated tag
5252 -- most tags checks cannot be performed
5254 Set_Kill_Tag_Checks (Typ);
5255 Set_Kill_Tag_Checks (Class_Wide_Type (Typ));
5257 -- Get rid of the _tag component when there was one.
5258 -- It is only useful for regular tagged types
5260 if Expander_Active and then Typ = Root_Type (Typ) then
5262 Tag_C := First_Tag_Component (Typ);
5263 C := First_Entity (Typ);
5266 Set_First_Entity (Typ, Next_Entity (Tag_C));
5269 while Next_Entity (C) /= Tag_C loop
5273 Set_Next_Entity (C, Next_Entity (Tag_C));
5279 ---------------------
5280 -- CPP_Constructor --
5281 ---------------------
5283 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
5285 when Pragma_CPP_Constructor => CPP_Constructor : declare
5291 Check_Arg_Count (1);
5292 Check_Optional_Identifier (Arg1, Name_Entity);
5293 Check_Arg_Is_Local_Name (Arg1);
5295 Id := Expression (Arg1);
5296 Find_Program_Unit_Name (Id);
5298 -- If we did not find the name, we are done
5300 if Etype (Id) = Any_Type then
5304 Def_Id := Entity (Id);
5306 if Ekind (Def_Id) = E_Function
5307 and then Is_Class_Wide_Type (Etype (Def_Id))
5308 and then Is_CPP_Class (Etype (Etype (Def_Id)))
5310 -- What the heck is this??? this pragma allows only 1 arg
5312 if Arg_Count >= 2 then
5313 Check_At_Most_N_Arguments (3);
5314 Process_Interface_Name (Def_Id, Arg2, Arg3);
5317 if No (Parameter_Specifications (Parent (Def_Id))) then
5318 Set_Has_Completion (Def_Id);
5319 Set_Is_Constructor (Def_Id);
5322 ("non-default constructors not implemented", Arg1);
5327 ("pragma% requires function returning a 'C'P'P_Class type",
5330 end CPP_Constructor;
5336 -- pragma CPP_Virtual
5337 -- [Entity =>] LOCAL_NAME
5338 -- [ [Vtable_Ptr =>] LOCAL_NAME,
5339 -- [Position =>] static_integer_EXPRESSION]);
5341 when Pragma_CPP_Virtual => CPP_Virtual : declare
5345 VTP_Type : constant Entity_Id := RTE (RE_Vtable_Ptr);
5351 Check_Arg_Order ((Name_Entity, Name_Vtable_Ptr, Name_Position));
5353 if Arg_Count = 3 then
5354 Check_Optional_Identifier (Arg2, Name_Vtable_Ptr);
5356 -- We allow Entry_Count as well as Position for the third
5357 -- parameter for back compatibility with versions of GNAT
5358 -- before version 3.12. The documentation has always said
5359 -- Position, but the code up to 3.12 said Entry_Count.
5361 if Chars (Arg3) /= Name_Entry_Count then
5362 Check_Optional_Identifier (Arg3, Name_Position);
5366 Check_Arg_Count (1);
5369 Check_Optional_Identifier (Arg1, Name_Entity);
5370 Check_Arg_Is_Local_Name (Arg1);
5372 -- First argument must be a subprogram name
5374 Arg := Expression (Arg1);
5375 Find_Program_Unit_Name (Arg);
5377 if Etype (Arg) = Any_Type then
5380 Subp := Entity (Arg);
5383 if not (Is_Subprogram (Subp)
5384 and then Is_Dispatching_Operation (Subp))
5387 ("pragma% must reference a primitive operation", Arg1);
5390 Typ := Find_Dispatching_Type (Subp);
5392 -- If only one Argument defaults are :
5393 -- . DTC_Entity is the default Vtable pointer
5394 -- . DT_Position will be set at the freezing point
5396 if Arg_Count = 1 then
5397 Set_DTC_Entity (Subp, First_Tag_Component (Typ));
5401 -- Second argument is a component name of type Vtable_Ptr
5403 Arg := Expression (Arg2);
5405 if Nkind (Arg) /= N_Identifier then
5406 Error_Msg_NE ("must be a& component name", Arg, Typ);
5410 DTC := First_Component (Typ);
5411 while Present (DTC) and then Chars (DTC) /= Chars (Arg) loop
5412 Next_Component (DTC);
5416 Error_Msg_NE ("must be a& component name", Arg, Typ);
5419 elsif Etype (DTC) /= VTP_Type then
5420 Wrong_Type (Arg, VTP_Type);
5424 -- Third argument is an integer (DT_Position)
5426 Arg := Expression (Arg3);
5427 Analyze_And_Resolve (Arg, Any_Integer);
5429 if not Is_Static_Expression (Arg) then
5430 Flag_Non_Static_Expr
5431 ("third argument of pragma CPP_Virtual must be static!",
5436 V := Expr_Value (Expression (Arg3));
5440 ("third argument of pragma% must be positive",
5444 Set_DTC_Entity (Subp, DTC);
5445 Set_DT_Position (Subp, V);
5454 -- pragma CPP_Vtable (
5455 -- [Entity =>] LOCAL_NAME
5456 -- [Vtable_Ptr =>] LOCAL_NAME,
5457 -- [Entry_Count =>] static_integer_EXPRESSION);
5459 when Pragma_CPP_Vtable => CPP_Vtable : declare
5462 VTP_Type : constant Entity_Id := RTE (RE_Vtable_Ptr);
5469 Check_Arg_Order ((Name_Entity, Name_Vtable_Ptr, Name_Entry_Count));
5470 Check_Arg_Count (3);
5471 Check_Optional_Identifier (Arg1, Name_Entity);
5472 Check_Optional_Identifier (Arg2, Name_Vtable_Ptr);
5473 Check_Optional_Identifier (Arg3, Name_Entry_Count);
5474 Check_Arg_Is_Local_Name (Arg1);
5476 -- First argument is a record type name
5478 Arg := Expression (Arg1);
5481 if Etype (Arg) = Any_Type then
5484 Typ := Entity (Arg);
5487 if not (Is_Tagged_Type (Typ) and then Is_CPP_Class (Typ)) then
5488 Error_Pragma_Arg ("'C'P'P_Class tagged type expected", Arg1);
5491 -- Second argument is a component name of type Vtable_Ptr
5493 Arg := Expression (Arg2);
5495 if Nkind (Arg) /= N_Identifier then
5496 Error_Msg_NE ("must be a& component name", Arg, Typ);
5500 DTC := First_Component (Typ);
5501 while Present (DTC) and then Chars (DTC) /= Chars (Arg) loop
5502 Next_Component (DTC);
5506 Error_Msg_NE ("must be a& component name", Arg, Typ);
5509 elsif Etype (DTC) /= VTP_Type then
5510 Wrong_Type (DTC, VTP_Type);
5513 -- If it is the first pragma Vtable, This becomes the default tag
5515 elsif (not Is_Tag (DTC))
5516 and then DT_Entry_Count (First_Tag_Component (Typ)) = No_Uint
5518 Set_Is_Tag (First_Tag_Component (Typ), False);
5519 Set_Is_Tag (DTC, True);
5520 Set_DT_Entry_Count (DTC, No_Uint);
5523 -- Those pragmas must appear before any primitive operation
5524 -- definition (except inherited ones) otherwise the default
5527 Elmt := First_Elmt (Primitive_Operations (Typ));
5528 while Present (Elmt) loop
5529 if No (Alias (Node (Elmt))) then
5530 Error_Msg_Sloc := Sloc (Node (Elmt));
5532 ("pragma% must appear before this primitive operation");
5538 -- Third argument is an integer (DT_Entry_Count)
5540 Arg := Expression (Arg3);
5541 Analyze_And_Resolve (Arg, Any_Integer);
5543 if not Is_Static_Expression (Arg) then
5544 Flag_Non_Static_Expr
5545 ("entry count for pragma CPP_Vtable must be a static " &
5546 "expression!", Arg3);
5550 V := Expr_Value (Expression (Arg3));
5554 ("entry count for pragma% must be positive", Arg3);
5556 Set_DT_Entry_Count (DTC, V);
5565 -- pragma Debug (PROCEDURE_CALL_STATEMENT);
5567 when Pragma_Debug => Debug : begin
5570 -- Rewrite into a conditional with a static condition
5572 Rewrite (N, Make_Implicit_If_Statement (N,
5573 Condition => New_Occurrence_Of (Boolean_Literals (
5574 Assertions_Enabled and Expander_Active), Loc),
5575 Then_Statements => New_List (
5576 Relocate_Node (Debug_Statement (N)))));
5580 ---------------------
5581 -- Detect_Blocking --
5582 ---------------------
5584 -- pragma Detect_Blocking;
5586 when Pragma_Detect_Blocking =>
5588 Check_Arg_Count (0);
5589 Check_Valid_Configuration_Pragma;
5590 Detect_Blocking := True;
5596 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
5598 when Pragma_Discard_Names => Discard_Names : declare
5603 Check_Ada_83_Warning;
5605 -- Deal with configuration pragma case
5607 if Arg_Count = 0 and then Is_Configuration_Pragma then
5608 Global_Discard_Names := True;
5611 -- Otherwise, check correct appropriate context
5614 Check_Is_In_Decl_Part_Or_Package_Spec;
5616 if Arg_Count = 0 then
5618 -- If there is no parameter, then from now on this pragma
5619 -- applies to any enumeration, exception or tagged type
5620 -- defined in the current declarative part.
5622 Set_Discard_Names (Current_Scope);
5626 Check_Arg_Count (1);
5627 Check_Optional_Identifier (Arg1, Name_On);
5628 Check_Arg_Is_Local_Name (Arg1);
5629 E_Id := Expression (Arg1);
5631 if Etype (E_Id) = Any_Type then
5637 if (Is_First_Subtype (E)
5638 and then (Is_Enumeration_Type (E)
5639 or else Is_Tagged_Type (E)))
5640 or else Ekind (E) = E_Exception
5642 Set_Discard_Names (E);
5645 ("inappropriate entity for pragma%", Arg1);
5655 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
5657 when Pragma_Elaborate => Elaborate : declare
5659 Parent_Node : Node_Id;
5664 -- Pragma must be in context items list of a compilation unit
5666 if not Is_List_Member (N) then
5671 Plist := List_Containing (N);
5672 Parent_Node := Parent (Plist);
5674 if Parent_Node = Empty
5675 or else Nkind (Parent_Node) /= N_Compilation_Unit
5676 or else Context_Items (Parent_Node) /= Plist
5683 -- Must be at least one argument
5685 if Arg_Count = 0 then
5686 Error_Pragma ("pragma% requires at least one argument");
5689 -- In Ada 83 mode, there can be no items following it in the
5690 -- context list except other pragmas and implicit with clauses
5691 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
5692 -- placement rule does not apply.
5694 if Ada_Version = Ada_83 and then Comes_From_Source (N) then
5697 while Present (Citem) loop
5698 if Nkind (Citem) = N_Pragma
5699 or else (Nkind (Citem) = N_With_Clause
5700 and then Implicit_With (Citem))
5705 ("(Ada 83) pragma% must be at end of context clause");
5712 -- Finally, the arguments must all be units mentioned in a with
5713 -- clause in the same context clause. Note we already checked
5714 -- (in Par.Prag) that the arguments are either identifiers or
5717 Outer : while Present (Arg) loop
5718 Citem := First (Plist);
5720 Inner : while Citem /= N loop
5721 if Nkind (Citem) = N_With_Clause
5722 and then Same_Name (Name (Citem), Expression (Arg))
5724 Set_Elaborate_Present (Citem, True);
5725 Set_Unit_Name (Expression (Arg), Name (Citem));
5727 -- With the pragma present, elaboration calls on
5728 -- subprograms from the named unit need no further
5729 -- checks, as long as the pragma appears in the current
5730 -- compilation unit. If the pragma appears in some unit
5731 -- in the context, there might still be a need for an
5732 -- Elaborate_All_Desirable from the current compilation
5733 -- to the the named unit, so we keep the check enabled.
5735 if In_Extended_Main_Source_Unit (N) then
5736 Set_Suppress_Elaboration_Warnings
5737 (Entity (Name (Citem)));
5747 ("argument of pragma% is not with'ed unit", Arg);
5753 -- Give a warning if operating in static mode with -gnatwl
5754 -- (elaboration warnings eanbled) switch set.
5756 if Elab_Warnings and not Dynamic_Elaboration_Checks then
5758 ("?use of pragma Elaborate may not be safe", N);
5760 ("?use pragma Elaborate_All instead if possible", N);
5768 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
5770 when Pragma_Elaborate_All => Elaborate_All : declare
5772 Parent_Node : Node_Id;
5777 Check_Ada_83_Warning;
5779 -- Pragma must be in context items list of a compilation unit
5781 if not Is_List_Member (N) then
5786 Plist := List_Containing (N);
5787 Parent_Node := Parent (Plist);
5789 if Parent_Node = Empty
5790 or else Nkind (Parent_Node) /= N_Compilation_Unit
5791 or else Context_Items (Parent_Node) /= Plist
5798 -- Must be at least one argument
5800 if Arg_Count = 0 then
5801 Error_Pragma ("pragma% requires at least one argument");
5804 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
5805 -- have to appear at the end of the context clause, but may
5806 -- appear mixed in with other items, even in Ada 83 mode.
5808 -- Final check: the arguments must all be units mentioned in
5809 -- a with clause in the same context clause. Note that we
5810 -- already checked (in Par.Prag) that all the arguments are
5811 -- either identifiers or selected components.
5814 Outr : while Present (Arg) loop
5815 Citem := First (Plist);
5817 Innr : while Citem /= N loop
5818 if Nkind (Citem) = N_With_Clause
5819 and then Same_Name (Name (Citem), Expression (Arg))
5821 Set_Elaborate_All_Present (Citem, True);
5822 Set_Unit_Name (Expression (Arg), Name (Citem));
5824 -- Suppress warnings and elaboration checks on the named
5825 -- unit if the pragma is in the current compilation, as
5826 -- for pragma Elaborate.
5828 if In_Extended_Main_Source_Unit (N) then
5829 Set_Suppress_Elaboration_Warnings
5830 (Entity (Name (Citem)));
5839 Set_Error_Posted (N);
5841 ("argument of pragma% is not with'ed unit", Arg);
5848 --------------------
5849 -- Elaborate_Body --
5850 --------------------
5852 -- pragma Elaborate_Body [( library_unit_NAME )];
5854 when Pragma_Elaborate_Body => Elaborate_Body : declare
5855 Cunit_Node : Node_Id;
5856 Cunit_Ent : Entity_Id;
5859 Check_Ada_83_Warning;
5860 Check_Valid_Library_Unit_Pragma;
5862 if Nkind (N) = N_Null_Statement then
5866 Cunit_Node := Cunit (Current_Sem_Unit);
5867 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
5869 if Nkind (Unit (Cunit_Node)) = N_Package_Body
5871 Nkind (Unit (Cunit_Node)) = N_Subprogram_Body
5873 Error_Pragma ("pragma% must refer to a spec, not a body");
5875 Set_Body_Required (Cunit_Node, True);
5876 Set_Has_Pragma_Elaborate_Body (Cunit_Ent);
5878 -- If we are in dynamic elaboration mode, then we suppress
5879 -- elaboration warnings for the unit, since it is definitely
5880 -- fine NOT to do dynamic checks at the first level (and such
5881 -- checks will be suppressed because no elaboration boolean
5882 -- is created for Elaborate_Body packages).
5884 -- But in the static model of elaboration, Elaborate_Body is
5885 -- definitely NOT good enough to ensure elaboration safety on
5886 -- its own, since the body may WITH other units that are not
5887 -- safe from an elaboration point of view, so a client must
5888 -- still do an Elaborate_All on such units.
5890 -- Debug flag -gnatdD restores the old behavior of 3.13,
5891 -- where Elaborate_Body always suppressed elab warnings.
5893 if Dynamic_Elaboration_Checks or Debug_Flag_DD then
5894 Set_Suppress_Elaboration_Warnings (Cunit_Ent);
5899 ------------------------
5900 -- Elaboration_Checks --
5901 ------------------------
5903 -- pragma Elaboration_Checks (Static | Dynamic);
5905 when Pragma_Elaboration_Checks =>
5907 Check_Arg_Count (1);
5908 Check_Arg_Is_One_Of (Arg1, Name_Static, Name_Dynamic);
5909 Dynamic_Elaboration_Checks :=
5910 (Chars (Get_Pragma_Arg (Arg1)) = Name_Dynamic);
5916 -- pragma Eliminate (
5917 -- [Unit_Name =>] IDENTIFIER |
5918 -- SELECTED_COMPONENT
5919 -- [,[Entity =>] IDENTIFIER |
5920 -- SELECTED_COMPONENT |
5922 -- [,]OVERLOADING_RESOLUTION);
5924 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
5927 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
5930 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
5932 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
5933 -- Result_Type => result_SUBTYPE_NAME]
5935 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
5936 -- SUBTYPE_NAME ::= STRING_LITERAL
5938 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
5939 -- SOURCE_TRACE ::= STRING_LITERAL
5941 when Pragma_Eliminate => Eliminate : declare
5942 Args : Args_List (1 .. 5);
5943 Names : constant Name_List (1 .. 5) := (
5946 Name_Parameter_Types,
5948 Name_Source_Location);
5950 Unit_Name : Node_Id renames Args (1);
5951 Entity : Node_Id renames Args (2);
5952 Parameter_Types : Node_Id renames Args (3);
5953 Result_Type : Node_Id renames Args (4);
5954 Source_Location : Node_Id renames Args (5);
5958 Check_Valid_Configuration_Pragma;
5959 Gather_Associations (Names, Args);
5961 if No (Unit_Name) then
5962 Error_Pragma ("missing Unit_Name argument for pragma%");
5966 and then (Present (Parameter_Types)
5968 Present (Result_Type)
5970 Present (Source_Location))
5972 Error_Pragma ("missing Entity argument for pragma%");
5975 if (Present (Parameter_Types)
5977 Present (Result_Type))
5979 Present (Source_Location)
5982 ("parameter profile and source location can not " &
5983 "be used together in pragma%");
5986 Process_Eliminate_Pragma
5995 -------------------------
5996 -- Explicit_Overriding --
5997 -------------------------
5999 when Pragma_Explicit_Overriding =>
6000 Check_Valid_Configuration_Pragma;
6001 Check_Arg_Count (0);
6002 Explicit_Overriding := True;
6009 -- [ Convention =>] convention_IDENTIFIER,
6010 -- [ Entity =>] local_NAME
6011 -- [, [External_Name =>] static_string_EXPRESSION ]
6012 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6014 when Pragma_Export => Export : declare
6019 Check_Ada_83_Warning;
6025 Check_At_Least_N_Arguments (2);
6026 Check_At_Most_N_Arguments (4);
6027 Process_Convention (C, Def_Id);
6029 if Ekind (Def_Id) /= E_Constant then
6030 Note_Possible_Modification (Expression (Arg2));
6033 Process_Interface_Name (Def_Id, Arg3, Arg4);
6034 Set_Exported (Def_Id, Arg2);
6037 ----------------------
6038 -- Export_Exception --
6039 ----------------------
6041 -- pragma Export_Exception (
6042 -- [Internal =>] LOCAL_NAME,
6043 -- [, [External =>] EXTERNAL_SYMBOL,]
6044 -- [, [Form =>] Ada | VMS]
6045 -- [, [Code =>] static_integer_EXPRESSION]);
6047 when Pragma_Export_Exception => Export_Exception : declare
6048 Args : Args_List (1 .. 4);
6049 Names : constant Name_List (1 .. 4) := (
6055 Internal : Node_Id renames Args (1);
6056 External : Node_Id renames Args (2);
6057 Form : Node_Id renames Args (3);
6058 Code : Node_Id renames Args (4);
6061 if Inside_A_Generic then
6062 Error_Pragma ("pragma% cannot be used for generic entities");
6065 Gather_Associations (Names, Args);
6066 Process_Extended_Import_Export_Exception_Pragma (
6067 Arg_Internal => Internal,
6068 Arg_External => External,
6072 if not Is_VMS_Exception (Entity (Internal)) then
6073 Set_Exported (Entity (Internal), Internal);
6075 end Export_Exception;
6077 ---------------------
6078 -- Export_Function --
6079 ---------------------
6081 -- pragma Export_Function (
6082 -- [Internal =>] LOCAL_NAME,
6083 -- [, [External =>] EXTERNAL_SYMBOL,]
6084 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6085 -- [, [Result_Type =>] TYPE_DESIGNATOR]
6086 -- [, [Mechanism =>] MECHANISM]
6087 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
6089 -- EXTERNAL_SYMBOL ::=
6091 -- | static_string_EXPRESSION
6093 -- PARAMETER_TYPES ::=
6095 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6097 -- TYPE_DESIGNATOR ::=
6099 -- | subtype_Name ' Access
6103 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6105 -- MECHANISM_ASSOCIATION ::=
6106 -- [formal_parameter_NAME =>] MECHANISM_NAME
6108 -- MECHANISM_NAME ::=
6111 -- | Descriptor [([Class =>] CLASS_NAME)]
6113 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6115 when Pragma_Export_Function => Export_Function : declare
6116 Args : Args_List (1 .. 6);
6117 Names : constant Name_List (1 .. 6) := (
6120 Name_Parameter_Types,
6123 Name_Result_Mechanism);
6125 Internal : Node_Id renames Args (1);
6126 External : Node_Id renames Args (2);
6127 Parameter_Types : Node_Id renames Args (3);
6128 Result_Type : Node_Id renames Args (4);
6129 Mechanism : Node_Id renames Args (5);
6130 Result_Mechanism : Node_Id renames Args (6);
6134 Gather_Associations (Names, Args);
6135 Process_Extended_Import_Export_Subprogram_Pragma (
6136 Arg_Internal => Internal,
6137 Arg_External => External,
6138 Arg_Parameter_Types => Parameter_Types,
6139 Arg_Result_Type => Result_Type,
6140 Arg_Mechanism => Mechanism,
6141 Arg_Result_Mechanism => Result_Mechanism);
6142 end Export_Function;
6148 -- pragma Export_Object (
6149 -- [Internal =>] LOCAL_NAME,
6150 -- [, [External =>] EXTERNAL_SYMBOL]
6151 -- [, [Size =>] EXTERNAL_SYMBOL]);
6153 -- EXTERNAL_SYMBOL ::=
6155 -- | static_string_EXPRESSION
6157 -- PARAMETER_TYPES ::=
6159 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6161 -- TYPE_DESIGNATOR ::=
6163 -- | subtype_Name ' Access
6167 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6169 -- MECHANISM_ASSOCIATION ::=
6170 -- [formal_parameter_NAME =>] MECHANISM_NAME
6172 -- MECHANISM_NAME ::=
6175 -- | Descriptor [([Class =>] CLASS_NAME)]
6177 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6179 when Pragma_Export_Object => Export_Object : declare
6180 Args : Args_List (1 .. 3);
6181 Names : constant Name_List (1 .. 3) := (
6186 Internal : Node_Id renames Args (1);
6187 External : Node_Id renames Args (2);
6188 Size : Node_Id renames Args (3);
6192 Gather_Associations (Names, Args);
6193 Process_Extended_Import_Export_Object_Pragma (
6194 Arg_Internal => Internal,
6195 Arg_External => External,
6199 ----------------------
6200 -- Export_Procedure --
6201 ----------------------
6203 -- pragma Export_Procedure (
6204 -- [Internal =>] LOCAL_NAME,
6205 -- [, [External =>] EXTERNAL_SYMBOL,]
6206 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6207 -- [, [Mechanism =>] MECHANISM]);
6209 -- EXTERNAL_SYMBOL ::=
6211 -- | static_string_EXPRESSION
6213 -- PARAMETER_TYPES ::=
6215 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6217 -- TYPE_DESIGNATOR ::=
6219 -- | subtype_Name ' Access
6223 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6225 -- MECHANISM_ASSOCIATION ::=
6226 -- [formal_parameter_NAME =>] MECHANISM_NAME
6228 -- MECHANISM_NAME ::=
6231 -- | Descriptor [([Class =>] CLASS_NAME)]
6233 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6235 when Pragma_Export_Procedure => Export_Procedure : declare
6236 Args : Args_List (1 .. 4);
6237 Names : constant Name_List (1 .. 4) := (
6240 Name_Parameter_Types,
6243 Internal : Node_Id renames Args (1);
6244 External : Node_Id renames Args (2);
6245 Parameter_Types : Node_Id renames Args (3);
6246 Mechanism : Node_Id renames Args (4);
6250 Gather_Associations (Names, Args);
6251 Process_Extended_Import_Export_Subprogram_Pragma (
6252 Arg_Internal => Internal,
6253 Arg_External => External,
6254 Arg_Parameter_Types => Parameter_Types,
6255 Arg_Mechanism => Mechanism);
6256 end Export_Procedure;
6262 -- pragma Export_Value (
6263 -- [Value =>] static_integer_EXPRESSION,
6264 -- [Link_Name =>] static_string_EXPRESSION);
6266 when Pragma_Export_Value =>
6268 Check_Arg_Order ((Name_Value, Name_Link_Name));
6269 Check_Arg_Count (2);
6271 Check_Optional_Identifier (Arg1, Name_Value);
6272 Check_Arg_Is_Static_Expression (Arg1, Any_Integer);
6274 Check_Optional_Identifier (Arg2, Name_Link_Name);
6275 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
6277 -----------------------------
6278 -- Export_Valued_Procedure --
6279 -----------------------------
6281 -- pragma Export_Valued_Procedure (
6282 -- [Internal =>] LOCAL_NAME,
6283 -- [, [External =>] EXTERNAL_SYMBOL,]
6284 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6285 -- [, [Mechanism =>] MECHANISM]);
6287 -- EXTERNAL_SYMBOL ::=
6289 -- | static_string_EXPRESSION
6291 -- PARAMETER_TYPES ::=
6293 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6295 -- TYPE_DESIGNATOR ::=
6297 -- | subtype_Name ' Access
6301 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6303 -- MECHANISM_ASSOCIATION ::=
6304 -- [formal_parameter_NAME =>] MECHANISM_NAME
6306 -- MECHANISM_NAME ::=
6309 -- | Descriptor [([Class =>] CLASS_NAME)]
6311 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6313 when Pragma_Export_Valued_Procedure =>
6314 Export_Valued_Procedure : declare
6315 Args : Args_List (1 .. 4);
6316 Names : constant Name_List (1 .. 4) := (
6319 Name_Parameter_Types,
6322 Internal : Node_Id renames Args (1);
6323 External : Node_Id renames Args (2);
6324 Parameter_Types : Node_Id renames Args (3);
6325 Mechanism : Node_Id renames Args (4);
6329 Gather_Associations (Names, Args);
6330 Process_Extended_Import_Export_Subprogram_Pragma (
6331 Arg_Internal => Internal,
6332 Arg_External => External,
6333 Arg_Parameter_Types => Parameter_Types,
6334 Arg_Mechanism => Mechanism);
6335 end Export_Valued_Procedure;
6341 -- pragma Extend_System ([Name =>] Identifier);
6343 when Pragma_Extend_System => Extend_System : declare
6346 Check_Valid_Configuration_Pragma;
6347 Check_Arg_Count (1);
6348 Check_Optional_Identifier (Arg1, Name_Name);
6349 Check_Arg_Is_Identifier (Arg1);
6351 Get_Name_String (Chars (Expression (Arg1)));
6354 and then Name_Buffer (1 .. 4) = "aux_"
6356 if Present (System_Extend_Pragma_Arg) then
6357 if Chars (Expression (Arg1)) =
6358 Chars (Expression (System_Extend_Pragma_Arg))
6362 Error_Msg_Sloc := Sloc (System_Extend_Pragma_Arg);
6363 Error_Pragma ("pragma% conflicts with that at#");
6367 System_Extend_Pragma_Arg := Arg1;
6369 if not GNAT_Mode then
6370 System_Extend_Unit := Arg1;
6374 Error_Pragma ("incorrect name for pragma%, must be Aux_xxx");
6378 ------------------------
6379 -- Extensions_Allowed --
6380 ------------------------
6382 -- pragma Extensions_Allowed (ON | OFF);
6384 when Pragma_Extensions_Allowed =>
6386 Check_Arg_Count (1);
6387 Check_No_Identifiers;
6388 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
6390 if Chars (Expression (Arg1)) = Name_On then
6391 Extensions_Allowed := True;
6392 Ada_Version := Ada_Version_Type'Last;
6394 Extensions_Allowed := False;
6395 Ada_Version := Ada_Version_Type'Min (Ada_Version, Ada_95);
6398 Ada_Version_Explicit := Ada_Version;
6404 -- pragma External (
6405 -- [ Convention =>] convention_IDENTIFIER,
6406 -- [ Entity =>] local_NAME
6407 -- [, [External_Name =>] static_string_EXPRESSION ]
6408 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6410 when Pragma_External => External : declare
6420 Check_At_Least_N_Arguments (2);
6421 Check_At_Most_N_Arguments (4);
6422 Process_Convention (C, Def_Id);
6423 Note_Possible_Modification (Expression (Arg2));
6424 Process_Interface_Name (Def_Id, Arg3, Arg4);
6425 Set_Exported (Def_Id, Arg2);
6428 --------------------------
6429 -- External_Name_Casing --
6430 --------------------------
6432 -- pragma External_Name_Casing (
6433 -- UPPERCASE | LOWERCASE
6434 -- [, AS_IS | UPPERCASE | LOWERCASE]);
6436 when Pragma_External_Name_Casing => External_Name_Casing : declare
6439 Check_No_Identifiers;
6441 if Arg_Count = 2 then
6443 (Arg2, Name_As_Is, Name_Uppercase, Name_Lowercase);
6445 case Chars (Get_Pragma_Arg (Arg2)) is
6447 Opt.External_Name_Exp_Casing := As_Is;
6449 when Name_Uppercase =>
6450 Opt.External_Name_Exp_Casing := Uppercase;
6452 when Name_Lowercase =>
6453 Opt.External_Name_Exp_Casing := Lowercase;
6460 Check_Arg_Count (1);
6463 Check_Arg_Is_One_Of (Arg1, Name_Uppercase, Name_Lowercase);
6465 case Chars (Get_Pragma_Arg (Arg1)) is
6466 when Name_Uppercase =>
6467 Opt.External_Name_Imp_Casing := Uppercase;
6469 when Name_Lowercase =>
6470 Opt.External_Name_Imp_Casing := Lowercase;
6475 end External_Name_Casing;
6477 ---------------------------
6478 -- Finalize_Storage_Only --
6479 ---------------------------
6481 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
6483 when Pragma_Finalize_Storage_Only => Finalize_Storage : declare
6484 Assoc : constant Node_Id := Arg1;
6485 Type_Id : constant Node_Id := Expression (Assoc);
6489 Check_No_Identifiers;
6490 Check_Arg_Count (1);
6491 Check_Arg_Is_Local_Name (Arg1);
6493 Find_Type (Type_Id);
6494 Typ := Entity (Type_Id);
6497 or else Rep_Item_Too_Early (Typ, N)
6501 Typ := Underlying_Type (Typ);
6504 if not Is_Controlled (Typ) then
6505 Error_Pragma ("pragma% must specify controlled type");
6508 Check_First_Subtype (Arg1);
6510 if Finalize_Storage_Only (Typ) then
6511 Error_Pragma ("duplicate pragma%, only one allowed");
6513 elsif not Rep_Item_Too_Late (Typ, N) then
6514 Set_Finalize_Storage_Only (Base_Type (Typ), True);
6516 end Finalize_Storage;
6518 --------------------------
6519 -- Float_Representation --
6520 --------------------------
6522 -- pragma Float_Representation (VAX_Float | IEEE_Float);
6524 when Pragma_Float_Representation => Float_Representation : declare
6532 if Arg_Count = 1 then
6533 Check_Valid_Configuration_Pragma;
6535 Check_Arg_Count (2);
6536 Check_Optional_Identifier (Arg2, Name_Entity);
6537 Check_Arg_Is_Local_Name (Arg2);
6540 Check_No_Identifier (Arg1);
6541 Check_Arg_Is_One_Of (Arg1, Name_VAX_Float, Name_IEEE_Float);
6543 if not OpenVMS_On_Target then
6544 if Chars (Expression (Arg1)) = Name_VAX_Float then
6546 ("?pragma% ignored (applies only to Open'V'M'S)");
6552 -- One argument case
6554 if Arg_Count = 1 then
6556 if Chars (Expression (Arg1)) = Name_VAX_Float then
6558 if Opt.Float_Format = 'I' then
6559 Error_Pragma ("'I'E'E'E format previously specified");
6562 Opt.Float_Format := 'V';
6565 if Opt.Float_Format = 'V' then
6566 Error_Pragma ("'V'A'X format previously specified");
6569 Opt.Float_Format := 'I';
6572 Set_Standard_Fpt_Formats;
6574 -- Two argument case
6577 Argx := Get_Pragma_Arg (Arg2);
6579 if not Is_Entity_Name (Argx)
6580 or else not Is_Floating_Point_Type (Entity (Argx))
6583 ("second argument of% pragma must be floating-point type",
6587 Ent := Entity (Argx);
6588 Digs := UI_To_Int (Digits_Value (Ent));
6590 -- Two arguments, VAX_Float case
6592 if Chars (Expression (Arg1)) = Name_VAX_Float then
6595 when 6 => Set_F_Float (Ent);
6596 when 9 => Set_D_Float (Ent);
6597 when 15 => Set_G_Float (Ent);
6601 ("wrong digits value, must be 6,9 or 15", Arg2);
6604 -- Two arguments, IEEE_Float case
6608 when 6 => Set_IEEE_Short (Ent);
6609 when 15 => Set_IEEE_Long (Ent);
6613 ("wrong digits value, must be 6 or 15", Arg2);
6617 end Float_Representation;
6623 -- pragma Ident (static_string_EXPRESSION)
6625 -- Note: pragma Comment shares this processing. Pragma Comment
6626 -- is identical to Ident, except that the restriction of the
6627 -- argument to 31 characters and the placement restrictions
6628 -- are not enforced for pragma Comment.
6630 when Pragma_Ident | Pragma_Comment => Ident : declare
6635 Check_Arg_Count (1);
6636 Check_No_Identifiers;
6637 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
6639 -- For pragma Ident, preserve DEC compatibility by requiring
6640 -- the pragma to appear in a declarative part or package spec.
6642 if Prag_Id = Pragma_Ident then
6643 Check_Is_In_Decl_Part_Or_Package_Spec;
6646 Str := Expr_Value_S (Expression (Arg1));
6653 GP := Parent (Parent (N));
6655 if Nkind (GP) = N_Package_Declaration
6657 Nkind (GP) = N_Generic_Package_Declaration
6662 -- If we have a compilation unit, then record the ident
6663 -- value, checking for improper duplication.
6665 if Nkind (GP) = N_Compilation_Unit then
6666 CS := Ident_String (Current_Sem_Unit);
6668 if Present (CS) then
6670 -- For Ident, we do not permit multiple instances
6672 if Prag_Id = Pragma_Ident then
6673 Error_Pragma ("duplicate% pragma not permitted");
6675 -- For Comment, we concatenate the string, unless we
6676 -- want to preserve the tree structure for ASIS.
6678 elsif not ASIS_Mode then
6679 Start_String (Strval (CS));
6680 Store_String_Char (' ');
6681 Store_String_Chars (Strval (Str));
6682 Set_Strval (CS, End_String);
6686 -- In VMS, the effect of IDENT is achieved by passing
6687 -- IDENTIFICATION=name as a --for-linker switch.
6689 if OpenVMS_On_Target then
6692 ("--for-linker=IDENTIFICATION=");
6693 String_To_Name_Buffer (Strval (Str));
6694 Store_String_Chars (Name_Buffer (1 .. Name_Len));
6696 -- Only the last processed IDENT is saved. The main
6697 -- purpose is so an IDENT associated with a main
6698 -- procedure will be used in preference to an IDENT
6699 -- associated with a with'd package.
6701 Replace_Linker_Option_String
6702 (End_String, "--for-linker=IDENTIFICATION=");
6705 Set_Ident_String (Current_Sem_Unit, Str);
6708 -- For subunits, we just ignore the Ident, since in GNAT
6709 -- these are not separate object files, and hence not
6710 -- separate units in the unit table.
6712 elsif Nkind (GP) = N_Subunit then
6715 -- Otherwise we have a misplaced pragma Ident, but we ignore
6716 -- this if we are in an instantiation, since it comes from
6717 -- a generic, and has no relevance to the instantiation.
6719 elsif Prag_Id = Pragma_Ident then
6720 if Instantiation_Location (Loc) = No_Location then
6721 Error_Pragma ("pragma% only allowed at outer level");
6732 -- [ Convention =>] convention_IDENTIFIER,
6733 -- [ Entity =>] local_NAME
6734 -- [, [External_Name =>] static_string_EXPRESSION ]
6735 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6737 when Pragma_Import =>
6738 Check_Ada_83_Warning;
6744 Check_At_Least_N_Arguments (2);
6745 Check_At_Most_N_Arguments (4);
6746 Process_Import_Or_Interface;
6748 ----------------------
6749 -- Import_Exception --
6750 ----------------------
6752 -- pragma Import_Exception (
6753 -- [Internal =>] LOCAL_NAME,
6754 -- [, [External =>] EXTERNAL_SYMBOL,]
6755 -- [, [Form =>] Ada | VMS]
6756 -- [, [Code =>] static_integer_EXPRESSION]);
6758 when Pragma_Import_Exception => Import_Exception : declare
6759 Args : Args_List (1 .. 4);
6760 Names : constant Name_List (1 .. 4) := (
6766 Internal : Node_Id renames Args (1);
6767 External : Node_Id renames Args (2);
6768 Form : Node_Id renames Args (3);
6769 Code : Node_Id renames Args (4);
6772 Gather_Associations (Names, Args);
6774 if Present (External) and then Present (Code) then
6776 ("cannot give both External and Code options for pragma%");
6779 Process_Extended_Import_Export_Exception_Pragma (
6780 Arg_Internal => Internal,
6781 Arg_External => External,
6785 if not Is_VMS_Exception (Entity (Internal)) then
6786 Set_Imported (Entity (Internal));
6788 end Import_Exception;
6790 ---------------------
6791 -- Import_Function --
6792 ---------------------
6794 -- pragma Import_Function (
6795 -- [Internal =>] LOCAL_NAME,
6796 -- [, [External =>] EXTERNAL_SYMBOL]
6797 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6798 -- [, [Result_Type =>] SUBTYPE_MARK]
6799 -- [, [Mechanism =>] MECHANISM]
6800 -- [, [Result_Mechanism =>] MECHANISM_NAME]
6801 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6803 -- EXTERNAL_SYMBOL ::=
6805 -- | static_string_EXPRESSION
6807 -- PARAMETER_TYPES ::=
6809 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6811 -- TYPE_DESIGNATOR ::=
6813 -- | subtype_Name ' Access
6817 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6819 -- MECHANISM_ASSOCIATION ::=
6820 -- [formal_parameter_NAME =>] MECHANISM_NAME
6822 -- MECHANISM_NAME ::=
6825 -- | Descriptor [([Class =>] CLASS_NAME)]
6827 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6829 when Pragma_Import_Function => Import_Function : declare
6830 Args : Args_List (1 .. 7);
6831 Names : constant Name_List (1 .. 7) := (
6834 Name_Parameter_Types,
6837 Name_Result_Mechanism,
6838 Name_First_Optional_Parameter);
6840 Internal : Node_Id renames Args (1);
6841 External : Node_Id renames Args (2);
6842 Parameter_Types : Node_Id renames Args (3);
6843 Result_Type : Node_Id renames Args (4);
6844 Mechanism : Node_Id renames Args (5);
6845 Result_Mechanism : Node_Id renames Args (6);
6846 First_Optional_Parameter : Node_Id renames Args (7);
6850 Gather_Associations (Names, Args);
6851 Process_Extended_Import_Export_Subprogram_Pragma (
6852 Arg_Internal => Internal,
6853 Arg_External => External,
6854 Arg_Parameter_Types => Parameter_Types,
6855 Arg_Result_Type => Result_Type,
6856 Arg_Mechanism => Mechanism,
6857 Arg_Result_Mechanism => Result_Mechanism,
6858 Arg_First_Optional_Parameter => First_Optional_Parameter);
6859 end Import_Function;
6865 -- pragma Import_Object (
6866 -- [Internal =>] LOCAL_NAME,
6867 -- [, [External =>] EXTERNAL_SYMBOL]
6868 -- [, [Size =>] EXTERNAL_SYMBOL]);
6870 -- EXTERNAL_SYMBOL ::=
6872 -- | static_string_EXPRESSION
6874 when Pragma_Import_Object => Import_Object : declare
6875 Args : Args_List (1 .. 3);
6876 Names : constant Name_List (1 .. 3) := (
6881 Internal : Node_Id renames Args (1);
6882 External : Node_Id renames Args (2);
6883 Size : Node_Id renames Args (3);
6887 Gather_Associations (Names, Args);
6888 Process_Extended_Import_Export_Object_Pragma (
6889 Arg_Internal => Internal,
6890 Arg_External => External,
6894 ----------------------
6895 -- Import_Procedure --
6896 ----------------------
6898 -- pragma Import_Procedure (
6899 -- [Internal =>] LOCAL_NAME,
6900 -- [, [External =>] EXTERNAL_SYMBOL]
6901 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6902 -- [, [Mechanism =>] MECHANISM]
6903 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6905 -- EXTERNAL_SYMBOL ::=
6907 -- | static_string_EXPRESSION
6909 -- PARAMETER_TYPES ::=
6911 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6913 -- TYPE_DESIGNATOR ::=
6915 -- | subtype_Name ' Access
6919 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6921 -- MECHANISM_ASSOCIATION ::=
6922 -- [formal_parameter_NAME =>] MECHANISM_NAME
6924 -- MECHANISM_NAME ::=
6927 -- | Descriptor [([Class =>] CLASS_NAME)]
6929 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6931 when Pragma_Import_Procedure => Import_Procedure : declare
6932 Args : Args_List (1 .. 5);
6933 Names : constant Name_List (1 .. 5) := (
6936 Name_Parameter_Types,
6938 Name_First_Optional_Parameter);
6940 Internal : Node_Id renames Args (1);
6941 External : Node_Id renames Args (2);
6942 Parameter_Types : Node_Id renames Args (3);
6943 Mechanism : Node_Id renames Args (4);
6944 First_Optional_Parameter : Node_Id renames Args (5);
6948 Gather_Associations (Names, Args);
6949 Process_Extended_Import_Export_Subprogram_Pragma (
6950 Arg_Internal => Internal,
6951 Arg_External => External,
6952 Arg_Parameter_Types => Parameter_Types,
6953 Arg_Mechanism => Mechanism,
6954 Arg_First_Optional_Parameter => First_Optional_Parameter);
6955 end Import_Procedure;
6957 -----------------------------
6958 -- Import_Valued_Procedure --
6959 -----------------------------
6961 -- pragma Import_Valued_Procedure (
6962 -- [Internal =>] LOCAL_NAME,
6963 -- [, [External =>] EXTERNAL_SYMBOL]
6964 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6965 -- [, [Mechanism =>] MECHANISM]
6966 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6968 -- EXTERNAL_SYMBOL ::=
6970 -- | static_string_EXPRESSION
6972 -- PARAMETER_TYPES ::=
6974 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6976 -- TYPE_DESIGNATOR ::=
6978 -- | subtype_Name ' Access
6982 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6984 -- MECHANISM_ASSOCIATION ::=
6985 -- [formal_parameter_NAME =>] MECHANISM_NAME
6987 -- MECHANISM_NAME ::=
6990 -- | Descriptor [([Class =>] CLASS_NAME)]
6992 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6994 when Pragma_Import_Valued_Procedure =>
6995 Import_Valued_Procedure : declare
6996 Args : Args_List (1 .. 5);
6997 Names : constant Name_List (1 .. 5) := (
7000 Name_Parameter_Types,
7002 Name_First_Optional_Parameter);
7004 Internal : Node_Id renames Args (1);
7005 External : Node_Id renames Args (2);
7006 Parameter_Types : Node_Id renames Args (3);
7007 Mechanism : Node_Id renames Args (4);
7008 First_Optional_Parameter : Node_Id renames Args (5);
7012 Gather_Associations (Names, Args);
7013 Process_Extended_Import_Export_Subprogram_Pragma (
7014 Arg_Internal => Internal,
7015 Arg_External => External,
7016 Arg_Parameter_Types => Parameter_Types,
7017 Arg_Mechanism => Mechanism,
7018 Arg_First_Optional_Parameter => First_Optional_Parameter);
7019 end Import_Valued_Procedure;
7021 ------------------------
7022 -- Initialize_Scalars --
7023 ------------------------
7025 -- pragma Initialize_Scalars;
7027 when Pragma_Initialize_Scalars =>
7029 Check_Arg_Count (0);
7030 Check_Valid_Configuration_Pragma;
7031 Check_Restriction (No_Initialize_Scalars, N);
7033 if not Restriction_Active (No_Initialize_Scalars) then
7034 Init_Or_Norm_Scalars := True;
7035 Initialize_Scalars := True;
7042 -- pragma Inline ( NAME {, NAME} );
7044 when Pragma_Inline =>
7046 -- Pragma is active if inlining option is active
7048 Process_Inline (Inline_Active);
7054 -- pragma Inline_Always ( NAME {, NAME} );
7056 when Pragma_Inline_Always =>
7057 Process_Inline (True);
7059 --------------------
7060 -- Inline_Generic --
7061 --------------------
7063 -- pragma Inline_Generic (NAME {, NAME});
7065 when Pragma_Inline_Generic =>
7066 Process_Generic_List;
7068 ----------------------
7069 -- Inspection_Point --
7070 ----------------------
7072 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
7074 when Pragma_Inspection_Point => Inspection_Point : declare
7079 if Arg_Count > 0 then
7082 Exp := Expression (Arg);
7085 if not Is_Entity_Name (Exp)
7086 or else not Is_Object (Entity (Exp))
7088 Error_Pragma_Arg ("object name required", Arg);
7095 end Inspection_Point;
7101 -- pragma Interface (
7102 -- convention_IDENTIFIER,
7105 when Pragma_Interface =>
7107 Check_Arg_Count (2);
7108 Check_No_Identifiers;
7109 Process_Import_Or_Interface;
7111 --------------------
7112 -- Interface_Name --
7113 --------------------
7115 -- pragma Interface_Name (
7116 -- [ Entity =>] local_NAME
7117 -- [,[External_Name =>] static_string_EXPRESSION ]
7118 -- [,[Link_Name =>] static_string_EXPRESSION ]);
7120 when Pragma_Interface_Name => Interface_Name : declare
7129 ((Name_Entity, Name_External_Name, Name_Link_Name));
7130 Check_At_Least_N_Arguments (2);
7131 Check_At_Most_N_Arguments (3);
7132 Id := Expression (Arg1);
7135 if not Is_Entity_Name (Id) then
7137 ("first argument for pragma% must be entity name", Arg1);
7138 elsif Etype (Id) = Any_Type then
7141 Def_Id := Entity (Id);
7144 -- Special DEC-compatible processing for the object case,
7145 -- forces object to be imported.
7147 if Ekind (Def_Id) = E_Variable then
7148 Kill_Size_Check_Code (Def_Id);
7149 Note_Possible_Modification (Id);
7151 -- Initialization is not allowed for imported variable
7153 if Present (Expression (Parent (Def_Id)))
7154 and then Comes_From_Source (Expression (Parent (Def_Id)))
7156 Error_Msg_Sloc := Sloc (Def_Id);
7158 ("no initialization allowed for declaration of& #",
7162 -- For compatibility, support VADS usage of providing both
7163 -- pragmas Interface and Interface_Name to obtain the effect
7164 -- of a single Import pragma.
7166 if Is_Imported (Def_Id)
7167 and then Present (First_Rep_Item (Def_Id))
7168 and then Nkind (First_Rep_Item (Def_Id)) = N_Pragma
7169 and then Chars (First_Rep_Item (Def_Id)) = Name_Interface
7173 Set_Imported (Def_Id);
7176 Set_Is_Public (Def_Id);
7177 Process_Interface_Name (Def_Id, Arg2, Arg3);
7180 -- Otherwise must be subprogram
7182 elsif not Is_Subprogram (Def_Id) then
7184 ("argument of pragma% is not subprogram", Arg1);
7187 Check_At_Most_N_Arguments (3);
7191 -- Loop through homonyms
7194 Def_Id := Get_Base_Subprogram (Hom_Id);
7196 if Is_Imported (Def_Id) then
7197 Process_Interface_Name (Def_Id, Arg2, Arg3);
7201 Hom_Id := Homonym (Hom_Id);
7203 exit when No (Hom_Id)
7204 or else Scope (Hom_Id) /= Current_Scope;
7209 ("argument of pragma% is not imported subprogram",
7215 -----------------------
7216 -- Interrupt_Handler --
7217 -----------------------
7219 -- pragma Interrupt_Handler (handler_NAME);
7221 when Pragma_Interrupt_Handler =>
7222 Check_Ada_83_Warning;
7223 Check_Arg_Count (1);
7224 Check_No_Identifiers;
7226 if No_Run_Time_Mode then
7227 Error_Msg_CRT ("Interrupt_Handler pragma", N);
7229 Check_Interrupt_Or_Attach_Handler;
7230 Process_Interrupt_Or_Attach_Handler;
7233 ------------------------
7234 -- Interrupt_Priority --
7235 ------------------------
7237 -- pragma Interrupt_Priority [(EXPRESSION)];
7239 when Pragma_Interrupt_Priority => Interrupt_Priority : declare
7240 P : constant Node_Id := Parent (N);
7244 Check_Ada_83_Warning;
7246 if Arg_Count /= 0 then
7247 Arg := Expression (Arg1);
7248 Check_Arg_Count (1);
7249 Check_No_Identifiers;
7251 -- The expression must be analyzed in the special manner
7252 -- described in "Handling of Default and Per-Object
7253 -- Expressions" in sem.ads.
7255 Analyze_Per_Use_Expression (Arg, RTE (RE_Interrupt_Priority));
7258 if Nkind (P) /= N_Task_Definition
7259 and then Nkind (P) /= N_Protected_Definition
7264 elsif Has_Priority_Pragma (P) then
7265 Error_Pragma ("duplicate pragma% not allowed");
7268 Set_Has_Priority_Pragma (P, True);
7269 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
7271 end Interrupt_Priority;
7273 ---------------------
7274 -- Interrupt_State --
7275 ---------------------
7277 -- pragma Interrupt_State (
7278 -- [Name =>] INTERRUPT_ID,
7279 -- [State =>] INTERRUPT_STATE);
7281 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
7282 -- INTERRUPT_STATE => System | Runtime | User
7284 -- Note: if the interrupt id is given as an identifier, then
7285 -- it must be one of the identifiers in Ada.Interrupts.Names.
7286 -- Otherwise it is given as a static integer expression which
7287 -- must be in the range of Ada.Interrupts.Interrupt_ID.
7289 when Pragma_Interrupt_State => Interrupt_State : declare
7291 Int_Id : constant Entity_Id := RTE (RE_Interrupt_ID);
7292 -- This is the entity Ada.Interrupts.Interrupt_ID;
7294 State_Type : Character;
7295 -- Set to 's'/'r'/'u' for System/Runtime/User
7298 -- Index to entry in Interrupt_States table
7301 -- Value of interrupt
7303 Arg1X : constant Node_Id := Get_Pragma_Arg (Arg1);
7304 -- The first argument to the pragma
7306 Int_Ent : Entity_Id;
7307 -- Interrupt entity in Ada.Interrupts.Names
7311 Check_Arg_Order ((Name_Name, Name_State));
7312 Check_Arg_Count (2);
7314 Check_Optional_Identifier (Arg1, Name_Name);
7315 Check_Optional_Identifier (Arg2, Name_State);
7316 Check_Arg_Is_Identifier (Arg2);
7318 -- First argument is identifier
7320 if Nkind (Arg1X) = N_Identifier then
7322 -- Search list of names in Ada.Interrupts.Names
7324 Int_Ent := First_Entity (RTE (RE_Names));
7326 if No (Int_Ent) then
7327 Error_Pragma_Arg ("invalid interrupt name", Arg1);
7329 elsif Chars (Int_Ent) = Chars (Arg1X) then
7330 Int_Val := Expr_Value (Constant_Value (Int_Ent));
7334 Next_Entity (Int_Ent);
7337 -- First argument is not an identifier, so it must be a
7338 -- static expression of type Ada.Interrupts.Interrupt_ID.
7341 Check_Arg_Is_Static_Expression (Arg1, Any_Integer);
7342 Int_Val := Expr_Value (Arg1X);
7344 if Int_Val < Expr_Value (Type_Low_Bound (Int_Id))
7346 Int_Val > Expr_Value (Type_High_Bound (Int_Id))
7349 ("value not in range of type " &
7350 """Ada.Interrupts.Interrupt_'I'D""", Arg1);
7356 case Chars (Get_Pragma_Arg (Arg2)) is
7357 when Name_Runtime => State_Type := 'r';
7358 when Name_System => State_Type := 's';
7359 when Name_User => State_Type := 'u';
7362 Error_Pragma_Arg ("invalid interrupt state", Arg2);
7365 -- Check if entry is already stored
7367 IST_Num := Interrupt_States.First;
7369 -- If entry not found, add it
7371 if IST_Num > Interrupt_States.Last then
7372 Interrupt_States.Append
7373 ((Interrupt_Number => UI_To_Int (Int_Val),
7374 Interrupt_State => State_Type,
7375 Pragma_Loc => Loc));
7378 -- Case of entry for the same entry
7380 elsif Int_Val = Interrupt_States.Table (IST_Num).
7383 -- If state matches, done, no need to make redundant entry
7386 State_Type = Interrupt_States.Table (IST_Num).
7389 -- Otherwise if state does not match, error
7392 Interrupt_States.Table (IST_Num).Pragma_Loc;
7394 ("state conflicts with that given at #", Arg2);
7398 IST_Num := IST_Num + 1;
7400 end Interrupt_State;
7402 ----------------------
7403 -- Java_Constructor --
7404 ----------------------
7406 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
7408 when Pragma_Java_Constructor => Java_Constructor : declare
7415 Check_Arg_Count (1);
7416 Check_Optional_Identifier (Arg1, Name_Entity);
7417 Check_Arg_Is_Local_Name (Arg1);
7419 Id := Expression (Arg1);
7420 Find_Program_Unit_Name (Id);
7422 -- If we did not find the name, we are done
7424 if Etype (Id) = Any_Type then
7428 Hom_Id := Entity (Id);
7430 -- Loop through homonyms
7433 Def_Id := Get_Base_Subprogram (Hom_Id);
7435 -- The constructor is required to be a function returning
7436 -- an access type whose designated type has convention Java.
7438 if Ekind (Def_Id) = E_Function
7439 and then Ekind (Etype (Def_Id)) in Access_Kind
7442 (Designated_Type (Etype (Def_Id))) = Convention_Java
7445 (Root_Type (Designated_Type (Etype (Def_Id))))
7448 Set_Is_Constructor (Def_Id);
7449 Set_Convention (Def_Id, Convention_Java);
7453 ("pragma% requires function returning a 'Java access type",
7457 Hom_Id := Homonym (Hom_Id);
7459 exit when No (Hom_Id) or else Scope (Hom_Id) /= Current_Scope;
7461 end Java_Constructor;
7463 ----------------------
7464 -- Java_Interface --
7465 ----------------------
7467 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
7469 when Pragma_Java_Interface => Java_Interface : declare
7475 Check_Arg_Count (1);
7476 Check_Optional_Identifier (Arg1, Name_Entity);
7477 Check_Arg_Is_Local_Name (Arg1);
7479 Arg := Expression (Arg1);
7482 if Etype (Arg) = Any_Type then
7486 if not Is_Entity_Name (Arg)
7487 or else not Is_Type (Entity (Arg))
7489 Error_Pragma_Arg ("pragma% requires a type mark", Arg1);
7492 Typ := Underlying_Type (Entity (Arg));
7494 -- For now we simply check some of the semantic constraints
7495 -- on the type. This currently leaves out some restrictions
7496 -- on interface types, namely that the parent type must be
7497 -- java.lang.Object.Typ and that all primitives of the type
7498 -- should be declared abstract. ???
7500 if not Is_Tagged_Type (Typ) or else not Is_Abstract (Typ) then
7501 Error_Pragma_Arg ("pragma% requires an abstract "
7502 & "tagged type", Arg1);
7504 elsif not Has_Discriminants (Typ)
7505 or else Ekind (Etype (First_Discriminant (Typ)))
7506 /= E_Anonymous_Access_Type
7508 not Is_Class_Wide_Type
7509 (Designated_Type (Etype (First_Discriminant (Typ))))
7512 ("type must have a class-wide access discriminant", Arg1);
7520 -- pragma Keep_Names ([On => ] local_NAME);
7522 when Pragma_Keep_Names => Keep_Names : declare
7527 Check_Arg_Count (1);
7528 Check_Optional_Identifier (Arg1, Name_On);
7529 Check_Arg_Is_Local_Name (Arg1);
7531 Arg := Expression (Arg1);
7534 if Etype (Arg) = Any_Type then
7538 if not Is_Entity_Name (Arg)
7539 or else Ekind (Entity (Arg)) /= E_Enumeration_Type
7542 ("pragma% requires a local enumeration type", Arg1);
7545 Set_Discard_Names (Entity (Arg), False);
7552 -- pragma License (RESTRICTED | UNRESTRICTED | GPL | MODIFIED_GPL);
7554 when Pragma_License =>
7556 Check_Arg_Count (1);
7557 Check_No_Identifiers;
7558 Check_Valid_Configuration_Pragma;
7559 Check_Arg_Is_Identifier (Arg1);
7562 Sind : constant Source_File_Index :=
7563 Source_Index (Current_Sem_Unit);
7566 case Chars (Get_Pragma_Arg (Arg1)) is
7568 Set_License (Sind, GPL);
7570 when Name_Modified_GPL =>
7571 Set_License (Sind, Modified_GPL);
7573 when Name_Restricted =>
7574 Set_License (Sind, Restricted);
7576 when Name_Unrestricted =>
7577 Set_License (Sind, Unrestricted);
7580 Error_Pragma_Arg ("invalid license name", Arg1);
7588 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
7590 when Pragma_Link_With => Link_With : declare
7596 if Operating_Mode = Generate_Code
7597 and then In_Extended_Main_Source_Unit (N)
7599 Check_At_Least_N_Arguments (1);
7600 Check_No_Identifiers;
7601 Check_Is_In_Decl_Part_Or_Package_Spec;
7602 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
7606 while Present (Arg) loop
7607 Check_Arg_Is_Static_Expression (Arg, Standard_String);
7609 -- Store argument, converting sequences of spaces
7610 -- to a single null character (this is one of the
7611 -- differences in processing between Link_With
7612 -- and Linker_Options).
7615 C : constant Char_Code := Get_Char_Code (' ');
7616 S : constant String_Id :=
7617 Strval (Expr_Value_S (Expression (Arg)));
7618 L : constant Nat := String_Length (S);
7621 procedure Skip_Spaces;
7622 -- Advance F past any spaces
7624 procedure Skip_Spaces is
7626 while F <= L and then Get_String_Char (S, F) = C loop
7632 Skip_Spaces; -- skip leading spaces
7634 -- Loop through characters, changing any embedded
7635 -- sequence of spaces to a single null character
7636 -- (this is how Link_With/Linker_Options differ)
7639 if Get_String_Char (S, F) = C then
7642 Store_String_Char (ASCII.NUL);
7645 Store_String_Char (Get_String_Char (S, F));
7653 if Present (Arg) then
7654 Store_String_Char (ASCII.NUL);
7658 Store_Linker_Option_String (End_String);
7666 -- pragma Linker_Alias (
7667 -- [Entity =>] LOCAL_NAME
7668 -- [Target =>] static_string_EXPRESSION);
7670 when Pragma_Linker_Alias =>
7672 Check_Arg_Order ((Name_Entity, Name_Target));
7673 Check_Arg_Count (2);
7674 Check_Optional_Identifier (Arg1, Name_Entity);
7675 Check_Optional_Identifier (Arg2, Name_Target);
7676 Check_Arg_Is_Library_Level_Local_Name (Arg1);
7677 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
7679 -- The only processing required is to link this item on to the
7680 -- list of rep items for the given entity. This is accomplished
7681 -- by the call to Rep_Item_Too_Late (when no error is detected
7682 -- and False is returned).
7684 if Rep_Item_Too_Late (Entity (Expression (Arg1)), N) then
7687 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
7690 ------------------------
7691 -- Linker_Constructor --
7692 ------------------------
7694 -- pragma Linker_Constructor (procedure_LOCAL_NAME);
7696 -- Code is shared with Linker_Destructor
7698 -----------------------
7699 -- Linker_Destructor --
7700 -----------------------
7702 -- pragma Linker_Destructor (procedure_LOCAL_NAME);
7704 when Pragma_Linker_Constructor |
7705 Pragma_Linker_Destructor =>
7706 Linker_Constructor : declare
7712 Check_Arg_Count (1);
7713 Check_No_Identifiers;
7714 Check_Arg_Is_Local_Name (Arg1);
7715 Arg1_X := Expression (Arg1);
7717 Proc := Find_Unique_Parameterless_Procedure (Arg1_X, Arg1);
7719 if not Is_Library_Level_Entity (Proc) then
7721 ("argument for pragma% must be library level entity", Arg1);
7724 -- The only processing required is to link this item on to the
7725 -- list of rep items for the given entity. This is accomplished
7726 -- by the call to Rep_Item_Too_Late (when no error is detected
7727 -- and False is returned).
7729 if Rep_Item_Too_Late (Proc, N) then
7732 Set_Has_Gigi_Rep_Item (Proc);
7734 end Linker_Constructor;
7736 --------------------
7737 -- Linker_Options --
7738 --------------------
7740 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
7742 when Pragma_Linker_Options => Linker_Options : declare
7746 Check_Ada_83_Warning;
7747 Check_No_Identifiers;
7748 Check_Arg_Count (1);
7749 Check_Is_In_Decl_Part_Or_Package_Spec;
7751 if Operating_Mode = Generate_Code
7752 and then In_Extended_Main_Source_Unit (N)
7754 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
7755 Start_String (Strval (Expr_Value_S (Expression (Arg1))));
7758 while Present (Arg) loop
7759 Check_Arg_Is_Static_Expression (Arg, Standard_String);
7760 Store_String_Char (ASCII.NUL);
7762 (Strval (Expr_Value_S (Expression (Arg))));
7766 Store_Linker_Option_String (End_String);
7770 --------------------
7771 -- Linker_Section --
7772 --------------------
7774 -- pragma Linker_Section (
7775 -- [Entity =>] LOCAL_NAME
7776 -- [Section =>] static_string_EXPRESSION);
7778 when Pragma_Linker_Section =>
7780 Check_Arg_Order ((Name_Entity, Name_Section));
7781 Check_Arg_Count (2);
7782 Check_Optional_Identifier (Arg1, Name_Entity);
7783 Check_Optional_Identifier (Arg2, Name_Section);
7784 Check_Arg_Is_Library_Level_Local_Name (Arg1);
7785 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
7787 -- The only processing required is to link this item on to the
7788 -- list of rep items for the given entity. This is accomplished
7789 -- by the call to Rep_Item_Too_Late (when no error is detected
7790 -- and False is returned).
7792 if Rep_Item_Too_Late (Entity (Expression (Arg1)), N) then
7795 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
7802 -- pragma List (On | Off)
7804 -- There is nothing to do here, since we did all the processing
7805 -- for this pragma in Par.Prag (so that it works properly even in
7806 -- syntax only mode)
7811 --------------------
7812 -- Locking_Policy --
7813 --------------------
7815 -- pragma Locking_Policy (policy_IDENTIFIER);
7817 when Pragma_Locking_Policy => declare
7821 Check_Ada_83_Warning;
7822 Check_Arg_Count (1);
7823 Check_No_Identifiers;
7824 Check_Arg_Is_Locking_Policy (Arg1);
7825 Check_Valid_Configuration_Pragma;
7826 Get_Name_String (Chars (Expression (Arg1)));
7827 LP := Fold_Upper (Name_Buffer (1));
7829 if Locking_Policy /= ' '
7830 and then Locking_Policy /= LP
7832 Error_Msg_Sloc := Locking_Policy_Sloc;
7833 Error_Pragma ("locking policy incompatible with policy#");
7835 -- Set new policy, but always preserve System_Location since
7836 -- we like the error message with the run time name.
7839 Locking_Policy := LP;
7841 if Locking_Policy_Sloc /= System_Location then
7842 Locking_Policy_Sloc := Loc;
7851 -- pragma Long_Float (D_Float | G_Float);
7853 when Pragma_Long_Float =>
7855 Check_Valid_Configuration_Pragma;
7856 Check_Arg_Count (1);
7857 Check_No_Identifier (Arg1);
7858 Check_Arg_Is_One_Of (Arg1, Name_D_Float, Name_G_Float);
7860 if not OpenVMS_On_Target then
7861 Error_Pragma ("?pragma% ignored (applies only to Open'V'M'S)");
7866 if Chars (Expression (Arg1)) = Name_D_Float then
7867 if Opt.Float_Format_Long = 'G' then
7868 Error_Pragma ("G_Float previously specified");
7871 Opt.Float_Format_Long := 'D';
7873 -- G_Float case (this is the default, does not need overriding)
7876 if Opt.Float_Format_Long = 'D' then
7877 Error_Pragma ("D_Float previously specified");
7880 Opt.Float_Format_Long := 'G';
7883 Set_Standard_Fpt_Formats;
7885 -----------------------
7886 -- Machine_Attribute --
7887 -----------------------
7889 -- pragma Machine_Attribute (
7890 -- [Entity =>] LOCAL_NAME,
7891 -- [Attribute_Name =>] static_string_EXPRESSION
7892 -- [,[Info =>] static_string_EXPRESSION] );
7894 when Pragma_Machine_Attribute => Machine_Attribute : declare
7899 Check_Arg_Order ((Name_Entity, Name_Attribute_Name, Name_Info));
7901 if Arg_Count = 3 then
7902 Check_Optional_Identifier (Arg3, Name_Info);
7903 Check_Arg_Is_Static_Expression (Arg3, Standard_String);
7905 Check_Arg_Count (2);
7908 Check_Optional_Identifier (Arg1, Name_Entity);
7909 Check_Optional_Identifier (Arg2, Name_Attribute_Name);
7910 Check_Arg_Is_Local_Name (Arg1);
7911 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
7912 Def_Id := Entity (Expression (Arg1));
7914 if Is_Access_Type (Def_Id) then
7915 Def_Id := Designated_Type (Def_Id);
7918 if Rep_Item_Too_Early (Def_Id, N) then
7922 Def_Id := Underlying_Type (Def_Id);
7924 -- The only processing required is to link this item on to the
7925 -- list of rep items for the given entity. This is accomplished
7926 -- by the call to Rep_Item_Too_Late (when no error is detected
7927 -- and False is returned).
7929 if Rep_Item_Too_Late (Def_Id, N) then
7932 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
7934 end Machine_Attribute;
7940 -- pragma Main_Storage
7941 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
7943 -- MAIN_STORAGE_OPTION ::=
7944 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
7945 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
7947 when Pragma_Main => Main : declare
7948 Args : Args_List (1 .. 3);
7949 Names : constant Name_List (1 .. 3) := (
7951 Name_Task_Stack_Size_Default,
7952 Name_Time_Slicing_Enabled);
7958 Gather_Associations (Names, Args);
7960 for J in 1 .. 2 loop
7961 if Present (Args (J)) then
7962 Check_Arg_Is_Static_Expression (Args (J), Any_Integer);
7966 if Present (Args (3)) then
7967 Check_Arg_Is_Static_Expression (Args (3), Standard_Boolean);
7971 while Present (Nod) loop
7972 if Nkind (Nod) = N_Pragma
7973 and then Chars (Nod) = Name_Main
7975 Error_Msg_Name_1 := Chars (N);
7976 Error_Msg_N ("duplicate pragma% not permitted", Nod);
7987 -- pragma Main_Storage
7988 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
7990 -- MAIN_STORAGE_OPTION ::=
7991 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
7992 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
7994 when Pragma_Main_Storage => Main_Storage : declare
7995 Args : Args_List (1 .. 2);
7996 Names : constant Name_List (1 .. 2) := (
7997 Name_Working_Storage,
8004 Gather_Associations (Names, Args);
8006 for J in 1 .. 2 loop
8007 if Present (Args (J)) then
8008 Check_Arg_Is_Static_Expression (Args (J), Any_Integer);
8012 Check_In_Main_Program;
8015 while Present (Nod) loop
8016 if Nkind (Nod) = N_Pragma
8017 and then Chars (Nod) = Name_Main_Storage
8019 Error_Msg_Name_1 := Chars (N);
8020 Error_Msg_N ("duplicate pragma% not permitted", Nod);
8031 -- pragma Memory_Size (NUMERIC_LITERAL)
8033 when Pragma_Memory_Size =>
8036 -- Memory size is simply ignored
8038 Check_No_Identifiers;
8039 Check_Arg_Count (1);
8040 Check_Arg_Is_Integer_Literal (Arg1);
8046 -- pragma No_Return (procedure_LOCAL_NAME);
8048 when Pragma_No_Return => No_Return : declare
8055 Check_Arg_Count (1);
8056 Check_No_Identifiers;
8057 Check_Arg_Is_Local_Name (Arg1);
8058 Id := Expression (Arg1);
8061 if not Is_Entity_Name (Id) then
8062 Error_Pragma_Arg ("entity name required", Arg1);
8065 if Etype (Id) = Any_Type then
8073 and then Scope (E) = Current_Scope
8075 if Ekind (E) = E_Procedure
8076 or else Ekind (E) = E_Generic_Procedure
8086 Error_Pragma ("no procedures found for pragma%");
8090 ------------------------
8091 -- No_Strict_Aliasing --
8092 ------------------------
8094 when Pragma_No_Strict_Aliasing => No_Strict_Alias : declare
8099 Check_At_Most_N_Arguments (1);
8101 if Arg_Count = 0 then
8102 Check_Valid_Configuration_Pragma;
8103 Opt.No_Strict_Aliasing := True;
8106 Check_Optional_Identifier (Arg2, Name_Entity);
8107 Check_Arg_Is_Local_Name (Arg1);
8108 E_Id := Entity (Expression (Arg1));
8110 if E_Id = Any_Type then
8112 elsif No (E_Id) or else not Is_Access_Type (E_Id) then
8113 Error_Pragma_Arg ("pragma% requires access type", Arg1);
8116 Set_No_Strict_Aliasing (Implementation_Base_Type (E_Id));
8118 end No_Strict_Alias;
8124 -- pragma Obsolescent [(static_string_EXPRESSION [, Ada_05])];
8126 when Pragma_Obsolescent => Obsolescent : declare
8127 Subp : Node_Or_Entity_Id;
8129 Active : Boolean := True;
8133 Check_At_Most_N_Arguments (2);
8134 Check_No_Identifiers;
8136 -- Check OK placement
8138 -- First possibility is within a declarative region, where the
8139 -- pragma immediately follows a subprogram declaration.
8141 if Present (Prev (N)) then
8144 -- Second possibility, stand alone subprogram declaration with the
8145 -- pragma immediately following the declaration.
8148 and then Nkind (Parent (N)) = N_Compilation_Unit_Aux
8150 Subp := Unit (Parent (Parent (N)));
8152 -- Any other possibility is a misplacement
8158 -- Check correct placement
8160 if Nkind (Subp) /= N_Subprogram_Declaration then
8162 ("pragma% misplaced, must immediately " &
8163 "follow subprogram spec");
8166 -- If OK placement, acquire arguments
8168 Subp := Defining_Entity (Subp);
8170 if Arg_Count >= 1 then
8172 -- Deal with static string argument
8174 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
8175 S := Strval (Expression (Arg1));
8177 for J in 1 .. String_Length (S) loop
8178 if not In_Character_Range (Get_String_Char (S, J)) then
8180 ("pragma% argument does not allow wide characters",
8185 Set_Obsolescent_Warning (Subp, Expression (Arg1));
8187 -- Check for Ada_05 parameter
8189 if Arg_Count /= 1 then
8190 Check_Arg_Count (2);
8193 Argx : constant Node_Id := Get_Pragma_Arg (Arg2);
8196 Check_Arg_Is_Identifier (Argx);
8198 if Chars (Argx) /= Name_Ada_05 then
8199 Error_Msg_Name_2 := Name_Ada_05;
8201 ("only allowed argument for pragma% is %", Argx);
8204 if Ada_Version_Explicit < Ada_05
8205 or else not Warn_On_Ada_2005_Compatibility
8213 -- Set flag if pragma active
8216 Set_Is_Obsolescent (Subp);
8224 -- pragma No_Run_Time
8226 -- Note: this pragma is retained for backwards compatibiltiy.
8227 -- See body of Rtsfind for full details on its handling.
8229 when Pragma_No_Run_Time =>
8231 Check_Valid_Configuration_Pragma;
8232 Check_Arg_Count (0);
8234 No_Run_Time_Mode := True;
8235 Configurable_Run_Time_Mode := True;
8238 Word32 : constant Boolean := Ttypes.System_Word_Size = 32;
8241 Duration_32_Bits_On_Target := True;
8245 Set_Restriction (No_Finalization, N);
8246 Set_Restriction (No_Exception_Handlers, N);
8247 Set_Restriction (Max_Tasks, N, 0);
8248 Set_Restriction (No_Tasking, N);
8250 -----------------------
8251 -- Normalize_Scalars --
8252 -----------------------
8254 -- pragma Normalize_Scalars;
8256 when Pragma_Normalize_Scalars =>
8257 Check_Ada_83_Warning;
8258 Check_Arg_Count (0);
8259 Check_Valid_Configuration_Pragma;
8260 Normalize_Scalars := True;
8261 Init_Or_Norm_Scalars := True;
8267 -- pragma Optimize (Time | Space);
8269 -- The actual check for optimize is done in Gigi. Note that this
8270 -- pragma does not actually change the optimization setting, it
8271 -- simply checks that it is consistent with the pragma.
8273 when Pragma_Optimize =>
8274 Check_No_Identifiers;
8275 Check_Arg_Count (1);
8276 Check_Arg_Is_One_Of (Arg1, Name_Time, Name_Space, Name_Off);
8278 -------------------------
8279 -- Optional_Overriding --
8280 -------------------------
8282 -- These pragmas are treated as part of the previous subprogram
8283 -- declaration, and analyzed immediately after it (see sem_ch6,
8284 -- Check_Overriding_Operation). If the pragma has not been analyzed
8285 -- yet, it appears in the wrong place.
8287 when Pragma_Optional_Overriding =>
8288 Error_Msg_N ("pragma must appear immediately after subprogram", N);
8294 -- pragma Pack (first_subtype_LOCAL_NAME);
8296 when Pragma_Pack => Pack : declare
8297 Assoc : constant Node_Id := Arg1;
8302 Check_No_Identifiers;
8303 Check_Arg_Count (1);
8304 Check_Arg_Is_Local_Name (Arg1);
8306 Type_Id := Expression (Assoc);
8307 Find_Type (Type_Id);
8308 Typ := Entity (Type_Id);
8311 or else Rep_Item_Too_Early (Typ, N)
8315 Typ := Underlying_Type (Typ);
8318 if not Is_Array_Type (Typ) and then not Is_Record_Type (Typ) then
8319 Error_Pragma ("pragma% must specify array or record type");
8322 Check_First_Subtype (Arg1);
8324 if Has_Pragma_Pack (Typ) then
8325 Error_Pragma ("duplicate pragma%, only one allowed");
8327 -- Array type. We set the Has_Pragma_Pack flag, and Is_Packed,
8328 -- but not Has_Non_Standard_Rep, because we don't actually know
8329 -- till freeze time if the array can have packed representation.
8330 -- That's because in the general case we do not know enough about
8331 -- the component type until it in turn is frozen, which certainly
8332 -- happens before the array type is frozen, but not necessarily
8333 -- till that point (i.e. right now it may be unfrozen).
8335 elsif Is_Array_Type (Typ) then
8336 if Has_Aliased_Components (Base_Type (Typ)) then
8338 ("pragma% ignored, cannot pack aliased components?");
8340 elsif Has_Atomic_Components (Typ)
8341 or else Is_Atomic (Component_Type (Typ))
8344 ("?pragma% ignored, cannot pack atomic components");
8346 elsif not Rep_Item_Too_Late (Typ, N) then
8347 Set_Is_Packed (Base_Type (Typ));
8348 Set_Has_Pragma_Pack (Base_Type (Typ));
8349 Set_Has_Non_Standard_Rep (Base_Type (Typ));
8352 -- Record type. For record types, the pack is always effective
8354 else pragma Assert (Is_Record_Type (Typ));
8355 if not Rep_Item_Too_Late (Typ, N) then
8356 Set_Has_Pragma_Pack (Base_Type (Typ));
8357 Set_Is_Packed (Base_Type (Typ));
8358 Set_Has_Non_Standard_Rep (Base_Type (Typ));
8369 -- There is nothing to do here, since we did all the processing
8370 -- for this pragma in Par.Prag (so that it works properly even in
8371 -- syntax only mode)
8380 -- pragma Passive [(PASSIVE_FORM)];
8382 -- PASSIVE_FORM ::= Semaphore | No
8384 when Pragma_Passive =>
8387 if Nkind (Parent (N)) /= N_Task_Definition then
8388 Error_Pragma ("pragma% must be within task definition");
8391 if Arg_Count /= 0 then
8392 Check_Arg_Count (1);
8393 Check_Arg_Is_One_Of (Arg1, Name_Semaphore, Name_No);
8400 -- pragma Polling (ON | OFF);
8402 when Pragma_Polling =>
8404 Check_Arg_Count (1);
8405 Check_No_Identifiers;
8406 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
8407 Polling_Required := (Chars (Expression (Arg1)) = Name_On);
8409 --------------------
8410 -- Persistent_BSS --
8411 --------------------
8413 when Pragma_Persistent_BSS => Persistent_BSS : declare
8420 Check_At_Most_N_Arguments (1);
8422 -- Case of application to specific object (one argument)
8424 if Arg_Count = 1 then
8425 Check_Arg_Is_Library_Level_Local_Name (Arg1);
8427 if not Is_Entity_Name (Expression (Arg1))
8429 (Ekind (Entity (Expression (Arg1))) /= E_Variable
8430 and then Ekind (Entity (Expression (Arg1))) /= E_Constant)
8432 Error_Pragma_Arg ("pragma% only applies to objects", Arg1);
8435 Ent := Entity (Expression (Arg1));
8436 Decl := Parent (Ent);
8438 if Rep_Item_Too_Late (Ent, N) then
8442 if Present (Expression (Decl)) then
8444 ("object for pragma% cannot have initialization", Arg1);
8447 if not Is_Potentially_Persistent_Type (Etype (Ent)) then
8449 ("object type for pragma% is not potentially persistent",
8454 Make_Linker_Section_Pragma
8455 (Ent, Sloc (N), ".persistent.bss");
8456 Insert_After (N, Prag);
8459 -- Case of use as configuration pragma with no arguments
8462 Check_Valid_Configuration_Pragma;
8463 Persistent_BSS_Mode := True;
8471 -- pragma Preelaborate [(library_unit_NAME)];
8473 -- Set the flag Is_Preelaborated of program unit name entity
8475 when Pragma_Preelaborate => Preelaborate : declare
8476 Pa : constant Node_Id := Parent (N);
8477 Pk : constant Node_Kind := Nkind (Pa);
8481 Check_Ada_83_Warning;
8482 Check_Valid_Library_Unit_Pragma;
8484 if Nkind (N) = N_Null_Statement then
8488 Ent := Find_Lib_Unit_Name;
8490 -- This filters out pragmas inside generic parent then
8491 -- show up inside instantiation
8494 and then not (Pk = N_Package_Specification
8495 and then Present (Generic_Parent (Pa)))
8497 if not Debug_Flag_U then
8498 Set_Is_Preelaborated (Ent);
8499 Set_Suppress_Elaboration_Warnings (Ent);
8504 ---------------------
8505 -- Preelaborate_05 --
8506 ---------------------
8508 -- pragma Preelaborate_05 [(library_unit_NAME)];
8510 -- This pragma is useable only in GNAT_Mode, where it is used like
8511 -- pragma Preelaborate but it is only effective in Ada 2005 mode
8512 -- (otherwise it is ignored). This is used to implement AI-362 which
8513 -- recategorizes some run-time packages in Ada 2005 mode.
8515 when Pragma_Preelaborate_05 => Preelaborate_05 : declare
8520 Check_Valid_Library_Unit_Pragma;
8522 if not GNAT_Mode then
8523 Error_Pragma ("pragma% only available in GNAT mode");
8526 if Nkind (N) = N_Null_Statement then
8530 -- This is one of the few cases where we need to test the value of
8531 -- Ada_Version_Explicit rather than Ada_Version (which is always
8532 -- set to Ada_05 in a predefined unit), we need to know the
8533 -- explicit version set to know if this pragma is active.
8535 if Ada_Version_Explicit >= Ada_05 then
8536 Ent := Find_Lib_Unit_Name;
8537 Set_Is_Preelaborated (Ent);
8538 Set_Suppress_Elaboration_Warnings (Ent);
8540 end Preelaborate_05;
8546 -- pragma Priority (EXPRESSION);
8548 when Pragma_Priority => Priority : declare
8549 P : constant Node_Id := Parent (N);
8553 Check_No_Identifiers;
8554 Check_Arg_Count (1);
8558 if Nkind (P) = N_Subprogram_Body then
8559 Check_In_Main_Program;
8561 Arg := Expression (Arg1);
8562 Analyze_And_Resolve (Arg, Standard_Integer);
8566 if not Is_Static_Expression (Arg) then
8567 Flag_Non_Static_Expr
8568 ("main subprogram priority is not static!", Arg);
8571 -- If constraint error, then we already signalled an error
8573 elsif Raises_Constraint_Error (Arg) then
8576 -- Otherwise check in range
8580 Val : constant Uint := Expr_Value (Arg);
8584 or else Val > Expr_Value (Expression
8585 (Parent (RTE (RE_Max_Priority))))
8588 ("main subprogram priority is out of range", Arg1);
8594 (Current_Sem_Unit, UI_To_Int (Expr_Value (Arg)));
8596 -- Task or Protected, must be of type Integer
8598 elsif Nkind (P) = N_Protected_Definition
8600 Nkind (P) = N_Task_Definition
8602 Arg := Expression (Arg1);
8604 -- The expression must be analyzed in the special manner
8605 -- described in "Handling of Default and Per-Object
8606 -- Expressions" in sem.ads.
8608 Analyze_Per_Use_Expression (Arg, Standard_Integer);
8610 if not Is_Static_Expression (Arg) then
8611 Check_Restriction (Static_Priorities, Arg);
8614 -- Anything else is incorrect
8620 if Has_Priority_Pragma (P) then
8621 Error_Pragma ("duplicate pragma% not allowed");
8623 Set_Has_Priority_Pragma (P, True);
8625 if Nkind (P) = N_Protected_Definition
8627 Nkind (P) = N_Task_Definition
8629 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
8630 -- exp_ch9 should use this ???
8639 -- pragma Profile (profile_IDENTIFIER);
8641 -- profile_IDENTIFIER => Protected | Ravenscar
8643 when Pragma_Profile =>
8644 Check_Arg_Count (1);
8645 Check_Valid_Configuration_Pragma;
8646 Check_No_Identifiers;
8649 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
8651 if Chars (Argx) = Name_Ravenscar then
8652 Set_Ravenscar_Profile (N);
8654 elsif Chars (Argx) = Name_Restricted then
8655 Set_Profile_Restrictions (Restricted, N, Warn => False);
8657 Error_Pragma_Arg ("& is not a valid profile", Argx);
8661 ----------------------
8662 -- Profile_Warnings --
8663 ----------------------
8665 -- pragma Profile_Warnings (profile_IDENTIFIER);
8667 -- profile_IDENTIFIER => Protected | Ravenscar
8669 when Pragma_Profile_Warnings =>
8671 Check_Arg_Count (1);
8672 Check_Valid_Configuration_Pragma;
8673 Check_No_Identifiers;
8676 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
8678 if Chars (Argx) = Name_Ravenscar then
8679 Set_Profile_Restrictions (Ravenscar, N, Warn => True);
8681 elsif Chars (Argx) = Name_Restricted then
8682 Set_Profile_Restrictions (Restricted, N, Warn => True);
8684 Error_Pragma_Arg ("& is not a valid profile", Argx);
8688 --------------------------
8689 -- Propagate_Exceptions --
8690 --------------------------
8692 -- pragma Propagate_Exceptions;
8694 when Pragma_Propagate_Exceptions =>
8696 Check_Arg_Count (0);
8698 if In_Extended_Main_Source_Unit (N) then
8699 Propagate_Exceptions := True;
8706 -- pragma Psect_Object (
8707 -- [Internal =>] LOCAL_NAME,
8708 -- [, [External =>] EXTERNAL_SYMBOL]
8709 -- [, [Size =>] EXTERNAL_SYMBOL]);
8711 when Pragma_Psect_Object | Pragma_Common_Object =>
8712 Psect_Object : declare
8713 Args : Args_List (1 .. 3);
8714 Names : constant Name_List (1 .. 3) := (
8719 Internal : Node_Id renames Args (1);
8720 External : Node_Id renames Args (2);
8721 Size : Node_Id renames Args (3);
8725 procedure Check_Too_Long (Arg : Node_Id);
8726 -- Posts message if the argument is an identifier with more
8727 -- than 31 characters, or a string literal with more than
8728 -- 31 characters, and we are operating under VMS
8730 --------------------
8731 -- Check_Too_Long --
8732 --------------------
8734 procedure Check_Too_Long (Arg : Node_Id) is
8735 X : constant Node_Id := Original_Node (Arg);
8738 if Nkind (X) /= N_String_Literal
8740 Nkind (X) /= N_Identifier
8743 ("inappropriate argument for pragma %", Arg);
8746 if OpenVMS_On_Target then
8747 if (Nkind (X) = N_String_Literal
8748 and then String_Length (Strval (X)) > 31)
8750 (Nkind (X) = N_Identifier
8751 and then Length_Of_Name (Chars (X)) > 31)
8754 ("argument for pragma % is longer than 31 characters",
8760 -- Start of processing for Common_Object/Psect_Object
8764 Gather_Associations (Names, Args);
8765 Process_Extended_Import_Export_Internal_Arg (Internal);
8767 Def_Id := Entity (Internal);
8769 if Ekind (Def_Id) /= E_Constant
8770 and then Ekind (Def_Id) /= E_Variable
8773 ("pragma% must designate an object", Internal);
8776 Check_Too_Long (Internal);
8778 if Is_Imported (Def_Id) or else Is_Exported (Def_Id) then
8780 ("cannot use pragma% for imported/exported object",
8784 if Is_Concurrent_Type (Etype (Internal)) then
8786 ("cannot specify pragma % for task/protected object",
8790 if Has_Rep_Pragma (Def_Id, Name_Common_Object)
8792 Has_Rep_Pragma (Def_Id, Name_Psect_Object)
8794 Error_Msg_N ("?duplicate Common/Psect_Object pragma", N);
8797 if Ekind (Def_Id) = E_Constant then
8799 ("cannot specify pragma % for a constant", Internal);
8802 if Is_Record_Type (Etype (Internal)) then
8808 Ent := First_Entity (Etype (Internal));
8809 while Present (Ent) loop
8810 Decl := Declaration_Node (Ent);
8812 if Ekind (Ent) = E_Component
8813 and then Nkind (Decl) = N_Component_Declaration
8814 and then Present (Expression (Decl))
8815 and then Warn_On_Export_Import
8818 ("?object for pragma % has defaults", Internal);
8828 if Present (Size) then
8829 Check_Too_Long (Size);
8832 if Present (External) then
8833 Check_Arg_Is_External_Name (External);
8834 Check_Too_Long (External);
8837 -- If all error tests pass, link pragma on to the rep item chain
8839 Record_Rep_Item (Def_Id, N);
8846 -- pragma Pure [(library_unit_NAME)];
8848 when Pragma_Pure => Pure : declare
8852 Check_Ada_83_Warning;
8853 Check_Valid_Library_Unit_Pragma;
8855 if Nkind (N) = N_Null_Statement then
8859 Ent := Find_Lib_Unit_Name;
8861 Set_Suppress_Elaboration_Warnings (Ent);
8868 -- pragma Pure_05 [(library_unit_NAME)];
8870 -- This pragma is useable only in GNAT_Mode, where it is used like
8871 -- pragma Pure but it is only effective in Ada 2005 mode (otherwise
8872 -- it is ignored). It may be used after a pragma Preelaborate, in
8873 -- which case it overrides the effect of the pragma Preelaborate.
8874 -- This is used to implement AI-362 which recategorizes some run-time
8875 -- packages in Ada 2005 mode.
8877 when Pragma_Pure_05 => Pure_05 : declare
8882 Check_Valid_Library_Unit_Pragma;
8884 if not GNAT_Mode then
8885 Error_Pragma ("pragma% only available in GNAT mode");
8887 if Nkind (N) = N_Null_Statement then
8891 -- This is one of the few cases where we need to test the value of
8892 -- Ada_Version_Explicit rather than Ada_Version (which is always
8893 -- set to Ada_05 in a predefined unit), we need to know the
8894 -- explicit version set to know if this pragma is active.
8896 if Ada_Version_Explicit >= Ada_05 then
8897 Ent := Find_Lib_Unit_Name;
8898 Set_Is_Preelaborated (Ent, False);
8900 Set_Suppress_Elaboration_Warnings (Ent);
8908 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
8910 when Pragma_Pure_Function => Pure_Function : declare
8914 Effective : Boolean := False;
8918 Check_Arg_Count (1);
8919 Check_Optional_Identifier (Arg1, Name_Entity);
8920 Check_Arg_Is_Local_Name (Arg1);
8921 E_Id := Expression (Arg1);
8923 if Error_Posted (E_Id) then
8927 -- Loop through homonyms (overloadings) of referenced entity
8933 Def_Id := Get_Base_Subprogram (E);
8935 if Ekind (Def_Id) /= E_Function
8936 and then Ekind (Def_Id) /= E_Generic_Function
8937 and then Ekind (Def_Id) /= E_Operator
8940 ("pragma% requires a function name", Arg1);
8943 Set_Is_Pure (Def_Id);
8945 if not Has_Pragma_Pure_Function (Def_Id) then
8946 Set_Has_Pragma_Pure_Function (Def_Id);
8951 exit when No (E) or else Scope (E) /= Current_Scope;
8955 and then Warn_On_Redundant_Constructs
8957 Error_Msg_NE ("pragma Pure_Function on& is redundant?",
8963 --------------------
8964 -- Queuing_Policy --
8965 --------------------
8967 -- pragma Queuing_Policy (policy_IDENTIFIER);
8969 when Pragma_Queuing_Policy => declare
8973 Check_Ada_83_Warning;
8974 Check_Arg_Count (1);
8975 Check_No_Identifiers;
8976 Check_Arg_Is_Queuing_Policy (Arg1);
8977 Check_Valid_Configuration_Pragma;
8978 Get_Name_String (Chars (Expression (Arg1)));
8979 QP := Fold_Upper (Name_Buffer (1));
8981 if Queuing_Policy /= ' '
8982 and then Queuing_Policy /= QP
8984 Error_Msg_Sloc := Queuing_Policy_Sloc;
8985 Error_Pragma ("queuing policy incompatible with policy#");
8987 -- Set new policy, but always preserve System_Location since
8988 -- we like the error message with the run time name.
8991 Queuing_Policy := QP;
8993 if Queuing_Policy_Sloc /= System_Location then
8994 Queuing_Policy_Sloc := Loc;
8999 ---------------------------
9000 -- Remote_Call_Interface --
9001 ---------------------------
9003 -- pragma Remote_Call_Interface [(library_unit_NAME)];
9005 when Pragma_Remote_Call_Interface => Remote_Call_Interface : declare
9006 Cunit_Node : Node_Id;
9007 Cunit_Ent : Entity_Id;
9011 Check_Ada_83_Warning;
9012 Check_Valid_Library_Unit_Pragma;
9014 if Nkind (N) = N_Null_Statement then
9018 Cunit_Node := Cunit (Current_Sem_Unit);
9019 K := Nkind (Unit (Cunit_Node));
9020 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
9022 if K = N_Package_Declaration
9023 or else K = N_Generic_Package_Declaration
9024 or else K = N_Subprogram_Declaration
9025 or else K = N_Generic_Subprogram_Declaration
9026 or else (K = N_Subprogram_Body
9027 and then Acts_As_Spec (Unit (Cunit_Node)))
9032 "pragma% must apply to package or subprogram declaration");
9035 Set_Is_Remote_Call_Interface (Cunit_Ent);
9036 end Remote_Call_Interface;
9042 -- pragma Remote_Types [(library_unit_NAME)];
9044 when Pragma_Remote_Types => Remote_Types : declare
9045 Cunit_Node : Node_Id;
9046 Cunit_Ent : Entity_Id;
9049 Check_Ada_83_Warning;
9050 Check_Valid_Library_Unit_Pragma;
9052 if Nkind (N) = N_Null_Statement then
9056 Cunit_Node := Cunit (Current_Sem_Unit);
9057 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
9059 if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration
9061 Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration
9064 "pragma% can only apply to a package declaration");
9067 Set_Is_Remote_Types (Cunit_Ent);
9074 -- pragma Ravenscar;
9076 when Pragma_Ravenscar =>
9078 Check_Arg_Count (0);
9079 Check_Valid_Configuration_Pragma;
9080 Set_Ravenscar_Profile (N);
9082 if Warn_On_Obsolescent_Feature then
9084 ("pragma Ravenscar is an obsolescent feature?", N);
9086 ("|use pragma Profile (Ravenscar) instead", N);
9089 -------------------------
9090 -- Restricted_Run_Time --
9091 -------------------------
9093 -- pragma Restricted_Run_Time;
9095 when Pragma_Restricted_Run_Time =>
9097 Check_Arg_Count (0);
9098 Check_Valid_Configuration_Pragma;
9099 Set_Profile_Restrictions (Restricted, N, Warn => False);
9101 if Warn_On_Obsolescent_Feature then
9103 ("pragma Restricted_Run_Time is an obsolescent feature?", N);
9105 ("|use pragma Profile (Restricted) instead", N);
9112 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
9115 -- restriction_IDENTIFIER
9116 -- | restriction_parameter_IDENTIFIER => EXPRESSION
9118 when Pragma_Restrictions =>
9119 Process_Restrictions_Or_Restriction_Warnings;
9121 --------------------------
9122 -- Restriction_Warnings --
9123 --------------------------
9125 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
9128 -- restriction_IDENTIFIER
9129 -- | restriction_parameter_IDENTIFIER => EXPRESSION
9131 when Pragma_Restriction_Warnings =>
9132 Process_Restrictions_Or_Restriction_Warnings;
9138 -- pragma Reviewable;
9140 when Pragma_Reviewable =>
9141 Check_Ada_83_Warning;
9142 Check_Arg_Count (0);
9148 -- pragma Share_Generic (NAME {, NAME});
9150 when Pragma_Share_Generic =>
9152 Process_Generic_List;
9158 -- pragma Shared (LOCAL_NAME);
9160 when Pragma_Shared =>
9162 Process_Atomic_Shared_Volatile;
9164 --------------------
9165 -- Shared_Passive --
9166 --------------------
9168 -- pragma Shared_Passive [(library_unit_NAME)];
9170 -- Set the flag Is_Shared_Passive of program unit name entity
9172 when Pragma_Shared_Passive => Shared_Passive : declare
9173 Cunit_Node : Node_Id;
9174 Cunit_Ent : Entity_Id;
9177 Check_Ada_83_Warning;
9178 Check_Valid_Library_Unit_Pragma;
9180 if Nkind (N) = N_Null_Statement then
9184 Cunit_Node := Cunit (Current_Sem_Unit);
9185 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
9187 if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration
9189 Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration
9192 "pragma% can only apply to a package declaration");
9195 Set_Is_Shared_Passive (Cunit_Ent);
9198 ----------------------
9199 -- Source_File_Name --
9200 ----------------------
9202 -- There are five forms for this pragma:
9204 -- pragma Source_File_Name (
9205 -- [UNIT_NAME =>] unit_NAME,
9206 -- BODY_FILE_NAME => STRING_LITERAL
9207 -- [, [INDEX =>] INTEGER_LITERAL]);
9209 -- pragma Source_File_Name (
9210 -- [UNIT_NAME =>] unit_NAME,
9211 -- SPEC_FILE_NAME => STRING_LITERAL
9212 -- [, [INDEX =>] INTEGER_LITERAL]);
9214 -- pragma Source_File_Name (
9215 -- BODY_FILE_NAME => STRING_LITERAL
9216 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9217 -- [, CASING => CASING_SPEC]);
9219 -- pragma Source_File_Name (
9220 -- SPEC_FILE_NAME => STRING_LITERAL
9221 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9222 -- [, CASING => CASING_SPEC]);
9224 -- pragma Source_File_Name (
9225 -- SUBUNIT_FILE_NAME => STRING_LITERAL
9226 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9227 -- [, CASING => CASING_SPEC]);
9229 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
9231 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
9232 -- Source_File_Name (SFN), however their usage is exclusive:
9233 -- SFN can only be used when no project file is used, while
9234 -- SFNP can only be used when a project file is used.
9236 -- No processing here. Processing was completed during parsing,
9237 -- since we need to have file names set as early as possible.
9238 -- Units are loaded well before semantic processing starts.
9240 -- The only processing we defer to this point is the check
9241 -- for correct placement.
9243 when Pragma_Source_File_Name =>
9245 Check_Valid_Configuration_Pragma;
9247 ------------------------------
9248 -- Source_File_Name_Project --
9249 ------------------------------
9251 -- See Source_File_Name for syntax
9253 -- No processing here. Processing was completed during parsing,
9254 -- since we need to have file names set as early as possible.
9255 -- Units are loaded well before semantic processing starts.
9257 -- The only processing we defer to this point is the check
9258 -- for correct placement.
9260 when Pragma_Source_File_Name_Project =>
9262 Check_Valid_Configuration_Pragma;
9264 -- Check that a pragma Source_File_Name_Project is used only
9265 -- in a configuration pragmas file.
9267 -- Pragmas Source_File_Name_Project should only be generated
9268 -- by the Project Manager in configuration pragmas files.
9270 -- This is really an ugly test. It seems to depend on some
9271 -- accidental and undocumented property. At the very least
9272 -- it needs to be documented, but it would be better to have
9273 -- a clean way of testing if we are in a configuration file???
9275 if Present (Parent (N)) then
9277 ("pragma% can only appear in a configuration pragmas file");
9280 ----------------------
9281 -- Source_Reference --
9282 ----------------------
9284 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
9286 -- Nothing to do, all processing completed in Par.Prag, since we
9287 -- need the information for possible parser messages that are output
9289 when Pragma_Source_Reference =>
9296 -- pragma Storage_Size (EXPRESSION);
9298 when Pragma_Storage_Size => Storage_Size : declare
9299 P : constant Node_Id := Parent (N);
9303 Check_No_Identifiers;
9304 Check_Arg_Count (1);
9306 -- The expression must be analyzed in the special manner
9307 -- described in "Handling of Default Expressions" in sem.ads.
9309 -- Set In_Default_Expression for per-object case ???
9311 Arg := Expression (Arg1);
9312 Analyze_Per_Use_Expression (Arg, Any_Integer);
9314 if not Is_Static_Expression (Arg) then
9315 Check_Restriction (Static_Storage_Size, Arg);
9318 if Nkind (P) /= N_Task_Definition then
9323 if Has_Storage_Size_Pragma (P) then
9324 Error_Pragma ("duplicate pragma% not allowed");
9326 Set_Has_Storage_Size_Pragma (P, True);
9329 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
9330 -- ??? exp_ch9 should use this!
9338 -- pragma Storage_Unit (NUMERIC_LITERAL);
9340 -- Only permitted argument is System'Storage_Unit value
9342 when Pragma_Storage_Unit =>
9343 Check_No_Identifiers;
9344 Check_Arg_Count (1);
9345 Check_Arg_Is_Integer_Literal (Arg1);
9347 if Intval (Expression (Arg1)) /=
9348 UI_From_Int (Ttypes.System_Storage_Unit)
9350 Error_Msg_Uint_1 := UI_From_Int (Ttypes.System_Storage_Unit);
9352 ("the only allowed argument for pragma% is ^", Arg1);
9355 --------------------
9356 -- Stream_Convert --
9357 --------------------
9359 -- pragma Stream_Convert (
9360 -- [Entity =>] type_LOCAL_NAME,
9361 -- [Read =>] function_NAME,
9362 -- [Write =>] function NAME);
9364 when Pragma_Stream_Convert => Stream_Convert : declare
9366 procedure Check_OK_Stream_Convert_Function (Arg : Node_Id);
9367 -- Check that the given argument is the name of a local
9368 -- function of one argument that is not overloaded earlier
9369 -- in the current local scope. A check is also made that the
9370 -- argument is a function with one parameter.
9372 --------------------------------------
9373 -- Check_OK_Stream_Convert_Function --
9374 --------------------------------------
9376 procedure Check_OK_Stream_Convert_Function (Arg : Node_Id) is
9380 Check_Arg_Is_Local_Name (Arg);
9381 Ent := Entity (Expression (Arg));
9383 if Has_Homonym (Ent) then
9385 ("argument for pragma% may not be overloaded", Arg);
9388 if Ekind (Ent) /= E_Function
9389 or else No (First_Formal (Ent))
9390 or else Present (Next_Formal (First_Formal (Ent)))
9393 ("argument for pragma% must be" &
9394 " function of one argument", Arg);
9396 end Check_OK_Stream_Convert_Function;
9398 -- Start of procecessing for Stream_Convert
9402 Check_Arg_Order ((Name_Entity, Name_Read, Name_Write));
9403 Check_Arg_Count (3);
9404 Check_Optional_Identifier (Arg1, Name_Entity);
9405 Check_Optional_Identifier (Arg2, Name_Read);
9406 Check_Optional_Identifier (Arg3, Name_Write);
9407 Check_Arg_Is_Local_Name (Arg1);
9408 Check_OK_Stream_Convert_Function (Arg2);
9409 Check_OK_Stream_Convert_Function (Arg3);
9412 Typ : constant Entity_Id :=
9413 Underlying_Type (Entity (Expression (Arg1)));
9414 Read : constant Entity_Id := Entity (Expression (Arg2));
9415 Write : constant Entity_Id := Entity (Expression (Arg3));
9418 if Etype (Typ) = Any_Type
9420 Etype (Read) = Any_Type
9422 Etype (Write) = Any_Type
9427 Check_First_Subtype (Arg1);
9429 if Rep_Item_Too_Early (Typ, N)
9431 Rep_Item_Too_Late (Typ, N)
9436 if Underlying_Type (Etype (Read)) /= Typ then
9438 ("incorrect return type for function&", Arg2);
9441 if Underlying_Type (Etype (First_Formal (Write))) /= Typ then
9443 ("incorrect parameter type for function&", Arg3);
9446 if Underlying_Type (Etype (First_Formal (Read))) /=
9447 Underlying_Type (Etype (Write))
9450 ("result type of & does not match Read parameter type",
9456 -------------------------
9457 -- Style_Checks (GNAT) --
9458 -------------------------
9460 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
9462 -- This is processed by the parser since some of the style
9463 -- checks take place during source scanning and parsing. This
9464 -- means that we don't need to issue error messages here.
9466 when Pragma_Style_Checks => Style_Checks : declare
9467 A : constant Node_Id := Expression (Arg1);
9473 Check_No_Identifiers;
9475 -- Two argument form
9477 if Arg_Count = 2 then
9478 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
9485 E_Id := Expression (Arg2);
9488 if not Is_Entity_Name (E_Id) then
9490 ("second argument of pragma% must be entity name",
9500 Set_Suppress_Style_Checks (E,
9501 (Chars (Expression (Arg1)) = Name_Off));
9502 exit when No (Homonym (E));
9508 -- One argument form
9511 Check_Arg_Count (1);
9513 if Nkind (A) = N_String_Literal then
9517 Slen : constant Natural := Natural (String_Length (S));
9518 Options : String (1 .. Slen);
9524 C := Get_String_Char (S, Int (J));
9525 exit when not In_Character_Range (C);
9526 Options (J) := Get_Character (C);
9529 Set_Style_Check_Options (Options);
9537 elsif Nkind (A) = N_Identifier then
9539 if Chars (A) = Name_All_Checks then
9540 Set_Default_Style_Check_Options;
9542 elsif Chars (A) = Name_On then
9543 Style_Check := True;
9545 elsif Chars (A) = Name_Off then
9546 Style_Check := False;
9557 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
9559 when Pragma_Subtitle =>
9561 Check_Arg_Count (1);
9562 Check_Optional_Identifier (Arg1, Name_Subtitle);
9563 Check_Arg_Is_String_Literal (Arg1);
9569 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
9571 when Pragma_Suppress =>
9572 Process_Suppress_Unsuppress (True);
9578 -- pragma Suppress_All;
9580 -- The only check made here is that the pragma appears in the
9581 -- proper place, i.e. following a compilation unit. If indeed
9582 -- it appears in this context, then the parser has already
9583 -- inserted an equivalent pragma Suppress (All_Checks) to get
9584 -- the required effect.
9586 when Pragma_Suppress_All =>
9588 Check_Arg_Count (0);
9590 if Nkind (Parent (N)) /= N_Compilation_Unit_Aux
9591 or else not Is_List_Member (N)
9592 or else List_Containing (N) /= Pragmas_After (Parent (N))
9595 ("misplaced pragma%, must follow compilation unit");
9598 -------------------------
9599 -- Suppress_Debug_Info --
9600 -------------------------
9602 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
9604 when Pragma_Suppress_Debug_Info =>
9606 Check_Arg_Count (1);
9607 Check_Optional_Identifier (Arg1, Name_Entity);
9608 Check_Arg_Is_Local_Name (Arg1);
9609 Set_Debug_Info_Off (Entity (Get_Pragma_Arg (Arg1)));
9611 ----------------------------------
9612 -- Suppress_Exception_Locations --
9613 ----------------------------------
9615 -- pragma Suppress_Exception_Locations;
9617 when Pragma_Suppress_Exception_Locations =>
9619 Check_Arg_Count (0);
9620 Check_Valid_Configuration_Pragma;
9621 Exception_Locations_Suppressed := True;
9623 -----------------------------
9624 -- Suppress_Initialization --
9625 -----------------------------
9627 -- pragma Suppress_Initialization ([Entity =>] type_Name);
9629 when Pragma_Suppress_Initialization => Suppress_Init : declare
9635 Check_Arg_Count (1);
9636 Check_Optional_Identifier (Arg1, Name_Entity);
9637 Check_Arg_Is_Local_Name (Arg1);
9639 E_Id := Expression (Arg1);
9641 if Etype (E_Id) = Any_Type then
9648 if Is_Incomplete_Or_Private_Type (E) then
9649 if No (Full_View (Base_Type (E))) then
9651 ("argument of pragma% cannot be an incomplete type",
9654 Set_Suppress_Init_Proc (Full_View (Base_Type (E)));
9657 Set_Suppress_Init_Proc (Base_Type (E));
9662 ("pragma% requires argument that is a type name", Arg1);
9670 -- pragma System_Name (DIRECT_NAME);
9672 -- Syntax check: one argument, which must be the identifier GNAT
9673 -- or the identifier GCC, no other identifiers are acceptable.
9675 when Pragma_System_Name =>
9676 Check_No_Identifiers;
9677 Check_Arg_Count (1);
9678 Check_Arg_Is_One_Of (Arg1, Name_Gcc, Name_Gnat);
9680 -----------------------------
9681 -- Task_Dispatching_Policy --
9682 -----------------------------
9684 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
9686 when Pragma_Task_Dispatching_Policy => declare
9690 Check_Ada_83_Warning;
9691 Check_Arg_Count (1);
9692 Check_No_Identifiers;
9693 Check_Arg_Is_Task_Dispatching_Policy (Arg1);
9694 Check_Valid_Configuration_Pragma;
9695 Get_Name_String (Chars (Expression (Arg1)));
9696 DP := Fold_Upper (Name_Buffer (1));
9698 if Task_Dispatching_Policy /= ' '
9699 and then Task_Dispatching_Policy /= DP
9701 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
9703 ("task dispatching policy incompatible with policy#");
9705 -- Set new policy, but always preserve System_Location since
9706 -- we like the error message with the run time name.
9709 Task_Dispatching_Policy := DP;
9711 if Task_Dispatching_Policy_Sloc /= System_Location then
9712 Task_Dispatching_Policy_Sloc := Loc;
9721 -- pragma Task_Info (EXPRESSION);
9723 when Pragma_Task_Info => Task_Info : declare
9724 P : constant Node_Id := Parent (N);
9729 if Nkind (P) /= N_Task_Definition then
9730 Error_Pragma ("pragma% must appear in task definition");
9733 Check_No_Identifiers;
9734 Check_Arg_Count (1);
9736 Analyze_And_Resolve (Expression (Arg1), RTE (RE_Task_Info_Type));
9738 if Etype (Expression (Arg1)) = Any_Type then
9742 if Has_Task_Info_Pragma (P) then
9743 Error_Pragma ("duplicate pragma% not allowed");
9745 Set_Has_Task_Info_Pragma (P, True);
9753 -- pragma Task_Name (string_EXPRESSION);
9755 when Pragma_Task_Name => Task_Name : declare
9756 -- pragma Priority (EXPRESSION);
9758 P : constant Node_Id := Parent (N);
9762 Check_No_Identifiers;
9763 Check_Arg_Count (1);
9765 Arg := Expression (Arg1);
9766 Analyze_And_Resolve (Arg, Standard_String);
9768 if Nkind (P) /= N_Task_Definition then
9772 if Has_Task_Name_Pragma (P) then
9773 Error_Pragma ("duplicate pragma% not allowed");
9775 Set_Has_Task_Name_Pragma (P, True);
9776 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
9784 -- pragma Task_Storage (
9785 -- [Task_Type =>] LOCAL_NAME,
9786 -- [Top_Guard =>] static_integer_EXPRESSION);
9788 when Pragma_Task_Storage => Task_Storage : declare
9789 Args : Args_List (1 .. 2);
9790 Names : constant Name_List (1 .. 2) := (
9794 Task_Type : Node_Id renames Args (1);
9795 Top_Guard : Node_Id renames Args (2);
9801 Gather_Associations (Names, Args);
9803 if No (Task_Type) then
9805 ("missing task_type argument for pragma%");
9808 Check_Arg_Is_Local_Name (Task_Type);
9810 Ent := Entity (Task_Type);
9812 if not Is_Task_Type (Ent) then
9814 ("argument for pragma% must be task type", Task_Type);
9817 if No (Top_Guard) then
9819 ("pragma% takes two arguments", Task_Type);
9821 Check_Arg_Is_Static_Expression (Top_Guard, Any_Integer);
9824 Check_First_Subtype (Task_Type);
9826 if Rep_Item_Too_Late (Ent, N) then
9835 -- pragma Thread_Body
9836 -- ( [Entity =>] LOCAL_NAME
9837 -- [,[Secondary_Stack_Size =>] static_integer_EXPRESSION]);
9839 when Pragma_Thread_Body => Thread_Body : declare
9846 Check_Arg_Order ((Name_Entity, Name_Secondary_Stack_Size));
9847 Check_At_Least_N_Arguments (1);
9848 Check_At_Most_N_Arguments (2);
9849 Check_Optional_Identifier (Arg1, Name_Entity);
9850 Check_Arg_Is_Local_Name (Arg1);
9852 Id := Expression (Arg1);
9854 if not Is_Entity_Name (Id)
9855 or else not Is_Subprogram (Entity (Id))
9857 Error_Pragma_Arg ("subprogram name required", Arg1);
9862 -- Go to renamed subprogram if present, since Thread_Body applies
9863 -- to the actual renamed entity, not to the renaming entity.
9865 if Present (Alias (E))
9866 and then Nkind (Parent (Declaration_Node (E))) =
9867 N_Subprogram_Renaming_Declaration
9872 -- Various error checks
9874 if Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Body then
9876 ("pragma% requires separate spec and must come before body");
9878 elsif Rep_Item_Too_Early (E, N)
9880 Rep_Item_Too_Late (E, N)
9884 elsif Is_Thread_Body (E) then
9886 ("only one thread body pragma allowed", Arg1);
9888 elsif Present (Homonym (E))
9889 and then Scope (Homonym (E)) = Current_Scope
9892 ("thread body subprogram must not be overloaded", Arg1);
9895 Set_Is_Thread_Body (E);
9897 -- Deal with secondary stack argument
9899 if Arg_Count = 2 then
9900 Check_Optional_Identifier (Arg2, Name_Secondary_Stack_Size);
9901 SS := Expression (Arg2);
9902 Analyze_And_Resolve (SS, Any_Integer);
9910 -- pragma Time_Slice (static_duration_EXPRESSION);
9912 when Pragma_Time_Slice => Time_Slice : declare
9918 Check_Arg_Count (1);
9919 Check_No_Identifiers;
9920 Check_In_Main_Program;
9921 Check_Arg_Is_Static_Expression (Arg1, Standard_Duration);
9923 if not Error_Posted (Arg1) then
9925 while Present (Nod) loop
9926 if Nkind (Nod) = N_Pragma
9927 and then Chars (Nod) = Name_Time_Slice
9929 Error_Msg_Name_1 := Chars (N);
9930 Error_Msg_N ("duplicate pragma% not permitted", Nod);
9937 -- Process only if in main unit
9939 if Get_Source_Unit (Loc) = Main_Unit then
9940 Opt.Time_Slice_Set := True;
9941 Val := Expr_Value_R (Expression (Arg1));
9943 if Val <= Ureal_0 then
9944 Opt.Time_Slice_Value := 0;
9946 elsif Val > UR_From_Uint (UI_From_Int (1000)) then
9947 Opt.Time_Slice_Value := 1_000_000_000;
9950 Opt.Time_Slice_Value :=
9951 UI_To_Int (UR_To_Uint (Val * UI_From_Int (1_000_000)));
9960 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
9962 -- TITLING_OPTION ::=
9963 -- [Title =>] STRING_LITERAL
9964 -- | [Subtitle =>] STRING_LITERAL
9966 when Pragma_Title => Title : declare
9967 Args : Args_List (1 .. 2);
9968 Names : constant Name_List (1 .. 2) := (
9974 Gather_Associations (Names, Args);
9976 for J in 1 .. 2 loop
9977 if Present (Args (J)) then
9978 Check_Arg_Is_String_Literal (Args (J));
9983 ---------------------
9984 -- Unchecked_Union --
9985 ---------------------
9987 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
9989 when Pragma_Unchecked_Union => Unchecked_Union : declare
9990 Assoc : constant Node_Id := Arg1;
9991 Type_Id : constant Node_Id := Expression (Assoc);
10002 Check_No_Identifiers;
10003 Check_Arg_Count (1);
10004 Check_Arg_Is_Local_Name (Arg1);
10006 Find_Type (Type_Id);
10007 Typ := Entity (Type_Id);
10010 or else Rep_Item_Too_Early (Typ, N)
10014 Typ := Underlying_Type (Typ);
10017 if Rep_Item_Too_Late (Typ, N) then
10021 Check_First_Subtype (Arg1);
10023 -- Note remaining cases are references to a type in the current
10024 -- declarative part. If we find an error, we post the error on
10025 -- the relevant type declaration at an appropriate point.
10027 if not Is_Record_Type (Typ) then
10028 Error_Msg_N ("Unchecked_Union must be record type", Typ);
10031 elsif Is_Tagged_Type (Typ) then
10032 Error_Msg_N ("Unchecked_Union must not be tagged", Typ);
10035 elsif Is_Limited_Type (Typ) then
10037 ("Unchecked_Union must not be limited record type", Typ);
10038 Explain_Limited_Type (Typ, Typ);
10042 if not Has_Discriminants (Typ) then
10044 ("Unchecked_Union must have one discriminant", Typ);
10048 Discr := First_Discriminant (Typ);
10050 if Present (Next_Discriminant (Discr)) then
10052 ("Unchecked_Union must have exactly one discriminant",
10053 Next_Discriminant (Discr));
10057 if No (Discriminant_Default_Value (Discr)) then
10059 ("Unchecked_Union discriminant must have default value",
10063 Tdef := Type_Definition (Declaration_Node (Typ));
10064 Clist := Component_List (Tdef);
10066 Comp := First (Component_Items (Clist));
10067 while Present (Comp) loop
10069 Check_Component (Comp);
10074 if No (Clist) or else No (Variant_Part (Clist)) then
10076 ("Unchecked_Union must have variant part",
10081 Vpart := Variant_Part (Clist);
10083 Variant := First (Variants (Vpart));
10084 while Present (Variant) loop
10085 Check_Variant (Variant);
10090 Set_Is_Unchecked_Union (Typ, True);
10091 Set_Convention (Typ, Convention_C);
10093 Set_Has_Unchecked_Union (Base_Type (Typ), True);
10094 Set_Is_Unchecked_Union (Base_Type (Typ), True);
10095 end Unchecked_Union;
10097 ------------------------
10098 -- Unimplemented_Unit --
10099 ------------------------
10101 -- pragma Unimplemented_Unit;
10103 -- Note: this only gives an error if we are generating code,
10104 -- or if we are in a generic library unit (where the pragma
10105 -- appears in the body, not in the spec).
10107 when Pragma_Unimplemented_Unit => Unimplemented_Unit : declare
10108 Cunitent : constant Entity_Id :=
10109 Cunit_Entity (Get_Source_Unit (Loc));
10110 Ent_Kind : constant Entity_Kind :=
10115 Check_Arg_Count (0);
10117 if Operating_Mode = Generate_Code
10118 or else Ent_Kind = E_Generic_Function
10119 or else Ent_Kind = E_Generic_Procedure
10120 or else Ent_Kind = E_Generic_Package
10122 Get_Name_String (Chars (Cunitent));
10123 Set_Casing (Mixed_Case);
10124 Write_Str (Name_Buffer (1 .. Name_Len));
10125 Write_Str (" is not implemented");
10127 raise Unrecoverable_Error;
10129 end Unimplemented_Unit;
10131 --------------------
10132 -- Universal_Data --
10133 --------------------
10135 -- pragma Universal_Data [(library_unit_NAME)];
10137 when Pragma_Universal_Data =>
10140 -- If this is a configuration pragma, then set the universal
10141 -- addressing option, otherwise confirm that the pragma
10142 -- satisfies the requirements of library unit pragma placement
10143 -- and leave it to the GNAAMP back end to detect the pragma
10144 -- (avoids transitive setting of the option due to withed units).
10146 if Is_Configuration_Pragma then
10147 Universal_Addressing_On_AAMP := True;
10149 Check_Valid_Library_Unit_Pragma;
10152 if not AAMP_On_Target then
10153 Error_Pragma ("?pragma% ignored (applies only to AAMP)");
10160 -- pragma Unreferenced (local_Name {, local_Name});
10162 when Pragma_Unreferenced => Unreferenced : declare
10163 Arg_Node : Node_Id;
10164 Arg_Expr : Node_Id;
10165 Arg_Ent : Entity_Id;
10169 Check_At_Least_N_Arguments (1);
10172 while Present (Arg_Node) loop
10173 Check_No_Identifier (Arg_Node);
10175 -- Note that the analyze call done by Check_Arg_Is_Local_Name
10176 -- will in fact generate a reference, so that the entity will
10177 -- have a reference, which will inhibit any warnings about it
10178 -- not being referenced, and also properly show up in the ali
10179 -- file as a reference. But this reference is recorded before
10180 -- the Has_Pragma_Unreferenced flag is set, so that no warning
10181 -- is generated for this reference.
10183 Check_Arg_Is_Local_Name (Arg_Node);
10184 Arg_Expr := Get_Pragma_Arg (Arg_Node);
10186 if Is_Entity_Name (Arg_Expr) then
10187 Arg_Ent := Entity (Arg_Expr);
10189 -- If the entity is overloaded, the pragma applies to the
10190 -- most recent overloading, as documented. In this case,
10191 -- name resolution does not generate a reference, so it
10192 -- must be done here explicitly.
10194 if Is_Overloaded (Arg_Expr) then
10195 Generate_Reference (Arg_Ent, N);
10198 Set_Has_Pragma_Unreferenced (Arg_Ent);
10205 ------------------------------
10206 -- Unreserve_All_Interrupts --
10207 ------------------------------
10209 -- pragma Unreserve_All_Interrupts;
10211 when Pragma_Unreserve_All_Interrupts =>
10213 Check_Arg_Count (0);
10215 if In_Extended_Main_Code_Unit (Main_Unit_Entity) then
10216 Unreserve_All_Interrupts := True;
10223 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
10225 when Pragma_Unsuppress =>
10227 Process_Suppress_Unsuppress (False);
10229 -------------------
10230 -- Use_VADS_Size --
10231 -------------------
10233 -- pragma Use_VADS_Size;
10235 when Pragma_Use_VADS_Size =>
10237 Check_Arg_Count (0);
10238 Check_Valid_Configuration_Pragma;
10239 Use_VADS_Size := True;
10241 ---------------------
10242 -- Validity_Checks --
10243 ---------------------
10245 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
10247 when Pragma_Validity_Checks => Validity_Checks : declare
10248 A : constant Node_Id := Expression (Arg1);
10254 Check_Arg_Count (1);
10255 Check_No_Identifiers;
10257 if Nkind (A) = N_String_Literal then
10261 Slen : constant Natural := Natural (String_Length (S));
10262 Options : String (1 .. Slen);
10268 C := Get_String_Char (S, Int (J));
10269 exit when not In_Character_Range (C);
10270 Options (J) := Get_Character (C);
10273 Set_Validity_Check_Options (Options);
10281 elsif Nkind (A) = N_Identifier then
10283 if Chars (A) = Name_All_Checks then
10284 Set_Validity_Check_Options ("a");
10286 elsif Chars (A) = Name_On then
10287 Validity_Checks_On := True;
10289 elsif Chars (A) = Name_Off then
10290 Validity_Checks_On := False;
10294 end Validity_Checks;
10300 -- pragma Volatile (LOCAL_NAME);
10302 when Pragma_Volatile =>
10303 Process_Atomic_Shared_Volatile;
10305 -------------------------
10306 -- Volatile_Components --
10307 -------------------------
10309 -- pragma Volatile_Components (array_LOCAL_NAME);
10311 -- Volatile is handled by the same circuit as Atomic_Components
10317 -- pragma Warnings (On | Off, [LOCAL_NAME])
10319 when Pragma_Warnings => Warnings : begin
10321 Check_At_Least_N_Arguments (1);
10322 Check_At_Most_N_Arguments (2);
10323 Check_No_Identifiers;
10325 -- One argument case was processed by parser in Par.Prag
10327 if Arg_Count /= 1 then
10328 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
10329 Check_Arg_Count (2);
10336 E_Id := Expression (Arg2);
10339 -- In the expansion of an inlined body, a reference to
10340 -- the formal may be wrapped in a conversion if the actual
10341 -- is a conversion. Retrieve the real entity name.
10343 if (In_Instance_Body
10344 or else In_Inlined_Body)
10345 and then Nkind (E_Id) = N_Unchecked_Type_Conversion
10347 E_Id := Expression (E_Id);
10350 if not Is_Entity_Name (E_Id) then
10352 ("second argument of pragma% must be entity name",
10356 E := Entity (E_Id);
10362 Set_Warnings_Off (E,
10363 (Chars (Expression (Arg1)) = Name_Off));
10365 if Is_Enumeration_Type (E) then
10369 Lit := First_Literal (E);
10370 while Present (Lit) loop
10371 Set_Warnings_Off (Lit);
10372 Next_Literal (Lit);
10377 exit when No (Homonym (E));
10385 -------------------
10386 -- Weak_External --
10387 -------------------
10389 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
10391 when Pragma_Weak_External => Weak_External : declare
10396 Check_Arg_Count (1);
10397 Check_Optional_Identifier (Arg1, Name_Entity);
10398 Check_Arg_Is_Library_Level_Local_Name (Arg1);
10399 Ent := Entity (Expression (Arg1));
10401 if Rep_Item_Too_Early (Ent, N) then
10404 Ent := Underlying_Type (Ent);
10407 -- The only processing required is to link this item on to the
10408 -- list of rep items for the given entity. This is accomplished
10409 -- by the call to Rep_Item_Too_Late (when no error is detected
10410 -- and False is returned).
10412 if Rep_Item_Too_Late (Ent, N) then
10415 Set_Has_Gigi_Rep_Item (Ent);
10419 --------------------
10420 -- Unknown_Pragma --
10421 --------------------
10423 -- Should be impossible, since the case of an unknown pragma is
10424 -- separately processed before the case statement is entered.
10426 when Unknown_Pragma =>
10427 raise Program_Error;
10431 when Pragma_Exit => null;
10432 end Analyze_Pragma;
10434 ---------------------------------
10435 -- Delay_Config_Pragma_Analyze --
10436 ---------------------------------
10438 function Delay_Config_Pragma_Analyze (N : Node_Id) return Boolean is
10440 return Chars (N) = Name_Interrupt_State;
10441 end Delay_Config_Pragma_Analyze;
10443 -------------------------
10444 -- Get_Base_Subprogram --
10445 -------------------------
10447 function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id is
10448 Result : Entity_Id;
10451 -- Follow subprogram renaming chain
10454 while Is_Subprogram (Result)
10456 (Is_Generic_Instance (Result)
10457 or else Nkind (Parent (Declaration_Node (Result))) =
10458 N_Subprogram_Renaming_Declaration)
10459 and then Present (Alias (Result))
10461 Result := Alias (Result);
10465 end Get_Base_Subprogram;
10467 -----------------------------
10468 -- Is_Config_Static_String --
10469 -----------------------------
10471 function Is_Config_Static_String (Arg : Node_Id) return Boolean is
10473 function Add_Config_Static_String (Arg : Node_Id) return Boolean;
10474 -- This is an internal recursive function that is just like the
10475 -- outer function except that it adds the string to the name buffer
10476 -- rather than placing the string in the name buffer.
10478 ------------------------------
10479 -- Add_Config_Static_String --
10480 ------------------------------
10482 function Add_Config_Static_String (Arg : Node_Id) return Boolean is
10489 if Nkind (N) = N_Op_Concat then
10490 if Add_Config_Static_String (Left_Opnd (N)) then
10491 N := Right_Opnd (N);
10497 if Nkind (N) /= N_String_Literal then
10498 Error_Msg_N ("string literal expected for pragma argument", N);
10502 for J in 1 .. String_Length (Strval (N)) loop
10503 C := Get_String_Char (Strval (N), J);
10505 if not In_Character_Range (C) then
10507 ("string literal contains invalid wide character",
10508 Sloc (N) + 1 + Source_Ptr (J));
10512 Add_Char_To_Name_Buffer (Get_Character (C));
10517 end Add_Config_Static_String;
10519 -- Start of prorcessing for Is_Config_Static_String
10524 return Add_Config_Static_String (Arg);
10525 end Is_Config_Static_String;
10527 -----------------------------------------
10528 -- Is_Non_Significant_Pragma_Reference --
10529 -----------------------------------------
10531 -- This function makes use of the following static table which indicates
10532 -- whether a given pragma is significant. A value of -1 in this table
10533 -- indicates that the reference is significant. A value of zero indicates
10534 -- than appearence as any argument is insignificant, a positive value
10535 -- indicates that appearence in that parameter position is significant.
10537 Sig_Flags : constant array (Pragma_Id) of Int :=
10539 (Pragma_AST_Entry => -1,
10540 Pragma_Abort_Defer => -1,
10541 Pragma_Ada_83 => -1,
10542 Pragma_Ada_95 => -1,
10543 Pragma_Ada_05 => -1,
10544 Pragma_All_Calls_Remote => -1,
10545 Pragma_Annotate => -1,
10546 Pragma_Assert => -1,
10547 Pragma_Assertion_Policy => 0,
10548 Pragma_Asynchronous => -1,
10549 Pragma_Atomic => 0,
10550 Pragma_Atomic_Components => 0,
10551 Pragma_Attach_Handler => -1,
10552 Pragma_CPP_Class => 0,
10553 Pragma_CPP_Constructor => 0,
10554 Pragma_CPP_Virtual => 0,
10555 Pragma_CPP_Vtable => 0,
10556 Pragma_C_Pass_By_Copy => 0,
10557 Pragma_Comment => 0,
10558 Pragma_Common_Object => -1,
10559 Pragma_Compile_Time_Warning => -1,
10560 Pragma_Complex_Representation => 0,
10561 Pragma_Component_Alignment => -1,
10562 Pragma_Controlled => 0,
10563 Pragma_Convention => 0,
10564 Pragma_Convention_Identifier => 0,
10565 Pragma_Debug => -1,
10566 Pragma_Detect_Blocking => -1,
10567 Pragma_Discard_Names => 0,
10568 Pragma_Elaborate => -1,
10569 Pragma_Elaborate_All => -1,
10570 Pragma_Elaborate_Body => -1,
10571 Pragma_Elaboration_Checks => -1,
10572 Pragma_Eliminate => -1,
10573 Pragma_Explicit_Overriding => -1,
10574 Pragma_Export => -1,
10575 Pragma_Export_Exception => -1,
10576 Pragma_Export_Function => -1,
10577 Pragma_Export_Object => -1,
10578 Pragma_Export_Procedure => -1,
10579 Pragma_Export_Value => -1,
10580 Pragma_Export_Valued_Procedure => -1,
10581 Pragma_Extend_System => -1,
10582 Pragma_Extensions_Allowed => -1,
10583 Pragma_External => -1,
10584 Pragma_External_Name_Casing => -1,
10585 Pragma_Finalize_Storage_Only => 0,
10586 Pragma_Float_Representation => 0,
10587 Pragma_Ident => -1,
10588 Pragma_Import => +2,
10589 Pragma_Import_Exception => 0,
10590 Pragma_Import_Function => 0,
10591 Pragma_Import_Object => 0,
10592 Pragma_Import_Procedure => 0,
10593 Pragma_Import_Valued_Procedure => 0,
10594 Pragma_Initialize_Scalars => -1,
10595 Pragma_Inline => 0,
10596 Pragma_Inline_Always => 0,
10597 Pragma_Inline_Generic => 0,
10598 Pragma_Inspection_Point => -1,
10599 Pragma_Interface => +2,
10600 Pragma_Interface_Name => +2,
10601 Pragma_Interrupt_Handler => -1,
10602 Pragma_Interrupt_Priority => -1,
10603 Pragma_Interrupt_State => -1,
10604 Pragma_Java_Constructor => -1,
10605 Pragma_Java_Interface => -1,
10606 Pragma_Keep_Names => 0,
10607 Pragma_License => -1,
10608 Pragma_Link_With => -1,
10609 Pragma_Linker_Alias => -1,
10610 Pragma_Linker_Constructor => -1,
10611 Pragma_Linker_Destructor => -1,
10612 Pragma_Linker_Options => -1,
10613 Pragma_Linker_Section => -1,
10615 Pragma_Locking_Policy => -1,
10616 Pragma_Long_Float => -1,
10617 Pragma_Machine_Attribute => -1,
10619 Pragma_Main_Storage => -1,
10620 Pragma_Memory_Size => -1,
10621 Pragma_No_Return => 0,
10622 Pragma_No_Run_Time => -1,
10623 Pragma_No_Strict_Aliasing => -1,
10624 Pragma_Normalize_Scalars => -1,
10625 Pragma_Obsolescent => 0,
10626 Pragma_Optimize => -1,
10627 Pragma_Optional_Overriding => -1,
10630 Pragma_Passive => -1,
10631 Pragma_Polling => -1,
10632 Pragma_Persistent_BSS => 0,
10633 Pragma_Preelaborate => -1,
10634 Pragma_Preelaborate_05 => -1,
10635 Pragma_Priority => -1,
10636 Pragma_Profile => 0,
10637 Pragma_Profile_Warnings => 0,
10638 Pragma_Propagate_Exceptions => -1,
10639 Pragma_Psect_Object => -1,
10641 Pragma_Pure_05 => -1,
10642 Pragma_Pure_Function => -1,
10643 Pragma_Queuing_Policy => -1,
10644 Pragma_Ravenscar => -1,
10645 Pragma_Remote_Call_Interface => -1,
10646 Pragma_Remote_Types => -1,
10647 Pragma_Restricted_Run_Time => -1,
10648 Pragma_Restriction_Warnings => -1,
10649 Pragma_Restrictions => -1,
10650 Pragma_Reviewable => -1,
10651 Pragma_Share_Generic => -1,
10652 Pragma_Shared => -1,
10653 Pragma_Shared_Passive => -1,
10654 Pragma_Source_File_Name => -1,
10655 Pragma_Source_File_Name_Project => -1,
10656 Pragma_Source_Reference => -1,
10657 Pragma_Storage_Size => -1,
10658 Pragma_Storage_Unit => -1,
10659 Pragma_Stream_Convert => -1,
10660 Pragma_Style_Checks => -1,
10661 Pragma_Subtitle => -1,
10662 Pragma_Suppress => 0,
10663 Pragma_Suppress_Exception_Locations => 0,
10664 Pragma_Suppress_All => -1,
10665 Pragma_Suppress_Debug_Info => 0,
10666 Pragma_Suppress_Initialization => 0,
10667 Pragma_System_Name => -1,
10668 Pragma_Task_Dispatching_Policy => -1,
10669 Pragma_Task_Info => -1,
10670 Pragma_Task_Name => -1,
10671 Pragma_Task_Storage => 0,
10672 Pragma_Thread_Body => +2,
10673 Pragma_Time_Slice => -1,
10674 Pragma_Title => -1,
10675 Pragma_Unchecked_Union => 0,
10676 Pragma_Unimplemented_Unit => -1,
10677 Pragma_Universal_Data => -1,
10678 Pragma_Unreferenced => -1,
10679 Pragma_Unreserve_All_Interrupts => -1,
10680 Pragma_Unsuppress => 0,
10681 Pragma_Use_VADS_Size => -1,
10682 Pragma_Validity_Checks => -1,
10683 Pragma_Volatile => 0,
10684 Pragma_Volatile_Components => 0,
10685 Pragma_Warnings => -1,
10686 Pragma_Weak_External => 0,
10687 Unknown_Pragma => 0);
10689 function Is_Non_Significant_Pragma_Reference (N : Node_Id) return Boolean is
10697 if Nkind (P) /= N_Pragma_Argument_Association then
10701 C := Sig_Flags (Get_Pragma_Id (Chars (Parent (P))));
10711 A := First (Pragma_Argument_Associations (Parent (P)));
10712 for J in 1 .. C - 1 loop
10723 end Is_Non_Significant_Pragma_Reference;
10725 ------------------------------
10726 -- Is_Pragma_String_Literal --
10727 ------------------------------
10729 -- This function returns true if the corresponding pragma argument is
10730 -- a static string expression. These are the only cases in which string
10731 -- literals can appear as pragma arguments. We also allow a string
10732 -- literal as the first argument to pragma Assert (although it will
10733 -- of course always generate a type error).
10735 function Is_Pragma_String_Literal (Par : Node_Id) return Boolean is
10736 Pragn : constant Node_Id := Parent (Par);
10737 Assoc : constant List_Id := Pragma_Argument_Associations (Pragn);
10738 Pname : constant Name_Id := Chars (Pragn);
10744 N := First (Assoc);
10751 if Pname = Name_Assert then
10754 elsif Pname = Name_Export then
10757 elsif Pname = Name_Ident then
10760 elsif Pname = Name_Import then
10763 elsif Pname = Name_Interface_Name then
10766 elsif Pname = Name_Linker_Alias then
10769 elsif Pname = Name_Linker_Section then
10772 elsif Pname = Name_Machine_Attribute then
10775 elsif Pname = Name_Source_File_Name then
10778 elsif Pname = Name_Source_Reference then
10781 elsif Pname = Name_Title then
10784 elsif Pname = Name_Subtitle then
10790 end Is_Pragma_String_Literal;
10792 --------------------------------------
10793 -- Process_Compilation_Unit_Pragmas --
10794 --------------------------------------
10796 procedure Process_Compilation_Unit_Pragmas (N : Node_Id) is
10798 -- A special check for pragma Suppress_All. This is a strange DEC
10799 -- pragma, strange because it comes at the end of the unit. If we
10800 -- have a pragma Suppress_All in the Pragmas_After of the current
10801 -- unit, then we insert a pragma Suppress (All_Checks) at the start
10802 -- of the context clause to ensure the correct processing.
10805 PA : constant List_Id := Pragmas_After (Aux_Decls_Node (N));
10809 if Present (PA) then
10811 while Present (P) loop
10812 if Chars (P) = Name_Suppress_All then
10813 Prepend_To (Context_Items (N),
10814 Make_Pragma (Sloc (P),
10815 Chars => Name_Suppress,
10816 Pragma_Argument_Associations => New_List (
10817 Make_Pragma_Argument_Association (Sloc (P),
10819 Make_Identifier (Sloc (P),
10820 Chars => Name_All_Checks)))));
10828 end Process_Compilation_Unit_Pragmas;
10830 --------------------------------
10831 -- Set_Encoded_Interface_Name --
10832 --------------------------------
10834 procedure Set_Encoded_Interface_Name (E : Entity_Id; S : Node_Id) is
10835 Str : constant String_Id := Strval (S);
10836 Len : constant Int := String_Length (Str);
10841 Hex : constant array (0 .. 15) of Character := "0123456789abcdef";
10844 -- Stores encoded value of character code CC. The encoding we
10845 -- use an underscore followed by four lower case hex digits.
10851 procedure Encode is
10853 Store_String_Char (Get_Char_Code ('_'));
10855 (Get_Char_Code (Hex (Integer (CC / 2 ** 12))));
10857 (Get_Char_Code (Hex (Integer (CC / 2 ** 8 and 16#0F#))));
10859 (Get_Char_Code (Hex (Integer (CC / 2 ** 4 and 16#0F#))));
10861 (Get_Char_Code (Hex (Integer (CC and 16#0F#))));
10864 -- Start of processing for Set_Encoded_Interface_Name
10867 -- If first character is asterisk, this is a link name, and we
10868 -- leave it completely unmodified. We also ignore null strings
10869 -- (the latter case happens only in error cases) and no encoding
10870 -- should occur for Java interface names.
10873 or else Get_String_Char (Str, 1) = Get_Char_Code ('*')
10876 Set_Interface_Name (E, S);
10881 CC := Get_String_Char (Str, J);
10883 exit when not In_Character_Range (CC);
10885 C := Get_Character (CC);
10887 exit when C /= '_' and then C /= '$'
10888 and then C not in '0' .. '9'
10889 and then C not in 'a' .. 'z'
10890 and then C not in 'A' .. 'Z';
10893 Set_Interface_Name (E, S);
10901 -- Here we need to encode. The encoding we use as follows:
10902 -- three underscores + four hex digits (lower case)
10906 for J in 1 .. String_Length (Str) loop
10907 CC := Get_String_Char (Str, J);
10909 if not In_Character_Range (CC) then
10912 C := Get_Character (CC);
10914 if C = '_' or else C = '$'
10915 or else C in '0' .. '9'
10916 or else C in 'a' .. 'z'
10917 or else C in 'A' .. 'Z'
10919 Store_String_Char (CC);
10926 Set_Interface_Name (E,
10927 Make_String_Literal (Sloc (S),
10928 Strval => End_String));
10930 end Set_Encoded_Interface_Name;
10932 -------------------
10933 -- Set_Unit_Name --
10934 -------------------
10936 procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id) is
10941 if Nkind (N) = N_Identifier
10942 and then Nkind (With_Item) = N_Identifier
10944 Set_Entity (N, Entity (With_Item));
10946 elsif Nkind (N) = N_Selected_Component then
10947 Change_Selected_Component_To_Expanded_Name (N);
10948 Set_Entity (N, Entity (With_Item));
10949 Set_Entity (Selector_Name (N), Entity (N));
10951 Pref := Prefix (N);
10952 Scop := Scope (Entity (N));
10953 while Nkind (Pref) = N_Selected_Component loop
10954 Change_Selected_Component_To_Expanded_Name (Pref);
10955 Set_Entity (Selector_Name (Pref), Scop);
10956 Set_Entity (Pref, Scop);
10957 Pref := Prefix (Pref);
10958 Scop := Scope (Scop);
10961 Set_Entity (Pref, Scop);