1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- This unit contains the semantic processing for all pragmas, both language
28 -- and implementation defined. For most pragmas, the parser only does the
29 -- most basic job of checking the syntax, so Sem_Prag also contains the code
30 -- to complete the syntax checks. Certain pragmas are handled partially or
31 -- completely by the parser (see Par.Prag for further details).
33 with Atree; use Atree;
34 with Casing; use Casing;
35 with Csets; use Csets;
36 with Debug; use Debug;
37 with Einfo; use Einfo;
38 with Errout; use Errout;
39 with Exp_Dist; use Exp_Dist;
41 with Lib.Writ; use Lib.Writ;
42 with Lib.Xref; use Lib.Xref;
43 with Namet; use Namet;
44 with Nlists; use Nlists;
45 with Nmake; use Nmake;
47 with Output; use Output;
48 with Restrict; use Restrict;
49 with Rident; use Rident;
50 with Rtsfind; use Rtsfind;
52 with Sem_Ch3; use Sem_Ch3;
53 with Sem_Ch8; use Sem_Ch8;
54 with Sem_Ch13; use Sem_Ch13;
55 with Sem_Dist; use Sem_Dist;
56 with Sem_Elim; use Sem_Elim;
57 with Sem_Eval; use Sem_Eval;
58 with Sem_Intr; use Sem_Intr;
59 with Sem_Mech; use Sem_Mech;
60 with Sem_Res; use Sem_Res;
61 with Sem_Type; use Sem_Type;
62 with Sem_Util; use Sem_Util;
63 with Sem_VFpt; use Sem_VFpt;
64 with Sem_Warn; use Sem_Warn;
65 with Stand; use Stand;
66 with Sinfo; use Sinfo;
67 with Sinfo.CN; use Sinfo.CN;
68 with Sinput; use Sinput;
69 with Snames; use Snames;
70 with Stringt; use Stringt;
71 with Stylesw; use Stylesw;
73 with Targparm; use Targparm;
74 with Tbuild; use Tbuild;
76 with Uintp; use Uintp;
77 with Urealp; use Urealp;
78 with Validsw; use Validsw;
80 with GNAT.Spelling_Checker; use GNAT.Spelling_Checker;
82 package body Sem_Prag is
84 ----------------------------------------------
85 -- Common Handling of Import-Export Pragmas --
86 ----------------------------------------------
88 -- In the following section, a number of Import_xxx and Export_xxx
89 -- pragmas are defined by GNAT. These are compatible with the DEC
90 -- pragmas of the same name, and all have the following common
91 -- form and processing:
94 -- [Internal =>] LOCAL_NAME,
95 -- [, [External =>] EXTERNAL_SYMBOL]
96 -- [, other optional parameters ]);
99 -- [Internal =>] LOCAL_NAME,
100 -- [, [External =>] EXTERNAL_SYMBOL]
101 -- [, other optional parameters ]);
103 -- EXTERNAL_SYMBOL ::=
105 -- | static_string_EXPRESSION
107 -- The internal LOCAL_NAME designates the entity that is imported or
108 -- exported, and must refer to an entity in the current declarative
109 -- part (as required by the rules for LOCAL_NAME).
111 -- The external linker name is designated by the External parameter
112 -- if given, or the Internal parameter if not (if there is no External
113 -- parameter, the External parameter is a copy of the Internal name).
115 -- If the External parameter is given as a string, then this string
116 -- is treated as an external name (exactly as though it had been given
117 -- as an External_Name parameter for a normal Import pragma).
119 -- If the External parameter is given as an identifier (or there is no
120 -- External parameter, so that the Internal identifier is used), then
121 -- the external name is the characters of the identifier, translated
122 -- to all upper case letters for OpenVMS versions of GNAT, and to all
123 -- lower case letters for all other versions
125 -- Note: the external name specified or implied by any of these special
126 -- Import_xxx or Export_xxx pragmas override an external or link name
127 -- specified in a previous Import or Export pragma.
129 -- Note: these and all other DEC-compatible GNAT pragmas allow full
130 -- use of named notation, following the standard rules for subprogram
131 -- calls, i.e. parameters can be given in any order if named notation
132 -- is used, and positional and named notation can be mixed, subject to
133 -- the rule that all positional parameters must appear first.
135 -- Note: All these pragmas are implemented exactly following the DEC
136 -- design and implementation and are intended to be fully compatible
137 -- with the use of these pragmas in the DEC Ada compiler.
139 --------------------------------------------
140 -- Checking for Duplicated External Names --
141 --------------------------------------------
143 -- It is suspicious if two separate Export pragmas use the same external
144 -- name. The following table is used to diagnose this situation so that
145 -- an appropriate warning can be issued.
147 -- The Node_Id stored is for the N_String_Literal node created to
148 -- hold the value of the external name. The Sloc of this node is
149 -- used to cross-reference the location of the duplication.
151 package Externals is new Table.Table (
152 Table_Component_Type => Node_Id,
153 Table_Index_Type => Int,
154 Table_Low_Bound => 0,
155 Table_Initial => 100,
156 Table_Increment => 100,
157 Table_Name => "Name_Externals");
159 -------------------------------------
160 -- Local Subprograms and Variables --
161 -------------------------------------
163 function Adjust_External_Name_Case (N : Node_Id) return Node_Id;
164 -- This routine is used for possible casing adjustment of an explicit
165 -- external name supplied as a string literal (the node N), according
166 -- to the casing requirement of Opt.External_Name_Casing. If this is
167 -- set to As_Is, then the string literal is returned unchanged, but if
168 -- it is set to Uppercase or Lowercase, then a new string literal with
169 -- appropriate casing is constructed.
171 function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id;
172 -- If Def_Id refers to a renamed subprogram, then the base subprogram
173 -- (the original one, following the renaming chain) is returned.
174 -- Otherwise the entity is returned unchanged. Should be in Einfo???
177 -- This is a dummy function called by the processing for pragma Reviewable.
178 -- It is there for assisting front end debugging. By placing a Reviewable
179 -- pragma in the source program, a breakpoint on rv catches this place in
180 -- the source, allowing convenient stepping to the point of interest.
182 procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id);
183 -- Place semantic information on the argument of an Elaborate or
184 -- Elaborate_All pragma. Entity name for unit and its parents is
185 -- taken from item in previous with_clause that mentions the unit.
187 -------------------------------
188 -- Adjust_External_Name_Case --
189 -------------------------------
191 function Adjust_External_Name_Case (N : Node_Id) return Node_Id is
195 -- Adjust case of literal if required
197 if Opt.External_Name_Exp_Casing = As_Is then
201 -- Copy existing string
207 for J in 1 .. String_Length (Strval (N)) loop
208 CC := Get_String_Char (Strval (N), J);
210 if Opt.External_Name_Exp_Casing = Uppercase
211 and then CC >= Get_Char_Code ('a')
212 and then CC <= Get_Char_Code ('z')
214 Store_String_Char (CC - 32);
216 elsif Opt.External_Name_Exp_Casing = Lowercase
217 and then CC >= Get_Char_Code ('A')
218 and then CC <= Get_Char_Code ('Z')
220 Store_String_Char (CC + 32);
223 Store_String_Char (CC);
228 Make_String_Literal (Sloc (N),
229 Strval => End_String);
231 end Adjust_External_Name_Case;
237 procedure Analyze_Pragma (N : Node_Id) is
238 Loc : constant Source_Ptr := Sloc (N);
241 Pragma_Exit : exception;
242 -- This exception is used to exit pragma processing completely. It
243 -- is used when an error is detected, and no further processing is
244 -- required. It is also used if an earlier error has left the tree
245 -- in a state where the pragma should not be processed.
248 -- Number of pragma argument associations
254 -- First four pragma arguments (pragma argument association nodes,
255 -- or Empty if the corresponding argument does not exist).
257 type Name_List is array (Natural range <>) of Name_Id;
258 type Args_List is array (Natural range <>) of Node_Id;
259 -- Types used for arguments to Check_Arg_Order and Gather_Associations
261 procedure Ada_2005_Pragma;
262 -- Called for pragmas defined in Ada 2005, that are not in Ada 95. In
263 -- Ada 95 mode, these are implementation defined pragmas, so should be
264 -- caught by the No_Implementation_Pragmas restriction
266 procedure Check_Ada_83_Warning;
267 -- Issues a warning message for the current pragma if operating in Ada
268 -- 83 mode (used for language pragmas that are not a standard part of
269 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
272 procedure Check_Arg_Count (Required : Nat);
273 -- Check argument count for pragma is equal to given parameter.
274 -- If not, then issue an error message and raise Pragma_Exit.
276 -- Note: all routines whose name is Check_Arg_Is_xxx take an
277 -- argument Arg which can either be a pragma argument association,
278 -- in which case the check is applied to the expression of the
279 -- association or an expression directly.
281 procedure Check_Arg_Is_External_Name (Arg : Node_Id);
282 -- Check that an argument has the right form for an EXTERNAL_NAME
283 -- parameter of an extended import/export pragma. The rule is that
284 -- the name must be an identifier or string literal (in Ada 83 mode)
285 -- or a static string expression (in Ada 95 mode).
287 procedure Check_Arg_Is_Identifier (Arg : Node_Id);
288 -- Check the specified argument Arg to make sure that it is an
289 -- identifier. If not give error and raise Pragma_Exit.
291 procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id);
292 -- Check the specified argument Arg to make sure that it is an
293 -- integer literal. If not give error and raise Pragma_Exit.
295 procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id);
296 -- Check the specified argument Arg to make sure that it has the
297 -- proper syntactic form for a local name and meets the semantic
298 -- requirements for a local name. The local name is analyzed as
299 -- part of the processing for this call. In addition, the local
300 -- name is required to represent an entity at the library level.
302 procedure Check_Arg_Is_Local_Name (Arg : Node_Id);
303 -- Check the specified argument Arg to make sure that it has the
304 -- proper syntactic form for a local name and meets the semantic
305 -- requirements for a local name. The local name is analyzed as
306 -- part of the processing for this call.
308 procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id);
309 -- Check the specified argument Arg to make sure that it is a valid
310 -- locking policy name. If not give error and raise Pragma_Exit.
312 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id);
313 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2, N3 : Name_Id);
314 -- Check the specified argument Arg to make sure that it is an
315 -- identifier whose name matches either N1 or N2 (or N3 if present).
316 -- If not then give error and raise Pragma_Exit.
318 procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id);
319 -- Check the specified argument Arg to make sure that it is a valid
320 -- queuing policy name. If not give error and raise Pragma_Exit.
322 procedure Check_Arg_Is_Static_Expression
325 -- Check the specified argument Arg to make sure that it is a static
326 -- expression of the given type (i.e. it will be analyzed and resolved
327 -- using this type, which can be any valid argument to Resolve, e.g.
328 -- Any_Integer is OK). If not, given error and raise Pragma_Exit.
330 procedure Check_Arg_Is_String_Literal (Arg : Node_Id);
331 -- Check the specified argument Arg to make sure that it is a
332 -- string literal. If not give error and raise Pragma_Exit
334 procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id);
335 -- Check the specified argument Arg to make sure that it is a valid
336 -- valid task dispatching policy name. If not give error and raise
339 procedure Check_Arg_Order (Names : Name_List);
340 -- Checks for an instance of two arguments with identifiers for the
341 -- current pragma which are not in the sequence indicated by Names,
342 -- and if so, generates a fatal message about bad order of arguments.
344 procedure Check_At_Least_N_Arguments (N : Nat);
345 -- Check there are at least N arguments present
347 procedure Check_At_Most_N_Arguments (N : Nat);
348 -- Check there are no more than N arguments present
350 procedure Check_Component (Comp : Node_Id);
351 -- Examine Unchecked_Union component for correct use of per-object
352 -- constrained subtypes, and for restrictions on finalizable components.
354 procedure Check_Duplicated_Export_Name (Nam : Node_Id);
355 -- Nam is an N_String_Literal node containing the external name set
356 -- by an Import or Export pragma (or extended Import or Export pragma).
357 -- This procedure checks for possible duplications if this is the
358 -- export case, and if found, issues an appropriate error message.
360 procedure Check_First_Subtype (Arg : Node_Id);
361 -- Checks that Arg, whose expression is an entity name referencing
362 -- a subtype, does not reference a type that is not a first subtype.
364 procedure Check_In_Main_Program;
365 -- Common checks for pragmas that appear within a main program
366 -- (Priority, Main_Storage, Time_Slice).
368 procedure Check_Interrupt_Or_Attach_Handler;
369 -- Common processing for first argument of pragma Interrupt_Handler
370 -- or pragma Attach_Handler.
372 procedure Check_Is_In_Decl_Part_Or_Package_Spec;
373 -- Check that pragma appears in a declarative part, or in a package
374 -- specification, i.e. that it does not occur in a statement sequence
377 procedure Check_No_Identifier (Arg : Node_Id);
378 -- Checks that the given argument does not have an identifier. If
379 -- an identifier is present, then an error message is issued, and
380 -- Pragma_Exit is raised.
382 procedure Check_No_Identifiers;
383 -- Checks that none of the arguments to the pragma has an identifier.
384 -- If any argument has an identifier, then an error message is issued,
385 -- and Pragma_Exit is raised.
387 procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id);
388 -- Checks if the given argument has an identifier, and if so, requires
389 -- it to match the given identifier name. If there is a non-matching
390 -- identifier, then an error message is given and Error_Pragmas raised.
392 procedure Check_Optional_Identifier (Arg : Node_Id; Id : String);
393 -- Checks if the given argument has an identifier, and if so, requires
394 -- it to match the given identifier name. If there is a non-matching
395 -- identifier, then an error message is given and Error_Pragmas raised.
396 -- In this version of the procedure, the identifier name is given as
397 -- a string with lower case letters.
399 procedure Check_Static_Constraint (Constr : Node_Id);
400 -- Constr is a constraint from an N_Subtype_Indication node from a
401 -- component constraint in an Unchecked_Union type. This routine checks
402 -- that the constraint is static as required by the restrictions for
405 procedure Check_Valid_Configuration_Pragma;
406 -- Legality checks for placement of a configuration pragma
408 procedure Check_Valid_Library_Unit_Pragma;
409 -- Legality checks for library unit pragmas. A special case arises for
410 -- pragmas in generic instances that come from copies of the original
411 -- library unit pragmas in the generic templates. In the case of other
412 -- than library level instantiations these can appear in contexts which
413 -- would normally be invalid (they only apply to the original template
414 -- and to library level instantiations), and they are simply ignored,
415 -- which is implemented by rewriting them as null statements.
417 procedure Check_Variant (Variant : Node_Id);
418 -- Check Unchecked_Union variant for lack of nested variants and
419 -- presence of at least one component.
421 procedure Error_Pragma (Msg : String);
422 pragma No_Return (Error_Pragma);
423 -- Outputs error message for current pragma. The message contains an %
424 -- that will be replaced with the pragma name, and the flag is placed
425 -- on the pragma itself. Pragma_Exit is then raised.
427 procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id);
428 pragma No_Return (Error_Pragma_Arg);
429 -- Outputs error message for current pragma. The message may contain
430 -- a % that will be replaced with the pragma name. The parameter Arg
431 -- may either be a pragma argument association, in which case the flag
432 -- is placed on the expression of this association, or an expression,
433 -- in which case the flag is placed directly on the expression. The
434 -- message is placed using Error_Msg_N, so the message may also contain
435 -- an & insertion character which will reference the given Arg value.
436 -- After placing the message, Pragma_Exit is raised.
438 procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id);
439 pragma No_Return (Error_Pragma_Arg);
440 -- Similar to above form of Error_Pragma_Arg except that two messages
441 -- are provided, the second is a continuation comment starting with \.
443 procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id);
444 pragma No_Return (Error_Pragma_Arg_Ident);
445 -- Outputs error message for current pragma. The message may contain
446 -- a % that will be replaced with the pragma name. The parameter Arg
447 -- must be a pragma argument association with a non-empty identifier
448 -- (i.e. its Chars field must be set), and the error message is placed
449 -- on the identifier. The message is placed using Error_Msg_N so
450 -- the message may also contain an & insertion character which will
451 -- reference the identifier. After placing the message, Pragma_Exit
454 function Find_Lib_Unit_Name return Entity_Id;
455 -- Used for a library unit pragma to find the entity to which the
456 -- library unit pragma applies, returns the entity found.
458 procedure Find_Program_Unit_Name (Id : Node_Id);
459 -- If the pragma is a compilation unit pragma, the id must denote the
460 -- compilation unit in the same compilation, and the pragma must appear
461 -- in the list of preceding or trailing pragmas. If it is a program
462 -- unit pragma that is not a compilation unit pragma, then the
463 -- identifier must be visible.
465 function Find_Unique_Parameterless_Procedure
467 Arg : Node_Id) return Entity_Id;
468 -- Used for a procedure pragma to find the unique parameterless
469 -- procedure identified by Name, returns it if it exists, otherwise
470 -- errors out and uses Arg as the pragma argument for the message.
472 procedure Gather_Associations
474 Args : out Args_List);
475 -- This procedure is used to gather the arguments for a pragma that
476 -- permits arbitrary ordering of parameters using the normal rules
477 -- for named and positional parameters. The Names argument is a list
478 -- of Name_Id values that corresponds to the allowed pragma argument
479 -- association identifiers in order. The result returned in Args is
480 -- a list of corresponding expressions that are the pragma arguments.
481 -- Note that this is a list of expressions, not of pragma argument
482 -- associations (Gather_Associations has completely checked all the
483 -- optional identifiers when it returns). An entry in Args is Empty
484 -- on return if the corresponding argument is not present.
486 function Get_Pragma_Arg (Arg : Node_Id) return Node_Id;
487 -- All the routines that check pragma arguments take either a pragma
488 -- argument association (in which case the expression of the argument
489 -- association is checked), or the expression directly. The function
490 -- Get_Pragma_Arg is a utility used to deal with these two cases. If
491 -- Arg is a pragma argument association node, then its expression is
492 -- returned, otherwise Arg is returned unchanged.
494 procedure GNAT_Pragma;
495 -- Called for all GNAT defined pragmas to check the relevant restriction
496 -- (No_Implementation_Pragmas).
498 function Is_Before_First_Decl
499 (Pragma_Node : Node_Id;
500 Decls : List_Id) return Boolean;
501 -- Return True if Pragma_Node is before the first declarative item in
502 -- Decls where Decls is the list of declarative items.
504 function Is_Configuration_Pragma return Boolean;
505 -- Deterermines if the placement of the current pragma is appropriate
506 -- for a configuration pragma (precedes the current compilation unit).
508 function Is_In_Context_Clause return Boolean;
509 -- Returns True if pragma appears within the context clause of a unit,
510 -- and False for any other placement (does not generate any messages).
512 function Is_Static_String_Expression (Arg : Node_Id) return Boolean;
513 -- Analyzes the argument, and determines if it is a static string
514 -- expression, returns True if so, False if non-static or not String.
516 procedure Pragma_Misplaced;
517 -- Issue fatal error message for misplaced pragma
519 procedure Process_Atomic_Shared_Volatile;
520 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
521 -- Shared is an obsolete Ada 83 pragma, treated as being identical
522 -- in effect to pragma Atomic.
524 procedure Process_Compile_Time_Warning_Or_Error;
525 -- Common processing for Compile_Time_Error and Compile_Time_Warning
527 procedure Process_Convention (C : out Convention_Id; E : out Entity_Id);
528 -- Common procesing for Convention, Interface, Import and Export.
529 -- Checks first two arguments of pragma, and sets the appropriate
530 -- convention value in the specified entity or entities. On return
531 -- C is the convention, E is the referenced entity.
533 procedure Process_Extended_Import_Export_Exception_Pragma
534 (Arg_Internal : Node_Id;
535 Arg_External : Node_Id;
538 -- Common processing for the pragmas Import/Export_Exception.
539 -- The three arguments correspond to the three named parameters of
540 -- the pragma. An argument is empty if the corresponding parameter
541 -- is not present in the pragma.
543 procedure Process_Extended_Import_Export_Object_Pragma
544 (Arg_Internal : Node_Id;
545 Arg_External : Node_Id;
547 -- Common processing for the pragmass Import/Export_Object.
548 -- The three arguments correspond to the three named parameters
549 -- of the pragmas. An argument is empty if the corresponding
550 -- parameter is not present in the pragma.
552 procedure Process_Extended_Import_Export_Internal_Arg
553 (Arg_Internal : Node_Id := Empty);
554 -- Common processing for all extended Import and Export pragmas. The
555 -- argument is the pragma parameter for the Internal argument. If
556 -- Arg_Internal is empty or inappropriate, an error message is posted.
557 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
558 -- set to identify the referenced entity.
560 procedure Process_Extended_Import_Export_Subprogram_Pragma
561 (Arg_Internal : Node_Id;
562 Arg_External : Node_Id;
563 Arg_Parameter_Types : Node_Id;
564 Arg_Result_Type : Node_Id := Empty;
565 Arg_Mechanism : Node_Id;
566 Arg_Result_Mechanism : Node_Id := Empty;
567 Arg_First_Optional_Parameter : Node_Id := Empty);
568 -- Common processing for all extended Import and Export pragmas
569 -- applying to subprograms. The caller omits any arguments that do
570 -- bnot apply to the pragma in question (for example, Arg_Result_Type
571 -- can be non-Empty only in the Import_Function and Export_Function
572 -- cases). The argument names correspond to the allowed pragma
573 -- association identifiers.
575 procedure Process_Generic_List;
576 -- Common processing for Share_Generic and Inline_Generic
578 procedure Process_Import_Or_Interface;
579 -- Common processing for Import of Interface
581 procedure Process_Inline (Active : Boolean);
582 -- Common processing for Inline and Inline_Always. The parameter
583 -- indicates if the inline pragma is active, i.e. if it should
584 -- actually cause inlining to occur.
586 procedure Process_Interface_Name
587 (Subprogram_Def : Entity_Id;
590 -- Given the last two arguments of pragma Import, pragma Export, or
591 -- pragma Interface_Name, performs validity checks and sets the
592 -- Interface_Name field of the given subprogram entity to the
593 -- appropriate external or link name, depending on the arguments
594 -- given. Ext_Arg is always present, but Link_Arg may be missing.
595 -- Note that Ext_Arg may represent the Link_Name if Link_Arg is
596 -- missing, and appropriate named notation is used for Ext_Arg.
597 -- If neither Ext_Arg nor Link_Arg is present, the interface name
598 -- is set to the default from the subprogram name.
600 procedure Process_Interrupt_Or_Attach_Handler;
601 -- Common processing for Interrupt and Attach_Handler pragmas
603 procedure Process_Restrictions_Or_Restriction_Warnings (Warn : Boolean);
604 -- Common processing for Restrictions and Restriction_Warnings pragmas.
605 -- Warn is False for Restrictions, True for Restriction_Warnings.
607 procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean);
608 -- Common processing for Suppress and Unsuppress. The boolean parameter
609 -- Suppress_Case is True for the Suppress case, and False for the
612 procedure Set_Exported (E : Entity_Id; Arg : Node_Id);
613 -- This procedure sets the Is_Exported flag for the given entity,
614 -- checking that the entity was not previously imported. Arg is
615 -- the argument that specified the entity. A check is also made
616 -- for exporting inappropriate entities.
618 procedure Set_Extended_Import_Export_External_Name
619 (Internal_Ent : Entity_Id;
620 Arg_External : Node_Id);
621 -- Common processing for all extended import export pragmas. The first
622 -- argument, Internal_Ent, is the internal entity, which has already
623 -- been checked for validity by the caller. Arg_External is from the
624 -- Import or Export pragma, and may be null if no External parameter
625 -- was present. If Arg_External is present and is a non-null string
626 -- (a null string is treated as the default), then the Interface_Name
627 -- field of Internal_Ent is set appropriately.
629 procedure Set_Imported (E : Entity_Id);
630 -- This procedure sets the Is_Imported flag for the given entity,
631 -- checking that it is not previously exported or imported.
633 procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id);
634 -- Mech is a parameter passing mechanism (see Import_Function syntax
635 -- for MECHANISM_NAME). This routine checks that the mechanism argument
636 -- has the right form, and if not issues an error message. If the
637 -- argument has the right form then the Mechanism field of Ent is
638 -- set appropriately.
640 procedure Set_Ravenscar_Profile (N : Node_Id);
641 -- Activate the set of configuration pragmas and restrictions that
642 -- make up the Ravenscar Profile. N is the corresponding pragma
643 -- node, which is used for error messages on any constructs
644 -- that violate the profile.
646 ---------------------
647 -- Ada_2005_Pragma --
648 ---------------------
650 procedure Ada_2005_Pragma is
652 if Ada_Version <= Ada_95 then
653 Check_Restriction (No_Implementation_Pragmas, N);
657 --------------------------
658 -- Check_Ada_83_Warning --
659 --------------------------
661 procedure Check_Ada_83_Warning is
663 if Ada_Version = Ada_83 and then Comes_From_Source (N) then
664 Error_Msg_N ("(Ada 83) pragma& is non-standard?", N);
666 end Check_Ada_83_Warning;
668 ---------------------
669 -- Check_Arg_Count --
670 ---------------------
672 procedure Check_Arg_Count (Required : Nat) is
674 if Arg_Count /= Required then
675 Error_Pragma ("wrong number of arguments for pragma%");
679 --------------------------------
680 -- Check_Arg_Is_External_Name --
681 --------------------------------
683 procedure Check_Arg_Is_External_Name (Arg : Node_Id) is
684 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
687 if Nkind (Argx) = N_Identifier then
691 Analyze_And_Resolve (Argx, Standard_String);
693 if Is_OK_Static_Expression (Argx) then
696 elsif Etype (Argx) = Any_Type then
699 -- An interesting special case, if we have a string literal and
700 -- we are in Ada 83 mode, then we allow it even though it will
701 -- not be flagged as static. This allows expected Ada 83 mode
702 -- use of external names which are string literals, even though
703 -- technically these are not static in Ada 83.
705 elsif Ada_Version = Ada_83
706 and then Nkind (Argx) = N_String_Literal
710 -- Static expression that raises Constraint_Error. This has
711 -- already been flagged, so just exit from pragma processing.
713 elsif Is_Static_Expression (Argx) then
716 -- Here we have a real error (non-static expression)
719 Error_Msg_Name_1 := Chars (N);
721 ("argument for pragma% must be a identifier or " &
722 "static string expression!", Argx);
726 end Check_Arg_Is_External_Name;
728 -----------------------------
729 -- Check_Arg_Is_Identifier --
730 -----------------------------
732 procedure Check_Arg_Is_Identifier (Arg : Node_Id) is
733 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
735 if Nkind (Argx) /= N_Identifier then
737 ("argument for pragma% must be identifier", Argx);
739 end Check_Arg_Is_Identifier;
741 ----------------------------------
742 -- Check_Arg_Is_Integer_Literal --
743 ----------------------------------
745 procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id) is
746 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
748 if Nkind (Argx) /= N_Integer_Literal then
750 ("argument for pragma% must be integer literal", Argx);
752 end Check_Arg_Is_Integer_Literal;
754 -------------------------------------------
755 -- Check_Arg_Is_Library_Level_Local_Name --
756 -------------------------------------------
760 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
761 -- | library_unit_NAME
763 procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id) is
765 Check_Arg_Is_Local_Name (Arg);
767 if not Is_Library_Level_Entity (Entity (Expression (Arg)))
768 and then Comes_From_Source (N)
771 ("argument for pragma% must be library level entity", Arg);
773 end Check_Arg_Is_Library_Level_Local_Name;
775 -----------------------------
776 -- Check_Arg_Is_Local_Name --
777 -----------------------------
781 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
782 -- | library_unit_NAME
784 procedure Check_Arg_Is_Local_Name (Arg : Node_Id) is
785 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
790 if Nkind (Argx) not in N_Direct_Name
791 and then (Nkind (Argx) /= N_Attribute_Reference
792 or else Present (Expressions (Argx))
793 or else Nkind (Prefix (Argx)) /= N_Identifier)
794 and then (not Is_Entity_Name (Argx)
795 or else not Is_Compilation_Unit (Entity (Argx)))
797 Error_Pragma_Arg ("argument for pragma% must be local name", Argx);
800 if Is_Entity_Name (Argx)
801 and then Scope (Entity (Argx)) /= Current_Scope
804 ("pragma% argument must be in same declarative part", Arg);
806 end Check_Arg_Is_Local_Name;
808 ---------------------------------
809 -- Check_Arg_Is_Locking_Policy --
810 ---------------------------------
812 procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id) is
813 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
816 Check_Arg_Is_Identifier (Argx);
818 if not Is_Locking_Policy_Name (Chars (Argx)) then
820 ("& is not a valid locking policy name", Argx);
822 end Check_Arg_Is_Locking_Policy;
824 -------------------------
825 -- Check_Arg_Is_One_Of --
826 -------------------------
828 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id) is
829 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
832 Check_Arg_Is_Identifier (Argx);
834 if Chars (Argx) /= N1 and then Chars (Argx) /= N2 then
835 Error_Msg_Name_2 := N1;
836 Error_Msg_Name_3 := N2;
837 Error_Pragma_Arg ("argument for pragma% must be% or%", Argx);
839 end Check_Arg_Is_One_Of;
841 procedure Check_Arg_Is_One_Of
843 N1, N2, N3 : Name_Id)
845 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
848 Check_Arg_Is_Identifier (Argx);
850 if Chars (Argx) /= N1
851 and then Chars (Argx) /= N2
852 and then Chars (Argx) /= N3
854 Error_Pragma_Arg ("invalid argument for pragma%", Argx);
856 end Check_Arg_Is_One_Of;
858 ---------------------------------
859 -- Check_Arg_Is_Queuing_Policy --
860 ---------------------------------
862 procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id) is
863 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
866 Check_Arg_Is_Identifier (Argx);
868 if not Is_Queuing_Policy_Name (Chars (Argx)) then
870 ("& is not a valid queuing policy name", Argx);
872 end Check_Arg_Is_Queuing_Policy;
874 ------------------------------------
875 -- Check_Arg_Is_Static_Expression --
876 ------------------------------------
878 procedure Check_Arg_Is_Static_Expression
882 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
885 Analyze_And_Resolve (Argx, Typ);
887 if Is_OK_Static_Expression (Argx) then
890 elsif Etype (Argx) = Any_Type then
893 -- An interesting special case, if we have a string literal and
894 -- we are in Ada 83 mode, then we allow it even though it will
895 -- not be flagged as static. This allows the use of Ada 95
896 -- pragmas like Import in Ada 83 mode. They will of course be
897 -- flagged with warnings as usual, but will not cause errors.
899 elsif Ada_Version = Ada_83
900 and then Nkind (Argx) = N_String_Literal
904 -- Static expression that raises Constraint_Error. This has
905 -- already been flagged, so just exit from pragma processing.
907 elsif Is_Static_Expression (Argx) then
910 -- Finally, we have a real error
913 Error_Msg_Name_1 := Chars (N);
915 ("argument for pragma% must be a static expression!", Argx);
918 end Check_Arg_Is_Static_Expression;
920 ---------------------------------
921 -- Check_Arg_Is_String_Literal --
922 ---------------------------------
924 procedure Check_Arg_Is_String_Literal (Arg : Node_Id) is
925 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
927 if Nkind (Argx) /= N_String_Literal then
929 ("argument for pragma% must be string literal", Argx);
931 end Check_Arg_Is_String_Literal;
933 ------------------------------------------
934 -- Check_Arg_Is_Task_Dispatching_Policy --
935 ------------------------------------------
937 procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id) is
938 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
941 Check_Arg_Is_Identifier (Argx);
943 if not Is_Task_Dispatching_Policy_Name (Chars (Argx)) then
945 ("& is not a valid task dispatching policy name", Argx);
947 end Check_Arg_Is_Task_Dispatching_Policy;
949 ---------------------
950 -- Check_Arg_Order --
951 ---------------------
953 procedure Check_Arg_Order (Names : Name_List) is
956 Highest_So_Far : Natural := 0;
957 -- Highest index in Names seen do far
961 for J in 1 .. Arg_Count loop
962 if Chars (Arg) /= No_Name then
963 for K in Names'Range loop
964 if Chars (Arg) = Names (K) then
965 if K < Highest_So_Far then
966 Error_Msg_Name_1 := Chars (N);
968 ("parameters out of order for pragma%", Arg);
969 Error_Msg_Name_1 := Names (K);
970 Error_Msg_Name_2 := Names (Highest_So_Far);
971 Error_Msg_N ("\% must appear before %", Arg);
985 --------------------------------
986 -- Check_At_Least_N_Arguments --
987 --------------------------------
989 procedure Check_At_Least_N_Arguments (N : Nat) is
991 if Arg_Count < N then
992 Error_Pragma ("too few arguments for pragma%");
994 end Check_At_Least_N_Arguments;
996 -------------------------------
997 -- Check_At_Most_N_Arguments --
998 -------------------------------
1000 procedure Check_At_Most_N_Arguments (N : Nat) is
1003 if Arg_Count > N then
1005 for J in 1 .. N loop
1007 Error_Pragma_Arg ("too many arguments for pragma%", Arg);
1010 end Check_At_Most_N_Arguments;
1012 ---------------------
1013 -- Check_Component --
1014 ---------------------
1016 procedure Check_Component (Comp : Node_Id) is
1018 if Nkind (Comp) = N_Component_Declaration then
1020 Sindic : constant Node_Id :=
1021 Subtype_Indication (Component_Definition (Comp));
1022 Typ : constant Entity_Id :=
1023 Etype (Defining_Identifier (Comp));
1025 if Nkind (Sindic) = N_Subtype_Indication then
1027 -- Ada 2005 (AI-216): If a component subtype is subject to
1028 -- a per-object constraint, then the component type shall
1029 -- be an Unchecked_Union.
1031 if Has_Per_Object_Constraint (Defining_Identifier (Comp))
1033 not Is_Unchecked_Union (Etype (Subtype_Mark (Sindic)))
1035 Error_Msg_N ("component subtype subject to per-object" &
1036 " constraint must be an Unchecked_Union", Comp);
1040 if Is_Controlled (Typ) then
1042 ("component of unchecked union cannot be controlled", Comp);
1044 elsif Has_Task (Typ) then
1046 ("component of unchecked union cannot have tasks", Comp);
1050 end Check_Component;
1052 ----------------------------------
1053 -- Check_Duplicated_Export_Name --
1054 ----------------------------------
1056 procedure Check_Duplicated_Export_Name (Nam : Node_Id) is
1057 String_Val : constant String_Id := Strval (Nam);
1060 -- We are only interested in the export case, and in the case of
1061 -- generics, it is the instance, not the template, that is the
1062 -- problem (the template will generate a warning in any case).
1064 if not Inside_A_Generic
1065 and then (Prag_Id = Pragma_Export
1067 Prag_Id = Pragma_Export_Procedure
1069 Prag_Id = Pragma_Export_Valued_Procedure
1071 Prag_Id = Pragma_Export_Function)
1073 for J in Externals.First .. Externals.Last loop
1074 if String_Equal (String_Val, Strval (Externals.Table (J))) then
1075 Error_Msg_Sloc := Sloc (Externals.Table (J));
1076 Error_Msg_N ("external name duplicates name given#", Nam);
1081 Externals.Append (Nam);
1083 end Check_Duplicated_Export_Name;
1085 -------------------------
1086 -- Check_First_Subtype --
1087 -------------------------
1089 procedure Check_First_Subtype (Arg : Node_Id) is
1090 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1092 if not Is_First_Subtype (Entity (Argx)) then
1094 ("pragma% cannot apply to subtype", Argx);
1096 end Check_First_Subtype;
1098 ---------------------------
1099 -- Check_In_Main_Program --
1100 ---------------------------
1102 procedure Check_In_Main_Program is
1103 P : constant Node_Id := Parent (N);
1106 -- Must be at in subprogram body
1108 if Nkind (P) /= N_Subprogram_Body then
1109 Error_Pragma ("% pragma allowed only in subprogram");
1111 -- Otherwise warn if obviously not main program
1113 elsif Present (Parameter_Specifications (Specification (P)))
1114 or else not Is_Compilation_Unit (Defining_Entity (P))
1116 Error_Msg_Name_1 := Chars (N);
1118 ("?pragma% is only effective in main program", N);
1120 end Check_In_Main_Program;
1122 ---------------------------------------
1123 -- Check_Interrupt_Or_Attach_Handler --
1124 ---------------------------------------
1126 procedure Check_Interrupt_Or_Attach_Handler is
1127 Arg1_X : constant Node_Id := Expression (Arg1);
1128 Handler_Proc, Proc_Scope : Entity_Id;
1133 if Prag_Id = Pragma_Interrupt_Handler then
1134 Check_Restriction (No_Dynamic_Attachment, N);
1137 Handler_Proc := Find_Unique_Parameterless_Procedure (Arg1_X, Arg1);
1138 Proc_Scope := Scope (Handler_Proc);
1140 -- On AAMP only, a pragma Interrupt_Handler is supported for
1141 -- nonprotected parameterless procedures.
1143 if not AAMP_On_Target
1144 or else Prag_Id = Pragma_Attach_Handler
1146 if Ekind (Proc_Scope) /= E_Protected_Type then
1148 ("argument of pragma% must be protected procedure", Arg1);
1151 if Parent (N) /= Protected_Definition (Parent (Proc_Scope)) then
1152 Error_Pragma ("pragma% must be in protected definition");
1156 if not Is_Library_Level_Entity (Proc_Scope)
1157 or else (AAMP_On_Target
1158 and then not Is_Library_Level_Entity (Handler_Proc))
1161 ("argument for pragma% must be library level entity", Arg1);
1163 end Check_Interrupt_Or_Attach_Handler;
1165 -------------------------------------------
1166 -- Check_Is_In_Decl_Part_Or_Package_Spec --
1167 -------------------------------------------
1169 procedure Check_Is_In_Decl_Part_Or_Package_Spec is
1178 elsif Nkind (P) = N_Handled_Sequence_Of_Statements then
1181 elsif Nkind (P) = N_Package_Specification then
1184 elsif Nkind (P) = N_Block_Statement then
1187 -- Note: the following tests seem a little peculiar, because
1188 -- they test for bodies, but if we were in the statement part
1189 -- of the body, we would already have hit the handled statement
1190 -- sequence, so the only way we get here is by being in the
1191 -- declarative part of the body.
1193 elsif Nkind (P) = N_Subprogram_Body
1194 or else Nkind (P) = N_Package_Body
1195 or else Nkind (P) = N_Task_Body
1196 or else Nkind (P) = N_Entry_Body
1204 Error_Pragma ("pragma% is not in declarative part or package spec");
1205 end Check_Is_In_Decl_Part_Or_Package_Spec;
1207 -------------------------
1208 -- Check_No_Identifier --
1209 -------------------------
1211 procedure Check_No_Identifier (Arg : Node_Id) is
1213 if Chars (Arg) /= No_Name then
1214 Error_Pragma_Arg_Ident
1215 ("pragma% does not permit identifier& here", Arg);
1217 end Check_No_Identifier;
1219 --------------------------
1220 -- Check_No_Identifiers --
1221 --------------------------
1223 procedure Check_No_Identifiers is
1226 if Arg_Count > 0 then
1228 while Present (Arg_Node) loop
1229 Check_No_Identifier (Arg_Node);
1233 end Check_No_Identifiers;
1235 -------------------------------
1236 -- Check_Optional_Identifier --
1237 -------------------------------
1239 procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id) is
1241 if Present (Arg) and then Chars (Arg) /= No_Name then
1242 if Chars (Arg) /= Id then
1243 Error_Msg_Name_1 := Chars (N);
1244 Error_Msg_Name_2 := Id;
1245 Error_Msg_N ("pragma% argument expects identifier%", Arg);
1249 end Check_Optional_Identifier;
1251 procedure Check_Optional_Identifier (Arg : Node_Id; Id : String) is
1253 Name_Buffer (1 .. Id'Length) := Id;
1254 Name_Len := Id'Length;
1255 Check_Optional_Identifier (Arg, Name_Find);
1256 end Check_Optional_Identifier;
1258 -----------------------------
1259 -- Check_Static_Constraint --
1260 -----------------------------
1262 -- Note: for convenience in writing this procedure, in addition to
1263 -- the officially (i.e. by spec) allowed argument which is always
1264 -- a constraint, it also allows ranges and discriminant associations.
1265 -- Above is not clear ???
1267 procedure Check_Static_Constraint (Constr : Node_Id) is
1269 --------------------
1270 -- Require_Static --
1271 --------------------
1273 procedure Require_Static (E : Node_Id);
1274 -- Require given expression to be static expression
1276 procedure Require_Static (E : Node_Id) is
1278 if not Is_OK_Static_Expression (E) then
1279 Flag_Non_Static_Expr
1280 ("non-static constraint not allowed in Unchecked_Union!", E);
1285 -- Start of processing for Check_Static_Constraint
1288 case Nkind (Constr) is
1289 when N_Discriminant_Association =>
1290 Require_Static (Expression (Constr));
1293 Require_Static (Low_Bound (Constr));
1294 Require_Static (High_Bound (Constr));
1296 when N_Attribute_Reference =>
1297 Require_Static (Type_Low_Bound (Etype (Prefix (Constr))));
1298 Require_Static (Type_High_Bound (Etype (Prefix (Constr))));
1300 when N_Range_Constraint =>
1301 Check_Static_Constraint (Range_Expression (Constr));
1303 when N_Index_Or_Discriminant_Constraint =>
1307 IDC := First (Constraints (Constr));
1308 while Present (IDC) loop
1309 Check_Static_Constraint (IDC);
1317 end Check_Static_Constraint;
1319 --------------------------------------
1320 -- Check_Valid_Configuration_Pragma --
1321 --------------------------------------
1323 -- A configuration pragma must appear in the context clause of
1324 -- a compilation unit, at the start of the list (i.e. only other
1325 -- pragmas may precede it).
1327 procedure Check_Valid_Configuration_Pragma is
1329 if not Is_Configuration_Pragma then
1330 Error_Pragma ("incorrect placement for configuration pragma%");
1332 end Check_Valid_Configuration_Pragma;
1334 -------------------------------------
1335 -- Check_Valid_Library_Unit_Pragma --
1336 -------------------------------------
1338 procedure Check_Valid_Library_Unit_Pragma is
1340 Parent_Node : Node_Id;
1341 Unit_Name : Entity_Id;
1342 Unit_Kind : Node_Kind;
1343 Unit_Node : Node_Id;
1344 Sindex : Source_File_Index;
1347 if not Is_List_Member (N) then
1351 Plist := List_Containing (N);
1352 Parent_Node := Parent (Plist);
1354 if Parent_Node = Empty then
1357 -- Case of pragma appearing after a compilation unit. In this
1358 -- case it must have an argument with the corresponding name
1359 -- and must be part of the following pragmas of its parent.
1361 elsif Nkind (Parent_Node) = N_Compilation_Unit_Aux then
1362 if Plist /= Pragmas_After (Parent_Node) then
1365 elsif Arg_Count = 0 then
1367 ("argument required if outside compilation unit");
1370 Check_No_Identifiers;
1371 Check_Arg_Count (1);
1372 Unit_Node := Unit (Parent (Parent_Node));
1373 Unit_Kind := Nkind (Unit_Node);
1375 Analyze (Expression (Arg1));
1377 if Unit_Kind = N_Generic_Subprogram_Declaration
1378 or else Unit_Kind = N_Subprogram_Declaration
1380 Unit_Name := Defining_Entity (Unit_Node);
1382 elsif Unit_Kind in N_Generic_Instantiation then
1383 Unit_Name := Defining_Entity (Unit_Node);
1386 Unit_Name := Cunit_Entity (Current_Sem_Unit);
1389 if Chars (Unit_Name) /=
1390 Chars (Entity (Expression (Arg1)))
1393 ("pragma% argument is not current unit name", Arg1);
1396 if Ekind (Unit_Name) = E_Package
1397 and then Present (Renamed_Entity (Unit_Name))
1399 Error_Pragma ("pragma% not allowed for renamed package");
1403 -- Pragma appears other than after a compilation unit
1406 -- Here we check for the generic instantiation case and also
1407 -- for the case of processing a generic formal package. We
1408 -- detect these cases by noting that the Sloc on the node
1409 -- does not belong to the current compilation unit.
1411 Sindex := Source_Index (Current_Sem_Unit);
1413 if Loc not in Source_First (Sindex) .. Source_Last (Sindex) then
1414 Rewrite (N, Make_Null_Statement (Loc));
1417 -- If before first declaration, the pragma applies to the
1418 -- enclosing unit, and the name if present must be this name.
1420 elsif Is_Before_First_Decl (N, Plist) then
1421 Unit_Node := Unit_Declaration_Node (Current_Scope);
1422 Unit_Kind := Nkind (Unit_Node);
1424 if Nkind (Parent (Unit_Node)) /= N_Compilation_Unit then
1427 elsif Unit_Kind = N_Subprogram_Body
1428 and then not Acts_As_Spec (Unit_Node)
1432 elsif Nkind (Parent_Node) = N_Package_Body then
1435 elsif Nkind (Parent_Node) = N_Package_Specification
1436 and then Plist = Private_Declarations (Parent_Node)
1440 elsif (Nkind (Parent_Node) = N_Generic_Package_Declaration
1441 or else Nkind (Parent_Node) =
1442 N_Generic_Subprogram_Declaration)
1443 and then Plist = Generic_Formal_Declarations (Parent_Node)
1447 elsif Arg_Count > 0 then
1448 Analyze (Expression (Arg1));
1450 if Entity (Expression (Arg1)) /= Current_Scope then
1452 ("name in pragma% must be enclosing unit", Arg1);
1455 -- It is legal to have no argument in this context
1461 -- Error if not before first declaration. This is because a
1462 -- library unit pragma argument must be the name of a library
1463 -- unit (RM 10.1.5(7)), but the only names permitted in this
1464 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1465 -- generic subprogram declarations or generic instantiations.
1469 ("pragma% misplaced, must be before first declaration");
1473 end Check_Valid_Library_Unit_Pragma;
1479 procedure Check_Variant (Variant : Node_Id) is
1480 Clist : constant Node_Id := Component_List (Variant);
1484 if not Is_Non_Empty_List (Component_Items (Clist)) then
1486 ("Unchecked_Union may not have empty component list",
1491 Comp := First (Component_Items (Clist));
1492 while Present (Comp) loop
1493 Check_Component (Comp);
1502 procedure Error_Pragma (Msg : String) is
1504 Error_Msg_Name_1 := Chars (N);
1505 Error_Msg_N (Msg, N);
1509 ----------------------
1510 -- Error_Pragma_Arg --
1511 ----------------------
1513 procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id) is
1515 Error_Msg_Name_1 := Chars (N);
1516 Error_Msg_N (Msg, Get_Pragma_Arg (Arg));
1518 end Error_Pragma_Arg;
1520 procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id) is
1522 Error_Msg_Name_1 := Chars (N);
1523 Error_Msg_N (Msg1, Get_Pragma_Arg (Arg));
1524 Error_Pragma_Arg (Msg2, Arg);
1525 end Error_Pragma_Arg;
1527 ----------------------------
1528 -- Error_Pragma_Arg_Ident --
1529 ----------------------------
1531 procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id) is
1533 Error_Msg_Name_1 := Chars (N);
1534 Error_Msg_N (Msg, Arg);
1536 end Error_Pragma_Arg_Ident;
1538 ------------------------
1539 -- Find_Lib_Unit_Name --
1540 ------------------------
1542 function Find_Lib_Unit_Name return Entity_Id is
1544 -- Return inner compilation unit entity, for case of nested
1545 -- categorization pragmas. This happens in generic unit.
1547 if Nkind (Parent (N)) = N_Package_Specification
1548 and then Defining_Entity (Parent (N)) /= Current_Scope
1550 return Defining_Entity (Parent (N));
1552 return Current_Scope;
1554 end Find_Lib_Unit_Name;
1556 ----------------------------
1557 -- Find_Program_Unit_Name --
1558 ----------------------------
1560 procedure Find_Program_Unit_Name (Id : Node_Id) is
1561 Unit_Name : Entity_Id;
1562 Unit_Kind : Node_Kind;
1563 P : constant Node_Id := Parent (N);
1566 if Nkind (P) = N_Compilation_Unit then
1567 Unit_Kind := Nkind (Unit (P));
1569 if Unit_Kind = N_Subprogram_Declaration
1570 or else Unit_Kind = N_Package_Declaration
1571 or else Unit_Kind in N_Generic_Declaration
1573 Unit_Name := Defining_Entity (Unit (P));
1575 if Chars (Id) = Chars (Unit_Name) then
1576 Set_Entity (Id, Unit_Name);
1577 Set_Etype (Id, Etype (Unit_Name));
1579 Set_Etype (Id, Any_Type);
1581 ("cannot find program unit referenced by pragma%");
1585 Set_Etype (Id, Any_Type);
1586 Error_Pragma ("pragma% inapplicable to this unit");
1592 end Find_Program_Unit_Name;
1594 -----------------------------------------
1595 -- Find_Unique_Parameterless_Procedure --
1596 -----------------------------------------
1598 function Find_Unique_Parameterless_Procedure
1600 Arg : Node_Id) return Entity_Id
1602 Proc : Entity_Id := Empty;
1605 -- The body of this procedure needs some comments ???
1607 if not Is_Entity_Name (Name) then
1609 ("argument of pragma% must be entity name", Arg);
1611 elsif not Is_Overloaded (Name) then
1612 Proc := Entity (Name);
1614 if Ekind (Proc) /= E_Procedure
1615 or else Present (First_Formal (Proc)) then
1617 ("argument of pragma% must be parameterless procedure", Arg);
1622 Found : Boolean := False;
1624 Index : Interp_Index;
1627 Get_First_Interp (Name, Index, It);
1628 while Present (It.Nam) loop
1631 if Ekind (Proc) = E_Procedure
1632 and then No (First_Formal (Proc))
1636 Set_Entity (Name, Proc);
1637 Set_Is_Overloaded (Name, False);
1640 ("ambiguous handler name for pragma% ", Arg);
1644 Get_Next_Interp (Index, It);
1649 ("argument of pragma% must be parameterless procedure",
1652 Proc := Entity (Name);
1658 end Find_Unique_Parameterless_Procedure;
1660 -------------------------
1661 -- Gather_Associations --
1662 -------------------------
1664 procedure Gather_Associations
1666 Args : out Args_List)
1671 -- Initialize all parameters to Empty
1673 for J in Args'Range loop
1677 -- That's all we have to do if there are no argument associations
1679 if No (Pragma_Argument_Associations (N)) then
1683 -- Otherwise first deal with any positional parameters present
1685 Arg := First (Pragma_Argument_Associations (N));
1686 for Index in Args'Range loop
1687 exit when No (Arg) or else Chars (Arg) /= No_Name;
1688 Args (Index) := Expression (Arg);
1692 -- Positional parameters all processed, if any left, then we
1693 -- have too many positional parameters.
1695 if Present (Arg) and then Chars (Arg) = No_Name then
1697 ("too many positional associations for pragma%", Arg);
1700 -- Process named parameters if any are present
1702 while Present (Arg) loop
1703 if Chars (Arg) = No_Name then
1705 ("positional association cannot follow named association",
1709 for Index in Names'Range loop
1710 if Names (Index) = Chars (Arg) then
1711 if Present (Args (Index)) then
1713 ("duplicate argument association for pragma%", Arg);
1715 Args (Index) := Expression (Arg);
1720 if Index = Names'Last then
1721 Error_Msg_Name_1 := Chars (N);
1722 Error_Msg_N ("pragma% does not allow & argument", Arg);
1724 -- Check for possible misspelling
1726 for Index1 in Names'Range loop
1727 if Is_Bad_Spelling_Of
1728 (Get_Name_String (Chars (Arg)),
1729 Get_Name_String (Names (Index1)))
1731 Error_Msg_Name_1 := Names (Index1);
1732 Error_Msg_N ("\possible misspelling of%", Arg);
1744 end Gather_Associations;
1746 --------------------
1747 -- Get_Pragma_Arg --
1748 --------------------
1750 function Get_Pragma_Arg (Arg : Node_Id) return Node_Id is
1752 if Nkind (Arg) = N_Pragma_Argument_Association then
1753 return Expression (Arg);
1763 procedure GNAT_Pragma is
1765 Check_Restriction (No_Implementation_Pragmas, N);
1768 --------------------------
1769 -- Is_Before_First_Decl --
1770 --------------------------
1772 function Is_Before_First_Decl
1773 (Pragma_Node : Node_Id;
1774 Decls : List_Id) return Boolean
1776 Item : Node_Id := First (Decls);
1779 -- Only other pragmas can come before this pragma
1782 if No (Item) or else Nkind (Item) /= N_Pragma then
1785 elsif Item = Pragma_Node then
1791 end Is_Before_First_Decl;
1793 -----------------------------
1794 -- Is_Configuration_Pragma --
1795 -----------------------------
1797 -- A configuration pragma must appear in the context clause of
1798 -- a compilation unit, at the start of the list (i.e. only other
1799 -- pragmas may precede it).
1801 function Is_Configuration_Pragma return Boolean is
1802 Lis : constant List_Id := List_Containing (N);
1803 Par : constant Node_Id := Parent (N);
1807 -- If no parent, then we are in the configuration pragma file,
1808 -- so the placement is definitely appropriate.
1813 -- Otherwise we must be in the context clause of a compilation unit
1814 -- and the only thing allowed before us in the context list is more
1815 -- configuration pragmas.
1817 elsif Nkind (Par) = N_Compilation_Unit
1818 and then Context_Items (Par) = Lis
1825 elsif Nkind (Prg) /= N_Pragma then
1835 end Is_Configuration_Pragma;
1837 --------------------------
1838 -- Is_In_Context_Clause --
1839 --------------------------
1841 function Is_In_Context_Clause return Boolean is
1843 Parent_Node : Node_Id;
1846 if not Is_List_Member (N) then
1850 Plist := List_Containing (N);
1851 Parent_Node := Parent (Plist);
1853 if Parent_Node = Empty
1854 or else Nkind (Parent_Node) /= N_Compilation_Unit
1855 or else Context_Items (Parent_Node) /= Plist
1862 end Is_In_Context_Clause;
1864 ---------------------------------
1865 -- Is_Static_String_Expression --
1866 ---------------------------------
1868 function Is_Static_String_Expression (Arg : Node_Id) return Boolean is
1869 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1872 Analyze_And_Resolve (Argx);
1873 return Is_OK_Static_Expression (Argx)
1874 and then Nkind (Argx) = N_String_Literal;
1875 end Is_Static_String_Expression;
1877 ----------------------
1878 -- Pragma_Misplaced --
1879 ----------------------
1881 procedure Pragma_Misplaced is
1883 Error_Pragma ("incorrect placement of pragma%");
1884 end Pragma_Misplaced;
1886 ------------------------------------
1887 -- Process Atomic_Shared_Volatile --
1888 ------------------------------------
1890 procedure Process_Atomic_Shared_Volatile is
1897 procedure Set_Atomic (E : Entity_Id);
1898 -- Set given type as atomic, and if no explicit alignment was
1899 -- given, set alignment to unknown, since back end knows what
1900 -- the alignment requirements are for atomic arrays. Note that
1901 -- this step is necessary for derived types.
1907 procedure Set_Atomic (E : Entity_Id) is
1911 if not Has_Alignment_Clause (E) then
1912 Set_Alignment (E, Uint_0);
1916 -- Start of processing for Process_Atomic_Shared_Volatile
1919 Check_Ada_83_Warning;
1920 Check_No_Identifiers;
1921 Check_Arg_Count (1);
1922 Check_Arg_Is_Local_Name (Arg1);
1923 E_Id := Expression (Arg1);
1925 if Etype (E_Id) = Any_Type then
1930 D := Declaration_Node (E);
1934 if Rep_Item_Too_Early (E, N)
1936 Rep_Item_Too_Late (E, N)
1940 Check_First_Subtype (Arg1);
1943 if Prag_Id /= Pragma_Volatile then
1945 Set_Atomic (Underlying_Type (E));
1946 Set_Atomic (Base_Type (E));
1949 -- Attribute belongs on the base type. If the
1950 -- view of the type is currently private, it also
1951 -- belongs on the underlying type.
1953 Set_Is_Volatile (Base_Type (E));
1954 Set_Is_Volatile (Underlying_Type (E));
1956 Set_Treat_As_Volatile (E);
1957 Set_Treat_As_Volatile (Underlying_Type (E));
1959 elsif K = N_Object_Declaration
1960 or else (K = N_Component_Declaration
1961 and then Original_Record_Component (E) = E)
1963 if Rep_Item_Too_Late (E, N) then
1967 if Prag_Id /= Pragma_Volatile then
1970 -- If the object declaration has an explicit
1971 -- initialization, a temporary may have to be
1972 -- created to hold the expression, to insure
1973 -- that access to the object remain atomic.
1975 if Nkind (Parent (E)) = N_Object_Declaration
1976 and then Present (Expression (Parent (E)))
1978 Set_Has_Delayed_Freeze (E);
1981 -- An interesting improvement here. If an object of type X
1982 -- is declared atomic, and the type X is not atomic, that's
1983 -- a pity, since it may not have appropraite alignment etc.
1984 -- We can rescue this in the special case where the object
1985 -- and type are in the same unit by just setting the type
1986 -- as atomic, so that the back end will process it as atomic.
1988 Utyp := Underlying_Type (Etype (E));
1991 and then Sloc (E) > No_Location
1992 and then Sloc (Utyp) > No_Location
1994 Get_Source_File_Index (Sloc (E)) =
1995 Get_Source_File_Index (Sloc (Underlying_Type (Etype (E))))
1997 Set_Is_Atomic (Underlying_Type (Etype (E)));
2001 Set_Is_Volatile (E);
2002 Set_Treat_As_Volatile (E);
2006 ("inappropriate entity for pragma%", Arg1);
2008 end Process_Atomic_Shared_Volatile;
2010 -------------------------------------------
2011 -- Process_Compile_Time_Warning_Or_Error --
2012 -------------------------------------------
2014 procedure Process_Compile_Time_Warning_Or_Error is
2015 Arg1x : constant Node_Id := Get_Pragma_Arg (Arg1);
2019 Check_Arg_Count (2);
2020 Check_No_Identifiers;
2021 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
2022 Analyze_And_Resolve (Arg1x, Standard_Boolean);
2024 if Compile_Time_Known_Value (Arg1x) then
2025 if Is_True (Expr_Value (Get_Pragma_Arg (Arg1))) then
2027 Str : constant String_Id :=
2028 Strval (Get_Pragma_Arg (Arg2));
2029 Len : constant Int := String_Length (Str);
2039 -- Loop through segments of message separated by line
2040 -- feeds. We output these segments as separate messages
2041 -- with continuation marks for all but the first.
2044 Error_Msg_Strlen := 0;
2046 -- Loop to copy characters from argument to error
2047 -- message string buffer.
2050 exit when Ptr > Len;
2051 CC := Get_String_Char (Str, Ptr);
2054 -- Ignore wide chars ??? else store character
2056 if In_Character_Range (CC) then
2057 C := Get_Character (CC);
2058 exit when C = ASCII.LF;
2059 Error_Msg_Strlen := Error_Msg_Strlen + 1;
2060 Error_Msg_String (Error_Msg_Strlen) := C;
2064 -- Here with one line ready to go
2066 Error_Msg_Warn := Prag_Id = Pragma_Compile_Time_Warning;
2068 if Cont = False then
2069 Error_Msg_N ("<~", Arg1);
2072 Error_Msg_N ("\<~", Arg1);
2075 exit when Ptr > Len;
2080 end Process_Compile_Time_Warning_Or_Error;
2082 ------------------------
2083 -- Process_Convention --
2084 ------------------------
2086 procedure Process_Convention
2087 (C : out Convention_Id;
2093 Comp_Unit : Unit_Number_Type;
2095 procedure Set_Convention_From_Pragma (E : Entity_Id);
2096 -- Set convention in entity E, and also flag that the entity has a
2097 -- convention pragma. If entity is for a private or incomplete type,
2098 -- also set convention and flag on underlying type. This procedure
2099 -- also deals with the special case of C_Pass_By_Copy convention.
2101 --------------------------------
2102 -- Set_Convention_From_Pragma --
2103 --------------------------------
2105 procedure Set_Convention_From_Pragma (E : Entity_Id) is
2107 -- Ada 2005 (AI-430): Check invalid attempt to change convention
2108 -- for an overridden dispatching operation. Technically this is
2109 -- an amendment and should only be done in Ada 2005 mode.
2110 -- However, this is clearly a mistake, since the problem that is
2111 -- addressed by this AI is that there is a clear gap in the RM!
2113 if Is_Dispatching_Operation (E)
2114 and then Present (Overridden_Operation (E))
2115 and then C /= Convention (Overridden_Operation (E))
2118 ("cannot change convention for " &
2119 "overridden dispatching operation",
2123 -- Set the convention
2125 Set_Convention (E, C);
2126 Set_Has_Convention_Pragma (E);
2128 if Is_Incomplete_Or_Private_Type (E) then
2129 Set_Convention (Underlying_Type (E), C);
2130 Set_Has_Convention_Pragma (Underlying_Type (E), True);
2133 -- A class-wide type should inherit the convention of
2134 -- the specific root type (although this isn't specified
2135 -- clearly by the RM).
2137 if Is_Type (E) and then Present (Class_Wide_Type (E)) then
2138 Set_Convention (Class_Wide_Type (E), C);
2141 -- If the entity is a record type, then check for special case
2142 -- of C_Pass_By_Copy, which is treated the same as C except that
2143 -- the special record flag is set. This convention is also only
2144 -- permitted on record types (see AI95-00131).
2146 if Cname = Name_C_Pass_By_Copy then
2147 if Is_Record_Type (E) then
2148 Set_C_Pass_By_Copy (Base_Type (E));
2149 elsif Is_Incomplete_Or_Private_Type (E)
2150 and then Is_Record_Type (Underlying_Type (E))
2152 Set_C_Pass_By_Copy (Base_Type (Underlying_Type (E)));
2155 ("C_Pass_By_Copy convention allowed only for record type",
2160 -- If the entity is a derived boolean type, check for the
2161 -- special case of convention C, C++, or Fortran, where we
2162 -- consider any nonzero value to represent true.
2164 if Is_Discrete_Type (E)
2165 and then Root_Type (Etype (E)) = Standard_Boolean
2171 C = Convention_Fortran)
2173 Set_Nonzero_Is_True (Base_Type (E));
2175 end Set_Convention_From_Pragma;
2177 -- Start of processing for Process_Convention
2180 Check_At_Least_N_Arguments (2);
2181 Check_Optional_Identifier (Arg1, Name_Convention);
2182 Check_Arg_Is_Identifier (Arg1);
2183 Cname := Chars (Expression (Arg1));
2185 -- C_Pass_By_Copy is treated as a synonym for convention C
2186 -- (this is tested again below to set the critical flag)
2188 if Cname = Name_C_Pass_By_Copy then
2191 -- Otherwise we must have something in the standard convention list
2193 elsif Is_Convention_Name (Cname) then
2194 C := Get_Convention_Id (Chars (Expression (Arg1)));
2196 -- In DEC VMS, it seems that there is an undocumented feature
2197 -- that any unrecognized convention is treated as the default,
2198 -- which for us is convention C. It does not seem so terrible
2199 -- to do this unconditionally, silently in the VMS case, and
2200 -- with a warning in the non-VMS case.
2203 if Warn_On_Export_Import and not OpenVMS_On_Target then
2205 ("?unrecognized convention name, C assumed",
2212 Check_Optional_Identifier (Arg2, Name_Entity);
2213 Check_Arg_Is_Local_Name (Arg2);
2215 Id := Expression (Arg2);
2218 if not Is_Entity_Name (Id) then
2219 Error_Pragma_Arg ("entity name required", Arg2);
2222 if Ekind (Entity (Id)) = E_Enumeration_Literal then
2223 Error_Pragma ("enumeration literal not allowed for pragma%");
2228 -- Go to renamed subprogram if present, since convention applies
2229 -- to the actual renamed entity, not to the renaming entity.
2230 -- If subprogram is inherited, go to parent subprogram.
2232 if Is_Subprogram (E)
2233 and then Present (Alias (E))
2235 if Nkind (Parent (Declaration_Node (E))) =
2236 N_Subprogram_Renaming_Declaration
2240 elsif Nkind (Parent (E)) = N_Full_Type_Declaration
2241 and then Scope (E) = Scope (Alias (E))
2247 -- Check that we are not applying this to a specless body
2249 if Is_Subprogram (E)
2250 and then Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Body
2253 ("pragma% requires separate spec and must come before body");
2256 -- Check that we are not applying this to a named constant
2258 if Ekind (E) = E_Named_Integer
2260 Ekind (E) = E_Named_Real
2262 Error_Msg_Name_1 := Chars (N);
2264 ("cannot apply pragma% to named constant!",
2265 Get_Pragma_Arg (Arg2));
2267 ("\supply appropriate type for&!", Arg2);
2270 if Etype (E) = Any_Type
2271 or else Rep_Item_Too_Early (E, N)
2275 E := Underlying_Type (E);
2278 if Rep_Item_Too_Late (E, N) then
2282 if Has_Convention_Pragma (E) then
2284 ("at most one Convention/Export/Import pragma is allowed", Arg2);
2286 elsif Convention (E) = Convention_Protected
2287 or else Ekind (Scope (E)) = E_Protected_Type
2290 ("a protected operation cannot be given a different convention",
2294 -- For Intrinsic, a subprogram is required
2296 if C = Convention_Intrinsic
2297 and then not Is_Subprogram (E)
2298 and then not Is_Generic_Subprogram (E)
2301 ("second argument of pragma% must be a subprogram", Arg2);
2304 -- For Stdcall, a subprogram, variable or subprogram type is required
2306 if C = Convention_Stdcall
2307 and then not Is_Subprogram (E)
2308 and then not Is_Generic_Subprogram (E)
2309 and then Ekind (E) /= E_Variable
2312 and then Ekind (Designated_Type (E)) = E_Subprogram_Type)
2315 ("second argument of pragma% must be subprogram (type)",
2319 if not Is_Subprogram (E)
2320 and then not Is_Generic_Subprogram (E)
2322 Set_Convention_From_Pragma (E);
2326 Check_First_Subtype (Arg2);
2327 Set_Convention_From_Pragma (Base_Type (E));
2329 -- For subprograms, we must set the convention on the
2330 -- internally generated directly designated type as well.
2332 if Ekind (E) = E_Access_Subprogram_Type then
2333 Set_Convention_From_Pragma (Directly_Designated_Type (E));
2337 -- For the subprogram case, set proper convention for all homonyms
2338 -- in same scope and the same declarative part, i.e. the same
2339 -- compilation unit.
2342 Comp_Unit := Get_Source_Unit (E);
2343 Set_Convention_From_Pragma (E);
2345 -- Treat a pragma Import as an implicit body, for GPS use
2347 if Prag_Id = Pragma_Import then
2348 Generate_Reference (E, Id, 'b');
2354 exit when No (E1) or else Scope (E1) /= Current_Scope;
2356 -- Note: below we are missing a check for Rep_Item_Too_Late.
2357 -- That is deliberate, we cannot chain the rep item on more
2358 -- than one Rep_Item chain, to be fixed later ???
2360 if Comes_From_Source (E1)
2361 and then Comp_Unit = Get_Source_Unit (E1)
2362 and then Nkind (Original_Node (Parent (E1))) /=
2363 N_Full_Type_Declaration
2365 Set_Convention_From_Pragma (E1);
2367 if Prag_Id = Pragma_Import then
2368 Generate_Reference (E, Id, 'b');
2373 end Process_Convention;
2375 -----------------------------------------------------
2376 -- Process_Extended_Import_Export_Exception_Pragma --
2377 -----------------------------------------------------
2379 procedure Process_Extended_Import_Export_Exception_Pragma
2380 (Arg_Internal : Node_Id;
2381 Arg_External : Node_Id;
2391 if not OpenVMS_On_Target then
2393 ("?pragma% ignored (applies only to Open'V'M'S)");
2396 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2397 Def_Id := Entity (Arg_Internal);
2399 if Ekind (Def_Id) /= E_Exception then
2401 ("pragma% must refer to declared exception", Arg_Internal);
2404 Set_Extended_Import_Export_External_Name (Def_Id, Arg_External);
2406 if Present (Arg_Form) then
2407 Check_Arg_Is_One_Of (Arg_Form, Name_Ada, Name_VMS);
2410 if Present (Arg_Form)
2411 and then Chars (Arg_Form) = Name_Ada
2415 Set_Is_VMS_Exception (Def_Id);
2416 Set_Exception_Code (Def_Id, No_Uint);
2419 if Present (Arg_Code) then
2420 if not Is_VMS_Exception (Def_Id) then
2422 ("Code option for pragma% not allowed for Ada case",
2426 Check_Arg_Is_Static_Expression (Arg_Code, Any_Integer);
2427 Code_Val := Expr_Value (Arg_Code);
2429 if not UI_Is_In_Int_Range (Code_Val) then
2431 ("Code option for pragma% must be in 32-bit range",
2435 Set_Exception_Code (Def_Id, Code_Val);
2438 end Process_Extended_Import_Export_Exception_Pragma;
2440 -------------------------------------------------
2441 -- Process_Extended_Import_Export_Internal_Arg --
2442 -------------------------------------------------
2444 procedure Process_Extended_Import_Export_Internal_Arg
2445 (Arg_Internal : Node_Id := Empty)
2450 if No (Arg_Internal) then
2451 Error_Pragma ("Internal parameter required for pragma%");
2454 if Nkind (Arg_Internal) = N_Identifier then
2457 elsif Nkind (Arg_Internal) = N_Operator_Symbol
2458 and then (Prag_Id = Pragma_Import_Function
2460 Prag_Id = Pragma_Export_Function)
2466 ("wrong form for Internal parameter for pragma%", Arg_Internal);
2469 Check_Arg_Is_Local_Name (Arg_Internal);
2470 end Process_Extended_Import_Export_Internal_Arg;
2472 --------------------------------------------------
2473 -- Process_Extended_Import_Export_Object_Pragma --
2474 --------------------------------------------------
2476 procedure Process_Extended_Import_Export_Object_Pragma
2477 (Arg_Internal : Node_Id;
2478 Arg_External : Node_Id;
2484 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2485 Def_Id := Entity (Arg_Internal);
2487 if Ekind (Def_Id) /= E_Constant
2488 and then Ekind (Def_Id) /= E_Variable
2491 ("pragma% must designate an object", Arg_Internal);
2494 if Has_Rep_Pragma (Def_Id, Name_Common_Object)
2496 Has_Rep_Pragma (Def_Id, Name_Psect_Object)
2499 ("previous Common/Psect_Object applies, pragma % not permitted",
2503 if Rep_Item_Too_Late (Def_Id, N) then
2507 Set_Extended_Import_Export_External_Name (Def_Id, Arg_External);
2509 if Present (Arg_Size) then
2510 Check_Arg_Is_External_Name (Arg_Size);
2513 -- Export_Object case
2515 if Prag_Id = Pragma_Export_Object then
2516 if not Is_Library_Level_Entity (Def_Id) then
2518 ("argument for pragma% must be library level entity",
2522 if Ekind (Current_Scope) = E_Generic_Package then
2523 Error_Pragma ("pragma& cannot appear in a generic unit");
2526 if not Size_Known_At_Compile_Time (Etype (Def_Id)) then
2528 ("exported object must have compile time known size",
2532 if Warn_On_Export_Import and then Is_Exported (Def_Id) then
2534 ("?duplicate Export_Object pragma", N);
2536 Set_Exported (Def_Id, Arg_Internal);
2539 -- Import_Object case
2542 if Is_Concurrent_Type (Etype (Def_Id)) then
2544 ("cannot use pragma% for task/protected object",
2548 if Ekind (Def_Id) = E_Constant then
2550 ("cannot import a constant", Arg_Internal);
2553 if Warn_On_Export_Import
2554 and then Has_Discriminants (Etype (Def_Id))
2557 ("imported value must be initialized?", Arg_Internal);
2560 if Warn_On_Export_Import
2561 and then Is_Access_Type (Etype (Def_Id))
2564 ("cannot import object of an access type?", Arg_Internal);
2567 if Warn_On_Export_Import
2568 and then Is_Imported (Def_Id)
2571 ("?duplicate Import_Object pragma", N);
2573 -- Check for explicit initialization present. Note that an
2574 -- initialization that generated by the code generator, e.g.
2575 -- for an access type, does not count here.
2577 elsif Present (Expression (Parent (Def_Id)))
2580 (Original_Node (Expression (Parent (Def_Id))))
2582 Error_Msg_Sloc := Sloc (Def_Id);
2584 ("no initialization allowed for declaration of& #",
2585 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2588 Set_Imported (Def_Id);
2589 Note_Possible_Modification (Arg_Internal);
2592 end Process_Extended_Import_Export_Object_Pragma;
2594 ------------------------------------------------------
2595 -- Process_Extended_Import_Export_Subprogram_Pragma --
2596 ------------------------------------------------------
2598 procedure Process_Extended_Import_Export_Subprogram_Pragma
2599 (Arg_Internal : Node_Id;
2600 Arg_External : Node_Id;
2601 Arg_Parameter_Types : Node_Id;
2602 Arg_Result_Type : Node_Id := Empty;
2603 Arg_Mechanism : Node_Id;
2604 Arg_Result_Mechanism : Node_Id := Empty;
2605 Arg_First_Optional_Parameter : Node_Id := Empty)
2611 Ambiguous : Boolean;
2615 function Same_Base_Type
2617 Formal : Entity_Id) return Boolean;
2618 -- Determines if Ptype references the type of Formal. Note that
2619 -- only the base types need to match according to the spec. Ptype
2620 -- here is the argument from the pragma, which is either a type
2621 -- name, or an access attribute.
2623 --------------------
2624 -- Same_Base_Type --
2625 --------------------
2627 function Same_Base_Type
2629 Formal : Entity_Id) return Boolean
2631 Ftyp : constant Entity_Id := Base_Type (Etype (Formal));
2635 -- Case where pragma argument is typ'Access
2637 if Nkind (Ptype) = N_Attribute_Reference
2638 and then Attribute_Name (Ptype) = Name_Access
2640 Pref := Prefix (Ptype);
2643 if not Is_Entity_Name (Pref)
2644 or else Entity (Pref) = Any_Type
2649 -- We have a match if the corresponding argument is of an
2650 -- anonymous access type, and its designicated type matches
2651 -- the type of the prefix of the access attribute
2653 return Ekind (Ftyp) = E_Anonymous_Access_Type
2654 and then Base_Type (Entity (Pref)) =
2655 Base_Type (Etype (Designated_Type (Ftyp)));
2657 -- Case where pragma argument is a type name
2662 if not Is_Entity_Name (Ptype)
2663 or else Entity (Ptype) = Any_Type
2668 -- We have a match if the corresponding argument is of
2669 -- the type given in the pragma (comparing base types)
2671 return Base_Type (Entity (Ptype)) = Ftyp;
2675 -- Start of processing for
2676 -- Process_Extended_Import_Export_Subprogram_Pragma
2679 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2683 -- Loop through homonyms (overloadings) of the entity
2685 Hom_Id := Entity (Arg_Internal);
2686 while Present (Hom_Id) loop
2687 Def_Id := Get_Base_Subprogram (Hom_Id);
2689 -- We need a subprogram in the current scope
2691 if not Is_Subprogram (Def_Id)
2692 or else Scope (Def_Id) /= Current_Scope
2699 -- Pragma cannot apply to subprogram body
2701 if Is_Subprogram (Def_Id)
2704 (Declaration_Node (Def_Id))) = N_Subprogram_Body
2707 ("pragma% requires separate spec"
2708 & " and must come before body");
2711 -- Test result type if given, note that the result type
2712 -- parameter can only be present for the function cases.
2714 if Present (Arg_Result_Type)
2715 and then not Same_Base_Type (Arg_Result_Type, Def_Id)
2719 elsif Etype (Def_Id) /= Standard_Void_Type
2721 (Chars (N) = Name_Export_Procedure
2722 or else Chars (N) = Name_Import_Procedure)
2726 -- Test parameter types if given. Note that this parameter
2727 -- has not been analyzed (and must not be, since it is
2728 -- semantic nonsense), so we get it as the parser left it.
2730 elsif Present (Arg_Parameter_Types) then
2731 Check_Matching_Types : declare
2736 Formal := First_Formal (Def_Id);
2738 if Nkind (Arg_Parameter_Types) = N_Null then
2739 if Present (Formal) then
2743 -- A list of one type, e.g. (List) is parsed as
2744 -- a parenthesized expression.
2746 elsif Nkind (Arg_Parameter_Types) /= N_Aggregate
2747 and then Paren_Count (Arg_Parameter_Types) = 1
2750 or else Present (Next_Formal (Formal))
2755 Same_Base_Type (Arg_Parameter_Types, Formal);
2758 -- A list of more than one type is parsed as a aggregate
2760 elsif Nkind (Arg_Parameter_Types) = N_Aggregate
2761 and then Paren_Count (Arg_Parameter_Types) = 0
2763 Ptype := First (Expressions (Arg_Parameter_Types));
2764 while Present (Ptype) or else Present (Formal) loop
2767 or else not Same_Base_Type (Ptype, Formal)
2772 Next_Formal (Formal);
2777 -- Anything else is of the wrong form
2781 ("wrong form for Parameter_Types parameter",
2782 Arg_Parameter_Types);
2784 end Check_Matching_Types;
2787 -- Match is now False if the entry we found did not match
2788 -- either a supplied Parameter_Types or Result_Types argument
2794 -- Ambiguous case, the flag Ambiguous shows if we already
2795 -- detected this and output the initial messages.
2798 if not Ambiguous then
2800 Error_Msg_Name_1 := Chars (N);
2802 ("pragma% does not uniquely identify subprogram!",
2804 Error_Msg_Sloc := Sloc (Ent);
2805 Error_Msg_N ("matching subprogram #!", N);
2809 Error_Msg_Sloc := Sloc (Def_Id);
2810 Error_Msg_N ("matching subprogram #!", N);
2815 Hom_Id := Homonym (Hom_Id);
2818 -- See if we found an entry
2821 if not Ambiguous then
2822 if Is_Generic_Subprogram (Entity (Arg_Internal)) then
2824 ("pragma% cannot be given for generic subprogram");
2828 ("pragma% does not identify local subprogram");
2835 -- Import pragmas must be be for imported entities
2837 if Prag_Id = Pragma_Import_Function
2839 Prag_Id = Pragma_Import_Procedure
2841 Prag_Id = Pragma_Import_Valued_Procedure
2843 if not Is_Imported (Ent) then
2845 ("pragma Import or Interface must precede pragma%");
2848 -- Here we have the Export case which can set the entity as exported
2850 -- But does not do so if the specified external name is null,
2851 -- since that is taken as a signal in DEC Ada 83 (with which
2852 -- we want to be compatible) to request no external name.
2854 elsif Nkind (Arg_External) = N_String_Literal
2855 and then String_Length (Strval (Arg_External)) = 0
2859 -- In all other cases, set entit as exported
2862 Set_Exported (Ent, Arg_Internal);
2865 -- Special processing for Valued_Procedure cases
2867 if Prag_Id = Pragma_Import_Valued_Procedure
2869 Prag_Id = Pragma_Export_Valued_Procedure
2871 Formal := First_Formal (Ent);
2875 ("at least one parameter required for pragma%");
2877 elsif Ekind (Formal) /= E_Out_Parameter then
2879 ("first parameter must have mode out for pragma%");
2882 Set_Is_Valued_Procedure (Ent);
2886 Set_Extended_Import_Export_External_Name (Ent, Arg_External);
2888 -- Process Result_Mechanism argument if present. We have already
2889 -- checked that this is only allowed for the function case.
2891 if Present (Arg_Result_Mechanism) then
2892 Set_Mechanism_Value (Ent, Arg_Result_Mechanism);
2895 -- Process Mechanism parameter if present. Note that this parameter
2896 -- is not analyzed, and must not be analyzed since it is semantic
2897 -- nonsense, so we get it in exactly as the parser left it.
2899 if Present (Arg_Mechanism) then
2907 -- A single mechanism association without a formal parameter
2908 -- name is parsed as a parenthesized expression. All other
2909 -- cases are parsed as aggregates, so we rewrite the single
2910 -- parameter case as an aggregate for consistency.
2912 if Nkind (Arg_Mechanism) /= N_Aggregate
2913 and then Paren_Count (Arg_Mechanism) = 1
2915 Rewrite (Arg_Mechanism,
2916 Make_Aggregate (Sloc (Arg_Mechanism),
2917 Expressions => New_List (
2918 Relocate_Node (Arg_Mechanism))));
2921 -- Case of only mechanism name given, applies to all formals
2923 if Nkind (Arg_Mechanism) /= N_Aggregate then
2924 Formal := First_Formal (Ent);
2925 while Present (Formal) loop
2926 Set_Mechanism_Value (Formal, Arg_Mechanism);
2927 Next_Formal (Formal);
2930 -- Case of list of mechanism associations given
2933 if Null_Record_Present (Arg_Mechanism) then
2935 ("inappropriate form for Mechanism parameter",
2939 -- Deal with positional ones first
2941 Formal := First_Formal (Ent);
2943 if Present (Expressions (Arg_Mechanism)) then
2944 Mname := First (Expressions (Arg_Mechanism));
2946 while Present (Mname) loop
2949 ("too many mechanism associations", Mname);
2952 Set_Mechanism_Value (Formal, Mname);
2953 Next_Formal (Formal);
2958 -- Deal with named entries
2960 if Present (Component_Associations (Arg_Mechanism)) then
2961 Massoc := First (Component_Associations (Arg_Mechanism));
2963 while Present (Massoc) loop
2964 Choice := First (Choices (Massoc));
2966 if Nkind (Choice) /= N_Identifier
2967 or else Present (Next (Choice))
2970 ("incorrect form for mechanism association",
2974 Formal := First_Formal (Ent);
2978 ("parameter name & not present", Choice);
2981 if Chars (Choice) = Chars (Formal) then
2983 (Formal, Expression (Massoc));
2987 Next_Formal (Formal);
2997 -- Process First_Optional_Parameter argument if present. We have
2998 -- already checked that this is only allowed for the Import case.
3000 if Present (Arg_First_Optional_Parameter) then
3001 if Nkind (Arg_First_Optional_Parameter) /= N_Identifier then
3003 ("first optional parameter must be formal parameter name",
3004 Arg_First_Optional_Parameter);
3007 Formal := First_Formal (Ent);
3011 ("specified formal parameter& not found",
3012 Arg_First_Optional_Parameter);
3015 exit when Chars (Formal) =
3016 Chars (Arg_First_Optional_Parameter);
3018 Next_Formal (Formal);
3021 Set_First_Optional_Parameter (Ent, Formal);
3023 -- Check specified and all remaining formals have right form
3025 while Present (Formal) loop
3026 if Ekind (Formal) /= E_In_Parameter then
3028 ("optional formal& is not of mode in!",
3029 Arg_First_Optional_Parameter, Formal);
3032 Dval := Default_Value (Formal);
3036 ("optional formal& does not have default value!",
3037 Arg_First_Optional_Parameter, Formal);
3039 elsif Compile_Time_Known_Value_Or_Aggr (Dval) then
3044 ("default value for optional formal& is non-static!",
3045 Arg_First_Optional_Parameter, Formal);
3049 Set_Is_Optional_Parameter (Formal);
3050 Next_Formal (Formal);
3053 end Process_Extended_Import_Export_Subprogram_Pragma;
3055 --------------------------
3056 -- Process_Generic_List --
3057 --------------------------
3059 procedure Process_Generic_List is
3065 Check_No_Identifiers;
3066 Check_At_Least_N_Arguments (1);
3069 while Present (Arg) loop
3070 Exp := Expression (Arg);
3073 if not Is_Entity_Name (Exp)
3075 (not Is_Generic_Instance (Entity (Exp))
3077 not Is_Generic_Unit (Entity (Exp)))
3080 ("pragma% argument must be name of generic unit/instance",
3086 end Process_Generic_List;
3088 ---------------------------------
3089 -- Process_Import_Or_Interface --
3090 ---------------------------------
3092 procedure Process_Import_Or_Interface is
3098 Process_Convention (C, Def_Id);
3099 Kill_Size_Check_Code (Def_Id);
3100 Note_Possible_Modification (Expression (Arg2));
3102 if Ekind (Def_Id) = E_Variable
3104 Ekind (Def_Id) = E_Constant
3106 -- We do not permit Import to apply to a renaming declaration
3108 if Present (Renamed_Object (Def_Id)) then
3110 ("pragma% not allowed for object renaming", Arg2);
3112 -- User initialization is not allowed for imported object, but
3113 -- the object declaration may contain a default initialization,
3114 -- that will be discarded. Note that an explicit initialization
3115 -- only counts if it comes from source, otherwise it is simply
3116 -- the code generator making an implicit initialization explicit.
3118 elsif Present (Expression (Parent (Def_Id)))
3119 and then Comes_From_Source (Expression (Parent (Def_Id)))
3121 Error_Msg_Sloc := Sloc (Def_Id);
3123 ("no initialization allowed for declaration of& #",
3124 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
3128 Set_Imported (Def_Id);
3129 Process_Interface_Name (Def_Id, Arg3, Arg4);
3131 -- Note that we do not set Is_Public here. That's because we
3132 -- only want to set if if there is no address clause, and we
3133 -- don't know that yet, so we delay that processing till
3136 -- pragma Import completes deferred constants
3138 if Ekind (Def_Id) = E_Constant then
3139 Set_Has_Completion (Def_Id);
3142 -- It is not possible to import a constant of an unconstrained
3143 -- array type (e.g. string) because there is no simple way to
3144 -- write a meaningful subtype for it.
3146 if Is_Array_Type (Etype (Def_Id))
3147 and then not Is_Constrained (Etype (Def_Id))
3150 ("imported constant& must have a constrained subtype",
3155 elsif Is_Subprogram (Def_Id)
3156 or else Is_Generic_Subprogram (Def_Id)
3158 -- If the name is overloaded, pragma applies to all of the
3159 -- denoted entities in the same declarative part.
3162 while Present (Hom_Id) loop
3163 Def_Id := Get_Base_Subprogram (Hom_Id);
3165 -- Ignore inherited subprograms because the pragma will
3166 -- apply to the parent operation, which is the one called.
3168 if Is_Overloadable (Def_Id)
3169 and then Present (Alias (Def_Id))
3173 -- If it is not a subprogram, it must be in an outer
3174 -- scope and pragma does not apply.
3176 elsif not Is_Subprogram (Def_Id)
3177 and then not Is_Generic_Subprogram (Def_Id)
3181 -- Verify that the homonym is in the same declarative
3182 -- part (not just the same scope).
3184 elsif Parent (Unit_Declaration_Node (Def_Id)) /= Parent (N)
3185 and then Nkind (Parent (N)) /= N_Compilation_Unit_Aux
3190 Set_Imported (Def_Id);
3192 -- Special processing for Convention_Intrinsic
3194 if C = Convention_Intrinsic then
3196 -- Link_Name argument not allowed for intrinsic
3199 and then Chars (Arg3) = Name_Link_Name
3204 if Present (Arg4) then
3206 ("Link_Name argument not allowed for " &
3211 Set_Is_Intrinsic_Subprogram (Def_Id);
3213 -- If no external name is present, then check that
3214 -- this is a valid intrinsic subprogram. If an external
3215 -- name is present, then this is handled by the back end.
3218 Check_Intrinsic_Subprogram (Def_Id, Expression (Arg2));
3222 -- All interfaced procedures need an external symbol
3223 -- created for them since they are always referenced
3224 -- from another object file.
3226 Set_Is_Public (Def_Id);
3228 -- Verify that the subprogram does not have a completion
3229 -- through a renaming declaration. For other completions
3230 -- the pragma appears as a too late representation.
3233 Decl : constant Node_Id := Unit_Declaration_Node (Def_Id);
3237 and then Nkind (Decl) = N_Subprogram_Declaration
3238 and then Present (Corresponding_Body (Decl))
3241 (Unit_Declaration_Node
3242 (Corresponding_Body (Decl))) =
3243 N_Subprogram_Renaming_Declaration
3245 Error_Msg_Sloc := Sloc (Def_Id);
3246 Error_Msg_NE ("cannot import&#," &
3247 " already completed by a renaming",
3252 Set_Has_Completion (Def_Id);
3253 Process_Interface_Name (Def_Id, Arg3, Arg4);
3256 if Is_Compilation_Unit (Hom_Id) then
3258 -- Its possible homonyms are not affected by the pragma.
3259 -- Such homonyms might be present in the context of other
3260 -- units being compiled.
3265 Hom_Id := Homonym (Hom_Id);
3269 -- When the convention is Java or CIL, we also allow Import to be
3270 -- given for packages, generic packages, exceptions, and record
3273 elsif (C = Convention_Java or else C = Convention_CIL)
3275 (Ekind (Def_Id) = E_Package
3276 or else Ekind (Def_Id) = E_Generic_Package
3277 or else Ekind (Def_Id) = E_Exception
3278 or else Nkind (Parent (Def_Id)) = N_Component_Declaration)
3280 Set_Imported (Def_Id);
3281 Set_Is_Public (Def_Id);
3282 Process_Interface_Name (Def_Id, Arg3, Arg4);
3284 -- Import a CPP class
3286 elsif Is_Record_Type (Def_Id)
3287 and then C = Convention_CPP
3289 if not Is_Tagged_Type (Def_Id) then
3290 Error_Msg_Sloc := Sloc (Def_Id);
3291 Error_Pragma_Arg ("imported 'C'P'P type must be tagged", Arg2);
3294 -- Types treated as CPP classes are treated as limited, but we
3295 -- don't require them to be declared this way. A warning is
3296 -- issued to encourage the user to declare them as limited.
3297 -- This is not an error, for compatibility reasons, because
3298 -- these types have been supported this way for some time.
3300 if not Is_Limited_Type (Def_Id) then
3302 ("imported 'C'P'P type should be " &
3303 "explicitly declared limited?",
3304 Get_Pragma_Arg (Arg2));
3306 ("\type will be considered limited",
3307 Get_Pragma_Arg (Arg2));
3310 Set_Is_CPP_Class (Def_Id);
3311 Set_Is_Limited_Record (Def_Id);
3316 ("second argument of pragma% must be object or subprogram",
3320 -- If this pragma applies to a compilation unit, then the unit,
3321 -- which is a subprogram, does not require (or allow) a body.
3322 -- We also do not need to elaborate imported procedures.
3324 if Nkind (Parent (N)) = N_Compilation_Unit_Aux then
3326 Cunit : constant Node_Id := Parent (Parent (N));
3328 Set_Body_Required (Cunit, False);
3331 end Process_Import_Or_Interface;
3333 --------------------
3334 -- Process_Inline --
3335 --------------------
3337 procedure Process_Inline (Active : Boolean) is
3343 Effective : Boolean := False;
3345 procedure Make_Inline (Subp : Entity_Id);
3346 -- Subp is the defining unit name of the subprogram
3347 -- declaration. Set the flag, as well as the flag in the
3348 -- corresponding body, if there is one present.
3350 procedure Set_Inline_Flags (Subp : Entity_Id);
3351 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp
3353 function Inlining_Not_Possible (Subp : Entity_Id) return Boolean;
3354 -- Returns True if it can be determined at this stage that inlining
3355 -- is not possible, for examle if the body is available and contains
3356 -- exception handlers, we prevent inlining, since otherwise we can
3357 -- get undefined symbols at link time. This function also emits a
3358 -- warning if front-end inlining is enabled and the pragma appears
3360 -- ??? is business with link symbols still valid, or does it relate
3361 -- to front end ZCX which is being phased out ???
3363 ---------------------------
3364 -- Inlining_Not_Possible --
3365 ---------------------------
3367 function Inlining_Not_Possible (Subp : Entity_Id) return Boolean is
3368 Decl : constant Node_Id := Unit_Declaration_Node (Subp);
3372 if Nkind (Decl) = N_Subprogram_Body then
3373 Stats := Handled_Statement_Sequence (Decl);
3374 return Present (Exception_Handlers (Stats))
3375 or else Present (At_End_Proc (Stats));
3377 elsif Nkind (Decl) = N_Subprogram_Declaration
3378 and then Present (Corresponding_Body (Decl))
3380 if Front_End_Inlining
3381 and then Analyzed (Corresponding_Body (Decl))
3383 Error_Msg_N ("pragma appears too late, ignored?", N);
3386 -- If the subprogram is a renaming as body, the body is
3387 -- just a call to the renamed subprogram, and inlining is
3388 -- trivially possible.
3391 Nkind (Unit_Declaration_Node (Corresponding_Body (Decl))) =
3392 N_Subprogram_Renaming_Declaration
3398 Handled_Statement_Sequence
3399 (Unit_Declaration_Node (Corresponding_Body (Decl)));
3402 Present (Exception_Handlers (Stats))
3403 or else Present (At_End_Proc (Stats));
3407 -- If body is not available, assume the best, the check is
3408 -- performed again when compiling enclosing package bodies.
3412 end Inlining_Not_Possible;
3418 procedure Make_Inline (Subp : Entity_Id) is
3419 Kind : constant Entity_Kind := Ekind (Subp);
3420 Inner_Subp : Entity_Id := Subp;
3423 if Etype (Subp) = Any_Type then
3426 -- If inlining is not possible, for now do not treat as an error
3428 elsif Inlining_Not_Possible (Subp) then
3432 -- Here we have a candidate for inlining, but we must exclude
3433 -- derived operations. Otherwise we will end up trying to
3434 -- inline a phantom declaration, and the result would be to
3435 -- drag in a body which has no direct inlining associated with
3436 -- it. That would not only be inefficient but would also result
3437 -- in the backend doing cross-unit inlining in cases where it
3438 -- was definitely inappropriate to do so.
3440 -- However, a simple Comes_From_Source test is insufficient,
3441 -- since we do want to allow inlining of generic instances,
3442 -- which also do not come from source. Predefined operators do
3443 -- not come from source but are not inlineable either.
3445 elsif not Comes_From_Source (Subp)
3446 and then not Is_Generic_Instance (Subp)
3447 and then Scope (Subp) /= Standard_Standard
3452 -- The referenced entity must either be the enclosing entity,
3453 -- or an entity declared within the current open scope.
3455 elsif Present (Scope (Subp))
3456 and then Scope (Subp) /= Current_Scope
3457 and then Subp /= Current_Scope
3460 ("argument of% must be entity in current scope", Assoc);
3464 -- Processing for procedure, operator or function.
3465 -- If subprogram is aliased (as for an instance) indicate
3466 -- that the renamed entity (if declared in the same unit)
3469 if Is_Subprogram (Subp) then
3470 while Present (Alias (Inner_Subp)) loop
3471 Inner_Subp := Alias (Inner_Subp);
3474 if In_Same_Source_Unit (Subp, Inner_Subp) then
3475 Set_Inline_Flags (Inner_Subp);
3477 Decl := Parent (Parent (Inner_Subp));
3479 if Nkind (Decl) = N_Subprogram_Declaration
3480 and then Present (Corresponding_Body (Decl))
3482 Set_Inline_Flags (Corresponding_Body (Decl));
3488 -- For a generic subprogram set flag as well, for use at
3489 -- the point of instantiation, to determine whether the
3490 -- body should be generated.
3492 elsif Is_Generic_Subprogram (Subp) then
3493 Set_Inline_Flags (Subp);
3496 -- Literals are by definition inlined
3498 elsif Kind = E_Enumeration_Literal then
3501 -- Anything else is an error
3505 ("expect subprogram name for pragma%", Assoc);
3509 ----------------------
3510 -- Set_Inline_Flags --
3511 ----------------------
3513 procedure Set_Inline_Flags (Subp : Entity_Id) is
3516 Set_Is_Inlined (Subp, True);
3519 if not Has_Pragma_Inline (Subp) then
3520 Set_Has_Pragma_Inline (Subp);
3521 Set_Next_Rep_Item (N, First_Rep_Item (Subp));
3522 Set_First_Rep_Item (Subp, N);
3525 end Set_Inline_Flags;
3527 -- Start of processing for Process_Inline
3530 Check_No_Identifiers;
3531 Check_At_Least_N_Arguments (1);
3534 Inline_Processing_Required := True;
3538 while Present (Assoc) loop
3539 Subp_Id := Expression (Assoc);
3543 if Is_Entity_Name (Subp_Id) then
3544 Subp := Entity (Subp_Id);
3546 if Subp = Any_Id then
3548 -- If previous error, avoid cascaded errors
3556 while Present (Homonym (Subp))
3557 and then Scope (Homonym (Subp)) = Current_Scope
3559 Make_Inline (Homonym (Subp));
3560 Subp := Homonym (Subp);
3567 ("inappropriate argument for pragma%", Assoc);
3570 and then Warn_On_Redundant_Constructs
3572 if Inlining_Not_Possible (Subp) then
3574 ("pragma Inline for& is ignored?", N, Entity (Subp_Id));
3577 ("pragma Inline for& is redundant?", N, Entity (Subp_Id));
3585 ----------------------------
3586 -- Process_Interface_Name --
3587 ----------------------------
3589 procedure Process_Interface_Name
3590 (Subprogram_Def : Entity_Id;
3596 String_Val : String_Id;
3598 procedure Check_Form_Of_Interface_Name (SN : Node_Id);
3599 -- SN is a string literal node for an interface name. This routine
3600 -- performs some minimal checks that the name is reasonable. In
3601 -- particular that no spaces or other obviously incorrect characters
3602 -- appear. This is only a warning, since any characters are allowed.
3604 ----------------------------------
3605 -- Check_Form_Of_Interface_Name --
3606 ----------------------------------
3608 procedure Check_Form_Of_Interface_Name (SN : Node_Id) is
3609 S : constant String_Id := Strval (Expr_Value_S (SN));
3610 SL : constant Nat := String_Length (S);
3615 Error_Msg_N ("interface name cannot be null string", SN);
3618 for J in 1 .. SL loop
3619 C := Get_String_Char (S, J);
3621 if Warn_On_Export_Import
3623 (not In_Character_Range (C)
3624 or else (Get_Character (C) = ' '
3625 and then VM_Target /= CLI_Target)
3626 or else Get_Character (C) = ',')
3629 ("?interface name contains illegal character", SN);
3632 end Check_Form_Of_Interface_Name;
3634 -- Start of processing for Process_Interface_Name
3637 if No (Link_Arg) then
3638 if No (Ext_Arg) then
3639 if VM_Target = CLI_Target
3640 and then Ekind (Subprogram_Def) = E_Package
3641 and then Nkind (Parent (Subprogram_Def)) =
3642 N_Package_Specification
3643 and then Present (Generic_Parent (Parent (Subprogram_Def)))
3648 (Generic_Parent (Parent (Subprogram_Def))));
3653 elsif Chars (Ext_Arg) = Name_Link_Name then
3655 Link_Nam := Expression (Ext_Arg);
3658 Check_Optional_Identifier (Ext_Arg, Name_External_Name);
3659 Ext_Nam := Expression (Ext_Arg);
3664 Check_Optional_Identifier (Ext_Arg, Name_External_Name);
3665 Check_Optional_Identifier (Link_Arg, Name_Link_Name);
3666 Ext_Nam := Expression (Ext_Arg);
3667 Link_Nam := Expression (Link_Arg);
3670 -- Check expressions for external name and link name are static
3672 if Present (Ext_Nam) then
3673 Check_Arg_Is_Static_Expression (Ext_Nam, Standard_String);
3674 Check_Form_Of_Interface_Name (Ext_Nam);
3676 -- Verify that the external name is not the name of a local
3677 -- entity, which would hide the imported one and lead to
3678 -- run-time surprises. The problem can only arise for entities
3679 -- declared in a package body (otherwise the external name is
3680 -- fully qualified and won't conflict).
3688 if Prag_Id = Pragma_Import then
3689 String_To_Name_Buffer (Strval (Expr_Value_S (Ext_Nam)));
3691 E := Entity_Id (Get_Name_Table_Info (Nam));
3693 if Nam /= Chars (Subprogram_Def)
3694 and then Present (E)
3695 and then not Is_Overloadable (E)
3696 and then Is_Immediately_Visible (E)
3697 and then not Is_Imported (E)
3698 and then Ekind (Scope (E)) = E_Package
3702 while Present (Par) loop
3703 if Nkind (Par) = N_Package_Body then
3704 Error_Msg_Sloc := Sloc (E);
3706 ("imported entity is hidden by & declared#",
3711 Par := Parent (Par);
3718 if Present (Link_Nam) then
3719 Check_Arg_Is_Static_Expression (Link_Nam, Standard_String);
3720 Check_Form_Of_Interface_Name (Link_Nam);
3723 -- If there is no link name, just set the external name
3725 if No (Link_Nam) then
3726 Link_Nam := Adjust_External_Name_Case (Expr_Value_S (Ext_Nam));
3728 -- For the Link_Name case, the given literal is preceded by an
3729 -- asterisk, which indicates to GCC that the given name should
3730 -- be taken literally, and in particular that no prepending of
3731 -- underlines should occur, even in systems where this is the
3737 if VM_Target = No_VM then
3738 Store_String_Char (Get_Char_Code ('*'));
3741 String_Val := Strval (Expr_Value_S (Link_Nam));
3743 for J in 1 .. String_Length (String_Val) loop
3744 Store_String_Char (Get_String_Char (String_Val, J));
3748 Make_String_Literal (Sloc (Link_Nam), End_String);
3751 Set_Encoded_Interface_Name
3752 (Get_Base_Subprogram (Subprogram_Def), Link_Nam);
3753 Check_Duplicated_Export_Name (Link_Nam);
3754 end Process_Interface_Name;
3756 -----------------------------------------
3757 -- Process_Interrupt_Or_Attach_Handler --
3758 -----------------------------------------
3760 procedure Process_Interrupt_Or_Attach_Handler is
3761 Arg1_X : constant Node_Id := Expression (Arg1);
3762 Handler_Proc : constant Entity_Id := Entity (Arg1_X);
3763 Proc_Scope : constant Entity_Id := Scope (Handler_Proc);
3766 Set_Is_Interrupt_Handler (Handler_Proc);
3768 -- If the pragma is not associated with a handler procedure
3769 -- within a protected type, then it must be for a nonprotected
3770 -- procedure for the AAMP target, in which case we don't
3771 -- associate a representation item with the procedure's scope.
3773 if Ekind (Proc_Scope) = E_Protected_Type then
3774 if Prag_Id = Pragma_Interrupt_Handler
3776 Prag_Id = Pragma_Attach_Handler
3778 Record_Rep_Item (Proc_Scope, N);
3781 end Process_Interrupt_Or_Attach_Handler;
3783 --------------------------------------------------
3784 -- Process_Restrictions_Or_Restriction_Warnings --
3785 --------------------------------------------------
3787 -- Note: some of the simple identifier cases were handled in par-prag,
3788 -- but it is harmless (and more straightforward) to simply handle all
3789 -- cases here, even if it means we repeat a bit of work in some cases.
3791 procedure Process_Restrictions_Or_Restriction_Warnings
3795 R_Id : Restriction_Id;
3800 procedure Check_Unit_Name (N : Node_Id);
3801 -- Checks unit name parameter for No_Dependence. Returns if it has
3802 -- an appropriate form, otherwise raises pragma argument error.
3804 ---------------------
3805 -- Check_Unit_Name --
3806 ---------------------
3808 procedure Check_Unit_Name (N : Node_Id) is
3810 if Nkind (N) = N_Selected_Component then
3811 Check_Unit_Name (Prefix (N));
3812 Check_Unit_Name (Selector_Name (N));
3814 elsif Nkind (N) = N_Identifier then
3819 ("wrong form for unit name for No_Dependence", N);
3821 end Check_Unit_Name;
3823 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
3826 Check_Ada_83_Warning;
3827 Check_At_Least_N_Arguments (1);
3828 Check_Valid_Configuration_Pragma;
3831 while Present (Arg) loop
3833 Expr := Expression (Arg);
3835 -- Case of no restriction identifier present
3837 if Id = No_Name then
3838 if Nkind (Expr) /= N_Identifier then
3840 ("invalid form for restriction", Arg);
3845 (Process_Restriction_Synonyms (Expr));
3847 if R_Id not in All_Boolean_Restrictions then
3849 ("invalid restriction identifier", Arg);
3852 if Implementation_Restriction (R_Id) then
3854 (No_Implementation_Restrictions, Arg);
3857 -- If this is a warning, then set the warning unless we already
3858 -- have a real restriction active (we never want a warning to
3859 -- override a real restriction).
3862 if not Restriction_Active (R_Id) then
3863 Set_Restriction (R_Id, N);
3864 Restriction_Warnings (R_Id) := True;
3867 -- If real restriction case, then set it and make sure that the
3868 -- restriction warning flag is off, since a real restriction
3869 -- always overrides a warning.
3872 Set_Restriction (R_Id, N);
3873 Restriction_Warnings (R_Id) := False;
3876 -- A very special case that must be processed here: pragma
3877 -- Restrictions (No_Exceptions) turns off all run-time
3878 -- checking. This is a bit dubious in terms of the formal
3879 -- language definition, but it is what is intended by RM
3880 -- H.4(12). Restriction_Warnings never affects generated code
3881 -- so this is done only in the real restriction case.
3883 if R_Id = No_Exceptions and then not Warn then
3884 Scope_Suppress := (others => True);
3887 -- Case of No_Dependence => unit-name. Note that the parser
3888 -- already made the necessary entry in the No_Dependence table.
3890 elsif Id = Name_No_Dependence then
3891 Check_Unit_Name (Expr);
3893 -- All other cases of restriction identifier present
3896 R_Id := Get_Restriction_Id (Process_Restriction_Synonyms (Arg));
3897 Analyze_And_Resolve (Expr, Any_Integer);
3899 if R_Id not in All_Parameter_Restrictions then
3901 ("invalid restriction parameter identifier", Arg);
3903 elsif not Is_OK_Static_Expression (Expr) then
3904 Flag_Non_Static_Expr
3905 ("value must be static expression!", Expr);
3908 elsif not Is_Integer_Type (Etype (Expr))
3909 or else Expr_Value (Expr) < 0
3912 ("value must be non-negative integer", Arg);
3915 -- Restriction pragma is active
3917 Val := Expr_Value (Expr);
3919 if not UI_Is_In_Int_Range (Val) then
3921 ("pragma ignored, value too large?", Arg);
3924 -- Warning case. If the real restriction is active, then we
3925 -- ignore the request, since warning never overrides a real
3926 -- restriction. Otherwise we set the proper warning. Note that
3927 -- this circuit sets the warning again if it is already set,
3928 -- which is what we want, since the constant may have changed.
3931 if not Restriction_Active (R_Id) then
3933 (R_Id, N, Integer (UI_To_Int (Val)));
3934 Restriction_Warnings (R_Id) := True;
3937 -- Real restriction case, set restriction and make sure warning
3938 -- flag is off since real restriction always overrides warning.
3941 Set_Restriction (R_Id, N, Integer (UI_To_Int (Val)));
3942 Restriction_Warnings (R_Id) := False;
3948 end Process_Restrictions_Or_Restriction_Warnings;
3950 ---------------------------------
3951 -- Process_Suppress_Unsuppress --
3952 ---------------------------------
3954 -- Note: this procedure makes entries in the check suppress data
3955 -- structures managed by Sem. See spec of package Sem for full
3956 -- details on how we handle recording of check suppression.
3958 procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean) is
3963 In_Package_Spec : constant Boolean :=
3964 (Ekind (Current_Scope) = E_Package
3966 Ekind (Current_Scope) = E_Generic_Package)
3967 and then not In_Package_Body (Current_Scope);
3969 procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id);
3970 -- Used to suppress a single check on the given entity
3972 --------------------------------
3973 -- Suppress_Unsuppress_Echeck --
3974 --------------------------------
3976 procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id) is
3977 ESR : constant Entity_Check_Suppress_Record :=
3980 Suppress => Suppress_Case);
3983 Set_Checks_May_Be_Suppressed (E);
3985 if In_Package_Spec then
3986 Global_Entity_Suppress.Append (ESR);
3988 Local_Entity_Suppress.Append (ESR);
3991 -- If this is a first subtype, and the base type is distinct,
3992 -- then also set the suppress flags on the base type.
3994 if Is_First_Subtype (E)
3995 and then Etype (E) /= E
3997 Suppress_Unsuppress_Echeck (Etype (E), C);
3999 end Suppress_Unsuppress_Echeck;
4001 -- Start of processing for Process_Suppress_Unsuppress
4004 -- Suppress/Unsuppress can appear as a configuration pragma,
4005 -- or in a declarative part or a package spec (RM 11.5(5))
4007 if not Is_Configuration_Pragma then
4008 Check_Is_In_Decl_Part_Or_Package_Spec;
4011 Check_At_Least_N_Arguments (1);
4012 Check_At_Most_N_Arguments (2);
4013 Check_No_Identifier (Arg1);
4014 Check_Arg_Is_Identifier (Arg1);
4016 if not Is_Check_Name (Chars (Expression (Arg1))) then
4018 ("argument of pragma% is not valid check name", Arg1);
4020 C := Get_Check_Id (Chars (Expression (Arg1)));
4023 if not Suppress_Case
4024 and then (C = All_Checks or else C = Overflow_Check)
4026 Opt.Overflow_Checks_Unsuppressed := True;
4029 if Arg_Count = 1 then
4031 -- Make an entry in the local scope suppress table. This is the
4032 -- table that directly shows the current value of the scope
4033 -- suppress check for any check id value.
4035 if C = All_Checks then
4037 -- For All_Checks, we set all specific checks with the
4038 -- exception of Elaboration_Check, which is handled specially
4039 -- because of not wanting All_Checks to have the effect of
4040 -- deactivating static elaboration order processing.
4042 for J in Scope_Suppress'Range loop
4043 if J /= Elaboration_Check then
4044 Scope_Suppress (J) := Suppress_Case;
4048 -- If not All_Checks, just set appropriate entry. Note that we
4049 -- will set Elaboration_Check if this is explicitly specified.
4052 Scope_Suppress (C) := Suppress_Case;
4055 -- Also make an entry in the Local_Entity_Suppress table. See
4056 -- extended description in the package spec of Sem for details.
4058 Local_Entity_Suppress.Append
4061 Suppress => Suppress_Case));
4063 -- Case of two arguments present, where the check is
4064 -- suppressed for a specified entity (given as the second
4065 -- argument of the pragma)
4068 Check_Optional_Identifier (Arg2, Name_On);
4069 E_Id := Expression (Arg2);
4072 if not Is_Entity_Name (E_Id) then
4074 ("second argument of pragma% must be entity name", Arg2);
4083 -- Enforce RM 11.5(7) which requires that for a pragma that
4084 -- appears within a package spec, the named entity must be
4085 -- within the package spec. We allow the package name itself
4086 -- to be mentioned since that makes sense, although it is not
4087 -- strictly allowed by 11.5(7).
4090 and then E /= Current_Scope
4091 and then Scope (E) /= Current_Scope
4094 ("entity in pragma% is not in package spec ('R'M 11.5(7))",
4098 -- Loop through homonyms. As noted below, in the case of a package
4099 -- spec, only homonyms within the package spec are considered.
4102 Suppress_Unsuppress_Echeck (E, C);
4104 if Is_Generic_Instance (E)
4105 and then Is_Subprogram (E)
4106 and then Present (Alias (E))
4108 Suppress_Unsuppress_Echeck (Alias (E), C);
4111 -- Move to next homonym
4116 -- If we are within a package specification, the
4117 -- pragma only applies to homonyms in the same scope.
4119 exit when In_Package_Spec
4120 and then Scope (E) /= Current_Scope;
4123 end Process_Suppress_Unsuppress;
4129 procedure Set_Exported (E : Entity_Id; Arg : Node_Id) is
4131 if Is_Imported (E) then
4133 ("cannot export entity& that was previously imported", Arg);
4135 elsif Present (Address_Clause (E)) then
4137 ("cannot export entity& that has an address clause", Arg);
4140 Set_Is_Exported (E);
4142 -- Generate a reference for entity explicitly, because the
4143 -- identifier may be overloaded and name resolution will not
4146 Generate_Reference (E, Arg);
4148 -- Deal with exporting non-library level entity
4150 if not Is_Library_Level_Entity (E) then
4152 -- Not allowed at all for subprograms
4154 if Is_Subprogram (E) then
4155 Error_Pragma_Arg ("local subprogram& cannot be exported", Arg);
4157 -- Otherwise set public and statically allocated
4161 Set_Is_Statically_Allocated (E);
4163 -- Warn if the corresponding W flag is set and the pragma
4164 -- comes from source. The latter may not be true e.g. on
4165 -- VMS where we expand export pragmas for exception codes
4166 -- associated with imported or exported exceptions. We do
4167 -- not want to generate a warning for something that the
4168 -- user did not write.
4170 if Warn_On_Export_Import
4171 and then Comes_From_Source (Arg)
4174 ("?& has been made static as a result of Export", Arg, E);
4176 ("\this usage is non-standard and non-portable", Arg);
4181 if Warn_On_Export_Import and then Is_Type (E) then
4183 ("exporting a type has no effect?", Arg, E);
4186 if Warn_On_Export_Import and Inside_A_Generic then
4188 ("all instances of& will have the same external name?", Arg, E);
4192 ----------------------------------------------
4193 -- Set_Extended_Import_Export_External_Name --
4194 ----------------------------------------------
4196 procedure Set_Extended_Import_Export_External_Name
4197 (Internal_Ent : Entity_Id;
4198 Arg_External : Node_Id)
4200 Old_Name : constant Node_Id := Interface_Name (Internal_Ent);
4204 if No (Arg_External) then
4208 Check_Arg_Is_External_Name (Arg_External);
4210 if Nkind (Arg_External) = N_String_Literal then
4211 if String_Length (Strval (Arg_External)) = 0 then
4214 New_Name := Adjust_External_Name_Case (Arg_External);
4217 elsif Nkind (Arg_External) = N_Identifier then
4218 New_Name := Get_Default_External_Name (Arg_External);
4220 -- Check_Arg_Is_External_Name should let through only
4221 -- identifiers and string literals or static string
4222 -- expressions (which are folded to string literals).
4225 raise Program_Error;
4228 -- If we already have an external name set (by a prior normal
4229 -- Import or Export pragma), then the external names must match
4231 if Present (Interface_Name (Internal_Ent)) then
4232 Check_Matching_Internal_Names : declare
4233 S1 : constant String_Id := Strval (Old_Name);
4234 S2 : constant String_Id := Strval (New_Name);
4237 -- Called if names do not match
4243 procedure Mismatch is
4245 Error_Msg_Sloc := Sloc (Old_Name);
4247 ("external name does not match that given #",
4251 -- Start of processing for Check_Matching_Internal_Names
4254 if String_Length (S1) /= String_Length (S2) then
4258 for J in 1 .. String_Length (S1) loop
4259 if Get_String_Char (S1, J) /= Get_String_Char (S2, J) then
4264 end Check_Matching_Internal_Names;
4266 -- Otherwise set the given name
4269 Set_Encoded_Interface_Name (Internal_Ent, New_Name);
4270 Check_Duplicated_Export_Name (New_Name);
4272 end Set_Extended_Import_Export_External_Name;
4278 procedure Set_Imported (E : Entity_Id) is
4280 Error_Msg_Sloc := Sloc (E);
4282 if Is_Exported (E) or else Is_Imported (E) then
4283 Error_Msg_NE ("import of& declared# not allowed", N, E);
4285 if Is_Exported (E) then
4286 Error_Msg_N ("\entity was previously exported", N);
4288 Error_Msg_N ("\entity was previously imported", N);
4291 Error_Pragma ("\(pragma% applies to all previous entities)");
4294 Set_Is_Imported (E);
4296 -- If the entity is an object that is not at the library
4297 -- level, then it is statically allocated. We do not worry
4298 -- about objects with address clauses in this context since
4299 -- they are not really imported in the linker sense.
4302 and then not Is_Library_Level_Entity (E)
4303 and then No (Address_Clause (E))
4305 Set_Is_Statically_Allocated (E);
4310 -------------------------
4311 -- Set_Mechanism_Value --
4312 -------------------------
4314 -- Note: the mechanism name has not been analyzed (and cannot indeed
4315 -- be analyzed, since it is semantic nonsense), so we get it in the
4316 -- exact form created by the parser.
4318 procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id) is
4322 procedure Bad_Class;
4323 -- Signal bad descriptor class name
4325 procedure Bad_Mechanism;
4326 -- Signal bad mechanism name
4332 procedure Bad_Class is
4334 Error_Pragma_Arg ("unrecognized descriptor class name", Class);
4337 -------------------------
4338 -- Bad_Mechanism_Value --
4339 -------------------------
4341 procedure Bad_Mechanism is
4343 Error_Pragma_Arg ("unrecognized mechanism name", Mech_Name);
4346 -- Start of processing for Set_Mechanism_Value
4349 if Mechanism (Ent) /= Default_Mechanism then
4351 ("mechanism for & has already been set", Mech_Name, Ent);
4354 -- MECHANISM_NAME ::= value | reference | descriptor
4356 if Nkind (Mech_Name) = N_Identifier then
4357 if Chars (Mech_Name) = Name_Value then
4358 Set_Mechanism (Ent, By_Copy);
4361 elsif Chars (Mech_Name) = Name_Reference then
4362 Set_Mechanism (Ent, By_Reference);
4365 elsif Chars (Mech_Name) = Name_Descriptor then
4366 Check_VMS (Mech_Name);
4367 Set_Mechanism (Ent, By_Descriptor);
4370 elsif Chars (Mech_Name) = Name_Copy then
4372 ("bad mechanism name, Value assumed", Mech_Name);
4378 -- MECHANISM_NAME ::= descriptor (CLASS_NAME)
4379 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4381 -- Note: this form is parsed as an indexed component
4383 elsif Nkind (Mech_Name) = N_Indexed_Component then
4384 Class := First (Expressions (Mech_Name));
4386 if Nkind (Prefix (Mech_Name)) /= N_Identifier
4387 or else Chars (Prefix (Mech_Name)) /= Name_Descriptor
4388 or else Present (Next (Class))
4393 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME)
4394 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4396 -- Note: this form is parsed as a function call
4398 elsif Nkind (Mech_Name) = N_Function_Call then
4400 Param := First (Parameter_Associations (Mech_Name));
4402 if Nkind (Name (Mech_Name)) /= N_Identifier
4403 or else Chars (Name (Mech_Name)) /= Name_Descriptor
4404 or else Present (Next (Param))
4405 or else No (Selector_Name (Param))
4406 or else Chars (Selector_Name (Param)) /= Name_Class
4410 Class := Explicit_Actual_Parameter (Param);
4417 -- Fall through here with Class set to descriptor class name
4419 Check_VMS (Mech_Name);
4421 if Nkind (Class) /= N_Identifier then
4424 elsif Chars (Class) = Name_UBS then
4425 Set_Mechanism (Ent, By_Descriptor_UBS);
4427 elsif Chars (Class) = Name_UBSB then
4428 Set_Mechanism (Ent, By_Descriptor_UBSB);
4430 elsif Chars (Class) = Name_UBA then
4431 Set_Mechanism (Ent, By_Descriptor_UBA);
4433 elsif Chars (Class) = Name_S then
4434 Set_Mechanism (Ent, By_Descriptor_S);
4436 elsif Chars (Class) = Name_SB then
4437 Set_Mechanism (Ent, By_Descriptor_SB);
4439 elsif Chars (Class) = Name_A then
4440 Set_Mechanism (Ent, By_Descriptor_A);
4442 elsif Chars (Class) = Name_NCA then
4443 Set_Mechanism (Ent, By_Descriptor_NCA);
4448 end Set_Mechanism_Value;
4450 ---------------------------
4451 -- Set_Ravenscar_Profile --
4452 ---------------------------
4454 -- The tasks to be done here are
4456 -- Set required policies
4458 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4459 -- pragma Locking_Policy (Ceiling_Locking)
4461 -- Set Detect_Blocking mode
4463 -- Set required restrictions (see System.Rident for detailed list)
4465 procedure Set_Ravenscar_Profile (N : Node_Id) is
4467 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4469 if Task_Dispatching_Policy /= ' '
4470 and then Task_Dispatching_Policy /= 'F'
4472 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
4473 Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
4475 -- Set the FIFO_Within_Priorities policy, but always preserve
4476 -- System_Location since we like the error message with the run time
4480 Task_Dispatching_Policy := 'F';
4482 if Task_Dispatching_Policy_Sloc /= System_Location then
4483 Task_Dispatching_Policy_Sloc := Loc;
4487 -- pragma Locking_Policy (Ceiling_Locking)
4489 if Locking_Policy /= ' '
4490 and then Locking_Policy /= 'C'
4492 Error_Msg_Sloc := Locking_Policy_Sloc;
4493 Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
4495 -- Set the Ceiling_Locking policy, but preserve System_Location since
4496 -- we like the error message with the run time name.
4499 Locking_Policy := 'C';
4501 if Locking_Policy_Sloc /= System_Location then
4502 Locking_Policy_Sloc := Loc;
4506 -- pragma Detect_Blocking
4508 Detect_Blocking := True;
4510 -- Set the corresponding restrictions
4512 Set_Profile_Restrictions (Ravenscar, N, Warn => False);
4513 end Set_Ravenscar_Profile;
4515 -- Start of processing for Analyze_Pragma
4518 if not Is_Pragma_Name (Chars (N)) then
4519 if Warn_On_Unrecognized_Pragma then
4520 Error_Pragma ("unrecognized pragma%?");
4525 Prag_Id := Get_Pragma_Id (Chars (N));
4535 if Present (Pragma_Argument_Associations (N)) then
4536 Arg1 := First (Pragma_Argument_Associations (N));
4538 if Present (Arg1) then
4539 Arg2 := Next (Arg1);
4541 if Present (Arg2) then
4542 Arg3 := Next (Arg2);
4544 if Present (Arg3) then
4545 Arg4 := Next (Arg3);
4551 -- Count number of arguments
4558 while Present (Arg_Node) loop
4559 Arg_Count := Arg_Count + 1;
4564 -- An enumeration type defines the pragmas that are supported by the
4565 -- implementation. Get_Pragma_Id (in package Prag) transorms a name
4566 -- into the corresponding enumeration value for the following case.
4574 -- pragma Abort_Defer;
4576 when Pragma_Abort_Defer =>
4578 Check_Arg_Count (0);
4580 -- The only required semantic processing is to check the
4581 -- placement. This pragma must appear at the start of the
4582 -- statement sequence of a handled sequence of statements.
4584 if Nkind (Parent (N)) /= N_Handled_Sequence_Of_Statements
4585 or else N /= First (Statements (Parent (N)))
4596 -- Note: this pragma also has some specific processing in Par.Prag
4597 -- because we want to set the Ada version mode during parsing.
4599 when Pragma_Ada_83 =>
4601 Ada_Version := Ada_83;
4602 Ada_Version_Explicit := Ada_Version;
4603 Check_Arg_Count (0);
4611 -- Note: this pragma also has some specific processing in Par.Prag
4612 -- because we want to set the Ada 83 version mode during parsing.
4614 when Pragma_Ada_95 =>
4616 Ada_Version := Ada_95;
4617 Ada_Version_Explicit := Ada_Version;
4618 Check_Arg_Count (0);
4620 ---------------------
4621 -- Ada_05/Ada_2005 --
4622 ---------------------
4625 -- pragma Ada_05 (LOCAL_NAME);
4628 -- pragma Ada_2005 (LOCAL_NAME):
4630 -- Note: these pragma also have some specific processing in Par.Prag
4631 -- because we want to set the Ada 2005 version mode during parsing.
4633 when Pragma_Ada_05 | Pragma_Ada_2005 => declare
4639 if Arg_Count = 1 then
4640 Check_Arg_Is_Local_Name (Arg1);
4641 E_Id := Expression (Arg1);
4643 if Etype (E_Id) = Any_Type then
4647 Set_Is_Ada_2005_Only (Entity (E_Id));
4650 Check_Arg_Count (0);
4651 Ada_Version := Ada_05;
4652 Ada_Version_Explicit := Ada_05;
4656 ----------------------
4657 -- All_Calls_Remote --
4658 ----------------------
4660 -- pragma All_Calls_Remote [(library_package_NAME)];
4662 when Pragma_All_Calls_Remote => All_Calls_Remote : declare
4663 Lib_Entity : Entity_Id;
4666 Check_Ada_83_Warning;
4667 Check_Valid_Library_Unit_Pragma;
4669 if Nkind (N) = N_Null_Statement then
4673 Lib_Entity := Find_Lib_Unit_Name;
4675 -- This pragma should only apply to a RCI unit (RM E.2.3(23))
4677 if Present (Lib_Entity)
4678 and then not Debug_Flag_U
4680 if not Is_Remote_Call_Interface (Lib_Entity) then
4681 Error_Pragma ("pragma% only apply to rci unit");
4683 -- Set flag for entity of the library unit
4686 Set_Has_All_Calls_Remote (Lib_Entity);
4690 end All_Calls_Remote;
4696 -- pragma Annotate (IDENTIFIER {, ARG});
4697 -- ARG ::= NAME | EXPRESSION
4699 when Pragma_Annotate => Annotate : begin
4701 Check_At_Least_N_Arguments (1);
4702 Check_Arg_Is_Identifier (Arg1);
4705 Arg : Node_Id := Arg2;
4709 while Present (Arg) loop
4710 Exp := Expression (Arg);
4713 if Is_Entity_Name (Exp) then
4716 elsif Nkind (Exp) = N_String_Literal then
4717 Resolve (Exp, Standard_String);
4719 elsif Is_Overloaded (Exp) then
4720 Error_Pragma_Arg ("ambiguous argument for pragma%", Exp);
4735 -- pragma Assert ([Check =>] Boolean_EXPRESSION
4736 -- [, [Message =>] Static_String_EXPRESSION]);
4738 when Pragma_Assert => Assert : declare
4743 Check_At_Least_N_Arguments (1);
4744 Check_At_Most_N_Arguments (2);
4745 Check_Arg_Order ((Name_Check, Name_Message));
4746 Check_Optional_Identifier (Arg1, Name_Check);
4748 if Arg_Count > 1 then
4749 Check_Optional_Identifier (Arg2, Name_Message);
4750 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
4753 -- If expansion is active and assertions are inactive, then
4754 -- we rewrite the Assertion as:
4756 -- if False and then condition then
4760 -- The reason we do this rewriting during semantic analysis
4761 -- rather than as part of normal expansion is that we cannot
4762 -- analyze and expand the code for the boolean expression
4763 -- directly, or it may cause insertion of actions that would
4764 -- escape the attempt to suppress the assertion code.
4766 Expr := Expression (Arg1);
4768 if Expander_Active and not Assertions_Enabled then
4770 Make_If_Statement (Loc,
4773 Left_Opnd => New_Occurrence_Of (Standard_False, Loc),
4774 Right_Opnd => Expr),
4775 Then_Statements => New_List (
4776 Make_Null_Statement (Loc))));
4780 -- Otherwise (if assertions are enabled, or if we are not
4781 -- operating with expansion active), then we just analyze
4782 -- and resolve the expression.
4785 Analyze_And_Resolve (Expr, Any_Boolean);
4788 -- If assertion is of the form (X'First = literal), where X is
4789 -- formal parameter, then set Low_Bound_Known flag on this formal.
4791 if Nkind (Expr) = N_Op_Eq then
4793 Right : constant Node_Id := Right_Opnd (Expr);
4794 Left : constant Node_Id := Left_Opnd (Expr);
4796 if Nkind (Left) = N_Attribute_Reference
4797 and then Attribute_Name (Left) = Name_First
4798 and then Is_Entity_Name (Prefix (Left))
4799 and then Is_Formal (Entity (Prefix (Left)))
4800 and then Nkind (Right) = N_Integer_Literal
4802 Set_Low_Bound_Known (Entity (Prefix (Left)));
4808 ----------------------
4809 -- Assertion_Policy --
4810 ----------------------
4812 -- pragma Assertion_Policy (Check | Ignore)
4814 when Pragma_Assertion_Policy =>
4816 Check_Arg_Count (1);
4817 Check_Arg_Is_One_Of (Arg1, Name_Check, Name_Ignore);
4818 Assertions_Enabled := Chars (Expression (Arg1)) = Name_Check;
4824 -- pragma AST_Entry (entry_IDENTIFIER);
4826 when Pragma_AST_Entry => AST_Entry : declare
4832 Check_Arg_Count (1);
4833 Check_No_Identifiers;
4834 Check_Arg_Is_Local_Name (Arg1);
4835 Ent := Entity (Expression (Arg1));
4837 -- Note: the implementation of the AST_Entry pragma could handle
4838 -- the entry family case fine, but for now we are consistent with
4839 -- the DEC rules, and do not allow the pragma, which of course
4840 -- has the effect of also forbidding the attribute.
4842 if Ekind (Ent) /= E_Entry then
4844 ("pragma% argument must be simple entry name", Arg1);
4846 elsif Is_AST_Entry (Ent) then
4848 ("duplicate % pragma for entry", Arg1);
4850 elsif Has_Homonym (Ent) then
4852 ("pragma% argument cannot specify overloaded entry", Arg1);
4856 FF : constant Entity_Id := First_Formal (Ent);
4859 if Present (FF) then
4860 if Present (Next_Formal (FF)) then
4862 ("entry for pragma% can have only one argument",
4865 elsif Parameter_Mode (FF) /= E_In_Parameter then
4867 ("entry parameter for pragma% must have mode IN",
4873 Set_Is_AST_Entry (Ent);
4881 -- pragma Asynchronous (LOCAL_NAME);
4883 when Pragma_Asynchronous => Asynchronous : declare
4891 procedure Process_Async_Pragma;
4892 -- Common processing for procedure and access-to-procedure case
4894 --------------------------
4895 -- Process_Async_Pragma --
4896 --------------------------
4898 procedure Process_Async_Pragma is
4901 Set_Is_Asynchronous (Nm);
4905 -- The formals should be of mode IN (RM E.4.1(6))
4908 while Present (S) loop
4909 Formal := Defining_Identifier (S);
4911 if Nkind (Formal) = N_Defining_Identifier
4912 and then Ekind (Formal) /= E_In_Parameter
4915 ("pragma% procedure can only have IN parameter",
4922 Set_Is_Asynchronous (Nm);
4923 end Process_Async_Pragma;
4925 -- Start of processing for pragma Asynchronous
4928 Check_Ada_83_Warning;
4929 Check_No_Identifiers;
4930 Check_Arg_Count (1);
4931 Check_Arg_Is_Local_Name (Arg1);
4933 if Debug_Flag_U then
4937 C_Ent := Cunit_Entity (Current_Sem_Unit);
4938 Analyze (Expression (Arg1));
4939 Nm := Entity (Expression (Arg1));
4941 if not Is_Remote_Call_Interface (C_Ent)
4942 and then not Is_Remote_Types (C_Ent)
4944 -- This pragma should only appear in an RCI or Remote Types
4945 -- unit (RM E.4.1(4))
4948 ("pragma% not in Remote_Call_Interface or " &
4949 "Remote_Types unit");
4952 if Ekind (Nm) = E_Procedure
4953 and then Nkind (Parent (Nm)) = N_Procedure_Specification
4955 if not Is_Remote_Call_Interface (Nm) then
4957 ("pragma% cannot be applied on non-remote procedure",
4961 L := Parameter_Specifications (Parent (Nm));
4962 Process_Async_Pragma;
4965 elsif Ekind (Nm) = E_Function then
4967 ("pragma% cannot be applied to function", Arg1);
4969 elsif Is_Remote_Access_To_Subprogram_Type (Nm) then
4971 if Is_Record_Type (Nm) then
4972 -- A record type that is the Equivalent_Type for
4973 -- a remote access-to-subprogram type.
4975 N := Declaration_Node (Corresponding_Remote_Type (Nm));
4978 -- A non-expanded RAS type (case where distribution is
4981 N := Declaration_Node (Nm);
4984 if Nkind (N) = N_Full_Type_Declaration
4985 and then Nkind (Type_Definition (N)) =
4986 N_Access_Procedure_Definition
4988 L := Parameter_Specifications (Type_Definition (N));
4989 Process_Async_Pragma;
4991 if Is_Asynchronous (Nm)
4992 and then Expander_Active
4993 and then Get_PCS_Name /= Name_No_DSA
4995 RACW_Type_Is_Asynchronous (Underlying_RACW_Type (Nm));
5000 ("pragma% cannot reference access-to-function type",
5004 -- Only other possibility is Access-to-class-wide type
5006 elsif Is_Access_Type (Nm)
5007 and then Is_Class_Wide_Type (Designated_Type (Nm))
5009 Check_First_Subtype (Arg1);
5010 Set_Is_Asynchronous (Nm);
5011 if Expander_Active then
5012 RACW_Type_Is_Asynchronous (Nm);
5016 Error_Pragma_Arg ("inappropriate argument for pragma%", Arg1);
5024 -- pragma Atomic (LOCAL_NAME);
5026 when Pragma_Atomic =>
5027 Process_Atomic_Shared_Volatile;
5029 -----------------------
5030 -- Atomic_Components --
5031 -----------------------
5033 -- pragma Atomic_Components (array_LOCAL_NAME);
5035 -- This processing is shared by Volatile_Components
5037 when Pragma_Atomic_Components |
5038 Pragma_Volatile_Components =>
5040 Atomic_Components : declare
5047 Check_Ada_83_Warning;
5048 Check_No_Identifiers;
5049 Check_Arg_Count (1);
5050 Check_Arg_Is_Local_Name (Arg1);
5051 E_Id := Expression (Arg1);
5053 if Etype (E_Id) = Any_Type then
5059 if Rep_Item_Too_Early (E, N)
5061 Rep_Item_Too_Late (E, N)
5066 D := Declaration_Node (E);
5069 if (K = N_Full_Type_Declaration and then Is_Array_Type (E))
5071 ((Ekind (E) = E_Constant or else Ekind (E) = E_Variable)
5072 and then Nkind (D) = N_Object_Declaration
5073 and then Nkind (Object_Definition (D)) =
5074 N_Constrained_Array_Definition)
5076 -- The flag is set on the object, or on the base type
5078 if Nkind (D) /= N_Object_Declaration then
5082 Set_Has_Volatile_Components (E);
5084 if Prag_Id = Pragma_Atomic_Components then
5085 Set_Has_Atomic_Components (E);
5087 if Is_Packed (E) then
5088 Set_Is_Packed (E, False);
5091 ("?Pack canceled, cannot pack atomic components",
5097 Error_Pragma_Arg ("inappropriate entity for pragma%", Arg1);
5099 end Atomic_Components;
5101 --------------------
5102 -- Attach_Handler --
5103 --------------------
5105 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
5107 when Pragma_Attach_Handler =>
5108 Check_Ada_83_Warning;
5109 Check_No_Identifiers;
5110 Check_Arg_Count (2);
5112 if No_Run_Time_Mode then
5113 Error_Msg_CRT ("Attach_Handler pragma", N);
5115 Check_Interrupt_Or_Attach_Handler;
5117 -- The expression that designates the attribute may
5118 -- depend on a discriminant, and is therefore a per-
5119 -- object expression, to be expanded in the init proc.
5120 -- If expansion is enabled, perform semantic checks
5123 if Expander_Active then
5125 Temp : constant Node_Id :=
5126 New_Copy_Tree (Expression (Arg2));
5128 Set_Parent (Temp, N);
5129 Pre_Analyze_And_Resolve (Temp, RTE (RE_Interrupt_ID));
5133 Analyze (Expression (Arg2));
5134 Resolve (Expression (Arg2), RTE (RE_Interrupt_ID));
5137 Process_Interrupt_Or_Attach_Handler;
5140 --------------------
5141 -- C_Pass_By_Copy --
5142 --------------------
5144 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
5146 when Pragma_C_Pass_By_Copy => C_Pass_By_Copy : declare
5152 Check_Valid_Configuration_Pragma;
5153 Check_Arg_Count (1);
5154 Check_Optional_Identifier (Arg1, "max_size");
5156 Arg := Expression (Arg1);
5157 Check_Arg_Is_Static_Expression (Arg, Any_Integer);
5159 Val := Expr_Value (Arg);
5163 ("maximum size for pragma% must be positive", Arg1);
5165 elsif UI_Is_In_Int_Range (Val) then
5166 Default_C_Record_Mechanism := UI_To_Int (Val);
5168 -- If a giant value is given, Int'Last will do well enough.
5169 -- If sometime someone complains that a record larger than
5170 -- two gigabytes is not copied, we will worry about it then!
5173 Default_C_Record_Mechanism := Mechanism_Type'Last;
5181 -- pragma Comment (static_string_EXPRESSION)
5183 -- Processing for pragma Comment shares the circuitry for
5184 -- pragma Ident. The only differences are that Ident enforces
5185 -- a limit of 31 characters on its argument, and also enforces
5186 -- limitations on placement for DEC compatibility. Pragma
5187 -- Comment shares neither of these restrictions.
5193 -- pragma Common_Object (
5194 -- [Internal =>] LOCAL_NAME,
5195 -- [, [External =>] EXTERNAL_SYMBOL]
5196 -- [, [Size =>] EXTERNAL_SYMBOL]);
5198 -- Processing for this pragma is shared with Psect_Object
5200 ------------------------
5201 -- Compile_Time_Error --
5202 ------------------------
5204 -- pragma Compile_Time_Error
5205 -- (boolean_EXPRESSION, static_string_EXPRESSION);
5207 when Pragma_Compile_Time_Error =>
5208 Process_Compile_Time_Warning_Or_Error;
5210 --------------------------
5211 -- Compile_Time_Warning --
5212 --------------------------
5214 -- pragma Compile_Time_Warning
5215 -- (boolean_EXPRESSION, static_string_EXPRESSION);
5217 when Pragma_Compile_Time_Warning =>
5218 Process_Compile_Time_Warning_Or_Error;
5220 -----------------------------
5221 -- Complete_Representation --
5222 -----------------------------
5224 -- pragma Complete_Representation;
5226 when Pragma_Complete_Representation =>
5228 Check_Arg_Count (0);
5230 if Nkind (Parent (N)) /= N_Record_Representation_Clause then
5232 ("pragma & must appear within record representation clause");
5235 ----------------------------
5236 -- Complex_Representation --
5237 ----------------------------
5239 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
5241 when Pragma_Complex_Representation => Complex_Representation : declare
5248 Check_Arg_Count (1);
5249 Check_Optional_Identifier (Arg1, Name_Entity);
5250 Check_Arg_Is_Local_Name (Arg1);
5251 E_Id := Expression (Arg1);
5253 if Etype (E_Id) = Any_Type then
5259 if not Is_Record_Type (E) then
5261 ("argument for pragma% must be record type", Arg1);
5264 Ent := First_Entity (E);
5267 or else No (Next_Entity (Ent))
5268 or else Present (Next_Entity (Next_Entity (Ent)))
5269 or else not Is_Floating_Point_Type (Etype (Ent))
5270 or else Etype (Ent) /= Etype (Next_Entity (Ent))
5273 ("record for pragma% must have two fields of same fpt type",
5277 Set_Has_Complex_Representation (Base_Type (E));
5279 end Complex_Representation;
5281 -------------------------
5282 -- Component_Alignment --
5283 -------------------------
5285 -- pragma Component_Alignment (
5286 -- [Form =>] ALIGNMENT_CHOICE
5287 -- [, [Name =>] type_LOCAL_NAME]);
5289 -- ALIGNMENT_CHOICE ::=
5291 -- | Component_Size_4
5295 when Pragma_Component_Alignment => Component_AlignmentP : declare
5296 Args : Args_List (1 .. 2);
5297 Names : constant Name_List (1 .. 2) := (
5301 Form : Node_Id renames Args (1);
5302 Name : Node_Id renames Args (2);
5304 Atype : Component_Alignment_Kind;
5309 Gather_Associations (Names, Args);
5312 Error_Pragma ("missing Form argument for pragma%");
5315 Check_Arg_Is_Identifier (Form);
5317 -- Get proper alignment, note that Default = Component_Size
5318 -- on all machines we have so far, and we want to set this
5319 -- value rather than the default value to indicate that it
5320 -- has been explicitly set (and thus will not get overridden
5321 -- by the default component alignment for the current scope)
5323 if Chars (Form) = Name_Component_Size then
5324 Atype := Calign_Component_Size;
5326 elsif Chars (Form) = Name_Component_Size_4 then
5327 Atype := Calign_Component_Size_4;
5329 elsif Chars (Form) = Name_Default then
5330 Atype := Calign_Component_Size;
5332 elsif Chars (Form) = Name_Storage_Unit then
5333 Atype := Calign_Storage_Unit;
5337 ("invalid Form parameter for pragma%", Form);
5340 -- Case with no name, supplied, affects scope table entry
5344 (Scope_Stack.Last).Component_Alignment_Default := Atype;
5346 -- Case of name supplied
5349 Check_Arg_Is_Local_Name (Name);
5351 Typ := Entity (Name);
5354 or else Rep_Item_Too_Early (Typ, N)
5358 Typ := Underlying_Type (Typ);
5361 if not Is_Record_Type (Typ)
5362 and then not Is_Array_Type (Typ)
5365 ("Name parameter of pragma% must identify record or " &
5366 "array type", Name);
5369 -- An explicit Component_Alignment pragma overrides an
5370 -- implicit pragma Pack, but not an explicit one.
5372 if not Has_Pragma_Pack (Base_Type (Typ)) then
5373 Set_Is_Packed (Base_Type (Typ), False);
5374 Set_Component_Alignment (Base_Type (Typ), Atype);
5377 end Component_AlignmentP;
5383 -- pragma Controlled (first_subtype_LOCAL_NAME);
5385 when Pragma_Controlled => Controlled : declare
5389 Check_No_Identifiers;
5390 Check_Arg_Count (1);
5391 Check_Arg_Is_Local_Name (Arg1);
5392 Arg := Expression (Arg1);
5394 if not Is_Entity_Name (Arg)
5395 or else not Is_Access_Type (Entity (Arg))
5397 Error_Pragma_Arg ("pragma% requires access type", Arg1);
5399 Set_Has_Pragma_Controlled (Base_Type (Entity (Arg)));
5407 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
5408 -- [Entity =>] LOCAL_NAME);
5410 when Pragma_Convention => Convention : declare
5414 Check_Arg_Order ((Name_Convention, Name_Entity));
5415 Check_Ada_83_Warning;
5416 Check_Arg_Count (2);
5417 Process_Convention (C, E);
5420 ---------------------------
5421 -- Convention_Identifier --
5422 ---------------------------
5424 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
5425 -- [Convention =>] convention_IDENTIFIER);
5427 when Pragma_Convention_Identifier => Convention_Identifier : declare
5433 Check_Arg_Order ((Name_Name, Name_Convention));
5434 Check_Arg_Count (2);
5435 Check_Optional_Identifier (Arg1, Name_Name);
5436 Check_Optional_Identifier (Arg2, Name_Convention);
5437 Check_Arg_Is_Identifier (Arg1);
5438 Check_Arg_Is_Identifier (Arg1);
5439 Idnam := Chars (Expression (Arg1));
5440 Cname := Chars (Expression (Arg2));
5442 if Is_Convention_Name (Cname) then
5443 Record_Convention_Identifier
5444 (Idnam, Get_Convention_Id (Cname));
5447 ("second arg for % pragma must be convention", Arg2);
5449 end Convention_Identifier;
5455 -- pragma CPP_Class ([Entity =>] local_NAME)
5457 when Pragma_CPP_Class => CPP_Class : declare
5462 if Warn_On_Obsolescent_Feature then
5464 ("'G'N'A'T pragma cpp'_class is now obsolete; replace it" &
5465 " by pragma import?", N);
5469 Check_Arg_Count (1);
5470 Check_Optional_Identifier (Arg1, Name_Entity);
5471 Check_Arg_Is_Local_Name (Arg1);
5473 Arg := Expression (Arg1);
5476 if Etype (Arg) = Any_Type then
5480 if not Is_Entity_Name (Arg)
5481 or else not Is_Type (Entity (Arg))
5483 Error_Pragma_Arg ("pragma% requires a type mark", Arg1);
5486 Typ := Entity (Arg);
5488 if not Is_Tagged_Type (Typ) then
5489 Error_Pragma_Arg ("pragma% applicable to tagged types ", Arg1);
5492 -- Types treated as CPP classes are treated as limited, but we
5493 -- don't require them to be declared this way. A warning is issued
5494 -- to encourage the user to declare them as limited. This is not
5495 -- an error, for compatibility reasons, because these types have
5496 -- been supported this way for some time.
5498 if not Is_Limited_Type (Typ) then
5500 ("imported 'C'P'P type should be " &
5501 "explicitly declared limited?",
5502 Get_Pragma_Arg (Arg1));
5504 ("\type will be considered limited",
5505 Get_Pragma_Arg (Arg1));
5508 Set_Is_CPP_Class (Typ);
5509 Set_Is_Limited_Record (Typ);
5510 Set_Convention (Typ, Convention_CPP);
5513 ---------------------
5514 -- CPP_Constructor --
5515 ---------------------
5517 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME
5518 -- [, [External_Name =>] static_string_EXPRESSION ]
5519 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5521 when Pragma_CPP_Constructor => CPP_Constructor : declare
5527 Check_At_Least_N_Arguments (1);
5528 Check_At_Most_N_Arguments (3);
5529 Check_Optional_Identifier (Arg1, Name_Entity);
5530 Check_Arg_Is_Local_Name (Arg1);
5532 Id := Expression (Arg1);
5533 Find_Program_Unit_Name (Id);
5535 -- If we did not find the name, we are done
5537 if Etype (Id) = Any_Type then
5541 Def_Id := Entity (Id);
5543 if Ekind (Def_Id) = E_Function
5544 and then Is_Class_Wide_Type (Etype (Def_Id))
5545 and then Is_CPP_Class (Etype (Etype (Def_Id)))
5547 if Arg_Count >= 2 then
5548 Set_Imported (Def_Id);
5549 Set_Is_Public (Def_Id);
5550 Process_Interface_Name (Def_Id, Arg2, Arg3);
5553 if No (Parameter_Specifications (Parent (Def_Id))) then
5554 Set_Has_Completion (Def_Id);
5555 Set_Is_Constructor (Def_Id);
5558 ("non-default constructors not implemented", Arg1);
5563 ("pragma% requires function returning a 'C'P'P_Class type",
5566 end CPP_Constructor;
5572 when Pragma_CPP_Virtual => CPP_Virtual : declare
5574 if Warn_On_Obsolescent_Feature then
5576 ("'G'N'A'T pragma cpp'_virtual is now obsolete and has " &
5585 when Pragma_CPP_Vtable => CPP_Vtable : declare
5587 if Warn_On_Obsolescent_Feature then
5589 ("'G'N'A'T pragma cpp'_vtable is now obsolete and has " &
5598 -- pragma Debug ([boolean_EXPRESSION,] PROCEDURE_CALL_STATEMENT);
5600 when Pragma_Debug => Debug : declare
5608 (Boolean_Literals (Debug_Pragmas_Enabled and Expander_Active),
5611 if Arg_Count = 2 then
5614 Left_Opnd => Relocate_Node (Cond),
5615 Right_Opnd => Expression (Arg1));
5618 -- Rewrite into a conditional with an appropriate condition. We
5619 -- wrap the procedure call in a block so that overhead from e.g.
5620 -- use of the secondary stack does not generate execution overhead
5621 -- for suppressed conditions.
5623 Rewrite (N, Make_Implicit_If_Statement (N,
5625 Then_Statements => New_List (
5626 Make_Block_Statement (Loc,
5627 Handled_Statement_Sequence =>
5628 Make_Handled_Sequence_Of_Statements (Loc,
5629 Statements => New_List (
5630 Relocate_Node (Debug_Statement (N))))))));
5638 -- pragma Debug_Policy (Check | Ignore)
5640 when Pragma_Debug_Policy =>
5642 Check_Arg_Count (1);
5643 Check_Arg_Is_One_Of (Arg1, Name_Check, Name_Ignore);
5644 Debug_Pragmas_Enabled := Chars (Expression (Arg1)) = Name_Check;
5646 ---------------------
5647 -- Detect_Blocking --
5648 ---------------------
5650 -- pragma Detect_Blocking;
5652 when Pragma_Detect_Blocking =>
5654 Check_Arg_Count (0);
5655 Check_Valid_Configuration_Pragma;
5656 Detect_Blocking := True;
5662 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
5664 when Pragma_Discard_Names => Discard_Names : declare
5669 Check_Ada_83_Warning;
5671 -- Deal with configuration pragma case
5673 if Arg_Count = 0 and then Is_Configuration_Pragma then
5674 Global_Discard_Names := True;
5677 -- Otherwise, check correct appropriate context
5680 Check_Is_In_Decl_Part_Or_Package_Spec;
5682 if Arg_Count = 0 then
5684 -- If there is no parameter, then from now on this pragma
5685 -- applies to any enumeration, exception or tagged type
5686 -- defined in the current declarative part, and recursively
5687 -- to any nested scope.
5689 Set_Discard_Names (Current_Scope);
5693 Check_Arg_Count (1);
5694 Check_Optional_Identifier (Arg1, Name_On);
5695 Check_Arg_Is_Local_Name (Arg1);
5696 E_Id := Expression (Arg1);
5698 if Etype (E_Id) = Any_Type then
5704 if (Is_First_Subtype (E)
5705 and then (Is_Enumeration_Type (E)
5706 or else Is_Tagged_Type (E)))
5707 or else Ekind (E) = E_Exception
5709 Set_Discard_Names (E);
5712 ("inappropriate entity for pragma%", Arg1);
5722 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
5724 when Pragma_Elaborate => Elaborate : declare
5729 -- Pragma must be in context items list of a compilation unit
5731 if not Is_In_Context_Clause then
5735 -- Must be at least one argument
5737 if Arg_Count = 0 then
5738 Error_Pragma ("pragma% requires at least one argument");
5741 -- In Ada 83 mode, there can be no items following it in the
5742 -- context list except other pragmas and implicit with clauses
5743 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
5744 -- placement rule does not apply.
5746 if Ada_Version = Ada_83 and then Comes_From_Source (N) then
5748 while Present (Citem) loop
5749 if Nkind (Citem) = N_Pragma
5750 or else (Nkind (Citem) = N_With_Clause
5751 and then Implicit_With (Citem))
5756 ("(Ada 83) pragma% must be at end of context clause");
5763 -- Finally, the arguments must all be units mentioned in a with
5764 -- clause in the same context clause. Note we already checked (in
5765 -- Par.Prag) that the arguments are all identifiers or selected
5769 Outer : while Present (Arg) loop
5770 Citem := First (List_Containing (N));
5771 Inner : while Citem /= N loop
5772 if Nkind (Citem) = N_With_Clause
5773 and then Same_Name (Name (Citem), Expression (Arg))
5775 Set_Elaborate_Present (Citem, True);
5776 Set_Unit_Name (Expression (Arg), Name (Citem));
5778 -- With the pragma present, elaboration calls on
5779 -- subprograms from the named unit need no further
5780 -- checks, as long as the pragma appears in the current
5781 -- compilation unit. If the pragma appears in some unit
5782 -- in the context, there might still be a need for an
5783 -- Elaborate_All_Desirable from the current compilation
5784 -- to the the named unit, so we keep the check enabled.
5786 if In_Extended_Main_Source_Unit (N) then
5787 Set_Suppress_Elaboration_Warnings
5788 (Entity (Name (Citem)));
5799 ("argument of pragma% is not with'ed unit", Arg);
5805 -- Give a warning if operating in static mode with -gnatwl
5806 -- (elaboration warnings eanbled) switch set.
5808 if Elab_Warnings and not Dynamic_Elaboration_Checks then
5810 ("?use of pragma Elaborate may not be safe", N);
5812 ("?use pragma Elaborate_All instead if possible", N);
5820 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
5822 when Pragma_Elaborate_All => Elaborate_All : declare
5827 Check_Ada_83_Warning;
5829 -- Pragma must be in context items list of a compilation unit
5831 if not Is_In_Context_Clause then
5835 -- Must be at least one argument
5837 if Arg_Count = 0 then
5838 Error_Pragma ("pragma% requires at least one argument");
5841 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
5842 -- have to appear at the end of the context clause, but may
5843 -- appear mixed in with other items, even in Ada 83 mode.
5845 -- Final check: the arguments must all be units mentioned in
5846 -- a with clause in the same context clause. Note that we
5847 -- already checked (in Par.Prag) that all the arguments are
5848 -- either identifiers or selected components.
5851 Outr : while Present (Arg) loop
5852 Citem := First (List_Containing (N));
5854 Innr : while Citem /= N loop
5855 if Nkind (Citem) = N_With_Clause
5856 and then Same_Name (Name (Citem), Expression (Arg))
5858 Set_Elaborate_All_Present (Citem, True);
5859 Set_Unit_Name (Expression (Arg), Name (Citem));
5861 -- Suppress warnings and elaboration checks on the named
5862 -- unit if the pragma is in the current compilation, as
5863 -- for pragma Elaborate.
5865 if In_Extended_Main_Source_Unit (N) then
5866 Set_Suppress_Elaboration_Warnings
5867 (Entity (Name (Citem)));
5876 Set_Error_Posted (N);
5878 ("argument of pragma% is not with'ed unit", Arg);
5885 --------------------
5886 -- Elaborate_Body --
5887 --------------------
5889 -- pragma Elaborate_Body [( library_unit_NAME )];
5891 when Pragma_Elaborate_Body => Elaborate_Body : declare
5892 Cunit_Node : Node_Id;
5893 Cunit_Ent : Entity_Id;
5896 Check_Ada_83_Warning;
5897 Check_Valid_Library_Unit_Pragma;
5899 if Nkind (N) = N_Null_Statement then
5903 Cunit_Node := Cunit (Current_Sem_Unit);
5904 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
5906 if Nkind (Unit (Cunit_Node)) = N_Package_Body
5908 Nkind (Unit (Cunit_Node)) = N_Subprogram_Body
5910 Error_Pragma ("pragma% must refer to a spec, not a body");
5912 Set_Body_Required (Cunit_Node, True);
5913 Set_Has_Pragma_Elaborate_Body (Cunit_Ent);
5915 -- If we are in dynamic elaboration mode, then we suppress
5916 -- elaboration warnings for the unit, since it is definitely
5917 -- fine NOT to do dynamic checks at the first level (and such
5918 -- checks will be suppressed because no elaboration boolean
5919 -- is created for Elaborate_Body packages).
5921 -- But in the static model of elaboration, Elaborate_Body is
5922 -- definitely NOT good enough to ensure elaboration safety on
5923 -- its own, since the body may WITH other units that are not
5924 -- safe from an elaboration point of view, so a client must
5925 -- still do an Elaborate_All on such units.
5927 -- Debug flag -gnatdD restores the old behavior of 3.13,
5928 -- where Elaborate_Body always suppressed elab warnings.
5930 if Dynamic_Elaboration_Checks or Debug_Flag_DD then
5931 Set_Suppress_Elaboration_Warnings (Cunit_Ent);
5936 ------------------------
5937 -- Elaboration_Checks --
5938 ------------------------
5940 -- pragma Elaboration_Checks (Static | Dynamic);
5942 when Pragma_Elaboration_Checks =>
5944 Check_Arg_Count (1);
5945 Check_Arg_Is_One_Of (Arg1, Name_Static, Name_Dynamic);
5946 Dynamic_Elaboration_Checks :=
5947 (Chars (Get_Pragma_Arg (Arg1)) = Name_Dynamic);
5953 -- pragma Eliminate (
5954 -- [Unit_Name =>] IDENTIFIER |
5955 -- SELECTED_COMPONENT
5956 -- [,[Entity =>] IDENTIFIER |
5957 -- SELECTED_COMPONENT |
5959 -- [,]OVERLOADING_RESOLUTION);
5961 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
5964 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
5967 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
5969 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
5970 -- Result_Type => result_SUBTYPE_NAME]
5972 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
5973 -- SUBTYPE_NAME ::= STRING_LITERAL
5975 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
5976 -- SOURCE_TRACE ::= STRING_LITERAL
5978 when Pragma_Eliminate => Eliminate : declare
5979 Args : Args_List (1 .. 5);
5980 Names : constant Name_List (1 .. 5) := (
5983 Name_Parameter_Types,
5985 Name_Source_Location);
5987 Unit_Name : Node_Id renames Args (1);
5988 Entity : Node_Id renames Args (2);
5989 Parameter_Types : Node_Id renames Args (3);
5990 Result_Type : Node_Id renames Args (4);
5991 Source_Location : Node_Id renames Args (5);
5995 Check_Valid_Configuration_Pragma;
5996 Gather_Associations (Names, Args);
5998 if No (Unit_Name) then
5999 Error_Pragma ("missing Unit_Name argument for pragma%");
6003 and then (Present (Parameter_Types)
6005 Present (Result_Type)
6007 Present (Source_Location))
6009 Error_Pragma ("missing Entity argument for pragma%");
6012 if (Present (Parameter_Types)
6014 Present (Result_Type))
6016 Present (Source_Location)
6019 ("parameter profile and source location cannot " &
6020 "be used together in pragma%");
6023 Process_Eliminate_Pragma
6037 -- [ Convention =>] convention_IDENTIFIER,
6038 -- [ Entity =>] local_NAME
6039 -- [, [External_Name =>] static_string_EXPRESSION ]
6040 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6042 when Pragma_Export => Export : declare
6047 Check_Ada_83_Warning;
6053 Check_At_Least_N_Arguments (2);
6054 Check_At_Most_N_Arguments (4);
6055 Process_Convention (C, Def_Id);
6057 if Ekind (Def_Id) /= E_Constant then
6058 Note_Possible_Modification (Expression (Arg2));
6061 Process_Interface_Name (Def_Id, Arg3, Arg4);
6062 Set_Exported (Def_Id, Arg2);
6065 ----------------------
6066 -- Export_Exception --
6067 ----------------------
6069 -- pragma Export_Exception (
6070 -- [Internal =>] LOCAL_NAME,
6071 -- [, [External =>] EXTERNAL_SYMBOL,]
6072 -- [, [Form =>] Ada | VMS]
6073 -- [, [Code =>] static_integer_EXPRESSION]);
6075 when Pragma_Export_Exception => Export_Exception : declare
6076 Args : Args_List (1 .. 4);
6077 Names : constant Name_List (1 .. 4) := (
6083 Internal : Node_Id renames Args (1);
6084 External : Node_Id renames Args (2);
6085 Form : Node_Id renames Args (3);
6086 Code : Node_Id renames Args (4);
6089 if Inside_A_Generic then
6090 Error_Pragma ("pragma% cannot be used for generic entities");
6093 Gather_Associations (Names, Args);
6094 Process_Extended_Import_Export_Exception_Pragma (
6095 Arg_Internal => Internal,
6096 Arg_External => External,
6100 if not Is_VMS_Exception (Entity (Internal)) then
6101 Set_Exported (Entity (Internal), Internal);
6103 end Export_Exception;
6105 ---------------------
6106 -- Export_Function --
6107 ---------------------
6109 -- pragma Export_Function (
6110 -- [Internal =>] LOCAL_NAME,
6111 -- [, [External =>] EXTERNAL_SYMBOL,]
6112 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6113 -- [, [Result_Type =>] TYPE_DESIGNATOR]
6114 -- [, [Mechanism =>] MECHANISM]
6115 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
6117 -- EXTERNAL_SYMBOL ::=
6119 -- | static_string_EXPRESSION
6121 -- PARAMETER_TYPES ::=
6123 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6125 -- TYPE_DESIGNATOR ::=
6127 -- | subtype_Name ' Access
6131 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6133 -- MECHANISM_ASSOCIATION ::=
6134 -- [formal_parameter_NAME =>] MECHANISM_NAME
6136 -- MECHANISM_NAME ::=
6139 -- | Descriptor [([Class =>] CLASS_NAME)]
6141 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6143 when Pragma_Export_Function => Export_Function : declare
6144 Args : Args_List (1 .. 6);
6145 Names : constant Name_List (1 .. 6) := (
6148 Name_Parameter_Types,
6151 Name_Result_Mechanism);
6153 Internal : Node_Id renames Args (1);
6154 External : Node_Id renames Args (2);
6155 Parameter_Types : Node_Id renames Args (3);
6156 Result_Type : Node_Id renames Args (4);
6157 Mechanism : Node_Id renames Args (5);
6158 Result_Mechanism : Node_Id renames Args (6);
6162 Gather_Associations (Names, Args);
6163 Process_Extended_Import_Export_Subprogram_Pragma (
6164 Arg_Internal => Internal,
6165 Arg_External => External,
6166 Arg_Parameter_Types => Parameter_Types,
6167 Arg_Result_Type => Result_Type,
6168 Arg_Mechanism => Mechanism,
6169 Arg_Result_Mechanism => Result_Mechanism);
6170 end Export_Function;
6176 -- pragma Export_Object (
6177 -- [Internal =>] LOCAL_NAME,
6178 -- [, [External =>] EXTERNAL_SYMBOL]
6179 -- [, [Size =>] EXTERNAL_SYMBOL]);
6181 -- EXTERNAL_SYMBOL ::=
6183 -- | static_string_EXPRESSION
6185 -- PARAMETER_TYPES ::=
6187 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6189 -- TYPE_DESIGNATOR ::=
6191 -- | subtype_Name ' Access
6195 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6197 -- MECHANISM_ASSOCIATION ::=
6198 -- [formal_parameter_NAME =>] MECHANISM_NAME
6200 -- MECHANISM_NAME ::=
6203 -- | Descriptor [([Class =>] CLASS_NAME)]
6205 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6207 when Pragma_Export_Object => Export_Object : declare
6208 Args : Args_List (1 .. 3);
6209 Names : constant Name_List (1 .. 3) := (
6214 Internal : Node_Id renames Args (1);
6215 External : Node_Id renames Args (2);
6216 Size : Node_Id renames Args (3);
6220 Gather_Associations (Names, Args);
6221 Process_Extended_Import_Export_Object_Pragma (
6222 Arg_Internal => Internal,
6223 Arg_External => External,
6227 ----------------------
6228 -- Export_Procedure --
6229 ----------------------
6231 -- pragma Export_Procedure (
6232 -- [Internal =>] LOCAL_NAME,
6233 -- [, [External =>] EXTERNAL_SYMBOL,]
6234 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6235 -- [, [Mechanism =>] MECHANISM]);
6237 -- EXTERNAL_SYMBOL ::=
6239 -- | static_string_EXPRESSION
6241 -- PARAMETER_TYPES ::=
6243 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6245 -- TYPE_DESIGNATOR ::=
6247 -- | subtype_Name ' Access
6251 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6253 -- MECHANISM_ASSOCIATION ::=
6254 -- [formal_parameter_NAME =>] MECHANISM_NAME
6256 -- MECHANISM_NAME ::=
6259 -- | Descriptor [([Class =>] CLASS_NAME)]
6261 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6263 when Pragma_Export_Procedure => Export_Procedure : declare
6264 Args : Args_List (1 .. 4);
6265 Names : constant Name_List (1 .. 4) := (
6268 Name_Parameter_Types,
6271 Internal : Node_Id renames Args (1);
6272 External : Node_Id renames Args (2);
6273 Parameter_Types : Node_Id renames Args (3);
6274 Mechanism : Node_Id renames Args (4);
6278 Gather_Associations (Names, Args);
6279 Process_Extended_Import_Export_Subprogram_Pragma (
6280 Arg_Internal => Internal,
6281 Arg_External => External,
6282 Arg_Parameter_Types => Parameter_Types,
6283 Arg_Mechanism => Mechanism);
6284 end Export_Procedure;
6290 -- pragma Export_Value (
6291 -- [Value =>] static_integer_EXPRESSION,
6292 -- [Link_Name =>] static_string_EXPRESSION);
6294 when Pragma_Export_Value =>
6296 Check_Arg_Order ((Name_Value, Name_Link_Name));
6297 Check_Arg_Count (2);
6299 Check_Optional_Identifier (Arg1, Name_Value);
6300 Check_Arg_Is_Static_Expression (Arg1, Any_Integer);
6302 Check_Optional_Identifier (Arg2, Name_Link_Name);
6303 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
6305 -----------------------------
6306 -- Export_Valued_Procedure --
6307 -----------------------------
6309 -- pragma Export_Valued_Procedure (
6310 -- [Internal =>] LOCAL_NAME,
6311 -- [, [External =>] EXTERNAL_SYMBOL,]
6312 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6313 -- [, [Mechanism =>] MECHANISM]);
6315 -- EXTERNAL_SYMBOL ::=
6317 -- | static_string_EXPRESSION
6319 -- PARAMETER_TYPES ::=
6321 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6323 -- TYPE_DESIGNATOR ::=
6325 -- | subtype_Name ' Access
6329 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6331 -- MECHANISM_ASSOCIATION ::=
6332 -- [formal_parameter_NAME =>] MECHANISM_NAME
6334 -- MECHANISM_NAME ::=
6337 -- | Descriptor [([Class =>] CLASS_NAME)]
6339 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6341 when Pragma_Export_Valued_Procedure =>
6342 Export_Valued_Procedure : declare
6343 Args : Args_List (1 .. 4);
6344 Names : constant Name_List (1 .. 4) := (
6347 Name_Parameter_Types,
6350 Internal : Node_Id renames Args (1);
6351 External : Node_Id renames Args (2);
6352 Parameter_Types : Node_Id renames Args (3);
6353 Mechanism : Node_Id renames Args (4);
6357 Gather_Associations (Names, Args);
6358 Process_Extended_Import_Export_Subprogram_Pragma (
6359 Arg_Internal => Internal,
6360 Arg_External => External,
6361 Arg_Parameter_Types => Parameter_Types,
6362 Arg_Mechanism => Mechanism);
6363 end Export_Valued_Procedure;
6369 -- pragma Extend_System ([Name =>] Identifier);
6371 when Pragma_Extend_System => Extend_System : declare
6374 Check_Valid_Configuration_Pragma;
6375 Check_Arg_Count (1);
6376 Check_Optional_Identifier (Arg1, Name_Name);
6377 Check_Arg_Is_Identifier (Arg1);
6379 Get_Name_String (Chars (Expression (Arg1)));
6382 and then Name_Buffer (1 .. 4) = "aux_"
6384 if Present (System_Extend_Pragma_Arg) then
6385 if Chars (Expression (Arg1)) =
6386 Chars (Expression (System_Extend_Pragma_Arg))
6390 Error_Msg_Sloc := Sloc (System_Extend_Pragma_Arg);
6391 Error_Pragma ("pragma% conflicts with that at#");
6395 System_Extend_Pragma_Arg := Arg1;
6397 if not GNAT_Mode then
6398 System_Extend_Unit := Arg1;
6402 Error_Pragma ("incorrect name for pragma%, must be Aux_xxx");
6406 ------------------------
6407 -- Extensions_Allowed --
6408 ------------------------
6410 -- pragma Extensions_Allowed (ON | OFF);
6412 when Pragma_Extensions_Allowed =>
6414 Check_Arg_Count (1);
6415 Check_No_Identifiers;
6416 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
6418 if Chars (Expression (Arg1)) = Name_On then
6419 Extensions_Allowed := True;
6421 Extensions_Allowed := False;
6428 -- pragma External (
6429 -- [ Convention =>] convention_IDENTIFIER,
6430 -- [ Entity =>] local_NAME
6431 -- [, [External_Name =>] static_string_EXPRESSION ]
6432 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6434 when Pragma_External => External : declare
6444 Check_At_Least_N_Arguments (2);
6445 Check_At_Most_N_Arguments (4);
6446 Process_Convention (C, Def_Id);
6447 Note_Possible_Modification (Expression (Arg2));
6448 Process_Interface_Name (Def_Id, Arg3, Arg4);
6449 Set_Exported (Def_Id, Arg2);
6452 --------------------------
6453 -- External_Name_Casing --
6454 --------------------------
6456 -- pragma External_Name_Casing (
6457 -- UPPERCASE | LOWERCASE
6458 -- [, AS_IS | UPPERCASE | LOWERCASE]);
6460 when Pragma_External_Name_Casing => External_Name_Casing : declare
6463 Check_No_Identifiers;
6465 if Arg_Count = 2 then
6467 (Arg2, Name_As_Is, Name_Uppercase, Name_Lowercase);
6469 case Chars (Get_Pragma_Arg (Arg2)) is
6471 Opt.External_Name_Exp_Casing := As_Is;
6473 when Name_Uppercase =>
6474 Opt.External_Name_Exp_Casing := Uppercase;
6476 when Name_Lowercase =>
6477 Opt.External_Name_Exp_Casing := Lowercase;
6484 Check_Arg_Count (1);
6487 Check_Arg_Is_One_Of (Arg1, Name_Uppercase, Name_Lowercase);
6489 case Chars (Get_Pragma_Arg (Arg1)) is
6490 when Name_Uppercase =>
6491 Opt.External_Name_Imp_Casing := Uppercase;
6493 when Name_Lowercase =>
6494 Opt.External_Name_Imp_Casing := Lowercase;
6499 end External_Name_Casing;
6501 ---------------------------
6502 -- Finalize_Storage_Only --
6503 ---------------------------
6505 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
6507 when Pragma_Finalize_Storage_Only => Finalize_Storage : declare
6508 Assoc : constant Node_Id := Arg1;
6509 Type_Id : constant Node_Id := Expression (Assoc);
6513 Check_No_Identifiers;
6514 Check_Arg_Count (1);
6515 Check_Arg_Is_Local_Name (Arg1);
6517 Find_Type (Type_Id);
6518 Typ := Entity (Type_Id);
6521 or else Rep_Item_Too_Early (Typ, N)
6525 Typ := Underlying_Type (Typ);
6528 if not Is_Controlled (Typ) then
6529 Error_Pragma ("pragma% must specify controlled type");
6532 Check_First_Subtype (Arg1);
6534 if Finalize_Storage_Only (Typ) then
6535 Error_Pragma ("duplicate pragma%, only one allowed");
6537 elsif not Rep_Item_Too_Late (Typ, N) then
6538 Set_Finalize_Storage_Only (Base_Type (Typ), True);
6540 end Finalize_Storage;
6542 --------------------------
6543 -- Float_Representation --
6544 --------------------------
6546 -- pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
6548 -- FLOAT_REP ::= VAX_Float | IEEE_Float
6550 when Pragma_Float_Representation => Float_Representation : declare
6558 if Arg_Count = 1 then
6559 Check_Valid_Configuration_Pragma;
6561 Check_Arg_Count (2);
6562 Check_Optional_Identifier (Arg2, Name_Entity);
6563 Check_Arg_Is_Local_Name (Arg2);
6566 Check_No_Identifier (Arg1);
6567 Check_Arg_Is_One_Of (Arg1, Name_VAX_Float, Name_IEEE_Float);
6569 if not OpenVMS_On_Target then
6570 if Chars (Expression (Arg1)) = Name_VAX_Float then
6572 ("?pragma% ignored (applies only to Open'V'M'S)");
6578 -- One argument case
6580 if Arg_Count = 1 then
6581 if Chars (Expression (Arg1)) = Name_VAX_Float then
6582 if Opt.Float_Format = 'I' then
6583 Error_Pragma ("'I'E'E'E format previously specified");
6586 Opt.Float_Format := 'V';
6589 if Opt.Float_Format = 'V' then
6590 Error_Pragma ("'V'A'X format previously specified");
6593 Opt.Float_Format := 'I';
6596 Set_Standard_Fpt_Formats;
6598 -- Two argument case
6601 Argx := Get_Pragma_Arg (Arg2);
6603 if not Is_Entity_Name (Argx)
6604 or else not Is_Floating_Point_Type (Entity (Argx))
6607 ("second argument of% pragma must be floating-point type",
6611 Ent := Entity (Argx);
6612 Digs := UI_To_Int (Digits_Value (Ent));
6614 -- Two arguments, VAX_Float case
6616 if Chars (Expression (Arg1)) = Name_VAX_Float then
6618 when 6 => Set_F_Float (Ent);
6619 when 9 => Set_D_Float (Ent);
6620 when 15 => Set_G_Float (Ent);
6624 ("wrong digits value, must be 6,9 or 15", Arg2);
6627 -- Two arguments, IEEE_Float case
6631 when 6 => Set_IEEE_Short (Ent);
6632 when 15 => Set_IEEE_Long (Ent);
6636 ("wrong digits value, must be 6 or 15", Arg2);
6640 end Float_Representation;
6646 -- pragma Ident (static_string_EXPRESSION)
6648 -- Note: pragma Comment shares this processing. Pragma Comment
6649 -- is identical to Ident, except that the restriction of the
6650 -- argument to 31 characters and the placement restrictions
6651 -- are not enforced for pragma Comment.
6653 when Pragma_Ident | Pragma_Comment => Ident : declare
6658 Check_Arg_Count (1);
6659 Check_No_Identifiers;
6660 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
6662 -- For pragma Ident, preserve DEC compatibility by requiring
6663 -- the pragma to appear in a declarative part or package spec.
6665 if Prag_Id = Pragma_Ident then
6666 Check_Is_In_Decl_Part_Or_Package_Spec;
6669 Str := Expr_Value_S (Expression (Arg1));
6676 GP := Parent (Parent (N));
6678 if Nkind (GP) = N_Package_Declaration
6680 Nkind (GP) = N_Generic_Package_Declaration
6685 -- If we have a compilation unit, then record the ident
6686 -- value, checking for improper duplication.
6688 if Nkind (GP) = N_Compilation_Unit then
6689 CS := Ident_String (Current_Sem_Unit);
6691 if Present (CS) then
6693 -- For Ident, we do not permit multiple instances
6695 if Prag_Id = Pragma_Ident then
6696 Error_Pragma ("duplicate% pragma not permitted");
6698 -- For Comment, we concatenate the string, unless we
6699 -- want to preserve the tree structure for ASIS.
6701 elsif not ASIS_Mode then
6702 Start_String (Strval (CS));
6703 Store_String_Char (' ');
6704 Store_String_Chars (Strval (Str));
6705 Set_Strval (CS, End_String);
6709 -- In VMS, the effect of IDENT is achieved by passing
6710 -- IDENTIFICATION=name as a --for-linker switch.
6712 if OpenVMS_On_Target then
6715 ("--for-linker=IDENTIFICATION=");
6716 String_To_Name_Buffer (Strval (Str));
6717 Store_String_Chars (Name_Buffer (1 .. Name_Len));
6719 -- Only the last processed IDENT is saved. The main
6720 -- purpose is so an IDENT associated with a main
6721 -- procedure will be used in preference to an IDENT
6722 -- associated with a with'd package.
6724 Replace_Linker_Option_String
6725 (End_String, "--for-linker=IDENTIFICATION=");
6728 Set_Ident_String (Current_Sem_Unit, Str);
6731 -- For subunits, we just ignore the Ident, since in GNAT
6732 -- these are not separate object files, and hence not
6733 -- separate units in the unit table.
6735 elsif Nkind (GP) = N_Subunit then
6738 -- Otherwise we have a misplaced pragma Ident, but we ignore
6739 -- this if we are in an instantiation, since it comes from
6740 -- a generic, and has no relevance to the instantiation.
6742 elsif Prag_Id = Pragma_Ident then
6743 if Instantiation_Location (Loc) = No_Location then
6744 Error_Pragma ("pragma% only allowed at outer level");
6755 -- [ Convention =>] convention_IDENTIFIER,
6756 -- [ Entity =>] local_NAME
6757 -- [, [External_Name =>] static_string_EXPRESSION ]
6758 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6760 when Pragma_Import =>
6761 Check_Ada_83_Warning;
6767 Check_At_Least_N_Arguments (2);
6768 Check_At_Most_N_Arguments (4);
6769 Process_Import_Or_Interface;
6771 ----------------------
6772 -- Import_Exception --
6773 ----------------------
6775 -- pragma Import_Exception (
6776 -- [Internal =>] LOCAL_NAME,
6777 -- [, [External =>] EXTERNAL_SYMBOL,]
6778 -- [, [Form =>] Ada | VMS]
6779 -- [, [Code =>] static_integer_EXPRESSION]);
6781 when Pragma_Import_Exception => Import_Exception : declare
6782 Args : Args_List (1 .. 4);
6783 Names : constant Name_List (1 .. 4) := (
6789 Internal : Node_Id renames Args (1);
6790 External : Node_Id renames Args (2);
6791 Form : Node_Id renames Args (3);
6792 Code : Node_Id renames Args (4);
6795 Gather_Associations (Names, Args);
6797 if Present (External) and then Present (Code) then
6799 ("cannot give both External and Code options for pragma%");
6802 Process_Extended_Import_Export_Exception_Pragma (
6803 Arg_Internal => Internal,
6804 Arg_External => External,
6808 if not Is_VMS_Exception (Entity (Internal)) then
6809 Set_Imported (Entity (Internal));
6811 end Import_Exception;
6813 ---------------------
6814 -- Import_Function --
6815 ---------------------
6817 -- pragma Import_Function (
6818 -- [Internal =>] LOCAL_NAME,
6819 -- [, [External =>] EXTERNAL_SYMBOL]
6820 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6821 -- [, [Result_Type =>] SUBTYPE_MARK]
6822 -- [, [Mechanism =>] MECHANISM]
6823 -- [, [Result_Mechanism =>] MECHANISM_NAME]
6824 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6826 -- EXTERNAL_SYMBOL ::=
6828 -- | static_string_EXPRESSION
6830 -- PARAMETER_TYPES ::=
6832 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6834 -- TYPE_DESIGNATOR ::=
6836 -- | subtype_Name ' Access
6840 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6842 -- MECHANISM_ASSOCIATION ::=
6843 -- [formal_parameter_NAME =>] MECHANISM_NAME
6845 -- MECHANISM_NAME ::=
6848 -- | Descriptor [([Class =>] CLASS_NAME)]
6850 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6852 when Pragma_Import_Function => Import_Function : declare
6853 Args : Args_List (1 .. 7);
6854 Names : constant Name_List (1 .. 7) := (
6857 Name_Parameter_Types,
6860 Name_Result_Mechanism,
6861 Name_First_Optional_Parameter);
6863 Internal : Node_Id renames Args (1);
6864 External : Node_Id renames Args (2);
6865 Parameter_Types : Node_Id renames Args (3);
6866 Result_Type : Node_Id renames Args (4);
6867 Mechanism : Node_Id renames Args (5);
6868 Result_Mechanism : Node_Id renames Args (6);
6869 First_Optional_Parameter : Node_Id renames Args (7);
6873 Gather_Associations (Names, Args);
6874 Process_Extended_Import_Export_Subprogram_Pragma (
6875 Arg_Internal => Internal,
6876 Arg_External => External,
6877 Arg_Parameter_Types => Parameter_Types,
6878 Arg_Result_Type => Result_Type,
6879 Arg_Mechanism => Mechanism,
6880 Arg_Result_Mechanism => Result_Mechanism,
6881 Arg_First_Optional_Parameter => First_Optional_Parameter);
6882 end Import_Function;
6888 -- pragma Import_Object (
6889 -- [Internal =>] LOCAL_NAME,
6890 -- [, [External =>] EXTERNAL_SYMBOL]
6891 -- [, [Size =>] EXTERNAL_SYMBOL]);
6893 -- EXTERNAL_SYMBOL ::=
6895 -- | static_string_EXPRESSION
6897 when Pragma_Import_Object => Import_Object : declare
6898 Args : Args_List (1 .. 3);
6899 Names : constant Name_List (1 .. 3) := (
6904 Internal : Node_Id renames Args (1);
6905 External : Node_Id renames Args (2);
6906 Size : Node_Id renames Args (3);
6910 Gather_Associations (Names, Args);
6911 Process_Extended_Import_Export_Object_Pragma (
6912 Arg_Internal => Internal,
6913 Arg_External => External,
6917 ----------------------
6918 -- Import_Procedure --
6919 ----------------------
6921 -- pragma Import_Procedure (
6922 -- [Internal =>] LOCAL_NAME,
6923 -- [, [External =>] EXTERNAL_SYMBOL]
6924 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6925 -- [, [Mechanism =>] MECHANISM]
6926 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6928 -- EXTERNAL_SYMBOL ::=
6930 -- | static_string_EXPRESSION
6932 -- PARAMETER_TYPES ::=
6934 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6936 -- TYPE_DESIGNATOR ::=
6938 -- | subtype_Name ' Access
6942 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6944 -- MECHANISM_ASSOCIATION ::=
6945 -- [formal_parameter_NAME =>] MECHANISM_NAME
6947 -- MECHANISM_NAME ::=
6950 -- | Descriptor [([Class =>] CLASS_NAME)]
6952 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6954 when Pragma_Import_Procedure => Import_Procedure : declare
6955 Args : Args_List (1 .. 5);
6956 Names : constant Name_List (1 .. 5) := (
6959 Name_Parameter_Types,
6961 Name_First_Optional_Parameter);
6963 Internal : Node_Id renames Args (1);
6964 External : Node_Id renames Args (2);
6965 Parameter_Types : Node_Id renames Args (3);
6966 Mechanism : Node_Id renames Args (4);
6967 First_Optional_Parameter : Node_Id renames Args (5);
6971 Gather_Associations (Names, Args);
6972 Process_Extended_Import_Export_Subprogram_Pragma (
6973 Arg_Internal => Internal,
6974 Arg_External => External,
6975 Arg_Parameter_Types => Parameter_Types,
6976 Arg_Mechanism => Mechanism,
6977 Arg_First_Optional_Parameter => First_Optional_Parameter);
6978 end Import_Procedure;
6980 -----------------------------
6981 -- Import_Valued_Procedure --
6982 -----------------------------
6984 -- pragma Import_Valued_Procedure (
6985 -- [Internal =>] LOCAL_NAME,
6986 -- [, [External =>] EXTERNAL_SYMBOL]
6987 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6988 -- [, [Mechanism =>] MECHANISM]
6989 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6991 -- EXTERNAL_SYMBOL ::=
6993 -- | static_string_EXPRESSION
6995 -- PARAMETER_TYPES ::=
6997 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6999 -- TYPE_DESIGNATOR ::=
7001 -- | subtype_Name ' Access
7005 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7007 -- MECHANISM_ASSOCIATION ::=
7008 -- [formal_parameter_NAME =>] MECHANISM_NAME
7010 -- MECHANISM_NAME ::=
7013 -- | Descriptor [([Class =>] CLASS_NAME)]
7015 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7017 when Pragma_Import_Valued_Procedure =>
7018 Import_Valued_Procedure : declare
7019 Args : Args_List (1 .. 5);
7020 Names : constant Name_List (1 .. 5) := (
7023 Name_Parameter_Types,
7025 Name_First_Optional_Parameter);
7027 Internal : Node_Id renames Args (1);
7028 External : Node_Id renames Args (2);
7029 Parameter_Types : Node_Id renames Args (3);
7030 Mechanism : Node_Id renames Args (4);
7031 First_Optional_Parameter : Node_Id renames Args (5);
7035 Gather_Associations (Names, Args);
7036 Process_Extended_Import_Export_Subprogram_Pragma (
7037 Arg_Internal => Internal,
7038 Arg_External => External,
7039 Arg_Parameter_Types => Parameter_Types,
7040 Arg_Mechanism => Mechanism,
7041 Arg_First_Optional_Parameter => First_Optional_Parameter);
7042 end Import_Valued_Procedure;
7044 ------------------------
7045 -- Initialize_Scalars --
7046 ------------------------
7048 -- pragma Initialize_Scalars;
7050 when Pragma_Initialize_Scalars =>
7052 Check_Arg_Count (0);
7053 Check_Valid_Configuration_Pragma;
7054 Check_Restriction (No_Initialize_Scalars, N);
7056 if not Restriction_Active (No_Initialize_Scalars) then
7057 Init_Or_Norm_Scalars := True;
7058 Initialize_Scalars := True;
7065 -- pragma Inline ( NAME {, NAME} );
7067 when Pragma_Inline =>
7069 -- Pragma is active if inlining option is active
7071 Process_Inline (Inline_Active);
7077 -- pragma Inline_Always ( NAME {, NAME} );
7079 when Pragma_Inline_Always =>
7080 Process_Inline (True);
7082 --------------------
7083 -- Inline_Generic --
7084 --------------------
7086 -- pragma Inline_Generic (NAME {, NAME});
7088 when Pragma_Inline_Generic =>
7089 Process_Generic_List;
7091 ----------------------
7092 -- Inspection_Point --
7093 ----------------------
7095 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
7097 when Pragma_Inspection_Point => Inspection_Point : declare
7102 if Arg_Count > 0 then
7105 Exp := Expression (Arg);
7108 if not Is_Entity_Name (Exp)
7109 or else not Is_Object (Entity (Exp))
7111 Error_Pragma_Arg ("object name required", Arg);
7118 end Inspection_Point;
7124 -- pragma Interface (
7125 -- [ Convention =>] convention_IDENTIFIER,
7126 -- [ Entity =>] local_NAME
7127 -- [, [External_Name =>] static_string_EXPRESSION ]
7128 -- [, [Link_Name =>] static_string_EXPRESSION ]);
7130 when Pragma_Interface =>
7137 Check_At_Least_N_Arguments (2);
7138 Check_At_Most_N_Arguments (4);
7139 Process_Import_Or_Interface;
7141 --------------------
7142 -- Interface_Name --
7143 --------------------
7145 -- pragma Interface_Name (
7146 -- [ Entity =>] local_NAME
7147 -- [,[External_Name =>] static_string_EXPRESSION ]
7148 -- [,[Link_Name =>] static_string_EXPRESSION ]);
7150 when Pragma_Interface_Name => Interface_Name : declare
7159 ((Name_Entity, Name_External_Name, Name_Link_Name));
7160 Check_At_Least_N_Arguments (2);
7161 Check_At_Most_N_Arguments (3);
7162 Id := Expression (Arg1);
7165 if not Is_Entity_Name (Id) then
7167 ("first argument for pragma% must be entity name", Arg1);
7168 elsif Etype (Id) = Any_Type then
7171 Def_Id := Entity (Id);
7174 -- Special DEC-compatible processing for the object case,
7175 -- forces object to be imported.
7177 if Ekind (Def_Id) = E_Variable then
7178 Kill_Size_Check_Code (Def_Id);
7179 Note_Possible_Modification (Id);
7181 -- Initialization is not allowed for imported variable
7183 if Present (Expression (Parent (Def_Id)))
7184 and then Comes_From_Source (Expression (Parent (Def_Id)))
7186 Error_Msg_Sloc := Sloc (Def_Id);
7188 ("no initialization allowed for declaration of& #",
7192 -- For compatibility, support VADS usage of providing both
7193 -- pragmas Interface and Interface_Name to obtain the effect
7194 -- of a single Import pragma.
7196 if Is_Imported (Def_Id)
7197 and then Present (First_Rep_Item (Def_Id))
7198 and then Nkind (First_Rep_Item (Def_Id)) = N_Pragma
7199 and then Chars (First_Rep_Item (Def_Id)) = Name_Interface
7203 Set_Imported (Def_Id);
7206 Set_Is_Public (Def_Id);
7207 Process_Interface_Name (Def_Id, Arg2, Arg3);
7210 -- Otherwise must be subprogram
7212 elsif not Is_Subprogram (Def_Id) then
7214 ("argument of pragma% is not subprogram", Arg1);
7217 Check_At_Most_N_Arguments (3);
7221 -- Loop through homonyms
7224 Def_Id := Get_Base_Subprogram (Hom_Id);
7226 if Is_Imported (Def_Id) then
7227 Process_Interface_Name (Def_Id, Arg2, Arg3);
7231 Hom_Id := Homonym (Hom_Id);
7233 exit when No (Hom_Id)
7234 or else Scope (Hom_Id) /= Current_Scope;
7239 ("argument of pragma% is not imported subprogram",
7245 -----------------------
7246 -- Interrupt_Handler --
7247 -----------------------
7249 -- pragma Interrupt_Handler (handler_NAME);
7251 when Pragma_Interrupt_Handler =>
7252 Check_Ada_83_Warning;
7253 Check_Arg_Count (1);
7254 Check_No_Identifiers;
7256 if No_Run_Time_Mode then
7257 Error_Msg_CRT ("Interrupt_Handler pragma", N);
7259 Check_Interrupt_Or_Attach_Handler;
7260 Process_Interrupt_Or_Attach_Handler;
7263 ------------------------
7264 -- Interrupt_Priority --
7265 ------------------------
7267 -- pragma Interrupt_Priority [(EXPRESSION)];
7269 when Pragma_Interrupt_Priority => Interrupt_Priority : declare
7270 P : constant Node_Id := Parent (N);
7274 Check_Ada_83_Warning;
7276 if Arg_Count /= 0 then
7277 Arg := Expression (Arg1);
7278 Check_Arg_Count (1);
7279 Check_No_Identifiers;
7281 -- The expression must be analyzed in the special manner
7282 -- described in "Handling of Default and Per-Object
7283 -- Expressions" in sem.ads.
7285 Analyze_Per_Use_Expression (Arg, RTE (RE_Interrupt_Priority));
7288 if Nkind (P) /= N_Task_Definition
7289 and then Nkind (P) /= N_Protected_Definition
7294 elsif Has_Priority_Pragma (P) then
7295 Error_Pragma ("duplicate pragma% not allowed");
7298 Set_Has_Priority_Pragma (P, True);
7299 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
7301 end Interrupt_Priority;
7303 ---------------------
7304 -- Interrupt_State --
7305 ---------------------
7307 -- pragma Interrupt_State (
7308 -- [Name =>] INTERRUPT_ID,
7309 -- [State =>] INTERRUPT_STATE);
7311 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
7312 -- INTERRUPT_STATE => System | Runtime | User
7314 -- Note: if the interrupt id is given as an identifier, then
7315 -- it must be one of the identifiers in Ada.Interrupts.Names.
7316 -- Otherwise it is given as a static integer expression which
7317 -- must be in the range of Ada.Interrupts.Interrupt_ID.
7319 when Pragma_Interrupt_State => Interrupt_State : declare
7321 Int_Id : constant Entity_Id := RTE (RE_Interrupt_ID);
7322 -- This is the entity Ada.Interrupts.Interrupt_ID;
7324 State_Type : Character;
7325 -- Set to 's'/'r'/'u' for System/Runtime/User
7328 -- Index to entry in Interrupt_States table
7331 -- Value of interrupt
7333 Arg1X : constant Node_Id := Get_Pragma_Arg (Arg1);
7334 -- The first argument to the pragma
7336 Int_Ent : Entity_Id;
7337 -- Interrupt entity in Ada.Interrupts.Names
7341 Check_Arg_Order ((Name_Name, Name_State));
7342 Check_Arg_Count (2);
7344 Check_Optional_Identifier (Arg1, Name_Name);
7345 Check_Optional_Identifier (Arg2, Name_State);
7346 Check_Arg_Is_Identifier (Arg2);
7348 -- First argument is identifier
7350 if Nkind (Arg1X) = N_Identifier then
7352 -- Search list of names in Ada.Interrupts.Names
7354 Int_Ent := First_Entity (RTE (RE_Names));
7356 if No (Int_Ent) then
7357 Error_Pragma_Arg ("invalid interrupt name", Arg1);
7359 elsif Chars (Int_Ent) = Chars (Arg1X) then
7360 Int_Val := Expr_Value (Constant_Value (Int_Ent));
7364 Next_Entity (Int_Ent);
7367 -- First argument is not an identifier, so it must be a
7368 -- static expression of type Ada.Interrupts.Interrupt_ID.
7371 Check_Arg_Is_Static_Expression (Arg1, Any_Integer);
7372 Int_Val := Expr_Value (Arg1X);
7374 if Int_Val < Expr_Value (Type_Low_Bound (Int_Id))
7376 Int_Val > Expr_Value (Type_High_Bound (Int_Id))
7379 ("value not in range of type " &
7380 """Ada.Interrupts.Interrupt_'I'D""", Arg1);
7386 case Chars (Get_Pragma_Arg (Arg2)) is
7387 when Name_Runtime => State_Type := 'r';
7388 when Name_System => State_Type := 's';
7389 when Name_User => State_Type := 'u';
7392 Error_Pragma_Arg ("invalid interrupt state", Arg2);
7395 -- Check if entry is already stored
7397 IST_Num := Interrupt_States.First;
7399 -- If entry not found, add it
7401 if IST_Num > Interrupt_States.Last then
7402 Interrupt_States.Append
7403 ((Interrupt_Number => UI_To_Int (Int_Val),
7404 Interrupt_State => State_Type,
7405 Pragma_Loc => Loc));
7408 -- Case of entry for the same entry
7410 elsif Int_Val = Interrupt_States.Table (IST_Num).
7413 -- If state matches, done, no need to make redundant entry
7416 State_Type = Interrupt_States.Table (IST_Num).
7419 -- Otherwise if state does not match, error
7422 Interrupt_States.Table (IST_Num).Pragma_Loc;
7424 ("state conflicts with that given #", Arg2);
7428 IST_Num := IST_Num + 1;
7430 end Interrupt_State;
7432 ----------------------
7433 -- Java_Constructor --
7434 ----------------------
7436 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
7438 when Pragma_CIL_Constructor | Pragma_Java_Constructor =>
7439 Java_Constructor : declare
7443 Convention : Convention_Id;
7447 Check_Arg_Count (1);
7448 Check_Optional_Identifier (Arg1, Name_Entity);
7449 Check_Arg_Is_Local_Name (Arg1);
7451 Id := Expression (Arg1);
7452 Find_Program_Unit_Name (Id);
7454 -- If we did not find the name, we are done
7456 if Etype (Id) = Any_Type then
7461 when Pragma_CIL_Constructor => Convention := Convention_CIL;
7462 when Pragma_Java_Constructor => Convention := Convention_Java;
7463 when others => null;
7466 Hom_Id := Entity (Id);
7468 -- Loop through homonyms
7471 Def_Id := Get_Base_Subprogram (Hom_Id);
7473 -- The constructor is required to be a function returning an
7474 -- access type whose designated type has convention Java/CIL.
7476 if Ekind (Def_Id) = E_Function
7478 (Is_Value_Type (Etype (Def_Id))
7480 (Ekind (Etype (Def_Id)) in Access_Kind
7483 (Designated_Type (Etype (Def_Id))) = Convention
7486 (Root_Type (Designated_Type (Etype (Def_Id)))) =
7489 Set_Is_Constructor (Def_Id);
7490 Set_Convention (Def_Id, Convention);
7491 Set_Is_Imported (Def_Id);
7494 if Convention = Convention_Java then
7496 ("pragma% requires function returning a " &
7497 "'Java access type", Arg1);
7499 pragma Assert (Convention = Convention_CIL);
7501 ("pragma% requires function returning a " &
7502 "'CIL access type", Arg1);
7506 Hom_Id := Homonym (Hom_Id);
7508 exit when No (Hom_Id) or else Scope (Hom_Id) /= Current_Scope;
7510 end Java_Constructor;
7512 ----------------------
7513 -- Java_Interface --
7514 ----------------------
7516 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
7518 when Pragma_Java_Interface => Java_Interface : declare
7524 Check_Arg_Count (1);
7525 Check_Optional_Identifier (Arg1, Name_Entity);
7526 Check_Arg_Is_Local_Name (Arg1);
7528 Arg := Expression (Arg1);
7531 if Etype (Arg) = Any_Type then
7535 if not Is_Entity_Name (Arg)
7536 or else not Is_Type (Entity (Arg))
7538 Error_Pragma_Arg ("pragma% requires a type mark", Arg1);
7541 Typ := Underlying_Type (Entity (Arg));
7543 -- For now we simply check some of the semantic constraints
7544 -- on the type. This currently leaves out some restrictions
7545 -- on interface types, namely that the parent type must be
7546 -- java.lang.Object.Typ and that all primitives of the type
7547 -- should be declared abstract. ???
7549 if not Is_Tagged_Type (Typ) or else not Is_Abstract_Type (Typ) then
7550 Error_Pragma_Arg ("pragma% requires an abstract "
7551 & "tagged type", Arg1);
7553 elsif not Has_Discriminants (Typ)
7554 or else Ekind (Etype (First_Discriminant (Typ)))
7555 /= E_Anonymous_Access_Type
7557 not Is_Class_Wide_Type
7558 (Designated_Type (Etype (First_Discriminant (Typ))))
7561 ("type must have a class-wide access discriminant", Arg1);
7569 -- pragma Keep_Names ([On => ] local_NAME);
7571 when Pragma_Keep_Names => Keep_Names : declare
7576 Check_Arg_Count (1);
7577 Check_Optional_Identifier (Arg1, Name_On);
7578 Check_Arg_Is_Local_Name (Arg1);
7580 Arg := Expression (Arg1);
7583 if Etype (Arg) = Any_Type then
7587 if not Is_Entity_Name (Arg)
7588 or else Ekind (Entity (Arg)) /= E_Enumeration_Type
7591 ("pragma% requires a local enumeration type", Arg1);
7594 Set_Discard_Names (Entity (Arg), False);
7601 -- pragma License (RESTRICTED | UNRESTRICTED | GPL | MODIFIED_GPL);
7603 when Pragma_License =>
7605 Check_Arg_Count (1);
7606 Check_No_Identifiers;
7607 Check_Valid_Configuration_Pragma;
7608 Check_Arg_Is_Identifier (Arg1);
7611 Sind : constant Source_File_Index :=
7612 Source_Index (Current_Sem_Unit);
7615 case Chars (Get_Pragma_Arg (Arg1)) is
7617 Set_License (Sind, GPL);
7619 when Name_Modified_GPL =>
7620 Set_License (Sind, Modified_GPL);
7622 when Name_Restricted =>
7623 Set_License (Sind, Restricted);
7625 when Name_Unrestricted =>
7626 Set_License (Sind, Unrestricted);
7629 Error_Pragma_Arg ("invalid license name", Arg1);
7637 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
7639 when Pragma_Link_With => Link_With : declare
7645 if Operating_Mode = Generate_Code
7646 and then In_Extended_Main_Source_Unit (N)
7648 Check_At_Least_N_Arguments (1);
7649 Check_No_Identifiers;
7650 Check_Is_In_Decl_Part_Or_Package_Spec;
7651 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
7655 while Present (Arg) loop
7656 Check_Arg_Is_Static_Expression (Arg, Standard_String);
7658 -- Store argument, converting sequences of spaces
7659 -- to a single null character (this is one of the
7660 -- differences in processing between Link_With
7661 -- and Linker_Options).
7664 C : constant Char_Code := Get_Char_Code (' ');
7665 S : constant String_Id :=
7666 Strval (Expr_Value_S (Expression (Arg)));
7667 L : constant Nat := String_Length (S);
7670 procedure Skip_Spaces;
7671 -- Advance F past any spaces
7673 procedure Skip_Spaces is
7675 while F <= L and then Get_String_Char (S, F) = C loop
7681 Skip_Spaces; -- skip leading spaces
7683 -- Loop through characters, changing any embedded
7684 -- sequence of spaces to a single null character
7685 -- (this is how Link_With/Linker_Options differ)
7688 if Get_String_Char (S, F) = C then
7691 Store_String_Char (ASCII.NUL);
7694 Store_String_Char (Get_String_Char (S, F));
7702 if Present (Arg) then
7703 Store_String_Char (ASCII.NUL);
7707 Store_Linker_Option_String (End_String);
7715 -- pragma Linker_Alias (
7716 -- [Entity =>] LOCAL_NAME
7717 -- [Target =>] static_string_EXPRESSION);
7719 when Pragma_Linker_Alias =>
7721 Check_Arg_Order ((Name_Entity, Name_Target));
7722 Check_Arg_Count (2);
7723 Check_Optional_Identifier (Arg1, Name_Entity);
7724 Check_Optional_Identifier (Arg2, Name_Target);
7725 Check_Arg_Is_Library_Level_Local_Name (Arg1);
7726 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
7728 -- The only processing required is to link this item on to the
7729 -- list of rep items for the given entity. This is accomplished
7730 -- by the call to Rep_Item_Too_Late (when no error is detected
7731 -- and False is returned).
7733 if Rep_Item_Too_Late (Entity (Expression (Arg1)), N) then
7736 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
7739 ------------------------
7740 -- Linker_Constructor --
7741 ------------------------
7743 -- pragma Linker_Constructor (procedure_LOCAL_NAME);
7745 -- Code is shared with Linker_Destructor
7747 -----------------------
7748 -- Linker_Destructor --
7749 -----------------------
7751 -- pragma Linker_Destructor (procedure_LOCAL_NAME);
7753 when Pragma_Linker_Constructor |
7754 Pragma_Linker_Destructor =>
7755 Linker_Constructor : declare
7761 Check_Arg_Count (1);
7762 Check_No_Identifiers;
7763 Check_Arg_Is_Local_Name (Arg1);
7764 Arg1_X := Expression (Arg1);
7766 Proc := Find_Unique_Parameterless_Procedure (Arg1_X, Arg1);
7768 if not Is_Library_Level_Entity (Proc) then
7770 ("argument for pragma% must be library level entity", Arg1);
7773 -- The only processing required is to link this item on to the
7774 -- list of rep items for the given entity. This is accomplished
7775 -- by the call to Rep_Item_Too_Late (when no error is detected
7776 -- and False is returned).
7778 if Rep_Item_Too_Late (Proc, N) then
7781 Set_Has_Gigi_Rep_Item (Proc);
7783 end Linker_Constructor;
7785 --------------------
7786 -- Linker_Options --
7787 --------------------
7789 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
7791 when Pragma_Linker_Options => Linker_Options : declare
7795 Check_Ada_83_Warning;
7796 Check_No_Identifiers;
7797 Check_Arg_Count (1);
7798 Check_Is_In_Decl_Part_Or_Package_Spec;
7800 if Operating_Mode = Generate_Code
7801 and then In_Extended_Main_Source_Unit (N)
7803 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
7804 Start_String (Strval (Expr_Value_S (Expression (Arg1))));
7807 while Present (Arg) loop
7808 Check_Arg_Is_Static_Expression (Arg, Standard_String);
7809 Store_String_Char (ASCII.NUL);
7811 (Strval (Expr_Value_S (Expression (Arg))));
7815 Store_Linker_Option_String (End_String);
7819 --------------------
7820 -- Linker_Section --
7821 --------------------
7823 -- pragma Linker_Section (
7824 -- [Entity =>] LOCAL_NAME
7825 -- [Section =>] static_string_EXPRESSION);
7827 when Pragma_Linker_Section =>
7829 Check_Arg_Order ((Name_Entity, Name_Section));
7830 Check_Arg_Count (2);
7831 Check_Optional_Identifier (Arg1, Name_Entity);
7832 Check_Optional_Identifier (Arg2, Name_Section);
7833 Check_Arg_Is_Library_Level_Local_Name (Arg1);
7834 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
7836 -- The only processing required is to link this item on to the
7837 -- list of rep items for the given entity. This is accomplished
7838 -- by the call to Rep_Item_Too_Late (when no error is detected
7839 -- and False is returned).
7841 if Rep_Item_Too_Late (Entity (Expression (Arg1)), N) then
7844 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
7851 -- pragma List (On | Off)
7853 -- There is nothing to do here, since we did all the processing
7854 -- for this pragma in Par.Prag (so that it works properly even in
7855 -- syntax only mode)
7860 --------------------
7861 -- Locking_Policy --
7862 --------------------
7864 -- pragma Locking_Policy (policy_IDENTIFIER);
7866 when Pragma_Locking_Policy => declare
7870 Check_Ada_83_Warning;
7871 Check_Arg_Count (1);
7872 Check_No_Identifiers;
7873 Check_Arg_Is_Locking_Policy (Arg1);
7874 Check_Valid_Configuration_Pragma;
7875 Get_Name_String (Chars (Expression (Arg1)));
7876 LP := Fold_Upper (Name_Buffer (1));
7878 if Locking_Policy /= ' '
7879 and then Locking_Policy /= LP
7881 Error_Msg_Sloc := Locking_Policy_Sloc;
7882 Error_Pragma ("locking policy incompatible with policy#");
7884 -- Set new policy, but always preserve System_Location since
7885 -- we like the error message with the run time name.
7888 Locking_Policy := LP;
7890 if Locking_Policy_Sloc /= System_Location then
7891 Locking_Policy_Sloc := Loc;
7900 -- pragma Long_Float (D_Float | G_Float);
7902 when Pragma_Long_Float =>
7904 Check_Valid_Configuration_Pragma;
7905 Check_Arg_Count (1);
7906 Check_No_Identifier (Arg1);
7907 Check_Arg_Is_One_Of (Arg1, Name_D_Float, Name_G_Float);
7909 if not OpenVMS_On_Target then
7910 Error_Pragma ("?pragma% ignored (applies only to Open'V'M'S)");
7915 if Chars (Expression (Arg1)) = Name_D_Float then
7916 if Opt.Float_Format_Long = 'G' then
7917 Error_Pragma ("G_Float previously specified");
7920 Opt.Float_Format_Long := 'D';
7922 -- G_Float case (this is the default, does not need overriding)
7925 if Opt.Float_Format_Long = 'D' then
7926 Error_Pragma ("D_Float previously specified");
7929 Opt.Float_Format_Long := 'G';
7932 Set_Standard_Fpt_Formats;
7934 -----------------------
7935 -- Machine_Attribute --
7936 -----------------------
7938 -- pragma Machine_Attribute (
7939 -- [Entity =>] LOCAL_NAME,
7940 -- [Attribute_Name =>] static_string_EXPRESSION
7941 -- [,[Info =>] static_string_EXPRESSION] );
7943 when Pragma_Machine_Attribute => Machine_Attribute : declare
7948 Check_Arg_Order ((Name_Entity, Name_Attribute_Name, Name_Info));
7950 if Arg_Count = 3 then
7951 Check_Optional_Identifier (Arg3, Name_Info);
7952 Check_Arg_Is_Static_Expression (Arg3, Standard_String);
7954 Check_Arg_Count (2);
7957 Check_Optional_Identifier (Arg1, Name_Entity);
7958 Check_Optional_Identifier (Arg2, Name_Attribute_Name);
7959 Check_Arg_Is_Local_Name (Arg1);
7960 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
7961 Def_Id := Entity (Expression (Arg1));
7963 if Is_Access_Type (Def_Id) then
7964 Def_Id := Designated_Type (Def_Id);
7967 if Rep_Item_Too_Early (Def_Id, N) then
7971 Def_Id := Underlying_Type (Def_Id);
7973 -- The only processing required is to link this item on to the
7974 -- list of rep items for the given entity. This is accomplished
7975 -- by the call to Rep_Item_Too_Late (when no error is detected
7976 -- and False is returned).
7978 if Rep_Item_Too_Late (Def_Id, N) then
7981 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
7983 end Machine_Attribute;
7989 -- pragma Main_Storage
7990 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
7992 -- MAIN_STORAGE_OPTION ::=
7993 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
7994 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
7996 when Pragma_Main => Main : declare
7997 Args : Args_List (1 .. 3);
7998 Names : constant Name_List (1 .. 3) := (
8000 Name_Task_Stack_Size_Default,
8001 Name_Time_Slicing_Enabled);
8007 Gather_Associations (Names, Args);
8009 for J in 1 .. 2 loop
8010 if Present (Args (J)) then
8011 Check_Arg_Is_Static_Expression (Args (J), Any_Integer);
8015 if Present (Args (3)) then
8016 Check_Arg_Is_Static_Expression (Args (3), Standard_Boolean);
8020 while Present (Nod) loop
8021 if Nkind (Nod) = N_Pragma
8022 and then Chars (Nod) = Name_Main
8024 Error_Msg_Name_1 := Chars (N);
8025 Error_Msg_N ("duplicate pragma% not permitted", Nod);
8036 -- pragma Main_Storage
8037 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
8039 -- MAIN_STORAGE_OPTION ::=
8040 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
8041 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
8043 when Pragma_Main_Storage => Main_Storage : declare
8044 Args : Args_List (1 .. 2);
8045 Names : constant Name_List (1 .. 2) := (
8046 Name_Working_Storage,
8053 Gather_Associations (Names, Args);
8055 for J in 1 .. 2 loop
8056 if Present (Args (J)) then
8057 Check_Arg_Is_Static_Expression (Args (J), Any_Integer);
8061 Check_In_Main_Program;
8064 while Present (Nod) loop
8065 if Nkind (Nod) = N_Pragma
8066 and then Chars (Nod) = Name_Main_Storage
8068 Error_Msg_Name_1 := Chars (N);
8069 Error_Msg_N ("duplicate pragma% not permitted", Nod);
8080 -- pragma Memory_Size (NUMERIC_LITERAL)
8082 when Pragma_Memory_Size =>
8085 -- Memory size is simply ignored
8087 Check_No_Identifiers;
8088 Check_Arg_Count (1);
8089 Check_Arg_Is_Integer_Literal (Arg1);
8097 -- The only correct use of this pragma is on its own in a file, in
8098 -- which case it is specially processed (see Gnat1drv.Check_Bad_Body
8099 -- and Frontend, which use Sinput.L.Source_File_Is_Pragma_No_Body to
8100 -- check for a file containing nothing but a No_Body pragma). If we
8101 -- attempt to process it during normal semantics processing, it means
8102 -- it was misplaced.
8104 when Pragma_No_Body =>
8105 Error_Pragma ("misplaced pragma %");
8111 -- pragma No_Return (procedure_LOCAL_NAME {, procedure_Local_Name});
8113 when Pragma_No_Return => No_Return : declare
8121 Check_At_Least_N_Arguments (1);
8123 -- Loop through arguments of pragma
8126 while Present (Arg) loop
8127 Check_Arg_Is_Local_Name (Arg);
8128 Id := Expression (Arg);
8131 if not Is_Entity_Name (Id) then
8132 Error_Pragma_Arg ("entity name required", Arg);
8135 if Etype (Id) = Any_Type then
8139 -- Loop to find matching procedures
8144 and then Scope (E) = Current_Scope
8146 if Ekind (E) = E_Procedure
8147 or else Ekind (E) = E_Generic_Procedure
8157 Error_Pragma_Arg ("no procedure & found for pragma%", Arg);
8164 ------------------------
8165 -- No_Strict_Aliasing --
8166 ------------------------
8168 -- pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
8170 when Pragma_No_Strict_Aliasing => No_Strict_Alias : declare
8175 Check_At_Most_N_Arguments (1);
8177 if Arg_Count = 0 then
8178 Check_Valid_Configuration_Pragma;
8179 Opt.No_Strict_Aliasing := True;
8182 Check_Optional_Identifier (Arg2, Name_Entity);
8183 Check_Arg_Is_Local_Name (Arg1);
8184 E_Id := Entity (Expression (Arg1));
8186 if E_Id = Any_Type then
8188 elsif No (E_Id) or else not Is_Access_Type (E_Id) then
8189 Error_Pragma_Arg ("pragma% requires access type", Arg1);
8192 Set_No_Strict_Aliasing (Implementation_Base_Type (E_Id));
8194 end No_Strict_Alias;
8200 -- pragma Obsolescent [(
8201 -- [Entity => NAME,]
8202 -- [(static_string_EXPRESSION [, Ada_05])];
8204 when Pragma_Obsolescent => Obsolescent : declare
8208 procedure Set_Obsolescent (E : Entity_Id);
8209 -- Given an entity Ent, mark it as obsolescent if appropriate
8211 ---------------------
8212 -- Set_Obsolescent --
8213 ---------------------
8215 procedure Set_Obsolescent (E : Entity_Id) is
8224 -- Entity name was given
8226 if Present (Ename) then
8228 -- If entity name matches, we are fine
8230 if Chars (Ename) = Chars (Ent) then
8233 -- If entity name does not match, only possibility is an
8234 -- enumeration literal from an enumeration type declaration.
8236 elsif Ekind (Ent) /= E_Enumeration_Type then
8238 ("pragma % entity name does not match declaration");
8241 Ent := First_Literal (E);
8245 ("pragma % entity name does not match any " &
8246 "enumeration literal");
8248 elsif Chars (Ent) = Chars (Ename) then
8252 Ent := Next_Literal (Ent);
8258 -- Ent points to entity to be marked
8260 if Arg_Count >= 1 then
8262 -- Deal with static string argument
8264 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
8265 S := Strval (Expression (Arg1));
8267 for J in 1 .. String_Length (S) loop
8268 if not In_Character_Range (Get_String_Char (S, J)) then
8270 ("pragma% argument does not allow wide characters",
8275 Set_Obsolescent_Warning (Ent, Expression (Arg1));
8277 -- Check for Ada_05 parameter
8279 if Arg_Count /= 1 then
8280 Check_Arg_Count (2);
8283 Argx : constant Node_Id := Get_Pragma_Arg (Arg2);
8286 Check_Arg_Is_Identifier (Argx);
8288 if Chars (Argx) /= Name_Ada_05 then
8289 Error_Msg_Name_2 := Name_Ada_05;
8291 ("only allowed argument for pragma% is %", Argx);
8294 if Ada_Version_Explicit < Ada_05
8295 or else not Warn_On_Ada_2005_Compatibility
8303 -- Set flag if pragma active
8306 Set_Is_Obsolescent (Ent);
8310 end Set_Obsolescent;
8312 -- Start of processing for pragma Obsolescent
8317 Check_At_Most_N_Arguments (3);
8319 -- See if first argument specifies an entity name
8322 and then Chars (Arg1) = Name_Entity
8324 Ename := Get_Pragma_Arg (Arg1);
8326 if Nkind (Ename) /= N_Character_Literal
8328 Nkind (Ename) /= N_Identifier
8330 Nkind (Ename) /= N_Operator_Symbol
8332 Error_Pragma_Arg ("entity name expected for pragma%", Arg1);
8335 -- Eliminate first argument, so we can share processing
8339 Arg_Count := Arg_Count - 1;
8341 -- No Entity name argument given
8347 Check_No_Identifiers;
8349 -- Get immediately preceding declaration
8352 while Present (Decl) and then Nkind (Decl) = N_Pragma loop
8356 -- Cases where we do not follow anything other than another pragma
8360 -- First case: library level compilation unit declaration with
8361 -- the pragma immediately following the declaration.
8363 if Nkind (Parent (N)) = N_Compilation_Unit_Aux then
8365 (Defining_Entity (Unit (Parent (Parent (N)))));
8368 -- Case 2: library unit placement for package
8372 Ent : constant Entity_Id := Find_Lib_Unit_Name;
8374 if Ekind (Ent) = E_Package
8375 or else Ekind (Ent) = E_Generic_Package
8377 Set_Obsolescent (Ent);
8383 -- Cases where we must follow a declaration
8386 if Nkind (Decl) not in N_Declaration
8387 and then Nkind (Decl) not in N_Later_Decl_Item
8388 and then Nkind (Decl) not in N_Generic_Declaration
8391 ("pragma% misplaced, " &
8392 "must immediately follow a declaration");
8395 Set_Obsolescent (Defining_Entity (Decl));
8405 -- pragma No_Run_Time
8407 -- Note: this pragma is retained for backwards compatibiltiy.
8408 -- See body of Rtsfind for full details on its handling.
8410 when Pragma_No_Run_Time =>
8412 Check_Valid_Configuration_Pragma;
8413 Check_Arg_Count (0);
8415 No_Run_Time_Mode := True;
8416 Configurable_Run_Time_Mode := True;
8419 Word32 : constant Boolean := Ttypes.System_Word_Size = 32;
8422 Duration_32_Bits_On_Target := True;
8426 Set_Restriction (No_Finalization, N);
8427 Set_Restriction (No_Exception_Handlers, N);
8428 Set_Restriction (Max_Tasks, N, 0);
8429 Set_Restriction (No_Tasking, N);
8431 -----------------------
8432 -- Normalize_Scalars --
8433 -----------------------
8435 -- pragma Normalize_Scalars;
8437 when Pragma_Normalize_Scalars =>
8438 Check_Ada_83_Warning;
8439 Check_Arg_Count (0);
8440 Check_Valid_Configuration_Pragma;
8441 Normalize_Scalars := True;
8442 Init_Or_Norm_Scalars := True;
8448 -- pragma Optimize (Time | Space);
8450 -- The actual check for optimize is done in Gigi. Note that this
8451 -- pragma does not actually change the optimization setting, it
8452 -- simply checks that it is consistent with the pragma.
8454 when Pragma_Optimize =>
8455 Check_No_Identifiers;
8456 Check_Arg_Count (1);
8457 Check_Arg_Is_One_Of (Arg1, Name_Time, Name_Space, Name_Off);
8463 -- pragma Pack (first_subtype_LOCAL_NAME);
8465 when Pragma_Pack => Pack : declare
8466 Assoc : constant Node_Id := Arg1;
8471 Check_No_Identifiers;
8472 Check_Arg_Count (1);
8473 Check_Arg_Is_Local_Name (Arg1);
8475 Type_Id := Expression (Assoc);
8476 Find_Type (Type_Id);
8477 Typ := Entity (Type_Id);
8480 or else Rep_Item_Too_Early (Typ, N)
8484 Typ := Underlying_Type (Typ);
8487 if not Is_Array_Type (Typ) and then not Is_Record_Type (Typ) then
8488 Error_Pragma ("pragma% must specify array or record type");
8491 Check_First_Subtype (Arg1);
8493 if Has_Pragma_Pack (Typ) then
8494 Error_Pragma ("duplicate pragma%, only one allowed");
8498 elsif Is_Array_Type (Typ) then
8500 -- Pack not allowed for aliased or atomic components
8502 if Has_Aliased_Components (Base_Type (Typ)) then
8504 ("pragma% ignored, cannot pack aliased components?");
8506 elsif Has_Atomic_Components (Typ)
8507 or else Is_Atomic (Component_Type (Typ))
8510 ("?pragma% ignored, cannot pack atomic components");
8513 -- If we had an explicit component size given, then we do not
8514 -- let Pack override this given size. We also give a warning
8515 -- that Pack is being ignored unless we can tell for sure that
8516 -- the Pack would not have had any effect anyway.
8518 if Has_Component_Size_Clause (Typ) then
8519 if Known_Static_RM_Size (Component_Type (Typ))
8521 RM_Size (Component_Type (Typ)) = Component_Size (Typ)
8526 ("?pragma% ignored, explicit component size given");
8529 -- If no prior array component size given, Pack is effective
8532 if not Rep_Item_Too_Late (Typ, N) then
8533 if VM_Target = No_VM then
8534 Set_Is_Packed (Base_Type (Typ));
8535 elsif not GNAT_Mode then
8537 ("?pragma% ignored in this configuration");
8540 Set_Has_Pragma_Pack (Base_Type (Typ));
8541 Set_Has_Non_Standard_Rep (Base_Type (Typ));
8545 -- For record types, the pack is always effective
8547 else pragma Assert (Is_Record_Type (Typ));
8548 if not Rep_Item_Too_Late (Typ, N) then
8549 if VM_Target = No_VM then
8550 Set_Is_Packed (Base_Type (Typ));
8551 elsif not GNAT_Mode then
8552 Error_Pragma ("?pragma% ignored in this configuration");
8555 Set_Has_Pragma_Pack (Base_Type (Typ));
8556 Set_Has_Non_Standard_Rep (Base_Type (Typ));
8567 -- There is nothing to do here, since we did all the processing
8568 -- for this pragma in Par.Prag (so that it works properly even in
8569 -- syntax only mode)
8578 -- pragma Passive [(PASSIVE_FORM)];
8580 -- PASSIVE_FORM ::= Semaphore | No
8582 when Pragma_Passive =>
8585 if Nkind (Parent (N)) /= N_Task_Definition then
8586 Error_Pragma ("pragma% must be within task definition");
8589 if Arg_Count /= 0 then
8590 Check_Arg_Count (1);
8591 Check_Arg_Is_One_Of (Arg1, Name_Semaphore, Name_No);
8594 ----------------------------------
8595 -- Preelaborable_Initialization --
8596 ----------------------------------
8598 -- pragma Preelaborable_Initialization (DIRECT_NAME);
8600 when Pragma_Preelaborable_Initialization => Preelab_Init : declare
8605 Check_Arg_Count (1);
8606 Check_No_Identifiers;
8607 Check_Arg_Is_Identifier (Arg1);
8608 Check_Arg_Is_Local_Name (Arg1);
8609 Check_First_Subtype (Arg1);
8610 Ent := Entity (Expression (Arg1));
8612 if not Is_Private_Type (Ent) then
8614 ("pragma % can only be applied to private type", Arg1);
8617 Set_Known_To_Have_Preelab_Init (Ent);
8624 -- pragma Polling (ON | OFF);
8626 when Pragma_Polling =>
8628 Check_Arg_Count (1);
8629 Check_No_Identifiers;
8630 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
8631 Polling_Required := (Chars (Expression (Arg1)) = Name_On);
8633 --------------------
8634 -- Persistent_BSS --
8635 --------------------
8637 when Pragma_Persistent_BSS => Persistent_BSS : declare
8644 Check_At_Most_N_Arguments (1);
8646 -- Case of application to specific object (one argument)
8648 if Arg_Count = 1 then
8649 Check_Arg_Is_Library_Level_Local_Name (Arg1);
8651 if not Is_Entity_Name (Expression (Arg1))
8653 (Ekind (Entity (Expression (Arg1))) /= E_Variable
8654 and then Ekind (Entity (Expression (Arg1))) /= E_Constant)
8656 Error_Pragma_Arg ("pragma% only applies to objects", Arg1);
8659 Ent := Entity (Expression (Arg1));
8660 Decl := Parent (Ent);
8662 if Rep_Item_Too_Late (Ent, N) then
8666 if Present (Expression (Decl)) then
8668 ("object for pragma% cannot have initialization", Arg1);
8671 if not Is_Potentially_Persistent_Type (Etype (Ent)) then
8673 ("object type for pragma% is not potentially persistent",
8678 Make_Linker_Section_Pragma
8679 (Ent, Sloc (N), ".persistent.bss");
8680 Insert_After (N, Prag);
8683 -- Case of use as configuration pragma with no arguments
8686 Check_Valid_Configuration_Pragma;
8687 Persistent_BSS_Mode := True;
8695 -- pragma Preelaborate [(library_unit_NAME)];
8697 -- Set the flag Is_Preelaborated of program unit name entity
8699 when Pragma_Preelaborate => Preelaborate : declare
8700 Pa : constant Node_Id := Parent (N);
8701 Pk : constant Node_Kind := Nkind (Pa);
8705 Check_Ada_83_Warning;
8706 Check_Valid_Library_Unit_Pragma;
8708 if Nkind (N) = N_Null_Statement then
8712 Ent := Find_Lib_Unit_Name;
8714 -- This filters out pragmas inside generic parent then
8715 -- show up inside instantiation
8718 and then not (Pk = N_Package_Specification
8719 and then Present (Generic_Parent (Pa)))
8721 if not Debug_Flag_U then
8722 Set_Is_Preelaborated (Ent);
8723 Set_Suppress_Elaboration_Warnings (Ent);
8728 ---------------------
8729 -- Preelaborate_05 --
8730 ---------------------
8732 -- pragma Preelaborate_05 [(library_unit_NAME)];
8734 -- This pragma is useable only in GNAT_Mode, where it is used like
8735 -- pragma Preelaborate but it is only effective in Ada 2005 mode
8736 -- (otherwise it is ignored). This is used to implement AI-362 which
8737 -- recategorizes some run-time packages in Ada 2005 mode.
8739 when Pragma_Preelaborate_05 => Preelaborate_05 : declare
8744 Check_Valid_Library_Unit_Pragma;
8746 if not GNAT_Mode then
8747 Error_Pragma ("pragma% only available in GNAT mode");
8750 if Nkind (N) = N_Null_Statement then
8754 -- This is one of the few cases where we need to test the value of
8755 -- Ada_Version_Explicit rather than Ada_Version (which is always
8756 -- set to Ada_05 in a predefined unit), we need to know the
8757 -- explicit version set to know if this pragma is active.
8759 if Ada_Version_Explicit >= Ada_05 then
8760 Ent := Find_Lib_Unit_Name;
8761 Set_Is_Preelaborated (Ent);
8762 Set_Suppress_Elaboration_Warnings (Ent);
8764 end Preelaborate_05;
8770 -- pragma Priority (EXPRESSION);
8772 when Pragma_Priority => Priority : declare
8773 P : constant Node_Id := Parent (N);
8777 Check_No_Identifiers;
8778 Check_Arg_Count (1);
8782 if Nkind (P) = N_Subprogram_Body then
8783 Check_In_Main_Program;
8785 Arg := Expression (Arg1);
8786 Analyze_And_Resolve (Arg, Standard_Integer);
8790 if not Is_Static_Expression (Arg) then
8791 Flag_Non_Static_Expr
8792 ("main subprogram priority is not static!", Arg);
8795 -- If constraint error, then we already signalled an error
8797 elsif Raises_Constraint_Error (Arg) then
8800 -- Otherwise check in range
8804 Val : constant Uint := Expr_Value (Arg);
8808 or else Val > Expr_Value (Expression
8809 (Parent (RTE (RE_Max_Priority))))
8812 ("main subprogram priority is out of range", Arg1);
8818 (Current_Sem_Unit, UI_To_Int (Expr_Value (Arg)));
8820 -- Load an arbitrary entity from System.Tasking to make sure
8821 -- this package is implicitly with'ed, since we need to have
8822 -- the tasking run-time active for the pragma Priority to have
8826 Discard : Entity_Id;
8827 pragma Warnings (Off, Discard);
8829 Discard := RTE (RE_Task_List);
8832 -- Task or Protected, must be of type Integer
8834 elsif Nkind (P) = N_Protected_Definition
8836 Nkind (P) = N_Task_Definition
8838 Arg := Expression (Arg1);
8840 -- The expression must be analyzed in the special manner
8841 -- described in "Handling of Default and Per-Object
8842 -- Expressions" in sem.ads.
8844 Analyze_Per_Use_Expression (Arg, Standard_Integer);
8846 if not Is_Static_Expression (Arg) then
8847 Check_Restriction (Static_Priorities, Arg);
8850 -- Anything else is incorrect
8856 if Has_Priority_Pragma (P) then
8857 Error_Pragma ("duplicate pragma% not allowed");
8859 Set_Has_Priority_Pragma (P, True);
8861 if Nkind (P) = N_Protected_Definition
8863 Nkind (P) = N_Task_Definition
8865 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
8866 -- exp_ch9 should use this ???
8871 -----------------------------------
8872 -- Priority_Specific_Dispatching --
8873 -----------------------------------
8875 -- pragma Priority_Specific_Dispatching (
8876 -- policy_IDENTIFIER,
8877 -- first_priority_EXPRESSION,
8878 -- last_priority_EXPRESSION);
8880 when Pragma_Priority_Specific_Dispatching =>
8881 Priority_Specific_Dispatching : declare
8882 Prio_Id : constant Entity_Id := RTE (RE_Any_Priority);
8883 -- This is the entity System.Any_Priority;
8886 Lower_Bound : Node_Id;
8887 Upper_Bound : Node_Id;
8893 Check_Arg_Count (3);
8894 Check_No_Identifiers;
8895 Check_Arg_Is_Task_Dispatching_Policy (Arg1);
8896 Check_Valid_Configuration_Pragma;
8897 Get_Name_String (Chars (Expression (Arg1)));
8898 DP := Fold_Upper (Name_Buffer (1));
8900 Lower_Bound := Expression (Arg2);
8901 Check_Arg_Is_Static_Expression (Lower_Bound, Standard_Integer);
8902 Lower_Val := Expr_Value (Lower_Bound);
8904 Upper_Bound := Expression (Arg3);
8905 Check_Arg_Is_Static_Expression (Upper_Bound, Standard_Integer);
8906 Upper_Val := Expr_Value (Upper_Bound);
8908 -- It is not allowed to use Task_Dispatching_Policy and
8909 -- Priority_Specific_Dispatching in the same partition.
8911 if Task_Dispatching_Policy /= ' ' then
8912 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
8914 ("pragma% incompatible with Task_Dispatching_Policy#");
8916 -- Check lower bound in range
8918 elsif Lower_Val < Expr_Value (Type_Low_Bound (Prio_Id))
8920 Lower_Val > Expr_Value (Type_High_Bound (Prio_Id))
8923 ("first_priority is out of range", Arg2);
8925 -- Check upper bound in range
8927 elsif Upper_Val < Expr_Value (Type_Low_Bound (Prio_Id))
8929 Upper_Val > Expr_Value (Type_High_Bound (Prio_Id))
8932 ("last_priority is out of range", Arg3);
8934 -- Check that the priority range is valid
8936 elsif Lower_Val > Upper_Val then
8938 ("last_priority_expression must be greater than" &
8939 " or equal to first_priority_expression");
8941 -- Store the new policy, but always preserve System_Location since
8942 -- we like the error message with the run-time name.
8945 -- Check overlapping in the priority ranges specified in other
8946 -- Priority_Specific_Dispatching pragmas within the same
8947 -- partition. We can only check those we know about!
8950 Specific_Dispatching.First .. Specific_Dispatching.Last
8952 if Specific_Dispatching.Table (J).First_Priority in
8953 UI_To_Int (Lower_Val) .. UI_To_Int (Upper_Val)
8954 or else Specific_Dispatching.Table (J).Last_Priority in
8955 UI_To_Int (Lower_Val) .. UI_To_Int (Upper_Val)
8958 Specific_Dispatching.Table (J).Pragma_Loc;
8959 Error_Pragma ("priority range overlaps with" &
8960 " Priority_Specific_Dispatching#");
8964 -- The use of Priority_Specific_Dispatching is incompatible
8965 -- with Task_Dispatching_Policy.
8967 if Task_Dispatching_Policy /= ' ' then
8968 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
8969 Error_Pragma ("Priority_Specific_Dispatching incompatible" &
8970 " with Task_Dispatching_Policy#");
8973 -- The use of Priority_Specific_Dispatching forces ceiling
8976 if Locking_Policy /= ' ' and then Locking_Policy /= 'C' then
8977 Error_Msg_Sloc := Locking_Policy_Sloc;
8978 Error_Pragma ("Priority_Specific_Dispatching incompatible" &
8979 " with Locking_Policy#");
8981 -- Set the Ceiling_Locking policy, but preserve System_Location
8982 -- since we like the error message with the run time name.
8985 Locking_Policy := 'C';
8987 if Locking_Policy_Sloc /= System_Location then
8988 Locking_Policy_Sloc := Loc;
8992 -- Add entry in the table
8994 Specific_Dispatching.Append
8995 ((Dispatching_Policy => DP,
8996 First_Priority => UI_To_Int (Lower_Val),
8997 Last_Priority => UI_To_Int (Upper_Val),
8998 Pragma_Loc => Loc));
9000 end Priority_Specific_Dispatching;
9006 -- pragma Profile (profile_IDENTIFIER);
9008 -- profile_IDENTIFIER => Protected | Ravenscar
9010 when Pragma_Profile =>
9012 Check_Arg_Count (1);
9013 Check_Valid_Configuration_Pragma;
9014 Check_No_Identifiers;
9017 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
9019 if Chars (Argx) = Name_Ravenscar then
9020 Set_Ravenscar_Profile (N);
9021 elsif Chars (Argx) = Name_Restricted then
9022 Set_Profile_Restrictions (Restricted, N, Warn => False);
9024 Error_Pragma_Arg ("& is not a valid profile", Argx);
9028 ----------------------
9029 -- Profile_Warnings --
9030 ----------------------
9032 -- pragma Profile_Warnings (profile_IDENTIFIER);
9034 -- profile_IDENTIFIER => Protected | Ravenscar
9036 when Pragma_Profile_Warnings =>
9038 Check_Arg_Count (1);
9039 Check_Valid_Configuration_Pragma;
9040 Check_No_Identifiers;
9043 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
9045 if Chars (Argx) = Name_Ravenscar then
9046 Set_Profile_Restrictions (Ravenscar, N, Warn => True);
9047 elsif Chars (Argx) = Name_Restricted then
9048 Set_Profile_Restrictions (Restricted, N, Warn => True);
9050 Error_Pragma_Arg ("& is not a valid profile", Argx);
9054 --------------------------
9055 -- Propagate_Exceptions --
9056 --------------------------
9058 -- pragma Propagate_Exceptions;
9060 -- Note: this pragma is obsolete and has no effect
9062 when Pragma_Propagate_Exceptions =>
9064 Check_Arg_Count (0);
9066 if In_Extended_Main_Source_Unit (N) then
9067 Propagate_Exceptions := True;
9074 -- pragma Psect_Object (
9075 -- [Internal =>] LOCAL_NAME,
9076 -- [, [External =>] EXTERNAL_SYMBOL]
9077 -- [, [Size =>] EXTERNAL_SYMBOL]);
9079 when Pragma_Psect_Object | Pragma_Common_Object =>
9080 Psect_Object : declare
9081 Args : Args_List (1 .. 3);
9082 Names : constant Name_List (1 .. 3) := (
9087 Internal : Node_Id renames Args (1);
9088 External : Node_Id renames Args (2);
9089 Size : Node_Id renames Args (3);
9093 procedure Check_Too_Long (Arg : Node_Id);
9094 -- Posts message if the argument is an identifier with more
9095 -- than 31 characters, or a string literal with more than
9096 -- 31 characters, and we are operating under VMS
9098 --------------------
9099 -- Check_Too_Long --
9100 --------------------
9102 procedure Check_Too_Long (Arg : Node_Id) is
9103 X : constant Node_Id := Original_Node (Arg);
9106 if Nkind (X) /= N_String_Literal
9108 Nkind (X) /= N_Identifier
9111 ("inappropriate argument for pragma %", Arg);
9114 if OpenVMS_On_Target then
9115 if (Nkind (X) = N_String_Literal
9116 and then String_Length (Strval (X)) > 31)
9118 (Nkind (X) = N_Identifier
9119 and then Length_Of_Name (Chars (X)) > 31)
9122 ("argument for pragma % is longer than 31 characters",
9128 -- Start of processing for Common_Object/Psect_Object
9132 Gather_Associations (Names, Args);
9133 Process_Extended_Import_Export_Internal_Arg (Internal);
9135 Def_Id := Entity (Internal);
9137 if Ekind (Def_Id) /= E_Constant
9138 and then Ekind (Def_Id) /= E_Variable
9141 ("pragma% must designate an object", Internal);
9144 Check_Too_Long (Internal);
9146 if Is_Imported (Def_Id) or else Is_Exported (Def_Id) then
9148 ("cannot use pragma% for imported/exported object",
9152 if Is_Concurrent_Type (Etype (Internal)) then
9154 ("cannot specify pragma % for task/protected object",
9158 if Has_Rep_Pragma (Def_Id, Name_Common_Object)
9160 Has_Rep_Pragma (Def_Id, Name_Psect_Object)
9162 Error_Msg_N ("?duplicate Common/Psect_Object pragma", N);
9165 if Ekind (Def_Id) = E_Constant then
9167 ("cannot specify pragma % for a constant", Internal);
9170 if Is_Record_Type (Etype (Internal)) then
9176 Ent := First_Entity (Etype (Internal));
9177 while Present (Ent) loop
9178 Decl := Declaration_Node (Ent);
9180 if Ekind (Ent) = E_Component
9181 and then Nkind (Decl) = N_Component_Declaration
9182 and then Present (Expression (Decl))
9183 and then Warn_On_Export_Import
9186 ("?object for pragma % has defaults", Internal);
9196 if Present (Size) then
9197 Check_Too_Long (Size);
9200 if Present (External) then
9201 Check_Arg_Is_External_Name (External);
9202 Check_Too_Long (External);
9205 -- If all error tests pass, link pragma on to the rep item chain
9207 Record_Rep_Item (Def_Id, N);
9214 -- pragma Pure [(library_unit_NAME)];
9216 when Pragma_Pure => Pure : declare
9220 Check_Ada_83_Warning;
9221 Check_Valid_Library_Unit_Pragma;
9223 if Nkind (N) = N_Null_Statement then
9227 Ent := Find_Lib_Unit_Name;
9229 Set_Has_Pragma_Pure (Ent);
9230 Set_Suppress_Elaboration_Warnings (Ent);
9237 -- pragma Pure_05 [(library_unit_NAME)];
9239 -- This pragma is useable only in GNAT_Mode, where it is used like
9240 -- pragma Pure but it is only effective in Ada 2005 mode (otherwise
9241 -- it is ignored). It may be used after a pragma Preelaborate, in
9242 -- which case it overrides the effect of the pragma Preelaborate.
9243 -- This is used to implement AI-362 which recategorizes some run-time
9244 -- packages in Ada 2005 mode.
9246 when Pragma_Pure_05 => Pure_05 : declare
9251 Check_Valid_Library_Unit_Pragma;
9253 if not GNAT_Mode then
9254 Error_Pragma ("pragma% only available in GNAT mode");
9256 if Nkind (N) = N_Null_Statement then
9260 -- This is one of the few cases where we need to test the value of
9261 -- Ada_Version_Explicit rather than Ada_Version (which is always
9262 -- set to Ada_05 in a predefined unit), we need to know the
9263 -- explicit version set to know if this pragma is active.
9265 if Ada_Version_Explicit >= Ada_05 then
9266 Ent := Find_Lib_Unit_Name;
9267 Set_Is_Preelaborated (Ent, False);
9269 Set_Suppress_Elaboration_Warnings (Ent);
9277 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
9279 when Pragma_Pure_Function => Pure_Function : declare
9283 Effective : Boolean := False;
9287 Check_Arg_Count (1);
9288 Check_Optional_Identifier (Arg1, Name_Entity);
9289 Check_Arg_Is_Local_Name (Arg1);
9290 E_Id := Expression (Arg1);
9292 if Error_Posted (E_Id) then
9296 -- Loop through homonyms (overloadings) of referenced entity
9302 Def_Id := Get_Base_Subprogram (E);
9304 if Ekind (Def_Id) /= E_Function
9305 and then Ekind (Def_Id) /= E_Generic_Function
9306 and then Ekind (Def_Id) /= E_Operator
9309 ("pragma% requires a function name", Arg1);
9312 Set_Is_Pure (Def_Id);
9314 if not Has_Pragma_Pure_Function (Def_Id) then
9315 Set_Has_Pragma_Pure_Function (Def_Id);
9320 exit when No (E) or else Scope (E) /= Current_Scope;
9324 and then Warn_On_Redundant_Constructs
9326 Error_Msg_NE ("pragma Pure_Function on& is redundant?",
9332 --------------------
9333 -- Queuing_Policy --
9334 --------------------
9336 -- pragma Queuing_Policy (policy_IDENTIFIER);
9338 when Pragma_Queuing_Policy => declare
9342 Check_Ada_83_Warning;
9343 Check_Arg_Count (1);
9344 Check_No_Identifiers;
9345 Check_Arg_Is_Queuing_Policy (Arg1);
9346 Check_Valid_Configuration_Pragma;
9347 Get_Name_String (Chars (Expression (Arg1)));
9348 QP := Fold_Upper (Name_Buffer (1));
9350 if Queuing_Policy /= ' '
9351 and then Queuing_Policy /= QP
9353 Error_Msg_Sloc := Queuing_Policy_Sloc;
9354 Error_Pragma ("queuing policy incompatible with policy#");
9356 -- Set new policy, but always preserve System_Location since
9357 -- we like the error message with the run time name.
9360 Queuing_Policy := QP;
9362 if Queuing_Policy_Sloc /= System_Location then
9363 Queuing_Policy_Sloc := Loc;
9368 ---------------------------
9369 -- Remote_Call_Interface --
9370 ---------------------------
9372 -- pragma Remote_Call_Interface [(library_unit_NAME)];
9374 when Pragma_Remote_Call_Interface => Remote_Call_Interface : declare
9375 Cunit_Node : Node_Id;
9376 Cunit_Ent : Entity_Id;
9380 Check_Ada_83_Warning;
9381 Check_Valid_Library_Unit_Pragma;
9383 if Nkind (N) = N_Null_Statement then
9387 Cunit_Node := Cunit (Current_Sem_Unit);
9388 K := Nkind (Unit (Cunit_Node));
9389 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
9391 if K = N_Package_Declaration
9392 or else K = N_Generic_Package_Declaration
9393 or else K = N_Subprogram_Declaration
9394 or else K = N_Generic_Subprogram_Declaration
9395 or else (K = N_Subprogram_Body
9396 and then Acts_As_Spec (Unit (Cunit_Node)))
9401 "pragma% must apply to package or subprogram declaration");
9404 Set_Is_Remote_Call_Interface (Cunit_Ent);
9405 end Remote_Call_Interface;
9411 -- pragma Remote_Types [(library_unit_NAME)];
9413 when Pragma_Remote_Types => Remote_Types : declare
9414 Cunit_Node : Node_Id;
9415 Cunit_Ent : Entity_Id;
9418 Check_Ada_83_Warning;
9419 Check_Valid_Library_Unit_Pragma;
9421 if Nkind (N) = N_Null_Statement then
9425 Cunit_Node := Cunit (Current_Sem_Unit);
9426 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
9428 if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration
9430 Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration
9433 "pragma% can only apply to a package declaration");
9436 Set_Is_Remote_Types (Cunit_Ent);
9443 -- pragma Ravenscar;
9445 when Pragma_Ravenscar =>
9447 Check_Arg_Count (0);
9448 Check_Valid_Configuration_Pragma;
9449 Set_Ravenscar_Profile (N);
9451 if Warn_On_Obsolescent_Feature then
9453 ("pragma Ravenscar is an obsolescent feature?", N);
9455 ("|use pragma Profile (Ravenscar) instead", N);
9458 -------------------------
9459 -- Restricted_Run_Time --
9460 -------------------------
9462 -- pragma Restricted_Run_Time;
9464 when Pragma_Restricted_Run_Time =>
9466 Check_Arg_Count (0);
9467 Check_Valid_Configuration_Pragma;
9468 Set_Profile_Restrictions (Restricted, N, Warn => False);
9470 if Warn_On_Obsolescent_Feature then
9472 ("pragma Restricted_Run_Time is an obsolescent feature?", N);
9474 ("|use pragma Profile (Restricted) instead", N);
9481 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
9484 -- restriction_IDENTIFIER
9485 -- | restriction_parameter_IDENTIFIER => EXPRESSION
9487 when Pragma_Restrictions =>
9488 Process_Restrictions_Or_Restriction_Warnings (Warn => False);
9490 --------------------------
9491 -- Restriction_Warnings --
9492 --------------------------
9494 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
9497 -- restriction_IDENTIFIER
9498 -- | restriction_parameter_IDENTIFIER => EXPRESSION
9500 when Pragma_Restriction_Warnings =>
9501 Process_Restrictions_Or_Restriction_Warnings (Warn => True);
9507 -- pragma Reviewable;
9509 when Pragma_Reviewable =>
9510 Check_Ada_83_Warning;
9511 Check_Arg_Count (0);
9518 -- pragma Share_Generic (NAME {, NAME});
9520 when Pragma_Share_Generic =>
9522 Process_Generic_List;
9528 -- pragma Shared (LOCAL_NAME);
9530 when Pragma_Shared =>
9532 Process_Atomic_Shared_Volatile;
9534 --------------------
9535 -- Shared_Passive --
9536 --------------------
9538 -- pragma Shared_Passive [(library_unit_NAME)];
9540 -- Set the flag Is_Shared_Passive of program unit name entity
9542 when Pragma_Shared_Passive => Shared_Passive : declare
9543 Cunit_Node : Node_Id;
9544 Cunit_Ent : Entity_Id;
9547 Check_Ada_83_Warning;
9548 Check_Valid_Library_Unit_Pragma;
9550 if Nkind (N) = N_Null_Statement then
9554 Cunit_Node := Cunit (Current_Sem_Unit);
9555 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
9557 if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration
9559 Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration
9562 "pragma% can only apply to a package declaration");
9565 Set_Is_Shared_Passive (Cunit_Ent);
9568 ----------------------
9569 -- Source_File_Name --
9570 ----------------------
9572 -- There are five forms for this pragma:
9574 -- pragma Source_File_Name (
9575 -- [UNIT_NAME =>] unit_NAME,
9576 -- BODY_FILE_NAME => STRING_LITERAL
9577 -- [, [INDEX =>] INTEGER_LITERAL]);
9579 -- pragma Source_File_Name (
9580 -- [UNIT_NAME =>] unit_NAME,
9581 -- SPEC_FILE_NAME => STRING_LITERAL
9582 -- [, [INDEX =>] INTEGER_LITERAL]);
9584 -- pragma Source_File_Name (
9585 -- BODY_FILE_NAME => STRING_LITERAL
9586 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9587 -- [, CASING => CASING_SPEC]);
9589 -- pragma Source_File_Name (
9590 -- SPEC_FILE_NAME => STRING_LITERAL
9591 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9592 -- [, CASING => CASING_SPEC]);
9594 -- pragma Source_File_Name (
9595 -- SUBUNIT_FILE_NAME => STRING_LITERAL
9596 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9597 -- [, CASING => CASING_SPEC]);
9599 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
9601 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
9602 -- Source_File_Name (SFN), however their usage is exclusive:
9603 -- SFN can only be used when no project file is used, while
9604 -- SFNP can only be used when a project file is used.
9606 -- No processing here. Processing was completed during parsing,
9607 -- since we need to have file names set as early as possible.
9608 -- Units are loaded well before semantic processing starts.
9610 -- The only processing we defer to this point is the check
9611 -- for correct placement.
9613 when Pragma_Source_File_Name =>
9615 Check_Valid_Configuration_Pragma;
9617 ------------------------------
9618 -- Source_File_Name_Project --
9619 ------------------------------
9621 -- See Source_File_Name for syntax
9623 -- No processing here. Processing was completed during parsing,
9624 -- since we need to have file names set as early as possible.
9625 -- Units are loaded well before semantic processing starts.
9627 -- The only processing we defer to this point is the check
9628 -- for correct placement.
9630 when Pragma_Source_File_Name_Project =>
9632 Check_Valid_Configuration_Pragma;
9634 -- Check that a pragma Source_File_Name_Project is used only
9635 -- in a configuration pragmas file.
9637 -- Pragmas Source_File_Name_Project should only be generated
9638 -- by the Project Manager in configuration pragmas files.
9640 -- This is really an ugly test. It seems to depend on some
9641 -- accidental and undocumented property. At the very least
9642 -- it needs to be documented, but it would be better to have
9643 -- a clean way of testing if we are in a configuration file???
9645 if Present (Parent (N)) then
9647 ("pragma% can only appear in a configuration pragmas file");
9650 ----------------------
9651 -- Source_Reference --
9652 ----------------------
9654 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
9656 -- Nothing to do, all processing completed in Par.Prag, since we
9657 -- need the information for possible parser messages that are output
9659 when Pragma_Source_Reference =>
9662 --------------------------------
9663 -- Static_Elaboration_Desired --
9664 --------------------------------
9668 when Pragma_Static_Elaboration_Desired =>
9671 -- Check number of arguments ???
9673 if Is_Compilation_Unit (Current_Scope)
9674 and then Ekind (Current_Scope) = E_Package
9676 Set_Static_Elaboration_Desired (Current_Scope, True);
9678 Error_Pragma ("pragma% must apply to a library-level package");
9685 -- pragma Storage_Size (EXPRESSION);
9687 when Pragma_Storage_Size => Storage_Size : declare
9688 P : constant Node_Id := Parent (N);
9692 Check_No_Identifiers;
9693 Check_Arg_Count (1);
9695 -- The expression must be analyzed in the special manner
9696 -- described in "Handling of Default Expressions" in sem.ads.
9698 -- Set In_Default_Expression for per-object case ???
9700 Arg := Expression (Arg1);
9701 Analyze_Per_Use_Expression (Arg, Any_Integer);
9703 if not Is_Static_Expression (Arg) then
9704 Check_Restriction (Static_Storage_Size, Arg);
9707 if Nkind (P) /= N_Task_Definition then
9712 if Has_Storage_Size_Pragma (P) then
9713 Error_Pragma ("duplicate pragma% not allowed");
9715 Set_Has_Storage_Size_Pragma (P, True);
9718 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
9719 -- ??? exp_ch9 should use this!
9727 -- pragma Storage_Unit (NUMERIC_LITERAL);
9729 -- Only permitted argument is System'Storage_Unit value
9731 when Pragma_Storage_Unit =>
9732 Check_No_Identifiers;
9733 Check_Arg_Count (1);
9734 Check_Arg_Is_Integer_Literal (Arg1);
9736 if Intval (Expression (Arg1)) /=
9737 UI_From_Int (Ttypes.System_Storage_Unit)
9739 Error_Msg_Uint_1 := UI_From_Int (Ttypes.System_Storage_Unit);
9741 ("the only allowed argument for pragma% is ^", Arg1);
9744 --------------------
9745 -- Stream_Convert --
9746 --------------------
9748 -- pragma Stream_Convert (
9749 -- [Entity =>] type_LOCAL_NAME,
9750 -- [Read =>] function_NAME,
9751 -- [Write =>] function NAME);
9753 when Pragma_Stream_Convert => Stream_Convert : declare
9755 procedure Check_OK_Stream_Convert_Function (Arg : Node_Id);
9756 -- Check that the given argument is the name of a local
9757 -- function of one argument that is not overloaded earlier
9758 -- in the current local scope. A check is also made that the
9759 -- argument is a function with one parameter.
9761 --------------------------------------
9762 -- Check_OK_Stream_Convert_Function --
9763 --------------------------------------
9765 procedure Check_OK_Stream_Convert_Function (Arg : Node_Id) is
9769 Check_Arg_Is_Local_Name (Arg);
9770 Ent := Entity (Expression (Arg));
9772 if Has_Homonym (Ent) then
9774 ("argument for pragma% may not be overloaded", Arg);
9777 if Ekind (Ent) /= E_Function
9778 or else No (First_Formal (Ent))
9779 or else Present (Next_Formal (First_Formal (Ent)))
9782 ("argument for pragma% must be" &
9783 " function of one argument", Arg);
9785 end Check_OK_Stream_Convert_Function;
9787 -- Start of procecessing for Stream_Convert
9791 Check_Arg_Order ((Name_Entity, Name_Read, Name_Write));
9792 Check_Arg_Count (3);
9793 Check_Optional_Identifier (Arg1, Name_Entity);
9794 Check_Optional_Identifier (Arg2, Name_Read);
9795 Check_Optional_Identifier (Arg3, Name_Write);
9796 Check_Arg_Is_Local_Name (Arg1);
9797 Check_OK_Stream_Convert_Function (Arg2);
9798 Check_OK_Stream_Convert_Function (Arg3);
9801 Typ : constant Entity_Id :=
9802 Underlying_Type (Entity (Expression (Arg1)));
9803 Read : constant Entity_Id := Entity (Expression (Arg2));
9804 Write : constant Entity_Id := Entity (Expression (Arg3));
9807 if Etype (Typ) = Any_Type
9809 Etype (Read) = Any_Type
9811 Etype (Write) = Any_Type
9816 Check_First_Subtype (Arg1);
9818 if Rep_Item_Too_Early (Typ, N)
9820 Rep_Item_Too_Late (Typ, N)
9825 if Underlying_Type (Etype (Read)) /= Typ then
9827 ("incorrect return type for function&", Arg2);
9830 if Underlying_Type (Etype (First_Formal (Write))) /= Typ then
9832 ("incorrect parameter type for function&", Arg3);
9835 if Underlying_Type (Etype (First_Formal (Read))) /=
9836 Underlying_Type (Etype (Write))
9839 ("result type of & does not match Read parameter type",
9845 -------------------------
9846 -- Style_Checks (GNAT) --
9847 -------------------------
9849 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
9851 -- This is processed by the parser since some of the style
9852 -- checks take place during source scanning and parsing. This
9853 -- means that we don't need to issue error messages here.
9855 when Pragma_Style_Checks => Style_Checks : declare
9856 A : constant Node_Id := Expression (Arg1);
9862 Check_No_Identifiers;
9864 -- Two argument form
9866 if Arg_Count = 2 then
9867 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
9874 E_Id := Expression (Arg2);
9877 if not Is_Entity_Name (E_Id) then
9879 ("second argument of pragma% must be entity name",
9889 Set_Suppress_Style_Checks (E,
9890 (Chars (Expression (Arg1)) = Name_Off));
9891 exit when No (Homonym (E));
9897 -- One argument form
9900 Check_Arg_Count (1);
9902 if Nkind (A) = N_String_Literal then
9906 Slen : constant Natural := Natural (String_Length (S));
9907 Options : String (1 .. Slen);
9913 C := Get_String_Char (S, Int (J));
9914 exit when not In_Character_Range (C);
9915 Options (J) := Get_Character (C);
9917 -- If at end of string, set options. As per discussion
9918 -- above, no need to check for errors, since we issued
9919 -- them in the parser.
9922 Set_Style_Check_Options (Options);
9930 elsif Nkind (A) = N_Identifier then
9931 if Chars (A) = Name_All_Checks then
9932 Set_Default_Style_Check_Options;
9934 elsif Chars (A) = Name_On then
9935 Style_Check := True;
9937 elsif Chars (A) = Name_Off then
9938 Style_Check := False;
9948 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
9950 when Pragma_Subtitle =>
9952 Check_Arg_Count (1);
9953 Check_Optional_Identifier (Arg1, Name_Subtitle);
9954 Check_Arg_Is_String_Literal (Arg1);
9960 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
9962 when Pragma_Suppress =>
9963 Process_Suppress_Unsuppress (True);
9969 -- pragma Suppress_All;
9971 -- The only check made here is that the pragma appears in the
9972 -- proper place, i.e. following a compilation unit. If indeed
9973 -- it appears in this context, then the parser has already
9974 -- inserted an equivalent pragma Suppress (All_Checks) to get
9975 -- the required effect.
9977 when Pragma_Suppress_All =>
9979 Check_Arg_Count (0);
9981 if Nkind (Parent (N)) /= N_Compilation_Unit_Aux
9982 or else not Is_List_Member (N)
9983 or else List_Containing (N) /= Pragmas_After (Parent (N))
9986 ("misplaced pragma%, must follow compilation unit");
9989 -------------------------
9990 -- Suppress_Debug_Info --
9991 -------------------------
9993 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
9995 when Pragma_Suppress_Debug_Info =>
9997 Check_Arg_Count (1);
9998 Check_Optional_Identifier (Arg1, Name_Entity);
9999 Check_Arg_Is_Local_Name (Arg1);
10000 Set_Debug_Info_Off (Entity (Get_Pragma_Arg (Arg1)));
10002 ----------------------------------
10003 -- Suppress_Exception_Locations --
10004 ----------------------------------
10006 -- pragma Suppress_Exception_Locations;
10008 when Pragma_Suppress_Exception_Locations =>
10010 Check_Arg_Count (0);
10011 Check_Valid_Configuration_Pragma;
10012 Exception_Locations_Suppressed := True;
10014 -----------------------------
10015 -- Suppress_Initialization --
10016 -----------------------------
10018 -- pragma Suppress_Initialization ([Entity =>] type_Name);
10020 when Pragma_Suppress_Initialization => Suppress_Init : declare
10026 Check_Arg_Count (1);
10027 Check_Optional_Identifier (Arg1, Name_Entity);
10028 Check_Arg_Is_Local_Name (Arg1);
10030 E_Id := Expression (Arg1);
10032 if Etype (E_Id) = Any_Type then
10036 E := Entity (E_Id);
10038 if Is_Type (E) then
10039 if Is_Incomplete_Or_Private_Type (E) then
10040 if No (Full_View (Base_Type (E))) then
10042 ("argument of pragma% cannot be an incomplete type",
10045 Set_Suppress_Init_Proc (Full_View (Base_Type (E)));
10048 Set_Suppress_Init_Proc (Base_Type (E));
10053 ("pragma% requires argument that is a type name", Arg1);
10061 -- pragma System_Name (DIRECT_NAME);
10063 -- Syntax check: one argument, which must be the identifier GNAT
10064 -- or the identifier GCC, no other identifiers are acceptable.
10066 when Pragma_System_Name =>
10067 Check_No_Identifiers;
10068 Check_Arg_Count (1);
10069 Check_Arg_Is_One_Of (Arg1, Name_Gcc, Name_Gnat);
10071 -----------------------------
10072 -- Task_Dispatching_Policy --
10073 -----------------------------
10075 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
10077 when Pragma_Task_Dispatching_Policy => declare
10081 Check_Ada_83_Warning;
10082 Check_Arg_Count (1);
10083 Check_No_Identifiers;
10084 Check_Arg_Is_Task_Dispatching_Policy (Arg1);
10085 Check_Valid_Configuration_Pragma;
10086 Get_Name_String (Chars (Expression (Arg1)));
10087 DP := Fold_Upper (Name_Buffer (1));
10089 if Task_Dispatching_Policy /= ' '
10090 and then Task_Dispatching_Policy /= DP
10092 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
10094 ("task dispatching policy incompatible with policy#");
10096 -- Set new policy, but always preserve System_Location since
10097 -- we like the error message with the run time name.
10100 Task_Dispatching_Policy := DP;
10102 if Task_Dispatching_Policy_Sloc /= System_Location then
10103 Task_Dispatching_Policy_Sloc := Loc;
10112 -- pragma Task_Info (EXPRESSION);
10114 when Pragma_Task_Info => Task_Info : declare
10115 P : constant Node_Id := Parent (N);
10120 if Nkind (P) /= N_Task_Definition then
10121 Error_Pragma ("pragma% must appear in task definition");
10124 Check_No_Identifiers;
10125 Check_Arg_Count (1);
10127 Analyze_And_Resolve (Expression (Arg1), RTE (RE_Task_Info_Type));
10129 if Etype (Expression (Arg1)) = Any_Type then
10133 if Has_Task_Info_Pragma (P) then
10134 Error_Pragma ("duplicate pragma% not allowed");
10136 Set_Has_Task_Info_Pragma (P, True);
10144 -- pragma Task_Name (string_EXPRESSION);
10146 when Pragma_Task_Name => Task_Name : declare
10147 -- pragma Priority (EXPRESSION);
10149 P : constant Node_Id := Parent (N);
10153 Check_No_Identifiers;
10154 Check_Arg_Count (1);
10156 Arg := Expression (Arg1);
10157 Analyze_And_Resolve (Arg, Standard_String);
10159 if Nkind (P) /= N_Task_Definition then
10163 if Has_Task_Name_Pragma (P) then
10164 Error_Pragma ("duplicate pragma% not allowed");
10166 Set_Has_Task_Name_Pragma (P, True);
10167 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
10175 -- pragma Task_Storage (
10176 -- [Task_Type =>] LOCAL_NAME,
10177 -- [Top_Guard =>] static_integer_EXPRESSION);
10179 when Pragma_Task_Storage => Task_Storage : declare
10180 Args : Args_List (1 .. 2);
10181 Names : constant Name_List (1 .. 2) := (
10185 Task_Type : Node_Id renames Args (1);
10186 Top_Guard : Node_Id renames Args (2);
10192 Gather_Associations (Names, Args);
10194 if No (Task_Type) then
10196 ("missing task_type argument for pragma%");
10199 Check_Arg_Is_Local_Name (Task_Type);
10201 Ent := Entity (Task_Type);
10203 if not Is_Task_Type (Ent) then
10205 ("argument for pragma% must be task type", Task_Type);
10208 if No (Top_Guard) then
10210 ("pragma% takes two arguments", Task_Type);
10212 Check_Arg_Is_Static_Expression (Top_Guard, Any_Integer);
10215 Check_First_Subtype (Task_Type);
10217 if Rep_Item_Too_Late (Ent, N) then
10226 -- pragma Time_Slice (static_duration_EXPRESSION);
10228 when Pragma_Time_Slice => Time_Slice : declare
10234 Check_Arg_Count (1);
10235 Check_No_Identifiers;
10236 Check_In_Main_Program;
10237 Check_Arg_Is_Static_Expression (Arg1, Standard_Duration);
10239 if not Error_Posted (Arg1) then
10241 while Present (Nod) loop
10242 if Nkind (Nod) = N_Pragma
10243 and then Chars (Nod) = Name_Time_Slice
10245 Error_Msg_Name_1 := Chars (N);
10246 Error_Msg_N ("duplicate pragma% not permitted", Nod);
10253 -- Process only if in main unit
10255 if Get_Source_Unit (Loc) = Main_Unit then
10256 Opt.Time_Slice_Set := True;
10257 Val := Expr_Value_R (Expression (Arg1));
10259 if Val <= Ureal_0 then
10260 Opt.Time_Slice_Value := 0;
10262 elsif Val > UR_From_Uint (UI_From_Int (1000)) then
10263 Opt.Time_Slice_Value := 1_000_000_000;
10266 Opt.Time_Slice_Value :=
10267 UI_To_Int (UR_To_Uint (Val * UI_From_Int (1_000_000)));
10276 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
10278 -- TITLING_OPTION ::=
10279 -- [Title =>] STRING_LITERAL
10280 -- | [Subtitle =>] STRING_LITERAL
10282 when Pragma_Title => Title : declare
10283 Args : Args_List (1 .. 2);
10284 Names : constant Name_List (1 .. 2) := (
10290 Gather_Associations (Names, Args);
10292 for J in 1 .. 2 loop
10293 if Present (Args (J)) then
10294 Check_Arg_Is_String_Literal (Args (J));
10299 ---------------------
10300 -- Unchecked_Union --
10301 ---------------------
10303 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
10305 when Pragma_Unchecked_Union => Unchecked_Union : declare
10306 Assoc : constant Node_Id := Arg1;
10307 Type_Id : constant Node_Id := Expression (Assoc);
10318 Check_No_Identifiers;
10319 Check_Arg_Count (1);
10320 Check_Arg_Is_Local_Name (Arg1);
10322 Find_Type (Type_Id);
10323 Typ := Entity (Type_Id);
10326 or else Rep_Item_Too_Early (Typ, N)
10330 Typ := Underlying_Type (Typ);
10333 if Rep_Item_Too_Late (Typ, N) then
10337 Check_First_Subtype (Arg1);
10339 -- Note remaining cases are references to a type in the current
10340 -- declarative part. If we find an error, we post the error on
10341 -- the relevant type declaration at an appropriate point.
10343 if not Is_Record_Type (Typ) then
10344 Error_Msg_N ("Unchecked_Union must be record type", Typ);
10347 elsif Is_Tagged_Type (Typ) then
10348 Error_Msg_N ("Unchecked_Union must not be tagged", Typ);
10351 elsif Is_Limited_Type (Typ) then
10353 ("Unchecked_Union must not be limited record type", Typ);
10354 Explain_Limited_Type (Typ, Typ);
10358 if not Has_Discriminants (Typ) then
10360 ("Unchecked_Union must have one discriminant", Typ);
10364 Discr := First_Discriminant (Typ);
10366 while Present (Discr) loop
10367 if No (Discriminant_Default_Value (Discr)) then
10369 ("Unchecked_Union discriminant must have default value",
10372 Next_Discriminant (Discr);
10375 Tdef := Type_Definition (Declaration_Node (Typ));
10376 Clist := Component_List (Tdef);
10378 Comp := First (Component_Items (Clist));
10379 while Present (Comp) loop
10381 Check_Component (Comp);
10386 if No (Clist) or else No (Variant_Part (Clist)) then
10388 ("Unchecked_Union must have variant part",
10393 Vpart := Variant_Part (Clist);
10395 Variant := First (Variants (Vpart));
10396 while Present (Variant) loop
10397 Check_Variant (Variant);
10402 Set_Is_Unchecked_Union (Typ, True);
10403 Set_Convention (Typ, Convention_C);
10405 Set_Has_Unchecked_Union (Base_Type (Typ), True);
10406 Set_Is_Unchecked_Union (Base_Type (Typ), True);
10407 end Unchecked_Union;
10409 ------------------------
10410 -- Unimplemented_Unit --
10411 ------------------------
10413 -- pragma Unimplemented_Unit;
10415 -- Note: this only gives an error if we are generating code,
10416 -- or if we are in a generic library unit (where the pragma
10417 -- appears in the body, not in the spec).
10419 when Pragma_Unimplemented_Unit => Unimplemented_Unit : declare
10420 Cunitent : constant Entity_Id :=
10421 Cunit_Entity (Get_Source_Unit (Loc));
10422 Ent_Kind : constant Entity_Kind :=
10427 Check_Arg_Count (0);
10429 if Operating_Mode = Generate_Code
10430 or else Ent_Kind = E_Generic_Function
10431 or else Ent_Kind = E_Generic_Procedure
10432 or else Ent_Kind = E_Generic_Package
10434 Get_Name_String (Chars (Cunitent));
10435 Set_Casing (Mixed_Case);
10436 Write_Str (Name_Buffer (1 .. Name_Len));
10437 Write_Str (" is not supported in this configuration");
10439 raise Unrecoverable_Error;
10441 end Unimplemented_Unit;
10443 ------------------------
10444 -- Universal_Aliasing --
10445 ------------------------
10447 -- pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
10449 when Pragma_Universal_Aliasing => Universal_Alias : declare
10454 Check_Arg_Count (1);
10455 Check_Optional_Identifier (Arg2, Name_Entity);
10456 Check_Arg_Is_Local_Name (Arg1);
10457 E_Id := Entity (Expression (Arg1));
10459 if E_Id = Any_Type then
10461 elsif No (E_Id) or else not Is_Type (E_Id) then
10462 Error_Pragma_Arg ("pragma% requires type", Arg1);
10465 Set_Universal_Aliasing (Implementation_Base_Type (E_Id));
10466 end Universal_Alias;
10468 --------------------
10469 -- Universal_Data --
10470 --------------------
10472 -- pragma Universal_Data [(library_unit_NAME)];
10474 when Pragma_Universal_Data =>
10477 -- If this is a configuration pragma, then set the universal
10478 -- addressing option, otherwise confirm that the pragma
10479 -- satisfies the requirements of library unit pragma placement
10480 -- and leave it to the GNAAMP back end to detect the pragma
10481 -- (avoids transitive setting of the option due to withed units).
10483 if Is_Configuration_Pragma then
10484 Universal_Addressing_On_AAMP := True;
10486 Check_Valid_Library_Unit_Pragma;
10489 if not AAMP_On_Target then
10490 Error_Pragma ("?pragma% ignored (applies only to AAMP)");
10497 -- pragma Unreferenced (local_Name {, local_Name});
10499 -- or when used in a context clause:
10501 -- pragma Unreferenced (library_unit_NAME {, library_unit_NAME}
10503 when Pragma_Unreferenced => Unreferenced : declare
10504 Arg_Node : Node_Id;
10505 Arg_Expr : Node_Id;
10506 Arg_Ent : Entity_Id;
10511 Check_At_Least_N_Arguments (1);
10513 -- Check case of appearing within context clause
10515 if Is_In_Context_Clause then
10517 -- The arguments must all be units mentioned in a with
10518 -- clause in the same context clause. Note we already checked
10519 -- (in Par.Prag) that the arguments are either identifiers or
10522 while Present (Arg_Node) loop
10523 Citem := First (List_Containing (N));
10524 while Citem /= N loop
10525 if Nkind (Citem) = N_With_Clause
10526 and then Same_Name (Name (Citem), Expression (Arg_Node))
10528 Set_Has_Pragma_Unreferenced
10531 (Library_Unit (Citem))));
10532 Set_Unit_Name (Expression (Arg_Node), Name (Citem));
10541 ("argument of pragma% is not with'ed unit", Arg_Node);
10547 -- Case of not in list of context items
10551 while Present (Arg_Node) loop
10552 Check_No_Identifier (Arg_Node);
10554 -- Note: the analyze call done by Check_Arg_Is_Local_Name
10555 -- will in fact generate reference, so that the entity will
10556 -- have a reference, which will inhibit any warnings about
10557 -- it not being referenced, and also properly show up in the
10558 -- ali file as a reference. But this reference is recorded
10559 -- before the Has_Pragma_Unreferenced flag is set, so that
10560 -- no warning is generated for this reference.
10562 Check_Arg_Is_Local_Name (Arg_Node);
10563 Arg_Expr := Get_Pragma_Arg (Arg_Node);
10565 if Is_Entity_Name (Arg_Expr) then
10566 Arg_Ent := Entity (Arg_Expr);
10568 -- If the entity is overloaded, the pragma applies to the
10569 -- most recent overloading, as documented. In this case,
10570 -- name resolution does not generate a reference, so it
10571 -- must be done here explicitly.
10573 if Is_Overloaded (Arg_Expr) then
10574 Generate_Reference (Arg_Ent, N);
10577 Set_Has_Pragma_Unreferenced (Arg_Ent);
10585 --------------------------
10586 -- Unreferenced_Objects --
10587 --------------------------
10589 -- pragma Unreferenced_Objects (local_Name {, local_Name});
10591 when Pragma_Unreferenced_Objects => Unreferenced_Objects : declare
10592 Arg_Node : Node_Id;
10593 Arg_Expr : Node_Id;
10597 Check_At_Least_N_Arguments (1);
10600 while Present (Arg_Node) loop
10601 Check_No_Identifier (Arg_Node);
10602 Check_Arg_Is_Local_Name (Arg_Node);
10603 Arg_Expr := Get_Pragma_Arg (Arg_Node);
10605 if not Is_Entity_Name (Arg_Expr)
10606 or else not Is_Type (Entity (Arg_Expr))
10609 ("argument for pragma% must be type or subtype", Arg_Node);
10612 Set_Has_Pragma_Unreferenced_Objects (Entity (Arg_Expr));
10615 end Unreferenced_Objects;
10617 ------------------------------
10618 -- Unreserve_All_Interrupts --
10619 ------------------------------
10621 -- pragma Unreserve_All_Interrupts;
10623 when Pragma_Unreserve_All_Interrupts =>
10625 Check_Arg_Count (0);
10627 if In_Extended_Main_Code_Unit (Main_Unit_Entity) then
10628 Unreserve_All_Interrupts := True;
10635 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
10637 when Pragma_Unsuppress =>
10639 Process_Suppress_Unsuppress (False);
10641 -------------------
10642 -- Use_VADS_Size --
10643 -------------------
10645 -- pragma Use_VADS_Size;
10647 when Pragma_Use_VADS_Size =>
10649 Check_Arg_Count (0);
10650 Check_Valid_Configuration_Pragma;
10651 Use_VADS_Size := True;
10653 ---------------------
10654 -- Validity_Checks --
10655 ---------------------
10657 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
10659 when Pragma_Validity_Checks => Validity_Checks : declare
10660 A : constant Node_Id := Expression (Arg1);
10666 Check_Arg_Count (1);
10667 Check_No_Identifiers;
10669 if Nkind (A) = N_String_Literal then
10673 Slen : constant Natural := Natural (String_Length (S));
10674 Options : String (1 .. Slen);
10680 C := Get_String_Char (S, Int (J));
10681 exit when not In_Character_Range (C);
10682 Options (J) := Get_Character (C);
10685 Set_Validity_Check_Options (Options);
10693 elsif Nkind (A) = N_Identifier then
10695 if Chars (A) = Name_All_Checks then
10696 Set_Validity_Check_Options ("a");
10698 elsif Chars (A) = Name_On then
10699 Validity_Checks_On := True;
10701 elsif Chars (A) = Name_Off then
10702 Validity_Checks_On := False;
10706 end Validity_Checks;
10712 -- pragma Volatile (LOCAL_NAME);
10714 when Pragma_Volatile =>
10715 Process_Atomic_Shared_Volatile;
10717 -------------------------
10718 -- Volatile_Components --
10719 -------------------------
10721 -- pragma Volatile_Components (array_LOCAL_NAME);
10723 -- Volatile is handled by the same circuit as Atomic_Components
10729 -- pragma Warnings (On | Off);
10730 -- pragma Warnings (On | Off, LOCAL_NAME);
10731 -- pragma Warnings (static_string_EXPRESSION);
10732 -- pragma Warnings (On | Off, STRING_LITERAL);
10734 when Pragma_Warnings => Warnings : begin
10736 Check_At_Least_N_Arguments (1);
10737 Check_No_Identifiers;
10740 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
10743 -- One argument case
10745 if Arg_Count = 1 then
10747 -- On/Off one argument case was processed by parser
10749 if Nkind (Argx) = N_Identifier
10751 (Chars (Argx) = Name_On
10753 Chars (Argx) = Name_Off)
10757 -- One argument case must be ON/OFF or static string expr
10759 elsif not Is_Static_String_Expression (Arg1) then
10761 ("argument of pragma% must be On/Off or " &
10762 "static string expression", Arg2);
10764 -- One argument string expression case
10768 Lit : constant Node_Id := Expr_Value_S (Argx);
10769 Str : constant String_Id := Strval (Lit);
10770 Len : constant Nat := String_Length (Str);
10778 while J <= Len loop
10779 C := Get_String_Char (Str, J);
10780 OK := In_Character_Range (C);
10783 Chr := Get_Character (C);
10787 if J < Len and then Chr = '.' then
10789 C := Get_String_Char (Str, J);
10790 Chr := Get_Character (C);
10792 if not Set_Dot_Warning_Switch (Chr) then
10794 ("invalid warning switch character " &
10801 OK := Set_Warning_Switch (Chr);
10807 ("invalid warning switch character " & Chr,
10816 -- Two or more arguments (must be two)
10819 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
10820 Check_At_Most_N_Arguments (2);
10828 E_Id := Expression (Arg2);
10831 -- In the expansion of an inlined body, a reference to
10832 -- the formal may be wrapped in a conversion if the
10833 -- actual is a conversion. Retrieve the real entity name.
10835 if (In_Instance_Body
10836 or else In_Inlined_Body)
10837 and then Nkind (E_Id) = N_Unchecked_Type_Conversion
10839 E_Id := Expression (E_Id);
10842 -- Entity name case
10844 if Is_Entity_Name (E_Id) then
10845 E := Entity (E_Id);
10852 (E, (Chars (Expression (Arg1)) = Name_Off));
10854 if Is_Enumeration_Type (E) then
10858 Lit := First_Literal (E);
10859 while Present (Lit) loop
10860 Set_Warnings_Off (Lit);
10861 Next_Literal (Lit);
10866 exit when No (Homonym (E));
10871 -- Error if not entity or static string literal case
10873 elsif not Is_Static_String_Expression (Arg2) then
10875 ("second argument of pragma% must be entity " &
10876 "name or static string expression", Arg2);
10878 -- String literal case
10881 String_To_Name_Buffer
10882 (Strval (Expr_Value_S (Expression (Arg2))));
10884 -- Configuration pragma case
10886 if Is_Configuration_Pragma then
10887 if Chars (Argx) = Name_On then
10889 ("pragma Warnings (On, string) cannot be " &
10890 "used as configuration pragma");
10893 Set_Specific_Warning_Off
10894 (No_Location, Name_Buffer (1 .. Name_Len));
10897 -- Normal (non-configuration pragma) case
10900 if Chars (Argx) = Name_Off then
10901 Set_Specific_Warning_Off
10902 (Loc, Name_Buffer (1 .. Name_Len));
10904 elsif Chars (Argx) = Name_On then
10905 Set_Specific_Warning_On
10906 (Loc, Name_Buffer (1 .. Name_Len), Err);
10910 ("?pragma Warnings On with no " &
10911 "matching Warnings Off",
10922 -------------------
10923 -- Weak_External --
10924 -------------------
10926 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
10928 when Pragma_Weak_External => Weak_External : declare
10933 Check_Arg_Count (1);
10934 Check_Optional_Identifier (Arg1, Name_Entity);
10935 Check_Arg_Is_Library_Level_Local_Name (Arg1);
10936 Ent := Entity (Expression (Arg1));
10938 if Rep_Item_Too_Early (Ent, N) then
10941 Ent := Underlying_Type (Ent);
10944 -- The only processing required is to link this item on to the
10945 -- list of rep items for the given entity. This is accomplished
10946 -- by the call to Rep_Item_Too_Late (when no error is detected
10947 -- and False is returned).
10949 if Rep_Item_Too_Late (Ent, N) then
10952 Set_Has_Gigi_Rep_Item (Ent);
10956 -----------------------------
10957 -- Wide_Character_Encoding --
10958 -----------------------------
10960 -- pragma Wide_Character_Encoding (IDENTIFIER);
10962 when Pragma_Wide_Character_Encoding =>
10964 -- Nothing to do, handled in parser. Note that we do not enforce
10965 -- configuration pragma placement, this pragma can appear at any
10966 -- place in the source, allowing mixed encodings within a single
10971 --------------------
10972 -- Unknown_Pragma --
10973 --------------------
10975 -- Should be impossible, since the case of an unknown pragma is
10976 -- separately processed before the case statement is entered.
10978 when Unknown_Pragma =>
10979 raise Program_Error;
10983 when Pragma_Exit => null;
10984 end Analyze_Pragma;
10986 ---------------------------------
10987 -- Delay_Config_Pragma_Analyze --
10988 ---------------------------------
10990 function Delay_Config_Pragma_Analyze (N : Node_Id) return Boolean is
10992 return Chars (N) = Name_Interrupt_State
10994 Chars (N) = Name_Priority_Specific_Dispatching;
10995 end Delay_Config_Pragma_Analyze;
10997 -------------------------
10998 -- Get_Base_Subprogram --
10999 -------------------------
11001 function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id is
11002 Result : Entity_Id;
11005 -- Follow subprogram renaming chain
11008 while Is_Subprogram (Result)
11010 (Is_Generic_Instance (Result)
11011 or else Nkind (Parent (Declaration_Node (Result))) =
11012 N_Subprogram_Renaming_Declaration)
11013 and then Present (Alias (Result))
11015 Result := Alias (Result);
11019 end Get_Base_Subprogram;
11021 -----------------------------
11022 -- Is_Config_Static_String --
11023 -----------------------------
11025 function Is_Config_Static_String (Arg : Node_Id) return Boolean is
11027 function Add_Config_Static_String (Arg : Node_Id) return Boolean;
11028 -- This is an internal recursive function that is just like the
11029 -- outer function except that it adds the string to the name buffer
11030 -- rather than placing the string in the name buffer.
11032 ------------------------------
11033 -- Add_Config_Static_String --
11034 ------------------------------
11036 function Add_Config_Static_String (Arg : Node_Id) return Boolean is
11043 if Nkind (N) = N_Op_Concat then
11044 if Add_Config_Static_String (Left_Opnd (N)) then
11045 N := Right_Opnd (N);
11051 if Nkind (N) /= N_String_Literal then
11052 Error_Msg_N ("string literal expected for pragma argument", N);
11056 for J in 1 .. String_Length (Strval (N)) loop
11057 C := Get_String_Char (Strval (N), J);
11059 if not In_Character_Range (C) then
11061 ("string literal contains invalid wide character",
11062 Sloc (N) + 1 + Source_Ptr (J));
11066 Add_Char_To_Name_Buffer (Get_Character (C));
11071 end Add_Config_Static_String;
11073 -- Start of prorcessing for Is_Config_Static_String
11078 return Add_Config_Static_String (Arg);
11079 end Is_Config_Static_String;
11081 -----------------------------------------
11082 -- Is_Non_Significant_Pragma_Reference --
11083 -----------------------------------------
11085 -- This function makes use of the following static table which indicates
11086 -- whether a given pragma is significant. A value of -1 in this table
11087 -- indicates that the reference is significant. A value of zero indicates
11088 -- than appearence as any argument is insignificant, a positive value
11089 -- indicates that appearence in that parameter position is significant.
11091 Sig_Flags : constant array (Pragma_Id) of Int :=
11093 (Pragma_AST_Entry => -1,
11094 Pragma_Abort_Defer => -1,
11095 Pragma_Ada_83 => -1,
11096 Pragma_Ada_95 => -1,
11097 Pragma_Ada_05 => -1,
11098 Pragma_Ada_2005 => -1,
11099 Pragma_All_Calls_Remote => -1,
11100 Pragma_Annotate => -1,
11101 Pragma_Assert => -1,
11102 Pragma_Assertion_Policy => 0,
11103 Pragma_Asynchronous => -1,
11104 Pragma_Atomic => 0,
11105 Pragma_Atomic_Components => 0,
11106 Pragma_Attach_Handler => -1,
11107 Pragma_CIL_Constructor => -1,
11108 Pragma_CPP_Class => 0,
11109 Pragma_CPP_Constructor => 0,
11110 Pragma_CPP_Virtual => 0,
11111 Pragma_CPP_Vtable => 0,
11112 Pragma_C_Pass_By_Copy => 0,
11113 Pragma_Comment => 0,
11114 Pragma_Common_Object => -1,
11115 Pragma_Compile_Time_Error => -1,
11116 Pragma_Compile_Time_Warning => -1,
11117 Pragma_Complete_Representation => 0,
11118 Pragma_Complex_Representation => 0,
11119 Pragma_Component_Alignment => -1,
11120 Pragma_Controlled => 0,
11121 Pragma_Convention => 0,
11122 Pragma_Convention_Identifier => 0,
11123 Pragma_Debug => -1,
11124 Pragma_Debug_Policy => 0,
11125 Pragma_Detect_Blocking => -1,
11126 Pragma_Discard_Names => 0,
11127 Pragma_Elaborate => -1,
11128 Pragma_Elaborate_All => -1,
11129 Pragma_Elaborate_Body => -1,
11130 Pragma_Elaboration_Checks => -1,
11131 Pragma_Eliminate => -1,
11132 Pragma_Export => -1,
11133 Pragma_Export_Exception => -1,
11134 Pragma_Export_Function => -1,
11135 Pragma_Export_Object => -1,
11136 Pragma_Export_Procedure => -1,
11137 Pragma_Export_Value => -1,
11138 Pragma_Export_Valued_Procedure => -1,
11139 Pragma_Extend_System => -1,
11140 Pragma_Extensions_Allowed => -1,
11141 Pragma_External => -1,
11142 Pragma_External_Name_Casing => -1,
11143 Pragma_Finalize_Storage_Only => 0,
11144 Pragma_Float_Representation => 0,
11145 Pragma_Ident => -1,
11146 Pragma_Import => +2,
11147 Pragma_Import_Exception => 0,
11148 Pragma_Import_Function => 0,
11149 Pragma_Import_Object => 0,
11150 Pragma_Import_Procedure => 0,
11151 Pragma_Import_Valued_Procedure => 0,
11152 Pragma_Initialize_Scalars => -1,
11153 Pragma_Inline => 0,
11154 Pragma_Inline_Always => 0,
11155 Pragma_Inline_Generic => 0,
11156 Pragma_Inspection_Point => -1,
11157 Pragma_Interface => +2,
11158 Pragma_Interface_Name => +2,
11159 Pragma_Interrupt_Handler => -1,
11160 Pragma_Interrupt_Priority => -1,
11161 Pragma_Interrupt_State => -1,
11162 Pragma_Java_Constructor => -1,
11163 Pragma_Java_Interface => -1,
11164 Pragma_Keep_Names => 0,
11165 Pragma_License => -1,
11166 Pragma_Link_With => -1,
11167 Pragma_Linker_Alias => -1,
11168 Pragma_Linker_Constructor => -1,
11169 Pragma_Linker_Destructor => -1,
11170 Pragma_Linker_Options => -1,
11171 Pragma_Linker_Section => -1,
11173 Pragma_Locking_Policy => -1,
11174 Pragma_Long_Float => -1,
11175 Pragma_Machine_Attribute => -1,
11177 Pragma_Main_Storage => -1,
11178 Pragma_Memory_Size => -1,
11179 Pragma_No_Return => 0,
11180 Pragma_No_Body => 0,
11181 Pragma_No_Run_Time => -1,
11182 Pragma_No_Strict_Aliasing => -1,
11183 Pragma_Normalize_Scalars => -1,
11184 Pragma_Obsolescent => 0,
11185 Pragma_Optimize => -1,
11188 Pragma_Passive => -1,
11189 Pragma_Preelaborable_Initialization => -1,
11190 Pragma_Polling => -1,
11191 Pragma_Persistent_BSS => 0,
11192 Pragma_Preelaborate => -1,
11193 Pragma_Preelaborate_05 => -1,
11194 Pragma_Priority => -1,
11195 Pragma_Priority_Specific_Dispatching => -1,
11196 Pragma_Profile => 0,
11197 Pragma_Profile_Warnings => 0,
11198 Pragma_Propagate_Exceptions => -1,
11199 Pragma_Psect_Object => -1,
11201 Pragma_Pure_05 => -1,
11202 Pragma_Pure_Function => -1,
11203 Pragma_Queuing_Policy => -1,
11204 Pragma_Ravenscar => -1,
11205 Pragma_Remote_Call_Interface => -1,
11206 Pragma_Remote_Types => -1,
11207 Pragma_Restricted_Run_Time => -1,
11208 Pragma_Restriction_Warnings => -1,
11209 Pragma_Restrictions => -1,
11210 Pragma_Reviewable => -1,
11211 Pragma_Share_Generic => -1,
11212 Pragma_Shared => -1,
11213 Pragma_Shared_Passive => -1,
11214 Pragma_Source_File_Name => -1,
11215 Pragma_Source_File_Name_Project => -1,
11216 Pragma_Source_Reference => -1,
11217 Pragma_Storage_Size => -1,
11218 Pragma_Storage_Unit => -1,
11219 Pragma_Static_Elaboration_Desired => -1,
11220 Pragma_Stream_Convert => -1,
11221 Pragma_Style_Checks => -1,
11222 Pragma_Subtitle => -1,
11223 Pragma_Suppress => 0,
11224 Pragma_Suppress_Exception_Locations => 0,
11225 Pragma_Suppress_All => -1,
11226 Pragma_Suppress_Debug_Info => 0,
11227 Pragma_Suppress_Initialization => 0,
11228 Pragma_System_Name => -1,
11229 Pragma_Task_Dispatching_Policy => -1,
11230 Pragma_Task_Info => -1,
11231 Pragma_Task_Name => -1,
11232 Pragma_Task_Storage => 0,
11233 Pragma_Time_Slice => -1,
11234 Pragma_Title => -1,
11235 Pragma_Unchecked_Union => 0,
11236 Pragma_Unimplemented_Unit => -1,
11237 Pragma_Universal_Aliasing => -1,
11238 Pragma_Universal_Data => -1,
11239 Pragma_Unreferenced => -1,
11240 Pragma_Unreferenced_Objects => -1,
11241 Pragma_Unreserve_All_Interrupts => -1,
11242 Pragma_Unsuppress => 0,
11243 Pragma_Use_VADS_Size => -1,
11244 Pragma_Validity_Checks => -1,
11245 Pragma_Volatile => 0,
11246 Pragma_Volatile_Components => 0,
11247 Pragma_Warnings => -1,
11248 Pragma_Weak_External => -1,
11249 Pragma_Wide_Character_Encoding => 0,
11250 Unknown_Pragma => 0);
11252 function Is_Non_Significant_Pragma_Reference (N : Node_Id) return Boolean is
11260 if Nkind (P) /= N_Pragma_Argument_Association then
11264 C := Sig_Flags (Get_Pragma_Id (Chars (Parent (P))));
11274 A := First (Pragma_Argument_Associations (Parent (P)));
11275 for J in 1 .. C - 1 loop
11286 end Is_Non_Significant_Pragma_Reference;
11288 ------------------------------
11289 -- Is_Pragma_String_Literal --
11290 ------------------------------
11292 -- This function returns true if the corresponding pragma argument is
11293 -- a static string expression. These are the only cases in which string
11294 -- literals can appear as pragma arguments. We also allow a string
11295 -- literal as the first argument to pragma Assert (although it will
11296 -- of course always generate a type error).
11298 function Is_Pragma_String_Literal (Par : Node_Id) return Boolean is
11299 Pragn : constant Node_Id := Parent (Par);
11300 Assoc : constant List_Id := Pragma_Argument_Associations (Pragn);
11301 Pname : constant Name_Id := Chars (Pragn);
11307 N := First (Assoc);
11314 if Pname = Name_Assert then
11317 elsif Pname = Name_Export then
11320 elsif Pname = Name_Ident then
11323 elsif Pname = Name_Import then
11326 elsif Pname = Name_Interface_Name then
11329 elsif Pname = Name_Linker_Alias then
11332 elsif Pname = Name_Linker_Section then
11335 elsif Pname = Name_Machine_Attribute then
11338 elsif Pname = Name_Source_File_Name then
11341 elsif Pname = Name_Source_Reference then
11344 elsif Pname = Name_Title then
11347 elsif Pname = Name_Subtitle then
11353 end Is_Pragma_String_Literal;
11355 --------------------------------------
11356 -- Process_Compilation_Unit_Pragmas --
11357 --------------------------------------
11359 procedure Process_Compilation_Unit_Pragmas (N : Node_Id) is
11361 -- A special check for pragma Suppress_All. This is a strange DEC
11362 -- pragma, strange because it comes at the end of the unit. If we
11363 -- have a pragma Suppress_All in the Pragmas_After of the current
11364 -- unit, then we insert a pragma Suppress (All_Checks) at the start
11365 -- of the context clause to ensure the correct processing.
11368 PA : constant List_Id := Pragmas_After (Aux_Decls_Node (N));
11372 if Present (PA) then
11374 while Present (P) loop
11375 if Chars (P) = Name_Suppress_All then
11376 Prepend_To (Context_Items (N),
11377 Make_Pragma (Sloc (P),
11378 Chars => Name_Suppress,
11379 Pragma_Argument_Associations => New_List (
11380 Make_Pragma_Argument_Association (Sloc (P),
11382 Make_Identifier (Sloc (P),
11383 Chars => Name_All_Checks)))));
11391 end Process_Compilation_Unit_Pragmas;
11402 --------------------------------
11403 -- Set_Encoded_Interface_Name --
11404 --------------------------------
11406 procedure Set_Encoded_Interface_Name (E : Entity_Id; S : Node_Id) is
11407 Str : constant String_Id := Strval (S);
11408 Len : constant Int := String_Length (Str);
11413 Hex : constant array (0 .. 15) of Character := "0123456789abcdef";
11416 -- Stores encoded value of character code CC. The encoding we
11417 -- use an underscore followed by four lower case hex digits.
11423 procedure Encode is
11425 Store_String_Char (Get_Char_Code ('_'));
11427 (Get_Char_Code (Hex (Integer (CC / 2 ** 12))));
11429 (Get_Char_Code (Hex (Integer (CC / 2 ** 8 and 16#0F#))));
11431 (Get_Char_Code (Hex (Integer (CC / 2 ** 4 and 16#0F#))));
11433 (Get_Char_Code (Hex (Integer (CC and 16#0F#))));
11436 -- Start of processing for Set_Encoded_Interface_Name
11439 -- If first character is asterisk, this is a link name, and we
11440 -- leave it completely unmodified. We also ignore null strings
11441 -- (the latter case happens only in error cases) and no encoding
11442 -- should occur for Java or AAMP interface names.
11445 or else Get_String_Char (Str, 1) = Get_Char_Code ('*')
11446 or else VM_Target /= No_VM
11447 or else AAMP_On_Target
11449 Set_Interface_Name (E, S);
11454 CC := Get_String_Char (Str, J);
11456 exit when not In_Character_Range (CC);
11458 C := Get_Character (CC);
11460 exit when C /= '_' and then C /= '$'
11461 and then C not in '0' .. '9'
11462 and then C not in 'a' .. 'z'
11463 and then C not in 'A' .. 'Z';
11466 Set_Interface_Name (E, S);
11474 -- Here we need to encode. The encoding we use as follows:
11475 -- three underscores + four hex digits (lower case)
11479 for J in 1 .. String_Length (Str) loop
11480 CC := Get_String_Char (Str, J);
11482 if not In_Character_Range (CC) then
11485 C := Get_Character (CC);
11487 if C = '_' or else C = '$'
11488 or else C in '0' .. '9'
11489 or else C in 'a' .. 'z'
11490 or else C in 'A' .. 'Z'
11492 Store_String_Char (CC);
11499 Set_Interface_Name (E,
11500 Make_String_Literal (Sloc (S),
11501 Strval => End_String));
11503 end Set_Encoded_Interface_Name;
11505 -------------------
11506 -- Set_Unit_Name --
11507 -------------------
11509 procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id) is
11514 if Nkind (N) = N_Identifier
11515 and then Nkind (With_Item) = N_Identifier
11517 Set_Entity (N, Entity (With_Item));
11519 elsif Nkind (N) = N_Selected_Component then
11520 Change_Selected_Component_To_Expanded_Name (N);
11521 Set_Entity (N, Entity (With_Item));
11522 Set_Entity (Selector_Name (N), Entity (N));
11524 Pref := Prefix (N);
11525 Scop := Scope (Entity (N));
11526 while Nkind (Pref) = N_Selected_Component loop
11527 Change_Selected_Component_To_Expanded_Name (Pref);
11528 Set_Entity (Selector_Name (Pref), Scop);
11529 Set_Entity (Pref, Scop);
11530 Pref := Prefix (Pref);
11531 Scop := Scope (Scop);
11534 Set_Entity (Pref, Scop);