1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- This unit contains the semantic processing for all pragmas, both language
27 -- and implementation defined. For most pragmas, the parser only does the
28 -- most basic job of checking the syntax, so Sem_Prag also contains the code
29 -- to complete the syntax checks. Certain pragmas are handled partially or
30 -- completely by the parser (see Par.Prag for further details).
32 with Atree; use Atree;
33 with Casing; use Casing;
34 with Checks; use Checks;
35 with Csets; use Csets;
36 with Debug; use Debug;
37 with Einfo; use Einfo;
38 with Errout; use Errout;
39 with Exp_Dist; use Exp_Dist;
41 with Lib.Writ; use Lib.Writ;
42 with Lib.Xref; use Lib.Xref;
43 with Namet.Sp; use Namet.Sp;
44 with Nlists; use Nlists;
45 with Nmake; use Nmake;
47 with Output; use Output;
48 with Restrict; use Restrict;
49 with Rident; use Rident;
50 with Rtsfind; use Rtsfind;
52 with Sem_Aux; use Sem_Aux;
53 with Sem_Ch3; use Sem_Ch3;
54 with Sem_Ch6; use Sem_Ch6;
55 with Sem_Ch8; use Sem_Ch8;
56 with Sem_Ch13; use Sem_Ch13;
57 with Sem_Dist; use Sem_Dist;
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 Sem_Warn; use Sem_Warn;
67 with Stand; use Stand;
68 with Sinfo; use Sinfo;
69 with Sinfo.CN; use Sinfo.CN;
70 with Sinput; use Sinput;
71 with Snames; use Snames;
72 with Stringt; use Stringt;
73 with Stylesw; use Stylesw;
75 with Targparm; use Targparm;
76 with Tbuild; use Tbuild;
78 with Uintp; use Uintp;
79 with Uname; use Uname;
80 with Urealp; use Urealp;
81 with Validsw; use Validsw;
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 function Get_Pragma_Arg (Arg : Node_Id) return Node_Id;
178 -- All the routines that check pragma arguments take either a pragma
179 -- argument association (in which case the expression of the argument
180 -- association is checked), or the expression directly. The function
181 -- Get_Pragma_Arg is a utility used to deal with these two cases. If Arg
182 -- is a pragma argument association node, then its expression is returned,
183 -- otherwise Arg is returned unchanged.
186 -- This is a dummy function called by the processing for pragma Reviewable.
187 -- It is there for assisting front end debugging. By placing a Reviewable
188 -- pragma in the source program, a breakpoint on rv catches this place in
189 -- the source, allowing convenient stepping to the point of interest.
191 procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id);
192 -- Place semantic information on the argument of an Elaborate or
193 -- Elaborate_All pragma. Entity name for unit and its parents is
194 -- taken from item in previous with_clause that mentions the unit.
196 -------------------------------
197 -- Adjust_External_Name_Case --
198 -------------------------------
200 function Adjust_External_Name_Case (N : Node_Id) return Node_Id is
204 -- Adjust case of literal if required
206 if Opt.External_Name_Exp_Casing = As_Is then
210 -- Copy existing string
216 for J in 1 .. String_Length (Strval (N)) loop
217 CC := Get_String_Char (Strval (N), J);
219 if Opt.External_Name_Exp_Casing = Uppercase
220 and then CC >= Get_Char_Code ('a')
221 and then CC <= Get_Char_Code ('z')
223 Store_String_Char (CC - 32);
225 elsif Opt.External_Name_Exp_Casing = Lowercase
226 and then CC >= Get_Char_Code ('A')
227 and then CC <= Get_Char_Code ('Z')
229 Store_String_Char (CC + 32);
232 Store_String_Char (CC);
237 Make_String_Literal (Sloc (N),
238 Strval => End_String);
240 end Adjust_External_Name_Case;
242 ------------------------------
243 -- Analyze_PPC_In_Decl_Part --
244 ------------------------------
246 procedure Analyze_PPC_In_Decl_Part (N : Node_Id; S : Entity_Id) is
247 Arg1 : constant Node_Id :=
248 First (Pragma_Argument_Associations (N));
249 Arg2 : constant Node_Id := Next (Arg1);
252 -- Install formals and push subprogram spec onto scope stack
253 -- so that we can see the formals from the pragma.
258 -- Preanalyze the boolean expression, we treat this as a
259 -- spec expression (i.e. similar to a default expression).
261 Preanalyze_Spec_Expression
262 (Get_Pragma_Arg (Arg1), Standard_Boolean);
264 -- If there is a message argument, analyze it the same way
266 if Present (Arg2) then
267 Preanalyze_Spec_Expression
268 (Get_Pragma_Arg (Arg2), Standard_String);
271 -- Remove the subprogram from the scope stack now that the
272 -- pre-analysis of the precondition/postcondition is done.
275 end Analyze_PPC_In_Decl_Part;
281 procedure Analyze_Pragma (N : Node_Id) is
282 Loc : constant Source_Ptr := Sloc (N);
283 Pname : constant Name_Id := Pragma_Name (N);
286 Pragma_Exit : exception;
287 -- This exception is used to exit pragma processing completely. It
288 -- is used when an error is detected, and no further processing is
289 -- required. It is also used if an earlier error has left the tree
290 -- in a state where the pragma should not be processed.
293 -- Number of pragma argument associations
299 -- First four pragma arguments (pragma argument association nodes,
300 -- or Empty if the corresponding argument does not exist).
302 type Name_List is array (Natural range <>) of Name_Id;
303 type Args_List is array (Natural range <>) of Node_Id;
304 -- Types used for arguments to Check_Arg_Order and Gather_Associations
306 procedure Ada_2005_Pragma;
307 -- Called for pragmas defined in Ada 2005, that are not in Ada 95. In
308 -- Ada 95 mode, these are implementation defined pragmas, so should be
309 -- caught by the No_Implementation_Pragmas restriction
311 procedure Check_Ada_83_Warning;
312 -- Issues a warning message for the current pragma if operating in Ada
313 -- 83 mode (used for language pragmas that are not a standard part of
314 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
317 procedure Check_Arg_Count (Required : Nat);
318 -- Check argument count for pragma is equal to given parameter.
319 -- If not, then issue an error message and raise Pragma_Exit.
321 -- Note: all routines whose name is Check_Arg_Is_xxx take an
322 -- argument Arg which can either be a pragma argument association,
323 -- in which case the check is applied to the expression of the
324 -- association or an expression directly.
326 procedure Check_Arg_Is_External_Name (Arg : Node_Id);
327 -- Check that an argument has the right form for an EXTERNAL_NAME
328 -- parameter of an extended import/export pragma. The rule is that
329 -- the name must be an identifier or string literal (in Ada 83 mode)
330 -- or a static string expression (in Ada 95 mode).
332 procedure Check_Arg_Is_Identifier (Arg : Node_Id);
333 -- Check the specified argument Arg to make sure that it is an
334 -- identifier. If not give error and raise Pragma_Exit.
336 procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id);
337 -- Check the specified argument Arg to make sure that it is an
338 -- integer literal. If not give error and raise Pragma_Exit.
340 procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id);
341 -- Check the specified argument Arg to make sure that it has the
342 -- proper syntactic form for a local name and meets the semantic
343 -- requirements for a local name. The local name is analyzed as
344 -- part of the processing for this call. In addition, the local
345 -- name is required to represent an entity at the library level.
347 procedure Check_Arg_Is_Local_Name (Arg : Node_Id);
348 -- Check the specified argument Arg to make sure that it has the
349 -- proper syntactic form for a local name and meets the semantic
350 -- requirements for a local name. The local name is analyzed as
351 -- part of the processing for this call.
353 procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id);
354 -- Check the specified argument Arg to make sure that it is a valid
355 -- locking policy name. If not give error and raise Pragma_Exit.
357 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id);
358 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2, N3 : Name_Id);
359 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2, N3, N4 : Name_Id);
360 -- Check the specified argument Arg to make sure that it is an
361 -- identifier whose name matches either N1 or N2 (or N3 if present).
362 -- If not then give error and raise Pragma_Exit.
364 procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id);
365 -- Check the specified argument Arg to make sure that it is a valid
366 -- queuing policy name. If not give error and raise Pragma_Exit.
368 procedure Check_Arg_Is_Static_Expression
371 -- Check the specified argument Arg to make sure that it is a static
372 -- expression of the given type (i.e. it will be analyzed and resolved
373 -- using this type, which can be any valid argument to Resolve, e.g.
374 -- Any_Integer is OK). If not, given error and raise Pragma_Exit.
376 procedure Check_Arg_Is_String_Literal (Arg : Node_Id);
377 -- Check the specified argument Arg to make sure that it is a
378 -- string literal. If not give error and raise Pragma_Exit
380 procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id);
381 -- Check the specified argument Arg to make sure that it is a valid
382 -- valid task dispatching policy name. If not give error and raise
385 procedure Check_Arg_Order (Names : Name_List);
386 -- Checks for an instance of two arguments with identifiers for the
387 -- current pragma which are not in the sequence indicated by Names,
388 -- and if so, generates a fatal message about bad order of arguments.
390 procedure Check_At_Least_N_Arguments (N : Nat);
391 -- Check there are at least N arguments present
393 procedure Check_At_Most_N_Arguments (N : Nat);
394 -- Check there are no more than N arguments present
396 procedure Check_Component (Comp : Node_Id);
397 -- Examine Unchecked_Union component for correct use of per-object
398 -- constrained subtypes, and for restrictions on finalizable components.
400 procedure Check_Duplicated_Export_Name (Nam : Node_Id);
401 -- Nam is an N_String_Literal node containing the external name set
402 -- by an Import or Export pragma (or extended Import or Export pragma).
403 -- This procedure checks for possible duplications if this is the
404 -- export case, and if found, issues an appropriate error message.
406 procedure Check_First_Subtype (Arg : Node_Id);
407 -- Checks that Arg, whose expression is an entity name referencing
408 -- a subtype, does not reference a type that is not a first subtype.
410 procedure Check_In_Main_Program;
411 -- Common checks for pragmas that appear within a main program
412 -- (Priority, Main_Storage, Time_Slice, Relative_Deadline).
414 procedure Check_Interrupt_Or_Attach_Handler;
415 -- Common processing for first argument of pragma Interrupt_Handler
416 -- or pragma Attach_Handler.
418 procedure Check_Is_In_Decl_Part_Or_Package_Spec;
419 -- Check that pragma appears in a declarative part, or in a package
420 -- specification, i.e. that it does not occur in a statement sequence
423 procedure Check_No_Identifier (Arg : Node_Id);
424 -- Checks that the given argument does not have an identifier. If
425 -- an identifier is present, then an error message is issued, and
426 -- Pragma_Exit is raised.
428 procedure Check_No_Identifiers;
429 -- Checks that none of the arguments to the pragma has an identifier.
430 -- If any argument has an identifier, then an error message is issued,
431 -- and Pragma_Exit is raised.
433 procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id);
434 -- Checks if the given argument has an identifier, and if so, requires
435 -- it to match the given identifier name. If there is a non-matching
436 -- identifier, then an error message is given and Error_Pragmas raised.
438 procedure Check_Optional_Identifier (Arg : Node_Id; Id : String);
439 -- Checks if the given argument has an identifier, and if so, requires
440 -- it to match the given identifier name. If there is a non-matching
441 -- identifier, then an error message is given and Error_Pragmas raised.
442 -- In this version of the procedure, the identifier name is given as
443 -- a string with lower case letters.
445 procedure Check_Precondition_Postcondition (In_Body : out Boolean);
446 -- Called to process a precondition or postcondition pragma. There are
449 -- The pragma appears after a subprogram spec
451 -- If the corresponding check is not enabled, the pragma is analyzed
452 -- but otherwise ignored and control returns with In_Body set False.
454 -- If the check is enabled, then the first step is to analyze the
455 -- pragma, but this is skipped if the subprogram spec appears within
456 -- a package specification (because this is the case where we delay
457 -- analysis till the end of the spec). Then (whether or not it was
458 -- analyzed), the pragma is chained to the subprogram in question
459 -- (using Spec_PPC_List and Next_Pragma) and control returns to the
460 -- caller with In_Body set False.
462 -- The pragma appears at the start of subprogram body declarations
464 -- In this case an immediate return to the caller is made with
465 -- In_Body set True, and the pragma is NOT analyzed.
467 -- In all other cases, an error message for bad placement is given
469 procedure Check_Static_Constraint (Constr : Node_Id);
470 -- Constr is a constraint from an N_Subtype_Indication node from a
471 -- component constraint in an Unchecked_Union type. This routine checks
472 -- that the constraint is static as required by the restrictions for
475 procedure Check_Valid_Configuration_Pragma;
476 -- Legality checks for placement of a configuration pragma
478 procedure Check_Valid_Library_Unit_Pragma;
479 -- Legality checks for library unit pragmas. A special case arises for
480 -- pragmas in generic instances that come from copies of the original
481 -- library unit pragmas in the generic templates. In the case of other
482 -- than library level instantiations these can appear in contexts which
483 -- would normally be invalid (they only apply to the original template
484 -- and to library level instantiations), and they are simply ignored,
485 -- which is implemented by rewriting them as null statements.
487 procedure Check_Variant (Variant : Node_Id);
488 -- Check Unchecked_Union variant for lack of nested variants and
489 -- presence of at least one component.
491 procedure Error_Pragma (Msg : String);
492 pragma No_Return (Error_Pragma);
493 -- Outputs error message for current pragma. The message contains a %
494 -- that will be replaced with the pragma name, and the flag is placed
495 -- on the pragma itself. Pragma_Exit is then raised.
497 procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id);
498 pragma No_Return (Error_Pragma_Arg);
499 -- Outputs error message for current pragma. The message may contain
500 -- a % that will be replaced with the pragma name. The parameter Arg
501 -- may either be a pragma argument association, in which case the flag
502 -- is placed on the expression of this association, or an expression,
503 -- in which case the flag is placed directly on the expression. The
504 -- message is placed using Error_Msg_N, so the message may also contain
505 -- an & insertion character which will reference the given Arg value.
506 -- After placing the message, Pragma_Exit is raised.
508 procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id);
509 pragma No_Return (Error_Pragma_Arg);
510 -- Similar to above form of Error_Pragma_Arg except that two messages
511 -- are provided, the second is a continuation comment starting with \.
513 procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id);
514 pragma No_Return (Error_Pragma_Arg_Ident);
515 -- Outputs error message for current pragma. The message may contain
516 -- a % that will be replaced with the pragma name. The parameter Arg
517 -- must be a pragma argument association with a non-empty identifier
518 -- (i.e. its Chars field must be set), and the error message is placed
519 -- on the identifier. The message is placed using Error_Msg_N so
520 -- the message may also contain an & insertion character which will
521 -- reference the identifier. After placing the message, Pragma_Exit
524 function Find_Lib_Unit_Name return Entity_Id;
525 -- Used for a library unit pragma to find the entity to which the
526 -- library unit pragma applies, returns the entity found.
528 procedure Find_Program_Unit_Name (Id : Node_Id);
529 -- If the pragma is a compilation unit pragma, the id must denote the
530 -- compilation unit in the same compilation, and the pragma must appear
531 -- in the list of preceding or trailing pragmas. If it is a program
532 -- unit pragma that is not a compilation unit pragma, then the
533 -- identifier must be visible.
535 function Find_Unique_Parameterless_Procedure
537 Arg : Node_Id) return Entity_Id;
538 -- Used for a procedure pragma to find the unique parameterless
539 -- procedure identified by Name, returns it if it exists, otherwise
540 -- errors out and uses Arg as the pragma argument for the message.
542 procedure Gather_Associations
544 Args : out Args_List);
545 -- This procedure is used to gather the arguments for a pragma that
546 -- permits arbitrary ordering of parameters using the normal rules
547 -- for named and positional parameters. The Names argument is a list
548 -- of Name_Id values that corresponds to the allowed pragma argument
549 -- association identifiers in order. The result returned in Args is
550 -- a list of corresponding expressions that are the pragma arguments.
551 -- Note that this is a list of expressions, not of pragma argument
552 -- associations (Gather_Associations has completely checked all the
553 -- optional identifiers when it returns). An entry in Args is Empty
554 -- on return if the corresponding argument is not present.
556 procedure GNAT_Pragma;
557 -- Called for all GNAT defined pragmas to check the relevant restriction
558 -- (No_Implementation_Pragmas).
560 function Is_Before_First_Decl
561 (Pragma_Node : Node_Id;
562 Decls : List_Id) return Boolean;
563 -- Return True if Pragma_Node is before the first declarative item in
564 -- Decls where Decls is the list of declarative items.
566 function Is_Configuration_Pragma return Boolean;
567 -- Determines if the placement of the current pragma is appropriate
568 -- for a configuration pragma.
570 function Is_In_Context_Clause return Boolean;
571 -- Returns True if pragma appears within the context clause of a unit,
572 -- and False for any other placement (does not generate any messages).
574 function Is_Static_String_Expression (Arg : Node_Id) return Boolean;
575 -- Analyzes the argument, and determines if it is a static string
576 -- expression, returns True if so, False if non-static or not String.
578 procedure Pragma_Misplaced;
579 -- Issue fatal error message for misplaced pragma
581 procedure Process_Atomic_Shared_Volatile;
582 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
583 -- Shared is an obsolete Ada 83 pragma, treated as being identical
584 -- in effect to pragma Atomic.
586 procedure Process_Compile_Time_Warning_Or_Error;
587 -- Common processing for Compile_Time_Error and Compile_Time_Warning
589 procedure Process_Convention (C : out Convention_Id; E : out Entity_Id);
590 -- Common processing for Convention, Interface, Import and Export.
591 -- Checks first two arguments of pragma, and sets the appropriate
592 -- convention value in the specified entity or entities. On return
593 -- C is the convention, E is the referenced entity.
595 procedure Process_Extended_Import_Export_Exception_Pragma
596 (Arg_Internal : Node_Id;
597 Arg_External : Node_Id;
600 -- Common processing for the pragmas Import/Export_Exception.
601 -- The three arguments correspond to the three named parameters of
602 -- the pragma. An argument is empty if the corresponding parameter
603 -- is not present in the pragma.
605 procedure Process_Extended_Import_Export_Object_Pragma
606 (Arg_Internal : Node_Id;
607 Arg_External : Node_Id;
609 -- Common processing for the pragmas Import/Export_Object.
610 -- The three arguments correspond to the three named parameters
611 -- of the pragmas. An argument is empty if the corresponding
612 -- parameter is not present in the pragma.
614 procedure Process_Extended_Import_Export_Internal_Arg
615 (Arg_Internal : Node_Id := Empty);
616 -- Common processing for all extended Import and Export pragmas. The
617 -- argument is the pragma parameter for the Internal argument. If
618 -- Arg_Internal is empty or inappropriate, an error message is posted.
619 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
620 -- set to identify the referenced entity.
622 procedure Process_Extended_Import_Export_Subprogram_Pragma
623 (Arg_Internal : Node_Id;
624 Arg_External : Node_Id;
625 Arg_Parameter_Types : Node_Id;
626 Arg_Result_Type : Node_Id := Empty;
627 Arg_Mechanism : Node_Id;
628 Arg_Result_Mechanism : Node_Id := Empty;
629 Arg_First_Optional_Parameter : Node_Id := Empty);
630 -- Common processing for all extended Import and Export pragmas
631 -- applying to subprograms. The caller omits any arguments that do
632 -- not apply to the pragma in question (for example, Arg_Result_Type
633 -- can be non-Empty only in the Import_Function and Export_Function
634 -- cases). The argument names correspond to the allowed pragma
635 -- association identifiers.
637 procedure Process_Generic_List;
638 -- Common processing for Share_Generic and Inline_Generic
640 procedure Process_Import_Or_Interface;
641 -- Common processing for Import of Interface
643 procedure Process_Inline (Active : Boolean);
644 -- Common processing for Inline and Inline_Always. The parameter
645 -- indicates if the inline pragma is active, i.e. if it should
646 -- actually cause inlining to occur.
648 procedure Process_Interface_Name
649 (Subprogram_Def : Entity_Id;
652 -- Given the last two arguments of pragma Import, pragma Export, or
653 -- pragma Interface_Name, performs validity checks and sets the
654 -- Interface_Name field of the given subprogram entity to the
655 -- appropriate external or link name, depending on the arguments
656 -- given. Ext_Arg is always present, but Link_Arg may be missing.
657 -- Note that Ext_Arg may represent the Link_Name if Link_Arg is
658 -- missing, and appropriate named notation is used for Ext_Arg.
659 -- If neither Ext_Arg nor Link_Arg is present, the interface name
660 -- is set to the default from the subprogram name.
662 procedure Process_Interrupt_Or_Attach_Handler;
663 -- Common processing for Interrupt and Attach_Handler pragmas
665 procedure Process_Restrictions_Or_Restriction_Warnings (Warn : Boolean);
666 -- Common processing for Restrictions and Restriction_Warnings pragmas.
667 -- Warn is False for Restrictions, True for Restriction_Warnings.
669 procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean);
670 -- Common processing for Suppress and Unsuppress. The boolean parameter
671 -- Suppress_Case is True for the Suppress case, and False for the
674 procedure Set_Exported (E : Entity_Id; Arg : Node_Id);
675 -- This procedure sets the Is_Exported flag for the given entity,
676 -- checking that the entity was not previously imported. Arg is
677 -- the argument that specified the entity. A check is also made
678 -- for exporting inappropriate entities.
680 procedure Set_Extended_Import_Export_External_Name
681 (Internal_Ent : Entity_Id;
682 Arg_External : Node_Id);
683 -- Common processing for all extended import export pragmas. The first
684 -- argument, Internal_Ent, is the internal entity, which has already
685 -- been checked for validity by the caller. Arg_External is from the
686 -- Import or Export pragma, and may be null if no External parameter
687 -- was present. If Arg_External is present and is a non-null string
688 -- (a null string is treated as the default), then the Interface_Name
689 -- field of Internal_Ent is set appropriately.
691 procedure Set_Imported (E : Entity_Id);
692 -- This procedure sets the Is_Imported flag for the given entity,
693 -- checking that it is not previously exported or imported.
695 procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id);
696 -- Mech is a parameter passing mechanism (see Import_Function syntax
697 -- for MECHANISM_NAME). This routine checks that the mechanism argument
698 -- has the right form, and if not issues an error message. If the
699 -- argument has the right form then the Mechanism field of Ent is
700 -- set appropriately.
702 procedure Set_Ravenscar_Profile (N : Node_Id);
703 -- Activate the set of configuration pragmas and restrictions that
704 -- make up the Ravenscar Profile. N is the corresponding pragma
705 -- node, which is used for error messages on any constructs
706 -- that violate the profile.
708 ---------------------
709 -- Ada_2005_Pragma --
710 ---------------------
712 procedure Ada_2005_Pragma is
714 if Ada_Version <= Ada_95 then
715 Check_Restriction (No_Implementation_Pragmas, N);
719 --------------------------
720 -- Check_Ada_83_Warning --
721 --------------------------
723 procedure Check_Ada_83_Warning is
725 if Ada_Version = Ada_83 and then Comes_From_Source (N) then
726 Error_Msg_N ("(Ada 83) pragma& is non-standard?", N);
728 end Check_Ada_83_Warning;
730 ---------------------
731 -- Check_Arg_Count --
732 ---------------------
734 procedure Check_Arg_Count (Required : Nat) is
736 if Arg_Count /= Required then
737 Error_Pragma ("wrong number of arguments for pragma%");
741 --------------------------------
742 -- Check_Arg_Is_External_Name --
743 --------------------------------
745 procedure Check_Arg_Is_External_Name (Arg : Node_Id) is
746 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
749 if Nkind (Argx) = N_Identifier then
753 Analyze_And_Resolve (Argx, Standard_String);
755 if Is_OK_Static_Expression (Argx) then
758 elsif Etype (Argx) = Any_Type then
761 -- An interesting special case, if we have a string literal and
762 -- we are in Ada 83 mode, then we allow it even though it will
763 -- not be flagged as static. This allows expected Ada 83 mode
764 -- use of external names which are string literals, even though
765 -- technically these are not static in Ada 83.
767 elsif Ada_Version = Ada_83
768 and then Nkind (Argx) = N_String_Literal
772 -- Static expression that raises Constraint_Error. This has
773 -- already been flagged, so just exit from pragma processing.
775 elsif Is_Static_Expression (Argx) then
778 -- Here we have a real error (non-static expression)
781 Error_Msg_Name_1 := Pname;
783 ("argument for pragma% must be a identifier or " &
784 "static string expression!", Argx);
788 end Check_Arg_Is_External_Name;
790 -----------------------------
791 -- Check_Arg_Is_Identifier --
792 -----------------------------
794 procedure Check_Arg_Is_Identifier (Arg : Node_Id) is
795 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
797 if Nkind (Argx) /= N_Identifier then
799 ("argument for pragma% must be identifier", Argx);
801 end Check_Arg_Is_Identifier;
803 ----------------------------------
804 -- Check_Arg_Is_Integer_Literal --
805 ----------------------------------
807 procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id) is
808 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
810 if Nkind (Argx) /= N_Integer_Literal then
812 ("argument for pragma% must be integer literal", Argx);
814 end Check_Arg_Is_Integer_Literal;
816 -------------------------------------------
817 -- Check_Arg_Is_Library_Level_Local_Name --
818 -------------------------------------------
822 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
823 -- | library_unit_NAME
825 procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id) is
827 Check_Arg_Is_Local_Name (Arg);
829 if not Is_Library_Level_Entity (Entity (Expression (Arg)))
830 and then Comes_From_Source (N)
833 ("argument for pragma% must be library level entity", Arg);
835 end Check_Arg_Is_Library_Level_Local_Name;
837 -----------------------------
838 -- Check_Arg_Is_Local_Name --
839 -----------------------------
843 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
844 -- | library_unit_NAME
846 procedure Check_Arg_Is_Local_Name (Arg : Node_Id) is
847 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
852 if Nkind (Argx) not in N_Direct_Name
853 and then (Nkind (Argx) /= N_Attribute_Reference
854 or else Present (Expressions (Argx))
855 or else Nkind (Prefix (Argx)) /= N_Identifier)
856 and then (not Is_Entity_Name (Argx)
857 or else not Is_Compilation_Unit (Entity (Argx)))
859 Error_Pragma_Arg ("argument for pragma% must be local name", Argx);
862 if Is_Entity_Name (Argx)
863 and then Scope (Entity (Argx)) /= Current_Scope
866 ("pragma% argument must be in same declarative part", Arg);
868 end Check_Arg_Is_Local_Name;
870 ---------------------------------
871 -- Check_Arg_Is_Locking_Policy --
872 ---------------------------------
874 procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id) is
875 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
878 Check_Arg_Is_Identifier (Argx);
880 if not Is_Locking_Policy_Name (Chars (Argx)) then
882 ("& is not a valid locking policy name", Argx);
884 end Check_Arg_Is_Locking_Policy;
886 -------------------------
887 -- Check_Arg_Is_One_Of --
888 -------------------------
890 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id) is
891 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
894 Check_Arg_Is_Identifier (Argx);
896 if Chars (Argx) /= N1 and then Chars (Argx) /= N2 then
897 Error_Msg_Name_2 := N1;
898 Error_Msg_Name_3 := N2;
899 Error_Pragma_Arg ("argument for pragma% must be% or%", Argx);
901 end Check_Arg_Is_One_Of;
903 procedure Check_Arg_Is_One_Of
905 N1, N2, N3 : Name_Id)
907 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
910 Check_Arg_Is_Identifier (Argx);
912 if Chars (Argx) /= N1
913 and then Chars (Argx) /= N2
914 and then Chars (Argx) /= N3
916 Error_Pragma_Arg ("invalid argument for pragma%", Argx);
918 end Check_Arg_Is_One_Of;
920 procedure Check_Arg_Is_One_Of
922 N1, N2, N3, N4 : Name_Id)
924 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
927 Check_Arg_Is_Identifier (Argx);
929 if Chars (Argx) /= N1
930 and then Chars (Argx) /= N2
931 and then Chars (Argx) /= N3
932 and then Chars (Argx) /= N4
934 Error_Pragma_Arg ("invalid argument for pragma%", Argx);
936 end Check_Arg_Is_One_Of;
938 ---------------------------------
939 -- Check_Arg_Is_Queuing_Policy --
940 ---------------------------------
942 procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id) is
943 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
946 Check_Arg_Is_Identifier (Argx);
948 if not Is_Queuing_Policy_Name (Chars (Argx)) then
950 ("& is not a valid queuing policy name", Argx);
952 end Check_Arg_Is_Queuing_Policy;
954 ------------------------------------
955 -- Check_Arg_Is_Static_Expression --
956 ------------------------------------
958 procedure Check_Arg_Is_Static_Expression
962 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
965 Analyze_And_Resolve (Argx, Typ);
967 if Is_OK_Static_Expression (Argx) then
970 elsif Etype (Argx) = Any_Type then
973 -- An interesting special case, if we have a string literal and
974 -- we are in Ada 83 mode, then we allow it even though it will
975 -- not be flagged as static. This allows the use of Ada 95
976 -- pragmas like Import in Ada 83 mode. They will of course be
977 -- flagged with warnings as usual, but will not cause errors.
979 elsif Ada_Version = Ada_83
980 and then Nkind (Argx) = N_String_Literal
984 -- Static expression that raises Constraint_Error. This has
985 -- already been flagged, so just exit from pragma processing.
987 elsif Is_Static_Expression (Argx) then
990 -- Finally, we have a real error
993 Error_Msg_Name_1 := Pname;
995 ("argument for pragma% must be a static expression!", Argx);
998 end Check_Arg_Is_Static_Expression;
1000 ---------------------------------
1001 -- Check_Arg_Is_String_Literal --
1002 ---------------------------------
1004 procedure Check_Arg_Is_String_Literal (Arg : Node_Id) is
1005 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1007 if Nkind (Argx) /= N_String_Literal then
1009 ("argument for pragma% must be string literal", Argx);
1011 end Check_Arg_Is_String_Literal;
1013 ------------------------------------------
1014 -- Check_Arg_Is_Task_Dispatching_Policy --
1015 ------------------------------------------
1017 procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id) is
1018 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1021 Check_Arg_Is_Identifier (Argx);
1023 if not Is_Task_Dispatching_Policy_Name (Chars (Argx)) then
1025 ("& is not a valid task dispatching policy name", Argx);
1027 end Check_Arg_Is_Task_Dispatching_Policy;
1029 ---------------------
1030 -- Check_Arg_Order --
1031 ---------------------
1033 procedure Check_Arg_Order (Names : Name_List) is
1036 Highest_So_Far : Natural := 0;
1037 -- Highest index in Names seen do far
1041 for J in 1 .. Arg_Count loop
1042 if Chars (Arg) /= No_Name then
1043 for K in Names'Range loop
1044 if Chars (Arg) = Names (K) then
1045 if K < Highest_So_Far then
1046 Error_Msg_Name_1 := Pname;
1048 ("parameters out of order for pragma%", Arg);
1049 Error_Msg_Name_1 := Names (K);
1050 Error_Msg_Name_2 := Names (Highest_So_Far);
1051 Error_Msg_N ("\% must appear before %", Arg);
1055 Highest_So_Far := K;
1063 end Check_Arg_Order;
1065 --------------------------------
1066 -- Check_At_Least_N_Arguments --
1067 --------------------------------
1069 procedure Check_At_Least_N_Arguments (N : Nat) is
1071 if Arg_Count < N then
1072 Error_Pragma ("too few arguments for pragma%");
1074 end Check_At_Least_N_Arguments;
1076 -------------------------------
1077 -- Check_At_Most_N_Arguments --
1078 -------------------------------
1080 procedure Check_At_Most_N_Arguments (N : Nat) is
1083 if Arg_Count > N then
1085 for J in 1 .. N loop
1087 Error_Pragma_Arg ("too many arguments for pragma%", Arg);
1090 end Check_At_Most_N_Arguments;
1092 ---------------------
1093 -- Check_Component --
1094 ---------------------
1096 procedure Check_Component (Comp : Node_Id) is
1098 if Nkind (Comp) = N_Component_Declaration then
1100 Sindic : constant Node_Id :=
1101 Subtype_Indication (Component_Definition (Comp));
1102 Typ : constant Entity_Id :=
1103 Etype (Defining_Identifier (Comp));
1105 if Nkind (Sindic) = N_Subtype_Indication then
1107 -- Ada 2005 (AI-216): If a component subtype is subject to
1108 -- a per-object constraint, then the component type shall
1109 -- be an Unchecked_Union.
1111 if Has_Per_Object_Constraint (Defining_Identifier (Comp))
1113 not Is_Unchecked_Union (Etype (Subtype_Mark (Sindic)))
1115 Error_Msg_N ("component subtype subject to per-object" &
1116 " constraint must be an Unchecked_Union", Comp);
1120 if Is_Controlled (Typ) then
1122 ("component of unchecked union cannot be controlled", Comp);
1124 elsif Has_Task (Typ) then
1126 ("component of unchecked union cannot have tasks", Comp);
1130 end Check_Component;
1132 ----------------------------------
1133 -- Check_Duplicated_Export_Name --
1134 ----------------------------------
1136 procedure Check_Duplicated_Export_Name (Nam : Node_Id) is
1137 String_Val : constant String_Id := Strval (Nam);
1140 -- We are only interested in the export case, and in the case of
1141 -- generics, it is the instance, not the template, that is the
1142 -- problem (the template will generate a warning in any case).
1144 if not Inside_A_Generic
1145 and then (Prag_Id = Pragma_Export
1147 Prag_Id = Pragma_Export_Procedure
1149 Prag_Id = Pragma_Export_Valued_Procedure
1151 Prag_Id = Pragma_Export_Function)
1153 for J in Externals.First .. Externals.Last loop
1154 if String_Equal (String_Val, Strval (Externals.Table (J))) then
1155 Error_Msg_Sloc := Sloc (Externals.Table (J));
1156 Error_Msg_N ("external name duplicates name given#", Nam);
1161 Externals.Append (Nam);
1163 end Check_Duplicated_Export_Name;
1165 -------------------------
1166 -- Check_First_Subtype --
1167 -------------------------
1169 procedure Check_First_Subtype (Arg : Node_Id) is
1170 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1172 if not Is_First_Subtype (Entity (Argx)) then
1174 ("pragma% cannot apply to subtype", Argx);
1176 end Check_First_Subtype;
1178 ---------------------------
1179 -- Check_In_Main_Program --
1180 ---------------------------
1182 procedure Check_In_Main_Program is
1183 P : constant Node_Id := Parent (N);
1186 -- Must be at in subprogram body
1188 if Nkind (P) /= N_Subprogram_Body then
1189 Error_Pragma ("% pragma allowed only in subprogram");
1191 -- Otherwise warn if obviously not main program
1193 elsif Present (Parameter_Specifications (Specification (P)))
1194 or else not Is_Compilation_Unit (Defining_Entity (P))
1196 Error_Msg_Name_1 := Pname;
1198 ("?pragma% is only effective in main program", N);
1200 end Check_In_Main_Program;
1202 ---------------------------------------
1203 -- Check_Interrupt_Or_Attach_Handler --
1204 ---------------------------------------
1206 procedure Check_Interrupt_Or_Attach_Handler is
1207 Arg1_X : constant Node_Id := Expression (Arg1);
1208 Handler_Proc, Proc_Scope : Entity_Id;
1213 if Prag_Id = Pragma_Interrupt_Handler then
1214 Check_Restriction (No_Dynamic_Attachment, N);
1217 Handler_Proc := Find_Unique_Parameterless_Procedure (Arg1_X, Arg1);
1218 Proc_Scope := Scope (Handler_Proc);
1220 -- On AAMP only, a pragma Interrupt_Handler is supported for
1221 -- nonprotected parameterless procedures.
1223 if not AAMP_On_Target
1224 or else Prag_Id = Pragma_Attach_Handler
1226 if Ekind (Proc_Scope) /= E_Protected_Type then
1228 ("argument of pragma% must be protected procedure", Arg1);
1231 if Parent (N) /= Protected_Definition (Parent (Proc_Scope)) then
1232 Error_Pragma ("pragma% must be in protected definition");
1236 if not Is_Library_Level_Entity (Proc_Scope)
1237 or else (AAMP_On_Target
1238 and then not Is_Library_Level_Entity (Handler_Proc))
1241 ("argument for pragma% must be library level entity", Arg1);
1243 end Check_Interrupt_Or_Attach_Handler;
1245 -------------------------------------------
1246 -- Check_Is_In_Decl_Part_Or_Package_Spec --
1247 -------------------------------------------
1249 procedure Check_Is_In_Decl_Part_Or_Package_Spec is
1258 elsif Nkind (P) = N_Handled_Sequence_Of_Statements then
1261 elsif Nkind (P) = N_Package_Specification then
1264 elsif Nkind (P) = N_Block_Statement then
1267 -- Note: the following tests seem a little peculiar, because
1268 -- they test for bodies, but if we were in the statement part
1269 -- of the body, we would already have hit the handled statement
1270 -- sequence, so the only way we get here is by being in the
1271 -- declarative part of the body.
1273 elsif Nkind (P) = N_Subprogram_Body
1274 or else Nkind (P) = N_Package_Body
1275 or else Nkind (P) = N_Task_Body
1276 or else Nkind (P) = N_Entry_Body
1284 Error_Pragma ("pragma% is not in declarative part or package spec");
1285 end Check_Is_In_Decl_Part_Or_Package_Spec;
1287 -------------------------
1288 -- Check_No_Identifier --
1289 -------------------------
1291 procedure Check_No_Identifier (Arg : Node_Id) is
1293 if Chars (Arg) /= No_Name then
1294 Error_Pragma_Arg_Ident
1295 ("pragma% does not permit identifier& here", Arg);
1297 end Check_No_Identifier;
1299 --------------------------
1300 -- Check_No_Identifiers --
1301 --------------------------
1303 procedure Check_No_Identifiers is
1306 if Arg_Count > 0 then
1308 while Present (Arg_Node) loop
1309 Check_No_Identifier (Arg_Node);
1313 end Check_No_Identifiers;
1315 -------------------------------
1316 -- Check_Optional_Identifier --
1317 -------------------------------
1319 procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id) is
1321 if Present (Arg) and then Chars (Arg) /= No_Name then
1322 if Chars (Arg) /= Id then
1323 Error_Msg_Name_1 := Pname;
1324 Error_Msg_Name_2 := Id;
1325 Error_Msg_N ("pragma% argument expects identifier%", Arg);
1329 end Check_Optional_Identifier;
1331 procedure Check_Optional_Identifier (Arg : Node_Id; Id : String) is
1333 Name_Buffer (1 .. Id'Length) := Id;
1334 Name_Len := Id'Length;
1335 Check_Optional_Identifier (Arg, Name_Find);
1336 end Check_Optional_Identifier;
1338 --------------------------------------
1339 -- Check_Precondition_Postcondition --
1340 --------------------------------------
1342 procedure Check_Precondition_Postcondition (In_Body : out Boolean) is
1348 if not Is_List_Member (N) then
1352 -- Record whether pragma is enabled
1354 Set_PPC_Enabled (N, Check_Enabled (Pname));
1356 -- Search prior declarations
1359 while Present (Prev (P)) loop
1361 PO := Original_Node (P);
1363 -- Skip past prior pragma
1365 if Nkind (PO) = N_Pragma then
1368 -- Skip stuff not coming from source
1370 elsif not Comes_From_Source (PO) then
1373 -- Here if we hit a subprogram declaration
1375 elsif Nkind (PO) = N_Subprogram_Declaration then
1376 S := Defining_Unit_Name (Specification (PO));
1378 -- Analyze the pragma unless it appears within a package spec,
1379 -- which is the case where we delay the analysis of the PPC
1380 -- until the end of the package declarations (for details,
1381 -- see Analyze_Package_Specification.Analyze_PPCs).
1383 if Ekind (Scope (S)) /= E_Package
1385 Ekind (Scope (S)) /= E_Generic_Package
1387 Analyze_PPC_In_Decl_Part (N, S);
1390 -- Chain spec PPC pragma to list for subprogram
1392 Set_Next_Pragma (N, Spec_PPC_List (S));
1393 Set_Spec_PPC_List (S, N);
1395 -- Return indicating spec case
1400 -- If we encounter any other declaration moving back, misplaced
1407 -- If we fall through loop, pragma is at start of list, so see if
1408 -- it is at the start of declarations of a subprogram body.
1410 if Nkind (Parent (N)) = N_Subprogram_Body
1411 and then List_Containing (N) = Declarations (Parent (N))
1416 -- If not, it was misplaced
1421 end Check_Precondition_Postcondition;
1423 -----------------------------
1424 -- Check_Static_Constraint --
1425 -----------------------------
1427 -- Note: for convenience in writing this procedure, in addition to
1428 -- the officially (i.e. by spec) allowed argument which is always
1429 -- a constraint, it also allows ranges and discriminant associations.
1430 -- Above is not clear ???
1432 procedure Check_Static_Constraint (Constr : Node_Id) is
1434 procedure Require_Static (E : Node_Id);
1435 -- Require given expression to be static expression
1437 --------------------
1438 -- Require_Static --
1439 --------------------
1441 procedure Require_Static (E : Node_Id) is
1443 if not Is_OK_Static_Expression (E) then
1444 Flag_Non_Static_Expr
1445 ("non-static constraint not allowed in Unchecked_Union!", E);
1450 -- Start of processing for Check_Static_Constraint
1453 case Nkind (Constr) is
1454 when N_Discriminant_Association =>
1455 Require_Static (Expression (Constr));
1458 Require_Static (Low_Bound (Constr));
1459 Require_Static (High_Bound (Constr));
1461 when N_Attribute_Reference =>
1462 Require_Static (Type_Low_Bound (Etype (Prefix (Constr))));
1463 Require_Static (Type_High_Bound (Etype (Prefix (Constr))));
1465 when N_Range_Constraint =>
1466 Check_Static_Constraint (Range_Expression (Constr));
1468 when N_Index_Or_Discriminant_Constraint =>
1472 IDC := First (Constraints (Constr));
1473 while Present (IDC) loop
1474 Check_Static_Constraint (IDC);
1482 end Check_Static_Constraint;
1484 --------------------------------------
1485 -- Check_Valid_Configuration_Pragma --
1486 --------------------------------------
1488 -- A configuration pragma must appear in the context clause of a
1489 -- compilation unit, and only other pragmas may precede it. Note that
1490 -- the test also allows use in a configuration pragma file.
1492 procedure Check_Valid_Configuration_Pragma is
1494 if not Is_Configuration_Pragma then
1495 Error_Pragma ("incorrect placement for configuration pragma%");
1497 end Check_Valid_Configuration_Pragma;
1499 -------------------------------------
1500 -- Check_Valid_Library_Unit_Pragma --
1501 -------------------------------------
1503 procedure Check_Valid_Library_Unit_Pragma is
1505 Parent_Node : Node_Id;
1506 Unit_Name : Entity_Id;
1507 Unit_Kind : Node_Kind;
1508 Unit_Node : Node_Id;
1509 Sindex : Source_File_Index;
1512 if not Is_List_Member (N) then
1516 Plist := List_Containing (N);
1517 Parent_Node := Parent (Plist);
1519 if Parent_Node = Empty then
1522 -- Case of pragma appearing after a compilation unit. In this
1523 -- case it must have an argument with the corresponding name
1524 -- and must be part of the following pragmas of its parent.
1526 elsif Nkind (Parent_Node) = N_Compilation_Unit_Aux then
1527 if Plist /= Pragmas_After (Parent_Node) then
1530 elsif Arg_Count = 0 then
1532 ("argument required if outside compilation unit");
1535 Check_No_Identifiers;
1536 Check_Arg_Count (1);
1537 Unit_Node := Unit (Parent (Parent_Node));
1538 Unit_Kind := Nkind (Unit_Node);
1540 Analyze (Expression (Arg1));
1542 if Unit_Kind = N_Generic_Subprogram_Declaration
1543 or else Unit_Kind = N_Subprogram_Declaration
1545 Unit_Name := Defining_Entity (Unit_Node);
1547 elsif Unit_Kind in N_Generic_Instantiation then
1548 Unit_Name := Defining_Entity (Unit_Node);
1551 Unit_Name := Cunit_Entity (Current_Sem_Unit);
1554 if Chars (Unit_Name) /=
1555 Chars (Entity (Expression (Arg1)))
1558 ("pragma% argument is not current unit name", Arg1);
1561 if Ekind (Unit_Name) = E_Package
1562 and then Present (Renamed_Entity (Unit_Name))
1564 Error_Pragma ("pragma% not allowed for renamed package");
1568 -- Pragma appears other than after a compilation unit
1571 -- Here we check for the generic instantiation case and also
1572 -- for the case of processing a generic formal package. We
1573 -- detect these cases by noting that the Sloc on the node
1574 -- does not belong to the current compilation unit.
1576 Sindex := Source_Index (Current_Sem_Unit);
1578 if Loc not in Source_First (Sindex) .. Source_Last (Sindex) then
1579 Rewrite (N, Make_Null_Statement (Loc));
1582 -- If before first declaration, the pragma applies to the
1583 -- enclosing unit, and the name if present must be this name.
1585 elsif Is_Before_First_Decl (N, Plist) then
1586 Unit_Node := Unit_Declaration_Node (Current_Scope);
1587 Unit_Kind := Nkind (Unit_Node);
1589 if Nkind (Parent (Unit_Node)) /= N_Compilation_Unit then
1592 elsif Unit_Kind = N_Subprogram_Body
1593 and then not Acts_As_Spec (Unit_Node)
1597 elsif Nkind (Parent_Node) = N_Package_Body then
1600 elsif Nkind (Parent_Node) = N_Package_Specification
1601 and then Plist = Private_Declarations (Parent_Node)
1605 elsif (Nkind (Parent_Node) = N_Generic_Package_Declaration
1606 or else Nkind (Parent_Node) =
1607 N_Generic_Subprogram_Declaration)
1608 and then Plist = Generic_Formal_Declarations (Parent_Node)
1612 elsif Arg_Count > 0 then
1613 Analyze (Expression (Arg1));
1615 if Entity (Expression (Arg1)) /= Current_Scope then
1617 ("name in pragma% must be enclosing unit", Arg1);
1620 -- It is legal to have no argument in this context
1626 -- Error if not before first declaration. This is because a
1627 -- library unit pragma argument must be the name of a library
1628 -- unit (RM 10.1.5(7)), but the only names permitted in this
1629 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1630 -- generic subprogram declarations or generic instantiations.
1634 ("pragma% misplaced, must be before first declaration");
1638 end Check_Valid_Library_Unit_Pragma;
1644 procedure Check_Variant (Variant : Node_Id) is
1645 Clist : constant Node_Id := Component_List (Variant);
1649 if not Is_Non_Empty_List (Component_Items (Clist)) then
1651 ("Unchecked_Union may not have empty component list",
1656 Comp := First (Component_Items (Clist));
1657 while Present (Comp) loop
1658 Check_Component (Comp);
1667 procedure Error_Pragma (Msg : String) is
1669 Error_Msg_Name_1 := Pname;
1670 Error_Msg_N (Msg, N);
1674 ----------------------
1675 -- Error_Pragma_Arg --
1676 ----------------------
1678 procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id) is
1680 Error_Msg_Name_1 := Pname;
1681 Error_Msg_N (Msg, Get_Pragma_Arg (Arg));
1683 end Error_Pragma_Arg;
1685 procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id) is
1687 Error_Msg_Name_1 := Pname;
1688 Error_Msg_N (Msg1, Get_Pragma_Arg (Arg));
1689 Error_Pragma_Arg (Msg2, Arg);
1690 end Error_Pragma_Arg;
1692 ----------------------------
1693 -- Error_Pragma_Arg_Ident --
1694 ----------------------------
1696 procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id) is
1698 Error_Msg_Name_1 := Pname;
1699 Error_Msg_N (Msg, Arg);
1701 end Error_Pragma_Arg_Ident;
1703 ------------------------
1704 -- Find_Lib_Unit_Name --
1705 ------------------------
1707 function Find_Lib_Unit_Name return Entity_Id is
1709 -- Return inner compilation unit entity, for case of nested
1710 -- categorization pragmas. This happens in generic unit.
1712 if Nkind (Parent (N)) = N_Package_Specification
1713 and then Defining_Entity (Parent (N)) /= Current_Scope
1715 return Defining_Entity (Parent (N));
1717 return Current_Scope;
1719 end Find_Lib_Unit_Name;
1721 ----------------------------
1722 -- Find_Program_Unit_Name --
1723 ----------------------------
1725 procedure Find_Program_Unit_Name (Id : Node_Id) is
1726 Unit_Name : Entity_Id;
1727 Unit_Kind : Node_Kind;
1728 P : constant Node_Id := Parent (N);
1731 if Nkind (P) = N_Compilation_Unit then
1732 Unit_Kind := Nkind (Unit (P));
1734 if Unit_Kind = N_Subprogram_Declaration
1735 or else Unit_Kind = N_Package_Declaration
1736 or else Unit_Kind in N_Generic_Declaration
1738 Unit_Name := Defining_Entity (Unit (P));
1740 if Chars (Id) = Chars (Unit_Name) then
1741 Set_Entity (Id, Unit_Name);
1742 Set_Etype (Id, Etype (Unit_Name));
1744 Set_Etype (Id, Any_Type);
1746 ("cannot find program unit referenced by pragma%");
1750 Set_Etype (Id, Any_Type);
1751 Error_Pragma ("pragma% inapplicable to this unit");
1757 end Find_Program_Unit_Name;
1759 -----------------------------------------
1760 -- Find_Unique_Parameterless_Procedure --
1761 -----------------------------------------
1763 function Find_Unique_Parameterless_Procedure
1765 Arg : Node_Id) return Entity_Id
1767 Proc : Entity_Id := Empty;
1770 -- The body of this procedure needs some comments ???
1772 if not Is_Entity_Name (Name) then
1774 ("argument of pragma% must be entity name", Arg);
1776 elsif not Is_Overloaded (Name) then
1777 Proc := Entity (Name);
1779 if Ekind (Proc) /= E_Procedure
1780 or else Present (First_Formal (Proc)) then
1782 ("argument of pragma% must be parameterless procedure", Arg);
1787 Found : Boolean := False;
1789 Index : Interp_Index;
1792 Get_First_Interp (Name, Index, It);
1793 while Present (It.Nam) loop
1796 if Ekind (Proc) = E_Procedure
1797 and then No (First_Formal (Proc))
1801 Set_Entity (Name, Proc);
1802 Set_Is_Overloaded (Name, False);
1805 ("ambiguous handler name for pragma% ", Arg);
1809 Get_Next_Interp (Index, It);
1814 ("argument of pragma% must be parameterless procedure",
1817 Proc := Entity (Name);
1823 end Find_Unique_Parameterless_Procedure;
1825 -------------------------
1826 -- Gather_Associations --
1827 -------------------------
1829 procedure Gather_Associations
1831 Args : out Args_List)
1836 -- Initialize all parameters to Empty
1838 for J in Args'Range loop
1842 -- That's all we have to do if there are no argument associations
1844 if No (Pragma_Argument_Associations (N)) then
1848 -- Otherwise first deal with any positional parameters present
1850 Arg := First (Pragma_Argument_Associations (N));
1851 for Index in Args'Range loop
1852 exit when No (Arg) or else Chars (Arg) /= No_Name;
1853 Args (Index) := Expression (Arg);
1857 -- Positional parameters all processed, if any left, then we
1858 -- have too many positional parameters.
1860 if Present (Arg) and then Chars (Arg) = No_Name then
1862 ("too many positional associations for pragma%", Arg);
1865 -- Process named parameters if any are present
1867 while Present (Arg) loop
1868 if Chars (Arg) = No_Name then
1870 ("positional association cannot follow named association",
1874 for Index in Names'Range loop
1875 if Names (Index) = Chars (Arg) then
1876 if Present (Args (Index)) then
1878 ("duplicate argument association for pragma%", Arg);
1880 Args (Index) := Expression (Arg);
1885 if Index = Names'Last then
1886 Error_Msg_Name_1 := Pname;
1887 Error_Msg_N ("pragma% does not allow & argument", Arg);
1889 -- Check for possible misspelling
1891 for Index1 in Names'Range loop
1892 if Is_Bad_Spelling_Of
1893 (Chars (Arg), Names (Index1))
1895 Error_Msg_Name_1 := Names (Index1);
1896 Error_Msg_N ("\possible misspelling of%", Arg);
1908 end Gather_Associations;
1914 procedure GNAT_Pragma is
1916 Check_Restriction (No_Implementation_Pragmas, N);
1919 --------------------------
1920 -- Is_Before_First_Decl --
1921 --------------------------
1923 function Is_Before_First_Decl
1924 (Pragma_Node : Node_Id;
1925 Decls : List_Id) return Boolean
1927 Item : Node_Id := First (Decls);
1930 -- Only other pragmas can come before this pragma
1933 if No (Item) or else Nkind (Item) /= N_Pragma then
1936 elsif Item = Pragma_Node then
1942 end Is_Before_First_Decl;
1944 -----------------------------
1945 -- Is_Configuration_Pragma --
1946 -----------------------------
1948 -- A configuration pragma must appear in the context clause of a
1949 -- compilation unit, and only other pragmas may precede it. Note that
1950 -- the test below also permits use in a configuration pragma file.
1952 function Is_Configuration_Pragma return Boolean is
1953 Lis : constant List_Id := List_Containing (N);
1954 Par : constant Node_Id := Parent (N);
1958 -- If no parent, then we are in the configuration pragma file,
1959 -- so the placement is definitely appropriate.
1964 -- Otherwise we must be in the context clause of a compilation unit
1965 -- and the only thing allowed before us in the context list is more
1966 -- configuration pragmas.
1968 elsif Nkind (Par) = N_Compilation_Unit
1969 and then Context_Items (Par) = Lis
1976 elsif Nkind (Prg) /= N_Pragma then
1986 end Is_Configuration_Pragma;
1988 --------------------------
1989 -- Is_In_Context_Clause --
1990 --------------------------
1992 function Is_In_Context_Clause return Boolean is
1994 Parent_Node : Node_Id;
1997 if not Is_List_Member (N) then
2001 Plist := List_Containing (N);
2002 Parent_Node := Parent (Plist);
2004 if Parent_Node = Empty
2005 or else Nkind (Parent_Node) /= N_Compilation_Unit
2006 or else Context_Items (Parent_Node) /= Plist
2013 end Is_In_Context_Clause;
2015 ---------------------------------
2016 -- Is_Static_String_Expression --
2017 ---------------------------------
2019 function Is_Static_String_Expression (Arg : Node_Id) return Boolean is
2020 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
2023 Analyze_And_Resolve (Argx);
2024 return Is_OK_Static_Expression (Argx)
2025 and then Nkind (Argx) = N_String_Literal;
2026 end Is_Static_String_Expression;
2028 ----------------------
2029 -- Pragma_Misplaced --
2030 ----------------------
2032 procedure Pragma_Misplaced is
2034 Error_Pragma ("incorrect placement of pragma%");
2035 end Pragma_Misplaced;
2037 ------------------------------------
2038 -- Process Atomic_Shared_Volatile --
2039 ------------------------------------
2041 procedure Process_Atomic_Shared_Volatile is
2048 procedure Set_Atomic (E : Entity_Id);
2049 -- Set given type as atomic, and if no explicit alignment was given,
2050 -- set alignment to unknown, since back end knows what the alignment
2051 -- requirements are for atomic arrays. Note: this step is necessary
2052 -- for derived types.
2058 procedure Set_Atomic (E : Entity_Id) is
2062 if not Has_Alignment_Clause (E) then
2063 Set_Alignment (E, Uint_0);
2067 -- Start of processing for Process_Atomic_Shared_Volatile
2070 Check_Ada_83_Warning;
2071 Check_No_Identifiers;
2072 Check_Arg_Count (1);
2073 Check_Arg_Is_Local_Name (Arg1);
2074 E_Id := Expression (Arg1);
2076 if Etype (E_Id) = Any_Type then
2081 D := Declaration_Node (E);
2085 if Rep_Item_Too_Early (E, N)
2087 Rep_Item_Too_Late (E, N)
2091 Check_First_Subtype (Arg1);
2094 if Prag_Id /= Pragma_Volatile then
2096 Set_Atomic (Underlying_Type (E));
2097 Set_Atomic (Base_Type (E));
2100 -- Attribute belongs on the base type. If the view of the type is
2101 -- currently private, it also belongs on the underlying type.
2103 Set_Is_Volatile (Base_Type (E));
2104 Set_Is_Volatile (Underlying_Type (E));
2106 Set_Treat_As_Volatile (E);
2107 Set_Treat_As_Volatile (Underlying_Type (E));
2109 elsif K = N_Object_Declaration
2110 or else (K = N_Component_Declaration
2111 and then Original_Record_Component (E) = E)
2113 if Rep_Item_Too_Late (E, N) then
2117 if Prag_Id /= Pragma_Volatile then
2120 -- If the object declaration has an explicit initialization, a
2121 -- temporary may have to be created to hold the expression, to
2122 -- ensure that access to the object remain atomic.
2124 if Nkind (Parent (E)) = N_Object_Declaration
2125 and then Present (Expression (Parent (E)))
2127 Set_Has_Delayed_Freeze (E);
2130 -- An interesting improvement here. If an object of type X
2131 -- is declared atomic, and the type X is not atomic, that's
2132 -- a pity, since it may not have appropriate alignment etc.
2133 -- We can rescue this in the special case where the object
2134 -- and type are in the same unit by just setting the type
2135 -- as atomic, so that the back end will process it as atomic.
2137 Utyp := Underlying_Type (Etype (E));
2140 and then Sloc (E) > No_Location
2141 and then Sloc (Utyp) > No_Location
2143 Get_Source_File_Index (Sloc (E)) =
2144 Get_Source_File_Index (Sloc (Underlying_Type (Etype (E))))
2146 Set_Is_Atomic (Underlying_Type (Etype (E)));
2150 Set_Is_Volatile (E);
2151 Set_Treat_As_Volatile (E);
2155 ("inappropriate entity for pragma%", Arg1);
2157 end Process_Atomic_Shared_Volatile;
2159 -------------------------------------------
2160 -- Process_Compile_Time_Warning_Or_Error --
2161 -------------------------------------------
2163 procedure Process_Compile_Time_Warning_Or_Error is
2164 Arg1x : constant Node_Id := Get_Pragma_Arg (Arg1);
2168 Check_Arg_Count (2);
2169 Check_No_Identifiers;
2170 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
2171 Analyze_And_Resolve (Arg1x, Standard_Boolean);
2173 if Compile_Time_Known_Value (Arg1x) then
2174 if Is_True (Expr_Value (Get_Pragma_Arg (Arg1))) then
2176 Str : constant String_Id :=
2177 Strval (Get_Pragma_Arg (Arg2));
2178 Len : constant Int := String_Length (Str);
2183 Cent : constant Entity_Id :=
2184 Cunit_Entity (Current_Sem_Unit);
2186 Force : constant Boolean :=
2187 Prag_Id = Pragma_Compile_Time_Warning
2189 Is_Spec_Name (Unit_Name (Current_Sem_Unit))
2190 and then (Ekind (Cent) /= E_Package
2191 or else not In_Private_Part (Cent));
2192 -- Set True if this is the warning case, and we are in the
2193 -- visible part of a package spec, or in a subprogram spec,
2194 -- in which case we want to force the client to see the
2195 -- warning, even though it is not in the main unit.
2198 -- Loop through segments of message separated by line
2199 -- feeds. We output these segments as separate messages
2200 -- with continuation marks for all but the first.
2205 Error_Msg_Strlen := 0;
2207 -- Loop to copy characters from argument to error
2208 -- message string buffer.
2211 exit when Ptr > Len;
2212 CC := Get_String_Char (Str, Ptr);
2215 -- Ignore wide chars ??? else store character
2217 if In_Character_Range (CC) then
2218 C := Get_Character (CC);
2219 exit when C = ASCII.LF;
2220 Error_Msg_Strlen := Error_Msg_Strlen + 1;
2221 Error_Msg_String (Error_Msg_Strlen) := C;
2225 -- Here with one line ready to go
2227 Error_Msg_Warn := Prag_Id = Pragma_Compile_Time_Warning;
2229 -- If this is a warning in a spec, then we want clients
2230 -- to see the warning, so mark the message with the
2231 -- special sequence !! to force the warning. In the case
2232 -- of a package spec, we do not force this if we are in
2233 -- the private part of the spec.
2236 if Cont = False then
2237 Error_Msg_N ("<~!!", Arg1);
2240 Error_Msg_N ("\<~!!", Arg1);
2243 -- Error, rather than warning, or in a body, so we do not
2244 -- need to force visibility for client (error will be
2245 -- output in any case, and this is the situation in which
2246 -- we do not want a client to get a warning, since the
2247 -- warning is in the body or the spec private part.
2250 if Cont = False then
2251 Error_Msg_N ("<~", Arg1);
2254 Error_Msg_N ("\<~", Arg1);
2258 exit when Ptr > Len;
2263 end Process_Compile_Time_Warning_Or_Error;
2265 ------------------------
2266 -- Process_Convention --
2267 ------------------------
2269 procedure Process_Convention
2270 (C : out Convention_Id;
2276 Comp_Unit : Unit_Number_Type;
2278 procedure Set_Convention_From_Pragma (E : Entity_Id);
2279 -- Set convention in entity E, and also flag that the entity has a
2280 -- convention pragma. If entity is for a private or incomplete type,
2281 -- also set convention and flag on underlying type. This procedure
2282 -- also deals with the special case of C_Pass_By_Copy convention.
2284 --------------------------------
2285 -- Set_Convention_From_Pragma --
2286 --------------------------------
2288 procedure Set_Convention_From_Pragma (E : Entity_Id) is
2290 -- Ada 2005 (AI-430): Check invalid attempt to change convention
2291 -- for an overridden dispatching operation. Technically this is
2292 -- an amendment and should only be done in Ada 2005 mode. However,
2293 -- this is clearly a mistake, since the problem that is addressed
2294 -- by this AI is that there is a clear gap in the RM!
2296 if Is_Dispatching_Operation (E)
2297 and then Present (Overridden_Operation (E))
2298 and then C /= Convention (Overridden_Operation (E))
2301 ("cannot change convention for " &
2302 "overridden dispatching operation",
2306 -- Set the convention
2308 Set_Convention (E, C);
2309 Set_Has_Convention_Pragma (E);
2311 if Is_Incomplete_Or_Private_Type (E) then
2312 Set_Convention (Underlying_Type (E), C);
2313 Set_Has_Convention_Pragma (Underlying_Type (E), True);
2316 -- A class-wide type should inherit the convention of
2317 -- the specific root type (although this isn't specified
2318 -- clearly by the RM).
2320 if Is_Type (E) and then Present (Class_Wide_Type (E)) then
2321 Set_Convention (Class_Wide_Type (E), C);
2324 -- If the entity is a record type, then check for special case of
2325 -- C_Pass_By_Copy, which is treated the same as C except that the
2326 -- special record flag is set. This convention is only permitted
2327 -- on record types (see AI95-00131).
2329 if Cname = Name_C_Pass_By_Copy then
2330 if Is_Record_Type (E) then
2331 Set_C_Pass_By_Copy (Base_Type (E));
2332 elsif Is_Incomplete_Or_Private_Type (E)
2333 and then Is_Record_Type (Underlying_Type (E))
2335 Set_C_Pass_By_Copy (Base_Type (Underlying_Type (E)));
2338 ("C_Pass_By_Copy convention allowed only for record type",
2343 -- If the entity is a derived boolean type, check for the
2344 -- special case of convention C, C++, or Fortran, where we
2345 -- consider any nonzero value to represent true.
2347 if Is_Discrete_Type (E)
2348 and then Root_Type (Etype (E)) = Standard_Boolean
2354 C = Convention_Fortran)
2356 Set_Nonzero_Is_True (Base_Type (E));
2358 end Set_Convention_From_Pragma;
2360 -- Start of processing for Process_Convention
2363 Check_At_Least_N_Arguments (2);
2364 Check_Optional_Identifier (Arg1, Name_Convention);
2365 Check_Arg_Is_Identifier (Arg1);
2366 Cname := Chars (Expression (Arg1));
2368 -- C_Pass_By_Copy is treated as a synonym for convention C
2369 -- (this is tested again below to set the critical flag)
2371 if Cname = Name_C_Pass_By_Copy then
2374 -- Otherwise we must have something in the standard convention list
2376 elsif Is_Convention_Name (Cname) then
2377 C := Get_Convention_Id (Chars (Expression (Arg1)));
2379 -- In DEC VMS, it seems that there is an undocumented feature that
2380 -- any unrecognized convention is treated as the default, which for
2381 -- us is convention C. It does not seem so terrible to do this
2382 -- unconditionally, silently in the VMS case, and with a warning
2383 -- in the non-VMS case.
2386 if Warn_On_Export_Import and not OpenVMS_On_Target then
2388 ("?unrecognized convention name, C assumed",
2395 Check_Optional_Identifier (Arg2, Name_Entity);
2396 Check_Arg_Is_Local_Name (Arg2);
2398 Id := Expression (Arg2);
2401 if not Is_Entity_Name (Id) then
2402 Error_Pragma_Arg ("entity name required", Arg2);
2407 -- Go to renamed subprogram if present, since convention applies to
2408 -- the actual renamed entity, not to the renaming entity. If the
2409 -- subprogram is inherited, go to parent subprogram.
2411 if Is_Subprogram (E)
2412 and then Present (Alias (E))
2414 if Nkind (Parent (Declaration_Node (E))) =
2415 N_Subprogram_Renaming_Declaration
2419 elsif Nkind (Parent (E)) = N_Full_Type_Declaration
2420 and then Scope (E) = Scope (Alias (E))
2426 -- Check that we are not applying this to a specless body
2428 if Is_Subprogram (E)
2429 and then Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Body
2432 ("pragma% requires separate spec and must come before body");
2435 -- Check that we are not applying this to a named constant
2437 if Ekind (E) = E_Named_Integer
2439 Ekind (E) = E_Named_Real
2441 Error_Msg_Name_1 := Pname;
2443 ("cannot apply pragma% to named constant!",
2444 Get_Pragma_Arg (Arg2));
2446 ("\supply appropriate type for&!", Arg2);
2449 if Ekind (E) = E_Enumeration_Literal then
2450 Error_Pragma ("enumeration literal not allowed for pragma%");
2453 -- Check for rep item appearing too early or too late
2455 if Etype (E) = Any_Type
2456 or else Rep_Item_Too_Early (E, N)
2460 E := Underlying_Type (E);
2463 if Rep_Item_Too_Late (E, N) then
2467 if Has_Convention_Pragma (E) then
2469 ("at most one Convention/Export/Import pragma is allowed", Arg2);
2471 elsif Convention (E) = Convention_Protected
2472 or else Ekind (Scope (E)) = E_Protected_Type
2475 ("a protected operation cannot be given a different convention",
2479 -- For Intrinsic, a subprogram is required
2481 if C = Convention_Intrinsic
2482 and then not Is_Subprogram (E)
2483 and then not Is_Generic_Subprogram (E)
2486 ("second argument of pragma% must be a subprogram", Arg2);
2489 -- For Stdcall, a subprogram, variable or subprogram type is required
2491 if C = Convention_Stdcall
2492 and then not Is_Subprogram (E)
2493 and then not Is_Generic_Subprogram (E)
2494 and then Ekind (E) /= E_Variable
2497 and then Ekind (Designated_Type (E)) = E_Subprogram_Type)
2500 ("second argument of pragma% must be subprogram (type)",
2504 if not Is_Subprogram (E)
2505 and then not Is_Generic_Subprogram (E)
2507 Set_Convention_From_Pragma (E);
2511 Check_First_Subtype (Arg2);
2512 Set_Convention_From_Pragma (Base_Type (E));
2514 -- For subprograms, we must set the convention on the
2515 -- internally generated directly designated type as well.
2517 if Ekind (E) = E_Access_Subprogram_Type then
2518 Set_Convention_From_Pragma (Directly_Designated_Type (E));
2522 -- For the subprogram case, set proper convention for all homonyms
2523 -- in same scope and the same declarative part, i.e. the same
2524 -- compilation unit.
2527 Comp_Unit := Get_Source_Unit (E);
2528 Set_Convention_From_Pragma (E);
2530 -- Treat a pragma Import as an implicit body, for GPS use
2532 if Prag_Id = Pragma_Import then
2533 Generate_Reference (E, Id, 'b');
2539 exit when No (E1) or else Scope (E1) /= Current_Scope;
2541 -- Do not set the pragma on inherited operations or on
2542 -- formal subprograms.
2544 if Comes_From_Source (E1)
2545 and then Comp_Unit = Get_Source_Unit (E1)
2546 and then not Is_Formal_Subprogram (E1)
2547 and then Nkind (Original_Node (Parent (E1))) /=
2548 N_Full_Type_Declaration
2550 Set_Convention_From_Pragma (E1);
2552 if Prag_Id = Pragma_Import then
2553 Generate_Reference (E, Id, 'b');
2558 end Process_Convention;
2560 -----------------------------------------------------
2561 -- Process_Extended_Import_Export_Exception_Pragma --
2562 -----------------------------------------------------
2564 procedure Process_Extended_Import_Export_Exception_Pragma
2565 (Arg_Internal : Node_Id;
2566 Arg_External : Node_Id;
2576 if not OpenVMS_On_Target then
2578 ("?pragma% ignored (applies only to Open'V'M'S)");
2581 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2582 Def_Id := Entity (Arg_Internal);
2584 if Ekind (Def_Id) /= E_Exception then
2586 ("pragma% must refer to declared exception", Arg_Internal);
2589 Set_Extended_Import_Export_External_Name (Def_Id, Arg_External);
2591 if Present (Arg_Form) then
2592 Check_Arg_Is_One_Of (Arg_Form, Name_Ada, Name_VMS);
2595 if Present (Arg_Form)
2596 and then Chars (Arg_Form) = Name_Ada
2600 Set_Is_VMS_Exception (Def_Id);
2601 Set_Exception_Code (Def_Id, No_Uint);
2604 if Present (Arg_Code) then
2605 if not Is_VMS_Exception (Def_Id) then
2607 ("Code option for pragma% not allowed for Ada case",
2611 Check_Arg_Is_Static_Expression (Arg_Code, Any_Integer);
2612 Code_Val := Expr_Value (Arg_Code);
2614 if not UI_Is_In_Int_Range (Code_Val) then
2616 ("Code option for pragma% must be in 32-bit range",
2620 Set_Exception_Code (Def_Id, Code_Val);
2623 end Process_Extended_Import_Export_Exception_Pragma;
2625 -------------------------------------------------
2626 -- Process_Extended_Import_Export_Internal_Arg --
2627 -------------------------------------------------
2629 procedure Process_Extended_Import_Export_Internal_Arg
2630 (Arg_Internal : Node_Id := Empty)
2635 if No (Arg_Internal) then
2636 Error_Pragma ("Internal parameter required for pragma%");
2639 if Nkind (Arg_Internal) = N_Identifier then
2642 elsif Nkind (Arg_Internal) = N_Operator_Symbol
2643 and then (Prag_Id = Pragma_Import_Function
2645 Prag_Id = Pragma_Export_Function)
2651 ("wrong form for Internal parameter for pragma%", Arg_Internal);
2654 Check_Arg_Is_Local_Name (Arg_Internal);
2655 end Process_Extended_Import_Export_Internal_Arg;
2657 --------------------------------------------------
2658 -- Process_Extended_Import_Export_Object_Pragma --
2659 --------------------------------------------------
2661 procedure Process_Extended_Import_Export_Object_Pragma
2662 (Arg_Internal : Node_Id;
2663 Arg_External : Node_Id;
2669 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2670 Def_Id := Entity (Arg_Internal);
2672 if Ekind (Def_Id) /= E_Constant
2673 and then Ekind (Def_Id) /= E_Variable
2676 ("pragma% must designate an object", Arg_Internal);
2679 if Has_Rep_Pragma (Def_Id, Name_Common_Object)
2681 Has_Rep_Pragma (Def_Id, Name_Psect_Object)
2684 ("previous Common/Psect_Object applies, pragma % not permitted",
2688 if Rep_Item_Too_Late (Def_Id, N) then
2692 Set_Extended_Import_Export_External_Name (Def_Id, Arg_External);
2694 if Present (Arg_Size) then
2695 Check_Arg_Is_External_Name (Arg_Size);
2698 -- Export_Object case
2700 if Prag_Id = Pragma_Export_Object then
2701 if not Is_Library_Level_Entity (Def_Id) then
2703 ("argument for pragma% must be library level entity",
2707 if Ekind (Current_Scope) = E_Generic_Package then
2708 Error_Pragma ("pragma& cannot appear in a generic unit");
2711 if not Size_Known_At_Compile_Time (Etype (Def_Id)) then
2713 ("exported object must have compile time known size",
2717 if Warn_On_Export_Import and then Is_Exported (Def_Id) then
2719 ("?duplicate Export_Object pragma", N);
2721 Set_Exported (Def_Id, Arg_Internal);
2724 -- Import_Object case
2727 if Is_Concurrent_Type (Etype (Def_Id)) then
2729 ("cannot use pragma% for task/protected object",
2733 if Ekind (Def_Id) = E_Constant then
2735 ("cannot import a constant", Arg_Internal);
2738 if Warn_On_Export_Import
2739 and then Has_Discriminants (Etype (Def_Id))
2742 ("imported value must be initialized?", Arg_Internal);
2745 if Warn_On_Export_Import
2746 and then Is_Access_Type (Etype (Def_Id))
2749 ("cannot import object of an access type?", Arg_Internal);
2752 if Warn_On_Export_Import
2753 and then Is_Imported (Def_Id)
2756 ("?duplicate Import_Object pragma", N);
2758 -- Check for explicit initialization present. Note that an
2759 -- initialization that generated by the code generator, e.g.
2760 -- for an access type, does not count here.
2762 elsif Present (Expression (Parent (Def_Id)))
2765 (Original_Node (Expression (Parent (Def_Id))))
2767 Error_Msg_Sloc := Sloc (Def_Id);
2769 ("imported entities cannot be initialized (RM B.1(24))",
2770 "\no initialization allowed for & declared#", Arg1);
2772 Set_Imported (Def_Id);
2773 Note_Possible_Modification (Arg_Internal, Sure => False);
2776 end Process_Extended_Import_Export_Object_Pragma;
2778 ------------------------------------------------------
2779 -- Process_Extended_Import_Export_Subprogram_Pragma --
2780 ------------------------------------------------------
2782 procedure Process_Extended_Import_Export_Subprogram_Pragma
2783 (Arg_Internal : Node_Id;
2784 Arg_External : Node_Id;
2785 Arg_Parameter_Types : Node_Id;
2786 Arg_Result_Type : Node_Id := Empty;
2787 Arg_Mechanism : Node_Id;
2788 Arg_Result_Mechanism : Node_Id := Empty;
2789 Arg_First_Optional_Parameter : Node_Id := Empty)
2795 Ambiguous : Boolean;
2799 function Same_Base_Type
2801 Formal : Entity_Id) return Boolean;
2802 -- Determines if Ptype references the type of Formal. Note that
2803 -- only the base types need to match according to the spec. Ptype
2804 -- here is the argument from the pragma, which is either a type
2805 -- name, or an access attribute.
2807 --------------------
2808 -- Same_Base_Type --
2809 --------------------
2811 function Same_Base_Type
2813 Formal : Entity_Id) return Boolean
2815 Ftyp : constant Entity_Id := Base_Type (Etype (Formal));
2819 -- Case where pragma argument is typ'Access
2821 if Nkind (Ptype) = N_Attribute_Reference
2822 and then Attribute_Name (Ptype) = Name_Access
2824 Pref := Prefix (Ptype);
2827 if not Is_Entity_Name (Pref)
2828 or else Entity (Pref) = Any_Type
2833 -- We have a match if the corresponding argument is of an
2834 -- anonymous access type, and its designated type matches
2835 -- the type of the prefix of the access attribute
2837 return Ekind (Ftyp) = E_Anonymous_Access_Type
2838 and then Base_Type (Entity (Pref)) =
2839 Base_Type (Etype (Designated_Type (Ftyp)));
2841 -- Case where pragma argument is a type name
2846 if not Is_Entity_Name (Ptype)
2847 or else Entity (Ptype) = Any_Type
2852 -- We have a match if the corresponding argument is of
2853 -- the type given in the pragma (comparing base types)
2855 return Base_Type (Entity (Ptype)) = Ftyp;
2859 -- Start of processing for
2860 -- Process_Extended_Import_Export_Subprogram_Pragma
2863 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2867 -- Loop through homonyms (overloadings) of the entity
2869 Hom_Id := Entity (Arg_Internal);
2870 while Present (Hom_Id) loop
2871 Def_Id := Get_Base_Subprogram (Hom_Id);
2873 -- We need a subprogram in the current scope
2875 if not Is_Subprogram (Def_Id)
2876 or else Scope (Def_Id) /= Current_Scope
2883 -- Pragma cannot apply to subprogram body
2885 if Is_Subprogram (Def_Id)
2888 (Declaration_Node (Def_Id))) = N_Subprogram_Body
2891 ("pragma% requires separate spec"
2892 & " and must come before body");
2895 -- Test result type if given, note that the result type
2896 -- parameter can only be present for the function cases.
2898 if Present (Arg_Result_Type)
2899 and then not Same_Base_Type (Arg_Result_Type, Def_Id)
2903 elsif Etype (Def_Id) /= Standard_Void_Type
2905 (Pname = Name_Export_Procedure
2907 Pname = Name_Import_Procedure)
2911 -- Test parameter types if given. Note that this parameter
2912 -- has not been analyzed (and must not be, since it is
2913 -- semantic nonsense), so we get it as the parser left it.
2915 elsif Present (Arg_Parameter_Types) then
2916 Check_Matching_Types : declare
2921 Formal := First_Formal (Def_Id);
2923 if Nkind (Arg_Parameter_Types) = N_Null then
2924 if Present (Formal) then
2928 -- A list of one type, e.g. (List) is parsed as
2929 -- a parenthesized expression.
2931 elsif Nkind (Arg_Parameter_Types) /= N_Aggregate
2932 and then Paren_Count (Arg_Parameter_Types) = 1
2935 or else Present (Next_Formal (Formal))
2940 Same_Base_Type (Arg_Parameter_Types, Formal);
2943 -- A list of more than one type is parsed as a aggregate
2945 elsif Nkind (Arg_Parameter_Types) = N_Aggregate
2946 and then Paren_Count (Arg_Parameter_Types) = 0
2948 Ptype := First (Expressions (Arg_Parameter_Types));
2949 while Present (Ptype) or else Present (Formal) loop
2952 or else not Same_Base_Type (Ptype, Formal)
2957 Next_Formal (Formal);
2962 -- Anything else is of the wrong form
2966 ("wrong form for Parameter_Types parameter",
2967 Arg_Parameter_Types);
2969 end Check_Matching_Types;
2972 -- Match is now False if the entry we found did not match
2973 -- either a supplied Parameter_Types or Result_Types argument
2979 -- Ambiguous case, the flag Ambiguous shows if we already
2980 -- detected this and output the initial messages.
2983 if not Ambiguous then
2985 Error_Msg_Name_1 := Pname;
2987 ("pragma% does not uniquely identify subprogram!",
2989 Error_Msg_Sloc := Sloc (Ent);
2990 Error_Msg_N ("matching subprogram #!", N);
2994 Error_Msg_Sloc := Sloc (Def_Id);
2995 Error_Msg_N ("matching subprogram #!", N);
3000 Hom_Id := Homonym (Hom_Id);
3003 -- See if we found an entry
3006 if not Ambiguous then
3007 if Is_Generic_Subprogram (Entity (Arg_Internal)) then
3009 ("pragma% cannot be given for generic subprogram");
3012 ("pragma% does not identify local subprogram");
3019 -- Import pragmas must be be for imported entities
3021 if Prag_Id = Pragma_Import_Function
3023 Prag_Id = Pragma_Import_Procedure
3025 Prag_Id = Pragma_Import_Valued_Procedure
3027 if not Is_Imported (Ent) then
3029 ("pragma Import or Interface must precede pragma%");
3032 -- Here we have the Export case which can set the entity as exported
3034 -- But does not do so if the specified external name is null, since
3035 -- that is taken as a signal in DEC Ada 83 (with which we want to be
3036 -- compatible) to request no external name.
3038 elsif Nkind (Arg_External) = N_String_Literal
3039 and then String_Length (Strval (Arg_External)) = 0
3043 -- In all other cases, set entity as exported
3046 Set_Exported (Ent, Arg_Internal);
3049 -- Special processing for Valued_Procedure cases
3051 if Prag_Id = Pragma_Import_Valued_Procedure
3053 Prag_Id = Pragma_Export_Valued_Procedure
3055 Formal := First_Formal (Ent);
3059 ("at least one parameter required for pragma%");
3061 elsif Ekind (Formal) /= E_Out_Parameter then
3063 ("first parameter must have mode out for pragma%");
3066 Set_Is_Valued_Procedure (Ent);
3070 Set_Extended_Import_Export_External_Name (Ent, Arg_External);
3072 -- Process Result_Mechanism argument if present. We have already
3073 -- checked that this is only allowed for the function case.
3075 if Present (Arg_Result_Mechanism) then
3076 Set_Mechanism_Value (Ent, Arg_Result_Mechanism);
3079 -- Process Mechanism parameter if present. Note that this parameter
3080 -- is not analyzed, and must not be analyzed since it is semantic
3081 -- nonsense, so we get it in exactly as the parser left it.
3083 if Present (Arg_Mechanism) then
3091 -- A single mechanism association without a formal parameter
3092 -- name is parsed as a parenthesized expression. All other
3093 -- cases are parsed as aggregates, so we rewrite the single
3094 -- parameter case as an aggregate for consistency.
3096 if Nkind (Arg_Mechanism) /= N_Aggregate
3097 and then Paren_Count (Arg_Mechanism) = 1
3099 Rewrite (Arg_Mechanism,
3100 Make_Aggregate (Sloc (Arg_Mechanism),
3101 Expressions => New_List (
3102 Relocate_Node (Arg_Mechanism))));
3105 -- Case of only mechanism name given, applies to all formals
3107 if Nkind (Arg_Mechanism) /= N_Aggregate then
3108 Formal := First_Formal (Ent);
3109 while Present (Formal) loop
3110 Set_Mechanism_Value (Formal, Arg_Mechanism);
3111 Next_Formal (Formal);
3114 -- Case of list of mechanism associations given
3117 if Null_Record_Present (Arg_Mechanism) then
3119 ("inappropriate form for Mechanism parameter",
3123 -- Deal with positional ones first
3125 Formal := First_Formal (Ent);
3127 if Present (Expressions (Arg_Mechanism)) then
3128 Mname := First (Expressions (Arg_Mechanism));
3129 while Present (Mname) loop
3132 ("too many mechanism associations", Mname);
3135 Set_Mechanism_Value (Formal, Mname);
3136 Next_Formal (Formal);
3141 -- Deal with named entries
3143 if Present (Component_Associations (Arg_Mechanism)) then
3144 Massoc := First (Component_Associations (Arg_Mechanism));
3145 while Present (Massoc) loop
3146 Choice := First (Choices (Massoc));
3148 if Nkind (Choice) /= N_Identifier
3149 or else Present (Next (Choice))
3152 ("incorrect form for mechanism association",
3156 Formal := First_Formal (Ent);
3160 ("parameter name & not present", Choice);
3163 if Chars (Choice) = Chars (Formal) then
3165 (Formal, Expression (Massoc));
3169 Next_Formal (Formal);
3179 -- Process First_Optional_Parameter argument if present. We have
3180 -- already checked that this is only allowed for the Import case.
3182 if Present (Arg_First_Optional_Parameter) then
3183 if Nkind (Arg_First_Optional_Parameter) /= N_Identifier then
3185 ("first optional parameter must be formal parameter name",
3186 Arg_First_Optional_Parameter);
3189 Formal := First_Formal (Ent);
3193 ("specified formal parameter& not found",
3194 Arg_First_Optional_Parameter);
3197 exit when Chars (Formal) =
3198 Chars (Arg_First_Optional_Parameter);
3200 Next_Formal (Formal);
3203 Set_First_Optional_Parameter (Ent, Formal);
3205 -- Check specified and all remaining formals have right form
3207 while Present (Formal) loop
3208 if Ekind (Formal) /= E_In_Parameter then
3210 ("optional formal& is not of mode in!",
3211 Arg_First_Optional_Parameter, Formal);
3214 Dval := Default_Value (Formal);
3218 ("optional formal& does not have default value!",
3219 Arg_First_Optional_Parameter, Formal);
3221 elsif Compile_Time_Known_Value_Or_Aggr (Dval) then
3226 ("default value for optional formal& is non-static!",
3227 Arg_First_Optional_Parameter, Formal);
3231 Set_Is_Optional_Parameter (Formal);
3232 Next_Formal (Formal);
3235 end Process_Extended_Import_Export_Subprogram_Pragma;
3237 --------------------------
3238 -- Process_Generic_List --
3239 --------------------------
3241 procedure Process_Generic_List is
3247 Check_No_Identifiers;
3248 Check_At_Least_N_Arguments (1);
3251 while Present (Arg) loop
3252 Exp := Expression (Arg);
3255 if not Is_Entity_Name (Exp)
3257 (not Is_Generic_Instance (Entity (Exp))
3259 not Is_Generic_Unit (Entity (Exp)))
3262 ("pragma% argument must be name of generic unit/instance",
3268 end Process_Generic_List;
3270 ---------------------------------
3271 -- Process_Import_Or_Interface --
3272 ---------------------------------
3274 procedure Process_Import_Or_Interface is
3280 Process_Convention (C, Def_Id);
3281 Kill_Size_Check_Code (Def_Id);
3282 Note_Possible_Modification (Expression (Arg2), Sure => False);
3284 if Ekind (Def_Id) = E_Variable
3286 Ekind (Def_Id) = E_Constant
3288 -- We do not permit Import to apply to a renaming declaration
3290 if Present (Renamed_Object (Def_Id)) then
3292 ("pragma% not allowed for object renaming", Arg2);
3294 -- User initialization is not allowed for imported object, but
3295 -- the object declaration may contain a default initialization,
3296 -- that will be discarded. Note that an explicit initialization
3297 -- only counts if it comes from source, otherwise it is simply
3298 -- the code generator making an implicit initialization explicit.
3300 elsif Present (Expression (Parent (Def_Id)))
3301 and then Comes_From_Source (Expression (Parent (Def_Id)))
3303 Error_Msg_Sloc := Sloc (Def_Id);
3305 ("no initialization allowed for declaration of& #",
3306 "\imported entities cannot be initialized (RM B.1(24))",
3310 Set_Imported (Def_Id);
3311 Process_Interface_Name (Def_Id, Arg3, Arg4);
3313 -- Note that we do not set Is_Public here. That's because we
3314 -- only want to set if if there is no address clause, and we
3315 -- don't know that yet, so we delay that processing till
3318 -- pragma Import completes deferred constants
3320 if Ekind (Def_Id) = E_Constant then
3321 Set_Has_Completion (Def_Id);
3324 -- It is not possible to import a constant of an unconstrained
3325 -- array type (e.g. string) because there is no simple way to
3326 -- write a meaningful subtype for it.
3328 if Is_Array_Type (Etype (Def_Id))
3329 and then not Is_Constrained (Etype (Def_Id))
3332 ("imported constant& must have a constrained subtype",
3337 elsif Is_Subprogram (Def_Id)
3338 or else Is_Generic_Subprogram (Def_Id)
3340 -- If the name is overloaded, pragma applies to all of the
3341 -- denoted entities in the same declarative part.
3344 while Present (Hom_Id) loop
3345 Def_Id := Get_Base_Subprogram (Hom_Id);
3347 -- Ignore inherited subprograms because the pragma will
3348 -- apply to the parent operation, which is the one called.
3350 if Is_Overloadable (Def_Id)
3351 and then Present (Alias (Def_Id))
3355 -- If it is not a subprogram, it must be in an outer
3356 -- scope and pragma does not apply.
3358 elsif not Is_Subprogram (Def_Id)
3359 and then not Is_Generic_Subprogram (Def_Id)
3363 -- Verify that the homonym is in the same declarative
3364 -- part (not just the same scope).
3366 elsif Parent (Unit_Declaration_Node (Def_Id)) /= Parent (N)
3367 and then Nkind (Parent (N)) /= N_Compilation_Unit_Aux
3372 Set_Imported (Def_Id);
3374 -- Special processing for Convention_Intrinsic
3376 if C = Convention_Intrinsic then
3378 -- Link_Name argument not allowed for intrinsic
3381 and then Chars (Arg3) = Name_Link_Name
3386 if Present (Arg4) then
3388 ("Link_Name argument not allowed for " &
3393 Set_Is_Intrinsic_Subprogram (Def_Id);
3395 -- If no external name is present, then check that
3396 -- this is a valid intrinsic subprogram. If an external
3397 -- name is present, then this is handled by the back end.
3400 Check_Intrinsic_Subprogram (Def_Id, Expression (Arg2));
3404 -- All interfaced procedures need an external symbol
3405 -- created for them since they are always referenced
3406 -- from another object file.
3408 Set_Is_Public (Def_Id);
3410 -- Verify that the subprogram does not have a completion
3411 -- through a renaming declaration. For other completions
3412 -- the pragma appears as a too late representation.
3415 Decl : constant Node_Id := Unit_Declaration_Node (Def_Id);
3419 and then Nkind (Decl) = N_Subprogram_Declaration
3420 and then Present (Corresponding_Body (Decl))
3423 (Unit_Declaration_Node
3424 (Corresponding_Body (Decl))) =
3425 N_Subprogram_Renaming_Declaration
3427 Error_Msg_Sloc := Sloc (Def_Id);
3429 ("cannot import&, renaming already provided for " &
3430 "declaration #", N, Def_Id);
3434 Set_Has_Completion (Def_Id);
3435 Process_Interface_Name (Def_Id, Arg3, Arg4);
3438 if Is_Compilation_Unit (Hom_Id) then
3440 -- Its possible homonyms are not affected by the pragma.
3441 -- Such homonyms might be present in the context of other
3442 -- units being compiled.
3447 Hom_Id := Homonym (Hom_Id);
3451 -- When the convention is Java or CIL, we also allow Import to be
3452 -- given for packages, generic packages, exceptions, and record
3455 elsif (C = Convention_Java or else C = Convention_CIL)
3457 (Ekind (Def_Id) = E_Package
3458 or else Ekind (Def_Id) = E_Generic_Package
3459 or else Ekind (Def_Id) = E_Exception
3460 or else Nkind (Parent (Def_Id)) = N_Component_Declaration)
3462 Set_Imported (Def_Id);
3463 Set_Is_Public (Def_Id);
3464 Process_Interface_Name (Def_Id, Arg3, Arg4);
3466 -- Import a CPP class
3468 elsif Is_Record_Type (Def_Id)
3469 and then C = Convention_CPP
3471 if not Is_Tagged_Type (Def_Id) then
3472 Error_Msg_Sloc := Sloc (Def_Id);
3473 Error_Pragma_Arg ("imported 'C'P'P type must be tagged", Arg2);
3476 -- Types treated as CPP classes are treated as limited, but we
3477 -- don't require them to be declared this way. A warning is
3478 -- issued to encourage the user to declare them as limited.
3479 -- This is not an error, for compatibility reasons, because
3480 -- these types have been supported this way for some time.
3482 if not Is_Limited_Type (Def_Id) then
3484 ("imported 'C'P'P type should be " &
3485 "explicitly declared limited?",
3486 Get_Pragma_Arg (Arg2));
3488 ("\type will be considered limited",
3489 Get_Pragma_Arg (Arg2));
3492 Set_Is_CPP_Class (Def_Id);
3493 Set_Is_Limited_Record (Def_Id);
3498 ("second argument of pragma% must be object or subprogram",
3502 -- If this pragma applies to a compilation unit, then the unit,
3503 -- which is a subprogram, does not require (or allow) a body.
3504 -- We also do not need to elaborate imported procedures.
3506 if Nkind (Parent (N)) = N_Compilation_Unit_Aux then
3508 Cunit : constant Node_Id := Parent (Parent (N));
3510 Set_Body_Required (Cunit, False);
3513 end Process_Import_Or_Interface;
3515 --------------------
3516 -- Process_Inline --
3517 --------------------
3519 procedure Process_Inline (Active : Boolean) is
3525 Effective : Boolean := False;
3527 procedure Make_Inline (Subp : Entity_Id);
3528 -- Subp is the defining unit name of the subprogram
3529 -- declaration. Set the flag, as well as the flag in the
3530 -- corresponding body, if there is one present.
3532 procedure Set_Inline_Flags (Subp : Entity_Id);
3533 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp and also
3534 -- Has_Pragma_Inline_Always for the Inline_Always case.
3536 function Inlining_Not_Possible (Subp : Entity_Id) return Boolean;
3537 -- Returns True if it can be determined at this stage that inlining
3538 -- is not possible, for example if the body is available and contains
3539 -- exception handlers, we prevent inlining, since otherwise we can
3540 -- get undefined symbols at link time. This function also emits a
3541 -- warning if front-end inlining is enabled and the pragma appears
3544 -- ??? is business with link symbols still valid, or does it relate
3545 -- to front end ZCX which is being phased out ???
3547 ---------------------------
3548 -- Inlining_Not_Possible --
3549 ---------------------------
3551 function Inlining_Not_Possible (Subp : Entity_Id) return Boolean is
3552 Decl : constant Node_Id := Unit_Declaration_Node (Subp);
3556 if Nkind (Decl) = N_Subprogram_Body then
3557 Stats := Handled_Statement_Sequence (Decl);
3558 return Present (Exception_Handlers (Stats))
3559 or else Present (At_End_Proc (Stats));
3561 elsif Nkind (Decl) = N_Subprogram_Declaration
3562 and then Present (Corresponding_Body (Decl))
3564 if Front_End_Inlining
3565 and then Analyzed (Corresponding_Body (Decl))
3567 Error_Msg_N ("pragma appears too late, ignored?", N);
3570 -- If the subprogram is a renaming as body, the body is
3571 -- just a call to the renamed subprogram, and inlining is
3572 -- trivially possible.
3575 Nkind (Unit_Declaration_Node (Corresponding_Body (Decl))) =
3576 N_Subprogram_Renaming_Declaration
3582 Handled_Statement_Sequence
3583 (Unit_Declaration_Node (Corresponding_Body (Decl)));
3586 Present (Exception_Handlers (Stats))
3587 or else Present (At_End_Proc (Stats));
3591 -- If body is not available, assume the best, the check is
3592 -- performed again when compiling enclosing package bodies.
3596 end Inlining_Not_Possible;
3602 procedure Make_Inline (Subp : Entity_Id) is
3603 Kind : constant Entity_Kind := Ekind (Subp);
3604 Inner_Subp : Entity_Id := Subp;
3607 -- Ignore if bad type, avoid cascaded error
3609 if Etype (Subp) = Any_Type then
3613 -- Ignore if all inlining is suppressed
3615 elsif Suppress_All_Inlining then
3619 -- If inlining is not possible, for now do not treat as an error
3621 elsif Inlining_Not_Possible (Subp) then
3625 -- Here we have a candidate for inlining, but we must exclude
3626 -- derived operations. Otherwise we would end up trying to inline
3627 -- a phantom declaration, and the result would be to drag in a
3628 -- body which has no direct inlining associated with it. That
3629 -- would not only be inefficient but would also result in the
3630 -- backend doing cross-unit inlining in cases where it was
3631 -- definitely inappropriate to do so.
3633 -- However, a simple Comes_From_Source test is insufficient, since
3634 -- we do want to allow inlining of generic instances which also do
3635 -- not come from source. We also need to recognize specs
3636 -- generated by the front-end for bodies that carry the pragma.
3637 -- Finally, predefined operators do not come from source but are
3638 -- not inlineable either.
3640 elsif Is_Generic_Instance (Subp)
3641 or else Nkind (Parent (Parent (Subp))) = N_Subprogram_Declaration
3645 elsif not Comes_From_Source (Subp)
3646 and then Scope (Subp) /= Standard_Standard
3652 -- The referenced entity must either be the enclosing entity,
3653 -- or an entity declared within the current open scope.
3655 if Present (Scope (Subp))
3656 and then Scope (Subp) /= Current_Scope
3657 and then Subp /= Current_Scope
3660 ("argument of% must be entity in current scope", Assoc);
3664 -- Processing for procedure, operator or function.
3665 -- If subprogram is aliased (as for an instance) indicate
3666 -- that the renamed entity (if declared in the same unit)
3669 if Is_Subprogram (Subp) then
3670 while Present (Alias (Inner_Subp)) loop
3671 Inner_Subp := Alias (Inner_Subp);
3674 if In_Same_Source_Unit (Subp, Inner_Subp) then
3675 Set_Inline_Flags (Inner_Subp);
3677 Decl := Parent (Parent (Inner_Subp));
3679 if Nkind (Decl) = N_Subprogram_Declaration
3680 and then Present (Corresponding_Body (Decl))
3682 Set_Inline_Flags (Corresponding_Body (Decl));
3688 -- For a generic subprogram set flag as well, for use at
3689 -- the point of instantiation, to determine whether the
3690 -- body should be generated.
3692 elsif Is_Generic_Subprogram (Subp) then
3693 Set_Inline_Flags (Subp);
3696 -- Literals are by definition inlined
3698 elsif Kind = E_Enumeration_Literal then
3701 -- Anything else is an error
3705 ("expect subprogram name for pragma%", Assoc);
3709 ----------------------
3710 -- Set_Inline_Flags --
3711 ----------------------
3713 procedure Set_Inline_Flags (Subp : Entity_Id) is
3716 Set_Is_Inlined (Subp, True);
3719 if not Has_Pragma_Inline (Subp) then
3720 Set_Has_Pragma_Inline (Subp);
3724 if Prag_Id = Pragma_Inline_Always then
3725 Set_Has_Pragma_Inline_Always (Subp);
3727 end Set_Inline_Flags;
3729 -- Start of processing for Process_Inline
3732 Check_No_Identifiers;
3733 Check_At_Least_N_Arguments (1);
3736 Inline_Processing_Required := True;
3740 while Present (Assoc) loop
3741 Subp_Id := Expression (Assoc);
3745 if Is_Entity_Name (Subp_Id) then
3746 Subp := Entity (Subp_Id);
3748 if Subp = Any_Id then
3750 -- If previous error, avoid cascaded errors
3758 while Present (Homonym (Subp))
3759 and then Scope (Homonym (Subp)) = Current_Scope
3761 Make_Inline (Homonym (Subp));
3762 Subp := Homonym (Subp);
3769 ("inappropriate argument for pragma%", Assoc);
3772 and then Warn_On_Redundant_Constructs
3773 and then not Suppress_All_Inlining
3775 if Inlining_Not_Possible (Subp) then
3777 ("pragma Inline for& is ignored?", N, Entity (Subp_Id));
3780 ("pragma Inline for& is redundant?", N, Entity (Subp_Id));
3788 ----------------------------
3789 -- Process_Interface_Name --
3790 ----------------------------
3792 procedure Process_Interface_Name
3793 (Subprogram_Def : Entity_Id;
3799 String_Val : String_Id;
3801 procedure Check_Form_Of_Interface_Name (SN : Node_Id);
3802 -- SN is a string literal node for an interface name. This routine
3803 -- performs some minimal checks that the name is reasonable. In
3804 -- particular that no spaces or other obviously incorrect characters
3805 -- appear. This is only a warning, since any characters are allowed.
3807 ----------------------------------
3808 -- Check_Form_Of_Interface_Name --
3809 ----------------------------------
3811 procedure Check_Form_Of_Interface_Name (SN : Node_Id) is
3812 S : constant String_Id := Strval (Expr_Value_S (SN));
3813 SL : constant Nat := String_Length (S);
3818 Error_Msg_N ("interface name cannot be null string", SN);
3821 for J in 1 .. SL loop
3822 C := Get_String_Char (S, J);
3824 if Warn_On_Export_Import
3826 (not In_Character_Range (C)
3827 or else (Get_Character (C) = ' '
3828 and then VM_Target /= CLI_Target)
3829 or else Get_Character (C) = ',')
3832 ("?interface name contains illegal character", SN);
3835 end Check_Form_Of_Interface_Name;
3837 -- Start of processing for Process_Interface_Name
3840 if No (Link_Arg) then
3841 if No (Ext_Arg) then
3842 if VM_Target = CLI_Target
3843 and then Ekind (Subprogram_Def) = E_Package
3844 and then Nkind (Parent (Subprogram_Def)) =
3845 N_Package_Specification
3846 and then Present (Generic_Parent (Parent (Subprogram_Def)))
3851 (Generic_Parent (Parent (Subprogram_Def))));
3856 elsif Chars (Ext_Arg) = Name_Link_Name then
3858 Link_Nam := Expression (Ext_Arg);
3861 Check_Optional_Identifier (Ext_Arg, Name_External_Name);
3862 Ext_Nam := Expression (Ext_Arg);
3867 Check_Optional_Identifier (Ext_Arg, Name_External_Name);
3868 Check_Optional_Identifier (Link_Arg, Name_Link_Name);
3869 Ext_Nam := Expression (Ext_Arg);
3870 Link_Nam := Expression (Link_Arg);
3873 -- Check expressions for external name and link name are static
3875 if Present (Ext_Nam) then
3876 Check_Arg_Is_Static_Expression (Ext_Nam, Standard_String);
3877 Check_Form_Of_Interface_Name (Ext_Nam);
3879 -- Verify that the external name is not the name of a local
3880 -- entity, which would hide the imported one and lead to
3881 -- run-time surprises. The problem can only arise for entities
3882 -- declared in a package body (otherwise the external name is
3883 -- fully qualified and won't conflict).
3891 if Prag_Id = Pragma_Import then
3892 String_To_Name_Buffer (Strval (Expr_Value_S (Ext_Nam)));
3894 E := Entity_Id (Get_Name_Table_Info (Nam));
3896 if Nam /= Chars (Subprogram_Def)
3897 and then Present (E)
3898 and then not Is_Overloadable (E)
3899 and then Is_Immediately_Visible (E)
3900 and then not Is_Imported (E)
3901 and then Ekind (Scope (E)) = E_Package
3904 while Present (Par) loop
3905 if Nkind (Par) = N_Package_Body then
3906 Error_Msg_Sloc := Sloc (E);
3908 ("imported entity is hidden by & declared#",
3913 Par := Parent (Par);
3920 if Present (Link_Nam) then
3921 Check_Arg_Is_Static_Expression (Link_Nam, Standard_String);
3922 Check_Form_Of_Interface_Name (Link_Nam);
3925 -- If there is no link name, just set the external name
3927 if No (Link_Nam) then
3928 Link_Nam := Adjust_External_Name_Case (Expr_Value_S (Ext_Nam));
3930 -- For the Link_Name case, the given literal is preceded by an
3931 -- asterisk, which indicates to GCC that the given name should
3932 -- be taken literally, and in particular that no prepending of
3933 -- underlines should occur, even in systems where this is the
3939 if VM_Target = No_VM then
3940 Store_String_Char (Get_Char_Code ('*'));
3943 String_Val := Strval (Expr_Value_S (Link_Nam));
3944 Store_String_Chars (String_Val);
3946 Make_String_Literal (Sloc (Link_Nam),
3947 Strval => End_String);
3950 Set_Encoded_Interface_Name
3951 (Get_Base_Subprogram (Subprogram_Def), Link_Nam);
3952 Check_Duplicated_Export_Name (Link_Nam);
3953 end Process_Interface_Name;
3955 -----------------------------------------
3956 -- Process_Interrupt_Or_Attach_Handler --
3957 -----------------------------------------
3959 procedure Process_Interrupt_Or_Attach_Handler is
3960 Arg1_X : constant Node_Id := Expression (Arg1);
3961 Handler_Proc : constant Entity_Id := Entity (Arg1_X);
3962 Proc_Scope : constant Entity_Id := Scope (Handler_Proc);
3965 Set_Is_Interrupt_Handler (Handler_Proc);
3967 -- If the pragma is not associated with a handler procedure
3968 -- within a protected type, then it must be for a nonprotected
3969 -- procedure for the AAMP target, in which case we don't
3970 -- associate a representation item with the procedure's scope.
3972 if Ekind (Proc_Scope) = E_Protected_Type then
3973 if Prag_Id = Pragma_Interrupt_Handler
3975 Prag_Id = Pragma_Attach_Handler
3977 Record_Rep_Item (Proc_Scope, N);
3980 end Process_Interrupt_Or_Attach_Handler;
3982 --------------------------------------------------
3983 -- Process_Restrictions_Or_Restriction_Warnings --
3984 --------------------------------------------------
3986 -- Note: some of the simple identifier cases were handled in par-prag,
3987 -- but it is harmless (and more straightforward) to simply handle all
3988 -- cases here, even if it means we repeat a bit of work in some cases.
3990 procedure Process_Restrictions_Or_Restriction_Warnings
3994 R_Id : Restriction_Id;
3999 procedure Check_Unit_Name (N : Node_Id);
4000 -- Checks unit name parameter for No_Dependence. Returns if it has
4001 -- an appropriate form, otherwise raises pragma argument error.
4003 ---------------------
4004 -- Check_Unit_Name --
4005 ---------------------
4007 procedure Check_Unit_Name (N : Node_Id) is
4009 if Nkind (N) = N_Selected_Component then
4010 Check_Unit_Name (Prefix (N));
4011 Check_Unit_Name (Selector_Name (N));
4013 elsif Nkind (N) = N_Identifier then
4018 ("wrong form for unit name for No_Dependence", N);
4020 end Check_Unit_Name;
4022 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
4025 Check_Ada_83_Warning;
4026 Check_At_Least_N_Arguments (1);
4027 Check_Valid_Configuration_Pragma;
4030 while Present (Arg) loop
4032 Expr := Expression (Arg);
4034 -- Case of no restriction identifier present
4036 if Id = No_Name then
4037 if Nkind (Expr) /= N_Identifier then
4039 ("invalid form for restriction", Arg);
4044 (Process_Restriction_Synonyms (Expr));
4046 if R_Id not in All_Boolean_Restrictions then
4047 Error_Msg_Name_1 := Pname;
4049 ("invalid restriction identifier&", Get_Pragma_Arg (Arg));
4051 -- Check for possible misspelling
4053 for J in Restriction_Id loop
4055 Rnm : constant String := Restriction_Id'Image (J);
4058 Name_Buffer (1 .. Rnm'Length) := Rnm;
4059 Name_Len := Rnm'Length;
4060 Set_Casing (All_Lower_Case);
4062 if Is_Bad_Spelling_Of (Chars (Expr), Name_Enter) then
4064 (Identifier_Casing (Current_Source_File));
4065 Error_Msg_String (1 .. Rnm'Length) :=
4066 Name_Buffer (1 .. Name_Len);
4067 Error_Msg_Strlen := Rnm'Length;
4069 ("\possible misspelling of ""~""",
4070 Get_Pragma_Arg (Arg));
4079 if Implementation_Restriction (R_Id) then
4080 Check_Restriction (No_Implementation_Restrictions, Arg);
4083 -- If this is a warning, then set the warning unless we already
4084 -- have a real restriction active (we never want a warning to
4085 -- override a real restriction).
4088 if not Restriction_Active (R_Id) then
4089 Set_Restriction (R_Id, N);
4090 Restriction_Warnings (R_Id) := True;
4093 -- If real restriction case, then set it and make sure that the
4094 -- restriction warning flag is off, since a real restriction
4095 -- always overrides a warning.
4098 Set_Restriction (R_Id, N);
4099 Restriction_Warnings (R_Id) := False;
4102 -- A very special case that must be processed here: pragma
4103 -- Restrictions (No_Exceptions) turns off all run-time
4104 -- checking. This is a bit dubious in terms of the formal
4105 -- language definition, but it is what is intended by RM
4106 -- H.4(12). Restriction_Warnings never affects generated code
4107 -- so this is done only in the real restriction case.
4109 if R_Id = No_Exceptions and then not Warn then
4110 Scope_Suppress := (others => True);
4113 -- Case of No_Dependence => unit-name. Note that the parser
4114 -- already made the necessary entry in the No_Dependence table.
4116 elsif Id = Name_No_Dependence then
4117 Check_Unit_Name (Expr);
4119 -- All other cases of restriction identifier present
4122 R_Id := Get_Restriction_Id (Process_Restriction_Synonyms (Arg));
4123 Analyze_And_Resolve (Expr, Any_Integer);
4125 if R_Id not in All_Parameter_Restrictions then
4127 ("invalid restriction parameter identifier", Arg);
4129 elsif not Is_OK_Static_Expression (Expr) then
4130 Flag_Non_Static_Expr
4131 ("value must be static expression!", Expr);
4134 elsif not Is_Integer_Type (Etype (Expr))
4135 or else Expr_Value (Expr) < 0
4138 ("value must be non-negative integer", Arg);
4141 -- Restriction pragma is active
4143 Val := Expr_Value (Expr);
4145 if not UI_Is_In_Int_Range (Val) then
4147 ("pragma ignored, value too large?", Arg);
4150 -- Warning case. If the real restriction is active, then we
4151 -- ignore the request, since warning never overrides a real
4152 -- restriction. Otherwise we set the proper warning. Note that
4153 -- this circuit sets the warning again if it is already set,
4154 -- which is what we want, since the constant may have changed.
4157 if not Restriction_Active (R_Id) then
4159 (R_Id, N, Integer (UI_To_Int (Val)));
4160 Restriction_Warnings (R_Id) := True;
4163 -- Real restriction case, set restriction and make sure warning
4164 -- flag is off since real restriction always overrides warning.
4167 Set_Restriction (R_Id, N, Integer (UI_To_Int (Val)));
4168 Restriction_Warnings (R_Id) := False;
4174 end Process_Restrictions_Or_Restriction_Warnings;
4176 ---------------------------------
4177 -- Process_Suppress_Unsuppress --
4178 ---------------------------------
4180 -- Note: this procedure makes entries in the check suppress data
4181 -- structures managed by Sem. See spec of package Sem for full
4182 -- details on how we handle recording of check suppression.
4184 procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean) is
4189 In_Package_Spec : constant Boolean :=
4190 (Ekind (Current_Scope) = E_Package
4192 Ekind (Current_Scope) = E_Generic_Package)
4193 and then not In_Package_Body (Current_Scope);
4195 procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id);
4196 -- Used to suppress a single check on the given entity
4198 --------------------------------
4199 -- Suppress_Unsuppress_Echeck --
4200 --------------------------------
4202 procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id) is
4204 Set_Checks_May_Be_Suppressed (E);
4206 if In_Package_Spec then
4207 Push_Global_Suppress_Stack_Entry
4210 Suppress => Suppress_Case);
4213 Push_Local_Suppress_Stack_Entry
4216 Suppress => Suppress_Case);
4219 -- If this is a first subtype, and the base type is distinct,
4220 -- then also set the suppress flags on the base type.
4222 if Is_First_Subtype (E)
4223 and then Etype (E) /= E
4225 Suppress_Unsuppress_Echeck (Etype (E), C);
4227 end Suppress_Unsuppress_Echeck;
4229 -- Start of processing for Process_Suppress_Unsuppress
4232 -- Suppress/Unsuppress can appear as a configuration pragma,
4233 -- or in a declarative part or a package spec (RM 11.5(5))
4235 if not Is_Configuration_Pragma then
4236 Check_Is_In_Decl_Part_Or_Package_Spec;
4239 Check_At_Least_N_Arguments (1);
4240 Check_At_Most_N_Arguments (2);
4241 Check_No_Identifier (Arg1);
4242 Check_Arg_Is_Identifier (Arg1);
4244 C := Get_Check_Id (Chars (Expression (Arg1)));
4246 if C = No_Check_Id then
4248 ("argument of pragma% is not valid check name", Arg1);
4251 if not Suppress_Case
4252 and then (C = All_Checks or else C = Overflow_Check)
4254 Opt.Overflow_Checks_Unsuppressed := True;
4257 if Arg_Count = 1 then
4259 -- Make an entry in the local scope suppress table. This is the
4260 -- table that directly shows the current value of the scope
4261 -- suppress check for any check id value.
4263 if C = All_Checks then
4265 -- For All_Checks, we set all specific predefined checks with
4266 -- the exception of Elaboration_Check, which is handled
4267 -- specially because of not wanting All_Checks to have the
4268 -- effect of deactivating static elaboration order processing.
4270 for J in Scope_Suppress'Range loop
4271 if J /= Elaboration_Check then
4272 Scope_Suppress (J) := Suppress_Case;
4276 -- If not All_Checks, and predefined check, then set appropriate
4277 -- scope entry. Note that we will set Elaboration_Check if this
4278 -- is explicitly specified.
4280 elsif C in Predefined_Check_Id then
4281 Scope_Suppress (C) := Suppress_Case;
4284 -- Also make an entry in the Local_Entity_Suppress table
4286 Push_Local_Suppress_Stack_Entry
4289 Suppress => Suppress_Case);
4291 -- Case of two arguments present, where the check is suppressed for
4292 -- a specified entity (given as the second argument of the pragma)
4295 Check_Optional_Identifier (Arg2, Name_On);
4296 E_Id := Expression (Arg2);
4299 if not Is_Entity_Name (E_Id) then
4301 ("second argument of pragma% must be entity name", Arg2);
4310 -- Enforce RM 11.5(7) which requires that for a pragma that
4311 -- appears within a package spec, the named entity must be
4312 -- within the package spec. We allow the package name itself
4313 -- to be mentioned since that makes sense, although it is not
4314 -- strictly allowed by 11.5(7).
4317 and then E /= Current_Scope
4318 and then Scope (E) /= Current_Scope
4321 ("entity in pragma% is not in package spec (RM 11.5(7))",
4325 -- Loop through homonyms. As noted below, in the case of a package
4326 -- spec, only homonyms within the package spec are considered.
4329 Suppress_Unsuppress_Echeck (E, C);
4331 if Is_Generic_Instance (E)
4332 and then Is_Subprogram (E)
4333 and then Present (Alias (E))
4335 Suppress_Unsuppress_Echeck (Alias (E), C);
4338 -- Move to next homonym
4343 -- If we are within a package specification, the
4344 -- pragma only applies to homonyms in the same scope.
4346 exit when In_Package_Spec
4347 and then Scope (E) /= Current_Scope;
4350 end Process_Suppress_Unsuppress;
4356 procedure Set_Exported (E : Entity_Id; Arg : Node_Id) is
4358 if Is_Imported (E) then
4360 ("cannot export entity& that was previously imported", Arg);
4362 elsif Present (Address_Clause (E)) then
4364 ("cannot export entity& that has an address clause", Arg);
4367 Set_Is_Exported (E);
4369 -- Generate a reference for entity explicitly, because the
4370 -- identifier may be overloaded and name resolution will not
4373 Generate_Reference (E, Arg);
4375 -- Deal with exporting non-library level entity
4377 if not Is_Library_Level_Entity (E) then
4379 -- Not allowed at all for subprograms
4381 if Is_Subprogram (E) then
4382 Error_Pragma_Arg ("local subprogram& cannot be exported", Arg);
4384 -- Otherwise set public and statically allocated
4388 Set_Is_Statically_Allocated (E);
4390 -- Warn if the corresponding W flag is set and the pragma
4391 -- comes from source. The latter may not be true e.g. on
4392 -- VMS where we expand export pragmas for exception codes
4393 -- associated with imported or exported exceptions. We do
4394 -- not want to generate a warning for something that the
4395 -- user did not write.
4397 if Warn_On_Export_Import
4398 and then Comes_From_Source (Arg)
4401 ("?& has been made static as a result of Export", Arg, E);
4403 ("\this usage is non-standard and non-portable", Arg);
4408 if Warn_On_Export_Import and then Is_Type (E) then
4410 ("exporting a type has no effect?", Arg, E);
4413 if Warn_On_Export_Import and Inside_A_Generic then
4415 ("all instances of& will have the same external name?", Arg, E);
4419 ----------------------------------------------
4420 -- Set_Extended_Import_Export_External_Name --
4421 ----------------------------------------------
4423 procedure Set_Extended_Import_Export_External_Name
4424 (Internal_Ent : Entity_Id;
4425 Arg_External : Node_Id)
4427 Old_Name : constant Node_Id := Interface_Name (Internal_Ent);
4431 if No (Arg_External) then
4435 Check_Arg_Is_External_Name (Arg_External);
4437 if Nkind (Arg_External) = N_String_Literal then
4438 if String_Length (Strval (Arg_External)) = 0 then
4441 New_Name := Adjust_External_Name_Case (Arg_External);
4444 elsif Nkind (Arg_External) = N_Identifier then
4445 New_Name := Get_Default_External_Name (Arg_External);
4447 -- Check_Arg_Is_External_Name should let through only
4448 -- identifiers and string literals or static string
4449 -- expressions (which are folded to string literals).
4452 raise Program_Error;
4455 -- If we already have an external name set (by a prior normal
4456 -- Import or Export pragma), then the external names must match
4458 if Present (Interface_Name (Internal_Ent)) then
4459 Check_Matching_Internal_Names : declare
4460 S1 : constant String_Id := Strval (Old_Name);
4461 S2 : constant String_Id := Strval (New_Name);
4464 -- Called if names do not match
4470 procedure Mismatch is
4472 Error_Msg_Sloc := Sloc (Old_Name);
4474 ("external name does not match that given #",
4478 -- Start of processing for Check_Matching_Internal_Names
4481 if String_Length (S1) /= String_Length (S2) then
4485 for J in 1 .. String_Length (S1) loop
4486 if Get_String_Char (S1, J) /= Get_String_Char (S2, J) then
4491 end Check_Matching_Internal_Names;
4493 -- Otherwise set the given name
4496 Set_Encoded_Interface_Name (Internal_Ent, New_Name);
4497 Check_Duplicated_Export_Name (New_Name);
4499 end Set_Extended_Import_Export_External_Name;
4505 procedure Set_Imported (E : Entity_Id) is
4507 -- Error message if already imported or exported
4509 if Is_Exported (E) or else Is_Imported (E) then
4510 if Is_Exported (E) then
4511 Error_Msg_NE ("entity& was previously exported", N, E);
4513 Error_Msg_NE ("entity& was previously imported", N, E);
4516 Error_Msg_Name_1 := Pname;
4518 ("\(pragma% applies to all previous entities)", N);
4520 Error_Msg_Sloc := Sloc (E);
4521 Error_Msg_NE ("\import not allowed for& declared#", N, E);
4523 -- Here if not previously imported or exported, OK to import
4526 Set_Is_Imported (E);
4528 -- If the entity is an object that is not at the library
4529 -- level, then it is statically allocated. We do not worry
4530 -- about objects with address clauses in this context since
4531 -- they are not really imported in the linker sense.
4534 and then not Is_Library_Level_Entity (E)
4535 and then No (Address_Clause (E))
4537 Set_Is_Statically_Allocated (E);
4542 -------------------------
4543 -- Set_Mechanism_Value --
4544 -------------------------
4546 -- Note: the mechanism name has not been analyzed (and cannot indeed
4547 -- be analyzed, since it is semantic nonsense), so we get it in the
4548 -- exact form created by the parser.
4550 procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id) is
4554 procedure Bad_Class;
4555 -- Signal bad descriptor class name
4557 procedure Bad_Mechanism;
4558 -- Signal bad mechanism name
4564 procedure Bad_Class is
4566 Error_Pragma_Arg ("unrecognized descriptor class name", Class);
4569 -------------------------
4570 -- Bad_Mechanism_Value --
4571 -------------------------
4573 procedure Bad_Mechanism is
4575 Error_Pragma_Arg ("unrecognized mechanism name", Mech_Name);
4578 -- Start of processing for Set_Mechanism_Value
4581 if Mechanism (Ent) /= Default_Mechanism then
4583 ("mechanism for & has already been set", Mech_Name, Ent);
4586 -- MECHANISM_NAME ::= value | reference | descriptor
4588 if Nkind (Mech_Name) = N_Identifier then
4589 if Chars (Mech_Name) = Name_Value then
4590 Set_Mechanism (Ent, By_Copy);
4593 elsif Chars (Mech_Name) = Name_Reference then
4594 Set_Mechanism (Ent, By_Reference);
4597 elsif Chars (Mech_Name) = Name_Descriptor then
4598 Check_VMS (Mech_Name);
4599 Set_Mechanism (Ent, By_Descriptor);
4602 elsif Chars (Mech_Name) = Name_Copy then
4604 ("bad mechanism name, Value assumed", Mech_Name);
4610 -- MECHANISM_NAME ::= descriptor (CLASS_NAME)
4611 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4613 -- Note: this form is parsed as an indexed component
4615 elsif Nkind (Mech_Name) = N_Indexed_Component then
4616 Class := First (Expressions (Mech_Name));
4618 if Nkind (Prefix (Mech_Name)) /= N_Identifier
4619 or else Chars (Prefix (Mech_Name)) /= Name_Descriptor
4620 or else Present (Next (Class))
4625 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME)
4626 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4628 -- Note: this form is parsed as a function call
4630 elsif Nkind (Mech_Name) = N_Function_Call then
4632 Param := First (Parameter_Associations (Mech_Name));
4634 if Nkind (Name (Mech_Name)) /= N_Identifier
4635 or else Chars (Name (Mech_Name)) /= Name_Descriptor
4636 or else Present (Next (Param))
4637 or else No (Selector_Name (Param))
4638 or else Chars (Selector_Name (Param)) /= Name_Class
4642 Class := Explicit_Actual_Parameter (Param);
4649 -- Fall through here with Class set to descriptor class name
4651 Check_VMS (Mech_Name);
4653 if Nkind (Class) /= N_Identifier then
4656 elsif Chars (Class) = Name_UBS then
4657 Set_Mechanism (Ent, By_Descriptor_UBS);
4659 elsif Chars (Class) = Name_UBSB then
4660 Set_Mechanism (Ent, By_Descriptor_UBSB);
4662 elsif Chars (Class) = Name_UBA then
4663 Set_Mechanism (Ent, By_Descriptor_UBA);
4665 elsif Chars (Class) = Name_S then
4666 Set_Mechanism (Ent, By_Descriptor_S);
4668 elsif Chars (Class) = Name_SB then
4669 Set_Mechanism (Ent, By_Descriptor_SB);
4671 elsif Chars (Class) = Name_A then
4672 Set_Mechanism (Ent, By_Descriptor_A);
4674 elsif Chars (Class) = Name_NCA then
4675 Set_Mechanism (Ent, By_Descriptor_NCA);
4680 end Set_Mechanism_Value;
4682 ---------------------------
4683 -- Set_Ravenscar_Profile --
4684 ---------------------------
4686 -- The tasks to be done here are
4688 -- Set required policies
4690 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4691 -- pragma Locking_Policy (Ceiling_Locking)
4693 -- Set Detect_Blocking mode
4695 -- Set required restrictions (see System.Rident for detailed list)
4697 procedure Set_Ravenscar_Profile (N : Node_Id) is
4699 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4701 if Task_Dispatching_Policy /= ' '
4702 and then Task_Dispatching_Policy /= 'F'
4704 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
4705 Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
4707 -- Set the FIFO_Within_Priorities policy, but always preserve
4708 -- System_Location since we like the error message with the run time
4712 Task_Dispatching_Policy := 'F';
4714 if Task_Dispatching_Policy_Sloc /= System_Location then
4715 Task_Dispatching_Policy_Sloc := Loc;
4719 -- pragma Locking_Policy (Ceiling_Locking)
4721 if Locking_Policy /= ' '
4722 and then Locking_Policy /= 'C'
4724 Error_Msg_Sloc := Locking_Policy_Sloc;
4725 Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
4727 -- Set the Ceiling_Locking policy, but preserve System_Location since
4728 -- we like the error message with the run time name.
4731 Locking_Policy := 'C';
4733 if Locking_Policy_Sloc /= System_Location then
4734 Locking_Policy_Sloc := Loc;
4738 -- pragma Detect_Blocking
4740 Detect_Blocking := True;
4742 -- Set the corresponding restrictions
4744 Set_Profile_Restrictions (Ravenscar, N, Warn => False);
4745 end Set_Ravenscar_Profile;
4747 -- Start of processing for Analyze_Pragma
4750 -- Deal with unrecognized pragma
4752 if not Is_Pragma_Name (Pname) then
4753 if Warn_On_Unrecognized_Pragma then
4754 Error_Msg_Name_1 := Pname;
4755 Error_Msg_N ("?unrecognized pragma%!", Pragma_Identifier (N));
4757 for PN in First_Pragma_Name .. Last_Pragma_Name loop
4758 if Is_Bad_Spelling_Of (Pname, PN) then
4759 Error_Msg_Name_1 := PN;
4761 ("\?possible misspelling of %!", Pragma_Identifier (N));
4770 -- Here to start processing for recognized pragma
4772 Prag_Id := Get_Pragma_Id (Pname);
4781 if Present (Pragma_Argument_Associations (N)) then
4782 Arg1 := First (Pragma_Argument_Associations (N));
4784 if Present (Arg1) then
4785 Arg2 := Next (Arg1);
4787 if Present (Arg2) then
4788 Arg3 := Next (Arg2);
4790 if Present (Arg3) then
4791 Arg4 := Next (Arg3);
4797 -- Count number of arguments
4804 while Present (Arg_Node) loop
4805 Arg_Count := Arg_Count + 1;
4810 -- An enumeration type defines the pragmas that are supported by the
4811 -- implementation. Get_Pragma_Id (in package Prag) transforms a name
4812 -- into the corresponding enumeration value for the following case.
4820 -- pragma Abort_Defer;
4822 when Pragma_Abort_Defer =>
4824 Check_Arg_Count (0);
4826 -- The only required semantic processing is to check the
4827 -- placement. This pragma must appear at the start of the
4828 -- statement sequence of a handled sequence of statements.
4830 if Nkind (Parent (N)) /= N_Handled_Sequence_Of_Statements
4831 or else N /= First (Statements (Parent (N)))
4842 -- Note: this pragma also has some specific processing in Par.Prag
4843 -- because we want to set the Ada version mode during parsing.
4845 when Pragma_Ada_83 =>
4847 Check_Arg_Count (0);
4849 -- We really should check unconditionally for proper configuration
4850 -- pragma placement, since we really don't want mixed Ada modes
4851 -- within a single unit, and the GNAT reference manual has always
4852 -- said this was a configuration pragma, but we did not check and
4853 -- are hesitant to add the check now.
4855 -- However, we really cannot tolerate mixing Ada 2005 with Ada 83
4856 -- or Ada 95, so we must check if we are in Ada 2005 mode.
4858 if Ada_Version >= Ada_05 then
4859 Check_Valid_Configuration_Pragma;
4862 -- Now set Ada 83 mode
4864 Ada_Version := Ada_83;
4865 Ada_Version_Explicit := Ada_Version;
4873 -- Note: this pragma also has some specific processing in Par.Prag
4874 -- because we want to set the Ada 83 version mode during parsing.
4876 when Pragma_Ada_95 =>
4878 Check_Arg_Count (0);
4880 -- We really should check unconditionally for proper configuration
4881 -- pragma placement, since we really don't want mixed Ada modes
4882 -- within a single unit, and the GNAT reference manual has always
4883 -- said this was a configuration pragma, but we did not check and
4884 -- are hesitant to add the check now.
4886 -- However, we really cannot tolerate mixing Ada 2005 with Ada 83
4887 -- or Ada 95, so we must check if we are in Ada 2005 mode.
4889 if Ada_Version >= Ada_05 then
4890 Check_Valid_Configuration_Pragma;
4893 -- Now set Ada 95 mode
4895 Ada_Version := Ada_95;
4896 Ada_Version_Explicit := Ada_Version;
4898 ---------------------
4899 -- Ada_05/Ada_2005 --
4900 ---------------------
4903 -- pragma Ada_05 (LOCAL_NAME);
4906 -- pragma Ada_2005 (LOCAL_NAME):
4908 -- Note: these pragma also have some specific processing in Par.Prag
4909 -- because we want to set the Ada 2005 version mode during parsing.
4911 when Pragma_Ada_05 | Pragma_Ada_2005 => declare
4917 if Arg_Count = 1 then
4918 Check_Arg_Is_Local_Name (Arg1);
4919 E_Id := Expression (Arg1);
4921 if Etype (E_Id) = Any_Type then
4925 Set_Is_Ada_2005_Only (Entity (E_Id));
4928 Check_Arg_Count (0);
4930 -- For Ada_2005 we unconditionally enforce the documented
4931 -- configuration pragma placement, since we do not want to
4932 -- tolerate mixed modes in a unit involving Ada 2005. That
4933 -- would cause real difficulties for those cases where there
4934 -- are incompatibilities between Ada 95 and Ada 2005.
4936 Check_Valid_Configuration_Pragma;
4938 -- Now set Ada 2005 mode
4940 Ada_Version := Ada_05;
4941 Ada_Version_Explicit := Ada_05;
4945 ----------------------
4946 -- All_Calls_Remote --
4947 ----------------------
4949 -- pragma All_Calls_Remote [(library_package_NAME)];
4951 when Pragma_All_Calls_Remote => All_Calls_Remote : declare
4952 Lib_Entity : Entity_Id;
4955 Check_Ada_83_Warning;
4956 Check_Valid_Library_Unit_Pragma;
4958 if Nkind (N) = N_Null_Statement then
4962 Lib_Entity := Find_Lib_Unit_Name;
4964 -- This pragma should only apply to a RCI unit (RM E.2.3(23))
4966 if Present (Lib_Entity)
4967 and then not Debug_Flag_U
4969 if not Is_Remote_Call_Interface (Lib_Entity) then
4970 Error_Pragma ("pragma% only apply to rci unit");
4972 -- Set flag for entity of the library unit
4975 Set_Has_All_Calls_Remote (Lib_Entity);
4979 end All_Calls_Remote;
4985 -- pragma Annotate (IDENTIFIER {, ARG});
4986 -- ARG ::= NAME | EXPRESSION
4988 when Pragma_Annotate => Annotate : begin
4990 Check_At_Least_N_Arguments (1);
4991 Check_Arg_Is_Identifier (Arg1);
4999 while Present (Arg) loop
5000 Exp := Expression (Arg);
5003 if Is_Entity_Name (Exp) then
5006 elsif Nkind (Exp) = N_String_Literal then
5007 Resolve (Exp, Standard_String);
5009 elsif Is_Overloaded (Exp) then
5010 Error_Pragma_Arg ("ambiguous argument for pragma%", Exp);
5025 -- pragma Assert ([Check =>] Boolean_EXPRESSION
5026 -- [, [Message =>] Static_String_EXPRESSION]);
5028 when Pragma_Assert => Assert : declare
5034 Check_At_Least_N_Arguments (1);
5035 Check_At_Most_N_Arguments (2);
5036 Check_Arg_Order ((Name_Check, Name_Message));
5037 Check_Optional_Identifier (Arg1, Name_Check);
5039 -- We treat pragma Assert as equivalent to:
5041 -- pragma Check (Assertion, condition [, msg]);
5043 -- So rewrite pragma in this manner, and analyze the result
5045 Expr := Get_Pragma_Arg (Arg1);
5047 Make_Pragma_Argument_Association (Loc,
5049 Make_Identifier (Loc,
5050 Chars => Name_Assertion)),
5052 Make_Pragma_Argument_Association (Sloc (Expr),
5053 Expression => Expr));
5055 if Arg_Count > 1 then
5056 Check_Optional_Identifier (Arg2, Name_Message);
5057 Analyze_And_Resolve (Get_Pragma_Arg (Arg2), Standard_String);
5058 Append_To (Newa, Relocate_Node (Arg2));
5063 Chars => Name_Check,
5064 Pragma_Argument_Associations => Newa));
5068 ----------------------
5069 -- Assertion_Policy --
5070 ----------------------
5072 -- pragma Assertion_Policy (Check | Ignore)
5074 when Pragma_Assertion_Policy => Assertion_Policy : declare
5079 Check_Valid_Configuration_Pragma;
5080 Check_Arg_Count (1);
5081 Check_No_Identifiers;
5082 Check_Arg_Is_One_Of (Arg1, Name_Check, Name_Ignore);
5084 -- We treat pragma Assertion_Policy as equivalent to:
5086 -- pragma Check_Policy (Assertion, policy)
5088 -- So rewrite the pragma in that manner and link on to the chain
5089 -- of Check_Policy pragmas, marking the pragma as analyzed.
5091 Policy := Get_Pragma_Arg (Arg1);
5095 Chars => Name_Check_Policy,
5097 Pragma_Argument_Associations => New_List (
5098 Make_Pragma_Argument_Association (Loc,
5100 Make_Identifier (Loc,
5101 Chars => Name_Assertion)),
5103 Make_Pragma_Argument_Association (Loc,
5105 Make_Identifier (Sloc (Policy),
5106 Chars => Chars (Policy))))));
5109 Set_Next_Pragma (N, Opt.Check_Policy_List);
5110 Opt.Check_Policy_List := N;
5111 end Assertion_Policy;
5117 -- pragma AST_Entry (entry_IDENTIFIER);
5119 when Pragma_AST_Entry => AST_Entry : declare
5125 Check_Arg_Count (1);
5126 Check_No_Identifiers;
5127 Check_Arg_Is_Local_Name (Arg1);
5128 Ent := Entity (Expression (Arg1));
5130 -- Note: the implementation of the AST_Entry pragma could handle
5131 -- the entry family case fine, but for now we are consistent with
5132 -- the DEC rules, and do not allow the pragma, which of course
5133 -- has the effect of also forbidding the attribute.
5135 if Ekind (Ent) /= E_Entry then
5137 ("pragma% argument must be simple entry name", Arg1);
5139 elsif Is_AST_Entry (Ent) then
5141 ("duplicate % pragma for entry", Arg1);
5143 elsif Has_Homonym (Ent) then
5145 ("pragma% argument cannot specify overloaded entry", Arg1);
5149 FF : constant Entity_Id := First_Formal (Ent);
5152 if Present (FF) then
5153 if Present (Next_Formal (FF)) then
5155 ("entry for pragma% can have only one argument",
5158 elsif Parameter_Mode (FF) /= E_In_Parameter then
5160 ("entry parameter for pragma% must have mode IN",
5166 Set_Is_AST_Entry (Ent);
5174 -- pragma Asynchronous (LOCAL_NAME);
5176 when Pragma_Asynchronous => Asynchronous : declare
5184 procedure Process_Async_Pragma;
5185 -- Common processing for procedure and access-to-procedure case
5187 --------------------------
5188 -- Process_Async_Pragma --
5189 --------------------------
5191 procedure Process_Async_Pragma is
5194 Set_Is_Asynchronous (Nm);
5198 -- The formals should be of mode IN (RM E.4.1(6))
5201 while Present (S) loop
5202 Formal := Defining_Identifier (S);
5204 if Nkind (Formal) = N_Defining_Identifier
5205 and then Ekind (Formal) /= E_In_Parameter
5208 ("pragma% procedure can only have IN parameter",
5215 Set_Is_Asynchronous (Nm);
5216 end Process_Async_Pragma;
5218 -- Start of processing for pragma Asynchronous
5221 Check_Ada_83_Warning;
5222 Check_No_Identifiers;
5223 Check_Arg_Count (1);
5224 Check_Arg_Is_Local_Name (Arg1);
5226 if Debug_Flag_U then
5230 C_Ent := Cunit_Entity (Current_Sem_Unit);
5231 Analyze (Expression (Arg1));
5232 Nm := Entity (Expression (Arg1));
5234 if not Is_Remote_Call_Interface (C_Ent)
5235 and then not Is_Remote_Types (C_Ent)
5237 -- This pragma should only appear in an RCI or Remote Types
5238 -- unit (RM E.4.1(4))
5241 ("pragma% not in Remote_Call_Interface or " &
5242 "Remote_Types unit");
5245 if Ekind (Nm) = E_Procedure
5246 and then Nkind (Parent (Nm)) = N_Procedure_Specification
5248 if not Is_Remote_Call_Interface (Nm) then
5250 ("pragma% cannot be applied on non-remote procedure",
5254 L := Parameter_Specifications (Parent (Nm));
5255 Process_Async_Pragma;
5258 elsif Ekind (Nm) = E_Function then
5260 ("pragma% cannot be applied to function", Arg1);
5262 elsif Is_Remote_Access_To_Subprogram_Type (Nm) then
5264 if Is_Record_Type (Nm) then
5265 -- A record type that is the Equivalent_Type for
5266 -- a remote access-to-subprogram type.
5268 N := Declaration_Node (Corresponding_Remote_Type (Nm));
5271 -- A non-expanded RAS type (case where distribution is
5274 N := Declaration_Node (Nm);
5277 if Nkind (N) = N_Full_Type_Declaration
5278 and then Nkind (Type_Definition (N)) =
5279 N_Access_Procedure_Definition
5281 L := Parameter_Specifications (Type_Definition (N));
5282 Process_Async_Pragma;
5284 if Is_Asynchronous (Nm)
5285 and then Expander_Active
5286 and then Get_PCS_Name /= Name_No_DSA
5288 RACW_Type_Is_Asynchronous (Underlying_RACW_Type (Nm));
5293 ("pragma% cannot reference access-to-function type",
5297 -- Only other possibility is Access-to-class-wide type
5299 elsif Is_Access_Type (Nm)
5300 and then Is_Class_Wide_Type (Designated_Type (Nm))
5302 Check_First_Subtype (Arg1);
5303 Set_Is_Asynchronous (Nm);
5304 if Expander_Active then
5305 RACW_Type_Is_Asynchronous (Nm);
5309 Error_Pragma_Arg ("inappropriate argument for pragma%", Arg1);
5317 -- pragma Atomic (LOCAL_NAME);
5319 when Pragma_Atomic =>
5320 Process_Atomic_Shared_Volatile;
5322 -----------------------
5323 -- Atomic_Components --
5324 -----------------------
5326 -- pragma Atomic_Components (array_LOCAL_NAME);
5328 -- This processing is shared by Volatile_Components
5330 when Pragma_Atomic_Components |
5331 Pragma_Volatile_Components =>
5333 Atomic_Components : declare
5340 Check_Ada_83_Warning;
5341 Check_No_Identifiers;
5342 Check_Arg_Count (1);
5343 Check_Arg_Is_Local_Name (Arg1);
5344 E_Id := Expression (Arg1);
5346 if Etype (E_Id) = Any_Type then
5352 if Rep_Item_Too_Early (E, N)
5354 Rep_Item_Too_Late (E, N)
5359 D := Declaration_Node (E);
5362 if (K = N_Full_Type_Declaration and then Is_Array_Type (E))
5364 ((Ekind (E) = E_Constant or else Ekind (E) = E_Variable)
5365 and then Nkind (D) = N_Object_Declaration
5366 and then Nkind (Object_Definition (D)) =
5367 N_Constrained_Array_Definition)
5369 -- The flag is set on the object, or on the base type
5371 if Nkind (D) /= N_Object_Declaration then
5375 Set_Has_Volatile_Components (E);
5377 if Prag_Id = Pragma_Atomic_Components then
5378 Set_Has_Atomic_Components (E);
5380 if Is_Packed (E) then
5381 Set_Is_Packed (E, False);
5384 ("?Pack canceled, cannot pack atomic components",
5390 Error_Pragma_Arg ("inappropriate entity for pragma%", Arg1);
5392 end Atomic_Components;
5394 --------------------
5395 -- Attach_Handler --
5396 --------------------
5398 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
5400 when Pragma_Attach_Handler =>
5401 Check_Ada_83_Warning;
5402 Check_No_Identifiers;
5403 Check_Arg_Count (2);
5405 if No_Run_Time_Mode then
5406 Error_Msg_CRT ("Attach_Handler pragma", N);
5408 Check_Interrupt_Or_Attach_Handler;
5410 -- The expression that designates the attribute may
5411 -- depend on a discriminant, and is therefore a per-
5412 -- object expression, to be expanded in the init proc.
5413 -- If expansion is enabled, perform semantic checks
5416 if Expander_Active then
5418 Temp : constant Node_Id :=
5419 New_Copy_Tree (Expression (Arg2));
5421 Set_Parent (Temp, N);
5422 Preanalyze_And_Resolve (Temp, RTE (RE_Interrupt_ID));
5426 Analyze (Expression (Arg2));
5427 Resolve (Expression (Arg2), RTE (RE_Interrupt_ID));
5430 Process_Interrupt_Or_Attach_Handler;
5433 --------------------
5434 -- C_Pass_By_Copy --
5435 --------------------
5437 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
5439 when Pragma_C_Pass_By_Copy => C_Pass_By_Copy : declare
5445 Check_Valid_Configuration_Pragma;
5446 Check_Arg_Count (1);
5447 Check_Optional_Identifier (Arg1, "max_size");
5449 Arg := Expression (Arg1);
5450 Check_Arg_Is_Static_Expression (Arg, Any_Integer);
5452 Val := Expr_Value (Arg);
5456 ("maximum size for pragma% must be positive", Arg1);
5458 elsif UI_Is_In_Int_Range (Val) then
5459 Default_C_Record_Mechanism := UI_To_Int (Val);
5461 -- If a giant value is given, Int'Last will do well enough.
5462 -- If sometime someone complains that a record larger than
5463 -- two gigabytes is not copied, we will worry about it then!
5466 Default_C_Record_Mechanism := Mechanism_Type'Last;
5474 -- pragma Check ([Name =>] Identifier,
5475 -- [Check =>] Boolean_Expression
5476 -- [,[Message =>] String_Expression]);
5478 when Pragma_Check => Check : declare
5483 -- Set True if category of assertions referenced by Name enabled
5487 Check_At_Least_N_Arguments (2);
5488 Check_At_Most_N_Arguments (3);
5489 Check_Optional_Identifier (Arg1, Name_Name);
5490 Check_Optional_Identifier (Arg2, Name_Check);
5492 if Arg_Count = 3 then
5493 Check_Optional_Identifier (Arg3, Name_Message);
5494 Analyze_And_Resolve (Get_Pragma_Arg (Arg3), Standard_String);
5497 Check_Arg_Is_Identifier (Arg1);
5498 Check_On := Check_Enabled (Chars (Get_Pragma_Arg (Arg1)));
5500 -- If expansion is active and the check is not enabled then we
5501 -- rewrite the Check as:
5503 -- if False and then condition then
5507 -- The reason we do this rewriting during semantic analysis rather
5508 -- than as part of normal expansion is that we cannot analyze and
5509 -- expand the code for the boolean expression directly, or it may
5510 -- cause insertion of actions that would escape the attempt to
5511 -- suppress the check code.
5513 -- Note that the Sloc for the if statement corresponds to the
5514 -- argument condition, not the pragma itself. The reason for this
5515 -- is that we may generate a warning if the condition is False at
5516 -- compile time, and we do not want to delete this warning when we
5517 -- delete the if statement.
5519 Expr := Expression (Arg2);
5521 if Expander_Active and then not Check_On then
5522 Eloc := Sloc (Expr);
5525 Make_If_Statement (Eloc,
5527 Make_And_Then (Eloc,
5528 Left_Opnd => New_Occurrence_Of (Standard_False, Eloc),
5529 Right_Opnd => Expr),
5530 Then_Statements => New_List (
5531 Make_Null_Statement (Eloc))));
5538 Analyze_And_Resolve (Expr, Any_Boolean);
5541 -- If assertion is of the form (X'First = literal), where X is
5542 -- a formal, then set Low_Bound_Known flag on this formal.
5544 if Nkind (Expr) = N_Op_Eq then
5546 Right : constant Node_Id := Right_Opnd (Expr);
5547 Left : constant Node_Id := Left_Opnd (Expr);
5549 if Nkind (Left) = N_Attribute_Reference
5550 and then Attribute_Name (Left) = Name_First
5551 and then Is_Entity_Name (Prefix (Left))
5552 and then Is_Formal (Entity (Prefix (Left)))
5553 and then Nkind (Right) = N_Integer_Literal
5555 Set_Low_Bound_Known (Entity (Prefix (Left)));
5565 -- pragma Check_Name (check_IDENTIFIER);
5567 when Pragma_Check_Name =>
5568 Check_No_Identifiers;
5570 Check_Valid_Configuration_Pragma;
5571 Check_Arg_Count (1);
5572 Check_Arg_Is_Identifier (Arg1);
5575 Nam : constant Name_Id := Chars (Expression (Arg1));
5578 for J in Check_Names.First .. Check_Names.Last loop
5579 if Check_Names.Table (J) = Nam then
5584 Check_Names.Append (Nam);
5591 -- pragma Check_Policy ([Name =>] IDENTIFIER,
5592 -- POLICY_IDENTIFIER;
5594 -- POLICY_IDENTIFIER ::= ON | OFF | CHECK | IGNORE
5596 -- Note: this is a configuration pragma, but it is allowed to
5597 -- appear anywhere else.
5599 when Pragma_Check_Policy =>
5601 Check_Arg_Count (2);
5602 Check_No_Identifier (Arg2);
5603 Check_Optional_Identifier (Arg1, Name_Name);
5605 (Arg2, Name_On, Name_Off, Name_Check, Name_Ignore);
5607 -- A Check_Policy pragma can appear either as a configuration
5608 -- pragma, or in a declarative part or a package spec (see RM
5609 -- 11.5(5) for rules for Suppress/Unsuppress which are also
5610 -- followed for Check_Policy).
5612 if not Is_Configuration_Pragma then
5613 Check_Is_In_Decl_Part_Or_Package_Spec;
5616 Set_Next_Pragma (N, Opt.Check_Policy_List);
5617 Opt.Check_Policy_List := N;
5619 ---------------------
5620 -- CIL_Constructor --
5621 ---------------------
5623 -- pragma CIL_Constructor ([Entity =>] LOCAL_NAME);
5625 -- Processing for this pragma is shared with Java_Constructor
5631 -- pragma Comment (static_string_EXPRESSION)
5633 -- Processing for pragma Comment shares the circuitry for
5634 -- pragma Ident. The only differences are that Ident enforces
5635 -- a limit of 31 characters on its argument, and also enforces
5636 -- limitations on placement for DEC compatibility. Pragma
5637 -- Comment shares neither of these restrictions.
5643 -- pragma Common_Object (
5644 -- [Internal =>] LOCAL_NAME
5645 -- [, [External =>] EXTERNAL_SYMBOL]
5646 -- [, [Size =>] EXTERNAL_SYMBOL]);
5648 -- Processing for this pragma is shared with Psect_Object
5650 ------------------------
5651 -- Compile_Time_Error --
5652 ------------------------
5654 -- pragma Compile_Time_Error
5655 -- (boolean_EXPRESSION, static_string_EXPRESSION);
5657 when Pragma_Compile_Time_Error =>
5658 Process_Compile_Time_Warning_Or_Error;
5660 --------------------------
5661 -- Compile_Time_Warning --
5662 --------------------------
5664 -- pragma Compile_Time_Warning
5665 -- (boolean_EXPRESSION, static_string_EXPRESSION);
5667 when Pragma_Compile_Time_Warning =>
5668 Process_Compile_Time_Warning_Or_Error;
5674 when Pragma_Compiler_Unit =>
5676 Check_Arg_Count (0);
5677 Set_Is_Compiler_Unit (Get_Source_Unit (N));
5679 -----------------------------
5680 -- Complete_Representation --
5681 -----------------------------
5683 -- pragma Complete_Representation;
5685 when Pragma_Complete_Representation =>
5687 Check_Arg_Count (0);
5689 if Nkind (Parent (N)) /= N_Record_Representation_Clause then
5691 ("pragma & must appear within record representation clause");
5694 ----------------------------
5695 -- Complex_Representation --
5696 ----------------------------
5698 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
5700 when Pragma_Complex_Representation => Complex_Representation : declare
5707 Check_Arg_Count (1);
5708 Check_Optional_Identifier (Arg1, Name_Entity);
5709 Check_Arg_Is_Local_Name (Arg1);
5710 E_Id := Expression (Arg1);
5712 if Etype (E_Id) = Any_Type then
5718 if not Is_Record_Type (E) then
5720 ("argument for pragma% must be record type", Arg1);
5723 Ent := First_Entity (E);
5726 or else No (Next_Entity (Ent))
5727 or else Present (Next_Entity (Next_Entity (Ent)))
5728 or else not Is_Floating_Point_Type (Etype (Ent))
5729 or else Etype (Ent) /= Etype (Next_Entity (Ent))
5732 ("record for pragma% must have two fields of the same "
5733 & "floating-point type", Arg1);
5736 Set_Has_Complex_Representation (Base_Type (E));
5738 -- We need to treat the type has having a non-standard
5739 -- representation, for back-end purposes, even though in
5740 -- general a complex will have the default representation
5741 -- of a record with two real components.
5743 Set_Has_Non_Standard_Rep (Base_Type (E));
5745 end Complex_Representation;
5747 -------------------------
5748 -- Component_Alignment --
5749 -------------------------
5751 -- pragma Component_Alignment (
5752 -- [Form =>] ALIGNMENT_CHOICE
5753 -- [, [Name =>] type_LOCAL_NAME]);
5755 -- ALIGNMENT_CHOICE ::=
5757 -- | Component_Size_4
5761 when Pragma_Component_Alignment => Component_AlignmentP : declare
5762 Args : Args_List (1 .. 2);
5763 Names : constant Name_List (1 .. 2) := (
5767 Form : Node_Id renames Args (1);
5768 Name : Node_Id renames Args (2);
5770 Atype : Component_Alignment_Kind;
5775 Gather_Associations (Names, Args);
5778 Error_Pragma ("missing Form argument for pragma%");
5781 Check_Arg_Is_Identifier (Form);
5783 -- Get proper alignment, note that Default = Component_Size
5784 -- on all machines we have so far, and we want to set this
5785 -- value rather than the default value to indicate that it
5786 -- has been explicitly set (and thus will not get overridden
5787 -- by the default component alignment for the current scope)
5789 if Chars (Form) = Name_Component_Size then
5790 Atype := Calign_Component_Size;
5792 elsif Chars (Form) = Name_Component_Size_4 then
5793 Atype := Calign_Component_Size_4;
5795 elsif Chars (Form) = Name_Default then
5796 Atype := Calign_Component_Size;
5798 elsif Chars (Form) = Name_Storage_Unit then
5799 Atype := Calign_Storage_Unit;
5803 ("invalid Form parameter for pragma%", Form);
5806 -- Case with no name, supplied, affects scope table entry
5810 (Scope_Stack.Last).Component_Alignment_Default := Atype;
5812 -- Case of name supplied
5815 Check_Arg_Is_Local_Name (Name);
5817 Typ := Entity (Name);
5820 or else Rep_Item_Too_Early (Typ, N)
5824 Typ := Underlying_Type (Typ);
5827 if not Is_Record_Type (Typ)
5828 and then not Is_Array_Type (Typ)
5831 ("Name parameter of pragma% must identify record or " &
5832 "array type", Name);
5835 -- An explicit Component_Alignment pragma overrides an
5836 -- implicit pragma Pack, but not an explicit one.
5838 if not Has_Pragma_Pack (Base_Type (Typ)) then
5839 Set_Is_Packed (Base_Type (Typ), False);
5840 Set_Component_Alignment (Base_Type (Typ), Atype);
5843 end Component_AlignmentP;
5849 -- pragma Controlled (first_subtype_LOCAL_NAME);
5851 when Pragma_Controlled => Controlled : declare
5855 Check_No_Identifiers;
5856 Check_Arg_Count (1);
5857 Check_Arg_Is_Local_Name (Arg1);
5858 Arg := Expression (Arg1);
5860 if not Is_Entity_Name (Arg)
5861 or else not Is_Access_Type (Entity (Arg))
5863 Error_Pragma_Arg ("pragma% requires access type", Arg1);
5865 Set_Has_Pragma_Controlled (Base_Type (Entity (Arg)));
5873 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
5874 -- [Entity =>] LOCAL_NAME);
5876 when Pragma_Convention => Convention : declare
5879 pragma Warnings (Off, C);
5880 pragma Warnings (Off, E);
5882 Check_Arg_Order ((Name_Convention, Name_Entity));
5883 Check_Ada_83_Warning;
5884 Check_Arg_Count (2);
5885 Process_Convention (C, E);
5888 ---------------------------
5889 -- Convention_Identifier --
5890 ---------------------------
5892 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
5893 -- [Convention =>] convention_IDENTIFIER);
5895 when Pragma_Convention_Identifier => Convention_Identifier : declare
5901 Check_Arg_Order ((Name_Name, Name_Convention));
5902 Check_Arg_Count (2);
5903 Check_Optional_Identifier (Arg1, Name_Name);
5904 Check_Optional_Identifier (Arg2, Name_Convention);
5905 Check_Arg_Is_Identifier (Arg1);
5906 Check_Arg_Is_Identifier (Arg2);
5907 Idnam := Chars (Expression (Arg1));
5908 Cname := Chars (Expression (Arg2));
5910 if Is_Convention_Name (Cname) then
5911 Record_Convention_Identifier
5912 (Idnam, Get_Convention_Id (Cname));
5915 ("second arg for % pragma must be convention", Arg2);
5917 end Convention_Identifier;
5923 -- pragma CPP_Class ([Entity =>] local_NAME)
5925 when Pragma_CPP_Class => CPP_Class : declare
5930 if Warn_On_Obsolescent_Feature then
5932 ("'G'N'A'T pragma cpp'_class is now obsolete; replace it" &
5933 " by pragma import?", N);
5937 Check_Arg_Count (1);
5938 Check_Optional_Identifier (Arg1, Name_Entity);
5939 Check_Arg_Is_Local_Name (Arg1);
5941 Arg := Expression (Arg1);
5944 if Etype (Arg) = Any_Type then
5948 if not Is_Entity_Name (Arg)
5949 or else not Is_Type (Entity (Arg))
5951 Error_Pragma_Arg ("pragma% requires a type mark", Arg1);
5954 Typ := Entity (Arg);
5956 if not Is_Tagged_Type (Typ) then
5957 Error_Pragma_Arg ("pragma% applicable to tagged types ", Arg1);
5960 -- Types treated as CPP classes are treated as limited, but we
5961 -- don't require them to be declared this way. A warning is issued
5962 -- to encourage the user to declare them as limited. This is not
5963 -- an error, for compatibility reasons, because these types have
5964 -- been supported this way for some time.
5966 if not Is_Limited_Type (Typ) then
5968 ("imported 'C'P'P type should be " &
5969 "explicitly declared limited?",
5970 Get_Pragma_Arg (Arg1));
5972 ("\type will be considered limited",
5973 Get_Pragma_Arg (Arg1));
5976 Set_Is_CPP_Class (Typ);
5977 Set_Is_Limited_Record (Typ);
5978 Set_Convention (Typ, Convention_CPP);
5981 ---------------------
5982 -- CPP_Constructor --
5983 ---------------------
5985 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME
5986 -- [, [External_Name =>] static_string_EXPRESSION ]
5987 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5989 when Pragma_CPP_Constructor => CPP_Constructor : declare
5995 Check_At_Least_N_Arguments (1);
5996 Check_At_Most_N_Arguments (3);
5997 Check_Optional_Identifier (Arg1, Name_Entity);
5998 Check_Arg_Is_Local_Name (Arg1);
6000 Id := Expression (Arg1);
6001 Find_Program_Unit_Name (Id);
6003 -- If we did not find the name, we are done
6005 if Etype (Id) = Any_Type then
6009 Def_Id := Entity (Id);
6011 if Ekind (Def_Id) = E_Function
6012 and then Is_Class_Wide_Type (Etype (Def_Id))
6013 and then Is_CPP_Class (Etype (Etype (Def_Id)))
6015 if Arg_Count >= 2 then
6016 Set_Imported (Def_Id);
6017 Set_Is_Public (Def_Id);
6018 Process_Interface_Name (Def_Id, Arg2, Arg3);
6021 if No (Parameter_Specifications (Parent (Def_Id))) then
6022 Set_Has_Completion (Def_Id);
6023 Set_Is_Constructor (Def_Id);
6026 ("non-default constructors not implemented", Arg1);
6031 ("pragma% requires function returning a 'C'P'P_Class type",
6034 end CPP_Constructor;
6040 when Pragma_CPP_Virtual => CPP_Virtual : declare
6042 if Warn_On_Obsolescent_Feature then
6044 ("'G'N'A'T pragma cpp'_virtual is now obsolete and has " &
6053 when Pragma_CPP_Vtable => CPP_Vtable : declare
6055 if Warn_On_Obsolescent_Feature then
6057 ("'G'N'A'T pragma cpp'_vtable is now obsolete and has " &
6066 -- pragma Debug ([boolean_EXPRESSION,] PROCEDURE_CALL_STATEMENT);
6068 when Pragma_Debug => Debug : declare
6076 (Boolean_Literals (Debug_Pragmas_Enabled and Expander_Active),
6079 if Arg_Count = 2 then
6082 Left_Opnd => Relocate_Node (Cond),
6083 Right_Opnd => Expression (Arg1));
6086 -- Rewrite into a conditional with an appropriate condition. We
6087 -- wrap the procedure call in a block so that overhead from e.g.
6088 -- use of the secondary stack does not generate execution overhead
6089 -- for suppressed conditions.
6091 Rewrite (N, Make_Implicit_If_Statement (N,
6093 Then_Statements => New_List (
6094 Make_Block_Statement (Loc,
6095 Handled_Statement_Sequence =>
6096 Make_Handled_Sequence_Of_Statements (Loc,
6097 Statements => New_List (
6098 Relocate_Node (Debug_Statement (N))))))));
6106 -- pragma Debug_Policy (Check | Ignore)
6108 when Pragma_Debug_Policy =>
6110 Check_Arg_Count (1);
6111 Check_Arg_Is_One_Of (Arg1, Name_Check, Name_Ignore);
6112 Debug_Pragmas_Enabled := Chars (Expression (Arg1)) = Name_Check;
6114 ---------------------
6115 -- Detect_Blocking --
6116 ---------------------
6118 -- pragma Detect_Blocking;
6120 when Pragma_Detect_Blocking =>
6122 Check_Arg_Count (0);
6123 Check_Valid_Configuration_Pragma;
6124 Detect_Blocking := True;
6130 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
6132 when Pragma_Discard_Names => Discard_Names : declare
6137 Check_Ada_83_Warning;
6139 -- Deal with configuration pragma case
6141 if Arg_Count = 0 and then Is_Configuration_Pragma then
6142 Global_Discard_Names := True;
6145 -- Otherwise, check correct appropriate context
6148 Check_Is_In_Decl_Part_Or_Package_Spec;
6150 if Arg_Count = 0 then
6152 -- If there is no parameter, then from now on this pragma
6153 -- applies to any enumeration, exception or tagged type
6154 -- defined in the current declarative part, and recursively
6155 -- to any nested scope.
6157 Set_Discard_Names (Current_Scope);
6161 Check_Arg_Count (1);
6162 Check_Optional_Identifier (Arg1, Name_On);
6163 Check_Arg_Is_Local_Name (Arg1);
6164 E_Id := Expression (Arg1);
6166 if Etype (E_Id) = Any_Type then
6172 if (Is_First_Subtype (E)
6173 and then (Is_Enumeration_Type (E)
6174 or else Is_Tagged_Type (E)))
6175 or else Ekind (E) = E_Exception
6177 Set_Discard_Names (E);
6180 ("inappropriate entity for pragma%", Arg1);
6190 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
6192 when Pragma_Elaborate => Elaborate : declare
6197 -- Pragma must be in context items list of a compilation unit
6199 if not Is_In_Context_Clause then
6203 -- Must be at least one argument
6205 if Arg_Count = 0 then
6206 Error_Pragma ("pragma% requires at least one argument");
6209 -- In Ada 83 mode, there can be no items following it in the
6210 -- context list except other pragmas and implicit with clauses
6211 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
6212 -- placement rule does not apply.
6214 if Ada_Version = Ada_83 and then Comes_From_Source (N) then
6216 while Present (Citem) loop
6217 if Nkind (Citem) = N_Pragma
6218 or else (Nkind (Citem) = N_With_Clause
6219 and then Implicit_With (Citem))
6224 ("(Ada 83) pragma% must be at end of context clause");
6231 -- Finally, the arguments must all be units mentioned in a with
6232 -- clause in the same context clause. Note we already checked (in
6233 -- Par.Prag) that the arguments are all identifiers or selected
6237 Outer : while Present (Arg) loop
6238 Citem := First (List_Containing (N));
6239 Inner : while Citem /= N loop
6240 if Nkind (Citem) = N_With_Clause
6241 and then Same_Name (Name (Citem), Expression (Arg))
6243 Set_Elaborate_Present (Citem, True);
6244 Set_Unit_Name (Expression (Arg), Name (Citem));
6246 -- With the pragma present, elaboration calls on
6247 -- subprograms from the named unit need no further
6248 -- checks, as long as the pragma appears in the current
6249 -- compilation unit. If the pragma appears in some unit
6250 -- in the context, there might still be a need for an
6251 -- Elaborate_All_Desirable from the current compilation
6252 -- to the named unit, so we keep the check enabled.
6254 if In_Extended_Main_Source_Unit (N) then
6255 Set_Suppress_Elaboration_Warnings
6256 (Entity (Name (Citem)));
6267 ("argument of pragma% is not with'ed unit", Arg);
6273 -- Give a warning if operating in static mode with -gnatwl
6274 -- (elaboration warnings enabled) switch set.
6276 if Elab_Warnings and not Dynamic_Elaboration_Checks then
6278 ("?use of pragma Elaborate may not be safe", N);
6280 ("?use pragma Elaborate_All instead if possible", N);
6288 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
6290 when Pragma_Elaborate_All => Elaborate_All : declare
6295 Check_Ada_83_Warning;
6297 -- Pragma must be in context items list of a compilation unit
6299 if not Is_In_Context_Clause then
6303 -- Must be at least one argument
6305 if Arg_Count = 0 then
6306 Error_Pragma ("pragma% requires at least one argument");
6309 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
6310 -- have to appear at the end of the context clause, but may
6311 -- appear mixed in with other items, even in Ada 83 mode.
6313 -- Final check: the arguments must all be units mentioned in
6314 -- a with clause in the same context clause. Note that we
6315 -- already checked (in Par.Prag) that all the arguments are
6316 -- either identifiers or selected components.
6319 Outr : while Present (Arg) loop
6320 Citem := First (List_Containing (N));
6321 Innr : while Citem /= N loop
6322 if Nkind (Citem) = N_With_Clause
6323 and then Same_Name (Name (Citem), Expression (Arg))
6325 Set_Elaborate_All_Present (Citem, True);
6326 Set_Unit_Name (Expression (Arg), Name (Citem));
6328 -- Suppress warnings and elaboration checks on the named
6329 -- unit if the pragma is in the current compilation, as
6330 -- for pragma Elaborate.
6332 if In_Extended_Main_Source_Unit (N) then
6333 Set_Suppress_Elaboration_Warnings
6334 (Entity (Name (Citem)));
6343 Set_Error_Posted (N);
6345 ("argument of pragma% is not with'ed unit", Arg);
6352 --------------------
6353 -- Elaborate_Body --
6354 --------------------
6356 -- pragma Elaborate_Body [( library_unit_NAME )];
6358 when Pragma_Elaborate_Body => Elaborate_Body : declare
6359 Cunit_Node : Node_Id;
6360 Cunit_Ent : Entity_Id;
6363 Check_Ada_83_Warning;
6364 Check_Valid_Library_Unit_Pragma;
6366 if Nkind (N) = N_Null_Statement then
6370 Cunit_Node := Cunit (Current_Sem_Unit);
6371 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
6373 if Nkind (Unit (Cunit_Node)) = N_Package_Body
6375 Nkind (Unit (Cunit_Node)) = N_Subprogram_Body
6377 Error_Pragma ("pragma% must refer to a spec, not a body");
6379 Set_Body_Required (Cunit_Node, True);
6380 Set_Has_Pragma_Elaborate_Body (Cunit_Ent);
6382 -- If we are in dynamic elaboration mode, then we suppress
6383 -- elaboration warnings for the unit, since it is definitely
6384 -- fine NOT to do dynamic checks at the first level (and such
6385 -- checks will be suppressed because no elaboration boolean
6386 -- is created for Elaborate_Body packages).
6388 -- But in the static model of elaboration, Elaborate_Body is
6389 -- definitely NOT good enough to ensure elaboration safety on
6390 -- its own, since the body may WITH other units that are not
6391 -- safe from an elaboration point of view, so a client must
6392 -- still do an Elaborate_All on such units.
6394 -- Debug flag -gnatdD restores the old behavior of 3.13,
6395 -- where Elaborate_Body always suppressed elab warnings.
6397 if Dynamic_Elaboration_Checks or Debug_Flag_DD then
6398 Set_Suppress_Elaboration_Warnings (Cunit_Ent);
6403 ------------------------
6404 -- Elaboration_Checks --
6405 ------------------------
6407 -- pragma Elaboration_Checks (Static | Dynamic);
6409 when Pragma_Elaboration_Checks =>
6411 Check_Arg_Count (1);
6412 Check_Arg_Is_One_Of (Arg1, Name_Static, Name_Dynamic);
6413 Dynamic_Elaboration_Checks :=
6414 (Chars (Get_Pragma_Arg (Arg1)) = Name_Dynamic);
6420 -- pragma Eliminate (
6421 -- [Unit_Name =>] IDENTIFIER |
6422 -- SELECTED_COMPONENT
6423 -- [,[Entity =>] IDENTIFIER |
6424 -- SELECTED_COMPONENT |
6426 -- [,]OVERLOADING_RESOLUTION);
6428 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
6431 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
6434 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
6436 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
6437 -- Result_Type => result_SUBTYPE_NAME]
6439 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
6440 -- SUBTYPE_NAME ::= STRING_LITERAL
6442 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
6443 -- SOURCE_TRACE ::= STRING_LITERAL
6445 when Pragma_Eliminate => Eliminate : declare
6446 Args : Args_List (1 .. 5);
6447 Names : constant Name_List (1 .. 5) := (
6450 Name_Parameter_Types,
6452 Name_Source_Location);
6454 Unit_Name : Node_Id renames Args (1);
6455 Entity : Node_Id renames Args (2);
6456 Parameter_Types : Node_Id renames Args (3);
6457 Result_Type : Node_Id renames Args (4);
6458 Source_Location : Node_Id renames Args (5);
6462 Check_Valid_Configuration_Pragma;
6463 Gather_Associations (Names, Args);
6465 if No (Unit_Name) then
6466 Error_Pragma ("missing Unit_Name argument for pragma%");
6470 and then (Present (Parameter_Types)
6472 Present (Result_Type)
6474 Present (Source_Location))
6476 Error_Pragma ("missing Entity argument for pragma%");
6479 if (Present (Parameter_Types)
6481 Present (Result_Type))
6483 Present (Source_Location)
6486 ("parameter profile and source location cannot " &
6487 "be used together in pragma%");
6490 Process_Eliminate_Pragma
6504 -- [ Convention =>] convention_IDENTIFIER,
6505 -- [ Entity =>] local_NAME
6506 -- [, [External_Name =>] static_string_EXPRESSION ]
6507 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6509 when Pragma_Export => Export : declare
6513 pragma Warnings (Off, C);
6516 Check_Ada_83_Warning;
6522 Check_At_Least_N_Arguments (2);
6523 Check_At_Most_N_Arguments (4);
6524 Process_Convention (C, Def_Id);
6526 if Ekind (Def_Id) /= E_Constant then
6527 Note_Possible_Modification (Expression (Arg2), Sure => False);
6530 Process_Interface_Name (Def_Id, Arg3, Arg4);
6531 Set_Exported (Def_Id, Arg2);
6533 -- If the entity is a deferred constant, propagate the
6534 -- information to the full view, because gigi elaborates
6535 -- the full view only.
6537 if Ekind (Def_Id) = E_Constant
6538 and then Present (Full_View (Def_Id))
6541 Id2 : constant Entity_Id := Full_View (Def_Id);
6543 Set_Is_Exported (Id2, Is_Exported (Def_Id));
6544 Set_First_Rep_Item (Id2, First_Rep_Item (Def_Id));
6545 Set_Interface_Name (Id2, Einfo.Interface_Name (Def_Id));
6550 ----------------------
6551 -- Export_Exception --
6552 ----------------------
6554 -- pragma Export_Exception (
6555 -- [Internal =>] LOCAL_NAME
6556 -- [, [External =>] EXTERNAL_SYMBOL]
6557 -- [, [Form =>] Ada | VMS]
6558 -- [, [Code =>] static_integer_EXPRESSION]);
6560 when Pragma_Export_Exception => Export_Exception : declare
6561 Args : Args_List (1 .. 4);
6562 Names : constant Name_List (1 .. 4) := (
6568 Internal : Node_Id renames Args (1);
6569 External : Node_Id renames Args (2);
6570 Form : Node_Id renames Args (3);
6571 Code : Node_Id renames Args (4);
6574 if Inside_A_Generic then
6575 Error_Pragma ("pragma% cannot be used for generic entities");
6578 Gather_Associations (Names, Args);
6579 Process_Extended_Import_Export_Exception_Pragma (
6580 Arg_Internal => Internal,
6581 Arg_External => External,
6585 if not Is_VMS_Exception (Entity (Internal)) then
6586 Set_Exported (Entity (Internal), Internal);
6588 end Export_Exception;
6590 ---------------------
6591 -- Export_Function --
6592 ---------------------
6594 -- pragma Export_Function (
6595 -- [Internal =>] LOCAL_NAME
6596 -- [, [External =>] EXTERNAL_SYMBOL]
6597 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6598 -- [, [Result_Type =>] TYPE_DESIGNATOR]
6599 -- [, [Mechanism =>] MECHANISM]
6600 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
6602 -- EXTERNAL_SYMBOL ::=
6604 -- | static_string_EXPRESSION
6606 -- PARAMETER_TYPES ::=
6608 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6610 -- TYPE_DESIGNATOR ::=
6612 -- | subtype_Name ' Access
6616 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6618 -- MECHANISM_ASSOCIATION ::=
6619 -- [formal_parameter_NAME =>] MECHANISM_NAME
6621 -- MECHANISM_NAME ::=
6624 -- | Descriptor [([Class =>] CLASS_NAME)]
6626 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6628 when Pragma_Export_Function => Export_Function : declare
6629 Args : Args_List (1 .. 6);
6630 Names : constant Name_List (1 .. 6) := (
6633 Name_Parameter_Types,
6636 Name_Result_Mechanism);
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);
6647 Gather_Associations (Names, Args);
6648 Process_Extended_Import_Export_Subprogram_Pragma (
6649 Arg_Internal => Internal,
6650 Arg_External => External,
6651 Arg_Parameter_Types => Parameter_Types,
6652 Arg_Result_Type => Result_Type,
6653 Arg_Mechanism => Mechanism,
6654 Arg_Result_Mechanism => Result_Mechanism);
6655 end Export_Function;
6661 -- pragma Export_Object (
6662 -- [Internal =>] LOCAL_NAME
6663 -- [, [External =>] EXTERNAL_SYMBOL]
6664 -- [, [Size =>] EXTERNAL_SYMBOL]);
6666 -- EXTERNAL_SYMBOL ::=
6668 -- | static_string_EXPRESSION
6670 -- PARAMETER_TYPES ::=
6672 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6674 -- TYPE_DESIGNATOR ::=
6676 -- | subtype_Name ' Access
6680 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6682 -- MECHANISM_ASSOCIATION ::=
6683 -- [formal_parameter_NAME =>] MECHANISM_NAME
6685 -- MECHANISM_NAME ::=
6688 -- | Descriptor [([Class =>] CLASS_NAME)]
6690 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6692 when Pragma_Export_Object => Export_Object : declare
6693 Args : Args_List (1 .. 3);
6694 Names : constant Name_List (1 .. 3) := (
6699 Internal : Node_Id renames Args (1);
6700 External : Node_Id renames Args (2);
6701 Size : Node_Id renames Args (3);
6705 Gather_Associations (Names, Args);
6706 Process_Extended_Import_Export_Object_Pragma (
6707 Arg_Internal => Internal,
6708 Arg_External => External,
6712 ----------------------
6713 -- Export_Procedure --
6714 ----------------------
6716 -- pragma Export_Procedure (
6717 -- [Internal =>] LOCAL_NAME
6718 -- [, [External =>] EXTERNAL_SYMBOL]
6719 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6720 -- [, [Mechanism =>] MECHANISM]);
6722 -- EXTERNAL_SYMBOL ::=
6724 -- | static_string_EXPRESSION
6726 -- PARAMETER_TYPES ::=
6728 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6730 -- TYPE_DESIGNATOR ::=
6732 -- | subtype_Name ' Access
6736 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6738 -- MECHANISM_ASSOCIATION ::=
6739 -- [formal_parameter_NAME =>] MECHANISM_NAME
6741 -- MECHANISM_NAME ::=
6744 -- | Descriptor [([Class =>] CLASS_NAME)]
6746 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6748 when Pragma_Export_Procedure => Export_Procedure : declare
6749 Args : Args_List (1 .. 4);
6750 Names : constant Name_List (1 .. 4) := (
6753 Name_Parameter_Types,
6756 Internal : Node_Id renames Args (1);
6757 External : Node_Id renames Args (2);
6758 Parameter_Types : Node_Id renames Args (3);
6759 Mechanism : Node_Id renames Args (4);
6763 Gather_Associations (Names, Args);
6764 Process_Extended_Import_Export_Subprogram_Pragma (
6765 Arg_Internal => Internal,
6766 Arg_External => External,
6767 Arg_Parameter_Types => Parameter_Types,
6768 Arg_Mechanism => Mechanism);
6769 end Export_Procedure;
6775 -- pragma Export_Value (
6776 -- [Value =>] static_integer_EXPRESSION,
6777 -- [Link_Name =>] static_string_EXPRESSION);
6779 when Pragma_Export_Value =>
6781 Check_Arg_Order ((Name_Value, Name_Link_Name));
6782 Check_Arg_Count (2);
6784 Check_Optional_Identifier (Arg1, Name_Value);
6785 Check_Arg_Is_Static_Expression (Arg1, Any_Integer);
6787 Check_Optional_Identifier (Arg2, Name_Link_Name);
6788 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
6790 -----------------------------
6791 -- Export_Valued_Procedure --
6792 -----------------------------
6794 -- pragma Export_Valued_Procedure (
6795 -- [Internal =>] LOCAL_NAME
6796 -- [, [External =>] EXTERNAL_SYMBOL,]
6797 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6798 -- [, [Mechanism =>] MECHANISM]);
6800 -- EXTERNAL_SYMBOL ::=
6802 -- | static_string_EXPRESSION
6804 -- PARAMETER_TYPES ::=
6806 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6808 -- TYPE_DESIGNATOR ::=
6810 -- | subtype_Name ' Access
6814 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6816 -- MECHANISM_ASSOCIATION ::=
6817 -- [formal_parameter_NAME =>] MECHANISM_NAME
6819 -- MECHANISM_NAME ::=
6822 -- | Descriptor [([Class =>] CLASS_NAME)]
6824 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6826 when Pragma_Export_Valued_Procedure =>
6827 Export_Valued_Procedure : declare
6828 Args : Args_List (1 .. 4);
6829 Names : constant Name_List (1 .. 4) := (
6832 Name_Parameter_Types,
6835 Internal : Node_Id renames Args (1);
6836 External : Node_Id renames Args (2);
6837 Parameter_Types : Node_Id renames Args (3);
6838 Mechanism : Node_Id renames Args (4);
6842 Gather_Associations (Names, Args);
6843 Process_Extended_Import_Export_Subprogram_Pragma (
6844 Arg_Internal => Internal,
6845 Arg_External => External,
6846 Arg_Parameter_Types => Parameter_Types,
6847 Arg_Mechanism => Mechanism);
6848 end Export_Valued_Procedure;
6854 -- pragma Extend_System ([Name =>] Identifier);
6856 when Pragma_Extend_System => Extend_System : declare
6859 Check_Valid_Configuration_Pragma;
6860 Check_Arg_Count (1);
6861 Check_Optional_Identifier (Arg1, Name_Name);
6862 Check_Arg_Is_Identifier (Arg1);
6864 Get_Name_String (Chars (Expression (Arg1)));
6867 and then Name_Buffer (1 .. 4) = "aux_"
6869 if Present (System_Extend_Pragma_Arg) then
6870 if Chars (Expression (Arg1)) =
6871 Chars (Expression (System_Extend_Pragma_Arg))
6875 Error_Msg_Sloc := Sloc (System_Extend_Pragma_Arg);
6876 Error_Pragma ("pragma% conflicts with that #");
6880 System_Extend_Pragma_Arg := Arg1;
6882 if not GNAT_Mode then
6883 System_Extend_Unit := Arg1;
6887 Error_Pragma ("incorrect name for pragma%, must be Aux_xxx");
6891 ------------------------
6892 -- Extensions_Allowed --
6893 ------------------------
6895 -- pragma Extensions_Allowed (ON | OFF);
6897 when Pragma_Extensions_Allowed =>
6899 Check_Arg_Count (1);
6900 Check_No_Identifiers;
6901 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
6903 if Chars (Expression (Arg1)) = Name_On then
6904 Extensions_Allowed := True;
6906 Extensions_Allowed := False;
6913 -- pragma External (
6914 -- [ Convention =>] convention_IDENTIFIER,
6915 -- [ Entity =>] local_NAME
6916 -- [, [External_Name =>] static_string_EXPRESSION ]
6917 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6919 when Pragma_External => External : declare
6923 pragma Warnings (Off, C);
6932 Check_At_Least_N_Arguments (2);
6933 Check_At_Most_N_Arguments (4);
6934 Process_Convention (C, Def_Id);
6935 Note_Possible_Modification (Expression (Arg2), Sure => False);
6936 Process_Interface_Name (Def_Id, Arg3, Arg4);
6937 Set_Exported (Def_Id, Arg2);
6940 --------------------------
6941 -- External_Name_Casing --
6942 --------------------------
6944 -- pragma External_Name_Casing (
6945 -- UPPERCASE | LOWERCASE
6946 -- [, AS_IS | UPPERCASE | LOWERCASE]);
6948 when Pragma_External_Name_Casing => External_Name_Casing : declare
6951 Check_No_Identifiers;
6953 if Arg_Count = 2 then
6955 (Arg2, Name_As_Is, Name_Uppercase, Name_Lowercase);
6957 case Chars (Get_Pragma_Arg (Arg2)) is
6959 Opt.External_Name_Exp_Casing := As_Is;
6961 when Name_Uppercase =>
6962 Opt.External_Name_Exp_Casing := Uppercase;
6964 when Name_Lowercase =>
6965 Opt.External_Name_Exp_Casing := Lowercase;
6972 Check_Arg_Count (1);
6975 Check_Arg_Is_One_Of (Arg1, Name_Uppercase, Name_Lowercase);
6977 case Chars (Get_Pragma_Arg (Arg1)) is
6978 when Name_Uppercase =>
6979 Opt.External_Name_Imp_Casing := Uppercase;
6981 when Name_Lowercase =>
6982 Opt.External_Name_Imp_Casing := Lowercase;
6987 end External_Name_Casing;
6989 --------------------------
6990 -- Favor_Top_Level --
6991 --------------------------
6993 -- pragma Favor_Top_Level (type_NAME);
6995 when Pragma_Favor_Top_Level => Favor_Top_Level : declare
6996 Named_Entity : Entity_Id;
7000 Check_No_Identifiers;
7001 Check_Arg_Count (1);
7002 Check_Arg_Is_Local_Name (Arg1);
7003 Named_Entity := Entity (Expression (Arg1));
7005 -- If it's an access-to-subprogram type (in particular, not a
7006 -- subtype), set the flag on that type.
7008 if Is_Access_Subprogram_Type (Named_Entity) then
7009 Set_Can_Use_Internal_Rep (Named_Entity, False);
7011 -- Otherwise it's an error (name denotes the wrong sort of entity)
7015 ("access-to-subprogram type expected", Expression (Arg1));
7017 end Favor_Top_Level;
7023 -- pragma Fast_Math;
7025 when Pragma_Fast_Math =>
7027 Check_No_Identifiers;
7028 Check_Valid_Configuration_Pragma;
7031 ---------------------------
7032 -- Finalize_Storage_Only --
7033 ---------------------------
7035 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
7037 when Pragma_Finalize_Storage_Only => Finalize_Storage : declare
7038 Assoc : constant Node_Id := Arg1;
7039 Type_Id : constant Node_Id := Expression (Assoc);
7043 Check_No_Identifiers;
7044 Check_Arg_Count (1);
7045 Check_Arg_Is_Local_Name (Arg1);
7047 Find_Type (Type_Id);
7048 Typ := Entity (Type_Id);
7051 or else Rep_Item_Too_Early (Typ, N)
7055 Typ := Underlying_Type (Typ);
7058 if not Is_Controlled (Typ) then
7059 Error_Pragma ("pragma% must specify controlled type");
7062 Check_First_Subtype (Arg1);
7064 if Finalize_Storage_Only (Typ) then
7065 Error_Pragma ("duplicate pragma%, only one allowed");
7067 elsif not Rep_Item_Too_Late (Typ, N) then
7068 Set_Finalize_Storage_Only (Base_Type (Typ), True);
7070 end Finalize_Storage;
7072 --------------------------
7073 -- Float_Representation --
7074 --------------------------
7076 -- pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
7078 -- FLOAT_REP ::= VAX_Float | IEEE_Float
7080 when Pragma_Float_Representation => Float_Representation : declare
7088 if Arg_Count = 1 then
7089 Check_Valid_Configuration_Pragma;
7091 Check_Arg_Count (2);
7092 Check_Optional_Identifier (Arg2, Name_Entity);
7093 Check_Arg_Is_Local_Name (Arg2);
7096 Check_No_Identifier (Arg1);
7097 Check_Arg_Is_One_Of (Arg1, Name_VAX_Float, Name_IEEE_Float);
7099 if not OpenVMS_On_Target then
7100 if Chars (Expression (Arg1)) = Name_VAX_Float then
7102 ("?pragma% ignored (applies only to Open'V'M'S)");
7108 -- One argument case
7110 if Arg_Count = 1 then
7111 if Chars (Expression (Arg1)) = Name_VAX_Float then
7112 if Opt.Float_Format = 'I' then
7113 Error_Pragma ("'I'E'E'E format previously specified");
7116 Opt.Float_Format := 'V';
7119 if Opt.Float_Format = 'V' then
7120 Error_Pragma ("'V'A'X format previously specified");
7123 Opt.Float_Format := 'I';
7126 Set_Standard_Fpt_Formats;
7128 -- Two argument case
7131 Argx := Get_Pragma_Arg (Arg2);
7133 if not Is_Entity_Name (Argx)
7134 or else not Is_Floating_Point_Type (Entity (Argx))
7137 ("second argument of% pragma must be floating-point type",
7141 Ent := Entity (Argx);
7142 Digs := UI_To_Int (Digits_Value (Ent));
7144 -- Two arguments, VAX_Float case
7146 if Chars (Expression (Arg1)) = Name_VAX_Float then
7148 when 6 => Set_F_Float (Ent);
7149 when 9 => Set_D_Float (Ent);
7150 when 15 => Set_G_Float (Ent);
7154 ("wrong digits value, must be 6,9 or 15", Arg2);
7157 -- Two arguments, IEEE_Float case
7161 when 6 => Set_IEEE_Short (Ent);
7162 when 15 => Set_IEEE_Long (Ent);
7166 ("wrong digits value, must be 6 or 15", Arg2);
7170 end Float_Representation;
7176 -- pragma Ident (static_string_EXPRESSION)
7178 -- Note: pragma Comment shares this processing. Pragma Comment
7179 -- is identical to Ident, except that the restriction of the
7180 -- argument to 31 characters and the placement restrictions
7181 -- are not enforced for pragma Comment.
7183 when Pragma_Ident | Pragma_Comment => Ident : declare
7188 Check_Arg_Count (1);
7189 Check_No_Identifiers;
7190 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
7192 -- For pragma Ident, preserve DEC compatibility by requiring
7193 -- the pragma to appear in a declarative part or package spec.
7195 if Prag_Id = Pragma_Ident then
7196 Check_Is_In_Decl_Part_Or_Package_Spec;
7199 Str := Expr_Value_S (Expression (Arg1));
7206 GP := Parent (Parent (N));
7208 if Nkind (GP) = N_Package_Declaration
7210 Nkind (GP) = N_Generic_Package_Declaration
7215 -- If we have a compilation unit, then record the ident
7216 -- value, checking for improper duplication.
7218 if Nkind (GP) = N_Compilation_Unit then
7219 CS := Ident_String (Current_Sem_Unit);
7221 if Present (CS) then
7223 -- For Ident, we do not permit multiple instances
7225 if Prag_Id = Pragma_Ident then
7226 Error_Pragma ("duplicate% pragma not permitted");
7228 -- For Comment, we concatenate the string, unless we
7229 -- want to preserve the tree structure for ASIS.
7231 elsif not ASIS_Mode then
7232 Start_String (Strval (CS));
7233 Store_String_Char (' ');
7234 Store_String_Chars (Strval (Str));
7235 Set_Strval (CS, End_String);
7239 -- In VMS, the effect of IDENT is achieved by passing
7240 -- IDENTIFICATION=name as a --for-linker switch.
7242 if OpenVMS_On_Target then
7245 ("--for-linker=IDENTIFICATION=");
7246 String_To_Name_Buffer (Strval (Str));
7247 Store_String_Chars (Name_Buffer (1 .. Name_Len));
7249 -- Only the last processed IDENT is saved. The main
7250 -- purpose is so an IDENT associated with a main
7251 -- procedure will be used in preference to an IDENT
7252 -- associated with a with'd package.
7254 Replace_Linker_Option_String
7255 (End_String, "--for-linker=IDENTIFICATION=");
7258 Set_Ident_String (Current_Sem_Unit, Str);
7261 -- For subunits, we just ignore the Ident, since in GNAT
7262 -- these are not separate object files, and hence not
7263 -- separate units in the unit table.
7265 elsif Nkind (GP) = N_Subunit then
7268 -- Otherwise we have a misplaced pragma Ident, but we ignore
7269 -- this if we are in an instantiation, since it comes from
7270 -- a generic, and has no relevance to the instantiation.
7272 elsif Prag_Id = Pragma_Ident then
7273 if Instantiation_Location (Loc) = No_Location then
7274 Error_Pragma ("pragma% only allowed at outer level");
7280 --------------------------
7281 -- Implemented_By_Entry --
7282 --------------------------
7284 -- pragma Implemented_By_Entry (DIRECT_NAME);
7286 when Pragma_Implemented_By_Entry => Implemented_By_Entry : declare
7291 Check_Arg_Count (1);
7292 Check_No_Identifiers;
7293 Check_Arg_Is_Identifier (Arg1);
7294 Check_Arg_Is_Local_Name (Arg1);
7295 Ent := Entity (Expression (Arg1));
7297 -- Pragma Implemented_By_Entry must be applied only to protected
7298 -- synchronized or task interface primitives.
7300 if (Ekind (Ent) /= E_Function
7301 and then Ekind (Ent) /= E_Procedure)
7302 or else not Present (First_Formal (Ent))
7303 or else not Is_Concurrent_Interface (Etype (First_Formal (Ent)))
7306 ("pragma % must be applied to a concurrent interface " &
7310 if Einfo.Implemented_By_Entry (Ent)
7311 and then Warn_On_Redundant_Constructs
7313 Error_Pragma ("?duplicate pragma%!");
7315 Set_Implemented_By_Entry (Ent);
7318 end Implemented_By_Entry;
7320 -----------------------
7321 -- Implicit_Packing --
7322 -----------------------
7324 -- pragma Implicit_Packing;
7326 when Pragma_Implicit_Packing =>
7328 Check_Arg_Count (0);
7329 Implicit_Packing := True;
7336 -- [Convention =>] convention_IDENTIFIER,
7337 -- [Entity =>] local_NAME
7338 -- [, [External_Name =>] static_string_EXPRESSION ]
7339 -- [, [Link_Name =>] static_string_EXPRESSION ]);
7341 when Pragma_Import =>
7342 Check_Ada_83_Warning;
7348 Check_At_Least_N_Arguments (2);
7349 Check_At_Most_N_Arguments (4);
7350 Process_Import_Or_Interface;
7352 ----------------------
7353 -- Import_Exception --
7354 ----------------------
7356 -- pragma Import_Exception (
7357 -- [Internal =>] LOCAL_NAME
7358 -- [, [External =>] EXTERNAL_SYMBOL]
7359 -- [, [Form =>] Ada | VMS]
7360 -- [, [Code =>] static_integer_EXPRESSION]);
7362 when Pragma_Import_Exception => Import_Exception : declare
7363 Args : Args_List (1 .. 4);
7364 Names : constant Name_List (1 .. 4) := (
7370 Internal : Node_Id renames Args (1);
7371 External : Node_Id renames Args (2);
7372 Form : Node_Id renames Args (3);
7373 Code : Node_Id renames Args (4);
7376 Gather_Associations (Names, Args);
7378 if Present (External) and then Present (Code) then
7380 ("cannot give both External and Code options for pragma%");
7383 Process_Extended_Import_Export_Exception_Pragma (
7384 Arg_Internal => Internal,
7385 Arg_External => External,
7389 if not Is_VMS_Exception (Entity (Internal)) then
7390 Set_Imported (Entity (Internal));
7392 end Import_Exception;
7394 ---------------------
7395 -- Import_Function --
7396 ---------------------
7398 -- pragma Import_Function (
7399 -- [Internal =>] LOCAL_NAME,
7400 -- [, [External =>] EXTERNAL_SYMBOL]
7401 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7402 -- [, [Result_Type =>] SUBTYPE_MARK]
7403 -- [, [Mechanism =>] MECHANISM]
7404 -- [, [Result_Mechanism =>] MECHANISM_NAME]
7405 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
7407 -- EXTERNAL_SYMBOL ::=
7409 -- | static_string_EXPRESSION
7411 -- PARAMETER_TYPES ::=
7413 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7415 -- TYPE_DESIGNATOR ::=
7417 -- | subtype_Name ' Access
7421 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7423 -- MECHANISM_ASSOCIATION ::=
7424 -- [formal_parameter_NAME =>] MECHANISM_NAME
7426 -- MECHANISM_NAME ::=
7429 -- | Descriptor [([Class =>] CLASS_NAME)]
7431 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7433 when Pragma_Import_Function => Import_Function : declare
7434 Args : Args_List (1 .. 7);
7435 Names : constant Name_List (1 .. 7) := (
7438 Name_Parameter_Types,
7441 Name_Result_Mechanism,
7442 Name_First_Optional_Parameter);
7444 Internal : Node_Id renames Args (1);
7445 External : Node_Id renames Args (2);
7446 Parameter_Types : Node_Id renames Args (3);
7447 Result_Type : Node_Id renames Args (4);
7448 Mechanism : Node_Id renames Args (5);
7449 Result_Mechanism : Node_Id renames Args (6);
7450 First_Optional_Parameter : Node_Id renames Args (7);
7454 Gather_Associations (Names, Args);
7455 Process_Extended_Import_Export_Subprogram_Pragma (
7456 Arg_Internal => Internal,
7457 Arg_External => External,
7458 Arg_Parameter_Types => Parameter_Types,
7459 Arg_Result_Type => Result_Type,
7460 Arg_Mechanism => Mechanism,
7461 Arg_Result_Mechanism => Result_Mechanism,
7462 Arg_First_Optional_Parameter => First_Optional_Parameter);
7463 end Import_Function;
7469 -- pragma Import_Object (
7470 -- [Internal =>] LOCAL_NAME
7471 -- [, [External =>] EXTERNAL_SYMBOL]
7472 -- [, [Size =>] EXTERNAL_SYMBOL]);
7474 -- EXTERNAL_SYMBOL ::=
7476 -- | static_string_EXPRESSION
7478 when Pragma_Import_Object => Import_Object : declare
7479 Args : Args_List (1 .. 3);
7480 Names : constant Name_List (1 .. 3) := (
7485 Internal : Node_Id renames Args (1);
7486 External : Node_Id renames Args (2);
7487 Size : Node_Id renames Args (3);
7491 Gather_Associations (Names, Args);
7492 Process_Extended_Import_Export_Object_Pragma (
7493 Arg_Internal => Internal,
7494 Arg_External => External,
7498 ----------------------
7499 -- Import_Procedure --
7500 ----------------------
7502 -- pragma Import_Procedure (
7503 -- [Internal =>] LOCAL_NAME
7504 -- [, [External =>] EXTERNAL_SYMBOL]
7505 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7506 -- [, [Mechanism =>] MECHANISM]
7507 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
7509 -- EXTERNAL_SYMBOL ::=
7511 -- | static_string_EXPRESSION
7513 -- PARAMETER_TYPES ::=
7515 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7517 -- TYPE_DESIGNATOR ::=
7519 -- | subtype_Name ' Access
7523 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7525 -- MECHANISM_ASSOCIATION ::=
7526 -- [formal_parameter_NAME =>] MECHANISM_NAME
7528 -- MECHANISM_NAME ::=
7531 -- | Descriptor [([Class =>] CLASS_NAME)]
7533 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7535 when Pragma_Import_Procedure => Import_Procedure : declare
7536 Args : Args_List (1 .. 5);
7537 Names : constant Name_List (1 .. 5) := (
7540 Name_Parameter_Types,
7542 Name_First_Optional_Parameter);
7544 Internal : Node_Id renames Args (1);
7545 External : Node_Id renames Args (2);
7546 Parameter_Types : Node_Id renames Args (3);
7547 Mechanism : Node_Id renames Args (4);
7548 First_Optional_Parameter : Node_Id renames Args (5);
7552 Gather_Associations (Names, Args);
7553 Process_Extended_Import_Export_Subprogram_Pragma (
7554 Arg_Internal => Internal,
7555 Arg_External => External,
7556 Arg_Parameter_Types => Parameter_Types,
7557 Arg_Mechanism => Mechanism,
7558 Arg_First_Optional_Parameter => First_Optional_Parameter);
7559 end Import_Procedure;
7561 -----------------------------
7562 -- Import_Valued_Procedure --
7563 -----------------------------
7565 -- pragma Import_Valued_Procedure (
7566 -- [Internal =>] LOCAL_NAME
7567 -- [, [External =>] EXTERNAL_SYMBOL]
7568 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7569 -- [, [Mechanism =>] MECHANISM]
7570 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
7572 -- EXTERNAL_SYMBOL ::=
7574 -- | static_string_EXPRESSION
7576 -- PARAMETER_TYPES ::=
7578 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7580 -- TYPE_DESIGNATOR ::=
7582 -- | subtype_Name ' Access
7586 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7588 -- MECHANISM_ASSOCIATION ::=
7589 -- [formal_parameter_NAME =>] MECHANISM_NAME
7591 -- MECHANISM_NAME ::=
7594 -- | Descriptor [([Class =>] CLASS_NAME)]
7596 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7598 when Pragma_Import_Valued_Procedure =>
7599 Import_Valued_Procedure : declare
7600 Args : Args_List (1 .. 5);
7601 Names : constant Name_List (1 .. 5) := (
7604 Name_Parameter_Types,
7606 Name_First_Optional_Parameter);
7608 Internal : Node_Id renames Args (1);
7609 External : Node_Id renames Args (2);
7610 Parameter_Types : Node_Id renames Args (3);
7611 Mechanism : Node_Id renames Args (4);
7612 First_Optional_Parameter : Node_Id renames Args (5);
7616 Gather_Associations (Names, Args);
7617 Process_Extended_Import_Export_Subprogram_Pragma (
7618 Arg_Internal => Internal,
7619 Arg_External => External,
7620 Arg_Parameter_Types => Parameter_Types,
7621 Arg_Mechanism => Mechanism,
7622 Arg_First_Optional_Parameter => First_Optional_Parameter);
7623 end Import_Valued_Procedure;
7625 ------------------------
7626 -- Initialize_Scalars --
7627 ------------------------
7629 -- pragma Initialize_Scalars;
7631 when Pragma_Initialize_Scalars =>
7633 Check_Arg_Count (0);
7634 Check_Valid_Configuration_Pragma;
7635 Check_Restriction (No_Initialize_Scalars, N);
7637 if not Restriction_Active (No_Initialize_Scalars) then
7638 Init_Or_Norm_Scalars := True;
7639 Initialize_Scalars := True;
7646 -- pragma Inline ( NAME {, NAME} );
7648 when Pragma_Inline =>
7650 -- Pragma is active if inlining option is active
7652 Process_Inline (Inline_Active);
7658 -- pragma Inline_Always ( NAME {, NAME} );
7660 when Pragma_Inline_Always =>
7661 Process_Inline (True);
7663 --------------------
7664 -- Inline_Generic --
7665 --------------------
7667 -- pragma Inline_Generic (NAME {, NAME});
7669 when Pragma_Inline_Generic =>
7670 Process_Generic_List;
7672 ----------------------
7673 -- Inspection_Point --
7674 ----------------------
7676 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
7678 when Pragma_Inspection_Point => Inspection_Point : declare
7683 if Arg_Count > 0 then
7686 Exp := Expression (Arg);
7689 if not Is_Entity_Name (Exp)
7690 or else not Is_Object (Entity (Exp))
7692 Error_Pragma_Arg ("object name required", Arg);
7699 end Inspection_Point;
7705 -- pragma Interface (
7706 -- [ Convention =>] convention_IDENTIFIER,
7707 -- [ Entity =>] local_NAME
7708 -- [, [External_Name =>] static_string_EXPRESSION ]
7709 -- [, [Link_Name =>] static_string_EXPRESSION ]);
7711 when Pragma_Interface =>
7718 Check_At_Least_N_Arguments (2);
7719 Check_At_Most_N_Arguments (4);
7720 Process_Import_Or_Interface;
7722 --------------------
7723 -- Interface_Name --
7724 --------------------
7726 -- pragma Interface_Name (
7727 -- [ Entity =>] local_NAME
7728 -- [,[External_Name =>] static_string_EXPRESSION ]
7729 -- [,[Link_Name =>] static_string_EXPRESSION ]);
7731 when Pragma_Interface_Name => Interface_Name : declare
7740 ((Name_Entity, Name_External_Name, Name_Link_Name));
7741 Check_At_Least_N_Arguments (2);
7742 Check_At_Most_N_Arguments (3);
7743 Id := Expression (Arg1);
7746 if not Is_Entity_Name (Id) then
7748 ("first argument for pragma% must be entity name", Arg1);
7749 elsif Etype (Id) = Any_Type then
7752 Def_Id := Entity (Id);
7755 -- Special DEC-compatible processing for the object case, forces
7756 -- object to be imported.
7758 if Ekind (Def_Id) = E_Variable then
7759 Kill_Size_Check_Code (Def_Id);
7760 Note_Possible_Modification (Id, Sure => False);
7762 -- Initialization is not allowed for imported variable
7764 if Present (Expression (Parent (Def_Id)))
7765 and then Comes_From_Source (Expression (Parent (Def_Id)))
7767 Error_Msg_Sloc := Sloc (Def_Id);
7769 ("no initialization allowed for declaration of& #",
7773 -- For compatibility, support VADS usage of providing both
7774 -- pragmas Interface and Interface_Name to obtain the effect
7775 -- of a single Import pragma.
7777 if Is_Imported (Def_Id)
7778 and then Present (First_Rep_Item (Def_Id))
7779 and then Nkind (First_Rep_Item (Def_Id)) = N_Pragma
7781 Pragma_Name (First_Rep_Item (Def_Id)) = Name_Interface
7785 Set_Imported (Def_Id);
7788 Set_Is_Public (Def_Id);
7789 Process_Interface_Name (Def_Id, Arg2, Arg3);
7792 -- Otherwise must be subprogram
7794 elsif not Is_Subprogram (Def_Id) then
7796 ("argument of pragma% is not subprogram", Arg1);
7799 Check_At_Most_N_Arguments (3);
7803 -- Loop through homonyms
7806 Def_Id := Get_Base_Subprogram (Hom_Id);
7808 if Is_Imported (Def_Id) then
7809 Process_Interface_Name (Def_Id, Arg2, Arg3);
7813 Hom_Id := Homonym (Hom_Id);
7815 exit when No (Hom_Id)
7816 or else Scope (Hom_Id) /= Current_Scope;
7821 ("argument of pragma% is not imported subprogram",
7827 -----------------------
7828 -- Interrupt_Handler --
7829 -----------------------
7831 -- pragma Interrupt_Handler (handler_NAME);
7833 when Pragma_Interrupt_Handler =>
7834 Check_Ada_83_Warning;
7835 Check_Arg_Count (1);
7836 Check_No_Identifiers;
7838 if No_Run_Time_Mode then
7839 Error_Msg_CRT ("Interrupt_Handler pragma", N);
7841 Check_Interrupt_Or_Attach_Handler;
7842 Process_Interrupt_Or_Attach_Handler;
7845 ------------------------
7846 -- Interrupt_Priority --
7847 ------------------------
7849 -- pragma Interrupt_Priority [(EXPRESSION)];
7851 when Pragma_Interrupt_Priority => Interrupt_Priority : declare
7852 P : constant Node_Id := Parent (N);
7856 Check_Ada_83_Warning;
7858 if Arg_Count /= 0 then
7859 Arg := Expression (Arg1);
7860 Check_Arg_Count (1);
7861 Check_No_Identifiers;
7863 -- The expression must be analyzed in the special manner
7864 -- described in "Handling of Default and Per-Object
7865 -- Expressions" in sem.ads.
7867 Preanalyze_Spec_Expression (Arg, RTE (RE_Interrupt_Priority));
7870 if Nkind (P) /= N_Task_Definition
7871 and then Nkind (P) /= N_Protected_Definition
7876 elsif Has_Priority_Pragma (P) then
7877 Error_Pragma ("duplicate pragma% not allowed");
7880 Set_Has_Priority_Pragma (P, True);
7881 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
7883 end Interrupt_Priority;
7885 ---------------------
7886 -- Interrupt_State --
7887 ---------------------
7889 -- pragma Interrupt_State (
7890 -- [Name =>] INTERRUPT_ID,
7891 -- [State =>] INTERRUPT_STATE);
7893 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
7894 -- INTERRUPT_STATE => System | Runtime | User
7896 -- Note: if the interrupt id is given as an identifier, then
7897 -- it must be one of the identifiers in Ada.Interrupts.Names.
7898 -- Otherwise it is given as a static integer expression which
7899 -- must be in the range of Ada.Interrupts.Interrupt_ID.
7901 when Pragma_Interrupt_State => Interrupt_State : declare
7903 Int_Id : constant Entity_Id := RTE (RE_Interrupt_ID);
7904 -- This is the entity Ada.Interrupts.Interrupt_ID;
7906 State_Type : Character;
7907 -- Set to 's'/'r'/'u' for System/Runtime/User
7910 -- Index to entry in Interrupt_States table
7913 -- Value of interrupt
7915 Arg1X : constant Node_Id := Get_Pragma_Arg (Arg1);
7916 -- The first argument to the pragma
7918 Int_Ent : Entity_Id;
7919 -- Interrupt entity in Ada.Interrupts.Names
7923 Check_Arg_Order ((Name_Name, Name_State));
7924 Check_Arg_Count (2);
7926 Check_Optional_Identifier (Arg1, Name_Name);
7927 Check_Optional_Identifier (Arg2, Name_State);
7928 Check_Arg_Is_Identifier (Arg2);
7930 -- First argument is identifier
7932 if Nkind (Arg1X) = N_Identifier then
7934 -- Search list of names in Ada.Interrupts.Names
7936 Int_Ent := First_Entity (RTE (RE_Names));
7938 if No (Int_Ent) then
7939 Error_Pragma_Arg ("invalid interrupt name", Arg1);
7941 elsif Chars (Int_Ent) = Chars (Arg1X) then
7942 Int_Val := Expr_Value (Constant_Value (Int_Ent));
7946 Next_Entity (Int_Ent);
7949 -- First argument is not an identifier, so it must be a
7950 -- static expression of type Ada.Interrupts.Interrupt_ID.
7953 Check_Arg_Is_Static_Expression (Arg1, Any_Integer);
7954 Int_Val := Expr_Value (Arg1X);
7956 if Int_Val < Expr_Value (Type_Low_Bound (Int_Id))
7958 Int_Val > Expr_Value (Type_High_Bound (Int_Id))
7961 ("value not in range of type " &
7962 """Ada.Interrupts.Interrupt_'I'D""", Arg1);
7968 case Chars (Get_Pragma_Arg (Arg2)) is
7969 when Name_Runtime => State_Type := 'r';
7970 when Name_System => State_Type := 's';
7971 when Name_User => State_Type := 'u';
7974 Error_Pragma_Arg ("invalid interrupt state", Arg2);
7977 -- Check if entry is already stored
7979 IST_Num := Interrupt_States.First;
7981 -- If entry not found, add it
7983 if IST_Num > Interrupt_States.Last then
7984 Interrupt_States.Append
7985 ((Interrupt_Number => UI_To_Int (Int_Val),
7986 Interrupt_State => State_Type,
7987 Pragma_Loc => Loc));
7990 -- Case of entry for the same entry
7992 elsif Int_Val = Interrupt_States.Table (IST_Num).
7995 -- If state matches, done, no need to make redundant entry
7998 State_Type = Interrupt_States.Table (IST_Num).
8001 -- Otherwise if state does not match, error
8004 Interrupt_States.Table (IST_Num).Pragma_Loc;
8006 ("state conflicts with that given #", Arg2);
8010 IST_Num := IST_Num + 1;
8012 end Interrupt_State;
8014 ----------------------
8015 -- Java_Constructor --
8016 ----------------------
8018 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
8020 -- Also handles pragma CIL_Constructor
8022 when Pragma_CIL_Constructor | Pragma_Java_Constructor =>
8023 Java_Constructor : declare
8027 Convention : Convention_Id;
8031 Check_Arg_Count (1);
8032 Check_Optional_Identifier (Arg1, Name_Entity);
8033 Check_Arg_Is_Local_Name (Arg1);
8035 Id := Expression (Arg1);
8036 Find_Program_Unit_Name (Id);
8038 -- If we did not find the name, we are done
8040 if Etype (Id) = Any_Type then
8045 when Pragma_CIL_Constructor => Convention := Convention_CIL;
8046 when Pragma_Java_Constructor => Convention := Convention_Java;
8047 when others => null;
8050 Hom_Id := Entity (Id);
8052 -- Loop through homonyms
8055 Def_Id := Get_Base_Subprogram (Hom_Id);
8057 -- The constructor is required to be a function returning an
8058 -- access type whose designated type has convention Java/CIL.
8060 if Ekind (Def_Id) = E_Function
8062 (Is_Value_Type (Etype (Def_Id))
8064 (Ekind (Etype (Def_Id)) in Access_Kind
8067 (Designated_Type (Etype (Def_Id))) = Convention
8070 (Root_Type (Designated_Type (Etype (Def_Id)))) =
8073 Set_Is_Constructor (Def_Id);
8074 Set_Convention (Def_Id, Convention);
8075 Set_Is_Imported (Def_Id);
8078 if Convention = Convention_Java then
8080 ("pragma% requires function returning a " &
8081 "'Java access type", Arg1);
8083 pragma Assert (Convention = Convention_CIL);
8085 ("pragma% requires function returning a " &
8086 "'CIL access type", Arg1);
8090 Hom_Id := Homonym (Hom_Id);
8092 exit when No (Hom_Id) or else Scope (Hom_Id) /= Current_Scope;
8094 end Java_Constructor;
8096 ----------------------
8097 -- Java_Interface --
8098 ----------------------
8100 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
8102 when Pragma_Java_Interface => Java_Interface : declare
8108 Check_Arg_Count (1);
8109 Check_Optional_Identifier (Arg1, Name_Entity);
8110 Check_Arg_Is_Local_Name (Arg1);
8112 Arg := Expression (Arg1);
8115 if Etype (Arg) = Any_Type then
8119 if not Is_Entity_Name (Arg)
8120 or else not Is_Type (Entity (Arg))
8122 Error_Pragma_Arg ("pragma% requires a type mark", Arg1);
8125 Typ := Underlying_Type (Entity (Arg));
8127 -- For now we simply check some of the semantic constraints
8128 -- on the type. This currently leaves out some restrictions
8129 -- on interface types, namely that the parent type must be
8130 -- java.lang.Object.Typ and that all primitives of the type
8131 -- should be declared abstract. ???
8133 if not Is_Tagged_Type (Typ) or else not Is_Abstract_Type (Typ) then
8134 Error_Pragma_Arg ("pragma% requires an abstract "
8135 & "tagged type", Arg1);
8137 elsif not Has_Discriminants (Typ)
8138 or else Ekind (Etype (First_Discriminant (Typ)))
8139 /= E_Anonymous_Access_Type
8141 not Is_Class_Wide_Type
8142 (Designated_Type (Etype (First_Discriminant (Typ))))
8145 ("type must have a class-wide access discriminant", Arg1);
8153 -- pragma Keep_Names ([On => ] local_NAME);
8155 when Pragma_Keep_Names => Keep_Names : declare
8160 Check_Arg_Count (1);
8161 Check_Optional_Identifier (Arg1, Name_On);
8162 Check_Arg_Is_Local_Name (Arg1);
8164 Arg := Expression (Arg1);
8167 if Etype (Arg) = Any_Type then
8171 if not Is_Entity_Name (Arg)
8172 or else Ekind (Entity (Arg)) /= E_Enumeration_Type
8175 ("pragma% requires a local enumeration type", Arg1);
8178 Set_Discard_Names (Entity (Arg), False);
8185 -- pragma License (RESTRICTED | UNRESTRICTED | GPL | MODIFIED_GPL);
8187 when Pragma_License =>
8189 Check_Arg_Count (1);
8190 Check_No_Identifiers;
8191 Check_Valid_Configuration_Pragma;
8192 Check_Arg_Is_Identifier (Arg1);
8195 Sind : constant Source_File_Index :=
8196 Source_Index (Current_Sem_Unit);
8199 case Chars (Get_Pragma_Arg (Arg1)) is
8201 Set_License (Sind, GPL);
8203 when Name_Modified_GPL =>
8204 Set_License (Sind, Modified_GPL);
8206 when Name_Restricted =>
8207 Set_License (Sind, Restricted);
8209 when Name_Unrestricted =>
8210 Set_License (Sind, Unrestricted);
8213 Error_Pragma_Arg ("invalid license name", Arg1);
8221 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
8223 when Pragma_Link_With => Link_With : declare
8229 if Operating_Mode = Generate_Code
8230 and then In_Extended_Main_Source_Unit (N)
8232 Check_At_Least_N_Arguments (1);
8233 Check_No_Identifiers;
8234 Check_Is_In_Decl_Part_Or_Package_Spec;
8235 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
8239 while Present (Arg) loop
8240 Check_Arg_Is_Static_Expression (Arg, Standard_String);
8242 -- Store argument, converting sequences of spaces
8243 -- to a single null character (this is one of the
8244 -- differences in processing between Link_With
8245 -- and Linker_Options).
8248 C : constant Char_Code := Get_Char_Code (' ');
8249 S : constant String_Id :=
8250 Strval (Expr_Value_S (Expression (Arg)));
8251 L : constant Nat := String_Length (S);
8254 procedure Skip_Spaces;
8255 -- Advance F past any spaces
8261 procedure Skip_Spaces is
8263 while F <= L and then Get_String_Char (S, F) = C loop
8268 -- Start of processing for Arg_Store
8271 Skip_Spaces; -- skip leading spaces
8273 -- Loop through characters, changing any embedded
8274 -- sequence of spaces to a single null character
8275 -- (this is how Link_With/Linker_Options differ)
8278 if Get_String_Char (S, F) = C then
8281 Store_String_Char (ASCII.NUL);
8284 Store_String_Char (Get_String_Char (S, F));
8292 if Present (Arg) then
8293 Store_String_Char (ASCII.NUL);
8297 Store_Linker_Option_String (End_String);
8305 -- pragma Linker_Alias (
8306 -- [Entity =>] LOCAL_NAME
8307 -- [Target =>] static_string_EXPRESSION);
8309 when Pragma_Linker_Alias =>
8311 Check_Arg_Order ((Name_Entity, Name_Target));
8312 Check_Arg_Count (2);
8313 Check_Optional_Identifier (Arg1, Name_Entity);
8314 Check_Optional_Identifier (Arg2, Name_Target);
8315 Check_Arg_Is_Library_Level_Local_Name (Arg1);
8316 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
8318 -- The only processing required is to link this item on to the
8319 -- list of rep items for the given entity. This is accomplished
8320 -- by the call to Rep_Item_Too_Late (when no error is detected
8321 -- and False is returned).
8323 if Rep_Item_Too_Late (Entity (Expression (Arg1)), N) then
8326 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
8329 ------------------------
8330 -- Linker_Constructor --
8331 ------------------------
8333 -- pragma Linker_Constructor (procedure_LOCAL_NAME);
8335 -- Code is shared with Linker_Destructor
8337 -----------------------
8338 -- Linker_Destructor --
8339 -----------------------
8341 -- pragma Linker_Destructor (procedure_LOCAL_NAME);
8343 when Pragma_Linker_Constructor |
8344 Pragma_Linker_Destructor =>
8345 Linker_Constructor : declare
8351 Check_Arg_Count (1);
8352 Check_No_Identifiers;
8353 Check_Arg_Is_Local_Name (Arg1);
8354 Arg1_X := Expression (Arg1);
8356 Proc := Find_Unique_Parameterless_Procedure (Arg1_X, Arg1);
8358 if not Is_Library_Level_Entity (Proc) then
8360 ("argument for pragma% must be library level entity", Arg1);
8363 -- The only processing required is to link this item on to the
8364 -- list of rep items for the given entity. This is accomplished
8365 -- by the call to Rep_Item_Too_Late (when no error is detected
8366 -- and False is returned).
8368 if Rep_Item_Too_Late (Proc, N) then
8371 Set_Has_Gigi_Rep_Item (Proc);
8373 end Linker_Constructor;
8375 --------------------
8376 -- Linker_Options --
8377 --------------------
8379 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
8381 when Pragma_Linker_Options => Linker_Options : declare
8385 Check_Ada_83_Warning;
8386 Check_No_Identifiers;
8387 Check_Arg_Count (1);
8388 Check_Is_In_Decl_Part_Or_Package_Spec;
8389 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
8390 Start_String (Strval (Expr_Value_S (Expression (Arg1))));
8393 while Present (Arg) loop
8394 Check_Arg_Is_Static_Expression (Arg, Standard_String);
8395 Store_String_Char (ASCII.NUL);
8396 Store_String_Chars (Strval (Expr_Value_S (Expression (Arg))));
8400 if Operating_Mode = Generate_Code
8401 and then In_Extended_Main_Source_Unit (N)
8403 Store_Linker_Option_String (End_String);
8407 --------------------
8408 -- Linker_Section --
8409 --------------------
8411 -- pragma Linker_Section (
8412 -- [Entity =>] LOCAL_NAME
8413 -- [Section =>] static_string_EXPRESSION);
8415 when Pragma_Linker_Section =>
8417 Check_Arg_Order ((Name_Entity, Name_Section));
8418 Check_Arg_Count (2);
8419 Check_Optional_Identifier (Arg1, Name_Entity);
8420 Check_Optional_Identifier (Arg2, Name_Section);
8421 Check_Arg_Is_Library_Level_Local_Name (Arg1);
8422 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
8424 -- The only processing required is to link this item on to the
8425 -- list of rep items for the given entity. This is accomplished
8426 -- by the call to Rep_Item_Too_Late (when no error is detected
8427 -- and False is returned).
8429 if Rep_Item_Too_Late (Entity (Expression (Arg1)), N) then
8432 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
8439 -- pragma List (On | Off)
8441 -- There is nothing to do here, since we did all the processing
8442 -- for this pragma in Par.Prag (so that it works properly even in
8443 -- syntax only mode)
8448 --------------------
8449 -- Locking_Policy --
8450 --------------------
8452 -- pragma Locking_Policy (policy_IDENTIFIER);
8454 when Pragma_Locking_Policy => declare
8458 Check_Ada_83_Warning;
8459 Check_Arg_Count (1);
8460 Check_No_Identifiers;
8461 Check_Arg_Is_Locking_Policy (Arg1);
8462 Check_Valid_Configuration_Pragma;
8463 Get_Name_String (Chars (Expression (Arg1)));
8464 LP := Fold_Upper (Name_Buffer (1));
8466 if Locking_Policy /= ' '
8467 and then Locking_Policy /= LP
8469 Error_Msg_Sloc := Locking_Policy_Sloc;
8470 Error_Pragma ("locking policy incompatible with policy#");
8472 -- Set new policy, but always preserve System_Location since
8473 -- we like the error message with the run time name.
8476 Locking_Policy := LP;
8478 if Locking_Policy_Sloc /= System_Location then
8479 Locking_Policy_Sloc := Loc;
8488 -- pragma Long_Float (D_Float | G_Float);
8490 when Pragma_Long_Float =>
8492 Check_Valid_Configuration_Pragma;
8493 Check_Arg_Count (1);
8494 Check_No_Identifier (Arg1);
8495 Check_Arg_Is_One_Of (Arg1, Name_D_Float, Name_G_Float);
8497 if not OpenVMS_On_Target then
8498 Error_Pragma ("?pragma% ignored (applies only to Open'V'M'S)");
8503 if Chars (Expression (Arg1)) = Name_D_Float then
8504 if Opt.Float_Format_Long = 'G' then
8505 Error_Pragma ("G_Float previously specified");
8508 Opt.Float_Format_Long := 'D';
8510 -- G_Float case (this is the default, does not need overriding)
8513 if Opt.Float_Format_Long = 'D' then
8514 Error_Pragma ("D_Float previously specified");
8517 Opt.Float_Format_Long := 'G';
8520 Set_Standard_Fpt_Formats;
8522 -----------------------
8523 -- Machine_Attribute --
8524 -----------------------
8526 -- pragma Machine_Attribute (
8527 -- [Entity =>] LOCAL_NAME,
8528 -- [Attribute_Name =>] static_string_EXPRESSION
8529 -- [, [Info =>] static_string_EXPRESSION] );
8531 when Pragma_Machine_Attribute => Machine_Attribute : declare
8536 Check_Arg_Order ((Name_Entity, Name_Attribute_Name, Name_Info));
8538 if Arg_Count = 3 then
8539 Check_Optional_Identifier (Arg3, Name_Info);
8540 Check_Arg_Is_Static_Expression (Arg3, Standard_String);
8542 Check_Arg_Count (2);
8545 Check_Optional_Identifier (Arg1, Name_Entity);
8546 Check_Optional_Identifier (Arg2, Name_Attribute_Name);
8547 Check_Arg_Is_Local_Name (Arg1);
8548 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
8549 Def_Id := Entity (Expression (Arg1));
8551 if Is_Access_Type (Def_Id) then
8552 Def_Id := Designated_Type (Def_Id);
8555 if Rep_Item_Too_Early (Def_Id, N) then
8559 Def_Id := Underlying_Type (Def_Id);
8561 -- The only processing required is to link this item on to the
8562 -- list of rep items for the given entity. This is accomplished
8563 -- by the call to Rep_Item_Too_Late (when no error is detected
8564 -- and False is returned).
8566 if Rep_Item_Too_Late (Def_Id, N) then
8569 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
8571 end Machine_Attribute;
8578 -- (MAIN_OPTION [, MAIN_OPTION]);
8581 -- [STACK_SIZE =>] static_integer_EXPRESSION
8582 -- | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
8583 -- | [TIME_SLICING_ENABLED =>] static_boolean_EXPRESSION
8585 when Pragma_Main => Main : declare
8586 Args : Args_List (1 .. 3);
8587 Names : constant Name_List (1 .. 3) := (
8589 Name_Task_Stack_Size_Default,
8590 Name_Time_Slicing_Enabled);
8596 Gather_Associations (Names, Args);
8598 for J in 1 .. 2 loop
8599 if Present (Args (J)) then
8600 Check_Arg_Is_Static_Expression (Args (J), Any_Integer);
8604 if Present (Args (3)) then
8605 Check_Arg_Is_Static_Expression (Args (3), Standard_Boolean);
8609 while Present (Nod) loop
8610 if Nkind (Nod) = N_Pragma
8611 and then Pragma_Name (Nod) = Name_Main
8613 Error_Msg_Name_1 := Pname;
8614 Error_Msg_N ("duplicate pragma% not permitted", Nod);
8625 -- pragma Main_Storage
8626 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
8628 -- MAIN_STORAGE_OPTION ::=
8629 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
8630 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
8632 when Pragma_Main_Storage => Main_Storage : declare
8633 Args : Args_List (1 .. 2);
8634 Names : constant Name_List (1 .. 2) := (
8635 Name_Working_Storage,
8642 Gather_Associations (Names, Args);
8644 for J in 1 .. 2 loop
8645 if Present (Args (J)) then
8646 Check_Arg_Is_Static_Expression (Args (J), Any_Integer);
8650 Check_In_Main_Program;
8653 while Present (Nod) loop
8654 if Nkind (Nod) = N_Pragma
8655 and then Pragma_Name (Nod) = Name_Main_Storage
8657 Error_Msg_Name_1 := Pname;
8658 Error_Msg_N ("duplicate pragma% not permitted", Nod);
8669 -- pragma Memory_Size (NUMERIC_LITERAL)
8671 when Pragma_Memory_Size =>
8674 -- Memory size is simply ignored
8676 Check_No_Identifiers;
8677 Check_Arg_Count (1);
8678 Check_Arg_Is_Integer_Literal (Arg1);
8686 -- The only correct use of this pragma is on its own in a file, in
8687 -- which case it is specially processed (see Gnat1drv.Check_Bad_Body
8688 -- and Frontend, which use Sinput.L.Source_File_Is_Pragma_No_Body to
8689 -- check for a file containing nothing but a No_Body pragma). If we
8690 -- attempt to process it during normal semantics processing, it means
8691 -- it was misplaced.
8693 when Pragma_No_Body =>
8700 -- pragma No_Return (procedure_LOCAL_NAME {, procedure_Local_Name});
8702 when Pragma_No_Return => No_Return : declare
8710 Check_At_Least_N_Arguments (1);
8712 -- Loop through arguments of pragma
8715 while Present (Arg) loop
8716 Check_Arg_Is_Local_Name (Arg);
8717 Id := Expression (Arg);
8720 if not Is_Entity_Name (Id) then
8721 Error_Pragma_Arg ("entity name required", Arg);
8724 if Etype (Id) = Any_Type then
8728 -- Loop to find matching procedures
8733 and then Scope (E) = Current_Scope
8735 if Ekind (E) = E_Procedure
8736 or else Ekind (E) = E_Generic_Procedure
8740 -- Set flag on any alias as well
8742 if Is_Overloadable (E) and then Present (Alias (E)) then
8743 Set_No_Return (Alias (E));
8753 Error_Pragma_Arg ("no procedure & found for pragma%", Arg);
8760 ------------------------
8761 -- No_Strict_Aliasing --
8762 ------------------------
8764 -- pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
8766 when Pragma_No_Strict_Aliasing => No_Strict_Alias : declare
8771 Check_At_Most_N_Arguments (1);
8773 if Arg_Count = 0 then
8774 Check_Valid_Configuration_Pragma;
8775 Opt.No_Strict_Aliasing := True;
8778 Check_Optional_Identifier (Arg2, Name_Entity);
8779 Check_Arg_Is_Local_Name (Arg1);
8780 E_Id := Entity (Expression (Arg1));
8782 if E_Id = Any_Type then
8784 elsif No (E_Id) or else not Is_Access_Type (E_Id) then
8785 Error_Pragma_Arg ("pragma% requires access type", Arg1);
8788 Set_No_Strict_Aliasing (Implementation_Base_Type (E_Id));
8790 end No_Strict_Alias;
8796 -- pragma Obsolescent [(
8797 -- [Entity => NAME,]
8798 -- [(static_string_EXPRESSION [, Ada_05])];
8800 when Pragma_Obsolescent => Obsolescent : declare
8804 procedure Set_Obsolescent (E : Entity_Id);
8805 -- Given an entity Ent, mark it as obsolescent if appropriate
8807 ---------------------
8808 -- Set_Obsolescent --
8809 ---------------------
8811 procedure Set_Obsolescent (E : Entity_Id) is
8820 -- Entity name was given
8822 if Present (Ename) then
8824 -- If entity name matches, we are fine
8826 if Chars (Ename) = Chars (Ent) then
8829 -- If entity name does not match, only possibility is an
8830 -- enumeration literal from an enumeration type declaration.
8832 elsif Ekind (Ent) /= E_Enumeration_Type then
8834 ("pragma % entity name does not match declaration");
8837 Ent := First_Literal (E);
8841 ("pragma % entity name does not match any " &
8842 "enumeration literal");
8844 elsif Chars (Ent) = Chars (Ename) then
8848 Ent := Next_Literal (Ent);
8854 -- Ent points to entity to be marked
8856 if Arg_Count >= 1 then
8858 -- Deal with static string argument
8860 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
8861 S := Strval (Expression (Arg1));
8863 for J in 1 .. String_Length (S) loop
8864 if not In_Character_Range (Get_String_Char (S, J)) then
8866 ("pragma% argument does not allow wide characters",
8871 Obsolescent_Warnings.Append
8872 ((Ent => Ent, Msg => Strval (Expression (Arg1))));
8874 -- Check for Ada_05 parameter
8876 if Arg_Count /= 1 then
8877 Check_Arg_Count (2);
8880 Argx : constant Node_Id := Get_Pragma_Arg (Arg2);
8883 Check_Arg_Is_Identifier (Argx);
8885 if Chars (Argx) /= Name_Ada_05 then
8886 Error_Msg_Name_2 := Name_Ada_05;
8888 ("only allowed argument for pragma% is %", Argx);
8891 if Ada_Version_Explicit < Ada_05
8892 or else not Warn_On_Ada_2005_Compatibility
8900 -- Set flag if pragma active
8903 Set_Is_Obsolescent (Ent);
8907 end Set_Obsolescent;
8909 -- Start of processing for pragma Obsolescent
8914 Check_At_Most_N_Arguments (3);
8916 -- See if first argument specifies an entity name
8919 and then Chars (Arg1) = Name_Entity
8921 Ename := Get_Pragma_Arg (Arg1);
8923 if Nkind (Ename) /= N_Character_Literal
8925 Nkind (Ename) /= N_Identifier
8927 Nkind (Ename) /= N_Operator_Symbol
8929 Error_Pragma_Arg ("entity name expected for pragma%", Arg1);
8932 -- Eliminate first argument, so we can share processing
8936 Arg_Count := Arg_Count - 1;
8938 -- No Entity name argument given
8944 Check_No_Identifiers;
8946 -- Get immediately preceding declaration
8949 while Present (Decl) and then Nkind (Decl) = N_Pragma loop
8953 -- Cases where we do not follow anything other than another pragma
8957 -- First case: library level compilation unit declaration with
8958 -- the pragma immediately following the declaration.
8960 if Nkind (Parent (N)) = N_Compilation_Unit_Aux then
8962 (Defining_Entity (Unit (Parent (Parent (N)))));
8965 -- Case 2: library unit placement for package
8969 Ent : constant Entity_Id := Find_Lib_Unit_Name;
8971 if Ekind (Ent) = E_Package
8972 or else Ekind (Ent) = E_Generic_Package
8974 Set_Obsolescent (Ent);
8980 -- Cases where we must follow a declaration
8983 if Nkind (Decl) not in N_Declaration
8984 and then Nkind (Decl) not in N_Later_Decl_Item
8985 and then Nkind (Decl) not in N_Generic_Declaration
8988 ("pragma% misplaced, " &
8989 "must immediately follow a declaration");
8992 Set_Obsolescent (Defining_Entity (Decl));
9002 -- pragma No_Run_Time
9004 -- Note: this pragma is retained for backwards compatibility.
9005 -- See body of Rtsfind for full details on its handling.
9007 when Pragma_No_Run_Time =>
9009 Check_Valid_Configuration_Pragma;
9010 Check_Arg_Count (0);
9012 No_Run_Time_Mode := True;
9013 Configurable_Run_Time_Mode := True;
9015 -- Set Duration to 32 bits if word size is 32
9017 if Ttypes.System_Word_Size = 32 then
9018 Duration_32_Bits_On_Target := True;
9021 -- Set appropriate restrictions
9023 Set_Restriction (No_Finalization, N);
9024 Set_Restriction (No_Exception_Handlers, N);
9025 Set_Restriction (Max_Tasks, N, 0);
9026 Set_Restriction (No_Tasking, N);
9028 -----------------------
9029 -- Normalize_Scalars --
9030 -----------------------
9032 -- pragma Normalize_Scalars;
9034 when Pragma_Normalize_Scalars =>
9035 Check_Ada_83_Warning;
9036 Check_Arg_Count (0);
9037 Check_Valid_Configuration_Pragma;
9038 Normalize_Scalars := True;
9039 Init_Or_Norm_Scalars := True;
9045 -- pragma Optimize (Time | Space | Off);
9047 -- The actual check for optimize is done in Gigi. Note that this
9048 -- pragma does not actually change the optimization setting, it
9049 -- simply checks that it is consistent with the pragma.
9051 when Pragma_Optimize =>
9052 Check_No_Identifiers;
9053 Check_Arg_Count (1);
9054 Check_Arg_Is_One_Of (Arg1, Name_Time, Name_Space, Name_Off);
9056 ------------------------
9057 -- Optimize_Alignment --
9058 ------------------------
9060 -- pragma Optimize_Alignment (Time | Space | Off);
9062 when Pragma_Optimize_Alignment =>
9064 Check_No_Identifiers;
9065 Check_Arg_Count (1);
9066 Check_Valid_Configuration_Pragma;
9069 Nam : constant Name_Id := Chars (Get_Pragma_Arg (Arg1));
9073 Opt.Optimize_Alignment := 'T';
9075 Opt.Optimize_Alignment := 'S';
9077 Opt.Optimize_Alignment := 'O';
9079 Error_Pragma_Arg ("invalid argument for pragma%", Arg1);
9083 -- Set indication that mode is set locally. If we are in fact in a
9084 -- configuration pragma file, this setting is harmless since the
9085 -- switch will get reset anyway at the start of each unit.
9087 Optimize_Alignment_Local := True;
9093 -- pragma Pack (first_subtype_LOCAL_NAME);
9095 when Pragma_Pack => Pack : declare
9096 Assoc : constant Node_Id := Arg1;
9101 Check_No_Identifiers;
9102 Check_Arg_Count (1);
9103 Check_Arg_Is_Local_Name (Arg1);
9105 Type_Id := Expression (Assoc);
9106 Find_Type (Type_Id);
9107 Typ := Entity (Type_Id);
9110 or else Rep_Item_Too_Early (Typ, N)
9114 Typ := Underlying_Type (Typ);
9117 if not Is_Array_Type (Typ) and then not Is_Record_Type (Typ) then
9118 Error_Pragma ("pragma% must specify array or record type");
9121 Check_First_Subtype (Arg1);
9123 if Has_Pragma_Pack (Typ) then
9124 Error_Pragma ("duplicate pragma%, only one allowed");
9128 elsif Is_Array_Type (Typ) then
9130 -- Pack not allowed for aliased or atomic components
9132 if Has_Aliased_Components (Base_Type (Typ)) then
9134 ("pragma% ignored, cannot pack aliased components?");
9136 elsif Has_Atomic_Components (Typ)
9137 or else Is_Atomic (Component_Type (Typ))
9140 ("?pragma% ignored, cannot pack atomic components");
9143 -- If we had an explicit component size given, then we do not
9144 -- let Pack override this given size. We also give a warning
9145 -- that Pack is being ignored unless we can tell for sure that
9146 -- the Pack would not have had any effect anyway.
9148 if Has_Component_Size_Clause (Typ) then
9149 if Known_Static_RM_Size (Component_Type (Typ))
9151 RM_Size (Component_Type (Typ)) = Component_Size (Typ)
9156 ("?pragma% ignored, explicit component size given");
9159 -- If no prior array component size given, Pack is effective
9162 if not Rep_Item_Too_Late (Typ, N) then
9163 if VM_Target = No_VM then
9164 Set_Is_Packed (Base_Type (Typ));
9165 elsif not GNAT_Mode then
9167 ("?pragma% ignored in this configuration");
9170 Set_Has_Pragma_Pack (Base_Type (Typ));
9171 Set_Has_Non_Standard_Rep (Base_Type (Typ));
9175 -- For record types, the pack is always effective
9177 else pragma Assert (Is_Record_Type (Typ));
9178 if not Rep_Item_Too_Late (Typ, N) then
9179 if VM_Target = No_VM then
9180 Set_Is_Packed (Base_Type (Typ));
9181 elsif not GNAT_Mode then
9182 Error_Pragma ("?pragma% ignored in this configuration");
9185 Set_Has_Pragma_Pack (Base_Type (Typ));
9186 Set_Has_Non_Standard_Rep (Base_Type (Typ));
9197 -- There is nothing to do here, since we did all the processing
9198 -- for this pragma in Par.Prag (so that it works properly even in
9199 -- syntax only mode)
9208 -- pragma Passive [(PASSIVE_FORM)];
9210 -- PASSIVE_FORM ::= Semaphore | No
9212 when Pragma_Passive =>
9215 if Nkind (Parent (N)) /= N_Task_Definition then
9216 Error_Pragma ("pragma% must be within task definition");
9219 if Arg_Count /= 0 then
9220 Check_Arg_Count (1);
9221 Check_Arg_Is_One_Of (Arg1, Name_Semaphore, Name_No);
9224 ----------------------------------
9225 -- Preelaborable_Initialization --
9226 ----------------------------------
9228 -- pragma Preelaborable_Initialization (DIRECT_NAME);
9230 when Pragma_Preelaborable_Initialization => Preelab_Init : declare
9235 Check_Arg_Count (1);
9236 Check_No_Identifiers;
9237 Check_Arg_Is_Identifier (Arg1);
9238 Check_Arg_Is_Local_Name (Arg1);
9239 Check_First_Subtype (Arg1);
9240 Ent := Entity (Expression (Arg1));
9242 if not Is_Private_Type (Ent)
9243 and then not Is_Protected_Type (Ent)
9246 ("pragma % can only be applied to private or protected type",
9250 -- Give an error if the pragma is applied to a protected type that
9251 -- does not qualify (due to having entries, or due to components
9252 -- that do not qualify).
9254 if Is_Protected_Type (Ent)
9255 and then not Has_Preelaborable_Initialization (Ent)
9258 ("protected type & does not have preelaborable " &
9259 "initialization", Ent);
9261 -- Otherwise mark the type as definitely having preelaborable
9265 Set_Known_To_Have_Preelab_Init (Ent);
9268 if Has_Pragma_Preelab_Init (Ent)
9269 and then Warn_On_Redundant_Constructs
9271 Error_Pragma ("?duplicate pragma%!");
9273 Set_Has_Pragma_Preelab_Init (Ent);
9281 -- pragma Polling (ON | OFF);
9283 when Pragma_Polling =>
9285 Check_Arg_Count (1);
9286 Check_No_Identifiers;
9287 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
9288 Polling_Required := (Chars (Expression (Arg1)) = Name_On);
9290 --------------------
9291 -- Persistent_BSS --
9292 --------------------
9294 when Pragma_Persistent_BSS => Persistent_BSS : declare
9301 Check_At_Most_N_Arguments (1);
9303 -- Case of application to specific object (one argument)
9305 if Arg_Count = 1 then
9306 Check_Arg_Is_Library_Level_Local_Name (Arg1);
9308 if not Is_Entity_Name (Expression (Arg1))
9310 (Ekind (Entity (Expression (Arg1))) /= E_Variable
9311 and then Ekind (Entity (Expression (Arg1))) /= E_Constant)
9313 Error_Pragma_Arg ("pragma% only applies to objects", Arg1);
9316 Ent := Entity (Expression (Arg1));
9317 Decl := Parent (Ent);
9319 if Rep_Item_Too_Late (Ent, N) then
9323 if Present (Expression (Decl)) then
9325 ("object for pragma% cannot have initialization", Arg1);
9328 if not Is_Potentially_Persistent_Type (Etype (Ent)) then
9330 ("object type for pragma% is not potentially persistent",
9335 Make_Linker_Section_Pragma
9336 (Ent, Sloc (N), ".persistent.bss");
9337 Insert_After (N, Prag);
9340 -- Case of use as configuration pragma with no arguments
9343 Check_Valid_Configuration_Pragma;
9344 Persistent_BSS_Mode := True;
9352 -- pragma Postcondition ([Check =>] Boolean_Expression
9353 -- [,[Message =>] String_Expression]);
9355 when Pragma_Postcondition => Postcondition : declare
9357 pragma Warnings (Off, In_Body);
9361 Check_At_Least_N_Arguments (1);
9362 Check_At_Most_N_Arguments (2);
9363 Check_Optional_Identifier (Arg1, Name_Check);
9365 -- All we need to do here is call the common check procedure,
9366 -- the remainder of the processing is found in Sem_Ch6/Sem_Ch7.
9368 Check_Precondition_Postcondition (In_Body);
9375 -- pragma Precondition ([Check =>] Boolean_Expression
9376 -- [,[Message =>] String_Expression]);
9378 when Pragma_Precondition => Precondition : declare
9383 Check_At_Least_N_Arguments (1);
9384 Check_At_Most_N_Arguments (2);
9385 Check_Optional_Identifier (Arg1, Name_Check);
9387 Check_Precondition_Postcondition (In_Body);
9389 -- If in spec, nothing to do. If in body, then we convert the
9390 -- pragma to pragma Check (Precondition, cond [, msg]). Note we
9391 -- do this whether or not precondition checks are enabled. That
9392 -- works fine since pragma Check will do this check.
9395 if Arg_Count = 2 then
9396 Check_Optional_Identifier (Arg3, Name_Message);
9397 Analyze_And_Resolve (Get_Pragma_Arg (Arg2), Standard_String);
9400 Analyze_And_Resolve (Get_Pragma_Arg (Arg1), Standard_Boolean);
9404 Chars => Name_Check,
9405 Pragma_Argument_Associations => New_List (
9406 Make_Pragma_Argument_Association (Loc,
9408 Make_Identifier (Loc,
9409 Chars => Name_Precondition)),
9411 Make_Pragma_Argument_Association (Sloc (Arg1),
9412 Expression => Relocate_Node (Get_Pragma_Arg (Arg1))))));
9414 if Arg_Count = 2 then
9415 Append_To (Pragma_Argument_Associations (N),
9416 Make_Pragma_Argument_Association (Sloc (Arg2),
9417 Expression => Relocate_Node (Get_Pragma_Arg (Arg2))));
9428 -- pragma Preelaborate [(library_unit_NAME)];
9430 -- Set the flag Is_Preelaborated of program unit name entity
9432 when Pragma_Preelaborate => Preelaborate : declare
9433 Pa : constant Node_Id := Parent (N);
9434 Pk : constant Node_Kind := Nkind (Pa);
9438 Check_Ada_83_Warning;
9439 Check_Valid_Library_Unit_Pragma;
9441 if Nkind (N) = N_Null_Statement then
9445 Ent := Find_Lib_Unit_Name;
9447 -- This filters out pragmas inside generic parent then
9448 -- show up inside instantiation
9451 and then not (Pk = N_Package_Specification
9452 and then Present (Generic_Parent (Pa)))
9454 if not Debug_Flag_U then
9455 Set_Is_Preelaborated (Ent);
9456 Set_Suppress_Elaboration_Warnings (Ent);
9461 ---------------------
9462 -- Preelaborate_05 --
9463 ---------------------
9465 -- pragma Preelaborate_05 [(library_unit_NAME)];
9467 -- This pragma is useable only in GNAT_Mode, where it is used like
9468 -- pragma Preelaborate but it is only effective in Ada 2005 mode
9469 -- (otherwise it is ignored). This is used to implement AI-362 which
9470 -- recategorizes some run-time packages in Ada 2005 mode.
9472 when Pragma_Preelaborate_05 => Preelaborate_05 : declare
9477 Check_Valid_Library_Unit_Pragma;
9479 if not GNAT_Mode then
9480 Error_Pragma ("pragma% only available in GNAT mode");
9483 if Nkind (N) = N_Null_Statement then
9487 -- This is one of the few cases where we need to test the value of
9488 -- Ada_Version_Explicit rather than Ada_Version (which is always
9489 -- set to Ada_05 in a predefined unit), we need to know the
9490 -- explicit version set to know if this pragma is active.
9492 if Ada_Version_Explicit >= Ada_05 then
9493 Ent := Find_Lib_Unit_Name;
9494 Set_Is_Preelaborated (Ent);
9495 Set_Suppress_Elaboration_Warnings (Ent);
9497 end Preelaborate_05;
9503 -- pragma Priority (EXPRESSION);
9505 when Pragma_Priority => Priority : declare
9506 P : constant Node_Id := Parent (N);
9510 Check_No_Identifiers;
9511 Check_Arg_Count (1);
9515 if Nkind (P) = N_Subprogram_Body then
9516 Check_In_Main_Program;
9518 Arg := Expression (Arg1);
9519 Analyze_And_Resolve (Arg, Standard_Integer);
9523 if not Is_Static_Expression (Arg) then
9524 Flag_Non_Static_Expr
9525 ("main subprogram priority is not static!", Arg);
9528 -- If constraint error, then we already signalled an error
9530 elsif Raises_Constraint_Error (Arg) then
9533 -- Otherwise check in range
9537 Val : constant Uint := Expr_Value (Arg);
9541 or else Val > Expr_Value (Expression
9542 (Parent (RTE (RE_Max_Priority))))
9545 ("main subprogram priority is out of range", Arg1);
9551 (Current_Sem_Unit, UI_To_Int (Expr_Value (Arg)));
9553 -- Load an arbitrary entity from System.Tasking to make sure
9554 -- this package is implicitly with'ed, since we need to have
9555 -- the tasking run-time active for the pragma Priority to have
9559 Discard : Entity_Id;
9560 pragma Warnings (Off, Discard);
9562 Discard := RTE (RE_Task_List);
9565 -- Task or Protected, must be of type Integer
9567 elsif Nkind (P) = N_Protected_Definition
9569 Nkind (P) = N_Task_Definition
9571 Arg := Expression (Arg1);
9573 -- The expression must be analyzed in the special manner
9574 -- described in "Handling of Default and Per-Object
9575 -- Expressions" in sem.ads.
9577 Preanalyze_Spec_Expression (Arg, Standard_Integer);
9579 if not Is_Static_Expression (Arg) then
9580 Check_Restriction (Static_Priorities, Arg);
9583 -- Anything else is incorrect
9589 if Has_Priority_Pragma (P) then
9590 Error_Pragma ("duplicate pragma% not allowed");
9592 Set_Has_Priority_Pragma (P, True);
9594 if Nkind (P) = N_Protected_Definition
9596 Nkind (P) = N_Task_Definition
9598 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
9599 -- exp_ch9 should use this ???
9604 -----------------------------------
9605 -- Priority_Specific_Dispatching --
9606 -----------------------------------
9608 -- pragma Priority_Specific_Dispatching (
9609 -- policy_IDENTIFIER,
9610 -- first_priority_EXPRESSION,
9611 -- last_priority_EXPRESSION);
9613 when Pragma_Priority_Specific_Dispatching =>
9614 Priority_Specific_Dispatching : declare
9615 Prio_Id : constant Entity_Id := RTE (RE_Any_Priority);
9616 -- This is the entity System.Any_Priority;
9619 Lower_Bound : Node_Id;
9620 Upper_Bound : Node_Id;
9626 Check_Arg_Count (3);
9627 Check_No_Identifiers;
9628 Check_Arg_Is_Task_Dispatching_Policy (Arg1);
9629 Check_Valid_Configuration_Pragma;
9630 Get_Name_String (Chars (Expression (Arg1)));
9631 DP := Fold_Upper (Name_Buffer (1));
9633 Lower_Bound := Expression (Arg2);
9634 Check_Arg_Is_Static_Expression (Lower_Bound, Standard_Integer);
9635 Lower_Val := Expr_Value (Lower_Bound);
9637 Upper_Bound := Expression (Arg3);
9638 Check_Arg_Is_Static_Expression (Upper_Bound, Standard_Integer);
9639 Upper_Val := Expr_Value (Upper_Bound);
9641 -- It is not allowed to use Task_Dispatching_Policy and
9642 -- Priority_Specific_Dispatching in the same partition.
9644 if Task_Dispatching_Policy /= ' ' then
9645 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
9647 ("pragma% incompatible with Task_Dispatching_Policy#");
9649 -- Check lower bound in range
9651 elsif Lower_Val < Expr_Value (Type_Low_Bound (Prio_Id))
9653 Lower_Val > Expr_Value (Type_High_Bound (Prio_Id))
9656 ("first_priority is out of range", Arg2);
9658 -- Check upper bound in range
9660 elsif Upper_Val < Expr_Value (Type_Low_Bound (Prio_Id))
9662 Upper_Val > Expr_Value (Type_High_Bound (Prio_Id))
9665 ("last_priority is out of range", Arg3);
9667 -- Check that the priority range is valid
9669 elsif Lower_Val > Upper_Val then
9671 ("last_priority_expression must be greater than" &
9672 " or equal to first_priority_expression");
9674 -- Store the new policy, but always preserve System_Location since
9675 -- we like the error message with the run-time name.
9678 -- Check overlapping in the priority ranges specified in other
9679 -- Priority_Specific_Dispatching pragmas within the same
9680 -- partition. We can only check those we know about!
9683 Specific_Dispatching.First .. Specific_Dispatching.Last
9685 if Specific_Dispatching.Table (J).First_Priority in
9686 UI_To_Int (Lower_Val) .. UI_To_Int (Upper_Val)
9687 or else Specific_Dispatching.Table (J).Last_Priority in
9688 UI_To_Int (Lower_Val) .. UI_To_Int (Upper_Val)
9691 Specific_Dispatching.Table (J).Pragma_Loc;
9693 ("priority range overlaps with "
9694 & "Priority_Specific_Dispatching#");
9698 -- The use of Priority_Specific_Dispatching is incompatible
9699 -- with Task_Dispatching_Policy.
9701 if Task_Dispatching_Policy /= ' ' then
9702 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
9704 ("Priority_Specific_Dispatching incompatible "
9705 & "with Task_Dispatching_Policy#");
9708 -- The use of Priority_Specific_Dispatching forces ceiling
9711 if Locking_Policy /= ' ' and then Locking_Policy /= 'C' then
9712 Error_Msg_Sloc := Locking_Policy_Sloc;
9714 ("Priority_Specific_Dispatching incompatible "
9715 & "with Locking_Policy#");
9717 -- Set the Ceiling_Locking policy, but preserve System_Location
9718 -- since we like the error message with the run time name.
9721 Locking_Policy := 'C';
9723 if Locking_Policy_Sloc /= System_Location then
9724 Locking_Policy_Sloc := Loc;
9728 -- Add entry in the table
9730 Specific_Dispatching.Append
9731 ((Dispatching_Policy => DP,
9732 First_Priority => UI_To_Int (Lower_Val),
9733 Last_Priority => UI_To_Int (Upper_Val),
9734 Pragma_Loc => Loc));
9736 end Priority_Specific_Dispatching;
9742 -- pragma Profile (profile_IDENTIFIER);
9744 -- profile_IDENTIFIER => Restricted | Ravenscar
9746 when Pragma_Profile =>
9748 Check_Arg_Count (1);
9749 Check_Valid_Configuration_Pragma;
9750 Check_No_Identifiers;
9753 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
9755 if Chars (Argx) = Name_Ravenscar then
9756 Set_Ravenscar_Profile (N);
9757 elsif Chars (Argx) = Name_Restricted then
9758 Set_Profile_Restrictions (Restricted, N, Warn => False);
9760 Error_Pragma_Arg ("& is not a valid profile", Argx);
9764 ----------------------
9765 -- Profile_Warnings --
9766 ----------------------
9768 -- pragma Profile_Warnings (profile_IDENTIFIER);
9770 -- profile_IDENTIFIER => Restricted | Ravenscar
9772 when Pragma_Profile_Warnings =>
9774 Check_Arg_Count (1);
9775 Check_Valid_Configuration_Pragma;
9776 Check_No_Identifiers;
9779 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
9781 if Chars (Argx) = Name_Ravenscar then
9782 Set_Profile_Restrictions (Ravenscar, N, Warn => True);
9783 elsif Chars (Argx) = Name_Restricted then
9784 Set_Profile_Restrictions (Restricted, N, Warn => True);
9786 Error_Pragma_Arg ("& is not a valid profile", Argx);
9790 --------------------------
9791 -- Propagate_Exceptions --
9792 --------------------------
9794 -- pragma Propagate_Exceptions;
9796 -- Note: this pragma is obsolete and has no effect
9798 when Pragma_Propagate_Exceptions =>
9800 Check_Arg_Count (0);
9802 if In_Extended_Main_Source_Unit (N) then
9803 Propagate_Exceptions := True;
9810 -- pragma Psect_Object (
9811 -- [Internal =>] LOCAL_NAME,
9812 -- [, [External =>] EXTERNAL_SYMBOL]
9813 -- [, [Size =>] EXTERNAL_SYMBOL]);
9815 when Pragma_Psect_Object | Pragma_Common_Object =>
9816 Psect_Object : declare
9817 Args : Args_List (1 .. 3);
9818 Names : constant Name_List (1 .. 3) := (
9823 Internal : Node_Id renames Args (1);
9824 External : Node_Id renames Args (2);
9825 Size : Node_Id renames Args (3);
9829 procedure Check_Too_Long (Arg : Node_Id);
9830 -- Posts message if the argument is an identifier with more
9831 -- than 31 characters, or a string literal with more than
9832 -- 31 characters, and we are operating under VMS
9834 --------------------
9835 -- Check_Too_Long --
9836 --------------------
9838 procedure Check_Too_Long (Arg : Node_Id) is
9839 X : constant Node_Id := Original_Node (Arg);
9842 if Nkind (X) /= N_String_Literal
9844 Nkind (X) /= N_Identifier
9847 ("inappropriate argument for pragma %", Arg);
9850 if OpenVMS_On_Target then
9851 if (Nkind (X) = N_String_Literal
9852 and then String_Length (Strval (X)) > 31)
9854 (Nkind (X) = N_Identifier
9855 and then Length_Of_Name (Chars (X)) > 31)
9858 ("argument for pragma % is longer than 31 characters",
9864 -- Start of processing for Common_Object/Psect_Object
9868 Gather_Associations (Names, Args);
9869 Process_Extended_Import_Export_Internal_Arg (Internal);
9871 Def_Id := Entity (Internal);
9873 if Ekind (Def_Id) /= E_Constant
9874 and then Ekind (Def_Id) /= E_Variable
9877 ("pragma% must designate an object", Internal);
9880 Check_Too_Long (Internal);
9882 if Is_Imported (Def_Id) or else Is_Exported (Def_Id) then
9884 ("cannot use pragma% for imported/exported object",
9888 if Is_Concurrent_Type (Etype (Internal)) then
9890 ("cannot specify pragma % for task/protected object",
9894 if Has_Rep_Pragma (Def_Id, Name_Common_Object)
9896 Has_Rep_Pragma (Def_Id, Name_Psect_Object)
9898 Error_Msg_N ("?duplicate Common/Psect_Object pragma", N);
9901 if Ekind (Def_Id) = E_Constant then
9903 ("cannot specify pragma % for a constant", Internal);
9906 if Is_Record_Type (Etype (Internal)) then
9912 Ent := First_Entity (Etype (Internal));
9913 while Present (Ent) loop
9914 Decl := Declaration_Node (Ent);
9916 if Ekind (Ent) = E_Component
9917 and then Nkind (Decl) = N_Component_Declaration
9918 and then Present (Expression (Decl))
9919 and then Warn_On_Export_Import
9922 ("?object for pragma % has defaults", Internal);
9932 if Present (Size) then
9933 Check_Too_Long (Size);
9936 if Present (External) then
9937 Check_Arg_Is_External_Name (External);
9938 Check_Too_Long (External);
9941 -- If all error tests pass, link pragma on to the rep item chain
9943 Record_Rep_Item (Def_Id, N);
9950 -- pragma Pure [(library_unit_NAME)];
9952 when Pragma_Pure => Pure : declare
9956 Check_Ada_83_Warning;
9957 Check_Valid_Library_Unit_Pragma;
9959 if Nkind (N) = N_Null_Statement then
9963 Ent := Find_Lib_Unit_Name;
9965 Set_Has_Pragma_Pure (Ent);
9966 Set_Suppress_Elaboration_Warnings (Ent);
9973 -- pragma Pure_05 [(library_unit_NAME)];
9975 -- This pragma is useable only in GNAT_Mode, where it is used like
9976 -- pragma Pure but it is only effective in Ada 2005 mode (otherwise
9977 -- it is ignored). It may be used after a pragma Preelaborate, in
9978 -- which case it overrides the effect of the pragma Preelaborate.
9979 -- This is used to implement AI-362 which recategorizes some run-time
9980 -- packages in Ada 2005 mode.
9982 when Pragma_Pure_05 => Pure_05 : declare
9987 Check_Valid_Library_Unit_Pragma;
9989 if not GNAT_Mode then
9990 Error_Pragma ("pragma% only available in GNAT mode");
9992 if Nkind (N) = N_Null_Statement then
9996 -- This is one of the few cases where we need to test the value of
9997 -- Ada_Version_Explicit rather than Ada_Version (which is always
9998 -- set to Ada_05 in a predefined unit), we need to know the
9999 -- explicit version set to know if this pragma is active.
10001 if Ada_Version_Explicit >= Ada_05 then
10002 Ent := Find_Lib_Unit_Name;
10003 Set_Is_Preelaborated (Ent, False);
10005 Set_Suppress_Elaboration_Warnings (Ent);
10009 -------------------
10010 -- Pure_Function --
10011 -------------------
10013 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
10015 when Pragma_Pure_Function => Pure_Function : declare
10018 Def_Id : Entity_Id;
10019 Effective : Boolean := False;
10023 Check_Arg_Count (1);
10024 Check_Optional_Identifier (Arg1, Name_Entity);
10025 Check_Arg_Is_Local_Name (Arg1);
10026 E_Id := Expression (Arg1);
10028 if Error_Posted (E_Id) then
10032 -- Loop through homonyms (overloadings) of referenced entity
10034 E := Entity (E_Id);
10036 if Present (E) then
10038 Def_Id := Get_Base_Subprogram (E);
10040 if Ekind (Def_Id) /= E_Function
10041 and then Ekind (Def_Id) /= E_Generic_Function
10042 and then Ekind (Def_Id) /= E_Operator
10045 ("pragma% requires a function name", Arg1);
10048 Set_Is_Pure (Def_Id);
10050 if not Has_Pragma_Pure_Function (Def_Id) then
10051 Set_Has_Pragma_Pure_Function (Def_Id);
10056 exit when No (E) or else Scope (E) /= Current_Scope;
10060 and then Warn_On_Redundant_Constructs
10062 Error_Msg_NE ("pragma Pure_Function on& is redundant?",
10068 --------------------
10069 -- Queuing_Policy --
10070 --------------------
10072 -- pragma Queuing_Policy (policy_IDENTIFIER);
10074 when Pragma_Queuing_Policy => declare
10078 Check_Ada_83_Warning;
10079 Check_Arg_Count (1);
10080 Check_No_Identifiers;
10081 Check_Arg_Is_Queuing_Policy (Arg1);
10082 Check_Valid_Configuration_Pragma;
10083 Get_Name_String (Chars (Expression (Arg1)));
10084 QP := Fold_Upper (Name_Buffer (1));
10086 if Queuing_Policy /= ' '
10087 and then Queuing_Policy /= QP
10089 Error_Msg_Sloc := Queuing_Policy_Sloc;
10090 Error_Pragma ("queuing policy incompatible with policy#");
10092 -- Set new policy, but always preserve System_Location since
10093 -- we like the error message with the run time name.
10096 Queuing_Policy := QP;
10098 if Queuing_Policy_Sloc /= System_Location then
10099 Queuing_Policy_Sloc := Loc;
10104 -----------------------
10105 -- Relative_Deadline --
10106 -----------------------
10108 -- pragma Relative_Deadline (time_span_EXPRESSION);
10110 when Pragma_Relative_Deadline => Relative_Deadline : declare
10111 P : constant Node_Id := Parent (N);
10116 Check_No_Identifiers;
10117 Check_Arg_Count (1);
10119 Arg := Expression (Arg1);
10121 -- The expression must be analyzed in the special manner described
10122 -- in "Handling of Default and Per-Object Expressions" in sem.ads.
10124 Preanalyze_Spec_Expression (Arg, RTE (RE_Time_Span));
10128 if Nkind (P) = N_Subprogram_Body then
10129 Check_In_Main_Program;
10133 elsif Nkind (P) = N_Task_Definition then
10136 -- Anything else is incorrect
10142 if Has_Relative_Deadline_Pragma (P) then
10143 Error_Pragma ("duplicate pragma% not allowed");
10145 Set_Has_Relative_Deadline_Pragma (P, True);
10147 if Nkind (P) = N_Task_Definition then
10148 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
10151 end Relative_Deadline;
10153 ---------------------------
10154 -- Remote_Call_Interface --
10155 ---------------------------
10157 -- pragma Remote_Call_Interface [(library_unit_NAME)];
10159 when Pragma_Remote_Call_Interface => Remote_Call_Interface : declare
10160 Cunit_Node : Node_Id;
10161 Cunit_Ent : Entity_Id;
10165 Check_Ada_83_Warning;
10166 Check_Valid_Library_Unit_Pragma;
10168 if Nkind (N) = N_Null_Statement then
10172 Cunit_Node := Cunit (Current_Sem_Unit);
10173 K := Nkind (Unit (Cunit_Node));
10174 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
10176 if K = N_Package_Declaration
10177 or else K = N_Generic_Package_Declaration
10178 or else K = N_Subprogram_Declaration
10179 or else K = N_Generic_Subprogram_Declaration
10180 or else (K = N_Subprogram_Body
10181 and then Acts_As_Spec (Unit (Cunit_Node)))
10186 "pragma% must apply to package or subprogram declaration");
10189 Set_Is_Remote_Call_Interface (Cunit_Ent);
10190 end Remote_Call_Interface;
10196 -- pragma Remote_Types [(library_unit_NAME)];
10198 when Pragma_Remote_Types => Remote_Types : declare
10199 Cunit_Node : Node_Id;
10200 Cunit_Ent : Entity_Id;
10203 Check_Ada_83_Warning;
10204 Check_Valid_Library_Unit_Pragma;
10206 if Nkind (N) = N_Null_Statement then
10210 Cunit_Node := Cunit (Current_Sem_Unit);
10211 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
10213 if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration
10215 Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration
10218 "pragma% can only apply to a package declaration");
10221 Set_Is_Remote_Types (Cunit_Ent);
10228 -- pragma Ravenscar;
10230 when Pragma_Ravenscar =>
10232 Check_Arg_Count (0);
10233 Check_Valid_Configuration_Pragma;
10234 Set_Ravenscar_Profile (N);
10236 if Warn_On_Obsolescent_Feature then
10238 ("pragma Ravenscar is an obsolescent feature?", N);
10240 ("|use pragma Profile (Ravenscar) instead", N);
10243 -------------------------
10244 -- Restricted_Run_Time --
10245 -------------------------
10247 -- pragma Restricted_Run_Time;
10249 when Pragma_Restricted_Run_Time =>
10251 Check_Arg_Count (0);
10252 Check_Valid_Configuration_Pragma;
10253 Set_Profile_Restrictions (Restricted, N, Warn => False);
10255 if Warn_On_Obsolescent_Feature then
10257 ("pragma Restricted_Run_Time is an obsolescent feature?", N);
10259 ("|use pragma Profile (Restricted) instead", N);
10266 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
10269 -- restriction_IDENTIFIER
10270 -- | restriction_parameter_IDENTIFIER => EXPRESSION
10272 when Pragma_Restrictions =>
10273 Process_Restrictions_Or_Restriction_Warnings (Warn => False);
10275 --------------------------
10276 -- Restriction_Warnings --
10277 --------------------------
10279 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
10282 -- restriction_IDENTIFIER
10283 -- | restriction_parameter_IDENTIFIER => EXPRESSION
10285 when Pragma_Restriction_Warnings =>
10287 Process_Restrictions_Or_Restriction_Warnings (Warn => True);
10293 -- pragma Reviewable;
10295 when Pragma_Reviewable =>
10296 Check_Ada_83_Warning;
10297 Check_Arg_Count (0);
10300 -------------------
10301 -- Share_Generic --
10302 -------------------
10304 -- pragma Share_Generic (NAME {, NAME});
10306 when Pragma_Share_Generic =>
10308 Process_Generic_List;
10314 -- pragma Shared (LOCAL_NAME);
10316 when Pragma_Shared =>
10318 Process_Atomic_Shared_Volatile;
10320 --------------------
10321 -- Shared_Passive --
10322 --------------------
10324 -- pragma Shared_Passive [(library_unit_NAME)];
10326 -- Set the flag Is_Shared_Passive of program unit name entity
10328 when Pragma_Shared_Passive => Shared_Passive : declare
10329 Cunit_Node : Node_Id;
10330 Cunit_Ent : Entity_Id;
10333 Check_Ada_83_Warning;
10334 Check_Valid_Library_Unit_Pragma;
10336 if Nkind (N) = N_Null_Statement then
10340 Cunit_Node := Cunit (Current_Sem_Unit);
10341 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
10343 if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration
10345 Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration
10348 "pragma% can only apply to a package declaration");
10351 Set_Is_Shared_Passive (Cunit_Ent);
10352 end Shared_Passive;
10354 ----------------------
10355 -- Source_File_Name --
10356 ----------------------
10358 -- There are five forms for this pragma:
10360 -- pragma Source_File_Name (
10361 -- [UNIT_NAME =>] unit_NAME,
10362 -- BODY_FILE_NAME => STRING_LITERAL
10363 -- [, [INDEX =>] INTEGER_LITERAL]);
10365 -- pragma Source_File_Name (
10366 -- [UNIT_NAME =>] unit_NAME,
10367 -- SPEC_FILE_NAME => STRING_LITERAL
10368 -- [, [INDEX =>] INTEGER_LITERAL]);
10370 -- pragma Source_File_Name (
10371 -- BODY_FILE_NAME => STRING_LITERAL
10372 -- [, DOT_REPLACEMENT => STRING_LITERAL]
10373 -- [, CASING => CASING_SPEC]);
10375 -- pragma Source_File_Name (
10376 -- SPEC_FILE_NAME => STRING_LITERAL
10377 -- [, DOT_REPLACEMENT => STRING_LITERAL]
10378 -- [, CASING => CASING_SPEC]);
10380 -- pragma Source_File_Name (
10381 -- SUBUNIT_FILE_NAME => STRING_LITERAL
10382 -- [, DOT_REPLACEMENT => STRING_LITERAL]
10383 -- [, CASING => CASING_SPEC]);
10385 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
10387 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
10388 -- Source_File_Name (SFN), however their usage is exclusive:
10389 -- SFN can only be used when no project file is used, while
10390 -- SFNP can only be used when a project file is used.
10392 -- No processing here. Processing was completed during parsing,
10393 -- since we need to have file names set as early as possible.
10394 -- Units are loaded well before semantic processing starts.
10396 -- The only processing we defer to this point is the check
10397 -- for correct placement.
10399 when Pragma_Source_File_Name =>
10401 Check_Valid_Configuration_Pragma;
10403 ------------------------------
10404 -- Source_File_Name_Project --
10405 ------------------------------
10407 -- See Source_File_Name for syntax
10409 -- No processing here. Processing was completed during parsing,
10410 -- since we need to have file names set as early as possible.
10411 -- Units are loaded well before semantic processing starts.
10413 -- The only processing we defer to this point is the check
10414 -- for correct placement.
10416 when Pragma_Source_File_Name_Project =>
10418 Check_Valid_Configuration_Pragma;
10420 -- Check that a pragma Source_File_Name_Project is used only
10421 -- in a configuration pragmas file.
10423 -- Pragmas Source_File_Name_Project should only be generated
10424 -- by the Project Manager in configuration pragmas files.
10426 -- This is really an ugly test. It seems to depend on some
10427 -- accidental and undocumented property. At the very least
10428 -- it needs to be documented, but it would be better to have
10429 -- a clean way of testing if we are in a configuration file???
10431 if Present (Parent (N)) then
10433 ("pragma% can only appear in a configuration pragmas file");
10436 ----------------------
10437 -- Source_Reference --
10438 ----------------------
10440 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
10442 -- Nothing to do, all processing completed in Par.Prag, since we
10443 -- need the information for possible parser messages that are output
10445 when Pragma_Source_Reference =>
10448 --------------------------------
10449 -- Static_Elaboration_Desired --
10450 --------------------------------
10452 -- pragma Static_Elaboration_Desired (DIRECT_NAME);
10454 when Pragma_Static_Elaboration_Desired =>
10456 Check_At_Most_N_Arguments (1);
10458 if Is_Compilation_Unit (Current_Scope)
10459 and then Ekind (Current_Scope) = E_Package
10461 Set_Static_Elaboration_Desired (Current_Scope, True);
10463 Error_Pragma ("pragma% must apply to a library-level package");
10470 -- pragma Storage_Size (EXPRESSION);
10472 when Pragma_Storage_Size => Storage_Size : declare
10473 P : constant Node_Id := Parent (N);
10477 Check_No_Identifiers;
10478 Check_Arg_Count (1);
10480 -- The expression must be analyzed in the special manner described
10481 -- in "Handling of Default Expressions" in sem.ads.
10483 Arg := Expression (Arg1);
10484 Preanalyze_Spec_Expression (Arg, Any_Integer);
10486 if not Is_Static_Expression (Arg) then
10487 Check_Restriction (Static_Storage_Size, Arg);
10490 if Nkind (P) /= N_Task_Definition then
10495 if Has_Storage_Size_Pragma (P) then
10496 Error_Pragma ("duplicate pragma% not allowed");
10498 Set_Has_Storage_Size_Pragma (P, True);
10501 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
10502 -- ??? exp_ch9 should use this!
10510 -- pragma Storage_Unit (NUMERIC_LITERAL);
10512 -- Only permitted argument is System'Storage_Unit value
10514 when Pragma_Storage_Unit =>
10515 Check_No_Identifiers;
10516 Check_Arg_Count (1);
10517 Check_Arg_Is_Integer_Literal (Arg1);
10519 if Intval (Expression (Arg1)) /=
10520 UI_From_Int (Ttypes.System_Storage_Unit)
10522 Error_Msg_Uint_1 := UI_From_Int (Ttypes.System_Storage_Unit);
10524 ("the only allowed argument for pragma% is ^", Arg1);
10527 --------------------
10528 -- Stream_Convert --
10529 --------------------
10531 -- pragma Stream_Convert (
10532 -- [Entity =>] type_LOCAL_NAME,
10533 -- [Read =>] function_NAME,
10534 -- [Write =>] function NAME);
10536 when Pragma_Stream_Convert => Stream_Convert : declare
10538 procedure Check_OK_Stream_Convert_Function (Arg : Node_Id);
10539 -- Check that the given argument is the name of a local
10540 -- function of one argument that is not overloaded earlier
10541 -- in the current local scope. A check is also made that the
10542 -- argument is a function with one parameter.
10544 --------------------------------------
10545 -- Check_OK_Stream_Convert_Function --
10546 --------------------------------------
10548 procedure Check_OK_Stream_Convert_Function (Arg : Node_Id) is
10552 Check_Arg_Is_Local_Name (Arg);
10553 Ent := Entity (Expression (Arg));
10555 if Has_Homonym (Ent) then
10557 ("argument for pragma% may not be overloaded", Arg);
10560 if Ekind (Ent) /= E_Function
10561 or else No (First_Formal (Ent))
10562 or else Present (Next_Formal (First_Formal (Ent)))
10565 ("argument for pragma% must be" &
10566 " function of one argument", Arg);
10568 end Check_OK_Stream_Convert_Function;
10570 -- Start of processing for Stream_Convert
10574 Check_Arg_Order ((Name_Entity, Name_Read, Name_Write));
10575 Check_Arg_Count (3);
10576 Check_Optional_Identifier (Arg1, Name_Entity);
10577 Check_Optional_Identifier (Arg2, Name_Read);
10578 Check_Optional_Identifier (Arg3, Name_Write);
10579 Check_Arg_Is_Local_Name (Arg1);
10580 Check_OK_Stream_Convert_Function (Arg2);
10581 Check_OK_Stream_Convert_Function (Arg3);
10584 Typ : constant Entity_Id :=
10585 Underlying_Type (Entity (Expression (Arg1)));
10586 Read : constant Entity_Id := Entity (Expression (Arg2));
10587 Write : constant Entity_Id := Entity (Expression (Arg3));
10590 Check_First_Subtype (Arg1);
10592 -- Check for too early or too late. Note that we don't enforce
10593 -- the rule about primitive operations in this case, since, as
10594 -- is the case for explicit stream attributes themselves, these
10595 -- restrictions are not appropriate. Note that the chaining of
10596 -- the pragma by Rep_Item_Too_Late is actually the critical
10597 -- processing done for this pragma.
10599 if Rep_Item_Too_Early (Typ, N)
10601 Rep_Item_Too_Late (Typ, N, FOnly => True)
10606 -- Return if previous error
10608 if Etype (Typ) = Any_Type
10610 Etype (Read) = Any_Type
10612 Etype (Write) = Any_Type
10619 if Underlying_Type (Etype (Read)) /= Typ then
10621 ("incorrect return type for function&", Arg2);
10624 if Underlying_Type (Etype (First_Formal (Write))) /= Typ then
10626 ("incorrect parameter type for function&", Arg3);
10629 if Underlying_Type (Etype (First_Formal (Read))) /=
10630 Underlying_Type (Etype (Write))
10633 ("result type of & does not match Read parameter type",
10637 end Stream_Convert;
10639 -------------------------
10640 -- Style_Checks (GNAT) --
10641 -------------------------
10643 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
10645 -- This is processed by the parser since some of the style
10646 -- checks take place during source scanning and parsing. This
10647 -- means that we don't need to issue error messages here.
10649 when Pragma_Style_Checks => Style_Checks : declare
10650 A : constant Node_Id := Expression (Arg1);
10656 Check_No_Identifiers;
10658 -- Two argument form
10660 if Arg_Count = 2 then
10661 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
10668 E_Id := Expression (Arg2);
10671 if not Is_Entity_Name (E_Id) then
10673 ("second argument of pragma% must be entity name",
10677 E := Entity (E_Id);
10683 Set_Suppress_Style_Checks (E,
10684 (Chars (Expression (Arg1)) = Name_Off));
10685 exit when No (Homonym (E));
10691 -- One argument form
10694 Check_Arg_Count (1);
10696 if Nkind (A) = N_String_Literal then
10700 Slen : constant Natural := Natural (String_Length (S));
10701 Options : String (1 .. Slen);
10707 C := Get_String_Char (S, Int (J));
10708 exit when not In_Character_Range (C);
10709 Options (J) := Get_Character (C);
10711 -- If at end of string, set options. As per discussion
10712 -- above, no need to check for errors, since we issued
10713 -- them in the parser.
10716 Set_Style_Check_Options (Options);
10724 elsif Nkind (A) = N_Identifier then
10725 if Chars (A) = Name_All_Checks then
10726 Set_Default_Style_Check_Options;
10728 elsif Chars (A) = Name_On then
10729 Style_Check := True;
10731 elsif Chars (A) = Name_Off then
10732 Style_Check := False;
10742 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
10744 when Pragma_Subtitle =>
10746 Check_Arg_Count (1);
10747 Check_Optional_Identifier (Arg1, Name_Subtitle);
10748 Check_Arg_Is_String_Literal (Arg1);
10754 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
10756 when Pragma_Suppress =>
10757 Process_Suppress_Unsuppress (True);
10763 -- pragma Suppress_All;
10765 -- The only check made here is that the pragma appears in the
10766 -- proper place, i.e. following a compilation unit. If indeed
10767 -- it appears in this context, then the parser has already
10768 -- inserted an equivalent pragma Suppress (All_Checks) to get
10769 -- the required effect.
10771 when Pragma_Suppress_All =>
10773 Check_Arg_Count (0);
10775 if Nkind (Parent (N)) /= N_Compilation_Unit_Aux
10776 or else not Is_List_Member (N)
10777 or else List_Containing (N) /= Pragmas_After (Parent (N))
10780 ("misplaced pragma%, must follow compilation unit");
10783 -------------------------
10784 -- Suppress_Debug_Info --
10785 -------------------------
10787 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
10789 when Pragma_Suppress_Debug_Info =>
10791 Check_Arg_Count (1);
10792 Check_Optional_Identifier (Arg1, Name_Entity);
10793 Check_Arg_Is_Local_Name (Arg1);
10794 Set_Debug_Info_Off (Entity (Get_Pragma_Arg (Arg1)));
10796 ----------------------------------
10797 -- Suppress_Exception_Locations --
10798 ----------------------------------
10800 -- pragma Suppress_Exception_Locations;
10802 when Pragma_Suppress_Exception_Locations =>
10804 Check_Arg_Count (0);
10805 Check_Valid_Configuration_Pragma;
10806 Exception_Locations_Suppressed := True;
10808 -----------------------------
10809 -- Suppress_Initialization --
10810 -----------------------------
10812 -- pragma Suppress_Initialization ([Entity =>] type_Name);
10814 when Pragma_Suppress_Initialization => Suppress_Init : declare
10820 Check_Arg_Count (1);
10821 Check_Optional_Identifier (Arg1, Name_Entity);
10822 Check_Arg_Is_Local_Name (Arg1);
10824 E_Id := Expression (Arg1);
10826 if Etype (E_Id) = Any_Type then
10830 E := Entity (E_Id);
10832 if Is_Type (E) then
10833 if Is_Incomplete_Or_Private_Type (E) then
10834 if No (Full_View (Base_Type (E))) then
10836 ("argument of pragma% cannot be an incomplete type",
10839 Set_Suppress_Init_Proc (Full_View (Base_Type (E)));
10842 Set_Suppress_Init_Proc (Base_Type (E));
10847 ("pragma% requires argument that is a type name", Arg1);
10855 -- pragma System_Name (DIRECT_NAME);
10857 -- Syntax check: one argument, which must be the identifier GNAT
10858 -- or the identifier GCC, no other identifiers are acceptable.
10860 when Pragma_System_Name =>
10861 Check_No_Identifiers;
10862 Check_Arg_Count (1);
10863 Check_Arg_Is_One_Of (Arg1, Name_Gcc, Name_Gnat);
10865 -----------------------------
10866 -- Task_Dispatching_Policy --
10867 -----------------------------
10869 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
10871 when Pragma_Task_Dispatching_Policy => declare
10875 Check_Ada_83_Warning;
10876 Check_Arg_Count (1);
10877 Check_No_Identifiers;
10878 Check_Arg_Is_Task_Dispatching_Policy (Arg1);
10879 Check_Valid_Configuration_Pragma;
10880 Get_Name_String (Chars (Expression (Arg1)));
10881 DP := Fold_Upper (Name_Buffer (1));
10883 if Task_Dispatching_Policy /= ' '
10884 and then Task_Dispatching_Policy /= DP
10886 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
10888 ("task dispatching policy incompatible with policy#");
10890 -- Set new policy, but always preserve System_Location since
10891 -- we like the error message with the run time name.
10894 Task_Dispatching_Policy := DP;
10896 if Task_Dispatching_Policy_Sloc /= System_Location then
10897 Task_Dispatching_Policy_Sloc := Loc;
10906 -- pragma Task_Info (EXPRESSION);
10908 when Pragma_Task_Info => Task_Info : declare
10909 P : constant Node_Id := Parent (N);
10914 if Nkind (P) /= N_Task_Definition then
10915 Error_Pragma ("pragma% must appear in task definition");
10918 Check_No_Identifiers;
10919 Check_Arg_Count (1);
10921 Analyze_And_Resolve (Expression (Arg1), RTE (RE_Task_Info_Type));
10923 if Etype (Expression (Arg1)) = Any_Type then
10927 if Has_Task_Info_Pragma (P) then
10928 Error_Pragma ("duplicate pragma% not allowed");
10930 Set_Has_Task_Info_Pragma (P, True);
10938 -- pragma Task_Name (string_EXPRESSION);
10940 when Pragma_Task_Name => Task_Name : declare
10941 P : constant Node_Id := Parent (N);
10945 Check_No_Identifiers;
10946 Check_Arg_Count (1);
10948 Arg := Expression (Arg1);
10949 Analyze_And_Resolve (Arg, Standard_String);
10951 if Nkind (P) /= N_Task_Definition then
10955 if Has_Task_Name_Pragma (P) then
10956 Error_Pragma ("duplicate pragma% not allowed");
10958 Set_Has_Task_Name_Pragma (P, True);
10959 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
10967 -- pragma Task_Storage (
10968 -- [Task_Type =>] LOCAL_NAME,
10969 -- [Top_Guard =>] static_integer_EXPRESSION);
10971 when Pragma_Task_Storage => Task_Storage : declare
10972 Args : Args_List (1 .. 2);
10973 Names : constant Name_List (1 .. 2) := (
10977 Task_Type : Node_Id renames Args (1);
10978 Top_Guard : Node_Id renames Args (2);
10984 Gather_Associations (Names, Args);
10986 if No (Task_Type) then
10988 ("missing task_type argument for pragma%");
10991 Check_Arg_Is_Local_Name (Task_Type);
10993 Ent := Entity (Task_Type);
10995 if not Is_Task_Type (Ent) then
10997 ("argument for pragma% must be task type", Task_Type);
11000 if No (Top_Guard) then
11002 ("pragma% takes two arguments", Task_Type);
11004 Check_Arg_Is_Static_Expression (Top_Guard, Any_Integer);
11007 Check_First_Subtype (Task_Type);
11009 if Rep_Item_Too_Late (Ent, N) then
11018 -- pragma Time_Slice (static_duration_EXPRESSION);
11020 when Pragma_Time_Slice => Time_Slice : declare
11026 Check_Arg_Count (1);
11027 Check_No_Identifiers;
11028 Check_In_Main_Program;
11029 Check_Arg_Is_Static_Expression (Arg1, Standard_Duration);
11031 if not Error_Posted (Arg1) then
11033 while Present (Nod) loop
11034 if Nkind (Nod) = N_Pragma
11035 and then Pragma_Name (Nod) = Name_Time_Slice
11037 Error_Msg_Name_1 := Pname;
11038 Error_Msg_N ("duplicate pragma% not permitted", Nod);
11045 -- Process only if in main unit
11047 if Get_Source_Unit (Loc) = Main_Unit then
11048 Opt.Time_Slice_Set := True;
11049 Val := Expr_Value_R (Expression (Arg1));
11051 if Val <= Ureal_0 then
11052 Opt.Time_Slice_Value := 0;
11054 elsif Val > UR_From_Uint (UI_From_Int (1000)) then
11055 Opt.Time_Slice_Value := 1_000_000_000;
11058 Opt.Time_Slice_Value :=
11059 UI_To_Int (UR_To_Uint (Val * UI_From_Int (1_000_000)));
11068 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
11070 -- TITLING_OPTION ::=
11071 -- [Title =>] STRING_LITERAL
11072 -- | [Subtitle =>] STRING_LITERAL
11074 when Pragma_Title => Title : declare
11075 Args : Args_List (1 .. 2);
11076 Names : constant Name_List (1 .. 2) := (
11082 Gather_Associations (Names, Args);
11084 for J in 1 .. 2 loop
11085 if Present (Args (J)) then
11086 Check_Arg_Is_String_Literal (Args (J));
11091 ---------------------
11092 -- Unchecked_Union --
11093 ---------------------
11095 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
11097 when Pragma_Unchecked_Union => Unchecked_Union : declare
11098 Assoc : constant Node_Id := Arg1;
11099 Type_Id : constant Node_Id := Expression (Assoc);
11110 Check_No_Identifiers;
11111 Check_Arg_Count (1);
11112 Check_Arg_Is_Local_Name (Arg1);
11114 Find_Type (Type_Id);
11115 Typ := Entity (Type_Id);
11118 or else Rep_Item_Too_Early (Typ, N)
11122 Typ := Underlying_Type (Typ);
11125 if Rep_Item_Too_Late (Typ, N) then
11129 Check_First_Subtype (Arg1);
11131 -- Note remaining cases are references to a type in the current
11132 -- declarative part. If we find an error, we post the error on
11133 -- the relevant type declaration at an appropriate point.
11135 if not Is_Record_Type (Typ) then
11136 Error_Msg_N ("Unchecked_Union must be record type", Typ);
11139 elsif Is_Tagged_Type (Typ) then
11140 Error_Msg_N ("Unchecked_Union must not be tagged", Typ);
11143 elsif Is_Limited_Type (Typ) then
11145 ("Unchecked_Union must not be limited record type", Typ);
11146 Explain_Limited_Type (Typ, Typ);
11150 if not Has_Discriminants (Typ) then
11152 ("Unchecked_Union must have one discriminant", Typ);
11156 Discr := First_Discriminant (Typ);
11157 while Present (Discr) loop
11158 if No (Discriminant_Default_Value (Discr)) then
11160 ("Unchecked_Union discriminant must have default value",
11163 Next_Discriminant (Discr);
11166 Tdef := Type_Definition (Declaration_Node (Typ));
11167 Clist := Component_List (Tdef);
11169 Comp := First (Component_Items (Clist));
11170 while Present (Comp) loop
11171 Check_Component (Comp);
11175 if No (Clist) or else No (Variant_Part (Clist)) then
11177 ("Unchecked_Union must have variant part",
11182 Vpart := Variant_Part (Clist);
11184 Variant := First (Variants (Vpart));
11185 while Present (Variant) loop
11186 Check_Variant (Variant);
11191 Set_Is_Unchecked_Union (Typ, True);
11192 Set_Convention (Typ, Convention_C);
11194 Set_Has_Unchecked_Union (Base_Type (Typ), True);
11195 Set_Is_Unchecked_Union (Base_Type (Typ), True);
11196 end Unchecked_Union;
11198 ------------------------
11199 -- Unimplemented_Unit --
11200 ------------------------
11202 -- pragma Unimplemented_Unit;
11204 -- Note: this only gives an error if we are generating code,
11205 -- or if we are in a generic library unit (where the pragma
11206 -- appears in the body, not in the spec).
11208 when Pragma_Unimplemented_Unit => Unimplemented_Unit : declare
11209 Cunitent : constant Entity_Id :=
11210 Cunit_Entity (Get_Source_Unit (Loc));
11211 Ent_Kind : constant Entity_Kind :=
11216 Check_Arg_Count (0);
11218 if Operating_Mode = Generate_Code
11219 or else Ent_Kind = E_Generic_Function
11220 or else Ent_Kind = E_Generic_Procedure
11221 or else Ent_Kind = E_Generic_Package
11223 Get_Name_String (Chars (Cunitent));
11224 Set_Casing (Mixed_Case);
11225 Write_Str (Name_Buffer (1 .. Name_Len));
11226 Write_Str (" is not supported in this configuration");
11228 raise Unrecoverable_Error;
11230 end Unimplemented_Unit;
11232 ------------------------
11233 -- Universal_Aliasing --
11234 ------------------------
11236 -- pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
11238 when Pragma_Universal_Aliasing => Universal_Alias : declare
11243 Check_Arg_Count (1);
11244 Check_Optional_Identifier (Arg2, Name_Entity);
11245 Check_Arg_Is_Local_Name (Arg1);
11246 E_Id := Entity (Expression (Arg1));
11248 if E_Id = Any_Type then
11250 elsif No (E_Id) or else not Is_Type (E_Id) then
11251 Error_Pragma_Arg ("pragma% requires type", Arg1);
11254 Set_Universal_Aliasing (Implementation_Base_Type (E_Id));
11255 end Universal_Alias;
11257 --------------------
11258 -- Universal_Data --
11259 --------------------
11261 -- pragma Universal_Data [(library_unit_NAME)];
11263 when Pragma_Universal_Data =>
11266 -- If this is a configuration pragma, then set the universal
11267 -- addressing option, otherwise confirm that the pragma
11268 -- satisfies the requirements of library unit pragma placement
11269 -- and leave it to the GNAAMP back end to detect the pragma
11270 -- (avoids transitive setting of the option due to withed units).
11272 if Is_Configuration_Pragma then
11273 Universal_Addressing_On_AAMP := True;
11275 Check_Valid_Library_Unit_Pragma;
11278 if not AAMP_On_Target then
11279 Error_Pragma ("?pragma% ignored (applies only to AAMP)");
11286 -- pragma Unmodified (local_Name {, local_Name});
11288 when Pragma_Unmodified => Unmodified : declare
11289 Arg_Node : Node_Id;
11290 Arg_Expr : Node_Id;
11291 Arg_Ent : Entity_Id;
11295 Check_At_Least_N_Arguments (1);
11297 -- Loop through arguments
11300 while Present (Arg_Node) loop
11301 Check_No_Identifier (Arg_Node);
11303 -- Note: the analyze call done by Check_Arg_Is_Local_Name
11304 -- will in fact generate reference, so that the entity will
11305 -- have a reference, which will inhibit any warnings about
11306 -- it not being referenced, and also properly show up in the
11307 -- ali file as a reference. But this reference is recorded
11308 -- before the Has_Pragma_Unreferenced flag is set, so that
11309 -- no warning is generated for this reference.
11311 Check_Arg_Is_Local_Name (Arg_Node);
11312 Arg_Expr := Get_Pragma_Arg (Arg_Node);
11314 if Is_Entity_Name (Arg_Expr) then
11315 Arg_Ent := Entity (Arg_Expr);
11317 if not Is_Assignable (Arg_Ent) then
11319 ("pragma% can only be applied to a variable",
11322 Set_Has_Pragma_Unmodified (Arg_Ent);
11334 -- pragma Unreferenced (local_Name {, local_Name});
11336 -- or when used in a context clause:
11338 -- pragma Unreferenced (library_unit_NAME {, library_unit_NAME}
11340 when Pragma_Unreferenced => Unreferenced : declare
11341 Arg_Node : Node_Id;
11342 Arg_Expr : Node_Id;
11343 Arg_Ent : Entity_Id;
11348 Check_At_Least_N_Arguments (1);
11350 -- Check case of appearing within context clause
11352 if Is_In_Context_Clause then
11354 -- The arguments must all be units mentioned in a with clause
11355 -- in the same context clause. Note we already checked (in
11356 -- Par.Prag) that the arguments are either identifiers or
11357 -- selected components.
11360 while Present (Arg_Node) loop
11361 Citem := First (List_Containing (N));
11362 while Citem /= N loop
11363 if Nkind (Citem) = N_With_Clause
11364 and then Same_Name (Name (Citem), Expression (Arg_Node))
11366 Set_Has_Pragma_Unreferenced
11369 (Library_Unit (Citem))));
11370 Set_Unit_Name (Expression (Arg_Node), Name (Citem));
11379 ("argument of pragma% is not with'ed unit", Arg_Node);
11385 -- Case of not in list of context items
11389 while Present (Arg_Node) loop
11390 Check_No_Identifier (Arg_Node);
11392 -- Note: the analyze call done by Check_Arg_Is_Local_Name
11393 -- will in fact generate reference, so that the entity will
11394 -- have a reference, which will inhibit any warnings about
11395 -- it not being referenced, and also properly show up in the
11396 -- ali file as a reference. But this reference is recorded
11397 -- before the Has_Pragma_Unreferenced flag is set, so that
11398 -- no warning is generated for this reference.
11400 Check_Arg_Is_Local_Name (Arg_Node);
11401 Arg_Expr := Get_Pragma_Arg (Arg_Node);
11403 if Is_Entity_Name (Arg_Expr) then
11404 Arg_Ent := Entity (Arg_Expr);
11406 -- If the entity is overloaded, the pragma applies to the
11407 -- most recent overloading, as documented. In this case,
11408 -- name resolution does not generate a reference, so it
11409 -- must be done here explicitly.
11411 if Is_Overloaded (Arg_Expr) then
11412 Generate_Reference (Arg_Ent, N);
11415 Set_Has_Pragma_Unreferenced (Arg_Ent);
11423 --------------------------
11424 -- Unreferenced_Objects --
11425 --------------------------
11427 -- pragma Unreferenced_Objects (local_Name {, local_Name});
11429 when Pragma_Unreferenced_Objects => Unreferenced_Objects : declare
11430 Arg_Node : Node_Id;
11431 Arg_Expr : Node_Id;
11435 Check_At_Least_N_Arguments (1);
11438 while Present (Arg_Node) loop
11439 Check_No_Identifier (Arg_Node);
11440 Check_Arg_Is_Local_Name (Arg_Node);
11441 Arg_Expr := Get_Pragma_Arg (Arg_Node);
11443 if not Is_Entity_Name (Arg_Expr)
11444 or else not Is_Type (Entity (Arg_Expr))
11447 ("argument for pragma% must be type or subtype", Arg_Node);
11450 Set_Has_Pragma_Unreferenced_Objects (Entity (Arg_Expr));
11453 end Unreferenced_Objects;
11455 ------------------------------
11456 -- Unreserve_All_Interrupts --
11457 ------------------------------
11459 -- pragma Unreserve_All_Interrupts;
11461 when Pragma_Unreserve_All_Interrupts =>
11463 Check_Arg_Count (0);
11465 if In_Extended_Main_Code_Unit (Main_Unit_Entity) then
11466 Unreserve_All_Interrupts := True;
11473 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
11475 when Pragma_Unsuppress =>
11477 Process_Suppress_Unsuppress (False);
11479 -------------------
11480 -- Use_VADS_Size --
11481 -------------------
11483 -- pragma Use_VADS_Size;
11485 when Pragma_Use_VADS_Size =>
11487 Check_Arg_Count (0);
11488 Check_Valid_Configuration_Pragma;
11489 Use_VADS_Size := True;
11491 ---------------------
11492 -- Validity_Checks --
11493 ---------------------
11495 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
11497 when Pragma_Validity_Checks => Validity_Checks : declare
11498 A : constant Node_Id := Expression (Arg1);
11504 Check_Arg_Count (1);
11505 Check_No_Identifiers;
11507 if Nkind (A) = N_String_Literal then
11511 Slen : constant Natural := Natural (String_Length (S));
11512 Options : String (1 .. Slen);
11518 C := Get_String_Char (S, Int (J));
11519 exit when not In_Character_Range (C);
11520 Options (J) := Get_Character (C);
11523 Set_Validity_Check_Options (Options);
11531 elsif Nkind (A) = N_Identifier then
11533 if Chars (A) = Name_All_Checks then
11534 Set_Validity_Check_Options ("a");
11536 elsif Chars (A) = Name_On then
11537 Validity_Checks_On := True;
11539 elsif Chars (A) = Name_Off then
11540 Validity_Checks_On := False;
11544 end Validity_Checks;
11550 -- pragma Volatile (LOCAL_NAME);
11552 when Pragma_Volatile =>
11553 Process_Atomic_Shared_Volatile;
11555 -------------------------
11556 -- Volatile_Components --
11557 -------------------------
11559 -- pragma Volatile_Components (array_LOCAL_NAME);
11561 -- Volatile is handled by the same circuit as Atomic_Components
11567 -- pragma Warnings (On | Off);
11568 -- pragma Warnings (On | Off, LOCAL_NAME);
11569 -- pragma Warnings (static_string_EXPRESSION);
11570 -- pragma Warnings (On | Off, STRING_LITERAL);
11572 when Pragma_Warnings => Warnings : begin
11574 Check_At_Least_N_Arguments (1);
11575 Check_No_Identifiers;
11578 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
11581 -- One argument case
11583 if Arg_Count = 1 then
11585 -- On/Off one argument case was processed by parser
11587 if Nkind (Argx) = N_Identifier
11589 (Chars (Argx) = Name_On
11591 Chars (Argx) = Name_Off)
11595 -- One argument case must be ON/OFF or static string expr
11597 elsif not Is_Static_String_Expression (Arg1) then
11599 ("argument of pragma% must be On/Off or " &
11600 "static string expression", Arg2);
11602 -- One argument string expression case
11606 Lit : constant Node_Id := Expr_Value_S (Argx);
11607 Str : constant String_Id := Strval (Lit);
11608 Len : constant Nat := String_Length (Str);
11616 while J <= Len loop
11617 C := Get_String_Char (Str, J);
11618 OK := In_Character_Range (C);
11621 Chr := Get_Character (C);
11625 if J < Len and then Chr = '.' then
11627 C := Get_String_Char (Str, J);
11628 Chr := Get_Character (C);
11630 if not Set_Dot_Warning_Switch (Chr) then
11632 ("invalid warning switch character " &
11639 OK := Set_Warning_Switch (Chr);
11645 ("invalid warning switch character " & Chr,
11654 -- Two or more arguments (must be two)
11657 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
11658 Check_At_Most_N_Arguments (2);
11666 E_Id := Expression (Arg2);
11669 -- In the expansion of an inlined body, a reference to
11670 -- the formal may be wrapped in a conversion if the
11671 -- actual is a conversion. Retrieve the real entity name.
11673 if (In_Instance_Body
11674 or else In_Inlined_Body)
11675 and then Nkind (E_Id) = N_Unchecked_Type_Conversion
11677 E_Id := Expression (E_Id);
11680 -- Entity name case
11682 if Is_Entity_Name (E_Id) then
11683 E := Entity (E_Id);
11690 (E, (Chars (Expression (Arg1)) = Name_Off));
11692 if Chars (Expression (Arg1)) = Name_Off
11693 and then Warn_On_Warnings_Off
11695 Warnings_Off_Pragmas.Append ((N, E));
11698 if Is_Enumeration_Type (E) then
11702 Lit := First_Literal (E);
11703 while Present (Lit) loop
11704 Set_Warnings_Off (Lit);
11705 Next_Literal (Lit);
11710 exit when No (Homonym (E));
11715 -- Error if not entity or static string literal case
11717 elsif not Is_Static_String_Expression (Arg2) then
11719 ("second argument of pragma% must be entity " &
11720 "name or static string expression", Arg2);
11722 -- String literal case
11725 String_To_Name_Buffer
11726 (Strval (Expr_Value_S (Expression (Arg2))));
11728 -- Note on configuration pragma case: If this is a
11729 -- configuration pragma, then for an OFF pragma, we
11730 -- just set Config True in the call, which is all
11731 -- that needs to be done. For the case of ON, this
11732 -- is normally an error, unless it is canceling the
11733 -- effect of a previous OFF pragma in the same file.
11734 -- In any other case, an error will be signalled (ON
11735 -- with no matching OFF).
11737 if Chars (Argx) = Name_Off then
11738 Set_Specific_Warning_Off
11739 (Loc, Name_Buffer (1 .. Name_Len),
11740 Config => Is_Configuration_Pragma);
11742 elsif Chars (Argx) = Name_On then
11743 Set_Specific_Warning_On
11744 (Loc, Name_Buffer (1 .. Name_Len), Err);
11748 ("?pragma Warnings On with no " &
11749 "matching Warnings Off",
11759 -------------------
11760 -- Weak_External --
11761 -------------------
11763 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
11765 when Pragma_Weak_External => Weak_External : declare
11770 Check_Arg_Count (1);
11771 Check_Optional_Identifier (Arg1, Name_Entity);
11772 Check_Arg_Is_Library_Level_Local_Name (Arg1);
11773 Ent := Entity (Expression (Arg1));
11775 if Rep_Item_Too_Early (Ent, N) then
11778 Ent := Underlying_Type (Ent);
11781 -- The only processing required is to link this item on to the
11782 -- list of rep items for the given entity. This is accomplished
11783 -- by the call to Rep_Item_Too_Late (when no error is detected
11784 -- and False is returned).
11786 if Rep_Item_Too_Late (Ent, N) then
11789 Set_Has_Gigi_Rep_Item (Ent);
11793 -----------------------------
11794 -- Wide_Character_Encoding --
11795 -----------------------------
11797 -- pragma Wide_Character_Encoding (IDENTIFIER);
11799 when Pragma_Wide_Character_Encoding =>
11801 -- Nothing to do, handled in parser. Note that we do not enforce
11802 -- configuration pragma placement, this pragma can appear at any
11803 -- place in the source, allowing mixed encodings within a single
11808 --------------------
11809 -- Unknown_Pragma --
11810 --------------------
11812 -- Should be impossible, since the case of an unknown pragma is
11813 -- separately processed before the case statement is entered.
11815 when Unknown_Pragma =>
11816 raise Program_Error;
11820 when Pragma_Exit => null;
11821 end Analyze_Pragma;
11823 -------------------
11824 -- Check_Enabled --
11825 -------------------
11827 function Check_Enabled (Nam : Name_Id) return Boolean is
11831 PP := Opt.Check_Policy_List;
11834 return Assertions_Enabled;
11837 Nam = Chars (Expression (First (Pragma_Argument_Associations (PP))))
11840 Chars (Expression (Last (Pragma_Argument_Associations (PP))))
11842 when Name_On | Name_Check =>
11844 when Name_Off | Name_Ignore =>
11847 raise Program_Error;
11851 PP := Next_Pragma (PP);
11856 ---------------------------------
11857 -- Delay_Config_Pragma_Analyze --
11858 ---------------------------------
11860 function Delay_Config_Pragma_Analyze (N : Node_Id) return Boolean is
11862 return Pragma_Name (N) = Name_Interrupt_State
11864 Pragma_Name (N) = Name_Priority_Specific_Dispatching;
11865 end Delay_Config_Pragma_Analyze;
11867 -------------------------
11868 -- Get_Base_Subprogram --
11869 -------------------------
11871 function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id is
11872 Result : Entity_Id;
11875 -- Follow subprogram renaming chain
11878 while Is_Subprogram (Result)
11880 (Is_Generic_Instance (Result)
11881 or else Nkind (Parent (Declaration_Node (Result))) =
11882 N_Subprogram_Renaming_Declaration)
11883 and then Present (Alias (Result))
11885 Result := Alias (Result);
11889 end Get_Base_Subprogram;
11891 --------------------
11892 -- Get_Pragma_Arg --
11893 --------------------
11895 function Get_Pragma_Arg (Arg : Node_Id) return Node_Id is
11897 if Nkind (Arg) = N_Pragma_Argument_Association then
11898 return Expression (Arg);
11902 end Get_Pragma_Arg;
11908 procedure Initialize is
11913 -----------------------------
11914 -- Is_Config_Static_String --
11915 -----------------------------
11917 function Is_Config_Static_String (Arg : Node_Id) return Boolean is
11919 function Add_Config_Static_String (Arg : Node_Id) return Boolean;
11920 -- This is an internal recursive function that is just like the
11921 -- outer function except that it adds the string to the name buffer
11922 -- rather than placing the string in the name buffer.
11924 ------------------------------
11925 -- Add_Config_Static_String --
11926 ------------------------------
11928 function Add_Config_Static_String (Arg : Node_Id) return Boolean is
11935 if Nkind (N) = N_Op_Concat then
11936 if Add_Config_Static_String (Left_Opnd (N)) then
11937 N := Right_Opnd (N);
11943 if Nkind (N) /= N_String_Literal then
11944 Error_Msg_N ("string literal expected for pragma argument", N);
11948 for J in 1 .. String_Length (Strval (N)) loop
11949 C := Get_String_Char (Strval (N), J);
11951 if not In_Character_Range (C) then
11953 ("string literal contains invalid wide character",
11954 Sloc (N) + 1 + Source_Ptr (J));
11958 Add_Char_To_Name_Buffer (Get_Character (C));
11963 end Add_Config_Static_String;
11965 -- Start of processing for Is_Config_Static_String
11970 return Add_Config_Static_String (Arg);
11971 end Is_Config_Static_String;
11973 -----------------------------------------
11974 -- Is_Non_Significant_Pragma_Reference --
11975 -----------------------------------------
11977 -- This function makes use of the following static table which indicates
11978 -- whether a given pragma is significant. A value of -1 in this table
11979 -- indicates that the reference is significant. A value of zero indicates
11980 -- than appearance as any argument is insignificant, a positive value
11981 -- indicates that appearance in that parameter position is significant.
11983 -- A value of 99 flags a special case requiring a special check (this is
11984 -- used for cases not covered by this standard encoding, e.g. pragma Check
11985 -- where the first argument is not significant, but the others are).
11987 Sig_Flags : constant array (Pragma_Id) of Int :=
11988 (Pragma_AST_Entry => -1,
11989 Pragma_Abort_Defer => -1,
11990 Pragma_Ada_83 => -1,
11991 Pragma_Ada_95 => -1,
11992 Pragma_Ada_05 => -1,
11993 Pragma_Ada_2005 => -1,
11994 Pragma_All_Calls_Remote => -1,
11995 Pragma_Annotate => -1,
11996 Pragma_Assert => -1,
11997 Pragma_Assertion_Policy => 0,
11998 Pragma_Asynchronous => -1,
11999 Pragma_Atomic => 0,
12000 Pragma_Atomic_Components => 0,
12001 Pragma_Attach_Handler => -1,
12002 Pragma_Check => 99,
12003 Pragma_Check_Name => 0,
12004 Pragma_Check_Policy => 0,
12005 Pragma_CIL_Constructor => -1,
12006 Pragma_CPP_Class => 0,
12007 Pragma_CPP_Constructor => 0,
12008 Pragma_CPP_Virtual => 0,
12009 Pragma_CPP_Vtable => 0,
12010 Pragma_C_Pass_By_Copy => 0,
12011 Pragma_Comment => 0,
12012 Pragma_Common_Object => -1,
12013 Pragma_Compile_Time_Error => -1,
12014 Pragma_Compile_Time_Warning => -1,
12015 Pragma_Compiler_Unit => 0,
12016 Pragma_Complete_Representation => 0,
12017 Pragma_Complex_Representation => 0,
12018 Pragma_Component_Alignment => -1,
12019 Pragma_Controlled => 0,
12020 Pragma_Convention => 0,
12021 Pragma_Convention_Identifier => 0,
12022 Pragma_Debug => -1,
12023 Pragma_Debug_Policy => 0,
12024 Pragma_Detect_Blocking => -1,
12025 Pragma_Discard_Names => 0,
12026 Pragma_Elaborate => -1,
12027 Pragma_Elaborate_All => -1,
12028 Pragma_Elaborate_Body => -1,
12029 Pragma_Elaboration_Checks => -1,
12030 Pragma_Eliminate => -1,
12031 Pragma_Export => -1,
12032 Pragma_Export_Exception => -1,
12033 Pragma_Export_Function => -1,
12034 Pragma_Export_Object => -1,
12035 Pragma_Export_Procedure => -1,
12036 Pragma_Export_Value => -1,
12037 Pragma_Export_Valued_Procedure => -1,
12038 Pragma_Extend_System => -1,
12039 Pragma_Extensions_Allowed => -1,
12040 Pragma_External => -1,
12041 Pragma_Favor_Top_Level => -1,
12042 Pragma_External_Name_Casing => -1,
12043 Pragma_Fast_Math => -1,
12044 Pragma_Finalize_Storage_Only => 0,
12045 Pragma_Float_Representation => 0,
12046 Pragma_Ident => -1,
12047 Pragma_Implemented_By_Entry => -1,
12048 Pragma_Implicit_Packing => 0,
12049 Pragma_Import => +2,
12050 Pragma_Import_Exception => 0,
12051 Pragma_Import_Function => 0,
12052 Pragma_Import_Object => 0,
12053 Pragma_Import_Procedure => 0,
12054 Pragma_Import_Valued_Procedure => 0,
12055 Pragma_Initialize_Scalars => -1,
12056 Pragma_Inline => 0,
12057 Pragma_Inline_Always => 0,
12058 Pragma_Inline_Generic => 0,
12059 Pragma_Inspection_Point => -1,
12060 Pragma_Interface => +2,
12061 Pragma_Interface_Name => +2,
12062 Pragma_Interrupt_Handler => -1,
12063 Pragma_Interrupt_Priority => -1,
12064 Pragma_Interrupt_State => -1,
12065 Pragma_Java_Constructor => -1,
12066 Pragma_Java_Interface => -1,
12067 Pragma_Keep_Names => 0,
12068 Pragma_License => -1,
12069 Pragma_Link_With => -1,
12070 Pragma_Linker_Alias => -1,
12071 Pragma_Linker_Constructor => -1,
12072 Pragma_Linker_Destructor => -1,
12073 Pragma_Linker_Options => -1,
12074 Pragma_Linker_Section => -1,
12076 Pragma_Locking_Policy => -1,
12077 Pragma_Long_Float => -1,
12078 Pragma_Machine_Attribute => -1,
12080 Pragma_Main_Storage => -1,
12081 Pragma_Memory_Size => -1,
12082 Pragma_No_Return => 0,
12083 Pragma_No_Body => 0,
12084 Pragma_No_Run_Time => -1,
12085 Pragma_No_Strict_Aliasing => -1,
12086 Pragma_Normalize_Scalars => -1,
12087 Pragma_Obsolescent => 0,
12088 Pragma_Optimize => -1,
12089 Pragma_Optimize_Alignment => -1,
12092 Pragma_Passive => -1,
12093 Pragma_Preelaborable_Initialization => -1,
12094 Pragma_Polling => -1,
12095 Pragma_Persistent_BSS => 0,
12096 Pragma_Postcondition => -1,
12097 Pragma_Precondition => -1,
12098 Pragma_Preelaborate => -1,
12099 Pragma_Preelaborate_05 => -1,
12100 Pragma_Priority => -1,
12101 Pragma_Priority_Specific_Dispatching => -1,
12102 Pragma_Profile => 0,
12103 Pragma_Profile_Warnings => 0,
12104 Pragma_Propagate_Exceptions => -1,
12105 Pragma_Psect_Object => -1,
12107 Pragma_Pure_05 => -1,
12108 Pragma_Pure_Function => -1,
12109 Pragma_Queuing_Policy => -1,
12110 Pragma_Ravenscar => -1,
12111 Pragma_Relative_Deadline => -1,
12112 Pragma_Remote_Call_Interface => -1,
12113 Pragma_Remote_Types => -1,
12114 Pragma_Restricted_Run_Time => -1,
12115 Pragma_Restriction_Warnings => -1,
12116 Pragma_Restrictions => -1,
12117 Pragma_Reviewable => -1,
12118 Pragma_Share_Generic => -1,
12119 Pragma_Shared => -1,
12120 Pragma_Shared_Passive => -1,
12121 Pragma_Source_File_Name => -1,
12122 Pragma_Source_File_Name_Project => -1,
12123 Pragma_Source_Reference => -1,
12124 Pragma_Storage_Size => -1,
12125 Pragma_Storage_Unit => -1,
12126 Pragma_Static_Elaboration_Desired => -1,
12127 Pragma_Stream_Convert => -1,
12128 Pragma_Style_Checks => -1,
12129 Pragma_Subtitle => -1,
12130 Pragma_Suppress => 0,
12131 Pragma_Suppress_Exception_Locations => 0,
12132 Pragma_Suppress_All => -1,
12133 Pragma_Suppress_Debug_Info => 0,
12134 Pragma_Suppress_Initialization => 0,
12135 Pragma_System_Name => -1,
12136 Pragma_Task_Dispatching_Policy => -1,
12137 Pragma_Task_Info => -1,
12138 Pragma_Task_Name => -1,
12139 Pragma_Task_Storage => 0,
12140 Pragma_Time_Slice => -1,
12141 Pragma_Title => -1,
12142 Pragma_Unchecked_Union => 0,
12143 Pragma_Unimplemented_Unit => -1,
12144 Pragma_Universal_Aliasing => -1,
12145 Pragma_Universal_Data => -1,
12146 Pragma_Unmodified => -1,
12147 Pragma_Unreferenced => -1,
12148 Pragma_Unreferenced_Objects => -1,
12149 Pragma_Unreserve_All_Interrupts => -1,
12150 Pragma_Unsuppress => 0,
12151 Pragma_Use_VADS_Size => -1,
12152 Pragma_Validity_Checks => -1,
12153 Pragma_Volatile => 0,
12154 Pragma_Volatile_Components => 0,
12155 Pragma_Warnings => -1,
12156 Pragma_Weak_External => -1,
12157 Pragma_Wide_Character_Encoding => 0,
12158 Unknown_Pragma => 0);
12160 function Is_Non_Significant_Pragma_Reference (N : Node_Id) return Boolean is
12169 if Nkind (P) /= N_Pragma_Argument_Association then
12173 Id := Get_Pragma_Id (Parent (P));
12174 C := Sig_Flags (Id);
12186 -- For pragma Check, the first argument is not significant,
12187 -- the second and the third (if present) arguments are
12190 when Pragma_Check =>
12192 P = First (Pragma_Argument_Associations (Parent (P)));
12195 raise Program_Error;
12199 A := First (Pragma_Argument_Associations (Parent (P)));
12200 for J in 1 .. C - 1 loop
12208 return A = P; -- is this wrong way round ???
12211 end Is_Non_Significant_Pragma_Reference;
12213 ------------------------------
12214 -- Is_Pragma_String_Literal --
12215 ------------------------------
12217 -- This function returns true if the corresponding pragma argument is
12218 -- a static string expression. These are the only cases in which string
12219 -- literals can appear as pragma arguments. We also allow a string
12220 -- literal as the first argument to pragma Assert (although it will
12221 -- of course always generate a type error).
12223 function Is_Pragma_String_Literal (Par : Node_Id) return Boolean is
12224 Pragn : constant Node_Id := Parent (Par);
12225 Assoc : constant List_Id := Pragma_Argument_Associations (Pragn);
12226 Pname : constant Name_Id := Pragma_Name (Pragn);
12232 N := First (Assoc);
12239 if Pname = Name_Assert then
12242 elsif Pname = Name_Export then
12245 elsif Pname = Name_Ident then
12248 elsif Pname = Name_Import then
12251 elsif Pname = Name_Interface_Name then
12254 elsif Pname = Name_Linker_Alias then
12257 elsif Pname = Name_Linker_Section then
12260 elsif Pname = Name_Machine_Attribute then
12263 elsif Pname = Name_Source_File_Name then
12266 elsif Pname = Name_Source_Reference then
12269 elsif Pname = Name_Title then
12272 elsif Pname = Name_Subtitle then
12278 end Is_Pragma_String_Literal;
12280 --------------------------------------
12281 -- Process_Compilation_Unit_Pragmas --
12282 --------------------------------------
12284 procedure Process_Compilation_Unit_Pragmas (N : Node_Id) is
12286 -- A special check for pragma Suppress_All. This is a strange DEC
12287 -- pragma, strange because it comes at the end of the unit. If we
12288 -- have a pragma Suppress_All in the Pragmas_After of the current
12289 -- unit, then we insert a pragma Suppress (All_Checks) at the start
12290 -- of the context clause to ensure the correct processing.
12293 PA : constant List_Id := Pragmas_After (Aux_Decls_Node (N));
12297 if Present (PA) then
12299 while Present (P) loop
12300 if Pragma_Name (P) = Name_Suppress_All then
12301 Prepend_To (Context_Items (N),
12302 Make_Pragma (Sloc (P),
12303 Chars => Name_Suppress,
12304 Pragma_Argument_Associations => New_List (
12305 Make_Pragma_Argument_Association (Sloc (P),
12307 Make_Identifier (Sloc (P),
12308 Chars => Name_All_Checks)))));
12316 end Process_Compilation_Unit_Pragmas;
12327 --------------------------------
12328 -- Set_Encoded_Interface_Name --
12329 --------------------------------
12331 procedure Set_Encoded_Interface_Name (E : Entity_Id; S : Node_Id) is
12332 Str : constant String_Id := Strval (S);
12333 Len : constant Int := String_Length (Str);
12338 Hex : constant array (0 .. 15) of Character := "0123456789abcdef";
12341 -- Stores encoded value of character code CC. The encoding we
12342 -- use an underscore followed by four lower case hex digits.
12348 procedure Encode is
12350 Store_String_Char (Get_Char_Code ('_'));
12352 (Get_Char_Code (Hex (Integer (CC / 2 ** 12))));
12354 (Get_Char_Code (Hex (Integer (CC / 2 ** 8 and 16#0F#))));
12356 (Get_Char_Code (Hex (Integer (CC / 2 ** 4 and 16#0F#))));
12358 (Get_Char_Code (Hex (Integer (CC and 16#0F#))));
12361 -- Start of processing for Set_Encoded_Interface_Name
12364 -- If first character is asterisk, this is a link name, and we
12365 -- leave it completely unmodified. We also ignore null strings
12366 -- (the latter case happens only in error cases) and no encoding
12367 -- should occur for Java or AAMP interface names.
12370 or else Get_String_Char (Str, 1) = Get_Char_Code ('*')
12371 or else VM_Target /= No_VM
12372 or else AAMP_On_Target
12374 Set_Interface_Name (E, S);
12379 CC := Get_String_Char (Str, J);
12381 exit when not In_Character_Range (CC);
12383 C := Get_Character (CC);
12385 exit when C /= '_' and then C /= '$'
12386 and then C not in '0' .. '9'
12387 and then C not in 'a' .. 'z'
12388 and then C not in 'A' .. 'Z';
12391 Set_Interface_Name (E, S);
12399 -- Here we need to encode. The encoding we use as follows:
12400 -- three underscores + four hex digits (lower case)
12404 for J in 1 .. String_Length (Str) loop
12405 CC := Get_String_Char (Str, J);
12407 if not In_Character_Range (CC) then
12410 C := Get_Character (CC);
12412 if C = '_' or else C = '$'
12413 or else C in '0' .. '9'
12414 or else C in 'a' .. 'z'
12415 or else C in 'A' .. 'Z'
12417 Store_String_Char (CC);
12424 Set_Interface_Name (E,
12425 Make_String_Literal (Sloc (S),
12426 Strval => End_String));
12428 end Set_Encoded_Interface_Name;
12430 -------------------
12431 -- Set_Unit_Name --
12432 -------------------
12434 procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id) is
12439 if Nkind (N) = N_Identifier
12440 and then Nkind (With_Item) = N_Identifier
12442 Set_Entity (N, Entity (With_Item));
12444 elsif Nkind (N) = N_Selected_Component then
12445 Change_Selected_Component_To_Expanded_Name (N);
12446 Set_Entity (N, Entity (With_Item));
12447 Set_Entity (Selector_Name (N), Entity (N));
12449 Pref := Prefix (N);
12450 Scop := Scope (Entity (N));
12451 while Nkind (Pref) = N_Selected_Component loop
12452 Change_Selected_Component_To_Expanded_Name (Pref);
12453 Set_Entity (Selector_Name (Pref), Scop);
12454 Set_Entity (Pref, Scop);
12455 Pref := Prefix (Pref);
12456 Scop := Scope (Scop);
12459 Set_Entity (Pref, Scop);