1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- This unit contains the semantic processing for all pragmas, both language
28 -- and implementation defined. For most pragmas, the parser only does the
29 -- most basic job of checking the syntax, so Sem_Prag also contains the code
30 -- to complete the syntax checks. Certain pragmas are handled partially or
31 -- completely by the parser (see Par.Prag for further details).
33 with Atree; use Atree;
34 with Casing; use Casing;
35 with Csets; use Csets;
36 with Debug; use Debug;
37 with Einfo; use Einfo;
38 with Elists; use Elists;
39 with Errout; use Errout;
40 with Exp_Dist; use Exp_Dist;
41 with Hostparm; use Hostparm;
43 with Lib.Writ; use Lib.Writ;
44 with Lib.Xref; use Lib.Xref;
45 with Namet; use Namet;
46 with Nlists; use Nlists;
47 with Nmake; use Nmake;
49 with Output; use Output;
50 with Restrict; use Restrict;
51 with Rident; use Rident;
52 with Rtsfind; use Rtsfind;
54 with Sem_Ch3; use Sem_Ch3;
55 with Sem_Ch8; use Sem_Ch8;
56 with Sem_Ch13; use Sem_Ch13;
57 with Sem_Disp; use Sem_Disp;
58 with Sem_Elim; use Sem_Elim;
59 with Sem_Eval; use Sem_Eval;
60 with Sem_Intr; use Sem_Intr;
61 with Sem_Mech; use Sem_Mech;
62 with Sem_Res; use Sem_Res;
63 with Sem_Type; use Sem_Type;
64 with Sem_Util; use Sem_Util;
65 with Sem_VFpt; use Sem_VFpt;
66 with Stand; use Stand;
67 with Sinfo; use Sinfo;
68 with Sinfo.CN; use Sinfo.CN;
69 with Sinput; use Sinput;
70 with Snames; use Snames;
71 with Stringt; use Stringt;
72 with Stylesw; use Stylesw;
74 with Targparm; use Targparm;
75 with Tbuild; use Tbuild;
77 with Uintp; use Uintp;
78 with Urealp; use Urealp;
79 with Validsw; use Validsw;
81 with GNAT.Spelling_Checker; use GNAT.Spelling_Checker;
83 package body Sem_Prag is
85 ----------------------------------------------
86 -- Common Handling of Import-Export Pragmas --
87 ----------------------------------------------
89 -- In the following section, a number of Import_xxx and Export_xxx
90 -- pragmas are defined by GNAT. These are compatible with the DEC
91 -- pragmas of the same name, and all have the following common
92 -- form and processing:
95 -- [Internal =>] LOCAL_NAME,
96 -- [, [External =>] EXTERNAL_SYMBOL]
97 -- [, other optional parameters ]);
100 -- [Internal =>] LOCAL_NAME,
101 -- [, [External =>] EXTERNAL_SYMBOL]
102 -- [, other optional parameters ]);
104 -- EXTERNAL_SYMBOL ::=
106 -- | static_string_EXPRESSION
108 -- The internal LOCAL_NAME designates the entity that is imported or
109 -- exported, and must refer to an entity in the current declarative
110 -- part (as required by the rules for LOCAL_NAME).
112 -- The external linker name is designated by the External parameter
113 -- if given, or the Internal parameter if not (if there is no External
114 -- parameter, the External parameter is a copy of the Internal name).
116 -- If the External parameter is given as a string, then this string
117 -- is treated as an external name (exactly as though it had been given
118 -- as an External_Name parameter for a normal Import pragma).
120 -- If the External parameter is given as an identifier (or there is no
121 -- External parameter, so that the Internal identifier is used), then
122 -- the external name is the characters of the identifier, translated
123 -- to all upper case letters for OpenVMS versions of GNAT, and to all
124 -- lower case letters for all other versions
126 -- Note: the external name specified or implied by any of these special
127 -- Import_xxx or Export_xxx pragmas override an external or link name
128 -- specified in a previous Import or Export pragma.
130 -- Note: these and all other DEC-compatible GNAT pragmas allow full
131 -- use of named notation, following the standard rules for subprogram
132 -- calls, i.e. parameters can be given in any order if named notation
133 -- is used, and positional and named notation can be mixed, subject to
134 -- the rule that all positional parameters must appear first.
136 -- Note: All these pragmas are implemented exactly following the DEC
137 -- design and implementation and are intended to be fully compatible
138 -- with the use of these pragmas in the DEC Ada compiler.
140 --------------------------------------------
141 -- Checking for Duplicated External Names --
142 --------------------------------------------
144 -- It is suspicious if two separate Export pragmas use the same external
145 -- name. The following table is used to diagnose this situation so that
146 -- an appropriate warning can be issued.
148 -- The Node_Id stored is for the N_String_Literal node created to
149 -- hold the value of the external name. The Sloc of this node is
150 -- used to cross-reference the location of the duplication.
152 package Externals is new Table.Table (
153 Table_Component_Type => Node_Id,
154 Table_Index_Type => Int,
155 Table_Low_Bound => 0,
156 Table_Initial => 100,
157 Table_Increment => 100,
158 Table_Name => "Name_Externals");
160 -------------------------------------
161 -- Local Subprograms and Variables --
162 -------------------------------------
164 function Adjust_External_Name_Case (N : Node_Id) return Node_Id;
165 -- This routine is used for possible casing adjustment of an explicit
166 -- external name supplied as a string literal (the node N), according
167 -- to the casing requirement of Opt.External_Name_Casing. If this is
168 -- set to As_Is, then the string literal is returned unchanged, but if
169 -- it is set to Uppercase or Lowercase, then a new string literal with
170 -- appropriate casing is constructed.
172 function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id;
173 -- If Def_Id refers to a renamed subprogram, then the base subprogram
174 -- (the original one, following the renaming chain) is returned.
175 -- Otherwise the entity is returned unchanged. Should be in Einfo???
177 procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id);
178 -- Place semantic information on the argument of an Elaborate or
179 -- Elaborate_All pragma. Entity name for unit and its parents is
180 -- taken from item in previous with_clause that mentions the unit.
182 -------------------------------
183 -- Adjust_External_Name_Case --
184 -------------------------------
186 function Adjust_External_Name_Case (N : Node_Id) return Node_Id is
190 -- Adjust case of literal if required
192 if Opt.External_Name_Exp_Casing = As_Is then
196 -- Copy existing string
202 for J in 1 .. String_Length (Strval (N)) loop
203 CC := Get_String_Char (Strval (N), J);
205 if Opt.External_Name_Exp_Casing = Uppercase
206 and then CC >= Get_Char_Code ('a')
207 and then CC <= Get_Char_Code ('z')
209 Store_String_Char (CC - 32);
211 elsif Opt.External_Name_Exp_Casing = Lowercase
212 and then CC >= Get_Char_Code ('A')
213 and then CC <= Get_Char_Code ('Z')
215 Store_String_Char (CC + 32);
218 Store_String_Char (CC);
223 Make_String_Literal (Sloc (N),
224 Strval => End_String);
226 end Adjust_External_Name_Case;
232 procedure Analyze_Pragma (N : Node_Id) is
233 Loc : constant Source_Ptr := Sloc (N);
236 Pragma_Exit : exception;
237 -- This exception is used to exit pragma processing completely. It
238 -- is used when an error is detected, and in other situations where
239 -- it is known that no further processing is required.
242 -- Number of pragma argument associations
248 -- First four pragma arguments (pragma argument association nodes,
249 -- or Empty if the corresponding argument does not exist).
251 procedure Check_Ada_83_Warning;
252 -- Issues a warning message for the current pragma if operating in Ada
253 -- 83 mode (used for language pragmas that are not a standard part of
254 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
257 procedure Check_Arg_Count (Required : Nat);
258 -- Check argument count for pragma is equal to given parameter.
259 -- If not, then issue an error message and raise Pragma_Exit.
261 -- Note: all routines whose name is Check_Arg_Is_xxx take an
262 -- argument Arg which can either be a pragma argument association,
263 -- in which case the check is applied to the expression of the
264 -- association or an expression directly.
266 procedure Check_Arg_Is_External_Name (Arg : Node_Id);
267 -- Check that an argument has the right form for an EXTERNAL_NAME
268 -- parameter of an extended import/export pragma. The rule is that
269 -- the name must be an identifier or string literal (in Ada 83 mode)
270 -- or a static string expression (in Ada 95 mode).
272 procedure Check_Arg_Is_Identifier (Arg : Node_Id);
273 -- Check the specified argument Arg to make sure that it is an
274 -- identifier. If not give error and raise Pragma_Exit.
276 procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id);
277 -- Check the specified argument Arg to make sure that it is an
278 -- integer literal. If not give error and raise Pragma_Exit.
280 procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id);
281 -- Check the specified argument Arg to make sure that it has the
282 -- proper syntactic form for a local name and meets the semantic
283 -- requirements for a local name. The local name is analyzed as
284 -- part of the processing for this call. In addition, the local
285 -- name is required to represent an entity at the library level.
287 procedure Check_Arg_Is_Local_Name (Arg : Node_Id);
288 -- Check the specified argument Arg to make sure that it has the
289 -- proper syntactic form for a local name and meets the semantic
290 -- requirements for a local name. The local name is analyzed as
291 -- part of the processing for this call.
293 procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id);
294 -- Check the specified argument Arg to make sure that it is a valid
295 -- locking policy name. If not give error and raise Pragma_Exit.
297 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id);
298 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2, N3 : Name_Id);
299 -- Check the specified argument Arg to make sure that it is an
300 -- identifier whose name matches either N1 or N2 (or N3 if present).
301 -- If not then give error and raise Pragma_Exit.
303 procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id);
304 -- Check the specified argument Arg to make sure that it is a valid
305 -- queuing policy name. If not give error and raise Pragma_Exit.
307 procedure Check_Arg_Is_Static_Expression
310 -- Check the specified argument Arg to make sure that it is a static
311 -- expression of the given type (i.e. it will be analyzed and resolved
312 -- using this type, which can be any valid argument to Resolve, e.g.
313 -- Any_Integer is OK). If not, given error and raise Pragma_Exit.
315 procedure Check_Arg_Is_String_Literal (Arg : Node_Id);
316 -- Check the specified argument Arg to make sure that it is a
317 -- string literal. If not give error and raise Pragma_Exit
319 procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id);
320 -- Check the specified argument Arg to make sure that it is a valid
321 -- valid task dispatching policy name. If not give error and raise
324 procedure Check_At_Least_N_Arguments (N : Nat);
325 -- Check there are at least N arguments present
327 procedure Check_At_Most_N_Arguments (N : Nat);
328 -- Check there are no more than N arguments present
330 procedure Check_Component (Comp : Node_Id);
331 -- Examine Unchecked_Union component for correct use of per-object
332 -- constrained subtypes.
334 procedure Check_Duplicated_Export_Name (Nam : Node_Id);
335 -- Nam is an N_String_Literal node containing the external name set
336 -- by an Import or Export pragma (or extended Import or Export pragma).
337 -- This procedure checks for possible duplications if this is the
338 -- export case, and if found, issues an appropriate error message.
340 procedure Check_First_Subtype (Arg : Node_Id);
341 -- Checks that Arg, whose expression is an entity name referencing
342 -- a subtype, does not reference a type that is not a first subtype.
344 procedure Check_In_Main_Program;
345 -- Common checks for pragmas that appear within a main program
346 -- (Priority, Main_Storage, Time_Slice).
348 procedure Check_Interrupt_Or_Attach_Handler;
349 -- Common processing for first argument of pragma Interrupt_Handler
350 -- or pragma Attach_Handler.
352 procedure Check_Is_In_Decl_Part_Or_Package_Spec;
353 -- Check that pragma appears in a declarative part, or in a package
354 -- specification, i.e. that it does not occur in a statement sequence
357 procedure Check_No_Identifier (Arg : Node_Id);
358 -- Checks that the given argument does not have an identifier. If
359 -- an identifier is present, then an error message is issued, and
360 -- Pragma_Exit is raised.
362 procedure Check_No_Identifiers;
363 -- Checks that none of the arguments to the pragma has an identifier.
364 -- If any argument has an identifier, then an error message is issued,
365 -- and Pragma_Exit is raised.
367 procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id);
368 -- Checks if the given argument has an identifier, and if so, requires
369 -- it to match the given identifier name. If there is a non-matching
370 -- identifier, then an error message is given and Error_Pragmas raised.
372 procedure Check_Optional_Identifier (Arg : Node_Id; Id : String);
373 -- Checks if the given argument has an identifier, and if so, requires
374 -- it to match the given identifier name. If there is a non-matching
375 -- identifier, then an error message is given and Error_Pragmas raised.
376 -- In this version of the procedure, the identifier name is given as
377 -- a string with lower case letters.
379 procedure Check_Static_Constraint (Constr : Node_Id);
380 -- Constr is a constraint from an N_Subtype_Indication node from a
381 -- component constraint in an Unchecked_Union type. This routine checks
382 -- that the constraint is static as required by the restrictions for
385 procedure Check_Valid_Configuration_Pragma;
386 -- Legality checks for placement of a configuration pragma
388 procedure Check_Valid_Library_Unit_Pragma;
389 -- Legality checks for library unit pragmas. A special case arises for
390 -- pragmas in generic instances that come from copies of the original
391 -- library unit pragmas in the generic templates. In the case of other
392 -- than library level instantiations these can appear in contexts which
393 -- would normally be invalid (they only apply to the original template
394 -- and to library level instantiations), and they are simply ignored,
395 -- which is implemented by rewriting them as null statements.
397 procedure Check_Variant (Variant : Node_Id);
398 -- Check Unchecked_Union variant for lack of nested variants and
399 -- presence of at least one component.
401 procedure Error_Pragma (Msg : String);
402 pragma No_Return (Error_Pragma);
403 -- Outputs error message for current pragma. The message contains an %
404 -- that will be replaced with the pragma name, and the flag is placed
405 -- on the pragma itself. Pragma_Exit is then raised.
407 procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id);
408 pragma No_Return (Error_Pragma_Arg);
409 -- Outputs error message for current pragma. The message may contain
410 -- a % that will be replaced with the pragma name. The parameter Arg
411 -- may either be a pragma argument association, in which case the flag
412 -- is placed on the expression of this association, or an expression,
413 -- in which case the flag is placed directly on the expression. The
414 -- message is placed using Error_Msg_N, so the message may also contain
415 -- an & insertion character which will reference the given Arg value.
416 -- After placing the message, Pragma_Exit is raised.
418 procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id);
419 pragma No_Return (Error_Pragma_Arg);
420 -- Similar to above form of Error_Pragma_Arg except that two messages
421 -- are provided, the second is a continuation comment starting with \.
423 procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id);
424 pragma No_Return (Error_Pragma_Arg_Ident);
425 -- Outputs error message for current pragma. The message may contain
426 -- a % that will be replaced with the pragma name. The parameter Arg
427 -- must be a pragma argument association with a non-empty identifier
428 -- (i.e. its Chars field must be set), and the error message is placed
429 -- on the identifier. The message is placed using Error_Msg_N so
430 -- the message may also contain an & insertion character which will
431 -- reference the identifier. After placing the message, Pragma_Exit
434 function Find_Lib_Unit_Name return Entity_Id;
435 -- Used for a library unit pragma to find the entity to which the
436 -- library unit pragma applies, returns the entity found.
438 procedure Find_Program_Unit_Name (Id : Node_Id);
439 -- If the pragma is a compilation unit pragma, the id must denote the
440 -- compilation unit in the same compilation, and the pragma must appear
441 -- in the list of preceding or trailing pragmas. If it is a program
442 -- unit pragma that is not a compilation unit pragma, then the
443 -- identifier must be visible.
445 type Name_List is array (Natural range <>) of Name_Id;
446 type Args_List is array (Natural range <>) of Node_Id;
447 procedure Gather_Associations
449 Args : out Args_List);
450 -- This procedure is used to gather the arguments for a pragma that
451 -- permits arbitrary ordering of parameters using the normal rules
452 -- for named and positional parameters. The Names argument is a list
453 -- of Name_Id values that corresponds to the allowed pragma argument
454 -- association identifiers in order. The result returned in Args is
455 -- a list of corresponding expressions that are the pragma arguments.
456 -- Note that this is a list of expressions, not of pragma argument
457 -- associations (Gather_Associations has completely checked all the
458 -- optional identifiers when it returns). An entry in Args is Empty
459 -- on return if the corresponding argument is not present.
461 function Get_Pragma_Arg (Arg : Node_Id) return Node_Id;
462 -- All the routines that check pragma arguments take either a pragma
463 -- argument association (in which case the expression of the argument
464 -- association is checked), or the expression directly. The function
465 -- Get_Pragma_Arg is a utility used to deal with these two cases. If
466 -- Arg is a pragma argument association node, then its expression is
467 -- returned, otherwise Arg is returned unchanged.
469 procedure GNAT_Pragma;
470 -- Called for all GNAT defined pragmas to note the use of the feature,
471 -- and also check the relevant restriction (No_Implementation_Pragmas).
473 function Is_Before_First_Decl
474 (Pragma_Node : Node_Id;
475 Decls : List_Id) return Boolean;
476 -- Return True if Pragma_Node is before the first declarative item in
477 -- Decls where Decls is the list of declarative items.
479 function Is_Configuration_Pragma return Boolean;
480 -- Deterermines if the placement of the current pragma is appropriate
481 -- for a configuration pragma (precedes the current compilation unit)
483 procedure Pragma_Misplaced;
484 -- Issue fatal error message for misplaced pragma
486 procedure Process_Atomic_Shared_Volatile;
487 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
488 -- Shared is an obsolete Ada 83 pragma, treated as being identical
489 -- in effect to pragma Atomic.
491 procedure Process_Convention (C : out Convention_Id; E : out Entity_Id);
492 -- Common procesing for Convention, Interface, Import and Export.
493 -- Checks first two arguments of pragma, and sets the appropriate
494 -- convention value in the specified entity or entities. On return
495 -- C is the convention, E is the referenced entity.
497 procedure Process_Extended_Import_Export_Exception_Pragma
498 (Arg_Internal : Node_Id;
499 Arg_External : Node_Id;
502 -- Common processing for the pragmas Import/Export_Exception.
503 -- The three arguments correspond to the three named parameters of
504 -- the pragma. An argument is empty if the corresponding parameter
505 -- is not present in the pragma.
507 procedure Process_Extended_Import_Export_Object_Pragma
508 (Arg_Internal : Node_Id;
509 Arg_External : Node_Id;
511 -- Common processing for the pragmass Import/Export_Object.
512 -- The three arguments correspond to the three named parameters
513 -- of the pragmas. An argument is empty if the corresponding
514 -- parameter is not present in the pragma.
516 procedure Process_Extended_Import_Export_Internal_Arg
517 (Arg_Internal : Node_Id := Empty);
518 -- Common processing for all extended Import and Export pragmas. The
519 -- argument is the pragma parameter for the Internal argument. If
520 -- Arg_Internal is empty or inappropriate, an error message is posted.
521 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
522 -- set to identify the referenced entity.
524 procedure Process_Extended_Import_Export_Subprogram_Pragma
525 (Arg_Internal : Node_Id;
526 Arg_External : Node_Id;
527 Arg_Parameter_Types : Node_Id;
528 Arg_Result_Type : Node_Id := Empty;
529 Arg_Mechanism : Node_Id;
530 Arg_Result_Mechanism : Node_Id := Empty;
531 Arg_First_Optional_Parameter : Node_Id := Empty);
532 -- Common processing for all extended Import and Export pragmas
533 -- applying to subprograms. The caller omits any arguments that do
534 -- bnot apply to the pragma in question (for example, Arg_Result_Type
535 -- can be non-Empty only in the Import_Function and Export_Function
536 -- cases). The argument names correspond to the allowed pragma
537 -- association identifiers.
539 procedure Process_Generic_List;
540 -- Common processing for Share_Generic and Inline_Generic
542 procedure Process_Import_Or_Interface;
543 -- Common processing for Import of Interface
545 procedure Process_Inline (Active : Boolean);
546 -- Common processing for Inline and Inline_Always. The parameter
547 -- indicates if the inline pragma is active, i.e. if it should
548 -- actually cause inlining to occur.
550 procedure Process_Interface_Name
551 (Subprogram_Def : Entity_Id;
554 -- Given the last two arguments of pragma Import, pragma Export, or
555 -- pragma Interface_Name, performs validity checks and sets the
556 -- Interface_Name field of the given subprogram entity to the
557 -- appropriate external or link name, depending on the arguments
558 -- given. Ext_Arg is always present, but Link_Arg may be missing.
559 -- Note that Ext_Arg may represent the Link_Name if Link_Arg is
560 -- missing, and appropriate named notation is used for Ext_Arg.
561 -- If neither Ext_Arg nor Link_Arg is present, the interface name
562 -- is set to the default from the subprogram name.
564 procedure Process_Interrupt_Or_Attach_Handler;
565 -- Common processing for Interrupt and Attach_Handler pragmas
567 procedure Process_Restrictions_Or_Restriction_Warnings;
568 -- Common processing for Restrictions and Restriction_Warnings pragmas
570 procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean);
571 -- Common processing for Suppress and Unsuppress. The boolean parameter
572 -- Suppress_Case is True for the Suppress case, and False for the
575 procedure Set_Exported (E : Entity_Id; Arg : Node_Id);
576 -- This procedure sets the Is_Exported flag for the given entity,
577 -- checking that the entity was not previously imported. Arg is
578 -- the argument that specified the entity. A check is also made
579 -- for exporting inappropriate entities.
581 procedure Set_Extended_Import_Export_External_Name
582 (Internal_Ent : Entity_Id;
583 Arg_External : Node_Id);
584 -- Common processing for all extended import export pragmas. The first
585 -- argument, Internal_Ent, is the internal entity, which has already
586 -- been checked for validity by the caller. Arg_External is from the
587 -- Import or Export pragma, and may be null if no External parameter
588 -- was present. If Arg_External is present and is a non-null string
589 -- (a null string is treated as the default), then the Interface_Name
590 -- field of Internal_Ent is set appropriately.
592 procedure Set_Imported (E : Entity_Id);
593 -- This procedure sets the Is_Imported flag for the given entity,
594 -- checking that it is not previously exported or imported.
596 procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id);
597 -- Mech is a parameter passing mechanism (see Import_Function syntax
598 -- for MECHANISM_NAME). This routine checks that the mechanism argument
599 -- has the right form, and if not issues an error message. If the
600 -- argument has the right form then the Mechanism field of Ent is
601 -- set appropriately.
603 procedure Set_Ravenscar_Profile (N : Node_Id);
604 -- Activate the set of configuration pragmas and restrictions that
605 -- make up the Ravenscar Profile. N is the corresponding pragma
606 -- node, which is used for error messages on any constructs
607 -- that violate the profile.
609 --------------------------
610 -- Check_Ada_83_Warning --
611 --------------------------
613 procedure Check_Ada_83_Warning is
615 if Ada_Version = Ada_83 and then Comes_From_Source (N) then
616 Error_Msg_N ("(Ada 83) pragma& is non-standard?", N);
618 end Check_Ada_83_Warning;
620 ---------------------
621 -- Check_Arg_Count --
622 ---------------------
624 procedure Check_Arg_Count (Required : Nat) is
626 if Arg_Count /= Required then
627 Error_Pragma ("wrong number of arguments for pragma%");
631 --------------------------------
632 -- Check_Arg_Is_External_Name --
633 --------------------------------
635 procedure Check_Arg_Is_External_Name (Arg : Node_Id) is
636 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
639 if Nkind (Argx) = N_Identifier then
643 Analyze_And_Resolve (Argx, Standard_String);
645 if Is_OK_Static_Expression (Argx) then
648 elsif Etype (Argx) = Any_Type then
651 -- An interesting special case, if we have a string literal and
652 -- we are in Ada 83 mode, then we allow it even though it will
653 -- not be flagged as static. This allows expected Ada 83 mode
654 -- use of external names which are string literals, even though
655 -- technically these are not static in Ada 83.
657 elsif Ada_Version = Ada_83
658 and then Nkind (Argx) = N_String_Literal
662 -- Static expression that raises Constraint_Error. This has
663 -- already been flagged, so just exit from pragma processing.
665 elsif Is_Static_Expression (Argx) then
668 -- Here we have a real error (non-static expression)
671 Error_Msg_Name_1 := Chars (N);
673 ("argument for pragma% must be a identifier or " &
674 "static string expression!", Argx);
678 end Check_Arg_Is_External_Name;
680 -----------------------------
681 -- Check_Arg_Is_Identifier --
682 -----------------------------
684 procedure Check_Arg_Is_Identifier (Arg : Node_Id) is
685 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
687 if Nkind (Argx) /= N_Identifier then
689 ("argument for pragma% must be identifier", Argx);
691 end Check_Arg_Is_Identifier;
693 ----------------------------------
694 -- Check_Arg_Is_Integer_Literal --
695 ----------------------------------
697 procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id) is
698 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
700 if Nkind (Argx) /= N_Integer_Literal then
702 ("argument for pragma% must be integer literal", Argx);
704 end Check_Arg_Is_Integer_Literal;
706 -------------------------------------------
707 -- Check_Arg_Is_Library_Level_Local_Name --
708 -------------------------------------------
712 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
713 -- | library_unit_NAME
715 procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id) is
717 Check_Arg_Is_Local_Name (Arg);
719 if not Is_Library_Level_Entity (Entity (Expression (Arg)))
720 and then Comes_From_Source (N)
723 ("argument for pragma% must be library level entity", Arg);
725 end Check_Arg_Is_Library_Level_Local_Name;
727 -----------------------------
728 -- Check_Arg_Is_Local_Name --
729 -----------------------------
733 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
734 -- | library_unit_NAME
736 procedure Check_Arg_Is_Local_Name (Arg : Node_Id) is
737 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
742 if Nkind (Argx) not in N_Direct_Name
743 and then (Nkind (Argx) /= N_Attribute_Reference
744 or else Present (Expressions (Argx))
745 or else Nkind (Prefix (Argx)) /= N_Identifier)
746 and then (not Is_Entity_Name (Argx)
747 or else not Is_Compilation_Unit (Entity (Argx)))
749 Error_Pragma_Arg ("argument for pragma% must be local name", Argx);
752 if Is_Entity_Name (Argx)
753 and then Scope (Entity (Argx)) /= Current_Scope
756 ("pragma% argument must be in same declarative part", Arg);
758 end Check_Arg_Is_Local_Name;
760 ---------------------------------
761 -- Check_Arg_Is_Locking_Policy --
762 ---------------------------------
764 procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id) is
765 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
768 Check_Arg_Is_Identifier (Argx);
770 if not Is_Locking_Policy_Name (Chars (Argx)) then
772 ("& is not a valid locking policy name", Argx);
774 end Check_Arg_Is_Locking_Policy;
776 -------------------------
777 -- Check_Arg_Is_One_Of --
778 -------------------------
780 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id) is
781 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
784 Check_Arg_Is_Identifier (Argx);
786 if Chars (Argx) /= N1 and then Chars (Argx) /= N2 then
787 Error_Msg_Name_2 := N1;
788 Error_Msg_Name_3 := N2;
789 Error_Pragma_Arg ("argument for pragma% must be% or%", Argx);
791 end Check_Arg_Is_One_Of;
793 procedure Check_Arg_Is_One_Of
795 N1, N2, N3 : Name_Id)
797 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
800 Check_Arg_Is_Identifier (Argx);
802 if Chars (Argx) /= N1
803 and then Chars (Argx) /= N2
804 and then Chars (Argx) /= N3
806 Error_Pragma_Arg ("invalid argument for pragma%", Argx);
808 end Check_Arg_Is_One_Of;
810 ---------------------------------
811 -- Check_Arg_Is_Queuing_Policy --
812 ---------------------------------
814 procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id) is
815 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
818 Check_Arg_Is_Identifier (Argx);
820 if not Is_Queuing_Policy_Name (Chars (Argx)) then
822 ("& is not a valid queuing policy name", Argx);
824 end Check_Arg_Is_Queuing_Policy;
826 ------------------------------------
827 -- Check_Arg_Is_Static_Expression --
828 ------------------------------------
830 procedure Check_Arg_Is_Static_Expression
834 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
837 Analyze_And_Resolve (Argx, Typ);
839 if Is_OK_Static_Expression (Argx) then
842 elsif Etype (Argx) = Any_Type then
845 -- An interesting special case, if we have a string literal and
846 -- we are in Ada 83 mode, then we allow it even though it will
847 -- not be flagged as static. This allows the use of Ada 95
848 -- pragmas like Import in Ada 83 mode. They will of course be
849 -- flagged with warnings as usual, but will not cause errors.
851 elsif Ada_Version = Ada_83
852 and then Nkind (Argx) = N_String_Literal
856 -- Static expression that raises Constraint_Error. This has
857 -- already been flagged, so just exit from pragma processing.
859 elsif Is_Static_Expression (Argx) then
862 -- Finally, we have a real error
865 Error_Msg_Name_1 := Chars (N);
867 ("argument for pragma% must be a static expression!", Argx);
870 end Check_Arg_Is_Static_Expression;
872 ---------------------------------
873 -- Check_Arg_Is_String_Literal --
874 ---------------------------------
876 procedure Check_Arg_Is_String_Literal (Arg : Node_Id) is
877 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
880 if Nkind (Argx) /= N_String_Literal then
882 ("argument for pragma% must be string literal", Argx);
885 end Check_Arg_Is_String_Literal;
887 ------------------------------------------
888 -- Check_Arg_Is_Task_Dispatching_Policy --
889 ------------------------------------------
891 procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id) is
892 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
895 Check_Arg_Is_Identifier (Argx);
897 if not Is_Task_Dispatching_Policy_Name (Chars (Argx)) then
899 ("& is not a valid task dispatching policy name", Argx);
901 end Check_Arg_Is_Task_Dispatching_Policy;
903 --------------------------------
904 -- Check_At_Least_N_Arguments --
905 --------------------------------
907 procedure Check_At_Least_N_Arguments (N : Nat) is
909 if Arg_Count < N then
910 Error_Pragma ("too few arguments for pragma%");
912 end Check_At_Least_N_Arguments;
914 -------------------------------
915 -- Check_At_Most_N_Arguments --
916 -------------------------------
918 procedure Check_At_Most_N_Arguments (N : Nat) is
922 if Arg_Count > N then
926 Error_Pragma_Arg ("too many arguments for pragma%", Arg);
929 end Check_At_Most_N_Arguments;
931 ---------------------
932 -- Check_Component --
933 ---------------------
935 procedure Check_Component (Comp : Node_Id) is
937 if Nkind (Comp) = N_Component_Declaration then
939 Sindic : constant Node_Id :=
940 Subtype_Indication (Component_Definition (Comp));
943 if Nkind (Sindic) = N_Subtype_Indication then
945 -- Ada 2005 (AI-216): If a component subtype is subject to
946 -- a per-object constraint, then the component type shall
947 -- be an Unchecked_Union.
949 if Has_Per_Object_Constraint (Defining_Identifier (Comp))
951 not Is_Unchecked_Union (Etype (Subtype_Mark (Sindic)))
953 Error_Msg_N ("component subtype subject to per-object" &
954 " constraint must be an Unchecked_Union", Comp);
961 ----------------------------------
962 -- Check_Duplicated_Export_Name --
963 ----------------------------------
965 procedure Check_Duplicated_Export_Name (Nam : Node_Id) is
966 String_Val : constant String_Id := Strval (Nam);
969 -- We are only interested in the export case, and in the case of
970 -- generics, it is the instance, not the template, that is the
971 -- problem (the template will generate a warning in any case).
973 if not Inside_A_Generic
974 and then (Prag_Id = Pragma_Export
976 Prag_Id = Pragma_Export_Procedure
978 Prag_Id = Pragma_Export_Valued_Procedure
980 Prag_Id = Pragma_Export_Function)
982 for J in Externals.First .. Externals.Last loop
983 if String_Equal (String_Val, Strval (Externals.Table (J))) then
984 Error_Msg_Sloc := Sloc (Externals.Table (J));
985 Error_Msg_N ("external name duplicates name given#", Nam);
990 Externals.Append (Nam);
992 end Check_Duplicated_Export_Name;
994 -------------------------
995 -- Check_First_Subtype --
996 -------------------------
998 procedure Check_First_Subtype (Arg : Node_Id) is
999 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1002 if not Is_First_Subtype (Entity (Argx)) then
1004 ("pragma% cannot apply to subtype", Argx);
1006 end Check_First_Subtype;
1008 ---------------------------
1009 -- Check_In_Main_Program --
1010 ---------------------------
1012 procedure Check_In_Main_Program is
1013 P : constant Node_Id := Parent (N);
1016 -- Must be at in subprogram body
1018 if Nkind (P) /= N_Subprogram_Body then
1019 Error_Pragma ("% pragma allowed only in subprogram");
1021 -- Otherwise warn if obviously not main program
1023 elsif Present (Parameter_Specifications (Specification (P)))
1024 or else not Is_Compilation_Unit (Defining_Entity (P))
1026 Error_Msg_Name_1 := Chars (N);
1028 ("?pragma% is only effective in main program", N);
1030 end Check_In_Main_Program;
1032 ---------------------------------------
1033 -- Check_Interrupt_Or_Attach_Handler --
1034 ---------------------------------------
1036 procedure Check_Interrupt_Or_Attach_Handler is
1037 Arg1_X : constant Node_Id := Expression (Arg1);
1042 if not Is_Entity_Name (Arg1_X) then
1044 ("argument of pragma% must be entity name", Arg1);
1046 elsif Prag_Id = Pragma_Interrupt_Handler then
1047 Check_Restriction (No_Dynamic_Attachment, N);
1051 Handler_Proc : Entity_Id := Empty;
1052 Proc_Scope : Entity_Id;
1053 Found : Boolean := False;
1056 if not Is_Overloaded (Arg1_X) then
1057 Handler_Proc := Entity (Arg1_X);
1062 Index : Interp_Index;
1065 Get_First_Interp (Arg1_X, Index, It);
1066 while Present (It.Nam) loop
1067 Handler_Proc := It.Nam;
1069 if Ekind (Handler_Proc) = E_Procedure
1070 and then No (First_Formal (Handler_Proc))
1074 Set_Entity (Arg1_X, Handler_Proc);
1075 Set_Is_Overloaded (Arg1_X, False);
1078 ("ambiguous handler name for pragma% ", Arg1);
1082 Get_Next_Interp (Index, It);
1087 ("argument of pragma% must be parameterless procedure",
1090 Handler_Proc := Entity (Arg1_X);
1095 Proc_Scope := Scope (Handler_Proc);
1097 -- On AAMP only, a pragma Interrupt_Handler is supported for
1098 -- nonprotected parameterless procedures.
1101 and then Prag_Id = Pragma_Interrupt_Handler
1103 if Ekind (Handler_Proc) /= E_Procedure then
1105 ("argument of pragma% must be a procedure", Arg1);
1108 elsif Ekind (Handler_Proc) /= E_Procedure
1109 or else Ekind (Proc_Scope) /= E_Protected_Type
1112 ("argument of pragma% must be protected procedure", Arg1);
1115 if (not AAMP_On_Target or else Prag_Id = Pragma_Attach_Handler)
1116 and then Ekind (Proc_Scope) = E_Protected_Type
1119 Protected_Definition (Parent (Proc_Scope))
1121 Error_Pragma ("pragma% must be in protected definition");
1125 if not Is_Library_Level_Entity (Proc_Scope)
1126 or else (AAMP_On_Target
1127 and then not Is_Library_Level_Entity (Handler_Proc))
1130 ("pragma% requires library-level entity", Arg1);
1133 if Present (First_Formal (Handler_Proc)) then
1135 ("argument of pragma% must be parameterless procedure",
1139 end Check_Interrupt_Or_Attach_Handler;
1141 -------------------------------------------
1142 -- Check_Is_In_Decl_Part_Or_Package_Spec --
1143 -------------------------------------------
1145 procedure Check_Is_In_Decl_Part_Or_Package_Spec is
1154 elsif Nkind (P) = N_Handled_Sequence_Of_Statements then
1157 elsif Nkind (P) = N_Package_Specification then
1160 elsif Nkind (P) = N_Block_Statement then
1163 -- Note: the following tests seem a little peculiar, because
1164 -- they test for bodies, but if we were in the statement part
1165 -- of the body, we would already have hit the handled statement
1166 -- sequence, so the only way we get here is by being in the
1167 -- declarative part of the body.
1169 elsif Nkind (P) = N_Subprogram_Body
1170 or else Nkind (P) = N_Package_Body
1171 or else Nkind (P) = N_Task_Body
1172 or else Nkind (P) = N_Entry_Body
1180 Error_Pragma ("pragma% is not in declarative part or package spec");
1181 end Check_Is_In_Decl_Part_Or_Package_Spec;
1183 -------------------------
1184 -- Check_No_Identifier --
1185 -------------------------
1187 procedure Check_No_Identifier (Arg : Node_Id) is
1189 if Chars (Arg) /= No_Name then
1190 Error_Pragma_Arg_Ident
1191 ("pragma% does not permit identifier& here", Arg);
1193 end Check_No_Identifier;
1195 --------------------------
1196 -- Check_No_Identifiers --
1197 --------------------------
1199 procedure Check_No_Identifiers is
1203 if Arg_Count > 0 then
1206 while Present (Arg_Node) loop
1207 Check_No_Identifier (Arg_Node);
1211 end Check_No_Identifiers;
1213 -------------------------------
1214 -- Check_Optional_Identifier --
1215 -------------------------------
1217 procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id) is
1219 if Present (Arg) and then Chars (Arg) /= No_Name then
1220 if Chars (Arg) /= Id then
1221 Error_Msg_Name_1 := Chars (N);
1222 Error_Msg_Name_2 := Id;
1223 Error_Msg_N ("pragma% argument expects identifier%", Arg);
1227 end Check_Optional_Identifier;
1229 procedure Check_Optional_Identifier (Arg : Node_Id; Id : String) is
1231 Name_Buffer (1 .. Id'Length) := Id;
1232 Name_Len := Id'Length;
1233 Check_Optional_Identifier (Arg, Name_Find);
1234 end Check_Optional_Identifier;
1236 -----------------------------
1237 -- Check_Static_Constraint --
1238 -----------------------------
1240 -- Note: for convenience in writing this procedure, in addition to
1241 -- the officially (i.e. by spec) allowed argument which is always
1242 -- a constraint, it also allows ranges and discriminant associations.
1243 -- Above is not clear ???
1245 procedure Check_Static_Constraint (Constr : Node_Id) is
1247 --------------------
1248 -- Require_Static --
1249 --------------------
1251 procedure Require_Static (E : Node_Id);
1252 -- Require given expression to be static expression
1254 procedure Require_Static (E : Node_Id) is
1256 if not Is_OK_Static_Expression (E) then
1257 Flag_Non_Static_Expr
1258 ("non-static constraint not allowed in Unchecked_Union!", E);
1263 -- Start of processing for Check_Static_Constraint
1266 case Nkind (Constr) is
1267 when N_Discriminant_Association =>
1268 Require_Static (Expression (Constr));
1271 Require_Static (Low_Bound (Constr));
1272 Require_Static (High_Bound (Constr));
1274 when N_Attribute_Reference =>
1275 Require_Static (Type_Low_Bound (Etype (Prefix (Constr))));
1276 Require_Static (Type_High_Bound (Etype (Prefix (Constr))));
1278 when N_Range_Constraint =>
1279 Check_Static_Constraint (Range_Expression (Constr));
1281 when N_Index_Or_Discriminant_Constraint =>
1283 IDC : Entity_Id := First (Constraints (Constr));
1285 while Present (IDC) loop
1286 Check_Static_Constraint (IDC);
1294 end Check_Static_Constraint;
1296 --------------------------------------
1297 -- Check_Valid_Configuration_Pragma --
1298 --------------------------------------
1300 -- A configuration pragma must appear in the context clause of
1301 -- a compilation unit, at the start of the list (i.e. only other
1302 -- pragmas may precede it).
1304 procedure Check_Valid_Configuration_Pragma is
1306 if not Is_Configuration_Pragma then
1307 Error_Pragma ("incorrect placement for configuration pragma%");
1309 end Check_Valid_Configuration_Pragma;
1311 -------------------------------------
1312 -- Check_Valid_Library_Unit_Pragma --
1313 -------------------------------------
1315 procedure Check_Valid_Library_Unit_Pragma is
1317 Parent_Node : Node_Id;
1318 Unit_Name : Entity_Id;
1319 Unit_Kind : Node_Kind;
1320 Unit_Node : Node_Id;
1321 Sindex : Source_File_Index;
1324 if not Is_List_Member (N) then
1328 Plist := List_Containing (N);
1329 Parent_Node := Parent (Plist);
1331 if Parent_Node = Empty then
1334 -- Case of pragma appearing after a compilation unit. In this
1335 -- case it must have an argument with the corresponding name
1336 -- and must be part of the following pragmas of its parent.
1338 elsif Nkind (Parent_Node) = N_Compilation_Unit_Aux then
1339 if Plist /= Pragmas_After (Parent_Node) then
1342 elsif Arg_Count = 0 then
1344 ("argument required if outside compilation unit");
1347 Check_No_Identifiers;
1348 Check_Arg_Count (1);
1349 Unit_Node := Unit (Parent (Parent_Node));
1350 Unit_Kind := Nkind (Unit_Node);
1352 Analyze (Expression (Arg1));
1354 if Unit_Kind = N_Generic_Subprogram_Declaration
1355 or else Unit_Kind = N_Subprogram_Declaration
1357 Unit_Name := Defining_Entity (Unit_Node);
1359 elsif Unit_Kind = N_Function_Instantiation
1360 or else Unit_Kind = N_Package_Instantiation
1361 or else Unit_Kind = N_Procedure_Instantiation
1363 Unit_Name := Defining_Entity (Unit_Node);
1366 Unit_Name := Cunit_Entity (Current_Sem_Unit);
1369 if Chars (Unit_Name) /=
1370 Chars (Entity (Expression (Arg1)))
1373 ("pragma% argument is not current unit name", Arg1);
1376 if Ekind (Unit_Name) = E_Package
1377 and then Present (Renamed_Entity (Unit_Name))
1379 Error_Pragma ("pragma% not allowed for renamed package");
1383 -- Pragma appears other than after a compilation unit
1386 -- Here we check for the generic instantiation case and also
1387 -- for the case of processing a generic formal package. We
1388 -- detect these cases by noting that the Sloc on the node
1389 -- does not belong to the current compilation unit.
1391 Sindex := Source_Index (Current_Sem_Unit);
1393 if Loc not in Source_First (Sindex) .. Source_Last (Sindex) then
1394 Rewrite (N, Make_Null_Statement (Loc));
1397 -- If before first declaration, the pragma applies to the
1398 -- enclosing unit, and the name if present must be this name.
1400 elsif Is_Before_First_Decl (N, Plist) then
1401 Unit_Node := Unit_Declaration_Node (Current_Scope);
1402 Unit_Kind := Nkind (Unit_Node);
1404 if Nkind (Parent (Unit_Node)) /= N_Compilation_Unit then
1407 elsif Unit_Kind = N_Subprogram_Body
1408 and then not Acts_As_Spec (Unit_Node)
1412 elsif Nkind (Parent_Node) = N_Package_Body then
1415 elsif Nkind (Parent_Node) = N_Package_Specification
1416 and then Plist = Private_Declarations (Parent_Node)
1420 elsif (Nkind (Parent_Node) = N_Generic_Package_Declaration
1421 or else Nkind (Parent_Node)
1422 = N_Generic_Subprogram_Declaration)
1423 and then Plist = Generic_Formal_Declarations (Parent_Node)
1427 elsif Arg_Count > 0 then
1428 Analyze (Expression (Arg1));
1430 if Entity (Expression (Arg1)) /= Current_Scope then
1432 ("name in pragma% must be enclosing unit", Arg1);
1435 -- It is legal to have no argument in this context
1441 -- Error if not before first declaration. This is because a
1442 -- library unit pragma argument must be the name of a library
1443 -- unit (RM 10.1.5(7)), but the only names permitted in this
1444 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1445 -- generic subprogram declarations or generic instantiations.
1449 ("pragma% misplaced, must be before first declaration");
1453 end Check_Valid_Library_Unit_Pragma;
1459 procedure Check_Variant (Variant : Node_Id) is
1460 Clist : constant Node_Id := Component_List (Variant);
1464 if Present (Variant_Part (Clist)) then
1466 ("Unchecked_Union may not have nested variants",
1467 Variant_Part (Clist));
1470 if not Is_Non_Empty_List (Component_Items (Clist)) then
1472 ("Unchecked_Union may not have empty component list",
1477 Comp := First (Component_Items (Clist));
1478 while Present (Comp) loop
1480 Check_Component (Comp);
1490 procedure Error_Pragma (Msg : String) is
1492 Error_Msg_Name_1 := Chars (N);
1493 Error_Msg_N (Msg, N);
1497 ----------------------
1498 -- Error_Pragma_Arg --
1499 ----------------------
1501 procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id) is
1503 Error_Msg_Name_1 := Chars (N);
1504 Error_Msg_N (Msg, Get_Pragma_Arg (Arg));
1506 end Error_Pragma_Arg;
1508 procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id) is
1510 Error_Msg_Name_1 := Chars (N);
1511 Error_Msg_N (Msg1, Get_Pragma_Arg (Arg));
1512 Error_Pragma_Arg (Msg2, Arg);
1513 end Error_Pragma_Arg;
1515 ----------------------------
1516 -- Error_Pragma_Arg_Ident --
1517 ----------------------------
1519 procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id) is
1521 Error_Msg_Name_1 := Chars (N);
1522 Error_Msg_N (Msg, Arg);
1524 end Error_Pragma_Arg_Ident;
1526 ------------------------
1527 -- Find_Lib_Unit_Name --
1528 ------------------------
1530 function Find_Lib_Unit_Name return Entity_Id is
1532 -- Return inner compilation unit entity, for case of nested
1533 -- categorization pragmas. This happens in generic unit.
1535 if Nkind (Parent (N)) = N_Package_Specification
1536 and then Defining_Entity (Parent (N)) /= Current_Scope
1538 return Defining_Entity (Parent (N));
1540 return Current_Scope;
1542 end Find_Lib_Unit_Name;
1544 ----------------------------
1545 -- Find_Program_Unit_Name --
1546 ----------------------------
1548 procedure Find_Program_Unit_Name (Id : Node_Id) is
1549 Unit_Name : Entity_Id;
1550 Unit_Kind : Node_Kind;
1551 P : constant Node_Id := Parent (N);
1554 if Nkind (P) = N_Compilation_Unit then
1555 Unit_Kind := Nkind (Unit (P));
1557 if Unit_Kind = N_Subprogram_Declaration
1558 or else Unit_Kind = N_Package_Declaration
1559 or else Unit_Kind in N_Generic_Declaration
1561 Unit_Name := Defining_Entity (Unit (P));
1563 if Chars (Id) = Chars (Unit_Name) then
1564 Set_Entity (Id, Unit_Name);
1565 Set_Etype (Id, Etype (Unit_Name));
1567 Set_Etype (Id, Any_Type);
1569 ("cannot find program unit referenced by pragma%");
1573 Set_Etype (Id, Any_Type);
1574 Error_Pragma ("pragma% inapplicable to this unit");
1581 end Find_Program_Unit_Name;
1583 -------------------------
1584 -- Gather_Associations --
1585 -------------------------
1587 procedure Gather_Associations
1589 Args : out Args_List)
1594 -- Initialize all parameters to Empty
1596 for J in Args'Range loop
1600 -- That's all we have to do if there are no argument associations
1602 if No (Pragma_Argument_Associations (N)) then
1606 -- Otherwise first deal with any positional parameters present
1608 Arg := First (Pragma_Argument_Associations (N));
1609 for Index in Args'Range loop
1610 exit when No (Arg) or else Chars (Arg) /= No_Name;
1611 Args (Index) := Expression (Arg);
1615 -- Positional parameters all processed, if any left, then we
1616 -- have too many positional parameters.
1618 if Present (Arg) and then Chars (Arg) = No_Name then
1620 ("too many positional associations for pragma%", Arg);
1623 -- Process named parameters if any are present
1625 while Present (Arg) loop
1626 if Chars (Arg) = No_Name then
1628 ("positional association cannot follow named association",
1632 for Index in Names'Range loop
1633 if Names (Index) = Chars (Arg) then
1634 if Present (Args (Index)) then
1636 ("duplicate argument association for pragma%", Arg);
1638 Args (Index) := Expression (Arg);
1643 if Index = Names'Last then
1644 Error_Msg_Name_1 := Chars (N);
1645 Error_Msg_N ("pragma% does not allow & argument", Arg);
1647 -- Check for possible misspelling
1649 for Index1 in Names'Range loop
1650 if Is_Bad_Spelling_Of
1651 (Get_Name_String (Chars (Arg)),
1652 Get_Name_String (Names (Index1)))
1654 Error_Msg_Name_1 := Names (Index1);
1655 Error_Msg_N ("\possible misspelling of%", Arg);
1667 end Gather_Associations;
1669 --------------------
1670 -- Get_Pragma_Arg --
1671 --------------------
1673 function Get_Pragma_Arg (Arg : Node_Id) return Node_Id is
1675 if Nkind (Arg) = N_Pragma_Argument_Association then
1676 return Expression (Arg);
1686 procedure GNAT_Pragma is
1688 Check_Restriction (No_Implementation_Pragmas, N);
1691 --------------------------
1692 -- Is_Before_First_Decl --
1693 --------------------------
1695 function Is_Before_First_Decl
1696 (Pragma_Node : Node_Id;
1697 Decls : List_Id) return Boolean
1699 Item : Node_Id := First (Decls);
1702 -- Only other pragmas can come before this pragma
1705 if No (Item) or else Nkind (Item) /= N_Pragma then
1708 elsif Item = Pragma_Node then
1714 end Is_Before_First_Decl;
1716 -----------------------------
1717 -- Is_Configuration_Pragma --
1718 -----------------------------
1720 -- A configuration pragma must appear in the context clause of
1721 -- a compilation unit, at the start of the list (i.e. only other
1722 -- pragmas may precede it).
1724 function Is_Configuration_Pragma return Boolean is
1725 Lis : constant List_Id := List_Containing (N);
1726 Par : constant Node_Id := Parent (N);
1730 -- If no parent, then we are in the configuration pragma file,
1731 -- so the placement is definitely appropriate.
1736 -- Otherwise we must be in the context clause of a compilation unit
1737 -- and the only thing allowed before us in the context list is more
1738 -- configuration pragmas.
1740 elsif Nkind (Par) = N_Compilation_Unit
1741 and then Context_Items (Par) = Lis
1748 elsif Nkind (Prg) /= N_Pragma then
1758 end Is_Configuration_Pragma;
1760 ----------------------
1761 -- Pragma_Misplaced --
1762 ----------------------
1764 procedure Pragma_Misplaced is
1766 Error_Pragma ("incorrect placement of pragma%");
1767 end Pragma_Misplaced;
1769 ------------------------------------
1770 -- Process Atomic_Shared_Volatile --
1771 ------------------------------------
1773 procedure Process_Atomic_Shared_Volatile is
1780 procedure Set_Atomic (E : Entity_Id);
1781 -- Set given type as atomic, and if no explicit alignment was
1782 -- given, set alignment to unknown, since back end knows what
1783 -- the alignment requirements are for atomic arrays. Note that
1784 -- this step is necessary for derived types.
1790 procedure Set_Atomic (E : Entity_Id) is
1794 if not Has_Alignment_Clause (E) then
1795 Set_Alignment (E, Uint_0);
1799 -- Start of processing for Process_Atomic_Shared_Volatile
1802 Check_Ada_83_Warning;
1803 Check_No_Identifiers;
1804 Check_Arg_Count (1);
1805 Check_Arg_Is_Local_Name (Arg1);
1806 E_Id := Expression (Arg1);
1808 if Etype (E_Id) = Any_Type then
1813 D := Declaration_Node (E);
1817 if Rep_Item_Too_Early (E, N)
1819 Rep_Item_Too_Late (E, N)
1823 Check_First_Subtype (Arg1);
1826 if Prag_Id /= Pragma_Volatile then
1828 Set_Atomic (Underlying_Type (E));
1829 Set_Atomic (Base_Type (E));
1832 -- Attribute belongs on the base type. If the
1833 -- view of the type is currently private, it also
1834 -- belongs on the underlying type.
1836 Set_Is_Volatile (Base_Type (E));
1837 Set_Is_Volatile (Underlying_Type (E));
1839 Set_Treat_As_Volatile (E);
1840 Set_Treat_As_Volatile (Underlying_Type (E));
1842 elsif K = N_Object_Declaration
1843 or else (K = N_Component_Declaration
1844 and then Original_Record_Component (E) = E)
1846 if Rep_Item_Too_Late (E, N) then
1850 if Prag_Id /= Pragma_Volatile then
1853 -- If the object declaration has an explicit
1854 -- initialization, a temporary may have to be
1855 -- created to hold the expression, to insure
1856 -- that access to the object remain atomic.
1858 if Nkind (Parent (E)) = N_Object_Declaration
1859 and then Present (Expression (Parent (E)))
1861 Set_Has_Delayed_Freeze (E);
1864 -- An interesting improvement here. If an object of type X
1865 -- is declared atomic, and the type X is not atomic, that's
1866 -- a pity, since it may not have appropraite alignment etc.
1867 -- We can rescue this in the special case where the object
1868 -- and type are in the same unit by just setting the type
1869 -- as atomic, so that the back end will process it as atomic.
1871 Utyp := Underlying_Type (Etype (E));
1874 and then Sloc (E) > No_Location
1875 and then Sloc (Utyp) > No_Location
1877 Get_Source_File_Index (Sloc (E)) =
1878 Get_Source_File_Index (Sloc (Underlying_Type (Etype (E))))
1880 Set_Is_Atomic (Underlying_Type (Etype (E)));
1884 Set_Is_Volatile (E);
1885 Set_Treat_As_Volatile (E);
1889 ("inappropriate entity for pragma%", Arg1);
1891 end Process_Atomic_Shared_Volatile;
1893 ------------------------
1894 -- Process_Convention --
1895 ------------------------
1897 procedure Process_Convention
1898 (C : out Convention_Id;
1904 Comp_Unit : Unit_Number_Type;
1906 procedure Set_Convention_From_Pragma (E : Entity_Id);
1907 -- Set convention in entity E, and also flag that the entity has a
1908 -- convention pragma. If entity is for a private or incomplete type,
1909 -- also set convention and flag on underlying type. This procedure
1910 -- also deals with the special case of C_Pass_By_Copy convention.
1912 --------------------------------
1913 -- Set_Convention_From_Pragma --
1914 --------------------------------
1916 procedure Set_Convention_From_Pragma (E : Entity_Id) is
1918 Set_Convention (E, C);
1919 Set_Has_Convention_Pragma (E);
1921 if Is_Incomplete_Or_Private_Type (E) then
1922 Set_Convention (Underlying_Type (E), C);
1923 Set_Has_Convention_Pragma (Underlying_Type (E), True);
1926 -- A class-wide type should inherit the convention of
1927 -- the specific root type (although this isn't specified
1928 -- clearly by the RM).
1930 if Is_Type (E) and then Present (Class_Wide_Type (E)) then
1931 Set_Convention (Class_Wide_Type (E), C);
1934 -- If the entity is a record type, then check for special case
1935 -- of C_Pass_By_Copy, which is treated the same as C except that
1936 -- the special record flag is set. This convention is also only
1937 -- permitted on record types (see AI95-00131).
1939 if Cname = Name_C_Pass_By_Copy then
1940 if Is_Record_Type (E) then
1941 Set_C_Pass_By_Copy (Base_Type (E));
1942 elsif Is_Incomplete_Or_Private_Type (E)
1943 and then Is_Record_Type (Underlying_Type (E))
1945 Set_C_Pass_By_Copy (Base_Type (Underlying_Type (E)));
1948 ("C_Pass_By_Copy convention allowed only for record type",
1953 -- If the entity is a derived boolean type, check for the
1954 -- special case of convention C, C++, or Fortran, where we
1955 -- consider any nonzero value to represent true.
1957 if Is_Discrete_Type (E)
1958 and then Root_Type (Etype (E)) = Standard_Boolean
1964 C = Convention_Fortran)
1966 Set_Nonzero_Is_True (Base_Type (E));
1968 end Set_Convention_From_Pragma;
1970 -- Start of processing for Process_Convention
1973 Check_At_Least_N_Arguments (2);
1974 Check_Arg_Is_Identifier (Arg1);
1975 Check_Optional_Identifier (Arg1, Name_Convention);
1976 Cname := Chars (Expression (Arg1));
1978 -- C_Pass_By_Copy is treated as a synonym for convention C
1979 -- (this is tested again below to set the critical flag)
1981 if Cname = Name_C_Pass_By_Copy then
1984 -- Otherwise we must have something in the standard convention list
1986 elsif Is_Convention_Name (Cname) then
1987 C := Get_Convention_Id (Chars (Expression (Arg1)));
1989 -- In DEC VMS, it seems that there is an undocumented feature
1990 -- that any unrecognized convention is treated as the default,
1991 -- which for us is convention C. It does not seem so terrible
1992 -- to do this unconditionally, silently in the VMS case, and
1993 -- with a warning in the non-VMS case.
1996 if Warn_On_Export_Import and not OpenVMS_On_Target then
1998 ("?unrecognized convention name, C assumed",
2005 Check_Arg_Is_Local_Name (Arg2);
2006 Check_Optional_Identifier (Arg2, Name_Entity);
2008 Id := Expression (Arg2);
2011 if not Is_Entity_Name (Id) then
2012 Error_Pragma_Arg ("entity name required", Arg2);
2017 -- Go to renamed subprogram if present, since convention applies
2018 -- to the actual renamed entity, not to the renaming entity.
2019 -- If subprogram is inherited, go to parent subprogram.
2021 if Is_Subprogram (E)
2022 and then Present (Alias (E))
2024 if Nkind (Parent (Declaration_Node (E)))
2025 = N_Subprogram_Renaming_Declaration
2029 elsif Nkind (Parent (E)) = N_Full_Type_Declaration
2030 and then Scope (E) = Scope (Alias (E))
2036 -- Check that we are not applying this to a specless body
2038 if Is_Subprogram (E)
2039 and then Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Body
2042 ("pragma% requires separate spec and must come before body");
2045 -- Check that we are not applying this to a named constant
2047 if Ekind (E) = E_Named_Integer
2049 Ekind (E) = E_Named_Real
2051 Error_Msg_Name_1 := Chars (N);
2053 ("cannot apply pragma% to named constant!",
2054 Get_Pragma_Arg (Arg2));
2056 ("\supply appropriate type for&!", Arg2);
2059 if Etype (E) = Any_Type
2060 or else Rep_Item_Too_Early (E, N)
2064 E := Underlying_Type (E);
2067 if Rep_Item_Too_Late (E, N) then
2071 if Has_Convention_Pragma (E) then
2073 ("at most one Convention/Export/Import pragma is allowed", Arg2);
2075 elsif Convention (E) = Convention_Protected
2076 or else Ekind (Scope (E)) = E_Protected_Type
2079 ("a protected operation cannot be given a different convention",
2083 -- For Intrinsic, a subprogram is required
2085 if C = Convention_Intrinsic
2086 and then not Is_Subprogram (E)
2087 and then not Is_Generic_Subprogram (E)
2090 ("second argument of pragma% must be a subprogram", Arg2);
2093 -- For Stdcall, a subprogram, variable or subprogram type is required
2095 if C = Convention_Stdcall
2096 and then not Is_Subprogram (E)
2097 and then not Is_Generic_Subprogram (E)
2098 and then Ekind (E) /= E_Variable
2101 and then Ekind (Designated_Type (E)) = E_Subprogram_Type)
2104 ("second argument of pragma% must be subprogram (type)",
2108 if not Is_Subprogram (E)
2109 and then not Is_Generic_Subprogram (E)
2111 Set_Convention_From_Pragma (E);
2115 Check_First_Subtype (Arg2);
2116 Set_Convention_From_Pragma (Base_Type (E));
2118 -- For subprograms, we must set the convention on the
2119 -- internally generated directly designated type as well.
2121 if Ekind (E) = E_Access_Subprogram_Type then
2122 Set_Convention_From_Pragma (Directly_Designated_Type (E));
2126 -- For the subprogram case, set proper convention for all homonyms
2127 -- in same scope and the same declarative part, i.e. the same
2128 -- compilation unit.
2131 Comp_Unit := Get_Source_Unit (E);
2132 Set_Convention_From_Pragma (E);
2134 -- Treat a pragma Import as an implicit body, for GPS use.
2136 if Prag_Id = Pragma_Import then
2137 Generate_Reference (E, Id, 'b');
2143 exit when No (E1) or else Scope (E1) /= Current_Scope;
2145 -- Note: below we are missing a check for Rep_Item_Too_Late.
2146 -- That is deliberate, we cannot chain the rep item on more
2147 -- than one Rep_Item chain, to be fixed later ???
2149 if Comes_From_Source (E1)
2150 and then Comp_Unit = Get_Source_Unit (E1)
2151 and then Nkind (Original_Node (Parent (E1))) /=
2152 N_Full_Type_Declaration
2154 Set_Convention_From_Pragma (E1);
2156 if Prag_Id = Pragma_Import then
2157 Generate_Reference (E, Id, 'b');
2162 end Process_Convention;
2164 -----------------------------------------------------
2165 -- Process_Extended_Import_Export_Exception_Pragma --
2166 -----------------------------------------------------
2168 procedure Process_Extended_Import_Export_Exception_Pragma
2169 (Arg_Internal : Node_Id;
2170 Arg_External : Node_Id;
2180 if not OpenVMS_On_Target then
2182 ("?pragma% ignored (applies only to Open'V'M'S)");
2185 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2186 Def_Id := Entity (Arg_Internal);
2188 if Ekind (Def_Id) /= E_Exception then
2190 ("pragma% must refer to declared exception", Arg_Internal);
2193 Set_Extended_Import_Export_External_Name (Def_Id, Arg_External);
2195 if Present (Arg_Form) then
2196 Check_Arg_Is_One_Of (Arg_Form, Name_Ada, Name_VMS);
2199 if Present (Arg_Form)
2200 and then Chars (Arg_Form) = Name_Ada
2204 Set_Is_VMS_Exception (Def_Id);
2205 Set_Exception_Code (Def_Id, No_Uint);
2208 if Present (Arg_Code) then
2209 if not Is_VMS_Exception (Def_Id) then
2211 ("Code option for pragma% not allowed for Ada case",
2215 Check_Arg_Is_Static_Expression (Arg_Code, Any_Integer);
2216 Code_Val := Expr_Value (Arg_Code);
2218 if not UI_Is_In_Int_Range (Code_Val) then
2220 ("Code option for pragma% must be in 32-bit range",
2224 Set_Exception_Code (Def_Id, Code_Val);
2227 end Process_Extended_Import_Export_Exception_Pragma;
2229 -------------------------------------------------
2230 -- Process_Extended_Import_Export_Internal_Arg --
2231 -------------------------------------------------
2233 procedure Process_Extended_Import_Export_Internal_Arg
2234 (Arg_Internal : Node_Id := Empty)
2239 if No (Arg_Internal) then
2240 Error_Pragma ("Internal parameter required for pragma%");
2243 if Nkind (Arg_Internal) = N_Identifier then
2246 elsif Nkind (Arg_Internal) = N_Operator_Symbol
2247 and then (Prag_Id = Pragma_Import_Function
2249 Prag_Id = Pragma_Export_Function)
2255 ("wrong form for Internal parameter for pragma%", Arg_Internal);
2258 Check_Arg_Is_Local_Name (Arg_Internal);
2259 end Process_Extended_Import_Export_Internal_Arg;
2261 --------------------------------------------------
2262 -- Process_Extended_Import_Export_Object_Pragma --
2263 --------------------------------------------------
2265 procedure Process_Extended_Import_Export_Object_Pragma
2266 (Arg_Internal : Node_Id;
2267 Arg_External : Node_Id;
2273 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2274 Def_Id := Entity (Arg_Internal);
2276 if Ekind (Def_Id) /= E_Constant
2277 and then Ekind (Def_Id) /= E_Variable
2280 ("pragma% must designate an object", Arg_Internal);
2283 if Is_Psected (Def_Id) then
2285 ("previous Psect_Object applies, pragma % not permitted",
2289 if Rep_Item_Too_Late (Def_Id, N) then
2293 Set_Extended_Import_Export_External_Name (Def_Id, Arg_External);
2295 if Present (Arg_Size) then
2296 Check_Arg_Is_External_Name (Arg_Size);
2299 -- Export_Object case
2301 if Prag_Id = Pragma_Export_Object then
2302 if not Is_Library_Level_Entity (Def_Id) then
2304 ("argument for pragma% must be library level entity",
2308 if Ekind (Current_Scope) = E_Generic_Package then
2309 Error_Pragma ("pragma& cannot appear in a generic unit");
2312 if not Size_Known_At_Compile_Time (Etype (Def_Id)) then
2314 ("exported object must have compile time known size",
2318 if Warn_On_Export_Import and then Is_Exported (Def_Id) then
2320 ("?duplicate Export_Object pragma", N);
2322 Set_Exported (Def_Id, Arg_Internal);
2325 -- Import_Object case
2328 if Is_Concurrent_Type (Etype (Def_Id)) then
2330 ("cannot use pragma% for task/protected object",
2334 if Ekind (Def_Id) = E_Constant then
2336 ("cannot import a constant", Arg_Internal);
2339 if Warn_On_Export_Import
2340 and then Has_Discriminants (Etype (Def_Id))
2343 ("imported value must be initialized?", Arg_Internal);
2346 if Warn_On_Export_Import
2347 and then Is_Access_Type (Etype (Def_Id))
2350 ("cannot import object of an access type?", Arg_Internal);
2353 if Warn_On_Export_Import
2354 and then Is_Imported (Def_Id)
2357 ("?duplicate Import_Object pragma", N);
2359 -- Check for explicit initialization present. Note that an
2360 -- initialization that generated by the code generator, e.g.
2361 -- for an access type, does not count here.
2363 elsif Present (Expression (Parent (Def_Id)))
2366 (Original_Node (Expression (Parent (Def_Id))))
2368 Error_Msg_Sloc := Sloc (Def_Id);
2370 ("no initialization allowed for declaration of& #",
2371 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2374 Set_Imported (Def_Id);
2375 Note_Possible_Modification (Arg_Internal);
2378 end Process_Extended_Import_Export_Object_Pragma;
2380 ------------------------------------------------------
2381 -- Process_Extended_Import_Export_Subprogram_Pragma --
2382 ------------------------------------------------------
2384 procedure Process_Extended_Import_Export_Subprogram_Pragma
2385 (Arg_Internal : Node_Id;
2386 Arg_External : Node_Id;
2387 Arg_Parameter_Types : Node_Id;
2388 Arg_Result_Type : Node_Id := Empty;
2389 Arg_Mechanism : Node_Id;
2390 Arg_Result_Mechanism : Node_Id := Empty;
2391 Arg_First_Optional_Parameter : Node_Id := Empty)
2397 Ambiguous : Boolean;
2401 function Same_Base_Type
2403 Formal : Entity_Id) return Boolean;
2404 -- Determines if Ptype references the type of Formal. Note that
2405 -- only the base types need to match according to the spec. Ptype
2406 -- here is the argument from the pragma, which is either a type
2407 -- name, or an access attribute.
2409 --------------------
2410 -- Same_Base_Type --
2411 --------------------
2413 function Same_Base_Type
2415 Formal : Entity_Id) return Boolean
2417 Ftyp : constant Entity_Id := Base_Type (Etype (Formal));
2421 -- Case where pragma argument is typ'Access
2423 if Nkind (Ptype) = N_Attribute_Reference
2424 and then Attribute_Name (Ptype) = Name_Access
2426 Pref := Prefix (Ptype);
2429 if not Is_Entity_Name (Pref)
2430 or else Entity (Pref) = Any_Type
2435 -- We have a match if the corresponding argument is of an
2436 -- anonymous access type, and its designicated type matches
2437 -- the type of the prefix of the access attribute
2439 return Ekind (Ftyp) = E_Anonymous_Access_Type
2440 and then Base_Type (Entity (Pref)) =
2441 Base_Type (Etype (Designated_Type (Ftyp)));
2443 -- Case where pragma argument is a type name
2448 if not Is_Entity_Name (Ptype)
2449 or else Entity (Ptype) = Any_Type
2454 -- We have a match if the corresponding argument is of
2455 -- the type given in the pragma (comparing base types)
2457 return Base_Type (Entity (Ptype)) = Ftyp;
2461 -- Start of processing for
2462 -- Process_Extended_Import_Export_Subprogram_Pragma
2465 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2466 Hom_Id := Entity (Arg_Internal);
2470 -- Loop through homonyms (overloadings) of Hom_Id
2472 while Present (Hom_Id) loop
2473 Def_Id := Get_Base_Subprogram (Hom_Id);
2475 -- We need a subprogram in the current scope
2477 if not Is_Subprogram (Def_Id)
2478 or else Scope (Def_Id) /= Current_Scope
2485 -- Pragma cannot apply to subprogram body
2487 if Is_Subprogram (Def_Id)
2490 (Declaration_Node (Def_Id))) = N_Subprogram_Body
2493 ("pragma% requires separate spec"
2494 & " and must come before body");
2497 -- Test result type if given, note that the result type
2498 -- parameter can only be present for the function cases.
2500 if Present (Arg_Result_Type)
2501 and then not Same_Base_Type (Arg_Result_Type, Def_Id)
2505 elsif Etype (Def_Id) /= Standard_Void_Type
2507 (Chars (N) = Name_Export_Procedure
2508 or else Chars (N) = Name_Import_Procedure)
2512 -- Test parameter types if given. Note that this parameter
2513 -- has not been analyzed (and must not be, since it is
2514 -- semantic nonsense), so we get it as the parser left it.
2516 elsif Present (Arg_Parameter_Types) then
2517 Check_Matching_Types : declare
2522 Formal := First_Formal (Def_Id);
2524 if Nkind (Arg_Parameter_Types) = N_Null then
2525 if Present (Formal) then
2529 -- A list of one type, e.g. (List) is parsed as
2530 -- a parenthesized expression.
2532 elsif Nkind (Arg_Parameter_Types) /= N_Aggregate
2533 and then Paren_Count (Arg_Parameter_Types) = 1
2536 or else Present (Next_Formal (Formal))
2541 Same_Base_Type (Arg_Parameter_Types, Formal);
2544 -- A list of more than one type is parsed as a aggregate
2546 elsif Nkind (Arg_Parameter_Types) = N_Aggregate
2547 and then Paren_Count (Arg_Parameter_Types) = 0
2549 Ptype := First (Expressions (Arg_Parameter_Types));
2550 while Present (Ptype) or else Present (Formal) loop
2553 or else not Same_Base_Type (Ptype, Formal)
2558 Next_Formal (Formal);
2563 -- Anything else is of the wrong form
2567 ("wrong form for Parameter_Types parameter",
2568 Arg_Parameter_Types);
2570 end Check_Matching_Types;
2573 -- Match is now False if the entry we found did not match
2574 -- either a supplied Parameter_Types or Result_Types argument
2580 -- Ambiguous case, the flag Ambiguous shows if we already
2581 -- detected this and output the initial messages.
2584 if not Ambiguous then
2586 Error_Msg_Name_1 := Chars (N);
2588 ("pragma% does not uniquely identify subprogram!",
2590 Error_Msg_Sloc := Sloc (Ent);
2591 Error_Msg_N ("matching subprogram #!", N);
2595 Error_Msg_Sloc := Sloc (Def_Id);
2596 Error_Msg_N ("matching subprogram #!", N);
2601 Hom_Id := Homonym (Hom_Id);
2604 -- See if we found an entry
2607 if not Ambiguous then
2608 if Is_Generic_Subprogram (Entity (Arg_Internal)) then
2610 ("pragma% cannot be given for generic subprogram");
2614 ("pragma% does not identify local subprogram");
2621 -- Import pragmas must be be for imported entities
2623 if Prag_Id = Pragma_Import_Function
2625 Prag_Id = Pragma_Import_Procedure
2627 Prag_Id = Pragma_Import_Valued_Procedure
2629 if not Is_Imported (Ent) then
2631 ("pragma Import or Interface must precede pragma%");
2634 -- Here we have the Export case which can set the entity as exported
2636 -- But does not do so if the specified external name is null,
2637 -- since that is taken as a signal in DEC Ada 83 (with which
2638 -- we want to be compatible) to request no external name.
2640 elsif Nkind (Arg_External) = N_String_Literal
2641 and then String_Length (Strval (Arg_External)) = 0
2645 -- In all other cases, set entit as exported
2648 Set_Exported (Ent, Arg_Internal);
2651 -- Special processing for Valued_Procedure cases
2653 if Prag_Id = Pragma_Import_Valued_Procedure
2655 Prag_Id = Pragma_Export_Valued_Procedure
2657 Formal := First_Formal (Ent);
2661 ("at least one parameter required for pragma%");
2663 elsif Ekind (Formal) /= E_Out_Parameter then
2665 ("first parameter must have mode out for pragma%");
2668 Set_Is_Valued_Procedure (Ent);
2672 Set_Extended_Import_Export_External_Name (Ent, Arg_External);
2674 -- Process Result_Mechanism argument if present. We have already
2675 -- checked that this is only allowed for the function case.
2677 if Present (Arg_Result_Mechanism) then
2678 Set_Mechanism_Value (Ent, Arg_Result_Mechanism);
2681 -- Process Mechanism parameter if present. Note that this parameter
2682 -- is not analyzed, and must not be analyzed since it is semantic
2683 -- nonsense, so we get it in exactly as the parser left it.
2685 if Present (Arg_Mechanism) then
2693 -- A single mechanism association without a formal parameter
2694 -- name is parsed as a parenthesized expression. All other
2695 -- cases are parsed as aggregates, so we rewrite the single
2696 -- parameter case as an aggregate for consistency.
2698 if Nkind (Arg_Mechanism) /= N_Aggregate
2699 and then Paren_Count (Arg_Mechanism) = 1
2701 Rewrite (Arg_Mechanism,
2702 Make_Aggregate (Sloc (Arg_Mechanism),
2703 Expressions => New_List (
2704 Relocate_Node (Arg_Mechanism))));
2707 -- Case of only mechanism name given, applies to all formals
2709 if Nkind (Arg_Mechanism) /= N_Aggregate then
2710 Formal := First_Formal (Ent);
2711 while Present (Formal) loop
2712 Set_Mechanism_Value (Formal, Arg_Mechanism);
2713 Next_Formal (Formal);
2716 -- Case of list of mechanism associations given
2719 if Null_Record_Present (Arg_Mechanism) then
2721 ("inappropriate form for Mechanism parameter",
2725 -- Deal with positional ones first
2727 Formal := First_Formal (Ent);
2729 if Present (Expressions (Arg_Mechanism)) then
2730 Mname := First (Expressions (Arg_Mechanism));
2732 while Present (Mname) loop
2735 ("too many mechanism associations", Mname);
2738 Set_Mechanism_Value (Formal, Mname);
2739 Next_Formal (Formal);
2744 -- Deal with named entries
2746 if Present (Component_Associations (Arg_Mechanism)) then
2747 Massoc := First (Component_Associations (Arg_Mechanism));
2749 while Present (Massoc) loop
2750 Choice := First (Choices (Massoc));
2752 if Nkind (Choice) /= N_Identifier
2753 or else Present (Next (Choice))
2756 ("incorrect form for mechanism association",
2760 Formal := First_Formal (Ent);
2764 ("parameter name & not present", Choice);
2767 if Chars (Choice) = Chars (Formal) then
2769 (Formal, Expression (Massoc));
2773 Next_Formal (Formal);
2783 -- Process First_Optional_Parameter argument if present. We have
2784 -- already checked that this is only allowed for the Import case.
2786 if Present (Arg_First_Optional_Parameter) then
2787 if Nkind (Arg_First_Optional_Parameter) /= N_Identifier then
2789 ("first optional parameter must be formal parameter name",
2790 Arg_First_Optional_Parameter);
2793 Formal := First_Formal (Ent);
2797 ("specified formal parameter& not found",
2798 Arg_First_Optional_Parameter);
2801 exit when Chars (Formal) =
2802 Chars (Arg_First_Optional_Parameter);
2804 Next_Formal (Formal);
2807 Set_First_Optional_Parameter (Ent, Formal);
2809 -- Check specified and all remaining formals have right form
2811 while Present (Formal) loop
2812 if Ekind (Formal) /= E_In_Parameter then
2814 ("optional formal& is not of mode in!",
2815 Arg_First_Optional_Parameter, Formal);
2818 Dval := Default_Value (Formal);
2820 if not Present (Dval) then
2822 ("optional formal& does not have default value!",
2823 Arg_First_Optional_Parameter, Formal);
2825 elsif Compile_Time_Known_Value_Or_Aggr (Dval) then
2830 ("default value for optional formal& is non-static!",
2831 Arg_First_Optional_Parameter, Formal);
2835 Set_Is_Optional_Parameter (Formal);
2836 Next_Formal (Formal);
2839 end Process_Extended_Import_Export_Subprogram_Pragma;
2841 --------------------------
2842 -- Process_Generic_List --
2843 --------------------------
2845 procedure Process_Generic_List is
2851 Check_No_Identifiers;
2852 Check_At_Least_N_Arguments (1);
2855 while Present (Arg) loop
2856 Exp := Expression (Arg);
2859 if not Is_Entity_Name (Exp)
2861 (not Is_Generic_Instance (Entity (Exp))
2863 not Is_Generic_Unit (Entity (Exp)))
2866 ("pragma% argument must be name of generic unit/instance",
2872 end Process_Generic_List;
2874 ---------------------------------
2875 -- Process_Import_Or_Interface --
2876 ---------------------------------
2878 procedure Process_Import_Or_Interface is
2884 Process_Convention (C, Def_Id);
2885 Kill_Size_Check_Code (Def_Id);
2886 Note_Possible_Modification (Expression (Arg2));
2888 if Ekind (Def_Id) = E_Variable
2890 Ekind (Def_Id) = E_Constant
2892 -- User initialization is not allowed for imported object, but
2893 -- the object declaration may contain a default initialization,
2894 -- that will be discarded. Note that an explicit initialization
2895 -- only counts if it comes from source, otherwise it is simply
2896 -- the code generator making an implicit initialization explicit.
2898 if Present (Expression (Parent (Def_Id)))
2899 and then Comes_From_Source (Expression (Parent (Def_Id)))
2901 Error_Msg_Sloc := Sloc (Def_Id);
2903 ("no initialization allowed for declaration of& #",
2904 "\imported entities cannot be initialized ('R'M' 'B.1(24))",
2908 Set_Imported (Def_Id);
2909 Process_Interface_Name (Def_Id, Arg3, Arg4);
2911 -- Note that we do not set Is_Public here. That's because we
2912 -- only want to set if if there is no address clause, and we
2913 -- don't know that yet, so we delay that processing till
2916 -- pragma Import completes deferred constants
2918 if Ekind (Def_Id) = E_Constant then
2919 Set_Has_Completion (Def_Id);
2922 -- It is not possible to import a constant of an unconstrained
2923 -- array type (e.g. string) because there is no simple way to
2924 -- write a meaningful subtype for it.
2926 if Is_Array_Type (Etype (Def_Id))
2927 and then not Is_Constrained (Etype (Def_Id))
2930 ("imported constant& must have a constrained subtype",
2935 elsif Is_Subprogram (Def_Id)
2936 or else Is_Generic_Subprogram (Def_Id)
2938 -- If the name is overloaded, pragma applies to all of the
2939 -- denoted entities in the same declarative part.
2942 while Present (Hom_Id) loop
2943 Def_Id := Get_Base_Subprogram (Hom_Id);
2945 -- Ignore inherited subprograms because the pragma will
2946 -- apply to the parent operation, which is the one called.
2948 if Is_Overloadable (Def_Id)
2949 and then Present (Alias (Def_Id))
2953 -- If it is not a subprogram, it must be in an outer
2954 -- scope and pragma does not apply.
2956 elsif not Is_Subprogram (Def_Id)
2957 and then not Is_Generic_Subprogram (Def_Id)
2961 -- Verify that the homonym is in the same declarative
2962 -- part (not just the same scope).
2964 elsif Parent (Unit_Declaration_Node (Def_Id)) /= Parent (N)
2965 and then Nkind (Parent (N)) /= N_Compilation_Unit_Aux
2970 Set_Imported (Def_Id);
2972 -- If Import intrinsic, set intrinsic flag and verify
2973 -- that it is known as such.
2975 if C = Convention_Intrinsic then
2976 Set_Is_Intrinsic_Subprogram (Def_Id);
2977 Check_Intrinsic_Subprogram
2978 (Def_Id, Expression (Arg2));
2981 -- All interfaced procedures need an external symbol
2982 -- created for them since they are always referenced
2983 -- from another object file.
2985 Set_Is_Public (Def_Id);
2987 -- Verify that the subprogram does not have a completion
2988 -- through a renaming declaration. For other completions
2989 -- the pragma appears as a too late representation.
2992 Decl : constant Node_Id := Unit_Declaration_Node (Def_Id);
2996 and then Nkind (Decl) = N_Subprogram_Declaration
2997 and then Present (Corresponding_Body (Decl))
3000 (Unit_Declaration_Node
3001 (Corresponding_Body (Decl))) =
3002 N_Subprogram_Renaming_Declaration
3004 Error_Msg_Sloc := Sloc (Def_Id);
3005 Error_Msg_NE ("cannot import&#," &
3006 " already completed by a renaming",
3011 Set_Has_Completion (Def_Id);
3012 Process_Interface_Name (Def_Id, Arg3, Arg4);
3015 if Is_Compilation_Unit (Hom_Id) then
3017 -- Its possible homonyms are not affected by the pragma.
3018 -- Such homonyms might be present in the context of other
3019 -- units being compiled.
3024 Hom_Id := Homonym (Hom_Id);
3028 -- When the convention is Java, we also allow Import to be given
3029 -- for packages, exceptions, and record components.
3031 elsif C = Convention_Java
3033 (Ekind (Def_Id) = E_Package
3034 or else Ekind (Def_Id) = E_Exception
3035 or else Nkind (Parent (Def_Id)) = N_Component_Declaration)
3037 Set_Imported (Def_Id);
3038 Set_Is_Public (Def_Id);
3039 Process_Interface_Name (Def_Id, Arg3, Arg4);
3043 ("second argument of pragma% must be object or subprogram",
3047 -- If this pragma applies to a compilation unit, then the unit,
3048 -- which is a subprogram, does not require (or allow) a body.
3049 -- We also do not need to elaborate imported procedures.
3051 if Nkind (Parent (N)) = N_Compilation_Unit_Aux then
3053 Cunit : constant Node_Id := Parent (Parent (N));
3055 Set_Body_Required (Cunit, False);
3058 end Process_Import_Or_Interface;
3060 --------------------
3061 -- Process_Inline --
3062 --------------------
3064 procedure Process_Inline (Active : Boolean) is
3070 Effective : Boolean := False;
3072 procedure Make_Inline (Subp : Entity_Id);
3073 -- Subp is the defining unit name of the subprogram
3074 -- declaration. Set the flag, as well as the flag in the
3075 -- corresponding body, if there is one present.
3077 procedure Set_Inline_Flags (Subp : Entity_Id);
3078 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp
3080 function Cannot_Inline (Subp : Entity_Id) return Boolean;
3081 -- Do not set the inline flag if body is available and contains
3082 -- exception handlers, to prevent undefined symbols at link time.
3083 -- Emit warning if front-end inlining is enabled and the pragma
3084 -- appears too late.
3090 function Cannot_Inline (Subp : Entity_Id) return Boolean is
3091 Decl : constant Node_Id := Unit_Declaration_Node (Subp);
3094 if Nkind (Decl) = N_Subprogram_Body then
3097 (Exception_Handlers (Handled_Statement_Sequence (Decl)));
3099 elsif Nkind (Decl) = N_Subprogram_Declaration
3100 and then Present (Corresponding_Body (Decl))
3102 if Front_End_Inlining
3103 and then Analyzed (Corresponding_Body (Decl))
3105 Error_Msg_N ("pragma appears too late, ignored?", N);
3108 -- If the subprogram is a renaming as body, the body is
3109 -- just a call to the renamed subprogram, and inlining is
3110 -- trivially possible.
3113 Nkind (Unit_Declaration_Node (Corresponding_Body (Decl)))
3114 = N_Subprogram_Renaming_Declaration
3120 Present (Exception_Handlers
3121 (Handled_Statement_Sequence
3122 (Unit_Declaration_Node (Corresponding_Body (Decl)))));
3125 -- If body is not available, assume the best, the check is
3126 -- performed again when compiling enclosing package bodies.
3136 procedure Make_Inline (Subp : Entity_Id) is
3137 Kind : constant Entity_Kind := Ekind (Subp);
3138 Inner_Subp : Entity_Id := Subp;
3141 if Etype (Subp) = Any_Type then
3144 elsif Cannot_Inline (Subp) then
3145 Applies := True; -- Do not treat as an error.
3148 -- Here we have a candidate for inlining, but we must exclude
3149 -- derived operations. Otherwise we will end up trying to
3150 -- inline a phantom declaration, and the result would be to
3151 -- drag in a body which has no direct inlining associated with
3152 -- it. That would not only be inefficient but would also result
3153 -- in the backend doing cross-unit inlining in cases where it
3154 -- was definitely inappropriate to do so.
3156 -- However, a simple Comes_From_Source test is insufficient,
3157 -- since we do want to allow inlining of generic instances,
3158 -- which also do not come from source. Predefined operators do
3159 -- not come from source but are not inlineable either.
3161 elsif not Comes_From_Source (Subp)
3162 and then not Is_Generic_Instance (Subp)
3163 and then Scope (Subp) /= Standard_Standard
3168 -- The referenced entity must either be the enclosing entity,
3169 -- or an entity declared within the current open scope.
3171 elsif Present (Scope (Subp))
3172 and then Scope (Subp) /= Current_Scope
3173 and then Subp /= Current_Scope
3176 ("argument of% must be entity in current scope", Assoc);
3180 -- Processing for procedure, operator or function.
3181 -- If subprogram is aliased (as for an instance) indicate
3182 -- that the renamed entity (if declared in the same unit)
3185 if Is_Subprogram (Subp) then
3186 while Present (Alias (Inner_Subp)) loop
3187 Inner_Subp := Alias (Inner_Subp);
3190 if In_Same_Source_Unit (Subp, Inner_Subp) then
3191 Set_Inline_Flags (Inner_Subp);
3193 Decl := Parent (Parent (Inner_Subp));
3195 if Nkind (Decl) = N_Subprogram_Declaration
3196 and then Present (Corresponding_Body (Decl))
3198 Set_Inline_Flags (Corresponding_Body (Decl));
3204 -- For a generic subprogram set flag as well, for use at
3205 -- the point of instantiation, to determine whether the
3206 -- body should be generated.
3208 elsif Is_Generic_Subprogram (Subp) then
3209 Set_Inline_Flags (Subp);
3212 -- Literals are by definition inlined
3214 elsif Kind = E_Enumeration_Literal then
3217 -- Anything else is an error
3221 ("expect subprogram name for pragma%", Assoc);
3225 ----------------------
3226 -- Set_Inline_Flags --
3227 ----------------------
3229 procedure Set_Inline_Flags (Subp : Entity_Id) is
3232 Set_Is_Inlined (Subp, True);
3235 if not Has_Pragma_Inline (Subp) then
3236 Set_Has_Pragma_Inline (Subp);
3237 Set_Next_Rep_Item (N, First_Rep_Item (Subp));
3238 Set_First_Rep_Item (Subp, N);
3241 end Set_Inline_Flags;
3243 -- Start of processing for Process_Inline
3246 Check_No_Identifiers;
3247 Check_At_Least_N_Arguments (1);
3250 Inline_Processing_Required := True;
3254 while Present (Assoc) loop
3255 Subp_Id := Expression (Assoc);
3259 if Is_Entity_Name (Subp_Id) then
3260 Subp := Entity (Subp_Id);
3262 if Subp = Any_Id then
3268 while Present (Homonym (Subp))
3269 and then Scope (Homonym (Subp)) = Current_Scope
3271 Make_Inline (Homonym (Subp));
3272 Subp := Homonym (Subp);
3279 ("inappropriate argument for pragma%", Assoc);
3282 and then Warn_On_Redundant_Constructs
3284 Error_Msg_NE ("pragma Inline for& is redundant?",
3285 N, Entity (Subp_Id));
3292 ----------------------------
3293 -- Process_Interface_Name --
3294 ----------------------------
3296 procedure Process_Interface_Name
3297 (Subprogram_Def : Entity_Id;
3303 String_Val : String_Id;
3305 procedure Check_Form_Of_Interface_Name (SN : Node_Id);
3306 -- SN is a string literal node for an interface name. This routine
3307 -- performs some minimal checks that the name is reasonable. In
3308 -- particular that no spaces or other obviously incorrect characters
3309 -- appear. This is only a warning, since any characters are allowed.
3311 ----------------------------------
3312 -- Check_Form_Of_Interface_Name --
3313 ----------------------------------
3315 procedure Check_Form_Of_Interface_Name (SN : Node_Id) is
3316 S : constant String_Id := Strval (Expr_Value_S (SN));
3317 SL : constant Nat := String_Length (S);
3322 Error_Msg_N ("interface name cannot be null string", SN);
3325 for J in 1 .. SL loop
3326 C := Get_String_Char (S, J);
3328 if Warn_On_Export_Import
3329 and then (not In_Character_Range (C)
3330 or else Get_Character (C) = ' '
3331 or else Get_Character (C) = ',')
3334 ("?interface name contains illegal character", SN);
3337 end Check_Form_Of_Interface_Name;
3339 -- Start of processing for Process_Interface_Name
3342 if No (Link_Arg) then
3343 if No (Ext_Arg) then
3346 elsif Chars (Ext_Arg) = Name_Link_Name then
3348 Link_Nam := Expression (Ext_Arg);
3351 Check_Optional_Identifier (Ext_Arg, Name_External_Name);
3352 Ext_Nam := Expression (Ext_Arg);
3357 Check_Optional_Identifier (Ext_Arg, Name_External_Name);
3358 Check_Optional_Identifier (Link_Arg, Name_Link_Name);
3359 Ext_Nam := Expression (Ext_Arg);
3360 Link_Nam := Expression (Link_Arg);
3363 -- Check expressions for external name and link name are static
3365 if Present (Ext_Nam) then
3366 Check_Arg_Is_Static_Expression (Ext_Nam, Standard_String);
3367 Check_Form_Of_Interface_Name (Ext_Nam);
3369 -- Verify that the external name is not the name of a local
3370 -- entity, which would hide the imported one and lead to
3371 -- run-time surprises. The problem can only arise for entities
3372 -- declared in a package body (otherwise the external name is
3373 -- fully qualified and won't conflict).
3381 if Prag_Id = Pragma_Import then
3382 String_To_Name_Buffer (Strval (Expr_Value_S (Ext_Nam)));
3384 E := Entity_Id (Get_Name_Table_Info (Nam));
3386 if Nam /= Chars (Subprogram_Def)
3387 and then Present (E)
3388 and then not Is_Overloadable (E)
3389 and then Is_Immediately_Visible (E)
3390 and then not Is_Imported (E)
3391 and then Ekind (Scope (E)) = E_Package
3395 while Present (Par) loop
3396 if Nkind (Par) = N_Package_Body then
3397 Error_Msg_Sloc := Sloc (E);
3399 ("imported entity is hidden by & declared#",
3404 Par := Parent (Par);
3411 if Present (Link_Nam) then
3412 Check_Arg_Is_Static_Expression (Link_Nam, Standard_String);
3413 Check_Form_Of_Interface_Name (Link_Nam);
3416 -- If there is no link name, just set the external name
3418 if No (Link_Nam) then
3419 Link_Nam := Adjust_External_Name_Case (Expr_Value_S (Ext_Nam));
3421 -- For the Link_Name case, the given literal is preceded by an
3422 -- asterisk, which indicates to GCC that the given name should
3423 -- be taken literally, and in particular that no prepending of
3424 -- underlines should occur, even in systems where this is the
3429 Store_String_Char (Get_Char_Code ('*'));
3430 String_Val := Strval (Expr_Value_S (Link_Nam));
3432 for J in 1 .. String_Length (String_Val) loop
3433 Store_String_Char (Get_String_Char (String_Val, J));
3437 Make_String_Literal (Sloc (Link_Nam), End_String);
3440 Set_Encoded_Interface_Name
3441 (Get_Base_Subprogram (Subprogram_Def), Link_Nam);
3442 Check_Duplicated_Export_Name (Link_Nam);
3443 end Process_Interface_Name;
3445 -----------------------------------------
3446 -- Process_Interrupt_Or_Attach_Handler --
3447 -----------------------------------------
3449 procedure Process_Interrupt_Or_Attach_Handler is
3450 Arg1_X : constant Node_Id := Expression (Arg1);
3451 Handler_Proc : constant Entity_Id := Entity (Arg1_X);
3452 Proc_Scope : constant Entity_Id := Scope (Handler_Proc);
3455 Set_Is_Interrupt_Handler (Handler_Proc);
3457 -- If the pragma is not associated with a handler procedure
3458 -- within a protected type, then it must be for a nonprotected
3459 -- procedure for the AAMP target, in which case we don't
3460 -- associate a representation item with the procedure's scope.
3462 if Ekind (Proc_Scope) = E_Protected_Type then
3463 if Prag_Id = Pragma_Interrupt_Handler
3465 Prag_Id = Pragma_Attach_Handler
3467 Record_Rep_Item (Proc_Scope, N);
3470 end Process_Interrupt_Or_Attach_Handler;
3472 --------------------------------------------------
3473 -- Process_Restrictions_Or_Restriction_Warnings --
3474 --------------------------------------------------
3476 procedure Process_Restrictions_Or_Restriction_Warnings is
3478 R_Id : Restriction_Id;
3483 procedure Set_Warning (R : All_Restrictions);
3484 -- If this is a Restriction_Warnings pragma, set warning flag,
3485 -- otherwise reset the flag.
3491 procedure Set_Warning (R : All_Restrictions) is
3493 if Prag_Id = Pragma_Restriction_Warnings then
3494 Restriction_Warnings (R) := True;
3496 Restriction_Warnings (R) := False;
3500 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
3503 Check_Ada_83_Warning;
3504 Check_At_Least_N_Arguments (1);
3505 Check_Valid_Configuration_Pragma;
3508 while Present (Arg) loop
3510 Expr := Expression (Arg);
3512 -- Case of no restriction identifier present
3514 if Id = No_Name then
3515 if Nkind (Expr) /= N_Identifier then
3517 ("invalid form for restriction", Arg);
3522 (Process_Restriction_Synonyms (Expr));
3524 if R_Id not in All_Boolean_Restrictions then
3526 ("invalid restriction identifier", Arg);
3529 if Implementation_Restriction (R_Id) then
3531 (No_Implementation_Restrictions, Arg);
3534 Set_Restriction (R_Id, N);
3537 -- A very special case that must be processed here:
3538 -- pragma Restrictions (No_Exceptions) turns off
3539 -- all run-time checking. This is a bit dubious in
3540 -- terms of the formal language definition, but it
3541 -- is what is intended by RM H.4(12).
3543 if R_Id = No_Exceptions then
3544 Scope_Suppress := (others => True);
3547 -- Case of restriction identifier present
3550 R_Id := Get_Restriction_Id (Process_Restriction_Synonyms (Arg));
3551 Analyze_And_Resolve (Expr, Any_Integer);
3553 if R_Id not in All_Parameter_Restrictions then
3555 ("invalid restriction parameter identifier", Arg);
3557 elsif not Is_OK_Static_Expression (Expr) then
3558 Flag_Non_Static_Expr
3559 ("value must be static expression!", Expr);
3562 elsif not Is_Integer_Type (Etype (Expr))
3563 or else Expr_Value (Expr) < 0
3566 ("value must be non-negative integer", Arg);
3568 -- Restriction pragma is active
3571 Val := Expr_Value (Expr);
3573 if not UI_Is_In_Int_Range (Val) then
3575 ("pragma ignored, value too large?", Arg);
3577 Set_Restriction (R_Id, N, Integer (UI_To_Int (Val)));
3585 end Process_Restrictions_Or_Restriction_Warnings;
3587 ---------------------------------
3588 -- Process_Suppress_Unsuppress --
3589 ---------------------------------
3591 -- Note: this procedure makes entries in the check suppress data
3592 -- structures managed by Sem. See spec of package Sem for full
3593 -- details on how we handle recording of check suppression.
3595 procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean) is
3600 In_Package_Spec : constant Boolean :=
3601 (Ekind (Current_Scope) = E_Package
3603 Ekind (Current_Scope) = E_Generic_Package)
3604 and then not In_Package_Body (Current_Scope);
3606 procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id);
3607 -- Used to suppress a single check on the given entity
3609 --------------------------------
3610 -- Suppress_Unsuppress_Echeck --
3611 --------------------------------
3613 procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id) is
3614 ESR : constant Entity_Check_Suppress_Record :=
3617 Suppress => Suppress_Case);
3620 Set_Checks_May_Be_Suppressed (E);
3622 if In_Package_Spec then
3623 Global_Entity_Suppress.Append (ESR);
3625 Local_Entity_Suppress.Append (ESR);
3628 -- If this is a first subtype, and the base type is distinct,
3629 -- then also set the suppress flags on the base type.
3631 if Is_First_Subtype (E)
3632 and then Etype (E) /= E
3634 Suppress_Unsuppress_Echeck (Etype (E), C);
3636 end Suppress_Unsuppress_Echeck;
3638 -- Start of processing for Process_Suppress_Unsuppress
3641 -- Suppress/Unsuppress can appear as a configuration pragma,
3642 -- or in a declarative part or a package spec (RM 11.5(5))
3644 if not Is_Configuration_Pragma then
3645 Check_Is_In_Decl_Part_Or_Package_Spec;
3648 Check_At_Least_N_Arguments (1);
3649 Check_At_Most_N_Arguments (2);
3650 Check_No_Identifier (Arg1);
3651 Check_Arg_Is_Identifier (Arg1);
3653 if not Is_Check_Name (Chars (Expression (Arg1))) then
3655 ("argument of pragma% is not valid check name", Arg1);
3657 C := Get_Check_Id (Chars (Expression (Arg1)));
3660 if Arg_Count = 1 then
3662 -- Make an entry in the local scope suppress table. This is the
3663 -- table that directly shows the current value of the scope
3664 -- suppress check for any check id value.
3666 if C = All_Checks then
3667 for J in Scope_Suppress'Range loop
3668 Scope_Suppress (J) := Suppress_Case;
3671 Scope_Suppress (C) := Suppress_Case;
3674 -- Also make an entry in the Local_Entity_Suppress table. See
3675 -- extended description in the package spec of Sem for details.
3677 Local_Entity_Suppress.Append
3680 Suppress => Suppress_Case));
3682 -- Case of two arguments present, where the check is
3683 -- suppressed for a specified entity (given as the second
3684 -- argument of the pragma)
3687 Check_Optional_Identifier (Arg2, Name_On);
3688 E_Id := Expression (Arg2);
3691 if not Is_Entity_Name (E_Id) then
3693 ("second argument of pragma% must be entity name", Arg2);
3702 -- Enforce RM 11.5(7) which requires that for a pragma that
3703 -- appears within a package spec, the named entity must be
3704 -- within the package spec. We allow the package name itself
3705 -- to be mentioned since that makes sense, although it is not
3706 -- strictly allowed by 11.5(7).
3709 and then E /= Current_Scope
3710 and then Scope (E) /= Current_Scope
3713 ("entity in pragma% is not in package spec ('R'M 11.5(7))",
3717 -- Loop through homonyms. As noted below, in the case of a package
3718 -- spec, only homonyms within the package spec are considered.
3721 Suppress_Unsuppress_Echeck (E, C);
3723 if Is_Generic_Instance (E)
3724 and then Is_Subprogram (E)
3725 and then Present (Alias (E))
3727 Suppress_Unsuppress_Echeck (Alias (E), C);
3730 -- Move to next homonym
3735 -- If we are within a package specification, the
3736 -- pragma only applies to homonyms in the same scope.
3738 exit when In_Package_Spec
3739 and then Scope (E) /= Current_Scope;
3742 end Process_Suppress_Unsuppress;
3748 procedure Set_Exported (E : Entity_Id; Arg : Node_Id) is
3750 if Is_Imported (E) then
3752 ("cannot export entity& that was previously imported", Arg);
3754 elsif Present (Address_Clause (E)) then
3756 ("cannot export entity& that has an address clause", Arg);
3759 Set_Is_Exported (E);
3761 -- Generate a reference for entity explicitly, because the
3762 -- identifier may be overloaded and name resolution will not
3765 Generate_Reference (E, Arg);
3767 -- Deal with exporting non-library level entity
3769 if not Is_Library_Level_Entity (E) then
3771 -- Not allowed at all for subprograms
3773 if Is_Subprogram (E) then
3774 Error_Pragma_Arg ("local subprogram& cannot be exported", Arg);
3776 -- Otherwise set public and statically allocated
3780 Set_Is_Statically_Allocated (E);
3782 -- Warn if the corresponding W flag is set and the pragma
3783 -- comes from source. The latter may not be true e.g. on
3784 -- VMS where we expand export pragmas for exception codes
3785 -- associated with imported or exported exceptions. We do
3786 -- not want to generate a warning for something that the
3787 -- user did not write.
3789 if Warn_On_Export_Import
3790 and then Comes_From_Source (Arg)
3793 ("?& has been made static as a result of Export", Arg, E);
3795 ("\this usage is non-standard and non-portable", Arg);
3800 if Warn_On_Export_Import and then Is_Type (E) then
3802 ("exporting a type has no effect?", Arg, E);
3805 if Warn_On_Export_Import and Inside_A_Generic then
3807 ("all instances of& will have the same external name?", Arg, E);
3811 ----------------------------------------------
3812 -- Set_Extended_Import_Export_External_Name --
3813 ----------------------------------------------
3815 procedure Set_Extended_Import_Export_External_Name
3816 (Internal_Ent : Entity_Id;
3817 Arg_External : Node_Id)
3819 Old_Name : constant Node_Id := Interface_Name (Internal_Ent);
3823 if No (Arg_External) then
3827 Check_Arg_Is_External_Name (Arg_External);
3829 if Nkind (Arg_External) = N_String_Literal then
3830 if String_Length (Strval (Arg_External)) = 0 then
3833 New_Name := Adjust_External_Name_Case (Arg_External);
3836 elsif Nkind (Arg_External) = N_Identifier then
3837 New_Name := Get_Default_External_Name (Arg_External);
3839 -- Check_Arg_Is_External_Name should let through only
3840 -- identifiers and string literals or static string
3841 -- expressions (which are folded to string literals).
3844 raise Program_Error;
3847 -- If we already have an external name set (by a prior normal
3848 -- Import or Export pragma), then the external names must match
3850 if Present (Interface_Name (Internal_Ent)) then
3851 Check_Matching_Internal_Names : declare
3852 S1 : constant String_Id := Strval (Old_Name);
3853 S2 : constant String_Id := Strval (New_Name);
3856 -- Called if names do not match
3862 procedure Mismatch is
3864 Error_Msg_Sloc := Sloc (Old_Name);
3866 ("external name does not match that given #",
3870 -- Start of processing for Check_Matching_Internal_Names
3873 if String_Length (S1) /= String_Length (S2) then
3877 for J in 1 .. String_Length (S1) loop
3878 if Get_String_Char (S1, J) /= Get_String_Char (S2, J) then
3883 end Check_Matching_Internal_Names;
3885 -- Otherwise set the given name
3888 Set_Encoded_Interface_Name (Internal_Ent, New_Name);
3889 Check_Duplicated_Export_Name (New_Name);
3891 end Set_Extended_Import_Export_External_Name;
3897 procedure Set_Imported (E : Entity_Id) is
3899 Error_Msg_Sloc := Sloc (E);
3901 if Is_Exported (E) or else Is_Imported (E) then
3902 Error_Msg_NE ("import of& declared# not allowed", N, E);
3904 if Is_Exported (E) then
3905 Error_Msg_N ("\entity was previously exported", N);
3907 Error_Msg_N ("\entity was previously imported", N);
3910 Error_Pragma ("\(pragma% applies to all previous entities)");
3913 Set_Is_Imported (E);
3915 -- If the entity is an object that is not at the library
3916 -- level, then it is statically allocated. We do not worry
3917 -- about objects with address clauses in this context since
3918 -- they are not really imported in the linker sense.
3921 and then not Is_Library_Level_Entity (E)
3922 and then No (Address_Clause (E))
3924 Set_Is_Statically_Allocated (E);
3929 -------------------------
3930 -- Set_Mechanism_Value --
3931 -------------------------
3933 -- Note: the mechanism name has not been analyzed (and cannot indeed
3934 -- be analyzed, since it is semantic nonsense), so we get it in the
3935 -- exact form created by the parser.
3937 procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id) is
3941 procedure Bad_Class;
3942 -- Signal bad descriptor class name
3944 procedure Bad_Mechanism;
3945 -- Signal bad mechanism name
3951 procedure Bad_Class is
3953 Error_Pragma_Arg ("unrecognized descriptor class name", Class);
3956 -------------------------
3957 -- Bad_Mechanism_Value --
3958 -------------------------
3960 procedure Bad_Mechanism is
3962 Error_Pragma_Arg ("unrecognized mechanism name", Mech_Name);
3965 -- Start of processing for Set_Mechanism_Value
3968 if Mechanism (Ent) /= Default_Mechanism then
3970 ("mechanism for & has already been set", Mech_Name, Ent);
3973 -- MECHANISM_NAME ::= value | reference | descriptor
3975 if Nkind (Mech_Name) = N_Identifier then
3976 if Chars (Mech_Name) = Name_Value then
3977 Set_Mechanism (Ent, By_Copy);
3980 elsif Chars (Mech_Name) = Name_Reference then
3981 Set_Mechanism (Ent, By_Reference);
3984 elsif Chars (Mech_Name) = Name_Descriptor then
3985 Check_VMS (Mech_Name);
3986 Set_Mechanism (Ent, By_Descriptor);
3989 elsif Chars (Mech_Name) = Name_Copy then
3991 ("bad mechanism name, Value assumed", Mech_Name);
3997 -- MECHANISM_NAME ::= descriptor (CLASS_NAME)
3998 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4000 -- Note: this form is parsed as an indexed component
4002 elsif Nkind (Mech_Name) = N_Indexed_Component then
4003 Class := First (Expressions (Mech_Name));
4005 if Nkind (Prefix (Mech_Name)) /= N_Identifier
4006 or else Chars (Prefix (Mech_Name)) /= Name_Descriptor
4007 or else Present (Next (Class))
4012 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME)
4013 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4015 -- Note: this form is parsed as a function call
4017 elsif Nkind (Mech_Name) = N_Function_Call then
4019 Param := First (Parameter_Associations (Mech_Name));
4021 if Nkind (Name (Mech_Name)) /= N_Identifier
4022 or else Chars (Name (Mech_Name)) /= Name_Descriptor
4023 or else Present (Next (Param))
4024 or else No (Selector_Name (Param))
4025 or else Chars (Selector_Name (Param)) /= Name_Class
4029 Class := Explicit_Actual_Parameter (Param);
4036 -- Fall through here with Class set to descriptor class name
4038 Check_VMS (Mech_Name);
4040 if Nkind (Class) /= N_Identifier then
4043 elsif Chars (Class) = Name_UBS then
4044 Set_Mechanism (Ent, By_Descriptor_UBS);
4046 elsif Chars (Class) = Name_UBSB then
4047 Set_Mechanism (Ent, By_Descriptor_UBSB);
4049 elsif Chars (Class) = Name_UBA then
4050 Set_Mechanism (Ent, By_Descriptor_UBA);
4052 elsif Chars (Class) = Name_S then
4053 Set_Mechanism (Ent, By_Descriptor_S);
4055 elsif Chars (Class) = Name_SB then
4056 Set_Mechanism (Ent, By_Descriptor_SB);
4058 elsif Chars (Class) = Name_A then
4059 Set_Mechanism (Ent, By_Descriptor_A);
4061 elsif Chars (Class) = Name_NCA then
4062 Set_Mechanism (Ent, By_Descriptor_NCA);
4068 end Set_Mechanism_Value;
4070 ---------------------------
4071 -- Set_Ravenscar_Profile --
4072 ---------------------------
4074 -- The tasks to be done here are
4076 -- Set required policies
4078 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4079 -- pragma Locking_Policy (Ceiling_Locking)
4081 -- Set Detect_Blocking mode
4083 -- Set required restrictions (see System.Rident for detailed list)
4085 procedure Set_Ravenscar_Profile (N : Node_Id) is
4087 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4089 if Task_Dispatching_Policy /= ' '
4090 and then Task_Dispatching_Policy /= 'F'
4092 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
4093 Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
4095 -- Set the FIFO_Within_Priorities policy, but always
4096 -- preserve System_Location since we like the error
4097 -- message with the run time name.
4100 Task_Dispatching_Policy := 'F';
4102 if Task_Dispatching_Policy_Sloc /= System_Location then
4103 Task_Dispatching_Policy_Sloc := Loc;
4107 -- pragma Locking_Policy (Ceiling_Locking)
4109 if Locking_Policy /= ' '
4110 and then Locking_Policy /= 'C'
4112 Error_Msg_Sloc := Locking_Policy_Sloc;
4113 Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
4115 -- Set the Ceiling_Locking policy, but always preserve
4116 -- System_Location since we like the error message with the
4120 Locking_Policy := 'C';
4122 if Locking_Policy_Sloc /= System_Location then
4123 Locking_Policy_Sloc := Loc;
4127 -- pragma Detect_Blocking
4129 Detect_Blocking := True;
4131 -- Set the corresponding restrictions
4133 Set_Profile_Restrictions (Ravenscar, N, Warn => False);
4134 end Set_Ravenscar_Profile;
4136 -- Start of processing for Analyze_Pragma
4139 if not Is_Pragma_Name (Chars (N)) then
4140 if Warn_On_Unrecognized_Pragma then
4141 Error_Pragma ("unrecognized pragma%!?");
4146 Prag_Id := Get_Pragma_Id (Chars (N));
4156 if Present (Pragma_Argument_Associations (N)) then
4157 Arg1 := First (Pragma_Argument_Associations (N));
4159 if Present (Arg1) then
4160 Arg2 := Next (Arg1);
4162 if Present (Arg2) then
4163 Arg3 := Next (Arg2);
4165 if Present (Arg3) then
4166 Arg4 := Next (Arg3);
4172 -- Count number of arguments
4179 while Present (Arg_Node) loop
4180 Arg_Count := Arg_Count + 1;
4185 -- An enumeration type defines the pragmas that are supported by the
4186 -- implementation. Get_Pragma_Id (in package Prag) transorms a name
4187 -- into the corresponding enumeration value for the following case.
4195 -- pragma Abort_Defer;
4197 when Pragma_Abort_Defer =>
4199 Check_Arg_Count (0);
4201 -- The only required semantic processing is to check the
4202 -- placement. This pragma must appear at the start of the
4203 -- statement sequence of a handled sequence of statements.
4205 if Nkind (Parent (N)) /= N_Handled_Sequence_Of_Statements
4206 or else N /= First (Statements (Parent (N)))
4217 -- Note: this pragma also has some specific processing in Par.Prag
4218 -- because we want to set the Ada version mode during parsing.
4220 when Pragma_Ada_83 =>
4222 Ada_Version := Ada_83;
4223 Check_Arg_Count (0);
4231 -- Note: this pragma also has some specific processing in Par.Prag
4232 -- because we want to set the Ada 83 version mode during parsing.
4234 when Pragma_Ada_95 =>
4236 Ada_Version := Ada_95;
4237 Check_Arg_Count (0);
4245 -- Note: this pragma also has some specific processing in Par.Prag
4246 -- because we want to set the Ada 83 version mode during parsing.
4248 when Pragma_Ada_05 =>
4250 Ada_Version := Ada_05;
4251 Check_Arg_Count (0);
4253 ----------------------
4254 -- All_Calls_Remote --
4255 ----------------------
4257 -- pragma All_Calls_Remote [(library_package_NAME)];
4259 when Pragma_All_Calls_Remote => All_Calls_Remote : declare
4260 Lib_Entity : Entity_Id;
4263 Check_Ada_83_Warning;
4264 Check_Valid_Library_Unit_Pragma;
4266 if Nkind (N) = N_Null_Statement then
4270 Lib_Entity := Find_Lib_Unit_Name;
4272 -- This pragma should only apply to a RCI unit (RM E.2.3(23)).
4274 if Present (Lib_Entity)
4275 and then not Debug_Flag_U
4277 if not Is_Remote_Call_Interface (Lib_Entity) then
4278 Error_Pragma ("pragma% only apply to rci unit");
4280 -- Set flag for entity of the library unit
4283 Set_Has_All_Calls_Remote (Lib_Entity);
4287 end All_Calls_Remote;
4293 -- pragma Annotate (IDENTIFIER {, ARG});
4294 -- ARG ::= NAME | EXPRESSION
4296 when Pragma_Annotate => Annotate : begin
4298 Check_At_Least_N_Arguments (1);
4299 Check_Arg_Is_Identifier (Arg1);
4302 Arg : Node_Id := Arg2;
4306 while Present (Arg) loop
4307 Exp := Expression (Arg);
4310 if Is_Entity_Name (Exp) then
4313 elsif Nkind (Exp) = N_String_Literal then
4314 Resolve (Exp, Standard_String);
4316 elsif Is_Overloaded (Exp) then
4317 Error_Pragma_Arg ("ambiguous argument for pragma%", Exp);
4332 -- pragma Assert (Boolean_EXPRESSION [, static_string_EXPRESSION]);
4334 when Pragma_Assert =>
4336 Check_No_Identifiers;
4338 if Arg_Count > 1 then
4339 Check_Arg_Count (2);
4340 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
4343 -- If expansion is active and assertions are inactive, then
4344 -- we rewrite the Assertion as:
4346 -- if False and then condition then
4350 -- The reason we do this rewriting during semantic analysis
4351 -- rather than as part of normal expansion is that we cannot
4352 -- analyze and expand the code for the boolean expression
4353 -- directly, or it may cause insertion of actions that would
4354 -- escape the attempt to suppress the assertion code.
4356 if Expander_Active and not Assertions_Enabled then
4358 Make_If_Statement (Loc,
4361 Left_Opnd => New_Occurrence_Of (Standard_False, Loc),
4362 Right_Opnd => Get_Pragma_Arg (Arg1)),
4363 Then_Statements => New_List (
4364 Make_Null_Statement (Loc))));
4368 -- Otherwise (if assertions are enabled, or if we are not
4369 -- operating with expansion active), then we just analyze
4370 -- and resolve the expression.
4373 Analyze_And_Resolve (Expression (Arg1), Any_Boolean);
4380 -- pragma AST_Entry (entry_IDENTIFIER);
4382 when Pragma_AST_Entry => AST_Entry : declare
4388 Check_Arg_Count (1);
4389 Check_No_Identifiers;
4390 Check_Arg_Is_Local_Name (Arg1);
4391 Ent := Entity (Expression (Arg1));
4393 -- Note: the implementation of the AST_Entry pragma could handle
4394 -- the entry family case fine, but for now we are consistent with
4395 -- the DEC rules, and do not allow the pragma, which of course
4396 -- has the effect of also forbidding the attribute.
4398 if Ekind (Ent) /= E_Entry then
4400 ("pragma% argument must be simple entry name", Arg1);
4402 elsif Is_AST_Entry (Ent) then
4404 ("duplicate % pragma for entry", Arg1);
4406 elsif Has_Homonym (Ent) then
4408 ("pragma% argument cannot specify overloaded entry", Arg1);
4412 FF : constant Entity_Id := First_Formal (Ent);
4415 if Present (FF) then
4416 if Present (Next_Formal (FF)) then
4418 ("entry for pragma% can have only one argument",
4421 elsif Parameter_Mode (FF) /= E_In_Parameter then
4423 ("entry parameter for pragma% must have mode IN",
4429 Set_Is_AST_Entry (Ent);
4437 -- pragma Asynchronous (LOCAL_NAME);
4439 when Pragma_Asynchronous => Asynchronous : declare
4447 procedure Process_Async_Pragma;
4448 -- Common processing for procedure and access-to-procedure case
4450 --------------------------
4451 -- Process_Async_Pragma --
4452 --------------------------
4454 procedure Process_Async_Pragma is
4456 if not Present (L) then
4457 Set_Is_Asynchronous (Nm);
4461 -- The formals should be of mode IN (RM E.4.1(6))
4464 while Present (S) loop
4465 Formal := Defining_Identifier (S);
4467 if Nkind (Formal) = N_Defining_Identifier
4468 and then Ekind (Formal) /= E_In_Parameter
4471 ("pragma% procedure can only have IN parameter",
4478 Set_Is_Asynchronous (Nm);
4479 end Process_Async_Pragma;
4481 -- Start of processing for pragma Asynchronous
4484 Check_Ada_83_Warning;
4485 Check_No_Identifiers;
4486 Check_Arg_Count (1);
4487 Check_Arg_Is_Local_Name (Arg1);
4489 if Debug_Flag_U then
4493 C_Ent := Cunit_Entity (Current_Sem_Unit);
4494 Analyze (Expression (Arg1));
4495 Nm := Entity (Expression (Arg1));
4497 if not Is_Remote_Call_Interface (C_Ent)
4498 and then not Is_Remote_Types (C_Ent)
4500 -- This pragma should only appear in an RCI or Remote Types
4501 -- unit (RM E.4.1(4))
4504 ("pragma% not in Remote_Call_Interface or " &
4505 "Remote_Types unit");
4508 if Ekind (Nm) = E_Procedure
4509 and then Nkind (Parent (Nm)) = N_Procedure_Specification
4511 if not Is_Remote_Call_Interface (Nm) then
4513 ("pragma% cannot be applied on non-remote procedure",
4517 L := Parameter_Specifications (Parent (Nm));
4518 Process_Async_Pragma;
4521 elsif Ekind (Nm) = E_Function then
4523 ("pragma% cannot be applied to function", Arg1);
4525 elsif Ekind (Nm) = E_Record_Type
4526 and then Present (Corresponding_Remote_Type (Nm))
4528 -- A record type that is the Equivalent_Type for
4529 -- a remote access-to-subprogram type.
4531 N := Declaration_Node (Corresponding_Remote_Type (Nm));
4533 if Nkind (N) = N_Full_Type_Declaration
4534 and then Nkind (Type_Definition (N)) =
4535 N_Access_Procedure_Definition
4537 L := Parameter_Specifications (Type_Definition (N));
4538 Process_Async_Pragma;
4540 if Is_Asynchronous (Nm)
4541 and then Expander_Active
4543 RACW_Type_Is_Asynchronous (
4544 Underlying_RACW_Type (Nm));
4549 ("pragma% cannot reference access-to-function type",
4553 -- Only other possibility is Access-to-class-wide type
4555 elsif Is_Access_Type (Nm)
4556 and then Is_Class_Wide_Type (Designated_Type (Nm))
4558 Check_First_Subtype (Arg1);
4559 Set_Is_Asynchronous (Nm);
4560 if Expander_Active then
4561 RACW_Type_Is_Asynchronous (Nm);
4565 Error_Pragma_Arg ("inappropriate argument for pragma%", Arg1);
4573 -- pragma Atomic (LOCAL_NAME);
4575 when Pragma_Atomic =>
4576 Process_Atomic_Shared_Volatile;
4578 -----------------------
4579 -- Atomic_Components --
4580 -----------------------
4582 -- pragma Atomic_Components (array_LOCAL_NAME);
4584 -- This processing is shared by Volatile_Components
4586 when Pragma_Atomic_Components |
4587 Pragma_Volatile_Components =>
4589 Atomic_Components : declare
4596 Check_Ada_83_Warning;
4597 Check_No_Identifiers;
4598 Check_Arg_Count (1);
4599 Check_Arg_Is_Local_Name (Arg1);
4600 E_Id := Expression (Arg1);
4602 if Etype (E_Id) = Any_Type then
4608 if Rep_Item_Too_Early (E, N)
4610 Rep_Item_Too_Late (E, N)
4615 D := Declaration_Node (E);
4618 if (K = N_Full_Type_Declaration and then Is_Array_Type (E))
4620 ((Ekind (E) = E_Constant or else Ekind (E) = E_Variable)
4621 and then Nkind (D) = N_Object_Declaration
4622 and then Nkind (Object_Definition (D)) =
4623 N_Constrained_Array_Definition)
4625 -- The flag is set on the object, or on the base type
4627 if Nkind (D) /= N_Object_Declaration then
4631 Set_Has_Volatile_Components (E);
4633 if Prag_Id = Pragma_Atomic_Components then
4634 Set_Has_Atomic_Components (E);
4636 if Is_Packed (E) then
4637 Set_Is_Packed (E, False);
4640 ("?Pack canceled, cannot pack atomic components",
4646 Error_Pragma_Arg ("inappropriate entity for pragma%", Arg1);
4648 end Atomic_Components;
4650 --------------------
4651 -- Attach_Handler --
4652 --------------------
4654 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
4656 when Pragma_Attach_Handler =>
4657 Check_Ada_83_Warning;
4658 Check_No_Identifiers;
4659 Check_Arg_Count (2);
4661 if No_Run_Time_Mode then
4662 Error_Msg_CRT ("Attach_Handler pragma", N);
4664 Check_Interrupt_Or_Attach_Handler;
4666 -- The expression that designates the attribute may
4667 -- depend on a discriminant, and is therefore a per-
4668 -- object expression, to be expanded in the init proc.
4669 -- If expansion is enabled, perform semantic checks
4672 if Expander_Active then
4674 Temp : constant Node_Id :=
4675 New_Copy_Tree (Expression (Arg2));
4677 Set_Parent (Temp, N);
4678 Pre_Analyze_And_Resolve (Temp, RTE (RE_Interrupt_ID));
4682 Analyze (Expression (Arg2));
4683 Resolve (Expression (Arg2), RTE (RE_Interrupt_ID));
4686 Process_Interrupt_Or_Attach_Handler;
4689 --------------------
4690 -- C_Pass_By_Copy --
4691 --------------------
4693 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
4695 when Pragma_C_Pass_By_Copy => C_Pass_By_Copy : declare
4701 Check_Valid_Configuration_Pragma;
4702 Check_Arg_Count (1);
4703 Check_Optional_Identifier (Arg1, "max_size");
4705 Arg := Expression (Arg1);
4706 Check_Arg_Is_Static_Expression (Arg, Any_Integer);
4708 Val := Expr_Value (Arg);
4712 ("maximum size for pragma% must be positive", Arg1);
4714 elsif UI_Is_In_Int_Range (Val) then
4715 Default_C_Record_Mechanism := UI_To_Int (Val);
4717 -- If a giant value is given, Int'Last will do well enough.
4718 -- If sometime someone complains that a record larger than
4719 -- two gigabytes is not copied, we will worry about it then!
4722 Default_C_Record_Mechanism := Mechanism_Type'Last;
4730 -- pragma Comment (static_string_EXPRESSION)
4732 -- Processing for pragma Comment shares the circuitry for
4733 -- pragma Ident. The only differences are that Ident enforces
4734 -- a limit of 31 characters on its argument, and also enforces
4735 -- limitations on placement for DEC compatibility. Pragma
4736 -- Comment shares neither of these restrictions.
4742 -- pragma Common_Object (
4743 -- [Internal =>] LOCAL_NAME,
4744 -- [, [External =>] EXTERNAL_SYMBOL]
4745 -- [, [Size =>] EXTERNAL_SYMBOL]);
4747 -- Processing for this pragma is shared with Psect_Object
4749 --------------------------
4750 -- Compile_Time_Warning --
4751 --------------------------
4753 -- pragma Compile_Time_Warning
4754 -- (boolean_EXPRESSION, static_string_EXPRESSION);
4756 when Pragma_Compile_Time_Warning => Compile_Time_Warning : declare
4757 Arg1x : constant Node_Id := Get_Pragma_Arg (Arg1);
4761 Check_Arg_Count (2);
4762 Check_No_Identifiers;
4763 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
4764 Analyze_And_Resolve (Arg1x, Standard_Boolean);
4766 if Compile_Time_Known_Value (Arg1x) then
4767 if Is_True (Expr_Value (Get_Pragma_Arg (Arg1))) then
4768 String_To_Name_Buffer (Strval (Get_Pragma_Arg (Arg2)));
4769 Add_Char_To_Name_Buffer ('?');
4772 Msg : String (1 .. Name_Len) :=
4773 Name_Buffer (1 .. Name_Len);
4778 -- This loop looks for multiple lines separated by
4779 -- ASCII.LF and breaks them into continuation error
4780 -- messages marked with the usual back slash.
4783 for S in 2 .. Msg'Length - 1 loop
4784 if Msg (S) = ASCII.LF then
4786 Error_Msg_N (Msg (B .. S), Arg1);
4792 Error_Msg_N (Msg (B .. Msg'Length), Arg1);
4796 end Compile_Time_Warning;
4798 ----------------------------
4799 -- Complex_Representation --
4800 ----------------------------
4802 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
4804 when Pragma_Complex_Representation => Complex_Representation : declare
4811 Check_Arg_Count (1);
4812 Check_Optional_Identifier (Arg1, Name_Entity);
4813 Check_Arg_Is_Local_Name (Arg1);
4814 E_Id := Expression (Arg1);
4816 if Etype (E_Id) = Any_Type then
4822 if not Is_Record_Type (E) then
4824 ("argument for pragma% must be record type", Arg1);
4827 Ent := First_Entity (E);
4830 or else No (Next_Entity (Ent))
4831 or else Present (Next_Entity (Next_Entity (Ent)))
4832 or else not Is_Floating_Point_Type (Etype (Ent))
4833 or else Etype (Ent) /= Etype (Next_Entity (Ent))
4836 ("record for pragma% must have two fields of same fpt type",
4840 Set_Has_Complex_Representation (Base_Type (E));
4842 end Complex_Representation;
4844 -------------------------
4845 -- Component_Alignment --
4846 -------------------------
4848 -- pragma Component_Alignment (
4849 -- [Form =>] ALIGNMENT_CHOICE
4850 -- [, [Name =>] type_LOCAL_NAME]);
4852 -- ALIGNMENT_CHOICE ::=
4854 -- | Component_Size_4
4858 when Pragma_Component_Alignment => Component_AlignmentP : declare
4859 Args : Args_List (1 .. 2);
4860 Names : constant Name_List (1 .. 2) := (
4864 Form : Node_Id renames Args (1);
4865 Name : Node_Id renames Args (2);
4867 Atype : Component_Alignment_Kind;
4872 Gather_Associations (Names, Args);
4875 Error_Pragma ("missing Form argument for pragma%");
4878 Check_Arg_Is_Identifier (Form);
4880 -- Get proper alignment, note that Default = Component_Size
4881 -- on all machines we have so far, and we want to set this
4882 -- value rather than the default value to indicate that it
4883 -- has been explicitly set (and thus will not get overridden
4884 -- by the default component alignment for the current scope)
4886 if Chars (Form) = Name_Component_Size then
4887 Atype := Calign_Component_Size;
4889 elsif Chars (Form) = Name_Component_Size_4 then
4890 Atype := Calign_Component_Size_4;
4892 elsif Chars (Form) = Name_Default then
4893 Atype := Calign_Component_Size;
4895 elsif Chars (Form) = Name_Storage_Unit then
4896 Atype := Calign_Storage_Unit;
4900 ("invalid Form parameter for pragma%", Form);
4903 -- Case with no name, supplied, affects scope table entry
4907 (Scope_Stack.Last).Component_Alignment_Default := Atype;
4909 -- Case of name supplied
4912 Check_Arg_Is_Local_Name (Name);
4914 Typ := Entity (Name);
4917 or else Rep_Item_Too_Early (Typ, N)
4921 Typ := Underlying_Type (Typ);
4924 if not Is_Record_Type (Typ)
4925 and then not Is_Array_Type (Typ)
4928 ("Name parameter of pragma% must identify record or " &
4929 "array type", Name);
4932 -- An explicit Component_Alignment pragma overrides an
4933 -- implicit pragma Pack, but not an explicit one.
4935 if not Has_Pragma_Pack (Base_Type (Typ)) then
4936 Set_Is_Packed (Base_Type (Typ), False);
4937 Set_Component_Alignment (Base_Type (Typ), Atype);
4940 end Component_AlignmentP;
4946 -- pragma Controlled (first_subtype_LOCAL_NAME);
4948 when Pragma_Controlled => Controlled : declare
4952 Check_No_Identifiers;
4953 Check_Arg_Count (1);
4954 Check_Arg_Is_Local_Name (Arg1);
4955 Arg := Expression (Arg1);
4957 if not Is_Entity_Name (Arg)
4958 or else not Is_Access_Type (Entity (Arg))
4960 Error_Pragma_Arg ("pragma% requires access type", Arg1);
4962 Set_Has_Pragma_Controlled (Base_Type (Entity (Arg)));
4970 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
4971 -- [Entity =>] LOCAL_NAME);
4973 when Pragma_Convention => Convention : declare
4977 Check_Ada_83_Warning;
4978 Check_Arg_Count (2);
4979 Process_Convention (C, E);
4982 ---------------------------
4983 -- Convention_Identifier --
4984 ---------------------------
4986 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
4987 -- [Convention =>] convention_IDENTIFIER);
4989 when Pragma_Convention_Identifier => Convention_Identifier : declare
4995 Check_Arg_Count (2);
4996 Check_Optional_Identifier (Arg1, Name_Name);
4997 Check_Optional_Identifier (Arg2, Name_Convention);
4998 Check_Arg_Is_Identifier (Arg1);
4999 Check_Arg_Is_Identifier (Arg1);
5000 Idnam := Chars (Expression (Arg1));
5001 Cname := Chars (Expression (Arg2));
5003 if Is_Convention_Name (Cname) then
5004 Record_Convention_Identifier
5005 (Idnam, Get_Convention_Id (Cname));
5008 ("second arg for % pragma must be convention", Arg2);
5010 end Convention_Identifier;
5016 -- pragma CPP_Class ([Entity =>] local_NAME)
5018 when Pragma_CPP_Class => CPP_Class : declare
5021 Default_DTC : Entity_Id := Empty;
5022 VTP_Type : constant Entity_Id := RTE (RE_Vtable_Ptr);
5028 Check_Arg_Count (1);
5029 Check_Optional_Identifier (Arg1, Name_Entity);
5030 Check_Arg_Is_Local_Name (Arg1);
5032 Arg := Expression (Arg1);
5035 if Etype (Arg) = Any_Type then
5039 if not Is_Entity_Name (Arg)
5040 or else not Is_Type (Entity (Arg))
5042 Error_Pragma_Arg ("pragma% requires a type mark", Arg1);
5045 Typ := Entity (Arg);
5047 if not Is_Record_Type (Typ) then
5048 Error_Pragma_Arg ("pragma% applicable to a record, "
5049 & "tagged record or record extension", Arg1);
5052 Default_DTC := First_Component (Typ);
5053 while Present (Default_DTC)
5054 and then Etype (Default_DTC) /= VTP_Type
5056 Next_Component (Default_DTC);
5059 -- Case of non tagged type
5061 if not Is_Tagged_Type (Typ) then
5062 Set_Is_CPP_Class (Typ);
5064 if Present (Default_DTC) then
5066 ("only tagged records can contain vtable pointers", Arg1);
5069 -- Case of tagged type with no vtable ptr
5071 -- What is test for Typ = Root_Typ (Typ) about here ???
5073 elsif Is_Tagged_Type (Typ)
5074 and then Typ = Root_Type (Typ)
5075 and then No (Default_DTC)
5078 ("a cpp_class must contain a vtable pointer", Arg1);
5080 -- Tagged type that has a vtable ptr
5082 elsif Present (Default_DTC) then
5083 Set_Is_CPP_Class (Typ);
5084 Set_Is_Limited_Record (Typ);
5085 Set_Is_Tag (Default_DTC);
5086 Set_DT_Entry_Count (Default_DTC, No_Uint);
5088 -- Since a CPP type has no direct link to its associated tag
5089 -- most tags checks cannot be performed
5091 Set_Kill_Tag_Checks (Typ);
5092 Set_Kill_Tag_Checks (Class_Wide_Type (Typ));
5094 -- Get rid of the _tag component when there was one.
5095 -- It is only useful for regular tagged types
5097 if Expander_Active and then Typ = Root_Type (Typ) then
5099 Tag_C := Tag_Component (Typ);
5100 C := First_Entity (Typ);
5103 Set_First_Entity (Typ, Next_Entity (Tag_C));
5106 while Next_Entity (C) /= Tag_C loop
5110 Set_Next_Entity (C, Next_Entity (Tag_C));
5116 ---------------------
5117 -- CPP_Constructor --
5118 ---------------------
5120 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
5122 when Pragma_CPP_Constructor => CPP_Constructor : declare
5128 Check_Arg_Count (1);
5129 Check_Optional_Identifier (Arg1, Name_Entity);
5130 Check_Arg_Is_Local_Name (Arg1);
5132 Id := Expression (Arg1);
5133 Find_Program_Unit_Name (Id);
5135 -- If we did not find the name, we are done
5137 if Etype (Id) = Any_Type then
5141 Def_Id := Entity (Id);
5143 if Ekind (Def_Id) = E_Function
5144 and then Is_Class_Wide_Type (Etype (Def_Id))
5145 and then Is_CPP_Class (Etype (Etype (Def_Id)))
5147 -- What the heck is this??? this pragma allows only 1 arg
5149 if Arg_Count >= 2 then
5150 Check_At_Most_N_Arguments (3);
5151 Process_Interface_Name (Def_Id, Arg2, Arg3);
5154 if No (Parameter_Specifications (Parent (Def_Id))) then
5155 Set_Has_Completion (Def_Id);
5156 Set_Is_Constructor (Def_Id);
5159 ("non-default constructors not implemented", Arg1);
5164 ("pragma% requires function returning a 'C'P'P_Class type",
5167 end CPP_Constructor;
5173 -- pragma CPP_Virtual
5174 -- [Entity =>] LOCAL_NAME
5175 -- [ [Vtable_Ptr =>] LOCAL_NAME,
5176 -- [Position =>] static_integer_EXPRESSION]);
5178 when Pragma_CPP_Virtual => CPP_Virtual : declare
5182 VTP_Type : constant Entity_Id := RTE (RE_Vtable_Ptr);
5189 if Arg_Count = 3 then
5190 Check_Optional_Identifier (Arg2, "vtable_ptr");
5192 -- We allow Entry_Count as well as Position for the third
5193 -- parameter for back compatibility with versions of GNAT
5194 -- before version 3.12. The documentation has always said
5195 -- Position, but the code up to 3.12 said Entry_Count.
5197 if Chars (Arg3) /= Name_Position then
5198 Check_Optional_Identifier (Arg3, "entry_count");
5202 Check_Arg_Count (1);
5205 Check_Optional_Identifier (Arg1, Name_Entity);
5206 Check_Arg_Is_Local_Name (Arg1);
5208 -- First argument must be a subprogram name
5210 Arg := Expression (Arg1);
5211 Find_Program_Unit_Name (Arg);
5213 if Etype (Arg) = Any_Type then
5216 Subp := Entity (Arg);
5219 if not (Is_Subprogram (Subp)
5220 and then Is_Dispatching_Operation (Subp))
5223 ("pragma% must reference a primitive operation", Arg1);
5226 Typ := Find_Dispatching_Type (Subp);
5228 -- If only one Argument defaults are :
5229 -- . DTC_Entity is the default Vtable pointer
5230 -- . DT_Position will be set at the freezing point
5232 if Arg_Count = 1 then
5233 Set_DTC_Entity (Subp, Tag_Component (Typ));
5237 -- Second argument is a component name of type Vtable_Ptr
5239 Arg := Expression (Arg2);
5241 if Nkind (Arg) /= N_Identifier then
5242 Error_Msg_NE ("must be a& component name", Arg, Typ);
5246 DTC := First_Component (Typ);
5247 while Present (DTC) and then Chars (DTC) /= Chars (Arg) loop
5248 Next_Component (DTC);
5252 Error_Msg_NE ("must be a& component name", Arg, Typ);
5255 elsif Etype (DTC) /= VTP_Type then
5256 Wrong_Type (Arg, VTP_Type);
5260 -- Third argument is an integer (DT_Position)
5262 Arg := Expression (Arg3);
5263 Analyze_And_Resolve (Arg, Any_Integer);
5265 if not Is_Static_Expression (Arg) then
5266 Flag_Non_Static_Expr
5267 ("third argument of pragma CPP_Virtual must be static!",
5272 V := Expr_Value (Expression (Arg3));
5276 ("third argument of pragma% must be positive",
5280 Set_DTC_Entity (Subp, DTC);
5281 Set_DT_Position (Subp, V);
5290 -- pragma CPP_Vtable (
5291 -- [Entity =>] LOCAL_NAME
5292 -- [Vtable_Ptr =>] LOCAL_NAME,
5293 -- [Entry_Count =>] static_integer_EXPRESSION);
5295 when Pragma_CPP_Vtable => CPP_Vtable : declare
5298 VTP_Type : constant Entity_Id := RTE (RE_Vtable_Ptr);
5305 Check_Arg_Count (3);
5306 Check_Optional_Identifier (Arg1, Name_Entity);
5307 Check_Optional_Identifier (Arg2, "vtable_ptr");
5308 Check_Optional_Identifier (Arg3, "entry_count");
5309 Check_Arg_Is_Local_Name (Arg1);
5311 -- First argument is a record type name
5313 Arg := Expression (Arg1);
5316 if Etype (Arg) = Any_Type then
5319 Typ := Entity (Arg);
5322 if not (Is_Tagged_Type (Typ) and then Is_CPP_Class (Typ)) then
5323 Error_Pragma_Arg ("'C'P'P_Class tagged type expected", Arg1);
5326 -- Second argument is a component name of type Vtable_Ptr
5328 Arg := Expression (Arg2);
5330 if Nkind (Arg) /= N_Identifier then
5331 Error_Msg_NE ("must be a& component name", Arg, Typ);
5335 DTC := First_Component (Typ);
5336 while Present (DTC) and then Chars (DTC) /= Chars (Arg) loop
5337 Next_Component (DTC);
5341 Error_Msg_NE ("must be a& component name", Arg, Typ);
5344 elsif Etype (DTC) /= VTP_Type then
5345 Wrong_Type (DTC, VTP_Type);
5348 -- If it is the first pragma Vtable, This becomes the default tag
5350 elsif (not Is_Tag (DTC))
5351 and then DT_Entry_Count (Tag_Component (Typ)) = No_Uint
5353 Set_Is_Tag (Tag_Component (Typ), False);
5354 Set_Is_Tag (DTC, True);
5355 Set_DT_Entry_Count (DTC, No_Uint);
5358 -- Those pragmas must appear before any primitive operation
5359 -- definition (except inherited ones) otherwise the default
5362 Elmt := First_Elmt (Primitive_Operations (Typ));
5363 while Present (Elmt) loop
5364 if No (Alias (Node (Elmt))) then
5365 Error_Msg_Sloc := Sloc (Node (Elmt));
5367 ("pragma% must appear before this primitive operation");
5373 -- Third argument is an integer (DT_Entry_Count)
5375 Arg := Expression (Arg3);
5376 Analyze_And_Resolve (Arg, Any_Integer);
5378 if not Is_Static_Expression (Arg) then
5379 Flag_Non_Static_Expr
5380 ("entry count for pragma CPP_Vtable must be a static " &
5381 "expression!", Arg3);
5385 V := Expr_Value (Expression (Arg3));
5389 ("entry count for pragma% must be positive", Arg3);
5391 Set_DT_Entry_Count (DTC, V);
5400 -- pragma Debug (PROCEDURE_CALL_STATEMENT);
5402 when Pragma_Debug => Debug : begin
5405 -- Rewrite into a conditional with a static condition
5407 Rewrite (N, Make_Implicit_If_Statement (N,
5408 Condition => New_Occurrence_Of (Boolean_Literals (
5409 Assertions_Enabled and Expander_Active), Loc),
5410 Then_Statements => New_List (
5411 Relocate_Node (Debug_Statement (N)))));
5415 ---------------------
5416 -- Detect_Blocking --
5417 ---------------------
5419 -- pragma Detect_Blocking;
5421 when Pragma_Detect_Blocking =>
5423 Check_Arg_Count (0);
5424 Check_Valid_Configuration_Pragma;
5425 Detect_Blocking := True;
5431 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
5433 when Pragma_Discard_Names => Discard_Names : declare
5438 Check_Ada_83_Warning;
5440 -- Deal with configuration pragma case
5442 if Arg_Count = 0 and then Is_Configuration_Pragma then
5443 Global_Discard_Names := True;
5446 -- Otherwise, check correct appropriate context
5449 Check_Is_In_Decl_Part_Or_Package_Spec;
5451 if Arg_Count = 0 then
5453 -- If there is no parameter, then from now on this pragma
5454 -- applies to any enumeration, exception or tagged type
5455 -- defined in the current declarative part.
5457 Set_Discard_Names (Current_Scope);
5461 Check_Arg_Count (1);
5462 Check_Optional_Identifier (Arg1, Name_On);
5463 Check_Arg_Is_Local_Name (Arg1);
5464 E_Id := Expression (Arg1);
5466 if Etype (E_Id) = Any_Type then
5472 if (Is_First_Subtype (E)
5473 and then (Is_Enumeration_Type (E)
5474 or else Is_Tagged_Type (E)))
5475 or else Ekind (E) = E_Exception
5477 Set_Discard_Names (E);
5480 ("inappropriate entity for pragma%", Arg1);
5490 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
5492 when Pragma_Elaborate => Elaborate : declare
5494 Parent_Node : Node_Id;
5499 -- Pragma must be in context items list of a compilation unit
5501 if not Is_List_Member (N) then
5506 Plist := List_Containing (N);
5507 Parent_Node := Parent (Plist);
5509 if Parent_Node = Empty
5510 or else Nkind (Parent_Node) /= N_Compilation_Unit
5511 or else Context_Items (Parent_Node) /= Plist
5518 -- Must be at least one argument
5520 if Arg_Count = 0 then
5521 Error_Pragma ("pragma% requires at least one argument");
5524 -- In Ada 83 mode, there can be no items following it in the
5525 -- context list except other pragmas and implicit with clauses
5526 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
5527 -- placement rule does not apply.
5529 if Ada_Version = Ada_83 and then Comes_From_Source (N) then
5532 while Present (Citem) loop
5533 if Nkind (Citem) = N_Pragma
5534 or else (Nkind (Citem) = N_With_Clause
5535 and then Implicit_With (Citem))
5540 ("(Ada 83) pragma% must be at end of context clause");
5547 -- Finally, the arguments must all be units mentioned in a with
5548 -- clause in the same context clause. Note we already checked
5549 -- (in Par.Prag) that the arguments are either identifiers or
5552 Outer : while Present (Arg) loop
5553 Citem := First (Plist);
5555 Inner : while Citem /= N loop
5556 if Nkind (Citem) = N_With_Clause
5557 and then Same_Name (Name (Citem), Expression (Arg))
5559 Set_Elaborate_Present (Citem, True);
5560 Set_Unit_Name (Expression (Arg), Name (Citem));
5561 Set_Suppress_Elaboration_Warnings (Entity (Name (Citem)));
5570 ("argument of pragma% is not with'ed unit", Arg);
5576 -- Give a warning if operating in static mode with -gnatwl
5577 -- (elaboration warnings eanbled) switch set.
5579 if Elab_Warnings and not Dynamic_Elaboration_Checks then
5581 ("?use of pragma Elaborate may not be safe", N);
5583 ("?use pragma Elaborate_All instead if possible", N);
5591 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
5593 when Pragma_Elaborate_All => Elaborate_All : declare
5595 Parent_Node : Node_Id;
5600 Check_Ada_83_Warning;
5602 -- Pragma must be in context items list of a compilation unit
5604 if not Is_List_Member (N) then
5609 Plist := List_Containing (N);
5610 Parent_Node := Parent (Plist);
5612 if Parent_Node = Empty
5613 or else Nkind (Parent_Node) /= N_Compilation_Unit
5614 or else Context_Items (Parent_Node) /= Plist
5621 -- Must be at least one argument
5623 if Arg_Count = 0 then
5624 Error_Pragma ("pragma% requires at least one argument");
5627 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
5628 -- have to appear at the end of the context clause, but may
5629 -- appear mixed in with other items, even in Ada 83 mode.
5631 -- Final check: the arguments must all be units mentioned in
5632 -- a with clause in the same context clause. Note that we
5633 -- already checked (in Par.Prag) that all the arguments are
5634 -- either identifiers or selected components.
5637 Outr : while Present (Arg) loop
5638 Citem := First (Plist);
5640 Innr : while Citem /= N loop
5641 if Nkind (Citem) = N_With_Clause
5642 and then Same_Name (Name (Citem), Expression (Arg))
5644 Set_Elaborate_All_Present (Citem, True);
5645 Set_Unit_Name (Expression (Arg), Name (Citem));
5646 Set_Suppress_Elaboration_Warnings (Entity (Name (Citem)));
5654 Set_Error_Posted (N);
5656 ("argument of pragma% is not with'ed unit", Arg);
5663 --------------------
5664 -- Elaborate_Body --
5665 --------------------
5667 -- pragma Elaborate_Body [( library_unit_NAME )];
5669 when Pragma_Elaborate_Body => Elaborate_Body : declare
5670 Cunit_Node : Node_Id;
5671 Cunit_Ent : Entity_Id;
5674 Check_Ada_83_Warning;
5675 Check_Valid_Library_Unit_Pragma;
5677 if Nkind (N) = N_Null_Statement then
5681 Cunit_Node := Cunit (Current_Sem_Unit);
5682 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
5684 if Nkind (Unit (Cunit_Node)) = N_Package_Body
5686 Nkind (Unit (Cunit_Node)) = N_Subprogram_Body
5688 Error_Pragma ("pragma% must refer to a spec, not a body");
5690 Set_Body_Required (Cunit_Node, True);
5691 Set_Has_Pragma_Elaborate_Body (Cunit_Ent);
5693 -- If we are in dynamic elaboration mode, then we suppress
5694 -- elaboration warnings for the unit, since it is definitely
5695 -- fine NOT to do dynamic checks at the first level (and such
5696 -- checks will be suppressed because no elaboration boolean
5697 -- is created for Elaborate_Body packages).
5699 -- But in the static model of elaboration, Elaborate_Body is
5700 -- definitely NOT good enough to ensure elaboration safety on
5701 -- its own, since the body may WITH other units that are not
5702 -- safe from an elaboration point of view, so a client must
5703 -- still do an Elaborate_All on such units.
5705 -- Debug flag -gnatdD restores the old behavior of 3.13,
5706 -- where Elaborate_Body always suppressed elab warnings.
5708 if Dynamic_Elaboration_Checks or Debug_Flag_DD then
5709 Set_Suppress_Elaboration_Warnings (Cunit_Ent);
5714 ------------------------
5715 -- Elaboration_Checks --
5716 ------------------------
5718 -- pragma Elaboration_Checks (Static | Dynamic);
5720 when Pragma_Elaboration_Checks =>
5722 Check_Arg_Count (1);
5723 Check_Arg_Is_One_Of (Arg1, Name_Static, Name_Dynamic);
5724 Dynamic_Elaboration_Checks :=
5725 (Chars (Get_Pragma_Arg (Arg1)) = Name_Dynamic);
5731 -- pragma Eliminate (
5732 -- [Unit_Name =>] IDENTIFIER |
5733 -- SELECTED_COMPONENT
5734 -- [,[Entity =>] IDENTIFIER |
5735 -- SELECTED_COMPONENT |
5737 -- [,]OVERLOADING_RESOLUTION);
5739 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
5742 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
5745 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
5747 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
5748 -- Result_Type => result_SUBTYPE_NAME]
5750 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
5751 -- SUBTYPE_NAME ::= STRING_LITERAL
5753 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
5754 -- SOURCE_TRACE ::= STRING_LITERAL
5756 when Pragma_Eliminate => Eliminate : declare
5757 Args : Args_List (1 .. 5);
5758 Names : constant Name_List (1 .. 5) := (
5761 Name_Parameter_Types,
5763 Name_Source_Location);
5765 Unit_Name : Node_Id renames Args (1);
5766 Entity : Node_Id renames Args (2);
5767 Parameter_Types : Node_Id renames Args (3);
5768 Result_Type : Node_Id renames Args (4);
5769 Source_Location : Node_Id renames Args (5);
5773 Check_Valid_Configuration_Pragma;
5774 Gather_Associations (Names, Args);
5776 if No (Unit_Name) then
5777 Error_Pragma ("missing Unit_Name argument for pragma%");
5781 and then (Present (Parameter_Types)
5783 Present (Result_Type)
5785 Present (Source_Location))
5787 Error_Pragma ("missing Entity argument for pragma%");
5790 if (Present (Parameter_Types)
5792 Present (Result_Type))
5794 Present (Source_Location)
5797 ("parameter profile and source location can not " &
5798 "be used together in pragma%");
5801 Process_Eliminate_Pragma
5810 -------------------------
5811 -- Explicit_Overriding --
5812 -------------------------
5814 when Pragma_Explicit_Overriding =>
5815 Check_Valid_Configuration_Pragma;
5816 Check_Arg_Count (0);
5817 Explicit_Overriding := True;
5824 -- [ Convention =>] convention_IDENTIFIER,
5825 -- [ Entity =>] local_NAME
5826 -- [, [External_Name =>] static_string_EXPRESSION ]
5827 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5829 when Pragma_Export => Export : declare
5834 Check_Ada_83_Warning;
5835 Check_At_Least_N_Arguments (2);
5836 Check_At_Most_N_Arguments (4);
5837 Process_Convention (C, Def_Id);
5839 if Ekind (Def_Id) /= E_Constant then
5840 Note_Possible_Modification (Expression (Arg2));
5843 Process_Interface_Name (Def_Id, Arg3, Arg4);
5844 Set_Exported (Def_Id, Arg2);
5847 ----------------------
5848 -- Export_Exception --
5849 ----------------------
5851 -- pragma Export_Exception (
5852 -- [Internal =>] LOCAL_NAME,
5853 -- [, [External =>] EXTERNAL_SYMBOL,]
5854 -- [, [Form =>] Ada | VMS]
5855 -- [, [Code =>] static_integer_EXPRESSION]);
5857 when Pragma_Export_Exception => Export_Exception : declare
5858 Args : Args_List (1 .. 4);
5859 Names : constant Name_List (1 .. 4) := (
5865 Internal : Node_Id renames Args (1);
5866 External : Node_Id renames Args (2);
5867 Form : Node_Id renames Args (3);
5868 Code : Node_Id renames Args (4);
5871 if Inside_A_Generic then
5872 Error_Pragma ("pragma% cannot be used for generic entities");
5875 Gather_Associations (Names, Args);
5876 Process_Extended_Import_Export_Exception_Pragma (
5877 Arg_Internal => Internal,
5878 Arg_External => External,
5882 if not Is_VMS_Exception (Entity (Internal)) then
5883 Set_Exported (Entity (Internal), Internal);
5885 end Export_Exception;
5887 ---------------------
5888 -- Export_Function --
5889 ---------------------
5891 -- pragma Export_Function (
5892 -- [Internal =>] LOCAL_NAME,
5893 -- [, [External =>] EXTERNAL_SYMBOL,]
5894 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
5895 -- [, [Result_Type =>] TYPE_DESIGNATOR]
5896 -- [, [Mechanism =>] MECHANISM]
5897 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
5899 -- EXTERNAL_SYMBOL ::=
5901 -- | static_string_EXPRESSION
5903 -- PARAMETER_TYPES ::=
5905 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
5907 -- TYPE_DESIGNATOR ::=
5909 -- | subtype_Name ' Access
5913 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
5915 -- MECHANISM_ASSOCIATION ::=
5916 -- [formal_parameter_NAME =>] MECHANISM_NAME
5918 -- MECHANISM_NAME ::=
5921 -- | Descriptor [([Class =>] CLASS_NAME)]
5923 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
5925 when Pragma_Export_Function => Export_Function : declare
5926 Args : Args_List (1 .. 6);
5927 Names : constant Name_List (1 .. 6) := (
5930 Name_Parameter_Types,
5933 Name_Result_Mechanism);
5935 Internal : Node_Id renames Args (1);
5936 External : Node_Id renames Args (2);
5937 Parameter_Types : Node_Id renames Args (3);
5938 Result_Type : Node_Id renames Args (4);
5939 Mechanism : Node_Id renames Args (5);
5940 Result_Mechanism : Node_Id renames Args (6);
5944 Gather_Associations (Names, Args);
5945 Process_Extended_Import_Export_Subprogram_Pragma (
5946 Arg_Internal => Internal,
5947 Arg_External => External,
5948 Arg_Parameter_Types => Parameter_Types,
5949 Arg_Result_Type => Result_Type,
5950 Arg_Mechanism => Mechanism,
5951 Arg_Result_Mechanism => Result_Mechanism);
5952 end Export_Function;
5958 -- pragma Export_Object (
5959 -- [Internal =>] LOCAL_NAME,
5960 -- [, [External =>] EXTERNAL_SYMBOL]
5961 -- [, [Size =>] EXTERNAL_SYMBOL]);
5963 -- EXTERNAL_SYMBOL ::=
5965 -- | static_string_EXPRESSION
5967 -- PARAMETER_TYPES ::=
5969 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
5971 -- TYPE_DESIGNATOR ::=
5973 -- | subtype_Name ' Access
5977 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
5979 -- MECHANISM_ASSOCIATION ::=
5980 -- [formal_parameter_NAME =>] MECHANISM_NAME
5982 -- MECHANISM_NAME ::=
5985 -- | Descriptor [([Class =>] CLASS_NAME)]
5987 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
5989 when Pragma_Export_Object => Export_Object : declare
5990 Args : Args_List (1 .. 3);
5991 Names : constant Name_List (1 .. 3) := (
5996 Internal : Node_Id renames Args (1);
5997 External : Node_Id renames Args (2);
5998 Size : Node_Id renames Args (3);
6002 Gather_Associations (Names, Args);
6003 Process_Extended_Import_Export_Object_Pragma (
6004 Arg_Internal => Internal,
6005 Arg_External => External,
6009 ----------------------
6010 -- Export_Procedure --
6011 ----------------------
6013 -- pragma Export_Procedure (
6014 -- [Internal =>] LOCAL_NAME,
6015 -- [, [External =>] EXTERNAL_SYMBOL,]
6016 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6017 -- [, [Mechanism =>] MECHANISM]);
6019 -- EXTERNAL_SYMBOL ::=
6021 -- | static_string_EXPRESSION
6023 -- PARAMETER_TYPES ::=
6025 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6027 -- TYPE_DESIGNATOR ::=
6029 -- | subtype_Name ' Access
6033 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6035 -- MECHANISM_ASSOCIATION ::=
6036 -- [formal_parameter_NAME =>] MECHANISM_NAME
6038 -- MECHANISM_NAME ::=
6041 -- | Descriptor [([Class =>] CLASS_NAME)]
6043 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6045 when Pragma_Export_Procedure => Export_Procedure : declare
6046 Args : Args_List (1 .. 4);
6047 Names : constant Name_List (1 .. 4) := (
6050 Name_Parameter_Types,
6053 Internal : Node_Id renames Args (1);
6054 External : Node_Id renames Args (2);
6055 Parameter_Types : Node_Id renames Args (3);
6056 Mechanism : Node_Id renames Args (4);
6060 Gather_Associations (Names, Args);
6061 Process_Extended_Import_Export_Subprogram_Pragma (
6062 Arg_Internal => Internal,
6063 Arg_External => External,
6064 Arg_Parameter_Types => Parameter_Types,
6065 Arg_Mechanism => Mechanism);
6066 end Export_Procedure;
6072 -- pragma Export_Value (
6073 -- [Value =>] static_integer_EXPRESSION,
6074 -- [Link_Name =>] static_string_EXPRESSION);
6076 when Pragma_Export_Value =>
6078 Check_Arg_Count (2);
6080 Check_Optional_Identifier (Arg1, Name_Value);
6081 Check_Arg_Is_Static_Expression (Arg1, Any_Integer);
6083 Check_Optional_Identifier (Arg2, Name_Link_Name);
6084 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
6086 -----------------------------
6087 -- Export_Valued_Procedure --
6088 -----------------------------
6090 -- pragma Export_Valued_Procedure (
6091 -- [Internal =>] LOCAL_NAME,
6092 -- [, [External =>] EXTERNAL_SYMBOL,]
6093 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6094 -- [, [Mechanism =>] MECHANISM]);
6096 -- EXTERNAL_SYMBOL ::=
6098 -- | static_string_EXPRESSION
6100 -- PARAMETER_TYPES ::=
6102 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6104 -- TYPE_DESIGNATOR ::=
6106 -- | subtype_Name ' Access
6110 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6112 -- MECHANISM_ASSOCIATION ::=
6113 -- [formal_parameter_NAME =>] MECHANISM_NAME
6115 -- MECHANISM_NAME ::=
6118 -- | Descriptor [([Class =>] CLASS_NAME)]
6120 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6122 when Pragma_Export_Valued_Procedure =>
6123 Export_Valued_Procedure : declare
6124 Args : Args_List (1 .. 4);
6125 Names : constant Name_List (1 .. 4) := (
6128 Name_Parameter_Types,
6131 Internal : Node_Id renames Args (1);
6132 External : Node_Id renames Args (2);
6133 Parameter_Types : Node_Id renames Args (3);
6134 Mechanism : Node_Id renames Args (4);
6138 Gather_Associations (Names, Args);
6139 Process_Extended_Import_Export_Subprogram_Pragma (
6140 Arg_Internal => Internal,
6141 Arg_External => External,
6142 Arg_Parameter_Types => Parameter_Types,
6143 Arg_Mechanism => Mechanism);
6144 end Export_Valued_Procedure;
6150 -- pragma Extend_System ([Name =>] Identifier);
6152 when Pragma_Extend_System => Extend_System : declare
6155 Check_Valid_Configuration_Pragma;
6156 Check_Arg_Count (1);
6157 Check_Optional_Identifier (Arg1, Name_Name);
6158 Check_Arg_Is_Identifier (Arg1);
6160 Get_Name_String (Chars (Expression (Arg1)));
6163 and then Name_Buffer (1 .. 4) = "aux_"
6165 if Present (System_Extend_Pragma_Arg) then
6166 if Chars (Expression (Arg1)) =
6167 Chars (Expression (System_Extend_Pragma_Arg))
6171 Error_Msg_Sloc := Sloc (System_Extend_Pragma_Arg);
6172 Error_Pragma ("pragma% conflicts with that at#");
6176 System_Extend_Pragma_Arg := Arg1;
6178 if not GNAT_Mode then
6179 System_Extend_Unit := Arg1;
6183 Error_Pragma ("incorrect name for pragma%, must be Aux_xxx");
6187 ------------------------
6188 -- Extensions_Allowed --
6189 ------------------------
6191 -- pragma Extensions_Allowed (ON | OFF);
6193 when Pragma_Extensions_Allowed =>
6195 Check_Arg_Count (1);
6196 Check_No_Identifiers;
6197 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
6199 if Chars (Expression (Arg1)) = Name_On then
6200 Extensions_Allowed := True;
6201 Ada_Version := Ada_Version_Type'Last;
6203 Extensions_Allowed := False;
6204 Ada_Version := Ada_Version_Type'Min (Ada_Version, Ada_95);
6211 -- pragma External (
6212 -- [ Convention =>] convention_IDENTIFIER,
6213 -- [ Entity =>] local_NAME
6214 -- [, [External_Name =>] static_string_EXPRESSION ]
6215 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6217 when Pragma_External => External : declare
6223 Check_At_Least_N_Arguments (2);
6224 Check_At_Most_N_Arguments (4);
6225 Process_Convention (C, Def_Id);
6226 Note_Possible_Modification (Expression (Arg2));
6227 Process_Interface_Name (Def_Id, Arg3, Arg4);
6228 Set_Exported (Def_Id, Arg2);
6231 --------------------------
6232 -- External_Name_Casing --
6233 --------------------------
6235 -- pragma External_Name_Casing (
6236 -- UPPERCASE | LOWERCASE
6237 -- [, AS_IS | UPPERCASE | LOWERCASE]);
6239 when Pragma_External_Name_Casing => External_Name_Casing : declare
6242 Check_No_Identifiers;
6244 if Arg_Count = 2 then
6246 (Arg2, Name_As_Is, Name_Uppercase, Name_Lowercase);
6248 case Chars (Get_Pragma_Arg (Arg2)) is
6250 Opt.External_Name_Exp_Casing := As_Is;
6252 when Name_Uppercase =>
6253 Opt.External_Name_Exp_Casing := Uppercase;
6255 when Name_Lowercase =>
6256 Opt.External_Name_Exp_Casing := Lowercase;
6263 Check_Arg_Count (1);
6266 Check_Arg_Is_One_Of (Arg1, Name_Uppercase, Name_Lowercase);
6268 case Chars (Get_Pragma_Arg (Arg1)) is
6269 when Name_Uppercase =>
6270 Opt.External_Name_Imp_Casing := Uppercase;
6272 when Name_Lowercase =>
6273 Opt.External_Name_Imp_Casing := Lowercase;
6278 end External_Name_Casing;
6280 ---------------------------
6281 -- Finalize_Storage_Only --
6282 ---------------------------
6284 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
6286 when Pragma_Finalize_Storage_Only => Finalize_Storage : declare
6287 Assoc : constant Node_Id := Arg1;
6288 Type_Id : constant Node_Id := Expression (Assoc);
6292 Check_No_Identifiers;
6293 Check_Arg_Count (1);
6294 Check_Arg_Is_Local_Name (Arg1);
6296 Find_Type (Type_Id);
6297 Typ := Entity (Type_Id);
6300 or else Rep_Item_Too_Early (Typ, N)
6304 Typ := Underlying_Type (Typ);
6307 if not Is_Controlled (Typ) then
6308 Error_Pragma ("pragma% must specify controlled type");
6311 Check_First_Subtype (Arg1);
6313 if Finalize_Storage_Only (Typ) then
6314 Error_Pragma ("duplicate pragma%, only one allowed");
6316 elsif not Rep_Item_Too_Late (Typ, N) then
6317 Set_Finalize_Storage_Only (Base_Type (Typ), True);
6319 end Finalize_Storage;
6321 --------------------------
6322 -- Float_Representation --
6323 --------------------------
6325 -- pragma Float_Representation (VAX_Float | IEEE_Float);
6327 when Pragma_Float_Representation => Float_Representation : declare
6335 if Arg_Count = 1 then
6336 Check_Valid_Configuration_Pragma;
6338 Check_Arg_Count (2);
6339 Check_Optional_Identifier (Arg2, Name_Entity);
6340 Check_Arg_Is_Local_Name (Arg2);
6343 Check_No_Identifier (Arg1);
6344 Check_Arg_Is_One_Of (Arg1, Name_VAX_Float, Name_IEEE_Float);
6346 if not OpenVMS_On_Target then
6347 if Chars (Expression (Arg1)) = Name_VAX_Float then
6349 ("?pragma% ignored (applies only to Open'V'M'S)");
6355 -- One argument case
6357 if Arg_Count = 1 then
6359 if Chars (Expression (Arg1)) = Name_VAX_Float then
6361 if Opt.Float_Format = 'I' then
6362 Error_Pragma ("'I'E'E'E format previously specified");
6365 Opt.Float_Format := 'V';
6368 if Opt.Float_Format = 'V' then
6369 Error_Pragma ("'V'A'X format previously specified");
6372 Opt.Float_Format := 'I';
6375 Set_Standard_Fpt_Formats;
6377 -- Two argument case
6380 Argx := Get_Pragma_Arg (Arg2);
6382 if not Is_Entity_Name (Argx)
6383 or else not Is_Floating_Point_Type (Entity (Argx))
6386 ("second argument of% pragma must be floating-point type",
6390 Ent := Entity (Argx);
6391 Digs := UI_To_Int (Digits_Value (Ent));
6393 -- Two arguments, VAX_Float case
6395 if Chars (Expression (Arg1)) = Name_VAX_Float then
6398 when 6 => Set_F_Float (Ent);
6399 when 9 => Set_D_Float (Ent);
6400 when 15 => Set_G_Float (Ent);
6404 ("wrong digits value, must be 6,9 or 15", Arg2);
6407 -- Two arguments, IEEE_Float case
6411 when 6 => Set_IEEE_Short (Ent);
6412 when 15 => Set_IEEE_Long (Ent);
6416 ("wrong digits value, must be 6 or 15", Arg2);
6420 end Float_Representation;
6426 -- pragma Ident (static_string_EXPRESSION)
6428 -- Note: pragma Comment shares this processing. Pragma Comment
6429 -- is identical to Ident, except that the restriction of the
6430 -- argument to 31 characters and the placement restrictions
6431 -- are not enforced for pragma Comment.
6433 when Pragma_Ident | Pragma_Comment => Ident : declare
6438 Check_Arg_Count (1);
6439 Check_No_Identifiers;
6440 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
6442 -- For pragma Ident, preserve DEC compatibility by requiring
6443 -- the pragma to appear in a declarative part or package spec.
6445 if Prag_Id = Pragma_Ident then
6446 Check_Is_In_Decl_Part_Or_Package_Spec;
6449 Str := Expr_Value_S (Expression (Arg1));
6456 GP := Parent (Parent (N));
6458 if Nkind (GP) = N_Package_Declaration
6460 Nkind (GP) = N_Generic_Package_Declaration
6465 -- If we have a compilation unit, then record the ident
6466 -- value, checking for improper duplication.
6468 if Nkind (GP) = N_Compilation_Unit then
6469 CS := Ident_String (Current_Sem_Unit);
6471 if Present (CS) then
6473 -- For Ident, we do not permit multiple instances
6475 if Prag_Id = Pragma_Ident then
6476 Error_Pragma ("duplicate% pragma not permitted");
6478 -- For Comment, we concatenate the string, unless we
6479 -- want to preserve the tree structure for ASIS.
6481 elsif not ASIS_Mode then
6482 Start_String (Strval (CS));
6483 Store_String_Char (' ');
6484 Store_String_Chars (Strval (Str));
6485 Set_Strval (CS, End_String);
6489 -- In VMS, the effect of IDENT is achieved by passing
6490 -- IDENTIFICATION=name as a --for-linker switch.
6492 if OpenVMS_On_Target then
6495 ("--for-linker=IDENTIFICATION=");
6496 String_To_Name_Buffer (Strval (Str));
6497 Store_String_Chars (Name_Buffer (1 .. Name_Len));
6499 -- Only the last processed IDENT is saved. The main
6500 -- purpose is so an IDENT associated with a main
6501 -- procedure will be used in preference to an IDENT
6502 -- associated with a with'd package.
6504 Replace_Linker_Option_String
6505 (End_String, "--for-linker=IDENTIFICATION=");
6508 Set_Ident_String (Current_Sem_Unit, Str);
6511 -- For subunits, we just ignore the Ident, since in GNAT
6512 -- these are not separate object files, and hence not
6513 -- separate units in the unit table.
6515 elsif Nkind (GP) = N_Subunit then
6518 -- Otherwise we have a misplaced pragma Ident, but we ignore
6519 -- this if we are in an instantiation, since it comes from
6520 -- a generic, and has no relevance to the instantiation.
6522 elsif Prag_Id = Pragma_Ident then
6523 if Instantiation_Location (Loc) = No_Location then
6524 Error_Pragma ("pragma% only allowed at outer level");
6535 -- [ Convention =>] convention_IDENTIFIER,
6536 -- [ Entity =>] local_NAME
6537 -- [, [External_Name =>] static_string_EXPRESSION ]
6538 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6540 when Pragma_Import =>
6541 Check_Ada_83_Warning;
6542 Check_At_Least_N_Arguments (2);
6543 Check_At_Most_N_Arguments (4);
6544 Process_Import_Or_Interface;
6546 ----------------------
6547 -- Import_Exception --
6548 ----------------------
6550 -- pragma Import_Exception (
6551 -- [Internal =>] LOCAL_NAME,
6552 -- [, [External =>] EXTERNAL_SYMBOL,]
6553 -- [, [Form =>] Ada | VMS]
6554 -- [, [Code =>] static_integer_EXPRESSION]);
6556 when Pragma_Import_Exception => Import_Exception : declare
6557 Args : Args_List (1 .. 4);
6558 Names : constant Name_List (1 .. 4) := (
6564 Internal : Node_Id renames Args (1);
6565 External : Node_Id renames Args (2);
6566 Form : Node_Id renames Args (3);
6567 Code : Node_Id renames Args (4);
6570 Gather_Associations (Names, Args);
6572 if Present (External) and then Present (Code) then
6574 ("cannot give both External and Code options for pragma%");
6577 Process_Extended_Import_Export_Exception_Pragma (
6578 Arg_Internal => Internal,
6579 Arg_External => External,
6583 if not Is_VMS_Exception (Entity (Internal)) then
6584 Set_Imported (Entity (Internal));
6586 end Import_Exception;
6588 ---------------------
6589 -- Import_Function --
6590 ---------------------
6592 -- pragma Import_Function (
6593 -- [Internal =>] LOCAL_NAME,
6594 -- [, [External =>] EXTERNAL_SYMBOL]
6595 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6596 -- [, [Result_Type =>] SUBTYPE_MARK]
6597 -- [, [Mechanism =>] MECHANISM]
6598 -- [, [Result_Mechanism =>] MECHANISM_NAME]
6599 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6601 -- EXTERNAL_SYMBOL ::=
6603 -- | static_string_EXPRESSION
6605 -- PARAMETER_TYPES ::=
6607 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6609 -- TYPE_DESIGNATOR ::=
6611 -- | subtype_Name ' Access
6615 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6617 -- MECHANISM_ASSOCIATION ::=
6618 -- [formal_parameter_NAME =>] MECHANISM_NAME
6620 -- MECHANISM_NAME ::=
6623 -- | Descriptor [([Class =>] CLASS_NAME)]
6625 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6627 when Pragma_Import_Function => Import_Function : declare
6628 Args : Args_List (1 .. 7);
6629 Names : constant Name_List (1 .. 7) := (
6632 Name_Parameter_Types,
6635 Name_Result_Mechanism,
6636 Name_First_Optional_Parameter);
6638 Internal : Node_Id renames Args (1);
6639 External : Node_Id renames Args (2);
6640 Parameter_Types : Node_Id renames Args (3);
6641 Result_Type : Node_Id renames Args (4);
6642 Mechanism : Node_Id renames Args (5);
6643 Result_Mechanism : Node_Id renames Args (6);
6644 First_Optional_Parameter : Node_Id renames Args (7);
6648 Gather_Associations (Names, Args);
6649 Process_Extended_Import_Export_Subprogram_Pragma (
6650 Arg_Internal => Internal,
6651 Arg_External => External,
6652 Arg_Parameter_Types => Parameter_Types,
6653 Arg_Result_Type => Result_Type,
6654 Arg_Mechanism => Mechanism,
6655 Arg_Result_Mechanism => Result_Mechanism,
6656 Arg_First_Optional_Parameter => First_Optional_Parameter);
6657 end Import_Function;
6663 -- pragma Import_Object (
6664 -- [Internal =>] LOCAL_NAME,
6665 -- [, [External =>] EXTERNAL_SYMBOL]
6666 -- [, [Size =>] EXTERNAL_SYMBOL]);
6668 -- EXTERNAL_SYMBOL ::=
6670 -- | static_string_EXPRESSION
6672 when Pragma_Import_Object => Import_Object : declare
6673 Args : Args_List (1 .. 3);
6674 Names : constant Name_List (1 .. 3) := (
6679 Internal : Node_Id renames Args (1);
6680 External : Node_Id renames Args (2);
6681 Size : Node_Id renames Args (3);
6685 Gather_Associations (Names, Args);
6686 Process_Extended_Import_Export_Object_Pragma (
6687 Arg_Internal => Internal,
6688 Arg_External => External,
6692 ----------------------
6693 -- Import_Procedure --
6694 ----------------------
6696 -- pragma Import_Procedure (
6697 -- [Internal =>] LOCAL_NAME,
6698 -- [, [External =>] EXTERNAL_SYMBOL]
6699 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6700 -- [, [Mechanism =>] MECHANISM]
6701 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6703 -- EXTERNAL_SYMBOL ::=
6705 -- | static_string_EXPRESSION
6707 -- PARAMETER_TYPES ::=
6709 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6711 -- TYPE_DESIGNATOR ::=
6713 -- | subtype_Name ' Access
6717 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6719 -- MECHANISM_ASSOCIATION ::=
6720 -- [formal_parameter_NAME =>] MECHANISM_NAME
6722 -- MECHANISM_NAME ::=
6725 -- | Descriptor [([Class =>] CLASS_NAME)]
6727 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6729 when Pragma_Import_Procedure => Import_Procedure : declare
6730 Args : Args_List (1 .. 5);
6731 Names : constant Name_List (1 .. 5) := (
6734 Name_Parameter_Types,
6736 Name_First_Optional_Parameter);
6738 Internal : Node_Id renames Args (1);
6739 External : Node_Id renames Args (2);
6740 Parameter_Types : Node_Id renames Args (3);
6741 Mechanism : Node_Id renames Args (4);
6742 First_Optional_Parameter : Node_Id renames Args (5);
6746 Gather_Associations (Names, Args);
6747 Process_Extended_Import_Export_Subprogram_Pragma (
6748 Arg_Internal => Internal,
6749 Arg_External => External,
6750 Arg_Parameter_Types => Parameter_Types,
6751 Arg_Mechanism => Mechanism,
6752 Arg_First_Optional_Parameter => First_Optional_Parameter);
6753 end Import_Procedure;
6755 -----------------------------
6756 -- Import_Valued_Procedure --
6757 -----------------------------
6759 -- pragma Import_Valued_Procedure (
6760 -- [Internal =>] LOCAL_NAME,
6761 -- [, [External =>] EXTERNAL_SYMBOL]
6762 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6763 -- [, [Mechanism =>] MECHANISM]
6764 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
6766 -- EXTERNAL_SYMBOL ::=
6768 -- | static_string_EXPRESSION
6770 -- PARAMETER_TYPES ::=
6772 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6774 -- TYPE_DESIGNATOR ::=
6776 -- | subtype_Name ' Access
6780 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6782 -- MECHANISM_ASSOCIATION ::=
6783 -- [formal_parameter_NAME =>] MECHANISM_NAME
6785 -- MECHANISM_NAME ::=
6788 -- | Descriptor [([Class =>] CLASS_NAME)]
6790 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6792 when Pragma_Import_Valued_Procedure =>
6793 Import_Valued_Procedure : declare
6794 Args : Args_List (1 .. 5);
6795 Names : constant Name_List (1 .. 5) := (
6798 Name_Parameter_Types,
6800 Name_First_Optional_Parameter);
6802 Internal : Node_Id renames Args (1);
6803 External : Node_Id renames Args (2);
6804 Parameter_Types : Node_Id renames Args (3);
6805 Mechanism : Node_Id renames Args (4);
6806 First_Optional_Parameter : Node_Id renames Args (5);
6810 Gather_Associations (Names, Args);
6811 Process_Extended_Import_Export_Subprogram_Pragma (
6812 Arg_Internal => Internal,
6813 Arg_External => External,
6814 Arg_Parameter_Types => Parameter_Types,
6815 Arg_Mechanism => Mechanism,
6816 Arg_First_Optional_Parameter => First_Optional_Parameter);
6817 end Import_Valued_Procedure;
6819 ------------------------
6820 -- Initialize_Scalars --
6821 ------------------------
6823 -- pragma Initialize_Scalars;
6825 when Pragma_Initialize_Scalars =>
6827 Check_Arg_Count (0);
6828 Check_Valid_Configuration_Pragma;
6829 Check_Restriction (No_Initialize_Scalars, N);
6831 if not Restriction_Active (No_Initialize_Scalars) then
6832 Init_Or_Norm_Scalars := True;
6833 Initialize_Scalars := True;
6840 -- pragma Inline ( NAME {, NAME} );
6842 when Pragma_Inline =>
6844 -- Pragma is active if inlining option is active
6846 Process_Inline (Inline_Active);
6852 -- pragma Inline_Always ( NAME {, NAME} );
6854 when Pragma_Inline_Always =>
6855 Process_Inline (True);
6857 --------------------
6858 -- Inline_Generic --
6859 --------------------
6861 -- pragma Inline_Generic (NAME {, NAME});
6863 when Pragma_Inline_Generic =>
6864 Process_Generic_List;
6866 ----------------------
6867 -- Inspection_Point --
6868 ----------------------
6870 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
6872 when Pragma_Inspection_Point => Inspection_Point : declare
6877 if Arg_Count > 0 then
6880 Exp := Expression (Arg);
6883 if not Is_Entity_Name (Exp)
6884 or else not Is_Object (Entity (Exp))
6886 Error_Pragma_Arg ("object name required", Arg);
6893 end Inspection_Point;
6899 -- pragma Interface (
6900 -- convention_IDENTIFIER,
6903 when Pragma_Interface =>
6905 Check_Arg_Count (2);
6906 Check_No_Identifiers;
6907 Process_Import_Or_Interface;
6909 --------------------
6910 -- Interface_Name --
6911 --------------------
6913 -- pragma Interface_Name (
6914 -- [ Entity =>] local_NAME
6915 -- [,[External_Name =>] static_string_EXPRESSION ]
6916 -- [,[Link_Name =>] static_string_EXPRESSION ]);
6918 when Pragma_Interface_Name => Interface_Name : declare
6926 Check_At_Least_N_Arguments (2);
6927 Check_At_Most_N_Arguments (3);
6928 Id := Expression (Arg1);
6931 if not Is_Entity_Name (Id) then
6933 ("first argument for pragma% must be entity name", Arg1);
6934 elsif Etype (Id) = Any_Type then
6937 Def_Id := Entity (Id);
6940 -- Special DEC-compatible processing for the object case,
6941 -- forces object to be imported.
6943 if Ekind (Def_Id) = E_Variable then
6944 Kill_Size_Check_Code (Def_Id);
6945 Note_Possible_Modification (Id);
6947 -- Initialization is not allowed for imported variable
6949 if Present (Expression (Parent (Def_Id)))
6950 and then Comes_From_Source (Expression (Parent (Def_Id)))
6952 Error_Msg_Sloc := Sloc (Def_Id);
6954 ("no initialization allowed for declaration of& #",
6958 -- For compatibility, support VADS usage of providing both
6959 -- pragmas Interface and Interface_Name to obtain the effect
6960 -- of a single Import pragma.
6962 if Is_Imported (Def_Id)
6963 and then Present (First_Rep_Item (Def_Id))
6964 and then Nkind (First_Rep_Item (Def_Id)) = N_Pragma
6965 and then Chars (First_Rep_Item (Def_Id)) = Name_Interface
6969 Set_Imported (Def_Id);
6972 Set_Is_Public (Def_Id);
6973 Process_Interface_Name (Def_Id, Arg2, Arg3);
6976 -- Otherwise must be subprogram
6978 elsif not Is_Subprogram (Def_Id) then
6980 ("argument of pragma% is not subprogram", Arg1);
6983 Check_At_Most_N_Arguments (3);
6987 -- Loop through homonyms
6990 Def_Id := Get_Base_Subprogram (Hom_Id);
6992 if Is_Imported (Def_Id) then
6993 Process_Interface_Name (Def_Id, Arg2, Arg3);
6997 Hom_Id := Homonym (Hom_Id);
6999 exit when No (Hom_Id)
7000 or else Scope (Hom_Id) /= Current_Scope;
7005 ("argument of pragma% is not imported subprogram",
7011 -----------------------
7012 -- Interrupt_Handler --
7013 -----------------------
7015 -- pragma Interrupt_Handler (handler_NAME);
7017 when Pragma_Interrupt_Handler =>
7018 Check_Ada_83_Warning;
7019 Check_Arg_Count (1);
7020 Check_No_Identifiers;
7022 if No_Run_Time_Mode then
7023 Error_Msg_CRT ("Interrupt_Handler pragma", N);
7025 Check_Interrupt_Or_Attach_Handler;
7026 Process_Interrupt_Or_Attach_Handler;
7029 ------------------------
7030 -- Interrupt_Priority --
7031 ------------------------
7033 -- pragma Interrupt_Priority [(EXPRESSION)];
7035 when Pragma_Interrupt_Priority => Interrupt_Priority : declare
7036 P : constant Node_Id := Parent (N);
7040 Check_Ada_83_Warning;
7042 if Arg_Count /= 0 then
7043 Arg := Expression (Arg1);
7044 Check_Arg_Count (1);
7045 Check_No_Identifiers;
7047 -- The expression must be analyzed in the special manner
7048 -- described in "Handling of Default and Per-Object
7049 -- Expressions" in sem.ads.
7051 Analyze_Per_Use_Expression (Arg, RTE (RE_Interrupt_Priority));
7054 if Nkind (P) /= N_Task_Definition
7055 and then Nkind (P) /= N_Protected_Definition
7060 elsif Has_Priority_Pragma (P) then
7061 Error_Pragma ("duplicate pragma% not allowed");
7064 Set_Has_Priority_Pragma (P, True);
7065 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
7067 end Interrupt_Priority;
7069 ---------------------
7070 -- Interrupt_State --
7071 ---------------------
7073 -- pragma Interrupt_State (
7074 -- [Name =>] INTERRUPT_ID,
7075 -- [State =>] INTERRUPT_STATE);
7077 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
7078 -- INTERRUPT_STATE => System | Runtime | User
7080 -- Note: if the interrupt id is given as an identifier, then
7081 -- it must be one of the identifiers in Ada.Interrupts.Names.
7082 -- Otherwise it is given as a static integer expression which
7083 -- must be in the range of Ada.Interrupts.Interrupt_ID.
7085 when Pragma_Interrupt_State => Interrupt_State : declare
7087 Int_Id : constant Entity_Id := RTE (RE_Interrupt_ID);
7088 -- This is the entity Ada.Interrupts.Interrupt_ID;
7090 State_Type : Character;
7091 -- Set to 's'/'r'/'u' for System/Runtime/User
7094 -- Index to entry in Interrupt_States table
7097 -- Value of interrupt
7099 Arg1X : constant Node_Id := Get_Pragma_Arg (Arg1);
7100 -- The first argument to the pragma
7102 Int_Ent : Entity_Id;
7103 -- Interrupt entity in Ada.Interrupts.Names
7107 Check_Arg_Count (2);
7109 Check_Optional_Identifier (Arg1, Name_Name);
7110 Check_Optional_Identifier (Arg2, "state");
7111 Check_Arg_Is_Identifier (Arg2);
7113 -- First argument is identifier
7115 if Nkind (Arg1X) = N_Identifier then
7117 -- Search list of names in Ada.Interrupts.Names
7119 Int_Ent := First_Entity (RTE (RE_Names));
7121 if No (Int_Ent) then
7122 Error_Pragma_Arg ("invalid interrupt name", Arg1);
7124 elsif Chars (Int_Ent) = Chars (Arg1X) then
7125 Int_Val := Expr_Value (Constant_Value (Int_Ent));
7129 Next_Entity (Int_Ent);
7132 -- First argument is not an identifier, so it must be a
7133 -- static expression of type Ada.Interrupts.Interrupt_ID.
7136 Check_Arg_Is_Static_Expression (Arg1, Any_Integer);
7137 Int_Val := Expr_Value (Arg1X);
7139 if Int_Val < Expr_Value (Type_Low_Bound (Int_Id))
7141 Int_Val > Expr_Value (Type_High_Bound (Int_Id))
7144 ("value not in range of type " &
7145 """Ada.Interrupts.Interrupt_'I'D""", Arg1);
7151 case Chars (Get_Pragma_Arg (Arg2)) is
7152 when Name_Runtime => State_Type := 'r';
7153 when Name_System => State_Type := 's';
7154 when Name_User => State_Type := 'u';
7157 Error_Pragma_Arg ("invalid interrupt state", Arg2);
7160 -- Check if entry is already stored
7162 IST_Num := Interrupt_States.First;
7164 -- If entry not found, add it
7166 if IST_Num > Interrupt_States.Last then
7167 Interrupt_States.Append
7168 ((Interrupt_Number => UI_To_Int (Int_Val),
7169 Interrupt_State => State_Type,
7170 Pragma_Loc => Loc));
7173 -- Case of entry for the same entry
7175 elsif Int_Val = Interrupt_States.Table (IST_Num).
7178 -- If state matches, done, no need to make redundant entry
7181 State_Type = Interrupt_States.Table (IST_Num).
7184 -- Otherwise if state does not match, error
7187 Interrupt_States.Table (IST_Num).Pragma_Loc;
7189 ("state conflicts with that given at #", Arg2);
7193 IST_Num := IST_Num + 1;
7195 end Interrupt_State;
7197 ----------------------
7198 -- Java_Constructor --
7199 ----------------------
7201 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
7203 when Pragma_Java_Constructor => Java_Constructor : declare
7210 Check_Arg_Count (1);
7211 Check_Optional_Identifier (Arg1, Name_Entity);
7212 Check_Arg_Is_Local_Name (Arg1);
7214 Id := Expression (Arg1);
7215 Find_Program_Unit_Name (Id);
7217 -- If we did not find the name, we are done
7219 if Etype (Id) = Any_Type then
7223 Hom_Id := Entity (Id);
7225 -- Loop through homonyms
7228 Def_Id := Get_Base_Subprogram (Hom_Id);
7230 -- The constructor is required to be a function returning
7231 -- an access type whose designated type has convention Java.
7233 if Ekind (Def_Id) = E_Function
7234 and then Ekind (Etype (Def_Id)) in Access_Kind
7237 (Designated_Type (Etype (Def_Id))) = Convention_Java
7240 (Root_Type (Designated_Type (Etype (Def_Id))))
7243 Set_Is_Constructor (Def_Id);
7244 Set_Convention (Def_Id, Convention_Java);
7248 ("pragma% requires function returning a 'Java access type",
7252 Hom_Id := Homonym (Hom_Id);
7254 exit when No (Hom_Id) or else Scope (Hom_Id) /= Current_Scope;
7256 end Java_Constructor;
7258 ----------------------
7259 -- Java_Interface --
7260 ----------------------
7262 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
7264 when Pragma_Java_Interface => Java_Interface : declare
7270 Check_Arg_Count (1);
7271 Check_Optional_Identifier (Arg1, Name_Entity);
7272 Check_Arg_Is_Local_Name (Arg1);
7274 Arg := Expression (Arg1);
7277 if Etype (Arg) = Any_Type then
7281 if not Is_Entity_Name (Arg)
7282 or else not Is_Type (Entity (Arg))
7284 Error_Pragma_Arg ("pragma% requires a type mark", Arg1);
7287 Typ := Underlying_Type (Entity (Arg));
7289 -- For now we simply check some of the semantic constraints
7290 -- on the type. This currently leaves out some restrictions
7291 -- on interface types, namely that the parent type must be
7292 -- java.lang.Object.Typ and that all primitives of the type
7293 -- should be declared abstract. ???
7295 if not Is_Tagged_Type (Typ) or else not Is_Abstract (Typ) then
7296 Error_Pragma_Arg ("pragma% requires an abstract "
7297 & "tagged type", Arg1);
7299 elsif not Has_Discriminants (Typ)
7300 or else Ekind (Etype (First_Discriminant (Typ)))
7301 /= E_Anonymous_Access_Type
7303 not Is_Class_Wide_Type
7304 (Designated_Type (Etype (First_Discriminant (Typ))))
7307 ("type must have a class-wide access discriminant", Arg1);
7315 -- pragma Keep_Names ([On => ] local_NAME);
7317 when Pragma_Keep_Names => Keep_Names : declare
7322 Check_Arg_Count (1);
7323 Check_Optional_Identifier (Arg1, Name_On);
7324 Check_Arg_Is_Local_Name (Arg1);
7326 Arg := Expression (Arg1);
7329 if Etype (Arg) = Any_Type then
7333 if not Is_Entity_Name (Arg)
7334 or else Ekind (Entity (Arg)) /= E_Enumeration_Type
7337 ("pragma% requires a local enumeration type", Arg1);
7340 Set_Discard_Names (Entity (Arg), False);
7347 -- pragma License (RESTRICTED | UNRESRICTED | GPL | MODIFIED_GPL);
7349 when Pragma_License =>
7351 Check_Arg_Count (1);
7352 Check_No_Identifiers;
7353 Check_Valid_Configuration_Pragma;
7354 Check_Arg_Is_Identifier (Arg1);
7357 Sind : constant Source_File_Index :=
7358 Source_Index (Current_Sem_Unit);
7361 case Chars (Get_Pragma_Arg (Arg1)) is
7363 Set_License (Sind, GPL);
7365 when Name_Modified_GPL =>
7366 Set_License (Sind, Modified_GPL);
7368 when Name_Restricted =>
7369 Set_License (Sind, Restricted);
7371 when Name_Unrestricted =>
7372 Set_License (Sind, Unrestricted);
7375 Error_Pragma_Arg ("invalid license name", Arg1);
7383 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
7385 when Pragma_Link_With => Link_With : declare
7391 if Operating_Mode = Generate_Code
7392 and then In_Extended_Main_Source_Unit (N)
7394 Check_At_Least_N_Arguments (1);
7395 Check_No_Identifiers;
7396 Check_Is_In_Decl_Part_Or_Package_Spec;
7397 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
7401 while Present (Arg) loop
7402 Check_Arg_Is_Static_Expression (Arg, Standard_String);
7404 -- Store argument, converting sequences of spaces
7405 -- to a single null character (this is one of the
7406 -- differences in processing between Link_With
7407 -- and Linker_Options).
7410 C : constant Char_Code := Get_Char_Code (' ');
7411 S : constant String_Id :=
7412 Strval (Expr_Value_S (Expression (Arg)));
7413 L : constant Nat := String_Length (S);
7416 procedure Skip_Spaces;
7417 -- Advance F past any spaces
7419 procedure Skip_Spaces is
7421 while F <= L and then Get_String_Char (S, F) = C loop
7427 Skip_Spaces; -- skip leading spaces
7429 -- Loop through characters, changing any embedded
7430 -- sequence of spaces to a single null character
7431 -- (this is how Link_With/Linker_Options differ)
7434 if Get_String_Char (S, F) = C then
7437 Store_String_Char (ASCII.NUL);
7440 Store_String_Char (Get_String_Char (S, F));
7448 if Present (Arg) then
7449 Store_String_Char (ASCII.NUL);
7453 Store_Linker_Option_String (End_String);
7461 -- pragma Linker_Alias (
7462 -- [Entity =>] LOCAL_NAME
7463 -- [Alias =>] static_string_EXPRESSION);
7465 when Pragma_Linker_Alias =>
7467 Check_Arg_Count (2);
7468 Check_Optional_Identifier (Arg1, Name_Entity);
7469 Check_Optional_Identifier (Arg2, "alias");
7470 Check_Arg_Is_Library_Level_Local_Name (Arg1);
7471 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
7473 -- The only processing required is to link this item on to the
7474 -- list of rep items for the given entity. This is accomplished
7475 -- by the call to Rep_Item_Too_Late (when no error is detected
7476 -- and False is returned).
7478 if Rep_Item_Too_Late (Entity (Expression (Arg1)), N) then
7481 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
7484 --------------------
7485 -- Linker_Options --
7486 --------------------
7488 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
7490 when Pragma_Linker_Options => Linker_Options : declare
7494 Check_Ada_83_Warning;
7495 Check_No_Identifiers;
7496 Check_Arg_Count (1);
7497 Check_Is_In_Decl_Part_Or_Package_Spec;
7499 if Operating_Mode = Generate_Code
7500 and then In_Extended_Main_Source_Unit (N)
7502 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
7503 Start_String (Strval (Expr_Value_S (Expression (Arg1))));
7506 while Present (Arg) loop
7507 Check_Arg_Is_Static_Expression (Arg, Standard_String);
7508 Store_String_Char (ASCII.NUL);
7510 (Strval (Expr_Value_S (Expression (Arg))));
7514 Store_Linker_Option_String (End_String);
7518 --------------------
7519 -- Linker_Section --
7520 --------------------
7522 -- pragma Linker_Section (
7523 -- [Entity =>] LOCAL_NAME
7524 -- [Section =>] static_string_EXPRESSION);
7526 when Pragma_Linker_Section =>
7528 Check_Arg_Count (2);
7529 Check_Optional_Identifier (Arg1, Name_Entity);
7530 Check_Optional_Identifier (Arg2, Name_Section);
7531 Check_Arg_Is_Library_Level_Local_Name (Arg1);
7532 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
7534 -- The only processing required is to link this item on to the
7535 -- list of rep items for the given entity. This is accomplished
7536 -- by the call to Rep_Item_Too_Late (when no error is detected
7537 -- and False is returned).
7539 if Rep_Item_Too_Late (Entity (Expression (Arg1)), N) then
7542 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
7549 -- pragma List (On | Off)
7551 -- There is nothing to do here, since we did all the processing
7552 -- for this pragma in Par.Prag (so that it works properly even in
7553 -- syntax only mode)
7558 --------------------
7559 -- Locking_Policy --
7560 --------------------
7562 -- pragma Locking_Policy (policy_IDENTIFIER);
7564 when Pragma_Locking_Policy => declare
7568 Check_Ada_83_Warning;
7569 Check_Arg_Count (1);
7570 Check_No_Identifiers;
7571 Check_Arg_Is_Locking_Policy (Arg1);
7572 Check_Valid_Configuration_Pragma;
7573 Get_Name_String (Chars (Expression (Arg1)));
7574 LP := Fold_Upper (Name_Buffer (1));
7576 if Locking_Policy /= ' '
7577 and then Locking_Policy /= LP
7579 Error_Msg_Sloc := Locking_Policy_Sloc;
7580 Error_Pragma ("locking policy incompatible with policy#");
7582 -- Set new policy, but always preserve System_Location since
7583 -- we like the error message with the run time name.
7586 Locking_Policy := LP;
7588 if Locking_Policy_Sloc /= System_Location then
7589 Locking_Policy_Sloc := Loc;
7598 -- pragma Long_Float (D_Float | G_Float);
7600 when Pragma_Long_Float =>
7602 Check_Valid_Configuration_Pragma;
7603 Check_Arg_Count (1);
7604 Check_No_Identifier (Arg1);
7605 Check_Arg_Is_One_Of (Arg1, Name_D_Float, Name_G_Float);
7607 if not OpenVMS_On_Target then
7608 Error_Pragma ("?pragma% ignored (applies only to Open'V'M'S)");
7613 if Chars (Expression (Arg1)) = Name_D_Float then
7614 if Opt.Float_Format_Long = 'G' then
7615 Error_Pragma ("G_Float previously specified");
7618 Opt.Float_Format_Long := 'D';
7620 -- G_Float case (this is the default, does not need overriding)
7623 if Opt.Float_Format_Long = 'D' then
7624 Error_Pragma ("D_Float previously specified");
7627 Opt.Float_Format_Long := 'G';
7630 Set_Standard_Fpt_Formats;
7632 -----------------------
7633 -- Machine_Attribute --
7634 -----------------------
7636 -- pragma Machine_Attribute (
7637 -- [Entity =>] LOCAL_NAME,
7638 -- [Attribute_Name =>] static_string_EXPRESSION
7639 -- [,[Info =>] static_string_EXPRESSION] );
7641 when Pragma_Machine_Attribute => Machine_Attribute : declare
7647 if Arg_Count = 3 then
7648 Check_Optional_Identifier (Arg3, "info");
7649 Check_Arg_Is_Static_Expression (Arg3, Standard_String);
7651 Check_Arg_Count (2);
7654 Check_Arg_Is_Local_Name (Arg1);
7655 Check_Optional_Identifier (Arg2, "attribute_name");
7656 Check_Optional_Identifier (Arg1, Name_Entity);
7657 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
7658 Def_Id := Entity (Expression (Arg1));
7660 if Is_Access_Type (Def_Id) then
7661 Def_Id := Designated_Type (Def_Id);
7664 if Rep_Item_Too_Early (Def_Id, N) then
7668 Def_Id := Underlying_Type (Def_Id);
7670 -- The only processing required is to link this item on to the
7671 -- list of rep items for the given entity. This is accomplished
7672 -- by the call to Rep_Item_Too_Late (when no error is detected
7673 -- and False is returned).
7675 if Rep_Item_Too_Late (Def_Id, N) then
7678 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
7680 end Machine_Attribute;
7686 -- pragma Main_Storage
7687 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
7689 -- MAIN_STORAGE_OPTION ::=
7690 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
7691 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
7693 when Pragma_Main => Main : declare
7694 Args : Args_List (1 .. 3);
7695 Names : constant Name_List (1 .. 3) := (
7697 Name_Task_Stack_Size_Default,
7698 Name_Time_Slicing_Enabled);
7704 Gather_Associations (Names, Args);
7706 for J in 1 .. 2 loop
7707 if Present (Args (J)) then
7708 Check_Arg_Is_Static_Expression (Args (J), Any_Integer);
7712 if Present (Args (3)) then
7713 Check_Arg_Is_Static_Expression (Args (3), Standard_Boolean);
7717 while Present (Nod) loop
7718 if Nkind (Nod) = N_Pragma
7719 and then Chars (Nod) = Name_Main
7721 Error_Msg_Name_1 := Chars (N);
7722 Error_Msg_N ("duplicate pragma% not permitted", Nod);
7733 -- pragma Main_Storage
7734 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
7736 -- MAIN_STORAGE_OPTION ::=
7737 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
7738 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
7740 when Pragma_Main_Storage => Main_Storage : declare
7741 Args : Args_List (1 .. 2);
7742 Names : constant Name_List (1 .. 2) := (
7743 Name_Working_Storage,
7750 Gather_Associations (Names, Args);
7752 for J in 1 .. 2 loop
7753 if Present (Args (J)) then
7754 Check_Arg_Is_Static_Expression (Args (J), Any_Integer);
7758 Check_In_Main_Program;
7761 while Present (Nod) loop
7762 if Nkind (Nod) = N_Pragma
7763 and then Chars (Nod) = Name_Main_Storage
7765 Error_Msg_Name_1 := Chars (N);
7766 Error_Msg_N ("duplicate pragma% not permitted", Nod);
7777 -- pragma Memory_Size (NUMERIC_LITERAL)
7779 when Pragma_Memory_Size =>
7782 -- Memory size is simply ignored
7784 Check_No_Identifiers;
7785 Check_Arg_Count (1);
7786 Check_Arg_Is_Integer_Literal (Arg1);
7792 -- pragma No_Return (procedure_LOCAL_NAME);
7794 when Pragma_No_Return => No_Return : declare
7801 Check_Arg_Count (1);
7802 Check_No_Identifiers;
7803 Check_Arg_Is_Local_Name (Arg1);
7804 Id := Expression (Arg1);
7807 if not Is_Entity_Name (Id) then
7808 Error_Pragma_Arg ("entity name required", Arg1);
7811 if Etype (Id) = Any_Type then
7819 and then Scope (E) = Current_Scope
7821 if Ekind (E) = E_Procedure
7822 or else Ekind (E) = E_Generic_Procedure
7832 Error_Pragma ("no procedures found for pragma%");
7836 ------------------------
7837 -- No_Strict_Aliasing --
7838 ------------------------
7840 when Pragma_No_Strict_Aliasing => No_Strict_Alias : declare
7845 Check_At_Most_N_Arguments (1);
7847 if Arg_Count = 0 then
7848 Check_Valid_Configuration_Pragma;
7849 Opt.No_Strict_Aliasing := True;
7852 Check_Optional_Identifier (Arg2, Name_Entity);
7853 Check_Arg_Is_Local_Name (Arg1);
7854 E_Id := Entity (Expression (Arg1));
7856 if E_Id = Any_Type then
7858 elsif No (E_Id) or else not Is_Access_Type (E_Id) then
7859 Error_Pragma_Arg ("pragma% requires access type", Arg1);
7862 Set_No_Strict_Aliasing (Implementation_Base_Type (E_Id));
7864 end No_Strict_Alias;
7870 -- pragma Obsolescent [(static_string_EXPRESSION)];
7872 when Pragma_Obsolescent => Obsolescent : declare
7875 Check_At_Most_N_Arguments (1);
7876 Check_No_Identifiers;
7878 if Arg_Count = 1 then
7879 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
7883 or else (Nkind (Prev (N))) /= N_Subprogram_Declaration
7886 ("pragma% misplaced, must immediately " &
7887 "follow subprogram spec");
7895 -- pragma No_Run_Time
7897 -- Note: this pragma is retained for backwards compatibiltiy.
7898 -- See body of Rtsfind for full details on its handling.
7900 when Pragma_No_Run_Time =>
7902 Check_Valid_Configuration_Pragma;
7903 Check_Arg_Count (0);
7905 No_Run_Time_Mode := True;
7906 Configurable_Run_Time_Mode := True;
7909 Word32 : constant Boolean := Ttypes.System_Word_Size = 32;
7912 Duration_32_Bits_On_Target := True;
7916 Set_Restriction (No_Finalization, N);
7917 Set_Restriction (No_Exception_Handlers, N);
7918 Set_Restriction (Max_Tasks, N, 0);
7919 Set_Restriction (No_Tasking, N);
7921 -----------------------
7922 -- Normalize_Scalars --
7923 -----------------------
7925 -- pragma Normalize_Scalars;
7927 when Pragma_Normalize_Scalars =>
7928 Check_Ada_83_Warning;
7929 Check_Arg_Count (0);
7930 Check_Valid_Configuration_Pragma;
7931 Normalize_Scalars := True;
7932 Init_Or_Norm_Scalars := True;
7938 -- pragma Optimize (Time | Space);
7940 -- The actual check for optimize is done in Gigi. Note that this
7941 -- pragma does not actually change the optimization setting, it
7942 -- simply checks that it is consistent with the pragma.
7944 when Pragma_Optimize =>
7945 Check_No_Identifiers;
7946 Check_Arg_Count (1);
7947 Check_Arg_Is_One_Of (Arg1, Name_Time, Name_Space, Name_Off);
7949 -------------------------
7950 -- Optional_Overriding --
7951 -------------------------
7953 -- These pragmas are treated as part of the previous subprogram
7954 -- declaration, and analyzed immediately after it (see sem_ch6,
7955 -- Check_Overriding_Operation). If the pragma has not been analyzed
7956 -- yet, it appears in the wrong place.
7958 when Pragma_Optional_Overriding =>
7959 Error_Msg_N ("pragma must appear immediately after subprogram", N);
7965 when Pragma_Overriding =>
7966 Error_Msg_N ("pragma must appear immediately after subprogram", N);
7972 -- pragma Pack (first_subtype_LOCAL_NAME);
7974 when Pragma_Pack => Pack : declare
7975 Assoc : constant Node_Id := Arg1;
7980 Check_No_Identifiers;
7981 Check_Arg_Count (1);
7982 Check_Arg_Is_Local_Name (Arg1);
7984 Type_Id := Expression (Assoc);
7985 Find_Type (Type_Id);
7986 Typ := Entity (Type_Id);
7989 or else Rep_Item_Too_Early (Typ, N)
7993 Typ := Underlying_Type (Typ);
7996 if not Is_Array_Type (Typ) and then not Is_Record_Type (Typ) then
7997 Error_Pragma ("pragma% must specify array or record type");
8000 Check_First_Subtype (Arg1);
8002 if Has_Pragma_Pack (Typ) then
8003 Error_Pragma ("duplicate pragma%, only one allowed");
8005 -- Array type. We set the Has_Pragma_Pack flag, and Is_Packed,
8006 -- but not Has_Non_Standard_Rep, because we don't actually know
8007 -- till freeze time if the array can have packed representation.
8008 -- That's because in the general case we do not know enough about
8009 -- the component type until it in turn is frozen, which certainly
8010 -- happens before the array type is frozen, but not necessarily
8011 -- till that point (i.e. right now it may be unfrozen).
8013 elsif Is_Array_Type (Typ) then
8014 if Has_Aliased_Components (Base_Type (Typ)) then
8016 ("pragma% ignored, cannot pack aliased components?");
8018 elsif Has_Atomic_Components (Typ)
8019 or else Is_Atomic (Component_Type (Typ))
8022 ("?pragma% ignored, cannot pack atomic components");
8024 elsif not Rep_Item_Too_Late (Typ, N) then
8025 Set_Is_Packed (Base_Type (Typ));
8026 Set_Has_Pragma_Pack (Base_Type (Typ));
8027 Set_Has_Non_Standard_Rep (Base_Type (Typ));
8030 -- Record type. For record types, the pack is always effective
8032 else pragma Assert (Is_Record_Type (Typ));
8033 if not Rep_Item_Too_Late (Typ, N) then
8034 Set_Has_Pragma_Pack (Base_Type (Typ));
8035 Set_Is_Packed (Base_Type (Typ));
8036 Set_Has_Non_Standard_Rep (Base_Type (Typ));
8047 -- There is nothing to do here, since we did all the processing
8048 -- for this pragma in Par.Prag (so that it works properly even in
8049 -- syntax only mode)
8058 -- pragma Passive [(PASSIVE_FORM)];
8060 -- PASSIVE_FORM ::= Semaphore | No
8062 when Pragma_Passive =>
8065 if Nkind (Parent (N)) /= N_Task_Definition then
8066 Error_Pragma ("pragma% must be within task definition");
8069 if Arg_Count /= 0 then
8070 Check_Arg_Count (1);
8071 Check_Arg_Is_One_Of (Arg1, Name_Semaphore, Name_No);
8078 -- pragma Polling (ON | OFF);
8080 when Pragma_Polling =>
8082 Check_Arg_Count (1);
8083 Check_No_Identifiers;
8084 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
8085 Polling_Required := (Chars (Expression (Arg1)) = Name_On);
8087 ---------------------
8088 -- Persistent_Data --
8089 ---------------------
8091 when Pragma_Persistent_Data => declare
8095 -- Register the pragma as applying to the compilation unit.
8096 -- Individual Persistent_Object pragmas for relevant objects
8097 -- are generated the end of the compilation.
8100 Check_Valid_Configuration_Pragma;
8101 Check_Arg_Count (0);
8102 Ent := Find_Lib_Unit_Name;
8103 Set_Is_Preelaborated (Ent);
8106 -----------------------
8107 -- Persistent_Object --
8108 -----------------------
8110 when Pragma_Persistent_Object => declare
8118 Check_Arg_Count (1);
8119 Check_Arg_Is_Library_Level_Local_Name (Arg1);
8121 if not Is_Entity_Name (Expression (Arg1))
8123 (Ekind (Entity (Expression (Arg1))) /= E_Variable
8124 and then Ekind (Entity (Expression (Arg1))) /= E_Constant)
8126 Error_Pragma_Arg ("pragma only applies to objects", Arg1);
8129 Ent := Entity (Expression (Arg1));
8130 Decl := Parent (Ent);
8132 if Nkind (Decl) /= N_Object_Declaration then
8136 -- Placement of the object depends on whether there is
8137 -- an initial value or none. If the No_Initialization flag
8138 -- is set, the initialization has been transformed into
8139 -- assignments, which is disallowed elaboration code.
8141 if No_Initialization (Decl) then
8143 ("initialization for persistent object"
8144 & "must be static expression", Decl);
8148 if No (Expression (Decl)) then
8150 Store_String_Chars ("section ("".persistent.bss"")");
8154 if not Is_OK_Static_Expression (Expression (Decl)) then
8155 Flag_Non_Static_Expr
8156 ("initialization for persistent object"
8157 & "must be static expression!", Expression (Decl));
8162 Store_String_Chars ("section ("".persistent.data"")");
8169 Name_Machine_Attribute,
8171 (Make_Pragma_Argument_Association
8172 (Sloc => Sloc (Arg1),
8173 Expression => New_Occurrence_Of (Ent, Sloc (Ent))),
8174 Make_Pragma_Argument_Association
8175 (Sloc => Sloc (Arg1),
8178 (Sloc => Sloc (Arg1),
8181 Insert_After (N, MA);
8183 Set_Has_Gigi_Rep_Item (Ent);
8190 -- pragma Preelaborate [(library_unit_NAME)];
8192 -- Set the flag Is_Preelaborated of program unit name entity
8194 when Pragma_Preelaborate => Preelaborate : declare
8195 Pa : constant Node_Id := Parent (N);
8196 Pk : constant Node_Kind := Nkind (Pa);
8200 Check_Ada_83_Warning;
8201 Check_Valid_Library_Unit_Pragma;
8203 if Nkind (N) = N_Null_Statement then
8207 Ent := Find_Lib_Unit_Name;
8209 -- This filters out pragmas inside generic parent then
8210 -- show up inside instantiation
8213 and then not (Pk = N_Package_Specification
8214 and then Present (Generic_Parent (Pa)))
8216 if not Debug_Flag_U then
8217 Set_Is_Preelaborated (Ent);
8218 Set_Suppress_Elaboration_Warnings (Ent);
8227 -- pragma Priority (EXPRESSION);
8229 when Pragma_Priority => Priority : declare
8230 P : constant Node_Id := Parent (N);
8234 Check_No_Identifiers;
8235 Check_Arg_Count (1);
8239 if Nkind (P) = N_Subprogram_Body then
8240 Check_In_Main_Program;
8242 Arg := Expression (Arg1);
8243 Analyze_And_Resolve (Arg, Standard_Integer);
8247 if not Is_Static_Expression (Arg) then
8248 Flag_Non_Static_Expr
8249 ("main subprogram priority is not static!", Arg);
8252 -- If constraint error, then we already signalled an error
8254 elsif Raises_Constraint_Error (Arg) then
8257 -- Otherwise check in range
8261 Val : constant Uint := Expr_Value (Arg);
8265 or else Val > Expr_Value (Expression
8266 (Parent (RTE (RE_Max_Priority))))
8269 ("main subprogram priority is out of range", Arg1);
8275 (Current_Sem_Unit, UI_To_Int (Expr_Value (Arg)));
8277 -- Task or Protected, must be of type Integer
8279 elsif Nkind (P) = N_Protected_Definition
8281 Nkind (P) = N_Task_Definition
8283 Arg := Expression (Arg1);
8285 -- The expression must be analyzed in the special manner
8286 -- described in "Handling of Default and Per-Object
8287 -- Expressions" in sem.ads.
8289 Analyze_Per_Use_Expression (Arg, Standard_Integer);
8291 if not Is_Static_Expression (Arg) then
8292 Check_Restriction (Static_Priorities, Arg);
8295 -- Anything else is incorrect
8301 if Has_Priority_Pragma (P) then
8302 Error_Pragma ("duplicate pragma% not allowed");
8304 Set_Has_Priority_Pragma (P, True);
8306 if Nkind (P) = N_Protected_Definition
8308 Nkind (P) = N_Task_Definition
8310 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
8311 -- exp_ch9 should use this ???
8320 -- pragma Profile (profile_IDENTIFIER);
8322 -- profile_IDENTIFIER => Protected | Ravenscar
8324 when Pragma_Profile =>
8325 Check_Arg_Count (1);
8326 Check_Valid_Configuration_Pragma;
8327 Check_No_Identifiers;
8330 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
8332 if Chars (Argx) = Name_Ravenscar then
8333 Set_Ravenscar_Profile (N);
8335 elsif Chars (Argx) = Name_Restricted then
8336 Set_Profile_Restrictions (Restricted, N, Warn => False);
8338 Error_Pragma_Arg ("& is not a valid profile", Argx);
8342 ----------------------
8343 -- Profile_Warnings --
8344 ----------------------
8346 -- pragma Profile_Warnings (profile_IDENTIFIER);
8348 -- profile_IDENTIFIER => Protected | Ravenscar
8350 when Pragma_Profile_Warnings =>
8352 Check_Arg_Count (1);
8353 Check_Valid_Configuration_Pragma;
8354 Check_No_Identifiers;
8357 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
8359 if Chars (Argx) = Name_Ravenscar then
8360 Set_Profile_Restrictions (Ravenscar, N, Warn => True);
8362 elsif Chars (Argx) = Name_Restricted then
8363 Set_Profile_Restrictions (Restricted, N, Warn => True);
8365 Error_Pragma_Arg ("& is not a valid profile", Argx);
8369 --------------------------
8370 -- Propagate_Exceptions --
8371 --------------------------
8373 -- pragma Propagate_Exceptions;
8375 when Pragma_Propagate_Exceptions =>
8377 Check_Arg_Count (0);
8379 if In_Extended_Main_Source_Unit (N) then
8380 Propagate_Exceptions := True;
8387 -- pragma Psect_Object (
8388 -- [Internal =>] LOCAL_NAME,
8389 -- [, [External =>] EXTERNAL_SYMBOL]
8390 -- [, [Size =>] EXTERNAL_SYMBOL]);
8392 when Pragma_Psect_Object | Pragma_Common_Object =>
8393 Psect_Object : declare
8394 Args : Args_List (1 .. 3);
8395 Names : constant Name_List (1 .. 3) := (
8400 Internal : Node_Id renames Args (1);
8401 External : Node_Id renames Args (2);
8402 Size : Node_Id renames Args (3);
8404 R_Internal : Node_Id;
8405 R_External : Node_Id;
8412 procedure Check_Too_Long (Arg : Node_Id);
8413 -- Posts message if the argument is an identifier with more
8414 -- than 31 characters, or a string literal with more than
8415 -- 31 characters, and we are operating under VMS
8417 --------------------
8418 -- Check_Too_Long --
8419 --------------------
8421 procedure Check_Too_Long (Arg : Node_Id) is
8422 X : constant Node_Id := Original_Node (Arg);
8425 if Nkind (X) /= N_String_Literal
8427 Nkind (X) /= N_Identifier
8430 ("inappropriate argument for pragma %", Arg);
8433 if OpenVMS_On_Target then
8434 if (Nkind (X) = N_String_Literal
8435 and then String_Length (Strval (X)) > 31)
8437 (Nkind (X) = N_Identifier
8438 and then Length_Of_Name (Chars (X)) > 31)
8441 ("argument for pragma % is longer than 31 characters",
8447 -- Start of processing for Common_Object/Psect_Object
8451 Gather_Associations (Names, Args);
8452 Process_Extended_Import_Export_Internal_Arg (Internal);
8454 R_Internal := Relocate_Node (Internal);
8456 Def_Id := Entity (R_Internal);
8458 if Ekind (Def_Id) /= E_Constant
8459 and then Ekind (Def_Id) /= E_Variable
8462 ("pragma% must designate an object", Internal);
8465 Check_Too_Long (R_Internal);
8467 if Is_Imported (Def_Id) or else Is_Exported (Def_Id) then
8469 ("cannot use pragma% for imported/exported object",
8473 if Is_Concurrent_Type (Etype (R_Internal)) then
8475 ("cannot specify pragma % for task/protected object",
8479 if Is_Psected (Def_Id) then
8480 Error_Msg_N ("?duplicate Psect_Object pragma", N);
8482 Set_Is_Psected (Def_Id);
8485 if Ekind (Def_Id) = E_Constant then
8487 ("cannot specify pragma % for a constant", R_Internal);
8490 if Is_Record_Type (Etype (R_Internal)) then
8496 Ent := First_Entity (Etype (R_Internal));
8497 while Present (Ent) loop
8498 Decl := Declaration_Node (Ent);
8500 if Ekind (Ent) = E_Component
8501 and then Nkind (Decl) = N_Component_Declaration
8502 and then Present (Expression (Decl))
8503 and then Warn_On_Export_Import
8506 ("?object for pragma % has defaults", R_Internal);
8516 if Present (Size) then
8517 Check_Too_Long (Size);
8520 -- Make Psect case-insensitive.
8522 if Present (External) then
8523 Check_Too_Long (External);
8525 if Nkind (External) = N_String_Literal then
8526 String_To_Name_Buffer (Strval (External));
8528 Get_Name_String (Chars (External));
8533 Store_String_Chars (Name_Buffer (1 .. Name_Len));
8535 R_External := Make_String_Literal
8536 (Sloc => Sloc (External), Strval => Str);
8538 Get_Name_String (Chars (Internal));
8541 Store_String_Chars (Name_Buffer (1 .. Name_Len));
8543 R_External := Make_String_Literal
8544 (Sloc => Sloc (Internal), Strval => Str);
8547 -- Transform into pragma Linker_Section, add attributes to
8548 -- match what DEC Ada does. Ignore size for now?
8553 Name_Linker_Section,
8555 (Make_Pragma_Argument_Association
8556 (Sloc => Sloc (R_Internal),
8557 Expression => R_Internal),
8558 Make_Pragma_Argument_Association
8559 (Sloc => Sloc (R_External),
8560 Expression => R_External))));
8564 -- Add Machine_Attribute of "overlaid", so the section overlays
8565 -- other sections of the same name.
8568 Store_String_Chars ("overlaid");
8574 Name_Machine_Attribute,
8576 (Make_Pragma_Argument_Association
8577 (Sloc => Sloc (R_Internal),
8578 Expression => R_Internal),
8579 Make_Pragma_Argument_Association
8580 (Sloc => Sloc (R_External),
8583 (Sloc => Sloc (R_External),
8587 -- Add Machine_Attribute of "global", so the section is visible
8591 Store_String_Chars ("global");
8597 Name_Machine_Attribute,
8599 (Make_Pragma_Argument_Association
8600 (Sloc => Sloc (R_Internal),
8601 Expression => R_Internal),
8603 Make_Pragma_Argument_Association
8604 (Sloc => Sloc (R_External),
8607 (Sloc => Sloc (R_External),
8611 -- Add Machine_Attribute of "initialize", so the section is
8615 Store_String_Chars ("initialize");
8621 Name_Machine_Attribute,
8623 (Make_Pragma_Argument_Association
8624 (Sloc => Sloc (R_Internal),
8625 Expression => R_Internal),
8627 Make_Pragma_Argument_Association
8628 (Sloc => Sloc (R_External),
8631 (Sloc => Sloc (R_External),
8640 -- pragma Pure [(library_unit_NAME)];
8642 when Pragma_Pure => Pure : declare
8645 Check_Ada_83_Warning;
8646 Check_Valid_Library_Unit_Pragma;
8648 if Nkind (N) = N_Null_Statement then
8652 Ent := Find_Lib_Unit_Name;
8654 Set_Suppress_Elaboration_Warnings (Ent);
8661 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
8663 when Pragma_Pure_Function => Pure_Function : declare
8667 Effective : Boolean := False;
8671 Check_Arg_Count (1);
8672 Check_Optional_Identifier (Arg1, Name_Entity);
8673 Check_Arg_Is_Local_Name (Arg1);
8674 E_Id := Expression (Arg1);
8676 if Error_Posted (E_Id) then
8680 -- Loop through homonyms (overloadings) of referenced entity
8686 Def_Id := Get_Base_Subprogram (E);
8688 if Ekind (Def_Id) /= E_Function
8689 and then Ekind (Def_Id) /= E_Generic_Function
8690 and then Ekind (Def_Id) /= E_Operator
8693 ("pragma% requires a function name", Arg1);
8696 Set_Is_Pure (Def_Id);
8698 if not Has_Pragma_Pure_Function (Def_Id) then
8699 Set_Has_Pragma_Pure_Function (Def_Id);
8704 exit when No (E) or else Scope (E) /= Current_Scope;
8708 and then Warn_On_Redundant_Constructs
8710 Error_Msg_NE ("pragma Pure_Function on& is redundant?",
8716 --------------------
8717 -- Queuing_Policy --
8718 --------------------
8720 -- pragma Queuing_Policy (policy_IDENTIFIER);
8722 when Pragma_Queuing_Policy => declare
8726 Check_Ada_83_Warning;
8727 Check_Arg_Count (1);
8728 Check_No_Identifiers;
8729 Check_Arg_Is_Queuing_Policy (Arg1);
8730 Check_Valid_Configuration_Pragma;
8731 Get_Name_String (Chars (Expression (Arg1)));
8732 QP := Fold_Upper (Name_Buffer (1));
8734 if Queuing_Policy /= ' '
8735 and then Queuing_Policy /= QP
8737 Error_Msg_Sloc := Queuing_Policy_Sloc;
8738 Error_Pragma ("queuing policy incompatible with policy#");
8740 -- Set new policy, but always preserve System_Location since
8741 -- we like the error message with the run time name.
8744 Queuing_Policy := QP;
8746 if Queuing_Policy_Sloc /= System_Location then
8747 Queuing_Policy_Sloc := Loc;
8752 ---------------------------
8753 -- Remote_Call_Interface --
8754 ---------------------------
8756 -- pragma Remote_Call_Interface [(library_unit_NAME)];
8758 when Pragma_Remote_Call_Interface => Remote_Call_Interface : declare
8759 Cunit_Node : Node_Id;
8760 Cunit_Ent : Entity_Id;
8764 Check_Ada_83_Warning;
8765 Check_Valid_Library_Unit_Pragma;
8767 if Nkind (N) = N_Null_Statement then
8771 Cunit_Node := Cunit (Current_Sem_Unit);
8772 K := Nkind (Unit (Cunit_Node));
8773 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
8775 if K = N_Package_Declaration
8776 or else K = N_Generic_Package_Declaration
8777 or else K = N_Subprogram_Declaration
8778 or else K = N_Generic_Subprogram_Declaration
8779 or else (K = N_Subprogram_Body
8780 and then Acts_As_Spec (Unit (Cunit_Node)))
8785 "pragma% must apply to package or subprogram declaration");
8788 Set_Is_Remote_Call_Interface (Cunit_Ent);
8789 end Remote_Call_Interface;
8795 -- pragma Remote_Types [(library_unit_NAME)];
8797 when Pragma_Remote_Types => Remote_Types : declare
8798 Cunit_Node : Node_Id;
8799 Cunit_Ent : Entity_Id;
8802 Check_Ada_83_Warning;
8803 Check_Valid_Library_Unit_Pragma;
8805 if Nkind (N) = N_Null_Statement then
8809 Cunit_Node := Cunit (Current_Sem_Unit);
8810 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
8812 if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration
8814 Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration
8817 "pragma% can only apply to a package declaration");
8820 Set_Is_Remote_Types (Cunit_Ent);
8827 -- pragma Ravenscar;
8829 when Pragma_Ravenscar =>
8831 Check_Arg_Count (0);
8832 Check_Valid_Configuration_Pragma;
8833 Set_Ravenscar_Profile (N);
8835 if Warn_On_Obsolescent_Feature then
8837 ("pragma Ravenscar is an obsolescent feature?", N);
8839 ("|use pragma Profile (Ravenscar) instead", N);
8842 -------------------------
8843 -- Restricted_Run_Time --
8844 -------------------------
8846 -- pragma Restricted_Run_Time;
8848 when Pragma_Restricted_Run_Time =>
8850 Check_Arg_Count (0);
8851 Check_Valid_Configuration_Pragma;
8852 Set_Profile_Restrictions (Restricted, N, Warn => False);
8854 if Warn_On_Obsolescent_Feature then
8856 ("pragma Restricted_Run_Time is an obsolescent feature?", N);
8858 ("|use pragma Profile (Restricted) instead", N);
8865 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
8868 -- restriction_IDENTIFIER
8869 -- | restriction_parameter_IDENTIFIER => EXPRESSION
8871 when Pragma_Restrictions =>
8872 Process_Restrictions_Or_Restriction_Warnings;
8874 --------------------------
8875 -- Restriction_Warnings --
8876 --------------------------
8878 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
8881 -- restriction_IDENTIFIER
8882 -- | restriction_parameter_IDENTIFIER => EXPRESSION
8884 when Pragma_Restriction_Warnings =>
8885 Process_Restrictions_Or_Restriction_Warnings;
8891 -- pragma Reviewable;
8893 when Pragma_Reviewable =>
8894 Check_Ada_83_Warning;
8895 Check_Arg_Count (0);
8901 -- pragma Share_Generic (NAME {, NAME});
8903 when Pragma_Share_Generic =>
8905 Process_Generic_List;
8911 -- pragma Shared (LOCAL_NAME);
8913 when Pragma_Shared =>
8915 Process_Atomic_Shared_Volatile;
8917 --------------------
8918 -- Shared_Passive --
8919 --------------------
8921 -- pragma Shared_Passive [(library_unit_NAME)];
8923 -- Set the flag Is_Shared_Passive of program unit name entity
8925 when Pragma_Shared_Passive => Shared_Passive : declare
8926 Cunit_Node : Node_Id;
8927 Cunit_Ent : Entity_Id;
8930 Check_Ada_83_Warning;
8931 Check_Valid_Library_Unit_Pragma;
8933 if Nkind (N) = N_Null_Statement then
8937 Cunit_Node := Cunit (Current_Sem_Unit);
8938 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
8940 if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration
8942 Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration
8945 "pragma% can only apply to a package declaration");
8948 Set_Is_Shared_Passive (Cunit_Ent);
8951 ----------------------
8952 -- Source_File_Name --
8953 ----------------------
8955 -- There are five forms for this pragma:
8957 -- pragma Source_File_Name (
8958 -- [UNIT_NAME =>] unit_NAME,
8959 -- BODY_FILE_NAME => STRING_LITERAL
8960 -- [, [INDEX =>] INTEGER_LITERAL]);
8962 -- pragma Source_File_Name (
8963 -- [UNIT_NAME =>] unit_NAME,
8964 -- SPEC_FILE_NAME => STRING_LITERAL
8965 -- [, [INDEX =>] INTEGER_LITERAL]);
8967 -- pragma Source_File_Name (
8968 -- BODY_FILE_NAME => STRING_LITERAL
8969 -- [, DOT_REPLACEMENT => STRING_LITERAL]
8970 -- [, CASING => CASING_SPEC]);
8972 -- pragma Source_File_Name (
8973 -- SPEC_FILE_NAME => STRING_LITERAL
8974 -- [, DOT_REPLACEMENT => STRING_LITERAL]
8975 -- [, CASING => CASING_SPEC]);
8977 -- pragma Source_File_Name (
8978 -- SUBUNIT_FILE_NAME => STRING_LITERAL
8979 -- [, DOT_REPLACEMENT => STRING_LITERAL]
8980 -- [, CASING => CASING_SPEC]);
8982 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
8984 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
8985 -- Source_File_Name (SFN), however their usage is exclusive:
8986 -- SFN can only be used when no project file is used, while
8987 -- SFNP can only be used when a project file is used.
8989 -- No processing here. Processing was completed during parsing,
8990 -- since we need to have file names set as early as possible.
8991 -- Units are loaded well before semantic processing starts.
8993 -- The only processing we defer to this point is the check
8994 -- for correct placement.
8996 when Pragma_Source_File_Name =>
8998 Check_Valid_Configuration_Pragma;
9000 ------------------------------
9001 -- Source_File_Name_Project --
9002 ------------------------------
9004 -- See Source_File_Name for syntax
9006 -- No processing here. Processing was completed during parsing,
9007 -- since we need to have file names set as early as possible.
9008 -- Units are loaded well before semantic processing starts.
9010 -- The only processing we defer to this point is the check
9011 -- for correct placement.
9013 when Pragma_Source_File_Name_Project =>
9015 Check_Valid_Configuration_Pragma;
9017 -- Check that a pragma Source_File_Name_Project is used only
9018 -- in a configuration pragmas file.
9020 -- Pragmas Source_File_Name_Project should only be generated
9021 -- by the Project Manager in configuration pragmas files.
9023 -- This is really an ugly test. It seems to depend on some
9024 -- accidental and undocumented property. At the very least
9025 -- it needs to be documented, but it would be better to have
9026 -- a clean way of testing if we are in a configuration file???
9028 if Present (Parent (N)) then
9030 ("pragma% can only appear in a configuration pragmas file");
9033 ----------------------
9034 -- Source_Reference --
9035 ----------------------
9037 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
9039 -- Nothing to do, all processing completed in Par.Prag, since we
9040 -- need the information for possible parser messages that are output
9042 when Pragma_Source_Reference =>
9049 -- pragma Storage_Size (EXPRESSION);
9051 when Pragma_Storage_Size => Storage_Size : declare
9052 P : constant Node_Id := Parent (N);
9056 Check_No_Identifiers;
9057 Check_Arg_Count (1);
9059 -- The expression must be analyzed in the special manner
9060 -- described in "Handling of Default Expressions" in sem.ads.
9062 -- Set In_Default_Expression for per-object case ???
9064 Arg := Expression (Arg1);
9065 Analyze_Per_Use_Expression (Arg, Any_Integer);
9067 if not Is_Static_Expression (Arg) then
9068 Check_Restriction (Static_Storage_Size, Arg);
9071 if Nkind (P) /= N_Task_Definition then
9076 if Has_Storage_Size_Pragma (P) then
9077 Error_Pragma ("duplicate pragma% not allowed");
9079 Set_Has_Storage_Size_Pragma (P, True);
9082 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
9083 -- ??? exp_ch9 should use this!
9091 -- pragma Storage_Unit (NUMERIC_LITERAL);
9093 -- Only permitted argument is System'Storage_Unit value
9095 when Pragma_Storage_Unit =>
9096 Check_No_Identifiers;
9097 Check_Arg_Count (1);
9098 Check_Arg_Is_Integer_Literal (Arg1);
9100 if Intval (Expression (Arg1)) /=
9101 UI_From_Int (Ttypes.System_Storage_Unit)
9103 Error_Msg_Uint_1 := UI_From_Int (Ttypes.System_Storage_Unit);
9105 ("the only allowed argument for pragma% is ^", Arg1);
9108 --------------------
9109 -- Stream_Convert --
9110 --------------------
9112 -- pragma Stream_Convert (
9113 -- [Entity =>] type_LOCAL_NAME,
9114 -- [Read =>] function_NAME,
9115 -- [Write =>] function NAME);
9117 when Pragma_Stream_Convert => Stream_Convert : declare
9119 procedure Check_OK_Stream_Convert_Function (Arg : Node_Id);
9120 -- Check that the given argument is the name of a local
9121 -- function of one argument that is not overloaded earlier
9122 -- in the current local scope. A check is also made that the
9123 -- argument is a function with one parameter.
9125 --------------------------------------
9126 -- Check_OK_Stream_Convert_Function --
9127 --------------------------------------
9129 procedure Check_OK_Stream_Convert_Function (Arg : Node_Id) is
9133 Check_Arg_Is_Local_Name (Arg);
9134 Ent := Entity (Expression (Arg));
9136 if Has_Homonym (Ent) then
9138 ("argument for pragma% may not be overloaded", Arg);
9141 if Ekind (Ent) /= E_Function
9142 or else No (First_Formal (Ent))
9143 or else Present (Next_Formal (First_Formal (Ent)))
9146 ("argument for pragma% must be" &
9147 " function of one argument", Arg);
9149 end Check_OK_Stream_Convert_Function;
9151 -- Start of procecessing for Stream_Convert
9155 Check_Arg_Count (3);
9156 Check_Optional_Identifier (Arg1, Name_Entity);
9157 Check_Optional_Identifier (Arg2, Name_Read);
9158 Check_Optional_Identifier (Arg3, Name_Write);
9159 Check_Arg_Is_Local_Name (Arg1);
9160 Check_OK_Stream_Convert_Function (Arg2);
9161 Check_OK_Stream_Convert_Function (Arg3);
9164 Typ : constant Entity_Id :=
9165 Underlying_Type (Entity (Expression (Arg1)));
9166 Read : constant Entity_Id := Entity (Expression (Arg2));
9167 Write : constant Entity_Id := Entity (Expression (Arg3));
9170 if Etype (Typ) = Any_Type
9172 Etype (Read) = Any_Type
9174 Etype (Write) = Any_Type
9179 Check_First_Subtype (Arg1);
9181 if Rep_Item_Too_Early (Typ, N)
9183 Rep_Item_Too_Late (Typ, N)
9188 if Underlying_Type (Etype (Read)) /= Typ then
9190 ("incorrect return type for function&", Arg2);
9193 if Underlying_Type (Etype (First_Formal (Write))) /= Typ then
9195 ("incorrect parameter type for function&", Arg3);
9198 if Underlying_Type (Etype (First_Formal (Read))) /=
9199 Underlying_Type (Etype (Write))
9202 ("result type of & does not match Read parameter type",
9208 -------------------------
9209 -- Style_Checks (GNAT) --
9210 -------------------------
9212 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
9214 -- This is processed by the parser since some of the style
9215 -- checks take place during source scanning and parsing. This
9216 -- means that we don't need to issue error messages here.
9218 when Pragma_Style_Checks => Style_Checks : declare
9219 A : constant Node_Id := Expression (Arg1);
9225 Check_No_Identifiers;
9227 -- Two argument form
9229 if Arg_Count = 2 then
9230 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
9237 E_Id := Expression (Arg2);
9240 if not Is_Entity_Name (E_Id) then
9242 ("second argument of pragma% must be entity name",
9252 Set_Suppress_Style_Checks (E,
9253 (Chars (Expression (Arg1)) = Name_Off));
9254 exit when No (Homonym (E));
9260 -- One argument form
9263 Check_Arg_Count (1);
9265 if Nkind (A) = N_String_Literal then
9269 Slen : constant Natural := Natural (String_Length (S));
9270 Options : String (1 .. Slen);
9276 C := Get_String_Char (S, Int (J));
9277 exit when not In_Character_Range (C);
9278 Options (J) := Get_Character (C);
9281 Set_Style_Check_Options (Options);
9289 elsif Nkind (A) = N_Identifier then
9291 if Chars (A) = Name_All_Checks then
9292 Set_Default_Style_Check_Options;
9294 elsif Chars (A) = Name_On then
9295 Style_Check := True;
9297 elsif Chars (A) = Name_Off then
9298 Style_Check := False;
9309 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
9311 when Pragma_Subtitle =>
9313 Check_Arg_Count (1);
9314 Check_Optional_Identifier (Arg1, Name_Subtitle);
9315 Check_Arg_Is_String_Literal (Arg1);
9321 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
9323 when Pragma_Suppress =>
9324 Process_Suppress_Unsuppress (True);
9330 -- pragma Suppress_All;
9332 -- The only check made here is that the pragma appears in the
9333 -- proper place, i.e. following a compilation unit. If indeed
9334 -- it appears in this context, then the parser has already
9335 -- inserted an equivalent pragma Suppress (All_Checks) to get
9336 -- the required effect.
9338 when Pragma_Suppress_All =>
9340 Check_Arg_Count (0);
9342 if Nkind (Parent (N)) /= N_Compilation_Unit_Aux
9343 or else not Is_List_Member (N)
9344 or else List_Containing (N) /= Pragmas_After (Parent (N))
9347 ("misplaced pragma%, must follow compilation unit");
9350 -------------------------
9351 -- Suppress_Debug_Info --
9352 -------------------------
9354 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
9356 when Pragma_Suppress_Debug_Info =>
9358 Check_Arg_Count (1);
9359 Check_Arg_Is_Local_Name (Arg1);
9360 Check_Optional_Identifier (Arg1, Name_Entity);
9361 Set_Debug_Info_Off (Entity (Get_Pragma_Arg (Arg1)));
9363 ----------------------------------
9364 -- Suppress_Exception_Locations --
9365 ----------------------------------
9367 -- pragma Suppress_Exception_Locations;
9369 when Pragma_Suppress_Exception_Locations =>
9371 Check_Arg_Count (0);
9372 Check_Valid_Configuration_Pragma;
9373 Exception_Locations_Suppressed := True;
9375 -----------------------------
9376 -- Suppress_Initialization --
9377 -----------------------------
9379 -- pragma Suppress_Initialization ([Entity =>] type_Name);
9381 when Pragma_Suppress_Initialization => Suppress_Init : declare
9387 Check_Arg_Count (1);
9388 Check_Optional_Identifier (Arg1, Name_Entity);
9389 Check_Arg_Is_Local_Name (Arg1);
9391 E_Id := Expression (Arg1);
9393 if Etype (E_Id) = Any_Type then
9400 if Is_Incomplete_Or_Private_Type (E) then
9401 if No (Full_View (Base_Type (E))) then
9403 ("argument of pragma% cannot be an incomplete type",
9406 Set_Suppress_Init_Proc (Full_View (Base_Type (E)));
9409 Set_Suppress_Init_Proc (Base_Type (E));
9414 ("pragma% requires argument that is a type name", Arg1);
9422 -- pragma System_Name (DIRECT_NAME);
9424 -- Syntax check: one argument, which must be the identifier GNAT
9425 -- or the identifier GCC, no other identifiers are acceptable.
9427 when Pragma_System_Name =>
9428 Check_No_Identifiers;
9429 Check_Arg_Count (1);
9430 Check_Arg_Is_One_Of (Arg1, Name_Gcc, Name_Gnat);
9432 -----------------------------
9433 -- Task_Dispatching_Policy --
9434 -----------------------------
9436 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
9438 when Pragma_Task_Dispatching_Policy => declare
9442 Check_Ada_83_Warning;
9443 Check_Arg_Count (1);
9444 Check_No_Identifiers;
9445 Check_Arg_Is_Task_Dispatching_Policy (Arg1);
9446 Check_Valid_Configuration_Pragma;
9447 Get_Name_String (Chars (Expression (Arg1)));
9448 DP := Fold_Upper (Name_Buffer (1));
9450 if Task_Dispatching_Policy /= ' '
9451 and then Task_Dispatching_Policy /= DP
9453 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
9455 ("task dispatching policy incompatible with policy#");
9457 -- Set new policy, but always preserve System_Location since
9458 -- we like the error message with the run time name.
9461 Task_Dispatching_Policy := DP;
9463 if Task_Dispatching_Policy_Sloc /= System_Location then
9464 Task_Dispatching_Policy_Sloc := Loc;
9473 -- pragma Task_Info (EXPRESSION);
9475 when Pragma_Task_Info => Task_Info : declare
9476 P : constant Node_Id := Parent (N);
9481 if Nkind (P) /= N_Task_Definition then
9482 Error_Pragma ("pragma% must appear in task definition");
9485 Check_No_Identifiers;
9486 Check_Arg_Count (1);
9488 Analyze_And_Resolve (Expression (Arg1), RTE (RE_Task_Info_Type));
9490 if Etype (Expression (Arg1)) = Any_Type then
9494 if Has_Task_Info_Pragma (P) then
9495 Error_Pragma ("duplicate pragma% not allowed");
9497 Set_Has_Task_Info_Pragma (P, True);
9505 -- pragma Task_Name (string_EXPRESSION);
9507 when Pragma_Task_Name => Task_Name : declare
9508 -- pragma Priority (EXPRESSION);
9510 P : constant Node_Id := Parent (N);
9514 Check_No_Identifiers;
9515 Check_Arg_Count (1);
9517 Arg := Expression (Arg1);
9518 Analyze_And_Resolve (Arg, Standard_String);
9520 if Nkind (P) /= N_Task_Definition then
9524 if Has_Task_Name_Pragma (P) then
9525 Error_Pragma ("duplicate pragma% not allowed");
9527 Set_Has_Task_Name_Pragma (P, True);
9528 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
9536 -- pragma Task_Storage (
9537 -- [Task_Type =>] LOCAL_NAME,
9538 -- [Top_Guard =>] static_integer_EXPRESSION);
9540 when Pragma_Task_Storage => Task_Storage : declare
9541 Args : Args_List (1 .. 2);
9542 Names : constant Name_List (1 .. 2) := (
9546 Task_Type : Node_Id renames Args (1);
9547 Top_Guard : Node_Id renames Args (2);
9553 Gather_Associations (Names, Args);
9555 if No (Task_Type) then
9557 ("missing task_type argument for pragma%");
9560 Check_Arg_Is_Local_Name (Task_Type);
9562 Ent := Entity (Task_Type);
9564 if not Is_Task_Type (Ent) then
9566 ("argument for pragma% must be task type", Task_Type);
9569 if No (Top_Guard) then
9571 ("pragma% takes two arguments", Task_Type);
9573 Check_Arg_Is_Static_Expression (Top_Guard, Any_Integer);
9576 Check_First_Subtype (Task_Type);
9578 if Rep_Item_Too_Late (Ent, N) then
9587 -- pragma Thread_Body
9588 -- ( [Entity =>] LOCAL_NAME
9589 -- [,[Secondary_Stack_Size =>] static_integer_EXPRESSION]);
9591 when Pragma_Thread_Body => Thread_Body : declare
9598 Check_At_Least_N_Arguments (1);
9599 Check_At_Most_N_Arguments (2);
9600 Check_Optional_Identifier (Arg1, Name_Entity);
9601 Check_Arg_Is_Local_Name (Arg1);
9603 Id := Expression (Arg1);
9605 if not Is_Entity_Name (Id)
9606 or else not Is_Subprogram (Entity (Id))
9608 Error_Pragma_Arg ("subprogram name required", Arg1);
9613 -- Go to renamed subprogram if present, since Thread_Body applies
9614 -- to the actual renamed entity, not to the renaming entity.
9616 if Present (Alias (E))
9617 and then Nkind (Parent (Declaration_Node (E))) =
9618 N_Subprogram_Renaming_Declaration
9623 -- Various error checks
9625 if Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Body then
9627 ("pragma% requires separate spec and must come before body");
9629 elsif Rep_Item_Too_Early (E, N)
9631 Rep_Item_Too_Late (E, N)
9635 elsif Is_Thread_Body (E) then
9637 ("only one thread body pragma allowed", Arg1);
9639 elsif Present (Homonym (E))
9640 and then Scope (Homonym (E)) = Current_Scope
9643 ("thread body subprogram must not be overloaded", Arg1);
9646 Set_Is_Thread_Body (E);
9648 -- Deal with secondary stack argument
9650 if Arg_Count = 2 then
9651 Check_Optional_Identifier (Arg2, Name_Secondary_Stack_Size);
9652 SS := Expression (Arg2);
9653 Analyze_And_Resolve (SS, Any_Integer);
9661 -- pragma Time_Slice (static_duration_EXPRESSION);
9663 when Pragma_Time_Slice => Time_Slice : declare
9669 Check_Arg_Count (1);
9670 Check_No_Identifiers;
9671 Check_In_Main_Program;
9672 Check_Arg_Is_Static_Expression (Arg1, Standard_Duration);
9674 if not Error_Posted (Arg1) then
9676 while Present (Nod) loop
9677 if Nkind (Nod) = N_Pragma
9678 and then Chars (Nod) = Name_Time_Slice
9680 Error_Msg_Name_1 := Chars (N);
9681 Error_Msg_N ("duplicate pragma% not permitted", Nod);
9688 -- Process only if in main unit
9690 if Get_Source_Unit (Loc) = Main_Unit then
9691 Opt.Time_Slice_Set := True;
9692 Val := Expr_Value_R (Expression (Arg1));
9694 if Val <= Ureal_0 then
9695 Opt.Time_Slice_Value := 0;
9697 elsif Val > UR_From_Uint (UI_From_Int (1000)) then
9698 Opt.Time_Slice_Value := 1_000_000_000;
9701 Opt.Time_Slice_Value :=
9702 UI_To_Int (UR_To_Uint (Val * UI_From_Int (1_000_000)));
9711 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
9713 -- TITLING_OPTION ::=
9714 -- [Title =>] STRING_LITERAL
9715 -- | [Subtitle =>] STRING_LITERAL
9717 when Pragma_Title => Title : declare
9718 Args : Args_List (1 .. 2);
9719 Names : constant Name_List (1 .. 2) := (
9725 Gather_Associations (Names, Args);
9727 for J in 1 .. 2 loop
9728 if Present (Args (J)) then
9729 Check_Arg_Is_String_Literal (Args (J));
9734 ---------------------
9735 -- Unchecked_Union --
9736 ---------------------
9738 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
9740 when Pragma_Unchecked_Union => Unchecked_Union : declare
9741 Assoc : constant Node_Id := Arg1;
9742 Type_Id : constant Node_Id := Expression (Assoc);
9753 Check_No_Identifiers;
9754 Check_Arg_Count (1);
9755 Check_Arg_Is_Local_Name (Arg1);
9757 Find_Type (Type_Id);
9758 Typ := Entity (Type_Id);
9761 or else Rep_Item_Too_Early (Typ, N)
9765 Typ := Underlying_Type (Typ);
9768 if Rep_Item_Too_Late (Typ, N) then
9772 Check_First_Subtype (Arg1);
9774 -- Note remaining cases are references to a type in the current
9775 -- declarative part. If we find an error, we post the error on
9776 -- the relevant type declaration at an appropriate point.
9778 if not Is_Record_Type (Typ) then
9779 Error_Msg_N ("Unchecked_Union must be record type", Typ);
9782 elsif Is_Tagged_Type (Typ) then
9783 Error_Msg_N ("Unchecked_Union must not be tagged", Typ);
9786 elsif Is_Limited_Type (Typ) then
9788 ("Unchecked_Union must not be limited record type", Typ);
9789 Explain_Limited_Type (Typ, Typ);
9793 if not Has_Discriminants (Typ) then
9795 ("Unchecked_Union must have one discriminant", Typ);
9799 Discr := First_Discriminant (Typ);
9801 if Present (Next_Discriminant (Discr)) then
9803 ("Unchecked_Union must have exactly one discriminant",
9804 Next_Discriminant (Discr));
9808 if No (Discriminant_Default_Value (Discr)) then
9810 ("Unchecked_Union discriminant must have default value",
9814 Tdef := Type_Definition (Declaration_Node (Typ));
9815 Clist := Component_List (Tdef);
9817 Comp := First (Component_Items (Clist));
9818 while Present (Comp) loop
9820 Check_Component (Comp);
9825 if No (Clist) or else No (Variant_Part (Clist)) then
9827 ("Unchecked_Union must have variant part",
9832 Vpart := Variant_Part (Clist);
9833 Variant := First (Variants (Vpart));
9834 while Present (Variant) loop
9836 Check_Variant (Variant);
9842 Set_Is_Unchecked_Union (Typ, True);
9843 Set_Convention (Typ, Convention_C);
9845 Set_Has_Unchecked_Union (Base_Type (Typ), True);
9846 Set_Is_Unchecked_Union (Base_Type (Typ), True);
9847 end Unchecked_Union;
9849 ------------------------
9850 -- Unimplemented_Unit --
9851 ------------------------
9853 -- pragma Unimplemented_Unit;
9855 -- Note: this only gives an error if we are generating code,
9856 -- or if we are in a generic library unit (where the pragma
9857 -- appears in the body, not in the spec).
9859 when Pragma_Unimplemented_Unit => Unimplemented_Unit : declare
9860 Cunitent : constant Entity_Id :=
9861 Cunit_Entity (Get_Source_Unit (Loc));
9862 Ent_Kind : constant Entity_Kind :=
9867 Check_Arg_Count (0);
9869 if Operating_Mode = Generate_Code
9870 or else Ent_Kind = E_Generic_Function
9871 or else Ent_Kind = E_Generic_Procedure
9872 or else Ent_Kind = E_Generic_Package
9874 Get_Name_String (Chars (Cunitent));
9875 Set_Casing (Mixed_Case);
9876 Write_Str (Name_Buffer (1 .. Name_Len));
9877 Write_Str (" is not implemented");
9879 raise Unrecoverable_Error;
9881 end Unimplemented_Unit;
9883 --------------------
9884 -- Universal_Data --
9885 --------------------
9887 -- pragma Universal_Data [(library_unit_NAME)];
9889 when Pragma_Universal_Data =>
9892 -- If this is a configuration pragma, then set the universal
9893 -- addressing option, otherwise confirm that the pragma
9894 -- satisfies the requirements of library unit pragma placement
9895 -- and leave it to the GNAAMP back end to detect the pragma
9896 -- (avoids transitive setting of the option due to withed units).
9898 if Is_Configuration_Pragma then
9899 Universal_Addressing_On_AAMP := True;
9901 Check_Valid_Library_Unit_Pragma;
9904 if not AAMP_On_Target then
9905 Error_Pragma ("?pragma% ignored (applies only to AAMP)");
9912 -- pragma Unreferenced (local_Name {, local_Name});
9914 when Pragma_Unreferenced => Unreferenced : declare
9917 Arg_Ent : Entity_Id;
9921 Check_At_Least_N_Arguments (1);
9925 while Present (Arg_Node) loop
9926 Check_No_Identifier (Arg_Node);
9928 -- Note that the analyze call done by Check_Arg_Is_Local_Name
9929 -- will in fact generate a reference, so that the entity will
9930 -- have a reference, which will inhibit any warnings about it
9931 -- not being referenced, and also properly show up in the ali
9932 -- file as a reference. But this reference is recorded before
9933 -- the Has_Pragma_Unreferenced flag is set, so that no warning
9934 -- is generated for this reference.
9936 Check_Arg_Is_Local_Name (Arg_Node);
9937 Arg_Expr := Get_Pragma_Arg (Arg_Node);
9939 if Is_Entity_Name (Arg_Expr) then
9940 Arg_Ent := Entity (Arg_Expr);
9942 -- If the entity is overloaded, the pragma applies to the
9943 -- most recent overloading, as documented. In this case,
9944 -- name resolution does not generate a reference, so it
9945 -- must be done here explicitly.
9947 if Is_Overloaded (Arg_Expr) then
9948 Generate_Reference (Arg_Ent, N);
9951 Set_Has_Pragma_Unreferenced (Arg_Ent);
9958 ------------------------------
9959 -- Unreserve_All_Interrupts --
9960 ------------------------------
9962 -- pragma Unreserve_All_Interrupts;
9964 when Pragma_Unreserve_All_Interrupts =>
9966 Check_Arg_Count (0);
9968 if In_Extended_Main_Code_Unit (Main_Unit_Entity) then
9969 Unreserve_All_Interrupts := True;
9976 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
9978 when Pragma_Unsuppress =>
9980 Process_Suppress_Unsuppress (False);
9986 -- pragma Use_VADS_Size;
9988 when Pragma_Use_VADS_Size =>
9990 Check_Arg_Count (0);
9991 Check_Valid_Configuration_Pragma;
9992 Use_VADS_Size := True;
9994 ---------------------
9995 -- Validity_Checks --
9996 ---------------------
9998 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
10000 when Pragma_Validity_Checks => Validity_Checks : declare
10001 A : constant Node_Id := Expression (Arg1);
10007 Check_Arg_Count (1);
10008 Check_No_Identifiers;
10010 if Nkind (A) = N_String_Literal then
10014 Slen : constant Natural := Natural (String_Length (S));
10015 Options : String (1 .. Slen);
10021 C := Get_String_Char (S, Int (J));
10022 exit when not In_Character_Range (C);
10023 Options (J) := Get_Character (C);
10026 Set_Validity_Check_Options (Options);
10034 elsif Nkind (A) = N_Identifier then
10036 if Chars (A) = Name_All_Checks then
10037 Set_Validity_Check_Options ("a");
10039 elsif Chars (A) = Name_On then
10040 Validity_Checks_On := True;
10042 elsif Chars (A) = Name_Off then
10043 Validity_Checks_On := False;
10047 end Validity_Checks;
10053 -- pragma Volatile (LOCAL_NAME);
10055 when Pragma_Volatile =>
10056 Process_Atomic_Shared_Volatile;
10058 -------------------------
10059 -- Volatile_Components --
10060 -------------------------
10062 -- pragma Volatile_Components (array_LOCAL_NAME);
10064 -- Volatile is handled by the same circuit as Atomic_Components
10070 -- pragma Warnings (On | Off, [LOCAL_NAME])
10072 when Pragma_Warnings => Warnings : begin
10074 Check_At_Least_N_Arguments (1);
10075 Check_At_Most_N_Arguments (2);
10076 Check_No_Identifiers;
10078 -- One argument case was processed by parser in Par.Prag
10080 if Arg_Count /= 1 then
10081 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
10082 Check_Arg_Count (2);
10089 E_Id := Expression (Arg2);
10092 -- In the expansion of an inlined body, a reference to
10093 -- the formal may be wrapped in a conversion if the actual
10094 -- is a conversion. Retrieve the real entity name.
10096 if (In_Instance_Body
10097 or else In_Inlined_Body)
10098 and then Nkind (E_Id) = N_Unchecked_Type_Conversion
10100 E_Id := Expression (E_Id);
10103 if not Is_Entity_Name (E_Id) then
10105 ("second argument of pragma% must be entity name",
10109 E := Entity (E_Id);
10115 Set_Warnings_Off (E,
10116 (Chars (Expression (Arg1)) = Name_Off));
10118 if Is_Enumeration_Type (E) then
10120 Lit : Entity_Id := First_Literal (E);
10123 while Present (Lit) loop
10124 Set_Warnings_Off (Lit);
10125 Next_Literal (Lit);
10130 exit when No (Homonym (E));
10138 -------------------
10139 -- Weak_External --
10140 -------------------
10142 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
10144 when Pragma_Weak_External => Weak_External : declare
10149 Check_Arg_Count (1);
10150 Check_Optional_Identifier (Arg1, Name_Entity);
10151 Check_Arg_Is_Library_Level_Local_Name (Arg1);
10152 Ent := Entity (Expression (Arg1));
10154 if Rep_Item_Too_Early (Ent, N) then
10157 Ent := Underlying_Type (Ent);
10160 -- The only processing required is to link this item on to the
10161 -- list of rep items for the given entity. This is accomplished
10162 -- by the call to Rep_Item_Too_Late (when no error is detected
10163 -- and False is returned).
10165 if Rep_Item_Too_Late (Ent, N) then
10168 Set_Has_Gigi_Rep_Item (Ent);
10172 --------------------
10173 -- Unknown_Pragma --
10174 --------------------
10176 -- Should be impossible, since the case of an unknown pragma is
10177 -- separately processed before the case statement is entered.
10179 when Unknown_Pragma =>
10180 raise Program_Error;
10184 when Pragma_Exit => null;
10185 end Analyze_Pragma;
10187 ---------------------------------
10188 -- Delay_Config_Pragma_Analyze --
10189 ---------------------------------
10191 function Delay_Config_Pragma_Analyze (N : Node_Id) return Boolean is
10193 return Chars (N) = Name_Interrupt_State;
10194 end Delay_Config_Pragma_Analyze;
10196 -------------------------
10197 -- Get_Base_Subprogram --
10198 -------------------------
10200 function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id is
10201 Result : Entity_Id;
10206 -- Follow subprogram renaming chain
10208 while Is_Subprogram (Result)
10210 (Is_Generic_Instance (Result)
10211 or else Nkind (Parent (Declaration_Node (Result))) =
10212 N_Subprogram_Renaming_Declaration)
10213 and then Present (Alias (Result))
10215 Result := Alias (Result);
10219 end Get_Base_Subprogram;
10221 -----------------------------
10222 -- Is_Config_Static_String --
10223 -----------------------------
10225 function Is_Config_Static_String (Arg : Node_Id) return Boolean is
10227 function Add_Config_Static_String (Arg : Node_Id) return Boolean;
10228 -- This is an internal recursive function that is just like the
10229 -- outer function except that it adds the string to the name buffer
10230 -- rather than placing the string in the name buffer.
10232 ------------------------------
10233 -- Add_Config_Static_String --
10234 ------------------------------
10236 function Add_Config_Static_String (Arg : Node_Id) return Boolean is
10243 if Nkind (N) = N_Op_Concat then
10244 if Add_Config_Static_String (Left_Opnd (N)) then
10245 N := Right_Opnd (N);
10251 if Nkind (N) /= N_String_Literal then
10252 Error_Msg_N ("string literal expected for pragma argument", N);
10256 for J in 1 .. String_Length (Strval (N)) loop
10257 C := Get_String_Char (Strval (N), J);
10259 if not In_Character_Range (C) then
10261 ("string literal contains invalid wide character",
10262 Sloc (N) + 1 + Source_Ptr (J));
10266 Add_Char_To_Name_Buffer (Get_Character (C));
10271 end Add_Config_Static_String;
10273 -- Start of prorcessing for Is_Config_Static_String
10278 return Add_Config_Static_String (Arg);
10279 end Is_Config_Static_String;
10281 -----------------------------------------
10282 -- Is_Non_Significant_Pragma_Reference --
10283 -----------------------------------------
10285 -- This function makes use of the following static table which indicates
10286 -- whether a given pragma is significant. A value of -1 in this table
10287 -- indicates that the reference is significant. A value of zero indicates
10288 -- than appearence as any argument is insignificant, a positive value
10289 -- indicates that appearence in that parameter position is significant.
10291 Sig_Flags : constant array (Pragma_Id) of Int :=
10293 (Pragma_AST_Entry => -1,
10294 Pragma_Abort_Defer => -1,
10295 Pragma_Ada_83 => -1,
10296 Pragma_Ada_95 => -1,
10297 Pragma_Ada_05 => -1,
10298 Pragma_All_Calls_Remote => -1,
10299 Pragma_Annotate => -1,
10300 Pragma_Assert => -1,
10301 Pragma_Asynchronous => -1,
10302 Pragma_Atomic => 0,
10303 Pragma_Atomic_Components => 0,
10304 Pragma_Attach_Handler => -1,
10305 Pragma_CPP_Class => 0,
10306 Pragma_CPP_Constructor => 0,
10307 Pragma_CPP_Virtual => 0,
10308 Pragma_CPP_Vtable => 0,
10309 Pragma_C_Pass_By_Copy => 0,
10310 Pragma_Comment => 0,
10311 Pragma_Common_Object => -1,
10312 Pragma_Compile_Time_Warning => -1,
10313 Pragma_Complex_Representation => 0,
10314 Pragma_Component_Alignment => -1,
10315 Pragma_Controlled => 0,
10316 Pragma_Convention => 0,
10317 Pragma_Convention_Identifier => 0,
10318 Pragma_Debug => -1,
10319 Pragma_Detect_Blocking => -1,
10320 Pragma_Discard_Names => 0,
10321 Pragma_Elaborate => -1,
10322 Pragma_Elaborate_All => -1,
10323 Pragma_Elaborate_Body => -1,
10324 Pragma_Elaboration_Checks => -1,
10325 Pragma_Eliminate => -1,
10326 Pragma_Explicit_Overriding => -1,
10327 Pragma_Export => -1,
10328 Pragma_Export_Exception => -1,
10329 Pragma_Export_Function => -1,
10330 Pragma_Export_Object => -1,
10331 Pragma_Export_Procedure => -1,
10332 Pragma_Export_Value => -1,
10333 Pragma_Export_Valued_Procedure => -1,
10334 Pragma_Extend_System => -1,
10335 Pragma_Extensions_Allowed => -1,
10336 Pragma_External => -1,
10337 Pragma_External_Name_Casing => -1,
10338 Pragma_Finalize_Storage_Only => 0,
10339 Pragma_Float_Representation => 0,
10340 Pragma_Ident => -1,
10341 Pragma_Import => +2,
10342 Pragma_Import_Exception => 0,
10343 Pragma_Import_Function => 0,
10344 Pragma_Import_Object => 0,
10345 Pragma_Import_Procedure => 0,
10346 Pragma_Import_Valued_Procedure => 0,
10347 Pragma_Initialize_Scalars => -1,
10348 Pragma_Inline => 0,
10349 Pragma_Inline_Always => 0,
10350 Pragma_Inline_Generic => 0,
10351 Pragma_Inspection_Point => -1,
10352 Pragma_Interface => +2,
10353 Pragma_Interface_Name => +2,
10354 Pragma_Interrupt_Handler => -1,
10355 Pragma_Interrupt_Priority => -1,
10356 Pragma_Interrupt_State => -1,
10357 Pragma_Java_Constructor => -1,
10358 Pragma_Java_Interface => -1,
10359 Pragma_Keep_Names => 0,
10360 Pragma_License => -1,
10361 Pragma_Link_With => -1,
10362 Pragma_Linker_Alias => -1,
10363 Pragma_Linker_Options => -1,
10364 Pragma_Linker_Section => -1,
10366 Pragma_Locking_Policy => -1,
10367 Pragma_Long_Float => -1,
10368 Pragma_Machine_Attribute => -1,
10370 Pragma_Main_Storage => -1,
10371 Pragma_Memory_Size => -1,
10372 Pragma_No_Return => 0,
10373 Pragma_No_Run_Time => -1,
10374 Pragma_No_Strict_Aliasing => -1,
10375 Pragma_Normalize_Scalars => -1,
10376 Pragma_Obsolescent => 0,
10377 Pragma_Optimize => -1,
10378 Pragma_Optional_Overriding => -1,
10379 Pragma_Overriding => -1,
10382 Pragma_Passive => -1,
10383 Pragma_Polling => -1,
10384 Pragma_Persistent_Data => -1,
10385 Pragma_Persistent_Object => -1,
10386 Pragma_Preelaborate => -1,
10387 Pragma_Priority => -1,
10388 Pragma_Profile => 0,
10389 Pragma_Profile_Warnings => 0,
10390 Pragma_Propagate_Exceptions => -1,
10391 Pragma_Psect_Object => -1,
10393 Pragma_Pure_Function => 0,
10394 Pragma_Queuing_Policy => -1,
10395 Pragma_Ravenscar => -1,
10396 Pragma_Remote_Call_Interface => -1,
10397 Pragma_Remote_Types => -1,
10398 Pragma_Restricted_Run_Time => -1,
10399 Pragma_Restriction_Warnings => -1,
10400 Pragma_Restrictions => -1,
10401 Pragma_Reviewable => -1,
10402 Pragma_Share_Generic => -1,
10403 Pragma_Shared => -1,
10404 Pragma_Shared_Passive => -1,
10405 Pragma_Source_File_Name => -1,
10406 Pragma_Source_File_Name_Project => -1,
10407 Pragma_Source_Reference => -1,
10408 Pragma_Storage_Size => -1,
10409 Pragma_Storage_Unit => -1,
10410 Pragma_Stream_Convert => -1,
10411 Pragma_Style_Checks => -1,
10412 Pragma_Subtitle => -1,
10413 Pragma_Suppress => 0,
10414 Pragma_Suppress_Exception_Locations => 0,
10415 Pragma_Suppress_All => -1,
10416 Pragma_Suppress_Debug_Info => 0,
10417 Pragma_Suppress_Initialization => 0,
10418 Pragma_System_Name => -1,
10419 Pragma_Task_Dispatching_Policy => -1,
10420 Pragma_Task_Info => -1,
10421 Pragma_Task_Name => -1,
10422 Pragma_Task_Storage => 0,
10423 Pragma_Thread_Body => +2,
10424 Pragma_Time_Slice => -1,
10425 Pragma_Title => -1,
10426 Pragma_Unchecked_Union => 0,
10427 Pragma_Unimplemented_Unit => -1,
10428 Pragma_Universal_Data => -1,
10429 Pragma_Unreferenced => -1,
10430 Pragma_Unreserve_All_Interrupts => -1,
10431 Pragma_Unsuppress => 0,
10432 Pragma_Use_VADS_Size => -1,
10433 Pragma_Validity_Checks => -1,
10434 Pragma_Volatile => 0,
10435 Pragma_Volatile_Components => 0,
10436 Pragma_Warnings => -1,
10437 Pragma_Weak_External => 0,
10438 Unknown_Pragma => 0);
10440 function Is_Non_Significant_Pragma_Reference (N : Node_Id) return Boolean is
10448 if Nkind (P) /= N_Pragma_Argument_Association then
10452 C := Sig_Flags (Get_Pragma_Id (Chars (Parent (P))));
10462 A := First (Pragma_Argument_Associations (Parent (P)));
10463 for J in 1 .. C - 1 loop
10474 end Is_Non_Significant_Pragma_Reference;
10476 ------------------------------
10477 -- Is_Pragma_String_Literal --
10478 ------------------------------
10480 -- This function returns true if the corresponding pragma argument is
10481 -- a static string expression. These are the only cases in which string
10482 -- literals can appear as pragma arguments. We also allow a string
10483 -- literal as the first argument to pragma Assert (although it will
10484 -- of course always generate a type error).
10486 function Is_Pragma_String_Literal (Par : Node_Id) return Boolean is
10487 Pragn : constant Node_Id := Parent (Par);
10488 Assoc : constant List_Id := Pragma_Argument_Associations (Pragn);
10489 Pname : constant Name_Id := Chars (Pragn);
10495 N := First (Assoc);
10502 if Pname = Name_Assert then
10505 elsif Pname = Name_Export then
10508 elsif Pname = Name_Ident then
10511 elsif Pname = Name_Import then
10514 elsif Pname = Name_Interface_Name then
10517 elsif Pname = Name_Linker_Alias then
10520 elsif Pname = Name_Linker_Section then
10523 elsif Pname = Name_Machine_Attribute then
10526 elsif Pname = Name_Source_File_Name then
10529 elsif Pname = Name_Source_Reference then
10532 elsif Pname = Name_Title then
10535 elsif Pname = Name_Subtitle then
10541 end Is_Pragma_String_Literal;
10543 --------------------------------------
10544 -- Process_Compilation_Unit_Pragmas --
10545 --------------------------------------
10547 procedure Process_Compilation_Unit_Pragmas (N : Node_Id) is
10549 -- A special check for pragma Suppress_All. This is a strange DEC
10550 -- pragma, strange because it comes at the end of the unit. If we
10551 -- have a pragma Suppress_All in the Pragmas_After of the current
10552 -- unit, then we insert a pragma Suppress (All_Checks) at the start
10553 -- of the context clause to ensure the correct processing.
10556 PA : constant List_Id := Pragmas_After (Aux_Decls_Node (N));
10560 if Present (PA) then
10562 while Present (P) loop
10563 if Chars (P) = Name_Suppress_All then
10564 Prepend_To (Context_Items (N),
10565 Make_Pragma (Sloc (P),
10566 Chars => Name_Suppress,
10567 Pragma_Argument_Associations => New_List (
10568 Make_Pragma_Argument_Association (Sloc (P),
10570 Make_Identifier (Sloc (P),
10571 Chars => Name_All_Checks)))));
10579 end Process_Compilation_Unit_Pragmas;
10581 --------------------------------
10582 -- Set_Encoded_Interface_Name --
10583 --------------------------------
10585 procedure Set_Encoded_Interface_Name (E : Entity_Id; S : Node_Id) is
10586 Str : constant String_Id := Strval (S);
10587 Len : constant Int := String_Length (Str);
10592 Hex : constant array (0 .. 15) of Character := "0123456789abcdef";
10595 -- Stores encoded value of character code CC. The encoding we
10596 -- use an underscore followed by four lower case hex digits.
10602 procedure Encode is
10604 Store_String_Char (Get_Char_Code ('_'));
10606 (Get_Char_Code (Hex (Integer (CC / 2 ** 12))));
10608 (Get_Char_Code (Hex (Integer (CC / 2 ** 8 and 16#0F#))));
10610 (Get_Char_Code (Hex (Integer (CC / 2 ** 4 and 16#0F#))));
10612 (Get_Char_Code (Hex (Integer (CC and 16#0F#))));
10615 -- Start of processing for Set_Encoded_Interface_Name
10618 -- If first character is asterisk, this is a link name, and we
10619 -- leave it completely unmodified. We also ignore null strings
10620 -- (the latter case happens only in error cases) and no encoding
10621 -- should occur for Java interface names.
10624 or else Get_String_Char (Str, 1) = Get_Char_Code ('*')
10627 Set_Interface_Name (E, S);
10632 CC := Get_String_Char (Str, J);
10634 exit when not In_Character_Range (CC);
10636 C := Get_Character (CC);
10638 exit when C /= '_' and then C /= '$'
10639 and then C not in '0' .. '9'
10640 and then C not in 'a' .. 'z'
10641 and then C not in 'A' .. 'Z';
10644 Set_Interface_Name (E, S);
10652 -- Here we need to encode. The encoding we use as follows:
10653 -- three underscores + four hex digits (lower case)
10657 for J in 1 .. String_Length (Str) loop
10658 CC := Get_String_Char (Str, J);
10660 if not In_Character_Range (CC) then
10663 C := Get_Character (CC);
10665 if C = '_' or else C = '$'
10666 or else C in '0' .. '9'
10667 or else C in 'a' .. 'z'
10668 or else C in 'A' .. 'Z'
10670 Store_String_Char (CC);
10677 Set_Interface_Name (E,
10678 Make_String_Literal (Sloc (S),
10679 Strval => End_String));
10681 end Set_Encoded_Interface_Name;
10683 -------------------
10684 -- Set_Unit_Name --
10685 -------------------
10687 procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id) is
10692 if Nkind (N) = N_Identifier
10693 and then Nkind (With_Item) = N_Identifier
10695 Set_Entity (N, Entity (With_Item));
10697 elsif Nkind (N) = N_Selected_Component then
10698 Change_Selected_Component_To_Expanded_Name (N);
10699 Set_Entity (N, Entity (With_Item));
10700 Set_Entity (Selector_Name (N), Entity (N));
10702 Pref := Prefix (N);
10703 Scop := Scope (Entity (N));
10704 while Nkind (Pref) = N_Selected_Component loop
10705 Change_Selected_Component_To_Expanded_Name (Pref);
10706 Set_Entity (Selector_Name (Pref), Scop);
10707 Set_Entity (Pref, Scop);
10708 Pref := Prefix (Pref);
10709 Scop := Scope (Scop);
10712 Set_Entity (Pref, Scop);