1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 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; use Namet;
44 with Namet.Sp; use Namet.Sp;
45 with Nlists; use Nlists;
46 with Nmake; use Nmake;
48 with Output; use Output;
49 with Restrict; use Restrict;
50 with Rident; use Rident;
51 with Rtsfind; use Rtsfind;
53 with Sem_Ch3; use Sem_Ch3;
54 with Sem_Ch8; use Sem_Ch8;
55 with Sem_Ch13; use Sem_Ch13;
56 with Sem_Dist; use Sem_Dist;
57 with Sem_Elim; use Sem_Elim;
58 with Sem_Eval; use Sem_Eval;
59 with Sem_Intr; use Sem_Intr;
60 with Sem_Mech; use Sem_Mech;
61 with Sem_Res; use Sem_Res;
62 with Sem_Type; use Sem_Type;
63 with Sem_Util; use Sem_Util;
64 with Sem_VFpt; use Sem_VFpt;
65 with Sem_Warn; use Sem_Warn;
66 with Stand; use Stand;
67 with Sinfo; use Sinfo;
68 with Sinfo.CN; use Sinfo.CN;
69 with Sinput; use Sinput;
70 with Snames; use Snames;
71 with Stringt; use Stringt;
72 with Stylesw; use Stylesw;
74 with Targparm; use Targparm;
75 with Tbuild; use Tbuild;
77 with Uintp; use Uintp;
78 with Urealp; use Urealp;
79 with Validsw; use Validsw;
81 package body Sem_Prag is
83 ----------------------------------------------
84 -- Common Handling of Import-Export Pragmas --
85 ----------------------------------------------
87 -- In the following section, a number of Import_xxx and Export_xxx
88 -- pragmas are defined by GNAT. These are compatible with the DEC
89 -- pragmas of the same name, and all have the following common
90 -- form and processing:
93 -- [Internal =>] LOCAL_NAME
94 -- [, [External =>] EXTERNAL_SYMBOL]
95 -- [, other optional parameters ]);
98 -- [Internal =>] LOCAL_NAME
99 -- [, [External =>] EXTERNAL_SYMBOL]
100 -- [, other optional parameters ]);
102 -- EXTERNAL_SYMBOL ::=
104 -- | static_string_EXPRESSION
106 -- The internal LOCAL_NAME designates the entity that is imported or
107 -- exported, and must refer to an entity in the current declarative
108 -- part (as required by the rules for LOCAL_NAME).
110 -- The external linker name is designated by the External parameter
111 -- if given, or the Internal parameter if not (if there is no External
112 -- parameter, the External parameter is a copy of the Internal name).
114 -- If the External parameter is given as a string, then this string
115 -- is treated as an external name (exactly as though it had been given
116 -- as an External_Name parameter for a normal Import pragma).
118 -- If the External parameter is given as an identifier (or there is no
119 -- External parameter, so that the Internal identifier is used), then
120 -- the external name is the characters of the identifier, translated
121 -- to all upper case letters for OpenVMS versions of GNAT, and to all
122 -- lower case letters for all other versions
124 -- Note: the external name specified or implied by any of these special
125 -- Import_xxx or Export_xxx pragmas override an external or link name
126 -- specified in a previous Import or Export pragma.
128 -- Note: these and all other DEC-compatible GNAT pragmas allow full
129 -- use of named notation, following the standard rules for subprogram
130 -- calls, i.e. parameters can be given in any order if named notation
131 -- is used, and positional and named notation can be mixed, subject to
132 -- the rule that all positional parameters must appear first.
134 -- Note: All these pragmas are implemented exactly following the DEC
135 -- design and implementation and are intended to be fully compatible
136 -- with the use of these pragmas in the DEC Ada compiler.
138 --------------------------------------------
139 -- Checking for Duplicated External Names --
140 --------------------------------------------
142 -- It is suspicious if two separate Export pragmas use the same external
143 -- name. The following table is used to diagnose this situation so that
144 -- an appropriate warning can be issued.
146 -- The Node_Id stored is for the N_String_Literal node created to
147 -- hold the value of the external name. The Sloc of this node is
148 -- used to cross-reference the location of the duplication.
150 package Externals is new Table.Table (
151 Table_Component_Type => Node_Id,
152 Table_Index_Type => Int,
153 Table_Low_Bound => 0,
154 Table_Initial => 100,
155 Table_Increment => 100,
156 Table_Name => "Name_Externals");
158 -------------------------------------
159 -- Local Subprograms and Variables --
160 -------------------------------------
162 function Adjust_External_Name_Case (N : Node_Id) return Node_Id;
163 -- This routine is used for possible casing adjustment of an explicit
164 -- external name supplied as a string literal (the node N), according
165 -- to the casing requirement of Opt.External_Name_Casing. If this is
166 -- set to As_Is, then the string literal is returned unchanged, but if
167 -- it is set to Uppercase or Lowercase, then a new string literal with
168 -- appropriate casing is constructed.
170 function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id;
171 -- If Def_Id refers to a renamed subprogram, then the base subprogram
172 -- (the original one, following the renaming chain) is returned.
173 -- Otherwise the entity is returned unchanged. Should be in Einfo???
176 -- This is a dummy function called by the processing for pragma Reviewable.
177 -- It is there for assisting front end debugging. By placing a Reviewable
178 -- pragma in the source program, a breakpoint on rv catches this place in
179 -- the source, allowing convenient stepping to the point of interest.
181 procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id);
182 -- Place semantic information on the argument of an Elaborate or
183 -- Elaborate_All pragma. Entity name for unit and its parents is
184 -- taken from item in previous with_clause that mentions the unit.
186 -------------------------------
187 -- Adjust_External_Name_Case --
188 -------------------------------
190 function Adjust_External_Name_Case (N : Node_Id) return Node_Id is
194 -- Adjust case of literal if required
196 if Opt.External_Name_Exp_Casing = As_Is then
200 -- Copy existing string
206 for J in 1 .. String_Length (Strval (N)) loop
207 CC := Get_String_Char (Strval (N), J);
209 if Opt.External_Name_Exp_Casing = Uppercase
210 and then CC >= Get_Char_Code ('a')
211 and then CC <= Get_Char_Code ('z')
213 Store_String_Char (CC - 32);
215 elsif Opt.External_Name_Exp_Casing = Lowercase
216 and then CC >= Get_Char_Code ('A')
217 and then CC <= Get_Char_Code ('Z')
219 Store_String_Char (CC + 32);
222 Store_String_Char (CC);
227 Make_String_Literal (Sloc (N),
228 Strval => End_String);
230 end Adjust_External_Name_Case;
236 procedure Analyze_Pragma (N : Node_Id) is
237 Loc : constant Source_Ptr := Sloc (N);
240 Pragma_Exit : exception;
241 -- This exception is used to exit pragma processing completely. It
242 -- is used when an error is detected, and no further processing is
243 -- required. It is also used if an earlier error has left the tree
244 -- in a state where the pragma should not be processed.
247 -- Number of pragma argument associations
253 -- First four pragma arguments (pragma argument association nodes,
254 -- or Empty if the corresponding argument does not exist).
256 type Name_List is array (Natural range <>) of Name_Id;
257 type Args_List is array (Natural range <>) of Node_Id;
258 -- Types used for arguments to Check_Arg_Order and Gather_Associations
260 procedure Ada_2005_Pragma;
261 -- Called for pragmas defined in Ada 2005, that are not in Ada 95. In
262 -- Ada 95 mode, these are implementation defined pragmas, so should be
263 -- caught by the No_Implementation_Pragmas restriction
265 procedure Check_Ada_83_Warning;
266 -- Issues a warning message for the current pragma if operating in Ada
267 -- 83 mode (used for language pragmas that are not a standard part of
268 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
271 procedure Check_Arg_Count (Required : Nat);
272 -- Check argument count for pragma is equal to given parameter.
273 -- If not, then issue an error message and raise Pragma_Exit.
275 -- Note: all routines whose name is Check_Arg_Is_xxx take an
276 -- argument Arg which can either be a pragma argument association,
277 -- in which case the check is applied to the expression of the
278 -- association or an expression directly.
280 procedure Check_Arg_Is_External_Name (Arg : Node_Id);
281 -- Check that an argument has the right form for an EXTERNAL_NAME
282 -- parameter of an extended import/export pragma. The rule is that
283 -- the name must be an identifier or string literal (in Ada 83 mode)
284 -- or a static string expression (in Ada 95 mode).
286 procedure Check_Arg_Is_Identifier (Arg : Node_Id);
287 -- Check the specified argument Arg to make sure that it is an
288 -- identifier. If not give error and raise Pragma_Exit.
290 procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id);
291 -- Check the specified argument Arg to make sure that it is an
292 -- integer literal. If not give error and raise Pragma_Exit.
294 procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id);
295 -- Check the specified argument Arg to make sure that it has the
296 -- proper syntactic form for a local name and meets the semantic
297 -- requirements for a local name. The local name is analyzed as
298 -- part of the processing for this call. In addition, the local
299 -- name is required to represent an entity at the library level.
301 procedure Check_Arg_Is_Local_Name (Arg : Node_Id);
302 -- Check the specified argument Arg to make sure that it has the
303 -- proper syntactic form for a local name and meets the semantic
304 -- requirements for a local name. The local name is analyzed as
305 -- part of the processing for this call.
307 procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id);
308 -- Check the specified argument Arg to make sure that it is a valid
309 -- locking policy name. If not give error and raise Pragma_Exit.
311 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id);
312 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2, N3 : Name_Id);
313 -- Check the specified argument Arg to make sure that it is an
314 -- identifier whose name matches either N1 or N2 (or N3 if present).
315 -- If not then give error and raise Pragma_Exit.
317 procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id);
318 -- Check the specified argument Arg to make sure that it is a valid
319 -- queuing policy name. If not give error and raise Pragma_Exit.
321 procedure Check_Arg_Is_Static_Expression
324 -- Check the specified argument Arg to make sure that it is a static
325 -- expression of the given type (i.e. it will be analyzed and resolved
326 -- using this type, which can be any valid argument to Resolve, e.g.
327 -- Any_Integer is OK). If not, given error and raise Pragma_Exit.
329 procedure Check_Arg_Is_String_Literal (Arg : Node_Id);
330 -- Check the specified argument Arg to make sure that it is a
331 -- string literal. If not give error and raise Pragma_Exit
333 procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id);
334 -- Check the specified argument Arg to make sure that it is a valid
335 -- valid task dispatching policy name. If not give error and raise
338 procedure Check_Arg_Order (Names : Name_List);
339 -- Checks for an instance of two arguments with identifiers for the
340 -- current pragma which are not in the sequence indicated by Names,
341 -- and if so, generates a fatal message about bad order of arguments.
343 procedure Check_At_Least_N_Arguments (N : Nat);
344 -- Check there are at least N arguments present
346 procedure Check_At_Most_N_Arguments (N : Nat);
347 -- Check there are no more than N arguments present
349 procedure Check_Component (Comp : Node_Id);
350 -- Examine Unchecked_Union component for correct use of per-object
351 -- constrained subtypes, and for restrictions on finalizable components.
353 procedure Check_Duplicated_Export_Name (Nam : Node_Id);
354 -- Nam is an N_String_Literal node containing the external name set
355 -- by an Import or Export pragma (or extended Import or Export pragma).
356 -- This procedure checks for possible duplications if this is the
357 -- export case, and if found, issues an appropriate error message.
359 procedure Check_First_Subtype (Arg : Node_Id);
360 -- Checks that Arg, whose expression is an entity name referencing
361 -- a subtype, does not reference a type that is not a first subtype.
363 procedure Check_In_Main_Program;
364 -- Common checks for pragmas that appear within a main program
365 -- (Priority, Main_Storage, Time_Slice).
367 procedure Check_Interrupt_Or_Attach_Handler;
368 -- Common processing for first argument of pragma Interrupt_Handler
369 -- or pragma Attach_Handler.
371 procedure Check_Is_In_Decl_Part_Or_Package_Spec;
372 -- Check that pragma appears in a declarative part, or in a package
373 -- specification, i.e. that it does not occur in a statement sequence
376 procedure Check_No_Identifier (Arg : Node_Id);
377 -- Checks that the given argument does not have an identifier. If
378 -- an identifier is present, then an error message is issued, and
379 -- Pragma_Exit is raised.
381 procedure Check_No_Identifiers;
382 -- Checks that none of the arguments to the pragma has an identifier.
383 -- If any argument has an identifier, then an error message is issued,
384 -- and Pragma_Exit is raised.
386 procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id);
387 -- Checks if the given argument has an identifier, and if so, requires
388 -- it to match the given identifier name. If there is a non-matching
389 -- identifier, then an error message is given and Error_Pragmas raised.
391 procedure Check_Optional_Identifier (Arg : Node_Id; Id : String);
392 -- Checks if the given argument has an identifier, and if so, requires
393 -- it to match the given identifier name. If there is a non-matching
394 -- identifier, then an error message is given and Error_Pragmas raised.
395 -- In this version of the procedure, the identifier name is given as
396 -- a string with lower case letters.
398 procedure Check_Static_Constraint (Constr : Node_Id);
399 -- Constr is a constraint from an N_Subtype_Indication node from a
400 -- component constraint in an Unchecked_Union type. This routine checks
401 -- that the constraint is static as required by the restrictions for
404 procedure Check_Valid_Configuration_Pragma;
405 -- Legality checks for placement of a configuration pragma
407 procedure Check_Valid_Library_Unit_Pragma;
408 -- Legality checks for library unit pragmas. A special case arises for
409 -- pragmas in generic instances that come from copies of the original
410 -- library unit pragmas in the generic templates. In the case of other
411 -- than library level instantiations these can appear in contexts which
412 -- would normally be invalid (they only apply to the original template
413 -- and to library level instantiations), and they are simply ignored,
414 -- which is implemented by rewriting them as null statements.
416 procedure Check_Variant (Variant : Node_Id);
417 -- Check Unchecked_Union variant for lack of nested variants and
418 -- presence of at least one component.
420 procedure Error_Pragma (Msg : String);
421 pragma No_Return (Error_Pragma);
422 -- Outputs error message for current pragma. The message contains a %
423 -- that will be replaced with the pragma name, and the flag is placed
424 -- on the pragma itself. Pragma_Exit is then raised.
426 procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id);
427 pragma No_Return (Error_Pragma_Arg);
428 -- Outputs error message for current pragma. The message may contain
429 -- a % that will be replaced with the pragma name. The parameter Arg
430 -- may either be a pragma argument association, in which case the flag
431 -- is placed on the expression of this association, or an expression,
432 -- in which case the flag is placed directly on the expression. The
433 -- message is placed using Error_Msg_N, so the message may also contain
434 -- an & insertion character which will reference the given Arg value.
435 -- After placing the message, Pragma_Exit is raised.
437 procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id);
438 pragma No_Return (Error_Pragma_Arg);
439 -- Similar to above form of Error_Pragma_Arg except that two messages
440 -- are provided, the second is a continuation comment starting with \.
442 procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id);
443 pragma No_Return (Error_Pragma_Arg_Ident);
444 -- Outputs error message for current pragma. The message may contain
445 -- a % that will be replaced with the pragma name. The parameter Arg
446 -- must be a pragma argument association with a non-empty identifier
447 -- (i.e. its Chars field must be set), and the error message is placed
448 -- on the identifier. The message is placed using Error_Msg_N so
449 -- the message may also contain an & insertion character which will
450 -- reference the identifier. After placing the message, Pragma_Exit
453 function Find_Lib_Unit_Name return Entity_Id;
454 -- Used for a library unit pragma to find the entity to which the
455 -- library unit pragma applies, returns the entity found.
457 procedure Find_Program_Unit_Name (Id : Node_Id);
458 -- If the pragma is a compilation unit pragma, the id must denote the
459 -- compilation unit in the same compilation, and the pragma must appear
460 -- in the list of preceding or trailing pragmas. If it is a program
461 -- unit pragma that is not a compilation unit pragma, then the
462 -- identifier must be visible.
464 function Find_Unique_Parameterless_Procedure
466 Arg : Node_Id) return Entity_Id;
467 -- Used for a procedure pragma to find the unique parameterless
468 -- procedure identified by Name, returns it if it exists, otherwise
469 -- errors out and uses Arg as the pragma argument for the message.
471 procedure Gather_Associations
473 Args : out Args_List);
474 -- This procedure is used to gather the arguments for a pragma that
475 -- permits arbitrary ordering of parameters using the normal rules
476 -- for named and positional parameters. The Names argument is a list
477 -- of Name_Id values that corresponds to the allowed pragma argument
478 -- association identifiers in order. The result returned in Args is
479 -- a list of corresponding expressions that are the pragma arguments.
480 -- Note that this is a list of expressions, not of pragma argument
481 -- associations (Gather_Associations has completely checked all the
482 -- optional identifiers when it returns). An entry in Args is Empty
483 -- on return if the corresponding argument is not present.
485 function Get_Pragma_Arg (Arg : Node_Id) return Node_Id;
486 -- All the routines that check pragma arguments take either a pragma
487 -- argument association (in which case the expression of the argument
488 -- association is checked), or the expression directly. The function
489 -- Get_Pragma_Arg is a utility used to deal with these two cases. If
490 -- Arg is a pragma argument association node, then its expression is
491 -- returned, otherwise Arg is returned unchanged.
493 procedure GNAT_Pragma;
494 -- Called for all GNAT defined pragmas to check the relevant restriction
495 -- (No_Implementation_Pragmas).
497 function Is_Before_First_Decl
498 (Pragma_Node : Node_Id;
499 Decls : List_Id) return Boolean;
500 -- Return True if Pragma_Node is before the first declarative item in
501 -- Decls where Decls is the list of declarative items.
503 function Is_Configuration_Pragma return Boolean;
504 -- Deterermines if the placement of the current pragma is appropriate
505 -- for a configuration pragma (precedes the current compilation unit).
507 function Is_In_Context_Clause return Boolean;
508 -- Returns True if pragma appears within the context clause of a unit,
509 -- and False for any other placement (does not generate any messages).
511 function Is_Static_String_Expression (Arg : Node_Id) return Boolean;
512 -- Analyzes the argument, and determines if it is a static string
513 -- expression, returns True if so, False if non-static or not String.
515 procedure Pragma_Misplaced;
516 -- Issue fatal error message for misplaced pragma
518 procedure Process_Atomic_Shared_Volatile;
519 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
520 -- Shared is an obsolete Ada 83 pragma, treated as being identical
521 -- in effect to pragma Atomic.
523 procedure Process_Compile_Time_Warning_Or_Error;
524 -- Common processing for Compile_Time_Error and Compile_Time_Warning
526 procedure Process_Convention (C : out Convention_Id; E : out Entity_Id);
527 -- Common procesing for Convention, Interface, Import and Export.
528 -- Checks first two arguments of pragma, and sets the appropriate
529 -- convention value in the specified entity or entities. On return
530 -- C is the convention, E is the referenced entity.
532 procedure Process_Extended_Import_Export_Exception_Pragma
533 (Arg_Internal : Node_Id;
534 Arg_External : Node_Id;
537 -- Common processing for the pragmas Import/Export_Exception.
538 -- The three arguments correspond to the three named parameters of
539 -- the pragma. An argument is empty if the corresponding parameter
540 -- is not present in the pragma.
542 procedure Process_Extended_Import_Export_Object_Pragma
543 (Arg_Internal : Node_Id;
544 Arg_External : Node_Id;
546 -- Common processing for the pragmass Import/Export_Object.
547 -- The three arguments correspond to the three named parameters
548 -- of the pragmas. An argument is empty if the corresponding
549 -- parameter is not present in the pragma.
551 procedure Process_Extended_Import_Export_Internal_Arg
552 (Arg_Internal : Node_Id := Empty);
553 -- Common processing for all extended Import and Export pragmas. The
554 -- argument is the pragma parameter for the Internal argument. If
555 -- Arg_Internal is empty or inappropriate, an error message is posted.
556 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
557 -- set to identify the referenced entity.
559 procedure Process_Extended_Import_Export_Subprogram_Pragma
560 (Arg_Internal : Node_Id;
561 Arg_External : Node_Id;
562 Arg_Parameter_Types : Node_Id;
563 Arg_Result_Type : Node_Id := Empty;
564 Arg_Mechanism : Node_Id;
565 Arg_Result_Mechanism : Node_Id := Empty;
566 Arg_First_Optional_Parameter : Node_Id := Empty);
567 -- Common processing for all extended Import and Export pragmas
568 -- applying to subprograms. The caller omits any arguments that do
569 -- bnot apply to the pragma in question (for example, Arg_Result_Type
570 -- can be non-Empty only in the Import_Function and Export_Function
571 -- cases). The argument names correspond to the allowed pragma
572 -- association identifiers.
574 procedure Process_Generic_List;
575 -- Common processing for Share_Generic and Inline_Generic
577 procedure Process_Import_Or_Interface;
578 -- Common processing for Import of Interface
580 procedure Process_Inline (Active : Boolean);
581 -- Common processing for Inline and Inline_Always. The parameter
582 -- indicates if the inline pragma is active, i.e. if it should
583 -- actually cause inlining to occur.
585 procedure Process_Interface_Name
586 (Subprogram_Def : Entity_Id;
589 -- Given the last two arguments of pragma Import, pragma Export, or
590 -- pragma Interface_Name, performs validity checks and sets the
591 -- Interface_Name field of the given subprogram entity to the
592 -- appropriate external or link name, depending on the arguments
593 -- given. Ext_Arg is always present, but Link_Arg may be missing.
594 -- Note that Ext_Arg may represent the Link_Name if Link_Arg is
595 -- missing, and appropriate named notation is used for Ext_Arg.
596 -- If neither Ext_Arg nor Link_Arg is present, the interface name
597 -- is set to the default from the subprogram name.
599 procedure Process_Interrupt_Or_Attach_Handler;
600 -- Common processing for Interrupt and Attach_Handler pragmas
602 procedure Process_Restrictions_Or_Restriction_Warnings (Warn : Boolean);
603 -- Common processing for Restrictions and Restriction_Warnings pragmas.
604 -- Warn is False for Restrictions, True for Restriction_Warnings.
606 procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean);
607 -- Common processing for Suppress and Unsuppress. The boolean parameter
608 -- Suppress_Case is True for the Suppress case, and False for the
611 procedure Set_Exported (E : Entity_Id; Arg : Node_Id);
612 -- This procedure sets the Is_Exported flag for the given entity,
613 -- checking that the entity was not previously imported. Arg is
614 -- the argument that specified the entity. A check is also made
615 -- for exporting inappropriate entities.
617 procedure Set_Extended_Import_Export_External_Name
618 (Internal_Ent : Entity_Id;
619 Arg_External : Node_Id);
620 -- Common processing for all extended import export pragmas. The first
621 -- argument, Internal_Ent, is the internal entity, which has already
622 -- been checked for validity by the caller. Arg_External is from the
623 -- Import or Export pragma, and may be null if no External parameter
624 -- was present. If Arg_External is present and is a non-null string
625 -- (a null string is treated as the default), then the Interface_Name
626 -- field of Internal_Ent is set appropriately.
628 procedure Set_Imported (E : Entity_Id);
629 -- This procedure sets the Is_Imported flag for the given entity,
630 -- checking that it is not previously exported or imported.
632 procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id);
633 -- Mech is a parameter passing mechanism (see Import_Function syntax
634 -- for MECHANISM_NAME). This routine checks that the mechanism argument
635 -- has the right form, and if not issues an error message. If the
636 -- argument has the right form then the Mechanism field of Ent is
637 -- set appropriately.
639 procedure Set_Ravenscar_Profile (N : Node_Id);
640 -- Activate the set of configuration pragmas and restrictions that
641 -- make up the Ravenscar Profile. N is the corresponding pragma
642 -- node, which is used for error messages on any constructs
643 -- that violate the profile.
645 ---------------------
646 -- Ada_2005_Pragma --
647 ---------------------
649 procedure Ada_2005_Pragma is
651 if Ada_Version <= Ada_95 then
652 Check_Restriction (No_Implementation_Pragmas, N);
656 --------------------------
657 -- Check_Ada_83_Warning --
658 --------------------------
660 procedure Check_Ada_83_Warning is
662 if Ada_Version = Ada_83 and then Comes_From_Source (N) then
663 Error_Msg_N ("(Ada 83) pragma& is non-standard?", N);
665 end Check_Ada_83_Warning;
667 ---------------------
668 -- Check_Arg_Count --
669 ---------------------
671 procedure Check_Arg_Count (Required : Nat) is
673 if Arg_Count /= Required then
674 Error_Pragma ("wrong number of arguments for pragma%");
678 --------------------------------
679 -- Check_Arg_Is_External_Name --
680 --------------------------------
682 procedure Check_Arg_Is_External_Name (Arg : Node_Id) is
683 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
686 if Nkind (Argx) = N_Identifier then
690 Analyze_And_Resolve (Argx, Standard_String);
692 if Is_OK_Static_Expression (Argx) then
695 elsif Etype (Argx) = Any_Type then
698 -- An interesting special case, if we have a string literal and
699 -- we are in Ada 83 mode, then we allow it even though it will
700 -- not be flagged as static. This allows expected Ada 83 mode
701 -- use of external names which are string literals, even though
702 -- technically these are not static in Ada 83.
704 elsif Ada_Version = Ada_83
705 and then Nkind (Argx) = N_String_Literal
709 -- Static expression that raises Constraint_Error. This has
710 -- already been flagged, so just exit from pragma processing.
712 elsif Is_Static_Expression (Argx) then
715 -- Here we have a real error (non-static expression)
718 Error_Msg_Name_1 := Chars (N);
720 ("argument for pragma% must be a identifier or " &
721 "static string expression!", Argx);
725 end Check_Arg_Is_External_Name;
727 -----------------------------
728 -- Check_Arg_Is_Identifier --
729 -----------------------------
731 procedure Check_Arg_Is_Identifier (Arg : Node_Id) is
732 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
734 if Nkind (Argx) /= N_Identifier then
736 ("argument for pragma% must be identifier", Argx);
738 end Check_Arg_Is_Identifier;
740 ----------------------------------
741 -- Check_Arg_Is_Integer_Literal --
742 ----------------------------------
744 procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id) is
745 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
747 if Nkind (Argx) /= N_Integer_Literal then
749 ("argument for pragma% must be integer literal", Argx);
751 end Check_Arg_Is_Integer_Literal;
753 -------------------------------------------
754 -- Check_Arg_Is_Library_Level_Local_Name --
755 -------------------------------------------
759 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
760 -- | library_unit_NAME
762 procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id) is
764 Check_Arg_Is_Local_Name (Arg);
766 if not Is_Library_Level_Entity (Entity (Expression (Arg)))
767 and then Comes_From_Source (N)
770 ("argument for pragma% must be library level entity", Arg);
772 end Check_Arg_Is_Library_Level_Local_Name;
774 -----------------------------
775 -- Check_Arg_Is_Local_Name --
776 -----------------------------
780 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
781 -- | library_unit_NAME
783 procedure Check_Arg_Is_Local_Name (Arg : Node_Id) is
784 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
789 if Nkind (Argx) not in N_Direct_Name
790 and then (Nkind (Argx) /= N_Attribute_Reference
791 or else Present (Expressions (Argx))
792 or else Nkind (Prefix (Argx)) /= N_Identifier)
793 and then (not Is_Entity_Name (Argx)
794 or else not Is_Compilation_Unit (Entity (Argx)))
796 Error_Pragma_Arg ("argument for pragma% must be local name", Argx);
799 if Is_Entity_Name (Argx)
800 and then Scope (Entity (Argx)) /= Current_Scope
803 ("pragma% argument must be in same declarative part", Arg);
805 end Check_Arg_Is_Local_Name;
807 ---------------------------------
808 -- Check_Arg_Is_Locking_Policy --
809 ---------------------------------
811 procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id) is
812 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
815 Check_Arg_Is_Identifier (Argx);
817 if not Is_Locking_Policy_Name (Chars (Argx)) then
819 ("& is not a valid locking policy name", Argx);
821 end Check_Arg_Is_Locking_Policy;
823 -------------------------
824 -- Check_Arg_Is_One_Of --
825 -------------------------
827 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id) is
828 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
831 Check_Arg_Is_Identifier (Argx);
833 if Chars (Argx) /= N1 and then Chars (Argx) /= N2 then
834 Error_Msg_Name_2 := N1;
835 Error_Msg_Name_3 := N2;
836 Error_Pragma_Arg ("argument for pragma% must be% or%", Argx);
838 end Check_Arg_Is_One_Of;
840 procedure Check_Arg_Is_One_Of
842 N1, N2, N3 : Name_Id)
844 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
847 Check_Arg_Is_Identifier (Argx);
849 if Chars (Argx) /= N1
850 and then Chars (Argx) /= N2
851 and then Chars (Argx) /= N3
853 Error_Pragma_Arg ("invalid argument for pragma%", Argx);
855 end Check_Arg_Is_One_Of;
857 ---------------------------------
858 -- Check_Arg_Is_Queuing_Policy --
859 ---------------------------------
861 procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id) is
862 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
865 Check_Arg_Is_Identifier (Argx);
867 if not Is_Queuing_Policy_Name (Chars (Argx)) then
869 ("& is not a valid queuing policy name", Argx);
871 end Check_Arg_Is_Queuing_Policy;
873 ------------------------------------
874 -- Check_Arg_Is_Static_Expression --
875 ------------------------------------
877 procedure Check_Arg_Is_Static_Expression
881 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
884 Analyze_And_Resolve (Argx, Typ);
886 if Is_OK_Static_Expression (Argx) then
889 elsif Etype (Argx) = Any_Type then
892 -- An interesting special case, if we have a string literal and
893 -- we are in Ada 83 mode, then we allow it even though it will
894 -- not be flagged as static. This allows the use of Ada 95
895 -- pragmas like Import in Ada 83 mode. They will of course be
896 -- flagged with warnings as usual, but will not cause errors.
898 elsif Ada_Version = Ada_83
899 and then Nkind (Argx) = N_String_Literal
903 -- Static expression that raises Constraint_Error. This has
904 -- already been flagged, so just exit from pragma processing.
906 elsif Is_Static_Expression (Argx) then
909 -- Finally, we have a real error
912 Error_Msg_Name_1 := Chars (N);
914 ("argument for pragma% must be a static expression!", Argx);
917 end Check_Arg_Is_Static_Expression;
919 ---------------------------------
920 -- Check_Arg_Is_String_Literal --
921 ---------------------------------
923 procedure Check_Arg_Is_String_Literal (Arg : Node_Id) is
924 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
926 if Nkind (Argx) /= N_String_Literal then
928 ("argument for pragma% must be string literal", Argx);
930 end Check_Arg_Is_String_Literal;
932 ------------------------------------------
933 -- Check_Arg_Is_Task_Dispatching_Policy --
934 ------------------------------------------
936 procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id) is
937 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
940 Check_Arg_Is_Identifier (Argx);
942 if not Is_Task_Dispatching_Policy_Name (Chars (Argx)) then
944 ("& is not a valid task dispatching policy name", Argx);
946 end Check_Arg_Is_Task_Dispatching_Policy;
948 ---------------------
949 -- Check_Arg_Order --
950 ---------------------
952 procedure Check_Arg_Order (Names : Name_List) is
955 Highest_So_Far : Natural := 0;
956 -- Highest index in Names seen do far
960 for J in 1 .. Arg_Count loop
961 if Chars (Arg) /= No_Name then
962 for K in Names'Range loop
963 if Chars (Arg) = Names (K) then
964 if K < Highest_So_Far then
965 Error_Msg_Name_1 := Chars (N);
967 ("parameters out of order for pragma%", Arg);
968 Error_Msg_Name_1 := Names (K);
969 Error_Msg_Name_2 := Names (Highest_So_Far);
970 Error_Msg_N ("\% must appear before %", Arg);
984 --------------------------------
985 -- Check_At_Least_N_Arguments --
986 --------------------------------
988 procedure Check_At_Least_N_Arguments (N : Nat) is
990 if Arg_Count < N then
991 Error_Pragma ("too few arguments for pragma%");
993 end Check_At_Least_N_Arguments;
995 -------------------------------
996 -- Check_At_Most_N_Arguments --
997 -------------------------------
999 procedure Check_At_Most_N_Arguments (N : Nat) is
1002 if Arg_Count > N then
1004 for J in 1 .. N loop
1006 Error_Pragma_Arg ("too many arguments for pragma%", Arg);
1009 end Check_At_Most_N_Arguments;
1011 ---------------------
1012 -- Check_Component --
1013 ---------------------
1015 procedure Check_Component (Comp : Node_Id) is
1017 if Nkind (Comp) = N_Component_Declaration then
1019 Sindic : constant Node_Id :=
1020 Subtype_Indication (Component_Definition (Comp));
1021 Typ : constant Entity_Id :=
1022 Etype (Defining_Identifier (Comp));
1024 if Nkind (Sindic) = N_Subtype_Indication then
1026 -- Ada 2005 (AI-216): If a component subtype is subject to
1027 -- a per-object constraint, then the component type shall
1028 -- be an Unchecked_Union.
1030 if Has_Per_Object_Constraint (Defining_Identifier (Comp))
1032 not Is_Unchecked_Union (Etype (Subtype_Mark (Sindic)))
1034 Error_Msg_N ("component subtype subject to per-object" &
1035 " constraint must be an Unchecked_Union", Comp);
1039 if Is_Controlled (Typ) then
1041 ("component of unchecked union cannot be controlled", Comp);
1043 elsif Has_Task (Typ) then
1045 ("component of unchecked union cannot have tasks", Comp);
1049 end Check_Component;
1051 ----------------------------------
1052 -- Check_Duplicated_Export_Name --
1053 ----------------------------------
1055 procedure Check_Duplicated_Export_Name (Nam : Node_Id) is
1056 String_Val : constant String_Id := Strval (Nam);
1059 -- We are only interested in the export case, and in the case of
1060 -- generics, it is the instance, not the template, that is the
1061 -- problem (the template will generate a warning in any case).
1063 if not Inside_A_Generic
1064 and then (Prag_Id = Pragma_Export
1066 Prag_Id = Pragma_Export_Procedure
1068 Prag_Id = Pragma_Export_Valued_Procedure
1070 Prag_Id = Pragma_Export_Function)
1072 for J in Externals.First .. Externals.Last loop
1073 if String_Equal (String_Val, Strval (Externals.Table (J))) then
1074 Error_Msg_Sloc := Sloc (Externals.Table (J));
1075 Error_Msg_N ("external name duplicates name given#", Nam);
1080 Externals.Append (Nam);
1082 end Check_Duplicated_Export_Name;
1084 -------------------------
1085 -- Check_First_Subtype --
1086 -------------------------
1088 procedure Check_First_Subtype (Arg : Node_Id) is
1089 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1091 if not Is_First_Subtype (Entity (Argx)) then
1093 ("pragma% cannot apply to subtype", Argx);
1095 end Check_First_Subtype;
1097 ---------------------------
1098 -- Check_In_Main_Program --
1099 ---------------------------
1101 procedure Check_In_Main_Program is
1102 P : constant Node_Id := Parent (N);
1105 -- Must be at in subprogram body
1107 if Nkind (P) /= N_Subprogram_Body then
1108 Error_Pragma ("% pragma allowed only in subprogram");
1110 -- Otherwise warn if obviously not main program
1112 elsif Present (Parameter_Specifications (Specification (P)))
1113 or else not Is_Compilation_Unit (Defining_Entity (P))
1115 Error_Msg_Name_1 := Chars (N);
1117 ("?pragma% is only effective in main program", N);
1119 end Check_In_Main_Program;
1121 ---------------------------------------
1122 -- Check_Interrupt_Or_Attach_Handler --
1123 ---------------------------------------
1125 procedure Check_Interrupt_Or_Attach_Handler is
1126 Arg1_X : constant Node_Id := Expression (Arg1);
1127 Handler_Proc, Proc_Scope : Entity_Id;
1132 if Prag_Id = Pragma_Interrupt_Handler then
1133 Check_Restriction (No_Dynamic_Attachment, N);
1136 Handler_Proc := Find_Unique_Parameterless_Procedure (Arg1_X, Arg1);
1137 Proc_Scope := Scope (Handler_Proc);
1139 -- On AAMP only, a pragma Interrupt_Handler is supported for
1140 -- nonprotected parameterless procedures.
1142 if not AAMP_On_Target
1143 or else Prag_Id = Pragma_Attach_Handler
1145 if Ekind (Proc_Scope) /= E_Protected_Type then
1147 ("argument of pragma% must be protected procedure", Arg1);
1150 if Parent (N) /= Protected_Definition (Parent (Proc_Scope)) then
1151 Error_Pragma ("pragma% must be in protected definition");
1155 if not Is_Library_Level_Entity (Proc_Scope)
1156 or else (AAMP_On_Target
1157 and then not Is_Library_Level_Entity (Handler_Proc))
1160 ("argument for pragma% must be library level entity", Arg1);
1162 end Check_Interrupt_Or_Attach_Handler;
1164 -------------------------------------------
1165 -- Check_Is_In_Decl_Part_Or_Package_Spec --
1166 -------------------------------------------
1168 procedure Check_Is_In_Decl_Part_Or_Package_Spec is
1177 elsif Nkind (P) = N_Handled_Sequence_Of_Statements then
1180 elsif Nkind (P) = N_Package_Specification then
1183 elsif Nkind (P) = N_Block_Statement then
1186 -- Note: the following tests seem a little peculiar, because
1187 -- they test for bodies, but if we were in the statement part
1188 -- of the body, we would already have hit the handled statement
1189 -- sequence, so the only way we get here is by being in the
1190 -- declarative part of the body.
1192 elsif Nkind (P) = N_Subprogram_Body
1193 or else Nkind (P) = N_Package_Body
1194 or else Nkind (P) = N_Task_Body
1195 or else Nkind (P) = N_Entry_Body
1203 Error_Pragma ("pragma% is not in declarative part or package spec");
1204 end Check_Is_In_Decl_Part_Or_Package_Spec;
1206 -------------------------
1207 -- Check_No_Identifier --
1208 -------------------------
1210 procedure Check_No_Identifier (Arg : Node_Id) is
1212 if Chars (Arg) /= No_Name then
1213 Error_Pragma_Arg_Ident
1214 ("pragma% does not permit identifier& here", Arg);
1216 end Check_No_Identifier;
1218 --------------------------
1219 -- Check_No_Identifiers --
1220 --------------------------
1222 procedure Check_No_Identifiers is
1225 if Arg_Count > 0 then
1227 while Present (Arg_Node) loop
1228 Check_No_Identifier (Arg_Node);
1232 end Check_No_Identifiers;
1234 -------------------------------
1235 -- Check_Optional_Identifier --
1236 -------------------------------
1238 procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id) is
1240 if Present (Arg) and then Chars (Arg) /= No_Name then
1241 if Chars (Arg) /= Id then
1242 Error_Msg_Name_1 := Chars (N);
1243 Error_Msg_Name_2 := Id;
1244 Error_Msg_N ("pragma% argument expects identifier%", Arg);
1248 end Check_Optional_Identifier;
1250 procedure Check_Optional_Identifier (Arg : Node_Id; Id : String) is
1252 Name_Buffer (1 .. Id'Length) := Id;
1253 Name_Len := Id'Length;
1254 Check_Optional_Identifier (Arg, Name_Find);
1255 end Check_Optional_Identifier;
1257 -----------------------------
1258 -- Check_Static_Constraint --
1259 -----------------------------
1261 -- Note: for convenience in writing this procedure, in addition to
1262 -- the officially (i.e. by spec) allowed argument which is always
1263 -- a constraint, it also allows ranges and discriminant associations.
1264 -- Above is not clear ???
1266 procedure Check_Static_Constraint (Constr : Node_Id) is
1268 --------------------
1269 -- Require_Static --
1270 --------------------
1272 procedure Require_Static (E : Node_Id);
1273 -- Require given expression to be static expression
1275 procedure Require_Static (E : Node_Id) is
1277 if not Is_OK_Static_Expression (E) then
1278 Flag_Non_Static_Expr
1279 ("non-static constraint not allowed in Unchecked_Union!", E);
1284 -- Start of processing for Check_Static_Constraint
1287 case Nkind (Constr) is
1288 when N_Discriminant_Association =>
1289 Require_Static (Expression (Constr));
1292 Require_Static (Low_Bound (Constr));
1293 Require_Static (High_Bound (Constr));
1295 when N_Attribute_Reference =>
1296 Require_Static (Type_Low_Bound (Etype (Prefix (Constr))));
1297 Require_Static (Type_High_Bound (Etype (Prefix (Constr))));
1299 when N_Range_Constraint =>
1300 Check_Static_Constraint (Range_Expression (Constr));
1302 when N_Index_Or_Discriminant_Constraint =>
1306 IDC := First (Constraints (Constr));
1307 while Present (IDC) loop
1308 Check_Static_Constraint (IDC);
1316 end Check_Static_Constraint;
1318 --------------------------------------
1319 -- Check_Valid_Configuration_Pragma --
1320 --------------------------------------
1322 -- A configuration pragma must appear in the context clause of
1323 -- a compilation unit, at the start of the list (i.e. only other
1324 -- pragmas may precede it).
1326 procedure Check_Valid_Configuration_Pragma is
1328 if not Is_Configuration_Pragma then
1329 Error_Pragma ("incorrect placement for configuration pragma%");
1331 end Check_Valid_Configuration_Pragma;
1333 -------------------------------------
1334 -- Check_Valid_Library_Unit_Pragma --
1335 -------------------------------------
1337 procedure Check_Valid_Library_Unit_Pragma is
1339 Parent_Node : Node_Id;
1340 Unit_Name : Entity_Id;
1341 Unit_Kind : Node_Kind;
1342 Unit_Node : Node_Id;
1343 Sindex : Source_File_Index;
1346 if not Is_List_Member (N) then
1350 Plist := List_Containing (N);
1351 Parent_Node := Parent (Plist);
1353 if Parent_Node = Empty then
1356 -- Case of pragma appearing after a compilation unit. In this
1357 -- case it must have an argument with the corresponding name
1358 -- and must be part of the following pragmas of its parent.
1360 elsif Nkind (Parent_Node) = N_Compilation_Unit_Aux then
1361 if Plist /= Pragmas_After (Parent_Node) then
1364 elsif Arg_Count = 0 then
1366 ("argument required if outside compilation unit");
1369 Check_No_Identifiers;
1370 Check_Arg_Count (1);
1371 Unit_Node := Unit (Parent (Parent_Node));
1372 Unit_Kind := Nkind (Unit_Node);
1374 Analyze (Expression (Arg1));
1376 if Unit_Kind = N_Generic_Subprogram_Declaration
1377 or else Unit_Kind = N_Subprogram_Declaration
1379 Unit_Name := Defining_Entity (Unit_Node);
1381 elsif Unit_Kind in N_Generic_Instantiation then
1382 Unit_Name := Defining_Entity (Unit_Node);
1385 Unit_Name := Cunit_Entity (Current_Sem_Unit);
1388 if Chars (Unit_Name) /=
1389 Chars (Entity (Expression (Arg1)))
1392 ("pragma% argument is not current unit name", Arg1);
1395 if Ekind (Unit_Name) = E_Package
1396 and then Present (Renamed_Entity (Unit_Name))
1398 Error_Pragma ("pragma% not allowed for renamed package");
1402 -- Pragma appears other than after a compilation unit
1405 -- Here we check for the generic instantiation case and also
1406 -- for the case of processing a generic formal package. We
1407 -- detect these cases by noting that the Sloc on the node
1408 -- does not belong to the current compilation unit.
1410 Sindex := Source_Index (Current_Sem_Unit);
1412 if Loc not in Source_First (Sindex) .. Source_Last (Sindex) then
1413 Rewrite (N, Make_Null_Statement (Loc));
1416 -- If before first declaration, the pragma applies to the
1417 -- enclosing unit, and the name if present must be this name.
1419 elsif Is_Before_First_Decl (N, Plist) then
1420 Unit_Node := Unit_Declaration_Node (Current_Scope);
1421 Unit_Kind := Nkind (Unit_Node);
1423 if Nkind (Parent (Unit_Node)) /= N_Compilation_Unit then
1426 elsif Unit_Kind = N_Subprogram_Body
1427 and then not Acts_As_Spec (Unit_Node)
1431 elsif Nkind (Parent_Node) = N_Package_Body then
1434 elsif Nkind (Parent_Node) = N_Package_Specification
1435 and then Plist = Private_Declarations (Parent_Node)
1439 elsif (Nkind (Parent_Node) = N_Generic_Package_Declaration
1440 or else Nkind (Parent_Node) =
1441 N_Generic_Subprogram_Declaration)
1442 and then Plist = Generic_Formal_Declarations (Parent_Node)
1446 elsif Arg_Count > 0 then
1447 Analyze (Expression (Arg1));
1449 if Entity (Expression (Arg1)) /= Current_Scope then
1451 ("name in pragma% must be enclosing unit", Arg1);
1454 -- It is legal to have no argument in this context
1460 -- Error if not before first declaration. This is because a
1461 -- library unit pragma argument must be the name of a library
1462 -- unit (RM 10.1.5(7)), but the only names permitted in this
1463 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1464 -- generic subprogram declarations or generic instantiations.
1468 ("pragma% misplaced, must be before first declaration");
1472 end Check_Valid_Library_Unit_Pragma;
1478 procedure Check_Variant (Variant : Node_Id) is
1479 Clist : constant Node_Id := Component_List (Variant);
1483 if not Is_Non_Empty_List (Component_Items (Clist)) then
1485 ("Unchecked_Union may not have empty component list",
1490 Comp := First (Component_Items (Clist));
1491 while Present (Comp) loop
1492 Check_Component (Comp);
1501 procedure Error_Pragma (Msg : String) is
1503 Error_Msg_Name_1 := Chars (N);
1504 Error_Msg_N (Msg, N);
1508 ----------------------
1509 -- Error_Pragma_Arg --
1510 ----------------------
1512 procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id) is
1514 Error_Msg_Name_1 := Chars (N);
1515 Error_Msg_N (Msg, Get_Pragma_Arg (Arg));
1517 end Error_Pragma_Arg;
1519 procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id) is
1521 Error_Msg_Name_1 := Chars (N);
1522 Error_Msg_N (Msg1, Get_Pragma_Arg (Arg));
1523 Error_Pragma_Arg (Msg2, Arg);
1524 end Error_Pragma_Arg;
1526 ----------------------------
1527 -- Error_Pragma_Arg_Ident --
1528 ----------------------------
1530 procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id) is
1532 Error_Msg_Name_1 := Chars (N);
1533 Error_Msg_N (Msg, Arg);
1535 end Error_Pragma_Arg_Ident;
1537 ------------------------
1538 -- Find_Lib_Unit_Name --
1539 ------------------------
1541 function Find_Lib_Unit_Name return Entity_Id is
1543 -- Return inner compilation unit entity, for case of nested
1544 -- categorization pragmas. This happens in generic unit.
1546 if Nkind (Parent (N)) = N_Package_Specification
1547 and then Defining_Entity (Parent (N)) /= Current_Scope
1549 return Defining_Entity (Parent (N));
1551 return Current_Scope;
1553 end Find_Lib_Unit_Name;
1555 ----------------------------
1556 -- Find_Program_Unit_Name --
1557 ----------------------------
1559 procedure Find_Program_Unit_Name (Id : Node_Id) is
1560 Unit_Name : Entity_Id;
1561 Unit_Kind : Node_Kind;
1562 P : constant Node_Id := Parent (N);
1565 if Nkind (P) = N_Compilation_Unit then
1566 Unit_Kind := Nkind (Unit (P));
1568 if Unit_Kind = N_Subprogram_Declaration
1569 or else Unit_Kind = N_Package_Declaration
1570 or else Unit_Kind in N_Generic_Declaration
1572 Unit_Name := Defining_Entity (Unit (P));
1574 if Chars (Id) = Chars (Unit_Name) then
1575 Set_Entity (Id, Unit_Name);
1576 Set_Etype (Id, Etype (Unit_Name));
1578 Set_Etype (Id, Any_Type);
1580 ("cannot find program unit referenced by pragma%");
1584 Set_Etype (Id, Any_Type);
1585 Error_Pragma ("pragma% inapplicable to this unit");
1591 end Find_Program_Unit_Name;
1593 -----------------------------------------
1594 -- Find_Unique_Parameterless_Procedure --
1595 -----------------------------------------
1597 function Find_Unique_Parameterless_Procedure
1599 Arg : Node_Id) return Entity_Id
1601 Proc : Entity_Id := Empty;
1604 -- The body of this procedure needs some comments ???
1606 if not Is_Entity_Name (Name) then
1608 ("argument of pragma% must be entity name", Arg);
1610 elsif not Is_Overloaded (Name) then
1611 Proc := Entity (Name);
1613 if Ekind (Proc) /= E_Procedure
1614 or else Present (First_Formal (Proc)) then
1616 ("argument of pragma% must be parameterless procedure", Arg);
1621 Found : Boolean := False;
1623 Index : Interp_Index;
1626 Get_First_Interp (Name, Index, It);
1627 while Present (It.Nam) loop
1630 if Ekind (Proc) = E_Procedure
1631 and then No (First_Formal (Proc))
1635 Set_Entity (Name, Proc);
1636 Set_Is_Overloaded (Name, False);
1639 ("ambiguous handler name for pragma% ", Arg);
1643 Get_Next_Interp (Index, It);
1648 ("argument of pragma% must be parameterless procedure",
1651 Proc := Entity (Name);
1657 end Find_Unique_Parameterless_Procedure;
1659 -------------------------
1660 -- Gather_Associations --
1661 -------------------------
1663 procedure Gather_Associations
1665 Args : out Args_List)
1670 -- Initialize all parameters to Empty
1672 for J in Args'Range loop
1676 -- That's all we have to do if there are no argument associations
1678 if No (Pragma_Argument_Associations (N)) then
1682 -- Otherwise first deal with any positional parameters present
1684 Arg := First (Pragma_Argument_Associations (N));
1685 for Index in Args'Range loop
1686 exit when No (Arg) or else Chars (Arg) /= No_Name;
1687 Args (Index) := Expression (Arg);
1691 -- Positional parameters all processed, if any left, then we
1692 -- have too many positional parameters.
1694 if Present (Arg) and then Chars (Arg) = No_Name then
1696 ("too many positional associations for pragma%", Arg);
1699 -- Process named parameters if any are present
1701 while Present (Arg) loop
1702 if Chars (Arg) = No_Name then
1704 ("positional association cannot follow named association",
1708 for Index in Names'Range loop
1709 if Names (Index) = Chars (Arg) then
1710 if Present (Args (Index)) then
1712 ("duplicate argument association for pragma%", Arg);
1714 Args (Index) := Expression (Arg);
1719 if Index = Names'Last then
1720 Error_Msg_Name_1 := Chars (N);
1721 Error_Msg_N ("pragma% does not allow & argument", Arg);
1723 -- Check for possible misspelling
1725 for Index1 in Names'Range loop
1726 if Is_Bad_Spelling_Of
1727 (Chars (Arg), Names (Index1))
1729 Error_Msg_Name_1 := Names (Index1);
1730 Error_Msg_N ("\possible misspelling of%", Arg);
1742 end Gather_Associations;
1744 --------------------
1745 -- Get_Pragma_Arg --
1746 --------------------
1748 function Get_Pragma_Arg (Arg : Node_Id) return Node_Id is
1750 if Nkind (Arg) = N_Pragma_Argument_Association then
1751 return Expression (Arg);
1761 procedure GNAT_Pragma is
1763 Check_Restriction (No_Implementation_Pragmas, N);
1766 --------------------------
1767 -- Is_Before_First_Decl --
1768 --------------------------
1770 function Is_Before_First_Decl
1771 (Pragma_Node : Node_Id;
1772 Decls : List_Id) return Boolean
1774 Item : Node_Id := First (Decls);
1777 -- Only other pragmas can come before this pragma
1780 if No (Item) or else Nkind (Item) /= N_Pragma then
1783 elsif Item = Pragma_Node then
1789 end Is_Before_First_Decl;
1791 -----------------------------
1792 -- Is_Configuration_Pragma --
1793 -----------------------------
1795 -- A configuration pragma must appear in the context clause of
1796 -- a compilation unit, at the start of the list (i.e. only other
1797 -- pragmas may precede it).
1799 function Is_Configuration_Pragma return Boolean is
1800 Lis : constant List_Id := List_Containing (N);
1801 Par : constant Node_Id := Parent (N);
1805 -- If no parent, then we are in the configuration pragma file,
1806 -- so the placement is definitely appropriate.
1811 -- Otherwise we must be in the context clause of a compilation unit
1812 -- and the only thing allowed before us in the context list is more
1813 -- configuration pragmas.
1815 elsif Nkind (Par) = N_Compilation_Unit
1816 and then Context_Items (Par) = Lis
1823 elsif Nkind (Prg) /= N_Pragma then
1833 end Is_Configuration_Pragma;
1835 --------------------------
1836 -- Is_In_Context_Clause --
1837 --------------------------
1839 function Is_In_Context_Clause return Boolean is
1841 Parent_Node : Node_Id;
1844 if not Is_List_Member (N) then
1848 Plist := List_Containing (N);
1849 Parent_Node := Parent (Plist);
1851 if Parent_Node = Empty
1852 or else Nkind (Parent_Node) /= N_Compilation_Unit
1853 or else Context_Items (Parent_Node) /= Plist
1860 end Is_In_Context_Clause;
1862 ---------------------------------
1863 -- Is_Static_String_Expression --
1864 ---------------------------------
1866 function Is_Static_String_Expression (Arg : Node_Id) return Boolean is
1867 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1870 Analyze_And_Resolve (Argx);
1871 return Is_OK_Static_Expression (Argx)
1872 and then Nkind (Argx) = N_String_Literal;
1873 end Is_Static_String_Expression;
1875 ----------------------
1876 -- Pragma_Misplaced --
1877 ----------------------
1879 procedure Pragma_Misplaced is
1881 Error_Pragma ("incorrect placement of pragma%");
1882 end Pragma_Misplaced;
1884 ------------------------------------
1885 -- Process Atomic_Shared_Volatile --
1886 ------------------------------------
1888 procedure Process_Atomic_Shared_Volatile is
1895 procedure Set_Atomic (E : Entity_Id);
1896 -- Set given type as atomic, and if no explicit alignment was
1897 -- given, set alignment to unknown, since back end knows what
1898 -- the alignment requirements are for atomic arrays. Note that
1899 -- this step is necessary for derived types.
1905 procedure Set_Atomic (E : Entity_Id) is
1909 if not Has_Alignment_Clause (E) then
1910 Set_Alignment (E, Uint_0);
1914 -- Start of processing for Process_Atomic_Shared_Volatile
1917 Check_Ada_83_Warning;
1918 Check_No_Identifiers;
1919 Check_Arg_Count (1);
1920 Check_Arg_Is_Local_Name (Arg1);
1921 E_Id := Expression (Arg1);
1923 if Etype (E_Id) = Any_Type then
1928 D := Declaration_Node (E);
1932 if Rep_Item_Too_Early (E, N)
1934 Rep_Item_Too_Late (E, N)
1938 Check_First_Subtype (Arg1);
1941 if Prag_Id /= Pragma_Volatile then
1943 Set_Atomic (Underlying_Type (E));
1944 Set_Atomic (Base_Type (E));
1947 -- Attribute belongs on the base type. If the
1948 -- view of the type is currently private, it also
1949 -- belongs on the underlying type.
1951 Set_Is_Volatile (Base_Type (E));
1952 Set_Is_Volatile (Underlying_Type (E));
1954 Set_Treat_As_Volatile (E);
1955 Set_Treat_As_Volatile (Underlying_Type (E));
1957 elsif K = N_Object_Declaration
1958 or else (K = N_Component_Declaration
1959 and then Original_Record_Component (E) = E)
1961 if Rep_Item_Too_Late (E, N) then
1965 if Prag_Id /= Pragma_Volatile then
1968 -- If the object declaration has an explicit
1969 -- initialization, a temporary may have to be
1970 -- created to hold the expression, to insure
1971 -- that access to the object remain atomic.
1973 if Nkind (Parent (E)) = N_Object_Declaration
1974 and then Present (Expression (Parent (E)))
1976 Set_Has_Delayed_Freeze (E);
1979 -- An interesting improvement here. If an object of type X
1980 -- is declared atomic, and the type X is not atomic, that's
1981 -- a pity, since it may not have appropraite alignment etc.
1982 -- We can rescue this in the special case where the object
1983 -- and type are in the same unit by just setting the type
1984 -- as atomic, so that the back end will process it as atomic.
1986 Utyp := Underlying_Type (Etype (E));
1989 and then Sloc (E) > No_Location
1990 and then Sloc (Utyp) > No_Location
1992 Get_Source_File_Index (Sloc (E)) =
1993 Get_Source_File_Index (Sloc (Underlying_Type (Etype (E))))
1995 Set_Is_Atomic (Underlying_Type (Etype (E)));
1999 Set_Is_Volatile (E);
2000 Set_Treat_As_Volatile (E);
2004 ("inappropriate entity for pragma%", Arg1);
2006 end Process_Atomic_Shared_Volatile;
2008 -------------------------------------------
2009 -- Process_Compile_Time_Warning_Or_Error --
2010 -------------------------------------------
2012 procedure Process_Compile_Time_Warning_Or_Error is
2013 Arg1x : constant Node_Id := Get_Pragma_Arg (Arg1);
2017 Check_Arg_Count (2);
2018 Check_No_Identifiers;
2019 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
2020 Analyze_And_Resolve (Arg1x, Standard_Boolean);
2022 if Compile_Time_Known_Value (Arg1x) then
2023 if Is_True (Expr_Value (Get_Pragma_Arg (Arg1))) then
2025 Str : constant String_Id :=
2026 Strval (Get_Pragma_Arg (Arg2));
2027 Len : constant Int := String_Length (Str);
2037 -- Loop through segments of message separated by line
2038 -- feeds. We output these segments as separate messages
2039 -- with continuation marks for all but the first.
2042 Error_Msg_Strlen := 0;
2044 -- Loop to copy characters from argument to error
2045 -- message string buffer.
2048 exit when Ptr > Len;
2049 CC := Get_String_Char (Str, Ptr);
2052 -- Ignore wide chars ??? else store character
2054 if In_Character_Range (CC) then
2055 C := Get_Character (CC);
2056 exit when C = ASCII.LF;
2057 Error_Msg_Strlen := Error_Msg_Strlen + 1;
2058 Error_Msg_String (Error_Msg_Strlen) := C;
2062 -- Here with one line ready to go
2064 Error_Msg_Warn := Prag_Id = Pragma_Compile_Time_Warning;
2066 if Cont = False then
2067 Error_Msg_N ("<~", Arg1);
2070 Error_Msg_N ("\<~", Arg1);
2073 exit when Ptr > Len;
2078 end Process_Compile_Time_Warning_Or_Error;
2080 ------------------------
2081 -- Process_Convention --
2082 ------------------------
2084 procedure Process_Convention
2085 (C : out Convention_Id;
2091 Comp_Unit : Unit_Number_Type;
2093 procedure Set_Convention_From_Pragma (E : Entity_Id);
2094 -- Set convention in entity E, and also flag that the entity has a
2095 -- convention pragma. If entity is for a private or incomplete type,
2096 -- also set convention and flag on underlying type. This procedure
2097 -- also deals with the special case of C_Pass_By_Copy convention.
2099 --------------------------------
2100 -- Set_Convention_From_Pragma --
2101 --------------------------------
2103 procedure Set_Convention_From_Pragma (E : Entity_Id) is
2105 -- Ada 2005 (AI-430): Check invalid attempt to change convention
2106 -- for an overridden dispatching operation. Technically this is
2107 -- an amendment and should only be done in Ada 2005 mode. However,
2108 -- this is clearly a mistake, since the problem that is addressed
2109 -- by this AI is that there is a clear gap in the RM!
2111 if Is_Dispatching_Operation (E)
2112 and then Present (Overridden_Operation (E))
2113 and then C /= Convention (Overridden_Operation (E))
2116 ("cannot change convention for " &
2117 "overridden dispatching operation",
2121 -- Set the convention
2123 Set_Convention (E, C);
2124 Set_Has_Convention_Pragma (E);
2126 if Is_Incomplete_Or_Private_Type (E) then
2127 Set_Convention (Underlying_Type (E), C);
2128 Set_Has_Convention_Pragma (Underlying_Type (E), True);
2131 -- A class-wide type should inherit the convention of
2132 -- the specific root type (although this isn't specified
2133 -- clearly by the RM).
2135 if Is_Type (E) and then Present (Class_Wide_Type (E)) then
2136 Set_Convention (Class_Wide_Type (E), C);
2139 -- If the entity is a record type, then check for special case of
2140 -- C_Pass_By_Copy, which is treated the same as C except that the
2141 -- special record flag is set. This convention is only permitted
2142 -- on record types (see AI95-00131).
2144 if Cname = Name_C_Pass_By_Copy then
2145 if Is_Record_Type (E) then
2146 Set_C_Pass_By_Copy (Base_Type (E));
2147 elsif Is_Incomplete_Or_Private_Type (E)
2148 and then Is_Record_Type (Underlying_Type (E))
2150 Set_C_Pass_By_Copy (Base_Type (Underlying_Type (E)));
2153 ("C_Pass_By_Copy convention allowed only for record type",
2158 -- If the entity is a derived boolean type, check for the
2159 -- special case of convention C, C++, or Fortran, where we
2160 -- consider any nonzero value to represent true.
2162 if Is_Discrete_Type (E)
2163 and then Root_Type (Etype (E)) = Standard_Boolean
2169 C = Convention_Fortran)
2171 Set_Nonzero_Is_True (Base_Type (E));
2173 end Set_Convention_From_Pragma;
2175 -- Start of processing for Process_Convention
2178 Check_At_Least_N_Arguments (2);
2179 Check_Optional_Identifier (Arg1, Name_Convention);
2180 Check_Arg_Is_Identifier (Arg1);
2181 Cname := Chars (Expression (Arg1));
2183 -- C_Pass_By_Copy is treated as a synonym for convention C
2184 -- (this is tested again below to set the critical flag)
2186 if Cname = Name_C_Pass_By_Copy then
2189 -- Otherwise we must have something in the standard convention list
2191 elsif Is_Convention_Name (Cname) then
2192 C := Get_Convention_Id (Chars (Expression (Arg1)));
2194 -- In DEC VMS, it seems that there is an undocumented feature that
2195 -- any unrecognized convention is treated as the default, which for
2196 -- us is convention C. It does not seem so terrible to do this
2197 -- unconditionally, silently in the VMS case, and with a warning
2198 -- in the non-VMS case.
2201 if Warn_On_Export_Import and not OpenVMS_On_Target then
2203 ("?unrecognized convention name, C assumed",
2210 Check_Optional_Identifier (Arg2, Name_Entity);
2211 Check_Arg_Is_Local_Name (Arg2);
2213 Id := Expression (Arg2);
2216 if not Is_Entity_Name (Id) then
2217 Error_Pragma_Arg ("entity name required", Arg2);
2222 -- Go to renamed subprogram if present, since convention applies to
2223 -- the actual renamed entity, not to the renaming entity. If the
2224 -- subprogram is inherited, go to parent subprogram.
2226 if Is_Subprogram (E)
2227 and then Present (Alias (E))
2229 if Nkind (Parent (Declaration_Node (E))) =
2230 N_Subprogram_Renaming_Declaration
2234 elsif Nkind (Parent (E)) = N_Full_Type_Declaration
2235 and then Scope (E) = Scope (Alias (E))
2241 -- Check that we are not applying this to a specless body
2243 if Is_Subprogram (E)
2244 and then Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Body
2247 ("pragma% requires separate spec and must come before body");
2250 -- Check that we are not applying this to a named constant
2252 if Ekind (E) = E_Named_Integer
2254 Ekind (E) = E_Named_Real
2256 Error_Msg_Name_1 := Chars (N);
2258 ("cannot apply pragma% to named constant!",
2259 Get_Pragma_Arg (Arg2));
2261 ("\supply appropriate type for&!", Arg2);
2264 if Ekind (E) = E_Enumeration_Literal then
2265 Error_Pragma ("enumeration literal not allowed for pragma%");
2268 -- Check for rep item appearing too early or too late
2270 if Etype (E) = Any_Type
2271 or else Rep_Item_Too_Early (E, N)
2275 E := Underlying_Type (E);
2278 if Rep_Item_Too_Late (E, N) then
2282 if Has_Convention_Pragma (E) then
2284 ("at most one Convention/Export/Import pragma is allowed", Arg2);
2286 elsif Convention (E) = Convention_Protected
2287 or else Ekind (Scope (E)) = E_Protected_Type
2290 ("a protected operation cannot be given a different convention",
2294 -- For Intrinsic, a subprogram is required
2296 if C = Convention_Intrinsic
2297 and then not Is_Subprogram (E)
2298 and then not Is_Generic_Subprogram (E)
2301 ("second argument of pragma% must be a subprogram", Arg2);
2304 -- For Stdcall, a subprogram, variable or subprogram type is required
2306 if C = Convention_Stdcall
2307 and then not Is_Subprogram (E)
2308 and then not Is_Generic_Subprogram (E)
2309 and then Ekind (E) /= E_Variable
2312 and then Ekind (Designated_Type (E)) = E_Subprogram_Type)
2315 ("second argument of pragma% must be subprogram (type)",
2319 if not Is_Subprogram (E)
2320 and then not Is_Generic_Subprogram (E)
2322 Set_Convention_From_Pragma (E);
2326 Check_First_Subtype (Arg2);
2327 Set_Convention_From_Pragma (Base_Type (E));
2329 -- For subprograms, we must set the convention on the
2330 -- internally generated directly designated type as well.
2332 if Ekind (E) = E_Access_Subprogram_Type then
2333 Set_Convention_From_Pragma (Directly_Designated_Type (E));
2337 -- For the subprogram case, set proper convention for all homonyms
2338 -- in same scope and the same declarative part, i.e. the same
2339 -- compilation unit.
2342 Comp_Unit := Get_Source_Unit (E);
2343 Set_Convention_From_Pragma (E);
2345 -- Treat a pragma Import as an implicit body, for GPS use
2347 if Prag_Id = Pragma_Import then
2348 Generate_Reference (E, Id, 'b');
2354 exit when No (E1) or else Scope (E1) /= Current_Scope;
2356 if Comes_From_Source (E1)
2357 and then Comp_Unit = Get_Source_Unit (E1)
2358 and then Nkind (Original_Node (Parent (E1))) /=
2359 N_Full_Type_Declaration
2361 Set_Convention_From_Pragma (E1);
2363 if Prag_Id = Pragma_Import then
2364 Generate_Reference (E, Id, 'b');
2369 end Process_Convention;
2371 -----------------------------------------------------
2372 -- Process_Extended_Import_Export_Exception_Pragma --
2373 -----------------------------------------------------
2375 procedure Process_Extended_Import_Export_Exception_Pragma
2376 (Arg_Internal : Node_Id;
2377 Arg_External : Node_Id;
2387 if not OpenVMS_On_Target then
2389 ("?pragma% ignored (applies only to Open'V'M'S)");
2392 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2393 Def_Id := Entity (Arg_Internal);
2395 if Ekind (Def_Id) /= E_Exception then
2397 ("pragma% must refer to declared exception", Arg_Internal);
2400 Set_Extended_Import_Export_External_Name (Def_Id, Arg_External);
2402 if Present (Arg_Form) then
2403 Check_Arg_Is_One_Of (Arg_Form, Name_Ada, Name_VMS);
2406 if Present (Arg_Form)
2407 and then Chars (Arg_Form) = Name_Ada
2411 Set_Is_VMS_Exception (Def_Id);
2412 Set_Exception_Code (Def_Id, No_Uint);
2415 if Present (Arg_Code) then
2416 if not Is_VMS_Exception (Def_Id) then
2418 ("Code option for pragma% not allowed for Ada case",
2422 Check_Arg_Is_Static_Expression (Arg_Code, Any_Integer);
2423 Code_Val := Expr_Value (Arg_Code);
2425 if not UI_Is_In_Int_Range (Code_Val) then
2427 ("Code option for pragma% must be in 32-bit range",
2431 Set_Exception_Code (Def_Id, Code_Val);
2434 end Process_Extended_Import_Export_Exception_Pragma;
2436 -------------------------------------------------
2437 -- Process_Extended_Import_Export_Internal_Arg --
2438 -------------------------------------------------
2440 procedure Process_Extended_Import_Export_Internal_Arg
2441 (Arg_Internal : Node_Id := Empty)
2446 if No (Arg_Internal) then
2447 Error_Pragma ("Internal parameter required for pragma%");
2450 if Nkind (Arg_Internal) = N_Identifier then
2453 elsif Nkind (Arg_Internal) = N_Operator_Symbol
2454 and then (Prag_Id = Pragma_Import_Function
2456 Prag_Id = Pragma_Export_Function)
2462 ("wrong form for Internal parameter for pragma%", Arg_Internal);
2465 Check_Arg_Is_Local_Name (Arg_Internal);
2466 end Process_Extended_Import_Export_Internal_Arg;
2468 --------------------------------------------------
2469 -- Process_Extended_Import_Export_Object_Pragma --
2470 --------------------------------------------------
2472 procedure Process_Extended_Import_Export_Object_Pragma
2473 (Arg_Internal : Node_Id;
2474 Arg_External : Node_Id;
2480 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2481 Def_Id := Entity (Arg_Internal);
2483 if Ekind (Def_Id) /= E_Constant
2484 and then Ekind (Def_Id) /= E_Variable
2487 ("pragma% must designate an object", Arg_Internal);
2490 if Has_Rep_Pragma (Def_Id, Name_Common_Object)
2492 Has_Rep_Pragma (Def_Id, Name_Psect_Object)
2495 ("previous Common/Psect_Object applies, pragma % not permitted",
2499 if Rep_Item_Too_Late (Def_Id, N) then
2503 Set_Extended_Import_Export_External_Name (Def_Id, Arg_External);
2505 if Present (Arg_Size) then
2506 Check_Arg_Is_External_Name (Arg_Size);
2509 -- Export_Object case
2511 if Prag_Id = Pragma_Export_Object then
2512 if not Is_Library_Level_Entity (Def_Id) then
2514 ("argument for pragma% must be library level entity",
2518 if Ekind (Current_Scope) = E_Generic_Package then
2519 Error_Pragma ("pragma& cannot appear in a generic unit");
2522 if not Size_Known_At_Compile_Time (Etype (Def_Id)) then
2524 ("exported object must have compile time known size",
2528 if Warn_On_Export_Import and then Is_Exported (Def_Id) then
2530 ("?duplicate Export_Object pragma", N);
2532 Set_Exported (Def_Id, Arg_Internal);
2535 -- Import_Object case
2538 if Is_Concurrent_Type (Etype (Def_Id)) then
2540 ("cannot use pragma% for task/protected object",
2544 if Ekind (Def_Id) = E_Constant then
2546 ("cannot import a constant", Arg_Internal);
2549 if Warn_On_Export_Import
2550 and then Has_Discriminants (Etype (Def_Id))
2553 ("imported value must be initialized?", Arg_Internal);
2556 if Warn_On_Export_Import
2557 and then Is_Access_Type (Etype (Def_Id))
2560 ("cannot import object of an access type?", Arg_Internal);
2563 if Warn_On_Export_Import
2564 and then Is_Imported (Def_Id)
2567 ("?duplicate Import_Object pragma", N);
2569 -- Check for explicit initialization present. Note that an
2570 -- initialization that generated by the code generator, e.g.
2571 -- for an access type, does not count here.
2573 elsif Present (Expression (Parent (Def_Id)))
2576 (Original_Node (Expression (Parent (Def_Id))))
2578 Error_Msg_Sloc := Sloc (Def_Id);
2580 ("imported entities cannot be initialized (RM B.1(24))",
2581 "\no initialization allowed for & declared#", Arg1);
2583 Set_Imported (Def_Id);
2584 Note_Possible_Modification (Arg_Internal);
2587 end Process_Extended_Import_Export_Object_Pragma;
2589 ------------------------------------------------------
2590 -- Process_Extended_Import_Export_Subprogram_Pragma --
2591 ------------------------------------------------------
2593 procedure Process_Extended_Import_Export_Subprogram_Pragma
2594 (Arg_Internal : Node_Id;
2595 Arg_External : Node_Id;
2596 Arg_Parameter_Types : Node_Id;
2597 Arg_Result_Type : Node_Id := Empty;
2598 Arg_Mechanism : Node_Id;
2599 Arg_Result_Mechanism : Node_Id := Empty;
2600 Arg_First_Optional_Parameter : Node_Id := Empty)
2606 Ambiguous : Boolean;
2610 function Same_Base_Type
2612 Formal : Entity_Id) return Boolean;
2613 -- Determines if Ptype references the type of Formal. Note that
2614 -- only the base types need to match according to the spec. Ptype
2615 -- here is the argument from the pragma, which is either a type
2616 -- name, or an access attribute.
2618 --------------------
2619 -- Same_Base_Type --
2620 --------------------
2622 function Same_Base_Type
2624 Formal : Entity_Id) return Boolean
2626 Ftyp : constant Entity_Id := Base_Type (Etype (Formal));
2630 -- Case where pragma argument is typ'Access
2632 if Nkind (Ptype) = N_Attribute_Reference
2633 and then Attribute_Name (Ptype) = Name_Access
2635 Pref := Prefix (Ptype);
2638 if not Is_Entity_Name (Pref)
2639 or else Entity (Pref) = Any_Type
2644 -- We have a match if the corresponding argument is of an
2645 -- anonymous access type, and its designicated type matches
2646 -- the type of the prefix of the access attribute
2648 return Ekind (Ftyp) = E_Anonymous_Access_Type
2649 and then Base_Type (Entity (Pref)) =
2650 Base_Type (Etype (Designated_Type (Ftyp)));
2652 -- Case where pragma argument is a type name
2657 if not Is_Entity_Name (Ptype)
2658 or else Entity (Ptype) = Any_Type
2663 -- We have a match if the corresponding argument is of
2664 -- the type given in the pragma (comparing base types)
2666 return Base_Type (Entity (Ptype)) = Ftyp;
2670 -- Start of processing for
2671 -- Process_Extended_Import_Export_Subprogram_Pragma
2674 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
2678 -- Loop through homonyms (overloadings) of the entity
2680 Hom_Id := Entity (Arg_Internal);
2681 while Present (Hom_Id) loop
2682 Def_Id := Get_Base_Subprogram (Hom_Id);
2684 -- We need a subprogram in the current scope
2686 if not Is_Subprogram (Def_Id)
2687 or else Scope (Def_Id) /= Current_Scope
2694 -- Pragma cannot apply to subprogram body
2696 if Is_Subprogram (Def_Id)
2699 (Declaration_Node (Def_Id))) = N_Subprogram_Body
2702 ("pragma% requires separate spec"
2703 & " and must come before body");
2706 -- Test result type if given, note that the result type
2707 -- parameter can only be present for the function cases.
2709 if Present (Arg_Result_Type)
2710 and then not Same_Base_Type (Arg_Result_Type, Def_Id)
2714 elsif Etype (Def_Id) /= Standard_Void_Type
2716 (Chars (N) = Name_Export_Procedure
2717 or else Chars (N) = Name_Import_Procedure)
2721 -- Test parameter types if given. Note that this parameter
2722 -- has not been analyzed (and must not be, since it is
2723 -- semantic nonsense), so we get it as the parser left it.
2725 elsif Present (Arg_Parameter_Types) then
2726 Check_Matching_Types : declare
2731 Formal := First_Formal (Def_Id);
2733 if Nkind (Arg_Parameter_Types) = N_Null then
2734 if Present (Formal) then
2738 -- A list of one type, e.g. (List) is parsed as
2739 -- a parenthesized expression.
2741 elsif Nkind (Arg_Parameter_Types) /= N_Aggregate
2742 and then Paren_Count (Arg_Parameter_Types) = 1
2745 or else Present (Next_Formal (Formal))
2750 Same_Base_Type (Arg_Parameter_Types, Formal);
2753 -- A list of more than one type is parsed as a aggregate
2755 elsif Nkind (Arg_Parameter_Types) = N_Aggregate
2756 and then Paren_Count (Arg_Parameter_Types) = 0
2758 Ptype := First (Expressions (Arg_Parameter_Types));
2759 while Present (Ptype) or else Present (Formal) loop
2762 or else not Same_Base_Type (Ptype, Formal)
2767 Next_Formal (Formal);
2772 -- Anything else is of the wrong form
2776 ("wrong form for Parameter_Types parameter",
2777 Arg_Parameter_Types);
2779 end Check_Matching_Types;
2782 -- Match is now False if the entry we found did not match
2783 -- either a supplied Parameter_Types or Result_Types argument
2789 -- Ambiguous case, the flag Ambiguous shows if we already
2790 -- detected this and output the initial messages.
2793 if not Ambiguous then
2795 Error_Msg_Name_1 := Chars (N);
2797 ("pragma% does not uniquely identify subprogram!",
2799 Error_Msg_Sloc := Sloc (Ent);
2800 Error_Msg_N ("matching subprogram #!", N);
2804 Error_Msg_Sloc := Sloc (Def_Id);
2805 Error_Msg_N ("matching subprogram #!", N);
2810 Hom_Id := Homonym (Hom_Id);
2813 -- See if we found an entry
2816 if not Ambiguous then
2817 if Is_Generic_Subprogram (Entity (Arg_Internal)) then
2819 ("pragma% cannot be given for generic subprogram");
2822 ("pragma% does not identify local subprogram");
2829 -- Import pragmas must be be for imported entities
2831 if Prag_Id = Pragma_Import_Function
2833 Prag_Id = Pragma_Import_Procedure
2835 Prag_Id = Pragma_Import_Valued_Procedure
2837 if not Is_Imported (Ent) then
2839 ("pragma Import or Interface must precede pragma%");
2842 -- Here we have the Export case which can set the entity as exported
2844 -- But does not do so if the specified external name is null, since
2845 -- that is taken as a signal in DEC Ada 83 (with which we want to be
2846 -- compatible) to request no external name.
2848 elsif Nkind (Arg_External) = N_String_Literal
2849 and then String_Length (Strval (Arg_External)) = 0
2853 -- In all other cases, set entit as exported
2856 Set_Exported (Ent, Arg_Internal);
2859 -- Special processing for Valued_Procedure cases
2861 if Prag_Id = Pragma_Import_Valued_Procedure
2863 Prag_Id = Pragma_Export_Valued_Procedure
2865 Formal := First_Formal (Ent);
2869 ("at least one parameter required for pragma%");
2871 elsif Ekind (Formal) /= E_Out_Parameter then
2873 ("first parameter must have mode out for pragma%");
2876 Set_Is_Valued_Procedure (Ent);
2880 Set_Extended_Import_Export_External_Name (Ent, Arg_External);
2882 -- Process Result_Mechanism argument if present. We have already
2883 -- checked that this is only allowed for the function case.
2885 if Present (Arg_Result_Mechanism) then
2886 Set_Mechanism_Value (Ent, Arg_Result_Mechanism);
2889 -- Process Mechanism parameter if present. Note that this parameter
2890 -- is not analyzed, and must not be analyzed since it is semantic
2891 -- nonsense, so we get it in exactly as the parser left it.
2893 if Present (Arg_Mechanism) then
2901 -- A single mechanism association without a formal parameter
2902 -- name is parsed as a parenthesized expression. All other
2903 -- cases are parsed as aggregates, so we rewrite the single
2904 -- parameter case as an aggregate for consistency.
2906 if Nkind (Arg_Mechanism) /= N_Aggregate
2907 and then Paren_Count (Arg_Mechanism) = 1
2909 Rewrite (Arg_Mechanism,
2910 Make_Aggregate (Sloc (Arg_Mechanism),
2911 Expressions => New_List (
2912 Relocate_Node (Arg_Mechanism))));
2915 -- Case of only mechanism name given, applies to all formals
2917 if Nkind (Arg_Mechanism) /= N_Aggregate then
2918 Formal := First_Formal (Ent);
2919 while Present (Formal) loop
2920 Set_Mechanism_Value (Formal, Arg_Mechanism);
2921 Next_Formal (Formal);
2924 -- Case of list of mechanism associations given
2927 if Null_Record_Present (Arg_Mechanism) then
2929 ("inappropriate form for Mechanism parameter",
2933 -- Deal with positional ones first
2935 Formal := First_Formal (Ent);
2937 if Present (Expressions (Arg_Mechanism)) then
2938 Mname := First (Expressions (Arg_Mechanism));
2939 while Present (Mname) loop
2942 ("too many mechanism associations", Mname);
2945 Set_Mechanism_Value (Formal, Mname);
2946 Next_Formal (Formal);
2951 -- Deal with named entries
2953 if Present (Component_Associations (Arg_Mechanism)) then
2954 Massoc := First (Component_Associations (Arg_Mechanism));
2955 while Present (Massoc) loop
2956 Choice := First (Choices (Massoc));
2958 if Nkind (Choice) /= N_Identifier
2959 or else Present (Next (Choice))
2962 ("incorrect form for mechanism association",
2966 Formal := First_Formal (Ent);
2970 ("parameter name & not present", Choice);
2973 if Chars (Choice) = Chars (Formal) then
2975 (Formal, Expression (Massoc));
2979 Next_Formal (Formal);
2989 -- Process First_Optional_Parameter argument if present. We have
2990 -- already checked that this is only allowed for the Import case.
2992 if Present (Arg_First_Optional_Parameter) then
2993 if Nkind (Arg_First_Optional_Parameter) /= N_Identifier then
2995 ("first optional parameter must be formal parameter name",
2996 Arg_First_Optional_Parameter);
2999 Formal := First_Formal (Ent);
3003 ("specified formal parameter& not found",
3004 Arg_First_Optional_Parameter);
3007 exit when Chars (Formal) =
3008 Chars (Arg_First_Optional_Parameter);
3010 Next_Formal (Formal);
3013 Set_First_Optional_Parameter (Ent, Formal);
3015 -- Check specified and all remaining formals have right form
3017 while Present (Formal) loop
3018 if Ekind (Formal) /= E_In_Parameter then
3020 ("optional formal& is not of mode in!",
3021 Arg_First_Optional_Parameter, Formal);
3024 Dval := Default_Value (Formal);
3028 ("optional formal& does not have default value!",
3029 Arg_First_Optional_Parameter, Formal);
3031 elsif Compile_Time_Known_Value_Or_Aggr (Dval) then
3036 ("default value for optional formal& is non-static!",
3037 Arg_First_Optional_Parameter, Formal);
3041 Set_Is_Optional_Parameter (Formal);
3042 Next_Formal (Formal);
3045 end Process_Extended_Import_Export_Subprogram_Pragma;
3047 --------------------------
3048 -- Process_Generic_List --
3049 --------------------------
3051 procedure Process_Generic_List is
3057 Check_No_Identifiers;
3058 Check_At_Least_N_Arguments (1);
3061 while Present (Arg) loop
3062 Exp := Expression (Arg);
3065 if not Is_Entity_Name (Exp)
3067 (not Is_Generic_Instance (Entity (Exp))
3069 not Is_Generic_Unit (Entity (Exp)))
3072 ("pragma% argument must be name of generic unit/instance",
3078 end Process_Generic_List;
3080 ---------------------------------
3081 -- Process_Import_Or_Interface --
3082 ---------------------------------
3084 procedure Process_Import_Or_Interface is
3090 Process_Convention (C, Def_Id);
3091 Kill_Size_Check_Code (Def_Id);
3092 Note_Possible_Modification (Expression (Arg2));
3094 if Ekind (Def_Id) = E_Variable
3096 Ekind (Def_Id) = E_Constant
3098 -- We do not permit Import to apply to a renaming declaration
3100 if Present (Renamed_Object (Def_Id)) then
3102 ("pragma% not allowed for object renaming", Arg2);
3104 -- User initialization is not allowed for imported object, but
3105 -- the object declaration may contain a default initialization,
3106 -- that will be discarded. Note that an explicit initialization
3107 -- only counts if it comes from source, otherwise it is simply
3108 -- the code generator making an implicit initialization explicit.
3110 elsif Present (Expression (Parent (Def_Id)))
3111 and then Comes_From_Source (Expression (Parent (Def_Id)))
3113 Error_Msg_Sloc := Sloc (Def_Id);
3115 ("no initialization allowed for declaration of& #",
3116 "\imported entities cannot be initialized (RM B.1(24))",
3120 Set_Imported (Def_Id);
3121 Process_Interface_Name (Def_Id, Arg3, Arg4);
3123 -- Note that we do not set Is_Public here. That's because we
3124 -- only want to set if if there is no address clause, and we
3125 -- don't know that yet, so we delay that processing till
3128 -- pragma Import completes deferred constants
3130 if Ekind (Def_Id) = E_Constant then
3131 Set_Has_Completion (Def_Id);
3134 -- It is not possible to import a constant of an unconstrained
3135 -- array type (e.g. string) because there is no simple way to
3136 -- write a meaningful subtype for it.
3138 if Is_Array_Type (Etype (Def_Id))
3139 and then not Is_Constrained (Etype (Def_Id))
3142 ("imported constant& must have a constrained subtype",
3147 elsif Is_Subprogram (Def_Id)
3148 or else Is_Generic_Subprogram (Def_Id)
3150 -- If the name is overloaded, pragma applies to all of the
3151 -- denoted entities in the same declarative part.
3154 while Present (Hom_Id) loop
3155 Def_Id := Get_Base_Subprogram (Hom_Id);
3157 -- Ignore inherited subprograms because the pragma will
3158 -- apply to the parent operation, which is the one called.
3160 if Is_Overloadable (Def_Id)
3161 and then Present (Alias (Def_Id))
3165 -- If it is not a subprogram, it must be in an outer
3166 -- scope and pragma does not apply.
3168 elsif not Is_Subprogram (Def_Id)
3169 and then not Is_Generic_Subprogram (Def_Id)
3173 -- Verify that the homonym is in the same declarative
3174 -- part (not just the same scope).
3176 elsif Parent (Unit_Declaration_Node (Def_Id)) /= Parent (N)
3177 and then Nkind (Parent (N)) /= N_Compilation_Unit_Aux
3182 Set_Imported (Def_Id);
3184 -- Special processing for Convention_Intrinsic
3186 if C = Convention_Intrinsic then
3188 -- Link_Name argument not allowed for intrinsic
3191 and then Chars (Arg3) = Name_Link_Name
3196 if Present (Arg4) then
3198 ("Link_Name argument not allowed for " &
3203 Set_Is_Intrinsic_Subprogram (Def_Id);
3205 -- If no external name is present, then check that
3206 -- this is a valid intrinsic subprogram. If an external
3207 -- name is present, then this is handled by the back end.
3210 Check_Intrinsic_Subprogram (Def_Id, Expression (Arg2));
3214 -- All interfaced procedures need an external symbol
3215 -- created for them since they are always referenced
3216 -- from another object file.
3218 Set_Is_Public (Def_Id);
3220 -- Verify that the subprogram does not have a completion
3221 -- through a renaming declaration. For other completions
3222 -- the pragma appears as a too late representation.
3225 Decl : constant Node_Id := Unit_Declaration_Node (Def_Id);
3229 and then Nkind (Decl) = N_Subprogram_Declaration
3230 and then Present (Corresponding_Body (Decl))
3233 (Unit_Declaration_Node
3234 (Corresponding_Body (Decl))) =
3235 N_Subprogram_Renaming_Declaration
3237 Error_Msg_Sloc := Sloc (Def_Id);
3239 ("cannot import&, renaming already provided for " &
3240 "declaration #", N, Def_Id);
3244 Set_Has_Completion (Def_Id);
3245 Process_Interface_Name (Def_Id, Arg3, Arg4);
3248 if Is_Compilation_Unit (Hom_Id) then
3250 -- Its possible homonyms are not affected by the pragma.
3251 -- Such homonyms might be present in the context of other
3252 -- units being compiled.
3257 Hom_Id := Homonym (Hom_Id);
3261 -- When the convention is Java or CIL, we also allow Import to be
3262 -- given for packages, generic packages, exceptions, and record
3265 elsif (C = Convention_Java or else C = Convention_CIL)
3267 (Ekind (Def_Id) = E_Package
3268 or else Ekind (Def_Id) = E_Generic_Package
3269 or else Ekind (Def_Id) = E_Exception
3270 or else Nkind (Parent (Def_Id)) = N_Component_Declaration)
3272 Set_Imported (Def_Id);
3273 Set_Is_Public (Def_Id);
3274 Process_Interface_Name (Def_Id, Arg3, Arg4);
3276 -- Import a CPP class
3278 elsif Is_Record_Type (Def_Id)
3279 and then C = Convention_CPP
3281 if not Is_Tagged_Type (Def_Id) then
3282 Error_Msg_Sloc := Sloc (Def_Id);
3283 Error_Pragma_Arg ("imported 'C'P'P type must be tagged", Arg2);
3286 -- Types treated as CPP classes are treated as limited, but we
3287 -- don't require them to be declared this way. A warning is
3288 -- issued to encourage the user to declare them as limited.
3289 -- This is not an error, for compatibility reasons, because
3290 -- these types have been supported this way for some time.
3292 if not Is_Limited_Type (Def_Id) then
3294 ("imported 'C'P'P type should be " &
3295 "explicitly declared limited?",
3296 Get_Pragma_Arg (Arg2));
3298 ("\type will be considered limited",
3299 Get_Pragma_Arg (Arg2));
3302 Set_Is_CPP_Class (Def_Id);
3303 Set_Is_Limited_Record (Def_Id);
3308 ("second argument of pragma% must be object or subprogram",
3312 -- If this pragma applies to a compilation unit, then the unit,
3313 -- which is a subprogram, does not require (or allow) a body.
3314 -- We also do not need to elaborate imported procedures.
3316 if Nkind (Parent (N)) = N_Compilation_Unit_Aux then
3318 Cunit : constant Node_Id := Parent (Parent (N));
3320 Set_Body_Required (Cunit, False);
3323 end Process_Import_Or_Interface;
3325 --------------------
3326 -- Process_Inline --
3327 --------------------
3329 procedure Process_Inline (Active : Boolean) is
3335 Effective : Boolean := False;
3337 procedure Make_Inline (Subp : Entity_Id);
3338 -- Subp is the defining unit name of the subprogram
3339 -- declaration. Set the flag, as well as the flag in the
3340 -- corresponding body, if there is one present.
3342 procedure Set_Inline_Flags (Subp : Entity_Id);
3343 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp and also
3344 -- Has_Pragma_Inline_Always for the Inline_Always case.
3346 function Inlining_Not_Possible (Subp : Entity_Id) return Boolean;
3347 -- Returns True if it can be determined at this stage that inlining
3348 -- is not possible, for examle if the body is available and contains
3349 -- exception handlers, we prevent inlining, since otherwise we can
3350 -- get undefined symbols at link time. This function also emits a
3351 -- warning if front-end inlining is enabled and the pragma appears
3354 -- ??? is business with link symbols still valid, or does it relate
3355 -- to front end ZCX which is being phased out ???
3357 ---------------------------
3358 -- Inlining_Not_Possible --
3359 ---------------------------
3361 function Inlining_Not_Possible (Subp : Entity_Id) return Boolean is
3362 Decl : constant Node_Id := Unit_Declaration_Node (Subp);
3366 if Nkind (Decl) = N_Subprogram_Body then
3367 Stats := Handled_Statement_Sequence (Decl);
3368 return Present (Exception_Handlers (Stats))
3369 or else Present (At_End_Proc (Stats));
3371 elsif Nkind (Decl) = N_Subprogram_Declaration
3372 and then Present (Corresponding_Body (Decl))
3374 if Front_End_Inlining
3375 and then Analyzed (Corresponding_Body (Decl))
3377 Error_Msg_N ("pragma appears too late, ignored?", N);
3380 -- If the subprogram is a renaming as body, the body is
3381 -- just a call to the renamed subprogram, and inlining is
3382 -- trivially possible.
3385 Nkind (Unit_Declaration_Node (Corresponding_Body (Decl))) =
3386 N_Subprogram_Renaming_Declaration
3392 Handled_Statement_Sequence
3393 (Unit_Declaration_Node (Corresponding_Body (Decl)));
3396 Present (Exception_Handlers (Stats))
3397 or else Present (At_End_Proc (Stats));
3401 -- If body is not available, assume the best, the check is
3402 -- performed again when compiling enclosing package bodies.
3406 end Inlining_Not_Possible;
3412 procedure Make_Inline (Subp : Entity_Id) is
3413 Kind : constant Entity_Kind := Ekind (Subp);
3414 Inner_Subp : Entity_Id := Subp;
3417 -- Ignore if bad type, avoid cascaded error
3419 if Etype (Subp) = Any_Type then
3423 -- Ignore if all inlining is suppressed
3425 elsif Suppress_All_Inlining then
3429 -- If inlining is not possible, for now do not treat as an error
3431 elsif Inlining_Not_Possible (Subp) then
3435 -- Here we have a candidate for inlining, but we must exclude
3436 -- derived operations. Otherwise we will end up trying to
3437 -- inline a phantom declaration, and the result would be to
3438 -- drag in a body which has no direct inlining associated with
3439 -- it. That would not only be inefficient but would also result
3440 -- in the backend doing cross-unit inlining in cases where it
3441 -- was definitely inappropriate to do so.
3443 -- However, a simple Comes_From_Source test is insufficient,
3444 -- since we do want to allow inlining of generic instances,
3445 -- which also do not come from source. Predefined operators do
3446 -- not come from source but are not inlineable either.
3448 elsif not Comes_From_Source (Subp)
3449 and then not Is_Generic_Instance (Subp)
3450 and then Scope (Subp) /= Standard_Standard
3455 -- The referenced entity must either be the enclosing entity,
3456 -- or an entity declared within the current open scope.
3458 elsif Present (Scope (Subp))
3459 and then Scope (Subp) /= Current_Scope
3460 and then Subp /= Current_Scope
3463 ("argument of% must be entity in current scope", Assoc);
3467 -- Processing for procedure, operator or function.
3468 -- If subprogram is aliased (as for an instance) indicate
3469 -- that the renamed entity (if declared in the same unit)
3472 if Is_Subprogram (Subp) then
3473 while Present (Alias (Inner_Subp)) loop
3474 Inner_Subp := Alias (Inner_Subp);
3477 if In_Same_Source_Unit (Subp, Inner_Subp) then
3478 Set_Inline_Flags (Inner_Subp);
3480 Decl := Parent (Parent (Inner_Subp));
3482 if Nkind (Decl) = N_Subprogram_Declaration
3483 and then Present (Corresponding_Body (Decl))
3485 Set_Inline_Flags (Corresponding_Body (Decl));
3491 -- For a generic subprogram set flag as well, for use at
3492 -- the point of instantiation, to determine whether the
3493 -- body should be generated.
3495 elsif Is_Generic_Subprogram (Subp) then
3496 Set_Inline_Flags (Subp);
3499 -- Literals are by definition inlined
3501 elsif Kind = E_Enumeration_Literal then
3504 -- Anything else is an error
3508 ("expect subprogram name for pragma%", Assoc);
3512 ----------------------
3513 -- Set_Inline_Flags --
3514 ----------------------
3516 procedure Set_Inline_Flags (Subp : Entity_Id) is
3519 Set_Is_Inlined (Subp, True);
3522 if not Has_Pragma_Inline (Subp) then
3523 Set_Has_Pragma_Inline (Subp);
3527 if Prag_Id = Pragma_Inline_Always then
3528 Set_Has_Pragma_Inline_Always (Subp);
3530 end Set_Inline_Flags;
3532 -- Start of processing for Process_Inline
3535 Check_No_Identifiers;
3536 Check_At_Least_N_Arguments (1);
3539 Inline_Processing_Required := True;
3543 while Present (Assoc) loop
3544 Subp_Id := Expression (Assoc);
3548 if Is_Entity_Name (Subp_Id) then
3549 Subp := Entity (Subp_Id);
3551 if Subp = Any_Id then
3553 -- If previous error, avoid cascaded errors
3561 while Present (Homonym (Subp))
3562 and then Scope (Homonym (Subp)) = Current_Scope
3564 Make_Inline (Homonym (Subp));
3565 Subp := Homonym (Subp);
3572 ("inappropriate argument for pragma%", Assoc);
3575 and then Warn_On_Redundant_Constructs
3576 and then not Suppress_All_Inlining
3578 if Inlining_Not_Possible (Subp) then
3580 ("pragma Inline for& is ignored?", N, Entity (Subp_Id));
3583 ("pragma Inline for& is redundant?", N, Entity (Subp_Id));
3591 ----------------------------
3592 -- Process_Interface_Name --
3593 ----------------------------
3595 procedure Process_Interface_Name
3596 (Subprogram_Def : Entity_Id;
3602 String_Val : String_Id;
3604 procedure Check_Form_Of_Interface_Name (SN : Node_Id);
3605 -- SN is a string literal node for an interface name. This routine
3606 -- performs some minimal checks that the name is reasonable. In
3607 -- particular that no spaces or other obviously incorrect characters
3608 -- appear. This is only a warning, since any characters are allowed.
3610 ----------------------------------
3611 -- Check_Form_Of_Interface_Name --
3612 ----------------------------------
3614 procedure Check_Form_Of_Interface_Name (SN : Node_Id) is
3615 S : constant String_Id := Strval (Expr_Value_S (SN));
3616 SL : constant Nat := String_Length (S);
3621 Error_Msg_N ("interface name cannot be null string", SN);
3624 for J in 1 .. SL loop
3625 C := Get_String_Char (S, J);
3627 if Warn_On_Export_Import
3629 (not In_Character_Range (C)
3630 or else (Get_Character (C) = ' '
3631 and then VM_Target /= CLI_Target)
3632 or else Get_Character (C) = ',')
3635 ("?interface name contains illegal character", SN);
3638 end Check_Form_Of_Interface_Name;
3640 -- Start of processing for Process_Interface_Name
3643 if No (Link_Arg) then
3644 if No (Ext_Arg) then
3645 if VM_Target = CLI_Target
3646 and then Ekind (Subprogram_Def) = E_Package
3647 and then Nkind (Parent (Subprogram_Def)) =
3648 N_Package_Specification
3649 and then Present (Generic_Parent (Parent (Subprogram_Def)))
3654 (Generic_Parent (Parent (Subprogram_Def))));
3659 elsif Chars (Ext_Arg) = Name_Link_Name then
3661 Link_Nam := Expression (Ext_Arg);
3664 Check_Optional_Identifier (Ext_Arg, Name_External_Name);
3665 Ext_Nam := Expression (Ext_Arg);
3670 Check_Optional_Identifier (Ext_Arg, Name_External_Name);
3671 Check_Optional_Identifier (Link_Arg, Name_Link_Name);
3672 Ext_Nam := Expression (Ext_Arg);
3673 Link_Nam := Expression (Link_Arg);
3676 -- Check expressions for external name and link name are static
3678 if Present (Ext_Nam) then
3679 Check_Arg_Is_Static_Expression (Ext_Nam, Standard_String);
3680 Check_Form_Of_Interface_Name (Ext_Nam);
3682 -- Verify that the external name is not the name of a local
3683 -- entity, which would hide the imported one and lead to
3684 -- run-time surprises. The problem can only arise for entities
3685 -- declared in a package body (otherwise the external name is
3686 -- fully qualified and won't conflict).
3694 if Prag_Id = Pragma_Import then
3695 String_To_Name_Buffer (Strval (Expr_Value_S (Ext_Nam)));
3697 E := Entity_Id (Get_Name_Table_Info (Nam));
3699 if Nam /= Chars (Subprogram_Def)
3700 and then Present (E)
3701 and then not Is_Overloadable (E)
3702 and then Is_Immediately_Visible (E)
3703 and then not Is_Imported (E)
3704 and then Ekind (Scope (E)) = E_Package
3707 while Present (Par) loop
3708 if Nkind (Par) = N_Package_Body then
3709 Error_Msg_Sloc := Sloc (E);
3711 ("imported entity is hidden by & declared#",
3716 Par := Parent (Par);
3723 if Present (Link_Nam) then
3724 Check_Arg_Is_Static_Expression (Link_Nam, Standard_String);
3725 Check_Form_Of_Interface_Name (Link_Nam);
3728 -- If there is no link name, just set the external name
3730 if No (Link_Nam) then
3731 Link_Nam := Adjust_External_Name_Case (Expr_Value_S (Ext_Nam));
3733 -- For the Link_Name case, the given literal is preceded by an
3734 -- asterisk, which indicates to GCC that the given name should
3735 -- be taken literally, and in particular that no prepending of
3736 -- underlines should occur, even in systems where this is the
3742 if VM_Target = No_VM then
3743 Store_String_Char (Get_Char_Code ('*'));
3746 String_Val := Strval (Expr_Value_S (Link_Nam));
3747 Store_String_Chars (String_Val);
3749 Make_String_Literal (Sloc (Link_Nam),
3750 Strval => End_String);
3753 Set_Encoded_Interface_Name
3754 (Get_Base_Subprogram (Subprogram_Def), Link_Nam);
3755 Check_Duplicated_Export_Name (Link_Nam);
3756 end Process_Interface_Name;
3758 -----------------------------------------
3759 -- Process_Interrupt_Or_Attach_Handler --
3760 -----------------------------------------
3762 procedure Process_Interrupt_Or_Attach_Handler is
3763 Arg1_X : constant Node_Id := Expression (Arg1);
3764 Handler_Proc : constant Entity_Id := Entity (Arg1_X);
3765 Proc_Scope : constant Entity_Id := Scope (Handler_Proc);
3768 Set_Is_Interrupt_Handler (Handler_Proc);
3770 -- If the pragma is not associated with a handler procedure
3771 -- within a protected type, then it must be for a nonprotected
3772 -- procedure for the AAMP target, in which case we don't
3773 -- associate a representation item with the procedure's scope.
3775 if Ekind (Proc_Scope) = E_Protected_Type then
3776 if Prag_Id = Pragma_Interrupt_Handler
3778 Prag_Id = Pragma_Attach_Handler
3780 Record_Rep_Item (Proc_Scope, N);
3783 end Process_Interrupt_Or_Attach_Handler;
3785 --------------------------------------------------
3786 -- Process_Restrictions_Or_Restriction_Warnings --
3787 --------------------------------------------------
3789 -- Note: some of the simple identifier cases were handled in par-prag,
3790 -- but it is harmless (and more straightforward) to simply handle all
3791 -- cases here, even if it means we repeat a bit of work in some cases.
3793 procedure Process_Restrictions_Or_Restriction_Warnings
3797 R_Id : Restriction_Id;
3802 procedure Check_Unit_Name (N : Node_Id);
3803 -- Checks unit name parameter for No_Dependence. Returns if it has
3804 -- an appropriate form, otherwise raises pragma argument error.
3806 ---------------------
3807 -- Check_Unit_Name --
3808 ---------------------
3810 procedure Check_Unit_Name (N : Node_Id) is
3812 if Nkind (N) = N_Selected_Component then
3813 Check_Unit_Name (Prefix (N));
3814 Check_Unit_Name (Selector_Name (N));
3816 elsif Nkind (N) = N_Identifier then
3821 ("wrong form for unit name for No_Dependence", N);
3823 end Check_Unit_Name;
3825 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
3828 Check_Ada_83_Warning;
3829 Check_At_Least_N_Arguments (1);
3830 Check_Valid_Configuration_Pragma;
3833 while Present (Arg) loop
3835 Expr := Expression (Arg);
3837 -- Case of no restriction identifier present
3839 if Id = No_Name then
3840 if Nkind (Expr) /= N_Identifier then
3842 ("invalid form for restriction", Arg);
3847 (Process_Restriction_Synonyms (Expr));
3849 if R_Id not in All_Boolean_Restrictions then
3851 ("invalid restriction identifier", Arg);
3854 if Implementation_Restriction (R_Id) then
3856 (No_Implementation_Restrictions, Arg);
3859 -- If this is a warning, then set the warning unless we already
3860 -- have a real restriction active (we never want a warning to
3861 -- override a real restriction).
3864 if not Restriction_Active (R_Id) then
3865 Set_Restriction (R_Id, N);
3866 Restriction_Warnings (R_Id) := True;
3869 -- If real restriction case, then set it and make sure that the
3870 -- restriction warning flag is off, since a real restriction
3871 -- always overrides a warning.
3874 Set_Restriction (R_Id, N);
3875 Restriction_Warnings (R_Id) := False;
3878 -- A very special case that must be processed here: pragma
3879 -- Restrictions (No_Exceptions) turns off all run-time
3880 -- checking. This is a bit dubious in terms of the formal
3881 -- language definition, but it is what is intended by RM
3882 -- H.4(12). Restriction_Warnings never affects generated code
3883 -- so this is done only in the real restriction case.
3885 if R_Id = No_Exceptions and then not Warn then
3886 Scope_Suppress := (others => True);
3889 -- Case of No_Dependence => unit-name. Note that the parser
3890 -- already made the necessary entry in the No_Dependence table.
3892 elsif Id = Name_No_Dependence then
3893 Check_Unit_Name (Expr);
3895 -- All other cases of restriction identifier present
3898 R_Id := Get_Restriction_Id (Process_Restriction_Synonyms (Arg));
3899 Analyze_And_Resolve (Expr, Any_Integer);
3901 if R_Id not in All_Parameter_Restrictions then
3903 ("invalid restriction parameter identifier", Arg);
3905 elsif not Is_OK_Static_Expression (Expr) then
3906 Flag_Non_Static_Expr
3907 ("value must be static expression!", Expr);
3910 elsif not Is_Integer_Type (Etype (Expr))
3911 or else Expr_Value (Expr) < 0
3914 ("value must be non-negative integer", Arg);
3917 -- Restriction pragma is active
3919 Val := Expr_Value (Expr);
3921 if not UI_Is_In_Int_Range (Val) then
3923 ("pragma ignored, value too large?", Arg);
3926 -- Warning case. If the real restriction is active, then we
3927 -- ignore the request, since warning never overrides a real
3928 -- restriction. Otherwise we set the proper warning. Note that
3929 -- this circuit sets the warning again if it is already set,
3930 -- which is what we want, since the constant may have changed.
3933 if not Restriction_Active (R_Id) then
3935 (R_Id, N, Integer (UI_To_Int (Val)));
3936 Restriction_Warnings (R_Id) := True;
3939 -- Real restriction case, set restriction and make sure warning
3940 -- flag is off since real restriction always overrides warning.
3943 Set_Restriction (R_Id, N, Integer (UI_To_Int (Val)));
3944 Restriction_Warnings (R_Id) := False;
3950 end Process_Restrictions_Or_Restriction_Warnings;
3952 ---------------------------------
3953 -- Process_Suppress_Unsuppress --
3954 ---------------------------------
3956 -- Note: this procedure makes entries in the check suppress data
3957 -- structures managed by Sem. See spec of package Sem for full
3958 -- details on how we handle recording of check suppression.
3960 procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean) is
3965 In_Package_Spec : constant Boolean :=
3966 (Ekind (Current_Scope) = E_Package
3968 Ekind (Current_Scope) = E_Generic_Package)
3969 and then not In_Package_Body (Current_Scope);
3971 procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id);
3972 -- Used to suppress a single check on the given entity
3974 --------------------------------
3975 -- Suppress_Unsuppress_Echeck --
3976 --------------------------------
3978 procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id) is
3980 Set_Checks_May_Be_Suppressed (E);
3982 if In_Package_Spec then
3983 Push_Global_Suppress_Stack_Entry
3986 Suppress => Suppress_Case);
3989 Push_Local_Suppress_Stack_Entry
3992 Suppress => Suppress_Case);
3995 -- If this is a first subtype, and the base type is distinct,
3996 -- then also set the suppress flags on the base type.
3998 if Is_First_Subtype (E)
3999 and then Etype (E) /= E
4001 Suppress_Unsuppress_Echeck (Etype (E), C);
4003 end Suppress_Unsuppress_Echeck;
4005 -- Start of processing for Process_Suppress_Unsuppress
4008 -- Suppress/Unsuppress can appear as a configuration pragma,
4009 -- or in a declarative part or a package spec (RM 11.5(5))
4011 if not Is_Configuration_Pragma then
4012 Check_Is_In_Decl_Part_Or_Package_Spec;
4015 Check_At_Least_N_Arguments (1);
4016 Check_At_Most_N_Arguments (2);
4017 Check_No_Identifier (Arg1);
4018 Check_Arg_Is_Identifier (Arg1);
4020 C := Get_Check_Id (Chars (Expression (Arg1)));
4022 if C = No_Check_Id then
4024 ("argument of pragma% is not valid check name", Arg1);
4027 if not Suppress_Case
4028 and then (C = All_Checks or else C = Overflow_Check)
4030 Opt.Overflow_Checks_Unsuppressed := True;
4033 if Arg_Count = 1 then
4035 -- Make an entry in the local scope suppress table. This is the
4036 -- table that directly shows the current value of the scope
4037 -- suppress check for any check id value.
4039 if C = All_Checks then
4041 -- For All_Checks, we set all specific predefined checks with
4042 -- the exception of Elaboration_Check, which is handled
4043 -- specially because of not wanting All_Checks to have the
4044 -- effect of deactivating static elaboration order processing.
4046 for J in Scope_Suppress'Range loop
4047 if J /= Elaboration_Check then
4048 Scope_Suppress (J) := Suppress_Case;
4052 -- If not All_Checks, and predefined check, then set appropriate
4053 -- scope entry. Note that we will set Elaboration_Check if this
4054 -- is explicitly specified.
4056 elsif C in Predefined_Check_Id then
4057 Scope_Suppress (C) := Suppress_Case;
4060 -- Also make an entry in the Local_Entity_Suppress table
4062 Push_Local_Suppress_Stack_Entry
4065 Suppress => Suppress_Case);
4067 -- Case of two arguments present, where the check is suppressed for
4068 -- a specified entity (given as the second argument of the pragma)
4071 Check_Optional_Identifier (Arg2, Name_On);
4072 E_Id := Expression (Arg2);
4075 if not Is_Entity_Name (E_Id) then
4077 ("second argument of pragma% must be entity name", Arg2);
4086 -- Enforce RM 11.5(7) which requires that for a pragma that
4087 -- appears within a package spec, the named entity must be
4088 -- within the package spec. We allow the package name itself
4089 -- to be mentioned since that makes sense, although it is not
4090 -- strictly allowed by 11.5(7).
4093 and then E /= Current_Scope
4094 and then Scope (E) /= Current_Scope
4097 ("entity in pragma% is not in package spec (RM 11.5(7))",
4101 -- Loop through homonyms. As noted below, in the case of a package
4102 -- spec, only homonyms within the package spec are considered.
4105 Suppress_Unsuppress_Echeck (E, C);
4107 if Is_Generic_Instance (E)
4108 and then Is_Subprogram (E)
4109 and then Present (Alias (E))
4111 Suppress_Unsuppress_Echeck (Alias (E), C);
4114 -- Move to next homonym
4119 -- If we are within a package specification, the
4120 -- pragma only applies to homonyms in the same scope.
4122 exit when In_Package_Spec
4123 and then Scope (E) /= Current_Scope;
4126 end Process_Suppress_Unsuppress;
4132 procedure Set_Exported (E : Entity_Id; Arg : Node_Id) is
4134 if Is_Imported (E) then
4136 ("cannot export entity& that was previously imported", Arg);
4138 elsif Present (Address_Clause (E)) then
4140 ("cannot export entity& that has an address clause", Arg);
4143 Set_Is_Exported (E);
4145 -- Generate a reference for entity explicitly, because the
4146 -- identifier may be overloaded and name resolution will not
4149 Generate_Reference (E, Arg);
4151 -- Deal with exporting non-library level entity
4153 if not Is_Library_Level_Entity (E) then
4155 -- Not allowed at all for subprograms
4157 if Is_Subprogram (E) then
4158 Error_Pragma_Arg ("local subprogram& cannot be exported", Arg);
4160 -- Otherwise set public and statically allocated
4164 Set_Is_Statically_Allocated (E);
4166 -- Warn if the corresponding W flag is set and the pragma
4167 -- comes from source. The latter may not be true e.g. on
4168 -- VMS where we expand export pragmas for exception codes
4169 -- associated with imported or exported exceptions. We do
4170 -- not want to generate a warning for something that the
4171 -- user did not write.
4173 if Warn_On_Export_Import
4174 and then Comes_From_Source (Arg)
4177 ("?& has been made static as a result of Export", Arg, E);
4179 ("\this usage is non-standard and non-portable", Arg);
4184 if Warn_On_Export_Import and then Is_Type (E) then
4186 ("exporting a type has no effect?", Arg, E);
4189 if Warn_On_Export_Import and Inside_A_Generic then
4191 ("all instances of& will have the same external name?", Arg, E);
4195 ----------------------------------------------
4196 -- Set_Extended_Import_Export_External_Name --
4197 ----------------------------------------------
4199 procedure Set_Extended_Import_Export_External_Name
4200 (Internal_Ent : Entity_Id;
4201 Arg_External : Node_Id)
4203 Old_Name : constant Node_Id := Interface_Name (Internal_Ent);
4207 if No (Arg_External) then
4211 Check_Arg_Is_External_Name (Arg_External);
4213 if Nkind (Arg_External) = N_String_Literal then
4214 if String_Length (Strval (Arg_External)) = 0 then
4217 New_Name := Adjust_External_Name_Case (Arg_External);
4220 elsif Nkind (Arg_External) = N_Identifier then
4221 New_Name := Get_Default_External_Name (Arg_External);
4223 -- Check_Arg_Is_External_Name should let through only
4224 -- identifiers and string literals or static string
4225 -- expressions (which are folded to string literals).
4228 raise Program_Error;
4231 -- If we already have an external name set (by a prior normal
4232 -- Import or Export pragma), then the external names must match
4234 if Present (Interface_Name (Internal_Ent)) then
4235 Check_Matching_Internal_Names : declare
4236 S1 : constant String_Id := Strval (Old_Name);
4237 S2 : constant String_Id := Strval (New_Name);
4240 -- Called if names do not match
4246 procedure Mismatch is
4248 Error_Msg_Sloc := Sloc (Old_Name);
4250 ("external name does not match that given #",
4254 -- Start of processing for Check_Matching_Internal_Names
4257 if String_Length (S1) /= String_Length (S2) then
4261 for J in 1 .. String_Length (S1) loop
4262 if Get_String_Char (S1, J) /= Get_String_Char (S2, J) then
4267 end Check_Matching_Internal_Names;
4269 -- Otherwise set the given name
4272 Set_Encoded_Interface_Name (Internal_Ent, New_Name);
4273 Check_Duplicated_Export_Name (New_Name);
4275 end Set_Extended_Import_Export_External_Name;
4281 procedure Set_Imported (E : Entity_Id) is
4283 -- Error message if already imported or exported
4285 if Is_Exported (E) or else Is_Imported (E) then
4286 if Is_Exported (E) then
4287 Error_Msg_NE ("entity& was previously exported", N, E);
4289 Error_Msg_NE ("entity& was previously imported", N, E);
4292 Error_Msg_Name_1 := Chars (N);
4294 ("\(pragma% applies to all previous entities)", N);
4296 Error_Msg_Sloc := Sloc (E);
4297 Error_Msg_NE ("\import not allowed for& declared#", N, E);
4299 -- Here if not previously imported or exported, OK to import
4302 Set_Is_Imported (E);
4304 -- If the entity is an object that is not at the library
4305 -- level, then it is statically allocated. We do not worry
4306 -- about objects with address clauses in this context since
4307 -- they are not really imported in the linker sense.
4310 and then not Is_Library_Level_Entity (E)
4311 and then No (Address_Clause (E))
4313 Set_Is_Statically_Allocated (E);
4318 -------------------------
4319 -- Set_Mechanism_Value --
4320 -------------------------
4322 -- Note: the mechanism name has not been analyzed (and cannot indeed
4323 -- be analyzed, since it is semantic nonsense), so we get it in the
4324 -- exact form created by the parser.
4326 procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id) is
4330 procedure Bad_Class;
4331 -- Signal bad descriptor class name
4333 procedure Bad_Mechanism;
4334 -- Signal bad mechanism name
4340 procedure Bad_Class is
4342 Error_Pragma_Arg ("unrecognized descriptor class name", Class);
4345 -------------------------
4346 -- Bad_Mechanism_Value --
4347 -------------------------
4349 procedure Bad_Mechanism is
4351 Error_Pragma_Arg ("unrecognized mechanism name", Mech_Name);
4354 -- Start of processing for Set_Mechanism_Value
4357 if Mechanism (Ent) /= Default_Mechanism then
4359 ("mechanism for & has already been set", Mech_Name, Ent);
4362 -- MECHANISM_NAME ::= value | reference | descriptor
4364 if Nkind (Mech_Name) = N_Identifier then
4365 if Chars (Mech_Name) = Name_Value then
4366 Set_Mechanism (Ent, By_Copy);
4369 elsif Chars (Mech_Name) = Name_Reference then
4370 Set_Mechanism (Ent, By_Reference);
4373 elsif Chars (Mech_Name) = Name_Descriptor then
4374 Check_VMS (Mech_Name);
4375 Set_Mechanism (Ent, By_Descriptor);
4378 elsif Chars (Mech_Name) = Name_Copy then
4380 ("bad mechanism name, Value assumed", Mech_Name);
4386 -- MECHANISM_NAME ::= descriptor (CLASS_NAME)
4387 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4389 -- Note: this form is parsed as an indexed component
4391 elsif Nkind (Mech_Name) = N_Indexed_Component then
4392 Class := First (Expressions (Mech_Name));
4394 if Nkind (Prefix (Mech_Name)) /= N_Identifier
4395 or else Chars (Prefix (Mech_Name)) /= Name_Descriptor
4396 or else Present (Next (Class))
4401 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME)
4402 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4404 -- Note: this form is parsed as a function call
4406 elsif Nkind (Mech_Name) = N_Function_Call then
4408 Param := First (Parameter_Associations (Mech_Name));
4410 if Nkind (Name (Mech_Name)) /= N_Identifier
4411 or else Chars (Name (Mech_Name)) /= Name_Descriptor
4412 or else Present (Next (Param))
4413 or else No (Selector_Name (Param))
4414 or else Chars (Selector_Name (Param)) /= Name_Class
4418 Class := Explicit_Actual_Parameter (Param);
4425 -- Fall through here with Class set to descriptor class name
4427 Check_VMS (Mech_Name);
4429 if Nkind (Class) /= N_Identifier then
4432 elsif Chars (Class) = Name_UBS then
4433 Set_Mechanism (Ent, By_Descriptor_UBS);
4435 elsif Chars (Class) = Name_UBSB then
4436 Set_Mechanism (Ent, By_Descriptor_UBSB);
4438 elsif Chars (Class) = Name_UBA then
4439 Set_Mechanism (Ent, By_Descriptor_UBA);
4441 elsif Chars (Class) = Name_S then
4442 Set_Mechanism (Ent, By_Descriptor_S);
4444 elsif Chars (Class) = Name_SB then
4445 Set_Mechanism (Ent, By_Descriptor_SB);
4447 elsif Chars (Class) = Name_A then
4448 Set_Mechanism (Ent, By_Descriptor_A);
4450 elsif Chars (Class) = Name_NCA then
4451 Set_Mechanism (Ent, By_Descriptor_NCA);
4456 end Set_Mechanism_Value;
4458 ---------------------------
4459 -- Set_Ravenscar_Profile --
4460 ---------------------------
4462 -- The tasks to be done here are
4464 -- Set required policies
4466 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4467 -- pragma Locking_Policy (Ceiling_Locking)
4469 -- Set Detect_Blocking mode
4471 -- Set required restrictions (see System.Rident for detailed list)
4473 procedure Set_Ravenscar_Profile (N : Node_Id) is
4475 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4477 if Task_Dispatching_Policy /= ' '
4478 and then Task_Dispatching_Policy /= 'F'
4480 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
4481 Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
4483 -- Set the FIFO_Within_Priorities policy, but always preserve
4484 -- System_Location since we like the error message with the run time
4488 Task_Dispatching_Policy := 'F';
4490 if Task_Dispatching_Policy_Sloc /= System_Location then
4491 Task_Dispatching_Policy_Sloc := Loc;
4495 -- pragma Locking_Policy (Ceiling_Locking)
4497 if Locking_Policy /= ' '
4498 and then Locking_Policy /= 'C'
4500 Error_Msg_Sloc := Locking_Policy_Sloc;
4501 Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
4503 -- Set the Ceiling_Locking policy, but preserve System_Location since
4504 -- we like the error message with the run time name.
4507 Locking_Policy := 'C';
4509 if Locking_Policy_Sloc /= System_Location then
4510 Locking_Policy_Sloc := Loc;
4514 -- pragma Detect_Blocking
4516 Detect_Blocking := True;
4518 -- Set the corresponding restrictions
4520 Set_Profile_Restrictions (Ravenscar, N, Warn => False);
4521 end Set_Ravenscar_Profile;
4523 -- Start of processing for Analyze_Pragma
4526 -- Deal with unrecognized pragma
4528 if not Is_Pragma_Name (Chars (N)) then
4529 if Warn_On_Unrecognized_Pragma then
4530 Error_Msg_Name_1 := Chars (N);
4531 Error_Msg_N ("?unrecognized pragma%!", Pragma_Identifier (N));
4533 for PN in First_Pragma_Name .. Last_Pragma_Name loop
4534 if Is_Bad_Spelling_Of (Chars (N), PN) then
4535 Error_Msg_Name_1 := PN;
4537 ("\?possible misspelling of %!", Pragma_Identifier (N));
4546 -- Here to start processing for recognized pragma
4548 Prag_Id := Get_Pragma_Id (Chars (N));
4557 if Present (Pragma_Argument_Associations (N)) then
4558 Arg1 := First (Pragma_Argument_Associations (N));
4560 if Present (Arg1) then
4561 Arg2 := Next (Arg1);
4563 if Present (Arg2) then
4564 Arg3 := Next (Arg2);
4566 if Present (Arg3) then
4567 Arg4 := Next (Arg3);
4573 -- Count number of arguments
4580 while Present (Arg_Node) loop
4581 Arg_Count := Arg_Count + 1;
4586 -- An enumeration type defines the pragmas that are supported by the
4587 -- implementation. Get_Pragma_Id (in package Prag) transorms a name
4588 -- into the corresponding enumeration value for the following case.
4596 -- pragma Abort_Defer;
4598 when Pragma_Abort_Defer =>
4600 Check_Arg_Count (0);
4602 -- The only required semantic processing is to check the
4603 -- placement. This pragma must appear at the start of the
4604 -- statement sequence of a handled sequence of statements.
4606 if Nkind (Parent (N)) /= N_Handled_Sequence_Of_Statements
4607 or else N /= First (Statements (Parent (N)))
4618 -- Note: this pragma also has some specific processing in Par.Prag
4619 -- because we want to set the Ada version mode during parsing.
4621 when Pragma_Ada_83 =>
4623 Check_Arg_Count (0);
4625 -- We really should check unconditionally for proper configuration
4626 -- pragma placement, since we really don't want mixed Ada modes
4627 -- within a single unit, and the GNAT reference manual has always
4628 -- said this was a configuration pragma, but we did not check and
4629 -- are hesitant to add the check now.
4631 -- However, we really cannot tolerate mixing Ada 2005 with Ada 83
4632 -- or Ada 95, so we must check if we are in Ada 2005 mode.
4634 if Ada_Version >= Ada_05 then
4635 Check_Valid_Configuration_Pragma;
4638 -- Now set Ada 83 mode
4640 Ada_Version := Ada_83;
4641 Ada_Version_Explicit := Ada_Version;
4649 -- Note: this pragma also has some specific processing in Par.Prag
4650 -- because we want to set the Ada 83 version mode during parsing.
4652 when Pragma_Ada_95 =>
4654 Check_Arg_Count (0);
4656 -- We really should check unconditionally for proper configuration
4657 -- pragma placement, since we really don't want mixed Ada modes
4658 -- within a single unit, and the GNAT reference manual has always
4659 -- said this was a configuration pragma, but we did not check and
4660 -- are hesitant to add the check now.
4662 -- However, we really cannot tolerate mixing Ada 2005 with Ada 83
4663 -- or Ada 95, so we must check if we are in Ada 2005 mode.
4665 if Ada_Version >= Ada_05 then
4666 Check_Valid_Configuration_Pragma;
4669 -- Now set Ada 95 mode
4671 Ada_Version := Ada_95;
4672 Ada_Version_Explicit := Ada_Version;
4674 ---------------------
4675 -- Ada_05/Ada_2005 --
4676 ---------------------
4679 -- pragma Ada_05 (LOCAL_NAME);
4682 -- pragma Ada_2005 (LOCAL_NAME):
4684 -- Note: these pragma also have some specific processing in Par.Prag
4685 -- because we want to set the Ada 2005 version mode during parsing.
4687 when Pragma_Ada_05 | Pragma_Ada_2005 => declare
4693 if Arg_Count = 1 then
4694 Check_Arg_Is_Local_Name (Arg1);
4695 E_Id := Expression (Arg1);
4697 if Etype (E_Id) = Any_Type then
4701 Set_Is_Ada_2005_Only (Entity (E_Id));
4704 Check_Arg_Count (0);
4706 -- For Ada_2005 we unconditionally enforce the documented
4707 -- configuration pragma placement, since we do not want to
4708 -- tolerate mixed modes in a unit involving Ada 2005. That
4709 -- would cause real difficulties for those cases where there
4710 -- are incompatibilities between Ada 95 and Ada 2005.
4712 Check_Valid_Configuration_Pragma;
4714 -- Now set Ada 2005 mode
4716 Ada_Version := Ada_05;
4717 Ada_Version_Explicit := Ada_05;
4721 ----------------------
4722 -- All_Calls_Remote --
4723 ----------------------
4725 -- pragma All_Calls_Remote [(library_package_NAME)];
4727 when Pragma_All_Calls_Remote => All_Calls_Remote : declare
4728 Lib_Entity : Entity_Id;
4731 Check_Ada_83_Warning;
4732 Check_Valid_Library_Unit_Pragma;
4734 if Nkind (N) = N_Null_Statement then
4738 Lib_Entity := Find_Lib_Unit_Name;
4740 -- This pragma should only apply to a RCI unit (RM E.2.3(23))
4742 if Present (Lib_Entity)
4743 and then not Debug_Flag_U
4745 if not Is_Remote_Call_Interface (Lib_Entity) then
4746 Error_Pragma ("pragma% only apply to rci unit");
4748 -- Set flag for entity of the library unit
4751 Set_Has_All_Calls_Remote (Lib_Entity);
4755 end All_Calls_Remote;
4761 -- pragma Annotate (IDENTIFIER {, ARG});
4762 -- ARG ::= NAME | EXPRESSION
4764 when Pragma_Annotate => Annotate : begin
4766 Check_At_Least_N_Arguments (1);
4767 Check_Arg_Is_Identifier (Arg1);
4775 while Present (Arg) loop
4776 Exp := Expression (Arg);
4779 if Is_Entity_Name (Exp) then
4782 elsif Nkind (Exp) = N_String_Literal then
4783 Resolve (Exp, Standard_String);
4785 elsif Is_Overloaded (Exp) then
4786 Error_Pragma_Arg ("ambiguous argument for pragma%", Exp);
4801 -- pragma Assert ([Check =>] Boolean_EXPRESSION
4802 -- [, [Message =>] Static_String_EXPRESSION]);
4804 when Pragma_Assert => Assert : declare
4810 Check_At_Least_N_Arguments (1);
4811 Check_At_Most_N_Arguments (2);
4812 Check_Arg_Order ((Name_Check, Name_Message));
4813 Check_Optional_Identifier (Arg1, Name_Check);
4815 if Arg_Count > 1 then
4816 Check_Optional_Identifier (Arg2, Name_Message);
4817 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
4820 -- If expansion is active and assertions are inactive, then
4821 -- we rewrite the Assertion as:
4823 -- if False and then condition then
4827 -- The reason we do this rewriting during semantic analysis rather
4828 -- than as part of normal expansion is that we cannot analyze and
4829 -- expand the code for the boolean expression directly, or it may
4830 -- cause insertion of actions that would escape the attempt to
4831 -- suppress the assertion code.
4833 -- Note that the Sloc for the if statement corresponds to the
4834 -- argument condition, not the pragma itself. The reason for this
4835 -- is that we may generate a warning if the condition is False at
4836 -- compile time, and we do not want to delete this warning when we
4837 -- delete the if statement.
4839 Expr := Expression (Arg1);
4840 Eloc := Sloc (Expr);
4842 if Expander_Active and not Assertions_Enabled then
4844 Make_If_Statement (Eloc,
4846 Make_And_Then (Eloc,
4847 Left_Opnd => New_Occurrence_Of (Standard_False, Eloc),
4848 Right_Opnd => Expr),
4849 Then_Statements => New_List (
4850 Make_Null_Statement (Eloc))));
4854 -- Otherwise (if assertions are enabled, or if we are not
4855 -- operating with expansion active), then we just analyze
4856 -- and resolve the expression.
4859 Analyze_And_Resolve (Expr, Any_Boolean);
4862 -- If assertion is of the form (X'First = literal), where X is
4863 -- formal parameter, then set Low_Bound_Known flag on this formal.
4865 if Nkind (Expr) = N_Op_Eq then
4867 Right : constant Node_Id := Right_Opnd (Expr);
4868 Left : constant Node_Id := Left_Opnd (Expr);
4870 if Nkind (Left) = N_Attribute_Reference
4871 and then Attribute_Name (Left) = Name_First
4872 and then Is_Entity_Name (Prefix (Left))
4873 and then Is_Formal (Entity (Prefix (Left)))
4874 and then Nkind (Right) = N_Integer_Literal
4876 Set_Low_Bound_Known (Entity (Prefix (Left)));
4882 ----------------------
4883 -- Assertion_Policy --
4884 ----------------------
4886 -- pragma Assertion_Policy (Check | Ignore)
4888 when Pragma_Assertion_Policy =>
4890 Check_Arg_Count (1);
4891 Check_Arg_Is_One_Of (Arg1, Name_Check, Name_Ignore);
4892 Assertions_Enabled := Chars (Expression (Arg1)) = Name_Check;
4898 -- pragma AST_Entry (entry_IDENTIFIER);
4900 when Pragma_AST_Entry => AST_Entry : declare
4906 Check_Arg_Count (1);
4907 Check_No_Identifiers;
4908 Check_Arg_Is_Local_Name (Arg1);
4909 Ent := Entity (Expression (Arg1));
4911 -- Note: the implementation of the AST_Entry pragma could handle
4912 -- the entry family case fine, but for now we are consistent with
4913 -- the DEC rules, and do not allow the pragma, which of course
4914 -- has the effect of also forbidding the attribute.
4916 if Ekind (Ent) /= E_Entry then
4918 ("pragma% argument must be simple entry name", Arg1);
4920 elsif Is_AST_Entry (Ent) then
4922 ("duplicate % pragma for entry", Arg1);
4924 elsif Has_Homonym (Ent) then
4926 ("pragma% argument cannot specify overloaded entry", Arg1);
4930 FF : constant Entity_Id := First_Formal (Ent);
4933 if Present (FF) then
4934 if Present (Next_Formal (FF)) then
4936 ("entry for pragma% can have only one argument",
4939 elsif Parameter_Mode (FF) /= E_In_Parameter then
4941 ("entry parameter for pragma% must have mode IN",
4947 Set_Is_AST_Entry (Ent);
4955 -- pragma Asynchronous (LOCAL_NAME);
4957 when Pragma_Asynchronous => Asynchronous : declare
4965 procedure Process_Async_Pragma;
4966 -- Common processing for procedure and access-to-procedure case
4968 --------------------------
4969 -- Process_Async_Pragma --
4970 --------------------------
4972 procedure Process_Async_Pragma is
4975 Set_Is_Asynchronous (Nm);
4979 -- The formals should be of mode IN (RM E.4.1(6))
4982 while Present (S) loop
4983 Formal := Defining_Identifier (S);
4985 if Nkind (Formal) = N_Defining_Identifier
4986 and then Ekind (Formal) /= E_In_Parameter
4989 ("pragma% procedure can only have IN parameter",
4996 Set_Is_Asynchronous (Nm);
4997 end Process_Async_Pragma;
4999 -- Start of processing for pragma Asynchronous
5002 Check_Ada_83_Warning;
5003 Check_No_Identifiers;
5004 Check_Arg_Count (1);
5005 Check_Arg_Is_Local_Name (Arg1);
5007 if Debug_Flag_U then
5011 C_Ent := Cunit_Entity (Current_Sem_Unit);
5012 Analyze (Expression (Arg1));
5013 Nm := Entity (Expression (Arg1));
5015 if not Is_Remote_Call_Interface (C_Ent)
5016 and then not Is_Remote_Types (C_Ent)
5018 -- This pragma should only appear in an RCI or Remote Types
5019 -- unit (RM E.4.1(4))
5022 ("pragma% not in Remote_Call_Interface or " &
5023 "Remote_Types unit");
5026 if Ekind (Nm) = E_Procedure
5027 and then Nkind (Parent (Nm)) = N_Procedure_Specification
5029 if not Is_Remote_Call_Interface (Nm) then
5031 ("pragma% cannot be applied on non-remote procedure",
5035 L := Parameter_Specifications (Parent (Nm));
5036 Process_Async_Pragma;
5039 elsif Ekind (Nm) = E_Function then
5041 ("pragma% cannot be applied to function", Arg1);
5043 elsif Is_Remote_Access_To_Subprogram_Type (Nm) then
5045 if Is_Record_Type (Nm) then
5046 -- A record type that is the Equivalent_Type for
5047 -- a remote access-to-subprogram type.
5049 N := Declaration_Node (Corresponding_Remote_Type (Nm));
5052 -- A non-expanded RAS type (case where distribution is
5055 N := Declaration_Node (Nm);
5058 if Nkind (N) = N_Full_Type_Declaration
5059 and then Nkind (Type_Definition (N)) =
5060 N_Access_Procedure_Definition
5062 L := Parameter_Specifications (Type_Definition (N));
5063 Process_Async_Pragma;
5065 if Is_Asynchronous (Nm)
5066 and then Expander_Active
5067 and then Get_PCS_Name /= Name_No_DSA
5069 RACW_Type_Is_Asynchronous (Underlying_RACW_Type (Nm));
5074 ("pragma% cannot reference access-to-function type",
5078 -- Only other possibility is Access-to-class-wide type
5080 elsif Is_Access_Type (Nm)
5081 and then Is_Class_Wide_Type (Designated_Type (Nm))
5083 Check_First_Subtype (Arg1);
5084 Set_Is_Asynchronous (Nm);
5085 if Expander_Active then
5086 RACW_Type_Is_Asynchronous (Nm);
5090 Error_Pragma_Arg ("inappropriate argument for pragma%", Arg1);
5098 -- pragma Atomic (LOCAL_NAME);
5100 when Pragma_Atomic =>
5101 Process_Atomic_Shared_Volatile;
5103 -----------------------
5104 -- Atomic_Components --
5105 -----------------------
5107 -- pragma Atomic_Components (array_LOCAL_NAME);
5109 -- This processing is shared by Volatile_Components
5111 when Pragma_Atomic_Components |
5112 Pragma_Volatile_Components =>
5114 Atomic_Components : declare
5121 Check_Ada_83_Warning;
5122 Check_No_Identifiers;
5123 Check_Arg_Count (1);
5124 Check_Arg_Is_Local_Name (Arg1);
5125 E_Id := Expression (Arg1);
5127 if Etype (E_Id) = Any_Type then
5133 if Rep_Item_Too_Early (E, N)
5135 Rep_Item_Too_Late (E, N)
5140 D := Declaration_Node (E);
5143 if (K = N_Full_Type_Declaration and then Is_Array_Type (E))
5145 ((Ekind (E) = E_Constant or else Ekind (E) = E_Variable)
5146 and then Nkind (D) = N_Object_Declaration
5147 and then Nkind (Object_Definition (D)) =
5148 N_Constrained_Array_Definition)
5150 -- The flag is set on the object, or on the base type
5152 if Nkind (D) /= N_Object_Declaration then
5156 Set_Has_Volatile_Components (E);
5158 if Prag_Id = Pragma_Atomic_Components then
5159 Set_Has_Atomic_Components (E);
5161 if Is_Packed (E) then
5162 Set_Is_Packed (E, False);
5165 ("?Pack canceled, cannot pack atomic components",
5171 Error_Pragma_Arg ("inappropriate entity for pragma%", Arg1);
5173 end Atomic_Components;
5175 --------------------
5176 -- Attach_Handler --
5177 --------------------
5179 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
5181 when Pragma_Attach_Handler =>
5182 Check_Ada_83_Warning;
5183 Check_No_Identifiers;
5184 Check_Arg_Count (2);
5186 if No_Run_Time_Mode then
5187 Error_Msg_CRT ("Attach_Handler pragma", N);
5189 Check_Interrupt_Or_Attach_Handler;
5191 -- The expression that designates the attribute may
5192 -- depend on a discriminant, and is therefore a per-
5193 -- object expression, to be expanded in the init proc.
5194 -- If expansion is enabled, perform semantic checks
5197 if Expander_Active then
5199 Temp : constant Node_Id :=
5200 New_Copy_Tree (Expression (Arg2));
5202 Set_Parent (Temp, N);
5203 Pre_Analyze_And_Resolve (Temp, RTE (RE_Interrupt_ID));
5207 Analyze (Expression (Arg2));
5208 Resolve (Expression (Arg2), RTE (RE_Interrupt_ID));
5211 Process_Interrupt_Or_Attach_Handler;
5214 --------------------
5215 -- C_Pass_By_Copy --
5216 --------------------
5218 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
5220 when Pragma_C_Pass_By_Copy => C_Pass_By_Copy : declare
5226 Check_Valid_Configuration_Pragma;
5227 Check_Arg_Count (1);
5228 Check_Optional_Identifier (Arg1, "max_size");
5230 Arg := Expression (Arg1);
5231 Check_Arg_Is_Static_Expression (Arg, Any_Integer);
5233 Val := Expr_Value (Arg);
5237 ("maximum size for pragma% must be positive", Arg1);
5239 elsif UI_Is_In_Int_Range (Val) then
5240 Default_C_Record_Mechanism := UI_To_Int (Val);
5242 -- If a giant value is given, Int'Last will do well enough.
5243 -- If sometime someone complains that a record larger than
5244 -- two gigabytes is not copied, we will worry about it then!
5247 Default_C_Record_Mechanism := Mechanism_Type'Last;
5255 -- pragma Check_Name (check_IDENTIFIER);
5257 when Pragma_Check_Name =>
5258 Check_No_Identifiers;
5260 Check_Valid_Configuration_Pragma;
5261 Check_Arg_Count (1);
5262 Check_Arg_Is_Identifier (Arg1);
5265 Nam : constant Name_Id := Chars (Expression (Arg1));
5268 for J in Check_Names.First .. Check_Names.Last loop
5269 if Check_Names.Table (J) = Nam then
5274 Check_Names.Append (Nam);
5277 ---------------------
5278 -- CIL_Constructor --
5279 ---------------------
5281 -- pragma CIL_Constructor ([Entity =>] LOCAL_NAME);
5283 -- Processing for this pragma is shared with Java_Constructor
5289 -- pragma Comment (static_string_EXPRESSION)
5291 -- Processing for pragma Comment shares the circuitry for
5292 -- pragma Ident. The only differences are that Ident enforces
5293 -- a limit of 31 characters on its argument, and also enforces
5294 -- limitations on placement for DEC compatibility. Pragma
5295 -- Comment shares neither of these restrictions.
5301 -- pragma Common_Object (
5302 -- [Internal =>] LOCAL_NAME
5303 -- [, [External =>] EXTERNAL_SYMBOL]
5304 -- [, [Size =>] EXTERNAL_SYMBOL]);
5306 -- Processing for this pragma is shared with Psect_Object
5308 ------------------------
5309 -- Compile_Time_Error --
5310 ------------------------
5312 -- pragma Compile_Time_Error
5313 -- (boolean_EXPRESSION, static_string_EXPRESSION);
5315 when Pragma_Compile_Time_Error =>
5316 Process_Compile_Time_Warning_Or_Error;
5318 --------------------------
5319 -- Compile_Time_Warning --
5320 --------------------------
5322 -- pragma Compile_Time_Warning
5323 -- (boolean_EXPRESSION, static_string_EXPRESSION);
5325 when Pragma_Compile_Time_Warning =>
5326 Process_Compile_Time_Warning_Or_Error;
5332 when Pragma_Compiler_Unit =>
5334 Check_Arg_Count (0);
5335 Set_Is_Compiler_Unit (Get_Source_Unit (N));
5337 -----------------------------
5338 -- Complete_Representation --
5339 -----------------------------
5341 -- pragma Complete_Representation;
5343 when Pragma_Complete_Representation =>
5345 Check_Arg_Count (0);
5347 if Nkind (Parent (N)) /= N_Record_Representation_Clause then
5349 ("pragma & must appear within record representation clause");
5352 ----------------------------
5353 -- Complex_Representation --
5354 ----------------------------
5356 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
5358 when Pragma_Complex_Representation => Complex_Representation : declare
5365 Check_Arg_Count (1);
5366 Check_Optional_Identifier (Arg1, Name_Entity);
5367 Check_Arg_Is_Local_Name (Arg1);
5368 E_Id := Expression (Arg1);
5370 if Etype (E_Id) = Any_Type then
5376 if not Is_Record_Type (E) then
5378 ("argument for pragma% must be record type", Arg1);
5381 Ent := First_Entity (E);
5384 or else No (Next_Entity (Ent))
5385 or else Present (Next_Entity (Next_Entity (Ent)))
5386 or else not Is_Floating_Point_Type (Etype (Ent))
5387 or else Etype (Ent) /= Etype (Next_Entity (Ent))
5390 ("record for pragma% must have two fields of the same "
5391 & "floating-point type", Arg1);
5394 Set_Has_Complex_Representation (Base_Type (E));
5396 -- We need to treat the type has having a non-standard
5397 -- representation, for back-end purposes, even though in
5398 -- general a complex will have the default representation
5399 -- of a record with two real components.
5401 Set_Has_Non_Standard_Rep (Base_Type (E));
5403 end Complex_Representation;
5405 -------------------------
5406 -- Component_Alignment --
5407 -------------------------
5409 -- pragma Component_Alignment (
5410 -- [Form =>] ALIGNMENT_CHOICE
5411 -- [, [Name =>] type_LOCAL_NAME]);
5413 -- ALIGNMENT_CHOICE ::=
5415 -- | Component_Size_4
5419 when Pragma_Component_Alignment => Component_AlignmentP : declare
5420 Args : Args_List (1 .. 2);
5421 Names : constant Name_List (1 .. 2) := (
5425 Form : Node_Id renames Args (1);
5426 Name : Node_Id renames Args (2);
5428 Atype : Component_Alignment_Kind;
5433 Gather_Associations (Names, Args);
5436 Error_Pragma ("missing Form argument for pragma%");
5439 Check_Arg_Is_Identifier (Form);
5441 -- Get proper alignment, note that Default = Component_Size
5442 -- on all machines we have so far, and we want to set this
5443 -- value rather than the default value to indicate that it
5444 -- has been explicitly set (and thus will not get overridden
5445 -- by the default component alignment for the current scope)
5447 if Chars (Form) = Name_Component_Size then
5448 Atype := Calign_Component_Size;
5450 elsif Chars (Form) = Name_Component_Size_4 then
5451 Atype := Calign_Component_Size_4;
5453 elsif Chars (Form) = Name_Default then
5454 Atype := Calign_Component_Size;
5456 elsif Chars (Form) = Name_Storage_Unit then
5457 Atype := Calign_Storage_Unit;
5461 ("invalid Form parameter for pragma%", Form);
5464 -- Case with no name, supplied, affects scope table entry
5468 (Scope_Stack.Last).Component_Alignment_Default := Atype;
5470 -- Case of name supplied
5473 Check_Arg_Is_Local_Name (Name);
5475 Typ := Entity (Name);
5478 or else Rep_Item_Too_Early (Typ, N)
5482 Typ := Underlying_Type (Typ);
5485 if not Is_Record_Type (Typ)
5486 and then not Is_Array_Type (Typ)
5489 ("Name parameter of pragma% must identify record or " &
5490 "array type", Name);
5493 -- An explicit Component_Alignment pragma overrides an
5494 -- implicit pragma Pack, but not an explicit one.
5496 if not Has_Pragma_Pack (Base_Type (Typ)) then
5497 Set_Is_Packed (Base_Type (Typ), False);
5498 Set_Component_Alignment (Base_Type (Typ), Atype);
5501 end Component_AlignmentP;
5507 -- pragma Controlled (first_subtype_LOCAL_NAME);
5509 when Pragma_Controlled => Controlled : declare
5513 Check_No_Identifiers;
5514 Check_Arg_Count (1);
5515 Check_Arg_Is_Local_Name (Arg1);
5516 Arg := Expression (Arg1);
5518 if not Is_Entity_Name (Arg)
5519 or else not Is_Access_Type (Entity (Arg))
5521 Error_Pragma_Arg ("pragma% requires access type", Arg1);
5523 Set_Has_Pragma_Controlled (Base_Type (Entity (Arg)));
5531 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
5532 -- [Entity =>] LOCAL_NAME);
5534 when Pragma_Convention => Convention : declare
5537 pragma Warnings (Off, C);
5538 pragma Warnings (Off, E);
5540 Check_Arg_Order ((Name_Convention, Name_Entity));
5541 Check_Ada_83_Warning;
5542 Check_Arg_Count (2);
5543 Process_Convention (C, E);
5546 ---------------------------
5547 -- Convention_Identifier --
5548 ---------------------------
5550 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
5551 -- [Convention =>] convention_IDENTIFIER);
5553 when Pragma_Convention_Identifier => Convention_Identifier : declare
5559 Check_Arg_Order ((Name_Name, Name_Convention));
5560 Check_Arg_Count (2);
5561 Check_Optional_Identifier (Arg1, Name_Name);
5562 Check_Optional_Identifier (Arg2, Name_Convention);
5563 Check_Arg_Is_Identifier (Arg1);
5564 Check_Arg_Is_Identifier (Arg2);
5565 Idnam := Chars (Expression (Arg1));
5566 Cname := Chars (Expression (Arg2));
5568 if Is_Convention_Name (Cname) then
5569 Record_Convention_Identifier
5570 (Idnam, Get_Convention_Id (Cname));
5573 ("second arg for % pragma must be convention", Arg2);
5575 end Convention_Identifier;
5581 -- pragma CPP_Class ([Entity =>] local_NAME)
5583 when Pragma_CPP_Class => CPP_Class : declare
5588 if Warn_On_Obsolescent_Feature then
5590 ("'G'N'A'T pragma cpp'_class is now obsolete; replace it" &
5591 " by pragma import?", N);
5595 Check_Arg_Count (1);
5596 Check_Optional_Identifier (Arg1, Name_Entity);
5597 Check_Arg_Is_Local_Name (Arg1);
5599 Arg := Expression (Arg1);
5602 if Etype (Arg) = Any_Type then
5606 if not Is_Entity_Name (Arg)
5607 or else not Is_Type (Entity (Arg))
5609 Error_Pragma_Arg ("pragma% requires a type mark", Arg1);
5612 Typ := Entity (Arg);
5614 if not Is_Tagged_Type (Typ) then
5615 Error_Pragma_Arg ("pragma% applicable to tagged types ", Arg1);
5618 -- Types treated as CPP classes are treated as limited, but we
5619 -- don't require them to be declared this way. A warning is issued
5620 -- to encourage the user to declare them as limited. This is not
5621 -- an error, for compatibility reasons, because these types have
5622 -- been supported this way for some time.
5624 if not Is_Limited_Type (Typ) then
5626 ("imported 'C'P'P type should be " &
5627 "explicitly declared limited?",
5628 Get_Pragma_Arg (Arg1));
5630 ("\type will be considered limited",
5631 Get_Pragma_Arg (Arg1));
5634 Set_Is_CPP_Class (Typ);
5635 Set_Is_Limited_Record (Typ);
5636 Set_Convention (Typ, Convention_CPP);
5639 ---------------------
5640 -- CPP_Constructor --
5641 ---------------------
5643 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME
5644 -- [, [External_Name =>] static_string_EXPRESSION ]
5645 -- [, [Link_Name =>] static_string_EXPRESSION ]);
5647 when Pragma_CPP_Constructor => CPP_Constructor : declare
5653 Check_At_Least_N_Arguments (1);
5654 Check_At_Most_N_Arguments (3);
5655 Check_Optional_Identifier (Arg1, Name_Entity);
5656 Check_Arg_Is_Local_Name (Arg1);
5658 Id := Expression (Arg1);
5659 Find_Program_Unit_Name (Id);
5661 -- If we did not find the name, we are done
5663 if Etype (Id) = Any_Type then
5667 Def_Id := Entity (Id);
5669 if Ekind (Def_Id) = E_Function
5670 and then Is_Class_Wide_Type (Etype (Def_Id))
5671 and then Is_CPP_Class (Etype (Etype (Def_Id)))
5673 if Arg_Count >= 2 then
5674 Set_Imported (Def_Id);
5675 Set_Is_Public (Def_Id);
5676 Process_Interface_Name (Def_Id, Arg2, Arg3);
5679 if No (Parameter_Specifications (Parent (Def_Id))) then
5680 Set_Has_Completion (Def_Id);
5681 Set_Is_Constructor (Def_Id);
5684 ("non-default constructors not implemented", Arg1);
5689 ("pragma% requires function returning a 'C'P'P_Class type",
5692 end CPP_Constructor;
5698 when Pragma_CPP_Virtual => CPP_Virtual : declare
5700 if Warn_On_Obsolescent_Feature then
5702 ("'G'N'A'T pragma cpp'_virtual is now obsolete and has " &
5711 when Pragma_CPP_Vtable => CPP_Vtable : declare
5713 if Warn_On_Obsolescent_Feature then
5715 ("'G'N'A'T pragma cpp'_vtable is now obsolete and has " &
5724 -- pragma Debug ([boolean_EXPRESSION,] PROCEDURE_CALL_STATEMENT);
5726 when Pragma_Debug => Debug : declare
5734 (Boolean_Literals (Debug_Pragmas_Enabled and Expander_Active),
5737 if Arg_Count = 2 then
5740 Left_Opnd => Relocate_Node (Cond),
5741 Right_Opnd => Expression (Arg1));
5744 -- Rewrite into a conditional with an appropriate condition. We
5745 -- wrap the procedure call in a block so that overhead from e.g.
5746 -- use of the secondary stack does not generate execution overhead
5747 -- for suppressed conditions.
5749 Rewrite (N, Make_Implicit_If_Statement (N,
5751 Then_Statements => New_List (
5752 Make_Block_Statement (Loc,
5753 Handled_Statement_Sequence =>
5754 Make_Handled_Sequence_Of_Statements (Loc,
5755 Statements => New_List (
5756 Relocate_Node (Debug_Statement (N))))))));
5764 -- pragma Debug_Policy (Check | Ignore)
5766 when Pragma_Debug_Policy =>
5768 Check_Arg_Count (1);
5769 Check_Arg_Is_One_Of (Arg1, Name_Check, Name_Ignore);
5770 Debug_Pragmas_Enabled := Chars (Expression (Arg1)) = Name_Check;
5772 ---------------------
5773 -- Detect_Blocking --
5774 ---------------------
5776 -- pragma Detect_Blocking;
5778 when Pragma_Detect_Blocking =>
5780 Check_Arg_Count (0);
5781 Check_Valid_Configuration_Pragma;
5782 Detect_Blocking := True;
5788 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
5790 when Pragma_Discard_Names => Discard_Names : declare
5795 Check_Ada_83_Warning;
5797 -- Deal with configuration pragma case
5799 if Arg_Count = 0 and then Is_Configuration_Pragma then
5800 Global_Discard_Names := True;
5803 -- Otherwise, check correct appropriate context
5806 Check_Is_In_Decl_Part_Or_Package_Spec;
5808 if Arg_Count = 0 then
5810 -- If there is no parameter, then from now on this pragma
5811 -- applies to any enumeration, exception or tagged type
5812 -- defined in the current declarative part, and recursively
5813 -- to any nested scope.
5815 Set_Discard_Names (Current_Scope);
5819 Check_Arg_Count (1);
5820 Check_Optional_Identifier (Arg1, Name_On);
5821 Check_Arg_Is_Local_Name (Arg1);
5822 E_Id := Expression (Arg1);
5824 if Etype (E_Id) = Any_Type then
5830 if (Is_First_Subtype (E)
5831 and then (Is_Enumeration_Type (E)
5832 or else Is_Tagged_Type (E)))
5833 or else Ekind (E) = E_Exception
5835 Set_Discard_Names (E);
5838 ("inappropriate entity for pragma%", Arg1);
5848 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
5850 when Pragma_Elaborate => Elaborate : declare
5855 -- Pragma must be in context items list of a compilation unit
5857 if not Is_In_Context_Clause then
5861 -- Must be at least one argument
5863 if Arg_Count = 0 then
5864 Error_Pragma ("pragma% requires at least one argument");
5867 -- In Ada 83 mode, there can be no items following it in the
5868 -- context list except other pragmas and implicit with clauses
5869 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
5870 -- placement rule does not apply.
5872 if Ada_Version = Ada_83 and then Comes_From_Source (N) then
5874 while Present (Citem) loop
5875 if Nkind (Citem) = N_Pragma
5876 or else (Nkind (Citem) = N_With_Clause
5877 and then Implicit_With (Citem))
5882 ("(Ada 83) pragma% must be at end of context clause");
5889 -- Finally, the arguments must all be units mentioned in a with
5890 -- clause in the same context clause. Note we already checked (in
5891 -- Par.Prag) that the arguments are all identifiers or selected
5895 Outer : while Present (Arg) loop
5896 Citem := First (List_Containing (N));
5897 Inner : while Citem /= N loop
5898 if Nkind (Citem) = N_With_Clause
5899 and then Same_Name (Name (Citem), Expression (Arg))
5901 Set_Elaborate_Present (Citem, True);
5902 Set_Unit_Name (Expression (Arg), Name (Citem));
5904 -- With the pragma present, elaboration calls on
5905 -- subprograms from the named unit need no further
5906 -- checks, as long as the pragma appears in the current
5907 -- compilation unit. If the pragma appears in some unit
5908 -- in the context, there might still be a need for an
5909 -- Elaborate_All_Desirable from the current compilation
5910 -- to the the named unit, so we keep the check enabled.
5912 if In_Extended_Main_Source_Unit (N) then
5913 Set_Suppress_Elaboration_Warnings
5914 (Entity (Name (Citem)));
5925 ("argument of pragma% is not with'ed unit", Arg);
5931 -- Give a warning if operating in static mode with -gnatwl
5932 -- (elaboration warnings eanbled) switch set.
5934 if Elab_Warnings and not Dynamic_Elaboration_Checks then
5936 ("?use of pragma Elaborate may not be safe", N);
5938 ("?use pragma Elaborate_All instead if possible", N);
5946 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
5948 when Pragma_Elaborate_All => Elaborate_All : declare
5953 Check_Ada_83_Warning;
5955 -- Pragma must be in context items list of a compilation unit
5957 if not Is_In_Context_Clause then
5961 -- Must be at least one argument
5963 if Arg_Count = 0 then
5964 Error_Pragma ("pragma% requires at least one argument");
5967 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
5968 -- have to appear at the end of the context clause, but may
5969 -- appear mixed in with other items, even in Ada 83 mode.
5971 -- Final check: the arguments must all be units mentioned in
5972 -- a with clause in the same context clause. Note that we
5973 -- already checked (in Par.Prag) that all the arguments are
5974 -- either identifiers or selected components.
5977 Outr : while Present (Arg) loop
5978 Citem := First (List_Containing (N));
5979 Innr : while Citem /= N loop
5980 if Nkind (Citem) = N_With_Clause
5981 and then Same_Name (Name (Citem), Expression (Arg))
5983 Set_Elaborate_All_Present (Citem, True);
5984 Set_Unit_Name (Expression (Arg), Name (Citem));
5986 -- Suppress warnings and elaboration checks on the named
5987 -- unit if the pragma is in the current compilation, as
5988 -- for pragma Elaborate.
5990 if In_Extended_Main_Source_Unit (N) then
5991 Set_Suppress_Elaboration_Warnings
5992 (Entity (Name (Citem)));
6001 Set_Error_Posted (N);
6003 ("argument of pragma% is not with'ed unit", Arg);
6010 --------------------
6011 -- Elaborate_Body --
6012 --------------------
6014 -- pragma Elaborate_Body [( library_unit_NAME )];
6016 when Pragma_Elaborate_Body => Elaborate_Body : declare
6017 Cunit_Node : Node_Id;
6018 Cunit_Ent : Entity_Id;
6021 Check_Ada_83_Warning;
6022 Check_Valid_Library_Unit_Pragma;
6024 if Nkind (N) = N_Null_Statement then
6028 Cunit_Node := Cunit (Current_Sem_Unit);
6029 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
6031 if Nkind (Unit (Cunit_Node)) = N_Package_Body
6033 Nkind (Unit (Cunit_Node)) = N_Subprogram_Body
6035 Error_Pragma ("pragma% must refer to a spec, not a body");
6037 Set_Body_Required (Cunit_Node, True);
6038 Set_Has_Pragma_Elaborate_Body (Cunit_Ent);
6040 -- If we are in dynamic elaboration mode, then we suppress
6041 -- elaboration warnings for the unit, since it is definitely
6042 -- fine NOT to do dynamic checks at the first level (and such
6043 -- checks will be suppressed because no elaboration boolean
6044 -- is created for Elaborate_Body packages).
6046 -- But in the static model of elaboration, Elaborate_Body is
6047 -- definitely NOT good enough to ensure elaboration safety on
6048 -- its own, since the body may WITH other units that are not
6049 -- safe from an elaboration point of view, so a client must
6050 -- still do an Elaborate_All on such units.
6052 -- Debug flag -gnatdD restores the old behavior of 3.13,
6053 -- where Elaborate_Body always suppressed elab warnings.
6055 if Dynamic_Elaboration_Checks or Debug_Flag_DD then
6056 Set_Suppress_Elaboration_Warnings (Cunit_Ent);
6061 ------------------------
6062 -- Elaboration_Checks --
6063 ------------------------
6065 -- pragma Elaboration_Checks (Static | Dynamic);
6067 when Pragma_Elaboration_Checks =>
6069 Check_Arg_Count (1);
6070 Check_Arg_Is_One_Of (Arg1, Name_Static, Name_Dynamic);
6071 Dynamic_Elaboration_Checks :=
6072 (Chars (Get_Pragma_Arg (Arg1)) = Name_Dynamic);
6078 -- pragma Eliminate (
6079 -- [Unit_Name =>] IDENTIFIER |
6080 -- SELECTED_COMPONENT
6081 -- [,[Entity =>] IDENTIFIER |
6082 -- SELECTED_COMPONENT |
6084 -- [,]OVERLOADING_RESOLUTION);
6086 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
6089 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
6092 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
6094 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
6095 -- Result_Type => result_SUBTYPE_NAME]
6097 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
6098 -- SUBTYPE_NAME ::= STRING_LITERAL
6100 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
6101 -- SOURCE_TRACE ::= STRING_LITERAL
6103 when Pragma_Eliminate => Eliminate : declare
6104 Args : Args_List (1 .. 5);
6105 Names : constant Name_List (1 .. 5) := (
6108 Name_Parameter_Types,
6110 Name_Source_Location);
6112 Unit_Name : Node_Id renames Args (1);
6113 Entity : Node_Id renames Args (2);
6114 Parameter_Types : Node_Id renames Args (3);
6115 Result_Type : Node_Id renames Args (4);
6116 Source_Location : Node_Id renames Args (5);
6120 Check_Valid_Configuration_Pragma;
6121 Gather_Associations (Names, Args);
6123 if No (Unit_Name) then
6124 Error_Pragma ("missing Unit_Name argument for pragma%");
6128 and then (Present (Parameter_Types)
6130 Present (Result_Type)
6132 Present (Source_Location))
6134 Error_Pragma ("missing Entity argument for pragma%");
6137 if (Present (Parameter_Types)
6139 Present (Result_Type))
6141 Present (Source_Location)
6144 ("parameter profile and source location cannot " &
6145 "be used together in pragma%");
6148 Process_Eliminate_Pragma
6162 -- [ Convention =>] convention_IDENTIFIER,
6163 -- [ Entity =>] local_NAME
6164 -- [, [External_Name =>] static_string_EXPRESSION ]
6165 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6167 when Pragma_Export => Export : declare
6171 pragma Warnings (Off, C);
6174 Check_Ada_83_Warning;
6180 Check_At_Least_N_Arguments (2);
6181 Check_At_Most_N_Arguments (4);
6182 Process_Convention (C, Def_Id);
6184 if Ekind (Def_Id) /= E_Constant then
6185 Note_Possible_Modification (Expression (Arg2));
6188 Process_Interface_Name (Def_Id, Arg3, Arg4);
6189 Set_Exported (Def_Id, Arg2);
6192 ----------------------
6193 -- Export_Exception --
6194 ----------------------
6196 -- pragma Export_Exception (
6197 -- [Internal =>] LOCAL_NAME
6198 -- [, [External =>] EXTERNAL_SYMBOL]
6199 -- [, [Form =>] Ada | VMS]
6200 -- [, [Code =>] static_integer_EXPRESSION]);
6202 when Pragma_Export_Exception => Export_Exception : declare
6203 Args : Args_List (1 .. 4);
6204 Names : constant Name_List (1 .. 4) := (
6210 Internal : Node_Id renames Args (1);
6211 External : Node_Id renames Args (2);
6212 Form : Node_Id renames Args (3);
6213 Code : Node_Id renames Args (4);
6216 if Inside_A_Generic then
6217 Error_Pragma ("pragma% cannot be used for generic entities");
6220 Gather_Associations (Names, Args);
6221 Process_Extended_Import_Export_Exception_Pragma (
6222 Arg_Internal => Internal,
6223 Arg_External => External,
6227 if not Is_VMS_Exception (Entity (Internal)) then
6228 Set_Exported (Entity (Internal), Internal);
6230 end Export_Exception;
6232 ---------------------
6233 -- Export_Function --
6234 ---------------------
6236 -- pragma Export_Function (
6237 -- [Internal =>] LOCAL_NAME
6238 -- [, [External =>] EXTERNAL_SYMBOL]
6239 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6240 -- [, [Result_Type =>] TYPE_DESIGNATOR]
6241 -- [, [Mechanism =>] MECHANISM]
6242 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
6244 -- EXTERNAL_SYMBOL ::=
6246 -- | static_string_EXPRESSION
6248 -- PARAMETER_TYPES ::=
6250 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6252 -- TYPE_DESIGNATOR ::=
6254 -- | subtype_Name ' Access
6258 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6260 -- MECHANISM_ASSOCIATION ::=
6261 -- [formal_parameter_NAME =>] MECHANISM_NAME
6263 -- MECHANISM_NAME ::=
6266 -- | Descriptor [([Class =>] CLASS_NAME)]
6268 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6270 when Pragma_Export_Function => Export_Function : declare
6271 Args : Args_List (1 .. 6);
6272 Names : constant Name_List (1 .. 6) := (
6275 Name_Parameter_Types,
6278 Name_Result_Mechanism);
6280 Internal : Node_Id renames Args (1);
6281 External : Node_Id renames Args (2);
6282 Parameter_Types : Node_Id renames Args (3);
6283 Result_Type : Node_Id renames Args (4);
6284 Mechanism : Node_Id renames Args (5);
6285 Result_Mechanism : Node_Id renames Args (6);
6289 Gather_Associations (Names, Args);
6290 Process_Extended_Import_Export_Subprogram_Pragma (
6291 Arg_Internal => Internal,
6292 Arg_External => External,
6293 Arg_Parameter_Types => Parameter_Types,
6294 Arg_Result_Type => Result_Type,
6295 Arg_Mechanism => Mechanism,
6296 Arg_Result_Mechanism => Result_Mechanism);
6297 end Export_Function;
6303 -- pragma Export_Object (
6304 -- [Internal =>] LOCAL_NAME
6305 -- [, [External =>] EXTERNAL_SYMBOL]
6306 -- [, [Size =>] EXTERNAL_SYMBOL]);
6308 -- EXTERNAL_SYMBOL ::=
6310 -- | static_string_EXPRESSION
6312 -- PARAMETER_TYPES ::=
6314 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6316 -- TYPE_DESIGNATOR ::=
6318 -- | subtype_Name ' Access
6322 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6324 -- MECHANISM_ASSOCIATION ::=
6325 -- [formal_parameter_NAME =>] MECHANISM_NAME
6327 -- MECHANISM_NAME ::=
6330 -- | Descriptor [([Class =>] CLASS_NAME)]
6332 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6334 when Pragma_Export_Object => Export_Object : declare
6335 Args : Args_List (1 .. 3);
6336 Names : constant Name_List (1 .. 3) := (
6341 Internal : Node_Id renames Args (1);
6342 External : Node_Id renames Args (2);
6343 Size : Node_Id renames Args (3);
6347 Gather_Associations (Names, Args);
6348 Process_Extended_Import_Export_Object_Pragma (
6349 Arg_Internal => Internal,
6350 Arg_External => External,
6354 ----------------------
6355 -- Export_Procedure --
6356 ----------------------
6358 -- pragma Export_Procedure (
6359 -- [Internal =>] LOCAL_NAME
6360 -- [, [External =>] EXTERNAL_SYMBOL]
6361 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6362 -- [, [Mechanism =>] MECHANISM]);
6364 -- EXTERNAL_SYMBOL ::=
6366 -- | static_string_EXPRESSION
6368 -- PARAMETER_TYPES ::=
6370 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6372 -- TYPE_DESIGNATOR ::=
6374 -- | subtype_Name ' Access
6378 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6380 -- MECHANISM_ASSOCIATION ::=
6381 -- [formal_parameter_NAME =>] MECHANISM_NAME
6383 -- MECHANISM_NAME ::=
6386 -- | Descriptor [([Class =>] CLASS_NAME)]
6388 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6390 when Pragma_Export_Procedure => Export_Procedure : declare
6391 Args : Args_List (1 .. 4);
6392 Names : constant Name_List (1 .. 4) := (
6395 Name_Parameter_Types,
6398 Internal : Node_Id renames Args (1);
6399 External : Node_Id renames Args (2);
6400 Parameter_Types : Node_Id renames Args (3);
6401 Mechanism : Node_Id renames Args (4);
6405 Gather_Associations (Names, Args);
6406 Process_Extended_Import_Export_Subprogram_Pragma (
6407 Arg_Internal => Internal,
6408 Arg_External => External,
6409 Arg_Parameter_Types => Parameter_Types,
6410 Arg_Mechanism => Mechanism);
6411 end Export_Procedure;
6417 -- pragma Export_Value (
6418 -- [Value =>] static_integer_EXPRESSION,
6419 -- [Link_Name =>] static_string_EXPRESSION);
6421 when Pragma_Export_Value =>
6423 Check_Arg_Order ((Name_Value, Name_Link_Name));
6424 Check_Arg_Count (2);
6426 Check_Optional_Identifier (Arg1, Name_Value);
6427 Check_Arg_Is_Static_Expression (Arg1, Any_Integer);
6429 Check_Optional_Identifier (Arg2, Name_Link_Name);
6430 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
6432 -----------------------------
6433 -- Export_Valued_Procedure --
6434 -----------------------------
6436 -- pragma Export_Valued_Procedure (
6437 -- [Internal =>] LOCAL_NAME
6438 -- [, [External =>] EXTERNAL_SYMBOL,]
6439 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6440 -- [, [Mechanism =>] MECHANISM]);
6442 -- EXTERNAL_SYMBOL ::=
6444 -- | static_string_EXPRESSION
6446 -- PARAMETER_TYPES ::=
6448 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6450 -- TYPE_DESIGNATOR ::=
6452 -- | subtype_Name ' Access
6456 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6458 -- MECHANISM_ASSOCIATION ::=
6459 -- [formal_parameter_NAME =>] MECHANISM_NAME
6461 -- MECHANISM_NAME ::=
6464 -- | Descriptor [([Class =>] CLASS_NAME)]
6466 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6468 when Pragma_Export_Valued_Procedure =>
6469 Export_Valued_Procedure : declare
6470 Args : Args_List (1 .. 4);
6471 Names : constant Name_List (1 .. 4) := (
6474 Name_Parameter_Types,
6477 Internal : Node_Id renames Args (1);
6478 External : Node_Id renames Args (2);
6479 Parameter_Types : Node_Id renames Args (3);
6480 Mechanism : Node_Id renames Args (4);
6484 Gather_Associations (Names, Args);
6485 Process_Extended_Import_Export_Subprogram_Pragma (
6486 Arg_Internal => Internal,
6487 Arg_External => External,
6488 Arg_Parameter_Types => Parameter_Types,
6489 Arg_Mechanism => Mechanism);
6490 end Export_Valued_Procedure;
6496 -- pragma Extend_System ([Name =>] Identifier);
6498 when Pragma_Extend_System => Extend_System : declare
6501 Check_Valid_Configuration_Pragma;
6502 Check_Arg_Count (1);
6503 Check_Optional_Identifier (Arg1, Name_Name);
6504 Check_Arg_Is_Identifier (Arg1);
6506 Get_Name_String (Chars (Expression (Arg1)));
6509 and then Name_Buffer (1 .. 4) = "aux_"
6511 if Present (System_Extend_Pragma_Arg) then
6512 if Chars (Expression (Arg1)) =
6513 Chars (Expression (System_Extend_Pragma_Arg))
6517 Error_Msg_Sloc := Sloc (System_Extend_Pragma_Arg);
6518 Error_Pragma ("pragma% conflicts with that #");
6522 System_Extend_Pragma_Arg := Arg1;
6524 if not GNAT_Mode then
6525 System_Extend_Unit := Arg1;
6529 Error_Pragma ("incorrect name for pragma%, must be Aux_xxx");
6533 ------------------------
6534 -- Extensions_Allowed --
6535 ------------------------
6537 -- pragma Extensions_Allowed (ON | OFF);
6539 when Pragma_Extensions_Allowed =>
6541 Check_Arg_Count (1);
6542 Check_No_Identifiers;
6543 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
6545 if Chars (Expression (Arg1)) = Name_On then
6546 Extensions_Allowed := True;
6548 Extensions_Allowed := False;
6555 -- pragma External (
6556 -- [ Convention =>] convention_IDENTIFIER,
6557 -- [ Entity =>] local_NAME
6558 -- [, [External_Name =>] static_string_EXPRESSION ]
6559 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6561 when Pragma_External => External : declare
6565 pragma Warnings (Off, C);
6574 Check_At_Least_N_Arguments (2);
6575 Check_At_Most_N_Arguments (4);
6576 Process_Convention (C, Def_Id);
6577 Note_Possible_Modification (Expression (Arg2));
6578 Process_Interface_Name (Def_Id, Arg3, Arg4);
6579 Set_Exported (Def_Id, Arg2);
6582 --------------------------
6583 -- External_Name_Casing --
6584 --------------------------
6586 -- pragma External_Name_Casing (
6587 -- UPPERCASE | LOWERCASE
6588 -- [, AS_IS | UPPERCASE | LOWERCASE]);
6590 when Pragma_External_Name_Casing => External_Name_Casing : declare
6593 Check_No_Identifiers;
6595 if Arg_Count = 2 then
6597 (Arg2, Name_As_Is, Name_Uppercase, Name_Lowercase);
6599 case Chars (Get_Pragma_Arg (Arg2)) is
6601 Opt.External_Name_Exp_Casing := As_Is;
6603 when Name_Uppercase =>
6604 Opt.External_Name_Exp_Casing := Uppercase;
6606 when Name_Lowercase =>
6607 Opt.External_Name_Exp_Casing := Lowercase;
6614 Check_Arg_Count (1);
6617 Check_Arg_Is_One_Of (Arg1, Name_Uppercase, Name_Lowercase);
6619 case Chars (Get_Pragma_Arg (Arg1)) is
6620 when Name_Uppercase =>
6621 Opt.External_Name_Imp_Casing := Uppercase;
6623 when Name_Lowercase =>
6624 Opt.External_Name_Imp_Casing := Lowercase;
6629 end External_Name_Casing;
6631 --------------------------
6632 -- Favor_Top_Level --
6633 --------------------------
6635 -- pragma Favor_Top_Level (type_NAME);
6637 when Pragma_Favor_Top_Level => Favor_Top_Level : declare
6638 Named_Entity : Entity_Id;
6642 Check_No_Identifiers;
6643 Check_Arg_Count (1);
6644 Check_Arg_Is_Local_Name (Arg1);
6645 Named_Entity := Entity (Expression (Arg1));
6647 -- If it's an access-to-subprogram type (in particular, not a
6648 -- subtype), set the flag on that type.
6650 if Ekind (Named_Entity) in Access_Subprogram_Type_Kind then
6651 Set_Can_Use_Internal_Rep (Named_Entity, False);
6653 -- Otherwise it's an error (name denotes the wrong sort of entity)
6657 ("access-to-subprogram type expected", Expression (Arg1));
6659 end Favor_Top_Level;
6665 -- pragma Fast_Math;
6667 when Pragma_Fast_Math =>
6669 Check_No_Identifiers;
6670 Check_Valid_Configuration_Pragma;
6673 ---------------------------
6674 -- Finalize_Storage_Only --
6675 ---------------------------
6677 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
6679 when Pragma_Finalize_Storage_Only => Finalize_Storage : declare
6680 Assoc : constant Node_Id := Arg1;
6681 Type_Id : constant Node_Id := Expression (Assoc);
6685 Check_No_Identifiers;
6686 Check_Arg_Count (1);
6687 Check_Arg_Is_Local_Name (Arg1);
6689 Find_Type (Type_Id);
6690 Typ := Entity (Type_Id);
6693 or else Rep_Item_Too_Early (Typ, N)
6697 Typ := Underlying_Type (Typ);
6700 if not Is_Controlled (Typ) then
6701 Error_Pragma ("pragma% must specify controlled type");
6704 Check_First_Subtype (Arg1);
6706 if Finalize_Storage_Only (Typ) then
6707 Error_Pragma ("duplicate pragma%, only one allowed");
6709 elsif not Rep_Item_Too_Late (Typ, N) then
6710 Set_Finalize_Storage_Only (Base_Type (Typ), True);
6712 end Finalize_Storage;
6714 --------------------------
6715 -- Float_Representation --
6716 --------------------------
6718 -- pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
6720 -- FLOAT_REP ::= VAX_Float | IEEE_Float
6722 when Pragma_Float_Representation => Float_Representation : declare
6730 if Arg_Count = 1 then
6731 Check_Valid_Configuration_Pragma;
6733 Check_Arg_Count (2);
6734 Check_Optional_Identifier (Arg2, Name_Entity);
6735 Check_Arg_Is_Local_Name (Arg2);
6738 Check_No_Identifier (Arg1);
6739 Check_Arg_Is_One_Of (Arg1, Name_VAX_Float, Name_IEEE_Float);
6741 if not OpenVMS_On_Target then
6742 if Chars (Expression (Arg1)) = Name_VAX_Float then
6744 ("?pragma% ignored (applies only to Open'V'M'S)");
6750 -- One argument case
6752 if Arg_Count = 1 then
6753 if Chars (Expression (Arg1)) = Name_VAX_Float then
6754 if Opt.Float_Format = 'I' then
6755 Error_Pragma ("'I'E'E'E format previously specified");
6758 Opt.Float_Format := 'V';
6761 if Opt.Float_Format = 'V' then
6762 Error_Pragma ("'V'A'X format previously specified");
6765 Opt.Float_Format := 'I';
6768 Set_Standard_Fpt_Formats;
6770 -- Two argument case
6773 Argx := Get_Pragma_Arg (Arg2);
6775 if not Is_Entity_Name (Argx)
6776 or else not Is_Floating_Point_Type (Entity (Argx))
6779 ("second argument of% pragma must be floating-point type",
6783 Ent := Entity (Argx);
6784 Digs := UI_To_Int (Digits_Value (Ent));
6786 -- Two arguments, VAX_Float case
6788 if Chars (Expression (Arg1)) = Name_VAX_Float then
6790 when 6 => Set_F_Float (Ent);
6791 when 9 => Set_D_Float (Ent);
6792 when 15 => Set_G_Float (Ent);
6796 ("wrong digits value, must be 6,9 or 15", Arg2);
6799 -- Two arguments, IEEE_Float case
6803 when 6 => Set_IEEE_Short (Ent);
6804 when 15 => Set_IEEE_Long (Ent);
6808 ("wrong digits value, must be 6 or 15", Arg2);
6812 end Float_Representation;
6818 -- pragma Ident (static_string_EXPRESSION)
6820 -- Note: pragma Comment shares this processing. Pragma Comment
6821 -- is identical to Ident, except that the restriction of the
6822 -- argument to 31 characters and the placement restrictions
6823 -- are not enforced for pragma Comment.
6825 when Pragma_Ident | Pragma_Comment => Ident : declare
6830 Check_Arg_Count (1);
6831 Check_No_Identifiers;
6832 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
6834 -- For pragma Ident, preserve DEC compatibility by requiring
6835 -- the pragma to appear in a declarative part or package spec.
6837 if Prag_Id = Pragma_Ident then
6838 Check_Is_In_Decl_Part_Or_Package_Spec;
6841 Str := Expr_Value_S (Expression (Arg1));
6848 GP := Parent (Parent (N));
6850 if Nkind (GP) = N_Package_Declaration
6852 Nkind (GP) = N_Generic_Package_Declaration
6857 -- If we have a compilation unit, then record the ident
6858 -- value, checking for improper duplication.
6860 if Nkind (GP) = N_Compilation_Unit then
6861 CS := Ident_String (Current_Sem_Unit);
6863 if Present (CS) then
6865 -- For Ident, we do not permit multiple instances
6867 if Prag_Id = Pragma_Ident then
6868 Error_Pragma ("duplicate% pragma not permitted");
6870 -- For Comment, we concatenate the string, unless we
6871 -- want to preserve the tree structure for ASIS.
6873 elsif not ASIS_Mode then
6874 Start_String (Strval (CS));
6875 Store_String_Char (' ');
6876 Store_String_Chars (Strval (Str));
6877 Set_Strval (CS, End_String);
6881 -- In VMS, the effect of IDENT is achieved by passing
6882 -- IDENTIFICATION=name as a --for-linker switch.
6884 if OpenVMS_On_Target then
6887 ("--for-linker=IDENTIFICATION=");
6888 String_To_Name_Buffer (Strval (Str));
6889 Store_String_Chars (Name_Buffer (1 .. Name_Len));
6891 -- Only the last processed IDENT is saved. The main
6892 -- purpose is so an IDENT associated with a main
6893 -- procedure will be used in preference to an IDENT
6894 -- associated with a with'd package.
6896 Replace_Linker_Option_String
6897 (End_String, "--for-linker=IDENTIFICATION=");
6900 Set_Ident_String (Current_Sem_Unit, Str);
6903 -- For subunits, we just ignore the Ident, since in GNAT
6904 -- these are not separate object files, and hence not
6905 -- separate units in the unit table.
6907 elsif Nkind (GP) = N_Subunit then
6910 -- Otherwise we have a misplaced pragma Ident, but we ignore
6911 -- this if we are in an instantiation, since it comes from
6912 -- a generic, and has no relevance to the instantiation.
6914 elsif Prag_Id = Pragma_Ident then
6915 if Instantiation_Location (Loc) = No_Location then
6916 Error_Pragma ("pragma% only allowed at outer level");
6922 --------------------------
6923 -- Implemented_By_Entry --
6924 --------------------------
6926 -- pragma Implemented_By_Entry (DIRECT_NAME);
6928 when Pragma_Implemented_By_Entry => Implemented_By_Entry : declare
6933 Check_Arg_Count (1);
6934 Check_No_Identifiers;
6935 Check_Arg_Is_Identifier (Arg1);
6936 Check_Arg_Is_Local_Name (Arg1);
6937 Ent := Entity (Expression (Arg1));
6939 -- Pragma Implemented_By_Entry must be applied only to protected
6940 -- synchronized or task interface primitives.
6942 if (Ekind (Ent) /= E_Function
6943 and then Ekind (Ent) /= E_Procedure)
6944 or else not Present (First_Formal (Ent))
6945 or else not Is_Concurrent_Interface (Etype (First_Formal (Ent)))
6948 ("pragma % must be applied to a concurrent interface " &
6952 if Einfo.Implemented_By_Entry (Ent)
6953 and then Warn_On_Redundant_Constructs
6955 Error_Pragma ("?duplicate pragma%!");
6957 Set_Implemented_By_Entry (Ent);
6960 end Implemented_By_Entry;
6962 -----------------------
6963 -- Implicit_Packing --
6964 -----------------------
6966 -- pragma Implicit_Packing;
6968 when Pragma_Implicit_Packing =>
6970 Check_Arg_Count (0);
6971 Implicit_Packing := True;
6978 -- [Convention =>] convention_IDENTIFIER,
6979 -- [Entity =>] local_NAME
6980 -- [, [External_Name =>] static_string_EXPRESSION ]
6981 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6983 when Pragma_Import =>
6984 Check_Ada_83_Warning;
6990 Check_At_Least_N_Arguments (2);
6991 Check_At_Most_N_Arguments (4);
6992 Process_Import_Or_Interface;
6994 ----------------------
6995 -- Import_Exception --
6996 ----------------------
6998 -- pragma Import_Exception (
6999 -- [Internal =>] LOCAL_NAME
7000 -- [, [External =>] EXTERNAL_SYMBOL]
7001 -- [, [Form =>] Ada | VMS]
7002 -- [, [Code =>] static_integer_EXPRESSION]);
7004 when Pragma_Import_Exception => Import_Exception : declare
7005 Args : Args_List (1 .. 4);
7006 Names : constant Name_List (1 .. 4) := (
7012 Internal : Node_Id renames Args (1);
7013 External : Node_Id renames Args (2);
7014 Form : Node_Id renames Args (3);
7015 Code : Node_Id renames Args (4);
7018 Gather_Associations (Names, Args);
7020 if Present (External) and then Present (Code) then
7022 ("cannot give both External and Code options for pragma%");
7025 Process_Extended_Import_Export_Exception_Pragma (
7026 Arg_Internal => Internal,
7027 Arg_External => External,
7031 if not Is_VMS_Exception (Entity (Internal)) then
7032 Set_Imported (Entity (Internal));
7034 end Import_Exception;
7036 ---------------------
7037 -- Import_Function --
7038 ---------------------
7040 -- pragma Import_Function (
7041 -- [Internal =>] LOCAL_NAME,
7042 -- [, [External =>] EXTERNAL_SYMBOL]
7043 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7044 -- [, [Result_Type =>] SUBTYPE_MARK]
7045 -- [, [Mechanism =>] MECHANISM]
7046 -- [, [Result_Mechanism =>] MECHANISM_NAME]
7047 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
7049 -- EXTERNAL_SYMBOL ::=
7051 -- | static_string_EXPRESSION
7053 -- PARAMETER_TYPES ::=
7055 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7057 -- TYPE_DESIGNATOR ::=
7059 -- | subtype_Name ' Access
7063 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7065 -- MECHANISM_ASSOCIATION ::=
7066 -- [formal_parameter_NAME =>] MECHANISM_NAME
7068 -- MECHANISM_NAME ::=
7071 -- | Descriptor [([Class =>] CLASS_NAME)]
7073 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7075 when Pragma_Import_Function => Import_Function : declare
7076 Args : Args_List (1 .. 7);
7077 Names : constant Name_List (1 .. 7) := (
7080 Name_Parameter_Types,
7083 Name_Result_Mechanism,
7084 Name_First_Optional_Parameter);
7086 Internal : Node_Id renames Args (1);
7087 External : Node_Id renames Args (2);
7088 Parameter_Types : Node_Id renames Args (3);
7089 Result_Type : Node_Id renames Args (4);
7090 Mechanism : Node_Id renames Args (5);
7091 Result_Mechanism : Node_Id renames Args (6);
7092 First_Optional_Parameter : Node_Id renames Args (7);
7096 Gather_Associations (Names, Args);
7097 Process_Extended_Import_Export_Subprogram_Pragma (
7098 Arg_Internal => Internal,
7099 Arg_External => External,
7100 Arg_Parameter_Types => Parameter_Types,
7101 Arg_Result_Type => Result_Type,
7102 Arg_Mechanism => Mechanism,
7103 Arg_Result_Mechanism => Result_Mechanism,
7104 Arg_First_Optional_Parameter => First_Optional_Parameter);
7105 end Import_Function;
7111 -- pragma Import_Object (
7112 -- [Internal =>] LOCAL_NAME
7113 -- [, [External =>] EXTERNAL_SYMBOL]
7114 -- [, [Size =>] EXTERNAL_SYMBOL]);
7116 -- EXTERNAL_SYMBOL ::=
7118 -- | static_string_EXPRESSION
7120 when Pragma_Import_Object => Import_Object : declare
7121 Args : Args_List (1 .. 3);
7122 Names : constant Name_List (1 .. 3) := (
7127 Internal : Node_Id renames Args (1);
7128 External : Node_Id renames Args (2);
7129 Size : Node_Id renames Args (3);
7133 Gather_Associations (Names, Args);
7134 Process_Extended_Import_Export_Object_Pragma (
7135 Arg_Internal => Internal,
7136 Arg_External => External,
7140 ----------------------
7141 -- Import_Procedure --
7142 ----------------------
7144 -- pragma Import_Procedure (
7145 -- [Internal =>] LOCAL_NAME
7146 -- [, [External =>] EXTERNAL_SYMBOL]
7147 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7148 -- [, [Mechanism =>] MECHANISM]
7149 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
7151 -- EXTERNAL_SYMBOL ::=
7153 -- | static_string_EXPRESSION
7155 -- PARAMETER_TYPES ::=
7157 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7159 -- TYPE_DESIGNATOR ::=
7161 -- | subtype_Name ' Access
7165 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7167 -- MECHANISM_ASSOCIATION ::=
7168 -- [formal_parameter_NAME =>] MECHANISM_NAME
7170 -- MECHANISM_NAME ::=
7173 -- | Descriptor [([Class =>] CLASS_NAME)]
7175 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7177 when Pragma_Import_Procedure => Import_Procedure : declare
7178 Args : Args_List (1 .. 5);
7179 Names : constant Name_List (1 .. 5) := (
7182 Name_Parameter_Types,
7184 Name_First_Optional_Parameter);
7186 Internal : Node_Id renames Args (1);
7187 External : Node_Id renames Args (2);
7188 Parameter_Types : Node_Id renames Args (3);
7189 Mechanism : Node_Id renames Args (4);
7190 First_Optional_Parameter : Node_Id renames Args (5);
7194 Gather_Associations (Names, Args);
7195 Process_Extended_Import_Export_Subprogram_Pragma (
7196 Arg_Internal => Internal,
7197 Arg_External => External,
7198 Arg_Parameter_Types => Parameter_Types,
7199 Arg_Mechanism => Mechanism,
7200 Arg_First_Optional_Parameter => First_Optional_Parameter);
7201 end Import_Procedure;
7203 -----------------------------
7204 -- Import_Valued_Procedure --
7205 -----------------------------
7207 -- pragma Import_Valued_Procedure (
7208 -- [Internal =>] LOCAL_NAME
7209 -- [, [External =>] EXTERNAL_SYMBOL]
7210 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7211 -- [, [Mechanism =>] MECHANISM]
7212 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
7214 -- EXTERNAL_SYMBOL ::=
7216 -- | static_string_EXPRESSION
7218 -- PARAMETER_TYPES ::=
7220 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7222 -- TYPE_DESIGNATOR ::=
7224 -- | subtype_Name ' Access
7228 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7230 -- MECHANISM_ASSOCIATION ::=
7231 -- [formal_parameter_NAME =>] MECHANISM_NAME
7233 -- MECHANISM_NAME ::=
7236 -- | Descriptor [([Class =>] CLASS_NAME)]
7238 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7240 when Pragma_Import_Valued_Procedure =>
7241 Import_Valued_Procedure : declare
7242 Args : Args_List (1 .. 5);
7243 Names : constant Name_List (1 .. 5) := (
7246 Name_Parameter_Types,
7248 Name_First_Optional_Parameter);
7250 Internal : Node_Id renames Args (1);
7251 External : Node_Id renames Args (2);
7252 Parameter_Types : Node_Id renames Args (3);
7253 Mechanism : Node_Id renames Args (4);
7254 First_Optional_Parameter : Node_Id renames Args (5);
7258 Gather_Associations (Names, Args);
7259 Process_Extended_Import_Export_Subprogram_Pragma (
7260 Arg_Internal => Internal,
7261 Arg_External => External,
7262 Arg_Parameter_Types => Parameter_Types,
7263 Arg_Mechanism => Mechanism,
7264 Arg_First_Optional_Parameter => First_Optional_Parameter);
7265 end Import_Valued_Procedure;
7267 ------------------------
7268 -- Initialize_Scalars --
7269 ------------------------
7271 -- pragma Initialize_Scalars;
7273 when Pragma_Initialize_Scalars =>
7275 Check_Arg_Count (0);
7276 Check_Valid_Configuration_Pragma;
7277 Check_Restriction (No_Initialize_Scalars, N);
7279 if not Restriction_Active (No_Initialize_Scalars) then
7280 Init_Or_Norm_Scalars := True;
7281 Initialize_Scalars := True;
7288 -- pragma Inline ( NAME {, NAME} );
7290 when Pragma_Inline =>
7292 -- Pragma is active if inlining option is active
7294 Process_Inline (Inline_Active);
7300 -- pragma Inline_Always ( NAME {, NAME} );
7302 when Pragma_Inline_Always =>
7303 Process_Inline (True);
7305 --------------------
7306 -- Inline_Generic --
7307 --------------------
7309 -- pragma Inline_Generic (NAME {, NAME});
7311 when Pragma_Inline_Generic =>
7312 Process_Generic_List;
7314 ----------------------
7315 -- Inspection_Point --
7316 ----------------------
7318 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
7320 when Pragma_Inspection_Point => Inspection_Point : declare
7325 if Arg_Count > 0 then
7328 Exp := Expression (Arg);
7331 if not Is_Entity_Name (Exp)
7332 or else not Is_Object (Entity (Exp))
7334 Error_Pragma_Arg ("object name required", Arg);
7341 end Inspection_Point;
7347 -- pragma Interface (
7348 -- [ Convention =>] convention_IDENTIFIER,
7349 -- [ Entity =>] local_NAME
7350 -- [, [External_Name =>] static_string_EXPRESSION ]
7351 -- [, [Link_Name =>] static_string_EXPRESSION ]);
7353 when Pragma_Interface =>
7360 Check_At_Least_N_Arguments (2);
7361 Check_At_Most_N_Arguments (4);
7362 Process_Import_Or_Interface;
7364 --------------------
7365 -- Interface_Name --
7366 --------------------
7368 -- pragma Interface_Name (
7369 -- [ Entity =>] local_NAME
7370 -- [,[External_Name =>] static_string_EXPRESSION ]
7371 -- [,[Link_Name =>] static_string_EXPRESSION ]);
7373 when Pragma_Interface_Name => Interface_Name : declare
7382 ((Name_Entity, Name_External_Name, Name_Link_Name));
7383 Check_At_Least_N_Arguments (2);
7384 Check_At_Most_N_Arguments (3);
7385 Id := Expression (Arg1);
7388 if not Is_Entity_Name (Id) then
7390 ("first argument for pragma% must be entity name", Arg1);
7391 elsif Etype (Id) = Any_Type then
7394 Def_Id := Entity (Id);
7397 -- Special DEC-compatible processing for the object case,
7398 -- forces object to be imported.
7400 if Ekind (Def_Id) = E_Variable then
7401 Kill_Size_Check_Code (Def_Id);
7402 Note_Possible_Modification (Id);
7404 -- Initialization is not allowed for imported variable
7406 if Present (Expression (Parent (Def_Id)))
7407 and then Comes_From_Source (Expression (Parent (Def_Id)))
7409 Error_Msg_Sloc := Sloc (Def_Id);
7411 ("no initialization allowed for declaration of& #",
7415 -- For compatibility, support VADS usage of providing both
7416 -- pragmas Interface and Interface_Name to obtain the effect
7417 -- of a single Import pragma.
7419 if Is_Imported (Def_Id)
7420 and then Present (First_Rep_Item (Def_Id))
7421 and then Nkind (First_Rep_Item (Def_Id)) = N_Pragma
7422 and then Chars (First_Rep_Item (Def_Id)) = Name_Interface
7426 Set_Imported (Def_Id);
7429 Set_Is_Public (Def_Id);
7430 Process_Interface_Name (Def_Id, Arg2, Arg3);
7433 -- Otherwise must be subprogram
7435 elsif not Is_Subprogram (Def_Id) then
7437 ("argument of pragma% is not subprogram", Arg1);
7440 Check_At_Most_N_Arguments (3);
7444 -- Loop through homonyms
7447 Def_Id := Get_Base_Subprogram (Hom_Id);
7449 if Is_Imported (Def_Id) then
7450 Process_Interface_Name (Def_Id, Arg2, Arg3);
7454 Hom_Id := Homonym (Hom_Id);
7456 exit when No (Hom_Id)
7457 or else Scope (Hom_Id) /= Current_Scope;
7462 ("argument of pragma% is not imported subprogram",
7468 -----------------------
7469 -- Interrupt_Handler --
7470 -----------------------
7472 -- pragma Interrupt_Handler (handler_NAME);
7474 when Pragma_Interrupt_Handler =>
7475 Check_Ada_83_Warning;
7476 Check_Arg_Count (1);
7477 Check_No_Identifiers;
7479 if No_Run_Time_Mode then
7480 Error_Msg_CRT ("Interrupt_Handler pragma", N);
7482 Check_Interrupt_Or_Attach_Handler;
7483 Process_Interrupt_Or_Attach_Handler;
7486 ------------------------
7487 -- Interrupt_Priority --
7488 ------------------------
7490 -- pragma Interrupt_Priority [(EXPRESSION)];
7492 when Pragma_Interrupt_Priority => Interrupt_Priority : declare
7493 P : constant Node_Id := Parent (N);
7497 Check_Ada_83_Warning;
7499 if Arg_Count /= 0 then
7500 Arg := Expression (Arg1);
7501 Check_Arg_Count (1);
7502 Check_No_Identifiers;
7504 -- The expression must be analyzed in the special manner
7505 -- described in "Handling of Default and Per-Object
7506 -- Expressions" in sem.ads.
7508 Analyze_Per_Use_Expression (Arg, RTE (RE_Interrupt_Priority));
7511 if Nkind (P) /= N_Task_Definition
7512 and then Nkind (P) /= N_Protected_Definition
7517 elsif Has_Priority_Pragma (P) then
7518 Error_Pragma ("duplicate pragma% not allowed");
7521 Set_Has_Priority_Pragma (P, True);
7522 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
7524 end Interrupt_Priority;
7526 ---------------------
7527 -- Interrupt_State --
7528 ---------------------
7530 -- pragma Interrupt_State (
7531 -- [Name =>] INTERRUPT_ID,
7532 -- [State =>] INTERRUPT_STATE);
7534 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
7535 -- INTERRUPT_STATE => System | Runtime | User
7537 -- Note: if the interrupt id is given as an identifier, then
7538 -- it must be one of the identifiers in Ada.Interrupts.Names.
7539 -- Otherwise it is given as a static integer expression which
7540 -- must be in the range of Ada.Interrupts.Interrupt_ID.
7542 when Pragma_Interrupt_State => Interrupt_State : declare
7544 Int_Id : constant Entity_Id := RTE (RE_Interrupt_ID);
7545 -- This is the entity Ada.Interrupts.Interrupt_ID;
7547 State_Type : Character;
7548 -- Set to 's'/'r'/'u' for System/Runtime/User
7551 -- Index to entry in Interrupt_States table
7554 -- Value of interrupt
7556 Arg1X : constant Node_Id := Get_Pragma_Arg (Arg1);
7557 -- The first argument to the pragma
7559 Int_Ent : Entity_Id;
7560 -- Interrupt entity in Ada.Interrupts.Names
7564 Check_Arg_Order ((Name_Name, Name_State));
7565 Check_Arg_Count (2);
7567 Check_Optional_Identifier (Arg1, Name_Name);
7568 Check_Optional_Identifier (Arg2, Name_State);
7569 Check_Arg_Is_Identifier (Arg2);
7571 -- First argument is identifier
7573 if Nkind (Arg1X) = N_Identifier then
7575 -- Search list of names in Ada.Interrupts.Names
7577 Int_Ent := First_Entity (RTE (RE_Names));
7579 if No (Int_Ent) then
7580 Error_Pragma_Arg ("invalid interrupt name", Arg1);
7582 elsif Chars (Int_Ent) = Chars (Arg1X) then
7583 Int_Val := Expr_Value (Constant_Value (Int_Ent));
7587 Next_Entity (Int_Ent);
7590 -- First argument is not an identifier, so it must be a
7591 -- static expression of type Ada.Interrupts.Interrupt_ID.
7594 Check_Arg_Is_Static_Expression (Arg1, Any_Integer);
7595 Int_Val := Expr_Value (Arg1X);
7597 if Int_Val < Expr_Value (Type_Low_Bound (Int_Id))
7599 Int_Val > Expr_Value (Type_High_Bound (Int_Id))
7602 ("value not in range of type " &
7603 """Ada.Interrupts.Interrupt_'I'D""", Arg1);
7609 case Chars (Get_Pragma_Arg (Arg2)) is
7610 when Name_Runtime => State_Type := 'r';
7611 when Name_System => State_Type := 's';
7612 when Name_User => State_Type := 'u';
7615 Error_Pragma_Arg ("invalid interrupt state", Arg2);
7618 -- Check if entry is already stored
7620 IST_Num := Interrupt_States.First;
7622 -- If entry not found, add it
7624 if IST_Num > Interrupt_States.Last then
7625 Interrupt_States.Append
7626 ((Interrupt_Number => UI_To_Int (Int_Val),
7627 Interrupt_State => State_Type,
7628 Pragma_Loc => Loc));
7631 -- Case of entry for the same entry
7633 elsif Int_Val = Interrupt_States.Table (IST_Num).
7636 -- If state matches, done, no need to make redundant entry
7639 State_Type = Interrupt_States.Table (IST_Num).
7642 -- Otherwise if state does not match, error
7645 Interrupt_States.Table (IST_Num).Pragma_Loc;
7647 ("state conflicts with that given #", Arg2);
7651 IST_Num := IST_Num + 1;
7653 end Interrupt_State;
7655 ----------------------
7656 -- Java_Constructor --
7657 ----------------------
7659 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
7661 -- Also handles pragma CIL_Constructor
7663 when Pragma_CIL_Constructor | Pragma_Java_Constructor =>
7664 Java_Constructor : declare
7668 Convention : Convention_Id;
7672 Check_Arg_Count (1);
7673 Check_Optional_Identifier (Arg1, Name_Entity);
7674 Check_Arg_Is_Local_Name (Arg1);
7676 Id := Expression (Arg1);
7677 Find_Program_Unit_Name (Id);
7679 -- If we did not find the name, we are done
7681 if Etype (Id) = Any_Type then
7686 when Pragma_CIL_Constructor => Convention := Convention_CIL;
7687 when Pragma_Java_Constructor => Convention := Convention_Java;
7688 when others => null;
7691 Hom_Id := Entity (Id);
7693 -- Loop through homonyms
7696 Def_Id := Get_Base_Subprogram (Hom_Id);
7698 -- The constructor is required to be a function returning an
7699 -- access type whose designated type has convention Java/CIL.
7701 if Ekind (Def_Id) = E_Function
7703 (Is_Value_Type (Etype (Def_Id))
7705 (Ekind (Etype (Def_Id)) in Access_Kind
7708 (Designated_Type (Etype (Def_Id))) = Convention
7711 (Root_Type (Designated_Type (Etype (Def_Id)))) =
7714 Set_Is_Constructor (Def_Id);
7715 Set_Convention (Def_Id, Convention);
7716 Set_Is_Imported (Def_Id);
7719 if Convention = Convention_Java then
7721 ("pragma% requires function returning a " &
7722 "'Java access type", Arg1);
7724 pragma Assert (Convention = Convention_CIL);
7726 ("pragma% requires function returning a " &
7727 "'CIL access type", Arg1);
7731 Hom_Id := Homonym (Hom_Id);
7733 exit when No (Hom_Id) or else Scope (Hom_Id) /= Current_Scope;
7735 end Java_Constructor;
7737 ----------------------
7738 -- Java_Interface --
7739 ----------------------
7741 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
7743 when Pragma_Java_Interface => Java_Interface : declare
7749 Check_Arg_Count (1);
7750 Check_Optional_Identifier (Arg1, Name_Entity);
7751 Check_Arg_Is_Local_Name (Arg1);
7753 Arg := Expression (Arg1);
7756 if Etype (Arg) = Any_Type then
7760 if not Is_Entity_Name (Arg)
7761 or else not Is_Type (Entity (Arg))
7763 Error_Pragma_Arg ("pragma% requires a type mark", Arg1);
7766 Typ := Underlying_Type (Entity (Arg));
7768 -- For now we simply check some of the semantic constraints
7769 -- on the type. This currently leaves out some restrictions
7770 -- on interface types, namely that the parent type must be
7771 -- java.lang.Object.Typ and that all primitives of the type
7772 -- should be declared abstract. ???
7774 if not Is_Tagged_Type (Typ) or else not Is_Abstract_Type (Typ) then
7775 Error_Pragma_Arg ("pragma% requires an abstract "
7776 & "tagged type", Arg1);
7778 elsif not Has_Discriminants (Typ)
7779 or else Ekind (Etype (First_Discriminant (Typ)))
7780 /= E_Anonymous_Access_Type
7782 not Is_Class_Wide_Type
7783 (Designated_Type (Etype (First_Discriminant (Typ))))
7786 ("type must have a class-wide access discriminant", Arg1);
7794 -- pragma Keep_Names ([On => ] local_NAME);
7796 when Pragma_Keep_Names => Keep_Names : declare
7801 Check_Arg_Count (1);
7802 Check_Optional_Identifier (Arg1, Name_On);
7803 Check_Arg_Is_Local_Name (Arg1);
7805 Arg := Expression (Arg1);
7808 if Etype (Arg) = Any_Type then
7812 if not Is_Entity_Name (Arg)
7813 or else Ekind (Entity (Arg)) /= E_Enumeration_Type
7816 ("pragma% requires a local enumeration type", Arg1);
7819 Set_Discard_Names (Entity (Arg), False);
7826 -- pragma License (RESTRICTED | UNRESTRICTED | GPL | MODIFIED_GPL);
7828 when Pragma_License =>
7830 Check_Arg_Count (1);
7831 Check_No_Identifiers;
7832 Check_Valid_Configuration_Pragma;
7833 Check_Arg_Is_Identifier (Arg1);
7836 Sind : constant Source_File_Index :=
7837 Source_Index (Current_Sem_Unit);
7840 case Chars (Get_Pragma_Arg (Arg1)) is
7842 Set_License (Sind, GPL);
7844 when Name_Modified_GPL =>
7845 Set_License (Sind, Modified_GPL);
7847 when Name_Restricted =>
7848 Set_License (Sind, Restricted);
7850 when Name_Unrestricted =>
7851 Set_License (Sind, Unrestricted);
7854 Error_Pragma_Arg ("invalid license name", Arg1);
7862 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
7864 when Pragma_Link_With => Link_With : declare
7870 if Operating_Mode = Generate_Code
7871 and then In_Extended_Main_Source_Unit (N)
7873 Check_At_Least_N_Arguments (1);
7874 Check_No_Identifiers;
7875 Check_Is_In_Decl_Part_Or_Package_Spec;
7876 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
7880 while Present (Arg) loop
7881 Check_Arg_Is_Static_Expression (Arg, Standard_String);
7883 -- Store argument, converting sequences of spaces
7884 -- to a single null character (this is one of the
7885 -- differences in processing between Link_With
7886 -- and Linker_Options).
7889 C : constant Char_Code := Get_Char_Code (' ');
7890 S : constant String_Id :=
7891 Strval (Expr_Value_S (Expression (Arg)));
7892 L : constant Nat := String_Length (S);
7895 procedure Skip_Spaces;
7896 -- Advance F past any spaces
7902 procedure Skip_Spaces is
7904 while F <= L and then Get_String_Char (S, F) = C loop
7909 -- Start of processing for Arg_Store
7912 Skip_Spaces; -- skip leading spaces
7914 -- Loop through characters, changing any embedded
7915 -- sequence of spaces to a single null character
7916 -- (this is how Link_With/Linker_Options differ)
7919 if Get_String_Char (S, F) = C then
7922 Store_String_Char (ASCII.NUL);
7925 Store_String_Char (Get_String_Char (S, F));
7933 if Present (Arg) then
7934 Store_String_Char (ASCII.NUL);
7938 Store_Linker_Option_String (End_String);
7946 -- pragma Linker_Alias (
7947 -- [Entity =>] LOCAL_NAME
7948 -- [Target =>] static_string_EXPRESSION);
7950 when Pragma_Linker_Alias =>
7952 Check_Arg_Order ((Name_Entity, Name_Target));
7953 Check_Arg_Count (2);
7954 Check_Optional_Identifier (Arg1, Name_Entity);
7955 Check_Optional_Identifier (Arg2, Name_Target);
7956 Check_Arg_Is_Library_Level_Local_Name (Arg1);
7957 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
7959 -- The only processing required is to link this item on to the
7960 -- list of rep items for the given entity. This is accomplished
7961 -- by the call to Rep_Item_Too_Late (when no error is detected
7962 -- and False is returned).
7964 if Rep_Item_Too_Late (Entity (Expression (Arg1)), N) then
7967 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
7970 ------------------------
7971 -- Linker_Constructor --
7972 ------------------------
7974 -- pragma Linker_Constructor (procedure_LOCAL_NAME);
7976 -- Code is shared with Linker_Destructor
7978 -----------------------
7979 -- Linker_Destructor --
7980 -----------------------
7982 -- pragma Linker_Destructor (procedure_LOCAL_NAME);
7984 when Pragma_Linker_Constructor |
7985 Pragma_Linker_Destructor =>
7986 Linker_Constructor : declare
7992 Check_Arg_Count (1);
7993 Check_No_Identifiers;
7994 Check_Arg_Is_Local_Name (Arg1);
7995 Arg1_X := Expression (Arg1);
7997 Proc := Find_Unique_Parameterless_Procedure (Arg1_X, Arg1);
7999 if not Is_Library_Level_Entity (Proc) then
8001 ("argument for pragma% must be library level entity", Arg1);
8004 -- The only processing required is to link this item on to the
8005 -- list of rep items for the given entity. This is accomplished
8006 -- by the call to Rep_Item_Too_Late (when no error is detected
8007 -- and False is returned).
8009 if Rep_Item_Too_Late (Proc, N) then
8012 Set_Has_Gigi_Rep_Item (Proc);
8014 end Linker_Constructor;
8016 --------------------
8017 -- Linker_Options --
8018 --------------------
8020 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
8022 when Pragma_Linker_Options => Linker_Options : declare
8026 Check_Ada_83_Warning;
8027 Check_No_Identifiers;
8028 Check_Arg_Count (1);
8029 Check_Is_In_Decl_Part_Or_Package_Spec;
8031 if Operating_Mode = Generate_Code
8032 and then In_Extended_Main_Source_Unit (N)
8034 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
8035 Start_String (Strval (Expr_Value_S (Expression (Arg1))));
8038 while Present (Arg) loop
8039 Check_Arg_Is_Static_Expression (Arg, Standard_String);
8040 Store_String_Char (ASCII.NUL);
8042 (Strval (Expr_Value_S (Expression (Arg))));
8046 Store_Linker_Option_String (End_String);
8050 --------------------
8051 -- Linker_Section --
8052 --------------------
8054 -- pragma Linker_Section (
8055 -- [Entity =>] LOCAL_NAME
8056 -- [Section =>] static_string_EXPRESSION);
8058 when Pragma_Linker_Section =>
8060 Check_Arg_Order ((Name_Entity, Name_Section));
8061 Check_Arg_Count (2);
8062 Check_Optional_Identifier (Arg1, Name_Entity);
8063 Check_Optional_Identifier (Arg2, Name_Section);
8064 Check_Arg_Is_Library_Level_Local_Name (Arg1);
8065 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
8067 -- The only processing required is to link this item on to the
8068 -- list of rep items for the given entity. This is accomplished
8069 -- by the call to Rep_Item_Too_Late (when no error is detected
8070 -- and False is returned).
8072 if Rep_Item_Too_Late (Entity (Expression (Arg1)), N) then
8075 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
8082 -- pragma List (On | Off)
8084 -- There is nothing to do here, since we did all the processing
8085 -- for this pragma in Par.Prag (so that it works properly even in
8086 -- syntax only mode)
8091 --------------------
8092 -- Locking_Policy --
8093 --------------------
8095 -- pragma Locking_Policy (policy_IDENTIFIER);
8097 when Pragma_Locking_Policy => declare
8101 Check_Ada_83_Warning;
8102 Check_Arg_Count (1);
8103 Check_No_Identifiers;
8104 Check_Arg_Is_Locking_Policy (Arg1);
8105 Check_Valid_Configuration_Pragma;
8106 Get_Name_String (Chars (Expression (Arg1)));
8107 LP := Fold_Upper (Name_Buffer (1));
8109 if Locking_Policy /= ' '
8110 and then Locking_Policy /= LP
8112 Error_Msg_Sloc := Locking_Policy_Sloc;
8113 Error_Pragma ("locking policy incompatible with policy#");
8115 -- Set new policy, but always preserve System_Location since
8116 -- we like the error message with the run time name.
8119 Locking_Policy := LP;
8121 if Locking_Policy_Sloc /= System_Location then
8122 Locking_Policy_Sloc := Loc;
8131 -- pragma Long_Float (D_Float | G_Float);
8133 when Pragma_Long_Float =>
8135 Check_Valid_Configuration_Pragma;
8136 Check_Arg_Count (1);
8137 Check_No_Identifier (Arg1);
8138 Check_Arg_Is_One_Of (Arg1, Name_D_Float, Name_G_Float);
8140 if not OpenVMS_On_Target then
8141 Error_Pragma ("?pragma% ignored (applies only to Open'V'M'S)");
8146 if Chars (Expression (Arg1)) = Name_D_Float then
8147 if Opt.Float_Format_Long = 'G' then
8148 Error_Pragma ("G_Float previously specified");
8151 Opt.Float_Format_Long := 'D';
8153 -- G_Float case (this is the default, does not need overriding)
8156 if Opt.Float_Format_Long = 'D' then
8157 Error_Pragma ("D_Float previously specified");
8160 Opt.Float_Format_Long := 'G';
8163 Set_Standard_Fpt_Formats;
8165 -----------------------
8166 -- Machine_Attribute --
8167 -----------------------
8169 -- pragma Machine_Attribute (
8170 -- [Entity =>] LOCAL_NAME,
8171 -- [Attribute_Name =>] static_string_EXPRESSION
8172 -- [, [Info =>] static_string_EXPRESSION] );
8174 when Pragma_Machine_Attribute => Machine_Attribute : declare
8179 Check_Arg_Order ((Name_Entity, Name_Attribute_Name, Name_Info));
8181 if Arg_Count = 3 then
8182 Check_Optional_Identifier (Arg3, Name_Info);
8183 Check_Arg_Is_Static_Expression (Arg3, Standard_String);
8185 Check_Arg_Count (2);
8188 Check_Optional_Identifier (Arg1, Name_Entity);
8189 Check_Optional_Identifier (Arg2, Name_Attribute_Name);
8190 Check_Arg_Is_Local_Name (Arg1);
8191 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
8192 Def_Id := Entity (Expression (Arg1));
8194 if Is_Access_Type (Def_Id) then
8195 Def_Id := Designated_Type (Def_Id);
8198 if Rep_Item_Too_Early (Def_Id, N) then
8202 Def_Id := Underlying_Type (Def_Id);
8204 -- The only processing required is to link this item on to the
8205 -- list of rep items for the given entity. This is accomplished
8206 -- by the call to Rep_Item_Too_Late (when no error is detected
8207 -- and False is returned).
8209 if Rep_Item_Too_Late (Def_Id, N) then
8212 Set_Has_Gigi_Rep_Item (Entity (Expression (Arg1)));
8214 end Machine_Attribute;
8221 -- (MAIN_OPTION [, MAIN_OPTION]);
8224 -- [STACK_SIZE =>] static_integer_EXPRESSION
8225 -- | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
8226 -- | [TIME_SLICING_ENABLED =>] static_boolean_EXPRESSION
8228 when Pragma_Main => Main : declare
8229 Args : Args_List (1 .. 3);
8230 Names : constant Name_List (1 .. 3) := (
8232 Name_Task_Stack_Size_Default,
8233 Name_Time_Slicing_Enabled);
8239 Gather_Associations (Names, Args);
8241 for J in 1 .. 2 loop
8242 if Present (Args (J)) then
8243 Check_Arg_Is_Static_Expression (Args (J), Any_Integer);
8247 if Present (Args (3)) then
8248 Check_Arg_Is_Static_Expression (Args (3), Standard_Boolean);
8252 while Present (Nod) loop
8253 if Nkind (Nod) = N_Pragma
8254 and then Chars (Nod) = Name_Main
8256 Error_Msg_Name_1 := Chars (N);
8257 Error_Msg_N ("duplicate pragma% not permitted", Nod);
8268 -- pragma Main_Storage
8269 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
8271 -- MAIN_STORAGE_OPTION ::=
8272 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
8273 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
8275 when Pragma_Main_Storage => Main_Storage : declare
8276 Args : Args_List (1 .. 2);
8277 Names : constant Name_List (1 .. 2) := (
8278 Name_Working_Storage,
8285 Gather_Associations (Names, Args);
8287 for J in 1 .. 2 loop
8288 if Present (Args (J)) then
8289 Check_Arg_Is_Static_Expression (Args (J), Any_Integer);
8293 Check_In_Main_Program;
8296 while Present (Nod) loop
8297 if Nkind (Nod) = N_Pragma
8298 and then Chars (Nod) = Name_Main_Storage
8300 Error_Msg_Name_1 := Chars (N);
8301 Error_Msg_N ("duplicate pragma% not permitted", Nod);
8312 -- pragma Memory_Size (NUMERIC_LITERAL)
8314 when Pragma_Memory_Size =>
8317 -- Memory size is simply ignored
8319 Check_No_Identifiers;
8320 Check_Arg_Count (1);
8321 Check_Arg_Is_Integer_Literal (Arg1);
8329 -- The only correct use of this pragma is on its own in a file, in
8330 -- which case it is specially processed (see Gnat1drv.Check_Bad_Body
8331 -- and Frontend, which use Sinput.L.Source_File_Is_Pragma_No_Body to
8332 -- check for a file containing nothing but a No_Body pragma). If we
8333 -- attempt to process it during normal semantics processing, it means
8334 -- it was misplaced.
8336 when Pragma_No_Body =>
8337 Error_Pragma ("misplaced pragma %");
8343 -- pragma No_Return (procedure_LOCAL_NAME {, procedure_Local_Name});
8345 when Pragma_No_Return => No_Return : declare
8353 Check_At_Least_N_Arguments (1);
8355 -- Loop through arguments of pragma
8358 while Present (Arg) loop
8359 Check_Arg_Is_Local_Name (Arg);
8360 Id := Expression (Arg);
8363 if not Is_Entity_Name (Id) then
8364 Error_Pragma_Arg ("entity name required", Arg);
8367 if Etype (Id) = Any_Type then
8371 -- Loop to find matching procedures
8376 and then Scope (E) = Current_Scope
8378 if Ekind (E) = E_Procedure
8379 or else Ekind (E) = E_Generic_Procedure
8383 -- Set flag on any alias as well
8385 if Is_Overloadable (E) and then Present (Alias (E)) then
8386 Set_No_Return (Alias (E));
8396 Error_Pragma_Arg ("no procedure & found for pragma%", Arg);
8403 ------------------------
8404 -- No_Strict_Aliasing --
8405 ------------------------
8407 -- pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
8409 when Pragma_No_Strict_Aliasing => No_Strict_Alias : declare
8414 Check_At_Most_N_Arguments (1);
8416 if Arg_Count = 0 then
8417 Check_Valid_Configuration_Pragma;
8418 Opt.No_Strict_Aliasing := True;
8421 Check_Optional_Identifier (Arg2, Name_Entity);
8422 Check_Arg_Is_Local_Name (Arg1);
8423 E_Id := Entity (Expression (Arg1));
8425 if E_Id = Any_Type then
8427 elsif No (E_Id) or else not Is_Access_Type (E_Id) then
8428 Error_Pragma_Arg ("pragma% requires access type", Arg1);
8431 Set_No_Strict_Aliasing (Implementation_Base_Type (E_Id));
8433 end No_Strict_Alias;
8439 -- pragma Obsolescent [(
8440 -- [Entity => NAME,]
8441 -- [(static_string_EXPRESSION [, Ada_05])];
8443 when Pragma_Obsolescent => Obsolescent : declare
8447 procedure Set_Obsolescent (E : Entity_Id);
8448 -- Given an entity Ent, mark it as obsolescent if appropriate
8450 ---------------------
8451 -- Set_Obsolescent --
8452 ---------------------
8454 procedure Set_Obsolescent (E : Entity_Id) is
8463 -- Entity name was given
8465 if Present (Ename) then
8467 -- If entity name matches, we are fine
8469 if Chars (Ename) = Chars (Ent) then
8472 -- If entity name does not match, only possibility is an
8473 -- enumeration literal from an enumeration type declaration.
8475 elsif Ekind (Ent) /= E_Enumeration_Type then
8477 ("pragma % entity name does not match declaration");
8480 Ent := First_Literal (E);
8484 ("pragma % entity name does not match any " &
8485 "enumeration literal");
8487 elsif Chars (Ent) = Chars (Ename) then
8491 Ent := Next_Literal (Ent);
8497 -- Ent points to entity to be marked
8499 if Arg_Count >= 1 then
8501 -- Deal with static string argument
8503 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
8504 S := Strval (Expression (Arg1));
8506 for J in 1 .. String_Length (S) loop
8507 if not In_Character_Range (Get_String_Char (S, J)) then
8509 ("pragma% argument does not allow wide characters",
8514 Set_Obsolescent_Warning (Ent, Expression (Arg1));
8516 -- Check for Ada_05 parameter
8518 if Arg_Count /= 1 then
8519 Check_Arg_Count (2);
8522 Argx : constant Node_Id := Get_Pragma_Arg (Arg2);
8525 Check_Arg_Is_Identifier (Argx);
8527 if Chars (Argx) /= Name_Ada_05 then
8528 Error_Msg_Name_2 := Name_Ada_05;
8530 ("only allowed argument for pragma% is %", Argx);
8533 if Ada_Version_Explicit < Ada_05
8534 or else not Warn_On_Ada_2005_Compatibility
8542 -- Set flag if pragma active
8545 Set_Is_Obsolescent (Ent);
8549 end Set_Obsolescent;
8551 -- Start of processing for pragma Obsolescent
8556 Check_At_Most_N_Arguments (3);
8558 -- See if first argument specifies an entity name
8561 and then Chars (Arg1) = Name_Entity
8563 Ename := Get_Pragma_Arg (Arg1);
8565 if Nkind (Ename) /= N_Character_Literal
8567 Nkind (Ename) /= N_Identifier
8569 Nkind (Ename) /= N_Operator_Symbol
8571 Error_Pragma_Arg ("entity name expected for pragma%", Arg1);
8574 -- Eliminate first argument, so we can share processing
8578 Arg_Count := Arg_Count - 1;
8580 -- No Entity name argument given
8586 Check_No_Identifiers;
8588 -- Get immediately preceding declaration
8591 while Present (Decl) and then Nkind (Decl) = N_Pragma loop
8595 -- Cases where we do not follow anything other than another pragma
8599 -- First case: library level compilation unit declaration with
8600 -- the pragma immediately following the declaration.
8602 if Nkind (Parent (N)) = N_Compilation_Unit_Aux then
8604 (Defining_Entity (Unit (Parent (Parent (N)))));
8607 -- Case 2: library unit placement for package
8611 Ent : constant Entity_Id := Find_Lib_Unit_Name;
8613 if Ekind (Ent) = E_Package
8614 or else Ekind (Ent) = E_Generic_Package
8616 Set_Obsolescent (Ent);
8622 -- Cases where we must follow a declaration
8625 if Nkind (Decl) not in N_Declaration
8626 and then Nkind (Decl) not in N_Later_Decl_Item
8627 and then Nkind (Decl) not in N_Generic_Declaration
8630 ("pragma% misplaced, " &
8631 "must immediately follow a declaration");
8634 Set_Obsolescent (Defining_Entity (Decl));
8644 -- pragma No_Run_Time
8646 -- Note: this pragma is retained for backwards compatibiltiy.
8647 -- See body of Rtsfind for full details on its handling.
8649 when Pragma_No_Run_Time =>
8651 Check_Valid_Configuration_Pragma;
8652 Check_Arg_Count (0);
8654 No_Run_Time_Mode := True;
8655 Configurable_Run_Time_Mode := True;
8657 -- Set Duration to 32 bits if word size is 32
8659 if Ttypes.System_Word_Size = 32 then
8660 Duration_32_Bits_On_Target := True;
8663 -- Set appropriate restrictions
8665 Set_Restriction (No_Finalization, N);
8666 Set_Restriction (No_Exception_Handlers, N);
8667 Set_Restriction (Max_Tasks, N, 0);
8668 Set_Restriction (No_Tasking, N);
8670 -----------------------
8671 -- Normalize_Scalars --
8672 -----------------------
8674 -- pragma Normalize_Scalars;
8676 when Pragma_Normalize_Scalars =>
8677 Check_Ada_83_Warning;
8678 Check_Arg_Count (0);
8679 Check_Valid_Configuration_Pragma;
8680 Normalize_Scalars := True;
8681 Init_Or_Norm_Scalars := True;
8687 -- pragma Optimize (Time | Space);
8689 -- The actual check for optimize is done in Gigi. Note that this
8690 -- pragma does not actually change the optimization setting, it
8691 -- simply checks that it is consistent with the pragma.
8693 when Pragma_Optimize =>
8694 Check_No_Identifiers;
8695 Check_Arg_Count (1);
8696 Check_Arg_Is_One_Of (Arg1, Name_Time, Name_Space, Name_Off);
8702 -- pragma Pack (first_subtype_LOCAL_NAME);
8704 when Pragma_Pack => Pack : declare
8705 Assoc : constant Node_Id := Arg1;
8710 Check_No_Identifiers;
8711 Check_Arg_Count (1);
8712 Check_Arg_Is_Local_Name (Arg1);
8714 Type_Id := Expression (Assoc);
8715 Find_Type (Type_Id);
8716 Typ := Entity (Type_Id);
8719 or else Rep_Item_Too_Early (Typ, N)
8723 Typ := Underlying_Type (Typ);
8726 if not Is_Array_Type (Typ) and then not Is_Record_Type (Typ) then
8727 Error_Pragma ("pragma% must specify array or record type");
8730 Check_First_Subtype (Arg1);
8732 if Has_Pragma_Pack (Typ) then
8733 Error_Pragma ("duplicate pragma%, only one allowed");
8737 elsif Is_Array_Type (Typ) then
8739 -- Pack not allowed for aliased or atomic components
8741 if Has_Aliased_Components (Base_Type (Typ)) then
8743 ("pragma% ignored, cannot pack aliased components?");
8745 elsif Has_Atomic_Components (Typ)
8746 or else Is_Atomic (Component_Type (Typ))
8749 ("?pragma% ignored, cannot pack atomic components");
8752 -- If we had an explicit component size given, then we do not
8753 -- let Pack override this given size. We also give a warning
8754 -- that Pack is being ignored unless we can tell for sure that
8755 -- the Pack would not have had any effect anyway.
8757 if Has_Component_Size_Clause (Typ) then
8758 if Known_Static_RM_Size (Component_Type (Typ))
8760 RM_Size (Component_Type (Typ)) = Component_Size (Typ)
8765 ("?pragma% ignored, explicit component size given");
8768 -- If no prior array component size given, Pack is effective
8771 if not Rep_Item_Too_Late (Typ, N) then
8772 if VM_Target = No_VM then
8773 Set_Is_Packed (Base_Type (Typ));
8774 elsif not GNAT_Mode then
8776 ("?pragma% ignored in this configuration");
8779 Set_Has_Pragma_Pack (Base_Type (Typ));
8780 Set_Has_Non_Standard_Rep (Base_Type (Typ));
8784 -- For record types, the pack is always effective
8786 else pragma Assert (Is_Record_Type (Typ));
8787 if not Rep_Item_Too_Late (Typ, N) then
8788 if VM_Target = No_VM then
8789 Set_Is_Packed (Base_Type (Typ));
8790 elsif not GNAT_Mode then
8791 Error_Pragma ("?pragma% ignored in this configuration");
8794 Set_Has_Pragma_Pack (Base_Type (Typ));
8795 Set_Has_Non_Standard_Rep (Base_Type (Typ));
8806 -- There is nothing to do here, since we did all the processing
8807 -- for this pragma in Par.Prag (so that it works properly even in
8808 -- syntax only mode)
8817 -- pragma Passive [(PASSIVE_FORM)];
8819 -- PASSIVE_FORM ::= Semaphore | No
8821 when Pragma_Passive =>
8824 if Nkind (Parent (N)) /= N_Task_Definition then
8825 Error_Pragma ("pragma% must be within task definition");
8828 if Arg_Count /= 0 then
8829 Check_Arg_Count (1);
8830 Check_Arg_Is_One_Of (Arg1, Name_Semaphore, Name_No);
8833 ----------------------------------
8834 -- Preelaborable_Initialization --
8835 ----------------------------------
8837 -- pragma Preelaborable_Initialization (DIRECT_NAME);
8839 when Pragma_Preelaborable_Initialization => Preelab_Init : declare
8844 Check_Arg_Count (1);
8845 Check_No_Identifiers;
8846 Check_Arg_Is_Identifier (Arg1);
8847 Check_Arg_Is_Local_Name (Arg1);
8848 Check_First_Subtype (Arg1);
8849 Ent := Entity (Expression (Arg1));
8851 if not Is_Private_Type (Ent)
8852 and then not Is_Protected_Type (Ent)
8855 ("pragma % can only be applied to private or protected type",
8859 -- Give an error if the pragma is applied to a protected type that
8860 -- does not qualify (due to having entries, or due to components
8861 -- that do not qualify).
8863 if Is_Protected_Type (Ent)
8864 and then not Has_Preelaborable_Initialization (Ent)
8867 ("protected type & does not have preelaborable " &
8868 "initialization", Ent);
8870 -- Otherwise mark the type as definitely having preelaborable
8874 Set_Known_To_Have_Preelab_Init (Ent);
8877 if Has_Pragma_Preelab_Init (Ent)
8878 and then Warn_On_Redundant_Constructs
8880 Error_Pragma ("?duplicate pragma%!");
8882 Set_Has_Pragma_Preelab_Init (Ent);
8890 -- pragma Polling (ON | OFF);
8892 when Pragma_Polling =>
8894 Check_Arg_Count (1);
8895 Check_No_Identifiers;
8896 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
8897 Polling_Required := (Chars (Expression (Arg1)) = Name_On);
8899 --------------------
8900 -- Persistent_BSS --
8901 --------------------
8903 when Pragma_Persistent_BSS => Persistent_BSS : declare
8910 Check_At_Most_N_Arguments (1);
8912 -- Case of application to specific object (one argument)
8914 if Arg_Count = 1 then
8915 Check_Arg_Is_Library_Level_Local_Name (Arg1);
8917 if not Is_Entity_Name (Expression (Arg1))
8919 (Ekind (Entity (Expression (Arg1))) /= E_Variable
8920 and then Ekind (Entity (Expression (Arg1))) /= E_Constant)
8922 Error_Pragma_Arg ("pragma% only applies to objects", Arg1);
8925 Ent := Entity (Expression (Arg1));
8926 Decl := Parent (Ent);
8928 if Rep_Item_Too_Late (Ent, N) then
8932 if Present (Expression (Decl)) then
8934 ("object for pragma% cannot have initialization", Arg1);
8937 if not Is_Potentially_Persistent_Type (Etype (Ent)) then
8939 ("object type for pragma% is not potentially persistent",
8944 Make_Linker_Section_Pragma
8945 (Ent, Sloc (N), ".persistent.bss");
8946 Insert_After (N, Prag);
8949 -- Case of use as configuration pragma with no arguments
8952 Check_Valid_Configuration_Pragma;
8953 Persistent_BSS_Mode := True;
8961 -- pragma Preelaborate [(library_unit_NAME)];
8963 -- Set the flag Is_Preelaborated of program unit name entity
8965 when Pragma_Preelaborate => Preelaborate : declare
8966 Pa : constant Node_Id := Parent (N);
8967 Pk : constant Node_Kind := Nkind (Pa);
8971 Check_Ada_83_Warning;
8972 Check_Valid_Library_Unit_Pragma;
8974 if Nkind (N) = N_Null_Statement then
8978 Ent := Find_Lib_Unit_Name;
8980 -- This filters out pragmas inside generic parent then
8981 -- show up inside instantiation
8984 and then not (Pk = N_Package_Specification
8985 and then Present (Generic_Parent (Pa)))
8987 if not Debug_Flag_U then
8988 Set_Is_Preelaborated (Ent);
8989 Set_Suppress_Elaboration_Warnings (Ent);
8994 ---------------------
8995 -- Preelaborate_05 --
8996 ---------------------
8998 -- pragma Preelaborate_05 [(library_unit_NAME)];
9000 -- This pragma is useable only in GNAT_Mode, where it is used like
9001 -- pragma Preelaborate but it is only effective in Ada 2005 mode
9002 -- (otherwise it is ignored). This is used to implement AI-362 which
9003 -- recategorizes some run-time packages in Ada 2005 mode.
9005 when Pragma_Preelaborate_05 => Preelaborate_05 : declare
9010 Check_Valid_Library_Unit_Pragma;
9012 if not GNAT_Mode then
9013 Error_Pragma ("pragma% only available in GNAT mode");
9016 if Nkind (N) = N_Null_Statement then
9020 -- This is one of the few cases where we need to test the value of
9021 -- Ada_Version_Explicit rather than Ada_Version (which is always
9022 -- set to Ada_05 in a predefined unit), we need to know the
9023 -- explicit version set to know if this pragma is active.
9025 if Ada_Version_Explicit >= Ada_05 then
9026 Ent := Find_Lib_Unit_Name;
9027 Set_Is_Preelaborated (Ent);
9028 Set_Suppress_Elaboration_Warnings (Ent);
9030 end Preelaborate_05;
9036 -- pragma Priority (EXPRESSION);
9038 when Pragma_Priority => Priority : declare
9039 P : constant Node_Id := Parent (N);
9043 Check_No_Identifiers;
9044 Check_Arg_Count (1);
9048 if Nkind (P) = N_Subprogram_Body then
9049 Check_In_Main_Program;
9051 Arg := Expression (Arg1);
9052 Analyze_And_Resolve (Arg, Standard_Integer);
9056 if not Is_Static_Expression (Arg) then
9057 Flag_Non_Static_Expr
9058 ("main subprogram priority is not static!", Arg);
9061 -- If constraint error, then we already signalled an error
9063 elsif Raises_Constraint_Error (Arg) then
9066 -- Otherwise check in range
9070 Val : constant Uint := Expr_Value (Arg);
9074 or else Val > Expr_Value (Expression
9075 (Parent (RTE (RE_Max_Priority))))
9078 ("main subprogram priority is out of range", Arg1);
9084 (Current_Sem_Unit, UI_To_Int (Expr_Value (Arg)));
9086 -- Load an arbitrary entity from System.Tasking to make sure
9087 -- this package is implicitly with'ed, since we need to have
9088 -- the tasking run-time active for the pragma Priority to have
9092 Discard : Entity_Id;
9093 pragma Warnings (Off, Discard);
9095 Discard := RTE (RE_Task_List);
9098 -- Task or Protected, must be of type Integer
9100 elsif Nkind (P) = N_Protected_Definition
9102 Nkind (P) = N_Task_Definition
9104 Arg := Expression (Arg1);
9106 -- The expression must be analyzed in the special manner
9107 -- described in "Handling of Default and Per-Object
9108 -- Expressions" in sem.ads.
9110 Analyze_Per_Use_Expression (Arg, Standard_Integer);
9112 if not Is_Static_Expression (Arg) then
9113 Check_Restriction (Static_Priorities, Arg);
9116 -- Anything else is incorrect
9122 if Has_Priority_Pragma (P) then
9123 Error_Pragma ("duplicate pragma% not allowed");
9125 Set_Has_Priority_Pragma (P, True);
9127 if Nkind (P) = N_Protected_Definition
9129 Nkind (P) = N_Task_Definition
9131 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
9132 -- exp_ch9 should use this ???
9137 -----------------------------------
9138 -- Priority_Specific_Dispatching --
9139 -----------------------------------
9141 -- pragma Priority_Specific_Dispatching (
9142 -- policy_IDENTIFIER,
9143 -- first_priority_EXPRESSION,
9144 -- last_priority_EXPRESSION);
9146 when Pragma_Priority_Specific_Dispatching =>
9147 Priority_Specific_Dispatching : declare
9148 Prio_Id : constant Entity_Id := RTE (RE_Any_Priority);
9149 -- This is the entity System.Any_Priority;
9152 Lower_Bound : Node_Id;
9153 Upper_Bound : Node_Id;
9159 Check_Arg_Count (3);
9160 Check_No_Identifiers;
9161 Check_Arg_Is_Task_Dispatching_Policy (Arg1);
9162 Check_Valid_Configuration_Pragma;
9163 Get_Name_String (Chars (Expression (Arg1)));
9164 DP := Fold_Upper (Name_Buffer (1));
9166 Lower_Bound := Expression (Arg2);
9167 Check_Arg_Is_Static_Expression (Lower_Bound, Standard_Integer);
9168 Lower_Val := Expr_Value (Lower_Bound);
9170 Upper_Bound := Expression (Arg3);
9171 Check_Arg_Is_Static_Expression (Upper_Bound, Standard_Integer);
9172 Upper_Val := Expr_Value (Upper_Bound);
9174 -- It is not allowed to use Task_Dispatching_Policy and
9175 -- Priority_Specific_Dispatching in the same partition.
9177 if Task_Dispatching_Policy /= ' ' then
9178 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
9180 ("pragma% incompatible with Task_Dispatching_Policy#");
9182 -- Check lower bound in range
9184 elsif Lower_Val < Expr_Value (Type_Low_Bound (Prio_Id))
9186 Lower_Val > Expr_Value (Type_High_Bound (Prio_Id))
9189 ("first_priority is out of range", Arg2);
9191 -- Check upper bound in range
9193 elsif Upper_Val < Expr_Value (Type_Low_Bound (Prio_Id))
9195 Upper_Val > Expr_Value (Type_High_Bound (Prio_Id))
9198 ("last_priority is out of range", Arg3);
9200 -- Check that the priority range is valid
9202 elsif Lower_Val > Upper_Val then
9204 ("last_priority_expression must be greater than" &
9205 " or equal to first_priority_expression");
9207 -- Store the new policy, but always preserve System_Location since
9208 -- we like the error message with the run-time name.
9211 -- Check overlapping in the priority ranges specified in other
9212 -- Priority_Specific_Dispatching pragmas within the same
9213 -- partition. We can only check those we know about!
9216 Specific_Dispatching.First .. Specific_Dispatching.Last
9218 if Specific_Dispatching.Table (J).First_Priority in
9219 UI_To_Int (Lower_Val) .. UI_To_Int (Upper_Val)
9220 or else Specific_Dispatching.Table (J).Last_Priority in
9221 UI_To_Int (Lower_Val) .. UI_To_Int (Upper_Val)
9224 Specific_Dispatching.Table (J).Pragma_Loc;
9226 ("priority range overlaps with "
9227 & "Priority_Specific_Dispatching#");
9231 -- The use of Priority_Specific_Dispatching is incompatible
9232 -- with Task_Dispatching_Policy.
9234 if Task_Dispatching_Policy /= ' ' then
9235 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
9237 ("Priority_Specific_Dispatching incompatible "
9238 & "with Task_Dispatching_Policy#");
9241 -- The use of Priority_Specific_Dispatching forces ceiling
9244 if Locking_Policy /= ' ' and then Locking_Policy /= 'C' then
9245 Error_Msg_Sloc := Locking_Policy_Sloc;
9247 ("Priority_Specific_Dispatching incompatible "
9248 & "with Locking_Policy#");
9250 -- Set the Ceiling_Locking policy, but preserve System_Location
9251 -- since we like the error message with the run time name.
9254 Locking_Policy := 'C';
9256 if Locking_Policy_Sloc /= System_Location then
9257 Locking_Policy_Sloc := Loc;
9261 -- Add entry in the table
9263 Specific_Dispatching.Append
9264 ((Dispatching_Policy => DP,
9265 First_Priority => UI_To_Int (Lower_Val),
9266 Last_Priority => UI_To_Int (Upper_Val),
9267 Pragma_Loc => Loc));
9269 end Priority_Specific_Dispatching;
9275 -- pragma Profile (profile_IDENTIFIER);
9277 -- profile_IDENTIFIER => Protected | Ravenscar
9279 when Pragma_Profile =>
9281 Check_Arg_Count (1);
9282 Check_Valid_Configuration_Pragma;
9283 Check_No_Identifiers;
9286 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
9288 if Chars (Argx) = Name_Ravenscar then
9289 Set_Ravenscar_Profile (N);
9290 elsif Chars (Argx) = Name_Restricted then
9291 Set_Profile_Restrictions (Restricted, N, Warn => False);
9293 Error_Pragma_Arg ("& is not a valid profile", Argx);
9297 ----------------------
9298 -- Profile_Warnings --
9299 ----------------------
9301 -- pragma Profile_Warnings (profile_IDENTIFIER);
9303 -- profile_IDENTIFIER => Protected | Ravenscar
9305 when Pragma_Profile_Warnings =>
9307 Check_Arg_Count (1);
9308 Check_Valid_Configuration_Pragma;
9309 Check_No_Identifiers;
9312 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
9314 if Chars (Argx) = Name_Ravenscar then
9315 Set_Profile_Restrictions (Ravenscar, N, Warn => True);
9316 elsif Chars (Argx) = Name_Restricted then
9317 Set_Profile_Restrictions (Restricted, N, Warn => True);
9319 Error_Pragma_Arg ("& is not a valid profile", Argx);
9323 --------------------------
9324 -- Propagate_Exceptions --
9325 --------------------------
9327 -- pragma Propagate_Exceptions;
9329 -- Note: this pragma is obsolete and has no effect
9331 when Pragma_Propagate_Exceptions =>
9333 Check_Arg_Count (0);
9335 if In_Extended_Main_Source_Unit (N) then
9336 Propagate_Exceptions := True;
9343 -- pragma Psect_Object (
9344 -- [Internal =>] LOCAL_NAME,
9345 -- [, [External =>] EXTERNAL_SYMBOL]
9346 -- [, [Size =>] EXTERNAL_SYMBOL]);
9348 when Pragma_Psect_Object | Pragma_Common_Object =>
9349 Psect_Object : declare
9350 Args : Args_List (1 .. 3);
9351 Names : constant Name_List (1 .. 3) := (
9356 Internal : Node_Id renames Args (1);
9357 External : Node_Id renames Args (2);
9358 Size : Node_Id renames Args (3);
9362 procedure Check_Too_Long (Arg : Node_Id);
9363 -- Posts message if the argument is an identifier with more
9364 -- than 31 characters, or a string literal with more than
9365 -- 31 characters, and we are operating under VMS
9367 --------------------
9368 -- Check_Too_Long --
9369 --------------------
9371 procedure Check_Too_Long (Arg : Node_Id) is
9372 X : constant Node_Id := Original_Node (Arg);
9375 if Nkind (X) /= N_String_Literal
9377 Nkind (X) /= N_Identifier
9380 ("inappropriate argument for pragma %", Arg);
9383 if OpenVMS_On_Target then
9384 if (Nkind (X) = N_String_Literal
9385 and then String_Length (Strval (X)) > 31)
9387 (Nkind (X) = N_Identifier
9388 and then Length_Of_Name (Chars (X)) > 31)
9391 ("argument for pragma % is longer than 31 characters",
9397 -- Start of processing for Common_Object/Psect_Object
9401 Gather_Associations (Names, Args);
9402 Process_Extended_Import_Export_Internal_Arg (Internal);
9404 Def_Id := Entity (Internal);
9406 if Ekind (Def_Id) /= E_Constant
9407 and then Ekind (Def_Id) /= E_Variable
9410 ("pragma% must designate an object", Internal);
9413 Check_Too_Long (Internal);
9415 if Is_Imported (Def_Id) or else Is_Exported (Def_Id) then
9417 ("cannot use pragma% for imported/exported object",
9421 if Is_Concurrent_Type (Etype (Internal)) then
9423 ("cannot specify pragma % for task/protected object",
9427 if Has_Rep_Pragma (Def_Id, Name_Common_Object)
9429 Has_Rep_Pragma (Def_Id, Name_Psect_Object)
9431 Error_Msg_N ("?duplicate Common/Psect_Object pragma", N);
9434 if Ekind (Def_Id) = E_Constant then
9436 ("cannot specify pragma % for a constant", Internal);
9439 if Is_Record_Type (Etype (Internal)) then
9445 Ent := First_Entity (Etype (Internal));
9446 while Present (Ent) loop
9447 Decl := Declaration_Node (Ent);
9449 if Ekind (Ent) = E_Component
9450 and then Nkind (Decl) = N_Component_Declaration
9451 and then Present (Expression (Decl))
9452 and then Warn_On_Export_Import
9455 ("?object for pragma % has defaults", Internal);
9465 if Present (Size) then
9466 Check_Too_Long (Size);
9469 if Present (External) then
9470 Check_Arg_Is_External_Name (External);
9471 Check_Too_Long (External);
9474 -- If all error tests pass, link pragma on to the rep item chain
9476 Record_Rep_Item (Def_Id, N);
9483 -- pragma Pure [(library_unit_NAME)];
9485 when Pragma_Pure => Pure : declare
9489 Check_Ada_83_Warning;
9490 Check_Valid_Library_Unit_Pragma;
9492 if Nkind (N) = N_Null_Statement then
9496 Ent := Find_Lib_Unit_Name;
9498 Set_Has_Pragma_Pure (Ent);
9499 Set_Suppress_Elaboration_Warnings (Ent);
9506 -- pragma Pure_05 [(library_unit_NAME)];
9508 -- This pragma is useable only in GNAT_Mode, where it is used like
9509 -- pragma Pure but it is only effective in Ada 2005 mode (otherwise
9510 -- it is ignored). It may be used after a pragma Preelaborate, in
9511 -- which case it overrides the effect of the pragma Preelaborate.
9512 -- This is used to implement AI-362 which recategorizes some run-time
9513 -- packages in Ada 2005 mode.
9515 when Pragma_Pure_05 => Pure_05 : declare
9520 Check_Valid_Library_Unit_Pragma;
9522 if not GNAT_Mode then
9523 Error_Pragma ("pragma% only available in GNAT mode");
9525 if Nkind (N) = N_Null_Statement then
9529 -- This is one of the few cases where we need to test the value of
9530 -- Ada_Version_Explicit rather than Ada_Version (which is always
9531 -- set to Ada_05 in a predefined unit), we need to know the
9532 -- explicit version set to know if this pragma is active.
9534 if Ada_Version_Explicit >= Ada_05 then
9535 Ent := Find_Lib_Unit_Name;
9536 Set_Is_Preelaborated (Ent, False);
9538 Set_Suppress_Elaboration_Warnings (Ent);
9546 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
9548 when Pragma_Pure_Function => Pure_Function : declare
9552 Effective : Boolean := False;
9556 Check_Arg_Count (1);
9557 Check_Optional_Identifier (Arg1, Name_Entity);
9558 Check_Arg_Is_Local_Name (Arg1);
9559 E_Id := Expression (Arg1);
9561 if Error_Posted (E_Id) then
9565 -- Loop through homonyms (overloadings) of referenced entity
9571 Def_Id := Get_Base_Subprogram (E);
9573 if Ekind (Def_Id) /= E_Function
9574 and then Ekind (Def_Id) /= E_Generic_Function
9575 and then Ekind (Def_Id) /= E_Operator
9578 ("pragma% requires a function name", Arg1);
9581 Set_Is_Pure (Def_Id);
9583 if not Has_Pragma_Pure_Function (Def_Id) then
9584 Set_Has_Pragma_Pure_Function (Def_Id);
9589 exit when No (E) or else Scope (E) /= Current_Scope;
9593 and then Warn_On_Redundant_Constructs
9595 Error_Msg_NE ("pragma Pure_Function on& is redundant?",
9601 --------------------
9602 -- Queuing_Policy --
9603 --------------------
9605 -- pragma Queuing_Policy (policy_IDENTIFIER);
9607 when Pragma_Queuing_Policy => declare
9611 Check_Ada_83_Warning;
9612 Check_Arg_Count (1);
9613 Check_No_Identifiers;
9614 Check_Arg_Is_Queuing_Policy (Arg1);
9615 Check_Valid_Configuration_Pragma;
9616 Get_Name_String (Chars (Expression (Arg1)));
9617 QP := Fold_Upper (Name_Buffer (1));
9619 if Queuing_Policy /= ' '
9620 and then Queuing_Policy /= QP
9622 Error_Msg_Sloc := Queuing_Policy_Sloc;
9623 Error_Pragma ("queuing policy incompatible with policy#");
9625 -- Set new policy, but always preserve System_Location since
9626 -- we like the error message with the run time name.
9629 Queuing_Policy := QP;
9631 if Queuing_Policy_Sloc /= System_Location then
9632 Queuing_Policy_Sloc := Loc;
9637 ---------------------------
9638 -- Remote_Call_Interface --
9639 ---------------------------
9641 -- pragma Remote_Call_Interface [(library_unit_NAME)];
9643 when Pragma_Remote_Call_Interface => Remote_Call_Interface : declare
9644 Cunit_Node : Node_Id;
9645 Cunit_Ent : Entity_Id;
9649 Check_Ada_83_Warning;
9650 Check_Valid_Library_Unit_Pragma;
9652 if Nkind (N) = N_Null_Statement then
9656 Cunit_Node := Cunit (Current_Sem_Unit);
9657 K := Nkind (Unit (Cunit_Node));
9658 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
9660 if K = N_Package_Declaration
9661 or else K = N_Generic_Package_Declaration
9662 or else K = N_Subprogram_Declaration
9663 or else K = N_Generic_Subprogram_Declaration
9664 or else (K = N_Subprogram_Body
9665 and then Acts_As_Spec (Unit (Cunit_Node)))
9670 "pragma% must apply to package or subprogram declaration");
9673 Set_Is_Remote_Call_Interface (Cunit_Ent);
9674 end Remote_Call_Interface;
9680 -- pragma Remote_Types [(library_unit_NAME)];
9682 when Pragma_Remote_Types => Remote_Types : declare
9683 Cunit_Node : Node_Id;
9684 Cunit_Ent : Entity_Id;
9687 Check_Ada_83_Warning;
9688 Check_Valid_Library_Unit_Pragma;
9690 if Nkind (N) = N_Null_Statement then
9694 Cunit_Node := Cunit (Current_Sem_Unit);
9695 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
9697 if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration
9699 Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration
9702 "pragma% can only apply to a package declaration");
9705 Set_Is_Remote_Types (Cunit_Ent);
9712 -- pragma Ravenscar;
9714 when Pragma_Ravenscar =>
9716 Check_Arg_Count (0);
9717 Check_Valid_Configuration_Pragma;
9718 Set_Ravenscar_Profile (N);
9720 if Warn_On_Obsolescent_Feature then
9722 ("pragma Ravenscar is an obsolescent feature?", N);
9724 ("|use pragma Profile (Ravenscar) instead", N);
9727 -------------------------
9728 -- Restricted_Run_Time --
9729 -------------------------
9731 -- pragma Restricted_Run_Time;
9733 when Pragma_Restricted_Run_Time =>
9735 Check_Arg_Count (0);
9736 Check_Valid_Configuration_Pragma;
9737 Set_Profile_Restrictions (Restricted, N, Warn => False);
9739 if Warn_On_Obsolescent_Feature then
9741 ("pragma Restricted_Run_Time is an obsolescent feature?", N);
9743 ("|use pragma Profile (Restricted) instead", N);
9750 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
9753 -- restriction_IDENTIFIER
9754 -- | restriction_parameter_IDENTIFIER => EXPRESSION
9756 when Pragma_Restrictions =>
9757 Process_Restrictions_Or_Restriction_Warnings (Warn => False);
9759 --------------------------
9760 -- Restriction_Warnings --
9761 --------------------------
9763 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
9766 -- restriction_IDENTIFIER
9767 -- | restriction_parameter_IDENTIFIER => EXPRESSION
9769 when Pragma_Restriction_Warnings =>
9770 Process_Restrictions_Or_Restriction_Warnings (Warn => True);
9776 -- pragma Reviewable;
9778 when Pragma_Reviewable =>
9779 Check_Ada_83_Warning;
9780 Check_Arg_Count (0);
9787 -- pragma Share_Generic (NAME {, NAME});
9789 when Pragma_Share_Generic =>
9791 Process_Generic_List;
9797 -- pragma Shared (LOCAL_NAME);
9799 when Pragma_Shared =>
9801 Process_Atomic_Shared_Volatile;
9803 --------------------
9804 -- Shared_Passive --
9805 --------------------
9807 -- pragma Shared_Passive [(library_unit_NAME)];
9809 -- Set the flag Is_Shared_Passive of program unit name entity
9811 when Pragma_Shared_Passive => Shared_Passive : declare
9812 Cunit_Node : Node_Id;
9813 Cunit_Ent : Entity_Id;
9816 Check_Ada_83_Warning;
9817 Check_Valid_Library_Unit_Pragma;
9819 if Nkind (N) = N_Null_Statement then
9823 Cunit_Node := Cunit (Current_Sem_Unit);
9824 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
9826 if Nkind (Unit (Cunit_Node)) /= N_Package_Declaration
9828 Nkind (Unit (Cunit_Node)) /= N_Generic_Package_Declaration
9831 "pragma% can only apply to a package declaration");
9834 Set_Is_Shared_Passive (Cunit_Ent);
9837 ----------------------
9838 -- Source_File_Name --
9839 ----------------------
9841 -- There are five forms for this pragma:
9843 -- pragma Source_File_Name (
9844 -- [UNIT_NAME =>] unit_NAME,
9845 -- BODY_FILE_NAME => STRING_LITERAL
9846 -- [, [INDEX =>] INTEGER_LITERAL]);
9848 -- pragma Source_File_Name (
9849 -- [UNIT_NAME =>] unit_NAME,
9850 -- SPEC_FILE_NAME => STRING_LITERAL
9851 -- [, [INDEX =>] INTEGER_LITERAL]);
9853 -- pragma Source_File_Name (
9854 -- BODY_FILE_NAME => STRING_LITERAL
9855 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9856 -- [, CASING => CASING_SPEC]);
9858 -- pragma Source_File_Name (
9859 -- SPEC_FILE_NAME => STRING_LITERAL
9860 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9861 -- [, CASING => CASING_SPEC]);
9863 -- pragma Source_File_Name (
9864 -- SUBUNIT_FILE_NAME => STRING_LITERAL
9865 -- [, DOT_REPLACEMENT => STRING_LITERAL]
9866 -- [, CASING => CASING_SPEC]);
9868 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
9870 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
9871 -- Source_File_Name (SFN), however their usage is exclusive:
9872 -- SFN can only be used when no project file is used, while
9873 -- SFNP can only be used when a project file is used.
9875 -- No processing here. Processing was completed during parsing,
9876 -- since we need to have file names set as early as possible.
9877 -- Units are loaded well before semantic processing starts.
9879 -- The only processing we defer to this point is the check
9880 -- for correct placement.
9882 when Pragma_Source_File_Name =>
9884 Check_Valid_Configuration_Pragma;
9886 ------------------------------
9887 -- Source_File_Name_Project --
9888 ------------------------------
9890 -- See Source_File_Name for syntax
9892 -- No processing here. Processing was completed during parsing,
9893 -- since we need to have file names set as early as possible.
9894 -- Units are loaded well before semantic processing starts.
9896 -- The only processing we defer to this point is the check
9897 -- for correct placement.
9899 when Pragma_Source_File_Name_Project =>
9901 Check_Valid_Configuration_Pragma;
9903 -- Check that a pragma Source_File_Name_Project is used only
9904 -- in a configuration pragmas file.
9906 -- Pragmas Source_File_Name_Project should only be generated
9907 -- by the Project Manager in configuration pragmas files.
9909 -- This is really an ugly test. It seems to depend on some
9910 -- accidental and undocumented property. At the very least
9911 -- it needs to be documented, but it would be better to have
9912 -- a clean way of testing if we are in a configuration file???
9914 if Present (Parent (N)) then
9916 ("pragma% can only appear in a configuration pragmas file");
9919 ----------------------
9920 -- Source_Reference --
9921 ----------------------
9923 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
9925 -- Nothing to do, all processing completed in Par.Prag, since we
9926 -- need the information for possible parser messages that are output
9928 when Pragma_Source_Reference =>
9931 --------------------------------
9932 -- Static_Elaboration_Desired --
9933 --------------------------------
9935 -- pragma Static_Elaboration_Desired (DIRECT_NAME);
9937 when Pragma_Static_Elaboration_Desired =>
9939 Check_At_Most_N_Arguments (1);
9941 if Is_Compilation_Unit (Current_Scope)
9942 and then Ekind (Current_Scope) = E_Package
9944 Set_Static_Elaboration_Desired (Current_Scope, True);
9946 Error_Pragma ("pragma% must apply to a library-level package");
9953 -- pragma Storage_Size (EXPRESSION);
9955 when Pragma_Storage_Size => Storage_Size : declare
9956 P : constant Node_Id := Parent (N);
9960 Check_No_Identifiers;
9961 Check_Arg_Count (1);
9963 -- The expression must be analyzed in the special manner
9964 -- described in "Handling of Default Expressions" in sem.ads.
9966 -- Set In_Default_Expression for per-object case ???
9968 Arg := Expression (Arg1);
9969 Analyze_Per_Use_Expression (Arg, Any_Integer);
9971 if not Is_Static_Expression (Arg) then
9972 Check_Restriction (Static_Storage_Size, Arg);
9975 if Nkind (P) /= N_Task_Definition then
9980 if Has_Storage_Size_Pragma (P) then
9981 Error_Pragma ("duplicate pragma% not allowed");
9983 Set_Has_Storage_Size_Pragma (P, True);
9986 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
9987 -- ??? exp_ch9 should use this!
9995 -- pragma Storage_Unit (NUMERIC_LITERAL);
9997 -- Only permitted argument is System'Storage_Unit value
9999 when Pragma_Storage_Unit =>
10000 Check_No_Identifiers;
10001 Check_Arg_Count (1);
10002 Check_Arg_Is_Integer_Literal (Arg1);
10004 if Intval (Expression (Arg1)) /=
10005 UI_From_Int (Ttypes.System_Storage_Unit)
10007 Error_Msg_Uint_1 := UI_From_Int (Ttypes.System_Storage_Unit);
10009 ("the only allowed argument for pragma% is ^", Arg1);
10012 --------------------
10013 -- Stream_Convert --
10014 --------------------
10016 -- pragma Stream_Convert (
10017 -- [Entity =>] type_LOCAL_NAME,
10018 -- [Read =>] function_NAME,
10019 -- [Write =>] function NAME);
10021 when Pragma_Stream_Convert => Stream_Convert : declare
10023 procedure Check_OK_Stream_Convert_Function (Arg : Node_Id);
10024 -- Check that the given argument is the name of a local
10025 -- function of one argument that is not overloaded earlier
10026 -- in the current local scope. A check is also made that the
10027 -- argument is a function with one parameter.
10029 --------------------------------------
10030 -- Check_OK_Stream_Convert_Function --
10031 --------------------------------------
10033 procedure Check_OK_Stream_Convert_Function (Arg : Node_Id) is
10037 Check_Arg_Is_Local_Name (Arg);
10038 Ent := Entity (Expression (Arg));
10040 if Has_Homonym (Ent) then
10042 ("argument for pragma% may not be overloaded", Arg);
10045 if Ekind (Ent) /= E_Function
10046 or else No (First_Formal (Ent))
10047 or else Present (Next_Formal (First_Formal (Ent)))
10050 ("argument for pragma% must be" &
10051 " function of one argument", Arg);
10053 end Check_OK_Stream_Convert_Function;
10055 -- Start of procecessing for Stream_Convert
10059 Check_Arg_Order ((Name_Entity, Name_Read, Name_Write));
10060 Check_Arg_Count (3);
10061 Check_Optional_Identifier (Arg1, Name_Entity);
10062 Check_Optional_Identifier (Arg2, Name_Read);
10063 Check_Optional_Identifier (Arg3, Name_Write);
10064 Check_Arg_Is_Local_Name (Arg1);
10065 Check_OK_Stream_Convert_Function (Arg2);
10066 Check_OK_Stream_Convert_Function (Arg3);
10069 Typ : constant Entity_Id :=
10070 Underlying_Type (Entity (Expression (Arg1)));
10071 Read : constant Entity_Id := Entity (Expression (Arg2));
10072 Write : constant Entity_Id := Entity (Expression (Arg3));
10075 if Etype (Typ) = Any_Type
10077 Etype (Read) = Any_Type
10079 Etype (Write) = Any_Type
10084 Check_First_Subtype (Arg1);
10086 if Rep_Item_Too_Early (Typ, N)
10088 Rep_Item_Too_Late (Typ, N)
10093 if Underlying_Type (Etype (Read)) /= Typ then
10095 ("incorrect return type for function&", Arg2);
10098 if Underlying_Type (Etype (First_Formal (Write))) /= Typ then
10100 ("incorrect parameter type for function&", Arg3);
10103 if Underlying_Type (Etype (First_Formal (Read))) /=
10104 Underlying_Type (Etype (Write))
10107 ("result type of & does not match Read parameter type",
10111 end Stream_Convert;
10113 -------------------------
10114 -- Style_Checks (GNAT) --
10115 -------------------------
10117 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
10119 -- This is processed by the parser since some of the style
10120 -- checks take place during source scanning and parsing. This
10121 -- means that we don't need to issue error messages here.
10123 when Pragma_Style_Checks => Style_Checks : declare
10124 A : constant Node_Id := Expression (Arg1);
10130 Check_No_Identifiers;
10132 -- Two argument form
10134 if Arg_Count = 2 then
10135 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
10142 E_Id := Expression (Arg2);
10145 if not Is_Entity_Name (E_Id) then
10147 ("second argument of pragma% must be entity name",
10151 E := Entity (E_Id);
10157 Set_Suppress_Style_Checks (E,
10158 (Chars (Expression (Arg1)) = Name_Off));
10159 exit when No (Homonym (E));
10165 -- One argument form
10168 Check_Arg_Count (1);
10170 if Nkind (A) = N_String_Literal then
10174 Slen : constant Natural := Natural (String_Length (S));
10175 Options : String (1 .. Slen);
10181 C := Get_String_Char (S, Int (J));
10182 exit when not In_Character_Range (C);
10183 Options (J) := Get_Character (C);
10185 -- If at end of string, set options. As per discussion
10186 -- above, no need to check for errors, since we issued
10187 -- them in the parser.
10190 Set_Style_Check_Options (Options);
10198 elsif Nkind (A) = N_Identifier then
10199 if Chars (A) = Name_All_Checks then
10200 Set_Default_Style_Check_Options;
10202 elsif Chars (A) = Name_On then
10203 Style_Check := True;
10205 elsif Chars (A) = Name_Off then
10206 Style_Check := False;
10216 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
10218 when Pragma_Subtitle =>
10220 Check_Arg_Count (1);
10221 Check_Optional_Identifier (Arg1, Name_Subtitle);
10222 Check_Arg_Is_String_Literal (Arg1);
10228 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
10230 when Pragma_Suppress =>
10231 Process_Suppress_Unsuppress (True);
10237 -- pragma Suppress_All;
10239 -- The only check made here is that the pragma appears in the
10240 -- proper place, i.e. following a compilation unit. If indeed
10241 -- it appears in this context, then the parser has already
10242 -- inserted an equivalent pragma Suppress (All_Checks) to get
10243 -- the required effect.
10245 when Pragma_Suppress_All =>
10247 Check_Arg_Count (0);
10249 if Nkind (Parent (N)) /= N_Compilation_Unit_Aux
10250 or else not Is_List_Member (N)
10251 or else List_Containing (N) /= Pragmas_After (Parent (N))
10254 ("misplaced pragma%, must follow compilation unit");
10257 -------------------------
10258 -- Suppress_Debug_Info --
10259 -------------------------
10261 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
10263 when Pragma_Suppress_Debug_Info =>
10265 Check_Arg_Count (1);
10266 Check_Optional_Identifier (Arg1, Name_Entity);
10267 Check_Arg_Is_Local_Name (Arg1);
10268 Set_Debug_Info_Off (Entity (Get_Pragma_Arg (Arg1)));
10270 ----------------------------------
10271 -- Suppress_Exception_Locations --
10272 ----------------------------------
10274 -- pragma Suppress_Exception_Locations;
10276 when Pragma_Suppress_Exception_Locations =>
10278 Check_Arg_Count (0);
10279 Check_Valid_Configuration_Pragma;
10280 Exception_Locations_Suppressed := True;
10282 -----------------------------
10283 -- Suppress_Initialization --
10284 -----------------------------
10286 -- pragma Suppress_Initialization ([Entity =>] type_Name);
10288 when Pragma_Suppress_Initialization => Suppress_Init : declare
10294 Check_Arg_Count (1);
10295 Check_Optional_Identifier (Arg1, Name_Entity);
10296 Check_Arg_Is_Local_Name (Arg1);
10298 E_Id := Expression (Arg1);
10300 if Etype (E_Id) = Any_Type then
10304 E := Entity (E_Id);
10306 if Is_Type (E) then
10307 if Is_Incomplete_Or_Private_Type (E) then
10308 if No (Full_View (Base_Type (E))) then
10310 ("argument of pragma% cannot be an incomplete type",
10313 Set_Suppress_Init_Proc (Full_View (Base_Type (E)));
10316 Set_Suppress_Init_Proc (Base_Type (E));
10321 ("pragma% requires argument that is a type name", Arg1);
10329 -- pragma System_Name (DIRECT_NAME);
10331 -- Syntax check: one argument, which must be the identifier GNAT
10332 -- or the identifier GCC, no other identifiers are acceptable.
10334 when Pragma_System_Name =>
10335 Check_No_Identifiers;
10336 Check_Arg_Count (1);
10337 Check_Arg_Is_One_Of (Arg1, Name_Gcc, Name_Gnat);
10339 -----------------------------
10340 -- Task_Dispatching_Policy --
10341 -----------------------------
10343 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
10345 when Pragma_Task_Dispatching_Policy => declare
10349 Check_Ada_83_Warning;
10350 Check_Arg_Count (1);
10351 Check_No_Identifiers;
10352 Check_Arg_Is_Task_Dispatching_Policy (Arg1);
10353 Check_Valid_Configuration_Pragma;
10354 Get_Name_String (Chars (Expression (Arg1)));
10355 DP := Fold_Upper (Name_Buffer (1));
10357 if Task_Dispatching_Policy /= ' '
10358 and then Task_Dispatching_Policy /= DP
10360 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
10362 ("task dispatching policy incompatible with policy#");
10364 -- Set new policy, but always preserve System_Location since
10365 -- we like the error message with the run time name.
10368 Task_Dispatching_Policy := DP;
10370 if Task_Dispatching_Policy_Sloc /= System_Location then
10371 Task_Dispatching_Policy_Sloc := Loc;
10380 -- pragma Task_Info (EXPRESSION);
10382 when Pragma_Task_Info => Task_Info : declare
10383 P : constant Node_Id := Parent (N);
10388 if Nkind (P) /= N_Task_Definition then
10389 Error_Pragma ("pragma% must appear in task definition");
10392 Check_No_Identifiers;
10393 Check_Arg_Count (1);
10395 Analyze_And_Resolve (Expression (Arg1), RTE (RE_Task_Info_Type));
10397 if Etype (Expression (Arg1)) = Any_Type then
10401 if Has_Task_Info_Pragma (P) then
10402 Error_Pragma ("duplicate pragma% not allowed");
10404 Set_Has_Task_Info_Pragma (P, True);
10412 -- pragma Task_Name (string_EXPRESSION);
10414 when Pragma_Task_Name => Task_Name : declare
10415 -- pragma Priority (EXPRESSION);
10417 P : constant Node_Id := Parent (N);
10421 Check_No_Identifiers;
10422 Check_Arg_Count (1);
10424 Arg := Expression (Arg1);
10425 Analyze_And_Resolve (Arg, Standard_String);
10427 if Nkind (P) /= N_Task_Definition then
10431 if Has_Task_Name_Pragma (P) then
10432 Error_Pragma ("duplicate pragma% not allowed");
10434 Set_Has_Task_Name_Pragma (P, True);
10435 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
10443 -- pragma Task_Storage (
10444 -- [Task_Type =>] LOCAL_NAME,
10445 -- [Top_Guard =>] static_integer_EXPRESSION);
10447 when Pragma_Task_Storage => Task_Storage : declare
10448 Args : Args_List (1 .. 2);
10449 Names : constant Name_List (1 .. 2) := (
10453 Task_Type : Node_Id renames Args (1);
10454 Top_Guard : Node_Id renames Args (2);
10460 Gather_Associations (Names, Args);
10462 if No (Task_Type) then
10464 ("missing task_type argument for pragma%");
10467 Check_Arg_Is_Local_Name (Task_Type);
10469 Ent := Entity (Task_Type);
10471 if not Is_Task_Type (Ent) then
10473 ("argument for pragma% must be task type", Task_Type);
10476 if No (Top_Guard) then
10478 ("pragma% takes two arguments", Task_Type);
10480 Check_Arg_Is_Static_Expression (Top_Guard, Any_Integer);
10483 Check_First_Subtype (Task_Type);
10485 if Rep_Item_Too_Late (Ent, N) then
10494 -- pragma Time_Slice (static_duration_EXPRESSION);
10496 when Pragma_Time_Slice => Time_Slice : declare
10502 Check_Arg_Count (1);
10503 Check_No_Identifiers;
10504 Check_In_Main_Program;
10505 Check_Arg_Is_Static_Expression (Arg1, Standard_Duration);
10507 if not Error_Posted (Arg1) then
10509 while Present (Nod) loop
10510 if Nkind (Nod) = N_Pragma
10511 and then Chars (Nod) = Name_Time_Slice
10513 Error_Msg_Name_1 := Chars (N);
10514 Error_Msg_N ("duplicate pragma% not permitted", Nod);
10521 -- Process only if in main unit
10523 if Get_Source_Unit (Loc) = Main_Unit then
10524 Opt.Time_Slice_Set := True;
10525 Val := Expr_Value_R (Expression (Arg1));
10527 if Val <= Ureal_0 then
10528 Opt.Time_Slice_Value := 0;
10530 elsif Val > UR_From_Uint (UI_From_Int (1000)) then
10531 Opt.Time_Slice_Value := 1_000_000_000;
10534 Opt.Time_Slice_Value :=
10535 UI_To_Int (UR_To_Uint (Val * UI_From_Int (1_000_000)));
10544 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
10546 -- TITLING_OPTION ::=
10547 -- [Title =>] STRING_LITERAL
10548 -- | [Subtitle =>] STRING_LITERAL
10550 when Pragma_Title => Title : declare
10551 Args : Args_List (1 .. 2);
10552 Names : constant Name_List (1 .. 2) := (
10558 Gather_Associations (Names, Args);
10560 for J in 1 .. 2 loop
10561 if Present (Args (J)) then
10562 Check_Arg_Is_String_Literal (Args (J));
10567 ---------------------
10568 -- Unchecked_Union --
10569 ---------------------
10571 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
10573 when Pragma_Unchecked_Union => Unchecked_Union : declare
10574 Assoc : constant Node_Id := Arg1;
10575 Type_Id : constant Node_Id := Expression (Assoc);
10586 Check_No_Identifiers;
10587 Check_Arg_Count (1);
10588 Check_Arg_Is_Local_Name (Arg1);
10590 Find_Type (Type_Id);
10591 Typ := Entity (Type_Id);
10594 or else Rep_Item_Too_Early (Typ, N)
10598 Typ := Underlying_Type (Typ);
10601 if Rep_Item_Too_Late (Typ, N) then
10605 Check_First_Subtype (Arg1);
10607 -- Note remaining cases are references to a type in the current
10608 -- declarative part. If we find an error, we post the error on
10609 -- the relevant type declaration at an appropriate point.
10611 if not Is_Record_Type (Typ) then
10612 Error_Msg_N ("Unchecked_Union must be record type", Typ);
10615 elsif Is_Tagged_Type (Typ) then
10616 Error_Msg_N ("Unchecked_Union must not be tagged", Typ);
10619 elsif Is_Limited_Type (Typ) then
10621 ("Unchecked_Union must not be limited record type", Typ);
10622 Explain_Limited_Type (Typ, Typ);
10626 if not Has_Discriminants (Typ) then
10628 ("Unchecked_Union must have one discriminant", Typ);
10632 Discr := First_Discriminant (Typ);
10633 while Present (Discr) loop
10634 if No (Discriminant_Default_Value (Discr)) then
10636 ("Unchecked_Union discriminant must have default value",
10639 Next_Discriminant (Discr);
10642 Tdef := Type_Definition (Declaration_Node (Typ));
10643 Clist := Component_List (Tdef);
10645 Comp := First (Component_Items (Clist));
10646 while Present (Comp) loop
10647 Check_Component (Comp);
10651 if No (Clist) or else No (Variant_Part (Clist)) then
10653 ("Unchecked_Union must have variant part",
10658 Vpart := Variant_Part (Clist);
10660 Variant := First (Variants (Vpart));
10661 while Present (Variant) loop
10662 Check_Variant (Variant);
10667 Set_Is_Unchecked_Union (Typ, True);
10668 Set_Convention (Typ, Convention_C);
10670 Set_Has_Unchecked_Union (Base_Type (Typ), True);
10671 Set_Is_Unchecked_Union (Base_Type (Typ), True);
10672 end Unchecked_Union;
10674 ------------------------
10675 -- Unimplemented_Unit --
10676 ------------------------
10678 -- pragma Unimplemented_Unit;
10680 -- Note: this only gives an error if we are generating code,
10681 -- or if we are in a generic library unit (where the pragma
10682 -- appears in the body, not in the spec).
10684 when Pragma_Unimplemented_Unit => Unimplemented_Unit : declare
10685 Cunitent : constant Entity_Id :=
10686 Cunit_Entity (Get_Source_Unit (Loc));
10687 Ent_Kind : constant Entity_Kind :=
10692 Check_Arg_Count (0);
10694 if Operating_Mode = Generate_Code
10695 or else Ent_Kind = E_Generic_Function
10696 or else Ent_Kind = E_Generic_Procedure
10697 or else Ent_Kind = E_Generic_Package
10699 Get_Name_String (Chars (Cunitent));
10700 Set_Casing (Mixed_Case);
10701 Write_Str (Name_Buffer (1 .. Name_Len));
10702 Write_Str (" is not supported in this configuration");
10704 raise Unrecoverable_Error;
10706 end Unimplemented_Unit;
10708 ------------------------
10709 -- Universal_Aliasing --
10710 ------------------------
10712 -- pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
10714 when Pragma_Universal_Aliasing => Universal_Alias : declare
10719 Check_Arg_Count (1);
10720 Check_Optional_Identifier (Arg2, Name_Entity);
10721 Check_Arg_Is_Local_Name (Arg1);
10722 E_Id := Entity (Expression (Arg1));
10724 if E_Id = Any_Type then
10726 elsif No (E_Id) or else not Is_Type (E_Id) then
10727 Error_Pragma_Arg ("pragma% requires type", Arg1);
10730 Set_Universal_Aliasing (Implementation_Base_Type (E_Id));
10731 end Universal_Alias;
10733 --------------------
10734 -- Universal_Data --
10735 --------------------
10737 -- pragma Universal_Data [(library_unit_NAME)];
10739 when Pragma_Universal_Data =>
10742 -- If this is a configuration pragma, then set the universal
10743 -- addressing option, otherwise confirm that the pragma
10744 -- satisfies the requirements of library unit pragma placement
10745 -- and leave it to the GNAAMP back end to detect the pragma
10746 -- (avoids transitive setting of the option due to withed units).
10748 if Is_Configuration_Pragma then
10749 Universal_Addressing_On_AAMP := True;
10751 Check_Valid_Library_Unit_Pragma;
10754 if not AAMP_On_Target then
10755 Error_Pragma ("?pragma% ignored (applies only to AAMP)");
10762 -- pragma Unreferenced (local_Name {, local_Name});
10764 -- or when used in a context clause:
10766 -- pragma Unreferenced (library_unit_NAME {, library_unit_NAME}
10768 when Pragma_Unreferenced => Unreferenced : declare
10769 Arg_Node : Node_Id;
10770 Arg_Expr : Node_Id;
10771 Arg_Ent : Entity_Id;
10776 Check_At_Least_N_Arguments (1);
10778 -- Check case of appearing within context clause
10780 if Is_In_Context_Clause then
10782 -- The arguments must all be units mentioned in a with clause
10783 -- in the same context clause. Note we already checked (in
10784 -- Par.Prag) that the arguments are either identifiers or
10785 -- selected components.
10788 while Present (Arg_Node) loop
10789 Citem := First (List_Containing (N));
10790 while Citem /= N loop
10791 if Nkind (Citem) = N_With_Clause
10792 and then Same_Name (Name (Citem), Expression (Arg_Node))
10794 Set_Has_Pragma_Unreferenced
10797 (Library_Unit (Citem))));
10798 Set_Unit_Name (Expression (Arg_Node), Name (Citem));
10807 ("argument of pragma% is not with'ed unit", Arg_Node);
10813 -- Case of not in list of context items
10817 while Present (Arg_Node) loop
10818 Check_No_Identifier (Arg_Node);
10820 -- Note: the analyze call done by Check_Arg_Is_Local_Name
10821 -- will in fact generate reference, so that the entity will
10822 -- have a reference, which will inhibit any warnings about
10823 -- it not being referenced, and also properly show up in the
10824 -- ali file as a reference. But this reference is recorded
10825 -- before the Has_Pragma_Unreferenced flag is set, so that
10826 -- no warning is generated for this reference.
10828 Check_Arg_Is_Local_Name (Arg_Node);
10829 Arg_Expr := Get_Pragma_Arg (Arg_Node);
10831 if Is_Entity_Name (Arg_Expr) then
10832 Arg_Ent := Entity (Arg_Expr);
10834 -- If the entity is overloaded, the pragma applies to the
10835 -- most recent overloading, as documented. In this case,
10836 -- name resolution does not generate a reference, so it
10837 -- must be done here explicitly.
10839 if Is_Overloaded (Arg_Expr) then
10840 Generate_Reference (Arg_Ent, N);
10843 Set_Has_Pragma_Unreferenced (Arg_Ent);
10851 --------------------------
10852 -- Unreferenced_Objects --
10853 --------------------------
10855 -- pragma Unreferenced_Objects (local_Name {, local_Name});
10857 when Pragma_Unreferenced_Objects => Unreferenced_Objects : declare
10858 Arg_Node : Node_Id;
10859 Arg_Expr : Node_Id;
10863 Check_At_Least_N_Arguments (1);
10866 while Present (Arg_Node) loop
10867 Check_No_Identifier (Arg_Node);
10868 Check_Arg_Is_Local_Name (Arg_Node);
10869 Arg_Expr := Get_Pragma_Arg (Arg_Node);
10871 if not Is_Entity_Name (Arg_Expr)
10872 or else not Is_Type (Entity (Arg_Expr))
10875 ("argument for pragma% must be type or subtype", Arg_Node);
10878 Set_Has_Pragma_Unreferenced_Objects (Entity (Arg_Expr));
10881 end Unreferenced_Objects;
10883 ------------------------------
10884 -- Unreserve_All_Interrupts --
10885 ------------------------------
10887 -- pragma Unreserve_All_Interrupts;
10889 when Pragma_Unreserve_All_Interrupts =>
10891 Check_Arg_Count (0);
10893 if In_Extended_Main_Code_Unit (Main_Unit_Entity) then
10894 Unreserve_All_Interrupts := True;
10901 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
10903 when Pragma_Unsuppress =>
10905 Process_Suppress_Unsuppress (False);
10907 -------------------
10908 -- Use_VADS_Size --
10909 -------------------
10911 -- pragma Use_VADS_Size;
10913 when Pragma_Use_VADS_Size =>
10915 Check_Arg_Count (0);
10916 Check_Valid_Configuration_Pragma;
10917 Use_VADS_Size := True;
10919 ---------------------
10920 -- Validity_Checks --
10921 ---------------------
10923 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
10925 when Pragma_Validity_Checks => Validity_Checks : declare
10926 A : constant Node_Id := Expression (Arg1);
10932 Check_Arg_Count (1);
10933 Check_No_Identifiers;
10935 if Nkind (A) = N_String_Literal then
10939 Slen : constant Natural := Natural (String_Length (S));
10940 Options : String (1 .. Slen);
10946 C := Get_String_Char (S, Int (J));
10947 exit when not In_Character_Range (C);
10948 Options (J) := Get_Character (C);
10951 Set_Validity_Check_Options (Options);
10959 elsif Nkind (A) = N_Identifier then
10961 if Chars (A) = Name_All_Checks then
10962 Set_Validity_Check_Options ("a");
10964 elsif Chars (A) = Name_On then
10965 Validity_Checks_On := True;
10967 elsif Chars (A) = Name_Off then
10968 Validity_Checks_On := False;
10972 end Validity_Checks;
10978 -- pragma Volatile (LOCAL_NAME);
10980 when Pragma_Volatile =>
10981 Process_Atomic_Shared_Volatile;
10983 -------------------------
10984 -- Volatile_Components --
10985 -------------------------
10987 -- pragma Volatile_Components (array_LOCAL_NAME);
10989 -- Volatile is handled by the same circuit as Atomic_Components
10995 -- pragma Warnings (On | Off);
10996 -- pragma Warnings (On | Off, LOCAL_NAME);
10997 -- pragma Warnings (static_string_EXPRESSION);
10998 -- pragma Warnings (On | Off, STRING_LITERAL);
11000 when Pragma_Warnings => Warnings : begin
11002 Check_At_Least_N_Arguments (1);
11003 Check_No_Identifiers;
11006 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
11009 -- One argument case
11011 if Arg_Count = 1 then
11013 -- On/Off one argument case was processed by parser
11015 if Nkind (Argx) = N_Identifier
11017 (Chars (Argx) = Name_On
11019 Chars (Argx) = Name_Off)
11023 -- One argument case must be ON/OFF or static string expr
11025 elsif not Is_Static_String_Expression (Arg1) then
11027 ("argument of pragma% must be On/Off or " &
11028 "static string expression", Arg2);
11030 -- One argument string expression case
11034 Lit : constant Node_Id := Expr_Value_S (Argx);
11035 Str : constant String_Id := Strval (Lit);
11036 Len : constant Nat := String_Length (Str);
11044 while J <= Len loop
11045 C := Get_String_Char (Str, J);
11046 OK := In_Character_Range (C);
11049 Chr := Get_Character (C);
11053 if J < Len and then Chr = '.' then
11055 C := Get_String_Char (Str, J);
11056 Chr := Get_Character (C);
11058 if not Set_Dot_Warning_Switch (Chr) then
11060 ("invalid warning switch character " &
11067 OK := Set_Warning_Switch (Chr);
11073 ("invalid warning switch character " & Chr,
11082 -- Two or more arguments (must be two)
11085 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
11086 Check_At_Most_N_Arguments (2);
11094 E_Id := Expression (Arg2);
11097 -- In the expansion of an inlined body, a reference to
11098 -- the formal may be wrapped in a conversion if the
11099 -- actual is a conversion. Retrieve the real entity name.
11101 if (In_Instance_Body
11102 or else In_Inlined_Body)
11103 and then Nkind (E_Id) = N_Unchecked_Type_Conversion
11105 E_Id := Expression (E_Id);
11108 -- Entity name case
11110 if Is_Entity_Name (E_Id) then
11111 E := Entity (E_Id);
11118 (E, (Chars (Expression (Arg1)) = Name_Off));
11120 if Is_Enumeration_Type (E) then
11124 Lit := First_Literal (E);
11125 while Present (Lit) loop
11126 Set_Warnings_Off (Lit);
11127 Next_Literal (Lit);
11132 exit when No (Homonym (E));
11137 -- Error if not entity or static string literal case
11139 elsif not Is_Static_String_Expression (Arg2) then
11141 ("second argument of pragma% must be entity " &
11142 "name or static string expression", Arg2);
11144 -- String literal case
11147 String_To_Name_Buffer
11148 (Strval (Expr_Value_S (Expression (Arg2))));
11150 -- Note on configuration pragma case: If this is a
11151 -- configuration pragma, then for an OFF pragma, we
11152 -- just set Config True in the call, which is all
11153 -- that needs to be done. For the case of ON, this
11154 -- is normally an error, unless it is canceling the
11155 -- effect of a previous OFF pragma in the same file.
11156 -- In any other case, an error will be signalled (ON
11157 -- with no matching OFF).
11159 if Chars (Argx) = Name_Off then
11160 Set_Specific_Warning_Off
11161 (Loc, Name_Buffer (1 .. Name_Len),
11162 Config => Is_Configuration_Pragma);
11164 elsif Chars (Argx) = Name_On then
11165 Set_Specific_Warning_On
11166 (Loc, Name_Buffer (1 .. Name_Len), Err);
11170 ("?pragma Warnings On with no " &
11171 "matching Warnings Off",
11181 -------------------
11182 -- Weak_External --
11183 -------------------
11185 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
11187 when Pragma_Weak_External => Weak_External : declare
11192 Check_Arg_Count (1);
11193 Check_Optional_Identifier (Arg1, Name_Entity);
11194 Check_Arg_Is_Library_Level_Local_Name (Arg1);
11195 Ent := Entity (Expression (Arg1));
11197 if Rep_Item_Too_Early (Ent, N) then
11200 Ent := Underlying_Type (Ent);
11203 -- The only processing required is to link this item on to the
11204 -- list of rep items for the given entity. This is accomplished
11205 -- by the call to Rep_Item_Too_Late (when no error is detected
11206 -- and False is returned).
11208 if Rep_Item_Too_Late (Ent, N) then
11211 Set_Has_Gigi_Rep_Item (Ent);
11215 -----------------------------
11216 -- Wide_Character_Encoding --
11217 -----------------------------
11219 -- pragma Wide_Character_Encoding (IDENTIFIER);
11221 when Pragma_Wide_Character_Encoding =>
11223 -- Nothing to do, handled in parser. Note that we do not enforce
11224 -- configuration pragma placement, this pragma can appear at any
11225 -- place in the source, allowing mixed encodings within a single
11230 --------------------
11231 -- Unknown_Pragma --
11232 --------------------
11234 -- Should be impossible, since the case of an unknown pragma is
11235 -- separately processed before the case statement is entered.
11237 when Unknown_Pragma =>
11238 raise Program_Error;
11242 when Pragma_Exit => null;
11243 end Analyze_Pragma;
11245 ---------------------------------
11246 -- Delay_Config_Pragma_Analyze --
11247 ---------------------------------
11249 function Delay_Config_Pragma_Analyze (N : Node_Id) return Boolean is
11251 return Chars (N) = Name_Interrupt_State
11253 Chars (N) = Name_Priority_Specific_Dispatching;
11254 end Delay_Config_Pragma_Analyze;
11256 -------------------------
11257 -- Get_Base_Subprogram --
11258 -------------------------
11260 function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id is
11261 Result : Entity_Id;
11264 -- Follow subprogram renaming chain
11267 while Is_Subprogram (Result)
11269 (Is_Generic_Instance (Result)
11270 or else Nkind (Parent (Declaration_Node (Result))) =
11271 N_Subprogram_Renaming_Declaration)
11272 and then Present (Alias (Result))
11274 Result := Alias (Result);
11278 end Get_Base_Subprogram;
11280 -----------------------------
11281 -- Is_Config_Static_String --
11282 -----------------------------
11284 function Is_Config_Static_String (Arg : Node_Id) return Boolean is
11286 function Add_Config_Static_String (Arg : Node_Id) return Boolean;
11287 -- This is an internal recursive function that is just like the
11288 -- outer function except that it adds the string to the name buffer
11289 -- rather than placing the string in the name buffer.
11291 ------------------------------
11292 -- Add_Config_Static_String --
11293 ------------------------------
11295 function Add_Config_Static_String (Arg : Node_Id) return Boolean is
11302 if Nkind (N) = N_Op_Concat then
11303 if Add_Config_Static_String (Left_Opnd (N)) then
11304 N := Right_Opnd (N);
11310 if Nkind (N) /= N_String_Literal then
11311 Error_Msg_N ("string literal expected for pragma argument", N);
11315 for J in 1 .. String_Length (Strval (N)) loop
11316 C := Get_String_Char (Strval (N), J);
11318 if not In_Character_Range (C) then
11320 ("string literal contains invalid wide character",
11321 Sloc (N) + 1 + Source_Ptr (J));
11325 Add_Char_To_Name_Buffer (Get_Character (C));
11330 end Add_Config_Static_String;
11332 -- Start of prorcessing for Is_Config_Static_String
11337 return Add_Config_Static_String (Arg);
11338 end Is_Config_Static_String;
11340 -----------------------------------------
11341 -- Is_Non_Significant_Pragma_Reference --
11342 -----------------------------------------
11344 -- This function makes use of the following static table which indicates
11345 -- whether a given pragma is significant. A value of -1 in this table
11346 -- indicates that the reference is significant. A value of zero indicates
11347 -- than appearence as any argument is insignificant, a positive value
11348 -- indicates that appearence in that parameter position is significant.
11350 Sig_Flags : constant array (Pragma_Id) of Int :=
11352 (Pragma_AST_Entry => -1,
11353 Pragma_Abort_Defer => -1,
11354 Pragma_Ada_83 => -1,
11355 Pragma_Ada_95 => -1,
11356 Pragma_Ada_05 => -1,
11357 Pragma_Ada_2005 => -1,
11358 Pragma_All_Calls_Remote => -1,
11359 Pragma_Annotate => -1,
11360 Pragma_Assert => -1,
11361 Pragma_Assertion_Policy => 0,
11362 Pragma_Asynchronous => -1,
11363 Pragma_Atomic => 0,
11364 Pragma_Atomic_Components => 0,
11365 Pragma_Attach_Handler => -1,
11366 Pragma_Check_Name => 0,
11367 Pragma_CIL_Constructor => -1,
11368 Pragma_CPP_Class => 0,
11369 Pragma_CPP_Constructor => 0,
11370 Pragma_CPP_Virtual => 0,
11371 Pragma_CPP_Vtable => 0,
11372 Pragma_C_Pass_By_Copy => 0,
11373 Pragma_Comment => 0,
11374 Pragma_Common_Object => -1,
11375 Pragma_Compile_Time_Error => -1,
11376 Pragma_Compile_Time_Warning => -1,
11377 Pragma_Compiler_Unit => 0,
11378 Pragma_Complete_Representation => 0,
11379 Pragma_Complex_Representation => 0,
11380 Pragma_Component_Alignment => -1,
11381 Pragma_Controlled => 0,
11382 Pragma_Convention => 0,
11383 Pragma_Convention_Identifier => 0,
11384 Pragma_Debug => -1,
11385 Pragma_Debug_Policy => 0,
11386 Pragma_Detect_Blocking => -1,
11387 Pragma_Discard_Names => 0,
11388 Pragma_Elaborate => -1,
11389 Pragma_Elaborate_All => -1,
11390 Pragma_Elaborate_Body => -1,
11391 Pragma_Elaboration_Checks => -1,
11392 Pragma_Eliminate => -1,
11393 Pragma_Export => -1,
11394 Pragma_Export_Exception => -1,
11395 Pragma_Export_Function => -1,
11396 Pragma_Export_Object => -1,
11397 Pragma_Export_Procedure => -1,
11398 Pragma_Export_Value => -1,
11399 Pragma_Export_Valued_Procedure => -1,
11400 Pragma_Extend_System => -1,
11401 Pragma_Extensions_Allowed => -1,
11402 Pragma_External => -1,
11403 Pragma_Favor_Top_Level => -1,
11404 Pragma_External_Name_Casing => -1,
11405 Pragma_Fast_Math => -1,
11406 Pragma_Finalize_Storage_Only => 0,
11407 Pragma_Float_Representation => 0,
11408 Pragma_Ident => -1,
11409 Pragma_Implemented_By_Entry => -1,
11410 Pragma_Implicit_Packing => 0,
11411 Pragma_Import => +2,
11412 Pragma_Import_Exception => 0,
11413 Pragma_Import_Function => 0,
11414 Pragma_Import_Object => 0,
11415 Pragma_Import_Procedure => 0,
11416 Pragma_Import_Valued_Procedure => 0,
11417 Pragma_Initialize_Scalars => -1,
11418 Pragma_Inline => 0,
11419 Pragma_Inline_Always => 0,
11420 Pragma_Inline_Generic => 0,
11421 Pragma_Inspection_Point => -1,
11422 Pragma_Interface => +2,
11423 Pragma_Interface_Name => +2,
11424 Pragma_Interrupt_Handler => -1,
11425 Pragma_Interrupt_Priority => -1,
11426 Pragma_Interrupt_State => -1,
11427 Pragma_Java_Constructor => -1,
11428 Pragma_Java_Interface => -1,
11429 Pragma_Keep_Names => 0,
11430 Pragma_License => -1,
11431 Pragma_Link_With => -1,
11432 Pragma_Linker_Alias => -1,
11433 Pragma_Linker_Constructor => -1,
11434 Pragma_Linker_Destructor => -1,
11435 Pragma_Linker_Options => -1,
11436 Pragma_Linker_Section => -1,
11438 Pragma_Locking_Policy => -1,
11439 Pragma_Long_Float => -1,
11440 Pragma_Machine_Attribute => -1,
11442 Pragma_Main_Storage => -1,
11443 Pragma_Memory_Size => -1,
11444 Pragma_No_Return => 0,
11445 Pragma_No_Body => 0,
11446 Pragma_No_Run_Time => -1,
11447 Pragma_No_Strict_Aliasing => -1,
11448 Pragma_Normalize_Scalars => -1,
11449 Pragma_Obsolescent => 0,
11450 Pragma_Optimize => -1,
11453 Pragma_Passive => -1,
11454 Pragma_Preelaborable_Initialization => -1,
11455 Pragma_Polling => -1,
11456 Pragma_Persistent_BSS => 0,
11457 Pragma_Preelaborate => -1,
11458 Pragma_Preelaborate_05 => -1,
11459 Pragma_Priority => -1,
11460 Pragma_Priority_Specific_Dispatching => -1,
11461 Pragma_Profile => 0,
11462 Pragma_Profile_Warnings => 0,
11463 Pragma_Propagate_Exceptions => -1,
11464 Pragma_Psect_Object => -1,
11466 Pragma_Pure_05 => -1,
11467 Pragma_Pure_Function => -1,
11468 Pragma_Queuing_Policy => -1,
11469 Pragma_Ravenscar => -1,
11470 Pragma_Remote_Call_Interface => -1,
11471 Pragma_Remote_Types => -1,
11472 Pragma_Restricted_Run_Time => -1,
11473 Pragma_Restriction_Warnings => -1,
11474 Pragma_Restrictions => -1,
11475 Pragma_Reviewable => -1,
11476 Pragma_Share_Generic => -1,
11477 Pragma_Shared => -1,
11478 Pragma_Shared_Passive => -1,
11479 Pragma_Source_File_Name => -1,
11480 Pragma_Source_File_Name_Project => -1,
11481 Pragma_Source_Reference => -1,
11482 Pragma_Storage_Size => -1,
11483 Pragma_Storage_Unit => -1,
11484 Pragma_Static_Elaboration_Desired => -1,
11485 Pragma_Stream_Convert => -1,
11486 Pragma_Style_Checks => -1,
11487 Pragma_Subtitle => -1,
11488 Pragma_Suppress => 0,
11489 Pragma_Suppress_Exception_Locations => 0,
11490 Pragma_Suppress_All => -1,
11491 Pragma_Suppress_Debug_Info => 0,
11492 Pragma_Suppress_Initialization => 0,
11493 Pragma_System_Name => -1,
11494 Pragma_Task_Dispatching_Policy => -1,
11495 Pragma_Task_Info => -1,
11496 Pragma_Task_Name => -1,
11497 Pragma_Task_Storage => 0,
11498 Pragma_Time_Slice => -1,
11499 Pragma_Title => -1,
11500 Pragma_Unchecked_Union => 0,
11501 Pragma_Unimplemented_Unit => -1,
11502 Pragma_Universal_Aliasing => -1,
11503 Pragma_Universal_Data => -1,
11504 Pragma_Unreferenced => -1,
11505 Pragma_Unreferenced_Objects => -1,
11506 Pragma_Unreserve_All_Interrupts => -1,
11507 Pragma_Unsuppress => 0,
11508 Pragma_Use_VADS_Size => -1,
11509 Pragma_Validity_Checks => -1,
11510 Pragma_Volatile => 0,
11511 Pragma_Volatile_Components => 0,
11512 Pragma_Warnings => -1,
11513 Pragma_Weak_External => -1,
11514 Pragma_Wide_Character_Encoding => 0,
11515 Unknown_Pragma => 0);
11517 function Is_Non_Significant_Pragma_Reference (N : Node_Id) return Boolean is
11525 if Nkind (P) /= N_Pragma_Argument_Association then
11529 C := Sig_Flags (Get_Pragma_Id (Chars (Parent (P))));
11539 A := First (Pragma_Argument_Associations (Parent (P)));
11540 for J in 1 .. C - 1 loop
11551 end Is_Non_Significant_Pragma_Reference;
11553 ------------------------------
11554 -- Is_Pragma_String_Literal --
11555 ------------------------------
11557 -- This function returns true if the corresponding pragma argument is
11558 -- a static string expression. These are the only cases in which string
11559 -- literals can appear as pragma arguments. We also allow a string
11560 -- literal as the first argument to pragma Assert (although it will
11561 -- of course always generate a type error).
11563 function Is_Pragma_String_Literal (Par : Node_Id) return Boolean is
11564 Pragn : constant Node_Id := Parent (Par);
11565 Assoc : constant List_Id := Pragma_Argument_Associations (Pragn);
11566 Pname : constant Name_Id := Chars (Pragn);
11572 N := First (Assoc);
11579 if Pname = Name_Assert then
11582 elsif Pname = Name_Export then
11585 elsif Pname = Name_Ident then
11588 elsif Pname = Name_Import then
11591 elsif Pname = Name_Interface_Name then
11594 elsif Pname = Name_Linker_Alias then
11597 elsif Pname = Name_Linker_Section then
11600 elsif Pname = Name_Machine_Attribute then
11603 elsif Pname = Name_Source_File_Name then
11606 elsif Pname = Name_Source_Reference then
11609 elsif Pname = Name_Title then
11612 elsif Pname = Name_Subtitle then
11618 end Is_Pragma_String_Literal;
11620 --------------------------------------
11621 -- Process_Compilation_Unit_Pragmas --
11622 --------------------------------------
11624 procedure Process_Compilation_Unit_Pragmas (N : Node_Id) is
11626 -- A special check for pragma Suppress_All. This is a strange DEC
11627 -- pragma, strange because it comes at the end of the unit. If we
11628 -- have a pragma Suppress_All in the Pragmas_After of the current
11629 -- unit, then we insert a pragma Suppress (All_Checks) at the start
11630 -- of the context clause to ensure the correct processing.
11633 PA : constant List_Id := Pragmas_After (Aux_Decls_Node (N));
11637 if Present (PA) then
11639 while Present (P) loop
11640 if Chars (P) = Name_Suppress_All then
11641 Prepend_To (Context_Items (N),
11642 Make_Pragma (Sloc (P),
11643 Chars => Name_Suppress,
11644 Pragma_Argument_Associations => New_List (
11645 Make_Pragma_Argument_Association (Sloc (P),
11647 Make_Identifier (Sloc (P),
11648 Chars => Name_All_Checks)))));
11656 end Process_Compilation_Unit_Pragmas;
11667 --------------------------------
11668 -- Set_Encoded_Interface_Name --
11669 --------------------------------
11671 procedure Set_Encoded_Interface_Name (E : Entity_Id; S : Node_Id) is
11672 Str : constant String_Id := Strval (S);
11673 Len : constant Int := String_Length (Str);
11678 Hex : constant array (0 .. 15) of Character := "0123456789abcdef";
11681 -- Stores encoded value of character code CC. The encoding we
11682 -- use an underscore followed by four lower case hex digits.
11688 procedure Encode is
11690 Store_String_Char (Get_Char_Code ('_'));
11692 (Get_Char_Code (Hex (Integer (CC / 2 ** 12))));
11694 (Get_Char_Code (Hex (Integer (CC / 2 ** 8 and 16#0F#))));
11696 (Get_Char_Code (Hex (Integer (CC / 2 ** 4 and 16#0F#))));
11698 (Get_Char_Code (Hex (Integer (CC and 16#0F#))));
11701 -- Start of processing for Set_Encoded_Interface_Name
11704 -- If first character is asterisk, this is a link name, and we
11705 -- leave it completely unmodified. We also ignore null strings
11706 -- (the latter case happens only in error cases) and no encoding
11707 -- should occur for Java or AAMP interface names.
11710 or else Get_String_Char (Str, 1) = Get_Char_Code ('*')
11711 or else VM_Target /= No_VM
11712 or else AAMP_On_Target
11714 Set_Interface_Name (E, S);
11719 CC := Get_String_Char (Str, J);
11721 exit when not In_Character_Range (CC);
11723 C := Get_Character (CC);
11725 exit when C /= '_' and then C /= '$'
11726 and then C not in '0' .. '9'
11727 and then C not in 'a' .. 'z'
11728 and then C not in 'A' .. 'Z';
11731 Set_Interface_Name (E, S);
11739 -- Here we need to encode. The encoding we use as follows:
11740 -- three underscores + four hex digits (lower case)
11744 for J in 1 .. String_Length (Str) loop
11745 CC := Get_String_Char (Str, J);
11747 if not In_Character_Range (CC) then
11750 C := Get_Character (CC);
11752 if C = '_' or else C = '$'
11753 or else C in '0' .. '9'
11754 or else C in 'a' .. 'z'
11755 or else C in 'A' .. 'Z'
11757 Store_String_Char (CC);
11764 Set_Interface_Name (E,
11765 Make_String_Literal (Sloc (S),
11766 Strval => End_String));
11768 end Set_Encoded_Interface_Name;
11770 -------------------
11771 -- Set_Unit_Name --
11772 -------------------
11774 procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id) is
11779 if Nkind (N) = N_Identifier
11780 and then Nkind (With_Item) = N_Identifier
11782 Set_Entity (N, Entity (With_Item));
11784 elsif Nkind (N) = N_Selected_Component then
11785 Change_Selected_Component_To_Expanded_Name (N);
11786 Set_Entity (N, Entity (With_Item));
11787 Set_Entity (Selector_Name (N), Entity (N));
11789 Pref := Prefix (N);
11790 Scop := Scope (Entity (N));
11791 while Nkind (Pref) = N_Selected_Component loop
11792 Change_Selected_Component_To_Expanded_Name (Pref);
11793 Set_Entity (Selector_Name (Pref), Scop);
11794 Set_Entity (Pref, Scop);
11795 Pref := Prefix (Pref);
11796 Scop := Scope (Scop);
11799 Set_Entity (Pref, Scop);