1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- This unit contains the semantic processing for all pragmas, both language
28 -- and implementation defined. For most pragmas, the parser only does the
29 -- most basic job of checking the syntax, so Sem_Prag also contains the code
30 -- to complete the syntax checks. Certain pragmas are handled partially or
31 -- completely by the parser (see Par.Prag for further details).
33 with Atree; use Atree;
34 with Casing; use Casing;
35 with Csets; use Csets;
36 with Debug; use Debug;
37 with Einfo; use Einfo;
38 with Elists; use Elists;
39 with Errout; use Errout;
40 with Expander; use Expander;
41 with Exp_Dist; use Exp_Dist;
42 with Fname; use Fname;
43 with Hostparm; use Hostparm;
45 with Lib.Writ; use Lib.Writ;
46 with Lib.Xref; use Lib.Xref;
47 with Namet; use Namet;
48 with Nlists; use Nlists;
49 with Nmake; use Nmake;
51 with Output; use Output;
52 with Restrict; use Restrict;
53 with Rident; use Rident;
54 with Rtsfind; use Rtsfind;
56 with Sem_Ch3; use Sem_Ch3;
57 with Sem_Ch8; use Sem_Ch8;
58 with Sem_Ch13; use Sem_Ch13;
59 with Sem_Disp; use Sem_Disp;
60 with Sem_Elim; use Sem_Elim;
61 with Sem_Eval; use Sem_Eval;
62 with Sem_Intr; use Sem_Intr;
63 with Sem_Mech; use Sem_Mech;
64 with Sem_Res; use Sem_Res;
65 with Sem_Type; use Sem_Type;
66 with Sem_Util; use Sem_Util;
67 with Sem_VFpt; use Sem_VFpt;
68 with Stand; use Stand;
69 with Sinfo; use Sinfo;
70 with Sinfo.CN; use Sinfo.CN;
71 with Sinput; use Sinput;
72 with Snames; use Snames;
73 with Stringt; use Stringt;
74 with Stylesw; use Stylesw;
76 with Targparm; use Targparm;
77 with Tbuild; use Tbuild;
79 with Uintp; use Uintp;
80 with Urealp; use Urealp;
81 with Validsw; use Validsw;
83 with GNAT.Spelling_Checker; use GNAT.Spelling_Checker;
85 package body Sem_Prag is
87 ----------------------------------------------
88 -- Common Handling of Import-Export Pragmas --
89 ----------------------------------------------
91 -- In the following section, a number of Import_xxx and Export_xxx
92 -- pragmas are defined by GNAT. These are compatible with the DEC
93 -- pragmas of the same name, and all have the following common
94 -- form and processing:
97 -- [Internal =>] LOCAL_NAME,
98 -- [, [External =>] EXTERNAL_SYMBOL]
99 -- [, other optional parameters ]);
102 -- [Internal =>] LOCAL_NAME,
103 -- [, [External =>] EXTERNAL_SYMBOL]
104 -- [, other optional parameters ]);
106 -- EXTERNAL_SYMBOL ::=
108 -- | static_string_EXPRESSION
110 -- The internal LOCAL_NAME designates the entity that is imported or
111 -- exported, and must refer to an entity in the current declarative
112 -- part (as required by the rules for LOCAL_NAME).
114 -- The external linker name is designated by the External parameter
115 -- if given, or the Internal parameter if not (if there is no External
116 -- parameter, the External parameter is a copy of the Internal name).
118 -- If the External parameter is given as a string, then this string
119 -- is treated as an external name (exactly as though it had been given
120 -- as an External_Name parameter for a normal Import pragma).
122 -- If the External parameter is given as an identifier (or there is no
123 -- External parameter, so that the Internal identifier is used), then
124 -- the external name is the characters of the identifier, translated
125 -- to all upper case letters for OpenVMS versions of GNAT, and to all
126 -- lower case letters for all other versions
128 -- Note: the external name specified or implied by any of these special
129 -- Import_xxx or Export_xxx pragmas override an external or link name
130 -- specified in a previous Import or Export pragma.
132 -- Note: these and all other DEC-compatible GNAT pragmas allow full
133 -- use of named notation, following the standard rules for subprogram
134 -- calls, i.e. parameters can be given in any order if named notation
135 -- is used, and positional and named notation can be mixed, subject to
136 -- the rule that all positional parameters must appear first.
138 -- Note: All these pragmas are implemented exactly following the DEC
139 -- design and implementation and are intended to be fully compatible
140 -- with the use of these pragmas in the DEC Ada compiler.
142 --------------------------------------------
143 -- Checking for Duplicated External Names --
144 --------------------------------------------
146 -- It is suspicious if two separate Export pragmas use the same external
147 -- name. The following table is used to diagnose this situation so that
148 -- an appropriate warning can be issued.
150 -- The Node_Id stored is for the N_String_Literal node created to
151 -- hold the value of the external name. The Sloc of this node is
152 -- used to cross-reference the location of the duplication.
154 package Externals is new Table.Table (
155 Table_Component_Type => Node_Id,
156 Table_Index_Type => Int,
157 Table_Low_Bound => 0,
158 Table_Initial => 100,
159 Table_Increment => 100,
160 Table_Name => "Name_Externals");
162 -------------------------------------
163 -- Local Subprograms and Variables --
164 -------------------------------------
166 function Adjust_External_Name_Case (N : Node_Id) return Node_Id;
167 -- This routine is used for possible casing adjustment of an explicit
168 -- external name supplied as a string literal (the node N), according
169 -- to the casing requirement of Opt.External_Name_Casing. If this is
170 -- set to As_Is, then the string literal is returned unchanged, but if
171 -- it is set to Uppercase or Lowercase, then a new string literal with
172 -- appropriate casing is constructed.
174 function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id;
175 -- If Def_Id refers to a renamed subprogram, then the base subprogram
176 -- (the original one, following the renaming chain) is returned.
177 -- Otherwise the entity is returned unchanged. Should be in Einfo???
179 procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id);
180 -- Place semantic information on the argument of an Elaborate or
181 -- Elaborate_All pragma. Entity name for unit and its parents is
182 -- taken from item in previous with_clause that mentions the unit.
184 -------------------------------
185 -- Adjust_External_Name_Case --
186 -------------------------------
188 function Adjust_External_Name_Case (N : Node_Id) return Node_Id is
192 -- Adjust case of literal if required
194 if Opt.External_Name_Exp_Casing = As_Is then
198 -- Copy existing string
204 for J in 1 .. String_Length (Strval (N)) loop
205 CC := Get_String_Char (Strval (N), J);
207 if Opt.External_Name_Exp_Casing = Uppercase
208 and then CC >= Get_Char_Code ('a')
209 and then CC <= Get_Char_Code ('z')
211 Store_String_Char (CC - 32);
213 elsif Opt.External_Name_Exp_Casing = Lowercase
214 and then CC >= Get_Char_Code ('A')
215 and then CC <= Get_Char_Code ('Z')
217 Store_String_Char (CC + 32);
220 Store_String_Char (CC);
225 Make_String_Literal (Sloc (N),
226 Strval => End_String);
228 end Adjust_External_Name_Case;
234 procedure Analyze_Pragma (N : Node_Id) is
235 Loc : constant Source_Ptr := Sloc (N);
238 Pragma_Exit : exception;
239 -- This exception is used to exit pragma processing completely. It
240 -- is used when an error is detected, and in other situations where
241 -- it is known that no further processing is required.
244 -- Number of pragma argument associations
250 -- First four pragma arguments (pragma argument association nodes,
251 -- or Empty if the corresponding argument does not exist).
253 procedure Check_Ada_83_Warning;
254 -- Issues a warning message for the current pragma if operating in Ada
255 -- 83 mode (used for language pragmas that are not a standard part of
256 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
259 procedure Check_Arg_Count (Required : Nat);
260 -- Check argument count for pragma is equal to given parameter.
261 -- If not, then issue an error message and raise Pragma_Exit.
263 -- Note: all routines whose name is Check_Arg_Is_xxx take an
264 -- argument Arg which can either be a pragma argument association,
265 -- in which case the check is applied to the expression of the
266 -- association or an expression directly.
268 procedure Check_Arg_Is_External_Name (Arg : Node_Id);
269 -- Check that an argument has the right form for an EXTERNAL_NAME
270 -- parameter of an extended import/export pragma. The rule is that
271 -- the name must be an identifier or string literal (in Ada 83 mode)
272 -- or a static string expression (in Ada 95 mode).
274 procedure Check_Arg_Is_Identifier (Arg : Node_Id);
275 -- Check the specified argument Arg to make sure that it is an
276 -- identifier. If not give error and raise Pragma_Exit.
278 procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id);
279 -- Check the specified argument Arg to make sure that it is an
280 -- integer literal. If not give error and raise Pragma_Exit.
282 procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id);
283 -- Check the specified argument Arg to make sure that it has the
284 -- proper syntactic form for a local name and meets the semantic
285 -- requirements for a local name. The local name is analyzed as
286 -- part of the processing for this call. In addition, the local
287 -- name is required to represent an entity at the library level.
289 procedure Check_Arg_Is_Local_Name (Arg : Node_Id);
290 -- Check the specified argument Arg to make sure that it has the
291 -- proper syntactic form for a local name and meets the semantic
292 -- requirements for a local name. The local name is analyzed as
293 -- part of the processing for this call.
295 procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id);
296 -- Check the specified argument Arg to make sure that it is a valid
297 -- locking policy name. If not give error and raise Pragma_Exit.
299 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id);
300 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2, N3 : Name_Id);
301 -- Check the specified argument Arg to make sure that it is an
302 -- identifier whose name matches either N1 or N2 (or N3 if present).
303 -- If not then give error and raise Pragma_Exit.
305 procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id);
306 -- Check the specified argument Arg to make sure that it is a valid
307 -- queuing policy name. If not give error and raise Pragma_Exit.
309 procedure Check_Arg_Is_Static_Expression
312 -- Check the specified argument Arg to make sure that it is a static
313 -- expression of the given type (i.e. it will be analyzed and resolved
314 -- using this type, which can be any valid argument to Resolve, e.g.
315 -- Any_Integer is OK). If not, given error and raise Pragma_Exit.
317 procedure Check_Arg_Is_String_Literal (Arg : Node_Id);
318 -- Check the specified argument Arg to make sure that it is a
319 -- string literal. If not give error and raise Pragma_Exit
321 procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id);
322 -- Check the specified argument Arg to make sure that it is a valid
323 -- valid task dispatching policy name. If not give error and raise
326 procedure Check_At_Least_N_Arguments (N : Nat);
327 -- Check there are at least N arguments present
329 procedure Check_At_Most_N_Arguments (N : Nat);
330 -- Check there are no more than N arguments present
332 procedure Check_Component (Comp : Node_Id);
333 -- Examine Unchecked_Union component for correct use of per-object
334 -- constrained subtypes.
336 procedure Check_Duplicated_Export_Name (Nam : Node_Id);
337 -- Nam is an N_String_Literal node containing the external name set
338 -- by an Import or Export pragma (or extended Import or Export pragma).
339 -- This procedure checks for possible duplications if this is the
340 -- export case, and if found, issues an appropriate error message.
342 procedure Check_First_Subtype (Arg : Node_Id);
343 -- Checks that Arg, whose expression is an entity name referencing
344 -- a subtype, does not reference a type that is not a first subtype.
346 procedure Check_In_Main_Program;
347 -- Common checks for pragmas that appear within a main program
348 -- (Priority, Main_Storage, Time_Slice).
350 procedure Check_Interrupt_Or_Attach_Handler;
351 -- Common processing for first argument of pragma Interrupt_Handler
352 -- or pragma Attach_Handler.
354 procedure Check_Is_In_Decl_Part_Or_Package_Spec;
355 -- Check that pragma appears in a declarative part, or in a package
356 -- specification, i.e. that it does not occur in a statement sequence
359 procedure Check_No_Identifier (Arg : Node_Id);
360 -- Checks that the given argument does not have an identifier. If
361 -- an identifier is present, then an error message is issued, and
362 -- Pragma_Exit is raised.
364 procedure Check_No_Identifiers;
365 -- Checks that none of the arguments to the pragma has an identifier.
366 -- If any argument has an identifier, then an error message is issued,
367 -- and Pragma_Exit is raised.
369 procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id);
370 -- Checks if the given argument has an identifier, and if so, requires
371 -- it to match the given identifier name. If there is a non-matching
372 -- identifier, then an error message is given and Error_Pragmas raised.
374 procedure Check_Optional_Identifier (Arg : Node_Id; Id : String);
375 -- Checks if the given argument has an identifier, and if so, requires
376 -- it to match the given identifier name. If there is a non-matching
377 -- identifier, then an error message is given and Error_Pragmas raised.
378 -- In this version of the procedure, the identifier name is given as
379 -- a string with lower case letters.
381 procedure Check_Static_Constraint (Constr : Node_Id);
382 -- Constr is a constraint from an N_Subtype_Indication node from a
383 -- component constraint in an Unchecked_Union type. This routine checks
384 -- that the constraint is static as required by the restrictions for
387 procedure Check_Valid_Configuration_Pragma;
388 -- Legality checks for placement of a configuration pragma
390 procedure Check_Valid_Library_Unit_Pragma;
391 -- Legality checks for library unit pragmas. A special case arises for
392 -- pragmas in generic instances that come from copies of the original
393 -- library unit pragmas in the generic templates. In the case of other
394 -- than library level instantiations these can appear in contexts which
395 -- would normally be invalid (they only apply to the original template
396 -- and to library level instantiations), and they are simply ignored,
397 -- which is implemented by rewriting them as null statements.
399 procedure Check_Variant (Variant : Node_Id);
400 -- Check Unchecked_Union variant for lack of nested variants and
401 -- presence of at least one component.
403 procedure Error_Pragma (Msg : String);
404 pragma No_Return (Error_Pragma);
405 -- Outputs error message for current pragma. The message contains an %
406 -- that will be replaced with the pragma name, and the flag is placed
407 -- on the pragma itself. Pragma_Exit is then raised.
409 procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id);
410 pragma No_Return (Error_Pragma_Arg);
411 -- Outputs error message for current pragma. The message may contain
412 -- a % that will be replaced with the pragma name. The parameter Arg
413 -- may either be a pragma argument association, in which case the flag
414 -- is placed on the expression of this association, or an expression,
415 -- in which case the flag is placed directly on the expression. The
416 -- message is placed using Error_Msg_N, so the message may also contain
417 -- an & insertion character which will reference the given Arg value.
418 -- After placing the message, Pragma_Exit is raised.
420 procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id);
421 pragma No_Return (Error_Pragma_Arg);
422 -- Similar to above form of Error_Pragma_Arg except that two messages
423 -- are provided, the second is a continuation comment starting with \.
425 procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id);
426 pragma No_Return (Error_Pragma_Arg_Ident);
427 -- Outputs error message for current pragma. The message may contain
428 -- a % that will be replaced with the pragma name. The parameter Arg
429 -- must be a pragma argument association with a non-empty identifier
430 -- (i.e. its Chars field must be set), and the error message is placed
431 -- on the identifier. The message is placed using Error_Msg_N so
432 -- the message may also contain an & insertion character which will
433 -- reference the identifier. After placing the message, Pragma_Exit
436 function Find_Lib_Unit_Name return Entity_Id;
437 -- Used for a library unit pragma to find the entity to which the
438 -- library unit pragma applies, returns the entity found.
440 procedure Find_Program_Unit_Name (Id : Node_Id);
441 -- If the pragma is a compilation unit pragma, the id must denote the
442 -- compilation unit in the same compilation, and the pragma must appear
443 -- in the list of preceding or trailing pragmas. If it is a program
444 -- unit pragma that is not a compilation unit pragma, then the
445 -- identifier must be visible.
447 type Name_List is array (Natural range <>) of Name_Id;
448 type Args_List is array (Natural range <>) of Node_Id;
449 procedure Gather_Associations
451 Args : out Args_List);
452 -- This procedure is used to gather the arguments for a pragma that
453 -- permits arbitrary ordering of parameters using the normal rules
454 -- for named and positional parameters. The Names argument is a list
455 -- of Name_Id values that corresponds to the allowed pragma argument
456 -- association identifiers in order. The result returned in Args is
457 -- a list of corresponding expressions that are the pragma arguments.
458 -- Note that this is a list of expressions, not of pragma argument
459 -- associations (Gather_Associations has completely checked all the
460 -- optional identifiers when it returns). An entry in Args is Empty
461 -- on return if the corresponding argument is not present.
463 function Get_Pragma_Arg (Arg : Node_Id) return Node_Id;
464 -- All the routines that check pragma arguments take either a pragma
465 -- argument association (in which case the expression of the argument
466 -- association is checked), or the expression directly. The function
467 -- Get_Pragma_Arg is a utility used to deal with these two cases. If
468 -- Arg is a pragma argument association node, then its expression is
469 -- returned, otherwise Arg is returned unchanged.
471 procedure GNAT_Pragma;
472 -- Called for all GNAT defined pragmas to note the use of the feature,
473 -- and also check the relevant restriction (No_Implementation_Pragmas).
475 function Is_Before_First_Decl
476 (Pragma_Node : Node_Id;
477 Decls : List_Id) return Boolean;
478 -- Return True if Pragma_Node is before the first declarative item in
479 -- Decls where Decls is the list of declarative items.
481 function Is_Configuration_Pragma return Boolean;
482 -- Deterermines if the placement of the current pragma is appropriate
483 -- for a configuration pragma (precedes the current compilation unit)
485 procedure Pragma_Misplaced;
486 -- Issue fatal error message for misplaced pragma
488 procedure Process_Atomic_Shared_Volatile;
489 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
490 -- Shared is an obsolete Ada 83 pragma, treated as being identical
491 -- in effect to pragma Atomic.
493 procedure Process_Convention (C : out Convention_Id; E : out Entity_Id);
494 -- Common procesing for Convention, Interface, Import and Export.
495 -- Checks first two arguments of pragma, and sets the appropriate
496 -- convention value in the specified entity or entities. On return
497 -- C is the convention, E is the referenced entity.
499 procedure Process_Extended_Import_Export_Exception_Pragma
500 (Arg_Internal : Node_Id;
501 Arg_External : Node_Id;
504 -- Common processing for the pragmas Import/Export_Exception.
505 -- The three arguments correspond to the three named parameters of
506 -- the pragma. An argument is empty if the corresponding parameter
507 -- is not present in the pragma.
509 procedure Process_Extended_Import_Export_Object_Pragma
510 (Arg_Internal : Node_Id;
511 Arg_External : Node_Id;
513 -- Common processing for the pragmass Import/Export_Object.
514 -- The three arguments correspond to the three named parameters
515 -- of the pragmas. An argument is empty if the corresponding
516 -- parameter is not present in the pragma.
518 procedure Process_Extended_Import_Export_Internal_Arg
519 (Arg_Internal : Node_Id := Empty);
520 -- Common processing for all extended Import and Export pragmas. The
521 -- argument is the pragma parameter for the Internal argument. If
522 -- Arg_Internal is empty or inappropriate, an error message is posted.
523 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
524 -- set to identify the referenced entity.
526 procedure Process_Extended_Import_Export_Subprogram_Pragma
527 (Arg_Internal : Node_Id;
528 Arg_External : Node_Id;
529 Arg_Parameter_Types : Node_Id;
530 Arg_Result_Type : Node_Id := Empty;
531 Arg_Mechanism : Node_Id;
532 Arg_Result_Mechanism : Node_Id := Empty;
533 Arg_First_Optional_Parameter : Node_Id := Empty);
534 -- Common processing for all extended Import and Export pragmas
535 -- applying to subprograms. The caller omits any arguments that do
536 -- bnot apply to the pragma in question (for example, Arg_Result_Type
537 -- can be non-Empty only in the Import_Function and Export_Function
538 -- cases). The argument names correspond to the allowed pragma
539 -- association identifiers.
541 procedure Process_Generic_List;
542 -- Common processing for Share_Generic and Inline_Generic
544 procedure Process_Import_Or_Interface;
545 -- Common processing for Import of Interface
547 procedure Process_Inline (Active : Boolean);
548 -- Common processing for Inline and Inline_Always. The parameter
549 -- indicates if the inline pragma is active, i.e. if it should
550 -- actually cause inlining to occur.
552 procedure Process_Interface_Name
553 (Subprogram_Def : Entity_Id;
556 -- Given the last two arguments of pragma Import, pragma Export, or
557 -- pragma Interface_Name, performs validity checks and sets the
558 -- Interface_Name field of the given subprogram entity to the
559 -- appropriate external or link name, depending on the arguments
560 -- given. Ext_Arg is always present, but Link_Arg may be missing.
561 -- Note that Ext_Arg may represent the Link_Name if Link_Arg is
562 -- missing, and appropriate named notation is used for Ext_Arg.
563 -- If neither Ext_Arg nor Link_Arg is present, the interface name
564 -- is set to the default from the subprogram name.
566 procedure Process_Interrupt_Or_Attach_Handler;
567 -- Common processing for Interrupt and Attach_Handler pragmas
569 procedure Process_Restrictions_Or_Restriction_Warnings;
570 -- Common processing for Restrictions and Restriction_Warnings pragmas
572 procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean);
573 -- Common processing for Suppress and Unsuppress. The boolean parameter
574 -- Suppress_Case is True for the Suppress case, and False for the
577 procedure Set_Exported (E : Entity_Id; Arg : Node_Id);
578 -- This procedure sets the Is_Exported flag for the given entity,
579 -- checking that the entity was not previously imported. Arg is
580 -- the argument that specified the entity. A check is also made
581 -- for exporting inappropriate entities.
583 procedure Set_Extended_Import_Export_External_Name
584 (Internal_Ent : Entity_Id;
585 Arg_External : Node_Id);
586 -- Common processing for all extended import export pragmas. The first
587 -- argument, Internal_Ent, is the internal entity, which has already
588 -- been checked for validity by the caller. Arg_External is from the
589 -- Import or Export pragma, and may be null if no External parameter
590 -- was present. If Arg_External is present and is a non-null string
591 -- (a null string is treated as the default), then the Interface_Name
592 -- field of Internal_Ent is set appropriately.
594 procedure Set_Imported (E : Entity_Id);
595 -- This procedure sets the Is_Imported flag for the given entity,
596 -- checking that it is not previously exported or imported.
598 procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id);
599 -- Mech is a parameter passing mechanism (see Import_Function syntax
600 -- for MECHANISM_NAME). This routine checks that the mechanism argument
601 -- has the right form, and if not issues an error message. If the
602 -- argument has the right form then the Mechanism field of Ent is
603 -- set appropriately.
605 procedure Set_Ravenscar_Profile (N : Node_Id);
606 -- Activate the set of configuration pragmas and restrictions that
607 -- make up the Ravenscar Profile. N is the corresponding pragma
608 -- node, which is used for error messages on any constructs
609 -- that violate the profile.
611 --------------------------
612 -- Check_Ada_83_Warning --
613 --------------------------
615 procedure Check_Ada_83_Warning is
617 if Ada_Version = Ada_83 and then Comes_From_Source (N) then
618 Error_Msg_N ("(Ada 83) pragma& is non-standard?", N);
620 end Check_Ada_83_Warning;
622 ---------------------
623 -- Check_Arg_Count --
624 ---------------------
626 procedure Check_Arg_Count (Required : Nat) is
628 if Arg_Count /= Required then
629 Error_Pragma ("wrong number of arguments for pragma%");
633 --------------------------------
634 -- Check_Arg_Is_External_Name --
635 --------------------------------
637 procedure Check_Arg_Is_External_Name (Arg : Node_Id) is
638 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
641 if Nkind (Argx) = N_Identifier then
645 Analyze_And_Resolve (Argx, Standard_String);
647 if Is_OK_Static_Expression (Argx) then
650 elsif Etype (Argx) = Any_Type then
653 -- An interesting special case, if we have a string literal and
654 -- we are in Ada 83 mode, then we allow it even though it will
655 -- not be flagged as static. This allows expected Ada 83 mode
656 -- use of external names which are string literals, even though
657 -- technically these are not static in Ada 83.
659 elsif Ada_Version = Ada_83
660 and then Nkind (Argx) = N_String_Literal
664 -- Static expression that raises Constraint_Error. This has
665 -- already been flagged, so just exit from pragma processing.
667 elsif Is_Static_Expression (Argx) then
670 -- Here we have a real error (non-static expression)
673 Error_Msg_Name_1 := Chars (N);
675 ("argument for pragma% must be a identifier or " &
676 "static string expression!", Argx);
680 end Check_Arg_Is_External_Name;
682 -----------------------------
683 -- Check_Arg_Is_Identifier --
684 -----------------------------
686 procedure Check_Arg_Is_Identifier (Arg : Node_Id) is
687 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
689 if Nkind (Argx) /= N_Identifier then
691 ("argument for pragma% must be identifier", Argx);
693 end Check_Arg_Is_Identifier;
695 ----------------------------------
696 -- Check_Arg_Is_Integer_Literal --
697 ----------------------------------
699 procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id) is
700 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
702 if Nkind (Argx) /= N_Integer_Literal then
704 ("argument for pragma% must be integer literal", Argx);
706 end Check_Arg_Is_Integer_Literal;
708 -------------------------------------------
709 -- Check_Arg_Is_Library_Level_Local_Name --
710 -------------------------------------------
714 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
715 -- | library_unit_NAME
717 procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id) is
719 Check_Arg_Is_Local_Name (Arg);
721 if not Is_Library_Level_Entity (Entity (Expression (Arg)))
722 and then Comes_From_Source (N)
725 ("argument for pragma% must be library level entity", Arg);
727 end Check_Arg_Is_Library_Level_Local_Name;
729 -----------------------------
730 -- Check_Arg_Is_Local_Name --
731 -----------------------------
735 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
736 -- | library_unit_NAME
738 procedure Check_Arg_Is_Local_Name (Arg : Node_Id) is
739 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
744 if Nkind (Argx) not in N_Direct_Name
745 and then (Nkind (Argx) /= N_Attribute_Reference
746 or else Present (Expressions (Argx))
747 or else Nkind (Prefix (Argx)) /= N_Identifier)
748 and then (not Is_Entity_Name (Argx)
749 or else not Is_Compilation_Unit (Entity (Argx)))
751 Error_Pragma_Arg ("argument for pragma% must be local name", Argx);
754 if Is_Entity_Name (Argx)
755 and then Scope (Entity (Argx)) /= Current_Scope
758 ("pragma% argument must be in same declarative part", Arg);
760 end Check_Arg_Is_Local_Name;
762 ---------------------------------
763 -- Check_Arg_Is_Locking_Policy --
764 ---------------------------------
766 procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id) is
767 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
770 Check_Arg_Is_Identifier (Argx);
772 if not Is_Locking_Policy_Name (Chars (Argx)) then
774 ("& is not a valid locking policy name", Argx);
776 end Check_Arg_Is_Locking_Policy;
778 -------------------------
779 -- Check_Arg_Is_One_Of --
780 -------------------------
782 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id) is
783 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
786 Check_Arg_Is_Identifier (Argx);
788 if Chars (Argx) /= N1 and then Chars (Argx) /= N2 then
789 Error_Msg_Name_2 := N1;
790 Error_Msg_Name_3 := N2;
791 Error_Pragma_Arg ("argument for pragma% must be% or%", Argx);
793 end Check_Arg_Is_One_Of;
795 procedure Check_Arg_Is_One_Of
797 N1, N2, N3 : Name_Id)
799 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
802 Check_Arg_Is_Identifier (Argx);
804 if Chars (Argx) /= N1
805 and then Chars (Argx) /= N2
806 and then Chars (Argx) /= N3
808 Error_Pragma_Arg ("invalid argument for pragma%", Argx);
810 end Check_Arg_Is_One_Of;
812 ---------------------------------
813 -- Check_Arg_Is_Queuing_Policy --
814 ---------------------------------
816 procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id) is
817 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
820 Check_Arg_Is_Identifier (Argx);
822 if not Is_Queuing_Policy_Name (Chars (Argx)) then
824 ("& is not a valid queuing policy name", Argx);
826 end Check_Arg_Is_Queuing_Policy;
828 ------------------------------------
829 -- Check_Arg_Is_Static_Expression --
830 ------------------------------------
832 procedure Check_Arg_Is_Static_Expression
836 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
839 Analyze_And_Resolve (Argx, Typ);
841 if Is_OK_Static_Expression (Argx) then
844 elsif Etype (Argx) = Any_Type then
847 -- An interesting special case, if we have a string literal and
848 -- we are in Ada 83 mode, then we allow it even though it will
849 -- not be flagged as static. This allows the use of Ada 95
850 -- pragmas like Import in Ada 83 mode. They will of course be
851 -- flagged with warnings as usual, but will not cause errors.
853 elsif Ada_Version = Ada_83
854 and then Nkind (Argx) = N_String_Literal
858 -- Static expression that raises Constraint_Error. This has
859 -- already been flagged, so just exit from pragma processing.
861 elsif Is_Static_Expression (Argx) then
864 -- Finally, we have a real error
867 Error_Msg_Name_1 := Chars (N);
869 ("argument for pragma% must be a static expression!", Argx);
872 end Check_Arg_Is_Static_Expression;
874 ---------------------------------
875 -- Check_Arg_Is_String_Literal --
876 ---------------------------------
878 procedure Check_Arg_Is_String_Literal (Arg : Node_Id) is
879 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
882 if Nkind (Argx) /= N_String_Literal then
884 ("argument for pragma% must be string literal", Argx);
887 end Check_Arg_Is_String_Literal;
889 ------------------------------------------
890 -- Check_Arg_Is_Task_Dispatching_Policy --
891 ------------------------------------------
893 procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id) is
894 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
897 Check_Arg_Is_Identifier (Argx);
899 if not Is_Task_Dispatching_Policy_Name (Chars (Argx)) then
901 ("& is not a valid task dispatching policy name", Argx);
903 end Check_Arg_Is_Task_Dispatching_Policy;
905 --------------------------------
906 -- Check_At_Least_N_Arguments --
907 --------------------------------
909 procedure Check_At_Least_N_Arguments (N : Nat) is
911 if Arg_Count < N then
912 Error_Pragma ("too few arguments for pragma%");
914 end Check_At_Least_N_Arguments;
916 -------------------------------
917 -- Check_At_Most_N_Arguments --
918 -------------------------------
920 procedure Check_At_Most_N_Arguments (N : Nat) is
924 if Arg_Count > N then
929 Error_Pragma_Arg ("too many arguments for pragma%", Arg);
932 end Check_At_Most_N_Arguments;
934 ---------------------
935 -- Check_Component --
936 ---------------------
938 procedure Check_Component (Comp : Node_Id) is
940 if Nkind (Comp) = N_Component_Declaration then
942 Sindic : constant Node_Id :=
943 Subtype_Indication (Component_Definition (Comp));
946 if Nkind (Sindic) = N_Subtype_Indication then
948 -- Ada 2005 (AI-216): If a component subtype is subject to
949 -- a per-object constraint, then the component type shall
950 -- be an Unchecked_Union.
952 if Has_Per_Object_Constraint (Defining_Identifier (Comp))
954 not Is_Unchecked_Union (Etype (Subtype_Mark (Sindic)))
956 Error_Msg_N ("component subtype subject to per-object" &
957 " constraint must be an Unchecked_Union", Comp);
964 ----------------------------------
965 -- Check_Duplicated_Export_Name --
966 ----------------------------------
968 procedure Check_Duplicated_Export_Name (Nam : Node_Id) is
969 String_Val : constant String_Id := Strval (Nam);
972 -- We are only interested in the export case, and in the case of
973 -- generics, it is the instance, not the template, that is the
974 -- problem (the template will generate a warning in any case).
976 if not Inside_A_Generic
977 and then (Prag_Id = Pragma_Export
979 Prag_Id = Pragma_Export_Procedure
981 Prag_Id = Pragma_Export_Valued_Procedure
983 Prag_Id = Pragma_Export_Function)
985 for J in Externals.First .. Externals.Last loop
986 if String_Equal (String_Val, Strval (Externals.Table (J))) then
987 Error_Msg_Sloc := Sloc (Externals.Table (J));
988 Error_Msg_N ("external name duplicates name given#", Nam);
993 Externals.Append (Nam);
995 end Check_Duplicated_Export_Name;
997 -------------------------
998 -- Check_First_Subtype --
999 -------------------------
1001 procedure Check_First_Subtype (Arg : Node_Id) is
1002 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1005 if not Is_First_Subtype (Entity (Argx)) then
1007 ("pragma% cannot apply to subtype", Argx);
1009 end Check_First_Subtype;
1011 ---------------------------
1012 -- Check_In_Main_Program --
1013 ---------------------------
1015 procedure Check_In_Main_Program is
1016 P : constant Node_Id := Parent (N);
1019 -- Must be at in subprogram body
1021 if Nkind (P) /= N_Subprogram_Body then
1022 Error_Pragma ("% pragma allowed only in subprogram");
1024 -- Otherwise warn if obviously not main program
1026 elsif Present (Parameter_Specifications (Specification (P)))
1027 or else not Is_Compilation_Unit (Defining_Entity (P))
1029 Error_Msg_Name_1 := Chars (N);
1031 ("?pragma% is only effective in main program", N);
1033 end Check_In_Main_Program;
1035 ---------------------------------------
1036 -- Check_Interrupt_Or_Attach_Handler --
1037 ---------------------------------------
1039 procedure Check_Interrupt_Or_Attach_Handler is
1040 Arg1_X : constant Node_Id := Expression (Arg1);
1045 if not Is_Entity_Name (Arg1_X) then
1047 ("argument of pragma% must be entity name", Arg1);
1049 elsif Prag_Id = Pragma_Interrupt_Handler then
1050 Check_Restriction (No_Dynamic_Attachment, N);
1054 Handler_Proc : Entity_Id := Empty;
1055 Proc_Scope : Entity_Id;
1056 Found : Boolean := False;
1059 if not Is_Overloaded (Arg1_X) then
1060 Handler_Proc := Entity (Arg1_X);
1065 Index : Interp_Index;
1068 Get_First_Interp (Arg1_X, Index, It);
1069 while Present (It.Nam) loop
1070 Handler_Proc := It.Nam;
1072 if Ekind (Handler_Proc) = E_Procedure
1073 and then No (First_Formal (Handler_Proc))
1077 Set_Entity (Arg1_X, Handler_Proc);
1078 Set_Is_Overloaded (Arg1_X, False);
1081 ("ambiguous handler name for pragma% ", Arg1);
1085 Get_Next_Interp (Index, It);
1090 ("argument of pragma% must be parameterless procedure",
1093 Handler_Proc := Entity (Arg1_X);
1098 Proc_Scope := Scope (Handler_Proc);
1100 -- On AAMP only, a pragma Interrupt_Handler is supported for
1101 -- nonprotected parameterless procedures.
1104 and then Prag_Id = Pragma_Interrupt_Handler
1106 if Ekind (Handler_Proc) /= E_Procedure then
1108 ("argument of pragma% must be a procedure", Arg1);
1111 elsif Ekind (Handler_Proc) /= E_Procedure
1112 or else Ekind (Proc_Scope) /= E_Protected_Type
1115 ("argument of pragma% must be protected procedure", Arg1);
1118 if (not AAMP_On_Target or else Prag_Id = Pragma_Attach_Handler)
1119 and then Ekind (Proc_Scope) = E_Protected_Type
1122 Protected_Definition (Parent (Proc_Scope))
1124 Error_Pragma ("pragma% must be in protected definition");
1128 if not Is_Library_Level_Entity (Proc_Scope)
1129 or else (AAMP_On_Target
1130 and then not Is_Library_Level_Entity (Handler_Proc))
1133 ("pragma% requires library-level entity", Arg1);
1136 if Present (First_Formal (Handler_Proc)) then
1138 ("argument of pragma% must be parameterless procedure",
1142 end Check_Interrupt_Or_Attach_Handler;
1144 -------------------------------------------
1145 -- Check_Is_In_Decl_Part_Or_Package_Spec --
1146 -------------------------------------------
1148 procedure Check_Is_In_Decl_Part_Or_Package_Spec is
1157 elsif Nkind (P) = N_Handled_Sequence_Of_Statements then
1160 elsif Nkind (P) = N_Package_Specification then
1163 elsif Nkind (P) = N_Block_Statement then
1166 -- Note: the following tests seem a little peculiar, because
1167 -- they test for bodies, but if we were in the statement part
1168 -- of the body, we would already have hit the handled statement
1169 -- sequence, so the only way we get here is by being in the
1170 -- declarative part of the body.
1172 elsif Nkind (P) = N_Subprogram_Body
1173 or else Nkind (P) = N_Package_Body
1174 or else Nkind (P) = N_Task_Body
1175 or else Nkind (P) = N_Entry_Body
1183 Error_Pragma ("pragma% is not in declarative part or package spec");
1184 end Check_Is_In_Decl_Part_Or_Package_Spec;
1186 -------------------------
1187 -- Check_No_Identifier --
1188 -------------------------
1190 procedure Check_No_Identifier (Arg : Node_Id) is
1192 if Chars (Arg) /= No_Name then
1193 Error_Pragma_Arg_Ident
1194 ("pragma% does not permit identifier& here", Arg);
1196 end Check_No_Identifier;
1198 --------------------------
1199 -- Check_No_Identifiers --
1200 --------------------------
1202 procedure Check_No_Identifiers is
1206 if Arg_Count > 0 then
1209 while Present (Arg_Node) loop
1210 Check_No_Identifier (Arg_Node);
1214 end Check_No_Identifiers;
1216 -------------------------------
1217 -- Check_Optional_Identifier --
1218 -------------------------------
1220 procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id) is
1222 if Present (Arg) and then Chars (Arg) /= No_Name then
1223 if Chars (Arg) /= Id then
1224 Error_Msg_Name_1 := Chars (N);
1225 Error_Msg_Name_2 := Id;
1226 Error_Msg_N ("pragma% argument expects identifier%", Arg);
1230 end Check_Optional_Identifier;
1232 procedure Check_Optional_Identifier (Arg : Node_Id; Id : String) is
1234 Name_Buffer (1 .. Id'Length) := Id;
1235 Name_Len := Id'Length;
1236 Check_Optional_Identifier (Arg, Name_Find);
1237 end Check_Optional_Identifier;
1239 -----------------------------
1240 -- Check_Static_Constraint --
1241 -----------------------------
1243 -- Note: for convenience in writing this procedure, in addition to
1244 -- the officially (i.e. by spec) allowed argument which is always
1245 -- a constraint, it also allows ranges and discriminant associations.
1246 -- Above is not clear ???
1248 procedure Check_Static_Constraint (Constr : Node_Id) is
1250 --------------------
1251 -- Require_Static --
1252 --------------------
1254 procedure Require_Static (E : Node_Id);
1255 -- Require given expression to be static expression
1257 procedure Require_Static (E : Node_Id) is
1259 if not Is_OK_Static_Expression (E) then
1260 Flag_Non_Static_Expr
1261 ("non-static constraint not allowed in Unchecked_Union!", E);
1266 -- Start of processing for Check_Static_Constraint
1269 case Nkind (Constr) is
1270 when N_Discriminant_Association =>
1271 Require_Static (Expression (Constr));
1274 Require_Static (Low_Bound (Constr));
1275 Require_Static (High_Bound (Constr));
1277 when N_Attribute_Reference =>
1278 Require_Static (Type_Low_Bound (Etype (Prefix (Constr))));
1279 Require_Static (Type_High_Bound (Etype (Prefix (Constr))));
1281 when N_Range_Constraint =>
1282 Check_Static_Constraint (Range_Expression (Constr));
1284 when N_Index_Or_Discriminant_Constraint =>
1286 IDC : Entity_Id := First (Constraints (Constr));
1288 while Present (IDC) loop
1289 Check_Static_Constraint (IDC);
1297 end Check_Static_Constraint;
1299 --------------------------------------
1300 -- Check_Valid_Configuration_Pragma --
1301 --------------------------------------
1303 -- A configuration pragma must appear in the context clause of
1304 -- a compilation unit, at the start of the list (i.e. only other
1305 -- pragmas may precede it).
1307 procedure Check_Valid_Configuration_Pragma is
1309 if not Is_Configuration_Pragma then
1310 Error_Pragma ("incorrect placement for configuration pragma%");
1312 end Check_Valid_Configuration_Pragma;
1314 -------------------------------------
1315 -- Check_Valid_Library_Unit_Pragma --
1316 -------------------------------------
1318 procedure Check_Valid_Library_Unit_Pragma is
1320 Parent_Node : Node_Id;
1321 Unit_Name : Entity_Id;
1322 Unit_Kind : Node_Kind;
1323 Unit_Node : Node_Id;
1324 Sindex : Source_File_Index;
1327 if not Is_List_Member (N) then
1331 Plist := List_Containing (N);
1332 Parent_Node := Parent (Plist);
1334 if Parent_Node = Empty then
1337 -- Case of pragma appearing after a compilation unit. In this
1338 -- case it must have an argument with the corresponding name
1339 -- and must be part of the following pragmas of its parent.
1341 elsif Nkind (Parent_Node) = N_Compilation_Unit_Aux then
1342 if Plist /= Pragmas_After (Parent_Node) then
1345 elsif Arg_Count = 0 then
1347 ("argument required if outside compilation unit");
1350 Check_No_Identifiers;
1351 Check_Arg_Count (1);
1352 Unit_Node := Unit (Parent (Parent_Node));
1353 Unit_Kind := Nkind (Unit_Node);
1355 Analyze (Expression (Arg1));
1357 if Unit_Kind = N_Generic_Subprogram_Declaration
1358 or else Unit_Kind = N_Subprogram_Declaration
1360 Unit_Name := Defining_Entity (Unit_Node);
1362 elsif Unit_Kind = N_Function_Instantiation
1363 or else Unit_Kind = N_Package_Instantiation
1364 or else Unit_Kind = N_Procedure_Instantiation
1366 Unit_Name := Defining_Entity (Unit_Node);
1369 Unit_Name := Cunit_Entity (Current_Sem_Unit);
1372 if Chars (Unit_Name) /=
1373 Chars (Entity (Expression (Arg1)))
1376 ("pragma% argument is not current unit name", Arg1);
1379 if Ekind (Unit_Name) = E_Package
1380 and then Present (Renamed_Entity (Unit_Name))
1382 Error_Pragma ("pragma% not allowed for renamed package");
1386 -- Pragma appears other than after a compilation unit
1389 -- Here we check for the generic instantiation case and also
1390 -- for the case of processing a generic formal package. We
1391 -- detect these cases by noting that the Sloc on the node
1392 -- does not belong to the current compilation unit.
1394 Sindex := Source_Index (Current_Sem_Unit);
1396 if Loc not in Source_First (Sindex) .. Source_Last (Sindex) then
1397 Rewrite (N, Make_Null_Statement (Loc));
1400 -- If before first declaration, the pragma applies to the
1401 -- enclosing unit, and the name if present must be this name.
1403 elsif Is_Before_First_Decl (N, Plist) then
1404 Unit_Node := Unit_Declaration_Node (Current_Scope);
1405 Unit_Kind := Nkind (Unit_Node);
1407 if Nkind (Parent (Unit_Node)) /= N_Compilation_Unit then
1410 elsif Unit_Kind = N_Subprogram_Body
1411 and then not Acts_As_Spec (Unit_Node)
1415 elsif Nkind (Parent_Node) = N_Package_Body then
1418 elsif Nkind (Parent_Node) = N_Package_Specification
1419 and then Plist = Private_Declarations (Parent_Node)
1423 elsif (Nkind (Parent_Node) = N_Generic_Package_Declaration
1424 or else Nkind (Parent_Node)
1425 = N_Generic_Subprogram_Declaration)
1426 and then Plist = Generic_Formal_Declarations (Parent_Node)
1430 elsif Arg_Count > 0 then
1431 Analyze (Expression (Arg1));
1433 if Entity (Expression (Arg1)) /= Current_Scope then
1435 ("name in pragma% must be enclosing unit", Arg1);
1438 -- It is legal to have no argument in this context
1444 -- Error if not before first declaration. This is because a
1445 -- library unit pragma argument must be the name of a library
1446 -- unit (RM 10.1.5(7)), but the only names permitted in this
1447 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1448 -- generic subprogram declarations or generic instantiations.
1452 ("pragma% misplaced, must be before first declaration");
1456 end Check_Valid_Library_Unit_Pragma;
1462 procedure Check_Variant (Variant : Node_Id) is
1463 Clist : constant Node_Id := Component_List (Variant);
1467 if Present (Variant_Part (Clist)) then
1469 ("Unchecked_Union may not have nested variants",
1470 Variant_Part (Clist));
1473 if not Is_Non_Empty_List (Component_Items (Clist)) then
1475 ("Unchecked_Union may not have empty component list",
1480 Comp := First (Component_Items (Clist));
1481 while Present (Comp) loop
1483 Check_Component (Comp);
1493 procedure Error_Pragma (Msg : String) is
1495 Error_Msg_Name_1 := Chars (N);
1496 Error_Msg_N (Msg, N);
1500 ----------------------
1501 -- Error_Pragma_Arg --
1502 ----------------------
1504 procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id) is
1506 Error_Msg_Name_1 := Chars (N);
1507 Error_Msg_N (Msg, Get_Pragma_Arg (Arg));
1509 end Error_Pragma_Arg;
1511 procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id) is
1513 Error_Msg_Name_1 := Chars (N);
1514 Error_Msg_N (Msg1, Get_Pragma_Arg (Arg));
1515 Error_Pragma_Arg (Msg2, Arg);
1516 end Error_Pragma_Arg;
1518 ----------------------------
1519 -- Error_Pragma_Arg_Ident --
1520 ----------------------------
1522 procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id) is
1524 Error_Msg_Name_1 := Chars (N);
1525 Error_Msg_N (Msg, Arg);
1527 end Error_Pragma_Arg_Ident;
1529 ------------------------
1530 -- Find_Lib_Unit_Name --
1531 ------------------------
1533 function Find_Lib_Unit_Name return Entity_Id is
1535 -- Return inner compilation unit entity, for case of nested
1536 -- categorization pragmas. This happens in generic unit.
1538 if Nkind (Parent (N)) = N_Package_Specification
1539 and then Defining_Entity (Parent (N)) /= Current_Scope
1541 return Defining_Entity (Parent (N));
1543 return Current_Scope;
1545 end Find_Lib_Unit_Name;
1547 ----------------------------
1548 -- Find_Program_Unit_Name --
1549 ----------------------------
1551 procedure Find_Program_Unit_Name (Id : Node_Id) is
1552 Unit_Name : Entity_Id;
1553 Unit_Kind : Node_Kind;
1554 P : constant Node_Id := Parent (N);
1557 if Nkind (P) = N_Compilation_Unit then
1558 Unit_Kind := Nkind (Unit (P));
1560 if Unit_Kind = N_Subprogram_Declaration
1561 or else Unit_Kind = N_Package_Declaration
1562 or else Unit_Kind in N_Generic_Declaration
1564 Unit_Name := Defining_Entity (Unit (P));
1566 if Chars (Id) = Chars (Unit_Name) then
1567 Set_Entity (Id, Unit_Name);
1568 Set_Etype (Id, Etype (Unit_Name));
1570 Set_Etype (Id, Any_Type);
1572 ("cannot find program unit referenced by pragma%");
1576 Set_Etype (Id, Any_Type);
1577 Error_Pragma ("pragma% inapplicable to this unit");
1584 end Find_Program_Unit_Name;
1586 -------------------------
1587 -- Gather_Associations --
1588 -------------------------
1590 procedure Gather_Associations
1592 Args : out Args_List)
1597 -- Initialize all parameters to Empty
1599 for J in Args'Range loop
1603 -- That's all we have to do if there are no argument associations
1605 if No (Pragma_Argument_Associations (N)) then
1609 -- Otherwise first deal with any positional parameters present
1611 Arg := First (Pragma_Argument_Associations (N));
1613 for Index in Args'Range loop
1614 exit when No (Arg) or else Chars (Arg) /= No_Name;
1615 Args (Index) := Expression (Arg);
1619 -- Positional parameters all processed, if any left, then we
1620 -- have too many positional parameters.
1622 if Present (Arg) and then Chars (Arg) = No_Name then
1624 ("too many positional associations for pragma%", Arg);
1627 -- Process named parameters if any are present
1629 while Present (Arg) loop
1630 if Chars (Arg) = No_Name then
1632 ("positional association cannot follow named association",
1636 for Index in Names'Range loop
1637 if Names (Index) = Chars (Arg) then
1638 if Present (Args (Index)) then
1640 ("duplicate argument association for pragma%", Arg);
1642 Args (Index) := Expression (Arg);
1647 if Index = Names'Last then
1648 Error_Msg_Name_1 := Chars (N);
1649 Error_Msg_N ("pragma% does not allow & argument", Arg);
1651 -- Check for possible misspelling
1653 for Index1 in Names'Range loop
1654 if Is_Bad_Spelling_Of
1655 (Get_Name_String (Chars (Arg)),
1656 Get_Name_String (Names (Index1)))
1658 Error_Msg_Name_1 := Names (Index1);
1659 Error_Msg_N ("\possible misspelling of%", Arg);
1671 end Gather_Associations;
1673 --------------------
1674 -- Get_Pragma_Arg --
1675 --------------------
1677 function Get_Pragma_Arg (Arg : Node_Id) return Node_Id is
1679 if Nkind (Arg) = N_Pragma_Argument_Association then
1680 return Expression (Arg);
1690 procedure GNAT_Pragma is
1692 Check_Restriction (No_Implementation_Pragmas, N);
1695 --------------------------
1696 -- Is_Before_First_Decl --
1697 --------------------------
1699 function Is_Before_First_Decl
1700 (Pragma_Node : Node_Id;
1701 Decls : List_Id) return Boolean
1703 Item : Node_Id := First (Decls);
1706 -- Only other pragmas can come before this pragma
1709 if No (Item) or else Nkind (Item) /= N_Pragma then
1712 elsif Item = Pragma_Node then
1718 end Is_Before_First_Decl;
1720 -----------------------------
1721 -- Is_Configuration_Pragma --
1722 -----------------------------
1724 -- A configuration pragma must appear in the context clause of
1725 -- a compilation unit, at the start of the list (i.e. only other
1726 -- pragmas may precede it).
1728 function Is_Configuration_Pragma return Boolean is
1729 Lis : constant List_Id := List_Containing (N);
1730 Par : constant Node_Id := Parent (N);
1734 -- If no parent, then we are in the configuration pragma file,
1735 -- so the placement is definitely appropriate.
1740 -- Otherwise we must be in the context clause of a compilation unit
1741 -- and the only thing allowed before us in the context list is more
1742 -- configuration pragmas.
1744 elsif Nkind (Par) = N_Compilation_Unit
1745 and then Context_Items (Par) = Lis
1752 elsif Nkind (Prg) /= N_Pragma then
1762 end Is_Configuration_Pragma;
1764 ----------------------
1765 -- Pragma_Misplaced --
1766 ----------------------
1768 procedure Pragma_Misplaced is
1770 Error_Pragma ("incorrect placement of pragma%");
1771 end Pragma_Misplaced;
1773 ------------------------------------
1774 -- Process Atomic_Shared_Volatile --
1775 ------------------------------------
1777 procedure Process_Atomic_Shared_Volatile is
1784 procedure Set_Atomic (E : Entity_Id);
1785 -- Set given type as atomic, and if no explicit alignment was
1786 -- given, set alignment to unknown, since back end knows what
1787 -- the alignment requirements are for atomic arrays. Note that
1788 -- this step is necessary for derived types.
1794 procedure Set_Atomic (E : Entity_Id) is
1798 if not Has_Alignment_Clause (E) then
1799 Set_Alignment (E, Uint_0);
1803 -- Start of processing for Process_Atomic_Shared_Volatile
1806 Check_Ada_83_Warning;
1807 Check_No_Identifiers;
1808 Check_Arg_Count (1);
1809 Check_Arg_Is_Local_Name (Arg1);
1810 E_Id := Expression (Arg1);
1812 if Etype (E_Id) = Any_Type then
1817 D := Declaration_Node (E);
1821 if Rep_Item_Too_Early (E, N)
1823 Rep_Item_Too_Late (E, N)
1827 Check_First_Subtype (Arg1);
1830 if Prag_Id /= Pragma_Volatile then
1832 Set_Atomic (Underlying_Type (E));
1833 Set_Atomic (Base_Type (E));
1836 -- Attribute belongs on the base type. If the
1837 -- view of the type is currently private, it also
1838 -- belongs on the underlying type.
1840 Set_Is_Volatile (Base_Type (E));
1841 Set_Is_Volatile (Underlying_Type (E));
1843 Set_Treat_As_Volatile (E);
1844 Set_Treat_As_Volatile (Underlying_Type (E));
1846 elsif K = N_Object_Declaration
1847 or else (K = N_Component_Declaration
1848 and then Original_Record_Component (E) = E)
1850 if Rep_Item_Too_Late (E, N) then
1854 if Prag_Id /= Pragma_Volatile then
1857 -- If the object declaration has an explicit
1858 -- initialization, a temporary may have to be
1859 -- created to hold the expression, to insure
1860 -- that access to the object remain atomic.
1862 if Nkind (Parent (E)) = N_Object_Declaration
1863 and then Present (Expression (Parent (E)))
1865 Set_Has_Delayed_Freeze (E);
1868 -- An interesting improvement here. If an object of type X
1869 -- is declared atomic, and the type X is not atomic, that's
1870 -- a pity, since it may not have appropraite alignment etc.
1871 -- We can rescue this in the special case where the object
1872 -- and type are in the same unit by just setting the type
1873 -- as atomic, so that the back end will process it as atomic.
1875 Utyp := Underlying_Type (Etype (E));
1878 and then Sloc (E) > No_Location
1879 and then Sloc (Utyp) > No_Location
1881 Get_Source_File_Index (Sloc (E)) =
1882 Get_Source_File_Index (Sloc (Underlying_Type (Etype (E))))
1884 Set_Is_Atomic (Underlying_Type (Etype (E)));
1888 Set_Is_Volatile (E);
1889 Set_Treat_As_Volatile (E);
1893 ("inappropriate entity for pragma%", Arg1);
1895 end Process_Atomic_Shared_Volatile;
1897 ------------------------
1898 -- Process_Convention --
1899 ------------------------
1901 procedure Process_Convention
1902 (C : out Convention_Id;
1908 Comp_Unit : Unit_Number_Type;
1910 procedure Set_Convention_From_Pragma (E : Entity_Id);
1911 -- Set convention in entity E, and also flag that the entity has a
1912 -- convention pragma. If entity is for a private or incomplete type,
1913 -- also set convention and flag on underlying type. This procedure
1914 -- also deals with the special case of C_Pass_By_Copy convention.
1916 --------------------------------
1917 -- Set_Convention_From_Pragma --
1918 --------------------------------
1920 procedure Set_Convention_From_Pragma (E : Entity_Id) is
1922 Set_Convention (E, C);
1923 Set_Has_Convention_Pragma (E);
1925 if Is_Incomplete_Or_Private_Type (E) then
1926 Set_Convention (Underlying_Type (E), C);
1927 Set_Has_Convention_Pragma (Underlying_Type (E), True);
1930 -- A class-wide type should inherit the convention of
1931 -- the specific root type (although this isn't specified
1932 -- clearly by the RM).
1934 if Is_Type (E) and then Present (Class_Wide_Type (E)) then
1935 Set_Convention (Class_Wide_Type (E), C);
1938 -- If the entity is a record type, then check for special case
1939 -- of C_Pass_By_Copy, which is treated the same as C except that
1940 -- the special record flag is set. This convention is also only
1941 -- permitted on record types (see AI95-00131).
1943 if Cname = Name_C_Pass_By_Copy then
1944 if Is_Record_Type (E) then
1945 Set_C_Pass_By_Copy (Base_Type (E));
1946 elsif Is_Incomplete_Or_Private_Type (E)
1947 and then Is_Record_Type (Underlying_Type (E))
1949 Set_C_Pass_By_Copy (Base_Type (Underlying_Type (E)));
1952 ("C_Pass_By_Copy convention allowed only for record type",
1957 -- If the entity is a derived boolean type, check for the
1958 -- special case of convention C, C++, or Fortran, where we
1959 -- consider any nonzero value to represent true.
1961 if Is_Discrete_Type (E)
1962 and then Root_Type (Etype (E)) = Standard_Boolean
1968 C = Convention_Fortran)
1970 Set_Nonzero_Is_True (Base_Type (E));
1972 end Set_Convention_From_Pragma;
1974 -- Start of processing for Process_Convention
1977 Check_At_Least_N_Arguments (2);
1978 Check_Arg_Is_Identifier (Arg1);
1979 Check_Optional_Identifier (Arg1, Name_Convention);
1980 Cname := Chars (Expression (Arg1));
1982 -- C_Pass_By_Copy is treated as a synonym for convention C
1983 -- (this is tested again below to set the critical flag)
1985 if Cname = Name_C_Pass_By_Copy then
1988 -- Otherwise we must have something in the standard convention list
1990 elsif Is_Convention_Name (Cname) then
1991 C := Get_Convention_Id (Chars (Expression (Arg1)));
1993 -- In DEC VMS, it seems that there is an undocumented feature
1994 -- that any unrecognized convention is treated as the default,
1995 -- which for us is convention C. It does not seem so terrible
1996 -- to do this unconditionally, silently in the VMS case, and
1997 -- with a warning in the non-VMS case.
2000 if Warn_On_Export_Import and not OpenVMS_On_Target then
2002 ("?unrecognized convention name, C assumed",
2009 Check_Arg_Is_Local_Name (Arg2);
2010 Check_Optional_Identifier (Arg2, Name_Entity);
2012 Id := Expression (Arg2);
2015 if not Is_Entity_Name (Id) then
2016 Error_Pragma_Arg ("entity name required", Arg2);
2021 -- Go to renamed subprogram if present, since convention applies
2022 -- to the actual renamed entity, not to the renaming entity.
2024 if Is_Subprogram (E)
2025 and then Present (Alias (E))
2026 and then Nkind (Parent (Declaration_Node (E))) =
2027 N_Subprogram_Renaming_Declaration
2032 -- Check that we not applying this to a specless body
2034 if Is_Subprogram (E)
2035 and then Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Body
2038 ("pragma% requires separate spec and must come before body");
2041 -- Check that we are not applying this to a named constant
2043 if Ekind (E) = E_Named_Integer
2045 Ekind (E) = E_Named_Real
2047 Error_Msg_Name_1 := Chars (N);
2049 ("cannot apply pragma% to named constant!",
2050 Get_Pragma_Arg (Arg2));
2052 ("\supply appropriate type for&!", Arg2);
2055 if Etype (E) = Any_Type
2056 or else Rep_Item_Too_Early (E, N)
2060 E := Underlying_Type (E);
2063 if Rep_Item_Too_Late (E, N) then
2067 if Has_Convention_Pragma (E) then
2069 ("at most one Convention/Export/Import pragma is allowed", Arg2);
2071 elsif Convention (E) = Convention_Protected
2072 or else Ekind (Scope (E)) = E_Protected_Type
2075 ("a protected operation cannot be given a different convention",
2079 -- For Intrinsic, a subprogram is required
2081 if C = Convention_Intrinsic
2082 and then not Is_Subprogram (E)
2083 and then not Is_Generic_Subprogram (E)
2086 ("second argument of pragma% must be a subprogram", Arg2);
2089 -- For Stdcall, a subprogram, variable or subprogram type is required
2091 if C = Convention_Stdcall
2092 and then not Is_Subprogram (E)
2093 and then not Is_Generic_Subprogram (E)
2094 and then Ekind (E) /= E_Variable
2097 and then Ekind (Designated_Type (E)) = E_Subprogram_Type)
2100 ("second argument of pragma% must be subprogram (type)",
2104 if not Is_Subprogram (E)
2105 and then not Is_Generic_Subprogram (E)
2107 Set_Convention_From_Pragma (E);
2111 Check_First_Subtype (Arg2);
2112 Set_Convention_From_Pragma (Base_Type (E));
2114 -- For subprograms, we must set the convention on the
2115 -- internally generated directly designated type as well.
2117 if Ekind (E) = E_Access_Subprogram_Type then
2118 Set_Convention_From_Pragma (Directly_Designated_Type (E));
2122 -- For the subprogram case, set proper convention for all homonyms
2123 -- in same scope and the same declarative part, i.e. the same
2124 -- compilation unit.
2127 Comp_Unit := Get_Source_Unit (E);
2128 Set_Convention_From_Pragma (E);
2130 -- Treat a pragma Import as an implicit body, for GPS use.
2132 if Prag_Id = Pragma_Import then
2133 Generate_Reference (E, Id, 'b');
2139 exit when No (E1) or else Scope (E1) /= Current_Scope;
2141 -- Note: below we are missing a check for Rep_Item_Too_Late.
2142 -- That is deliberate, we cannot chain the rep item on more
2143 -- than one Rep_Item chain, to be fixed later ???
2145 if Comes_From_Source (E1)
2146 and then Comp_Unit = Get_Source_Unit (E1)
2147 and then Nkind (Original_Node (Parent (E1))) /=
2148 N_Full_Type_Declaration
2150 Set_Convention_From_Pragma (E1);
2152 if Prag_Id = Pragma_Import then
2153 Generate_Reference (E, Id, 'b');
2158 end Process_Convention;
2160 -----------------------------------------------------
2161 -- Process_Extended_Import_Export_Exception_Pragma --
2162 -----------------------------------------------------
2164 procedure Process_Extended_Import_Export_Exception_Pragma
2165 (Arg_Internal : Node_Id;
2166 Arg_External : Node_Id;
2176 if not OpenVMS_On_Target then
2178 ("?pragma% ignored (applies only to Open'V'M'S)");
2181 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2182 Def_Id := Entity (Arg_Internal);
2184 if Ekind (Def_Id) /= E_Exception then
2186 ("pragma% must refer to declared exception", Arg_Internal);
2189 Set_Extended_Import_Export_External_Name (Def_Id, Arg_External);
2191 if Present (Arg_Form) then
2192 Check_Arg_Is_One_Of (Arg_Form, Name_Ada, Name_VMS);
2195 if Present (Arg_Form)
2196 and then Chars (Arg_Form) = Name_Ada
2200 Set_Is_VMS_Exception (Def_Id);
2201 Set_Exception_Code (Def_Id, No_Uint);
2204 if Present (Arg_Code) then
2205 if not Is_VMS_Exception (Def_Id) then
2207 ("Code option for pragma% not allowed for Ada case",
2211 Check_Arg_Is_Static_Expression (Arg_Code, Any_Integer);
2212 Code_Val := Expr_Value (Arg_Code);
2214 if not UI_Is_In_Int_Range (Code_Val) then
2216 ("Code option for pragma% must be in 32-bit range",
2220 Set_Exception_Code (Def_Id, Code_Val);
2223 end Process_Extended_Import_Export_Exception_Pragma;
2225 -------------------------------------------------
2226 -- Process_Extended_Import_Export_Internal_Arg --
2227 -------------------------------------------------
2229 procedure Process_Extended_Import_Export_Internal_Arg
2230 (Arg_Internal : Node_Id := Empty)
2235 if No (Arg_Internal) then
2236 Error_Pragma ("Internal parameter required for pragma%");
2239 if Nkind (Arg_Internal) = N_Identifier then
2242 elsif Nkind (Arg_Internal) = N_Operator_Symbol
2243 and then (Prag_Id = Pragma_Import_Function
2245 Prag_Id = Pragma_Export_Function)
2251 ("wrong form for Internal parameter for pragma%", Arg_Internal);
2254 Check_Arg_Is_Local_Name (Arg_Internal);
2255 end Process_Extended_Import_Export_Internal_Arg;
2257 --------------------------------------------------
2258 -- Process_Extended_Import_Export_Object_Pragma --
2259 --------------------------------------------------
2261 procedure Process_Extended_Import_Export_Object_Pragma
2262 (Arg_Internal : Node_Id;
2263 Arg_External : Node_Id;
2269 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2270 Def_Id := Entity (Arg_Internal);
2272 if Ekind (Def_Id) /= E_Constant
2273 and then Ekind (Def_Id) /= E_Variable
2276 ("pragma% must designate an object", Arg_Internal);
2279 if Is_Psected (Def_Id) then
2281 ("previous Psect_Object applies, pragma % not permitted",
2285 if Rep_Item_Too_Late (Def_Id, N) then
2289 Set_Extended_Import_Export_External_Name (Def_Id, Arg_External);
2291 if Present (Arg_Size) then
2292 Check_Arg_Is_External_Name (Arg_Size);
2295 -- Export_Object case
2297 if Prag_Id = Pragma_Export_Object then
2298 if not Is_Library_Level_Entity (Def_Id) then
2300 ("argument for pragma% must be library level entity",
2304 if Ekind (Current_Scope) = E_Generic_Package then
2305 Error_Pragma ("pragma& cannot appear in a generic unit");
2308 if not Size_Known_At_Compile_Time (Etype (Def_Id)) then
2310 ("exported object must have compile time known size",
2314 if Warn_On_Export_Import and then Is_Exported (Def_Id) then
2316 ("?duplicate Export_Object pragma", N);
2318 Set_Exported (Def_Id, Arg_Internal);
2321 -- Import_Object case
2324 if Is_Concurrent_Type (Etype (Def_Id)) then
2326 ("cannot use pragma% for task/protected object",
2330 if Ekind (Def_Id) = E_Constant then
2332 ("cannot import a constant", Arg_Internal);
2335 if Warn_On_Export_Import
2336 and then Has_Discriminants (Etype (Def_Id))
2339 ("imported value must be initialized?", Arg_Internal);
2342 if Warn_On_Export_Import
2343 and then Is_Access_Type (Etype (Def_Id))
2346 ("cannot import object of an access type?", Arg_Internal);
2349 if Warn_On_Export_Import
2350 and then Is_Imported (Def_Id)
2353 ("?duplicate Import_Object pragma", N);
2355 -- Check for explicit initialization present. Note that an
2356 -- initialization that generated by the code generator, e.g.
2357 -- for an access type, does not count here.
2359 elsif Present (Expression (Parent (Def_Id)))
2362 (Original_Node (Expression (Parent (Def_Id))))
2364 Error_Msg_Sloc := Sloc (Def_Id);
2366 ("no initialization allowed for declaration of& #",
2367 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2370 Set_Imported (Def_Id);
2371 Note_Possible_Modification (Arg_Internal);
2374 end Process_Extended_Import_Export_Object_Pragma;
2376 ------------------------------------------------------
2377 -- Process_Extended_Import_Export_Subprogram_Pragma --
2378 ------------------------------------------------------
2380 procedure Process_Extended_Import_Export_Subprogram_Pragma
2381 (Arg_Internal : Node_Id;
2382 Arg_External : Node_Id;
2383 Arg_Parameter_Types : Node_Id;
2384 Arg_Result_Type : Node_Id := Empty;
2385 Arg_Mechanism : Node_Id;
2386 Arg_Result_Mechanism : Node_Id := Empty;
2387 Arg_First_Optional_Parameter : Node_Id := Empty)
2393 Ambiguous : Boolean;
2397 function Same_Base_Type
2399 Formal : Entity_Id) return Boolean;
2400 -- Determines if Ptype references the type of Formal. Note that
2401 -- only the base types need to match according to the spec. Ptype
2402 -- here is the argument from the pragma, which is either a type
2403 -- name, or an access attribute.
2405 --------------------
2406 -- Same_Base_Type --
2407 --------------------
2409 function Same_Base_Type
2411 Formal : Entity_Id) return Boolean
2413 Ftyp : constant Entity_Id := Base_Type (Etype (Formal));
2417 -- Case where pragma argument is typ'Access
2419 if Nkind (Ptype) = N_Attribute_Reference
2420 and then Attribute_Name (Ptype) = Name_Access
2422 Pref := Prefix (Ptype);
2425 if not Is_Entity_Name (Pref)
2426 or else Entity (Pref) = Any_Type
2431 -- We have a match if the corresponding argument is of an
2432 -- anonymous access type, and its designicated type matches
2433 -- the type of the prefix of the access attribute
2435 return Ekind (Ftyp) = E_Anonymous_Access_Type
2436 and then Base_Type (Entity (Pref)) =
2437 Base_Type (Etype (Designated_Type (Ftyp)));
2439 -- Case where pragma argument is a type name
2444 if not Is_Entity_Name (Ptype)
2445 or else Entity (Ptype) = Any_Type
2450 -- We have a match if the corresponding argument is of
2451 -- the type given in the pragma (comparing base types)
2453 return Base_Type (Entity (Ptype)) = Ftyp;
2457 -- Start of processing for
2458 -- Process_Extended_Import_Export_Subprogram_Pragma
2461 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2462 Hom_Id := Entity (Arg_Internal);
2466 -- Loop through homonyms (overloadings) of Hom_Id
2468 while Present (Hom_Id) loop
2469 Def_Id := Get_Base_Subprogram (Hom_Id);
2471 -- We need a subprogram in the current scope
2473 if not Is_Subprogram (Def_Id)
2474 or else Scope (Def_Id) /= Current_Scope
2481 -- Pragma cannot apply to subprogram body
2483 if Is_Subprogram (Def_Id)
2486 (Declaration_Node (Def_Id))) = N_Subprogram_Body
2489 ("pragma% requires separate spec"
2490 & " and must come before body");
2493 -- Test result type if given, note that the result type
2494 -- parameter can only be present for the function cases.
2496 if Present (Arg_Result_Type)
2497 and then not Same_Base_Type (Arg_Result_Type, Def_Id)
2501 elsif Etype (Def_Id) /= Standard_Void_Type
2503 (Chars (N) = Name_Export_Procedure
2504 or else Chars (N) = Name_Import_Procedure)
2508 -- Test parameter types if given. Note that this parameter
2509 -- has not been analyzed (and must not be, since it is
2510 -- semantic nonsense), so we get it as the parser left it.
2512 elsif Present (Arg_Parameter_Types) then
2513 Check_Matching_Types : declare
2518 Formal := First_Formal (Def_Id);
2520 if Nkind (Arg_Parameter_Types) = N_Null then
2521 if Present (Formal) then
2525 -- A list of one type, e.g. (List) is parsed as
2526 -- a parenthesized expression.
2528 elsif Nkind (Arg_Parameter_Types) /= N_Aggregate
2529 and then Paren_Count (Arg_Parameter_Types) = 1
2532 or else Present (Next_Formal (Formal))
2537 Same_Base_Type (Arg_Parameter_Types, Formal);
2540 -- A list of more than one type is parsed as a aggregate
2542 elsif Nkind (Arg_Parameter_Types) = N_Aggregate
2543 and then Paren_Count (Arg_Parameter_Types) = 0
2545 Ptype := First (Expressions (Arg_Parameter_Types));
2546 while Present (Ptype) or else Present (Formal) loop
2549 or else not Same_Base_Type (Ptype, Formal)
2554 Next_Formal (Formal);
2559 -- Anything else is of the wrong form
2563 ("wrong form for Parameter_Types parameter",
2564 Arg_Parameter_Types);
2566 end Check_Matching_Types;
2569 -- Match is now False if the entry we found did not match
2570 -- either a supplied Parameter_Types or Result_Types argument
2576 -- Ambiguous case, the flag Ambiguous shows if we already
2577 -- detected this and output the initial messages.
2580 if not Ambiguous then
2582 Error_Msg_Name_1 := Chars (N);
2584 ("pragma% does not uniquely identify subprogram!",
2586 Error_Msg_Sloc := Sloc (Ent);
2587 Error_Msg_N ("matching subprogram #!", N);
2591 Error_Msg_Sloc := Sloc (Def_Id);
2592 Error_Msg_N ("matching subprogram #!", N);
2597 Hom_Id := Homonym (Hom_Id);
2600 -- See if we found an entry
2603 if not Ambiguous then
2604 if Is_Generic_Subprogram (Entity (Arg_Internal)) then
2606 ("pragma% cannot be given for generic subprogram");
2610 ("pragma% does not identify local subprogram");
2617 -- Import pragmas must be be for imported entities
2619 if Prag_Id = Pragma_Import_Function
2621 Prag_Id = Pragma_Import_Procedure
2623 Prag_Id = Pragma_Import_Valued_Procedure
2625 if not Is_Imported (Ent) then
2627 ("pragma Import or Interface must precede pragma%");
2630 -- Here we have the Export case which can set the entity as exported
2632 -- But does not do so if the specified external name is null,
2633 -- since that is taken as a signal in DEC Ada 83 (with which
2634 -- we want to be compatible) to request no external name.
2636 elsif Nkind (Arg_External) = N_String_Literal
2637 and then String_Length (Strval (Arg_External)) = 0
2641 -- In all other cases, set entit as exported
2644 Set_Exported (Ent, Arg_Internal);
2647 -- Special processing for Valued_Procedure cases
2649 if Prag_Id = Pragma_Import_Valued_Procedure
2651 Prag_Id = Pragma_Export_Valued_Procedure
2653 Formal := First_Formal (Ent);
2657 ("at least one parameter required for pragma%");
2659 elsif Ekind (Formal) /= E_Out_Parameter then
2661 ("first parameter must have mode out for pragma%");
2664 Set_Is_Valued_Procedure (Ent);
2668 Set_Extended_Import_Export_External_Name (Ent, Arg_External);
2670 -- Process Result_Mechanism argument if present. We have already
2671 -- checked that this is only allowed for the function case.
2673 if Present (Arg_Result_Mechanism) then
2674 Set_Mechanism_Value (Ent, Arg_Result_Mechanism);
2677 -- Process Mechanism parameter if present. Note that this parameter
2678 -- is not analyzed, and must not be analyzed since it is semantic
2679 -- nonsense, so we get it in exactly as the parser left it.
2681 if Present (Arg_Mechanism) then
2689 -- A single mechanism association without a formal parameter
2690 -- name is parsed as a parenthesized expression. All other
2691 -- cases are parsed as aggregates, so we rewrite the single
2692 -- parameter case as an aggregate for consistency.
2694 if Nkind (Arg_Mechanism) /= N_Aggregate
2695 and then Paren_Count (Arg_Mechanism) = 1
2697 Rewrite (Arg_Mechanism,
2698 Make_Aggregate (Sloc (Arg_Mechanism),
2699 Expressions => New_List (
2700 Relocate_Node (Arg_Mechanism))));
2703 -- Case of only mechanism name given, applies to all formals
2705 if Nkind (Arg_Mechanism) /= N_Aggregate then
2706 Formal := First_Formal (Ent);
2707 while Present (Formal) loop
2708 Set_Mechanism_Value (Formal, Arg_Mechanism);
2709 Next_Formal (Formal);
2712 -- Case of list of mechanism associations given
2715 if Null_Record_Present (Arg_Mechanism) then
2717 ("inappropriate form for Mechanism parameter",
2721 -- Deal with positional ones first
2723 Formal := First_Formal (Ent);
2724 if Present (Expressions (Arg_Mechanism)) then
2725 Mname := First (Expressions (Arg_Mechanism));
2727 while Present (Mname) loop
2730 ("too many mechanism associations", Mname);
2733 Set_Mechanism_Value (Formal, Mname);
2734 Next_Formal (Formal);
2739 -- Deal with named entries
2741 if Present (Component_Associations (Arg_Mechanism)) then
2742 Massoc := First (Component_Associations (Arg_Mechanism));
2744 while Present (Massoc) loop
2745 Choice := First (Choices (Massoc));
2747 if Nkind (Choice) /= N_Identifier
2748 or else Present (Next (Choice))
2751 ("incorrect form for mechanism association",
2755 Formal := First_Formal (Ent);
2759 ("parameter name & not present", Choice);
2762 if Chars (Choice) = Chars (Formal) then
2764 (Formal, Expression (Massoc));
2768 Next_Formal (Formal);
2778 -- Process First_Optional_Parameter argument if present. We have
2779 -- already checked that this is only allowed for the Import case.
2781 if Present (Arg_First_Optional_Parameter) then
2782 if Nkind (Arg_First_Optional_Parameter) /= N_Identifier then
2784 ("first optional parameter must be formal parameter name",
2785 Arg_First_Optional_Parameter);
2788 Formal := First_Formal (Ent);
2792 ("specified formal parameter& not found",
2793 Arg_First_Optional_Parameter);
2796 exit when Chars (Formal) =
2797 Chars (Arg_First_Optional_Parameter);
2799 Next_Formal (Formal);
2802 Set_First_Optional_Parameter (Ent, Formal);
2804 -- Check specified and all remaining formals have right form
2806 while Present (Formal) loop
2807 if Ekind (Formal) /= E_In_Parameter then
2809 ("optional formal& is not of mode in!",
2810 Arg_First_Optional_Parameter, Formal);
2813 Dval := Default_Value (Formal);
2815 if not Present (Dval) then
2817 ("optional formal& does not have default value!",
2818 Arg_First_Optional_Parameter, Formal);
2820 elsif Compile_Time_Known_Value_Or_Aggr (Dval) then
2825 ("default value for optional formal& is non-static!",
2826 Arg_First_Optional_Parameter, Formal);
2830 Set_Is_Optional_Parameter (Formal);
2831 Next_Formal (Formal);
2834 end Process_Extended_Import_Export_Subprogram_Pragma;
2836 --------------------------
2837 -- Process_Generic_List --
2838 --------------------------
2840 procedure Process_Generic_List is
2846 Check_No_Identifiers;
2847 Check_At_Least_N_Arguments (1);
2850 while Present (Arg) loop
2851 Exp := Expression (Arg);
2854 if not Is_Entity_Name (Exp)
2856 (not Is_Generic_Instance (Entity (Exp))
2858 not Is_Generic_Unit (Entity (Exp)))
2861 ("pragma% argument must be name of generic unit/instance",
2867 end Process_Generic_List;
2869 ---------------------------------
2870 -- Process_Import_Or_Interface --
2871 ---------------------------------
2873 procedure Process_Import_Or_Interface is
2879 Process_Convention (C, Def_Id);
2880 Kill_Size_Check_Code (Def_Id);
2881 Note_Possible_Modification (Expression (Arg2));
2883 if Ekind (Def_Id) = E_Variable
2885 Ekind (Def_Id) = E_Constant
2887 -- User initialization is not allowed for imported object, but
2888 -- the object declaration may contain a default initialization,
2889 -- that will be discarded. Note that an explicit initialization
2890 -- only counts if it comes from source, otherwise it is simply
2891 -- the code generator making an implicit initialization explicit.
2893 if Present (Expression (Parent (Def_Id)))
2894 and then Comes_From_Source (Expression (Parent (Def_Id)))
2896 Error_Msg_Sloc := Sloc (Def_Id);
2898 ("no initialization allowed for declaration of& #",
2899 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2903 Set_Imported (Def_Id);
2904 Set_Is_Public (Def_Id);
2905 Process_Interface_Name (Def_Id, Arg3, Arg4);
2907 -- pragma Import completes deferred constants
2909 if Ekind (Def_Id) = E_Constant then
2910 Set_Has_Completion (Def_Id);
2913 -- It is not possible to import a constant of an unconstrained
2914 -- array type (e.g. string) because there is no simple way to
2915 -- write a meaningful subtype for it.
2917 if Is_Array_Type (Etype (Def_Id))
2918 and then not Is_Constrained (Etype (Def_Id))
2921 ("imported constant& must have a constrained subtype",
2926 elsif Is_Subprogram (Def_Id)
2927 or else Is_Generic_Subprogram (Def_Id)
2929 -- If the name is overloaded, pragma applies to all of the
2930 -- denoted entities in the same declarative part.
2934 while Present (Hom_Id) loop
2935 Def_Id := Get_Base_Subprogram (Hom_Id);
2937 -- Ignore inherited subprograms because the pragma will
2938 -- apply to the parent operation, which is the one called.
2940 if Is_Overloadable (Def_Id)
2941 and then Present (Alias (Def_Id))
2945 -- If it is not a subprogram, it must be in an outer
2946 -- scope and pragma does not apply.
2948 elsif not Is_Subprogram (Def_Id)
2949 and then not Is_Generic_Subprogram (Def_Id)
2953 -- Verify that the homonym is in the same declarative
2954 -- part (not just the same scope).
2956 elsif Parent (Unit_Declaration_Node (Def_Id)) /= Parent (N)
2957 and then Nkind (Parent (N)) /= N_Compilation_Unit_Aux
2962 Set_Imported (Def_Id);
2964 -- If Import intrinsic, set intrinsic flag
2965 -- and verify that it is known as such.
2967 if C = Convention_Intrinsic then
2968 Set_Is_Intrinsic_Subprogram (Def_Id);
2969 Check_Intrinsic_Subprogram
2970 (Def_Id, Expression (Arg2));
2973 -- All interfaced procedures need an external
2974 -- symbol created for them since they are
2975 -- always referenced from another object file.
2977 Set_Is_Public (Def_Id);
2979 -- Verify that the subprogram does not have a completion
2980 -- through a renaming declaration. For other completions
2981 -- the pragma appears as a too late representation.
2984 Decl : constant Node_Id := Unit_Declaration_Node (Def_Id);
2988 and then Nkind (Decl) = N_Subprogram_Declaration
2989 and then Present (Corresponding_Body (Decl))
2992 (Unit_Declaration_Node
2993 (Corresponding_Body (Decl))) =
2994 N_Subprogram_Renaming_Declaration
2996 Error_Msg_Sloc := Sloc (Def_Id);
2997 Error_Msg_NE ("cannot import&#," &
2998 " already completed by a renaming",
3003 Set_Has_Completion (Def_Id);
3004 Process_Interface_Name (Def_Id, Arg3, Arg4);
3007 if Is_Compilation_Unit (Hom_Id) then
3009 -- Its possible homonyms are not affected by the pragma.
3010 -- Such homonyms might be present in the context of other
3011 -- units being compiled.
3016 Hom_Id := Homonym (Hom_Id);
3020 -- When the convention is Java, we also allow Import to be given
3021 -- for packages, exceptions, and record components.
3023 elsif C = Convention_Java
3025 (Ekind (Def_Id) = E_Package
3026 or else Ekind (Def_Id) = E_Exception
3027 or else Nkind (Parent (Def_Id)) = N_Component_Declaration)
3029 Set_Imported (Def_Id);
3030 Set_Is_Public (Def_Id);
3031 Process_Interface_Name (Def_Id, Arg3, Arg4);
3035 ("second argument of pragma% must be object or subprogram",
3039 -- If this pragma applies to a compilation unit, then the unit,
3040 -- which is a subprogram, does not require (or allow) a body.
3041 -- We also do not need to elaborate imported procedures.
3043 if Nkind (Parent (N)) = N_Compilation_Unit_Aux then
3045 Cunit : constant Node_Id := Parent (Parent (N));
3047 Set_Body_Required (Cunit, False);
3050 end Process_Import_Or_Interface;
3052 --------------------
3053 -- Process_Inline --
3054 --------------------
3056 procedure Process_Inline (Active : Boolean) is
3062 Effective : Boolean := False;
3064 procedure Make_Inline (Subp : Entity_Id);
3065 -- Subp is the defining unit name of the subprogram
3066 -- declaration. Set the flag, as well as the flag in the
3067 -- corresponding body, if there is one present.
3069 procedure Set_Inline_Flags (Subp : Entity_Id);
3070 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp
3072 function Cannot_Inline (Subp : Entity_Id) return Boolean;
3073 -- Do not set the inline flag if body is available and contains
3074 -- exception handlers, to prevent undefined symbols at link time.
3075 -- Emit warning if front-end inlining is enabled and the pragma
3076 -- appears too late.
3082 function Cannot_Inline (Subp : Entity_Id) return Boolean is
3083 Decl : constant Node_Id := Unit_Declaration_Node (Subp);
3086 if Nkind (Decl) = N_Subprogram_Body then
3089 (Exception_Handlers (Handled_Statement_Sequence (Decl)));
3091 elsif Nkind (Decl) = N_Subprogram_Declaration
3092 and then Present (Corresponding_Body (Decl))
3094 if Front_End_Inlining
3095 and then Analyzed (Corresponding_Body (Decl))
3097 Error_Msg_N ("pragma appears too late, ignored?", N);
3100 -- If the subprogram is a renaming as body, the body is
3101 -- just a call to the renamed subprogram, and inlining is
3102 -- trivially possible.
3105 Nkind (Unit_Declaration_Node (Corresponding_Body (Decl)))
3106 = N_Subprogram_Renaming_Declaration
3112 Present (Exception_Handlers
3113 (Handled_Statement_Sequence
3114 (Unit_Declaration_Node (Corresponding_Body (Decl)))));
3117 -- If body is not available, assume the best, the check is
3118 -- performed again when compiling enclosing package bodies.
3128 procedure Make_Inline (Subp : Entity_Id) is
3129 Kind : constant Entity_Kind := Ekind (Subp);
3130 Inner_Subp : Entity_Id := Subp;
3133 if Etype (Subp) = Any_Type then
3136 elsif Cannot_Inline (Subp) then
3137 Applies := True; -- Do not treat as an error.
3140 -- Here we have a candidate for inlining, but we must exclude
3141 -- derived operations. Otherwise we will end up trying to
3142 -- inline a phantom declaration, and the result would be to
3143 -- drag in a body which has no direct inlining associated with
3144 -- it. That would not only be inefficient but would also result
3145 -- in the backend doing cross-unit inlining in cases where it
3146 -- was definitely inappropriate to do so.
3148 -- However, a simple Comes_From_Source test is insufficient,
3149 -- since we do want to allow inlining of generic instances,
3150 -- which also do not come from source. Predefined operators do
3151 -- not come from source but are not inlineable either.
3153 elsif not Comes_From_Source (Subp)
3154 and then not Is_Generic_Instance (Subp)
3155 and then Scope (Subp) /= Standard_Standard
3160 -- The referenced entity must either be the enclosing entity,
3161 -- or an entity declared within the current open scope.
3163 elsif Present (Scope (Subp))
3164 and then Scope (Subp) /= Current_Scope
3165 and then Subp /= Current_Scope
3168 ("argument of% must be entity in current scope", Assoc);
3172 -- Processing for procedure, operator or function.
3173 -- If subprogram is aliased (as for an instance) indicate
3174 -- that the renamed entity (if declared in the same unit)
3177 if Is_Subprogram (Subp) then
3178 while Present (Alias (Inner_Subp)) loop
3179 Inner_Subp := Alias (Inner_Subp);
3182 if In_Same_Source_Unit (Subp, Inner_Subp) then
3183 Set_Inline_Flags (Inner_Subp);
3185 Decl := Parent (Parent (Inner_Subp));
3187 if Nkind (Decl) = N_Subprogram_Declaration
3188 and then Present (Corresponding_Body (Decl))
3190 Set_Inline_Flags (Corresponding_Body (Decl));
3196 -- For a generic subprogram set flag as well, for use at
3197 -- the point of instantiation, to determine whether the
3198 -- body should be generated.
3200 elsif Is_Generic_Subprogram (Subp) then
3201 Set_Inline_Flags (Subp);
3204 -- Literals are by definition inlined
3206 elsif Kind = E_Enumeration_Literal then
3209 -- Anything else is an error
3213 ("expect subprogram name for pragma%", Assoc);
3217 ----------------------
3218 -- Set_Inline_Flags --
3219 ----------------------
3221 procedure Set_Inline_Flags (Subp : Entity_Id) is
3224 Set_Is_Inlined (Subp, True);
3227 if not Has_Pragma_Inline (Subp) then
3228 Set_Has_Pragma_Inline (Subp);
3229 Set_Next_Rep_Item (N, First_Rep_Item (Subp));
3230 Set_First_Rep_Item (Subp, N);
3233 end Set_Inline_Flags;
3235 -- Start of processing for Process_Inline
3238 Check_No_Identifiers;
3239 Check_At_Least_N_Arguments (1);
3242 Inline_Processing_Required := True;
3246 while Present (Assoc) loop
3247 Subp_Id := Expression (Assoc);
3251 if Is_Entity_Name (Subp_Id) then
3252 Subp := Entity (Subp_Id);
3254 if Subp = Any_Id then
3260 while Present (Homonym (Subp))
3261 and then Scope (Homonym (Subp)) = Current_Scope
3263 Make_Inline (Homonym (Subp));
3264 Subp := Homonym (Subp);
3271 ("inappropriate argument for pragma%", Assoc);
3274 and then Warn_On_Redundant_Constructs
3276 Error_Msg_NE ("pragma inline on& is redundant?",
3277 N, Entity (Subp_Id));
3284 ----------------------------
3285 -- Process_Interface_Name --
3286 ----------------------------
3288 procedure Process_Interface_Name
3289 (Subprogram_Def : Entity_Id;
3295 String_Val : String_Id;
3297 procedure Check_Form_Of_Interface_Name (SN : Node_Id);
3298 -- SN is a string literal node for an interface name. This routine
3299 -- performs some minimal checks that the name is reasonable. In
3300 -- particular that no spaces or other obviously incorrect characters
3301 -- appear. This is only a warning, since any characters are allowed.
3303 procedure Check_Form_Of_Interface_Name (SN : Node_Id) is
3304 S : constant String_Id := Strval (Expr_Value_S (SN));
3305 SL : constant Nat := String_Length (S);
3310 Error_Msg_N ("interface name cannot be null string", SN);
3313 for J in 1 .. SL loop
3314 C := Get_String_Char (S, J);
3316 if Warn_On_Export_Import
3317 and then (not In_Character_Range (C)
3318 or else Get_Character (C) = ' '
3319 or else Get_Character (C) = ',')
3322 ("?interface name contains illegal character", SN);
3325 end Check_Form_Of_Interface_Name;
3327 -- Start of processing for Process_Interface_Name
3330 if No (Link_Arg) then
3331 if No (Ext_Arg) then
3334 elsif Chars (Ext_Arg) = Name_Link_Name then
3336 Link_Nam := Expression (Ext_Arg);
3339 Check_Optional_Identifier (Ext_Arg, Name_External_Name);
3340 Ext_Nam := Expression (Ext_Arg);
3345 Check_Optional_Identifier (Ext_Arg, Name_External_Name);
3346 Check_Optional_Identifier (Link_Arg, Name_Link_Name);
3347 Ext_Nam := Expression (Ext_Arg);
3348 Link_Nam := Expression (Link_Arg);
3351 -- Check expressions for external name and link name are static
3353 if Present (Ext_Nam) then
3354 Check_Arg_Is_Static_Expression (Ext_Nam, Standard_String);
3355 Check_Form_Of_Interface_Name (Ext_Nam);
3357 -- Verify that the external name is not the name of a local
3358 -- entity, which would hide the imported one and lead to
3359 -- run-time surprises. The problem can only arise for entities
3360 -- declared in a package body (otherwise the external name is
3361 -- fully qualified and won't conflict).
3369 if Prag_Id = Pragma_Import then
3370 String_To_Name_Buffer (Strval (Expr_Value_S (Ext_Nam)));
3372 E := Entity_Id (Get_Name_Table_Info (Nam));
3374 if Nam /= Chars (Subprogram_Def)
3375 and then Present (E)
3376 and then not Is_Overloadable (E)
3377 and then Is_Immediately_Visible (E)
3378 and then not Is_Imported (E)
3379 and then Ekind (Scope (E)) = E_Package
3383 while Present (Par) loop
3384 if Nkind (Par) = N_Package_Body then
3385 Error_Msg_Sloc := Sloc (E);
3387 ("imported entity is hidden by & declared#",
3392 Par := Parent (Par);
3399 if Present (Link_Nam) then
3400 Check_Arg_Is_Static_Expression (Link_Nam, Standard_String);
3401 Check_Form_Of_Interface_Name (Link_Nam);
3404 -- If there is no link name, just set the external name
3406 if No (Link_Nam) then
3407 Link_Nam := Adjust_External_Name_Case (Expr_Value_S (Ext_Nam));
3409 -- For the Link_Name case, the given literal is preceded by an
3410 -- asterisk, which indicates to GCC that the given name should
3411 -- be taken literally, and in particular that no prepending of
3412 -- underlines should occur, even in systems where this is the
3417 Store_String_Char (Get_Char_Code ('*'));
3418 String_Val := Strval (Expr_Value_S (Link_Nam));
3420 for J in 1 .. String_Length (String_Val) loop
3421 Store_String_Char (Get_String_Char (String_Val, J));
3425 Make_String_Literal (Sloc (Link_Nam), End_String);
3428 Set_Encoded_Interface_Name
3429 (Get_Base_Subprogram (Subprogram_Def), Link_Nam);
3430 Check_Duplicated_Export_Name (Link_Nam);
3431 end Process_Interface_Name;
3433 -----------------------------------------
3434 -- Process_Interrupt_Or_Attach_Handler --
3435 -----------------------------------------
3437 procedure Process_Interrupt_Or_Attach_Handler is
3438 Arg1_X : constant Node_Id := Expression (Arg1);
3439 Handler_Proc : constant Entity_Id := Entity (Arg1_X);
3440 Proc_Scope : constant Entity_Id := Scope (Handler_Proc);
3443 Set_Is_Interrupt_Handler (Handler_Proc);
3445 -- If the pragma is not associated with a handler procedure
3446 -- within a protected type, then it must be for a nonprotected
3447 -- procedure for the AAMP target, in which case we don't
3448 -- associate a representation item with the procedure's scope.
3450 if Ekind (Proc_Scope) = E_Protected_Type then
3451 if Prag_Id = Pragma_Interrupt_Handler
3453 Prag_Id = Pragma_Attach_Handler
3455 Record_Rep_Item (Proc_Scope, N);
3458 end Process_Interrupt_Or_Attach_Handler;
3460 --------------------------------------------------
3461 -- Process_Restrictions_Or_Restriction_Warnings --
3462 --------------------------------------------------
3464 procedure Process_Restrictions_Or_Restriction_Warnings is
3466 R_Id : Restriction_Id;
3471 procedure Set_Warning (R : All_Restrictions);
3472 -- If this is a Restriction_Warnings pragma, set warning flag,
3473 -- otherwise reset the flag.
3479 procedure Set_Warning (R : All_Restrictions) is
3481 if Prag_Id = Pragma_Restriction_Warnings then
3482 Restriction_Warnings (R) := True;
3484 Restriction_Warnings (R) := False;
3488 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
3491 Check_Ada_83_Warning;
3492 Check_At_Least_N_Arguments (1);
3493 Check_Valid_Configuration_Pragma;
3496 while Present (Arg) loop
3498 Expr := Expression (Arg);
3500 -- Case of no restriction identifier present
3502 if Id = No_Name then
3503 if Nkind (Expr) /= N_Identifier then
3505 ("invalid form for restriction", Arg);
3510 (Process_Restriction_Synonyms (Expr));
3512 if R_Id not in All_Boolean_Restrictions then
3514 ("invalid restriction identifier", Arg);
3517 if Implementation_Restriction (R_Id) then
3519 (No_Implementation_Restrictions, Arg);
3522 Set_Restriction (R_Id, N);
3525 -- A very special case that must be processed here:
3526 -- pragma Restrictions (No_Exceptions) turns off
3527 -- all run-time checking. This is a bit dubious in
3528 -- terms of the formal language definition, but it
3529 -- is what is intended by RM H.4(12).
3531 if R_Id = No_Exceptions then
3532 Scope_Suppress := (others => True);
3535 -- Case of restriction identifier present
3538 R_Id := Get_Restriction_Id (Process_Restriction_Synonyms (Arg));
3539 Analyze_And_Resolve (Expr, Any_Integer);
3541 if R_Id not in All_Parameter_Restrictions then
3543 ("invalid restriction parameter identifier", Arg);
3545 elsif not Is_OK_Static_Expression (Expr) then
3546 Flag_Non_Static_Expr
3547 ("value must be static expression!", Expr);
3550 elsif not Is_Integer_Type (Etype (Expr))
3551 or else Expr_Value (Expr) < 0
3554 ("value must be non-negative integer", Arg);
3556 -- Restriction pragma is active
3559 Val := Expr_Value (Expr);
3561 if not UI_Is_In_Int_Range (Val) then
3563 ("pragma ignored, value too large?", Arg);
3565 Set_Restriction (R_Id, N, Integer (UI_To_Int (Val)));
3573 end Process_Restrictions_Or_Restriction_Warnings;
3575 ---------------------------------
3576 -- Process_Suppress_Unsuppress --
3577 ---------------------------------
3579 -- Note: this procedure makes entries in the check suppress data
3580 -- structures managed by Sem. See spec of package Sem for full
3581 -- details on how we handle recording of check suppression.
3583 procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean) is
3588 In_Package_Spec : constant Boolean :=
3589 (Ekind (Current_Scope) = E_Package
3591 Ekind (Current_Scope) = E_Generic_Package)
3592 and then not In_Package_Body (Current_Scope);
3594 procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id);
3595 -- Used to suppress a single check on the given entity
3597 --------------------------------
3598 -- Suppress_Unsuppress_Echeck --
3599 --------------------------------
3601 procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id) is
3602 ESR : constant Entity_Check_Suppress_Record :=
3605 Suppress => Suppress_Case);
3608 Set_Checks_May_Be_Suppressed (E);
3610 if In_Package_Spec then
3611 Global_Entity_Suppress.Append (ESR);
3613 Local_Entity_Suppress.Append (ESR);
3616 -- If this is a first subtype, and the base type is distinct,
3617 -- then also set the suppress flags on the base type.
3619 if Is_First_Subtype (E)
3620 and then Etype (E) /= E
3622 Suppress_Unsuppress_Echeck (Etype (E), C);
3624 end Suppress_Unsuppress_Echeck;
3626 -- Start of processing for Process_Suppress_Unsuppress
3629 -- Suppress/Unsuppress can appear as a configuration pragma,
3630 -- or in a declarative part or a package spec (RM 11.5(5))
3632 if not Is_Configuration_Pragma then
3633 Check_Is_In_Decl_Part_Or_Package_Spec;
3636 Check_At_Least_N_Arguments (1);
3637 Check_At_Most_N_Arguments (2);
3638 Check_No_Identifier (Arg1);
3639 Check_Arg_Is_Identifier (Arg1);
3641 if not Is_Check_Name (Chars (Expression (Arg1))) then
3643 ("argument of pragma% is not valid check name", Arg1);
3645 C := Get_Check_Id (Chars (Expression (Arg1)));
3648 if Arg_Count = 1 then
3650 -- Make an entry in the local scope suppress table. This is the
3651 -- table that directly shows the current value of the scope
3652 -- suppress check for any check id value.
3654 if C = All_Checks then
3655 for J in Scope_Suppress'Range loop
3656 Scope_Suppress (J) := Suppress_Case;
3659 Scope_Suppress (C) := Suppress_Case;
3662 -- Also make an entry in the Local_Entity_Suppress table. See
3663 -- extended description in the package spec of Sem for details.
3665 Local_Entity_Suppress.Append
3668 Suppress => Suppress_Case));
3670 -- Case of two arguments present, where the check is
3671 -- suppressed for a specified entity (given as the second
3672 -- argument of the pragma)
3675 Check_Optional_Identifier (Arg2, Name_On);
3676 E_Id := Expression (Arg2);
3679 if not Is_Entity_Name (E_Id) then
3681 ("second argument of pragma% must be entity name", Arg2);
3690 -- Enforce RM 11.5(7) which requires that for a pragma that
3691 -- appears within a package spec, the named entity must be
3692 -- within the package spec. We allow the package name itself
3693 -- to be mentioned since that makes sense, although it is not
3694 -- strictly allowed by 11.5(7).
3697 and then E /= Current_Scope
3698 and then Scope (E) /= Current_Scope
3701 ("entity in pragma% is not in package spec ('R'M 11.5(7))",
3705 -- Loop through homonyms. As noted below, in the case of a package
3706 -- spec, only homonyms within the package spec are considered.
3709 Suppress_Unsuppress_Echeck (E, C);
3711 if Is_Generic_Instance (E)
3712 and then Is_Subprogram (E)
3713 and then Present (Alias (E))
3715 Suppress_Unsuppress_Echeck (Alias (E), C);
3718 -- Move to next homonym
3723 -- If we are within a package specification, the
3724 -- pragma only applies to homonyms in the same scope.
3726 exit when In_Package_Spec
3727 and then Scope (E) /= Current_Scope;
3730 end Process_Suppress_Unsuppress;
3736 procedure Set_Exported (E : Entity_Id; Arg : Node_Id) is
3738 if Is_Imported (E) then
3740 ("cannot export entity& that was previously imported", Arg);
3742 elsif Present (Address_Clause (E)) then
3744 ("cannot export entity& that has an address clause", Arg);
3747 Set_Is_Exported (E);
3749 -- Generate a reference for entity explicitly, because the
3750 -- identifier may be overloaded and name resolution will not
3753 Generate_Reference (E, Arg);
3755 -- Deal with exporting non-library level entity
3757 if not Is_Library_Level_Entity (E) then
3759 -- Not allowed at all for subprograms
3761 if Is_Subprogram (E) then
3762 Error_Pragma_Arg ("local subprogram& cannot be exported", Arg);
3764 -- Otherwise set public and statically allocated
3768 Set_Is_Statically_Allocated (E);
3770 -- Warn if the corresponding W flag is set and the pragma
3771 -- comes from source. The latter may not be true e.g. on
3772 -- VMS where we expand export pragmas for exception codes
3773 -- associated with imported or exported exceptions. We do
3774 -- not want to generate a warning for something that the
3775 -- user did not write.
3777 if Warn_On_Export_Import
3778 and then Comes_From_Source (Arg)
3781 ("?& has been made static as a result of Export", Arg, E);
3783 ("\this usage is non-standard and non-portable", Arg);
3788 if Warn_On_Export_Import and then Is_Type (E) then
3790 ("exporting a type has no effect?", Arg, E);
3793 if Warn_On_Export_Import and Inside_A_Generic then
3795 ("all instances of& will have the same external name?", Arg, E);
3799 ----------------------------------------------
3800 -- Set_Extended_Import_Export_External_Name --
3801 ----------------------------------------------
3803 procedure Set_Extended_Import_Export_External_Name
3804 (Internal_Ent : Entity_Id;
3805 Arg_External : Node_Id)
3807 Old_Name : constant Node_Id := Interface_Name (Internal_Ent);
3811 if No (Arg_External) then
3815 Check_Arg_Is_External_Name (Arg_External);
3817 if Nkind (Arg_External) = N_String_Literal then
3818 if String_Length (Strval (Arg_External)) = 0 then
3821 New_Name := Adjust_External_Name_Case (Arg_External);
3824 elsif Nkind (Arg_External) = N_Identifier then
3825 New_Name := Get_Default_External_Name (Arg_External);
3827 -- Check_Arg_Is_External_Name should let through only
3828 -- identifiers and string literals or static string
3829 -- expressions (which are folded to string literals).
3832 raise Program_Error;
3835 -- If we already have an external name set (by a prior normal
3836 -- Import or Export pragma), then the external names must match
3838 if Present (Interface_Name (Internal_Ent)) then
3840 S1 : constant String_Id := Strval (Old_Name);
3841 S2 : constant String_Id := Strval (New_Name);
3844 -- Called if names do not match
3846 procedure Mismatch is
3848 Error_Msg_Sloc := Sloc (Old_Name);
3850 ("external name does not match that given #",
3855 if String_Length (S1) /= String_Length (S2) then
3859 for J in 1 .. String_Length (S1) loop
3860 if Get_String_Char (S1, J) /= Get_String_Char (S2, J) then
3867 -- Otherwise set the given name
3870 Set_Encoded_Interface_Name (Internal_Ent, New_Name);
3871 Check_Duplicated_Export_Name (New_Name);
3873 end Set_Extended_Import_Export_External_Name;
3879 procedure Set_Imported (E : Entity_Id) is
3881 Error_Msg_Sloc := Sloc (E);
3883 if Is_Exported (E) or else Is_Imported (E) then
3884 Error_Msg_NE ("import of& declared# not allowed", N, E);
3886 if Is_Exported (E) then
3887 Error_Msg_N ("\entity was previously exported", N);
3889 Error_Msg_N ("\entity was previously imported", N);
3892 Error_Pragma ("\(pragma% applies to all previous entities)");
3895 Set_Is_Imported (E);
3897 -- If the entity is an object that is not at the library
3898 -- level, then it is statically allocated. We do not worry
3899 -- about objects with address clauses in this context since
3900 -- they are not really imported in the linker sense.
3903 and then not Is_Library_Level_Entity (E)
3904 and then No (Address_Clause (E))
3906 Set_Is_Statically_Allocated (E);
3911 -------------------------
3912 -- Set_Mechanism_Value --
3913 -------------------------
3915 -- Note: the mechanism name has not been analyzed (and cannot indeed
3916 -- be analyzed, since it is semantic nonsense), so we get it in the
3917 -- exact form created by the parser.
3919 procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id) is
3923 procedure Bad_Class;
3924 -- Signal bad descriptor class name
3926 procedure Bad_Mechanism;
3927 -- Signal bad mechanism name
3929 procedure Bad_Class is
3931 Error_Pragma_Arg ("unrecognized descriptor class name", Class);
3934 procedure Bad_Mechanism is
3936 Error_Pragma_Arg ("unrecognized mechanism name", Mech_Name);
3939 -- Start of processing for Set_Mechanism_Value
3942 if Mechanism (Ent) /= Default_Mechanism then
3944 ("mechanism for & has already been set", Mech_Name, Ent);
3947 -- MECHANISM_NAME ::= value | reference | descriptor
3949 if Nkind (Mech_Name) = N_Identifier then
3950 if Chars (Mech_Name) = Name_Value then
3951 Set_Mechanism (Ent, By_Copy);
3954 elsif Chars (Mech_Name) = Name_Reference then
3955 Set_Mechanism (Ent, By_Reference);
3958 elsif Chars (Mech_Name) = Name_Descriptor then
3959 Check_VMS (Mech_Name);
3960 Set_Mechanism (Ent, By_Descriptor);
3963 elsif Chars (Mech_Name) = Name_Copy then
3965 ("bad mechanism name, Value assumed", Mech_Name);
3971 -- MECHANISM_NAME ::= descriptor (CLASS_NAME)
3972 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3974 -- Note: this form is parsed as an indexed component
3976 elsif Nkind (Mech_Name) = N_Indexed_Component then
3977 Class := First (Expressions (Mech_Name));
3979 if Nkind (Prefix (Mech_Name)) /= N_Identifier
3980 or else Chars (Prefix (Mech_Name)) /= Name_Descriptor
3981 or else Present (Next (Class))
3986 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME)
3987 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3989 -- Note: this form is parsed as a function call
3991 elsif Nkind (Mech_Name) = N_Function_Call then
3993 Param := First (Parameter_Associations (Mech_Name));
3995 if Nkind (Name (Mech_Name)) /= N_Identifier
3996 or else Chars (Name (Mech_Name)) /= Name_Descriptor
3997 or else Present (Next (Param))
3998 or else No (Selector_Name (Param))
3999 or else Chars (Selector_Name (Param)) /= Name_Class
4003 Class := Explicit_Actual_Parameter (Param);
4010 -- Fall through here with Class set to descriptor class name
4012 Check_VMS (Mech_Name);
4014 if Nkind (Class) /= N_Identifier then
4017 elsif Chars (Class) = Name_UBS then
4018 Set_Mechanism (Ent, By_Descriptor_UBS);
4020 elsif Chars (Class) = Name_UBSB then
4021 Set_Mechanism (Ent, By_Descriptor_UBSB);
4023 elsif Chars (Class) = Name_UBA then
4024 Set_Mechanism (Ent, By_Descriptor_UBA);
4026 elsif Chars (Class) = Name_S then
4027 Set_Mechanism (Ent, By_Descriptor_S);
4029 elsif Chars (Class) = Name_SB then
4030 Set_Mechanism (Ent, By_Descriptor_SB);
4032 elsif Chars (Class) = Name_A then
4033 Set_Mechanism (Ent, By_Descriptor_A);
4035 elsif Chars (Class) = Name_NCA then
4036 Set_Mechanism (Ent, By_Descriptor_NCA);
4042 end Set_Mechanism_Value;
4044 ---------------------------
4045 -- Set_Ravenscar_Profile --
4046 ---------------------------
4048 -- The tasks to be done here are
4050 -- Set required policies
4052 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4053 -- pragma Locking_Policy (Ceiling_Locking)
4055 -- Set Detect_Blocking mode
4057 -- Set required restrictions (see System.Rident for detailed list)
4059 procedure Set_Ravenscar_Profile (N : Node_Id) is
4061 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4063 if Task_Dispatching_Policy /= ' '
4064 and then Task_Dispatching_Policy /= 'F'
4066 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
4067 Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
4069 -- Set the FIFO_Within_Priorities policy, but always
4070 -- preserve System_Location since we like the error
4071 -- message with the run time name.
4074 Task_Dispatching_Policy := 'F';
4076 if Task_Dispatching_Policy_Sloc /= System_Location then
4077 Task_Dispatching_Policy_Sloc := Loc;
4081 -- pragma Locking_Policy (Ceiling_Locking)
4083 if Locking_Policy /= ' '
4084 and then Locking_Policy /= 'C'
4086 Error_Msg_Sloc := Locking_Policy_Sloc;
4087 Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
4089 -- Set the Ceiling_Locking policy, but always preserve
4090 -- System_Location since we like the error message with the
4094 Locking_Policy := 'C';
4096 if Locking_Policy_Sloc /= System_Location then
4097 Locking_Policy_Sloc := Loc;
4101 -- pragma Detect_Blocking
4103 Detect_Blocking := True;
4105 -- Set the corresponding restrictions
4107 Set_Profile_Restrictions (Ravenscar, N, Warn => False);
4108 end Set_Ravenscar_Profile;
4110 -- Start of processing for Analyze_Pragma
4113 if not Is_Pragma_Name (Chars (N)) then
4114 if Warn_On_Unrecognized_Pragma then
4115 Error_Pragma ("unrecognized pragma%!?");
4120 Prag_Id := Get_Pragma_Id (Chars (N));
4130 if Present (Pragma_Argument_Associations (N)) then
4131 Arg1 := First (Pragma_Argument_Associations (N));
4133 if Present (Arg1) then
4134 Arg2 := Next (Arg1);
4136 if Present (Arg2) then
4137 Arg3 := Next (Arg2);
4139 if Present (Arg3) then
4140 Arg4 := Next (Arg3);
4146 -- Count number of arguments
4153 while Present (Arg_Node) loop
4154 Arg_Count := Arg_Count + 1;
4159 -- An enumeration type defines the pragmas that are supported by the
4160 -- implementation. Get_Pragma_Id (in package Prag) transorms a name
4161 -- into the corresponding enumeration value for the following case.
4169 -- pragma Abort_Defer;
4171 when Pragma_Abort_Defer =>
4173 Check_Arg_Count (0);
4175 -- The only required semantic processing is to check the
4176 -- placement. This pragma must appear at the start of the
4177 -- statement sequence of a handled sequence of statements.
4179 if Nkind (Parent (N)) /= N_Handled_Sequence_Of_Statements
4180 or else N /= First (Statements (Parent (N)))
4191 -- Note: this pragma also has some specific processing in Par.Prag
4192 -- because we want to set the Ada version mode during parsing.
4194 when Pragma_Ada_83 =>
4196 Ada_Version := Ada_83;
4197 Check_Arg_Count (0);
4205 -- Note: this pragma also has some specific processing in Par.Prag
4206 -- because we want to set the Ada 83 version mode during parsing.
4208 when Pragma_Ada_95 =>
4210 Ada_Version := Ada_95;
4211 Check_Arg_Count (0);
4219 -- Note: this pragma also has some specific processing in Par.Prag
4220 -- because we want to set the Ada 83 version mode during parsing.
4222 when Pragma_Ada_05 =>
4224 Ada_Version := Ada_05;
4225 Check_Arg_Count (0);
4227 ----------------------
4228 -- All_Calls_Remote --
4229 ----------------------
4231 -- pragma All_Calls_Remote [(library_package_NAME)];
4233 when Pragma_All_Calls_Remote => All_Calls_Remote : declare
4234 Lib_Entity : Entity_Id;
4237 Check_Ada_83_Warning;
4238 Check_Valid_Library_Unit_Pragma;
4240 if Nkind (N) = N_Null_Statement then
4244 Lib_Entity := Find_Lib_Unit_Name;
4246 -- This pragma should only apply to a RCI unit (RM E.2.3(23)).
4248 if Present (Lib_Entity)
4249 and then not Debug_Flag_U
4251 if not Is_Remote_Call_Interface (Lib_Entity) then
4252 Error_Pragma ("pragma% only apply to rci unit");
4254 -- Set flag for entity of the library unit
4257 Set_Has_All_Calls_Remote (Lib_Entity);
4261 end All_Calls_Remote;
4267 -- pragma Annotate (IDENTIFIER {, ARG});
4268 -- ARG ::= NAME | EXPRESSION
4270 when Pragma_Annotate => Annotate : begin
4272 Check_At_Least_N_Arguments (1);
4273 Check_Arg_Is_Identifier (Arg1);
4276 Arg : Node_Id := Arg2;
4280 while Present (Arg) loop
4281 Exp := Expression (Arg);
4284 if Is_Entity_Name (Exp) then
4287 elsif Nkind (Exp) = N_String_Literal then
4288 Resolve (Exp, Standard_String);
4290 elsif Is_Overloaded (Exp) then
4291 Error_Pragma_Arg ("ambiguous argument for pragma%", Exp);
4306 -- pragma Assert (Boolean_EXPRESSION [, static_string_EXPRESSION]);
4308 when Pragma_Assert =>
4310 Check_No_Identifiers;
4312 if Arg_Count > 1 then
4313 Check_Arg_Count (2);
4314 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
4317 -- If expansion is active and assertions are inactive, then
4318 -- we rewrite the Assertion as:
4320 -- if False and then condition then
4324 -- The reason we do this rewriting during semantic analysis
4325 -- rather than as part of normal expansion is that we cannot
4326 -- analyze and expand the code for the boolean expression
4327 -- directly, or it may cause insertion of actions that would
4328 -- escape the attempt to suppress the assertion code.
4330 if Expander_Active and not Assertions_Enabled then
4332 Make_If_Statement (Loc,
4335 Left_Opnd => New_Occurrence_Of (Standard_False, Loc),
4336 Right_Opnd => Get_Pragma_Arg (Arg1)),
4337 Then_Statements => New_List (
4338 Make_Null_Statement (Loc))));
4342 -- Otherwise (if assertions are enabled, or if we are not
4343 -- operating with expansion active), then we just analyze
4344 -- and resolve the expression.
4347 Analyze_And_Resolve (Expression (Arg1), Any_Boolean);
4354 -- pragma AST_Entry (entry_IDENTIFIER);
4356 when Pragma_AST_Entry => AST_Entry : declare
4362 Check_Arg_Count (1);
4363 Check_No_Identifiers;
4364 Check_Arg_Is_Local_Name (Arg1);
4365 Ent := Entity (Expression (Arg1));
4367 -- Note: the implementation of the AST_Entry pragma could handle
4368 -- the entry family case fine, but for now we are consistent with
4369 -- the DEC rules, and do not allow the pragma, which of course
4370 -- has the effect of also forbidding the attribute.
4372 if Ekind (Ent) /= E_Entry then
4374 ("pragma% argument must be simple entry name", Arg1);
4376 elsif Is_AST_Entry (Ent) then
4378 ("duplicate % pragma for entry", Arg1);
4380 elsif Has_Homonym (Ent) then
4382 ("pragma% argument cannot specify overloaded entry", Arg1);
4386 FF : constant Entity_Id := First_Formal (Ent);
4389 if Present (FF) then
4390 if Present (Next_Formal (FF)) then
4392 ("entry for pragma% can have only one argument",
4395 elsif Parameter_Mode (FF) /= E_In_Parameter then
4397 ("entry parameter for pragma% must have mode IN",
4403 Set_Is_AST_Entry (Ent);
4411 -- pragma Asynchronous (LOCAL_NAME);
4413 when Pragma_Asynchronous => Asynchronous : declare
4421 procedure Process_Async_Pragma;
4422 -- Common processing for procedure and access-to-procedure case
4424 --------------------------
4425 -- Process_Async_Pragma --
4426 --------------------------
4428 procedure Process_Async_Pragma is
4430 if not Present (L) then
4431 Set_Is_Asynchronous (Nm);
4435 -- The formals should be of mode IN (RM E.4.1(6))
4438 while Present (S) loop
4439 Formal := Defining_Identifier (S);
4441 if Nkind (Formal) = N_Defining_Identifier
4442 and then Ekind (Formal) /= E_In_Parameter
4445 ("pragma% procedure can only have IN parameter",
4452 Set_Is_Asynchronous (Nm);
4453 end Process_Async_Pragma;
4455 -- Start of processing for pragma Asynchronous
4458 Check_Ada_83_Warning;
4459 Check_No_Identifiers;
4460 Check_Arg_Count (1);
4461 Check_Arg_Is_Local_Name (Arg1);
4463 if Debug_Flag_U then
4467 C_Ent := Cunit_Entity (Current_Sem_Unit);
4468 Analyze (Expression (Arg1));
4469 Nm := Entity (Expression (Arg1));
4471 if not Is_Remote_Call_Interface (C_Ent)
4472 and then not Is_Remote_Types (C_Ent)
4474 -- This pragma should only appear in an RCI or Remote Types
4475 -- unit (RM E.4.1(4))
4478 ("pragma% not in Remote_Call_Interface or " &
4479 "Remote_Types unit");
4482 if Ekind (Nm) = E_Procedure
4483 and then Nkind (Parent (Nm)) = N_Procedure_Specification
4485 if not Is_Remote_Call_Interface (Nm) then
4487 ("pragma% cannot be applied on non-remote procedure",
4491 L := Parameter_Specifications (Parent (Nm));
4492 Process_Async_Pragma;
4495 elsif Ekind (Nm) = E_Function then
4497 ("pragma% cannot be applied to function", Arg1);
4499 elsif Ekind (Nm) = E_Record_Type
4500 and then Present (Corresponding_Remote_Type (Nm))
4502 N := Declaration_Node (Corresponding_Remote_Type (Nm));
4504 if Nkind (N) = N_Full_Type_Declaration
4505 and then Nkind (Type_Definition (N)) =
4506 N_Access_Procedure_Definition
4508 L := Parameter_Specifications (Type_Definition (N));
4509 Process_Async_Pragma;
4513 ("pragma% cannot reference access-to-function type",
4517 -- Only other possibility is Access-to-class-wide type
4519 elsif Is_Access_Type (Nm)
4520 and then Is_Class_Wide_Type (Designated_Type (Nm))
4522 Check_First_Subtype (Arg1);
4523 Set_Is_Asynchronous (Nm);
4524 if Expander_Active then
4525 RACW_Type_Is_Asynchronous (Nm);
4529 Error_Pragma_Arg ("inappropriate argument for pragma%", Arg1);
4537 -- pragma Atomic (LOCAL_NAME);
4539 when Pragma_Atomic =>
4540 Process_Atomic_Shared_Volatile;
4542 -----------------------
4543 -- Atomic_Components --
4544 -----------------------
4546 -- pragma Atomic_Components (array_LOCAL_NAME);
4548 -- This processing is shared by Volatile_Components
4550 when Pragma_Atomic_Components |
4551 Pragma_Volatile_Components =>
4553 Atomic_Components : declare
4560 Check_Ada_83_Warning;
4561 Check_No_Identifiers;
4562 Check_Arg_Count (1);
4563 Check_Arg_Is_Local_Name (Arg1);
4564 E_Id := Expression (Arg1);
4566 if Etype (E_Id) = Any_Type then
4572 if Rep_Item_Too_Early (E, N)
4574 Rep_Item_Too_Late (E, N)
4579 D := Declaration_Node (E);
4582 if (K = N_Full_Type_Declaration and then Is_Array_Type (E))
4584 ((Ekind (E) = E_Constant or else Ekind (E) = E_Variable)
4585 and then Nkind (D) = N_Object_Declaration
4586 and then Nkind (Object_Definition (D)) =
4587 N_Constrained_Array_Definition)
4589 -- The flag is set on the object, or on the base type
4591 if Nkind (D) /= N_Object_Declaration then
4595 Set_Has_Volatile_Components (E);
4597 if Prag_Id = Pragma_Atomic_Components then
4598 Set_Has_Atomic_Components (E);
4600 if Is_Packed (E) then
4601 Set_Is_Packed (E, False);
4604 ("?Pack canceled, cannot pack atomic components",
4610 Error_Pragma_Arg ("inappropriate entity for pragma%", Arg1);
4612 end Atomic_Components;
4614 --------------------
4615 -- Attach_Handler --
4616 --------------------
4618 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
4620 when Pragma_Attach_Handler =>
4621 Check_Ada_83_Warning;
4622 Check_No_Identifiers;
4623 Check_Arg_Count (2);
4625 if No_Run_Time_Mode then
4626 Error_Msg_CRT ("Attach_Handler pragma", N);
4628 Check_Interrupt_Or_Attach_Handler;
4630 -- The expression that designates the attribute may
4631 -- depend on a discriminant, and is therefore a per-
4632 -- object expression, to be expanded in the init proc.
4633 -- If expansion is enabled, perform semantic checks
4636 if Expander_Active then
4638 Temp : constant Node_Id :=
4639 New_Copy_Tree (Expression (Arg2));
4641 Set_Parent (Temp, N);
4642 Pre_Analyze_And_Resolve (Temp, RTE (RE_Interrupt_ID));
4646 Analyze (Expression (Arg2));
4647 Resolve (Expression (Arg2), RTE (RE_Interrupt_ID));
4650 Process_Interrupt_Or_Attach_Handler;
4653 --------------------
4654 -- C_Pass_By_Copy --
4655 --------------------
4657 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
4659 when Pragma_C_Pass_By_Copy => C_Pass_By_Copy : declare
4665 Check_Valid_Configuration_Pragma;
4666 Check_Arg_Count (1);
4667 Check_Optional_Identifier (Arg1, "max_size");
4669 Arg := Expression (Arg1);
4670 Check_Arg_Is_Static_Expression (Arg, Any_Integer);
4672 Val := Expr_Value (Arg);
4676 ("maximum size for pragma% must be positive", Arg1);
4678 elsif UI_Is_In_Int_Range (Val) then
4679 Default_C_Record_Mechanism := UI_To_Int (Val);
4681 -- If a giant value is given, Int'Last will do well enough.
4682 -- If sometime someone complains that a record larger than
4683 -- two gigabytes is not copied, we will worry about it then!
4686 Default_C_Record_Mechanism := Mechanism_Type'Last;
4694 -- pragma Comment (static_string_EXPRESSION)
4696 -- Processing for pragma Comment shares the circuitry for
4697 -- pragma Ident. The only differences are that Ident enforces
4698 -- a limit of 31 characters on its argument, and also enforces
4699 -- limitations on placement for DEC compatibility. Pragma
4700 -- Comment shares neither of these restrictions.
4706 -- pragma Common_Object (
4707 -- [Internal =>] LOCAL_NAME,
4708 -- [, [External =>] EXTERNAL_SYMBOL]
4709 -- [, [Size =>] EXTERNAL_SYMBOL]);
4711 -- Processing for this pragma is shared with Psect_Object
4713 --------------------------
4714 -- Compile_Time_Warning --
4715 --------------------------
4717 -- pragma Compile_Time_Warning
4718 -- (boolean_EXPRESSION, static_string_EXPRESSION);
4720 when Pragma_Compile_Time_Warning => Compile_Time_Warning : declare
4721 Arg1x : constant Node_Id := Get_Pragma_Arg (Arg1);
4725 Check_Arg_Count (2);
4726 Check_No_Identifiers;
4727 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
4728 Analyze_And_Resolve (Arg1x, Standard_Boolean);
4730 if Compile_Time_Known_Value (Arg1x) then
4731 if Is_True (Expr_Value (Get_Pragma_Arg (Arg1))) then
4732 String_To_Name_Buffer (Strval (Get_Pragma_Arg (Arg2)));
4733 Add_Char_To_Name_Buffer ('?');
4736 Msg : String (1 .. Name_Len) :=
4737 Name_Buffer (1 .. Name_Len);
4742 -- This loop looks for multiple lines separated by
4743 -- ASCII.LF and breaks them into continuation error
4744 -- messages marked with the usual back slash.
4747 for S in 2 .. Msg'Length - 1 loop
4748 if Msg (S) = ASCII.LF then
4750 Error_Msg_N (Msg (B .. S), Arg1);
4756 Error_Msg_N (Msg (B .. Msg'Length), Arg1);
4760 end Compile_Time_Warning;
4762 ----------------------------
4763 -- Complex_Representation --
4764 ----------------------------
4766 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
4768 when Pragma_Complex_Representation => Complex_Representation : declare
4775 Check_Arg_Count (1);
4776 Check_Optional_Identifier (Arg1, Name_Entity);
4777 Check_Arg_Is_Local_Name (Arg1);
4778 E_Id := Expression (Arg1);
4780 if Etype (E_Id) = Any_Type then
4786 if not Is_Record_Type (E) then
4788 ("argument for pragma% must be record type", Arg1);
4791 Ent := First_Entity (E);
4794 or else No (Next_Entity (Ent))
4795 or else Present (Next_Entity (Next_Entity (Ent)))
4796 or else not Is_Floating_Point_Type (Etype (Ent))
4797 or else Etype (Ent) /= Etype (Next_Entity (Ent))
4800 ("record for pragma% must have two fields of same fpt type",
4804 Set_Has_Complex_Representation (Base_Type (E));
4806 end Complex_Representation;
4808 -------------------------
4809 -- Component_Alignment --
4810 -------------------------
4812 -- pragma Component_Alignment (
4813 -- [Form =>] ALIGNMENT_CHOICE
4814 -- [, [Name =>] type_LOCAL_NAME]);
4816 -- ALIGNMENT_CHOICE ::=
4818 -- | Component_Size_4
4822 when Pragma_Component_Alignment => Component_AlignmentP : declare
4823 Args : Args_List (1 .. 2);
4824 Names : constant Name_List (1 .. 2) := (
4828 Form : Node_Id renames Args (1);
4829 Name : Node_Id renames Args (2);
4831 Atype : Component_Alignment_Kind;
4836 Gather_Associations (Names, Args);
4839 Error_Pragma ("missing Form argument for pragma%");
4842 Check_Arg_Is_Identifier (Form);
4844 -- Get proper alignment, note that Default = Component_Size
4845 -- on all machines we have so far, and we want to set this
4846 -- value rather than the default value to indicate that it
4847 -- has been explicitly set (and thus will not get overridden
4848 -- by the default component alignment for the current scope)
4850 if Chars (Form) = Name_Component_Size then
4851 Atype := Calign_Component_Size;
4853 elsif Chars (Form) = Name_Component_Size_4 then
4854 Atype := Calign_Component_Size_4;
4856 elsif Chars (Form) = Name_Default then
4857 Atype := Calign_Component_Size;
4859 elsif Chars (Form) = Name_Storage_Unit then
4860 Atype := Calign_Storage_Unit;
4864 ("invalid Form parameter for pragma%", Form);
4867 -- Case with no name, supplied, affects scope table entry
4871 (Scope_Stack.Last).Component_Alignment_Default := Atype;
4873 -- Case of name supplied
4876 Check_Arg_Is_Local_Name (Name);
4878 Typ := Entity (Name);
4881 or else Rep_Item_Too_Early (Typ, N)
4885 Typ := Underlying_Type (Typ);
4888 if not Is_Record_Type (Typ)
4889 and then not Is_Array_Type (Typ)
4892 ("Name parameter of pragma% must identify record or " &
4893 "array type", Name);
4896 -- An explicit Component_Alignment pragma overrides an
4897 -- implicit pragma Pack, but not an explicit one.
4899 if not Has_Pragma_Pack (Base_Type (Typ)) then
4900 Set_Is_Packed (Base_Type (Typ), False);
4901 Set_Component_Alignment (Base_Type (Typ), Atype);
4904 end Component_AlignmentP;
4910 -- pragma Controlled (first_subtype_LOCAL_NAME);
4912 when Pragma_Controlled => Controlled : declare
4916 Check_No_Identifiers;
4917 Check_Arg_Count (1);
4918 Check_Arg_Is_Local_Name (Arg1);
4919 Arg := Expression (Arg1);
4921 if not Is_Entity_Name (Arg)
4922 or else not Is_Access_Type (Entity (Arg))
4924 Error_Pragma_Arg ("pragma% requires access type", Arg1);
4926 Set_Has_Pragma_Controlled (Base_Type (Entity (Arg)));
4934 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
4935 -- [Entity =>] LOCAL_NAME);
4937 when Pragma_Convention => Convention : declare
4941 Check_Ada_83_Warning;
4942 Check_Arg_Count (2);
4943 Process_Convention (C, E);
4946 ---------------------------
4947 -- Convention_Identifier --
4948 ---------------------------
4950 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
4951 -- [Convention =>] convention_IDENTIFIER);
4953 when Pragma_Convention_Identifier => Convention_Identifier : declare
4959 Check_Arg_Count (2);
4960 Check_Optional_Identifier (Arg1, Name_Name);
4961 Check_Optional_Identifier (Arg2, Name_Convention);
4962 Check_Arg_Is_Identifier (Arg1);
4963 Check_Arg_Is_Identifier (Arg1);
4964 Idnam := Chars (Expression (Arg1));
4965 Cname := Chars (Expression (Arg2));
4967 if Is_Convention_Name (Cname) then
4968 Record_Convention_Identifier
4969 (Idnam, Get_Convention_Id (Cname));
4972 ("second arg for % pragma must be convention", Arg2);
4974 end Convention_Identifier;
4980 -- pragma CPP_Class ([Entity =>] local_NAME)
4982 when Pragma_CPP_Class => CPP_Class : declare
4985 Default_DTC : Entity_Id := Empty;
4986 VTP_Type : constant Entity_Id := RTE (RE_Vtable_Ptr);
4992 Check_Arg_Count (1);
4993 Check_Optional_Identifier (Arg1, Name_Entity);
4994 Check_Arg_Is_Local_Name (Arg1);
4996 Arg := Expression (Arg1);
4999 if Etype (Arg) = Any_Type then
5003 if not Is_Entity_Name (Arg)
5004 or else not Is_Type (Entity (Arg))
5006 Error_Pragma_Arg ("pragma% requires a type mark", Arg1);
5009 Typ := Entity (Arg);
5011 if not Is_Record_Type (Typ) then
5012 Error_Pragma_Arg ("pragma% applicable to a record, "
5013 & "tagged record or record extension", Arg1);
5016 Default_DTC := First_Component (Typ);
5017 while Present (Default_DTC)
5018 and then Etype (Default_DTC) /= VTP_Type
5020 Next_Component (Default_DTC);
5023 -- Case of non tagged type
5025 if not Is_Tagged_Type (Typ) then
5026 Set_Is_CPP_Class (Typ);
5028 if Present (Default_DTC) then
5030 ("only tagged records can contain vtable pointers", Arg1);
5033 -- Case of tagged type with no vtable ptr
5035 -- What is test for Typ = Root_Typ (Typ) about here ???
5037 elsif Is_Tagged_Type (Typ)
5038 and then Typ = Root_Type (Typ)
5039 and then No (Default_DTC)
5042 ("a cpp_class must contain a vtable pointer", Arg1);
5044 -- Tagged type that has a vtable ptr
5046 elsif Present (Default_DTC) then
5047 Set_Is_CPP_Class (Typ);
5048 Set_Is_Limited_Record (Typ);
5049 Set_Is_Tag (Default_DTC);
5050 Set_DT_Entry_Count (Default_DTC, No_Uint);
5052 -- Since a CPP type has no direct link to its associated tag
5053 -- most tags checks cannot be performed
5055 Set_Kill_Tag_Checks (Typ);
5056 Set_Kill_Tag_Checks (Class_Wide_Type (Typ));
5058 -- Get rid of the _tag component when there was one.
5059 -- It is only useful for regular tagged types
5061 if Expander_Active and then Typ = Root_Type (Typ) then
5063 Tag_C := Tag_Component (Typ);
5064 C := First_Entity (Typ);
5067 Set_First_Entity (Typ, Next_Entity (Tag_C));
5070 while Next_Entity (C) /= Tag_C loop
5074 Set_Next_Entity (C, Next_Entity (Tag_C));
5080 ---------------------
5081 -- CPP_Constructor --
5082 ---------------------
5084 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
5086 when Pragma_CPP_Constructor => CPP_Constructor : declare
5092 Check_Arg_Count (1);
5093 Check_Optional_Identifier (Arg1, Name_Entity);
5094 Check_Arg_Is_Local_Name (Arg1);
5096 Id := Expression (Arg1);
5097 Find_Program_Unit_Name (Id);
5099 -- If we did not find the name, we are done
5101 if Etype (Id) = Any_Type then
5105 Def_Id := Entity (Id);
5107 if Ekind (Def_Id) = E_Function
5108 and then Is_Class_Wide_Type (Etype (Def_Id))
5109 and then Is_CPP_Class (Etype (Etype (Def_Id)))
5111 -- What the heck is this??? this pragma allows only 1 arg
5113 if Arg_Count >= 2 then
5114 Check_At_Most_N_Arguments (3);
5115 Process_Interface_Name (Def_Id, Arg2, Arg3);
5118 if No (Parameter_Specifications (Parent (Def_Id))) then
5119 Set_Has_Completion (Def_Id);
5120 Set_Is_Constructor (Def_Id);
5123 ("non-default constructors not implemented", Arg1);
5128 ("pragma% requires function returning a 'C'P'P_Class type",
5131 end CPP_Constructor;
5137 -- pragma CPP_Virtual
5138 -- [Entity =>] LOCAL_NAME
5139 -- [ [Vtable_Ptr =>] LOCAL_NAME,
5140 -- [Position =>] static_integer_EXPRESSION]);
5142 when Pragma_CPP_Virtual => CPP_Virtual : declare
5146 VTP_Type : constant Entity_Id := RTE (RE_Vtable_Ptr);
5153 if Arg_Count = 3 then
5154 Check_Optional_Identifier (Arg2, "vtable_ptr");
5156 -- We allow Entry_Count as well as Position for the third
5157 -- parameter for back compatibility with versions of GNAT
5158 -- before version 3.12. The documentation has always said
5159 -- Position, but the code up to 3.12 said Entry_Count.
5161 if Chars (Arg3) /= Name_Position then
5162 Check_Optional_Identifier (Arg3, "entry_count");
5166 Check_Arg_Count (1);
5169 Check_Optional_Identifier (Arg1, Name_Entity);
5170 Check_Arg_Is_Local_Name (Arg1);
5172 -- First argument must be a subprogram name
5174 Arg := Expression (Arg1);
5175 Find_Program_Unit_Name (Arg);
5177 if Etype (Arg) = Any_Type then
5180 Subp := Entity (Arg);
5183 if not (Is_Subprogram (Subp)
5184 and then Is_Dispatching_Operation (Subp))
5187 ("pragma% must reference a primitive operation", Arg1);
5190 Typ := Find_Dispatching_Type (Subp);
5192 -- If only one Argument defaults are :
5193 -- . DTC_Entity is the default Vtable pointer
5194 -- . DT_Position will be set at the freezing point
5196 if Arg_Count = 1 then
5197 Set_DTC_Entity (Subp, Tag_Component (Typ));
5201 -- Second argument is a component name of type Vtable_Ptr
5203 Arg := Expression (Arg2);
5205 if Nkind (Arg) /= N_Identifier then
5206 Error_Msg_NE ("must be a& component name", Arg, Typ);
5210 DTC := First_Component (Typ);
5211 while Present (DTC) and then Chars (DTC) /= Chars (Arg) loop
5212 Next_Component (DTC);
5216 Error_Msg_NE ("must be a& component name", Arg, Typ);
5219 elsif Etype (DTC) /= VTP_Type then
5220 Wrong_Type (Arg, VTP_Type);
5224 -- Third argument is an integer (DT_Position)
5226 Arg := Expression (Arg3);
5227 Analyze_And_Resolve (Arg, Any_Integer);
5229 if not Is_Static_Expression (Arg) then
5230 Flag_Non_Static_Expr
5231 ("third argument of pragma CPP_Virtual must be static!",
5236 V := Expr_Value (Expression (Arg3));
5240 ("third argument of pragma% must be positive",
5244 Set_DTC_Entity (Subp, DTC);
5245 Set_DT_Position (Subp, V);
5254 -- pragma CPP_Vtable (
5255 -- [Entity =>] LOCAL_NAME
5256 -- [Vtable_Ptr =>] LOCAL_NAME,
5257 -- [Entry_Count =>] static_integer_EXPRESSION);
5259 when Pragma_CPP_Vtable => CPP_Vtable : declare
5262 VTP_Type : constant Entity_Id := RTE (RE_Vtable_Ptr);
5269 Check_Arg_Count (3);
5270 Check_Optional_Identifier (Arg1, Name_Entity);
5271 Check_Optional_Identifier (Arg2, "vtable_ptr");
5272 Check_Optional_Identifier (Arg3, "entry_count");
5273 Check_Arg_Is_Local_Name (Arg1);
5275 -- First argument is a record type name
5277 Arg := Expression (Arg1);
5280 if Etype (Arg) = Any_Type then
5283 Typ := Entity (Arg);
5286 if not (Is_Tagged_Type (Typ) and then Is_CPP_Class (Typ)) then
5287 Error_Pragma_Arg ("'C'P'P_Class tagged type expected", Arg1);
5290 -- Second argument is a component name of type Vtable_Ptr
5292 Arg := Expression (Arg2);
5294 if Nkind (Arg) /= N_Identifier then
5295 Error_Msg_NE ("must be a& component name", Arg, Typ);
5299 DTC := First_Component (Typ);
5300 while Present (DTC) and then Chars (DTC) /= Chars (Arg) loop
5301 Next_Component (DTC);
5305 Error_Msg_NE ("must be a& component name", Arg, Typ);
5308 elsif Etype (DTC) /= VTP_Type then
5309 Wrong_Type (DTC, VTP_Type);
5312 -- If it is the first pragma Vtable, This becomes the default tag
5314 elsif (not Is_Tag (DTC))
5315 and then DT_Entry_Count (Tag_Component (Typ)) = No_Uint
5317 Set_Is_Tag (Tag_Component (Typ), False);
5318 Set_Is_Tag (DTC, True);
5319 Set_DT_Entry_Count (DTC, No_Uint);
5322 -- Those pragmas must appear before any primitive operation
5323 -- definition (except inherited ones) otherwise the default
5326 Elmt := First_Elmt (Primitive_Operations (Typ));
5327 while Present (Elmt) loop
5328 if No (Alias (Node (Elmt))) then
5329 Error_Msg_Sloc := Sloc (Node (Elmt));
5331 ("pragma% must appear before this primitive operation");
5337 -- Third argument is an integer (DT_Entry_Count)
5339 Arg := Expression (Arg3);
5340 Analyze_And_Resolve (Arg, Any_Integer);
5342 if not Is_Static_Expression (Arg) then
5343 Flag_Non_Static_Expr
5344 ("entry count for pragma CPP_Vtable must be a static " &
5345 "expression!", Arg3);
5349 V := Expr_Value (Expression (Arg3));
5353 ("entry count for pragma% must be positive", Arg3);
5355 Set_DT_Entry_Count (DTC, V);
5364 -- pragma Debug (PROCEDURE_CALL_STATEMENT);
5366 when Pragma_Debug => Debug : begin
5369 -- If assertions are enabled, and we are expanding code, then
5370 -- we rewrite the pragma with its corresponding procedure call
5371 -- and then analyze the call.
5373 if Assertions_Enabled and Expander_Active then
5374 Rewrite (N, Relocate_Node (Debug_Statement (N)));
5377 -- Otherwise we work a bit to get a tree that makes sense
5378 -- for ASIS purposes, namely a pragma with an analyzed
5379 -- argument that looks like a procedure call.
5382 Expander_Mode_Save_And_Set (False);
5383 Rewrite (N, Relocate_Node (Debug_Statement (N)));
5387 Chars => Name_Debug,
5388 Pragma_Argument_Associations =>
5389 New_List (Relocate_Node (N))));
5390 Expander_Mode_Restore;
5394 ---------------------
5395 -- Detect_Blocking --
5396 ---------------------
5398 -- pragma Detect_Blocking;
5400 when Pragma_Detect_Blocking =>
5402 Check_Arg_Count (0);
5403 Check_Valid_Configuration_Pragma;
5404 Detect_Blocking := True;
5410 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
5412 when Pragma_Discard_Names => Discard_Names : declare
5417 Check_Ada_83_Warning;
5419 -- Deal with configuration pragma case
5421 if Arg_Count = 0 and then Is_Configuration_Pragma then
5422 Global_Discard_Names := True;
5425 -- Otherwise, check correct appropriate context
5428 Check_Is_In_Decl_Part_Or_Package_Spec;
5430 if Arg_Count = 0 then
5432 -- If there is no parameter, then from now on this pragma
5433 -- applies to any enumeration, exception or tagged type
5434 -- defined in the current declarative part.
5436 Set_Discard_Names (Current_Scope);
5440 Check_Arg_Count (1);
5441 Check_Optional_Identifier (Arg1, Name_On);
5442 Check_Arg_Is_Local_Name (Arg1);
5443 E_Id := Expression (Arg1);
5445 if Etype (E_Id) = Any_Type then
5451 if (Is_First_Subtype (E)
5452 and then (Is_Enumeration_Type (E)
5453 or else Is_Tagged_Type (E)))
5454 or else Ekind (E) = E_Exception
5456 Set_Discard_Names (E);
5459 ("inappropriate entity for pragma%", Arg1);
5469 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
5471 when Pragma_Elaborate => Elaborate : declare
5473 Parent_Node : Node_Id;
5478 -- Pragma must be in context items list of a compilation unit
5480 if not Is_List_Member (N) then
5485 Plist := List_Containing (N);
5486 Parent_Node := Parent (Plist);
5488 if Parent_Node = Empty
5489 or else Nkind (Parent_Node) /= N_Compilation_Unit
5490 or else Context_Items (Parent_Node) /= Plist
5497 -- Must be at least one argument
5499 if Arg_Count = 0 then
5500 Error_Pragma ("pragma% requires at least one argument");
5503 -- In Ada 83 mode, there can be no items following it in the
5504 -- context list except other pragmas and implicit with clauses
5505 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
5506 -- placement rule does not apply.
5508 if Ada_Version = Ada_83 and then Comes_From_Source (N) then
5511 while Present (Citem) loop
5512 if Nkind (Citem) = N_Pragma
5513 or else (Nkind (Citem) = N_With_Clause
5514 and then Implicit_With (Citem))
5519 ("(Ada 83) pragma% must be at end of context clause");
5526 -- Finally, the arguments must all be units mentioned in a with
5527 -- clause in the same context clause. Note we already checked
5528 -- (in Par.Prag) that the arguments are either identifiers or
5531 Outer : while Present (Arg) loop
5532 Citem := First (Plist);
5534 Inner : while Citem /= N loop
5535 if Nkind (Citem) = N_With_Clause
5536 and then Same_Name (Name (Citem), Expression (Arg))
5538 Set_Elaborate_Present (Citem, True);
5539 Set_Unit_Name (Expression (Arg), Name (Citem));
5540 Set_Suppress_Elaboration_Warnings (Entity (Name (Citem)));
5549 ("argument of pragma% is not with'ed unit", Arg);
5555 -- Give a warning if operating in static mode with -gnatwl
5556 -- (elaboration warnings eanbled) switch set.
5558 if Elab_Warnings and not Dynamic_Elaboration_Checks then
5560 ("?use of pragma Elaborate may not be safe", N);
5562 ("?use pragma Elaborate_All instead if possible", N);
5570 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
5572 when Pragma_Elaborate_All => Elaborate_All : declare
5574 Parent_Node : Node_Id;
5579 Check_Ada_83_Warning;
5581 -- Pragma must be in context items list of a compilation unit
5583 if not Is_List_Member (N) then
5588 Plist := List_Containing (N);
5589 Parent_Node := Parent (Plist);
5591 if Parent_Node = Empty
5592 or else Nkind (Parent_Node) /= N_Compilation_Unit
5593 or else Context_Items (Parent_Node) /= Plist
5600 -- Must be at least one argument
5602 if Arg_Count = 0 then
5603 Error_Pragma ("pragma% requires at least one argument");
5606 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
5607 -- have to appear at the end of the context clause, but may
5608 -- appear mixed in with other items, even in Ada 83 mode.
5610 -- Final check: the arguments must all be units mentioned in
5611 -- a with clause in the same context clause. Note that we
5612 -- already checked (in Par.Prag) that all the arguments are
5613 -- either identifiers or selected components.
5616 Outr : while Present (Arg) loop
5617 Citem := First (Plist);
5619 Innr : while Citem /= N loop
5620 if Nkind (Citem) = N_With_Clause
5621 and then Same_Name (Name (Citem), Expression (Arg))
5623 Set_Elaborate_All_Present (Citem, True);
5624 Set_Unit_Name (Expression (Arg), Name (Citem));
5625 Set_Suppress_Elaboration_Warnings (Entity (Name (Citem)));
5633 Set_Error_Posted (N);
5635 ("argument of pragma% is not with'ed unit", Arg);
5642 --------------------
5643 -- Elaborate_Body --
5644 --------------------
5646 -- pragma Elaborate_Body [( library_unit_NAME )];
5648 when Pragma_Elaborate_Body => Elaborate_Body : declare
5649 Cunit_Node : Node_Id;
5650 Cunit_Ent : Entity_Id;
5653 Check_Ada_83_Warning;
5654 Check_Valid_Library_Unit_Pragma;
5656 if Nkind (N) = N_Null_Statement then
5660 Cunit_Node := Cunit (Current_Sem_Unit);
5661 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
5663 if Nkind (Unit (Cunit_Node)) = N_Package_Body
5665 Nkind (Unit (Cunit_Node)) = N_Subprogram_Body
5667 Error_Pragma ("pragma% must refer to a spec, not a body");
5669 Set_Body_Required (Cunit_Node, True);
5670 Set_Has_Pragma_Elaborate_Body (Cunit_Ent);
5672 -- If we are in dynamic elaboration mode, then we suppress
5673 -- elaboration warnings for the unit, since it is definitely
5674 -- fine NOT to do dynamic checks at the first level (and such
5675 -- checks will be suppressed because no elaboration boolean
5676 -- is created for Elaborate_Body packages).
5678 -- But in the static model of elaboration, Elaborate_Body is
5679 -- definitely NOT good enough to ensure elaboration safety on
5680 -- its own, since the body may WITH other units that are not
5681 -- safe from an elaboration point of view, so a client must
5682 -- still do an Elaborate_All on such units.
5684 -- Debug flag -gnatdD restores the old behavior of 3.13,
5685 -- where Elaborate_Body always suppressed elab warnings.
5687 if Dynamic_Elaboration_Checks or Debug_Flag_DD then
5688 Set_Suppress_Elaboration_Warnings (Cunit_Ent);
5693 ------------------------
5694 -- Elaboration_Checks --
5695 ------------------------
5697 -- pragma Elaboration_Checks (Static | Dynamic);
5699 when Pragma_Elaboration_Checks =>
5701 Check_Arg_Count (1);
5702 Check_Arg_Is_One_Of (Arg1, Name_Static, Name_Dynamic);
5703 Dynamic_Elaboration_Checks :=
5704 (Chars (Get_Pragma_Arg (Arg1)) = Name_Dynamic);
5710 -- pragma Eliminate (
5711 -- [Unit_Name =>] IDENTIFIER |
5712 -- SELECTED_COMPONENT
5713 -- [,[Entity =>] IDENTIFIER |
5714 -- SELECTED_COMPONENT |
5716 -- [,]OVERLOADING_RESOLUTION);
5718 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
5721 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
5724 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
5726 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
5727 -- Result_Type => result_SUBTYPE_NAME]
5729 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
5730 -- SUBTYPE_NAME ::= STRING_LITERAL
5732 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
5733 -- SOURCE_TRACE ::= STRING_LITERAL
5735 when Pragma_Eliminate => Eliminate : declare
5736 Args : Args_List (1 .. 5);
5737 Names : constant Name_List (1 .. 5) := (
5740 Name_Parameter_Types,
5742 Name_Source_Location);
5744 Unit_Name : Node_Id renames Args (1);
5745 Entity : Node_Id renames Args (2);
5746 Parameter_Types : Node_Id renames Args (3);
5747 Result_Type : Node_Id renames Args (4);
5748 Source_Location : Node_Id renames Args (5);
5752 Check_Valid_Configuration_Pragma;
5753 Gather_Associations (Names, Args);
5755 if No (Unit_Name) then
5756 Error_Pragma ("missing Unit_Name argument for pragma%");
5760 and then (Present (Parameter_Types)
5762 Present (Result_Type)
5764 Present (Source_Location))
5766 Error_Pragma ("missing Entity argument for pragma%");
5769 if (Present (Parameter_Types)
5771 Present (Result_Type))
5773 Present (Source_Location)
5776 ("parameter profile and source location can not " &
5777 "be used together in pragma%");
5780 Process_Eliminate_Pragma
5789 -------------------------
5790 -- Explicit_Overriding --
5791 -------------------------
5793 when Pragma_Explicit_Overriding =>
5794 Check_Valid_Configuration_Pragma;
5795 Check_Arg_Count (0);
5796 Explicit_Overriding := True;
5803 -- [ Convention =>] convention_IDENTIFIER,
5804 -- [ Entity =>] local_NAME
5805 -- [, [External_Name =>] static_string_EXPRESSION ]
5806 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5808 when Pragma_Export => Export : declare
5813 Check_Ada_83_Warning;
5814 Check_At_Least_N_Arguments (2);
5815 Check_At_Most_N_Arguments (4);
5816 Process_Convention (C, Def_Id);
5818 if Ekind (Def_Id) /= E_Constant then
5819 Note_Possible_Modification (Expression (Arg2));
5822 Process_Interface_Name (Def_Id, Arg3, Arg4);
5823 Set_Exported (Def_Id, Arg2);
5826 ----------------------
5827 -- Export_Exception --
5828 ----------------------
5830 -- pragma Export_Exception (
5831 -- [Internal =>] LOCAL_NAME,
5832 -- [, [External =>] EXTERNAL_SYMBOL,]
5833 -- [, [Form =>] Ada | VMS]
5834 -- [, [Code =>] static_integer_EXPRESSION]);
5836 when Pragma_Export_Exception => Export_Exception : declare
5837 Args : Args_List (1 .. 4);
5838 Names : constant Name_List (1 .. 4) := (
5844 Internal : Node_Id renames Args (1);
5845 External : Node_Id renames Args (2);
5846 Form : Node_Id renames Args (3);
5847 Code : Node_Id renames Args (4);
5850 if Inside_A_Generic then
5851 Error_Pragma ("pragma% cannot be used for generic entities");
5854 Gather_Associations (Names, Args);
5855 Process_Extended_Import_Export_Exception_Pragma (
5856 Arg_Internal => Internal,
5857 Arg_External => External,
5861 if not Is_VMS_Exception (Entity (Internal)) then
5862 Set_Exported (Entity (Internal), Internal);
5864 end Export_Exception;
5866 ---------------------
5867 -- Export_Function --
5868 ---------------------
5870 -- pragma Export_Function (
5871 -- [Internal =>] LOCAL_NAME,
5872 -- [, [External =>] EXTERNAL_SYMBOL,]
5873 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5874 -- [, [Result_Type =>] TYPE_DESIGNATOR]
5875 -- [, [Mechanism =>] MECHANISM]
5876 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
5878 -- EXTERNAL_SYMBOL ::=
5880 -- | static_string_EXPRESSION
5882 -- PARAMETER_TYPES ::=
5884 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
5886 -- TYPE_DESIGNATOR ::=
5888 -- | subtype_Name ' Access
5892 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
5894 -- MECHANISM_ASSOCIATION ::=
5895 -- [formal_parameter_NAME =>] MECHANISM_NAME
5897 -- MECHANISM_NAME ::=
5900 -- | Descriptor [([Class =>] CLASS_NAME)]
5902 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
5904 when Pragma_Export_Function => Export_Function : declare
5905 Args : Args_List (1 .. 6);
5906 Names : constant Name_List (1 .. 6) := (
5909 Name_Parameter_Types,
5912 Name_Result_Mechanism);
5914 Internal : Node_Id renames Args (1);
5915 External : Node_Id renames Args (2);
5916 Parameter_Types : Node_Id renames Args (3);
5917 Result_Type : Node_Id renames Args (4);
5918 Mechanism : Node_Id renames Args (5);
5919 Result_Mechanism : Node_Id renames Args (6);
5923 Gather_Associations (Names, Args);
5924 Process_Extended_Import_Export_Subprogram_Pragma (
5925 Arg_Internal => Internal,
5926 Arg_External => External,
5927 Arg_Parameter_Types => Parameter_Types,
5928 Arg_Result_Type => Result_Type,
5929 Arg_Mechanism => Mechanism,
5930 Arg_Result_Mechanism => Result_Mechanism);
5931 end Export_Function;
5937 -- pragma Export_Object (
5938 -- [Internal =>] LOCAL_NAME,
5939 -- [, [External =>] EXTERNAL_SYMBOL]
5940 -- [, [Size =>] EXTERNAL_SYMBOL]);
5942 -- EXTERNAL_SYMBOL ::=
5944 -- | static_string_EXPRESSION
5946 -- PARAMETER_TYPES ::=
5948 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
5950 -- TYPE_DESIGNATOR ::=
5952 -- | subtype_Name ' Access
5956 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
5958 -- MECHANISM_ASSOCIATION ::=
5959 -- [formal_parameter_NAME =>] MECHANISM_NAME
5961 -- MECHANISM_NAME ::=
5964 -- | Descriptor [([Class =>] CLASS_NAME)]
5966 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
5968 when Pragma_Export_Object => Export_Object : declare
5969 Args : Args_List (1 .. 3);
5970 Names : constant Name_List (1 .. 3) := (
5975 Internal : Node_Id renames Args (1);
5976 External : Node_Id renames Args (2);
5977 Size : Node_Id renames Args (3);
5981 Gather_Associations (Names, Args);
5982 Process_Extended_Import_Export_Object_Pragma (
5983 Arg_Internal => Internal,
5984 Arg_External => External,
5988 ----------------------
5989 -- Export_Procedure --
5990 ----------------------
5992 -- pragma Export_Procedure (
5993 -- [Internal =>] LOCAL_NAME,
5994 -- [, [External =>] EXTERNAL_SYMBOL,]
5995 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5996 -- [, [Mechanism =>] MECHANISM]);
5998 -- EXTERNAL_SYMBOL ::=
6000 -- | static_string_EXPRESSION
6002 -- PARAMETER_TYPES ::=
6004 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6006 -- TYPE_DESIGNATOR ::=
6008 -- | subtype_Name ' Access
6012 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6014 -- MECHANISM_ASSOCIATION ::=
6015 -- [formal_parameter_NAME =>] MECHANISM_NAME
6017 -- MECHANISM_NAME ::=
6020 -- | Descriptor [([Class =>] CLASS_NAME)]
6022 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6024 when Pragma_Export_Procedure => Export_Procedure : declare
6025 Args : Args_List (1 .. 4);
6026 Names : constant Name_List (1 .. 4) := (
6029 Name_Parameter_Types,
6032 Internal : Node_Id renames Args (1);
6033 External : Node_Id renames Args (2);
6034 Parameter_Types : Node_Id renames Args (3);
6035 Mechanism : Node_Id renames Args (4);
6039 Gather_Associations (Names, Args);
6040 Process_Extended_Import_Export_Subprogram_Pragma (
6041 Arg_Internal => Internal,
6042 Arg_External => External,
6043 Arg_Parameter_Types => Parameter_Types,
6044 Arg_Mechanism => Mechanism);
6045 end Export_Procedure;
6051 -- pragma Export_Value (
6052 -- [Value =>] static_integer_EXPRESSION,
6053 -- [Link_Name =>] static_string_EXPRESSION);
6055 when Pragma_Export_Value =>
6057 Check_Arg_Count (2);
6059 Check_Optional_Identifier (Arg1, Name_Value);
6060 Check_Arg_Is_Static_Expression (Arg1, Any_Integer);
6062 Check_Optional_Identifier (Arg2, Name_Link_Name);
6063 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
6065 -----------------------------
6066 -- Export_Valued_Procedure --
6067 -----------------------------
6069 -- pragma Export_Valued_Procedure (
6070 -- [Internal =>] LOCAL_NAME,
6071 -- [, [External =>] EXTERNAL_SYMBOL,]
6072 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6073 -- [, [Mechanism =>] MECHANISM]);
6075 -- EXTERNAL_SYMBOL ::=
6077 -- | static_string_EXPRESSION
6079 -- PARAMETER_TYPES ::=
6081 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6083 -- TYPE_DESIGNATOR ::=
6085 -- | subtype_Name ' Access
6089 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6091 -- MECHANISM_ASSOCIATION ::=
6092 -- [formal_parameter_NAME =>] MECHANISM_NAME
6094 -- MECHANISM_NAME ::=
6097 -- | Descriptor [([Class =>] CLASS_NAME)]
6099 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6101 when Pragma_Export_Valued_Procedure =>
6102 Export_Valued_Procedure : declare
6103 Args : Args_List (1 .. 4);
6104 Names : constant Name_List (1 .. 4) := (
6107 Name_Parameter_Types,
6110 Internal : Node_Id renames Args (1);
6111 External : Node_Id renames Args (2);
6112 Parameter_Types : Node_Id renames Args (3);
6113 Mechanism : Node_Id renames Args (4);
6117 Gather_Associations (Names, Args);
6118 Process_Extended_Import_Export_Subprogram_Pragma (
6119 Arg_Internal => Internal,
6120 Arg_External => External,
6121 Arg_Parameter_Types => Parameter_Types,
6122 Arg_Mechanism => Mechanism);
6123 end Export_Valued_Procedure;
6129 -- pragma Extend_System ([Name =>] Identifier);
6131 when Pragma_Extend_System => Extend_System : declare
6134 Check_Valid_Configuration_Pragma;
6135 Check_Arg_Count (1);
6136 Check_Optional_Identifier (Arg1, Name_Name);
6137 Check_Arg_Is_Identifier (Arg1);
6139 Get_Name_String (Chars (Expression (Arg1)));
6142 and then Name_Buffer (1 .. 4) = "aux_"
6144 if Present (System_Extend_Pragma_Arg) then
6145 if Chars (Expression (Arg1)) =
6146 Chars (Expression (System_Extend_Pragma_Arg))
6150 Error_Msg_Sloc := Sloc (System_Extend_Pragma_Arg);
6151 Error_Pragma ("pragma% conflicts with that at#");
6155 System_Extend_Pragma_Arg := Arg1;
6157 if not GNAT_Mode then
6158 System_Extend_Unit := Arg1;
6162 Error_Pragma ("incorrect name for pragma%, must be Aux_xxx");
6166 ------------------------
6167 -- Extensions_Allowed --
6168 ------------------------
6170 -- pragma Extensions_Allowed (ON | OFF);
6172 when Pragma_Extensions_Allowed =>
6174 Check_Arg_Count (1);
6175 Check_No_Identifiers;
6176 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
6178 if Chars (Expression (Arg1)) = Name_On then
6179 Extensions_Allowed := True;
6180 Ada_Version := Ada_Version_Type'Last;
6182 Extensions_Allowed := False;
6183 Ada_Version := Ada_Version_Type'Min (Ada_Version, Ada_95);
6190 -- pragma External (
6191 -- [ Convention =>] convention_IDENTIFIER,
6192 -- [ Entity =>] local_NAME
6193 -- [, [External_Name =>] static_string_EXPRESSION ]
6194 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6196 when Pragma_External => External : declare
6202 Check_At_Least_N_Arguments (2);
6203 Check_At_Most_N_Arguments (4);
6204 Process_Convention (C, Def_Id);
6205 Note_Possible_Modification (Expression (Arg2));
6206 Process_Interface_Name (Def_Id, Arg3, Arg4);
6207 Set_Exported (Def_Id, Arg2);
6210 --------------------------
6211 -- External_Name_Casing --
6212 --------------------------
6214 -- pragma External_Name_Casing (
6215 -- UPPERCASE | LOWERCASE
6216 -- [, AS_IS | UPPERCASE | LOWERCASE]);
6218 when Pragma_External_Name_Casing =>
6220 External_Name_Casing : declare
6223 Check_No_Identifiers;
6225 if Arg_Count = 2 then
6227 (Arg2, Name_As_Is, Name_Uppercase, Name_Lowercase);
6229 case Chars (Get_Pragma_Arg (Arg2)) is
6231 Opt.External_Name_Exp_Casing := As_Is;
6233 when Name_Uppercase =>
6234 Opt.External_Name_Exp_Casing := Uppercase;
6236 when Name_Lowercase =>
6237 Opt.External_Name_Exp_Casing := Lowercase;
6244 Check_Arg_Count (1);
6247 Check_Arg_Is_One_Of (Arg1, Name_Uppercase, Name_Lowercase);
6249 case Chars (Get_Pragma_Arg (Arg1)) is
6250 when Name_Uppercase =>
6251 Opt.External_Name_Imp_Casing := Uppercase;
6253 when Name_Lowercase =>
6254 Opt.External_Name_Imp_Casing := Lowercase;
6259 end External_Name_Casing;
6261 ---------------------------
6262 -- Finalize_Storage_Only --
6263 ---------------------------
6265 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
6267 when Pragma_Finalize_Storage_Only => Finalize_Storage : declare
6268 Assoc : constant Node_Id := Arg1;
6269 Type_Id : constant Node_Id := Expression (Assoc);
6273 Check_No_Identifiers;
6274 Check_Arg_Count (1);
6275 Check_Arg_Is_Local_Name (Arg1);
6277 Find_Type (Type_Id);
6278 Typ := Entity (Type_Id);
6281 or else Rep_Item_Too_Early (Typ, N)
6285 Typ := Underlying_Type (Typ);
6288 if not Is_Controlled (Typ) then
6289 Error_Pragma ("pragma% must specify controlled type");
6292 Check_First_Subtype (Arg1);
6294 if Finalize_Storage_Only (Typ) then
6295 Error_Pragma ("duplicate pragma%, only one allowed");
6297 elsif not Rep_Item_Too_Late (Typ, N) then
6298 Set_Finalize_Storage_Only (Base_Type (Typ), True);
6300 end Finalize_Storage;
6302 --------------------------
6303 -- Float_Representation --
6304 --------------------------
6306 -- pragma Float_Representation (VAX_Float | IEEE_Float);
6308 when Pragma_Float_Representation => Float_Representation : declare
6316 if Arg_Count = 1 then
6317 Check_Valid_Configuration_Pragma;
6319 Check_Arg_Count (2);
6320 Check_Optional_Identifier (Arg2, Name_Entity);
6321 Check_Arg_Is_Local_Name (Arg2);
6324 Check_No_Identifier (Arg1);
6325 Check_Arg_Is_One_Of (Arg1, Name_VAX_Float, Name_IEEE_Float);
6327 if not OpenVMS_On_Target then
6328 if Chars (Expression (Arg1)) = Name_VAX_Float then
6330 ("?pragma% ignored (applies only to Open'V'M'S)");
6336 -- One argument case
6338 if Arg_Count = 1 then
6340 if Chars (Expression (Arg1)) = Name_VAX_Float then
6342 if Opt.Float_Format = 'I' then
6343 Error_Pragma ("'I'E'E'E format previously specified");
6346 Opt.Float_Format := 'V';
6349 if Opt.Float_Format = 'V' then
6350 Error_Pragma ("'V'A'X format previously specified");
6353 Opt.Float_Format := 'I';
6356 Set_Standard_Fpt_Formats;
6358 -- Two argument case
6361 Argx := Get_Pragma_Arg (Arg2);
6363 if not Is_Entity_Name (Argx)
6364 or else not Is_Floating_Point_Type (Entity (Argx))
6367 ("second argument of% pragma must be floating-point type",
6371 Ent := Entity (Argx);
6372 Digs := UI_To_Int (Digits_Value (Ent));
6374 -- Two arguments, VAX_Float case
6376 if Chars (Expression (Arg1)) = Name_VAX_Float then
6379 when 6 => Set_F_Float (Ent);
6380 when 9 => Set_D_Float (Ent);
6381 when 15 => Set_G_Float (Ent);
6385 ("wrong digits value, must be 6,9 or 15", Arg2);
6388 -- Two arguments, IEEE_Float case
6392 when 6 => Set_IEEE_Short (Ent);
6393 when 15 => Set_IEEE_Long (Ent);
6397 ("wrong digits value, must be 6 or 15", Arg2);
6401 end Float_Representation;
6407 -- pragma Ident (static_string_EXPRESSION)
6409 -- Note: pragma Comment shares this processing. Pragma Comment
6410 -- is identical to Ident, except that the restriction of the
6411 -- argument to 31 characters and the placement restrictions
6412 -- are not enforced for pragma Comment.
6414 when Pragma_Ident | Pragma_Comment => Ident : declare
6419 Check_Arg_Count (1);
6420 Check_No_Identifiers;
6421 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
6423 -- For pragma Ident, preserve DEC compatibility by requiring
6424 -- the pragma to appear in a declarative part or package spec.
6426 if Prag_Id = Pragma_Ident then
6427 Check_Is_In_Decl_Part_Or_Package_Spec;
6430 Str := Expr_Value_S (Expression (Arg1));
6437 GP := Parent (Parent (N));
6439 if Nkind (GP) = N_Package_Declaration
6441 Nkind (GP) = N_Generic_Package_Declaration
6446 -- If we have a compilation unit, then record the ident
6447 -- value, checking for improper duplication.
6449 if Nkind (GP) = N_Compilation_Unit then
6450 CS := Ident_String (Current_Sem_Unit);
6452 if Present (CS) then
6454 -- For Ident, we do not permit multiple instances
6456 if Prag_Id = Pragma_Ident then
6457 Error_Pragma ("duplicate% pragma not permitted");
6459 -- For Comment, we concatenate the string, unless we
6460 -- want to preserve the tree structure for ASIS.
6462 elsif not ASIS_Mode then
6463 Start_String (Strval (CS));
6464 Store_String_Char (' ');
6465 Store_String_Chars (Strval (Str));
6466 Set_Strval (CS, End_String);
6470 -- In VMS, the effect of IDENT is achieved by passing
6471 -- IDENTIFICATION=name as a --for-linker switch.
6473 if OpenVMS_On_Target then
6476 ("--for-linker=IDENTIFICATION=");
6477 String_To_Name_Buffer (Strval (Str));
6478 Store_String_Chars (Name_Buffer (1 .. Name_Len));
6480 -- Only the last processed IDENT is saved. The main
6481 -- purpose is so an IDENT associated with a main
6482 -- procedure will be used in preference to an IDENT
6483 -- associated with a with'd package.
6485 Replace_Linker_Option_String
6486 (End_String, "--for-linker=IDENTIFICATION=");
6489 Set_Ident_String (Current_Sem_Unit, Str);
6492 -- For subunits, we just ignore the Ident, since in GNAT
6493 -- these are not separate object files, and hence not
6494 -- separate units in the unit table.
6496 elsif Nkind (GP) = N_Subunit then
6499 -- Otherwise we have a misplaced pragma Ident, but we ignore
6500 -- this if we are in an instantiation, since it comes from
6501 -- a generic, and has no relevance to the instantiation.
6503 elsif Prag_Id = Pragma_Ident then
6504 if Instantiation_Location (Loc) = No_Location then
6505 Error_Pragma ("pragma% only allowed at outer level");
6516 -- [ Convention =>] convention_IDENTIFIER,
6517 -- [ Entity =>] local_NAME
6518 -- [, [External_Name =>] static_string_EXPRESSION ]
6519 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6521 when Pragma_Import =>
6522 Check_Ada_83_Warning;
6523 Check_At_Least_N_Arguments (2);
6524 Check_At_Most_N_Arguments (4);
6525 Process_Import_Or_Interface;
6527 ----------------------
6528 -- Import_Exception --
6529 ----------------------
6531 -- pragma Import_Exception (
6532 -- [Internal =>] LOCAL_NAME,
6533 -- [, [External =>] EXTERNAL_SYMBOL,]
6534 -- [, [Form =>] Ada | VMS]
6535 -- [, [Code =>] static_integer_EXPRESSION]);
6537 when Pragma_Import_Exception => Import_Exception : declare
6538 Args : Args_List (1 .. 4);
6539 Names : constant Name_List (1 .. 4) := (
6545 Internal : Node_Id renames Args (1);
6546 External : Node_Id renames Args (2);
6547 Form : Node_Id renames Args (3);
6548 Code : Node_Id renames Args (4);
6551 Gather_Associations (Names, Args);
6553 if Present (External) and then Present (Code) then
6555 ("cannot give both External and Code options for pragma%");
6558 Process_Extended_Import_Export_Exception_Pragma (
6559 Arg_Internal => Internal,
6560 Arg_External => External,
6564 if not Is_VMS_Exception (Entity (Internal)) then
6565 Set_Imported (Entity (Internal));
6567 end Import_Exception;
6569 ---------------------
6570 -- Import_Function --
6571 ---------------------
6573 -- pragma Import_Function (
6574 -- [Internal =>] LOCAL_NAME,
6575 -- [, [External =>] EXTERNAL_SYMBOL]
6576 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6577 -- [, [Result_Type =>] SUBTYPE_MARK]
6578 -- [, [Mechanism =>] MECHANISM]
6579 -- [, [Result_Mechanism =>] MECHANISM_NAME]
6580 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6582 -- EXTERNAL_SYMBOL ::=
6584 -- | static_string_EXPRESSION
6586 -- PARAMETER_TYPES ::=
6588 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6590 -- TYPE_DESIGNATOR ::=
6592 -- | subtype_Name ' Access
6596 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6598 -- MECHANISM_ASSOCIATION ::=
6599 -- [formal_parameter_NAME =>] MECHANISM_NAME
6601 -- MECHANISM_NAME ::=
6604 -- | Descriptor [([Class =>] CLASS_NAME)]
6606 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6608 when Pragma_Import_Function => Import_Function : declare
6609 Args : Args_List (1 .. 7);
6610 Names : constant Name_List (1 .. 7) := (
6613 Name_Parameter_Types,
6616 Name_Result_Mechanism,
6617 Name_First_Optional_Parameter);
6619 Internal : Node_Id renames Args (1);
6620 External : Node_Id renames Args (2);
6621 Parameter_Types : Node_Id renames Args (3);
6622 Result_Type : Node_Id renames Args (4);
6623 Mechanism : Node_Id renames Args (5);
6624 Result_Mechanism : Node_Id renames Args (6);
6625 First_Optional_Parameter : Node_Id renames Args (7);
6629 Gather_Associations (Names, Args);
6630 Process_Extended_Import_Export_Subprogram_Pragma (
6631 Arg_Internal => Internal,
6632 Arg_External => External,
6633 Arg_Parameter_Types => Parameter_Types,
6634 Arg_Result_Type => Result_Type,
6635 Arg_Mechanism => Mechanism,
6636 Arg_Result_Mechanism => Result_Mechanism,
6637 Arg_First_Optional_Parameter => First_Optional_Parameter);
6638 end Import_Function;
6644 -- pragma Import_Object (
6645 -- [Internal =>] LOCAL_NAME,
6646 -- [, [External =>] EXTERNAL_SYMBOL]
6647 -- [, [Size =>] EXTERNAL_SYMBOL]);
6649 -- EXTERNAL_SYMBOL ::=
6651 -- | static_string_EXPRESSION
6653 when Pragma_Import_Object => Import_Object : declare
6654 Args : Args_List (1 .. 3);
6655 Names : constant Name_List (1 .. 3) := (
6660 Internal : Node_Id renames Args (1);
6661 External : Node_Id renames Args (2);
6662 Size : Node_Id renames Args (3);
6666 Gather_Associations (Names, Args);
6667 Process_Extended_Import_Export_Object_Pragma (
6668 Arg_Internal => Internal,
6669 Arg_External => External,
6673 ----------------------
6674 -- Import_Procedure --
6675 ----------------------
6677 -- pragma Import_Procedure (
6678 -- [Internal =>] LOCAL_NAME,
6679 -- [, [External =>] EXTERNAL_SYMBOL]
6680 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6681 -- [, [Mechanism =>] MECHANISM]
6682 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6684 -- EXTERNAL_SYMBOL ::=
6686 -- | static_string_EXPRESSION
6688 -- PARAMETER_TYPES ::=
6690 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6692 -- TYPE_DESIGNATOR ::=
6694 -- | subtype_Name ' Access
6698 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6700 -- MECHANISM_ASSOCIATION ::=
6701 -- [formal_parameter_NAME =>] MECHANISM_NAME
6703 -- MECHANISM_NAME ::=
6706 -- | Descriptor [([Class =>] CLASS_NAME)]
6708 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6710 when Pragma_Import_Procedure => Import_Procedure : declare
6711 Args : Args_List (1 .. 5);
6712 Names : constant Name_List (1 .. 5) := (
6715 Name_Parameter_Types,
6717 Name_First_Optional_Parameter);
6719 Internal : Node_Id renames Args (1);
6720 External : Node_Id renames Args (2);
6721 Parameter_Types : Node_Id renames Args (3);
6722 Mechanism : Node_Id renames Args (4);
6723 First_Optional_Parameter : Node_Id renames Args (5);
6727 Gather_Associations (Names, Args);
6728 Process_Extended_Import_Export_Subprogram_Pragma (
6729 Arg_Internal => Internal,
6730 Arg_External => External,
6731 Arg_Parameter_Types => Parameter_Types,
6732 Arg_Mechanism => Mechanism,
6733 Arg_First_Optional_Parameter => First_Optional_Parameter);
6734 end Import_Procedure;
6736 -----------------------------
6737 -- Import_Valued_Procedure --
6738 -----------------------------
6740 -- pragma Import_Valued_Procedure (
6741 -- [Internal =>] LOCAL_NAME,
6742 -- [, [External =>] EXTERNAL_SYMBOL]
6743 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6744 -- [, [Mechanism =>] MECHANISM]
6745 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6747 -- EXTERNAL_SYMBOL ::=
6749 -- | static_string_EXPRESSION
6751 -- PARAMETER_TYPES ::=
6753 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6755 -- TYPE_DESIGNATOR ::=
6757 -- | subtype_Name ' Access
6761 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6763 -- MECHANISM_ASSOCIATION ::=
6764 -- [formal_parameter_NAME =>] MECHANISM_NAME
6766 -- MECHANISM_NAME ::=
6769 -- | Descriptor [([Class =>] CLASS_NAME)]
6771 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6773 when Pragma_Import_Valued_Procedure =>
6774 Import_Valued_Procedure : declare
6775 Args : Args_List (1 .. 5);
6776 Names : constant Name_List (1 .. 5) := (
6779 Name_Parameter_Types,
6781 Name_First_Optional_Parameter);
6783 Internal : Node_Id renames Args (1);
6784 External : Node_Id renames Args (2);
6785 Parameter_Types : Node_Id renames Args (3);
6786 Mechanism : Node_Id renames Args (4);
6787 First_Optional_Parameter : Node_Id renames Args (5);
6791 Gather_Associations (Names, Args);
6792 Process_Extended_Import_Export_Subprogram_Pragma (
6793 Arg_Internal => Internal,
6794 Arg_External => External,
6795 Arg_Parameter_Types => Parameter_Types,
6796 Arg_Mechanism => Mechanism,
6797 Arg_First_Optional_Parameter => First_Optional_Parameter);
6798 end Import_Valued_Procedure;
6800 ------------------------
6801 -- Initialize_Scalars --
6802 ------------------------
6804 -- pragma Initialize_Scalars;
6806 when Pragma_Initialize_Scalars =>
6808 Check_Arg_Count (0);
6809 Check_Valid_Configuration_Pragma;
6810 Check_Restriction (No_Initialize_Scalars, N);
6812 if not Restriction_Active (No_Initialize_Scalars) then
6813 Init_Or_Norm_Scalars := True;
6814 Initialize_Scalars := True;
6821 -- pragma Inline ( NAME {, NAME} );
6823 when Pragma_Inline =>
6825 -- Pragma is active if inlining option is active
6827 if Inline_Active then
6828 Process_Inline (True);
6830 -- Pragma is active in a predefined file in config run time mode
6832 elsif Configurable_Run_Time_Mode
6834 Is_Predefined_File_Name (Unit_File_Name (Current_Sem_Unit))
6836 Process_Inline (True);
6838 -- Otherwise inlining is not active
6841 Process_Inline (False);
6848 -- pragma Inline_Always ( NAME {, NAME} );
6850 when Pragma_Inline_Always =>
6851 Process_Inline (True);
6853 --------------------
6854 -- Inline_Generic --
6855 --------------------
6857 -- pragma Inline_Generic (NAME {, NAME});
6859 when Pragma_Inline_Generic =>
6860 Process_Generic_List;
6862 ----------------------
6863 -- Inspection_Point --
6864 ----------------------
6866 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
6868 when Pragma_Inspection_Point => Inspection_Point : declare
6873 if Arg_Count > 0 then
6876 Exp := Expression (Arg);
6879 if not Is_Entity_Name (Exp)
6880 or else not Is_Object (Entity (Exp))
6882 Error_Pragma_Arg ("object name required", Arg);
6889 end Inspection_Point;
6895 -- pragma Interface (
6896 -- convention_IDENTIFIER,
6899 when Pragma_Interface =>
6901 Check_Arg_Count (2);
6902 Check_No_Identifiers;
6903 Process_Import_Or_Interface;
6905 --------------------
6906 -- Interface_Name --
6907 --------------------
6909 -- pragma Interface_Name (
6910 -- [ Entity =>] local_NAME
6911 -- [,[External_Name =>] static_string_EXPRESSION ]
6912 -- [,[Link_Name =>] static_string_EXPRESSION ]);
6914 when Pragma_Interface_Name => Interface_Name : declare
6922 Check_At_Least_N_Arguments (2);
6923 Check_At_Most_N_Arguments (3);
6924 Id := Expression (Arg1);
6927 if not Is_Entity_Name (Id) then
6929 ("first argument for pragma% must be entity name", Arg1);
6930 elsif Etype (Id) = Any_Type then
6933 Def_Id := Entity (Id);
6936 -- Special DEC-compatible processing for the object case,
6937 -- forces object to be imported.
6939 if Ekind (Def_Id) = E_Variable then
6940 Kill_Size_Check_Code (Def_Id);
6941 Note_Possible_Modification (Id);
6943 -- Initialization is not allowed for imported variable
6945 if Present (Expression (Parent (Def_Id)))
6946 and then Comes_From_Source (Expression (Parent (Def_Id)))
6948 Error_Msg_Sloc := Sloc (Def_Id);
6950 ("no initialization allowed for declaration of& #",
6954 -- For compatibility, support VADS usage of providing both
6955 -- pragmas Interface and Interface_Name to obtain the effect
6956 -- of a single Import pragma.
6958 if Is_Imported (Def_Id)
6959 and then Present (First_Rep_Item (Def_Id))
6960 and then Nkind (First_Rep_Item (Def_Id)) = N_Pragma
6961 and then Chars (First_Rep_Item (Def_Id)) = Name_Interface
6965 Set_Imported (Def_Id);
6968 Set_Is_Public (Def_Id);
6969 Process_Interface_Name (Def_Id, Arg2, Arg3);
6972 -- Otherwise must be subprogram
6974 elsif not Is_Subprogram (Def_Id) then
6976 ("argument of pragma% is not subprogram", Arg1);
6979 Check_At_Most_N_Arguments (3);
6983 -- Loop through homonyms
6986 Def_Id := Get_Base_Subprogram (Hom_Id);
6988 if Is_Imported (Def_Id) then
6989 Process_Interface_Name (Def_Id, Arg2, Arg3);
6993 Hom_Id := Homonym (Hom_Id);
6995 exit when No (Hom_Id)
6996 or else Scope (Hom_Id) /= Current_Scope;
7001 ("argument of pragma% is not imported subprogram",
7007 -----------------------
7008 -- Interrupt_Handler --
7009 -----------------------
7011 -- pragma Interrupt_Handler (handler_NAME);
7013 when Pragma_Interrupt_Handler =>
7014 Check_Ada_83_Warning;
7015 Check_Arg_Count (1);
7016 Check_No_Identifiers;
7018 if No_Run_Time_Mode then
7019 Error_Msg_CRT ("Interrupt_Handler pragma", N);
7021 Check_Interrupt_Or_Attach_Handler;
7022 Process_Interrupt_Or_Attach_Handler;
7025 ------------------------
7026 -- Interrupt_Priority --
7027 ------------------------
7029 -- pragma Interrupt_Priority [(EXPRESSION)];
7031 when Pragma_Interrupt_Priority => Interrupt_Priority : declare
7032 P : constant Node_Id := Parent (N);
7036 Check_Ada_83_Warning;
7038 if Arg_Count /= 0 then
7039 Arg := Expression (Arg1);
7040 Check_Arg_Count (1);
7041 Check_No_Identifiers;
7043 -- The expression must be analyzed in the special manner
7044 -- described in "Handling of Default and Per-Object
7045 -- Expressions" in sem.ads.
7047 Analyze_Per_Use_Expression (Arg, RTE (RE_Interrupt_Priority));
7050 if Nkind (P) /= N_Task_Definition
7051 and then Nkind (P) /= N_Protected_Definition
7056 elsif Has_Priority_Pragma (P) then
7057 Error_Pragma ("duplicate pragma% not allowed");
7060 Set_Has_Priority_Pragma (P, True);
7061 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
7063 end Interrupt_Priority;
7065 ---------------------
7066 -- Interrupt_State --
7067 ---------------------
7069 -- pragma Interrupt_State (
7070 -- [Name =>] INTERRUPT_ID,
7071 -- [State =>] INTERRUPT_STATE);
7073 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
7074 -- INTERRUPT_STATE => System | Runtime | User
7076 -- Note: if the interrupt id is given as an identifier, then
7077 -- it must be one of the identifiers in Ada.Interrupts.Names.
7078 -- Otherwise it is given as a static integer expression which
7079 -- must be in the range of Ada.Interrupts.Interrupt_ID.
7081 when Pragma_Interrupt_State => Interrupt_State : declare
7083 Int_Id : constant Entity_Id := RTE (RE_Interrupt_ID);
7084 -- This is the entity Ada.Interrupts.Interrupt_ID;
7086 State_Type : Character;
7087 -- Set to 's'/'r'/'u' for System/Runtime/User
7090 -- Index to entry in Interrupt_States table
7093 -- Value of interrupt
7095 Arg1X : constant Node_Id := Get_Pragma_Arg (Arg1);
7096 -- The first argument to the pragma
7098 Int_Ent : Entity_Id;
7099 -- Interrupt entity in Ada.Interrupts.Names
7103 Check_Arg_Count (2);
7105 Check_Optional_Identifier (Arg1, Name_Name);
7106 Check_Optional_Identifier (Arg2, "state");
7107 Check_Arg_Is_Identifier (Arg2);
7109 -- First argument is identifier
7111 if Nkind (Arg1X) = N_Identifier then
7113 -- Search list of names in Ada.Interrupts.Names
7115 Int_Ent := First_Entity (RTE (RE_Names));
7117 if No (Int_Ent) then
7118 Error_Pragma_Arg ("invalid interrupt name", Arg1);
7120 elsif Chars (Int_Ent) = Chars (Arg1X) then
7121 Int_Val := Expr_Value (Constant_Value (Int_Ent));
7125 Next_Entity (Int_Ent);
7128 -- First argument is not an identifier, so it must be a
7129 -- static expression of type Ada.Interrupts.Interrupt_ID.
7132 Check_Arg_Is_Static_Expression (Arg1, Any_Integer);
7133 Int_Val := Expr_Value (Arg1X);
7135 if Int_Val < Expr_Value (Type_Low_Bound (Int_Id))
7137 Int_Val > Expr_Value (Type_High_Bound (Int_Id))
7140 ("value not in range of type " &
7141 """Ada.Interrupts.Interrupt_'I'D""", Arg1);
7147 case Chars (Get_Pragma_Arg (Arg2)) is
7148 when Name_Runtime => State_Type := 'r';
7149 when Name_System => State_Type := 's';
7150 when Name_User => State_Type := 'u';
7153 Error_Pragma_Arg ("invalid interrupt state", Arg2);
7156 -- Check if entry is already stored
7158 IST_Num := Interrupt_States.First;
7160 -- If entry not found, add it
7162 if IST_Num > Interrupt_States.Last then
7163 Interrupt_States.Append
7164 ((Interrupt_Number => UI_To_Int (Int_Val),
7165 Interrupt_State => State_Type,
7166 Pragma_Loc => Loc));
7169 -- Case of entry for the same entry
7171 elsif Int_Val = Interrupt_States.Table (IST_Num).
7174 -- If state matches, done, no need to make redundant entry
7177 State_Type = Interrupt_States.Table (IST_Num).
7180 -- Otherwise if state does not match, error
7183 Interrupt_States.Table (IST_Num).Pragma_Loc;
7185 ("state conflicts with that given at #", Arg2);
7189 IST_Num := IST_Num + 1;
7191 end Interrupt_State;
7193 ----------------------
7194 -- Java_Constructor --
7195 ----------------------
7197 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
7199 when Pragma_Java_Constructor => Java_Constructor : declare
7206 Check_Arg_Count (1);
7207 Check_Optional_Identifier (Arg1, Name_Entity);
7208 Check_Arg_Is_Local_Name (Arg1);
7210 Id := Expression (Arg1);
7211 Find_Program_Unit_Name (Id);
7213 -- If we did not find the name, we are done
7215 if Etype (Id) = Any_Type then
7219 Hom_Id := Entity (Id);
7221 -- Loop through homonyms
7224 Def_Id := Get_Base_Subprogram (Hom_Id);
7226 -- The constructor is required to be a function returning
7227 -- an access type whose designated type has convention Java.
7229 if Ekind (Def_Id) = E_Function
7230 and then Ekind (Etype (Def_Id)) in Access_Kind
7233 (Designated_Type (Etype (Def_Id))) = Convention_Java
7236 (Root_Type (Designated_Type (Etype (Def_Id))))
7239 Set_Is_Constructor (Def_Id);
7240 Set_Convention (Def_Id, Convention_Java);
7244 ("pragma% requires function returning a 'Java access type",
7248 Hom_Id := Homonym (Hom_Id);
7250 exit when No (Hom_Id) or else Scope (Hom_Id) /= Current_Scope;
7252 end Java_Constructor;
7254 ----------------------
7255 -- Java_Interface --
7256 ----------------------
7258 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
7260 when Pragma_Java_Interface => Java_Interface : declare
7266 Check_Arg_Count (1);
7267 Check_Optional_Identifier (Arg1, Name_Entity);
7268 Check_Arg_Is_Local_Name (Arg1);
7270 Arg := Expression (Arg1);
7273 if Etype (Arg) = Any_Type then
7277 if not Is_Entity_Name (Arg)
7278 or else not Is_Type (Entity (Arg))
7280 Error_Pragma_Arg ("pragma% requires a type mark", Arg1);
7283 Typ := Underlying_Type (Entity (Arg));
7285 -- For now we simply check some of the semantic constraints
7286 -- on the type. This currently leaves out some restrictions
7287 -- on interface types, namely that the parent type must be
7288 -- java.lang.Object.Typ and that all primitives of the type
7289 -- should be declared abstract. ???
7291 if not Is_Tagged_Type (Typ) or else not Is_Abstract (Typ) then
7292 Error_Pragma_Arg ("pragma% requires an abstract "
7293 & "tagged type", Arg1);
7295 elsif not Has_Discriminants (Typ)
7296 or else Ekind (Etype (First_Discriminant (Typ)))
7297 /= E_Anonymous_Access_Type
7299 not Is_Class_Wide_Type
7300 (Designated_Type (Etype (First_Discriminant (Typ))))
7303 ("type must have a class-wide access discriminant", Arg1);
7311 -- pragma Keep_Names ([On => ] local_NAME);
7313 when Pragma_Keep_Names => Keep_Names : declare
7318 Check_Arg_Count (1);
7319 Check_Optional_Identifier (Arg1, Name_On);
7320 Check_Arg_Is_Local_Name (Arg1);
7322 Arg := Expression (Arg1);
7325 if Etype (Arg) = Any_Type then
7329 if not Is_Entity_Name (Arg)
7330 or else Ekind (Entity (Arg)) /= E_Enumeration_Type
7333 ("pragma% requires a local enumeration type", Arg1);
7336 Set_Discard_Names (Entity (Arg), False);
7343 -- pragma License (RESTRICTED | UNRESRICTED | GPL | MODIFIED_GPL);
7345 when Pragma_License =>
7347 Check_Arg_Count (1);
7348 Check_No_Identifiers;
7349 Check_Valid_Configuration_Pragma;
7350 Check_Arg_Is_Identifier (Arg1);
7353 Sind : constant Source_File_Index :=
7354 Source_Index (Current_Sem_Unit);
7357 case Chars (Get_Pragma_Arg (Arg1)) is
7359 Set_License (Sind, GPL);
7361 when Name_Modified_GPL =>
7362 Set_License (Sind, Modified_GPL);
7364 when Name_Restricted =>
7365 Set_License (Sind, Restricted);
7367 when Name_Unrestricted =>
7368 Set_License (Sind, Unrestricted);
7371 Error_Pragma_Arg ("invalid license name", Arg1);
7379 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
7381 when Pragma_Link_With => Link_With : declare
7387 if Operating_Mode = Generate_Code
7388 and then In_Extended_Main_Source_Unit (N)
7390 Check_At_Least_N_Arguments (1);
7391 Check_No_Identifiers;
7392 Check_Is_In_Decl_Part_Or_Package_Spec;
7393 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
7397 while Present (Arg) loop
7398 Check_Arg_Is_Static_Expression (Arg, Standard_String);
7400 -- Store argument, converting sequences of spaces
7401 -- to a single null character (this is one of the
7402 -- differences in processing between Link_With
7403 -- and Linker_Options).
7406 C : constant Char_Code := Get_Char_Code (' ');
7407 S : constant String_Id :=
7408 Strval (Expr_Value_S (Expression (Arg)));
7409 L : constant Nat := String_Length (S);
7412 procedure Skip_Spaces;
7413 -- Advance F past any spaces
7415 procedure Skip_Spaces is
7417 while F <= L and then Get_String_Char (S, F) = C loop
7423 Skip_Spaces; -- skip leading spaces
7425 -- Loop through characters, changing any embedded
7426 -- sequence of spaces to a single null character
7427 -- (this is how Link_With/Linker_Options differ)
7430 if Get_String_Char (S, F) = C then
7433 Store_String_Char (ASCII.NUL);
7436 Store_String_Char (Get_String_Char (S, F));
7444 if Present (Arg) then
7445 Store_String_Char (ASCII.NUL);
7449 Store_Linker_Option_String (End_String);
7457 -- pragma Linker_Alias (
7458 -- [Entity =>] LOCAL_NAME
7459 -- [Alias =>] static_string_EXPRESSION);
7461 when Pragma_Linker_Alias =>
7463 Check_Arg_Count (2);
7464 Check_Optional_Identifier (Arg1, Name_Entity);
7465 Check_Optional_Identifier (Arg2, "alias");
7466 Check_Arg_Is_Library_Level_Local_Name (Arg1);
7467 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
7469 -- The only processing required is to link this item on to the
7470 -- list of rep items for the given entity. This is accomplished
7471 -- by the call to Rep_Item_Too_Late (when no error is detected
7472 -- and False is returned).
7474 if Rep_Item_Too_Late (Entity (Expression (Arg1)), N) then
7477 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
7480 --------------------
7481 -- Linker_Options --
7482 --------------------
7484 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
7486 when Pragma_Linker_Options => Linker_Options : declare
7490 Check_Ada_83_Warning;
7491 Check_No_Identifiers;
7492 Check_Arg_Count (1);
7493 Check_Is_In_Decl_Part_Or_Package_Spec;
7495 if Operating_Mode = Generate_Code
7496 and then In_Extended_Main_Source_Unit (N)
7498 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
7499 Start_String (Strval (Expr_Value_S (Expression (Arg1))));
7502 while Present (Arg) loop
7503 Check_Arg_Is_Static_Expression (Arg, Standard_String);
7504 Store_String_Char (ASCII.NUL);
7506 (Strval (Expr_Value_S (Expression (Arg))));
7510 Store_Linker_Option_String (End_String);
7514 --------------------
7515 -- Linker_Section --
7516 --------------------
7518 -- pragma Linker_Section (
7519 -- [Entity =>] LOCAL_NAME
7520 -- [Section =>] static_string_EXPRESSION);
7522 when Pragma_Linker_Section =>
7524 Check_Arg_Count (2);
7525 Check_Optional_Identifier (Arg1, Name_Entity);
7526 Check_Optional_Identifier (Arg2, Name_Section);
7527 Check_Arg_Is_Library_Level_Local_Name (Arg1);
7528 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
7530 -- The only processing required is to link this item on to the
7531 -- list of rep items for the given entity. This is accomplished
7532 -- by the call to Rep_Item_Too_Late (when no error is detected
7533 -- and False is returned).
7535 if Rep_Item_Too_Late (Entity (Expression (Arg1)), N) then
7538 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
7545 -- pragma List (On | Off)
7547 -- There is nothing to do here, since we did all the processing
7548 -- for this pragma in Par.Prag (so that it works properly even in
7549 -- syntax only mode)
7554 --------------------
7555 -- Locking_Policy --
7556 --------------------
7558 -- pragma Locking_Policy (policy_IDENTIFIER);
7560 when Pragma_Locking_Policy => declare
7564 Check_Ada_83_Warning;
7565 Check_Arg_Count (1);
7566 Check_No_Identifiers;
7567 Check_Arg_Is_Locking_Policy (Arg1);
7568 Check_Valid_Configuration_Pragma;
7569 Get_Name_String (Chars (Expression (Arg1)));
7570 LP := Fold_Upper (Name_Buffer (1));
7572 if Locking_Policy /= ' '
7573 and then Locking_Policy /= LP
7575 Error_Msg_Sloc := Locking_Policy_Sloc;
7576 Error_Pragma ("locking policy incompatible with policy#");
7578 -- Set new policy, but always preserve System_Location since
7579 -- we like the error message with the run time name.
7582 Locking_Policy := LP;
7584 if Locking_Policy_Sloc /= System_Location then
7585 Locking_Policy_Sloc := Loc;
7594 -- pragma Long_Float (D_Float | G_Float);
7596 when Pragma_Long_Float =>
7598 Check_Valid_Configuration_Pragma;
7599 Check_Arg_Count (1);
7600 Check_No_Identifier (Arg1);
7601 Check_Arg_Is_One_Of (Arg1, Name_D_Float, Name_G_Float);
7603 if not OpenVMS_On_Target then
7604 Error_Pragma ("?pragma% ignored (applies only to Open'V'M'S)");
7609 if Chars (Expression (Arg1)) = Name_D_Float then
7610 if Opt.Float_Format_Long = 'G' then
7611 Error_Pragma ("G_Float previously specified");
7614 Opt.Float_Format_Long := 'D';
7616 -- G_Float case (this is the default, does not need overriding)
7619 if Opt.Float_Format_Long = 'D' then
7620 Error_Pragma ("D_Float previously specified");
7623 Opt.Float_Format_Long := 'G';
7626 Set_Standard_Fpt_Formats;
7628 -----------------------
7629 -- Machine_Attribute --
7630 -----------------------
7632 -- pragma Machine_Attribute (
7633 -- [Entity =>] LOCAL_NAME,
7634 -- [Attribute_Name =>] static_string_EXPRESSION
7635 -- [,[Info =>] static_string_EXPRESSION] );
7637 when Pragma_Machine_Attribute => Machine_Attribute : declare
7643 if Arg_Count = 3 then
7644 Check_Optional_Identifier (Arg3, "info");
7645 Check_Arg_Is_Static_Expression (Arg3, Standard_String);
7647 Check_Arg_Count (2);
7650 Check_Arg_Is_Local_Name (Arg1);
7651 Check_Optional_Identifier (Arg2, "attribute_name");
7652 Check_Optional_Identifier (Arg1, Name_Entity);
7653 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
7654 Def_Id := Entity (Expression (Arg1));
7656 if Is_Access_Type (Def_Id) then
7657 Def_Id := Designated_Type (Def_Id);
7660 if Rep_Item_Too_Early (Def_Id, N) then
7664 Def_Id := Underlying_Type (Def_Id);
7666 -- The only processing required is to link this item on to the
7667 -- list of rep items for the given entity. This is accomplished
7668 -- by the call to Rep_Item_Too_Late (when no error is detected
7669 -- and False is returned).
7671 if Rep_Item_Too_Late (Def_Id, N) then
7674 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
7676 end Machine_Attribute;
7682 -- pragma Main_Storage
7683 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
7685 -- MAIN_STORAGE_OPTION ::=
7686 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
7687 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
7689 when Pragma_Main => Main : declare
7690 Args : Args_List (1 .. 3);
7691 Names : constant Name_List (1 .. 3) := (
7693 Name_Task_Stack_Size_Default,
7694 Name_Time_Slicing_Enabled);
7700 Gather_Associations (Names, Args);
7702 for J in 1 .. 2 loop
7703 if Present (Args (J)) then
7704 Check_Arg_Is_Static_Expression (Args (J), Any_Integer);
7708 if Present (Args (3)) then
7709 Check_Arg_Is_Static_Expression (Args (3), Standard_Boolean);
7713 while Present (Nod) loop
7714 if Nkind (Nod) = N_Pragma
7715 and then Chars (Nod) = Name_Main
7717 Error_Msg_Name_1 := Chars (N);
7718 Error_Msg_N ("duplicate pragma% not permitted", Nod);
7729 -- pragma Main_Storage
7730 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
7732 -- MAIN_STORAGE_OPTION ::=
7733 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
7734 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
7736 when Pragma_Main_Storage => Main_Storage : declare
7737 Args : Args_List (1 .. 2);
7738 Names : constant Name_List (1 .. 2) := (
7739 Name_Working_Storage,
7746 Gather_Associations (Names, Args);
7748 for J in 1 .. 2 loop
7749 if Present (Args (J)) then
7750 Check_Arg_Is_Static_Expression (Args (J), Any_Integer);
7754 Check_In_Main_Program;
7757 while Present (Nod) loop
7758 if Nkind (Nod) = N_Pragma
7759 and then Chars (Nod) = Name_Main_Storage
7761 Error_Msg_Name_1 := Chars (N);
7762 Error_Msg_N ("duplicate pragma% not permitted", Nod);
7773 -- pragma Memory_Size (NUMERIC_LITERAL)
7775 when Pragma_Memory_Size =>
7778 -- Memory size is simply ignored
7780 Check_No_Identifiers;
7781 Check_Arg_Count (1);
7782 Check_Arg_Is_Integer_Literal (Arg1);
7788 -- pragma No_Return (procedure_LOCAL_NAME);
7790 when Pragma_No_Return => No_Return : declare
7797 Check_Arg_Count (1);
7798 Check_No_Identifiers;
7799 Check_Arg_Is_Local_Name (Arg1);
7800 Id := Expression (Arg1);
7803 if not Is_Entity_Name (Id) then
7804 Error_Pragma_Arg ("entity name required", Arg1);
7807 if Etype (Id) = Any_Type then
7815 and then Scope (E) = Current_Scope
7817 if Ekind (E) = E_Procedure
7818 or else Ekind (E) = E_Generic_Procedure
7828 Error_Pragma ("no procedures found for pragma%");
7832 ------------------------
7833 -- No_Strict_Aliasing --
7834 ------------------------
7836 when Pragma_No_Strict_Aliasing => No_Strict_Alias : declare
7841 Check_At_Most_N_Arguments (1);
7843 if Arg_Count = 0 then
7844 Check_Valid_Configuration_Pragma;
7845 Opt.No_Strict_Aliasing := True;
7848 Check_Optional_Identifier (Arg2, Name_Entity);
7849 Check_Arg_Is_Local_Name (Arg1);
7850 E_Id := Entity (Expression (Arg1));
7852 if E_Id = Any_Type then
7854 elsif No (E_Id) or else not Is_Access_Type (E_Id) then
7855 Error_Pragma_Arg ("pragma% requires access type", Arg1);
7858 Set_No_Strict_Aliasing (Implementation_Base_Type (E_Id));
7860 end No_Strict_Alias;
7866 -- pragma Obsolescent [(static_string_EXPRESSION)];
7868 when Pragma_Obsolescent => Obsolescent : declare
7871 Check_At_Most_N_Arguments (1);
7872 Check_No_Identifiers;
7874 if Arg_Count = 1 then
7875 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
7879 or else (Nkind (Prev (N))) /= N_Subprogram_Declaration
7882 ("pragma% misplaced, must immediately " &
7883 "follow subprogram spec");
7891 -- pragma No_Run_Time
7893 -- Note: this pragma is retained for backwards compatibiltiy.
7894 -- See body of Rtsfind for full details on its handling.
7896 when Pragma_No_Run_Time =>
7898 Check_Valid_Configuration_Pragma;
7899 Check_Arg_Count (0);
7901 No_Run_Time_Mode := True;
7902 Configurable_Run_Time_Mode := True;
7905 Word32 : constant Boolean := Ttypes.System_Word_Size = 32;
7908 Duration_32_Bits_On_Target := True;
7912 Set_Restriction (No_Finalization, N);
7913 Set_Restriction (No_Exception_Handlers, N);
7914 Set_Restriction (Max_Tasks, N, 0);
7915 Set_Restriction (No_Tasking, N);
7917 -----------------------
7918 -- Normalize_Scalars --
7919 -----------------------
7921 -- pragma Normalize_Scalars;
7923 when Pragma_Normalize_Scalars =>
7924 Check_Ada_83_Warning;
7925 Check_Arg_Count (0);
7926 Check_Valid_Configuration_Pragma;
7927 Normalize_Scalars := True;
7928 Init_Or_Norm_Scalars := True;
7934 -- pragma Optimize (Time | Space);
7936 -- The actual check for optimize is done in Gigi. Note that this
7937 -- pragma does not actually change the optimization setting, it
7938 -- simply checks that it is consistent with the pragma.
7940 when Pragma_Optimize =>
7941 Check_No_Identifiers;
7942 Check_Arg_Count (1);
7943 Check_Arg_Is_One_Of (Arg1, Name_Time, Name_Space, Name_Off);
7945 -------------------------
7946 -- Optional_Overriding --
7947 -------------------------
7949 -- These pragmas are treated as part of the previous subprogram
7950 -- declaration, and analyzed immediately after it (see sem_ch6,
7951 -- Check_Overriding_Operation). If the pragma has not been analyzed
7952 -- yet, it appears in the wrong place.
7954 when Pragma_Optional_Overriding =>
7955 Error_Msg_N ("pragma must appear immediately after subprogram", N);
7961 when Pragma_Overriding =>
7962 Error_Msg_N ("pragma must appear immediately after subprogram", N);
7968 -- pragma Pack (first_subtype_LOCAL_NAME);
7970 when Pragma_Pack => Pack : declare
7971 Assoc : constant Node_Id := Arg1;
7976 Check_No_Identifiers;
7977 Check_Arg_Count (1);
7978 Check_Arg_Is_Local_Name (Arg1);
7980 Type_Id := Expression (Assoc);
7981 Find_Type (Type_Id);
7982 Typ := Entity (Type_Id);
7985 or else Rep_Item_Too_Early (Typ, N)
7989 Typ := Underlying_Type (Typ);
7992 if not Is_Array_Type (Typ) and then not Is_Record_Type (Typ) then
7993 Error_Pragma ("pragma% must specify array or record type");
7996 Check_First_Subtype (Arg1);
7998 if Has_Pragma_Pack (Typ) then
7999 Error_Pragma ("duplicate pragma%, only one allowed");
8001 -- Array type. We set the Has_Pragma_Pack flag, and Is_Packed,
8002 -- but not Has_Non_Standard_Rep, because we don't actually know
8003 -- till freeze time if the array can have packed representation.
8004 -- That's because in the general case we do not know enough about
8005 -- the component type until it in turn is frozen, which certainly
8006 -- happens before the array type is frozen, but not necessarily
8007 -- till that point (i.e. right now it may be unfrozen).
8009 elsif Is_Array_Type (Typ) then
8010 if Has_Aliased_Components (Base_Type (Typ)) then
8012 ("pragma% ignored, cannot pack aliased components?");
8014 elsif Has_Atomic_Components (Typ)
8015 or else Is_Atomic (Component_Type (Typ))
8018 ("?pragma% ignored, cannot pack atomic components");
8020 elsif not Rep_Item_Too_Late (Typ, N) then
8021 Set_Is_Packed (Base_Type (Typ));
8022 Set_Has_Pragma_Pack (Base_Type (Typ));
8023 Set_Has_Non_Standard_Rep (Base_Type (Typ));
8026 -- Record type. For record types, the pack is always effective
8028 else pragma Assert (Is_Record_Type (Typ));
8029 if not Rep_Item_Too_Late (Typ, N) then
8030 Set_Has_Pragma_Pack (Base_Type (Typ));
8031 Set_Is_Packed (Base_Type (Typ));
8032 Set_Has_Non_Standard_Rep (Base_Type (Typ));
8043 -- There is nothing to do here, since we did all the processing
8044 -- for this pragma in Par.Prag (so that it works properly even in
8045 -- syntax only mode)
8054 -- pragma Passive [(PASSIVE_FORM)];
8056 -- PASSIVE_FORM ::= Semaphore | No
8058 when Pragma_Passive =>
8061 if Nkind (Parent (N)) /= N_Task_Definition then
8062 Error_Pragma ("pragma% must be within task definition");
8065 if Arg_Count /= 0 then
8066 Check_Arg_Count (1);
8067 Check_Arg_Is_One_Of (Arg1, Name_Semaphore, Name_No);
8074 -- pragma Polling (ON | OFF);
8076 when Pragma_Polling =>
8078 Check_Arg_Count (1);
8079 Check_No_Identifiers;
8080 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
8081 Polling_Required := (Chars (Expression (Arg1)) = Name_On);
8083 ---------------------
8084 -- Persistent_Data --
8085 ---------------------
8087 when Pragma_Persistent_Data => declare
8091 -- Register the pragma as applying to the compilation unit.
8092 -- Individual Persistent_Object pragmas for relevant objects
8093 -- are generated the end of the compilation.
8096 Check_Valid_Configuration_Pragma;
8097 Check_Arg_Count (0);
8098 Ent := Find_Lib_Unit_Name;
8099 Set_Is_Preelaborated (Ent);
8102 -----------------------
8103 -- Persistent_Object --
8104 -----------------------
8106 when Pragma_Persistent_Object => declare
8114 Check_Arg_Count (1);
8115 Check_Arg_Is_Library_Level_Local_Name (Arg1);
8117 if not Is_Entity_Name (Expression (Arg1))
8119 (Ekind (Entity (Expression (Arg1))) /= E_Variable
8120 and then Ekind (Entity (Expression (Arg1))) /= E_Constant)
8122 Error_Pragma_Arg ("pragma only applies to objects", Arg1);
8125 Ent := Entity (Expression (Arg1));
8126 Decl := Parent (Ent);
8128 if Nkind (Decl) /= N_Object_Declaration then
8132 -- Placement of the object depends on whether there is
8133 -- an initial value or none. If the No_Initialization flag
8134 -- is set, the initialization has been transformed into
8135 -- assignments, which is disallowed elaboration code.
8137 if No_Initialization (Decl) then
8139 ("initialization for persistent object"
8140 & "must be static expression", Decl);
8144 if No (Expression (Decl)) then
8146 Store_String_Chars ("section ("".persistent.bss"")");
8150 if not Is_OK_Static_Expression (Expression (Decl)) then
8151 Flag_Non_Static_Expr
8152 ("initialization for persistent object"
8153 & "must be static expression!", Expression (Decl));
8158 Store_String_Chars ("section ("".persistent.data"")");
8165 Name_Machine_Attribute,
8167 (Make_Pragma_Argument_Association
8168 (Sloc => Sloc (Arg1),
8169 Expression => New_Occurrence_Of (Ent, Sloc (Ent))),
8170 Make_Pragma_Argument_Association
8171 (Sloc => Sloc (Arg1),
8174 (Sloc => Sloc (Arg1),
8177 Insert_After (N, MA);
8179 Set_Has_Gigi_Rep_Item (Ent);
8186 -- pragma Preelaborate [(library_unit_NAME)];
8188 -- Set the flag Is_Preelaborated of program unit name entity
8190 when Pragma_Preelaborate => Preelaborate : declare
8191 Pa : constant Node_Id := Parent (N);
8192 Pk : constant Node_Kind := Nkind (Pa);
8196 Check_Ada_83_Warning;
8197 Check_Valid_Library_Unit_Pragma;
8199 if Nkind (N) = N_Null_Statement then
8203 Ent := Find_Lib_Unit_Name;
8205 -- This filters out pragmas inside generic parent then
8206 -- show up inside instantiation
8209 and then not (Pk = N_Package_Specification
8210 and then Present (Generic_Parent (Pa)))
8212 if not Debug_Flag_U then
8213 Set_Is_Preelaborated (Ent);
8214 Set_Suppress_Elaboration_Warnings (Ent);
8223 -- pragma Priority (EXPRESSION);
8225 when Pragma_Priority => Priority : declare
8226 P : constant Node_Id := Parent (N);
8230 Check_No_Identifiers;
8231 Check_Arg_Count (1);
8235 if Nkind (P) = N_Subprogram_Body then
8236 Check_In_Main_Program;
8238 Arg := Expression (Arg1);
8239 Analyze_And_Resolve (Arg, Standard_Integer);
8243 if not Is_Static_Expression (Arg) then
8244 Flag_Non_Static_Expr
8245 ("main subprogram priority is not static!", Arg);
8248 -- If constraint error, then we already signalled an error
8250 elsif Raises_Constraint_Error (Arg) then
8253 -- Otherwise check in range
8257 Val : constant Uint := Expr_Value (Arg);
8261 or else Val > Expr_Value (Expression
8262 (Parent (RTE (RE_Max_Priority))))
8265 ("main subprogram priority is out of range", Arg1);
8271 (Current_Sem_Unit, UI_To_Int (Expr_Value (Arg)));
8273 -- Task or Protected, must be of type Integer
8275 elsif Nkind (P) = N_Protected_Definition
8277 Nkind (P) = N_Task_Definition
8279 Arg := Expression (Arg1);
8281 -- The expression must be analyzed in the special manner
8282 -- described in "Handling of Default and Per-Object
8283 -- Expressions" in sem.ads.
8285 Analyze_Per_Use_Expression (Arg, Standard_Integer);
8287 if not Is_Static_Expression (Arg) then
8288 Check_Restriction (Static_Priorities, Arg);
8291 -- Anything else is incorrect
8297 if Has_Priority_Pragma (P) then
8298 Error_Pragma ("duplicate pragma% not allowed");
8300 Set_Has_Priority_Pragma (P, True);
8302 if Nkind (P) = N_Protected_Definition
8304 Nkind (P) = N_Task_Definition
8306 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
8307 -- exp_ch9 should use this ???
8316 -- pragma Profile (profile_IDENTIFIER);
8318 -- profile_IDENTIFIER => Protected | Ravenscar
8320 when Pragma_Profile =>
8321 Check_Arg_Count (1);
8322 Check_Valid_Configuration_Pragma;
8323 Check_No_Identifiers;
8326 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
8328 if Chars (Argx) = Name_Ravenscar then
8329 Set_Ravenscar_Profile (N);
8331 elsif Chars (Argx) = Name_Restricted then
8332 Set_Profile_Restrictions (Restricted, N, Warn => False);
8334 Error_Pragma_Arg ("& is not a valid profile", Argx);
8338 ----------------------
8339 -- Profile_Warnings --
8340 ----------------------
8342 -- pragma Profile_Warnings (profile_IDENTIFIER);
8344 -- profile_IDENTIFIER => Protected | Ravenscar
8346 when Pragma_Profile_Warnings =>
8348 Check_Arg_Count (1);
8349 Check_Valid_Configuration_Pragma;
8350 Check_No_Identifiers;
8353 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
8355 if Chars (Argx) = Name_Ravenscar then
8356 Set_Profile_Restrictions (Ravenscar, N, Warn => True);
8358 elsif Chars (Argx) = Name_Restricted then
8359 Set_Profile_Restrictions (Restricted, N, Warn => True);
8361 Error_Pragma_Arg ("& is not a valid profile", Argx);
8365 --------------------------
8366 -- Propagate_Exceptions --
8367 --------------------------
8369 -- pragma Propagate_Exceptions;
8371 when Pragma_Propagate_Exceptions =>
8373 Check_Arg_Count (0);
8375 if In_Extended_Main_Source_Unit (N) then
8376 Propagate_Exceptions := True;
8383 -- pragma Psect_Object (
8384 -- [Internal =>] LOCAL_NAME,
8385 -- [, [External =>] EXTERNAL_SYMBOL]
8386 -- [, [Size =>] EXTERNAL_SYMBOL]);
8388 when Pragma_Psect_Object | Pragma_Common_Object =>
8389 Psect_Object : declare
8390 Args : Args_List (1 .. 3);
8391 Names : constant Name_List (1 .. 3) := (
8396 Internal : Node_Id renames Args (1);
8397 External : Node_Id renames Args (2);
8398 Size : Node_Id renames Args (3);
8400 R_Internal : Node_Id;
8401 R_External : Node_Id;
8408 procedure Check_Too_Long (Arg : Node_Id);
8409 -- Posts message if the argument is an identifier with more
8410 -- than 31 characters, or a string literal with more than
8411 -- 31 characters, and we are operating under VMS
8413 --------------------
8414 -- Check_Too_Long --
8415 --------------------
8417 procedure Check_Too_Long (Arg : Node_Id) is
8418 X : constant Node_Id := Original_Node (Arg);
8421 if Nkind (X) /= N_String_Literal
8423 Nkind (X) /= N_Identifier
8426 ("inappropriate argument for pragma %", Arg);
8429 if OpenVMS_On_Target then
8430 if (Nkind (X) = N_String_Literal
8431 and then String_Length (Strval (X)) > 31)
8433 (Nkind (X) = N_Identifier
8434 and then Length_Of_Name (Chars (X)) > 31)
8437 ("argument for pragma % is longer than 31 characters",
8443 -- Start of processing for Common_Object/Psect_Object
8447 Gather_Associations (Names, Args);
8448 Process_Extended_Import_Export_Internal_Arg (Internal);
8450 R_Internal := Relocate_Node (Internal);
8452 Def_Id := Entity (R_Internal);
8454 if Ekind (Def_Id) /= E_Constant
8455 and then Ekind (Def_Id) /= E_Variable
8458 ("pragma% must designate an object", Internal);
8461 Check_Too_Long (R_Internal);
8463 if Is_Imported (Def_Id) or else Is_Exported (Def_Id) then
8465 ("cannot use pragma% for imported/exported object",
8469 if Is_Concurrent_Type (Etype (R_Internal)) then
8471 ("cannot specify pragma % for task/protected object",
8475 if Is_Psected (Def_Id) then
8476 Error_Msg_N ("?duplicate Psect_Object pragma", N);
8478 Set_Is_Psected (Def_Id);
8481 if Ekind (Def_Id) = E_Constant then
8483 ("cannot specify pragma % for a constant", R_Internal);
8486 if Is_Record_Type (Etype (R_Internal)) then
8492 Ent := First_Entity (Etype (R_Internal));
8493 while Present (Ent) loop
8494 Decl := Declaration_Node (Ent);
8496 if Ekind (Ent) = E_Component
8497 and then Nkind (Decl) = N_Component_Declaration
8498 and then Present (Expression (Decl))
8499 and then Warn_On_Export_Import
8502 ("?object for pragma % has defaults", R_Internal);
8512 if Present (Size) then
8513 Check_Too_Long (Size);
8516 -- Make Psect case-insensitive.
8518 if Present (External) then
8519 Check_Too_Long (External);
8521 if Nkind (External) = N_String_Literal then
8522 String_To_Name_Buffer (Strval (External));
8524 Get_Name_String (Chars (External));
8529 Store_String_Chars (Name_Buffer (1 .. Name_Len));
8531 R_External := Make_String_Literal
8532 (Sloc => Sloc (External), Strval => Str);
8534 Get_Name_String (Chars (Internal));
8537 Store_String_Chars (Name_Buffer (1 .. Name_Len));
8539 R_External := Make_String_Literal
8540 (Sloc => Sloc (Internal), Strval => Str);
8543 -- Transform into pragma Linker_Section, add attributes to
8544 -- match what DEC Ada does. Ignore size for now?
8549 Name_Linker_Section,
8551 (Make_Pragma_Argument_Association
8552 (Sloc => Sloc (R_Internal),
8553 Expression => R_Internal),
8554 Make_Pragma_Argument_Association
8555 (Sloc => Sloc (R_External),
8556 Expression => R_External))));
8560 -- Add Machine_Attribute of "overlaid", so the section overlays
8561 -- other sections of the same name.
8564 Store_String_Chars ("overlaid");
8570 Name_Machine_Attribute,
8572 (Make_Pragma_Argument_Association
8573 (Sloc => Sloc (R_Internal),
8574 Expression => R_Internal),
8575 Make_Pragma_Argument_Association
8576 (Sloc => Sloc (R_External),
8579 (Sloc => Sloc (R_External),
8583 -- Add Machine_Attribute of "global", so the section is visible
8587 Store_String_Chars ("global");
8593 Name_Machine_Attribute,
8595 (Make_Pragma_Argument_Association
8596 (Sloc => Sloc (R_Internal),
8597 Expression => R_Internal),
8599 Make_Pragma_Argument_Association
8600 (Sloc => Sloc (R_External),
8603 (Sloc => Sloc (R_External),
8607 -- Add Machine_Attribute of "initialize", so the section is
8611 Store_String_Chars ("initialize");
8617 Name_Machine_Attribute,
8619 (Make_Pragma_Argument_Association
8620 (Sloc => Sloc (R_Internal),
8621 Expression => R_Internal),
8623 Make_Pragma_Argument_Association
8624 (Sloc => Sloc (R_External),
8627 (Sloc => Sloc (R_External),
8636 -- pragma Pure [(library_unit_NAME)];
8638 when Pragma_Pure => Pure : declare
8641 Check_Ada_83_Warning;
8642 Check_Valid_Library_Unit_Pragma;
8644 if Nkind (N) = N_Null_Statement then
8648 Ent := Find_Lib_Unit_Name;
8650 Set_Suppress_Elaboration_Warnings (Ent);
8657 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
8659 when Pragma_Pure_Function => Pure_Function : declare
8663 Effective : Boolean := False;
8667 Check_Arg_Count (1);
8668 Check_Optional_Identifier (Arg1, Name_Entity);
8669 Check_Arg_Is_Local_Name (Arg1);
8670 E_Id := Expression (Arg1);
8672 if Error_Posted (E_Id) then
8676 -- Loop through homonyms (overloadings) of referenced entity
8682 Def_Id := Get_Base_Subprogram (E);
8684 if Ekind (Def_Id) /= E_Function
8685 and then Ekind (Def_Id) /= E_Generic_Function
8686 and then Ekind (Def_Id) /= E_Operator
8689 ("pragma% requires a function name", Arg1);
8692 Set_Is_Pure (Def_Id);
8694 if not Has_Pragma_Pure_Function (Def_Id) then
8695 Set_Has_Pragma_Pure_Function (Def_Id);
8700 exit when No (E) or else Scope (E) /= Current_Scope;
8704 and then Warn_On_Redundant_Constructs
8706 Error_Msg_NE ("pragma Pure_Function on& is redundant?",
8712 --------------------
8713 -- Queuing_Policy --
8714 --------------------
8716 -- pragma Queuing_Policy (policy_IDENTIFIER);
8718 when Pragma_Queuing_Policy => declare
8722 Check_Ada_83_Warning;
8723 Check_Arg_Count (1);
8724 Check_No_Identifiers;
8725 Check_Arg_Is_Queuing_Policy (Arg1);
8726 Check_Valid_Configuration_Pragma;
8727 Get_Name_String (Chars (Expression (Arg1)));
8728 QP := Fold_Upper (Name_Buffer (1));
8730 if Queuing_Policy /= ' '
8731 and then Queuing_Policy /= QP
8733 Error_Msg_Sloc := Queuing_Policy_Sloc;
8734 Error_Pragma ("queuing policy incompatible with policy#");
8736 -- Set new policy, but always preserve System_Location since
8737 -- we like the error message with the run time name.
8740 Queuing_Policy := QP;
8742 if Queuing_Policy_Sloc /= System_Location then
8743 Queuing_Policy_Sloc := Loc;
8748 ---------------------------
8749 -- Remote_Call_Interface --
8750 ---------------------------
8752 -- pragma Remote_Call_Interface [(library_unit_NAME)];
8754 when Pragma_Remote_Call_Interface => Remote_Call_Interface : declare
8755 Cunit_Node : Node_Id;
8756 Cunit_Ent : Entity_Id;
8760 Check_Ada_83_Warning;
8761 Check_Valid_Library_Unit_Pragma;
8763 if Nkind (N) = N_Null_Statement then
8767 Cunit_Node := Cunit (Current_Sem_Unit);
8768 K := Nkind (Unit (Cunit_Node));
8769 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
8771 if K = N_Package_Declaration
8772 or else K = N_Generic_Package_Declaration
8773 or else K = N_Subprogram_Declaration
8774 or else K = N_Generic_Subprogram_Declaration
8775 or else (K = N_Subprogram_Body
8776 and then Acts_As_Spec (Unit (Cunit_Node)))
8781 "pragma% must apply to package or subprogram declaration");
8784 Set_Is_Remote_Call_Interface (Cunit_Ent);
8785 end Remote_Call_Interface;
8791 -- pragma Remote_Types [(library_unit_NAME)];
8793 when Pragma_Remote_Types => Remote_Types : declare
8794 Cunit_Node : Node_Id;
8795 Cunit_Ent : Entity_Id;
8798 Check_Ada_83_Warning;
8799 Check_Valid_Library_Unit_Pragma;
8801 if Nkind (N) = N_Null_Statement then
8805 Cunit_Node := Cunit (Current_Sem_Unit);
8806 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
8808 if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration
8810 Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration
8813 "pragma% can only apply to a package declaration");
8816 Set_Is_Remote_Types (Cunit_Ent);
8823 -- pragma Ravenscar;
8825 when Pragma_Ravenscar =>
8827 Check_Arg_Count (0);
8828 Check_Valid_Configuration_Pragma;
8829 Set_Ravenscar_Profile (N);
8831 if Warn_On_Obsolescent_Feature then
8833 ("pragma Ravenscar is an obsolescent feature?", N);
8835 ("|use pragma Profile (Ravenscar) instead", N);
8838 -------------------------
8839 -- Restricted_Run_Time --
8840 -------------------------
8842 -- pragma Restricted_Run_Time;
8844 when Pragma_Restricted_Run_Time =>
8846 Check_Arg_Count (0);
8847 Check_Valid_Configuration_Pragma;
8848 Set_Profile_Restrictions (Restricted, N, Warn => False);
8850 if Warn_On_Obsolescent_Feature then
8852 ("pragma Restricted_Run_Time is an obsolescent feature?", N);
8854 ("|use pragma Profile (Restricted) instead", N);
8861 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
8864 -- restriction_IDENTIFIER
8865 -- | restriction_parameter_IDENTIFIER => EXPRESSION
8867 when Pragma_Restrictions =>
8868 Process_Restrictions_Or_Restriction_Warnings;
8870 --------------------------
8871 -- Restriction_Warnings --
8872 --------------------------
8874 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
8877 -- restriction_IDENTIFIER
8878 -- | restriction_parameter_IDENTIFIER => EXPRESSION
8880 when Pragma_Restriction_Warnings =>
8881 Process_Restrictions_Or_Restriction_Warnings;
8887 -- pragma Reviewable;
8889 when Pragma_Reviewable =>
8890 Check_Ada_83_Warning;
8891 Check_Arg_Count (0);
8897 -- pragma Share_Generic (NAME {, NAME});
8899 when Pragma_Share_Generic =>
8901 Process_Generic_List;
8907 -- pragma Shared (LOCAL_NAME);
8909 when Pragma_Shared =>
8911 Process_Atomic_Shared_Volatile;
8913 --------------------
8914 -- Shared_Passive --
8915 --------------------
8917 -- pragma Shared_Passive [(library_unit_NAME)];
8919 -- Set the flag Is_Shared_Passive of program unit name entity
8921 when Pragma_Shared_Passive => Shared_Passive : declare
8922 Cunit_Node : Node_Id;
8923 Cunit_Ent : Entity_Id;
8926 Check_Ada_83_Warning;
8927 Check_Valid_Library_Unit_Pragma;
8929 if Nkind (N) = N_Null_Statement then
8933 Cunit_Node := Cunit (Current_Sem_Unit);
8934 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
8936 if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration
8938 Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration
8941 "pragma% can only apply to a package declaration");
8944 Set_Is_Shared_Passive (Cunit_Ent);
8947 ----------------------
8948 -- Source_File_Name --
8949 ----------------------
8951 -- There are five forms for this pragma:
8953 -- pragma Source_File_Name (
8954 -- [UNIT_NAME =>] unit_NAME,
8955 -- BODY_FILE_NAME => STRING_LITERAL
8956 -- [, [INDEX =>] INTEGER_LITERAL]);
8958 -- pragma Source_File_Name (
8959 -- [UNIT_NAME =>] unit_NAME,
8960 -- SPEC_FILE_NAME => STRING_LITERAL
8961 -- [, [INDEX =>] INTEGER_LITERAL]);
8963 -- pragma Source_File_Name (
8964 -- BODY_FILE_NAME => STRING_LITERAL
8965 -- [, DOT_REPLACEMENT => STRING_LITERAL]
8966 -- [, CASING => CASING_SPEC]);
8968 -- pragma Source_File_Name (
8969 -- SPEC_FILE_NAME => STRING_LITERAL
8970 -- [, DOT_REPLACEMENT => STRING_LITERAL]
8971 -- [, CASING => CASING_SPEC]);
8973 -- pragma Source_File_Name (
8974 -- SUBUNIT_FILE_NAME => STRING_LITERAL
8975 -- [, DOT_REPLACEMENT => STRING_LITERAL]
8976 -- [, CASING => CASING_SPEC]);
8978 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
8980 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
8981 -- Source_File_Name (SFN), however their usage is exclusive:
8982 -- SFN can only be used when no project file is used, while
8983 -- SFNP can only be used when a project file is used.
8985 -- No processing here. Processing was completed during parsing,
8986 -- since we need to have file names set as early as possible.
8987 -- Units are loaded well before semantic processing starts.
8989 -- The only processing we defer to this point is the check
8990 -- for correct placement.
8992 when Pragma_Source_File_Name =>
8994 Check_Valid_Configuration_Pragma;
8996 ------------------------------
8997 -- Source_File_Name_Project --
8998 ------------------------------
9000 -- See Source_File_Name for syntax
9002 -- No processing here. Processing was completed during parsing,
9003 -- since we need to have file names set as early as possible.
9004 -- Units are loaded well before semantic processing starts.
9006 -- The only processing we defer to this point is the check
9007 -- for correct placement.
9009 when Pragma_Source_File_Name_Project =>
9011 Check_Valid_Configuration_Pragma;
9013 -- Check that a pragma Source_File_Name_Project is used only
9014 -- in a configuration pragmas file.
9016 -- Pragmas Source_File_Name_Project should only be generated
9017 -- by the Project Manager in configuration pragmas files.
9019 -- This is really an ugly test. It seems to depend on some
9020 -- accidental and undocumented property. At the very least
9021 -- it needs to be documented, but it would be better to have
9022 -- a clean way of testing if we are in a configuration file???
9024 if Present (Parent (N)) then
9026 ("pragma% can only appear in a configuration pragmas file");
9029 ----------------------
9030 -- Source_Reference --
9031 ----------------------
9033 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
9035 -- Nothing to do, all processing completed in Par.Prag, since we
9036 -- need the information for possible parser messages that are output
9038 when Pragma_Source_Reference =>
9045 -- pragma Storage_Size (EXPRESSION);
9047 when Pragma_Storage_Size => Storage_Size : declare
9048 P : constant Node_Id := Parent (N);
9052 Check_No_Identifiers;
9053 Check_Arg_Count (1);
9055 -- The expression must be analyzed in the special manner
9056 -- described in "Handling of Default Expressions" in sem.ads.
9058 -- Set In_Default_Expression for per-object case ???
9060 Arg := Expression (Arg1);
9061 Analyze_Per_Use_Expression (Arg, Any_Integer);
9063 if not Is_Static_Expression (Arg) then
9064 Check_Restriction (Static_Storage_Size, Arg);
9067 if Nkind (P) /= N_Task_Definition then
9072 if Has_Storage_Size_Pragma (P) then
9073 Error_Pragma ("duplicate pragma% not allowed");
9075 Set_Has_Storage_Size_Pragma (P, True);
9078 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
9079 -- ??? exp_ch9 should use this!
9087 -- pragma Storage_Unit (NUMERIC_LITERAL);
9089 -- Only permitted argument is System'Storage_Unit value
9091 when Pragma_Storage_Unit =>
9092 Check_No_Identifiers;
9093 Check_Arg_Count (1);
9094 Check_Arg_Is_Integer_Literal (Arg1);
9096 if Intval (Expression (Arg1)) /=
9097 UI_From_Int (Ttypes.System_Storage_Unit)
9099 Error_Msg_Uint_1 := UI_From_Int (Ttypes.System_Storage_Unit);
9101 ("the only allowed argument for pragma% is ^", Arg1);
9104 --------------------
9105 -- Stream_Convert --
9106 --------------------
9108 -- pragma Stream_Convert (
9109 -- [Entity =>] type_LOCAL_NAME,
9110 -- [Read =>] function_NAME,
9111 -- [Write =>] function NAME);
9113 when Pragma_Stream_Convert => Stream_Convert : declare
9115 procedure Check_OK_Stream_Convert_Function (Arg : Node_Id);
9116 -- Check that the given argument is the name of a local
9117 -- function of one argument that is not overloaded earlier
9118 -- in the current local scope. A check is also made that the
9119 -- argument is a function with one parameter.
9121 --------------------------------------
9122 -- Check_OK_Stream_Convert_Function --
9123 --------------------------------------
9125 procedure Check_OK_Stream_Convert_Function (Arg : Node_Id) is
9129 Check_Arg_Is_Local_Name (Arg);
9130 Ent := Entity (Expression (Arg));
9132 if Has_Homonym (Ent) then
9134 ("argument for pragma% may not be overloaded", Arg);
9137 if Ekind (Ent) /= E_Function
9138 or else No (First_Formal (Ent))
9139 or else Present (Next_Formal (First_Formal (Ent)))
9142 ("argument for pragma% must be" &
9143 " function of one argument", Arg);
9145 end Check_OK_Stream_Convert_Function;
9147 -- Start of procecessing for Stream_Convert
9151 Check_Arg_Count (3);
9152 Check_Optional_Identifier (Arg1, Name_Entity);
9153 Check_Optional_Identifier (Arg2, Name_Read);
9154 Check_Optional_Identifier (Arg3, Name_Write);
9155 Check_Arg_Is_Local_Name (Arg1);
9156 Check_OK_Stream_Convert_Function (Arg2);
9157 Check_OK_Stream_Convert_Function (Arg3);
9160 Typ : constant Entity_Id :=
9161 Underlying_Type (Entity (Expression (Arg1)));
9162 Read : constant Entity_Id := Entity (Expression (Arg2));
9163 Write : constant Entity_Id := Entity (Expression (Arg3));
9166 if Etype (Typ) = Any_Type
9168 Etype (Read) = Any_Type
9170 Etype (Write) = Any_Type
9175 Check_First_Subtype (Arg1);
9177 if Rep_Item_Too_Early (Typ, N)
9179 Rep_Item_Too_Late (Typ, N)
9184 if Underlying_Type (Etype (Read)) /= Typ then
9186 ("incorrect return type for function&", Arg2);
9189 if Underlying_Type (Etype (First_Formal (Write))) /= Typ then
9191 ("incorrect parameter type for function&", Arg3);
9194 if Underlying_Type (Etype (First_Formal (Read))) /=
9195 Underlying_Type (Etype (Write))
9198 ("result type of & does not match Read parameter type",
9204 -------------------------
9205 -- Style_Checks (GNAT) --
9206 -------------------------
9208 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
9210 -- This is processed by the parser since some of the style
9211 -- checks take place during source scanning and parsing. This
9212 -- means that we don't need to issue error messages here.
9214 when Pragma_Style_Checks => Style_Checks : declare
9215 A : constant Node_Id := Expression (Arg1);
9221 Check_No_Identifiers;
9223 -- Two argument form
9225 if Arg_Count = 2 then
9226 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
9233 E_Id := Expression (Arg2);
9236 if not Is_Entity_Name (E_Id) then
9238 ("second argument of pragma% must be entity name",
9248 Set_Suppress_Style_Checks (E,
9249 (Chars (Expression (Arg1)) = Name_Off));
9250 exit when No (Homonym (E));
9256 -- One argument form
9259 Check_Arg_Count (1);
9261 if Nkind (A) = N_String_Literal then
9265 Slen : constant Natural := Natural (String_Length (S));
9266 Options : String (1 .. Slen);
9272 C := Get_String_Char (S, Int (J));
9273 exit when not In_Character_Range (C);
9274 Options (J) := Get_Character (C);
9277 Set_Style_Check_Options (Options);
9285 elsif Nkind (A) = N_Identifier then
9287 if Chars (A) = Name_All_Checks then
9288 Set_Default_Style_Check_Options;
9290 elsif Chars (A) = Name_On then
9291 Style_Check := True;
9293 elsif Chars (A) = Name_Off then
9294 Style_Check := False;
9305 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
9307 when Pragma_Subtitle =>
9309 Check_Arg_Count (1);
9310 Check_Optional_Identifier (Arg1, Name_Subtitle);
9311 Check_Arg_Is_String_Literal (Arg1);
9317 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
9319 when Pragma_Suppress =>
9320 Process_Suppress_Unsuppress (True);
9326 -- pragma Suppress_All;
9328 -- The only check made here is that the pragma appears in the
9329 -- proper place, i.e. following a compilation unit. If indeed
9330 -- it appears in this context, then the parser has already
9331 -- inserted an equivalent pragma Suppress (All_Checks) to get
9332 -- the required effect.
9334 when Pragma_Suppress_All =>
9336 Check_Arg_Count (0);
9338 if Nkind (Parent (N)) /= N_Compilation_Unit_Aux
9339 or else not Is_List_Member (N)
9340 or else List_Containing (N) /= Pragmas_After (Parent (N))
9343 ("misplaced pragma%, must follow compilation unit");
9346 -------------------------
9347 -- Suppress_Debug_Info --
9348 -------------------------
9350 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
9352 when Pragma_Suppress_Debug_Info =>
9354 Check_Arg_Count (1);
9355 Check_Arg_Is_Local_Name (Arg1);
9356 Check_Optional_Identifier (Arg1, Name_Entity);
9357 Set_Debug_Info_Off (Entity (Get_Pragma_Arg (Arg1)));
9359 ----------------------------------
9360 -- Suppress_Exception_Locations --
9361 ----------------------------------
9363 -- pragma Suppress_Exception_Locations;
9365 when Pragma_Suppress_Exception_Locations =>
9367 Check_Arg_Count (0);
9368 Check_Valid_Configuration_Pragma;
9369 Exception_Locations_Suppressed := True;
9371 -----------------------------
9372 -- Suppress_Initialization --
9373 -----------------------------
9375 -- pragma Suppress_Initialization ([Entity =>] type_Name);
9377 when Pragma_Suppress_Initialization => Suppress_Init : declare
9383 Check_Arg_Count (1);
9384 Check_Optional_Identifier (Arg1, Name_Entity);
9385 Check_Arg_Is_Local_Name (Arg1);
9387 E_Id := Expression (Arg1);
9389 if Etype (E_Id) = Any_Type then
9396 if Is_Incomplete_Or_Private_Type (E) then
9397 if No (Full_View (Base_Type (E))) then
9399 ("argument of pragma% cannot be an incomplete type",
9402 Set_Suppress_Init_Proc (Full_View (Base_Type (E)));
9405 Set_Suppress_Init_Proc (Base_Type (E));
9410 ("pragma% requires argument that is a type name", Arg1);
9418 -- pragma System_Name (DIRECT_NAME);
9420 -- Syntax check: one argument, which must be the identifier GNAT
9421 -- or the identifier GCC, no other identifiers are acceptable.
9423 when Pragma_System_Name =>
9424 Check_No_Identifiers;
9425 Check_Arg_Count (1);
9426 Check_Arg_Is_One_Of (Arg1, Name_Gcc, Name_Gnat);
9428 -----------------------------
9429 -- Task_Dispatching_Policy --
9430 -----------------------------
9432 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
9434 when Pragma_Task_Dispatching_Policy => declare
9438 Check_Ada_83_Warning;
9439 Check_Arg_Count (1);
9440 Check_No_Identifiers;
9441 Check_Arg_Is_Task_Dispatching_Policy (Arg1);
9442 Check_Valid_Configuration_Pragma;
9443 Get_Name_String (Chars (Expression (Arg1)));
9444 DP := Fold_Upper (Name_Buffer (1));
9446 if Task_Dispatching_Policy /= ' '
9447 and then Task_Dispatching_Policy /= DP
9449 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
9451 ("task dispatching policy incompatible with policy#");
9453 -- Set new policy, but always preserve System_Location since
9454 -- we like the error message with the run time name.
9457 Task_Dispatching_Policy := DP;
9459 if Task_Dispatching_Policy_Sloc /= System_Location then
9460 Task_Dispatching_Policy_Sloc := Loc;
9469 -- pragma Task_Info (EXPRESSION);
9471 when Pragma_Task_Info => Task_Info : declare
9472 P : constant Node_Id := Parent (N);
9477 if Nkind (P) /= N_Task_Definition then
9478 Error_Pragma ("pragma% must appear in task definition");
9481 Check_No_Identifiers;
9482 Check_Arg_Count (1);
9484 Analyze_And_Resolve (Expression (Arg1), RTE (RE_Task_Info_Type));
9486 if Etype (Expression (Arg1)) = Any_Type then
9490 if Has_Task_Info_Pragma (P) then
9491 Error_Pragma ("duplicate pragma% not allowed");
9493 Set_Has_Task_Info_Pragma (P, True);
9501 -- pragma Task_Name (string_EXPRESSION);
9503 when Pragma_Task_Name => Task_Name : declare
9504 -- pragma Priority (EXPRESSION);
9506 P : constant Node_Id := Parent (N);
9510 Check_No_Identifiers;
9511 Check_Arg_Count (1);
9513 Arg := Expression (Arg1);
9514 Analyze_And_Resolve (Arg, Standard_String);
9516 if Nkind (P) /= N_Task_Definition then
9520 if Has_Task_Name_Pragma (P) then
9521 Error_Pragma ("duplicate pragma% not allowed");
9523 Set_Has_Task_Name_Pragma (P, True);
9524 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
9532 -- pragma Task_Storage (
9533 -- [Task_Type =>] LOCAL_NAME,
9534 -- [Top_Guard =>] static_integer_EXPRESSION);
9536 when Pragma_Task_Storage => Task_Storage : declare
9537 Args : Args_List (1 .. 2);
9538 Names : constant Name_List (1 .. 2) := (
9542 Task_Type : Node_Id renames Args (1);
9543 Top_Guard : Node_Id renames Args (2);
9549 Gather_Associations (Names, Args);
9551 if No (Task_Type) then
9553 ("missing task_type argument for pragma%");
9556 Check_Arg_Is_Local_Name (Task_Type);
9558 Ent := Entity (Task_Type);
9560 if not Is_Task_Type (Ent) then
9562 ("argument for pragma% must be task type", Task_Type);
9565 if No (Top_Guard) then
9567 ("pragma% takes two arguments", Task_Type);
9569 Check_Arg_Is_Static_Expression (Top_Guard, Any_Integer);
9572 Check_First_Subtype (Task_Type);
9574 if Rep_Item_Too_Late (Ent, N) then
9583 -- pragma Thread_Body
9584 -- ( [Entity =>] LOCAL_NAME
9585 -- [,[Secondary_Stack_Size =>] static_integer_EXPRESSION]);
9587 when Pragma_Thread_Body => Thread_Body : declare
9594 Check_At_Least_N_Arguments (1);
9595 Check_At_Most_N_Arguments (2);
9596 Check_Optional_Identifier (Arg1, Name_Entity);
9597 Check_Arg_Is_Local_Name (Arg1);
9599 Id := Expression (Arg1);
9601 if not Is_Entity_Name (Id)
9602 or else not Is_Subprogram (Entity (Id))
9604 Error_Pragma_Arg ("subprogram name required", Arg1);
9609 -- Go to renamed subprogram if present, since Thread_Body applies
9610 -- to the actual renamed entity, not to the renaming entity.
9612 if Present (Alias (E))
9613 and then Nkind (Parent (Declaration_Node (E))) =
9614 N_Subprogram_Renaming_Declaration
9619 -- Various error checks
9621 if Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Body then
9623 ("pragma% requires separate spec and must come before body");
9625 elsif Rep_Item_Too_Early (E, N)
9627 Rep_Item_Too_Late (E, N)
9631 elsif Is_Thread_Body (E) then
9633 ("only one thread body pragma allowed", Arg1);
9635 elsif Present (Homonym (E))
9636 and then Scope (Homonym (E)) = Current_Scope
9639 ("thread body subprogram must not be overloaded", Arg1);
9642 Set_Is_Thread_Body (E);
9644 -- Deal with secondary stack argument
9646 if Arg_Count = 2 then
9647 Check_Optional_Identifier (Arg2, Name_Secondary_Stack_Size);
9648 SS := Expression (Arg2);
9649 Analyze_And_Resolve (SS, Any_Integer);
9657 -- pragma Time_Slice (static_duration_EXPRESSION);
9659 when Pragma_Time_Slice => Time_Slice : declare
9665 Check_Arg_Count (1);
9666 Check_No_Identifiers;
9667 Check_In_Main_Program;
9668 Check_Arg_Is_Static_Expression (Arg1, Standard_Duration);
9670 if not Error_Posted (Arg1) then
9672 while Present (Nod) loop
9673 if Nkind (Nod) = N_Pragma
9674 and then Chars (Nod) = Name_Time_Slice
9676 Error_Msg_Name_1 := Chars (N);
9677 Error_Msg_N ("duplicate pragma% not permitted", Nod);
9684 -- Process only if in main unit
9686 if Get_Source_Unit (Loc) = Main_Unit then
9687 Opt.Time_Slice_Set := True;
9688 Val := Expr_Value_R (Expression (Arg1));
9690 if Val <= Ureal_0 then
9691 Opt.Time_Slice_Value := 0;
9693 elsif Val > UR_From_Uint (UI_From_Int (1000)) then
9694 Opt.Time_Slice_Value := 1_000_000_000;
9697 Opt.Time_Slice_Value :=
9698 UI_To_Int (UR_To_Uint (Val * UI_From_Int (1_000_000)));
9707 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
9709 -- TITLING_OPTION ::=
9710 -- [Title =>] STRING_LITERAL
9711 -- | [Subtitle =>] STRING_LITERAL
9713 when Pragma_Title => Title : declare
9714 Args : Args_List (1 .. 2);
9715 Names : constant Name_List (1 .. 2) := (
9721 Gather_Associations (Names, Args);
9723 for J in 1 .. 2 loop
9724 if Present (Args (J)) then
9725 Check_Arg_Is_String_Literal (Args (J));
9730 ---------------------
9731 -- Unchecked_Union --
9732 ---------------------
9734 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
9736 when Pragma_Unchecked_Union => Unchecked_Union : declare
9737 Assoc : constant Node_Id := Arg1;
9738 Type_Id : constant Node_Id := Expression (Assoc);
9749 Check_No_Identifiers;
9750 Check_Arg_Count (1);
9751 Check_Arg_Is_Local_Name (Arg1);
9753 Find_Type (Type_Id);
9754 Typ := Entity (Type_Id);
9757 or else Rep_Item_Too_Early (Typ, N)
9761 Typ := Underlying_Type (Typ);
9764 if Rep_Item_Too_Late (Typ, N) then
9768 Check_First_Subtype (Arg1);
9770 -- Note remaining cases are references to a type in the current
9771 -- declarative part. If we find an error, we post the error on
9772 -- the relevant type declaration at an appropriate point.
9774 if not Is_Record_Type (Typ) then
9775 Error_Msg_N ("Unchecked_Union must be record type", Typ);
9778 elsif Is_Tagged_Type (Typ) then
9779 Error_Msg_N ("Unchecked_Union must not be tagged", Typ);
9782 elsif Is_Limited_Type (Typ) then
9784 ("Unchecked_Union must not be limited record type", Typ);
9785 Explain_Limited_Type (Typ, Typ);
9789 if not Has_Discriminants (Typ) then
9791 ("Unchecked_Union must have one discriminant", Typ);
9795 Discr := First_Discriminant (Typ);
9797 if Present (Next_Discriminant (Discr)) then
9799 ("Unchecked_Union must have exactly one discriminant",
9800 Next_Discriminant (Discr));
9804 if No (Discriminant_Default_Value (Discr)) then
9806 ("Unchecked_Union discriminant must have default value",
9810 Tdef := Type_Definition (Declaration_Node (Typ));
9811 Clist := Component_List (Tdef);
9813 Comp := First (Component_Items (Clist));
9814 while Present (Comp) loop
9816 Check_Component (Comp);
9821 if No (Clist) or else No (Variant_Part (Clist)) then
9823 ("Unchecked_Union must have variant part",
9828 Vpart := Variant_Part (Clist);
9829 Variant := First (Variants (Vpart));
9830 while Present (Variant) loop
9832 Check_Variant (Variant);
9838 Set_Is_Unchecked_Union (Typ, True);
9839 Set_Convention (Typ, Convention_C);
9841 Set_Has_Unchecked_Union (Base_Type (Typ), True);
9842 Set_Is_Unchecked_Union (Base_Type (Typ), True);
9843 end Unchecked_Union;
9845 ------------------------
9846 -- Unimplemented_Unit --
9847 ------------------------
9849 -- pragma Unimplemented_Unit;
9851 -- Note: this only gives an error if we are generating code,
9852 -- or if we are in a generic library unit (where the pragma
9853 -- appears in the body, not in the spec).
9855 when Pragma_Unimplemented_Unit => Unimplemented_Unit : declare
9856 Cunitent : constant Entity_Id :=
9857 Cunit_Entity (Get_Source_Unit (Loc));
9858 Ent_Kind : constant Entity_Kind :=
9863 Check_Arg_Count (0);
9865 if Operating_Mode = Generate_Code
9866 or else Ent_Kind = E_Generic_Function
9867 or else Ent_Kind = E_Generic_Procedure
9868 or else Ent_Kind = E_Generic_Package
9870 Get_Name_String (Chars (Cunitent));
9871 Set_Casing (Mixed_Case);
9872 Write_Str (Name_Buffer (1 .. Name_Len));
9873 Write_Str (" is not implemented");
9875 raise Unrecoverable_Error;
9877 end Unimplemented_Unit;
9879 --------------------
9880 -- Universal_Data --
9881 --------------------
9883 -- pragma Universal_Data [(library_unit_NAME)];
9885 when Pragma_Universal_Data =>
9888 -- If this is a configuration pragma, then set the universal
9889 -- addressing option, otherwise confirm that the pragma
9890 -- satisfies the requirements of library unit pragma placement
9891 -- and leave it to the GNAAMP back end to detect the pragma
9892 -- (avoids transitive setting of the option due to withed units).
9894 if Is_Configuration_Pragma then
9895 Universal_Addressing_On_AAMP := True;
9897 Check_Valid_Library_Unit_Pragma;
9900 if not AAMP_On_Target then
9901 Error_Pragma ("?pragma% ignored (applies only to AAMP)");
9908 -- pragma Unreferenced (local_Name {, local_Name});
9910 when Pragma_Unreferenced => Unreferenced : declare
9913 Arg_Ent : Entity_Id;
9917 Check_At_Least_N_Arguments (1);
9921 while Present (Arg_Node) loop
9922 Check_No_Identifier (Arg_Node);
9924 -- Note that the analyze call done by Check_Arg_Is_Local_Name
9925 -- will in fact generate a reference, so that the entity will
9926 -- have a reference, which will inhibit any warnings about it
9927 -- not being referenced, and also properly show up in the ali
9928 -- file as a reference. But this reference is recorded before
9929 -- the Has_Pragma_Unreferenced flag is set, so that no warning
9930 -- is generated for this reference.
9932 Check_Arg_Is_Local_Name (Arg_Node);
9933 Arg_Expr := Get_Pragma_Arg (Arg_Node);
9935 if Is_Entity_Name (Arg_Expr) then
9936 Arg_Ent := Entity (Arg_Expr);
9938 -- If the entity is overloaded, the pragma applies to the
9939 -- most recent overloading, as documented. In this case,
9940 -- name resolution does not generate a reference, so it
9941 -- must be done here explicitly.
9943 if Is_Overloaded (Arg_Expr) then
9944 Generate_Reference (Arg_Ent, N);
9947 Set_Has_Pragma_Unreferenced (Arg_Ent);
9954 ------------------------------
9955 -- Unreserve_All_Interrupts --
9956 ------------------------------
9958 -- pragma Unreserve_All_Interrupts;
9960 when Pragma_Unreserve_All_Interrupts =>
9962 Check_Arg_Count (0);
9964 if In_Extended_Main_Code_Unit (Main_Unit_Entity) then
9965 Unreserve_All_Interrupts := True;
9972 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
9974 when Pragma_Unsuppress =>
9976 Process_Suppress_Unsuppress (False);
9982 -- pragma Use_VADS_Size;
9984 when Pragma_Use_VADS_Size =>
9986 Check_Arg_Count (0);
9987 Check_Valid_Configuration_Pragma;
9988 Use_VADS_Size := True;
9990 ---------------------
9991 -- Validity_Checks --
9992 ---------------------
9994 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
9996 when Pragma_Validity_Checks => Validity_Checks : declare
9997 A : constant Node_Id := Expression (Arg1);
10003 Check_Arg_Count (1);
10004 Check_No_Identifiers;
10006 if Nkind (A) = N_String_Literal then
10010 Slen : constant Natural := Natural (String_Length (S));
10011 Options : String (1 .. Slen);
10017 C := Get_String_Char (S, Int (J));
10018 exit when not In_Character_Range (C);
10019 Options (J) := Get_Character (C);
10022 Set_Validity_Check_Options (Options);
10030 elsif Nkind (A) = N_Identifier then
10032 if Chars (A) = Name_All_Checks then
10033 Set_Validity_Check_Options ("a");
10035 elsif Chars (A) = Name_On then
10036 Validity_Checks_On := True;
10038 elsif Chars (A) = Name_Off then
10039 Validity_Checks_On := False;
10043 end Validity_Checks;
10049 -- pragma Volatile (LOCAL_NAME);
10051 when Pragma_Volatile =>
10052 Process_Atomic_Shared_Volatile;
10054 -------------------------
10055 -- Volatile_Components --
10056 -------------------------
10058 -- pragma Volatile_Components (array_LOCAL_NAME);
10060 -- Volatile is handled by the same circuit as Atomic_Components
10066 -- pragma Warnings (On | Off, [LOCAL_NAME])
10068 when Pragma_Warnings => Warnings : begin
10070 Check_At_Least_N_Arguments (1);
10071 Check_At_Most_N_Arguments (2);
10072 Check_No_Identifiers;
10074 -- One argument case was processed by parser in Par.Prag
10076 if Arg_Count /= 1 then
10077 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
10078 Check_Arg_Count (2);
10085 E_Id := Expression (Arg2);
10088 -- In the expansion of an inlined body, a reference to
10089 -- the formal may be wrapped in a conversion if the actual
10090 -- is a conversion. Retrieve the real entity name.
10092 if (In_Instance_Body
10093 or else In_Inlined_Body)
10094 and then Nkind (E_Id) = N_Unchecked_Type_Conversion
10096 E_Id := Expression (E_Id);
10099 if not Is_Entity_Name (E_Id) then
10101 ("second argument of pragma% must be entity name",
10105 E := Entity (E_Id);
10111 Set_Warnings_Off (E,
10112 (Chars (Expression (Arg1)) = Name_Off));
10114 if Is_Enumeration_Type (E) then
10116 Lit : Entity_Id := First_Literal (E);
10119 while Present (Lit) loop
10120 Set_Warnings_Off (Lit);
10121 Next_Literal (Lit);
10126 exit when No (Homonym (E));
10134 -------------------
10135 -- Weak_External --
10136 -------------------
10138 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
10140 when Pragma_Weak_External => Weak_External : declare
10145 Check_Arg_Count (1);
10146 Check_Optional_Identifier (Arg1, Name_Entity);
10147 Check_Arg_Is_Library_Level_Local_Name (Arg1);
10148 Ent := Entity (Expression (Arg1));
10150 if Rep_Item_Too_Early (Ent, N) then
10153 Ent := Underlying_Type (Ent);
10156 -- The only processing required is to link this item on to the
10157 -- list of rep items for the given entity. This is accomplished
10158 -- by the call to Rep_Item_Too_Late (when no error is detected
10159 -- and False is returned).
10161 if Rep_Item_Too_Late (Ent, N) then
10164 Set_Has_Gigi_Rep_Item (Ent);
10168 --------------------
10169 -- Unknown_Pragma --
10170 --------------------
10172 -- Should be impossible, since the case of an unknown pragma is
10173 -- separately processed before the case statement is entered.
10175 when Unknown_Pragma =>
10176 raise Program_Error;
10180 when Pragma_Exit => null;
10181 end Analyze_Pragma;
10183 ---------------------------------
10184 -- Delay_Config_Pragma_Analyze --
10185 ---------------------------------
10187 function Delay_Config_Pragma_Analyze (N : Node_Id) return Boolean is
10189 return Chars (N) = Name_Interrupt_State;
10190 end Delay_Config_Pragma_Analyze;
10192 -------------------------
10193 -- Get_Base_Subprogram --
10194 -------------------------
10196 function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id is
10197 Result : Entity_Id;
10202 -- Follow subprogram renaming chain
10204 while Is_Subprogram (Result)
10206 (Is_Generic_Instance (Result)
10207 or else Nkind (Parent (Declaration_Node (Result))) =
10208 N_Subprogram_Renaming_Declaration)
10209 and then Present (Alias (Result))
10211 Result := Alias (Result);
10215 end Get_Base_Subprogram;
10217 -----------------------------
10218 -- Is_Config_Static_String --
10219 -----------------------------
10221 function Is_Config_Static_String (Arg : Node_Id) return Boolean is
10223 function Add_Config_Static_String (Arg : Node_Id) return Boolean;
10224 -- This is an internal recursive function that is just like the
10225 -- outer function except that it adds the string to the name buffer
10226 -- rather than placing the string in the name buffer.
10228 ------------------------------
10229 -- Add_Config_Static_String --
10230 ------------------------------
10232 function Add_Config_Static_String (Arg : Node_Id) return Boolean is
10239 if Nkind (N) = N_Op_Concat then
10240 if Add_Config_Static_String (Left_Opnd (N)) then
10241 N := Right_Opnd (N);
10247 if Nkind (N) /= N_String_Literal then
10248 Error_Msg_N ("string literal expected for pragma argument", N);
10252 for J in 1 .. String_Length (Strval (N)) loop
10253 C := Get_String_Char (Strval (N), J);
10255 if not In_Character_Range (C) then
10257 ("string literal contains invalid wide character",
10258 Sloc (N) + 1 + Source_Ptr (J));
10262 Add_Char_To_Name_Buffer (Get_Character (C));
10267 end Add_Config_Static_String;
10269 -- Start of prorcessing for Is_Config_Static_String
10274 return Add_Config_Static_String (Arg);
10275 end Is_Config_Static_String;
10277 -----------------------------------------
10278 -- Is_Non_Significant_Pragma_Reference --
10279 -----------------------------------------
10281 -- This function makes use of the following static table which indicates
10282 -- whether a given pragma is significant. A value of -1 in this table
10283 -- indicates that the reference is significant. A value of zero indicates
10284 -- than appearence as any argument is insignificant, a positive value
10285 -- indicates that appearence in that parameter position is significant.
10287 Sig_Flags : constant array (Pragma_Id) of Int :=
10289 (Pragma_AST_Entry => -1,
10290 Pragma_Abort_Defer => -1,
10291 Pragma_Ada_83 => -1,
10292 Pragma_Ada_95 => -1,
10293 Pragma_Ada_05 => -1,
10294 Pragma_All_Calls_Remote => -1,
10295 Pragma_Annotate => -1,
10296 Pragma_Assert => -1,
10297 Pragma_Asynchronous => -1,
10298 Pragma_Atomic => 0,
10299 Pragma_Atomic_Components => 0,
10300 Pragma_Attach_Handler => -1,
10301 Pragma_CPP_Class => 0,
10302 Pragma_CPP_Constructor => 0,
10303 Pragma_CPP_Virtual => 0,
10304 Pragma_CPP_Vtable => 0,
10305 Pragma_C_Pass_By_Copy => 0,
10306 Pragma_Comment => 0,
10307 Pragma_Common_Object => -1,
10308 Pragma_Compile_Time_Warning => -1,
10309 Pragma_Complex_Representation => 0,
10310 Pragma_Component_Alignment => -1,
10311 Pragma_Controlled => 0,
10312 Pragma_Convention => 0,
10313 Pragma_Convention_Identifier => 0,
10314 Pragma_Debug => -1,
10315 Pragma_Detect_Blocking => -1,
10316 Pragma_Discard_Names => 0,
10317 Pragma_Elaborate => -1,
10318 Pragma_Elaborate_All => -1,
10319 Pragma_Elaborate_Body => -1,
10320 Pragma_Elaboration_Checks => -1,
10321 Pragma_Eliminate => -1,
10322 Pragma_Explicit_Overriding => -1,
10323 Pragma_Export => -1,
10324 Pragma_Export_Exception => -1,
10325 Pragma_Export_Function => -1,
10326 Pragma_Export_Object => -1,
10327 Pragma_Export_Procedure => -1,
10328 Pragma_Export_Value => -1,
10329 Pragma_Export_Valued_Procedure => -1,
10330 Pragma_Extend_System => -1,
10331 Pragma_Extensions_Allowed => -1,
10332 Pragma_External => -1,
10333 Pragma_External_Name_Casing => -1,
10334 Pragma_Finalize_Storage_Only => 0,
10335 Pragma_Float_Representation => 0,
10336 Pragma_Ident => -1,
10337 Pragma_Import => +2,
10338 Pragma_Import_Exception => 0,
10339 Pragma_Import_Function => 0,
10340 Pragma_Import_Object => 0,
10341 Pragma_Import_Procedure => 0,
10342 Pragma_Import_Valued_Procedure => 0,
10343 Pragma_Initialize_Scalars => -1,
10344 Pragma_Inline => 0,
10345 Pragma_Inline_Always => 0,
10346 Pragma_Inline_Generic => 0,
10347 Pragma_Inspection_Point => -1,
10348 Pragma_Interface => +2,
10349 Pragma_Interface_Name => +2,
10350 Pragma_Interrupt_Handler => -1,
10351 Pragma_Interrupt_Priority => -1,
10352 Pragma_Interrupt_State => -1,
10353 Pragma_Java_Constructor => -1,
10354 Pragma_Java_Interface => -1,
10355 Pragma_Keep_Names => 0,
10356 Pragma_License => -1,
10357 Pragma_Link_With => -1,
10358 Pragma_Linker_Alias => -1,
10359 Pragma_Linker_Options => -1,
10360 Pragma_Linker_Section => -1,
10362 Pragma_Locking_Policy => -1,
10363 Pragma_Long_Float => -1,
10364 Pragma_Machine_Attribute => -1,
10366 Pragma_Main_Storage => -1,
10367 Pragma_Memory_Size => -1,
10368 Pragma_No_Return => 0,
10369 Pragma_No_Run_Time => -1,
10370 Pragma_No_Strict_Aliasing => -1,
10371 Pragma_Normalize_Scalars => -1,
10372 Pragma_Obsolescent => 0,
10373 Pragma_Optimize => -1,
10374 Pragma_Optional_Overriding => -1,
10375 Pragma_Overriding => -1,
10378 Pragma_Passive => -1,
10379 Pragma_Polling => -1,
10380 Pragma_Persistent_Data => -1,
10381 Pragma_Persistent_Object => -1,
10382 Pragma_Preelaborate => -1,
10383 Pragma_Priority => -1,
10384 Pragma_Profile => 0,
10385 Pragma_Profile_Warnings => 0,
10386 Pragma_Propagate_Exceptions => -1,
10387 Pragma_Psect_Object => -1,
10389 Pragma_Pure_Function => 0,
10390 Pragma_Queuing_Policy => -1,
10391 Pragma_Ravenscar => -1,
10392 Pragma_Remote_Call_Interface => -1,
10393 Pragma_Remote_Types => -1,
10394 Pragma_Restricted_Run_Time => -1,
10395 Pragma_Restriction_Warnings => -1,
10396 Pragma_Restrictions => -1,
10397 Pragma_Reviewable => -1,
10398 Pragma_Share_Generic => -1,
10399 Pragma_Shared => -1,
10400 Pragma_Shared_Passive => -1,
10401 Pragma_Source_File_Name => -1,
10402 Pragma_Source_File_Name_Project => -1,
10403 Pragma_Source_Reference => -1,
10404 Pragma_Storage_Size => -1,
10405 Pragma_Storage_Unit => -1,
10406 Pragma_Stream_Convert => -1,
10407 Pragma_Style_Checks => -1,
10408 Pragma_Subtitle => -1,
10409 Pragma_Suppress => 0,
10410 Pragma_Suppress_Exception_Locations => 0,
10411 Pragma_Suppress_All => -1,
10412 Pragma_Suppress_Debug_Info => 0,
10413 Pragma_Suppress_Initialization => 0,
10414 Pragma_System_Name => -1,
10415 Pragma_Task_Dispatching_Policy => -1,
10416 Pragma_Task_Info => -1,
10417 Pragma_Task_Name => -1,
10418 Pragma_Task_Storage => 0,
10419 Pragma_Thread_Body => +2,
10420 Pragma_Time_Slice => -1,
10421 Pragma_Title => -1,
10422 Pragma_Unchecked_Union => 0,
10423 Pragma_Unimplemented_Unit => -1,
10424 Pragma_Universal_Data => -1,
10425 Pragma_Unreferenced => -1,
10426 Pragma_Unreserve_All_Interrupts => -1,
10427 Pragma_Unsuppress => 0,
10428 Pragma_Use_VADS_Size => -1,
10429 Pragma_Validity_Checks => -1,
10430 Pragma_Volatile => 0,
10431 Pragma_Volatile_Components => 0,
10432 Pragma_Warnings => -1,
10433 Pragma_Weak_External => 0,
10434 Unknown_Pragma => 0);
10436 function Is_Non_Significant_Pragma_Reference (N : Node_Id) return Boolean is
10444 if Nkind (P) /= N_Pragma_Argument_Association then
10448 C := Sig_Flags (Get_Pragma_Id (Chars (Parent (P))));
10458 A := First (Pragma_Argument_Associations (Parent (P)));
10459 for J in 1 .. C - 1 loop
10470 end Is_Non_Significant_Pragma_Reference;
10472 ------------------------------
10473 -- Is_Pragma_String_Literal --
10474 ------------------------------
10476 -- This function returns true if the corresponding pragma argument is
10477 -- a static string expression. These are the only cases in which string
10478 -- literals can appear as pragma arguments. We also allow a string
10479 -- literal as the first argument to pragma Assert (although it will
10480 -- of course always generate a type error).
10482 function Is_Pragma_String_Literal (Par : Node_Id) return Boolean is
10483 Pragn : constant Node_Id := Parent (Par);
10484 Assoc : constant List_Id := Pragma_Argument_Associations (Pragn);
10485 Pname : constant Name_Id := Chars (Pragn);
10491 N := First (Assoc);
10498 if Pname = Name_Assert then
10501 elsif Pname = Name_Export then
10504 elsif Pname = Name_Ident then
10507 elsif Pname = Name_Import then
10510 elsif Pname = Name_Interface_Name then
10513 elsif Pname = Name_Linker_Alias then
10516 elsif Pname = Name_Linker_Section then
10519 elsif Pname = Name_Machine_Attribute then
10522 elsif Pname = Name_Source_File_Name then
10525 elsif Pname = Name_Source_Reference then
10528 elsif Pname = Name_Title then
10531 elsif Pname = Name_Subtitle then
10537 end Is_Pragma_String_Literal;
10539 --------------------------------------
10540 -- Process_Compilation_Unit_Pragmas --
10541 --------------------------------------
10543 procedure Process_Compilation_Unit_Pragmas (N : Node_Id) is
10545 -- A special check for pragma Suppress_All. This is a strange DEC
10546 -- pragma, strange because it comes at the end of the unit. If we
10547 -- have a pragma Suppress_All in the Pragmas_After of the current
10548 -- unit, then we insert a pragma Suppress (All_Checks) at the start
10549 -- of the context clause to ensure the correct processing.
10552 PA : constant List_Id := Pragmas_After (Aux_Decls_Node (N));
10556 if Present (PA) then
10558 while Present (P) loop
10559 if Chars (P) = Name_Suppress_All then
10560 Prepend_To (Context_Items (N),
10561 Make_Pragma (Sloc (P),
10562 Chars => Name_Suppress,
10563 Pragma_Argument_Associations => New_List (
10564 Make_Pragma_Argument_Association (Sloc (P),
10566 Make_Identifier (Sloc (P),
10567 Chars => Name_All_Checks)))));
10575 end Process_Compilation_Unit_Pragmas;
10577 --------------------------------
10578 -- Set_Encoded_Interface_Name --
10579 --------------------------------
10581 procedure Set_Encoded_Interface_Name (E : Entity_Id; S : Node_Id) is
10582 Str : constant String_Id := Strval (S);
10583 Len : constant Int := String_Length (Str);
10588 Hex : constant array (0 .. 15) of Character := "0123456789abcdef";
10591 -- Stores encoded value of character code CC. The encoding we
10592 -- use an underscore followed by four lower case hex digits.
10594 procedure Encode is
10596 Store_String_Char (Get_Char_Code ('_'));
10598 (Get_Char_Code (Hex (Integer (CC / 2 ** 12))));
10600 (Get_Char_Code (Hex (Integer (CC / 2 ** 8 and 16#0F#))));
10602 (Get_Char_Code (Hex (Integer (CC / 2 ** 4 and 16#0F#))));
10604 (Get_Char_Code (Hex (Integer (CC and 16#0F#))));
10607 -- Start of processing for Set_Encoded_Interface_Name
10610 -- If first character is asterisk, this is a link name, and we
10611 -- leave it completely unmodified. We also ignore null strings
10612 -- (the latter case happens only in error cases) and no encoding
10613 -- should occur for Java interface names.
10616 or else Get_String_Char (Str, 1) = Get_Char_Code ('*')
10619 Set_Interface_Name (E, S);
10624 CC := Get_String_Char (Str, J);
10626 exit when not In_Character_Range (CC);
10628 C := Get_Character (CC);
10630 exit when C /= '_' and then C /= '$'
10631 and then C not in '0' .. '9'
10632 and then C not in 'a' .. 'z'
10633 and then C not in 'A' .. 'Z';
10636 Set_Interface_Name (E, S);
10644 -- Here we need to encode. The encoding we use as follows:
10645 -- three underscores + four hex digits (lower case)
10649 for J in 1 .. String_Length (Str) loop
10650 CC := Get_String_Char (Str, J);
10652 if not In_Character_Range (CC) then
10655 C := Get_Character (CC);
10657 if C = '_' or else C = '$'
10658 or else C in '0' .. '9'
10659 or else C in 'a' .. 'z'
10660 or else C in 'A' .. 'Z'
10662 Store_String_Char (CC);
10669 Set_Interface_Name (E,
10670 Make_String_Literal (Sloc (S),
10671 Strval => End_String));
10673 end Set_Encoded_Interface_Name;
10675 -------------------
10676 -- Set_Unit_Name --
10677 -------------------
10679 procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id) is
10684 if Nkind (N) = N_Identifier
10685 and then Nkind (With_Item) = N_Identifier
10687 Set_Entity (N, Entity (With_Item));
10689 elsif Nkind (N) = N_Selected_Component then
10690 Change_Selected_Component_To_Expanded_Name (N);
10691 Set_Entity (N, Entity (With_Item));
10692 Set_Entity (Selector_Name (N), Entity (N));
10694 Pref := Prefix (N);
10695 Scop := Scope (Entity (N));
10697 while Nkind (Pref) = N_Selected_Component loop
10698 Change_Selected_Component_To_Expanded_Name (Pref);
10699 Set_Entity (Selector_Name (Pref), Scop);
10700 Set_Entity (Pref, Scop);
10701 Pref := Prefix (Pref);
10702 Scop := Scope (Scop);
10705 Set_Entity (Pref, Scop);