1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2013, 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 Aspects; use Aspects;
33 with Atree; use Atree;
34 with Casing; use Casing;
35 with Checks; use Checks;
36 with Csets; use Csets;
37 with Debug; use Debug;
38 with Einfo; use Einfo;
39 with Elists; use Elists;
40 with Errout; use Errout;
41 with Exp_Dist; use Exp_Dist;
42 with Exp_Util; use Exp_Util;
43 with Freeze; use Freeze;
45 with Lib.Writ; use Lib.Writ;
46 with Lib.Xref; use Lib.Xref;
47 with Namet.Sp; use Namet.Sp;
48 with Nlists; use Nlists;
49 with Nmake; use Nmake;
51 with Output; use Output;
52 with Par_SCO; use Par_SCO;
53 with Restrict; use Restrict;
54 with Rident; use Rident;
55 with Rtsfind; use Rtsfind;
57 with Sem_Aux; use Sem_Aux;
58 with Sem_Ch3; use Sem_Ch3;
59 with Sem_Ch6; use Sem_Ch6;
60 with Sem_Ch8; use Sem_Ch8;
61 with Sem_Ch12; use Sem_Ch12;
62 with Sem_Ch13; use Sem_Ch13;
63 with Sem_Disp; use Sem_Disp;
64 with Sem_Dist; use Sem_Dist;
65 with Sem_Elim; use Sem_Elim;
66 with Sem_Eval; use Sem_Eval;
67 with Sem_Intr; use Sem_Intr;
68 with Sem_Mech; use Sem_Mech;
69 with Sem_Res; use Sem_Res;
70 with Sem_Type; use Sem_Type;
71 with Sem_Util; use Sem_Util;
72 with Sem_VFpt; use Sem_VFpt;
73 with Sem_Warn; use Sem_Warn;
74 with Stand; use Stand;
75 with Sinfo; use Sinfo;
76 with Sinfo.CN; use Sinfo.CN;
77 with Sinput; use Sinput;
78 with Snames; use Snames;
79 with Stringt; use Stringt;
80 with Stylesw; use Stylesw;
82 with Targparm; use Targparm;
83 with Tbuild; use Tbuild;
85 with Uintp; use Uintp;
86 with Uname; use Uname;
87 with Urealp; use Urealp;
88 with Validsw; use Validsw;
89 with Warnsw; use Warnsw;
91 package body Sem_Prag is
93 ----------------------------------------------
94 -- Common Handling of Import-Export Pragmas --
95 ----------------------------------------------
97 -- In the following section, a number of Import_xxx and Export_xxx pragmas
98 -- are defined by GNAT. These are compatible with the DEC pragmas of the
99 -- same name, and all have the following common form and processing:
102 -- [Internal =>] LOCAL_NAME
103 -- [, [External =>] EXTERNAL_SYMBOL]
104 -- [, other optional parameters ]);
107 -- [Internal =>] LOCAL_NAME
108 -- [, [External =>] EXTERNAL_SYMBOL]
109 -- [, other optional parameters ]);
111 -- EXTERNAL_SYMBOL ::=
113 -- | static_string_EXPRESSION
115 -- The internal LOCAL_NAME designates the entity that is imported or
116 -- exported, and must refer to an entity in the current declarative
117 -- part (as required by the rules for LOCAL_NAME).
119 -- The external linker name is designated by the External parameter if
120 -- given, or the Internal parameter if not (if there is no External
121 -- parameter, the External parameter is a copy of the Internal name).
123 -- If the External parameter is given as a string, then this string is
124 -- treated as an external name (exactly as though it had been given as an
125 -- External_Name parameter for a normal Import pragma).
127 -- If the External parameter is given as an identifier (or there is no
128 -- External parameter, so that the Internal identifier is used), then
129 -- the external name is the characters of the identifier, translated
130 -- to all upper case letters for OpenVMS versions of GNAT, and to all
131 -- lower case letters for all other versions
133 -- Note: the external name specified or implied by any of these special
134 -- Import_xxx or Export_xxx pragmas override an external or link name
135 -- specified in a previous Import or Export pragma.
137 -- Note: these and all other DEC-compatible GNAT pragmas allow full use of
138 -- named notation, following the standard rules for subprogram calls, i.e.
139 -- parameters can be given in any order if named notation is used, and
140 -- positional and named notation can be mixed, subject to the rule that all
141 -- positional parameters must appear first.
143 -- Note: All these pragmas are implemented exactly following the DEC design
144 -- and implementation and are intended to be fully compatible with the use
145 -- of these pragmas in the DEC Ada compiler.
147 --------------------------------------------
148 -- Checking for Duplicated External Names --
149 --------------------------------------------
151 -- It is suspicious if two separate Export pragmas use the same external
152 -- name. The following table is used to diagnose this situation so that
153 -- an appropriate warning can be issued.
155 -- The Node_Id stored is for the N_String_Literal node created to hold
156 -- the value of the external name. The Sloc of this node is used to
157 -- cross-reference the location of the duplication.
159 package Externals is new Table.Table (
160 Table_Component_Type => Node_Id,
161 Table_Index_Type => Int,
162 Table_Low_Bound => 0,
163 Table_Initial => 100,
164 Table_Increment => 100,
165 Table_Name => "Name_Externals");
167 -------------------------------------
168 -- Local Subprograms and Variables --
169 -------------------------------------
171 function Adjust_External_Name_Case (N : Node_Id) return Node_Id;
172 -- This routine is used for possible casing adjustment of an explicit
173 -- external name supplied as a string literal (the node N), according to
174 -- the casing requirement of Opt.External_Name_Casing. If this is set to
175 -- As_Is, then the string literal is returned unchanged, but if it is set
176 -- to Uppercase or Lowercase, then a new string literal with appropriate
177 -- casing is constructed.
179 function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id;
180 -- If Def_Id refers to a renamed subprogram, then the base subprogram (the
181 -- original one, following the renaming chain) is returned. Otherwise the
182 -- entity is returned unchanged. Should be in Einfo???
184 procedure Preanalyze_CTC_Args (N, Arg_Req, Arg_Ens : Node_Id);
185 -- Preanalyze the boolean expressions in the Requires and Ensures arguments
186 -- of a Contract_Case or Test_Case pragma if present (possibly Empty). We
187 -- treat these as spec expressions (i.e. similar to a default expression).
190 -- This is a dummy function called by the processing for pragma Reviewable.
191 -- It is there for assisting front end debugging. By placing a Reviewable
192 -- pragma in the source program, a breakpoint on rv catches this place in
193 -- the source, allowing convenient stepping to the point of interest.
195 procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id);
196 -- Place semantic information on the argument of an Elaborate/Elaborate_All
197 -- pragma. Entity name for unit and its parents is taken from item in
198 -- previous with_clause that mentions the unit.
200 -------------------------------
201 -- Adjust_External_Name_Case --
202 -------------------------------
204 function Adjust_External_Name_Case (N : Node_Id) return Node_Id is
208 -- Adjust case of literal if required
210 if Opt.External_Name_Exp_Casing = As_Is then
214 -- Copy existing string
220 for J in 1 .. String_Length (Strval (N)) loop
221 CC := Get_String_Char (Strval (N), J);
223 if Opt.External_Name_Exp_Casing = Uppercase
224 and then CC >= Get_Char_Code ('a')
225 and then CC <= Get_Char_Code ('z')
227 Store_String_Char (CC - 32);
229 elsif Opt.External_Name_Exp_Casing = Lowercase
230 and then CC >= Get_Char_Code ('A')
231 and then CC <= Get_Char_Code ('Z')
233 Store_String_Char (CC + 32);
236 Store_String_Char (CC);
241 Make_String_Literal (Sloc (N),
242 Strval => End_String);
244 end Adjust_External_Name_Case;
246 ------------------------------
247 -- Analyze_CTC_In_Decl_Part --
248 ------------------------------
250 procedure Analyze_CTC_In_Decl_Part (N : Node_Id; S : Entity_Id) is
252 procedure Analyze_Contract_Cases (Aggr : Node_Id);
253 -- Pre-analyze the guard and consequence expressions of a Contract_Cases
254 -- pragma/aspect aggregate expression.
256 ----------------------------
257 -- Analyze_Contract_Cases --
258 ----------------------------
260 procedure Analyze_Contract_Cases (Aggr : Node_Id) is
261 Case_Guard : Node_Id;
266 Post_Case := First (Component_Associations (Aggr));
267 while Present (Post_Case) loop
268 Case_Guard := First (Choices (Post_Case));
269 Conseq := Expression (Post_Case);
271 -- Preanalyze the boolean expression, we treat this as a spec
272 -- expression (i.e. similar to a default expression).
274 if Nkind (Case_Guard) /= N_Others_Choice then
275 Preanalyze_Assert_Expression (Case_Guard, Standard_Boolean);
278 Preanalyze_Assert_Expression (Conseq, Standard_Boolean);
282 end Analyze_Contract_Cases;
284 -- Start of processing for Analyze_CTC_In_Decl_Part
287 -- Install formals and push subprogram spec onto scope stack so that we
288 -- can see the formals from the pragma.
293 -- Preanalyze the boolean expressions, we treat these as spec
294 -- expressions (i.e. similar to a default expression).
296 if Pragma_Name (N) = Name_Test_Case
297 or else Pragma_Name (N) = Name_Contract_Case
301 Get_Requires_From_CTC_Pragma (N),
302 Get_Ensures_From_CTC_Pragma (N));
304 elsif Pragma_Name (N) = Name_Contract_Cases then
305 Analyze_Contract_Cases
306 (Expression (First (Pragma_Argument_Associations (N))));
308 -- In ASIS mode, for a pragma generated from a source aspect, also
309 -- analyze the original aspect expression.
312 and then Present (Corresponding_Aspect (N))
314 Analyze_Contract_Cases (Expression (Corresponding_Aspect (N)));
318 -- Remove the subprogram from the scope stack now that the pre-analysis
319 -- of the expressions in the contract case or test case is done.
322 end Analyze_CTC_In_Decl_Part;
324 ------------------------------
325 -- Analyze_PPC_In_Decl_Part --
326 ------------------------------
328 procedure Analyze_PPC_In_Decl_Part (N : Node_Id; S : Entity_Id) is
329 Arg1 : constant Node_Id := First (Pragma_Argument_Associations (N));
332 -- Install formals and push subprogram spec onto scope stack so that we
333 -- can see the formals from the pragma.
338 -- Preanalyze the boolean expression, we treat this as a spec expression
339 -- (i.e. similar to a default expression).
341 Preanalyze_Assert_Expression (Get_Pragma_Arg (Arg1), Standard_Boolean);
343 -- In ASIS mode, for a pragma generated from a source aspect, also
344 -- analyze the original aspect expression.
347 and then Present (Corresponding_Aspect (N))
349 Preanalyze_Assert_Expression
350 (Expression (Corresponding_Aspect (N)), Standard_Boolean);
353 -- For a class-wide condition, a reference to a controlling formal must
354 -- be interpreted as having the class-wide type (or an access to such)
355 -- so that the inherited condition can be properly applied to any
356 -- overriding operation (see ARM12 6.6.1 (7)).
358 if Class_Present (N) then
359 Class_Wide_Condition : declare
360 T : constant Entity_Id := Find_Dispatching_Type (S);
362 ACW : Entity_Id := Empty;
363 -- Access to T'class, created if there is a controlling formal
364 -- that is an access parameter.
366 function Get_ACW return Entity_Id;
367 -- If the expression has a reference to an controlling access
368 -- parameter, create an access to T'class for the necessary
369 -- conversions if one does not exist.
371 function Process (N : Node_Id) return Traverse_Result;
372 -- ARM 6.1.1: Within the expression for a Pre'Class or Post'Class
373 -- aspect for a primitive subprogram of a tagged type T, a name
374 -- that denotes a formal parameter of type T is interpreted as
375 -- having type T'Class. Similarly, a name that denotes a formal
376 -- accessparameter of type access-to-T is interpreted as having
377 -- type access-to-T'Class. This ensures the expression is well-
378 -- defined for a primitive subprogram of a type descended from T.
384 function Get_ACW return Entity_Id is
385 Loc : constant Source_Ptr := Sloc (N);
390 Decl := Make_Full_Type_Declaration (Loc,
391 Defining_Identifier => Make_Temporary (Loc, 'T'),
393 Make_Access_To_Object_Definition (Loc,
394 Subtype_Indication =>
395 New_Occurrence_Of (Class_Wide_Type (T), Loc),
396 All_Present => True));
398 Insert_Before (Unit_Declaration_Node (S), Decl);
400 ACW := Defining_Identifier (Decl);
401 Freeze_Before (Unit_Declaration_Node (S), ACW);
411 function Process (N : Node_Id) return Traverse_Result is
412 Loc : constant Source_Ptr := Sloc (N);
416 if Is_Entity_Name (N)
417 and then Is_Formal (Entity (N))
418 and then Nkind (Parent (N)) /= N_Type_Conversion
420 if Etype (Entity (N)) = T then
421 Typ := Class_Wide_Type (T);
423 elsif Is_Access_Type (Etype (Entity (N)))
424 and then Designated_Type (Etype (Entity (N))) = T
431 if Present (Typ) then
433 Make_Type_Conversion (Loc,
435 New_Occurrence_Of (Typ, Loc),
436 Expression => New_Occurrence_Of (Entity (N), Loc)));
444 procedure Replace_Type is new Traverse_Proc (Process);
446 -- Start of processing for Class_Wide_Condition
449 if not Present (T) then
451 Chars (Identifier (Corresponding_Aspect (N)));
453 Error_Msg_Name_2 := Name_Class;
456 ("aspect `%''%` can only be specified for a primitive "
457 & "operation of a tagged type", Corresponding_Aspect (N));
460 Replace_Type (Get_Pragma_Arg (Arg1));
461 end Class_Wide_Condition;
464 -- Remove the subprogram from the scope stack now that the pre-analysis
465 -- of the precondition/postcondition is done.
468 end Analyze_PPC_In_Decl_Part;
474 procedure Analyze_Pragma (N : Node_Id) is
475 Loc : constant Source_Ptr := Sloc (N);
479 -- Name of the source pragma, or name of the corresponding aspect for
480 -- pragmas which originate in a source aspect. In the latter case, the
481 -- name may be different from the pragma name.
483 Pragma_Exit : exception;
484 -- This exception is used to exit pragma processing completely. It is
485 -- used when an error is detected, and no further processing is
486 -- required. It is also used if an earlier error has left the tree in
487 -- a state where the pragma should not be processed.
490 -- Number of pragma argument associations
496 -- First four pragma arguments (pragma argument association nodes, or
497 -- Empty if the corresponding argument does not exist).
499 type Name_List is array (Natural range <>) of Name_Id;
500 type Args_List is array (Natural range <>) of Node_Id;
501 -- Types used for arguments to Check_Arg_Order and Gather_Associations
503 procedure Ada_2005_Pragma;
504 -- Called for pragmas defined in Ada 2005, that are not in Ada 95. In
505 -- Ada 95 mode, these are implementation defined pragmas, so should be
506 -- caught by the No_Implementation_Pragmas restriction.
508 procedure Ada_2012_Pragma;
509 -- Called for pragmas defined in Ada 2012, that are not in Ada 95 or 05.
510 -- In Ada 95 or 05 mode, these are implementation defined pragmas, so
511 -- should be caught by the No_Implementation_Pragmas restriction.
513 procedure Add_Item (Item : Entity_Id; To_List : in out Elist_Id);
514 -- Subsidiary routine to the analysis of pragmas Depends and Global.
515 -- Append an input or output item to a list. If the list is empty, a
516 -- new one is created.
518 procedure Check_Ada_83_Warning;
519 -- Issues a warning message for the current pragma if operating in Ada
520 -- 83 mode (used for language pragmas that are not a standard part of
521 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
524 procedure Check_Arg_Count (Required : Nat);
525 -- Check argument count for pragma is equal to given parameter. If not,
526 -- then issue an error message and raise Pragma_Exit.
528 -- Note: all routines whose name is Check_Arg_Is_xxx take an argument
529 -- Arg which can either be a pragma argument association, in which case
530 -- the check is applied to the expression of the association or an
531 -- expression directly.
533 procedure Check_Arg_Is_External_Name (Arg : Node_Id);
534 -- Check that an argument has the right form for an EXTERNAL_NAME
535 -- parameter of an extended import/export pragma. The rule is that the
536 -- name must be an identifier or string literal (in Ada 83 mode) or a
537 -- static string expression (in Ada 95 mode).
539 procedure Check_Arg_Is_Identifier (Arg : Node_Id);
540 -- Check the specified argument Arg to make sure that it is an
541 -- identifier. If not give error and raise Pragma_Exit.
543 procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id);
544 -- Check the specified argument Arg to make sure that it is an integer
545 -- literal. If not give error and raise Pragma_Exit.
547 procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id);
548 -- Check the specified argument Arg to make sure that it has the proper
549 -- syntactic form for a local name and meets the semantic requirements
550 -- for a local name. The local name is analyzed as part of the
551 -- processing for this call. In addition, the local name is required
552 -- to represent an entity at the library level.
554 procedure Check_Arg_Is_Local_Name (Arg : Node_Id);
555 -- Check the specified argument Arg to make sure that it has the proper
556 -- syntactic form for a local name and meets the semantic requirements
557 -- for a local name. The local name is analyzed as part of the
558 -- processing for this call.
560 procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id);
561 -- Check the specified argument Arg to make sure that it is a valid
562 -- locking policy name. If not give error and raise Pragma_Exit.
564 procedure Check_Arg_Is_Partition_Elaboration_Policy (Arg : Node_Id);
565 -- Check the specified argument Arg to make sure that it is a valid
566 -- elaboration policy name. If not give error and raise Pragma_Exit.
568 procedure Check_Arg_Is_One_Of
571 procedure Check_Arg_Is_One_Of
573 N1, N2, N3 : Name_Id);
574 procedure Check_Arg_Is_One_Of
576 N1, N2, N3, N4 : Name_Id);
577 procedure Check_Arg_Is_One_Of
579 N1, N2, N3, N4, N5 : Name_Id);
580 -- Check the specified argument Arg to make sure that it is an
581 -- identifier whose name matches either N1 or N2 (or N3, N4, N5 if
582 -- present). If not then give error and raise Pragma_Exit.
584 procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id);
585 -- Check the specified argument Arg to make sure that it is a valid
586 -- queuing policy name. If not give error and raise Pragma_Exit.
588 procedure Check_Arg_Is_Static_Expression
590 Typ : Entity_Id := Empty);
591 -- Check the specified argument Arg to make sure that it is a static
592 -- expression of the given type (i.e. it will be analyzed and resolved
593 -- using this type, which can be any valid argument to Resolve, e.g.
594 -- Any_Integer is OK). If not, given error and raise Pragma_Exit. If
595 -- Typ is left Empty, then any static expression is allowed.
597 procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id);
598 -- Check the specified argument Arg to make sure that it is a valid task
599 -- dispatching policy name. If not give error and raise Pragma_Exit.
601 procedure Check_Arg_Order (Names : Name_List);
602 -- Checks for an instance of two arguments with identifiers for the
603 -- current pragma which are not in the sequence indicated by Names,
604 -- and if so, generates a fatal message about bad order of arguments.
606 procedure Check_At_Least_N_Arguments (N : Nat);
607 -- Check there are at least N arguments present
609 procedure Check_At_Most_N_Arguments (N : Nat);
610 -- Check there are no more than N arguments present
612 procedure Check_Component
615 In_Variant_Part : Boolean := False);
616 -- Examine an Unchecked_Union component for correct use of per-object
617 -- constrained subtypes, and for restrictions on finalizable components.
618 -- UU_Typ is the related Unchecked_Union type. Flag In_Variant_Part
619 -- should be set when Comp comes from a record variant.
621 procedure Check_Contract_Or_Test_Case;
622 -- Called to process a contract-case or test-case pragma. It
623 -- starts with checking pragma arguments, and the rest of the
624 -- treatment is similar to the one for pre- and postcondition in
625 -- Check_Precondition_Postcondition, except the placement rules for the
626 -- contract-case and test-case pragmas are stricter. These pragmas may
627 -- only occur after a subprogram spec declared directly in a package
628 -- spec unit. In this case, the pragma is chained to the subprogram in
629 -- question (using Spec_CTC_List and Next_Pragma) and analysis of the
630 -- pragma is delayed till the end of the spec. In all other cases, an
631 -- error message for bad placement is given.
633 procedure Check_Duplicate_Pragma (E : Entity_Id);
634 -- Check if a rep item of the same name as the current pragma is already
635 -- chained as a rep pragma to the given entity. If so give a message
636 -- about the duplicate, and then raise Pragma_Exit so does not return.
638 procedure Check_Duplicated_Export_Name (Nam : Node_Id);
639 -- Nam is an N_String_Literal node containing the external name set by
640 -- an Import or Export pragma (or extended Import or Export pragma).
641 -- This procedure checks for possible duplications if this is the export
642 -- case, and if found, issues an appropriate error message.
644 procedure Check_Expr_Is_Static_Expression
646 Typ : Entity_Id := Empty);
647 -- Check the specified expression Expr to make sure that it is a static
648 -- expression of the given type (i.e. it will be analyzed and resolved
649 -- using this type, which can be any valid argument to Resolve, e.g.
650 -- Any_Integer is OK). If not, given error and raise Pragma_Exit. If
651 -- Typ is left Empty, then any static expression is allowed.
653 procedure Check_First_Subtype (Arg : Node_Id);
654 -- Checks that Arg, whose expression is an entity name, references a
657 procedure Check_Identifier (Arg : Node_Id; Id : Name_Id);
658 -- Checks that the given argument has an identifier, and if so, requires
659 -- it to match the given identifier name. If there is no identifier, or
660 -- a non-matching identifier, then an error message is given and
661 -- Pragma_Exit is raised.
663 procedure Check_Identifier_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id);
664 -- Checks that the given argument has an identifier, and if so, requires
665 -- it to match one of the given identifier names. If there is no
666 -- identifier, or a non-matching identifier, then an error message is
667 -- given and Pragma_Exit is raised.
669 procedure Check_In_Main_Program;
670 -- Common checks for pragmas that appear within a main program
671 -- (Priority, Main_Storage, Time_Slice, Relative_Deadline, CPU).
673 procedure Check_Interrupt_Or_Attach_Handler;
674 -- Common processing for first argument of pragma Interrupt_Handler or
675 -- pragma Attach_Handler.
677 procedure Check_Loop_Pragma_Placement;
678 -- Verify whether pragma Loop_Invariant or Loop_Optimize or Loop_Variant
679 -- appear immediately within a construct restricted to loops.
681 procedure Check_Is_In_Decl_Part_Or_Package_Spec;
682 -- Check that pragma appears in a declarative part, or in a package
683 -- specification, i.e. that it does not occur in a statement sequence
686 procedure Check_No_Identifier (Arg : Node_Id);
687 -- Checks that the given argument does not have an identifier. If
688 -- an identifier is present, then an error message is issued, and
689 -- Pragma_Exit is raised.
691 procedure Check_No_Identifiers;
692 -- Checks that none of the arguments to the pragma has an identifier.
693 -- If any argument has an identifier, then an error message is issued,
694 -- and Pragma_Exit is raised.
696 procedure Check_No_Link_Name;
697 -- Checks that no link name is specified
699 procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id);
700 -- Checks if the given argument has an identifier, and if so, requires
701 -- it to match the given identifier name. If there is a non-matching
702 -- identifier, then an error message is given and Pragma_Exit is raised.
704 procedure Check_Optional_Identifier (Arg : Node_Id; Id : String);
705 -- Checks if the given argument has an identifier, and if so, requires
706 -- it to match the given identifier name. If there is a non-matching
707 -- identifier, then an error message is given and Pragma_Exit is raised.
708 -- In this version of the procedure, the identifier name is given as
709 -- a string with lower case letters.
711 procedure Check_Precondition_Postcondition (In_Body : out Boolean);
712 -- Called to process a precondition or postcondition pragma. There are
715 -- The pragma appears after a subprogram spec
717 -- If the corresponding check is not enabled, the pragma is analyzed
718 -- but otherwise ignored and control returns with In_Body set False.
720 -- If the check is enabled, then the first step is to analyze the
721 -- pragma, but this is skipped if the subprogram spec appears within
722 -- a package specification (because this is the case where we delay
723 -- analysis till the end of the spec). Then (whether or not it was
724 -- analyzed), the pragma is chained to the subprogram in question
725 -- (using Spec_PPC_List and Next_Pragma) and control returns to the
726 -- caller with In_Body set False.
728 -- The pragma appears at the start of subprogram body declarations
730 -- In this case an immediate return to the caller is made with
731 -- In_Body set True, and the pragma is NOT analyzed.
733 -- In all other cases, an error message for bad placement is given
735 procedure Check_Static_Constraint (Constr : Node_Id);
736 -- Constr is a constraint from an N_Subtype_Indication node from a
737 -- component constraint in an Unchecked_Union type. This routine checks
738 -- that the constraint is static as required by the restrictions for
741 procedure Check_Valid_Configuration_Pragma;
742 -- Legality checks for placement of a configuration pragma
744 procedure Check_Valid_Library_Unit_Pragma;
745 -- Legality checks for library unit pragmas. A special case arises for
746 -- pragmas in generic instances that come from copies of the original
747 -- library unit pragmas in the generic templates. In the case of other
748 -- than library level instantiations these can appear in contexts which
749 -- would normally be invalid (they only apply to the original template
750 -- and to library level instantiations), and they are simply ignored,
751 -- which is implemented by rewriting them as null statements.
753 procedure Check_Variant (Variant : Node_Id; UU_Typ : Entity_Id);
754 -- Check an Unchecked_Union variant for lack of nested variants and
755 -- presence of at least one component. UU_Typ is the related Unchecked_
758 procedure Error_Pragma (Msg : String);
759 pragma No_Return (Error_Pragma);
760 -- Outputs error message for current pragma. The message contains a %
761 -- that will be replaced with the pragma name, and the flag is placed
762 -- on the pragma itself. Pragma_Exit is then raised. Note: this routine
763 -- calls Fix_Error (see spec of that function for details).
765 procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id);
766 pragma No_Return (Error_Pragma_Arg);
767 -- Outputs error message for current pragma. The message may contain
768 -- a % that will be replaced with the pragma name. The parameter Arg
769 -- may either be a pragma argument association, in which case the flag
770 -- is placed on the expression of this association, or an expression,
771 -- in which case the flag is placed directly on the expression. The
772 -- message is placed using Error_Msg_N, so the message may also contain
773 -- an & insertion character which will reference the given Arg value.
774 -- After placing the message, Pragma_Exit is raised. Note: this routine
775 -- calls Fix_Error (see spec of that function for details).
777 procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id);
778 pragma No_Return (Error_Pragma_Arg);
779 -- Similar to above form of Error_Pragma_Arg except that two messages
780 -- are provided, the second is a continuation comment starting with \.
782 procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id);
783 pragma No_Return (Error_Pragma_Arg_Ident);
784 -- Outputs error message for current pragma. The message may contain
785 -- a % that will be replaced with the pragma name. The parameter Arg
786 -- must be a pragma argument association with a non-empty identifier
787 -- (i.e. its Chars field must be set), and the error message is placed
788 -- on the identifier. The message is placed using Error_Msg_N so
789 -- the message may also contain an & insertion character which will
790 -- reference the identifier. After placing the message, Pragma_Exit
791 -- is raised. Note: this routine calls Fix_Error (see spec of that
792 -- function for details).
794 procedure Error_Pragma_Ref (Msg : String; Ref : Entity_Id);
795 pragma No_Return (Error_Pragma_Ref);
796 -- Outputs error message for current pragma. The message may contain
797 -- a % that will be replaced with the pragma name. The parameter Ref
798 -- must be an entity whose name can be referenced by & and sloc by #.
799 -- After placing the message, Pragma_Exit is raised. Note: this routine
800 -- calls Fix_Error (see spec of that function for details).
802 function Find_Lib_Unit_Name return Entity_Id;
803 -- Used for a library unit pragma to find the entity to which the
804 -- library unit pragma applies, returns the entity found.
806 procedure Find_Program_Unit_Name (Id : Node_Id);
807 -- If the pragma is a compilation unit pragma, the id must denote the
808 -- compilation unit in the same compilation, and the pragma must appear
809 -- in the list of preceding or trailing pragmas. If it is a program
810 -- unit pragma that is not a compilation unit pragma, then the
811 -- identifier must be visible.
813 function Find_Unique_Parameterless_Procedure
815 Arg : Node_Id) return Entity_Id;
816 -- Used for a procedure pragma to find the unique parameterless
817 -- procedure identified by Name, returns it if it exists, otherwise
818 -- errors out and uses Arg as the pragma argument for the message.
820 procedure Fix_Error (Msg : in out String);
821 -- This is called prior to issuing an error message. Msg is a string
822 -- that typically contains the substring "pragma". If the current pragma
823 -- comes from an aspect, each such "pragma" substring is replaced with
824 -- the characters "aspect", and if Error_Msg_Name_1 is Name_Precondition
825 -- (resp Name_Postcondition) it is changed to Name_Pre (resp Name_Post).
827 procedure Gather_Associations
829 Args : out Args_List);
830 -- This procedure is used to gather the arguments for a pragma that
831 -- permits arbitrary ordering of parameters using the normal rules
832 -- for named and positional parameters. The Names argument is a list
833 -- of Name_Id values that corresponds to the allowed pragma argument
834 -- association identifiers in order. The result returned in Args is
835 -- a list of corresponding expressions that are the pragma arguments.
836 -- Note that this is a list of expressions, not of pragma argument
837 -- associations (Gather_Associations has completely checked all the
838 -- optional identifiers when it returns). An entry in Args is Empty
839 -- on return if the corresponding argument is not present.
841 procedure GNAT_Pragma;
842 -- Called for all GNAT defined pragmas to check the relevant restriction
843 -- (No_Implementation_Pragmas).
845 procedure S14_Pragma;
846 -- Called for all pragmas defined for formal verification to check that
847 -- the S14_Extensions flag is set.
848 -- This name needs fixing ??? There is no such thing as an
849 -- "S14_Extensions" flag ???
851 function Is_Before_First_Decl
852 (Pragma_Node : Node_Id;
853 Decls : List_Id) return Boolean;
854 -- Return True if Pragma_Node is before the first declarative item in
855 -- Decls where Decls is the list of declarative items.
857 function Is_Configuration_Pragma return Boolean;
858 -- Determines if the placement of the current pragma is appropriate
859 -- for a configuration pragma.
861 function Is_In_Context_Clause return Boolean;
862 -- Returns True if pragma appears within the context clause of a unit,
863 -- and False for any other placement (does not generate any messages).
865 function Is_Static_String_Expression (Arg : Node_Id) return Boolean;
866 -- Analyzes the argument, and determines if it is a static string
867 -- expression, returns True if so, False if non-static or not String.
869 procedure Pragma_Misplaced;
870 pragma No_Return (Pragma_Misplaced);
871 -- Issue fatal error message for misplaced pragma
873 procedure Process_Atomic_Shared_Volatile;
874 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
875 -- Shared is an obsolete Ada 83 pragma, treated as being identical
876 -- in effect to pragma Atomic.
878 procedure Process_Compile_Time_Warning_Or_Error;
879 -- Common processing for Compile_Time_Error and Compile_Time_Warning
881 procedure Process_Convention
882 (C : out Convention_Id;
883 Ent : out Entity_Id);
884 -- Common processing for Convention, Interface, Import and Export.
885 -- Checks first two arguments of pragma, and sets the appropriate
886 -- convention value in the specified entity or entities. On return
887 -- C is the convention, Ent is the referenced entity.
889 procedure Process_Disable_Enable_Atomic_Sync (Nam : Name_Id);
890 -- Common processing for Disable/Enable_Atomic_Synchronization. Nam is
891 -- Name_Suppress for Disable and Name_Unsuppress for Enable.
893 procedure Process_Extended_Import_Export_Exception_Pragma
894 (Arg_Internal : Node_Id;
895 Arg_External : Node_Id;
898 -- Common processing for the pragmas Import/Export_Exception. The three
899 -- arguments correspond to the three named parameters of the pragma. An
900 -- argument is empty if the corresponding parameter is not present in
903 procedure Process_Extended_Import_Export_Object_Pragma
904 (Arg_Internal : Node_Id;
905 Arg_External : Node_Id;
907 -- Common processing for the pragmas Import/Export_Object. The three
908 -- arguments correspond to the three named parameters of the pragmas. An
909 -- argument is empty if the corresponding parameter is not present in
912 procedure Process_Extended_Import_Export_Internal_Arg
913 (Arg_Internal : Node_Id := Empty);
914 -- Common processing for all extended Import and Export pragmas. The
915 -- argument is the pragma parameter for the Internal argument. If
916 -- Arg_Internal is empty or inappropriate, an error message is posted.
917 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
918 -- set to identify the referenced entity.
920 procedure Process_Extended_Import_Export_Subprogram_Pragma
921 (Arg_Internal : Node_Id;
922 Arg_External : Node_Id;
923 Arg_Parameter_Types : Node_Id;
924 Arg_Result_Type : Node_Id := Empty;
925 Arg_Mechanism : Node_Id;
926 Arg_Result_Mechanism : Node_Id := Empty;
927 Arg_First_Optional_Parameter : Node_Id := Empty);
928 -- Common processing for all extended Import and Export pragmas applying
929 -- to subprograms. The caller omits any arguments that do not apply to
930 -- the pragma in question (for example, Arg_Result_Type can be non-Empty
931 -- only in the Import_Function and Export_Function cases). The argument
932 -- names correspond to the allowed pragma association identifiers.
934 procedure Process_Generic_List;
935 -- Common processing for Share_Generic and Inline_Generic
937 procedure Process_Import_Or_Interface;
938 -- Common processing for Import of Interface
940 procedure Process_Import_Predefined_Type;
941 -- Processing for completing a type with pragma Import. This is used
942 -- to declare types that match predefined C types, especially for cases
943 -- without corresponding Ada predefined type.
945 type Inline_Status is (Suppressed, Disabled, Enabled);
946 -- Inline status of a subprogram, indicated as follows:
947 -- Suppressed: inlining is suppressed for the subprogram
948 -- Disabled: no inlining is requested for the subprogram
949 -- Enabled: inlining is requested/required for the subprogram
951 procedure Process_Inline (Status : Inline_Status);
952 -- Common processing for Inline, Inline_Always and No_Inline. Parameter
953 -- indicates the inline status specified by the pragma.
955 procedure Process_Interface_Name
956 (Subprogram_Def : Entity_Id;
959 -- Given the last two arguments of pragma Import, pragma Export, or
960 -- pragma Interface_Name, performs validity checks and sets the
961 -- Interface_Name field of the given subprogram entity to the
962 -- appropriate external or link name, depending on the arguments given.
963 -- Ext_Arg is always present, but Link_Arg may be missing. Note that
964 -- Ext_Arg may represent the Link_Name if Link_Arg is missing, and
965 -- appropriate named notation is used for Ext_Arg. If neither Ext_Arg
966 -- nor Link_Arg is present, the interface name is set to the default
967 -- from the subprogram name.
969 procedure Process_Interrupt_Or_Attach_Handler;
970 -- Common processing for Interrupt and Attach_Handler pragmas
972 procedure Process_Restrictions_Or_Restriction_Warnings (Warn : Boolean);
973 -- Common processing for Restrictions and Restriction_Warnings pragmas.
974 -- Warn is True for Restriction_Warnings, or for Restrictions if the
975 -- flag Treat_Restrictions_As_Warnings is set, and False if this flag
976 -- is not set in the Restrictions case.
978 procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean);
979 -- Common processing for Suppress and Unsuppress. The boolean parameter
980 -- Suppress_Case is True for the Suppress case, and False for the
983 procedure Set_Exported (E : Entity_Id; Arg : Node_Id);
984 -- This procedure sets the Is_Exported flag for the given entity,
985 -- checking that the entity was not previously imported. Arg is
986 -- the argument that specified the entity. A check is also made
987 -- for exporting inappropriate entities.
989 procedure Set_Extended_Import_Export_External_Name
990 (Internal_Ent : Entity_Id;
991 Arg_External : Node_Id);
992 -- Common processing for all extended import export pragmas. The first
993 -- argument, Internal_Ent, is the internal entity, which has already
994 -- been checked for validity by the caller. Arg_External is from the
995 -- Import or Export pragma, and may be null if no External parameter
996 -- was present. If Arg_External is present and is a non-null string
997 -- (a null string is treated as the default), then the Interface_Name
998 -- field of Internal_Ent is set appropriately.
1000 procedure Set_Imported (E : Entity_Id);
1001 -- This procedure sets the Is_Imported flag for the given entity,
1002 -- checking that it is not previously exported or imported.
1004 procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id);
1005 -- Mech is a parameter passing mechanism (see Import_Function syntax
1006 -- for MECHANISM_NAME). This routine checks that the mechanism argument
1007 -- has the right form, and if not issues an error message. If the
1008 -- argument has the right form then the Mechanism field of Ent is
1009 -- set appropriately.
1011 procedure Set_Rational_Profile;
1012 -- Activate the set of configuration pragmas and permissions that make
1013 -- up the Rational profile.
1015 procedure Set_Ravenscar_Profile (N : Node_Id);
1016 -- Activate the set of configuration pragmas and restrictions that make
1017 -- up the Ravenscar Profile. N is the corresponding pragma node, which
1018 -- is used for error messages on any constructs that violate the
1021 ---------------------
1022 -- Ada_2005_Pragma --
1023 ---------------------
1025 procedure Ada_2005_Pragma is
1027 if Ada_Version <= Ada_95 then
1028 Check_Restriction (No_Implementation_Pragmas, N);
1030 end Ada_2005_Pragma;
1032 ---------------------
1033 -- Ada_2012_Pragma --
1034 ---------------------
1036 procedure Ada_2012_Pragma is
1038 if Ada_Version <= Ada_2005 then
1039 Check_Restriction (No_Implementation_Pragmas, N);
1041 end Ada_2012_Pragma;
1047 procedure Add_Item (Item : Entity_Id; To_List : in out Elist_Id) is
1049 if No (To_List) then
1050 To_List := New_Elmt_List;
1053 Append_Unique_Elmt (Item, To_List);
1056 --------------------------
1057 -- Check_Ada_83_Warning --
1058 --------------------------
1060 procedure Check_Ada_83_Warning is
1062 if Ada_Version = Ada_83 and then Comes_From_Source (N) then
1063 Error_Msg_N ("(Ada 83) pragma& is non-standard??", N);
1065 end Check_Ada_83_Warning;
1067 ---------------------
1068 -- Check_Arg_Count --
1069 ---------------------
1071 procedure Check_Arg_Count (Required : Nat) is
1073 if Arg_Count /= Required then
1074 Error_Pragma ("wrong number of arguments for pragma%");
1076 end Check_Arg_Count;
1078 --------------------------------
1079 -- Check_Arg_Is_External_Name --
1080 --------------------------------
1082 procedure Check_Arg_Is_External_Name (Arg : Node_Id) is
1083 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1086 if Nkind (Argx) = N_Identifier then
1090 Analyze_And_Resolve (Argx, Standard_String);
1092 if Is_OK_Static_Expression (Argx) then
1095 elsif Etype (Argx) = Any_Type then
1098 -- An interesting special case, if we have a string literal and
1099 -- we are in Ada 83 mode, then we allow it even though it will
1100 -- not be flagged as static. This allows expected Ada 83 mode
1101 -- use of external names which are string literals, even though
1102 -- technically these are not static in Ada 83.
1104 elsif Ada_Version = Ada_83
1105 and then Nkind (Argx) = N_String_Literal
1109 -- Static expression that raises Constraint_Error. This has
1110 -- already been flagged, so just exit from pragma processing.
1112 elsif Is_Static_Expression (Argx) then
1115 -- Here we have a real error (non-static expression)
1118 Error_Msg_Name_1 := Pname;
1122 "argument for pragma% must be a identifier or "
1123 & "static string expression!";
1126 Flag_Non_Static_Expr (Msg, Argx);
1131 end Check_Arg_Is_External_Name;
1133 -----------------------------
1134 -- Check_Arg_Is_Identifier --
1135 -----------------------------
1137 procedure Check_Arg_Is_Identifier (Arg : Node_Id) is
1138 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1140 if Nkind (Argx) /= N_Identifier then
1142 ("argument for pragma% must be identifier", Argx);
1144 end Check_Arg_Is_Identifier;
1146 ----------------------------------
1147 -- Check_Arg_Is_Integer_Literal --
1148 ----------------------------------
1150 procedure Check_Arg_Is_Integer_Literal (Arg : Node_Id) is
1151 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1153 if Nkind (Argx) /= N_Integer_Literal then
1155 ("argument for pragma% must be integer literal", Argx);
1157 end Check_Arg_Is_Integer_Literal;
1159 -------------------------------------------
1160 -- Check_Arg_Is_Library_Level_Local_Name --
1161 -------------------------------------------
1165 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
1166 -- | library_unit_NAME
1168 procedure Check_Arg_Is_Library_Level_Local_Name (Arg : Node_Id) is
1170 Check_Arg_Is_Local_Name (Arg);
1172 if not Is_Library_Level_Entity (Entity (Get_Pragma_Arg (Arg)))
1173 and then Comes_From_Source (N)
1176 ("argument for pragma% must be library level entity", Arg);
1178 end Check_Arg_Is_Library_Level_Local_Name;
1180 -----------------------------
1181 -- Check_Arg_Is_Local_Name --
1182 -----------------------------
1186 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
1187 -- | library_unit_NAME
1189 procedure Check_Arg_Is_Local_Name (Arg : Node_Id) is
1190 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1195 if Nkind (Argx) not in N_Direct_Name
1196 and then (Nkind (Argx) /= N_Attribute_Reference
1197 or else Present (Expressions (Argx))
1198 or else Nkind (Prefix (Argx)) /= N_Identifier)
1199 and then (not Is_Entity_Name (Argx)
1200 or else not Is_Compilation_Unit (Entity (Argx)))
1202 Error_Pragma_Arg ("argument for pragma% must be local name", Argx);
1205 -- No further check required if not an entity name
1207 if not Is_Entity_Name (Argx) then
1213 Ent : constant Entity_Id := Entity (Argx);
1214 Scop : constant Entity_Id := Scope (Ent);
1216 -- Case of a pragma applied to a compilation unit: pragma must
1217 -- occur immediately after the program unit in the compilation.
1219 if Is_Compilation_Unit (Ent) then
1221 Decl : constant Node_Id := Unit_Declaration_Node (Ent);
1224 -- Case of pragma placed immediately after spec
1226 if Parent (N) = Aux_Decls_Node (Parent (Decl)) then
1229 -- Case of pragma placed immediately after body
1231 elsif Nkind (Decl) = N_Subprogram_Declaration
1232 and then Present (Corresponding_Body (Decl))
1236 (Parent (Unit_Declaration_Node
1237 (Corresponding_Body (Decl))));
1239 -- All other cases are illegal
1246 -- Special restricted placement rule from 10.2.1(11.8/2)
1248 elsif Is_Generic_Formal (Ent)
1249 and then Prag_Id = Pragma_Preelaborable_Initialization
1251 OK := List_Containing (N) =
1252 Generic_Formal_Declarations
1253 (Unit_Declaration_Node (Scop));
1255 -- Default case, just check that the pragma occurs in the scope
1256 -- of the entity denoted by the name.
1259 OK := Current_Scope = Scop;
1264 ("pragma% argument must be in same declarative part", Arg);
1268 end Check_Arg_Is_Local_Name;
1270 ---------------------------------
1271 -- Check_Arg_Is_Locking_Policy --
1272 ---------------------------------
1274 procedure Check_Arg_Is_Locking_Policy (Arg : Node_Id) is
1275 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1278 Check_Arg_Is_Identifier (Argx);
1280 if not Is_Locking_Policy_Name (Chars (Argx)) then
1281 Error_Pragma_Arg ("& is not a valid locking policy name", Argx);
1283 end Check_Arg_Is_Locking_Policy;
1285 -----------------------------------------------
1286 -- Check_Arg_Is_Partition_Elaboration_Policy --
1287 -----------------------------------------------
1289 procedure Check_Arg_Is_Partition_Elaboration_Policy (Arg : Node_Id) is
1290 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1293 Check_Arg_Is_Identifier (Argx);
1295 if not Is_Partition_Elaboration_Policy_Name (Chars (Argx)) then
1297 ("& is not a valid partition elaboration policy name", Argx);
1299 end Check_Arg_Is_Partition_Elaboration_Policy;
1301 -------------------------
1302 -- Check_Arg_Is_One_Of --
1303 -------------------------
1305 procedure Check_Arg_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id) is
1306 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1309 Check_Arg_Is_Identifier (Argx);
1311 if Chars (Argx) /= N1 and then Chars (Argx) /= N2 then
1312 Error_Msg_Name_2 := N1;
1313 Error_Msg_Name_3 := N2;
1314 Error_Pragma_Arg ("argument for pragma% must be% or%", Argx);
1316 end Check_Arg_Is_One_Of;
1318 procedure Check_Arg_Is_One_Of
1320 N1, N2, N3 : Name_Id)
1322 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1325 Check_Arg_Is_Identifier (Argx);
1327 if Chars (Argx) /= N1
1328 and then Chars (Argx) /= N2
1329 and then Chars (Argx) /= N3
1331 Error_Pragma_Arg ("invalid argument for pragma%", Argx);
1333 end Check_Arg_Is_One_Of;
1335 procedure Check_Arg_Is_One_Of
1337 N1, N2, N3, N4 : Name_Id)
1339 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1342 Check_Arg_Is_Identifier (Argx);
1344 if Chars (Argx) /= N1
1345 and then Chars (Argx) /= N2
1346 and then Chars (Argx) /= N3
1347 and then Chars (Argx) /= N4
1349 Error_Pragma_Arg ("invalid argument for pragma%", Argx);
1351 end Check_Arg_Is_One_Of;
1353 procedure Check_Arg_Is_One_Of
1355 N1, N2, N3, N4, N5 : Name_Id)
1357 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1360 Check_Arg_Is_Identifier (Argx);
1362 if Chars (Argx) /= N1
1363 and then Chars (Argx) /= N2
1364 and then Chars (Argx) /= N3
1365 and then Chars (Argx) /= N4
1366 and then Chars (Argx) /= N5
1368 Error_Pragma_Arg ("invalid argument for pragma%", Argx);
1370 end Check_Arg_Is_One_Of;
1372 ---------------------------------
1373 -- Check_Arg_Is_Queuing_Policy --
1374 ---------------------------------
1376 procedure Check_Arg_Is_Queuing_Policy (Arg : Node_Id) is
1377 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1380 Check_Arg_Is_Identifier (Argx);
1382 if not Is_Queuing_Policy_Name (Chars (Argx)) then
1383 Error_Pragma_Arg ("& is not a valid queuing policy name", Argx);
1385 end Check_Arg_Is_Queuing_Policy;
1387 ------------------------------------
1388 -- Check_Arg_Is_Static_Expression --
1389 ------------------------------------
1391 procedure Check_Arg_Is_Static_Expression
1393 Typ : Entity_Id := Empty)
1396 Check_Expr_Is_Static_Expression (Get_Pragma_Arg (Arg), Typ);
1397 end Check_Arg_Is_Static_Expression;
1399 ------------------------------------------
1400 -- Check_Arg_Is_Task_Dispatching_Policy --
1401 ------------------------------------------
1403 procedure Check_Arg_Is_Task_Dispatching_Policy (Arg : Node_Id) is
1404 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1407 Check_Arg_Is_Identifier (Argx);
1409 if not Is_Task_Dispatching_Policy_Name (Chars (Argx)) then
1411 ("& is not a valid task dispatching policy name", Argx);
1413 end Check_Arg_Is_Task_Dispatching_Policy;
1415 ---------------------
1416 -- Check_Arg_Order --
1417 ---------------------
1419 procedure Check_Arg_Order (Names : Name_List) is
1422 Highest_So_Far : Natural := 0;
1423 -- Highest index in Names seen do far
1427 for J in 1 .. Arg_Count loop
1428 if Chars (Arg) /= No_Name then
1429 for K in Names'Range loop
1430 if Chars (Arg) = Names (K) then
1431 if K < Highest_So_Far then
1432 Error_Msg_Name_1 := Pname;
1434 ("parameters out of order for pragma%", Arg);
1435 Error_Msg_Name_1 := Names (K);
1436 Error_Msg_Name_2 := Names (Highest_So_Far);
1437 Error_Msg_N ("\% must appear before %", Arg);
1441 Highest_So_Far := K;
1449 end Check_Arg_Order;
1451 --------------------------------
1452 -- Check_At_Least_N_Arguments --
1453 --------------------------------
1455 procedure Check_At_Least_N_Arguments (N : Nat) is
1457 if Arg_Count < N then
1458 Error_Pragma ("too few arguments for pragma%");
1460 end Check_At_Least_N_Arguments;
1462 -------------------------------
1463 -- Check_At_Most_N_Arguments --
1464 -------------------------------
1466 procedure Check_At_Most_N_Arguments (N : Nat) is
1469 if Arg_Count > N then
1471 for J in 1 .. N loop
1473 Error_Pragma_Arg ("too many arguments for pragma%", Arg);
1476 end Check_At_Most_N_Arguments;
1478 ---------------------
1479 -- Check_Component --
1480 ---------------------
1482 procedure Check_Component
1485 In_Variant_Part : Boolean := False)
1487 Comp_Id : constant Entity_Id := Defining_Identifier (Comp);
1488 Sindic : constant Node_Id :=
1489 Subtype_Indication (Component_Definition (Comp));
1490 Typ : constant Entity_Id := Etype (Comp_Id);
1493 -- Ada 2005 (AI-216): If a component subtype is subject to a per-
1494 -- object constraint, then the component type shall be an Unchecked_
1497 if Nkind (Sindic) = N_Subtype_Indication
1498 and then Has_Per_Object_Constraint (Comp_Id)
1499 and then not Is_Unchecked_Union (Etype (Subtype_Mark (Sindic)))
1502 ("component subtype subject to per-object constraint "
1503 & "must be an Unchecked_Union", Comp);
1505 -- Ada 2012 (AI05-0026): For an unchecked union type declared within
1506 -- the body of a generic unit, or within the body of any of its
1507 -- descendant library units, no part of the type of a component
1508 -- declared in a variant_part of the unchecked union type shall be of
1509 -- a formal private type or formal private extension declared within
1510 -- the formal part of the generic unit.
1512 elsif Ada_Version >= Ada_2012
1513 and then In_Generic_Body (UU_Typ)
1514 and then In_Variant_Part
1515 and then Is_Private_Type (Typ)
1516 and then Is_Generic_Type (Typ)
1519 ("component of unchecked union cannot be of generic type", Comp);
1521 elsif Needs_Finalization (Typ) then
1523 ("component of unchecked union cannot be controlled", Comp);
1525 elsif Has_Task (Typ) then
1527 ("component of unchecked union cannot have tasks", Comp);
1529 end Check_Component;
1531 ---------------------------------
1532 -- Check_Contract_Or_Test_Case --
1533 ---------------------------------
1535 procedure Check_Contract_Or_Test_Case is
1539 procedure Chain_CTC (PO : Node_Id);
1540 -- If PO is a [generic] subprogram declaration node, then the
1541 -- contract-case or test-case applies to this subprogram and the
1542 -- processing for the pragma is completed. Otherwise the pragma
1549 procedure Chain_CTC (PO : Node_Id) is
1553 if Nkind (PO) = N_Abstract_Subprogram_Declaration then
1555 ("pragma% cannot be applied to abstract subprogram");
1557 elsif Nkind (PO) = N_Entry_Declaration then
1558 Error_Pragma ("pragma% cannot be applied to entry");
1560 elsif not Nkind_In (PO, N_Subprogram_Declaration,
1561 N_Generic_Subprogram_Declaration)
1566 -- Here if we have [generic] subprogram declaration
1568 S := Defining_Unit_Name (Specification (PO));
1570 -- Note: we do not analyze the pragma at this point. Instead we
1571 -- delay this analysis until the end of the declarative part in
1572 -- which the pragma appears. This implements the required delay
1573 -- in this analysis, allowing forward references. The analysis
1574 -- happens at the end of Analyze_Declarations.
1576 -- There should not be another contract-case or test-case with the
1577 -- same name associated to this subprogram.
1580 Name : constant String_Id := Get_Name_From_CTC_Pragma (N);
1584 CTC := Spec_CTC_List (Contract (S));
1585 while Present (CTC) loop
1587 -- Omit pragma Contract_Cases because it does not introduce
1588 -- a unique case name and it does not follow the syntax of
1589 -- Contract_Case and Test_Case.
1591 if Pragma_Name (CTC) = Name_Contract_Cases then
1595 (Name, Get_Name_From_CTC_Pragma (CTC))
1597 Error_Msg_Sloc := Sloc (CTC);
1598 Error_Pragma ("name for pragma% is already used#");
1601 CTC := Next_Pragma (CTC);
1605 -- Chain spec CTC pragma to list for subprogram
1607 Set_Next_Pragma (N, Spec_CTC_List (Contract (S)));
1608 Set_Spec_CTC_List (Contract (S), N);
1611 -- Start of processing for Check_Contract_Or_Test_Case
1614 -- First check pragma arguments
1617 Check_At_Least_N_Arguments (2);
1618 Check_At_Most_N_Arguments (4);
1620 ((Name_Name, Name_Mode, Name_Requires, Name_Ensures));
1622 Check_Optional_Identifier (Arg1, Name_Name);
1623 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
1625 -- In ASIS mode, for a pragma generated from a source aspect, also
1626 -- analyze the original aspect expression.
1629 and then Present (Corresponding_Aspect (N))
1631 Check_Expr_Is_Static_Expression
1632 (Original_Node (Get_Pragma_Arg (Arg1)), Standard_String);
1635 Check_Optional_Identifier (Arg2, Name_Mode);
1636 Check_Arg_Is_One_Of (Arg2, Name_Nominal, Name_Robustness);
1638 if Arg_Count = 4 then
1639 Check_Identifier (Arg3, Name_Requires);
1640 Check_Identifier (Arg4, Name_Ensures);
1642 elsif Arg_Count = 3 then
1643 Check_Identifier_Is_One_Of (Arg3, Name_Requires, Name_Ensures);
1646 -- Check pragma placement
1648 if not Is_List_Member (N) then
1652 -- Contract-case or test-case should only appear in package spec unit
1654 if Get_Source_Unit (N) = No_Unit
1655 or else not Nkind_In (Sinfo.Unit (Cunit (Get_Source_Unit (N))),
1656 N_Package_Declaration,
1657 N_Generic_Package_Declaration)
1662 -- Search prior declarations
1665 while Present (Prev (P)) loop
1668 -- If the previous node is a generic subprogram, do not go to to
1669 -- the original node, which is the unanalyzed tree: we need to
1670 -- attach the contract-case or test-case to the analyzed version
1671 -- at this point. They get propagated to the original tree when
1672 -- analyzing the corresponding body.
1674 if Nkind (P) not in N_Generic_Declaration then
1675 PO := Original_Node (P);
1680 -- Skip past prior pragma
1682 if Nkind (PO) = N_Pragma then
1685 -- Skip stuff not coming from source
1687 elsif not Comes_From_Source (PO) then
1690 -- Only remaining possibility is subprogram declaration. First
1691 -- check that it is declared directly in a package declaration.
1692 -- This may be either the package declaration for the current unit
1693 -- being defined or a local package declaration.
1695 elsif not Present (Parent (Parent (PO)))
1696 or else not Present (Parent (Parent (Parent (PO))))
1697 or else not Nkind_In (Parent (Parent (PO)),
1698 N_Package_Declaration,
1699 N_Generic_Package_Declaration)
1709 -- If we fall through, pragma was misplaced
1712 end Check_Contract_Or_Test_Case;
1714 ----------------------------
1715 -- Check_Duplicate_Pragma --
1716 ----------------------------
1718 procedure Check_Duplicate_Pragma (E : Entity_Id) is
1719 Id : Entity_Id := E;
1723 -- Nothing to do if this pragma comes from an aspect specification,
1724 -- since we could not be duplicating a pragma, and we dealt with the
1725 -- case of duplicated aspects in Analyze_Aspect_Specifications.
1727 if From_Aspect_Specification (N) then
1731 -- Otherwise current pragma may duplicate previous pragma or a
1732 -- previously given aspect specification or attribute definition
1733 -- clause for the same pragma.
1735 P := Get_Rep_Item (E, Pragma_Name (N), Check_Parents => False);
1738 Error_Msg_Name_1 := Pragma_Name (N);
1739 Error_Msg_Sloc := Sloc (P);
1741 -- For a single protected or a single task object, the error is
1742 -- issued on the original entity.
1744 if Ekind_In (Id, E_Task_Type, E_Protected_Type) then
1745 Id := Defining_Identifier (Original_Node (Parent (Id)));
1748 if Nkind (P) = N_Aspect_Specification
1749 or else From_Aspect_Specification (P)
1751 Error_Msg_NE ("aspect% for & previously given#", N, Id);
1753 Error_Msg_NE ("pragma% for & duplicates pragma#", N, Id);
1758 end Check_Duplicate_Pragma;
1760 ----------------------------------
1761 -- Check_Duplicated_Export_Name --
1762 ----------------------------------
1764 procedure Check_Duplicated_Export_Name (Nam : Node_Id) is
1765 String_Val : constant String_Id := Strval (Nam);
1768 -- We are only interested in the export case, and in the case of
1769 -- generics, it is the instance, not the template, that is the
1770 -- problem (the template will generate a warning in any case).
1772 if not Inside_A_Generic
1773 and then (Prag_Id = Pragma_Export
1775 Prag_Id = Pragma_Export_Procedure
1777 Prag_Id = Pragma_Export_Valued_Procedure
1779 Prag_Id = Pragma_Export_Function)
1781 for J in Externals.First .. Externals.Last loop
1782 if String_Equal (String_Val, Strval (Externals.Table (J))) then
1783 Error_Msg_Sloc := Sloc (Externals.Table (J));
1784 Error_Msg_N ("external name duplicates name given#", Nam);
1789 Externals.Append (Nam);
1791 end Check_Duplicated_Export_Name;
1793 -------------------------------------
1794 -- Check_Expr_Is_Static_Expression --
1795 -------------------------------------
1797 procedure Check_Expr_Is_Static_Expression
1799 Typ : Entity_Id := Empty)
1802 if Present (Typ) then
1803 Analyze_And_Resolve (Expr, Typ);
1805 Analyze_And_Resolve (Expr);
1808 if Is_OK_Static_Expression (Expr) then
1811 elsif Etype (Expr) = Any_Type then
1814 -- An interesting special case, if we have a string literal and we
1815 -- are in Ada 83 mode, then we allow it even though it will not be
1816 -- flagged as static. This allows the use of Ada 95 pragmas like
1817 -- Import in Ada 83 mode. They will of course be flagged with
1818 -- warnings as usual, but will not cause errors.
1820 elsif Ada_Version = Ada_83
1821 and then Nkind (Expr) = N_String_Literal
1825 -- Static expression that raises Constraint_Error. This has already
1826 -- been flagged, so just exit from pragma processing.
1828 elsif Is_Static_Expression (Expr) then
1831 -- Finally, we have a real error
1834 Error_Msg_Name_1 := Pname;
1838 "argument for pragma% must be a static expression!";
1841 Flag_Non_Static_Expr (Msg, Expr);
1846 end Check_Expr_Is_Static_Expression;
1848 -------------------------
1849 -- Check_First_Subtype --
1850 -------------------------
1852 procedure Check_First_Subtype (Arg : Node_Id) is
1853 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
1854 Ent : constant Entity_Id := Entity (Argx);
1857 if Is_First_Subtype (Ent) then
1860 elsif Is_Type (Ent) then
1862 ("pragma% cannot apply to subtype", Argx);
1864 elsif Is_Object (Ent) then
1866 ("pragma% cannot apply to object, requires a type", Argx);
1870 ("pragma% cannot apply to&, requires a type", Argx);
1872 end Check_First_Subtype;
1874 ----------------------
1875 -- Check_Identifier --
1876 ----------------------
1878 procedure Check_Identifier (Arg : Node_Id; Id : Name_Id) is
1881 and then Nkind (Arg) = N_Pragma_Argument_Association
1883 if Chars (Arg) = No_Name or else Chars (Arg) /= Id then
1884 Error_Msg_Name_1 := Pname;
1885 Error_Msg_Name_2 := Id;
1886 Error_Msg_N ("pragma% argument expects identifier%", Arg);
1890 end Check_Identifier;
1892 --------------------------------
1893 -- Check_Identifier_Is_One_Of --
1894 --------------------------------
1896 procedure Check_Identifier_Is_One_Of (Arg : Node_Id; N1, N2 : Name_Id) is
1899 and then Nkind (Arg) = N_Pragma_Argument_Association
1901 if Chars (Arg) = No_Name then
1902 Error_Msg_Name_1 := Pname;
1903 Error_Msg_N ("pragma% argument expects an identifier", Arg);
1906 elsif Chars (Arg) /= N1
1907 and then Chars (Arg) /= N2
1909 Error_Msg_Name_1 := Pname;
1910 Error_Msg_N ("invalid identifier for pragma% argument", Arg);
1914 end Check_Identifier_Is_One_Of;
1916 ---------------------------
1917 -- Check_In_Main_Program --
1918 ---------------------------
1920 procedure Check_In_Main_Program is
1921 P : constant Node_Id := Parent (N);
1924 -- Must be at in subprogram body
1926 if Nkind (P) /= N_Subprogram_Body then
1927 Error_Pragma ("% pragma allowed only in subprogram");
1929 -- Otherwise warn if obviously not main program
1931 elsif Present (Parameter_Specifications (Specification (P)))
1932 or else not Is_Compilation_Unit (Defining_Entity (P))
1934 Error_Msg_Name_1 := Pname;
1936 ("??pragma% is only effective in main program", N);
1938 end Check_In_Main_Program;
1940 ---------------------------------------
1941 -- Check_Interrupt_Or_Attach_Handler --
1942 ---------------------------------------
1944 procedure Check_Interrupt_Or_Attach_Handler is
1945 Arg1_X : constant Node_Id := Get_Pragma_Arg (Arg1);
1946 Handler_Proc, Proc_Scope : Entity_Id;
1951 if Prag_Id = Pragma_Interrupt_Handler then
1952 Check_Restriction (No_Dynamic_Attachment, N);
1955 Handler_Proc := Find_Unique_Parameterless_Procedure (Arg1_X, Arg1);
1956 Proc_Scope := Scope (Handler_Proc);
1958 -- On AAMP only, a pragma Interrupt_Handler is supported for
1959 -- nonprotected parameterless procedures.
1961 if not AAMP_On_Target
1962 or else Prag_Id = Pragma_Attach_Handler
1964 if Ekind (Proc_Scope) /= E_Protected_Type then
1966 ("argument of pragma% must be protected procedure", Arg1);
1969 if Parent (N) /= Protected_Definition (Parent (Proc_Scope)) then
1970 Error_Pragma ("pragma% must be in protected definition");
1974 if not Is_Library_Level_Entity (Proc_Scope)
1975 or else (AAMP_On_Target
1976 and then not Is_Library_Level_Entity (Handler_Proc))
1979 ("argument for pragma% must be library level entity", Arg1);
1982 -- AI05-0033: A pragma cannot appear within a generic body, because
1983 -- instance can be in a nested scope. The check that protected type
1984 -- is itself a library-level declaration is done elsewhere.
1986 -- Note: we omit this check in Relaxed_RM_Semantics mode to properly
1987 -- handle code prior to AI-0033. Analysis tools typically are not
1988 -- interested in this pragma in any case, so no need to worry too
1989 -- much about its placement.
1991 if Inside_A_Generic then
1992 if Ekind (Scope (Current_Scope)) = E_Generic_Package
1993 and then In_Package_Body (Scope (Current_Scope))
1994 and then not Relaxed_RM_Semantics
1996 Error_Pragma ("pragma% cannot be used inside a generic");
1999 end Check_Interrupt_Or_Attach_Handler;
2001 ---------------------------------
2002 -- Check_Loop_Pragma_Placement --
2003 ---------------------------------
2005 procedure Check_Loop_Pragma_Placement is
2006 procedure Placement_Error (Constr : Node_Id);
2007 pragma No_Return (Placement_Error);
2008 -- Node Constr denotes the last loop restricted construct before we
2009 -- encountered an illegal relation between enclosing constructs. Emit
2010 -- an error depending on what Constr was.
2012 ---------------------
2013 -- Placement_Error --
2014 ---------------------
2016 procedure Placement_Error (Constr : Node_Id) is
2018 if Nkind (Constr) = N_Pragma then
2020 ("pragma % must appear immediately within the statements "
2024 ("block containing pragma % must appear immediately within "
2025 & "the statements of a loop", Constr);
2027 end Placement_Error;
2029 -- Local declarations
2034 -- Start of processing for Check_Loop_Pragma_Placement
2039 while Present (Stmt) loop
2041 -- The pragma or previous block must appear immediately within the
2042 -- current block's declarative or statement part.
2044 if Nkind (Stmt) = N_Block_Statement then
2045 if (No (Declarations (Stmt))
2046 or else List_Containing (Prev) /= Declarations (Stmt))
2048 List_Containing (Prev) /=
2049 Statements (Handled_Statement_Sequence (Stmt))
2051 Placement_Error (Prev);
2054 -- Keep inspecting the parents because we are now within a
2055 -- chain of nested blocks.
2059 Stmt := Parent (Stmt);
2062 -- The pragma or previous block must appear immediately within the
2063 -- statements of the loop.
2065 elsif Nkind (Stmt) = N_Loop_Statement then
2066 if List_Containing (Prev) /= Statements (Stmt) then
2067 Placement_Error (Prev);
2070 -- Stop the traversal because we reached the innermost loop
2071 -- regardless of whether we encountered an error or not.
2075 -- Ignore a handled statement sequence. Note that this node may
2076 -- be related to a subprogram body in which case we will emit an
2077 -- error on the next iteration of the search.
2079 elsif Nkind (Stmt) = N_Handled_Sequence_Of_Statements then
2080 Stmt := Parent (Stmt);
2082 -- Any other statement breaks the chain from the pragma to the
2086 Placement_Error (Prev);
2090 end Check_Loop_Pragma_Placement;
2092 -------------------------------------------
2093 -- Check_Is_In_Decl_Part_Or_Package_Spec --
2094 -------------------------------------------
2096 procedure Check_Is_In_Decl_Part_Or_Package_Spec is
2105 elsif Nkind (P) = N_Handled_Sequence_Of_Statements then
2108 elsif Nkind_In (P, N_Package_Specification,
2113 -- Note: the following tests seem a little peculiar, because
2114 -- they test for bodies, but if we were in the statement part
2115 -- of the body, we would already have hit the handled statement
2116 -- sequence, so the only way we get here is by being in the
2117 -- declarative part of the body.
2119 elsif Nkind_In (P, N_Subprogram_Body,
2130 Error_Pragma ("pragma% is not in declarative part or package spec");
2131 end Check_Is_In_Decl_Part_Or_Package_Spec;
2133 -------------------------
2134 -- Check_No_Identifier --
2135 -------------------------
2137 procedure Check_No_Identifier (Arg : Node_Id) is
2139 if Nkind (Arg) = N_Pragma_Argument_Association
2140 and then Chars (Arg) /= No_Name
2142 Error_Pragma_Arg_Ident
2143 ("pragma% does not permit identifier& here", Arg);
2145 end Check_No_Identifier;
2147 --------------------------
2148 -- Check_No_Identifiers --
2149 --------------------------
2151 procedure Check_No_Identifiers is
2154 if Arg_Count > 0 then
2156 while Present (Arg_Node) loop
2157 Check_No_Identifier (Arg_Node);
2161 end Check_No_Identifiers;
2163 ------------------------
2164 -- Check_No_Link_Name --
2165 ------------------------
2167 procedure Check_No_Link_Name is
2170 and then Chars (Arg3) = Name_Link_Name
2175 if Present (Arg4) then
2177 ("Link_Name argument not allowed for Import Intrinsic", Arg4);
2179 end Check_No_Link_Name;
2181 -------------------------------
2182 -- Check_Optional_Identifier --
2183 -------------------------------
2185 procedure Check_Optional_Identifier (Arg : Node_Id; Id : Name_Id) is
2188 and then Nkind (Arg) = N_Pragma_Argument_Association
2189 and then Chars (Arg) /= No_Name
2191 if Chars (Arg) /= Id then
2192 Error_Msg_Name_1 := Pname;
2193 Error_Msg_Name_2 := Id;
2194 Error_Msg_N ("pragma% argument expects identifier%", Arg);
2198 end Check_Optional_Identifier;
2200 procedure Check_Optional_Identifier (Arg : Node_Id; Id : String) is
2202 Name_Buffer (1 .. Id'Length) := Id;
2203 Name_Len := Id'Length;
2204 Check_Optional_Identifier (Arg, Name_Find);
2205 end Check_Optional_Identifier;
2207 --------------------------------------
2208 -- Check_Precondition_Postcondition --
2209 --------------------------------------
2211 procedure Check_Precondition_Postcondition (In_Body : out Boolean) is
2215 procedure Chain_PPC (PO : Node_Id);
2216 -- If PO is an entry or a [generic] subprogram declaration node, then
2217 -- the precondition/postcondition applies to this subprogram and the
2218 -- processing for the pragma is completed. Otherwise the pragma is
2225 procedure Chain_PPC (PO : Node_Id) is
2229 if Nkind (PO) = N_Abstract_Subprogram_Declaration then
2230 if not From_Aspect_Specification (N) then
2232 ("pragma% cannot be applied to abstract subprogram");
2234 elsif Class_Present (N) then
2239 ("aspect % requires ''Class for abstract subprogram");
2242 -- AI05-0230: The same restriction applies to null procedures. For
2243 -- compatibility with earlier uses of the Ada pragma, apply this
2244 -- rule only to aspect specifications.
2246 -- The above discrpency needs documentation. Robert is dubious
2247 -- about whether it is a good idea ???
2249 elsif Nkind (PO) = N_Subprogram_Declaration
2250 and then Nkind (Specification (PO)) = N_Procedure_Specification
2251 and then Null_Present (Specification (PO))
2252 and then From_Aspect_Specification (N)
2253 and then not Class_Present (N)
2256 ("aspect % requires ''Class for null procedure");
2258 -- Pre/postconditions are legal on a subprogram body if it is not
2259 -- a completion of a declaration. They are also legal on a stub
2260 -- with no previous declarations (this is checked when processing
2261 -- the corresponding aspects).
2263 elsif Nkind (PO) = N_Subprogram_Body
2264 and then Acts_As_Spec (PO)
2268 elsif Nkind (PO) = N_Subprogram_Body_Stub then
2271 elsif not Nkind_In (PO, N_Subprogram_Declaration,
2272 N_Expression_Function,
2273 N_Generic_Subprogram_Declaration,
2274 N_Entry_Declaration)
2279 -- Here if we have [generic] subprogram or entry declaration
2281 if Nkind (PO) = N_Entry_Declaration then
2282 S := Defining_Entity (PO);
2284 S := Defining_Unit_Name (Specification (PO));
2286 if Nkind (S) = N_Defining_Program_Unit_Name then
2287 S := Defining_Identifier (S);
2291 -- Note: we do not analyze the pragma at this point. Instead we
2292 -- delay this analysis until the end of the declarative part in
2293 -- which the pragma appears. This implements the required delay
2294 -- in this analysis, allowing forward references. The analysis
2295 -- happens at the end of Analyze_Declarations.
2297 -- Chain spec PPC pragma to list for subprogram
2299 Set_Next_Pragma (N, Spec_PPC_List (Contract (S)));
2300 Set_Spec_PPC_List (Contract (S), N);
2302 -- Return indicating spec case
2308 -- Start of processing for Check_Precondition_Postcondition
2311 if not Is_List_Member (N) then
2315 -- Preanalyze message argument if present. Visibility in this
2316 -- argument is established at the point of pragma occurrence.
2318 if Arg_Count = 2 then
2319 Check_Optional_Identifier (Arg2, Name_Message);
2320 Preanalyze_Spec_Expression
2321 (Get_Pragma_Arg (Arg2), Standard_String);
2324 -- For a pragma PPC in the extended main source unit, record enabled
2327 -- This may seem redundant with the call to Check_Enabled occurring
2328 -- later on when the pragma is rewritten into a pragma Check but
2329 -- is actually required in the case of a postcondition within a
2332 if Check_Enabled (Pname) and then not Split_PPC (N) then
2333 Set_SCO_Pragma_Enabled (Loc);
2336 -- If we are within an inlined body, the legality of the pragma
2337 -- has been checked already.
2339 if In_Inlined_Body then
2344 -- Search prior declarations
2347 while Present (Prev (P)) loop
2350 -- If the previous node is a generic subprogram, do not go to to
2351 -- the original node, which is the unanalyzed tree: we need to
2352 -- attach the pre/postconditions to the analyzed version at this
2353 -- point. They get propagated to the original tree when analyzing
2354 -- the corresponding body.
2356 if Nkind (P) not in N_Generic_Declaration then
2357 PO := Original_Node (P);
2362 -- Skip past prior pragma
2364 if Nkind (PO) = N_Pragma then
2367 -- Skip stuff not coming from source
2369 elsif not Comes_From_Source (PO) then
2371 -- The condition may apply to a subprogram instantiation
2373 if Nkind (PO) = N_Subprogram_Declaration
2374 and then Present (Generic_Parent (Specification (PO)))
2379 elsif Nkind (PO) = N_Subprogram_Declaration
2380 and then In_Instance
2385 -- For all other cases of non source code, do nothing
2391 -- Only remaining possibility is subprogram declaration
2399 -- If we fall through loop, pragma is at start of list, so see if it
2400 -- is at the start of declarations of a subprogram body.
2402 if Nkind (Parent (N)) = N_Subprogram_Body
2403 and then List_Containing (N) = Declarations (Parent (N))
2405 if Operating_Mode /= Generate_Code
2406 or else Inside_A_Generic
2408 -- Analyze pragma expression for correctness and for ASIS use
2410 Preanalyze_Assert_Expression
2411 (Get_Pragma_Arg (Arg1), Standard_Boolean);
2413 -- In ASIS mode, for a pragma generated from a source aspect,
2414 -- also analyze the original aspect expression.
2417 and then Present (Corresponding_Aspect (N))
2419 Preanalyze_Assert_Expression
2420 (Expression (Corresponding_Aspect (N)), Standard_Boolean);
2427 -- See if it is in the pragmas after a library level subprogram
2429 elsif Nkind (Parent (N)) = N_Compilation_Unit_Aux then
2431 -- In formal verification mode, analyze pragma expression for
2432 -- correctness, as it is not expanded later.
2435 Analyze_PPC_In_Decl_Part
2436 (N, Defining_Entity (Unit (Parent (Parent (N)))));
2439 Chain_PPC (Unit (Parent (Parent (N))));
2443 -- If we fall through, pragma was misplaced
2446 end Check_Precondition_Postcondition;
2448 -----------------------------
2449 -- Check_Static_Constraint --
2450 -----------------------------
2452 -- Note: for convenience in writing this procedure, in addition to
2453 -- the officially (i.e. by spec) allowed argument which is always a
2454 -- constraint, it also allows ranges and discriminant associations.
2455 -- Above is not clear ???
2457 procedure Check_Static_Constraint (Constr : Node_Id) is
2459 procedure Require_Static (E : Node_Id);
2460 -- Require given expression to be static expression
2462 --------------------
2463 -- Require_Static --
2464 --------------------
2466 procedure Require_Static (E : Node_Id) is
2468 if not Is_OK_Static_Expression (E) then
2469 Flag_Non_Static_Expr
2470 ("non-static constraint not allowed in Unchecked_Union!", E);
2475 -- Start of processing for Check_Static_Constraint
2478 case Nkind (Constr) is
2479 when N_Discriminant_Association =>
2480 Require_Static (Expression (Constr));
2483 Require_Static (Low_Bound (Constr));
2484 Require_Static (High_Bound (Constr));
2486 when N_Attribute_Reference =>
2487 Require_Static (Type_Low_Bound (Etype (Prefix (Constr))));
2488 Require_Static (Type_High_Bound (Etype (Prefix (Constr))));
2490 when N_Range_Constraint =>
2491 Check_Static_Constraint (Range_Expression (Constr));
2493 when N_Index_Or_Discriminant_Constraint =>
2497 IDC := First (Constraints (Constr));
2498 while Present (IDC) loop
2499 Check_Static_Constraint (IDC);
2507 end Check_Static_Constraint;
2509 --------------------------------------
2510 -- Check_Valid_Configuration_Pragma --
2511 --------------------------------------
2513 -- A configuration pragma must appear in the context clause of a
2514 -- compilation unit, and only other pragmas may precede it. Note that
2515 -- the test also allows use in a configuration pragma file.
2517 procedure Check_Valid_Configuration_Pragma is
2519 if not Is_Configuration_Pragma then
2520 Error_Pragma ("incorrect placement for configuration pragma%");
2522 end Check_Valid_Configuration_Pragma;
2524 -------------------------------------
2525 -- Check_Valid_Library_Unit_Pragma --
2526 -------------------------------------
2528 procedure Check_Valid_Library_Unit_Pragma is
2530 Parent_Node : Node_Id;
2531 Unit_Name : Entity_Id;
2532 Unit_Kind : Node_Kind;
2533 Unit_Node : Node_Id;
2534 Sindex : Source_File_Index;
2537 if not Is_List_Member (N) then
2541 Plist := List_Containing (N);
2542 Parent_Node := Parent (Plist);
2544 if Parent_Node = Empty then
2547 -- Case of pragma appearing after a compilation unit. In this case
2548 -- it must have an argument with the corresponding name and must
2549 -- be part of the following pragmas of its parent.
2551 elsif Nkind (Parent_Node) = N_Compilation_Unit_Aux then
2552 if Plist /= Pragmas_After (Parent_Node) then
2555 elsif Arg_Count = 0 then
2557 ("argument required if outside compilation unit");
2560 Check_No_Identifiers;
2561 Check_Arg_Count (1);
2562 Unit_Node := Unit (Parent (Parent_Node));
2563 Unit_Kind := Nkind (Unit_Node);
2565 Analyze (Get_Pragma_Arg (Arg1));
2567 if Unit_Kind = N_Generic_Subprogram_Declaration
2568 or else Unit_Kind = N_Subprogram_Declaration
2570 Unit_Name := Defining_Entity (Unit_Node);
2572 elsif Unit_Kind in N_Generic_Instantiation then
2573 Unit_Name := Defining_Entity (Unit_Node);
2576 Unit_Name := Cunit_Entity (Current_Sem_Unit);
2579 if Chars (Unit_Name) /=
2580 Chars (Entity (Get_Pragma_Arg (Arg1)))
2583 ("pragma% argument is not current unit name", Arg1);
2586 if Ekind (Unit_Name) = E_Package
2587 and then Present (Renamed_Entity (Unit_Name))
2589 Error_Pragma ("pragma% not allowed for renamed package");
2593 -- Pragma appears other than after a compilation unit
2596 -- Here we check for the generic instantiation case and also
2597 -- for the case of processing a generic formal package. We
2598 -- detect these cases by noting that the Sloc on the node
2599 -- does not belong to the current compilation unit.
2601 Sindex := Source_Index (Current_Sem_Unit);
2603 if Loc not in Source_First (Sindex) .. Source_Last (Sindex) then
2604 Rewrite (N, Make_Null_Statement (Loc));
2607 -- If before first declaration, the pragma applies to the
2608 -- enclosing unit, and the name if present must be this name.
2610 elsif Is_Before_First_Decl (N, Plist) then
2611 Unit_Node := Unit_Declaration_Node (Current_Scope);
2612 Unit_Kind := Nkind (Unit_Node);
2614 if Nkind (Parent (Unit_Node)) /= N_Compilation_Unit then
2617 elsif Unit_Kind = N_Subprogram_Body
2618 and then not Acts_As_Spec (Unit_Node)
2622 elsif Nkind (Parent_Node) = N_Package_Body then
2625 elsif Nkind (Parent_Node) = N_Package_Specification
2626 and then Plist = Private_Declarations (Parent_Node)
2630 elsif (Nkind (Parent_Node) = N_Generic_Package_Declaration
2631 or else Nkind (Parent_Node) =
2632 N_Generic_Subprogram_Declaration)
2633 and then Plist = Generic_Formal_Declarations (Parent_Node)
2637 elsif Arg_Count > 0 then
2638 Analyze (Get_Pragma_Arg (Arg1));
2640 if Entity (Get_Pragma_Arg (Arg1)) /= Current_Scope then
2642 ("name in pragma% must be enclosing unit", Arg1);
2645 -- It is legal to have no argument in this context
2651 -- Error if not before first declaration. This is because a
2652 -- library unit pragma argument must be the name of a library
2653 -- unit (RM 10.1.5(7)), but the only names permitted in this
2654 -- context are (RM 10.1.5(6)) names of subprogram declarations,
2655 -- generic subprogram declarations or generic instantiations.
2659 ("pragma% misplaced, must be before first declaration");
2663 end Check_Valid_Library_Unit_Pragma;
2669 procedure Check_Variant (Variant : Node_Id; UU_Typ : Entity_Id) is
2670 Clist : constant Node_Id := Component_List (Variant);
2674 Comp := First (Component_Items (Clist));
2675 while Present (Comp) loop
2676 Check_Component (Comp, UU_Typ, In_Variant_Part => True);
2685 procedure Error_Pragma (Msg : String) is
2686 MsgF : String := Msg;
2688 Error_Msg_Name_1 := Pname;
2690 Error_Msg_N (MsgF, N);
2694 ----------------------
2695 -- Error_Pragma_Arg --
2696 ----------------------
2698 procedure Error_Pragma_Arg (Msg : String; Arg : Node_Id) is
2699 MsgF : String := Msg;
2701 Error_Msg_Name_1 := Pname;
2703 Error_Msg_N (MsgF, Get_Pragma_Arg (Arg));
2705 end Error_Pragma_Arg;
2707 procedure Error_Pragma_Arg (Msg1, Msg2 : String; Arg : Node_Id) is
2708 MsgF : String := Msg1;
2710 Error_Msg_Name_1 := Pname;
2712 Error_Msg_N (MsgF, Get_Pragma_Arg (Arg));
2713 Error_Pragma_Arg (Msg2, Arg);
2714 end Error_Pragma_Arg;
2716 ----------------------------
2717 -- Error_Pragma_Arg_Ident --
2718 ----------------------------
2720 procedure Error_Pragma_Arg_Ident (Msg : String; Arg : Node_Id) is
2721 MsgF : String := Msg;
2723 Error_Msg_Name_1 := Pname;
2725 Error_Msg_N (MsgF, Arg);
2727 end Error_Pragma_Arg_Ident;
2729 ----------------------
2730 -- Error_Pragma_Ref --
2731 ----------------------
2733 procedure Error_Pragma_Ref (Msg : String; Ref : Entity_Id) is
2734 MsgF : String := Msg;
2736 Error_Msg_Name_1 := Pname;
2738 Error_Msg_Sloc := Sloc (Ref);
2739 Error_Msg_NE (MsgF, N, Ref);
2741 end Error_Pragma_Ref;
2743 ------------------------
2744 -- Find_Lib_Unit_Name --
2745 ------------------------
2747 function Find_Lib_Unit_Name return Entity_Id is
2749 -- Return inner compilation unit entity, for case of nested
2750 -- categorization pragmas. This happens in generic unit.
2752 if Nkind (Parent (N)) = N_Package_Specification
2753 and then Defining_Entity (Parent (N)) /= Current_Scope
2755 return Defining_Entity (Parent (N));
2757 return Current_Scope;
2759 end Find_Lib_Unit_Name;
2761 ----------------------------
2762 -- Find_Program_Unit_Name --
2763 ----------------------------
2765 procedure Find_Program_Unit_Name (Id : Node_Id) is
2766 Unit_Name : Entity_Id;
2767 Unit_Kind : Node_Kind;
2768 P : constant Node_Id := Parent (N);
2771 if Nkind (P) = N_Compilation_Unit then
2772 Unit_Kind := Nkind (Unit (P));
2774 if Unit_Kind = N_Subprogram_Declaration
2775 or else Unit_Kind = N_Package_Declaration
2776 or else Unit_Kind in N_Generic_Declaration
2778 Unit_Name := Defining_Entity (Unit (P));
2780 if Chars (Id) = Chars (Unit_Name) then
2781 Set_Entity (Id, Unit_Name);
2782 Set_Etype (Id, Etype (Unit_Name));
2784 Set_Etype (Id, Any_Type);
2786 ("cannot find program unit referenced by pragma%");
2790 Set_Etype (Id, Any_Type);
2791 Error_Pragma ("pragma% inapplicable to this unit");
2797 end Find_Program_Unit_Name;
2799 -----------------------------------------
2800 -- Find_Unique_Parameterless_Procedure --
2801 -----------------------------------------
2803 function Find_Unique_Parameterless_Procedure
2805 Arg : Node_Id) return Entity_Id
2807 Proc : Entity_Id := Empty;
2810 -- The body of this procedure needs some comments ???
2812 if not Is_Entity_Name (Name) then
2814 ("argument of pragma% must be entity name", Arg);
2816 elsif not Is_Overloaded (Name) then
2817 Proc := Entity (Name);
2819 if Ekind (Proc) /= E_Procedure
2820 or else Present (First_Formal (Proc))
2823 ("argument of pragma% must be parameterless procedure", Arg);
2828 Found : Boolean := False;
2830 Index : Interp_Index;
2833 Get_First_Interp (Name, Index, It);
2834 while Present (It.Nam) loop
2837 if Ekind (Proc) = E_Procedure
2838 and then No (First_Formal (Proc))
2842 Set_Entity (Name, Proc);
2843 Set_Is_Overloaded (Name, False);
2846 ("ambiguous handler name for pragma% ", Arg);
2850 Get_Next_Interp (Index, It);
2855 ("argument of pragma% must be parameterless procedure",
2858 Proc := Entity (Name);
2864 end Find_Unique_Parameterless_Procedure;
2870 procedure Fix_Error (Msg : in out String) is
2872 if From_Aspect_Specification (N) then
2873 for J in Msg'First .. Msg'Last - 5 loop
2874 if Msg (J .. J + 5) = "pragma" then
2875 Msg (J .. J + 5) := "aspect";
2879 if Error_Msg_Name_1 = Name_Precondition then
2880 Error_Msg_Name_1 := Name_Pre;
2881 elsif Error_Msg_Name_1 = Name_Postcondition then
2882 Error_Msg_Name_1 := Name_Post;
2887 -------------------------
2888 -- Gather_Associations --
2889 -------------------------
2891 procedure Gather_Associations
2893 Args : out Args_List)
2898 -- Initialize all parameters to Empty
2900 for J in Args'Range loop
2904 -- That's all we have to do if there are no argument associations
2906 if No (Pragma_Argument_Associations (N)) then
2910 -- Otherwise first deal with any positional parameters present
2912 Arg := First (Pragma_Argument_Associations (N));
2913 for Index in Args'Range loop
2914 exit when No (Arg) or else Chars (Arg) /= No_Name;
2915 Args (Index) := Get_Pragma_Arg (Arg);
2919 -- Positional parameters all processed, if any left, then we
2920 -- have too many positional parameters.
2922 if Present (Arg) and then Chars (Arg) = No_Name then
2924 ("too many positional associations for pragma%", Arg);
2927 -- Process named parameters if any are present
2929 while Present (Arg) loop
2930 if Chars (Arg) = No_Name then
2932 ("positional association cannot follow named association",
2936 for Index in Names'Range loop
2937 if Names (Index) = Chars (Arg) then
2938 if Present (Args (Index)) then
2940 ("duplicate argument association for pragma%", Arg);
2942 Args (Index) := Get_Pragma_Arg (Arg);
2947 if Index = Names'Last then
2948 Error_Msg_Name_1 := Pname;
2949 Error_Msg_N ("pragma% does not allow & argument", Arg);
2951 -- Check for possible misspelling
2953 for Index1 in Names'Range loop
2954 if Is_Bad_Spelling_Of
2955 (Chars (Arg), Names (Index1))
2957 Error_Msg_Name_1 := Names (Index1);
2958 Error_Msg_N -- CODEFIX
2959 ("\possible misspelling of%", Arg);
2971 end Gather_Associations;
2977 procedure GNAT_Pragma is
2979 -- We need to check the No_Implementation_Pragmas restriction for
2980 -- the case of a pragma from source. Note that the case of aspects
2981 -- generating corresponding pragmas marks these pragmas as not being
2982 -- from source, so this test also catches that case.
2984 if Comes_From_Source (N) then
2985 Check_Restriction (No_Implementation_Pragmas, N);
2989 --------------------------
2990 -- Is_Before_First_Decl --
2991 --------------------------
2993 function Is_Before_First_Decl
2994 (Pragma_Node : Node_Id;
2995 Decls : List_Id) return Boolean
2997 Item : Node_Id := First (Decls);
3000 -- Only other pragmas can come before this pragma
3003 if No (Item) or else Nkind (Item) /= N_Pragma then
3006 elsif Item = Pragma_Node then
3012 end Is_Before_First_Decl;
3014 -----------------------------
3015 -- Is_Configuration_Pragma --
3016 -----------------------------
3018 -- A configuration pragma must appear in the context clause of a
3019 -- compilation unit, and only other pragmas may precede it. Note that
3020 -- the test below also permits use in a configuration pragma file.
3022 function Is_Configuration_Pragma return Boolean is
3023 Lis : constant List_Id := List_Containing (N);
3024 Par : constant Node_Id := Parent (N);
3028 -- If no parent, then we are in the configuration pragma file,
3029 -- so the placement is definitely appropriate.
3034 -- Otherwise we must be in the context clause of a compilation unit
3035 -- and the only thing allowed before us in the context list is more
3036 -- configuration pragmas.
3038 elsif Nkind (Par) = N_Compilation_Unit
3039 and then Context_Items (Par) = Lis
3046 elsif Nkind (Prg) /= N_Pragma then
3056 end Is_Configuration_Pragma;
3058 --------------------------
3059 -- Is_In_Context_Clause --
3060 --------------------------
3062 function Is_In_Context_Clause return Boolean is
3064 Parent_Node : Node_Id;
3067 if not Is_List_Member (N) then
3071 Plist := List_Containing (N);
3072 Parent_Node := Parent (Plist);
3074 if Parent_Node = Empty
3075 or else Nkind (Parent_Node) /= N_Compilation_Unit
3076 or else Context_Items (Parent_Node) /= Plist
3083 end Is_In_Context_Clause;
3085 ---------------------------------
3086 -- Is_Static_String_Expression --
3087 ---------------------------------
3089 function Is_Static_String_Expression (Arg : Node_Id) return Boolean is
3090 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
3093 Analyze_And_Resolve (Argx);
3094 return Is_OK_Static_Expression (Argx)
3095 and then Nkind (Argx) = N_String_Literal;
3096 end Is_Static_String_Expression;
3098 ----------------------
3099 -- Pragma_Misplaced --
3100 ----------------------
3102 procedure Pragma_Misplaced is
3104 Error_Pragma ("incorrect placement of pragma%");
3105 end Pragma_Misplaced;
3107 ------------------------------------
3108 -- Process_Atomic_Shared_Volatile --
3109 ------------------------------------
3111 procedure Process_Atomic_Shared_Volatile is
3118 procedure Set_Atomic (E : Entity_Id);
3119 -- Set given type as atomic, and if no explicit alignment was given,
3120 -- set alignment to unknown, since back end knows what the alignment
3121 -- requirements are for atomic arrays. Note: this step is necessary
3122 -- for derived types.
3128 procedure Set_Atomic (E : Entity_Id) is
3132 if not Has_Alignment_Clause (E) then
3133 Set_Alignment (E, Uint_0);
3137 -- Start of processing for Process_Atomic_Shared_Volatile
3140 Check_Ada_83_Warning;
3141 Check_No_Identifiers;
3142 Check_Arg_Count (1);
3143 Check_Arg_Is_Local_Name (Arg1);
3144 E_Id := Get_Pragma_Arg (Arg1);
3146 if Etype (E_Id) = Any_Type then
3151 D := Declaration_Node (E);
3154 -- Check duplicate before we chain ourselves!
3156 Check_Duplicate_Pragma (E);
3158 -- Now check appropriateness of the entity
3161 if Rep_Item_Too_Early (E, N)
3163 Rep_Item_Too_Late (E, N)
3167 Check_First_Subtype (Arg1);
3170 if Prag_Id /= Pragma_Volatile then
3172 Set_Atomic (Underlying_Type (E));
3173 Set_Atomic (Base_Type (E));
3176 -- Attribute belongs on the base type. If the view of the type is
3177 -- currently private, it also belongs on the underlying type.
3179 Set_Is_Volatile (Base_Type (E));
3180 Set_Is_Volatile (Underlying_Type (E));
3182 Set_Treat_As_Volatile (E);
3183 Set_Treat_As_Volatile (Underlying_Type (E));
3185 elsif K = N_Object_Declaration
3186 or else (K = N_Component_Declaration
3187 and then Original_Record_Component (E) = E)
3189 if Rep_Item_Too_Late (E, N) then
3193 if Prag_Id /= Pragma_Volatile then
3196 -- If the object declaration has an explicit initialization, a
3197 -- temporary may have to be created to hold the expression, to
3198 -- ensure that access to the object remain atomic.
3200 if Nkind (Parent (E)) = N_Object_Declaration
3201 and then Present (Expression (Parent (E)))
3203 Set_Has_Delayed_Freeze (E);
3206 -- An interesting improvement here. If an object of composite
3207 -- type X is declared atomic, and the type X isn't, that's a
3208 -- pity, since it may not have appropriate alignment etc. We
3209 -- can rescue this in the special case where the object and
3210 -- type are in the same unit by just setting the type as
3211 -- atomic, so that the back end will process it as atomic.
3213 -- Note: we used to do this for elementary types as well,
3214 -- but that turns out to be a bad idea and can have unwanted
3215 -- effects, most notably if the type is elementary, the object
3216 -- a simple component within a record, and both are in a spec:
3217 -- every object of this type in the entire program will be
3218 -- treated as atomic, thus incurring a potentially costly
3219 -- synchronization operation for every access.
3221 -- Of course it would be best if the back end could just adjust
3222 -- the alignment etc for the specific object, but that's not
3223 -- something we are capable of doing at this point.
3225 Utyp := Underlying_Type (Etype (E));
3228 and then Is_Composite_Type (Utyp)
3229 and then Sloc (E) > No_Location
3230 and then Sloc (Utyp) > No_Location
3232 Get_Source_File_Index (Sloc (E)) =
3233 Get_Source_File_Index (Sloc (Underlying_Type (Etype (E))))
3235 Set_Is_Atomic (Underlying_Type (Etype (E)));
3239 Set_Is_Volatile (E);
3240 Set_Treat_As_Volatile (E);
3244 ("inappropriate entity for pragma%", Arg1);
3246 end Process_Atomic_Shared_Volatile;
3248 -------------------------------------------
3249 -- Process_Compile_Time_Warning_Or_Error --
3250 -------------------------------------------
3252 procedure Process_Compile_Time_Warning_Or_Error is
3253 Arg1x : constant Node_Id := Get_Pragma_Arg (Arg1);
3256 Check_Arg_Count (2);
3257 Check_No_Identifiers;
3258 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
3259 Analyze_And_Resolve (Arg1x, Standard_Boolean);
3261 if Compile_Time_Known_Value (Arg1x) then
3262 if Is_True (Expr_Value (Get_Pragma_Arg (Arg1))) then
3264 Str : constant String_Id :=
3265 Strval (Get_Pragma_Arg (Arg2));
3266 Len : constant Int := String_Length (Str);
3271 Cent : constant Entity_Id :=
3272 Cunit_Entity (Current_Sem_Unit);
3274 Force : constant Boolean :=
3275 Prag_Id = Pragma_Compile_Time_Warning
3277 Is_Spec_Name (Unit_Name (Current_Sem_Unit))
3278 and then (Ekind (Cent) /= E_Package
3279 or else not In_Private_Part (Cent));
3280 -- Set True if this is the warning case, and we are in the
3281 -- visible part of a package spec, or in a subprogram spec,
3282 -- in which case we want to force the client to see the
3283 -- warning, even though it is not in the main unit.
3286 -- Loop through segments of message separated by line feeds.
3287 -- We output these segments as separate messages with
3288 -- continuation marks for all but the first.
3293 Error_Msg_Strlen := 0;
3295 -- Loop to copy characters from argument to error message
3299 exit when Ptr > Len;
3300 CC := Get_String_Char (Str, Ptr);
3303 -- Ignore wide chars ??? else store character
3305 if In_Character_Range (CC) then
3306 C := Get_Character (CC);
3307 exit when C = ASCII.LF;
3308 Error_Msg_Strlen := Error_Msg_Strlen + 1;
3309 Error_Msg_String (Error_Msg_Strlen) := C;
3313 -- Here with one line ready to go
3315 Error_Msg_Warn := Prag_Id = Pragma_Compile_Time_Warning;
3317 -- If this is a warning in a spec, then we want clients
3318 -- to see the warning, so mark the message with the
3319 -- special sequence !! to force the warning. In the case
3320 -- of a package spec, we do not force this if we are in
3321 -- the private part of the spec.
3324 if Cont = False then
3325 Error_Msg_N ("<~!!", Arg1);
3328 Error_Msg_N ("\<~!!", Arg1);
3331 -- Error, rather than warning, or in a body, so we do not
3332 -- need to force visibility for client (error will be
3333 -- output in any case, and this is the situation in which
3334 -- we do not want a client to get a warning, since the
3335 -- warning is in the body or the spec private part).
3338 if Cont = False then
3339 Error_Msg_N ("<~", Arg1);
3342 Error_Msg_N ("\<~", Arg1);
3346 exit when Ptr > Len;
3351 end Process_Compile_Time_Warning_Or_Error;
3353 ------------------------
3354 -- Process_Convention --
3355 ------------------------
3357 procedure Process_Convention
3358 (C : out Convention_Id;
3359 Ent : out Entity_Id)
3365 Comp_Unit : Unit_Number_Type;
3367 procedure Diagnose_Multiple_Pragmas (S : Entity_Id);
3368 -- Called if we have more than one Export/Import/Convention pragma.
3369 -- This is generally illegal, but we have a special case of allowing
3370 -- Import and Interface to coexist if they specify the convention in
3371 -- a consistent manner. We are allowed to do this, since Interface is
3372 -- an implementation defined pragma, and we choose to do it since we
3373 -- know Rational allows this combination. S is the entity id of the
3374 -- subprogram in question. This procedure also sets the special flag
3375 -- Import_Interface_Present in both pragmas in the case where we do
3376 -- have matching Import and Interface pragmas.
3378 procedure Set_Convention_From_Pragma (E : Entity_Id);
3379 -- Set convention in entity E, and also flag that the entity has a
3380 -- convention pragma. If entity is for a private or incomplete type,
3381 -- also set convention and flag on underlying type. This procedure
3382 -- also deals with the special case of C_Pass_By_Copy convention.
3384 -------------------------------
3385 -- Diagnose_Multiple_Pragmas --
3386 -------------------------------
3388 procedure Diagnose_Multiple_Pragmas (S : Entity_Id) is
3389 Pdec : constant Node_Id := Declaration_Node (S);
3393 function Same_Convention (Decl : Node_Id) return Boolean;
3394 -- Decl is a pragma node. This function returns True if this
3395 -- pragma has a first argument that is an identifier with a
3396 -- Chars field corresponding to the Convention_Id C.
3398 function Same_Name (Decl : Node_Id) return Boolean;
3399 -- Decl is a pragma node. This function returns True if this
3400 -- pragma has a second argument that is an identifier with a
3401 -- Chars field that matches the Chars of the current subprogram.
3403 ---------------------
3404 -- Same_Convention --
3405 ---------------------
3407 function Same_Convention (Decl : Node_Id) return Boolean is
3408 Arg1 : constant Node_Id :=
3409 First (Pragma_Argument_Associations (Decl));
3412 if Present (Arg1) then
3414 Arg : constant Node_Id := Get_Pragma_Arg (Arg1);
3416 if Nkind (Arg) = N_Identifier
3417 and then Is_Convention_Name (Chars (Arg))
3418 and then Get_Convention_Id (Chars (Arg)) = C
3426 end Same_Convention;
3432 function Same_Name (Decl : Node_Id) return Boolean is
3433 Arg1 : constant Node_Id :=
3434 First (Pragma_Argument_Associations (Decl));
3442 Arg2 := Next (Arg1);
3449 Arg : constant Node_Id := Get_Pragma_Arg (Arg2);
3451 if Nkind (Arg) = N_Identifier
3452 and then Chars (Arg) = Chars (S)
3461 -- Start of processing for Diagnose_Multiple_Pragmas
3466 -- Definitely give message if we have Convention/Export here
3468 if Prag_Id = Pragma_Convention or else Prag_Id = Pragma_Export then
3471 -- If we have an Import or Export, scan back from pragma to
3472 -- find any previous pragma applying to the same procedure.
3473 -- The scan will be terminated by the start of the list, or
3474 -- hitting the subprogram declaration. This won't allow one
3475 -- pragma to appear in the public part and one in the private
3476 -- part, but that seems very unlikely in practice.
3480 while Present (Decl) and then Decl /= Pdec loop
3482 -- Look for pragma with same name as us
3484 if Nkind (Decl) = N_Pragma
3485 and then Same_Name (Decl)
3487 -- Give error if same as our pragma or Export/Convention
3489 if Pragma_Name (Decl) = Name_Export
3491 Pragma_Name (Decl) = Name_Convention
3493 Pragma_Name (Decl) = Pragma_Name (N)
3497 -- Case of Import/Interface or the other way round
3499 elsif Pragma_Name (Decl) = Name_Interface
3501 Pragma_Name (Decl) = Name_Import
3503 -- Here we know that we have Import and Interface. It
3504 -- doesn't matter which way round they are. See if
3505 -- they specify the same convention. If so, all OK,
3506 -- and set special flags to stop other messages
3508 if Same_Convention (Decl) then
3509 Set_Import_Interface_Present (N);
3510 Set_Import_Interface_Present (Decl);
3513 -- If different conventions, special message
3516 Error_Msg_Sloc := Sloc (Decl);
3518 ("convention differs from that given#", Arg1);
3528 -- Give message if needed if we fall through those tests
3529 -- except on Relaxed_RM_Semantics where we let go: either this
3530 -- is a case accepted/ignored by other Ada compilers (e.g.
3531 -- a mix of Convention and Import), or another error will be
3532 -- generated later (e.g. using both Import and Export).
3534 if Err and not Relaxed_RM_Semantics then
3536 ("at most one Convention/Export/Import pragma is allowed",
3539 end Diagnose_Multiple_Pragmas;
3541 --------------------------------
3542 -- Set_Convention_From_Pragma --
3543 --------------------------------
3545 procedure Set_Convention_From_Pragma (E : Entity_Id) is
3547 -- Ada 2005 (AI-430): Check invalid attempt to change convention
3548 -- for an overridden dispatching operation. Technically this is
3549 -- an amendment and should only be done in Ada 2005 mode. However,
3550 -- this is clearly a mistake, since the problem that is addressed
3551 -- by this AI is that there is a clear gap in the RM!
3553 if Is_Dispatching_Operation (E)
3554 and then Present (Overridden_Operation (E))
3555 and then C /= Convention (Overridden_Operation (E))
3558 ("cannot change convention for overridden dispatching "
3559 & "operation", Arg1);
3562 -- Set the convention
3564 Set_Convention (E, C);
3565 Set_Has_Convention_Pragma (E);
3567 if Is_Incomplete_Or_Private_Type (E)
3568 and then Present (Underlying_Type (E))
3570 Set_Convention (Underlying_Type (E), C);
3571 Set_Has_Convention_Pragma (Underlying_Type (E), True);
3574 -- A class-wide type should inherit the convention of the specific
3575 -- root type (although this isn't specified clearly by the RM).
3577 if Is_Type (E) and then Present (Class_Wide_Type (E)) then
3578 Set_Convention (Class_Wide_Type (E), C);
3581 -- If the entity is a record type, then check for special case of
3582 -- C_Pass_By_Copy, which is treated the same as C except that the
3583 -- special record flag is set. This convention is only permitted
3584 -- on record types (see AI95-00131).
3586 if Cname = Name_C_Pass_By_Copy then
3587 if Is_Record_Type (E) then
3588 Set_C_Pass_By_Copy (Base_Type (E));
3589 elsif Is_Incomplete_Or_Private_Type (E)
3590 and then Is_Record_Type (Underlying_Type (E))
3592 Set_C_Pass_By_Copy (Base_Type (Underlying_Type (E)));
3595 ("C_Pass_By_Copy convention allowed only for record type",
3600 -- If the entity is a derived boolean type, check for the special
3601 -- case of convention C, C++, or Fortran, where we consider any
3602 -- nonzero value to represent true.
3604 if Is_Discrete_Type (E)
3605 and then Root_Type (Etype (E)) = Standard_Boolean
3611 C = Convention_Fortran)
3613 Set_Nonzero_Is_True (Base_Type (E));
3615 end Set_Convention_From_Pragma;
3617 -- Start of processing for Process_Convention
3620 Check_At_Least_N_Arguments (2);
3621 Check_Optional_Identifier (Arg1, Name_Convention);
3622 Check_Arg_Is_Identifier (Arg1);
3623 Cname := Chars (Get_Pragma_Arg (Arg1));
3625 -- C_Pass_By_Copy is treated as a synonym for convention C (this is
3626 -- tested again below to set the critical flag).
3628 if Cname = Name_C_Pass_By_Copy then
3631 -- Otherwise we must have something in the standard convention list
3633 elsif Is_Convention_Name (Cname) then
3634 C := Get_Convention_Id (Chars (Get_Pragma_Arg (Arg1)));
3636 -- In DEC VMS, it seems that there is an undocumented feature that
3637 -- any unrecognized convention is treated as the default, which for
3638 -- us is convention C. It does not seem so terrible to do this
3639 -- unconditionally, silently in the VMS case, and with a warning
3640 -- in the non-VMS case.
3643 if Warn_On_Export_Import and not OpenVMS_On_Target then
3645 ("??unrecognized convention name, C assumed",
3646 Get_Pragma_Arg (Arg1));
3652 Check_Optional_Identifier (Arg2, Name_Entity);
3653 Check_Arg_Is_Local_Name (Arg2);
3655 Id := Get_Pragma_Arg (Arg2);
3658 if not Is_Entity_Name (Id) then
3659 Error_Pragma_Arg ("entity name required", Arg2);
3664 -- Set entity to return
3668 -- Ada_Pass_By_Copy special checking
3670 if C = Convention_Ada_Pass_By_Copy then
3671 if not Is_First_Subtype (E) then
3673 ("convention `Ada_Pass_By_Copy` only "
3674 & "allowed for types", Arg2);
3677 if Is_By_Reference_Type (E) then
3679 ("convention `Ada_Pass_By_Copy` not allowed for "
3680 & "by-reference type", Arg1);
3684 -- Ada_Pass_By_Reference special checking
3686 if C = Convention_Ada_Pass_By_Reference then
3687 if not Is_First_Subtype (E) then
3689 ("convention `Ada_Pass_By_Reference` only "
3690 & "allowed for types", Arg2);
3693 if Is_By_Copy_Type (E) then
3695 ("convention `Ada_Pass_By_Reference` not allowed for "
3696 & "by-copy type", Arg1);
3700 -- Go to renamed subprogram if present, since convention applies to
3701 -- the actual renamed entity, not to the renaming entity. If the
3702 -- subprogram is inherited, go to parent subprogram.
3704 if Is_Subprogram (E)
3705 and then Present (Alias (E))
3707 if Nkind (Parent (Declaration_Node (E))) =
3708 N_Subprogram_Renaming_Declaration
3710 if Scope (E) /= Scope (Alias (E)) then
3712 ("cannot apply pragma% to non-local entity&#", E);
3717 elsif Nkind_In (Parent (E), N_Full_Type_Declaration,
3718 N_Private_Extension_Declaration)
3719 and then Scope (E) = Scope (Alias (E))
3723 -- Return the parent subprogram the entity was inherited from
3729 -- Check that we are not applying this to a specless body
3730 -- Relax this check if Relaxed_RM_Semantics to accomodate other Ada
3733 if Is_Subprogram (E)
3734 and then Nkind (Parent (Declaration_Node (E))) = N_Subprogram_Body
3735 and then not Relaxed_RM_Semantics
3738 ("pragma% requires separate spec and must come before body");
3741 -- Check that we are not applying this to a named constant
3743 if Ekind_In (E, E_Named_Integer, E_Named_Real) then
3744 Error_Msg_Name_1 := Pname;
3746 ("cannot apply pragma% to named constant!",
3747 Get_Pragma_Arg (Arg2));
3749 ("\supply appropriate type for&!", Arg2);
3752 if Ekind (E) = E_Enumeration_Literal then
3753 Error_Pragma ("enumeration literal not allowed for pragma%");
3756 -- Check for rep item appearing too early or too late
3758 if Etype (E) = Any_Type
3759 or else Rep_Item_Too_Early (E, N)
3763 elsif Present (Underlying_Type (E)) then
3764 E := Underlying_Type (E);
3767 if Rep_Item_Too_Late (E, N) then
3771 if Has_Convention_Pragma (E) then
3772 Diagnose_Multiple_Pragmas (E);
3774 elsif Convention (E) = Convention_Protected
3775 or else Ekind (Scope (E)) = E_Protected_Type
3778 ("a protected operation cannot be given a different convention",
3782 -- For Intrinsic, a subprogram is required
3784 if C = Convention_Intrinsic
3785 and then not Is_Subprogram (E)
3786 and then not Is_Generic_Subprogram (E)
3789 ("second argument of pragma% must be a subprogram", Arg2);
3794 if C = Convention_Stdcall then
3796 -- A dispatching call is not allowed. A dispatching subprogram
3797 -- cannot be used to interface to the Win32 API, so in fact this
3798 -- check does not impose any effective restriction.
3800 if Is_Dispatching_Operation (E) then
3803 ("dispatching subprograms cannot use Stdcall convention");
3805 -- Subprogram is allowed, but not a generic subprogram, and not a
3806 -- dispatching operation.
3808 elsif not Is_Subprogram (E)
3809 and then not Is_Generic_Subprogram (E)
3813 and then Ekind (E) /= E_Variable
3815 -- An access to subprogram is also allowed
3819 and then Ekind (Designated_Type (E)) = E_Subprogram_Type)
3822 ("second argument of pragma% must be subprogram (type)",
3827 if not Is_Subprogram (E)
3828 and then not Is_Generic_Subprogram (E)
3830 Set_Convention_From_Pragma (E);
3833 Check_First_Subtype (Arg2);
3834 Set_Convention_From_Pragma (Base_Type (E));
3836 -- For subprograms, we must set the convention on the
3837 -- internally generated directly designated type as well.
3839 if Ekind (E) = E_Access_Subprogram_Type then
3840 Set_Convention_From_Pragma (Directly_Designated_Type (E));
3844 -- For the subprogram case, set proper convention for all homonyms
3845 -- in same scope and the same declarative part, i.e. the same
3846 -- compilation unit.
3849 Comp_Unit := Get_Source_Unit (E);
3850 Set_Convention_From_Pragma (E);
3852 -- Treat a pragma Import as an implicit body, and pragma import
3853 -- as implicit reference (for navigation in GPS).
3855 if Prag_Id = Pragma_Import then
3856 Generate_Reference (E, Id, 'b');
3858 -- For exported entities we restrict the generation of references
3859 -- to entities exported to foreign languages since entities
3860 -- exported to Ada do not provide further information to GPS and
3861 -- add undesired references to the output of the gnatxref tool.
3863 elsif Prag_Id = Pragma_Export
3864 and then Convention (E) /= Convention_Ada
3866 Generate_Reference (E, Id, 'i');
3869 -- If the pragma comes from from an aspect, it only applies
3870 -- to the given entity, not its homonyms.
3872 if From_Aspect_Specification (N) then
3876 -- Otherwise Loop through the homonyms of the pragma argument's
3877 -- entity, an apply convention to those in the current scope.
3883 exit when No (E1) or else Scope (E1) /= Current_Scope;
3885 -- Do not set the pragma on inherited operations or on formal
3888 if Comes_From_Source (E1)
3889 and then Comp_Unit = Get_Source_Unit (E1)
3890 and then not Is_Formal_Subprogram (E1)
3891 and then Nkind (Original_Node (Parent (E1))) /=
3892 N_Full_Type_Declaration
3894 if Present (Alias (E1))
3895 and then Scope (E1) /= Scope (Alias (E1))
3898 ("cannot apply pragma% to non-local entity& declared#",
3902 Set_Convention_From_Pragma (E1);
3904 if Prag_Id = Pragma_Import then
3905 Generate_Reference (E1, Id, 'b');
3910 end Process_Convention;
3912 ----------------------------------------
3913 -- Process_Disable_Enable_Atomic_Sync --
3914 ----------------------------------------
3916 procedure Process_Disable_Enable_Atomic_Sync (Nam : Name_Id) is
3919 Check_No_Identifiers;
3920 Check_At_Most_N_Arguments (1);
3922 -- Modeled internally as
3923 -- pragma Suppress/Unsuppress (Atomic_Synchronization [,Entity])
3927 Pragma_Identifier =>
3928 Make_Identifier (Loc, Nam),
3929 Pragma_Argument_Associations => New_List (
3930 Make_Pragma_Argument_Association (Loc,
3932 Make_Identifier (Loc, Name_Atomic_Synchronization)))));
3934 if Present (Arg1) then
3935 Append_To (Pragma_Argument_Associations (N), New_Copy (Arg1));
3939 end Process_Disable_Enable_Atomic_Sync;
3941 -----------------------------------------------------
3942 -- Process_Extended_Import_Export_Exception_Pragma --
3943 -----------------------------------------------------
3945 procedure Process_Extended_Import_Export_Exception_Pragma
3946 (Arg_Internal : Node_Id;
3947 Arg_External : Node_Id;
3955 if not OpenVMS_On_Target then
3957 ("??pragma% ignored (applies only to Open'V'M'S)");
3960 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
3961 Def_Id := Entity (Arg_Internal);
3963 if Ekind (Def_Id) /= E_Exception then
3965 ("pragma% must refer to declared exception", Arg_Internal);
3968 Set_Extended_Import_Export_External_Name (Def_Id, Arg_External);
3970 if Present (Arg_Form) then
3971 Check_Arg_Is_One_Of (Arg_Form, Name_Ada, Name_VMS);
3974 if Present (Arg_Form)
3975 and then Chars (Arg_Form) = Name_Ada
3979 Set_Is_VMS_Exception (Def_Id);
3980 Set_Exception_Code (Def_Id, No_Uint);
3983 if Present (Arg_Code) then
3984 if not Is_VMS_Exception (Def_Id) then
3986 ("Code option for pragma% not allowed for Ada case",
3990 Check_Arg_Is_Static_Expression (Arg_Code, Any_Integer);
3991 Code_Val := Expr_Value (Arg_Code);
3993 if not UI_Is_In_Int_Range (Code_Val) then
3995 ("Code option for pragma% must be in 32-bit range",
3999 Set_Exception_Code (Def_Id, Code_Val);
4002 end Process_Extended_Import_Export_Exception_Pragma;
4004 -------------------------------------------------
4005 -- Process_Extended_Import_Export_Internal_Arg --
4006 -------------------------------------------------
4008 procedure Process_Extended_Import_Export_Internal_Arg
4009 (Arg_Internal : Node_Id := Empty)
4012 if No (Arg_Internal) then
4013 Error_Pragma ("Internal parameter required for pragma%");
4016 if Nkind (Arg_Internal) = N_Identifier then
4019 elsif Nkind (Arg_Internal) = N_Operator_Symbol
4020 and then (Prag_Id = Pragma_Import_Function
4022 Prag_Id = Pragma_Export_Function)
4028 ("wrong form for Internal parameter for pragma%", Arg_Internal);
4031 Check_Arg_Is_Local_Name (Arg_Internal);
4032 end Process_Extended_Import_Export_Internal_Arg;
4034 --------------------------------------------------
4035 -- Process_Extended_Import_Export_Object_Pragma --
4036 --------------------------------------------------
4038 procedure Process_Extended_Import_Export_Object_Pragma
4039 (Arg_Internal : Node_Id;
4040 Arg_External : Node_Id;
4046 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
4047 Def_Id := Entity (Arg_Internal);
4049 if not Ekind_In (Def_Id, E_Constant, E_Variable) then
4051 ("pragma% must designate an object", Arg_Internal);
4054 if Has_Rep_Pragma (Def_Id, Name_Common_Object)
4056 Has_Rep_Pragma (Def_Id, Name_Psect_Object)
4059 ("previous Common/Psect_Object applies, pragma % not permitted",
4063 if Rep_Item_Too_Late (Def_Id, N) then
4067 Set_Extended_Import_Export_External_Name (Def_Id, Arg_External);
4069 if Present (Arg_Size) then
4070 Check_Arg_Is_External_Name (Arg_Size);
4073 -- Export_Object case
4075 if Prag_Id = Pragma_Export_Object then
4076 if not Is_Library_Level_Entity (Def_Id) then
4078 ("argument for pragma% must be library level entity",
4082 if Ekind (Current_Scope) = E_Generic_Package then
4083 Error_Pragma ("pragma& cannot appear in a generic unit");
4086 if not Size_Known_At_Compile_Time (Etype (Def_Id)) then
4088 ("exported object must have compile time known size",
4092 if Warn_On_Export_Import and then Is_Exported (Def_Id) then
4093 Error_Msg_N ("??duplicate Export_Object pragma", N);
4095 Set_Exported (Def_Id, Arg_Internal);
4098 -- Import_Object case
4101 if Is_Concurrent_Type (Etype (Def_Id)) then
4103 ("cannot use pragma% for task/protected object",
4107 if Ekind (Def_Id) = E_Constant then
4109 ("cannot import a constant", Arg_Internal);
4112 if Warn_On_Export_Import
4113 and then Has_Discriminants (Etype (Def_Id))
4116 ("imported value must be initialized??", Arg_Internal);
4119 if Warn_On_Export_Import
4120 and then Is_Access_Type (Etype (Def_Id))
4123 ("cannot import object of an access type??", Arg_Internal);
4126 if Warn_On_Export_Import
4127 and then Is_Imported (Def_Id)
4129 Error_Msg_N ("??duplicate Import_Object pragma", N);
4131 -- Check for explicit initialization present. Note that an
4132 -- initialization generated by the code generator, e.g. for an
4133 -- access type, does not count here.
4135 elsif Present (Expression (Parent (Def_Id)))
4138 (Original_Node (Expression (Parent (Def_Id))))
4140 Error_Msg_Sloc := Sloc (Def_Id);
4142 ("imported entities cannot be initialized (RM B.1(24))",
4143 "\no initialization allowed for & declared#", Arg1);
4145 Set_Imported (Def_Id);
4146 Note_Possible_Modification (Arg_Internal, Sure => False);
4149 end Process_Extended_Import_Export_Object_Pragma;
4151 ------------------------------------------------------
4152 -- Process_Extended_Import_Export_Subprogram_Pragma --
4153 ------------------------------------------------------
4155 procedure Process_Extended_Import_Export_Subprogram_Pragma
4156 (Arg_Internal : Node_Id;
4157 Arg_External : Node_Id;
4158 Arg_Parameter_Types : Node_Id;
4159 Arg_Result_Type : Node_Id := Empty;
4160 Arg_Mechanism : Node_Id;
4161 Arg_Result_Mechanism : Node_Id := Empty;
4162 Arg_First_Optional_Parameter : Node_Id := Empty)
4168 Ambiguous : Boolean;
4172 function Same_Base_Type
4174 Formal : Entity_Id) return Boolean;
4175 -- Determines if Ptype references the type of Formal. Note that only
4176 -- the base types need to match according to the spec. Ptype here is
4177 -- the argument from the pragma, which is either a type name, or an
4178 -- access attribute.
4180 --------------------
4181 -- Same_Base_Type --
4182 --------------------
4184 function Same_Base_Type
4186 Formal : Entity_Id) return Boolean
4188 Ftyp : constant Entity_Id := Base_Type (Etype (Formal));
4192 -- Case where pragma argument is typ'Access
4194 if Nkind (Ptype) = N_Attribute_Reference
4195 and then Attribute_Name (Ptype) = Name_Access
4197 Pref := Prefix (Ptype);
4200 if not Is_Entity_Name (Pref)
4201 or else Entity (Pref) = Any_Type
4206 -- We have a match if the corresponding argument is of an
4207 -- anonymous access type, and its designated type matches the
4208 -- type of the prefix of the access attribute
4210 return Ekind (Ftyp) = E_Anonymous_Access_Type
4211 and then Base_Type (Entity (Pref)) =
4212 Base_Type (Etype (Designated_Type (Ftyp)));
4214 -- Case where pragma argument is a type name
4219 if not Is_Entity_Name (Ptype)
4220 or else Entity (Ptype) = Any_Type
4225 -- We have a match if the corresponding argument is of the type
4226 -- given in the pragma (comparing base types)
4228 return Base_Type (Entity (Ptype)) = Ftyp;
4232 -- Start of processing for
4233 -- Process_Extended_Import_Export_Subprogram_Pragma
4236 Process_Extended_Import_Export_Internal_Arg (Arg_Internal);
4240 -- Loop through homonyms (overloadings) of the entity
4242 Hom_Id := Entity (Arg_Internal);
4243 while Present (Hom_Id) loop
4244 Def_Id := Get_Base_Subprogram (Hom_Id);
4246 -- We need a subprogram in the current scope
4248 if not Is_Subprogram (Def_Id)
4249 or else Scope (Def_Id) /= Current_Scope
4256 -- Pragma cannot apply to subprogram body
4258 if Is_Subprogram (Def_Id)
4259 and then Nkind (Parent (Declaration_Node (Def_Id))) =
4263 ("pragma% requires separate spec"
4264 & " and must come before body");
4267 -- Test result type if given, note that the result type
4268 -- parameter can only be present for the function cases.
4270 if Present (Arg_Result_Type)
4271 and then not Same_Base_Type (Arg_Result_Type, Def_Id)
4275 elsif Etype (Def_Id) /= Standard_Void_Type
4277 (Pname = Name_Export_Procedure
4279 Pname = Name_Import_Procedure)
4283 -- Test parameter types if given. Note that this parameter
4284 -- has not been analyzed (and must not be, since it is
4285 -- semantic nonsense), so we get it as the parser left it.
4287 elsif Present (Arg_Parameter_Types) then
4288 Check_Matching_Types : declare
4293 Formal := First_Formal (Def_Id);
4295 if Nkind (Arg_Parameter_Types) = N_Null then
4296 if Present (Formal) then
4300 -- A list of one type, e.g. (List) is parsed as
4301 -- a parenthesized expression.
4303 elsif Nkind (Arg_Parameter_Types) /= N_Aggregate
4304 and then Paren_Count (Arg_Parameter_Types) = 1
4307 or else Present (Next_Formal (Formal))
4312 Same_Base_Type (Arg_Parameter_Types, Formal);
4315 -- A list of more than one type is parsed as a aggregate
4317 elsif Nkind (Arg_Parameter_Types) = N_Aggregate
4318 and then Paren_Count (Arg_Parameter_Types) = 0
4320 Ptype := First (Expressions (Arg_Parameter_Types));
4321 while Present (Ptype) or else Present (Formal) loop
4324 or else not Same_Base_Type (Ptype, Formal)
4329 Next_Formal (Formal);
4334 -- Anything else is of the wrong form
4338 ("wrong form for Parameter_Types parameter",
4339 Arg_Parameter_Types);
4341 end Check_Matching_Types;
4344 -- Match is now False if the entry we found did not match
4345 -- either a supplied Parameter_Types or Result_Types argument
4351 -- Ambiguous case, the flag Ambiguous shows if we already
4352 -- detected this and output the initial messages.
4355 if not Ambiguous then
4357 Error_Msg_Name_1 := Pname;
4359 ("pragma% does not uniquely identify subprogram!",
4361 Error_Msg_Sloc := Sloc (Ent);
4362 Error_Msg_N ("matching subprogram #!", N);
4366 Error_Msg_Sloc := Sloc (Def_Id);
4367 Error_Msg_N ("matching subprogram #!", N);
4372 Hom_Id := Homonym (Hom_Id);
4375 -- See if we found an entry
4378 if not Ambiguous then
4379 if Is_Generic_Subprogram (Entity (Arg_Internal)) then
4381 ("pragma% cannot be given for generic subprogram");
4384 ("pragma% does not identify local subprogram");
4391 -- Import pragmas must be for imported entities
4393 if Prag_Id = Pragma_Import_Function
4395 Prag_Id = Pragma_Import_Procedure
4397 Prag_Id = Pragma_Import_Valued_Procedure
4399 if not Is_Imported (Ent) then
4401 ("pragma Import or Interface must precede pragma%");
4404 -- Here we have the Export case which can set the entity as exported
4406 -- But does not do so if the specified external name is null, since
4407 -- that is taken as a signal in DEC Ada 83 (with which we want to be
4408 -- compatible) to request no external name.
4410 elsif Nkind (Arg_External) = N_String_Literal
4411 and then String_Length (Strval (Arg_External)) = 0
4415 -- In all other cases, set entity as exported
4418 Set_Exported (Ent, Arg_Internal);
4421 -- Special processing for Valued_Procedure cases
4423 if Prag_Id = Pragma_Import_Valued_Procedure
4425 Prag_Id = Pragma_Export_Valued_Procedure
4427 Formal := First_Formal (Ent);
4430 Error_Pragma ("at least one parameter required for pragma%");
4432 elsif Ekind (Formal) /= E_Out_Parameter then
4433 Error_Pragma ("first parameter must have mode out for pragma%");
4436 Set_Is_Valued_Procedure (Ent);
4440 Set_Extended_Import_Export_External_Name (Ent, Arg_External);
4442 -- Process Result_Mechanism argument if present. We have already
4443 -- checked that this is only allowed for the function case.
4445 if Present (Arg_Result_Mechanism) then
4446 Set_Mechanism_Value (Ent, Arg_Result_Mechanism);
4449 -- Process Mechanism parameter if present. Note that this parameter
4450 -- is not analyzed, and must not be analyzed since it is semantic
4451 -- nonsense, so we get it in exactly as the parser left it.
4453 if Present (Arg_Mechanism) then
4461 -- A single mechanism association without a formal parameter
4462 -- name is parsed as a parenthesized expression. All other
4463 -- cases are parsed as aggregates, so we rewrite the single
4464 -- parameter case as an aggregate for consistency.
4466 if Nkind (Arg_Mechanism) /= N_Aggregate
4467 and then Paren_Count (Arg_Mechanism) = 1
4469 Rewrite (Arg_Mechanism,
4470 Make_Aggregate (Sloc (Arg_Mechanism),
4471 Expressions => New_List (
4472 Relocate_Node (Arg_Mechanism))));
4475 -- Case of only mechanism name given, applies to all formals
4477 if Nkind (Arg_Mechanism) /= N_Aggregate then
4478 Formal := First_Formal (Ent);
4479 while Present (Formal) loop
4480 Set_Mechanism_Value (Formal, Arg_Mechanism);
4481 Next_Formal (Formal);
4484 -- Case of list of mechanism associations given
4487 if Null_Record_Present (Arg_Mechanism) then
4489 ("inappropriate form for Mechanism parameter",
4493 -- Deal with positional ones first
4495 Formal := First_Formal (Ent);
4497 if Present (Expressions (Arg_Mechanism)) then
4498 Mname := First (Expressions (Arg_Mechanism));
4499 while Present (Mname) loop
4502 ("too many mechanism associations", Mname);
4505 Set_Mechanism_Value (Formal, Mname);
4506 Next_Formal (Formal);
4511 -- Deal with named entries
4513 if Present (Component_Associations (Arg_Mechanism)) then
4514 Massoc := First (Component_Associations (Arg_Mechanism));
4515 while Present (Massoc) loop
4516 Choice := First (Choices (Massoc));
4518 if Nkind (Choice) /= N_Identifier
4519 or else Present (Next (Choice))
4522 ("incorrect form for mechanism association",
4526 Formal := First_Formal (Ent);
4530 ("parameter name & not present", Choice);
4533 if Chars (Choice) = Chars (Formal) then
4535 (Formal, Expression (Massoc));
4537 -- Set entity on identifier (needed by ASIS)
4539 Set_Entity (Choice, Formal);
4544 Next_Formal (Formal);
4554 -- Process First_Optional_Parameter argument if present. We have
4555 -- already checked that this is only allowed for the Import case.
4557 if Present (Arg_First_Optional_Parameter) then
4558 if Nkind (Arg_First_Optional_Parameter) /= N_Identifier then
4560 ("first optional parameter must be formal parameter name",
4561 Arg_First_Optional_Parameter);
4564 Formal := First_Formal (Ent);
4568 ("specified formal parameter& not found",
4569 Arg_First_Optional_Parameter);
4572 exit when Chars (Formal) =
4573 Chars (Arg_First_Optional_Parameter);
4575 Next_Formal (Formal);
4578 Set_First_Optional_Parameter (Ent, Formal);
4580 -- Check specified and all remaining formals have right form
4582 while Present (Formal) loop
4583 if Ekind (Formal) /= E_In_Parameter then
4585 ("optional formal& is not of mode in!",
4586 Arg_First_Optional_Parameter, Formal);
4589 Dval := Default_Value (Formal);
4593 ("optional formal& does not have default value!",
4594 Arg_First_Optional_Parameter, Formal);
4596 elsif Compile_Time_Known_Value_Or_Aggr (Dval) then
4601 ("default value for optional formal& is non-static!",
4602 Arg_First_Optional_Parameter, Formal);
4606 Set_Is_Optional_Parameter (Formal);
4607 Next_Formal (Formal);
4610 end Process_Extended_Import_Export_Subprogram_Pragma;
4612 --------------------------
4613 -- Process_Generic_List --
4614 --------------------------
4616 procedure Process_Generic_List is
4621 Check_No_Identifiers;
4622 Check_At_Least_N_Arguments (1);
4625 while Present (Arg) loop
4626 Exp := Get_Pragma_Arg (Arg);
4629 if not Is_Entity_Name (Exp)
4631 (not Is_Generic_Instance (Entity (Exp))
4633 not Is_Generic_Unit (Entity (Exp)))
4636 ("pragma% argument must be name of generic unit/instance",
4642 end Process_Generic_List;
4644 ------------------------------------
4645 -- Process_Import_Predefined_Type --
4646 ------------------------------------
4648 procedure Process_Import_Predefined_Type is
4649 Loc : constant Source_Ptr := Sloc (N);
4651 Ftyp : Node_Id := Empty;
4657 String_To_Name_Buffer (Strval (Expression (Arg3)));
4660 Elmt := First_Elmt (Predefined_Float_Types);
4661 while Present (Elmt) and then Chars (Node (Elmt)) /= Nam loop
4665 Ftyp := Node (Elmt);
4667 if Present (Ftyp) then
4669 -- Don't build a derived type declaration, because predefined C
4670 -- types have no declaration anywhere, so cannot really be named.
4671 -- Instead build a full type declaration, starting with an
4672 -- appropriate type definition is built
4674 if Is_Floating_Point_Type (Ftyp) then
4675 Def := Make_Floating_Point_Definition (Loc,
4676 Make_Integer_Literal (Loc, Digits_Value (Ftyp)),
4677 Make_Real_Range_Specification (Loc,
4678 Make_Real_Literal (Loc, Realval (Type_Low_Bound (Ftyp))),
4679 Make_Real_Literal (Loc, Realval (Type_High_Bound (Ftyp)))));
4681 -- Should never have a predefined type we cannot handle
4684 raise Program_Error;
4687 -- Build and insert a Full_Type_Declaration, which will be
4688 -- analyzed as soon as this list entry has been analyzed.
4690 Decl := Make_Full_Type_Declaration (Loc,
4691 Make_Defining_Identifier (Loc, Chars (Expression (Arg2))),
4692 Type_Definition => Def);
4694 Insert_After (N, Decl);
4695 Mark_Rewrite_Insertion (Decl);
4698 Error_Pragma_Arg ("no matching type found for pragma%",
4701 end Process_Import_Predefined_Type;
4703 ---------------------------------
4704 -- Process_Import_Or_Interface --
4705 ---------------------------------
4707 procedure Process_Import_Or_Interface is
4713 Process_Convention (C, Def_Id);
4714 Kill_Size_Check_Code (Def_Id);
4715 Note_Possible_Modification (Get_Pragma_Arg (Arg2), Sure => False);
4717 if Ekind_In (Def_Id, E_Variable, E_Constant) then
4719 -- We do not permit Import to apply to a renaming declaration
4721 if Present (Renamed_Object (Def_Id)) then
4723 ("pragma% not allowed for object renaming", Arg2);
4725 -- User initialization is not allowed for imported object, but
4726 -- the object declaration may contain a default initialization,
4727 -- that will be discarded. Note that an explicit initialization
4728 -- only counts if it comes from source, otherwise it is simply
4729 -- the code generator making an implicit initialization explicit.
4731 elsif Present (Expression (Parent (Def_Id)))
4732 and then Comes_From_Source (Expression (Parent (Def_Id)))
4734 Error_Msg_Sloc := Sloc (Def_Id);
4736 ("no initialization allowed for declaration of& #",
4737 "\imported entities cannot be initialized (RM B.1(24))",
4741 Set_Imported (Def_Id);
4742 Process_Interface_Name (Def_Id, Arg3, Arg4);
4744 -- Note that we do not set Is_Public here. That's because we
4745 -- only want to set it if there is no address clause, and we
4746 -- don't know that yet, so we delay that processing till
4749 -- pragma Import completes deferred constants
4751 if Ekind (Def_Id) = E_Constant then
4752 Set_Has_Completion (Def_Id);
4755 -- It is not possible to import a constant of an unconstrained
4756 -- array type (e.g. string) because there is no simple way to
4757 -- write a meaningful subtype for it.
4759 if Is_Array_Type (Etype (Def_Id))
4760 and then not Is_Constrained (Etype (Def_Id))
4763 ("imported constant& must have a constrained subtype",
4768 elsif Is_Subprogram (Def_Id)
4769 or else Is_Generic_Subprogram (Def_Id)
4771 -- If the name is overloaded, pragma applies to all of the denoted
4772 -- entities in the same declarative part, unless the pragma comes
4773 -- from an aspect specification.
4776 while Present (Hom_Id) loop
4778 Def_Id := Get_Base_Subprogram (Hom_Id);
4780 -- Ignore inherited subprograms because the pragma will apply
4781 -- to the parent operation, which is the one called.
4783 if Is_Overloadable (Def_Id)
4784 and then Present (Alias (Def_Id))
4788 -- If it is not a subprogram, it must be in an outer scope and
4789 -- pragma does not apply.
4791 elsif not Is_Subprogram (Def_Id)
4792 and then not Is_Generic_Subprogram (Def_Id)
4796 -- The pragma does not apply to primitives of interfaces
4798 elsif Is_Dispatching_Operation (Def_Id)
4799 and then Present (Find_Dispatching_Type (Def_Id))
4800 and then Is_Interface (Find_Dispatching_Type (Def_Id))
4804 -- Verify that the homonym is in the same declarative part (not
4805 -- just the same scope). If the pragma comes from an aspect
4806 -- specification we know that it is part of the declaration.
4808 elsif Parent (Unit_Declaration_Node (Def_Id)) /= Parent (N)
4809 and then Nkind (Parent (N)) /= N_Compilation_Unit_Aux
4810 and then not From_Aspect_Specification (N)
4815 Set_Imported (Def_Id);
4817 -- Reject an Import applied to an abstract subprogram
4819 if Is_Subprogram (Def_Id)
4820 and then Is_Abstract_Subprogram (Def_Id)
4822 Error_Msg_Sloc := Sloc (Def_Id);
4824 ("cannot import abstract subprogram& declared#",
4828 -- Special processing for Convention_Intrinsic
4830 if C = Convention_Intrinsic then
4832 -- Link_Name argument not allowed for intrinsic
4836 Set_Is_Intrinsic_Subprogram (Def_Id);
4838 -- If no external name is present, then check that this
4839 -- is a valid intrinsic subprogram. If an external name
4840 -- is present, then this is handled by the back end.
4843 Check_Intrinsic_Subprogram
4844 (Def_Id, Get_Pragma_Arg (Arg2));
4848 -- All interfaced procedures need an external symbol created
4849 -- for them since they are always referenced from another
4852 Set_Is_Public (Def_Id);
4854 -- Verify that the subprogram does not have a completion
4855 -- through a renaming declaration. For other completions the
4856 -- pragma appears as a too late representation.
4859 Decl : constant Node_Id := Unit_Declaration_Node (Def_Id);
4863 and then Nkind (Decl) = N_Subprogram_Declaration
4864 and then Present (Corresponding_Body (Decl))
4865 and then Nkind (Unit_Declaration_Node
4866 (Corresponding_Body (Decl))) =
4867 N_Subprogram_Renaming_Declaration
4869 Error_Msg_Sloc := Sloc (Def_Id);
4871 ("cannot import&, renaming already provided for "
4872 & "declaration #", N, Def_Id);
4876 Set_Has_Completion (Def_Id);
4877 Process_Interface_Name (Def_Id, Arg3, Arg4);
4880 if Is_Compilation_Unit (Hom_Id) then
4882 -- Its possible homonyms are not affected by the pragma.
4883 -- Such homonyms might be present in the context of other
4884 -- units being compiled.
4888 elsif From_Aspect_Specification (N) then
4892 Hom_Id := Homonym (Hom_Id);
4896 -- When the convention is Java or CIL, we also allow Import to be
4897 -- given for packages, generic packages, exceptions, record
4898 -- components, and access to subprograms.
4900 elsif (C = Convention_Java or else C = Convention_CIL)
4902 (Is_Package_Or_Generic_Package (Def_Id)
4903 or else Ekind (Def_Id) = E_Exception
4904 or else Ekind (Def_Id) = E_Access_Subprogram_Type
4905 or else Nkind (Parent (Def_Id)) = N_Component_Declaration)
4907 Set_Imported (Def_Id);
4908 Set_Is_Public (Def_Id);
4909 Process_Interface_Name (Def_Id, Arg3, Arg4);
4911 -- Import a CPP class
4913 elsif C = Convention_CPP
4914 and then (Is_Record_Type (Def_Id)
4915 or else Ekind (Def_Id) = E_Incomplete_Type)
4917 if Ekind (Def_Id) = E_Incomplete_Type then
4918 if Present (Full_View (Def_Id)) then
4919 Def_Id := Full_View (Def_Id);
4923 ("cannot import 'C'P'P type before full declaration seen",
4924 Get_Pragma_Arg (Arg2));
4926 -- Although we have reported the error we decorate it as
4927 -- CPP_Class to avoid reporting spurious errors
4929 Set_Is_CPP_Class (Def_Id);
4934 -- Types treated as CPP classes must be declared limited (note:
4935 -- this used to be a warning but there is no real benefit to it
4936 -- since we did effectively intend to treat the type as limited
4939 if not Is_Limited_Type (Def_Id) then
4941 ("imported 'C'P'P type must be limited",
4942 Get_Pragma_Arg (Arg2));
4945 if Etype (Def_Id) /= Def_Id
4946 and then not Is_CPP_Class (Root_Type (Def_Id))
4948 Error_Msg_N ("root type must be a 'C'P'P type", Arg1);
4951 Set_Is_CPP_Class (Def_Id);
4953 -- Imported CPP types must not have discriminants (because C++
4954 -- classes do not have discriminants).
4956 if Has_Discriminants (Def_Id) then
4958 ("imported 'C'P'P type cannot have discriminants",
4959 First (Discriminant_Specifications
4960 (Declaration_Node (Def_Id))));
4963 -- Check that components of imported CPP types do not have default
4964 -- expressions. For private types this check is performed when the
4965 -- full view is analyzed (see Process_Full_View).
4967 if not Is_Private_Type (Def_Id) then
4968 Check_CPP_Type_Has_No_Defaults (Def_Id);
4971 elsif Nkind (Parent (Def_Id)) = N_Incomplete_Type_Declaration then
4973 Check_Arg_Count (3);
4974 Check_Arg_Is_Static_Expression (Arg3, Standard_String);
4976 Process_Import_Predefined_Type;
4980 ("second argument of pragma% must be object, subprogram "
4981 & "or incomplete type",
4985 -- If this pragma applies to a compilation unit, then the unit, which
4986 -- is a subprogram, does not require (or allow) a body. We also do
4987 -- not need to elaborate imported procedures.
4989 if Nkind (Parent (N)) = N_Compilation_Unit_Aux then
4991 Cunit : constant Node_Id := Parent (Parent (N));
4993 Set_Body_Required (Cunit, False);
4996 end Process_Import_Or_Interface;
4998 --------------------
4999 -- Process_Inline --
5000 --------------------
5002 procedure Process_Inline (Status : Inline_Status) is
5009 Effective : Boolean := False;
5010 -- Set True if inline has some effect, i.e. if there is at least one
5011 -- subprogram set as inlined as a result of the use of the pragma.
5013 procedure Make_Inline (Subp : Entity_Id);
5014 -- Subp is the defining unit name of the subprogram declaration. Set
5015 -- the flag, as well as the flag in the corresponding body, if there
5018 procedure Set_Inline_Flags (Subp : Entity_Id);
5019 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp and also
5020 -- Has_Pragma_Inline_Always for the Inline_Always case.
5022 function Inlining_Not_Possible (Subp : Entity_Id) return Boolean;
5023 -- Returns True if it can be determined at this stage that inlining
5024 -- is not possible, for example if the body is available and contains
5025 -- exception handlers, we prevent inlining, since otherwise we can
5026 -- get undefined symbols at link time. This function also emits a
5027 -- warning if front-end inlining is enabled and the pragma appears
5030 -- ??? is business with link symbols still valid, or does it relate
5031 -- to front end ZCX which is being phased out ???
5033 ---------------------------
5034 -- Inlining_Not_Possible --
5035 ---------------------------
5037 function Inlining_Not_Possible (Subp : Entity_Id) return Boolean is
5038 Decl : constant Node_Id := Unit_Declaration_Node (Subp);
5042 if Nkind (Decl) = N_Subprogram_Body then
5043 Stats := Handled_Statement_Sequence (Decl);
5044 return Present (Exception_Handlers (Stats))
5045 or else Present (At_End_Proc (Stats));
5047 elsif Nkind (Decl) = N_Subprogram_Declaration
5048 and then Present (Corresponding_Body (Decl))
5050 if Front_End_Inlining
5051 and then Analyzed (Corresponding_Body (Decl))
5053 Error_Msg_N ("pragma appears too late, ignored??", N);
5056 -- If the subprogram is a renaming as body, the body is just a
5057 -- call to the renamed subprogram, and inlining is trivially
5061 Nkind (Unit_Declaration_Node (Corresponding_Body (Decl))) =
5062 N_Subprogram_Renaming_Declaration
5068 Handled_Statement_Sequence
5069 (Unit_Declaration_Node (Corresponding_Body (Decl)));
5072 Present (Exception_Handlers (Stats))
5073 or else Present (At_End_Proc (Stats));
5077 -- If body is not available, assume the best, the check is
5078 -- performed again when compiling enclosing package bodies.
5082 end Inlining_Not_Possible;
5088 procedure Make_Inline (Subp : Entity_Id) is
5089 Kind : constant Entity_Kind := Ekind (Subp);
5090 Inner_Subp : Entity_Id := Subp;
5093 -- Ignore if bad type, avoid cascaded error
5095 if Etype (Subp) = Any_Type then
5099 -- Ignore if all inlining is suppressed
5101 elsif Suppress_All_Inlining then
5105 -- If inlining is not possible, for now do not treat as an error
5107 elsif Status /= Suppressed
5108 and then Inlining_Not_Possible (Subp)
5113 -- Here we have a candidate for inlining, but we must exclude
5114 -- derived operations. Otherwise we would end up trying to inline
5115 -- a phantom declaration, and the result would be to drag in a
5116 -- body which has no direct inlining associated with it. That
5117 -- would not only be inefficient but would also result in the
5118 -- backend doing cross-unit inlining in cases where it was
5119 -- definitely inappropriate to do so.
5121 -- However, a simple Comes_From_Source test is insufficient, since
5122 -- we do want to allow inlining of generic instances which also do
5123 -- not come from source. We also need to recognize specs generated
5124 -- by the front-end for bodies that carry the pragma. Finally,
5125 -- predefined operators do not come from source but are not
5126 -- inlineable either.
5128 elsif Is_Generic_Instance (Subp)
5129 or else Nkind (Parent (Parent (Subp))) = N_Subprogram_Declaration
5133 elsif not Comes_From_Source (Subp)
5134 and then Scope (Subp) /= Standard_Standard
5140 -- The referenced entity must either be the enclosing entity, or
5141 -- an entity declared within the current open scope.
5143 if Present (Scope (Subp))
5144 and then Scope (Subp) /= Current_Scope
5145 and then Subp /= Current_Scope
5148 ("argument of% must be entity in current scope", Assoc);
5152 -- Processing for procedure, operator or function. If subprogram
5153 -- is aliased (as for an instance) indicate that the renamed
5154 -- entity (if declared in the same unit) is inlined.
5156 if Is_Subprogram (Subp) then
5157 Inner_Subp := Ultimate_Alias (Inner_Subp);
5159 if In_Same_Source_Unit (Subp, Inner_Subp) then
5160 Set_Inline_Flags (Inner_Subp);
5162 Decl := Parent (Parent (Inner_Subp));
5164 if Nkind (Decl) = N_Subprogram_Declaration
5165 and then Present (Corresponding_Body (Decl))
5167 Set_Inline_Flags (Corresponding_Body (Decl));
5169 elsif Is_Generic_Instance (Subp) then
5171 -- Indicate that the body needs to be created for
5172 -- inlining subsequent calls. The instantiation node
5173 -- follows the declaration of the wrapper package
5176 if Scope (Subp) /= Standard_Standard
5178 Need_Subprogram_Instance_Body
5179 (Next (Unit_Declaration_Node (Scope (Alias (Subp)))),
5185 -- Inline is a program unit pragma (RM 10.1.5) and cannot
5186 -- appear in a formal part to apply to a formal subprogram.
5187 -- Do not apply check within an instance or a formal package
5188 -- the test will have been applied to the original generic.
5190 elsif Nkind (Decl) in N_Formal_Subprogram_Declaration
5191 and then List_Containing (Decl) = List_Containing (N)
5192 and then not In_Instance
5195 ("Inline cannot apply to a formal subprogram", N);
5197 -- If Subp is a renaming, it is the renamed entity that
5198 -- will appear in any call, and be inlined. However, for
5199 -- ASIS uses it is convenient to indicate that the renaming
5200 -- itself is an inlined subprogram, so that some gnatcheck
5201 -- rules can be applied in the absence of expansion.
5203 elsif Nkind (Decl) = N_Subprogram_Renaming_Declaration then
5204 Set_Inline_Flags (Subp);
5210 -- For a generic subprogram set flag as well, for use at the point
5211 -- of instantiation, to determine whether the body should be
5214 elsif Is_Generic_Subprogram (Subp) then
5215 Set_Inline_Flags (Subp);
5218 -- Literals are by definition inlined
5220 elsif Kind = E_Enumeration_Literal then
5223 -- Anything else is an error
5227 ("expect subprogram name for pragma%", Assoc);
5231 ----------------------
5232 -- Set_Inline_Flags --
5233 ----------------------
5235 procedure Set_Inline_Flags (Subp : Entity_Id) is
5237 -- First set the Has_Pragma_XXX flags and issue the appropriate
5238 -- errors and warnings for suspicious combinations.
5240 if Prag_Id = Pragma_No_Inline then
5241 if Has_Pragma_Inline_Always (Subp) then
5243 ("Inline_Always and No_Inline are mutually exclusive", N);
5244 elsif Has_Pragma_Inline (Subp) then
5246 ("Inline and No_Inline both specified for& ??",
5247 N, Entity (Subp_Id));
5250 Set_Has_Pragma_No_Inline (Subp);
5252 if Prag_Id = Pragma_Inline_Always then
5253 if Has_Pragma_No_Inline (Subp) then
5255 ("Inline_Always and No_Inline are mutually exclusive",
5259 Set_Has_Pragma_Inline_Always (Subp);
5261 if Has_Pragma_No_Inline (Subp) then
5263 ("Inline and No_Inline both specified for& ??",
5264 N, Entity (Subp_Id));
5268 if not Has_Pragma_Inline (Subp) then
5269 Set_Has_Pragma_Inline (Subp);
5274 -- Then adjust the Is_Inlined flag. It can never be set if the
5275 -- subprogram is subject to pragma No_Inline.
5279 Set_Is_Inlined (Subp, False);
5283 if not Has_Pragma_No_Inline (Subp) then
5284 Set_Is_Inlined (Subp, True);
5287 end Set_Inline_Flags;
5289 -- Start of processing for Process_Inline
5292 Check_No_Identifiers;
5293 Check_At_Least_N_Arguments (1);
5295 if Status = Enabled then
5296 Inline_Processing_Required := True;
5300 while Present (Assoc) loop
5301 Subp_Id := Get_Pragma_Arg (Assoc);
5305 if Is_Entity_Name (Subp_Id) then
5306 Subp := Entity (Subp_Id);
5308 if Subp = Any_Id then
5310 -- If previous error, avoid cascaded errors
5312 Check_Error_Detected;
5319 -- For the pragma case, climb homonym chain. This is
5320 -- what implements allowing the pragma in the renaming
5321 -- case, with the result applying to the ancestors, and
5322 -- also allows Inline to apply to all previous homonyms.
5324 if not From_Aspect_Specification (N) then
5325 while Present (Homonym (Subp))
5326 and then Scope (Homonym (Subp)) = Current_Scope
5328 Make_Inline (Homonym (Subp));
5329 Subp := Homonym (Subp);
5337 ("inappropriate argument for pragma%", Assoc);
5340 and then Warn_On_Redundant_Constructs
5341 and then not (Status = Suppressed or else Suppress_All_Inlining)
5343 if Inlining_Not_Possible (Subp) then
5345 ("pragma Inline for& is ignored?r?",
5346 N, Entity (Subp_Id));
5349 ("pragma Inline for& is redundant?r?",
5350 N, Entity (Subp_Id));
5358 ----------------------------
5359 -- Process_Interface_Name --
5360 ----------------------------
5362 procedure Process_Interface_Name
5363 (Subprogram_Def : Entity_Id;
5369 String_Val : String_Id;
5371 procedure Check_Form_Of_Interface_Name
5373 Ext_Name_Case : Boolean);
5374 -- SN is a string literal node for an interface name. This routine
5375 -- performs some minimal checks that the name is reasonable. In
5376 -- particular that no spaces or other obviously incorrect characters
5377 -- appear. This is only a warning, since any characters are allowed.
5378 -- Ext_Name_Case is True for an External_Name, False for a Link_Name.
5380 ----------------------------------
5381 -- Check_Form_Of_Interface_Name --
5382 ----------------------------------
5384 procedure Check_Form_Of_Interface_Name
5386 Ext_Name_Case : Boolean)
5388 S : constant String_Id := Strval (Expr_Value_S (SN));
5389 SL : constant Nat := String_Length (S);
5394 Error_Msg_N ("interface name cannot be null string", SN);
5397 for J in 1 .. SL loop
5398 C := Get_String_Char (S, J);
5400 -- Look for dubious character and issue unconditional warning.
5401 -- Definitely dubious if not in character range.
5403 if not In_Character_Range (C)
5405 -- For all cases except CLI target,
5406 -- commas, spaces and slashes are dubious (in CLI, we use
5407 -- commas and backslashes in external names to specify
5408 -- assembly version and public key, while slashes and spaces
5409 -- can be used in names to mark nested classes and
5412 or else ((not Ext_Name_Case or else VM_Target /= CLI_Target)
5413 and then (Get_Character (C) = ','
5415 Get_Character (C) = '\'))
5416 or else (VM_Target /= CLI_Target
5417 and then (Get_Character (C) = ' '
5419 Get_Character (C) = '/'))
5422 ("??interface name contains illegal character",
5423 Sloc (SN) + Source_Ptr (J));
5426 end Check_Form_Of_Interface_Name;
5428 -- Start of processing for Process_Interface_Name
5431 if No (Link_Arg) then
5432 if No (Ext_Arg) then
5433 if VM_Target = CLI_Target
5434 and then Ekind (Subprogram_Def) = E_Package
5435 and then Nkind (Parent (Subprogram_Def)) =
5436 N_Package_Specification
5437 and then Present (Generic_Parent (Parent (Subprogram_Def)))
5442 (Generic_Parent (Parent (Subprogram_Def))));
5447 elsif Chars (Ext_Arg) = Name_Link_Name then
5449 Link_Nam := Expression (Ext_Arg);
5452 Check_Optional_Identifier (Ext_Arg, Name_External_Name);
5453 Ext_Nam := Expression (Ext_Arg);
5458 Check_Optional_Identifier (Ext_Arg, Name_External_Name);
5459 Check_Optional_Identifier (Link_Arg, Name_Link_Name);
5460 Ext_Nam := Expression (Ext_Arg);
5461 Link_Nam := Expression (Link_Arg);
5464 -- Check expressions for external name and link name are static
5466 if Present (Ext_Nam) then
5467 Check_Arg_Is_Static_Expression (Ext_Nam, Standard_String);
5468 Check_Form_Of_Interface_Name (Ext_Nam, Ext_Name_Case => True);
5470 -- Verify that external name is not the name of a local entity,
5471 -- which would hide the imported one and could lead to run-time
5472 -- surprises. The problem can only arise for entities declared in
5473 -- a package body (otherwise the external name is fully qualified
5474 -- and will not conflict).
5482 if Prag_Id = Pragma_Import then
5483 String_To_Name_Buffer (Strval (Expr_Value_S (Ext_Nam)));
5485 E := Entity_Id (Get_Name_Table_Info (Nam));
5487 if Nam /= Chars (Subprogram_Def)
5488 and then Present (E)
5489 and then not Is_Overloadable (E)
5490 and then Is_Immediately_Visible (E)
5491 and then not Is_Imported (E)
5492 and then Ekind (Scope (E)) = E_Package
5495 while Present (Par) loop
5496 if Nkind (Par) = N_Package_Body then
5497 Error_Msg_Sloc := Sloc (E);
5499 ("imported entity is hidden by & declared#",
5504 Par := Parent (Par);
5511 if Present (Link_Nam) then
5512 Check_Arg_Is_Static_Expression (Link_Nam, Standard_String);
5513 Check_Form_Of_Interface_Name (Link_Nam, Ext_Name_Case => False);
5516 -- If there is no link name, just set the external name
5518 if No (Link_Nam) then
5519 Link_Nam := Adjust_External_Name_Case (Expr_Value_S (Ext_Nam));
5521 -- For the Link_Name case, the given literal is preceded by an
5522 -- asterisk, which indicates to GCC that the given name should be
5523 -- taken literally, and in particular that no prepending of
5524 -- underlines should occur, even in systems where this is the
5530 if VM_Target = No_VM then
5531 Store_String_Char (Get_Char_Code ('*'));
5534 String_Val := Strval (Expr_Value_S (Link_Nam));
5535 Store_String_Chars (String_Val);
5537 Make_String_Literal (Sloc (Link_Nam),
5538 Strval => End_String);
5541 -- Set the interface name. If the entity is a generic instance, use
5542 -- its alias, which is the callable entity.
5544 if Is_Generic_Instance (Subprogram_Def) then
5545 Set_Encoded_Interface_Name
5546 (Alias (Get_Base_Subprogram (Subprogram_Def)), Link_Nam);
5548 Set_Encoded_Interface_Name
5549 (Get_Base_Subprogram (Subprogram_Def), Link_Nam);
5552 -- We allow duplicated export names in CIL/Java, as they are always
5553 -- enclosed in a namespace that differentiates them, and overloaded
5554 -- entities are supported by the VM.
5556 if Convention (Subprogram_Def) /= Convention_CIL
5558 Convention (Subprogram_Def) /= Convention_Java
5560 Check_Duplicated_Export_Name (Link_Nam);
5562 end Process_Interface_Name;
5564 -----------------------------------------
5565 -- Process_Interrupt_Or_Attach_Handler --
5566 -----------------------------------------
5568 procedure Process_Interrupt_Or_Attach_Handler is
5569 Arg1_X : constant Node_Id := Get_Pragma_Arg (Arg1);
5570 Handler_Proc : constant Entity_Id := Entity (Arg1_X);
5571 Proc_Scope : constant Entity_Id := Scope (Handler_Proc);
5574 Set_Is_Interrupt_Handler (Handler_Proc);
5576 -- If the pragma is not associated with a handler procedure within a
5577 -- protected type, then it must be for a nonprotected procedure for
5578 -- the AAMP target, in which case we don't associate a representation
5579 -- item with the procedure's scope.
5581 if Ekind (Proc_Scope) = E_Protected_Type then
5582 if Prag_Id = Pragma_Interrupt_Handler
5584 Prag_Id = Pragma_Attach_Handler
5586 Record_Rep_Item (Proc_Scope, N);
5589 end Process_Interrupt_Or_Attach_Handler;
5591 --------------------------------------------------
5592 -- Process_Restrictions_Or_Restriction_Warnings --
5593 --------------------------------------------------
5595 -- Note: some of the simple identifier cases were handled in par-prag,
5596 -- but it is harmless (and more straightforward) to simply handle all
5597 -- cases here, even if it means we repeat a bit of work in some cases.
5599 procedure Process_Restrictions_Or_Restriction_Warnings
5603 R_Id : Restriction_Id;
5608 procedure Check_Unit_Name (N : Node_Id);
5609 -- Checks unit name parameter for No_Dependence. Returns if it has
5610 -- an appropriate form, otherwise raises pragma argument error.
5612 ---------------------
5613 -- Check_Unit_Name --
5614 ---------------------
5616 procedure Check_Unit_Name (N : Node_Id) is
5618 if Nkind (N) = N_Selected_Component then
5619 Check_Unit_Name (Prefix (N));
5620 Check_Unit_Name (Selector_Name (N));
5622 elsif Nkind (N) = N_Identifier then
5627 ("wrong form for unit name for No_Dependence", N);
5629 end Check_Unit_Name;
5631 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
5634 -- Ignore all Restrictions pragma in CodePeer mode
5636 if CodePeer_Mode then
5640 Check_Ada_83_Warning;
5641 Check_At_Least_N_Arguments (1);
5642 Check_Valid_Configuration_Pragma;
5645 while Present (Arg) loop
5647 Expr := Get_Pragma_Arg (Arg);
5649 -- Case of no restriction identifier present
5651 if Id = No_Name then
5652 if Nkind (Expr) /= N_Identifier then
5654 ("invalid form for restriction", Arg);
5659 (Process_Restriction_Synonyms (Expr));
5661 if R_Id not in All_Boolean_Restrictions then
5662 Error_Msg_Name_1 := Pname;
5664 ("invalid restriction identifier&", Get_Pragma_Arg (Arg));
5666 -- Check for possible misspelling
5668 for J in Restriction_Id loop
5670 Rnm : constant String := Restriction_Id'Image (J);
5673 Name_Buffer (1 .. Rnm'Length) := Rnm;
5674 Name_Len := Rnm'Length;
5675 Set_Casing (All_Lower_Case);
5677 if Is_Bad_Spelling_Of (Chars (Expr), Name_Enter) then
5679 (Identifier_Casing (Current_Source_File));
5680 Error_Msg_String (1 .. Rnm'Length) :=
5681 Name_Buffer (1 .. Name_Len);
5682 Error_Msg_Strlen := Rnm'Length;
5683 Error_Msg_N -- CODEFIX
5684 ("\possible misspelling of ""~""",
5685 Get_Pragma_Arg (Arg));
5694 if Implementation_Restriction (R_Id) then
5695 Check_Restriction (No_Implementation_Restrictions, Arg);
5698 -- Special processing for No_Elaboration_Code restriction
5700 if R_Id = No_Elaboration_Code then
5702 -- Restriction is only recognized within a configuration
5703 -- pragma file, or within a unit of the main extended
5704 -- program. Note: the test for Main_Unit is needed to
5705 -- properly include the case of configuration pragma files.
5707 if not (Current_Sem_Unit = Main_Unit
5708 or else In_Extended_Main_Source_Unit (N))
5712 -- Don't allow in a subunit unless already specified in
5715 elsif Nkind (Parent (N)) = N_Compilation_Unit
5716 and then Nkind (Unit (Parent (N))) = N_Subunit
5717 and then not Restriction_Active (No_Elaboration_Code)
5720 ("invalid specification of ""No_Elaboration_Code""",
5723 ("\restriction cannot be specified in a subunit", N);
5725 ("\unless also specified in body or spec", N);
5728 -- If we have a No_Elaboration_Code pragma that we
5729 -- accept, then it needs to be added to the configuration
5730 -- restrcition set so that we get proper application to
5731 -- other units in the main extended source as required.
5734 Add_To_Config_Boolean_Restrictions (No_Elaboration_Code);
5738 -- If this is a warning, then set the warning unless we already
5739 -- have a real restriction active (we never want a warning to
5740 -- override a real restriction).
5743 if not Restriction_Active (R_Id) then
5744 Set_Restriction (R_Id, N);
5745 Restriction_Warnings (R_Id) := True;
5748 -- If real restriction case, then set it and make sure that the
5749 -- restriction warning flag is off, since a real restriction
5750 -- always overrides a warning.
5753 Set_Restriction (R_Id, N);
5754 Restriction_Warnings (R_Id) := False;
5757 -- Check for obsolescent restrictions in Ada 2005 mode
5760 and then Ada_Version >= Ada_2005
5761 and then (R_Id = No_Asynchronous_Control
5763 R_Id = No_Unchecked_Deallocation
5765 R_Id = No_Unchecked_Conversion)
5767 Check_Restriction (No_Obsolescent_Features, N);
5770 -- A very special case that must be processed here: pragma
5771 -- Restrictions (No_Exceptions) turns off all run-time
5772 -- checking. This is a bit dubious in terms of the formal
5773 -- language definition, but it is what is intended by RM
5774 -- H.4(12). Restriction_Warnings never affects generated code
5775 -- so this is done only in the real restriction case.
5777 -- Atomic_Synchronization is not a real check, so it is not
5778 -- affected by this processing).
5780 if R_Id = No_Exceptions and then not Warn then
5781 for J in Scope_Suppress.Suppress'Range loop
5782 if J /= Atomic_Synchronization then
5783 Scope_Suppress.Suppress (J) := True;
5788 -- Case of No_Dependence => unit-name. Note that the parser
5789 -- already made the necessary entry in the No_Dependence table.
5791 elsif Id = Name_No_Dependence then
5792 Check_Unit_Name (Expr);
5794 -- Case of No_Specification_Of_Aspect => Identifier.
5796 elsif Id = Name_No_Specification_Of_Aspect then
5801 if Nkind (Expr) /= N_Identifier then
5804 A_Id := Get_Aspect_Id (Chars (Expr));
5807 if A_Id = No_Aspect then
5808 Error_Pragma_Arg ("invalid restriction name", Arg);
5810 Set_Restriction_No_Specification_Of_Aspect (Expr, Warn);
5814 elsif Id = Name_No_Use_Of_Attribute then
5815 if Nkind (Expr) /= N_Identifier
5816 or else not Is_Attribute_Name (Chars (Expr))
5818 Error_Msg_N ("unknown attribute name?", Expr);
5821 Set_Restriction_No_Use_Of_Attribute (Expr, Warn);
5824 elsif Id = Name_No_Use_Of_Pragma then
5825 if Nkind (Expr) /= N_Identifier
5826 or else not Is_Pragma_Name (Chars (Expr))
5828 Error_Msg_N ("unknown pragma name?", Expr);
5831 Set_Restriction_No_Use_Of_Pragma (Expr, Warn);
5834 -- All other cases of restriction identifier present
5837 R_Id := Get_Restriction_Id (Process_Restriction_Synonyms (Arg));
5838 Analyze_And_Resolve (Expr, Any_Integer);
5840 if R_Id not in All_Parameter_Restrictions then
5842 ("invalid restriction parameter identifier", Arg);
5844 elsif not Is_OK_Static_Expression (Expr) then
5845 Flag_Non_Static_Expr
5846 ("value must be static expression!", Expr);
5849 elsif not Is_Integer_Type (Etype (Expr))
5850 or else Expr_Value (Expr) < 0
5853 ("value must be non-negative integer", Arg);
5856 -- Restriction pragma is active
5858 Val := Expr_Value (Expr);
5860 if not UI_Is_In_Int_Range (Val) then
5862 ("pragma ignored, value too large??", Arg);
5865 -- Warning case. If the real restriction is active, then we
5866 -- ignore the request, since warning never overrides a real
5867 -- restriction. Otherwise we set the proper warning. Note that
5868 -- this circuit sets the warning again if it is already set,
5869 -- which is what we want, since the constant may have changed.
5872 if not Restriction_Active (R_Id) then
5874 (R_Id, N, Integer (UI_To_Int (Val)));
5875 Restriction_Warnings (R_Id) := True;
5878 -- Real restriction case, set restriction and make sure warning
5879 -- flag is off since real restriction always overrides warning.
5882 Set_Restriction (R_Id, N, Integer (UI_To_Int (Val)));
5883 Restriction_Warnings (R_Id) := False;
5889 end Process_Restrictions_Or_Restriction_Warnings;
5891 ---------------------------------
5892 -- Process_Suppress_Unsuppress --
5893 ---------------------------------
5895 -- Note: this procedure makes entries in the check suppress data
5896 -- structures managed by Sem. See spec of package Sem for full
5897 -- details on how we handle recording of check suppression.
5899 procedure Process_Suppress_Unsuppress (Suppress_Case : Boolean) is
5904 In_Package_Spec : constant Boolean :=
5905 Is_Package_Or_Generic_Package (Current_Scope)
5906 and then not In_Package_Body (Current_Scope);
5908 procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id);
5909 -- Used to suppress a single check on the given entity
5911 --------------------------------
5912 -- Suppress_Unsuppress_Echeck --
5913 --------------------------------
5915 procedure Suppress_Unsuppress_Echeck (E : Entity_Id; C : Check_Id) is
5917 -- Check for error of trying to set atomic synchronization for
5918 -- a non-atomic variable.
5920 if C = Atomic_Synchronization
5921 and then not (Is_Atomic (E) or else Has_Atomic_Components (E))
5924 ("pragma & requires atomic type or variable",
5925 Pragma_Identifier (Original_Node (N)));
5928 Set_Checks_May_Be_Suppressed (E);
5930 if In_Package_Spec then
5931 Push_Global_Suppress_Stack_Entry
5934 Suppress => Suppress_Case);
5936 Push_Local_Suppress_Stack_Entry
5939 Suppress => Suppress_Case);
5942 -- If this is a first subtype, and the base type is distinct,
5943 -- then also set the suppress flags on the base type.
5945 if Is_First_Subtype (E) and then Etype (E) /= E then
5946 Suppress_Unsuppress_Echeck (Etype (E), C);
5948 end Suppress_Unsuppress_Echeck;
5950 -- Start of processing for Process_Suppress_Unsuppress
5953 -- Ignore pragma Suppress/Unsuppress in CodePeer and Alfa modes on
5954 -- user code: we want to generate checks for analysis purposes, as
5955 -- set respectively by -gnatC and -gnatd.F
5957 if (CodePeer_Mode or Alfa_Mode) and then Comes_From_Source (N) then
5961 -- Suppress/Unsuppress can appear as a configuration pragma, or in a
5962 -- declarative part or a package spec (RM 11.5(5)).
5964 if not Is_Configuration_Pragma then
5965 Check_Is_In_Decl_Part_Or_Package_Spec;
5968 Check_At_Least_N_Arguments (1);
5969 Check_At_Most_N_Arguments (2);
5970 Check_No_Identifier (Arg1);
5971 Check_Arg_Is_Identifier (Arg1);
5973 C := Get_Check_Id (Chars (Get_Pragma_Arg (Arg1)));
5975 if C = No_Check_Id then
5977 ("argument of pragma% is not valid check name", Arg1);
5980 if Arg_Count = 1 then
5982 -- Make an entry in the local scope suppress table. This is the
5983 -- table that directly shows the current value of the scope
5984 -- suppress check for any check id value.
5986 if C = All_Checks then
5988 -- For All_Checks, we set all specific predefined checks with
5989 -- the exception of Elaboration_Check, which is handled
5990 -- specially because of not wanting All_Checks to have the
5991 -- effect of deactivating static elaboration order processing.
5992 -- Atomic_Synchronization is also not affected, since this is
5993 -- not a real check.
5995 for J in Scope_Suppress.Suppress'Range loop
5996 if J /= Elaboration_Check
5998 J /= Atomic_Synchronization
6000 Scope_Suppress.Suppress (J) := Suppress_Case;
6004 -- If not All_Checks, and predefined check, then set appropriate
6005 -- scope entry. Note that we will set Elaboration_Check if this
6006 -- is explicitly specified. Atomic_Synchronization is allowed
6007 -- only if internally generated and entity is atomic.
6009 elsif C in Predefined_Check_Id
6010 and then (not Comes_From_Source (N)
6011 or else C /= Atomic_Synchronization)
6013 Scope_Suppress.Suppress (C) := Suppress_Case;
6016 -- Also make an entry in the Local_Entity_Suppress table
6018 Push_Local_Suppress_Stack_Entry
6021 Suppress => Suppress_Case);
6023 -- Case of two arguments present, where the check is suppressed for
6024 -- a specified entity (given as the second argument of the pragma)
6027 -- This is obsolescent in Ada 2005 mode
6029 if Ada_Version >= Ada_2005 then
6030 Check_Restriction (No_Obsolescent_Features, Arg2);
6033 Check_Optional_Identifier (Arg2, Name_On);
6034 E_Id := Get_Pragma_Arg (Arg2);
6037 if not Is_Entity_Name (E_Id) then
6039 ("second argument of pragma% must be entity name", Arg2);
6048 -- Enforce RM 11.5(7) which requires that for a pragma that
6049 -- appears within a package spec, the named entity must be
6050 -- within the package spec. We allow the package name itself
6051 -- to be mentioned since that makes sense, although it is not
6052 -- strictly allowed by 11.5(7).
6055 and then E /= Current_Scope
6056 and then Scope (E) /= Current_Scope
6059 ("entity in pragma% is not in package spec (RM 11.5(7))",
6063 -- Loop through homonyms. As noted below, in the case of a package
6064 -- spec, only homonyms within the package spec are considered.
6067 Suppress_Unsuppress_Echeck (E, C);
6069 if Is_Generic_Instance (E)
6070 and then Is_Subprogram (E)
6071 and then Present (Alias (E))
6073 Suppress_Unsuppress_Echeck (Alias (E), C);
6076 -- Move to next homonym if not aspect spec case
6078 exit when From_Aspect_Specification (N);
6082 -- If we are within a package specification, the pragma only
6083 -- applies to homonyms in the same scope.
6085 exit when In_Package_Spec
6086 and then Scope (E) /= Current_Scope;
6089 end Process_Suppress_Unsuppress;
6095 procedure Set_Exported (E : Entity_Id; Arg : Node_Id) is
6097 if Is_Imported (E) then
6099 ("cannot export entity& that was previously imported", Arg);
6101 elsif Present (Address_Clause (E))
6102 and then not Relaxed_RM_Semantics
6105 ("cannot export entity& that has an address clause", Arg);
6108 Set_Is_Exported (E);
6110 -- Generate a reference for entity explicitly, because the
6111 -- identifier may be overloaded and name resolution will not
6114 Generate_Reference (E, Arg);
6116 -- Deal with exporting non-library level entity
6118 if not Is_Library_Level_Entity (E) then
6120 -- Not allowed at all for subprograms
6122 if Is_Subprogram (E) then
6123 Error_Pragma_Arg ("local subprogram& cannot be exported", Arg);
6125 -- Otherwise set public and statically allocated
6129 Set_Is_Statically_Allocated (E);
6131 -- Warn if the corresponding W flag is set and the pragma comes
6132 -- from source. The latter may not be true e.g. on VMS where we
6133 -- expand export pragmas for exception codes associated with
6134 -- imported or exported exceptions. We do not want to generate
6135 -- a warning for something that the user did not write.
6137 if Warn_On_Export_Import
6138 and then Comes_From_Source (Arg)
6141 ("?x?& has been made static as a result of Export",
6144 ("\?x?this usage is non-standard and non-portable",
6150 if Warn_On_Export_Import and then Is_Type (E) then
6151 Error_Msg_NE ("exporting a type has no effect?x?", Arg, E);
6154 if Warn_On_Export_Import and Inside_A_Generic then
6156 ("all instances of& will have the same external name?x?",
6161 ----------------------------------------------
6162 -- Set_Extended_Import_Export_External_Name --
6163 ----------------------------------------------
6165 procedure Set_Extended_Import_Export_External_Name
6166 (Internal_Ent : Entity_Id;
6167 Arg_External : Node_Id)
6169 Old_Name : constant Node_Id := Interface_Name (Internal_Ent);
6173 if No (Arg_External) then
6177 Check_Arg_Is_External_Name (Arg_External);
6179 if Nkind (Arg_External) = N_String_Literal then
6180 if String_Length (Strval (Arg_External)) = 0 then
6183 New_Name := Adjust_External_Name_Case (Arg_External);
6186 elsif Nkind (Arg_External) = N_Identifier then
6187 New_Name := Get_Default_External_Name (Arg_External);
6189 -- Check_Arg_Is_External_Name should let through only identifiers and
6190 -- string literals or static string expressions (which are folded to
6191 -- string literals).
6194 raise Program_Error;
6197 -- If we already have an external name set (by a prior normal Import
6198 -- or Export pragma), then the external names must match
6200 if Present (Interface_Name (Internal_Ent)) then
6201 Check_Matching_Internal_Names : declare
6202 S1 : constant String_Id := Strval (Old_Name);
6203 S2 : constant String_Id := Strval (New_Name);
6206 pragma No_Return (Mismatch);
6207 -- Called if names do not match
6213 procedure Mismatch is
6215 Error_Msg_Sloc := Sloc (Old_Name);
6217 ("external name does not match that given #",
6221 -- Start of processing for Check_Matching_Internal_Names
6224 if String_Length (S1) /= String_Length (S2) then
6228 for J in 1 .. String_Length (S1) loop
6229 if Get_String_Char (S1, J) /= Get_String_Char (S2, J) then
6234 end Check_Matching_Internal_Names;
6236 -- Otherwise set the given name
6239 Set_Encoded_Interface_Name (Internal_Ent, New_Name);
6240 Check_Duplicated_Export_Name (New_Name);
6242 end Set_Extended_Import_Export_External_Name;
6248 procedure Set_Imported (E : Entity_Id) is
6250 -- Error message if already imported or exported
6252 if Is_Exported (E) or else Is_Imported (E) then
6254 -- Error if being set Exported twice
6256 if Is_Exported (E) then
6257 Error_Msg_NE ("entity& was previously exported", N, E);
6259 -- Ignore error in CodePeer mode where we treat all imported
6260 -- subprograms as unknown.
6262 elsif CodePeer_Mode then
6265 -- OK if Import/Interface case
6267 elsif Import_Interface_Present (N) then
6270 -- Error if being set Imported twice
6273 Error_Msg_NE ("entity& was previously imported", N, E);
6276 Error_Msg_Name_1 := Pname;
6278 ("\(pragma% applies to all previous entities)", N);
6280 Error_Msg_Sloc := Sloc (E);
6281 Error_Msg_NE ("\import not allowed for& declared#", N, E);
6283 -- Here if not previously imported or exported, OK to import
6286 Set_Is_Imported (E);
6288 -- If the entity is an object that is not at the library level,
6289 -- then it is statically allocated. We do not worry about objects
6290 -- with address clauses in this context since they are not really
6291 -- imported in the linker sense.
6294 and then not Is_Library_Level_Entity (E)
6295 and then No (Address_Clause (E))
6297 Set_Is_Statically_Allocated (E);
6304 -------------------------
6305 -- Set_Mechanism_Value --
6306 -------------------------
6308 -- Note: the mechanism name has not been analyzed (and cannot indeed be
6309 -- analyzed, since it is semantic nonsense), so we get it in the exact
6310 -- form created by the parser.
6312 procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id) is
6315 Mech_Name_Id : Name_Id;
6317 procedure Bad_Class;
6318 pragma No_Return (Bad_Class);
6319 -- Signal bad descriptor class name
6321 procedure Bad_Mechanism;
6322 pragma No_Return (Bad_Mechanism);
6323 -- Signal bad mechanism name
6329 procedure Bad_Class is
6331 Error_Pragma_Arg ("unrecognized descriptor class name", Class);
6334 -------------------------
6335 -- Bad_Mechanism_Value --
6336 -------------------------
6338 procedure Bad_Mechanism is
6340 Error_Pragma_Arg ("unrecognized mechanism name", Mech_Name);
6343 -- Start of processing for Set_Mechanism_Value
6346 if Mechanism (Ent) /= Default_Mechanism then
6348 ("mechanism for & has already been set", Mech_Name, Ent);
6351 -- MECHANISM_NAME ::= value | reference | descriptor |
6354 if Nkind (Mech_Name) = N_Identifier then
6355 if Chars (Mech_Name) = Name_Value then
6356 Set_Mechanism (Ent, By_Copy);
6359 elsif Chars (Mech_Name) = Name_Reference then
6360 Set_Mechanism (Ent, By_Reference);
6363 elsif Chars (Mech_Name) = Name_Descriptor then
6364 Check_VMS (Mech_Name);
6366 -- Descriptor => Short_Descriptor if pragma was given
6368 if Short_Descriptors then
6369 Set_Mechanism (Ent, By_Short_Descriptor);
6371 Set_Mechanism (Ent, By_Descriptor);
6376 elsif Chars (Mech_Name) = Name_Short_Descriptor then
6377 Check_VMS (Mech_Name);
6378 Set_Mechanism (Ent, By_Short_Descriptor);
6381 elsif Chars (Mech_Name) = Name_Copy then
6383 ("bad mechanism name, Value assumed", Mech_Name);
6389 -- MECHANISM_NAME ::= descriptor (CLASS_NAME) |
6390 -- short_descriptor (CLASS_NAME)
6391 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6393 -- Note: this form is parsed as an indexed component
6395 elsif Nkind (Mech_Name) = N_Indexed_Component then
6396 Class := First (Expressions (Mech_Name));
6398 if Nkind (Prefix (Mech_Name)) /= N_Identifier
6399 or else not (Chars (Prefix (Mech_Name)) = Name_Descriptor or else
6400 Chars (Prefix (Mech_Name)) = Name_Short_Descriptor)
6401 or else Present (Next (Class))
6405 Mech_Name_Id := Chars (Prefix (Mech_Name));
6407 -- Change Descriptor => Short_Descriptor if pragma was given
6409 if Mech_Name_Id = Name_Descriptor
6410 and then Short_Descriptors
6412 Mech_Name_Id := Name_Short_Descriptor;
6416 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME) |
6417 -- short_descriptor (Class => CLASS_NAME)
6418 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6420 -- Note: this form is parsed as a function call
6422 elsif Nkind (Mech_Name) = N_Function_Call then
6423 Param := First (Parameter_Associations (Mech_Name));
6425 if Nkind (Name (Mech_Name)) /= N_Identifier
6426 or else not (Chars (Name (Mech_Name)) = Name_Descriptor or else
6427 Chars (Name (Mech_Name)) = Name_Short_Descriptor)
6428 or else Present (Next (Param))
6429 or else No (Selector_Name (Param))
6430 or else Chars (Selector_Name (Param)) /= Name_Class
6434 Class := Explicit_Actual_Parameter (Param);
6435 Mech_Name_Id := Chars (Name (Mech_Name));
6442 -- Fall through here with Class set to descriptor class name
6444 Check_VMS (Mech_Name);
6446 if Nkind (Class) /= N_Identifier then
6449 elsif Mech_Name_Id = Name_Descriptor
6450 and then Chars (Class) = Name_UBS
6452 Set_Mechanism (Ent, By_Descriptor_UBS);
6454 elsif Mech_Name_Id = Name_Descriptor
6455 and then Chars (Class) = Name_UBSB
6457 Set_Mechanism (Ent, By_Descriptor_UBSB);
6459 elsif Mech_Name_Id = Name_Descriptor
6460 and then Chars (Class) = Name_UBA
6462 Set_Mechanism (Ent, By_Descriptor_UBA);
6464 elsif Mech_Name_Id = Name_Descriptor
6465 and then Chars (Class) = Name_S
6467 Set_Mechanism (Ent, By_Descriptor_S);
6469 elsif Mech_Name_Id = Name_Descriptor
6470 and then Chars (Class) = Name_SB
6472 Set_Mechanism (Ent, By_Descriptor_SB);
6474 elsif Mech_Name_Id = Name_Descriptor
6475 and then Chars (Class) = Name_A
6477 Set_Mechanism (Ent, By_Descriptor_A);
6479 elsif Mech_Name_Id = Name_Descriptor
6480 and then Chars (Class) = Name_NCA
6482 Set_Mechanism (Ent, By_Descriptor_NCA);
6484 elsif Mech_Name_Id = Name_Short_Descriptor
6485 and then Chars (Class) = Name_UBS
6487 Set_Mechanism (Ent, By_Short_Descriptor_UBS);
6489 elsif Mech_Name_Id = Name_Short_Descriptor
6490 and then Chars (Class) = Name_UBSB
6492 Set_Mechanism (Ent, By_Short_Descriptor_UBSB);
6494 elsif Mech_Name_Id = Name_Short_Descriptor
6495 and then Chars (Class) = Name_UBA
6497 Set_Mechanism (Ent, By_Short_Descriptor_UBA);
6499 elsif Mech_Name_Id = Name_Short_Descriptor
6500 and then Chars (Class) = Name_S
6502 Set_Mechanism (Ent, By_Short_Descriptor_S);
6504 elsif Mech_Name_Id = Name_Short_Descriptor
6505 and then Chars (Class) = Name_SB
6507 Set_Mechanism (Ent, By_Short_Descriptor_SB);
6509 elsif Mech_Name_Id = Name_Short_Descriptor
6510 and then Chars (Class) = Name_A
6512 Set_Mechanism (Ent, By_Short_Descriptor_A);
6514 elsif Mech_Name_Id = Name_Short_Descriptor
6515 and then Chars (Class) = Name_NCA
6517 Set_Mechanism (Ent, By_Short_Descriptor_NCA);
6522 end Set_Mechanism_Value;
6524 --------------------------
6525 -- Set_Rational_Profile --
6526 --------------------------
6528 -- The Rational profile includes Implicit_Packing, Use_Vads_Size, and
6529 -- and extension to the semantics of renaming declarations.
6531 procedure Set_Rational_Profile is
6533 Implicit_Packing := True;
6534 Overriding_Renamings := True;
6535 Use_VADS_Size := True;
6536 end Set_Rational_Profile;
6538 ---------------------------
6539 -- Set_Ravenscar_Profile --
6540 ---------------------------
6542 -- The tasks to be done here are
6544 -- Set required policies
6546 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
6547 -- pragma Locking_Policy (Ceiling_Locking)
6549 -- Set Detect_Blocking mode
6551 -- Set required restrictions (see System.Rident for detailed list)
6553 -- Set the No_Dependence rules
6554 -- No_Dependence => Ada.Asynchronous_Task_Control
6555 -- No_Dependence => Ada.Calendar
6556 -- No_Dependence => Ada.Execution_Time.Group_Budget
6557 -- No_Dependence => Ada.Execution_Time.Timers
6558 -- No_Dependence => Ada.Task_Attributes
6559 -- No_Dependence => System.Multiprocessors.Dispatching_Domains
6561 procedure Set_Ravenscar_Profile (N : Node_Id) is
6562 Prefix_Entity : Entity_Id;
6563 Selector_Entity : Entity_Id;
6564 Prefix_Node : Node_Id;
6568 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
6570 if Task_Dispatching_Policy /= ' '
6571 and then Task_Dispatching_Policy /= 'F'
6573 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
6574 Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
6576 -- Set the FIFO_Within_Priorities policy, but always preserve
6577 -- System_Location since we like the error message with the run time
6581 Task_Dispatching_Policy := 'F';
6583 if Task_Dispatching_Policy_Sloc /= System_Location then
6584 Task_Dispatching_Policy_Sloc := Loc;
6588 -- pragma Locking_Policy (Ceiling_Locking)
6590 if Locking_Policy /= ' '
6591 and then Locking_Policy /= 'C'
6593 Error_Msg_Sloc := Locking_Policy_Sloc;
6594 Error_Pragma ("Profile (Ravenscar) incompatible with policy#");
6596 -- Set the Ceiling_Locking policy, but preserve System_Location since
6597 -- we like the error message with the run time name.
6600 Locking_Policy := 'C';
6602 if Locking_Policy_Sloc /= System_Location then
6603 Locking_Policy_Sloc := Loc;
6607 -- pragma Detect_Blocking
6609 Detect_Blocking := True;
6611 -- Set the corresponding restrictions
6613 Set_Profile_Restrictions
6614 (Ravenscar, N, Warn => Treat_Restrictions_As_Warnings);
6616 -- Set the No_Dependence restrictions
6618 -- The following No_Dependence restrictions:
6619 -- No_Dependence => Ada.Asynchronous_Task_Control
6620 -- No_Dependence => Ada.Calendar
6621 -- No_Dependence => Ada.Task_Attributes
6622 -- are already set by previous call to Set_Profile_Restrictions.
6624 -- Set the following restrictions which were added to Ada 2005:
6625 -- No_Dependence => Ada.Execution_Time.Group_Budget
6626 -- No_Dependence => Ada.Execution_Time.Timers
6628 if Ada_Version >= Ada_2005 then
6629 Name_Buffer (1 .. 3) := "ada";
6632 Prefix_Entity := Make_Identifier (Loc, Name_Find);
6634 Name_Buffer (1 .. 14) := "execution_time";
6637 Selector_Entity := Make_Identifier (Loc, Name_Find);
6640 Make_Selected_Component
6642 Prefix => Prefix_Entity,
6643 Selector_Name => Selector_Entity);
6645 Name_Buffer (1 .. 13) := "group_budgets";
6648 Selector_Entity := Make_Identifier (Loc, Name_Find);
6651 Make_Selected_Component
6653 Prefix => Prefix_Node,
6654 Selector_Name => Selector_Entity);
6656 Set_Restriction_No_Dependence
6658 Warn => Treat_Restrictions_As_Warnings,
6659 Profile => Ravenscar);
6661 Name_Buffer (1 .. 6) := "timers";
6664 Selector_Entity := Make_Identifier (Loc, Name_Find);
6667 Make_Selected_Component
6669 Prefix => Prefix_Node,
6670 Selector_Name => Selector_Entity);
6672 Set_Restriction_No_Dependence
6674 Warn => Treat_Restrictions_As_Warnings,
6675 Profile => Ravenscar);
6678 -- Set the following restrictions which was added to Ada 2012 (see
6680 -- No_Dependence => System.Multiprocessors.Dispatching_Domains
6682 if Ada_Version >= Ada_2012 then
6683 Name_Buffer (1 .. 6) := "system";
6686 Prefix_Entity := Make_Identifier (Loc, Name_Find);
6688 Name_Buffer (1 .. 15) := "multiprocessors";
6691 Selector_Entity := Make_Identifier (Loc, Name_Find);
6694 Make_Selected_Component
6696 Prefix => Prefix_Entity,
6697 Selector_Name => Selector_Entity);
6699 Name_Buffer (1 .. 19) := "dispatching_domains";
6702 Selector_Entity := Make_Identifier (Loc, Name_Find);
6705 Make_Selected_Component
6707 Prefix => Prefix_Node,
6708 Selector_Name => Selector_Entity);
6710 Set_Restriction_No_Dependence
6712 Warn => Treat_Restrictions_As_Warnings,
6713 Profile => Ravenscar);
6715 end Set_Ravenscar_Profile;
6721 procedure S14_Pragma is
6723 if not Formal_Extensions then
6724 Error_Pragma ("pragma% requires the use of debug switch -gnatd.V");
6728 -- Start of processing for Analyze_Pragma
6731 -- The following code is a defense against recursion. Not clear that
6732 -- this can happen legitimately, but perhaps some error situations
6733 -- can cause it, and we did see this recursion during testing.
6735 if Analyzed (N) then
6738 Set_Analyzed (N, True);
6741 -- Deal with unrecognized pragma
6743 Pname := Pragma_Name (N);
6745 if not Is_Pragma_Name (Pname) then
6746 if Warn_On_Unrecognized_Pragma then
6747 Error_Msg_Name_1 := Pname;
6748 Error_Msg_N ("?g?unrecognized pragma%!", Pragma_Identifier (N));
6750 for PN in First_Pragma_Name .. Last_Pragma_Name loop
6751 if Is_Bad_Spelling_Of (Pname, PN) then
6752 Error_Msg_Name_1 := PN;
6753 Error_Msg_N -- CODEFIX
6754 ("\?g?possible misspelling of %!", Pragma_Identifier (N));
6763 -- Here to start processing for recognized pragma
6765 Prag_Id := Get_Pragma_Id (Pname);
6767 if Present (Corresponding_Aspect (N)) then
6768 Pname := Chars (Identifier (Corresponding_Aspect (N)));
6779 if Present (Pragma_Argument_Associations (N)) then
6780 Arg_Count := List_Length (Pragma_Argument_Associations (N));
6781 Arg1 := First (Pragma_Argument_Associations (N));
6783 if Present (Arg1) then
6784 Arg2 := Next (Arg1);
6786 if Present (Arg2) then
6787 Arg3 := Next (Arg2);
6789 if Present (Arg3) then
6790 Arg4 := Next (Arg3);
6796 Check_Restriction_No_Use_Of_Pragma (N);
6798 -- An enumeration type defines the pragmas that are supported by the
6799 -- implementation. Get_Pragma_Id (in package Prag) transforms a name
6800 -- into the corresponding enumeration value for the following case.
6808 -- pragma Abort_Defer;
6810 when Pragma_Abort_Defer =>
6812 Check_Arg_Count (0);
6814 -- The only required semantic processing is to check the
6815 -- placement. This pragma must appear at the start of the
6816 -- statement sequence of a handled sequence of statements.
6818 if Nkind (Parent (N)) /= N_Handled_Sequence_Of_Statements
6819 or else N /= First (Statements (Parent (N)))
6824 --------------------
6825 -- Abstract_State --
6826 --------------------
6828 -- pragma Abstract_State (ABSTRACT_STATE_LIST)
6830 -- ABSTRACT_STATE_LIST ::=
6832 -- | STATE_NAME_WITH_PROPERTIES {, STATE_NAME_WITH_PROPERTIES}
6834 -- STATE_NAME_WITH_PROPERTIES ::=
6836 -- | (STATE_NAME with PROPERTY_LIST)
6838 -- PROPERTY_LIST ::= PROPERTY {, PROPERTY}
6839 -- PROPERTY ::= SIMPLE_PROPERTY | NAME_VALUE_PROPERTY
6841 -- SIMPLE_PROPERTY ::= IDENTIFIER
6842 -- NAME_VALUE_PROPERTY ::= IDENTIFIER => EXPRESSION
6844 -- STATE_NAME ::= DEFINING_IDENTIFIER
6846 when Pragma_Abstract_State => Abstract_State : declare
6847 Pack_Id : Entity_Id;
6849 -- Flags used to verify the consistency of states
6851 Non_Null_Seen : Boolean := False;
6852 Null_Seen : Boolean := False;
6854 procedure Analyze_Abstract_State (State : Node_Id);
6855 -- Verify the legality of a single state declaration. Create and
6856 -- decorate a state abstraction entity and introduce it into the
6857 -- visibility chain.
6859 ----------------------------
6860 -- Analyze_Abstract_State --
6861 ----------------------------
6863 procedure Analyze_Abstract_State (State : Node_Id) is
6864 procedure Check_Duplicate_Property
6866 Status : in out Boolean);
6867 -- Flag Status denotes whether a particular property has been
6868 -- seen while processing a state. This routine verifies that
6869 -- Prop is not a duplicate property and sets the flag Status.
6871 ------------------------------
6872 -- Check_Duplicate_Property --
6873 ------------------------------
6875 procedure Check_Duplicate_Property
6877 Status : in out Boolean)
6881 Error_Msg_N ("duplicate state property", Prop);
6885 end Check_Duplicate_Property;
6889 Errors : constant Nat := Serious_Errors_Detected;
6890 Loc : constant Source_Ptr := Sloc (State);
6893 Is_Null : Boolean := False;
6894 Level : Uint := Uint_0;
6898 -- Flags used to verify the consistency of properties
6900 Input_Seen : Boolean := False;
6901 Integrity_Seen : Boolean := False;
6902 Output_Seen : Boolean := False;
6903 Volatile_Seen : Boolean := False;
6905 -- Start of processing for Analyze_Abstract_State
6908 -- A package with a null abstract state is not allowed to
6909 -- declare additional states.
6913 ("package & has null abstract state", State, Pack_Id);
6915 -- Null states appear as internally generated entities
6917 elsif Nkind (State) = N_Null then
6918 Name := New_Internal_Name ('S');
6922 -- Catch a case where a null state appears in a list of
6925 if Non_Null_Seen then
6927 ("package & has non-null abstract state",
6931 -- Simple state declaration
6933 elsif Nkind (State) = N_Identifier then
6934 Name := Chars (State);
6935 Non_Null_Seen := True;
6937 -- State declaration with various properties. This construct
6938 -- appears as an extension aggregate in the tree.
6940 elsif Nkind (State) = N_Extension_Aggregate then
6941 if Nkind (Ancestor_Part (State)) = N_Identifier then
6942 Name := Chars (Ancestor_Part (State));
6943 Non_Null_Seen := True;
6946 ("state name must be an identifier",
6947 Ancestor_Part (State));
6950 -- Process properties Input, Output and Volatile. Ensure
6951 -- that none of them appear more than once.
6953 Prop := First (Expressions (State));
6954 while Present (Prop) loop
6955 if Nkind (Prop) = N_Identifier then
6956 if Chars (Prop) = Name_Input then
6957 Check_Duplicate_Property (Prop, Input_Seen);
6958 elsif Chars (Prop) = Name_Output then
6959 Check_Duplicate_Property (Prop, Output_Seen);
6960 elsif Chars (Prop) = Name_Volatile then
6961 Check_Duplicate_Property (Prop, Volatile_Seen);
6963 Error_Msg_N ("invalid state property", Prop);
6966 Error_Msg_N ("invalid state property", Prop);
6972 -- Volatile requires exactly one Input or Output
6976 ((Input_Seen and then Output_Seen) -- both
6978 (not Input_Seen and then not Output_Seen)) -- none
6981 ("property Volatile requires exactly one Input or "
6985 -- Either Input or Output require Volatile
6987 if (Input_Seen or Output_Seen)
6988 and then not Volatile_Seen
6991 ("properties Input and Output require Volatile", State);
6994 -- State property Integrity appears as a component
6997 Assoc := First (Component_Associations (State));
6998 while Present (Assoc) loop
6999 Prop := First (Choices (Assoc));
7000 while Present (Prop) loop
7001 if Nkind (Prop) = N_Identifier
7002 and then Chars (Prop) = Name_Integrity
7004 Check_Duplicate_Property (Prop, Integrity_Seen);
7006 Error_Msg_N ("invalid state property", Prop);
7012 if Nkind (Expression (Assoc)) = N_Integer_Literal then
7013 Level := Intval (Expression (Assoc));
7016 ("integrity level must be an integer literal",
7017 Expression (Assoc));
7023 -- Any other attempt to declare a state is erroneous
7026 Error_Msg_N ("malformed abstract state declaration", State);
7029 -- Do not generate a state abstraction entity if it was not
7030 -- properly declared.
7032 if Serious_Errors_Detected > Errors then
7036 -- The generated state abstraction reuses the same characters
7037 -- from the original state declaration. Decorate the entity.
7039 Id := Make_Defining_Identifier (Loc, New_External_Name (Name));
7040 Set_Comes_From_Source (Id, not Is_Null);
7041 Set_Parent (Id, State);
7042 Set_Ekind (Id, E_Abstract_State);
7043 Set_Etype (Id, Standard_Void_Type);
7044 Set_Integrity_Level (Id, Level);
7045 Set_Refined_State (Id, Empty);
7047 -- Every non-null state must be nameable and resolvable the
7048 -- same way a constant is.
7051 Push_Scope (Pack_Id);
7056 -- Associate the state with its related package
7058 if No (Abstract_States (Pack_Id)) then
7059 Set_Abstract_States (Pack_Id, New_Elmt_List);
7062 Append_Elmt (Id, Abstract_States (Pack_Id));
7063 end Analyze_Abstract_State;
7070 -- Start of processing for Abstract_State
7075 Check_Arg_Count (1);
7077 -- Ensure the proper placement of the pragma. Abstract states must
7078 -- be associated with a package declaration.
7080 if From_Aspect_Specification (N) then
7081 Par := Parent (Corresponding_Aspect (N));
7083 Par := Parent (Parent (N));
7086 if Nkind (Par) = N_Compilation_Unit then
7090 if Nkind (Par) /= N_Package_Declaration then
7095 Pack_Id := Defining_Entity (Par);
7096 State := Expression (Arg1);
7098 -- Multiple abstract states appear as an aggregate
7100 if Nkind (State) = N_Aggregate then
7101 State := First (Expressions (State));
7102 while Present (State) loop
7103 Analyze_Abstract_State (State);
7108 -- Various forms of a single abstract state. Note that these may
7109 -- include malformed state declarations.
7112 Analyze_Abstract_State (State);
7122 -- Note: this pragma also has some specific processing in Par.Prag
7123 -- because we want to set the Ada version mode during parsing.
7125 when Pragma_Ada_83 =>
7127 Check_Arg_Count (0);
7129 -- We really should check unconditionally for proper configuration
7130 -- pragma placement, since we really don't want mixed Ada modes
7131 -- within a single unit, and the GNAT reference manual has always
7132 -- said this was a configuration pragma, but we did not check and
7133 -- are hesitant to add the check now.
7135 -- However, we really cannot tolerate mixing Ada 2005 or Ada 2012
7136 -- with Ada 83 or Ada 95, so we must check if we are in Ada 2005
7137 -- or Ada 2012 mode.
7139 if Ada_Version >= Ada_2005 then
7140 Check_Valid_Configuration_Pragma;
7143 -- Now set Ada 83 mode
7145 Ada_Version := Ada_83;
7146 Ada_Version_Explicit := Ada_Version;
7154 -- Note: this pragma also has some specific processing in Par.Prag
7155 -- because we want to set the Ada 83 version mode during parsing.
7157 when Pragma_Ada_95 =>
7159 Check_Arg_Count (0);
7161 -- We really should check unconditionally for proper configuration
7162 -- pragma placement, since we really don't want mixed Ada modes
7163 -- within a single unit, and the GNAT reference manual has always
7164 -- said this was a configuration pragma, but we did not check and
7165 -- are hesitant to add the check now.
7167 -- However, we really cannot tolerate mixing Ada 2005 with Ada 83
7168 -- or Ada 95, so we must check if we are in Ada 2005 mode.
7170 if Ada_Version >= Ada_2005 then
7171 Check_Valid_Configuration_Pragma;
7174 -- Now set Ada 95 mode
7176 Ada_Version := Ada_95;
7177 Ada_Version_Explicit := Ada_Version;
7179 ---------------------
7180 -- Ada_05/Ada_2005 --
7181 ---------------------
7184 -- pragma Ada_05 (LOCAL_NAME);
7187 -- pragma Ada_2005 (LOCAL_NAME):
7189 -- Note: these pragmas also have some specific processing in Par.Prag
7190 -- because we want to set the Ada 2005 version mode during parsing.
7192 when Pragma_Ada_05 | Pragma_Ada_2005 => declare
7198 if Arg_Count = 1 then
7199 Check_Arg_Is_Local_Name (Arg1);
7200 E_Id := Get_Pragma_Arg (Arg1);
7202 if Etype (E_Id) = Any_Type then
7206 Set_Is_Ada_2005_Only (Entity (E_Id));
7207 Record_Rep_Item (Entity (E_Id), N);
7210 Check_Arg_Count (0);
7212 -- For Ada_2005 we unconditionally enforce the documented
7213 -- configuration pragma placement, since we do not want to
7214 -- tolerate mixed modes in a unit involving Ada 2005. That
7215 -- would cause real difficulties for those cases where there
7216 -- are incompatibilities between Ada 95 and Ada 2005.
7218 Check_Valid_Configuration_Pragma;
7220 -- Now set appropriate Ada mode
7222 Ada_Version := Ada_2005;
7223 Ada_Version_Explicit := Ada_2005;
7227 ---------------------
7228 -- Ada_12/Ada_2012 --
7229 ---------------------
7232 -- pragma Ada_12 (LOCAL_NAME);
7235 -- pragma Ada_2012 (LOCAL_NAME):
7237 -- Note: these pragmas also have some specific processing in Par.Prag
7238 -- because we want to set the Ada 2012 version mode during parsing.
7240 when Pragma_Ada_12 | Pragma_Ada_2012 => declare
7246 if Arg_Count = 1 then
7247 Check_Arg_Is_Local_Name (Arg1);
7248 E_Id := Get_Pragma_Arg (Arg1);
7250 if Etype (E_Id) = Any_Type then
7254 Set_Is_Ada_2012_Only (Entity (E_Id));
7255 Record_Rep_Item (Entity (E_Id), N);
7258 Check_Arg_Count (0);
7260 -- For Ada_2012 we unconditionally enforce the documented
7261 -- configuration pragma placement, since we do not want to
7262 -- tolerate mixed modes in a unit involving Ada 2012. That
7263 -- would cause real difficulties for those cases where there
7264 -- are incompatibilities between Ada 95 and Ada 2012. We could
7265 -- allow mixing of Ada 2005 and Ada 2012 but it's not worth it.
7267 Check_Valid_Configuration_Pragma;
7269 -- Now set appropriate Ada mode
7271 Ada_Version := Ada_2012;
7272 Ada_Version_Explicit := Ada_2012;
7276 ----------------------
7277 -- All_Calls_Remote --
7278 ----------------------
7280 -- pragma All_Calls_Remote [(library_package_NAME)];
7282 when Pragma_All_Calls_Remote => All_Calls_Remote : declare
7283 Lib_Entity : Entity_Id;
7286 Check_Ada_83_Warning;
7287 Check_Valid_Library_Unit_Pragma;
7289 if Nkind (N) = N_Null_Statement then
7293 Lib_Entity := Find_Lib_Unit_Name;
7295 -- This pragma should only apply to a RCI unit (RM E.2.3(23))
7297 if Present (Lib_Entity)
7298 and then not Debug_Flag_U
7300 if not Is_Remote_Call_Interface (Lib_Entity) then
7301 Error_Pragma ("pragma% only apply to rci unit");
7303 -- Set flag for entity of the library unit
7306 Set_Has_All_Calls_Remote (Lib_Entity);
7310 end All_Calls_Remote;
7316 -- pragma Annotate (IDENTIFIER [, IDENTIFIER {, ARG}]);
7317 -- ARG ::= NAME | EXPRESSION
7319 -- The first two arguments are by convention intended to refer to an
7320 -- external tool and a tool-specific function. These arguments are
7323 when Pragma_Annotate => Annotate : declare
7329 Check_At_Least_N_Arguments (1);
7330 Check_Arg_Is_Identifier (Arg1);
7331 Check_No_Identifiers;
7334 -- Second parameter is optional, it is never analyzed
7339 -- Here if we have a second parameter
7342 -- Second parameter must be identifier
7344 Check_Arg_Is_Identifier (Arg2);
7346 -- Process remaining parameters if any
7349 while Present (Arg) loop
7350 Exp := Get_Pragma_Arg (Arg);
7353 if Is_Entity_Name (Exp) then
7356 -- For string literals, we assume Standard_String as the
7357 -- type, unless the string contains wide or wide_wide
7360 elsif Nkind (Exp) = N_String_Literal then
7361 if Has_Wide_Wide_Character (Exp) then
7362 Resolve (Exp, Standard_Wide_Wide_String);
7363 elsif Has_Wide_Character (Exp) then
7364 Resolve (Exp, Standard_Wide_String);
7366 Resolve (Exp, Standard_String);
7369 elsif Is_Overloaded (Exp) then
7371 ("ambiguous argument for pragma%", Exp);
7382 ---------------------------
7383 -- Assert/Assert_And_Cut --
7384 ---------------------------
7387 -- ( [Check => ] Boolean_EXPRESSION
7388 -- [, [Message =>] Static_String_EXPRESSION]);
7390 -- pragma Assert_And_Cut
7391 -- ( [Check => ] Boolean_EXPRESSION
7392 -- [, [Message =>] Static_String_EXPRESSION]);
7394 when Pragma_Assert | Pragma_Assert_And_Cut => Assert : declare
7399 if Prag_Id = Pragma_Assert then
7401 else -- Pragma_Assert_And_Cut
7406 Check_At_Least_N_Arguments (1);
7407 Check_At_Most_N_Arguments (2);
7408 Check_Arg_Order ((Name_Check, Name_Message));
7409 Check_Optional_Identifier (Arg1, Name_Check);
7411 -- We treat pragma Assert as equivalent to:
7413 -- pragma Check (Assertion, condition [, msg]);
7415 -- So rewrite pragma in this manner, transfer the message
7416 -- argument if present, and analyze the result
7418 -- Pragma Assert_And_Cut is treated exactly like pragma Assert by
7419 -- the frontend. Formal verification tools may use it to "cut" the
7420 -- paths through the code, to make verification tractable. When
7421 -- dealing with a semantically analyzed tree, the information that
7422 -- a Check node N corresponds to a source Assert_And_Cut pragma
7423 -- can be retrieved from the pragma kind of Original_Node(N).
7425 Expr := Get_Pragma_Arg (Arg1);
7427 Make_Pragma_Argument_Association (Loc,
7428 Expression => Make_Identifier (Loc, Name_Assertion)),
7430 Make_Pragma_Argument_Association (Sloc (Expr),
7431 Expression => Expr));
7433 if Arg_Count > 1 then
7434 Check_Optional_Identifier (Arg2, Name_Message);
7435 Append_To (Newa, New_Copy_Tree (Arg2));
7440 Chars => Name_Check,
7441 Pragma_Argument_Associations => Newa));
7445 ----------------------
7446 -- Assertion_Policy --
7447 ----------------------
7449 -- pragma Assertion_Policy (Check | Disable | Ignore)
7451 when Pragma_Assertion_Policy => Assertion_Policy : declare
7456 Check_Valid_Configuration_Pragma;
7457 Check_Arg_Count (1);
7458 Check_No_Identifiers;
7459 Check_Arg_Is_One_Of (Arg1, Name_Check, Name_Disable, Name_Ignore);
7461 -- We treat pragma Assertion_Policy as equivalent to:
7463 -- pragma Check_Policy (Assertion, policy)
7465 -- So rewrite the pragma in that manner and link on to the chain
7466 -- of Check_Policy pragmas, marking the pragma as analyzed.
7468 Policy := Get_Pragma_Arg (Arg1);
7472 Chars => Name_Check_Policy,
7473 Pragma_Argument_Associations => New_List (
7474 Make_Pragma_Argument_Association (Loc,
7475 Expression => Make_Identifier (Loc, Name_Assertion)),
7477 Make_Pragma_Argument_Association (Loc,
7479 Make_Identifier (Sloc (Policy), Chars (Policy))))));
7482 Set_Next_Pragma (N, Opt.Check_Policy_List);
7483 Opt.Check_Policy_List := N;
7484 end Assertion_Policy;
7490 -- pragma Assume (boolean_EXPRESSION);
7492 when Pragma_Assume => Assume : declare
7496 Check_Arg_Count (1);
7498 -- Pragma Assume is transformed into pragma Check in the following
7501 -- pragma Check (Assume, Expr);
7505 Chars => Name_Check,
7506 Pragma_Argument_Associations => New_List (
7507 Make_Pragma_Argument_Association (Loc,
7508 Expression => Make_Identifier (Loc, Name_Assume)),
7510 Make_Pragma_Argument_Association (Loc,
7511 Expression => Relocate_Node (Expression (Arg1))))));
7515 ------------------------------
7516 -- Assume_No_Invalid_Values --
7517 ------------------------------
7519 -- pragma Assume_No_Invalid_Values (On | Off);
7521 when Pragma_Assume_No_Invalid_Values =>
7523 Check_Valid_Configuration_Pragma;
7524 Check_Arg_Count (1);
7525 Check_No_Identifiers;
7526 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
7528 if Chars (Get_Pragma_Arg (Arg1)) = Name_On then
7529 Assume_No_Invalid_Values := True;
7531 Assume_No_Invalid_Values := False;
7534 --------------------------
7535 -- Attribute_Definition --
7536 --------------------------
7538 -- pragma Attribute_Definition
7539 -- ([Attribute =>] ATTRIBUTE_DESIGNATOR,
7540 -- [Entity =>] LOCAL_NAME,
7541 -- [Expression =>] EXPRESSION | NAME);
7543 when Pragma_Attribute_Definition => Attribute_Definition : declare
7544 Attribute_Designator : constant Node_Id := Get_Pragma_Arg (Arg1);
7549 Check_Arg_Count (3);
7550 Check_Optional_Identifier (Arg1, "attribute");
7551 Check_Optional_Identifier (Arg2, "entity");
7552 Check_Optional_Identifier (Arg3, "expression");
7554 if Nkind (Attribute_Designator) /= N_Identifier then
7555 Error_Msg_N ("attribute name expected", Attribute_Designator);
7559 Check_Arg_Is_Local_Name (Arg2);
7561 -- If the attribute is not recognized, then issue a warning (not
7562 -- an error), and ignore the pragma.
7564 Aname := Chars (Attribute_Designator);
7566 if not Is_Attribute_Name (Aname) then
7567 Bad_Attribute (Attribute_Designator, Aname, Warn => True);
7571 -- Otherwise, rewrite the pragma as an attribute definition clause
7574 Make_Attribute_Definition_Clause (Loc,
7575 Name => Get_Pragma_Arg (Arg2),
7577 Expression => Get_Pragma_Arg (Arg3)));
7579 end Attribute_Definition;
7585 -- pragma AST_Entry (entry_IDENTIFIER);
7587 when Pragma_AST_Entry => AST_Entry : declare
7593 Check_Arg_Count (1);
7594 Check_No_Identifiers;
7595 Check_Arg_Is_Local_Name (Arg1);
7596 Ent := Entity (Get_Pragma_Arg (Arg1));
7598 -- Note: the implementation of the AST_Entry pragma could handle
7599 -- the entry family case fine, but for now we are consistent with
7600 -- the DEC rules, and do not allow the pragma, which of course
7601 -- has the effect of also forbidding the attribute.
7603 if Ekind (Ent) /= E_Entry then
7605 ("pragma% argument must be simple entry name", Arg1);
7607 elsif Is_AST_Entry (Ent) then
7609 ("duplicate % pragma for entry", Arg1);
7611 elsif Has_Homonym (Ent) then
7613 ("pragma% argument cannot specify overloaded entry", Arg1);
7617 FF : constant Entity_Id := First_Formal (Ent);
7620 if Present (FF) then
7621 if Present (Next_Formal (FF)) then
7623 ("entry for pragma% can have only one argument",
7626 elsif Parameter_Mode (FF) /= E_In_Parameter then
7628 ("entry parameter for pragma% must have mode IN",
7634 Set_Is_AST_Entry (Ent);
7642 -- pragma Asynchronous (LOCAL_NAME);
7644 when Pragma_Asynchronous => Asynchronous : declare
7652 procedure Process_Async_Pragma;
7653 -- Common processing for procedure and access-to-procedure case
7655 --------------------------
7656 -- Process_Async_Pragma --
7657 --------------------------
7659 procedure Process_Async_Pragma is
7662 Set_Is_Asynchronous (Nm);
7666 -- The formals should be of mode IN (RM E.4.1(6))
7669 while Present (S) loop
7670 Formal := Defining_Identifier (S);
7672 if Nkind (Formal) = N_Defining_Identifier
7673 and then Ekind (Formal) /= E_In_Parameter
7676 ("pragma% procedure can only have IN parameter",
7683 Set_Is_Asynchronous (Nm);
7684 end Process_Async_Pragma;
7686 -- Start of processing for pragma Asynchronous
7689 Check_Ada_83_Warning;
7690 Check_No_Identifiers;
7691 Check_Arg_Count (1);
7692 Check_Arg_Is_Local_Name (Arg1);
7694 if Debug_Flag_U then
7698 C_Ent := Cunit_Entity (Current_Sem_Unit);
7699 Analyze (Get_Pragma_Arg (Arg1));
7700 Nm := Entity (Get_Pragma_Arg (Arg1));
7702 if not Is_Remote_Call_Interface (C_Ent)
7703 and then not Is_Remote_Types (C_Ent)
7705 -- This pragma should only appear in an RCI or Remote Types
7706 -- unit (RM E.4.1(4)).
7709 ("pragma% not in Remote_Call_Interface or Remote_Types unit");
7712 if Ekind (Nm) = E_Procedure
7713 and then Nkind (Parent (Nm)) = N_Procedure_Specification
7715 if not Is_Remote_Call_Interface (Nm) then
7717 ("pragma% cannot be applied on non-remote procedure",
7721 L := Parameter_Specifications (Parent (Nm));
7722 Process_Async_Pragma;
7725 elsif Ekind (Nm) = E_Function then
7727 ("pragma% cannot be applied to function", Arg1);
7729 elsif Is_Remote_Access_To_Subprogram_Type (Nm) then
7730 if Is_Record_Type (Nm) then
7732 -- A record type that is the Equivalent_Type for a remote
7733 -- access-to-subprogram type.
7735 N := Declaration_Node (Corresponding_Remote_Type (Nm));
7738 -- A non-expanded RAS type (distribution is not enabled)
7740 N := Declaration_Node (Nm);
7743 if Nkind (N) = N_Full_Type_Declaration
7744 and then Nkind (Type_Definition (N)) =
7745 N_Access_Procedure_Definition
7747 L := Parameter_Specifications (Type_Definition (N));
7748 Process_Async_Pragma;
7750 if Is_Asynchronous (Nm)
7751 and then Expander_Active
7752 and then Get_PCS_Name /= Name_No_DSA
7754 RACW_Type_Is_Asynchronous (Underlying_RACW_Type (Nm));
7759 ("pragma% cannot reference access-to-function type",
7763 -- Only other possibility is Access-to-class-wide type
7765 elsif Is_Access_Type (Nm)
7766 and then Is_Class_Wide_Type (Designated_Type (Nm))
7768 Check_First_Subtype (Arg1);
7769 Set_Is_Asynchronous (Nm);
7770 if Expander_Active then
7771 RACW_Type_Is_Asynchronous (Nm);
7775 Error_Pragma_Arg ("inappropriate argument for pragma%", Arg1);
7783 -- pragma Atomic (LOCAL_NAME);
7785 when Pragma_Atomic =>
7786 Process_Atomic_Shared_Volatile;
7788 -----------------------
7789 -- Atomic_Components --
7790 -----------------------
7792 -- pragma Atomic_Components (array_LOCAL_NAME);
7794 -- This processing is shared by Volatile_Components
7796 when Pragma_Atomic_Components |
7797 Pragma_Volatile_Components =>
7799 Atomic_Components : declare
7806 Check_Ada_83_Warning;
7807 Check_No_Identifiers;
7808 Check_Arg_Count (1);
7809 Check_Arg_Is_Local_Name (Arg1);
7810 E_Id := Get_Pragma_Arg (Arg1);
7812 if Etype (E_Id) = Any_Type then
7818 Check_Duplicate_Pragma (E);
7820 if Rep_Item_Too_Early (E, N)
7822 Rep_Item_Too_Late (E, N)
7827 D := Declaration_Node (E);
7830 if (K = N_Full_Type_Declaration and then Is_Array_Type (E))
7832 ((Ekind (E) = E_Constant or else Ekind (E) = E_Variable)
7833 and then Nkind (D) = N_Object_Declaration
7834 and then Nkind (Object_Definition (D)) =
7835 N_Constrained_Array_Definition)
7837 -- The flag is set on the object, or on the base type
7839 if Nkind (D) /= N_Object_Declaration then
7843 Set_Has_Volatile_Components (E);
7845 if Prag_Id = Pragma_Atomic_Components then
7846 Set_Has_Atomic_Components (E);
7850 Error_Pragma_Arg ("inappropriate entity for pragma%", Arg1);
7852 end Atomic_Components;
7854 --------------------
7855 -- Attach_Handler --
7856 --------------------
7858 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
7860 when Pragma_Attach_Handler =>
7861 Check_Ada_83_Warning;
7862 Check_No_Identifiers;
7863 Check_Arg_Count (2);
7865 if No_Run_Time_Mode then
7866 Error_Msg_CRT ("Attach_Handler pragma", N);
7868 Check_Interrupt_Or_Attach_Handler;
7870 -- The expression that designates the attribute may depend on a
7871 -- discriminant, and is therefore a per-object expression, to
7872 -- be expanded in the init proc. If expansion is enabled, then
7873 -- perform semantic checks on a copy only.
7875 if Expander_Active then
7877 Temp : constant Node_Id :=
7878 New_Copy_Tree (Get_Pragma_Arg (Arg2));
7880 Set_Parent (Temp, N);
7881 Preanalyze_And_Resolve (Temp, RTE (RE_Interrupt_ID));
7885 Analyze (Get_Pragma_Arg (Arg2));
7886 Resolve (Get_Pragma_Arg (Arg2), RTE (RE_Interrupt_ID));
7889 Process_Interrupt_Or_Attach_Handler;
7892 --------------------
7893 -- C_Pass_By_Copy --
7894 --------------------
7896 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
7898 when Pragma_C_Pass_By_Copy => C_Pass_By_Copy : declare
7904 Check_Valid_Configuration_Pragma;
7905 Check_Arg_Count (1);
7906 Check_Optional_Identifier (Arg1, "max_size");
7908 Arg := Get_Pragma_Arg (Arg1);
7909 Check_Arg_Is_Static_Expression (Arg, Any_Integer);
7911 Val := Expr_Value (Arg);
7915 ("maximum size for pragma% must be positive", Arg1);
7917 elsif UI_Is_In_Int_Range (Val) then
7918 Default_C_Record_Mechanism := UI_To_Int (Val);
7920 -- If a giant value is given, Int'Last will do well enough.
7921 -- If sometime someone complains that a record larger than
7922 -- two gigabytes is not copied, we will worry about it then!
7925 Default_C_Record_Mechanism := Mechanism_Type'Last;
7933 -- pragma Check ([Name =>] IDENTIFIER,
7934 -- [Check =>] Boolean_EXPRESSION
7935 -- [,[Message =>] String_EXPRESSION]);
7937 when Pragma_Check => Check : declare
7944 -- Set True if category of assertions referenced by Name enabled
7948 Check_At_Least_N_Arguments (2);
7949 Check_At_Most_N_Arguments (3);
7950 Check_Optional_Identifier (Arg1, Name_Name);
7951 Check_Optional_Identifier (Arg2, Name_Check);
7953 if Arg_Count = 3 then
7954 Check_Optional_Identifier (Arg3, Name_Message);
7955 Str := Get_Pragma_Arg (Arg3);
7958 Check_Arg_Is_Identifier (Arg1);
7959 Cname := Chars (Get_Pragma_Arg (Arg1));
7960 Check_On := Check_Enabled (Cname);
7961 Expr := Get_Pragma_Arg (Arg2);
7963 -- Deal with SCO generation
7966 when Name_Predicate |
7969 -- Nothing to do: since checks occur in client units,
7970 -- the SCO for the aspect in the declaration unit is
7971 -- conservatively always enabled.
7977 if Check_On and then not Split_PPC (N) then
7979 -- Mark pragma/aspect SCO as enabled
7981 Set_SCO_Pragma_Enabled (Loc);
7985 -- Deal with analyzing the string argument.
7987 if Arg_Count = 3 then
7989 -- If checks are not on we don't want any expansion (since
7990 -- such expansion would not get properly deleted) but
7991 -- we do want to analyze (to get proper references).
7992 -- The Preanalyze_And_Resolve routine does just what we want
7994 if not Check_On then
7995 Preanalyze_And_Resolve (Str, Standard_String);
7997 -- Otherwise we need a proper analysis and expansion
8000 Analyze_And_Resolve (Str, Standard_String);
8004 -- Now you might think we could just do the same with the Boolean
8005 -- expression if checks are off (and expansion is on) and then
8006 -- rewrite the check as a null statement. This would work but we
8007 -- would lose the useful warnings about an assertion being bound
8008 -- to fail even if assertions are turned off.
8010 -- So instead we wrap the boolean expression in an if statement
8013 -- if False and then condition then
8017 -- The reason we do this rewriting during semantic analysis
8018 -- rather than as part of normal expansion is that we cannot
8019 -- analyze and expand the code for the boolean expression
8020 -- directly, or it may cause insertion of actions that would
8021 -- escape the attempt to suppress the check code.
8023 -- Note that the Sloc for the if statement corresponds to the
8024 -- argument condition, not the pragma itself. The reason for
8025 -- this is that we may generate a warning if the condition is
8026 -- False at compile time, and we do not want to delete this
8027 -- warning when we delete the if statement.
8029 if Expander_Active and not Check_On then
8030 Eloc := Sloc (Expr);
8033 Make_If_Statement (Eloc,
8035 Make_And_Then (Eloc,
8036 Left_Opnd => New_Occurrence_Of (Standard_False, Eloc),
8037 Right_Opnd => Expr),
8038 Then_Statements => New_List (
8039 Make_Null_Statement (Eloc))));
8041 In_Assertion_Expr := In_Assertion_Expr + 1;
8043 In_Assertion_Expr := In_Assertion_Expr - 1;
8045 -- Check is active or expansion not active. In these cases we can
8046 -- just go ahead and analyze the boolean with no worries.
8049 In_Assertion_Expr := In_Assertion_Expr + 1;
8050 Analyze_And_Resolve (Expr, Any_Boolean);
8051 In_Assertion_Expr := In_Assertion_Expr - 1;
8055 --------------------------
8056 -- Check_Float_Overflow --
8057 --------------------------
8059 -- pragma Check_Float_Overflow;
8061 when Pragma_Check_Float_Overflow =>
8063 Check_Valid_Configuration_Pragma;
8064 Check_Arg_Count (0);
8065 Check_Float_Overflow := True;
8071 -- pragma Check_Name (check_IDENTIFIER);
8073 when Pragma_Check_Name =>
8074 Check_No_Identifiers;
8076 Check_Valid_Configuration_Pragma;
8077 Check_Arg_Count (1);
8078 Check_Arg_Is_Identifier (Arg1);
8081 Nam : constant Name_Id := Chars (Get_Pragma_Arg (Arg1));
8084 for J in Check_Names.First .. Check_Names.Last loop
8085 if Check_Names.Table (J) = Nam then
8090 Check_Names.Append (Nam);
8097 -- pragma Check_Policy (
8098 -- [Name =>] IDENTIFIER,
8099 -- [Policy =>] POLICY_IDENTIFIER);
8101 -- POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
8103 -- Note: this is a configuration pragma, but it is allowed to appear
8106 when Pragma_Check_Policy =>
8108 Check_Arg_Count (2);
8109 Check_Optional_Identifier (Arg1, Name_Name);
8110 Check_Optional_Identifier (Arg2, Name_Policy);
8112 (Arg2, Name_On, Name_Off, Name_Check, Name_Disable, Name_Ignore);
8114 -- A Check_Policy pragma can appear either as a configuration
8115 -- pragma, or in a declarative part or a package spec (see RM
8116 -- 11.5(5) for rules for Suppress/Unsuppress which are also
8117 -- followed for Check_Policy).
8119 if not Is_Configuration_Pragma then
8120 Check_Is_In_Decl_Part_Or_Package_Spec;
8123 Set_Next_Pragma (N, Opt.Check_Policy_List);
8124 Opt.Check_Policy_List := N;
8126 ---------------------
8127 -- CIL_Constructor --
8128 ---------------------
8130 -- pragma CIL_Constructor ([Entity =>] LOCAL_NAME);
8132 -- Processing for this pragma is shared with Java_Constructor
8138 -- pragma Comment (static_string_EXPRESSION)
8140 -- Processing for pragma Comment shares the circuitry for pragma
8141 -- Ident. The only differences are that Ident enforces a limit of 31
8142 -- characters on its argument, and also enforces limitations on
8143 -- placement for DEC compatibility. Pragma Comment shares neither of
8144 -- these restrictions.
8150 -- pragma Common_Object (
8151 -- [Internal =>] LOCAL_NAME
8152 -- [, [External =>] EXTERNAL_SYMBOL]
8153 -- [, [Size =>] EXTERNAL_SYMBOL]);
8155 -- Processing for this pragma is shared with Psect_Object
8157 ------------------------
8158 -- Compile_Time_Error --
8159 ------------------------
8161 -- pragma Compile_Time_Error
8162 -- (boolean_EXPRESSION, static_string_EXPRESSION);
8164 when Pragma_Compile_Time_Error =>
8166 Process_Compile_Time_Warning_Or_Error;
8168 --------------------------
8169 -- Compile_Time_Warning --
8170 --------------------------
8172 -- pragma Compile_Time_Warning
8173 -- (boolean_EXPRESSION, static_string_EXPRESSION);
8175 when Pragma_Compile_Time_Warning =>
8177 Process_Compile_Time_Warning_Or_Error;
8183 when Pragma_Compiler_Unit =>
8185 Check_Arg_Count (0);
8186 Set_Is_Compiler_Unit (Get_Source_Unit (N));
8188 -----------------------------
8189 -- Complete_Representation --
8190 -----------------------------
8192 -- pragma Complete_Representation;
8194 when Pragma_Complete_Representation =>
8196 Check_Arg_Count (0);
8198 if Nkind (Parent (N)) /= N_Record_Representation_Clause then
8200 ("pragma & must appear within record representation clause");
8203 ----------------------------
8204 -- Complex_Representation --
8205 ----------------------------
8207 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
8209 when Pragma_Complex_Representation => Complex_Representation : declare
8216 Check_Arg_Count (1);
8217 Check_Optional_Identifier (Arg1, Name_Entity);
8218 Check_Arg_Is_Local_Name (Arg1);
8219 E_Id := Get_Pragma_Arg (Arg1);
8221 if Etype (E_Id) = Any_Type then
8227 if not Is_Record_Type (E) then
8229 ("argument for pragma% must be record type", Arg1);
8232 Ent := First_Entity (E);
8235 or else No (Next_Entity (Ent))
8236 or else Present (Next_Entity (Next_Entity (Ent)))
8237 or else not Is_Floating_Point_Type (Etype (Ent))
8238 or else Etype (Ent) /= Etype (Next_Entity (Ent))
8241 ("record for pragma% must have two fields of the same "
8242 & "floating-point type", Arg1);
8245 Set_Has_Complex_Representation (Base_Type (E));
8247 -- We need to treat the type has having a non-standard
8248 -- representation, for back-end purposes, even though in
8249 -- general a complex will have the default representation
8250 -- of a record with two real components.
8252 Set_Has_Non_Standard_Rep (Base_Type (E));
8254 end Complex_Representation;
8256 -------------------------
8257 -- Component_Alignment --
8258 -------------------------
8260 -- pragma Component_Alignment (
8261 -- [Form =>] ALIGNMENT_CHOICE
8262 -- [, [Name =>] type_LOCAL_NAME]);
8264 -- ALIGNMENT_CHOICE ::=
8266 -- | Component_Size_4
8270 when Pragma_Component_Alignment => Component_AlignmentP : declare
8271 Args : Args_List (1 .. 2);
8272 Names : constant Name_List (1 .. 2) := (
8276 Form : Node_Id renames Args (1);
8277 Name : Node_Id renames Args (2);
8279 Atype : Component_Alignment_Kind;
8284 Gather_Associations (Names, Args);
8287 Error_Pragma ("missing Form argument for pragma%");
8290 Check_Arg_Is_Identifier (Form);
8292 -- Get proper alignment, note that Default = Component_Size on all
8293 -- machines we have so far, and we want to set this value rather
8294 -- than the default value to indicate that it has been explicitly
8295 -- set (and thus will not get overridden by the default component
8296 -- alignment for the current scope)
8298 if Chars (Form) = Name_Component_Size then
8299 Atype := Calign_Component_Size;
8301 elsif Chars (Form) = Name_Component_Size_4 then
8302 Atype := Calign_Component_Size_4;
8304 elsif Chars (Form) = Name_Default then
8305 Atype := Calign_Component_Size;
8307 elsif Chars (Form) = Name_Storage_Unit then
8308 Atype := Calign_Storage_Unit;
8312 ("invalid Form parameter for pragma%", Form);
8315 -- Case with no name, supplied, affects scope table entry
8319 (Scope_Stack.Last).Component_Alignment_Default := Atype;
8321 -- Case of name supplied
8324 Check_Arg_Is_Local_Name (Name);
8326 Typ := Entity (Name);
8329 or else Rep_Item_Too_Early (Typ, N)
8333 Typ := Underlying_Type (Typ);
8336 if not Is_Record_Type (Typ)
8337 and then not Is_Array_Type (Typ)
8340 ("Name parameter of pragma% must identify record or "
8341 & "array type", Name);
8344 -- An explicit Component_Alignment pragma overrides an
8345 -- implicit pragma Pack, but not an explicit one.
8347 if not Has_Pragma_Pack (Base_Type (Typ)) then
8348 Set_Is_Packed (Base_Type (Typ), False);
8349 Set_Component_Alignment (Base_Type (Typ), Atype);
8352 end Component_AlignmentP;
8358 -- pragma Contract_Case
8359 -- ([Name =>] Static_String_EXPRESSION
8360 -- ,[Mode =>] MODE_TYPE
8361 -- [, Requires => Boolean_EXPRESSION]
8362 -- [, Ensures => Boolean_EXPRESSION]);
8364 -- MODE_TYPE ::= Nominal | Robustness
8366 when Pragma_Contract_Case =>
8367 Check_Contract_Or_Test_Case;
8369 --------------------
8370 -- Contract_Cases --
8371 --------------------
8373 -- pragma Contract_Cases (CONTRACT_CASE_LIST);
8375 -- CONTRACT_CASE_LIST ::= CONTRACT_CASE {, CONTRACT_CASE}
8377 -- CONTRACT_CASE ::= CASE_GUARD => CONSEQUENCE
8379 -- CASE_GUARD ::= boolean_EXPRESSION | others
8381 -- CONSEQUENCE ::= boolean_EXPRESSION
8383 when Pragma_Contract_Cases => Contract_Cases : declare
8384 procedure Chain_Contract_Cases (Subp_Decl : Node_Id);
8385 -- Chain pragma Contract_Cases to the contract of a subprogram.
8386 -- Subp_Decl is the declaration of the subprogram.
8388 --------------------------
8389 -- Chain_Contract_Cases --
8390 --------------------------
8392 procedure Chain_Contract_Cases (Subp_Decl : Node_Id) is
8393 Subp : constant Entity_Id :=
8394 Defining_Unit_Name (Specification (Subp_Decl));
8398 Check_Duplicate_Pragma (Subp);
8399 CTC := Spec_CTC_List (Contract (Subp));
8400 while Present (CTC) loop
8401 if Chars (Pragma_Identifier (CTC)) = Pname then
8402 Error_Msg_Name_1 := Pname;
8403 Error_Msg_Sloc := Sloc (CTC);
8405 if From_Aspect_Specification (CTC) then
8407 ("aspect% for & previously given#", N, Subp);
8410 ("pragma% for & duplicates pragma#", N, Subp);
8416 CTC := Next_Pragma (CTC);
8419 -- Prepend pragma Contract_Cases to the contract
8421 Set_Next_Pragma (N, Spec_CTC_List (Contract (Subp)));
8422 Set_Spec_CTC_List (Contract (Subp), N);
8423 end Chain_Contract_Cases;
8427 Case_Guard : Node_Id;
8430 Others_Seen : Boolean := False;
8431 Contract_Case : Node_Id;
8432 Subp_Decl : Node_Id;
8434 -- Start of processing for Contract_Cases
8439 Check_Arg_Count (1);
8441 -- Completely ignore if disabled
8443 if not Check_Enabled (Pname) then
8444 Rewrite (N, Make_Null_Statement (Loc));
8449 -- Check the placement of the pragma
8451 if not Is_List_Member (N) then
8455 -- Pragma Contract_Cases must be associated with a subprogram
8458 while Present (Prev (Decl)) loop
8459 Decl := Prev (Decl);
8461 if Nkind (Decl) in N_Generic_Declaration then
8464 Subp_Decl := Original_Node (Decl);
8467 -- Skip prior pragmas
8469 if Nkind (Subp_Decl) = N_Pragma then
8472 -- Skip internally generated code
8474 elsif not Comes_From_Source (Subp_Decl) then
8477 -- We have found the related subprogram
8479 elsif Nkind_In (Subp_Decl, N_Generic_Subprogram_Declaration,
8480 N_Subprogram_Declaration)
8489 -- All contract cases must appear as an aggregate
8491 if Nkind (Expression (Arg1)) /= N_Aggregate then
8492 Error_Pragma ("wrong syntax for pragma %");
8496 -- Verify the legality of individual contract cases
8499 First (Component_Associations (Expression (Arg1)));
8500 while Present (Contract_Case) loop
8501 if Nkind (Contract_Case) /= N_Component_Association then
8503 ("wrong syntax in contract case", Contract_Case);
8507 Case_Guard := First (Choices (Contract_Case));
8509 -- Each contract case must have exactly on case guard
8511 Extra := Next (Case_Guard);
8512 if Present (Extra) then
8514 ("contract case may have only one case guard", Extra);
8518 -- Check the placement of "others" (if available)
8520 if Nkind (Case_Guard) = N_Others_Choice then
8523 ("only one others choice allowed in pragma %",
8527 Others_Seen := True;
8530 elsif Others_Seen then
8532 ("others must be the last choice in pragma %", N);
8536 Next (Contract_Case);
8539 Chain_Contract_Cases (Subp_Decl);
8546 -- pragma Controlled (first_subtype_LOCAL_NAME);
8548 when Pragma_Controlled => Controlled : declare
8552 Check_No_Identifiers;
8553 Check_Arg_Count (1);
8554 Check_Arg_Is_Local_Name (Arg1);
8555 Arg := Get_Pragma_Arg (Arg1);
8557 if not Is_Entity_Name (Arg)
8558 or else not Is_Access_Type (Entity (Arg))
8560 Error_Pragma_Arg ("pragma% requires access type", Arg1);
8562 Set_Has_Pragma_Controlled (Base_Type (Entity (Arg)));
8570 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
8571 -- [Entity =>] LOCAL_NAME);
8573 when Pragma_Convention => Convention : declare
8576 pragma Warnings (Off, C);
8577 pragma Warnings (Off, E);
8579 Check_Arg_Order ((Name_Convention, Name_Entity));
8580 Check_Ada_83_Warning;
8581 Check_Arg_Count (2);
8582 Process_Convention (C, E);
8585 ---------------------------
8586 -- Convention_Identifier --
8587 ---------------------------
8589 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
8590 -- [Convention =>] convention_IDENTIFIER);
8592 when Pragma_Convention_Identifier => Convention_Identifier : declare
8598 Check_Arg_Order ((Name_Name, Name_Convention));
8599 Check_Arg_Count (2);
8600 Check_Optional_Identifier (Arg1, Name_Name);
8601 Check_Optional_Identifier (Arg2, Name_Convention);
8602 Check_Arg_Is_Identifier (Arg1);
8603 Check_Arg_Is_Identifier (Arg2);
8604 Idnam := Chars (Get_Pragma_Arg (Arg1));
8605 Cname := Chars (Get_Pragma_Arg (Arg2));
8607 if Is_Convention_Name (Cname) then
8608 Record_Convention_Identifier
8609 (Idnam, Get_Convention_Id (Cname));
8612 ("second arg for % pragma must be convention", Arg2);
8614 end Convention_Identifier;
8620 -- pragma CPP_Class ([Entity =>] local_NAME)
8622 when Pragma_CPP_Class => CPP_Class : declare
8626 if Warn_On_Obsolescent_Feature then
8628 ("'G'N'A'T pragma cpp'_class is now obsolete and has no "
8629 & "effect; replace it by pragma import?j?", N);
8632 Check_Arg_Count (1);
8636 Chars => Name_Import,
8637 Pragma_Argument_Associations => New_List (
8638 Make_Pragma_Argument_Association (Loc,
8639 Expression => Make_Identifier (Loc, Name_CPP)),
8640 New_Copy (First (Pragma_Argument_Associations (N))))));
8644 ---------------------
8645 -- CPP_Constructor --
8646 ---------------------
8648 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME
8649 -- [, [External_Name =>] static_string_EXPRESSION ]
8650 -- [, [Link_Name =>] static_string_EXPRESSION ]);
8652 when Pragma_CPP_Constructor => CPP_Constructor : declare
8656 Tag_Typ : Entity_Id;
8660 Check_At_Least_N_Arguments (1);
8661 Check_At_Most_N_Arguments (3);
8662 Check_Optional_Identifier (Arg1, Name_Entity);
8663 Check_Arg_Is_Local_Name (Arg1);
8665 Id := Get_Pragma_Arg (Arg1);
8666 Find_Program_Unit_Name (Id);
8668 -- If we did not find the name, we are done
8670 if Etype (Id) = Any_Type then
8674 Def_Id := Entity (Id);
8676 -- Check if already defined as constructor
8678 if Is_Constructor (Def_Id) then
8680 ("??duplicate argument for pragma 'C'P'P_Constructor", Arg1);
8684 if Ekind (Def_Id) = E_Function
8685 and then (Is_CPP_Class (Etype (Def_Id))
8686 or else (Is_Class_Wide_Type (Etype (Def_Id))
8688 Is_CPP_Class (Root_Type (Etype (Def_Id)))))
8690 if Scope (Def_Id) /= Scope (Etype (Def_Id)) then
8692 ("'C'P'P constructor must be defined in the scope of "
8693 & "its returned type", Arg1);
8696 if Arg_Count >= 2 then
8697 Set_Imported (Def_Id);
8698 Set_Is_Public (Def_Id);
8699 Process_Interface_Name (Def_Id, Arg2, Arg3);
8702 Set_Has_Completion (Def_Id);
8703 Set_Is_Constructor (Def_Id);
8704 Set_Convention (Def_Id, Convention_CPP);
8706 -- Imported C++ constructors are not dispatching primitives
8707 -- because in C++ they don't have a dispatch table slot.
8708 -- However, in Ada the constructor has the profile of a
8709 -- function that returns a tagged type and therefore it has
8710 -- been treated as a primitive operation during semantic
8711 -- analysis. We now remove it from the list of primitive
8712 -- operations of the type.
8714 if Is_Tagged_Type (Etype (Def_Id))
8715 and then not Is_Class_Wide_Type (Etype (Def_Id))
8716 and then Is_Dispatching_Operation (Def_Id)
8718 Tag_Typ := Etype (Def_Id);
8720 Elmt := First_Elmt (Primitive_Operations (Tag_Typ));
8721 while Present (Elmt) and then Node (Elmt) /= Def_Id loop
8725 Remove_Elmt (Primitive_Operations (Tag_Typ), Elmt);
8726 Set_Is_Dispatching_Operation (Def_Id, False);
8729 -- For backward compatibility, if the constructor returns a
8730 -- class wide type, and we internally change the return type to
8731 -- the corresponding root type.
8733 if Is_Class_Wide_Type (Etype (Def_Id)) then
8734 Set_Etype (Def_Id, Root_Type (Etype (Def_Id)));
8738 ("pragma% requires function returning a 'C'P'P_Class type",
8741 end CPP_Constructor;
8747 when Pragma_CPP_Virtual => CPP_Virtual : declare
8751 if Warn_On_Obsolescent_Feature then
8753 ("'G'N'A'T pragma cpp'_virtual is now obsolete and has no "
8762 when Pragma_CPP_Vtable => CPP_Vtable : declare
8766 if Warn_On_Obsolescent_Feature then
8768 ("'G'N'A'T pragma cpp'_vtable is now obsolete and has no "
8777 -- pragma CPU (EXPRESSION);
8779 when Pragma_CPU => CPU : declare
8780 P : constant Node_Id := Parent (N);
8786 Check_No_Identifiers;
8787 Check_Arg_Count (1);
8791 if Nkind (P) = N_Subprogram_Body then
8792 Check_In_Main_Program;
8794 Arg := Get_Pragma_Arg (Arg1);
8795 Analyze_And_Resolve (Arg, Any_Integer);
8797 Ent := Defining_Unit_Name (Specification (P));
8799 if Nkind (Ent) = N_Defining_Program_Unit_Name then
8800 Ent := Defining_Identifier (Ent);
8805 if not Is_Static_Expression (Arg) then
8806 Flag_Non_Static_Expr
8807 ("main subprogram affinity is not static!", Arg);
8810 -- If constraint error, then we already signalled an error
8812 elsif Raises_Constraint_Error (Arg) then
8815 -- Otherwise check in range
8819 CPU_Id : constant Entity_Id := RTE (RE_CPU_Range);
8820 -- This is the entity System.Multiprocessors.CPU_Range;
8822 Val : constant Uint := Expr_Value (Arg);
8825 if Val < Expr_Value (Type_Low_Bound (CPU_Id))
8827 Val > Expr_Value (Type_High_Bound (CPU_Id))
8830 ("main subprogram CPU is out of range", Arg1);
8836 (Current_Sem_Unit, UI_To_Int (Expr_Value (Arg)));
8840 elsif Nkind (P) = N_Task_Definition then
8841 Arg := Get_Pragma_Arg (Arg1);
8842 Ent := Defining_Identifier (Parent (P));
8844 -- The expression must be analyzed in the special manner
8845 -- described in "Handling of Default and Per-Object
8846 -- Expressions" in sem.ads.
8848 Preanalyze_Spec_Expression (Arg, RTE (RE_CPU_Range));
8850 -- Anything else is incorrect
8856 -- Check duplicate pragma before we chain the pragma in the Rep
8857 -- Item chain of Ent.
8859 Check_Duplicate_Pragma (Ent);
8860 Record_Rep_Item (Ent, N);
8867 -- pragma Debug ([boolean_EXPRESSION,] PROCEDURE_CALL_STATEMENT);
8869 when Pragma_Debug => Debug : declare
8876 -- Skip analysis if disabled
8878 if Debug_Pragmas_Disabled then
8879 Rewrite (N, Make_Null_Statement (Loc));
8886 (Boolean_Literals (Debug_Pragmas_Enabled and Expander_Active),
8889 if Debug_Pragmas_Enabled then
8890 Set_SCO_Pragma_Enabled (Loc);
8893 if Arg_Count = 2 then
8896 Left_Opnd => Relocate_Node (Cond),
8897 Right_Opnd => Get_Pragma_Arg (Arg1));
8898 Call := Get_Pragma_Arg (Arg2);
8900 Call := Get_Pragma_Arg (Arg1);
8904 N_Indexed_Component,
8908 N_Selected_Component)
8910 -- If this pragma Debug comes from source, its argument was
8911 -- parsed as a name form (which is syntactically identical).
8912 -- In a generic context a parameterless call will be left as
8913 -- an expanded name (if global) or selected_component if local.
8914 -- Change it to a procedure call statement now.
8916 Change_Name_To_Procedure_Call_Statement (Call);
8918 elsif Nkind (Call) = N_Procedure_Call_Statement then
8920 -- Already in the form of a procedure call statement: nothing
8921 -- to do (could happen in case of an internally generated
8927 -- All other cases: diagnose error
8930 ("argument of pragma ""Debug"" is not procedure call",
8935 -- Rewrite into a conditional with an appropriate condition. We
8936 -- wrap the procedure call in a block so that overhead from e.g.
8937 -- use of the secondary stack does not generate execution overhead
8938 -- for suppressed conditions.
8940 -- Normally the analysis that follows will freeze the subprogram
8941 -- being called. However, if the call is to a null procedure,
8942 -- we want to freeze it before creating the block, because the
8943 -- analysis that follows may be done with expansion disabled, in
8944 -- which case the body will not be generated, leading to spurious
8947 if Nkind (Call) = N_Procedure_Call_Statement
8948 and then Is_Entity_Name (Name (Call))
8950 Analyze (Name (Call));
8951 Freeze_Before (N, Entity (Name (Call)));
8954 Rewrite (N, Make_Implicit_If_Statement (N,
8956 Then_Statements => New_List (
8957 Make_Block_Statement (Loc,
8958 Handled_Statement_Sequence =>
8959 Make_Handled_Sequence_Of_Statements (Loc,
8960 Statements => New_List (Relocate_Node (Call)))))));
8968 -- pragma Debug_Policy (Check | Ignore)
8970 when Pragma_Debug_Policy =>
8972 Check_Arg_Count (1);
8973 Check_Arg_Is_One_Of (Arg1, Name_Check, Name_Disable, Name_Ignore);
8974 Debug_Pragmas_Enabled :=
8975 Chars (Get_Pragma_Arg (Arg1)) = Name_Check;
8976 Debug_Pragmas_Disabled :=
8977 Chars (Get_Pragma_Arg (Arg1)) = Name_Disable;
8983 -- pragma Depends (DEPENDENCY_RELATION);
8985 -- DEPENDENCY_RELATION ::=
8987 -- | DEPENDENCY_CLAUSE {, DEPENDENCY_CLAUSE}
8989 -- DEPENDENCY_CLAUSE ::= OUTPUT_LIST =>[+] INPUT_LIST
8991 -- OUTPUT_LIST ::= null | OUTPUT | (OUTPUT {, OUTPUT})
8993 -- INPUT_LIST ::= null | INPUT | (INPUT {, INPUT})
8995 -- OUTPUT ::= NAME | FUNCTION_RESULT
8998 -- where FUNCTION_RESULT is a function Result attribute_reference
9000 when Pragma_Depends => Depends : declare
9001 All_Inputs_Seen : Elist_Id := No_Elist;
9002 -- A list containing the entities of all the inputs processed so
9003 -- far. This Elist is populated with unique entities because the
9004 -- same input may appear in multiple input lists.
9006 Global_Seen : Boolean := False;
9007 -- A flag set when pragma Global has been processed
9009 Outputs_Seen : Elist_Id := No_Elist;
9010 -- A list containing the entities of all the outputs processed so
9011 -- far. The elements of this list may come from different output
9014 Null_Output_Seen : Boolean := False;
9015 -- A flag used to track the legality of a null output
9017 Result_Seen : Boolean := False;
9018 -- A flag set when Subp_Id'Result is processed
9020 Subp_Id : Entity_Id;
9021 -- The entity of the subprogram subject to pragma Depends
9023 Subp_Inputs : Elist_Id := No_Elist;
9024 Subp_Outputs : Elist_Id := No_Elist;
9025 -- Two lists containing the full set of inputs and output of the
9026 -- related subprograms. Note that these lists contain both nodes
9029 procedure Analyze_Dependency_Clause
9032 -- Verify the legality of a single dependency clause. Flag Is_Last
9033 -- denotes whether Clause is the last clause in the relation.
9037 Item_Id : Entity_Id) return Boolean;
9038 -- Determine whether a particular item appears in a mixed list of
9039 -- nodes and entities.
9041 procedure Check_Function_Return;
9042 -- Verify that Funtion'Result appears as one of the outputs
9044 procedure Check_Mode
9046 Item_Id : Entity_Id;
9047 Is_Input : Boolean);
9048 -- Ensure that an item has a proper "in", "in out" or "out" mode
9049 -- depending on its function. If this is not the case, emit an
9052 procedure Check_Usage
9053 (Subp_List : Elist_Id;
9054 Item_List : Elist_Id;
9055 Is_Input : Boolean);
9056 -- Verify that all items from list Subp_List appear in Item_List.
9057 -- Emit an error if this is not the case.
9059 procedure Collect_Subprogram_Inputs_Outputs;
9060 -- Gather all inputs and outputs of the subprogram. These are the
9061 -- formal parameters and entities classified in pragma Global.
9063 procedure Normalize_Clause (Clause : Node_Id);
9064 -- Remove a self-dependency "+" from the input list of a clause.
9065 -- Depending on the contents of the relation, either split the
9066 -- the clause into multiple smaller clauses or perform the
9067 -- normalization in place.
9069 -------------------------------
9070 -- Analyze_Dependency_Clause --
9071 -------------------------------
9073 procedure Analyze_Dependency_Clause
9077 procedure Analyze_Input_List (Inputs : Node_Id);
9078 -- Verify the legality of a single input list
9080 procedure Analyze_Input_Output
9083 Top_Level : Boolean;
9084 Seen : in out Elist_Id;
9085 Null_Seen : in out Boolean);
9086 -- Verify the legality of a single input or output item. Flag
9087 -- Is_Input should be set whenever Item is an input, False when
9088 -- it denotes an output. Flag Top_Level should be set whenever
9089 -- Item appears immediately within an input or output list.
9090 -- Seen is a collection of all abstract states, variables and
9091 -- formals processed so far. Flag Null_Seen denotes whether a
9092 -- null input or output has been encountered.
9094 ------------------------
9095 -- Analyze_Input_List --
9096 ------------------------
9098 procedure Analyze_Input_List (Inputs : Node_Id) is
9099 Inputs_Seen : Elist_Id := No_Elist;
9100 -- A list containing the entities of all inputs that appear
9101 -- in the current input list.
9103 Null_Input_Seen : Boolean := False;
9104 -- A flag used to track the legality of a null input
9109 -- Multiple inputs appear as an aggregate
9111 if Nkind (Inputs) = N_Aggregate then
9112 if Present (Component_Associations (Inputs)) then
9114 ("nested dependency relations not allowed", Inputs);
9116 elsif Present (Expressions (Inputs)) then
9117 Input := First (Expressions (Inputs));
9118 while Present (Input) loop
9119 Analyze_Input_Output
9123 Seen => Inputs_Seen,
9124 Null_Seen => Null_Input_Seen);
9131 ("malformed input dependency list", Inputs);
9134 -- Process a solitary input
9137 Analyze_Input_Output
9141 Seen => Inputs_Seen,
9142 Null_Seen => Null_Input_Seen);
9144 end Analyze_Input_List;
9146 --------------------------
9147 -- Analyze_Input_Output --
9148 --------------------------
9150 procedure Analyze_Input_Output
9153 Top_Level : Boolean;
9154 Seen : in out Elist_Id;
9155 Null_Seen : in out Boolean)
9157 Is_Output : constant Boolean := not Is_Input;
9159 Item_Id : Entity_Id;
9162 -- Multiple input or output items appear as an aggregate
9164 if Nkind (Item) = N_Aggregate then
9165 if not Top_Level then
9167 ("nested grouping of items not allowed", Item);
9169 elsif Present (Component_Associations (Item)) then
9171 ("nested dependency relations not allowed", Item);
9173 -- Recursively analyze the grouped items
9175 elsif Present (Expressions (Item)) then
9176 Grouped := First (Expressions (Item));
9177 while Present (Grouped) loop
9178 Analyze_Input_Output
9180 Is_Input => Is_Input,
9183 Null_Seen => Null_Seen);
9189 Error_Msg_N ("malformed dependency list", Item);
9192 -- Process Function'Result in the context of a dependency
9195 elsif Nkind (Item) = N_Attribute_Reference
9196 and then Attribute_Name (Item) = Name_Result
9198 -- It is sufficent to analyze the prefix of 'Result in
9199 -- order to establish legality of the attribute.
9201 Analyze (Prefix (Item));
9203 -- The prefix of 'Result must denote the function for
9204 -- which aspect/pragma Depends applies.
9206 if not Is_Entity_Name (Prefix (Item))
9207 or else Ekind (Subp_Id) /= E_Function
9208 or else Entity (Prefix (Item)) /= Subp_Id
9210 Error_Msg_Name_1 := Name_Result;
9212 ("prefix of attribute % must denote the enclosing "
9213 & "function", Item);
9215 -- Function'Result is allowed to appear on the output
9216 -- side of a dependency clause.
9220 ("function result cannot act as input", Item);
9223 Result_Seen := True;
9226 -- Detect multiple uses of null in a single dependency list
9227 -- or throughout the whole relation. Verify the placement of
9228 -- a null output list relative to the other clauses.
9230 elsif Nkind (Item) = N_Null then
9233 ("multiple null dependency relations not allowed",
9238 if Is_Output and then not Is_Last then
9240 ("null output list must be the last clause in "
9241 & "a dependency relation", Item);
9250 -- Find the entity of the item. If this is a renaming,
9251 -- climb the renaming chain to reach the root object.
9252 -- Renamings of non-entire objects do not yield an
9255 Item_Id := Entity_Of (Item);
9257 if Present (Item_Id) then
9258 if Ekind_In (Item_Id, E_Abstract_State,
9264 -- Ensure that the item is of the correct mode
9265 -- depending on its function.
9267 Check_Mode (Item, Item_Id, Is_Input);
9269 -- Detect multiple uses of the same state, variable
9270 -- or formal parameter. If this is not the case,
9271 -- add the item to the list of processed relations.
9273 if Contains (Seen, Item_Id) then
9274 Error_Msg_N ("duplicate use of item", Item);
9276 Add_Item (Item_Id, Seen);
9279 -- Detect an illegal use of an input related to a
9280 -- null output. Such input items cannot appear in
9281 -- other input lists.
9284 and then Contains (All_Inputs_Seen, Item_Id)
9287 ("input of a null output list appears in "
9288 & "multiple input lists", Item);
9290 Add_Item (Item_Id, All_Inputs_Seen);
9293 -- When the item renames an entire object, replace
9294 -- the item with a reference to the object.
9296 if Present (Renamed_Object (Entity (Item))) then
9298 New_Reference_To (Item_Id, Sloc (Item)));
9302 -- All other input/output items are illegal
9306 ("item must denote variable, state or formal "
9307 & "parameter", Item);
9310 -- All other input/output items are illegal
9314 ("item must denote variable, state or formal "
9315 & "parameter", Item);
9318 end Analyze_Input_Output;
9325 -- Start of processing for Analyze_Dependency_Clause
9328 -- Process the output_list of a dependency_clause
9330 Output := First (Choices (Clause));
9331 while Present (Output) loop
9332 Analyze_Input_Output
9336 Seen => Outputs_Seen,
9337 Null_Seen => Null_Output_Seen);
9342 -- Process the input_list of a dependency_clause
9344 Inputs := Expression (Clause);
9346 -- An input list with a self-dependency appears as operator "+"
9347 -- where the actuals inputs are the right operand.
9349 if Nkind (Inputs) = N_Op_Plus then
9350 Inputs := Right_Opnd (Inputs);
9353 Analyze_Input_List (Inputs);
9354 end Analyze_Dependency_Clause;
9362 Item_Id : Entity_Id) return Boolean
9368 if Present (List) then
9369 Elmt := First_Elmt (List);
9370 while Present (Elmt) loop
9371 if Nkind (Node (Elmt)) = N_Defining_Identifier then
9374 Id := Entity (Node (Elmt));
9377 if Id = Item_Id then
9388 ----------------------------
9389 -- Check_Function_Return --
9390 ----------------------------
9392 procedure Check_Function_Return is
9394 if Ekind (Subp_Id) = E_Function and then not Result_Seen then
9396 ("result of & must appear in exactly one output list",
9399 end Check_Function_Return;
9405 procedure Check_Mode
9407 Item_Id : Entity_Id;
9412 if Ekind (Item_Id) = E_Out_Parameter
9413 or else (Global_Seen
9414 and then not Appears_In (Subp_Inputs, Item_Id))
9417 ("item & must have mode in or in out", Item, Item_Id);
9423 if Ekind (Item_Id) = E_In_Parameter
9426 and then not Appears_In (Subp_Outputs, Item_Id))
9429 ("item & must have mode out or in out", Item, Item_Id);
9438 procedure Check_Usage
9439 (Subp_List : Elist_Id;
9440 Item_List : Elist_Id;
9443 procedure Usage_Error (Item : Node_Id; Item_Id : Entity_Id);
9444 -- Emit an error concerning the erroneous usage of an item
9450 procedure Usage_Error (Item : Node_Id; Item_Id : Entity_Id) is
9454 ("item & must appear in at least one input list of "
9455 & "aspect Depends", Item, Item_Id);
9458 ("item & must appear in exactly one output list of "
9459 & "aspect Depends", Item, Item_Id);
9467 Item_Id : Entity_Id;
9469 -- Start of processing for Check_Usage
9472 if No (Subp_List) then
9476 -- Each input or output of the subprogram must appear in a
9477 -- dependency relation.
9479 Elmt := First_Elmt (Subp_List);
9480 while Present (Elmt) loop
9481 Item := Node (Elmt);
9483 if Nkind (Item) = N_Defining_Identifier then
9486 Item_Id := Entity (Item);
9489 -- The item does not appear in a dependency
9491 if not Contains (Item_List, Item_Id) then
9492 if Is_Formal (Item_Id) then
9493 Usage_Error (Item, Item_Id);
9495 -- States and global variables are not used properly only
9496 -- when the subprogram is subject to pragma Global.
9498 elsif Global_Seen then
9499 Usage_Error (Item, Item_Id);
9507 ---------------------------------------
9508 -- Collect_Subprogram_Inputs_Outputs --
9509 ---------------------------------------
9511 procedure Collect_Subprogram_Inputs_Outputs is
9512 procedure Collect_Global_List
9514 Mode : Name_Id := Name_Input);
9515 -- Collect all relevant items from a global list
9517 -------------------------
9518 -- Collect_Global_List --
9519 -------------------------
9521 procedure Collect_Global_List
9523 Mode : Name_Id := Name_Input)
9525 procedure Collect_Global_Item
9528 -- Add an item to the proper subprogram input or output
9531 -------------------------
9532 -- Collect_Global_Item --
9533 -------------------------
9535 procedure Collect_Global_Item
9540 if Mode = Name_In_Out or else Mode = Name_Input then
9541 Add_Item (Item, Subp_Inputs);
9544 if Mode = Name_In_Out or else Mode = Name_Output then
9545 Add_Item (Item, Subp_Outputs);
9547 end Collect_Global_Item;
9554 -- Start of processing for Collect_Global_List
9557 -- Single global item declaration
9559 if Nkind_In (List, N_Identifier, N_Selected_Component) then
9560 Collect_Global_Item (List, Mode);
9562 -- Simple global list or moded global list declaration
9565 if Present (Expressions (List)) then
9566 Item := First (Expressions (List));
9567 while Present (Item) loop
9568 Collect_Global_Item (Item, Mode);
9574 Assoc := First (Component_Associations (List));
9575 while Present (Assoc) loop
9577 (List => Expression (Assoc),
9578 Mode => Chars (First (Choices (Assoc))));
9584 end Collect_Global_List;
9592 -- Start of processing for Collect_Subprogram_Inputs_Outputs
9595 -- Process all formal parameters
9597 Formal := First_Formal (Subp_Id);
9598 while Present (Formal) loop
9599 if Ekind_In (Formal, E_In_Out_Parameter,
9602 Add_Item (Formal, Subp_Inputs);
9605 if Ekind_In (Formal, E_In_Out_Parameter,
9608 Add_Item (Formal, Subp_Outputs);
9611 Next_Formal (Formal);
9614 -- If the subprogram is subject to pragma Global, traverse all
9615 -- global lists and gather the relevant items.
9617 Global := Find_Aspect (Subp_Id, Aspect_Global);
9618 if Present (Global) then
9619 Global_Seen := True;
9621 -- Retrieve the pragma as it contains the analyzed lists
9623 Global := Aspect_Rep_Item (Global);
9625 -- The pragma may not have been analyzed because of the
9626 -- arbitrary declaration order of aspects. Make sure that
9627 -- it is analyzed for the purposes of item extraction.
9629 if not Analyzed (Global) then
9634 Expression (First (Pragma_Argument_Associations (Global)));
9636 -- Nothing to be done for a null global list
9638 if Nkind (List) /= N_Null then
9639 Collect_Global_List (List);
9642 end Collect_Subprogram_Inputs_Outputs;
9644 ----------------------
9645 -- Normalize_Clause --
9646 ----------------------
9648 procedure Normalize_Clause (Clause : Node_Id) is
9649 procedure Create_Or_Modify_Clause
9655 Multiple : Boolean);
9656 -- Create a brand new clause to represent the self-reference
9657 -- or modify the input and/or output lists of an existing
9658 -- clause. Output denotes a self-referencial output. Outputs
9659 -- is the output list of a clause. Inputs is the input list
9660 -- of a clause. After denotes the clause after which the new
9661 -- clause is to be inserted. Flag In_Place should be set when
9662 -- normalizing the last output of an output list. Flag Multiple
9663 -- should be set when Output comes from a list with multiple
9666 -----------------------------
9667 -- Create_Or_Modify_Clause --
9668 -----------------------------
9670 procedure Create_Or_Modify_Clause
9678 procedure Propagate_Output
9681 -- Handle the various cases of output propagation to the
9682 -- input list. Output denotes a self-referencial output
9683 -- item. Inputs is the input list of a clause.
9685 ----------------------
9686 -- Propagate_Output --
9687 ----------------------
9689 procedure Propagate_Output
9693 function In_Input_List
9695 Inputs : List_Id) return Boolean;
9696 -- Determine whether a particulat item appears in the
9697 -- input list of a clause.
9703 function In_Input_List
9705 Inputs : List_Id) return Boolean
9710 Elmt := First (Inputs);
9711 while Present (Elmt) loop
9712 if Entity_Of (Elmt) = Item then
9724 Output_Id : constant Entity_Id := Entity_Of (Output);
9727 -- Start of processing for Propagate_Output
9730 -- The clause is of the form:
9732 -- (Output =>+ null)
9734 -- Remove the null input and replace it with a copy of
9737 -- (Output => Output)
9739 if Nkind (Inputs) = N_Null then
9740 Rewrite (Inputs, New_Copy_Tree (Output));
9742 -- The clause is of the form:
9744 -- (Output =>+ (Input1, ..., InputN))
9746 -- Determine whether the output is not already mentioned
9747 -- in the input list and if not, add it to the list of
9750 -- (Output => (Output, Input1, ..., InputN))
9752 elsif Nkind (Inputs) = N_Aggregate then
9753 Grouped := Expressions (Inputs);
9755 if not In_Input_List
9759 Prepend_To (Grouped, New_Copy_Tree (Output));
9762 -- The clause is of the form:
9764 -- (Output =>+ Input)
9766 -- If the input does not mention the output, group the
9769 -- (Output => (Output, Input))
9771 elsif Entity_Of (Inputs) /= Output_Id then
9773 Make_Aggregate (Loc,
9774 Expressions => New_List (
9775 New_Copy_Tree (Output),
9776 New_Copy_Tree (Inputs))));
9778 end Propagate_Output;
9782 Loc : constant Source_Ptr := Sloc (Output);
9785 -- Start of processing for Create_Or_Modify_Clause
9788 -- A function result cannot depend on itself because it
9789 -- cannot appear in the input list of a relation.
9791 if Nkind (Output) = N_Attribute_Reference
9792 and then Attribute_Name (Output) = Name_Result
9795 ("function result cannot depend on itself", Output);
9798 -- A null output depending on itself does not require any
9801 elsif Nkind (Output) = N_Null then
9805 -- When performing the transformation in place, simply add
9806 -- the output to the list of inputs (if not already there).
9807 -- This case arises when dealing with the last output of an
9808 -- output list - we perform the normalization in place to
9809 -- avoid generating a malformed tree.
9812 Propagate_Output (Output, Inputs);
9814 -- A list with multiple outputs is slowly trimmed until
9815 -- only one element remains. When this happens, replace
9816 -- the aggregate with the element itself.
9820 Rewrite (Outputs, Output);
9826 -- Unchain the output from its output list as it will
9827 -- appear in a new clause. Note that we cannot simply
9828 -- rewrite the output as null because this will violate
9829 -- the semantics of aspect/pragma Depends.
9833 -- Create a new clause of the form:
9835 -- (Output => Inputs)
9838 Make_Component_Association (Loc,
9839 Choices => New_List (Output),
9840 Expression => New_Copy_Tree (Inputs));
9842 -- The new clause contains replicated content that has
9843 -- already been analyzed. There is not need to reanalyze
9844 -- it or renormalize it again.
9846 Set_Analyzed (Clause);
9849 (Output => First (Choices (Clause)),
9850 Inputs => Expression (Clause));
9852 Insert_After (After, Clause);
9854 end Create_Or_Modify_Clause;
9858 Outputs : constant Node_Id := First (Choices (Clause));
9860 Last_Output : Node_Id;
9861 Next_Output : Node_Id;
9864 -- Start of processing for Normalize_Clause
9867 -- A self-dependency appears as operator "+". Remove the "+"
9868 -- from the tree by moving the real inputs to their proper
9871 if Nkind (Expression (Clause)) = N_Op_Plus then
9873 (Expression (Clause), Right_Opnd (Expression (Clause)));
9874 Inputs := Expression (Clause);
9876 -- Multiple outputs appear as an aggregate
9878 if Nkind (Outputs) = N_Aggregate then
9879 Last_Output := Last (Expressions (Outputs));
9881 Output := First (Expressions (Outputs));
9882 while Present (Output) loop
9884 -- Normalization may remove an output from its list,
9885 -- preserve the subsequent output now.
9887 Next_Output := Next (Output);
9889 Create_Or_Modify_Clause
9894 In_Place => Output = Last_Output,
9897 Output := Next_Output;
9903 Create_Or_Modify_Clause
9912 end Normalize_Clause;
9918 Last_Clause : Node_Id;
9919 Subp_Decl : Node_Id;
9921 -- Start of processing for Depends
9926 Check_Arg_Count (1);
9928 -- Ensure the proper placement of the pragma. Depends must be
9929 -- associated with a subprogram declaration.
9931 Subp_Decl := Parent (Corresponding_Aspect (N));
9933 if Nkind (Subp_Decl) /= N_Subprogram_Declaration then
9938 Subp_Id := Defining_Unit_Name (Specification (Subp_Decl));
9939 Clause := Expression (Arg1);
9941 -- Empty dependency list
9943 if Nkind (Clause) = N_Null then
9945 -- Gather all states, variables and formal parameters that the
9946 -- subprogram may depend on. These items are obtained from the
9947 -- parameter profile or pragma Global (if available).
9949 Collect_Subprogram_Inputs_Outputs;
9951 -- Verify that every input or output of the subprogram appear
9954 Check_Usage (Subp_Inputs, All_Inputs_Seen, True);
9955 Check_Usage (Subp_Outputs, Outputs_Seen, False);
9956 Check_Function_Return;
9958 -- Dependency clauses appear as component associations of an
9961 elsif Nkind (Clause) = N_Aggregate
9962 and then Present (Component_Associations (Clause))
9964 Last_Clause := Last (Component_Associations (Clause));
9966 -- Gather all states, variables and formal parameters that the
9967 -- subprogram may depend on. These items are obtained from the
9968 -- parameter profile or pragma Global (if available).
9970 Collect_Subprogram_Inputs_Outputs;
9972 -- Ensure that the formal parameters are visible when analyzing
9973 -- all clauses. This falls out of the general rule of aspects
9974 -- pertaining to subprogram declarations.
9976 Push_Scope (Subp_Id);
9977 Install_Formals (Subp_Id);
9979 Clause := First (Component_Associations (Clause));
9980 while Present (Clause) loop
9981 Errors := Serious_Errors_Detected;
9983 -- Normalization may create extra clauses that contain
9984 -- replicated input and output names. There is no need
9985 -- to reanalyze or renormalize these extra clauses.
9987 if not Analyzed (Clause) then
9988 Set_Analyzed (Clause);
9990 Analyze_Dependency_Clause
9992 Is_Last => Clause = Last_Clause);
9994 -- Do not normalize an erroneous clause because the
9995 -- inputs or outputs may denote illegal items.
9997 if Errors = Serious_Errors_Detected then
9998 Normalize_Clause (Clause);
10007 -- Verify that every input or output of the subprogram appear
10008 -- in a dependency.
10010 Check_Usage (Subp_Inputs, All_Inputs_Seen, True);
10011 Check_Usage (Subp_Outputs, Outputs_Seen, False);
10012 Check_Function_Return;
10014 -- The top level dependency relation is malformed
10017 Error_Msg_N ("malformed dependency relation", Clause);
10021 ---------------------
10022 -- Detect_Blocking --
10023 ---------------------
10025 -- pragma Detect_Blocking;
10027 when Pragma_Detect_Blocking =>
10029 Check_Arg_Count (0);
10030 Check_Valid_Configuration_Pragma;
10031 Detect_Blocking := True;
10033 --------------------------
10034 -- Default_Storage_Pool --
10035 --------------------------
10037 -- pragma Default_Storage_Pool (storage_pool_NAME | null);
10039 when Pragma_Default_Storage_Pool =>
10041 Check_Arg_Count (1);
10043 -- Default_Storage_Pool can appear as a configuration pragma, or
10044 -- in a declarative part or a package spec.
10046 if not Is_Configuration_Pragma then
10047 Check_Is_In_Decl_Part_Or_Package_Spec;
10050 -- Case of Default_Storage_Pool (null);
10052 if Nkind (Expression (Arg1)) = N_Null then
10053 Analyze (Expression (Arg1));
10055 -- This is an odd case, this is not really an expression, so
10056 -- we don't have a type for it. So just set the type to Empty.
10058 Set_Etype (Expression (Arg1), Empty);
10060 -- Case of Default_Storage_Pool (storage_pool_NAME);
10063 -- If it's a configuration pragma, then the only allowed
10064 -- argument is "null".
10066 if Is_Configuration_Pragma then
10067 Error_Pragma_Arg ("NULL expected", Arg1);
10070 -- The expected type for a non-"null" argument is
10071 -- Root_Storage_Pool'Class.
10073 Analyze_And_Resolve
10074 (Get_Pragma_Arg (Arg1),
10075 Typ => Class_Wide_Type (RTE (RE_Root_Storage_Pool)));
10078 -- Finally, record the pool name (or null). Freeze.Freeze_Entity
10079 -- for an access type will use this information to set the
10080 -- appropriate attributes of the access type.
10082 Default_Pool := Expression (Arg1);
10084 ------------------------------------
10085 -- Disable_Atomic_Synchronization --
10086 ------------------------------------
10088 -- pragma Disable_Atomic_Synchronization [(Entity)];
10090 when Pragma_Disable_Atomic_Synchronization =>
10091 Process_Disable_Enable_Atomic_Sync (Name_Suppress);
10093 -------------------
10094 -- Discard_Names --
10095 -------------------
10097 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
10099 when Pragma_Discard_Names => Discard_Names : declare
10104 Check_Ada_83_Warning;
10106 -- Deal with configuration pragma case
10108 if Arg_Count = 0 and then Is_Configuration_Pragma then
10109 Global_Discard_Names := True;
10112 -- Otherwise, check correct appropriate context
10115 Check_Is_In_Decl_Part_Or_Package_Spec;
10117 if Arg_Count = 0 then
10119 -- If there is no parameter, then from now on this pragma
10120 -- applies to any enumeration, exception or tagged type
10121 -- defined in the current declarative part, and recursively
10122 -- to any nested scope.
10124 Set_Discard_Names (Current_Scope);
10128 Check_Arg_Count (1);
10129 Check_Optional_Identifier (Arg1, Name_On);
10130 Check_Arg_Is_Local_Name (Arg1);
10132 E_Id := Get_Pragma_Arg (Arg1);
10134 if Etype (E_Id) = Any_Type then
10137 E := Entity (E_Id);
10140 if (Is_First_Subtype (E)
10142 (Is_Enumeration_Type (E) or else Is_Tagged_Type (E)))
10143 or else Ekind (E) = E_Exception
10145 Set_Discard_Names (E);
10146 Record_Rep_Item (E, N);
10150 ("inappropriate entity for pragma%", Arg1);
10157 ------------------------
10158 -- Dispatching_Domain --
10159 ------------------------
10161 -- pragma Dispatching_Domain (EXPRESSION);
10163 when Pragma_Dispatching_Domain => Dispatching_Domain : declare
10164 P : constant Node_Id := Parent (N);
10170 Check_No_Identifiers;
10171 Check_Arg_Count (1);
10173 -- This pragma is born obsolete, but not the aspect
10175 if not From_Aspect_Specification (N) then
10177 (No_Obsolescent_Features, Pragma_Identifier (N));
10180 if Nkind (P) = N_Task_Definition then
10181 Arg := Get_Pragma_Arg (Arg1);
10182 Ent := Defining_Identifier (Parent (P));
10184 -- The expression must be analyzed in the special manner
10185 -- described in "Handling of Default and Per-Object
10186 -- Expressions" in sem.ads.
10188 Preanalyze_Spec_Expression (Arg, RTE (RE_Dispatching_Domain));
10190 -- Check duplicate pragma before we chain the pragma in the Rep
10191 -- Item chain of Ent.
10193 Check_Duplicate_Pragma (Ent);
10194 Record_Rep_Item (Ent, N);
10196 -- Anything else is incorrect
10201 end Dispatching_Domain;
10207 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
10209 when Pragma_Elaborate => Elaborate : declare
10214 -- Pragma must be in context items list of a compilation unit
10216 if not Is_In_Context_Clause then
10220 -- Must be at least one argument
10222 if Arg_Count = 0 then
10223 Error_Pragma ("pragma% requires at least one argument");
10226 -- In Ada 83 mode, there can be no items following it in the
10227 -- context list except other pragmas and implicit with clauses
10228 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
10229 -- placement rule does not apply.
10231 if Ada_Version = Ada_83 and then Comes_From_Source (N) then
10233 while Present (Citem) loop
10234 if Nkind (Citem) = N_Pragma
10235 or else (Nkind (Citem) = N_With_Clause
10236 and then Implicit_With (Citem))
10241 ("(Ada 83) pragma% must be at end of context clause");
10248 -- Finally, the arguments must all be units mentioned in a with
10249 -- clause in the same context clause. Note we already checked (in
10250 -- Par.Prag) that the arguments are all identifiers or selected
10254 Outer : while Present (Arg) loop
10255 Citem := First (List_Containing (N));
10256 Inner : while Citem /= N loop
10257 if Nkind (Citem) = N_With_Clause
10258 and then Same_Name (Name (Citem), Get_Pragma_Arg (Arg))
10260 Set_Elaborate_Present (Citem, True);
10261 Set_Unit_Name (Get_Pragma_Arg (Arg), Name (Citem));
10262 Generate_Reference (Entity (Name (Citem)), Citem);
10264 -- With the pragma present, elaboration calls on
10265 -- subprograms from the named unit need no further
10266 -- checks, as long as the pragma appears in the current
10267 -- compilation unit. If the pragma appears in some unit
10268 -- in the context, there might still be a need for an
10269 -- Elaborate_All_Desirable from the current compilation
10270 -- to the named unit, so we keep the check enabled.
10272 if In_Extended_Main_Source_Unit (N) then
10273 Set_Suppress_Elaboration_Warnings
10274 (Entity (Name (Citem)));
10285 ("argument of pragma% is not withed unit", Arg);
10291 -- Give a warning if operating in static mode with -gnatwl
10292 -- (elaboration warnings enabled) switch set.
10294 if Elab_Warnings and not Dynamic_Elaboration_Checks then
10296 ("?l?use of pragma Elaborate may not be safe", N);
10298 ("?l?use pragma Elaborate_All instead if possible", N);
10302 -------------------
10303 -- Elaborate_All --
10304 -------------------
10306 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
10308 when Pragma_Elaborate_All => Elaborate_All : declare
10313 Check_Ada_83_Warning;
10315 -- Pragma must be in context items list of a compilation unit
10317 if not Is_In_Context_Clause then
10321 -- Must be at least one argument
10323 if Arg_Count = 0 then
10324 Error_Pragma ("pragma% requires at least one argument");
10327 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
10328 -- have to appear at the end of the context clause, but may
10329 -- appear mixed in with other items, even in Ada 83 mode.
10331 -- Final check: the arguments must all be units mentioned in
10332 -- a with clause in the same context clause. Note that we
10333 -- already checked (in Par.Prag) that all the arguments are
10334 -- either identifiers or selected components.
10337 Outr : while Present (Arg) loop
10338 Citem := First (List_Containing (N));
10339 Innr : while Citem /= N loop
10340 if Nkind (Citem) = N_With_Clause
10341 and then Same_Name (Name (Citem), Get_Pragma_Arg (Arg))
10343 Set_Elaborate_All_Present (Citem, True);
10344 Set_Unit_Name (Get_Pragma_Arg (Arg), Name (Citem));
10346 -- Suppress warnings and elaboration checks on the named
10347 -- unit if the pragma is in the current compilation, as
10348 -- for pragma Elaborate.
10350 if In_Extended_Main_Source_Unit (N) then
10351 Set_Suppress_Elaboration_Warnings
10352 (Entity (Name (Citem)));
10361 Set_Error_Posted (N);
10363 ("argument of pragma% is not withed unit", Arg);
10370 --------------------
10371 -- Elaborate_Body --
10372 --------------------
10374 -- pragma Elaborate_Body [( library_unit_NAME )];
10376 when Pragma_Elaborate_Body => Elaborate_Body : declare
10377 Cunit_Node : Node_Id;
10378 Cunit_Ent : Entity_Id;
10381 Check_Ada_83_Warning;
10382 Check_Valid_Library_Unit_Pragma;
10384 if Nkind (N) = N_Null_Statement then
10388 Cunit_Node := Cunit (Current_Sem_Unit);
10389 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
10391 if Nkind_In (Unit (Cunit_Node), N_Package_Body,
10394 Error_Pragma ("pragma% must refer to a spec, not a body");
10396 Set_Body_Required (Cunit_Node, True);
10397 Set_Has_Pragma_Elaborate_Body (Cunit_Ent);
10399 -- If we are in dynamic elaboration mode, then we suppress
10400 -- elaboration warnings for the unit, since it is definitely
10401 -- fine NOT to do dynamic checks at the first level (and such
10402 -- checks will be suppressed because no elaboration boolean
10403 -- is created for Elaborate_Body packages).
10405 -- But in the static model of elaboration, Elaborate_Body is
10406 -- definitely NOT good enough to ensure elaboration safety on
10407 -- its own, since the body may WITH other units that are not
10408 -- safe from an elaboration point of view, so a client must
10409 -- still do an Elaborate_All on such units.
10411 -- Debug flag -gnatdD restores the old behavior of 3.13, where
10412 -- Elaborate_Body always suppressed elab warnings.
10414 if Dynamic_Elaboration_Checks or Debug_Flag_DD then
10415 Set_Suppress_Elaboration_Warnings (Cunit_Ent);
10418 end Elaborate_Body;
10420 ------------------------
10421 -- Elaboration_Checks --
10422 ------------------------
10424 -- pragma Elaboration_Checks (Static | Dynamic);
10426 when Pragma_Elaboration_Checks =>
10428 Check_Arg_Count (1);
10429 Check_Arg_Is_One_Of (Arg1, Name_Static, Name_Dynamic);
10430 Dynamic_Elaboration_Checks :=
10431 (Chars (Get_Pragma_Arg (Arg1)) = Name_Dynamic);
10437 -- pragma Eliminate (
10438 -- [Unit_Name =>] IDENTIFIER | SELECTED_COMPONENT,
10439 -- [,[Entity =>] IDENTIFIER |
10440 -- SELECTED_COMPONENT |
10442 -- [, OVERLOADING_RESOLUTION]);
10444 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
10447 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
10448 -- FUNCTION_PROFILE
10450 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
10452 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
10453 -- Result_Type => result_SUBTYPE_NAME]
10455 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
10456 -- SUBTYPE_NAME ::= STRING_LITERAL
10458 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
10459 -- SOURCE_TRACE ::= STRING_LITERAL
10461 when Pragma_Eliminate => Eliminate : declare
10462 Args : Args_List (1 .. 5);
10463 Names : constant Name_List (1 .. 5) := (
10466 Name_Parameter_Types,
10468 Name_Source_Location);
10470 Unit_Name : Node_Id renames Args (1);
10471 Entity : Node_Id renames Args (2);
10472 Parameter_Types : Node_Id renames Args (3);
10473 Result_Type : Node_Id renames Args (4);
10474 Source_Location : Node_Id renames Args (5);
10478 Check_Valid_Configuration_Pragma;
10479 Gather_Associations (Names, Args);
10481 if No (Unit_Name) then
10482 Error_Pragma ("missing Unit_Name argument for pragma%");
10486 and then (Present (Parameter_Types)
10488 Present (Result_Type)
10490 Present (Source_Location))
10492 Error_Pragma ("missing Entity argument for pragma%");
10495 if (Present (Parameter_Types)
10497 Present (Result_Type))
10499 Present (Source_Location)
10502 ("parameter profile and source location cannot be used "
10503 & "together in pragma%");
10506 Process_Eliminate_Pragma
10515 -----------------------------------
10516 -- Enable_Atomic_Synchronization --
10517 -----------------------------------
10519 -- pragma Enable_Atomic_Synchronization [(Entity)];
10521 when Pragma_Enable_Atomic_Synchronization =>
10522 Process_Disable_Enable_Atomic_Sync (Name_Unsuppress);
10529 -- [ Convention =>] convention_IDENTIFIER,
10530 -- [ Entity =>] local_NAME
10531 -- [, [External_Name =>] static_string_EXPRESSION ]
10532 -- [, [Link_Name =>] static_string_EXPRESSION ]);
10534 when Pragma_Export => Export : declare
10536 Def_Id : Entity_Id;
10538 pragma Warnings (Off, C);
10541 Check_Ada_83_Warning;
10545 Name_External_Name,
10548 Check_At_Least_N_Arguments (2);
10550 Check_At_Most_N_Arguments (4);
10551 Process_Convention (C, Def_Id);
10553 if Ekind (Def_Id) /= E_Constant then
10554 Note_Possible_Modification
10555 (Get_Pragma_Arg (Arg2), Sure => False);
10558 Process_Interface_Name (Def_Id, Arg3, Arg4);
10559 Set_Exported (Def_Id, Arg2);
10561 -- If the entity is a deferred constant, propagate the information
10562 -- to the full view, because gigi elaborates the full view only.
10564 if Ekind (Def_Id) = E_Constant
10565 and then Present (Full_View (Def_Id))
10568 Id2 : constant Entity_Id := Full_View (Def_Id);
10570 Set_Is_Exported (Id2, Is_Exported (Def_Id));
10571 Set_First_Rep_Item (Id2, First_Rep_Item (Def_Id));
10572 Set_Interface_Name (Id2, Einfo.Interface_Name (Def_Id));
10577 ----------------------
10578 -- Export_Exception --
10579 ----------------------
10581 -- pragma Export_Exception (
10582 -- [Internal =>] LOCAL_NAME
10583 -- [, [External =>] EXTERNAL_SYMBOL]
10584 -- [, [Form =>] Ada | VMS]
10585 -- [, [Code =>] static_integer_EXPRESSION]);
10587 when Pragma_Export_Exception => Export_Exception : declare
10588 Args : Args_List (1 .. 4);
10589 Names : constant Name_List (1 .. 4) := (
10595 Internal : Node_Id renames Args (1);
10596 External : Node_Id renames Args (2);
10597 Form : Node_Id renames Args (3);
10598 Code : Node_Id renames Args (4);
10603 if Inside_A_Generic then
10604 Error_Pragma ("pragma% cannot be used for generic entities");
10607 Gather_Associations (Names, Args);
10608 Process_Extended_Import_Export_Exception_Pragma (
10609 Arg_Internal => Internal,
10610 Arg_External => External,
10614 if not Is_VMS_Exception (Entity (Internal)) then
10615 Set_Exported (Entity (Internal), Internal);
10617 end Export_Exception;
10619 ---------------------
10620 -- Export_Function --
10621 ---------------------
10623 -- pragma Export_Function (
10624 -- [Internal =>] LOCAL_NAME
10625 -- [, [External =>] EXTERNAL_SYMBOL]
10626 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
10627 -- [, [Result_Type =>] TYPE_DESIGNATOR]
10628 -- [, [Mechanism =>] MECHANISM]
10629 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
10631 -- EXTERNAL_SYMBOL ::=
10633 -- | static_string_EXPRESSION
10635 -- PARAMETER_TYPES ::=
10637 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
10639 -- TYPE_DESIGNATOR ::=
10641 -- | subtype_Name ' Access
10645 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
10647 -- MECHANISM_ASSOCIATION ::=
10648 -- [formal_parameter_NAME =>] MECHANISM_NAME
10650 -- MECHANISM_NAME ::=
10653 -- | Descriptor [([Class =>] CLASS_NAME)]
10655 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
10657 when Pragma_Export_Function => Export_Function : declare
10658 Args : Args_List (1 .. 6);
10659 Names : constant Name_List (1 .. 6) := (
10662 Name_Parameter_Types,
10665 Name_Result_Mechanism);
10667 Internal : Node_Id renames Args (1);
10668 External : Node_Id renames Args (2);
10669 Parameter_Types : Node_Id renames Args (3);
10670 Result_Type : Node_Id renames Args (4);
10671 Mechanism : Node_Id renames Args (5);
10672 Result_Mechanism : Node_Id renames Args (6);
10676 Gather_Associations (Names, Args);
10677 Process_Extended_Import_Export_Subprogram_Pragma (
10678 Arg_Internal => Internal,
10679 Arg_External => External,
10680 Arg_Parameter_Types => Parameter_Types,
10681 Arg_Result_Type => Result_Type,
10682 Arg_Mechanism => Mechanism,
10683 Arg_Result_Mechanism => Result_Mechanism);
10684 end Export_Function;
10686 -------------------
10687 -- Export_Object --
10688 -------------------
10690 -- pragma Export_Object (
10691 -- [Internal =>] LOCAL_NAME
10692 -- [, [External =>] EXTERNAL_SYMBOL]
10693 -- [, [Size =>] EXTERNAL_SYMBOL]);
10695 -- EXTERNAL_SYMBOL ::=
10697 -- | static_string_EXPRESSION
10699 -- PARAMETER_TYPES ::=
10701 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
10703 -- TYPE_DESIGNATOR ::=
10705 -- | subtype_Name ' Access
10709 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
10711 -- MECHANISM_ASSOCIATION ::=
10712 -- [formal_parameter_NAME =>] MECHANISM_NAME
10714 -- MECHANISM_NAME ::=
10717 -- | Descriptor [([Class =>] CLASS_NAME)]
10719 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
10721 when Pragma_Export_Object => Export_Object : declare
10722 Args : Args_List (1 .. 3);
10723 Names : constant Name_List (1 .. 3) := (
10728 Internal : Node_Id renames Args (1);
10729 External : Node_Id renames Args (2);
10730 Size : Node_Id renames Args (3);
10734 Gather_Associations (Names, Args);
10735 Process_Extended_Import_Export_Object_Pragma (
10736 Arg_Internal => Internal,
10737 Arg_External => External,
10741 ----------------------
10742 -- Export_Procedure --
10743 ----------------------
10745 -- pragma Export_Procedure (
10746 -- [Internal =>] LOCAL_NAME
10747 -- [, [External =>] EXTERNAL_SYMBOL]
10748 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
10749 -- [, [Mechanism =>] MECHANISM]);
10751 -- EXTERNAL_SYMBOL ::=
10753 -- | static_string_EXPRESSION
10755 -- PARAMETER_TYPES ::=
10757 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
10759 -- TYPE_DESIGNATOR ::=
10761 -- | subtype_Name ' Access
10765 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
10767 -- MECHANISM_ASSOCIATION ::=
10768 -- [formal_parameter_NAME =>] MECHANISM_NAME
10770 -- MECHANISM_NAME ::=
10773 -- | Descriptor [([Class =>] CLASS_NAME)]
10775 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
10777 when Pragma_Export_Procedure => Export_Procedure : declare
10778 Args : Args_List (1 .. 4);
10779 Names : constant Name_List (1 .. 4) := (
10782 Name_Parameter_Types,
10785 Internal : Node_Id renames Args (1);
10786 External : Node_Id renames Args (2);
10787 Parameter_Types : Node_Id renames Args (3);
10788 Mechanism : Node_Id renames Args (4);
10792 Gather_Associations (Names, Args);
10793 Process_Extended_Import_Export_Subprogram_Pragma (
10794 Arg_Internal => Internal,
10795 Arg_External => External,
10796 Arg_Parameter_Types => Parameter_Types,
10797 Arg_Mechanism => Mechanism);
10798 end Export_Procedure;
10804 -- pragma Export_Value (
10805 -- [Value =>] static_integer_EXPRESSION,
10806 -- [Link_Name =>] static_string_EXPRESSION);
10808 when Pragma_Export_Value =>
10810 Check_Arg_Order ((Name_Value, Name_Link_Name));
10811 Check_Arg_Count (2);
10813 Check_Optional_Identifier (Arg1, Name_Value);
10814 Check_Arg_Is_Static_Expression (Arg1, Any_Integer);
10816 Check_Optional_Identifier (Arg2, Name_Link_Name);
10817 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
10819 -----------------------------
10820 -- Export_Valued_Procedure --
10821 -----------------------------
10823 -- pragma Export_Valued_Procedure (
10824 -- [Internal =>] LOCAL_NAME
10825 -- [, [External =>] EXTERNAL_SYMBOL,]
10826 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
10827 -- [, [Mechanism =>] MECHANISM]);
10829 -- EXTERNAL_SYMBOL ::=
10831 -- | static_string_EXPRESSION
10833 -- PARAMETER_TYPES ::=
10835 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
10837 -- TYPE_DESIGNATOR ::=
10839 -- | subtype_Name ' Access
10843 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
10845 -- MECHANISM_ASSOCIATION ::=
10846 -- [formal_parameter_NAME =>] MECHANISM_NAME
10848 -- MECHANISM_NAME ::=
10851 -- | Descriptor [([Class =>] CLASS_NAME)]
10853 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
10855 when Pragma_Export_Valued_Procedure =>
10856 Export_Valued_Procedure : declare
10857 Args : Args_List (1 .. 4);
10858 Names : constant Name_List (1 .. 4) := (
10861 Name_Parameter_Types,
10864 Internal : Node_Id renames Args (1);
10865 External : Node_Id renames Args (2);
10866 Parameter_Types : Node_Id renames Args (3);
10867 Mechanism : Node_Id renames Args (4);
10871 Gather_Associations (Names, Args);
10872 Process_Extended_Import_Export_Subprogram_Pragma (
10873 Arg_Internal => Internal,
10874 Arg_External => External,
10875 Arg_Parameter_Types => Parameter_Types,
10876 Arg_Mechanism => Mechanism);
10877 end Export_Valued_Procedure;
10879 -------------------
10880 -- Extend_System --
10881 -------------------
10883 -- pragma Extend_System ([Name =>] Identifier);
10885 when Pragma_Extend_System => Extend_System : declare
10888 Check_Valid_Configuration_Pragma;
10889 Check_Arg_Count (1);
10890 Check_Optional_Identifier (Arg1, Name_Name);
10891 Check_Arg_Is_Identifier (Arg1);
10893 Get_Name_String (Chars (Get_Pragma_Arg (Arg1)));
10896 and then Name_Buffer (1 .. 4) = "aux_"
10898 if Present (System_Extend_Pragma_Arg) then
10899 if Chars (Get_Pragma_Arg (Arg1)) =
10900 Chars (Expression (System_Extend_Pragma_Arg))
10904 Error_Msg_Sloc := Sloc (System_Extend_Pragma_Arg);
10905 Error_Pragma ("pragma% conflicts with that #");
10909 System_Extend_Pragma_Arg := Arg1;
10911 if not GNAT_Mode then
10912 System_Extend_Unit := Arg1;
10916 Error_Pragma ("incorrect name for pragma%, must be Aux_xxx");
10920 ------------------------
10921 -- Extensions_Allowed --
10922 ------------------------
10924 -- pragma Extensions_Allowed (ON | OFF);
10926 when Pragma_Extensions_Allowed =>
10928 Check_Arg_Count (1);
10929 Check_No_Identifiers;
10930 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
10932 if Chars (Get_Pragma_Arg (Arg1)) = Name_On then
10933 Extensions_Allowed := True;
10934 Ada_Version := Ada_Version_Type'Last;
10937 Extensions_Allowed := False;
10938 Ada_Version := Ada_Version_Explicit;
10945 -- pragma External (
10946 -- [ Convention =>] convention_IDENTIFIER,
10947 -- [ Entity =>] local_NAME
10948 -- [, [External_Name =>] static_string_EXPRESSION ]
10949 -- [, [Link_Name =>] static_string_EXPRESSION ]);
10951 when Pragma_External => External : declare
10952 Def_Id : Entity_Id;
10955 pragma Warnings (Off, C);
10962 Name_External_Name,
10964 Check_At_Least_N_Arguments (2);
10965 Check_At_Most_N_Arguments (4);
10966 Process_Convention (C, Def_Id);
10967 Note_Possible_Modification
10968 (Get_Pragma_Arg (Arg2), Sure => False);
10969 Process_Interface_Name (Def_Id, Arg3, Arg4);
10970 Set_Exported (Def_Id, Arg2);
10973 --------------------------
10974 -- External_Name_Casing --
10975 --------------------------
10977 -- pragma External_Name_Casing (
10978 -- UPPERCASE | LOWERCASE
10979 -- [, AS_IS | UPPERCASE | LOWERCASE]);
10981 when Pragma_External_Name_Casing => External_Name_Casing : declare
10984 Check_No_Identifiers;
10986 if Arg_Count = 2 then
10987 Check_Arg_Is_One_Of
10988 (Arg2, Name_As_Is, Name_Uppercase, Name_Lowercase);
10990 case Chars (Get_Pragma_Arg (Arg2)) is
10992 Opt.External_Name_Exp_Casing := As_Is;
10994 when Name_Uppercase =>
10995 Opt.External_Name_Exp_Casing := Uppercase;
10997 when Name_Lowercase =>
10998 Opt.External_Name_Exp_Casing := Lowercase;
11005 Check_Arg_Count (1);
11008 Check_Arg_Is_One_Of (Arg1, Name_Uppercase, Name_Lowercase);
11010 case Chars (Get_Pragma_Arg (Arg1)) is
11011 when Name_Uppercase =>
11012 Opt.External_Name_Imp_Casing := Uppercase;
11014 when Name_Lowercase =>
11015 Opt.External_Name_Imp_Casing := Lowercase;
11020 end External_Name_Casing;
11022 --------------------------
11023 -- Favor_Top_Level --
11024 --------------------------
11026 -- pragma Favor_Top_Level (type_NAME);
11028 when Pragma_Favor_Top_Level => Favor_Top_Level : declare
11029 Named_Entity : Entity_Id;
11033 Check_No_Identifiers;
11034 Check_Arg_Count (1);
11035 Check_Arg_Is_Local_Name (Arg1);
11036 Named_Entity := Entity (Get_Pragma_Arg (Arg1));
11038 -- If it's an access-to-subprogram type (in particular, not a
11039 -- subtype), set the flag on that type.
11041 if Is_Access_Subprogram_Type (Named_Entity) then
11042 Set_Can_Use_Internal_Rep (Named_Entity, False);
11044 -- Otherwise it's an error (name denotes the wrong sort of entity)
11048 ("access-to-subprogram type expected",
11049 Get_Pragma_Arg (Arg1));
11051 end Favor_Top_Level;
11057 -- pragma Fast_Math;
11059 when Pragma_Fast_Math =>
11061 Check_No_Identifiers;
11062 Check_Valid_Configuration_Pragma;
11065 ---------------------------
11066 -- Finalize_Storage_Only --
11067 ---------------------------
11069 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
11071 when Pragma_Finalize_Storage_Only => Finalize_Storage : declare
11072 Assoc : constant Node_Id := Arg1;
11073 Type_Id : constant Node_Id := Get_Pragma_Arg (Assoc);
11078 Check_No_Identifiers;
11079 Check_Arg_Count (1);
11080 Check_Arg_Is_Local_Name (Arg1);
11082 Find_Type (Type_Id);
11083 Typ := Entity (Type_Id);
11086 or else Rep_Item_Too_Early (Typ, N)
11090 Typ := Underlying_Type (Typ);
11093 if not Is_Controlled (Typ) then
11094 Error_Pragma ("pragma% must specify controlled type");
11097 Check_First_Subtype (Arg1);
11099 if Finalize_Storage_Only (Typ) then
11100 Error_Pragma ("duplicate pragma%, only one allowed");
11102 elsif not Rep_Item_Too_Late (Typ, N) then
11103 Set_Finalize_Storage_Only (Base_Type (Typ), True);
11105 end Finalize_Storage;
11107 --------------------------
11108 -- Float_Representation --
11109 --------------------------
11111 -- pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
11113 -- FLOAT_REP ::= VAX_Float | IEEE_Float
11115 when Pragma_Float_Representation => Float_Representation : declare
11123 if Arg_Count = 1 then
11124 Check_Valid_Configuration_Pragma;
11126 Check_Arg_Count (2);
11127 Check_Optional_Identifier (Arg2, Name_Entity);
11128 Check_Arg_Is_Local_Name (Arg2);
11131 Check_No_Identifier (Arg1);
11132 Check_Arg_Is_One_Of (Arg1, Name_VAX_Float, Name_IEEE_Float);
11134 if not OpenVMS_On_Target then
11135 if Chars (Get_Pragma_Arg (Arg1)) = Name_VAX_Float then
11137 ("??pragma% ignored (applies only to Open'V'M'S)");
11143 -- One argument case
11145 if Arg_Count = 1 then
11146 if Chars (Get_Pragma_Arg (Arg1)) = Name_VAX_Float then
11147 if Opt.Float_Format = 'I' then
11148 Error_Pragma ("'I'E'E'E format previously specified");
11151 Opt.Float_Format := 'V';
11154 if Opt.Float_Format = 'V' then
11155 Error_Pragma ("'V'A'X format previously specified");
11158 Opt.Float_Format := 'I';
11161 Set_Standard_Fpt_Formats;
11163 -- Two argument case
11166 Argx := Get_Pragma_Arg (Arg2);
11168 if not Is_Entity_Name (Argx)
11169 or else not Is_Floating_Point_Type (Entity (Argx))
11172 ("second argument of% pragma must be floating-point type",
11176 Ent := Entity (Argx);
11177 Digs := UI_To_Int (Digits_Value (Ent));
11179 -- Two arguments, VAX_Float case
11181 if Chars (Get_Pragma_Arg (Arg1)) = Name_VAX_Float then
11183 when 6 => Set_F_Float (Ent);
11184 when 9 => Set_D_Float (Ent);
11185 when 15 => Set_G_Float (Ent);
11189 ("wrong digits value, must be 6,9 or 15", Arg2);
11192 -- Two arguments, IEEE_Float case
11196 when 6 => Set_IEEE_Short (Ent);
11197 when 15 => Set_IEEE_Long (Ent);
11201 ("wrong digits value, must be 6 or 15", Arg2);
11205 end Float_Representation;
11211 -- pragma GHOST (function_LOCAL_NAME);
11213 when Pragma_Ghost => Ghost : declare
11215 Subp_Id : Entity_Id;
11220 Check_Arg_Count (1);
11221 Check_Arg_Is_Local_Name (Arg1);
11223 -- Ensure the proper placement of the pragma. Ghost must be
11224 -- associated with a subprogram declaration.
11226 Subp := Parent (Corresponding_Aspect (N));
11228 if Nkind (Subp) /= N_Subprogram_Declaration then
11233 Subp_Id := Defining_Unit_Name (Specification (Subp));
11235 if Ekind (Subp_Id) /= E_Function then
11236 Error_Pragma ("pragma % must be applied to a function");
11244 -- pragma Global (GLOBAL_SPECIFICATION)
11246 -- GLOBAL_SPECIFICATION ::=
11249 -- | MODED_GLOBAL_LIST {, MODED_GLOBAL_LIST}
11251 -- MODED_GLOBAL_LIST ::= MODE_SELECTOR => GLOBAL_LIST
11253 -- MODE_SELECTOR ::= Input | Output | In_Out | Contract_In
11254 -- GLOBAL_LIST ::= GLOBAL_ITEM | (GLOBAL_ITEM {, GLOBAL_ITEM})
11255 -- GLOBAL_ITEM ::= NAME
11257 when Pragma_Global => Global : declare
11258 Subp_Id : Entity_Id;
11260 Seen : Elist_Id := No_Elist;
11261 -- A list containing the entities of all the items processed so
11262 -- far. It plays a role in detecting distinct entities.
11264 Contract_Seen : Boolean := False;
11265 In_Out_Seen : Boolean := False;
11266 Input_Seen : Boolean := False;
11267 Output_Seen : Boolean := False;
11268 -- Flags used to verify the consistency of modes
11270 procedure Analyze_Global_List
11272 Global_Mode : Name_Id := Name_Input);
11273 -- Verify the legality of a single global list declaration.
11274 -- Global_Mode denotes the current mode in effect.
11276 -------------------------
11277 -- Analyze_Global_List --
11278 -------------------------
11280 procedure Analyze_Global_List
11282 Global_Mode : Name_Id := Name_Input)
11284 procedure Analyze_Global_Item
11286 Global_Mode : Name_Id);
11287 -- Verify the legality of a single global item declaration.
11288 -- Global_Mode denotes the current mode in effect.
11290 procedure Check_Duplicate_Mode
11292 Status : in out Boolean);
11293 -- Flag Status denotes whether a particular mode has been seen
11294 -- while processing a global list. This routine verifies that
11295 -- Mode is not a duplicate mode and sets the flag Status.
11297 procedure Check_Mode_Restriction_In_Function (Mode : Node_Id);
11298 -- Mode denotes either In_Out or Output. Depending on the kind
11299 -- of the related subprogram, emit an error if those two modes
11300 -- apply to a function.
11302 -------------------------
11303 -- Analyze_Global_Item --
11304 -------------------------
11306 procedure Analyze_Global_Item
11308 Global_Mode : Name_Id)
11310 Item_Id : Entity_Id;
11313 -- Detect one of the following cases
11315 -- with Global => (null, Name)
11316 -- with Global => (Name_1, null, Name_2)
11317 -- with Global => (Name, null)
11319 if Nkind (Item) = N_Null then
11321 ("cannot mix null and non-null global items", Item);
11327 -- Find the entity of the item. If this is a renaming, climb
11328 -- the renaming chain to reach the root object. Renamings of
11329 -- non-entire objects do not yield an entity (Empty).
11331 Item_Id := Entity_Of (Item);
11333 if Present (Item_Id) then
11335 -- A global item cannot reference a formal parameter. Do
11336 -- this check first to provide a better error diagnostic.
11338 if Is_Formal (Item_Id) then
11340 ("global item cannot reference formal parameter",
11344 -- The only legal references are those to abstract states
11347 elsif not Ekind_In (Item_Id, E_Abstract_State,
11351 ("global item must denote variable or state", Item);
11355 -- When the item renames an entire object, replace the
11356 -- item with a reference to the object.
11358 if Present (Renamed_Object (Entity (Item))) then
11360 New_Reference_To (Item_Id, Sloc (Item)));
11364 -- Some form of illegal construct masquerading as a name
11368 ("global item must denote variable or state", Item);
11372 -- The same entity might be referenced through various way.
11373 -- Check the entity of the item rather than the item itself.
11375 if Contains (Seen, Item_Id) then
11376 Error_Msg_N ("duplicate global item", Item);
11378 -- Add the entity of the current item to the list of
11379 -- processed items.
11382 Add_Item (Item_Id, Seen);
11385 if Ekind (Item_Id) = E_Abstract_State
11386 and then Is_Volatile_State (Item_Id)
11388 -- A global item of mode In_Out or Output cannot denote a
11389 -- volatile Input state.
11391 if Is_Input_State (Item_Id)
11392 and then (Global_Mode = Name_In_Out
11394 Global_Mode = Name_Output)
11397 ("global item of mode In_Out or Output cannot "
11398 & "reference Volatile Input state", Item);
11400 -- A global item of mode In_Out or Input cannot reference
11401 -- a volatile Output state.
11403 elsif Is_Output_State (Item_Id)
11404 and then (Global_Mode = Name_In_Out
11406 Global_Mode = Name_Input)
11409 ("global item of mode In_Out or Input cannot "
11410 & "reference Volatile Output state", Item);
11413 end Analyze_Global_Item;
11415 --------------------------
11416 -- Check_Duplicate_Mode --
11417 --------------------------
11419 procedure Check_Duplicate_Mode
11421 Status : in out Boolean)
11425 Error_Msg_N ("duplicate global mode", Mode);
11429 end Check_Duplicate_Mode;
11431 ----------------------------------------
11432 -- Check_Mode_Restriction_In_Function --
11433 ----------------------------------------
11435 procedure Check_Mode_Restriction_In_Function (Mode : Node_Id) is
11437 if Ekind (Subp_Id) = E_Function then
11439 ("global mode & not applicable to functions", Mode);
11441 end Check_Mode_Restriction_In_Function;
11449 -- Start of processing for Analyze_Global_List
11452 -- Single global item declaration
11454 if Nkind_In (List, N_Identifier, N_Selected_Component) then
11455 Analyze_Global_Item (List, Global_Mode);
11457 -- Simple global list or moded global list declaration
11459 elsif Nkind (List) = N_Aggregate then
11461 -- The declaration of a simple global list appear as a
11462 -- collection of expressions.
11464 if Present (Expressions (List)) then
11465 if Present (Component_Associations (List)) then
11467 ("cannot mix moded and non-moded global lists",
11471 Item := First (Expressions (List));
11472 while Present (Item) loop
11473 Analyze_Global_Item (Item, Global_Mode);
11478 -- The declaration of a moded global list appears as a
11479 -- collection of component associations where individual
11480 -- choices denote modes.
11482 elsif Present (Component_Associations (List)) then
11483 if Present (Expressions (List)) then
11485 ("cannot mix moded and non-moded global lists",
11489 Assoc := First (Component_Associations (List));
11490 while Present (Assoc) loop
11491 Mode := First (Choices (Assoc));
11493 if Nkind (Mode) = N_Identifier then
11494 if Chars (Mode) = Name_Contract_In then
11495 Check_Duplicate_Mode (Mode, Contract_Seen);
11497 elsif Chars (Mode) = Name_In_Out then
11498 Check_Duplicate_Mode (Mode, In_Out_Seen);
11499 Check_Mode_Restriction_In_Function (Mode);
11501 elsif Chars (Mode) = Name_Input then
11502 Check_Duplicate_Mode (Mode, Input_Seen);
11504 elsif Chars (Mode) = Name_Output then
11505 Check_Duplicate_Mode (Mode, Output_Seen);
11506 Check_Mode_Restriction_In_Function (Mode);
11509 Error_Msg_N ("invalid mode selector", Mode);
11513 Error_Msg_N ("invalid mode selector", Mode);
11516 -- Items in a moded list appear as a collection of
11517 -- expressions. Reuse the existing machinery to
11520 Analyze_Global_List
11521 (List => Expression (Assoc),
11522 Global_Mode => Chars (Mode));
11527 -- Something went horribly wrong, we have a malformed tree
11530 raise Program_Error;
11533 -- Any other attempt to declare a global item is erroneous
11536 Error_Msg_N ("malformed global list declaration", List);
11538 end Analyze_Global_List;
11545 -- Start of processing for Global
11550 Check_Arg_Count (1);
11552 -- Ensure the proper placement of the pragma. Global must be
11553 -- associated with a subprogram declaration.
11555 Subp := Parent (Corresponding_Aspect (N));
11557 if Nkind (Subp) /= N_Subprogram_Declaration then
11562 Subp_Id := Defining_Unit_Name (Specification (Subp));
11563 List := Expression (Arg1);
11565 -- There is nothing to be done for a null global list
11567 if Nkind (List) = N_Null then
11570 -- Analyze the various forms of global lists and items. Note that
11571 -- some of these may be malformed in which case the analysis emits
11575 -- Ensure that the formal parameters are visible when
11576 -- processing an item. This falls out of the general rule of
11577 -- aspects pertaining to subprogram declarations.
11579 Push_Scope (Subp_Id);
11580 Install_Formals (Subp_Id);
11582 Analyze_Global_List (List);
11592 -- pragma Ident (static_string_EXPRESSION)
11594 -- Note: pragma Comment shares this processing. Pragma Comment is
11595 -- identical to Ident, except that the restriction of the argument to
11596 -- 31 characters and the placement restrictions are not enforced for
11599 when Pragma_Ident | Pragma_Comment => Ident : declare
11604 Check_Arg_Count (1);
11605 Check_No_Identifiers;
11606 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
11609 -- For pragma Ident, preserve DEC compatibility by requiring the
11610 -- pragma to appear in a declarative part or package spec.
11612 if Prag_Id = Pragma_Ident then
11613 Check_Is_In_Decl_Part_Or_Package_Spec;
11616 Str := Expr_Value_S (Get_Pragma_Arg (Arg1));
11623 GP := Parent (Parent (N));
11625 if Nkind_In (GP, N_Package_Declaration,
11626 N_Generic_Package_Declaration)
11631 -- If we have a compilation unit, then record the ident value,
11632 -- checking for improper duplication.
11634 if Nkind (GP) = N_Compilation_Unit then
11635 CS := Ident_String (Current_Sem_Unit);
11637 if Present (CS) then
11639 -- For Ident, we do not permit multiple instances
11641 if Prag_Id = Pragma_Ident then
11642 Error_Pragma ("duplicate% pragma not permitted");
11644 -- For Comment, we concatenate the string, unless we want
11645 -- to preserve the tree structure for ASIS.
11647 elsif not ASIS_Mode then
11648 Start_String (Strval (CS));
11649 Store_String_Char (' ');
11650 Store_String_Chars (Strval (Str));
11651 Set_Strval (CS, End_String);
11655 -- In VMS, the effect of IDENT is achieved by passing
11656 -- --identification=name as a --for-linker switch.
11658 if OpenVMS_On_Target then
11661 ("--for-linker=--identification=");
11662 String_To_Name_Buffer (Strval (Str));
11663 Store_String_Chars (Name_Buffer (1 .. Name_Len));
11665 -- Only the last processed IDENT is saved. The main
11666 -- purpose is so an IDENT associated with a main
11667 -- procedure will be used in preference to an IDENT
11668 -- associated with a with'd package.
11670 Replace_Linker_Option_String
11671 (End_String, "--for-linker=--identification=");
11674 Set_Ident_String (Current_Sem_Unit, Str);
11677 -- For subunits, we just ignore the Ident, since in GNAT these
11678 -- are not separate object files, and hence not separate units
11679 -- in the unit table.
11681 elsif Nkind (GP) = N_Subunit then
11684 -- Otherwise we have a misplaced pragma Ident, but we ignore
11685 -- this if we are in an instantiation, since it comes from
11686 -- a generic, and has no relevance to the instantiation.
11688 elsif Prag_Id = Pragma_Ident then
11689 if Instantiation_Location (Loc) = No_Location then
11690 Error_Pragma ("pragma% only allowed at outer level");
11696 ----------------------------
11697 -- Implementation_Defined --
11698 ----------------------------
11700 -- pragma Implementation_Defined (local_NAME);
11702 -- Marks previously declared entity as implementation defined. For
11703 -- an overloaded entity, applies to the most recent homonym.
11705 -- pragma Implementation_Defined;
11707 -- The form with no arguments appears anywhere within a scope, most
11708 -- typically a package spec, and indicates that all entities that are
11709 -- defined within the package spec are Implementation_Defined.
11711 when Pragma_Implementation_Defined => Implementation_Defined : declare
11715 Check_No_Identifiers;
11717 -- Form with no arguments
11719 if Arg_Count = 0 then
11720 Set_Is_Implementation_Defined (Current_Scope);
11722 -- Form with one argument
11725 Check_Arg_Count (1);
11726 Check_Arg_Is_Local_Name (Arg1);
11727 Ent := Entity (Get_Pragma_Arg (Arg1));
11728 Set_Is_Implementation_Defined (Ent);
11730 end Implementation_Defined;
11736 -- pragma Implemented (procedure_LOCAL_NAME, IMPLEMENTATION_KIND);
11738 -- IMPLEMENTATION_KIND ::=
11739 -- By_Entry | By_Protected_Procedure | By_Any | Optional
11741 -- "By_Any" and "Optional" are treated as synonyms in order to
11742 -- support Ada 2012 aspect Synchronization.
11744 when Pragma_Implemented => Implemented : declare
11745 Proc_Id : Entity_Id;
11750 Check_Arg_Count (2);
11751 Check_No_Identifiers;
11752 Check_Arg_Is_Identifier (Arg1);
11753 Check_Arg_Is_Local_Name (Arg1);
11754 Check_Arg_Is_One_Of (Arg2,
11757 Name_By_Protected_Procedure,
11760 -- Extract the name of the local procedure
11762 Proc_Id := Entity (Get_Pragma_Arg (Arg1));
11764 -- Ada 2012 (AI05-0030): The procedure_LOCAL_NAME must denote a
11765 -- primitive procedure of a synchronized tagged type.
11767 if Ekind (Proc_Id) = E_Procedure
11768 and then Is_Primitive (Proc_Id)
11769 and then Present (First_Formal (Proc_Id))
11771 Typ := Etype (First_Formal (Proc_Id));
11773 if Is_Tagged_Type (Typ)
11776 -- Check for a protected, a synchronized or a task interface
11778 ((Is_Interface (Typ)
11779 and then Is_Synchronized_Interface (Typ))
11781 -- Check for a protected type or a task type that implements
11785 (Is_Concurrent_Record_Type (Typ)
11786 and then Present (Interfaces (Typ)))
11788 -- Check for a private record extension with keyword
11792 (Ekind_In (Typ, E_Record_Type_With_Private,
11793 E_Record_Subtype_With_Private)
11794 and then Synchronized_Present (Parent (Typ))))
11799 ("controlling formal must be of synchronized tagged type",
11804 -- Procedures declared inside a protected type must be accepted
11806 elsif Ekind (Proc_Id) = E_Procedure
11807 and then Is_Protected_Type (Scope (Proc_Id))
11811 -- The first argument is not a primitive procedure
11815 ("pragma % must be applied to a primitive procedure", Arg1);
11819 -- Ada 2012 (AI05-0030): Cannot apply the implementation_kind
11820 -- By_Protected_Procedure to the primitive procedure of a task
11823 if Chars (Arg2) = Name_By_Protected_Procedure
11824 and then Is_Interface (Typ)
11825 and then Is_Task_Interface (Typ)
11828 ("implementation kind By_Protected_Procedure cannot be "
11829 & "applied to a task interface primitive", Arg2);
11833 Record_Rep_Item (Proc_Id, N);
11836 ----------------------
11837 -- Implicit_Packing --
11838 ----------------------
11840 -- pragma Implicit_Packing;
11842 when Pragma_Implicit_Packing =>
11844 Check_Arg_Count (0);
11845 Implicit_Packing := True;
11852 -- [Convention =>] convention_IDENTIFIER,
11853 -- [Entity =>] local_NAME
11854 -- [, [External_Name =>] static_string_EXPRESSION ]
11855 -- [, [Link_Name =>] static_string_EXPRESSION ]);
11857 when Pragma_Import =>
11858 Check_Ada_83_Warning;
11862 Name_External_Name,
11865 Check_At_Least_N_Arguments (2);
11866 Check_At_Most_N_Arguments (4);
11867 Process_Import_Or_Interface;
11869 ----------------------
11870 -- Import_Exception --
11871 ----------------------
11873 -- pragma Import_Exception (
11874 -- [Internal =>] LOCAL_NAME
11875 -- [, [External =>] EXTERNAL_SYMBOL]
11876 -- [, [Form =>] Ada | VMS]
11877 -- [, [Code =>] static_integer_EXPRESSION]);
11879 when Pragma_Import_Exception => Import_Exception : declare
11880 Args : Args_List (1 .. 4);
11881 Names : constant Name_List (1 .. 4) := (
11887 Internal : Node_Id renames Args (1);
11888 External : Node_Id renames Args (2);
11889 Form : Node_Id renames Args (3);
11890 Code : Node_Id renames Args (4);
11894 Gather_Associations (Names, Args);
11896 if Present (External) and then Present (Code) then
11898 ("cannot give both External and Code options for pragma%");
11901 Process_Extended_Import_Export_Exception_Pragma (
11902 Arg_Internal => Internal,
11903 Arg_External => External,
11907 if not Is_VMS_Exception (Entity (Internal)) then
11908 Set_Imported (Entity (Internal));
11910 end Import_Exception;
11912 ---------------------
11913 -- Import_Function --
11914 ---------------------
11916 -- pragma Import_Function (
11917 -- [Internal =>] LOCAL_NAME,
11918 -- [, [External =>] EXTERNAL_SYMBOL]
11919 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
11920 -- [, [Result_Type =>] SUBTYPE_MARK]
11921 -- [, [Mechanism =>] MECHANISM]
11922 -- [, [Result_Mechanism =>] MECHANISM_NAME]
11923 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
11925 -- EXTERNAL_SYMBOL ::=
11927 -- | static_string_EXPRESSION
11929 -- PARAMETER_TYPES ::=
11931 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
11933 -- TYPE_DESIGNATOR ::=
11935 -- | subtype_Name ' Access
11939 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
11941 -- MECHANISM_ASSOCIATION ::=
11942 -- [formal_parameter_NAME =>] MECHANISM_NAME
11944 -- MECHANISM_NAME ::=
11947 -- | Descriptor [([Class =>] CLASS_NAME)]
11949 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
11951 when Pragma_Import_Function => Import_Function : declare
11952 Args : Args_List (1 .. 7);
11953 Names : constant Name_List (1 .. 7) := (
11956 Name_Parameter_Types,
11959 Name_Result_Mechanism,
11960 Name_First_Optional_Parameter);
11962 Internal : Node_Id renames Args (1);
11963 External : Node_Id renames Args (2);
11964 Parameter_Types : Node_Id renames Args (3);
11965 Result_Type : Node_Id renames Args (4);
11966 Mechanism : Node_Id renames Args (5);
11967 Result_Mechanism : Node_Id renames Args (6);
11968 First_Optional_Parameter : Node_Id renames Args (7);
11972 Gather_Associations (Names, Args);
11973 Process_Extended_Import_Export_Subprogram_Pragma (
11974 Arg_Internal => Internal,
11975 Arg_External => External,
11976 Arg_Parameter_Types => Parameter_Types,
11977 Arg_Result_Type => Result_Type,
11978 Arg_Mechanism => Mechanism,
11979 Arg_Result_Mechanism => Result_Mechanism,
11980 Arg_First_Optional_Parameter => First_Optional_Parameter);
11981 end Import_Function;
11983 -------------------
11984 -- Import_Object --
11985 -------------------
11987 -- pragma Import_Object (
11988 -- [Internal =>] LOCAL_NAME
11989 -- [, [External =>] EXTERNAL_SYMBOL]
11990 -- [, [Size =>] EXTERNAL_SYMBOL]);
11992 -- EXTERNAL_SYMBOL ::=
11994 -- | static_string_EXPRESSION
11996 when Pragma_Import_Object => Import_Object : declare
11997 Args : Args_List (1 .. 3);
11998 Names : constant Name_List (1 .. 3) := (
12003 Internal : Node_Id renames Args (1);
12004 External : Node_Id renames Args (2);
12005 Size : Node_Id renames Args (3);
12009 Gather_Associations (Names, Args);
12010 Process_Extended_Import_Export_Object_Pragma (
12011 Arg_Internal => Internal,
12012 Arg_External => External,
12016 ----------------------
12017 -- Import_Procedure --
12018 ----------------------
12020 -- pragma Import_Procedure (
12021 -- [Internal =>] LOCAL_NAME
12022 -- [, [External =>] EXTERNAL_SYMBOL]
12023 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
12024 -- [, [Mechanism =>] MECHANISM]
12025 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
12027 -- EXTERNAL_SYMBOL ::=
12029 -- | static_string_EXPRESSION
12031 -- PARAMETER_TYPES ::=
12033 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
12035 -- TYPE_DESIGNATOR ::=
12037 -- | subtype_Name ' Access
12041 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
12043 -- MECHANISM_ASSOCIATION ::=
12044 -- [formal_parameter_NAME =>] MECHANISM_NAME
12046 -- MECHANISM_NAME ::=
12049 -- | Descriptor [([Class =>] CLASS_NAME)]
12051 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
12053 when Pragma_Import_Procedure => Import_Procedure : declare
12054 Args : Args_List (1 .. 5);
12055 Names : constant Name_List (1 .. 5) := (
12058 Name_Parameter_Types,
12060 Name_First_Optional_Parameter);
12062 Internal : Node_Id renames Args (1);
12063 External : Node_Id renames Args (2);
12064 Parameter_Types : Node_Id renames Args (3);
12065 Mechanism : Node_Id renames Args (4);
12066 First_Optional_Parameter : Node_Id renames Args (5);
12070 Gather_Associations (Names, Args);
12071 Process_Extended_Import_Export_Subprogram_Pragma (
12072 Arg_Internal => Internal,
12073 Arg_External => External,
12074 Arg_Parameter_Types => Parameter_Types,
12075 Arg_Mechanism => Mechanism,
12076 Arg_First_Optional_Parameter => First_Optional_Parameter);
12077 end Import_Procedure;
12079 -----------------------------
12080 -- Import_Valued_Procedure --
12081 -----------------------------
12083 -- pragma Import_Valued_Procedure (
12084 -- [Internal =>] LOCAL_NAME
12085 -- [, [External =>] EXTERNAL_SYMBOL]
12086 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
12087 -- [, [Mechanism =>] MECHANISM]
12088 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
12090 -- EXTERNAL_SYMBOL ::=
12092 -- | static_string_EXPRESSION
12094 -- PARAMETER_TYPES ::=
12096 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
12098 -- TYPE_DESIGNATOR ::=
12100 -- | subtype_Name ' Access
12104 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
12106 -- MECHANISM_ASSOCIATION ::=
12107 -- [formal_parameter_NAME =>] MECHANISM_NAME
12109 -- MECHANISM_NAME ::=
12112 -- | Descriptor [([Class =>] CLASS_NAME)]
12114 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
12116 when Pragma_Import_Valued_Procedure =>
12117 Import_Valued_Procedure : declare
12118 Args : Args_List (1 .. 5);
12119 Names : constant Name_List (1 .. 5) := (
12122 Name_Parameter_Types,
12124 Name_First_Optional_Parameter);
12126 Internal : Node_Id renames Args (1);
12127 External : Node_Id renames Args (2);
12128 Parameter_Types : Node_Id renames Args (3);
12129 Mechanism : Node_Id renames Args (4);
12130 First_Optional_Parameter : Node_Id renames Args (5);
12134 Gather_Associations (Names, Args);
12135 Process_Extended_Import_Export_Subprogram_Pragma (
12136 Arg_Internal => Internal,
12137 Arg_External => External,
12138 Arg_Parameter_Types => Parameter_Types,
12139 Arg_Mechanism => Mechanism,
12140 Arg_First_Optional_Parameter => First_Optional_Parameter);
12141 end Import_Valued_Procedure;
12147 -- pragma Independent (LOCAL_NAME);
12149 when Pragma_Independent => Independent : declare
12156 Check_Ada_83_Warning;
12158 Check_No_Identifiers;
12159 Check_Arg_Count (1);
12160 Check_Arg_Is_Local_Name (Arg1);
12161 E_Id := Get_Pragma_Arg (Arg1);
12163 if Etype (E_Id) = Any_Type then
12167 E := Entity (E_Id);
12168 D := Declaration_Node (E);
12171 -- Check duplicate before we chain ourselves!
12173 Check_Duplicate_Pragma (E);
12175 -- Check appropriate entity
12177 if Is_Type (E) then
12178 if Rep_Item_Too_Early (E, N)
12180 Rep_Item_Too_Late (E, N)
12184 Check_First_Subtype (Arg1);
12187 elsif K = N_Object_Declaration
12188 or else (K = N_Component_Declaration
12189 and then Original_Record_Component (E) = E)
12191 if Rep_Item_Too_Late (E, N) then
12197 ("inappropriate entity for pragma%", Arg1);
12200 Independence_Checks.Append ((N, E));
12203 ----------------------------
12204 -- Independent_Components --
12205 ----------------------------
12207 -- pragma Atomic_Components (array_LOCAL_NAME);
12209 -- This processing is shared by Volatile_Components
12211 when Pragma_Independent_Components => Independent_Components : declare
12218 Check_Ada_83_Warning;
12220 Check_No_Identifiers;
12221 Check_Arg_Count (1);
12222 Check_Arg_Is_Local_Name (Arg1);
12223 E_Id := Get_Pragma_Arg (Arg1);
12225 if Etype (E_Id) = Any_Type then
12229 E := Entity (E_Id);
12231 -- Check duplicate before we chain ourselves!
12233 Check_Duplicate_Pragma (E);
12235 -- Check appropriate entity
12237 if Rep_Item_Too_Early (E, N)
12239 Rep_Item_Too_Late (E, N)
12244 D := Declaration_Node (E);
12247 if K = N_Full_Type_Declaration
12248 and then (Is_Array_Type (E) or else Is_Record_Type (E))
12250 Independence_Checks.Append ((N, E));
12251 Set_Has_Independent_Components (Base_Type (E));
12253 elsif (Ekind (E) = E_Constant or else Ekind (E) = E_Variable)
12254 and then Nkind (D) = N_Object_Declaration
12255 and then Nkind (Object_Definition (D)) =
12256 N_Constrained_Array_Definition
12258 Independence_Checks.Append ((N, E));
12259 Set_Has_Independent_Components (E);
12262 Error_Pragma_Arg ("inappropriate entity for pragma%", Arg1);
12264 end Independent_Components;
12266 ------------------------
12267 -- Initialize_Scalars --
12268 ------------------------
12270 -- pragma Initialize_Scalars;
12272 when Pragma_Initialize_Scalars =>
12274 Check_Arg_Count (0);
12275 Check_Valid_Configuration_Pragma;
12276 Check_Restriction (No_Initialize_Scalars, N);
12278 -- Initialize_Scalars creates false positives in CodePeer, and
12279 -- incorrect negative results in Alfa mode, so ignore this pragma
12282 if not Restriction_Active (No_Initialize_Scalars)
12283 and then not (CodePeer_Mode or Alfa_Mode)
12285 Init_Or_Norm_Scalars := True;
12286 Initialize_Scalars := True;
12293 -- pragma Inline ( NAME {, NAME} );
12295 when Pragma_Inline =>
12297 -- Inline status is Enabled if inlining option is active
12299 if Inline_Active then
12300 Process_Inline (Enabled);
12302 Process_Inline (Disabled);
12305 -------------------
12306 -- Inline_Always --
12307 -------------------
12309 -- pragma Inline_Always ( NAME {, NAME} );
12311 when Pragma_Inline_Always =>
12314 -- Pragma always active unless in CodePeer or Alfa mode, since
12315 -- this causes walk order issues.
12317 if not (CodePeer_Mode or Alfa_Mode) then
12318 Process_Inline (Enabled);
12321 --------------------
12322 -- Inline_Generic --
12323 --------------------
12325 -- pragma Inline_Generic (NAME {, NAME});
12327 when Pragma_Inline_Generic =>
12329 Process_Generic_List;
12331 ----------------------
12332 -- Inspection_Point --
12333 ----------------------
12335 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
12337 when Pragma_Inspection_Point => Inspection_Point : declare
12342 if Arg_Count > 0 then
12345 Exp := Get_Pragma_Arg (Arg);
12348 if not Is_Entity_Name (Exp)
12349 or else not Is_Object (Entity (Exp))
12351 Error_Pragma_Arg ("object name required", Arg);
12355 exit when No (Arg);
12358 end Inspection_Point;
12364 -- pragma Interface (
12365 -- [ Convention =>] convention_IDENTIFIER,
12366 -- [ Entity =>] local_NAME
12367 -- [, [External_Name =>] static_string_EXPRESSION ]
12368 -- [, [Link_Name =>] static_string_EXPRESSION ]);
12370 when Pragma_Interface =>
12375 Name_External_Name,
12377 Check_At_Least_N_Arguments (2);
12378 Check_At_Most_N_Arguments (4);
12379 Process_Import_Or_Interface;
12381 -- In Ada 2005, the permission to use Interface (a reserved word)
12382 -- as a pragma name is considered an obsolescent feature, and this
12383 -- pragma was already obsolescent in Ada 95.
12385 if Ada_Version >= Ada_95 then
12387 (No_Obsolescent_Features, Pragma_Identifier (N));
12389 if Warn_On_Obsolescent_Feature then
12391 ("pragma Interface is an obsolescent feature?j?", N);
12393 ("|use pragma Import instead?j?", N);
12397 --------------------
12398 -- Interface_Name --
12399 --------------------
12401 -- pragma Interface_Name (
12402 -- [ Entity =>] local_NAME
12403 -- [,[External_Name =>] static_string_EXPRESSION ]
12404 -- [,[Link_Name =>] static_string_EXPRESSION ]);
12406 when Pragma_Interface_Name => Interface_Name : declare
12408 Def_Id : Entity_Id;
12409 Hom_Id : Entity_Id;
12415 ((Name_Entity, Name_External_Name, Name_Link_Name));
12416 Check_At_Least_N_Arguments (2);
12417 Check_At_Most_N_Arguments (3);
12418 Id := Get_Pragma_Arg (Arg1);
12421 -- This is obsolete from Ada 95 on, but it is an implementation
12422 -- defined pragma, so we do not consider that it violates the
12423 -- restriction (No_Obsolescent_Features).
12425 if Ada_Version >= Ada_95 then
12426 if Warn_On_Obsolescent_Feature then
12428 ("pragma Interface_Name is an obsolescent feature?j?", N);
12430 ("|use pragma Import instead?j?", N);
12434 if not Is_Entity_Name (Id) then
12436 ("first argument for pragma% must be entity name", Arg1);
12437 elsif Etype (Id) = Any_Type then
12440 Def_Id := Entity (Id);
12443 -- Special DEC-compatible processing for the object case, forces
12444 -- object to be imported.
12446 if Ekind (Def_Id) = E_Variable then
12447 Kill_Size_Check_Code (Def_Id);
12448 Note_Possible_Modification (Id, Sure => False);
12450 -- Initialization is not allowed for imported variable
12452 if Present (Expression (Parent (Def_Id)))
12453 and then Comes_From_Source (Expression (Parent (Def_Id)))
12455 Error_Msg_Sloc := Sloc (Def_Id);
12457 ("no initialization allowed for declaration of& #",
12461 -- For compatibility, support VADS usage of providing both
12462 -- pragmas Interface and Interface_Name to obtain the effect
12463 -- of a single Import pragma.
12465 if Is_Imported (Def_Id)
12466 and then Present (First_Rep_Item (Def_Id))
12467 and then Nkind (First_Rep_Item (Def_Id)) = N_Pragma
12469 Pragma_Name (First_Rep_Item (Def_Id)) = Name_Interface
12473 Set_Imported (Def_Id);
12476 Set_Is_Public (Def_Id);
12477 Process_Interface_Name (Def_Id, Arg2, Arg3);
12480 -- Otherwise must be subprogram
12482 elsif not Is_Subprogram (Def_Id) then
12484 ("argument of pragma% is not subprogram", Arg1);
12487 Check_At_Most_N_Arguments (3);
12491 -- Loop through homonyms
12494 Def_Id := Get_Base_Subprogram (Hom_Id);
12496 if Is_Imported (Def_Id) then
12497 Process_Interface_Name (Def_Id, Arg2, Arg3);
12501 exit when From_Aspect_Specification (N);
12502 Hom_Id := Homonym (Hom_Id);
12504 exit when No (Hom_Id)
12505 or else Scope (Hom_Id) /= Current_Scope;
12510 ("argument of pragma% is not imported subprogram",
12514 end Interface_Name;
12516 -----------------------
12517 -- Interrupt_Handler --
12518 -----------------------
12520 -- pragma Interrupt_Handler (handler_NAME);
12522 when Pragma_Interrupt_Handler =>
12523 Check_Ada_83_Warning;
12524 Check_Arg_Count (1);
12525 Check_No_Identifiers;
12527 if No_Run_Time_Mode then
12528 Error_Msg_CRT ("Interrupt_Handler pragma", N);
12530 Check_Interrupt_Or_Attach_Handler;
12531 Process_Interrupt_Or_Attach_Handler;
12534 ------------------------
12535 -- Interrupt_Priority --
12536 ------------------------
12538 -- pragma Interrupt_Priority [(EXPRESSION)];
12540 when Pragma_Interrupt_Priority => Interrupt_Priority : declare
12541 P : constant Node_Id := Parent (N);
12546 Check_Ada_83_Warning;
12548 if Arg_Count /= 0 then
12549 Arg := Get_Pragma_Arg (Arg1);
12550 Check_Arg_Count (1);
12551 Check_No_Identifiers;
12553 -- The expression must be analyzed in the special manner
12554 -- described in "Handling of Default and Per-Object
12555 -- Expressions" in sem.ads.
12557 Preanalyze_Spec_Expression (Arg, RTE (RE_Interrupt_Priority));
12560 if not Nkind_In (P, N_Task_Definition, N_Protected_Definition) then
12565 Ent := Defining_Identifier (Parent (P));
12567 -- Check duplicate pragma before we chain the pragma in the Rep
12568 -- Item chain of Ent.
12570 Check_Duplicate_Pragma (Ent);
12571 Record_Rep_Item (Ent, N);
12573 end Interrupt_Priority;
12575 ---------------------
12576 -- Interrupt_State --
12577 ---------------------
12579 -- pragma Interrupt_State (
12580 -- [Name =>] INTERRUPT_ID,
12581 -- [State =>] INTERRUPT_STATE);
12583 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
12584 -- INTERRUPT_STATE => System | Runtime | User
12586 -- Note: if the interrupt id is given as an identifier, then it must
12587 -- be one of the identifiers in Ada.Interrupts.Names. Otherwise it is
12588 -- given as a static integer expression which must be in the range of
12589 -- Ada.Interrupts.Interrupt_ID.
12591 when Pragma_Interrupt_State => Interrupt_State : declare
12593 Int_Id : constant Entity_Id := RTE (RE_Interrupt_ID);
12594 -- This is the entity Ada.Interrupts.Interrupt_ID;
12596 State_Type : Character;
12597 -- Set to 's'/'r'/'u' for System/Runtime/User
12600 -- Index to entry in Interrupt_States table
12603 -- Value of interrupt
12605 Arg1X : constant Node_Id := Get_Pragma_Arg (Arg1);
12606 -- The first argument to the pragma
12608 Int_Ent : Entity_Id;
12609 -- Interrupt entity in Ada.Interrupts.Names
12613 Check_Arg_Order ((Name_Name, Name_State));
12614 Check_Arg_Count (2);
12616 Check_Optional_Identifier (Arg1, Name_Name);
12617 Check_Optional_Identifier (Arg2, Name_State);
12618 Check_Arg_Is_Identifier (Arg2);
12620 -- First argument is identifier
12622 if Nkind (Arg1X) = N_Identifier then
12624 -- Search list of names in Ada.Interrupts.Names
12626 Int_Ent := First_Entity (RTE (RE_Names));
12628 if No (Int_Ent) then
12629 Error_Pragma_Arg ("invalid interrupt name", Arg1);
12631 elsif Chars (Int_Ent) = Chars (Arg1X) then
12632 Int_Val := Expr_Value (Constant_Value (Int_Ent));
12636 Next_Entity (Int_Ent);
12639 -- First argument is not an identifier, so it must be a static
12640 -- expression of type Ada.Interrupts.Interrupt_ID.
12643 Check_Arg_Is_Static_Expression (Arg1, Any_Integer);
12644 Int_Val := Expr_Value (Arg1X);
12646 if Int_Val < Expr_Value (Type_Low_Bound (Int_Id))
12648 Int_Val > Expr_Value (Type_High_Bound (Int_Id))
12651 ("value not in range of type "
12652 & """Ada.Interrupts.Interrupt_'I'D""", Arg1);
12658 case Chars (Get_Pragma_Arg (Arg2)) is
12659 when Name_Runtime => State_Type := 'r';
12660 when Name_System => State_Type := 's';
12661 when Name_User => State_Type := 'u';
12664 Error_Pragma_Arg ("invalid interrupt state", Arg2);
12667 -- Check if entry is already stored
12669 IST_Num := Interrupt_States.First;
12671 -- If entry not found, add it
12673 if IST_Num > Interrupt_States.Last then
12674 Interrupt_States.Append
12675 ((Interrupt_Number => UI_To_Int (Int_Val),
12676 Interrupt_State => State_Type,
12677 Pragma_Loc => Loc));
12680 -- Case of entry for the same entry
12682 elsif Int_Val = Interrupt_States.Table (IST_Num).
12685 -- If state matches, done, no need to make redundant entry
12688 State_Type = Interrupt_States.Table (IST_Num).
12691 -- Otherwise if state does not match, error
12694 Interrupt_States.Table (IST_Num).Pragma_Loc;
12696 ("state conflicts with that given #", Arg2);
12700 IST_Num := IST_Num + 1;
12702 end Interrupt_State;
12708 -- pragma Invariant
12709 -- ([Entity =>] type_LOCAL_NAME,
12710 -- [Check =>] EXPRESSION
12711 -- [,[Message =>] String_Expression]);
12713 when Pragma_Invariant => Invariant : declare
12719 pragma Unreferenced (Discard);
12723 Check_At_Least_N_Arguments (2);
12724 Check_At_Most_N_Arguments (3);
12725 Check_Optional_Identifier (Arg1, Name_Entity);
12726 Check_Optional_Identifier (Arg2, Name_Check);
12728 if Arg_Count = 3 then
12729 Check_Optional_Identifier (Arg3, Name_Message);
12730 Check_Arg_Is_Static_Expression (Arg3, Standard_String);
12733 Check_Arg_Is_Local_Name (Arg1);
12735 Type_Id := Get_Pragma_Arg (Arg1);
12736 Find_Type (Type_Id);
12737 Typ := Entity (Type_Id);
12739 if Typ = Any_Type then
12742 -- An invariant must apply to a private type, or appear in the
12743 -- private part of a package spec and apply to a completion.
12745 elsif Ekind_In (Typ, E_Private_Type,
12746 E_Record_Type_With_Private,
12747 E_Limited_Private_Type)
12751 elsif In_Private_Part (Current_Scope)
12752 and then Has_Private_Declaration (Typ)
12756 elsif In_Private_Part (Current_Scope) then
12758 ("pragma% only allowed for private type declared in "
12759 & "visible part", Arg1);
12763 ("pragma% only allowed for private type", Arg1);
12766 -- Note that the type has at least one invariant, and also that
12767 -- it has inheritable invariants if we have Invariant'Class.
12768 -- Build the corresponding invariant procedure declaration, so
12769 -- that calls to it can be generated before the body is built
12770 -- (for example wihin an expression function).
12772 PDecl := Build_Invariant_Procedure_Declaration (Typ);
12773 Insert_After (N, PDecl);
12776 if Class_Present (N) then
12777 Set_Has_Inheritable_Invariants (Typ);
12780 -- The remaining processing is simply to link the pragma on to
12781 -- the rep item chain, for processing when the type is frozen.
12782 -- This is accomplished by a call to Rep_Item_Too_Late.
12784 Discard := Rep_Item_Too_Late (Typ, N, FOnly => True);
12787 ----------------------
12788 -- Java_Constructor --
12789 ----------------------
12791 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
12793 -- Also handles pragma CIL_Constructor
12795 when Pragma_CIL_Constructor | Pragma_Java_Constructor =>
12796 Java_Constructor : declare
12797 Convention : Convention_Id;
12798 Def_Id : Entity_Id;
12799 Hom_Id : Entity_Id;
12801 This_Formal : Entity_Id;
12805 Check_Arg_Count (1);
12806 Check_Optional_Identifier (Arg1, Name_Entity);
12807 Check_Arg_Is_Local_Name (Arg1);
12809 Id := Get_Pragma_Arg (Arg1);
12810 Find_Program_Unit_Name (Id);
12812 -- If we did not find the name, we are done
12814 if Etype (Id) = Any_Type then
12818 -- Check wrong use of pragma in wrong VM target
12820 if VM_Target = No_VM then
12823 elsif VM_Target = CLI_Target
12824 and then Prag_Id = Pragma_Java_Constructor
12826 Error_Pragma ("must use pragma 'C'I'L_'Constructor");
12828 elsif VM_Target = JVM_Target
12829 and then Prag_Id = Pragma_CIL_Constructor
12831 Error_Pragma ("must use pragma 'Java_'Constructor");
12835 when Pragma_CIL_Constructor => Convention := Convention_CIL;
12836 when Pragma_Java_Constructor => Convention := Convention_Java;
12837 when others => null;
12840 Hom_Id := Entity (Id);
12842 -- Loop through homonyms
12845 Def_Id := Get_Base_Subprogram (Hom_Id);
12847 -- The constructor is required to be a function
12849 if Ekind (Def_Id) /= E_Function then
12850 if VM_Target = JVM_Target then
12852 ("pragma% requires function returning a 'Java access "
12856 ("pragma% requires function returning a 'C'I'L access "
12861 -- Check arguments: For tagged type the first formal must be
12862 -- named "this" and its type must be a named access type
12863 -- designating a class-wide tagged type that has convention
12864 -- CIL/Java. The first formal must also have a null default
12865 -- value. For example:
12867 -- type Typ is tagged ...
12868 -- type Ref is access all Typ;
12869 -- pragma Convention (CIL, Typ);
12871 -- function New_Typ (This : Ref) return Ref;
12872 -- function New_Typ (This : Ref; I : Integer) return Ref;
12873 -- pragma Cil_Constructor (New_Typ);
12875 -- Reason: The first formal must NOT be a primitive of the
12878 -- This rule also applies to constructors of delegates used
12879 -- to interface with standard target libraries. For example:
12881 -- type Delegate is access procedure ...
12882 -- pragma Import (CIL, Delegate, ...);
12884 -- function new_Delegate
12885 -- (This : Delegate := null; ... ) return Delegate;
12887 -- For value-types this rule does not apply.
12889 if not Is_Value_Type (Etype (Def_Id)) then
12890 if No (First_Formal (Def_Id)) then
12891 Error_Msg_Name_1 := Pname;
12892 Error_Msg_N ("% function must have parameters", Def_Id);
12896 -- In the JRE library we have several occurrences in which
12897 -- the "this" parameter is not the first formal.
12899 This_Formal := First_Formal (Def_Id);
12901 -- In the JRE library we have several occurrences in which
12902 -- the "this" parameter is not the first formal. Search for
12905 if VM_Target = JVM_Target then
12906 while Present (This_Formal)
12907 and then Get_Name_String (Chars (This_Formal)) /= "this"
12909 Next_Formal (This_Formal);
12912 if No (This_Formal) then
12913 This_Formal := First_Formal (Def_Id);
12917 -- Warning: The first parameter should be named "this".
12918 -- We temporarily allow it because we have the following
12919 -- case in the Java runtime (file s-osinte.ads) ???
12921 -- function new_Thread
12922 -- (Self_Id : System.Address) return Thread_Id;
12923 -- pragma Java_Constructor (new_Thread);
12925 if VM_Target = JVM_Target
12926 and then Get_Name_String (Chars (First_Formal (Def_Id)))
12928 and then Etype (First_Formal (Def_Id)) = RTE (RE_Address)
12932 elsif Get_Name_String (Chars (This_Formal)) /= "this" then
12933 Error_Msg_Name_1 := Pname;
12935 ("first formal of % function must be named `this`",
12936 Parent (This_Formal));
12938 elsif not Is_Access_Type (Etype (This_Formal)) then
12939 Error_Msg_Name_1 := Pname;
12941 ("first formal of % function must be an access type",
12942 Parameter_Type (Parent (This_Formal)));
12944 -- For delegates the type of the first formal must be a
12945 -- named access-to-subprogram type (see previous example)
12947 elsif Ekind (Etype (Def_Id)) = E_Access_Subprogram_Type
12948 and then Ekind (Etype (This_Formal))
12949 /= E_Access_Subprogram_Type
12951 Error_Msg_Name_1 := Pname;
12953 ("first formal of % function must be a named access "
12954 & "to subprogram type",
12955 Parameter_Type (Parent (This_Formal)));
12957 -- Warning: We should reject anonymous access types because
12958 -- the constructor must not be handled as a primitive of the
12959 -- tagged type. We temporarily allow it because this profile
12960 -- is currently generated by cil2ada???
12962 elsif Ekind (Etype (Def_Id)) /= E_Access_Subprogram_Type
12963 and then not Ekind_In (Etype (This_Formal),
12965 E_General_Access_Type,
12966 E_Anonymous_Access_Type)
12968 Error_Msg_Name_1 := Pname;
12970 ("first formal of % function must be a named access "
12971 & "type", Parameter_Type (Parent (This_Formal)));
12973 elsif Atree.Convention
12974 (Designated_Type (Etype (This_Formal))) /= Convention
12976 Error_Msg_Name_1 := Pname;
12978 if Convention = Convention_Java then
12980 ("pragma% requires convention 'Cil in designated "
12981 & "type", Parameter_Type (Parent (This_Formal)));
12984 ("pragma% requires convention 'Java in designated "
12985 & "type", Parameter_Type (Parent (This_Formal)));
12988 elsif No (Expression (Parent (This_Formal)))
12989 or else Nkind (Expression (Parent (This_Formal))) /= N_Null
12991 Error_Msg_Name_1 := Pname;
12993 ("pragma% requires first formal with default `null`",
12994 Parameter_Type (Parent (This_Formal)));
12998 -- Check result type: the constructor must be a function
13000 -- * a value type (only allowed in the CIL compiler)
13001 -- * an access-to-subprogram type with convention Java/CIL
13002 -- * an access-type designating a type that has convention
13005 if Is_Value_Type (Etype (Def_Id)) then
13008 -- Access-to-subprogram type with convention Java/CIL
13010 elsif Ekind (Etype (Def_Id)) = E_Access_Subprogram_Type then
13011 if Atree.Convention (Etype (Def_Id)) /= Convention then
13012 if Convention = Convention_Java then
13014 ("pragma% requires function returning a 'Java "
13015 & "access type", Arg1);
13017 pragma Assert (Convention = Convention_CIL);
13019 ("pragma% requires function returning a 'C'I'L "
13020 & "access type", Arg1);
13024 elsif Ekind (Etype (Def_Id)) in Access_Kind then
13025 if not Ekind_In (Etype (Def_Id), E_Access_Type,
13026 E_General_Access_Type)
13029 (Designated_Type (Etype (Def_Id))) /= Convention
13031 Error_Msg_Name_1 := Pname;
13033 if Convention = Convention_Java then
13035 ("pragma% requires function returning a named "
13036 & "'Java access type", Arg1);
13039 ("pragma% requires function returning a named "
13040 & "'C'I'L access type", Arg1);
13045 Set_Is_Constructor (Def_Id);
13046 Set_Convention (Def_Id, Convention);
13047 Set_Is_Imported (Def_Id);
13049 exit when From_Aspect_Specification (N);
13050 Hom_Id := Homonym (Hom_Id);
13052 exit when No (Hom_Id) or else Scope (Hom_Id) /= Current_Scope;
13054 end Java_Constructor;
13056 ----------------------
13057 -- Java_Interface --
13058 ----------------------
13060 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
13062 when Pragma_Java_Interface => Java_Interface : declare
13068 Check_Arg_Count (1);
13069 Check_Optional_Identifier (Arg1, Name_Entity);
13070 Check_Arg_Is_Local_Name (Arg1);
13072 Arg := Get_Pragma_Arg (Arg1);
13075 if Etype (Arg) = Any_Type then
13079 if not Is_Entity_Name (Arg)
13080 or else not Is_Type (Entity (Arg))
13082 Error_Pragma_Arg ("pragma% requires a type mark", Arg1);
13085 Typ := Underlying_Type (Entity (Arg));
13087 -- For now simply check some of the semantic constraints on the
13088 -- type. This currently leaves out some restrictions on interface
13089 -- types, namely that the parent type must be java.lang.Object.Typ
13090 -- and that all primitives of the type should be declared
13093 if not Is_Tagged_Type (Typ) or else not Is_Abstract_Type (Typ) then
13094 Error_Pragma_Arg ("pragma% requires an abstract "
13095 & "tagged type", Arg1);
13097 elsif not Has_Discriminants (Typ)
13098 or else Ekind (Etype (First_Discriminant (Typ)))
13099 /= E_Anonymous_Access_Type
13101 not Is_Class_Wide_Type
13102 (Designated_Type (Etype (First_Discriminant (Typ))))
13105 ("type must have a class-wide access discriminant", Arg1);
13107 end Java_Interface;
13113 -- pragma Keep_Names ([On => ] local_NAME);
13115 when Pragma_Keep_Names => Keep_Names : declare
13120 Check_Arg_Count (1);
13121 Check_Optional_Identifier (Arg1, Name_On);
13122 Check_Arg_Is_Local_Name (Arg1);
13124 Arg := Get_Pragma_Arg (Arg1);
13127 if Etype (Arg) = Any_Type then
13131 if not Is_Entity_Name (Arg)
13132 or else Ekind (Entity (Arg)) /= E_Enumeration_Type
13135 ("pragma% requires a local enumeration type", Arg1);
13138 Set_Discard_Names (Entity (Arg), False);
13145 -- pragma License (RESTRICTED | UNRESTRICTED | GPL | MODIFIED_GPL);
13147 when Pragma_License =>
13149 Check_Arg_Count (1);
13150 Check_No_Identifiers;
13151 Check_Valid_Configuration_Pragma;
13152 Check_Arg_Is_Identifier (Arg1);
13155 Sind : constant Source_File_Index :=
13156 Source_Index (Current_Sem_Unit);
13159 case Chars (Get_Pragma_Arg (Arg1)) is
13161 Set_License (Sind, GPL);
13163 when Name_Modified_GPL =>
13164 Set_License (Sind, Modified_GPL);
13166 when Name_Restricted =>
13167 Set_License (Sind, Restricted);
13169 when Name_Unrestricted =>
13170 Set_License (Sind, Unrestricted);
13173 Error_Pragma_Arg ("invalid license name", Arg1);
13181 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
13183 when Pragma_Link_With => Link_With : declare
13189 if Operating_Mode = Generate_Code
13190 and then In_Extended_Main_Source_Unit (N)
13192 Check_At_Least_N_Arguments (1);
13193 Check_No_Identifiers;
13194 Check_Is_In_Decl_Part_Or_Package_Spec;
13195 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
13199 while Present (Arg) loop
13200 Check_Arg_Is_Static_Expression (Arg, Standard_String);
13202 -- Store argument, converting sequences of spaces to a
13203 -- single null character (this is one of the differences
13204 -- in processing between Link_With and Linker_Options).
13206 Arg_Store : declare
13207 C : constant Char_Code := Get_Char_Code (' ');
13208 S : constant String_Id :=
13209 Strval (Expr_Value_S (Get_Pragma_Arg (Arg)));
13210 L : constant Nat := String_Length (S);
13213 procedure Skip_Spaces;
13214 -- Advance F past any spaces
13220 procedure Skip_Spaces is
13222 while F <= L and then Get_String_Char (S, F) = C loop
13227 -- Start of processing for Arg_Store
13230 Skip_Spaces; -- skip leading spaces
13232 -- Loop through characters, changing any embedded
13233 -- sequence of spaces to a single null character (this
13234 -- is how Link_With/Linker_Options differ)
13237 if Get_String_Char (S, F) = C then
13240 Store_String_Char (ASCII.NUL);
13243 Store_String_Char (Get_String_Char (S, F));
13251 if Present (Arg) then
13252 Store_String_Char (ASCII.NUL);
13256 Store_Linker_Option_String (End_String);
13264 -- pragma Linker_Alias (
13265 -- [Entity =>] LOCAL_NAME
13266 -- [Target =>] static_string_EXPRESSION);
13268 when Pragma_Linker_Alias =>
13270 Check_Arg_Order ((Name_Entity, Name_Target));
13271 Check_Arg_Count (2);
13272 Check_Optional_Identifier (Arg1, Name_Entity);
13273 Check_Optional_Identifier (Arg2, Name_Target);
13274 Check_Arg_Is_Library_Level_Local_Name (Arg1);
13275 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
13277 -- The only processing required is to link this item on to the
13278 -- list of rep items for the given entity. This is accomplished
13279 -- by the call to Rep_Item_Too_Late (when no error is detected
13280 -- and False is returned).
13282 if Rep_Item_Too_Late (Entity (Get_Pragma_Arg (Arg1)), N) then
13285 Set_Has_Gigi_Rep_Item (Entity (Get_Pragma_Arg (Arg1)));
13288 ------------------------
13289 -- Linker_Constructor --
13290 ------------------------
13292 -- pragma Linker_Constructor (procedure_LOCAL_NAME);
13294 -- Code is shared with Linker_Destructor
13296 -----------------------
13297 -- Linker_Destructor --
13298 -----------------------
13300 -- pragma Linker_Destructor (procedure_LOCAL_NAME);
13302 when Pragma_Linker_Constructor |
13303 Pragma_Linker_Destructor =>
13304 Linker_Constructor : declare
13310 Check_Arg_Count (1);
13311 Check_No_Identifiers;
13312 Check_Arg_Is_Local_Name (Arg1);
13313 Arg1_X := Get_Pragma_Arg (Arg1);
13315 Proc := Find_Unique_Parameterless_Procedure (Arg1_X, Arg1);
13317 if not Is_Library_Level_Entity (Proc) then
13319 ("argument for pragma% must be library level entity", Arg1);
13322 -- The only processing required is to link this item on to the
13323 -- list of rep items for the given entity. This is accomplished
13324 -- by the call to Rep_Item_Too_Late (when no error is detected
13325 -- and False is returned).
13327 if Rep_Item_Too_Late (Proc, N) then
13330 Set_Has_Gigi_Rep_Item (Proc);
13332 end Linker_Constructor;
13334 --------------------
13335 -- Linker_Options --
13336 --------------------
13338 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
13340 when Pragma_Linker_Options => Linker_Options : declare
13344 Check_Ada_83_Warning;
13345 Check_No_Identifiers;
13346 Check_Arg_Count (1);
13347 Check_Is_In_Decl_Part_Or_Package_Spec;
13348 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
13349 Start_String (Strval (Expr_Value_S (Get_Pragma_Arg (Arg1))));
13352 while Present (Arg) loop
13353 Check_Arg_Is_Static_Expression (Arg, Standard_String);
13354 Store_String_Char (ASCII.NUL);
13356 (Strval (Expr_Value_S (Get_Pragma_Arg (Arg))));
13360 if Operating_Mode = Generate_Code
13361 and then In_Extended_Main_Source_Unit (N)
13363 Store_Linker_Option_String (End_String);
13365 end Linker_Options;
13367 --------------------
13368 -- Linker_Section --
13369 --------------------
13371 -- pragma Linker_Section (
13372 -- [Entity =>] LOCAL_NAME
13373 -- [Section =>] static_string_EXPRESSION);
13375 when Pragma_Linker_Section =>
13377 Check_Arg_Order ((Name_Entity, Name_Section));
13378 Check_Arg_Count (2);
13379 Check_Optional_Identifier (Arg1, Name_Entity);
13380 Check_Optional_Identifier (Arg2, Name_Section);
13381 Check_Arg_Is_Library_Level_Local_Name (Arg1);
13382 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
13384 -- This pragma applies only to objects
13386 if not Is_Object (Entity (Get_Pragma_Arg (Arg1))) then
13387 Error_Pragma_Arg ("pragma% applies only to objects", Arg1);
13390 -- The only processing required is to link this item on to the
13391 -- list of rep items for the given entity. This is accomplished
13392 -- by the call to Rep_Item_Too_Late (when no error is detected
13393 -- and False is returned).
13395 if Rep_Item_Too_Late (Entity (Get_Pragma_Arg (Arg1)), N) then
13398 Set_Has_Gigi_Rep_Item (Entity (Get_Pragma_Arg (Arg1)));
13405 -- pragma List (On | Off)
13407 -- There is nothing to do here, since we did all the processing for
13408 -- this pragma in Par.Prag (so that it works properly even in syntax
13411 when Pragma_List =>
13418 -- pragma Lock_Free [(Boolean_EXPRESSION)];
13420 when Pragma_Lock_Free => Lock_Free : declare
13421 P : constant Node_Id := Parent (N);
13427 Check_No_Identifiers;
13428 Check_At_Most_N_Arguments (1);
13430 -- Protected definition case
13432 if Nkind (P) = N_Protected_Definition then
13433 Ent := Defining_Identifier (Parent (P));
13437 if Arg_Count = 1 then
13438 Arg := Get_Pragma_Arg (Arg1);
13439 Val := Is_True (Static_Boolean (Arg));
13441 -- No arguments (expression is considered to be True)
13447 -- Check duplicate pragma before we chain the pragma in the Rep
13448 -- Item chain of Ent.
13450 Check_Duplicate_Pragma (Ent);
13451 Record_Rep_Item (Ent, N);
13452 Set_Uses_Lock_Free (Ent, Val);
13454 -- Anything else is incorrect placement
13461 --------------------
13462 -- Locking_Policy --
13463 --------------------
13465 -- pragma Locking_Policy (policy_IDENTIFIER);
13467 when Pragma_Locking_Policy => declare
13468 subtype LP_Range is Name_Id
13469 range First_Locking_Policy_Name .. Last_Locking_Policy_Name;
13474 Check_Ada_83_Warning;
13475 Check_Arg_Count (1);
13476 Check_No_Identifiers;
13477 Check_Arg_Is_Locking_Policy (Arg1);
13478 Check_Valid_Configuration_Pragma;
13479 LP_Val := Chars (Get_Pragma_Arg (Arg1));
13482 when Name_Ceiling_Locking =>
13484 when Name_Inheritance_Locking =>
13486 when Name_Concurrent_Readers_Locking =>
13490 if Locking_Policy /= ' '
13491 and then Locking_Policy /= LP
13493 Error_Msg_Sloc := Locking_Policy_Sloc;
13494 Error_Pragma ("locking policy incompatible with policy#");
13496 -- Set new policy, but always preserve System_Location since we
13497 -- like the error message with the run time name.
13500 Locking_Policy := LP;
13502 if Locking_Policy_Sloc /= System_Location then
13503 Locking_Policy_Sloc := Loc;
13512 -- pragma Long_Float (D_Float | G_Float);
13514 when Pragma_Long_Float => Long_Float : declare
13517 Check_Valid_Configuration_Pragma;
13518 Check_Arg_Count (1);
13519 Check_No_Identifier (Arg1);
13520 Check_Arg_Is_One_Of (Arg1, Name_D_Float, Name_G_Float);
13522 if not OpenVMS_On_Target then
13523 Error_Pragma ("??pragma% ignored (applies only to Open'V'M'S)");
13528 if Chars (Get_Pragma_Arg (Arg1)) = Name_D_Float then
13529 if Opt.Float_Format_Long = 'G' then
13531 ("G_Float previously specified", Arg1);
13533 elsif Current_Sem_Unit /= Main_Unit
13534 and then Opt.Float_Format_Long /= 'D'
13537 ("main unit not compiled with pragma Long_Float (D_Float)",
13538 "\pragma% must be used consistently for whole partition",
13542 Opt.Float_Format_Long := 'D';
13545 -- G_Float case (this is the default, does not need overriding)
13548 if Opt.Float_Format_Long = 'D' then
13549 Error_Pragma ("D_Float previously specified");
13551 elsif Current_Sem_Unit /= Main_Unit
13552 and then Opt.Float_Format_Long /= 'G'
13555 ("main unit not compiled with pragma Long_Float (G_Float)",
13556 "\pragma% must be used consistently for whole partition",
13560 Opt.Float_Format_Long := 'G';
13564 Set_Standard_Fpt_Formats;
13567 --------------------
13568 -- Loop_Invariant --
13569 --------------------
13571 -- pragma Loop_Invariant ( boolean_EXPRESSION );
13573 when Pragma_Loop_Invariant => Loop_Invariant : declare
13577 Check_Arg_Count (1);
13578 Check_Loop_Pragma_Placement;
13580 -- Completely ignore if disabled
13582 if not Check_Enabled (Pname) then
13583 Rewrite (N, Make_Null_Statement (Loc));
13588 Preanalyze_Assert_Expression (Expression (Arg1), Any_Boolean);
13590 -- Transform pragma Loop_Invariant into equivalent pragma Check
13592 -- pragma Check (Loop_Invaraint, Arg1);
13596 Chars => Name_Check,
13597 Pragma_Argument_Associations => New_List (
13598 Make_Pragma_Argument_Association (Loc,
13599 Expression => Make_Identifier (Loc, Name_Loop_Invariant)),
13600 Relocate_Node (Arg1))));
13603 end Loop_Invariant;
13605 -------------------
13606 -- Loop_Optimize --
13607 -------------------
13609 -- pragma Loop_Optimize ( OPTIMIZATION_HINT {, OPTIMIZATION_HINT } );
13611 -- OPTIMIZATION_HINT ::= No_Unroll | Unroll | No_Vector | Vector
13613 when Pragma_Loop_Optimize => Loop_Optimize : declare
13618 Check_At_Least_N_Arguments (1);
13619 Check_No_Identifiers;
13621 Hint := First (Pragma_Argument_Associations (N));
13622 while Present (Hint) loop
13623 Check_Arg_Is_One_Of (Hint,
13624 Name_No_Unroll, Name_Unroll, Name_No_Vector, Name_Vector);
13628 Check_Loop_Pragma_Placement;
13635 -- pragma Loop_Variant
13636 -- ( LOOP_VARIANT_ITEM {, LOOP_VARIANT_ITEM } );
13638 -- LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
13640 -- CHANGE_DIRECTION ::= Increases | Decreases
13642 when Pragma_Loop_Variant => Loop_Variant : declare
13648 Check_At_Least_N_Arguments (1);
13649 Check_Loop_Pragma_Placement;
13651 -- Completely ignore if disabled
13653 if not Check_Enabled (Pname) then
13654 Rewrite (N, Make_Null_Statement (Loc));
13659 -- Process all increasing / decreasing expressions
13661 Variant := First (Pragma_Argument_Associations (N));
13662 while Present (Variant) loop
13663 if Chars (Variant) /= Name_Decreases
13664 and then Chars (Variant) /= Name_Increases
13666 Error_Pragma_Arg ("wrong change modifier", Variant);
13669 Preanalyze_Assert_Expression
13670 (Expression (Variant), Any_Discrete);
13676 -----------------------
13677 -- Machine_Attribute --
13678 -----------------------
13680 -- pragma Machine_Attribute (
13681 -- [Entity =>] LOCAL_NAME,
13682 -- [Attribute_Name =>] static_string_EXPRESSION
13683 -- [, [Info =>] static_EXPRESSION] );
13685 when Pragma_Machine_Attribute => Machine_Attribute : declare
13686 Def_Id : Entity_Id;
13690 Check_Arg_Order ((Name_Entity, Name_Attribute_Name, Name_Info));
13692 if Arg_Count = 3 then
13693 Check_Optional_Identifier (Arg3, Name_Info);
13694 Check_Arg_Is_Static_Expression (Arg3);
13696 Check_Arg_Count (2);
13699 Check_Optional_Identifier (Arg1, Name_Entity);
13700 Check_Optional_Identifier (Arg2, Name_Attribute_Name);
13701 Check_Arg_Is_Local_Name (Arg1);
13702 Check_Arg_Is_Static_Expression (Arg2, Standard_String);
13703 Def_Id := Entity (Get_Pragma_Arg (Arg1));
13705 if Is_Access_Type (Def_Id) then
13706 Def_Id := Designated_Type (Def_Id);
13709 if Rep_Item_Too_Early (Def_Id, N) then
13713 Def_Id := Underlying_Type (Def_Id);
13715 -- The only processing required is to link this item on to the
13716 -- list of rep items for the given entity. This is accomplished
13717 -- by the call to Rep_Item_Too_Late (when no error is detected
13718 -- and False is returned).
13720 if Rep_Item_Too_Late (Def_Id, N) then
13723 Set_Has_Gigi_Rep_Item (Entity (Get_Pragma_Arg (Arg1)));
13725 end Machine_Attribute;
13732 -- (MAIN_OPTION [, MAIN_OPTION]);
13735 -- [STACK_SIZE =>] static_integer_EXPRESSION
13736 -- | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
13737 -- | [TIME_SLICING_ENABLED =>] static_boolean_EXPRESSION
13739 when Pragma_Main => Main : declare
13740 Args : Args_List (1 .. 3);
13741 Names : constant Name_List (1 .. 3) := (
13743 Name_Task_Stack_Size_Default,
13744 Name_Time_Slicing_Enabled);
13750 Gather_Associations (Names, Args);
13752 for J in 1 .. 2 loop
13753 if Present (Args (J)) then
13754 Check_Arg_Is_Static_Expression (Args (J), Any_Integer);
13758 if Present (Args (3)) then
13759 Check_Arg_Is_Static_Expression (Args (3), Standard_Boolean);
13763 while Present (Nod) loop
13764 if Nkind (Nod) = N_Pragma
13765 and then Pragma_Name (Nod) = Name_Main
13767 Error_Msg_Name_1 := Pname;
13768 Error_Msg_N ("duplicate pragma% not permitted", Nod);
13779 -- pragma Main_Storage
13780 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
13782 -- MAIN_STORAGE_OPTION ::=
13783 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
13784 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
13786 when Pragma_Main_Storage => Main_Storage : declare
13787 Args : Args_List (1 .. 2);
13788 Names : constant Name_List (1 .. 2) := (
13789 Name_Working_Storage,
13796 Gather_Associations (Names, Args);
13798 for J in 1 .. 2 loop
13799 if Present (Args (J)) then
13800 Check_Arg_Is_Static_Expression (Args (J), Any_Integer);
13804 Check_In_Main_Program;
13807 while Present (Nod) loop
13808 if Nkind (Nod) = N_Pragma
13809 and then Pragma_Name (Nod) = Name_Main_Storage
13811 Error_Msg_Name_1 := Pname;
13812 Error_Msg_N ("duplicate pragma% not permitted", Nod);
13823 -- pragma Memory_Size (NUMERIC_LITERAL)
13825 when Pragma_Memory_Size =>
13828 -- Memory size is simply ignored
13830 Check_No_Identifiers;
13831 Check_Arg_Count (1);
13832 Check_Arg_Is_Integer_Literal (Arg1);
13840 -- The only correct use of this pragma is on its own in a file, in
13841 -- which case it is specially processed (see Gnat1drv.Check_Bad_Body
13842 -- and Frontend, which use Sinput.L.Source_File_Is_Pragma_No_Body to
13843 -- check for a file containing nothing but a No_Body pragma). If we
13844 -- attempt to process it during normal semantics processing, it means
13845 -- it was misplaced.
13847 when Pragma_No_Body =>
13855 -- pragma No_Inline ( NAME {, NAME} );
13857 when Pragma_No_Inline =>
13859 Process_Inline (Suppressed);
13865 -- pragma No_Return (procedure_LOCAL_NAME {, procedure_Local_Name});
13867 when Pragma_No_Return => No_Return : declare
13875 Check_At_Least_N_Arguments (1);
13877 -- Loop through arguments of pragma
13880 while Present (Arg) loop
13881 Check_Arg_Is_Local_Name (Arg);
13882 Id := Get_Pragma_Arg (Arg);
13885 if not Is_Entity_Name (Id) then
13886 Error_Pragma_Arg ("entity name required", Arg);
13889 if Etype (Id) = Any_Type then
13893 -- Loop to find matching procedures
13898 and then Scope (E) = Current_Scope
13900 if Ekind_In (E, E_Procedure, E_Generic_Procedure) then
13903 -- Set flag on any alias as well
13905 if Is_Overloadable (E) and then Present (Alias (E)) then
13906 Set_No_Return (Alias (E));
13912 exit when From_Aspect_Specification (N);
13917 Error_Pragma_Arg ("no procedure & found for pragma%", Arg);
13928 -- pragma No_Run_Time;
13930 -- Note: this pragma is retained for backwards compatibility. See
13931 -- body of Rtsfind for full details on its handling.
13933 when Pragma_No_Run_Time =>
13935 Check_Valid_Configuration_Pragma;
13936 Check_Arg_Count (0);
13938 No_Run_Time_Mode := True;
13939 Configurable_Run_Time_Mode := True;
13941 -- Set Duration to 32 bits if word size is 32
13943 if Ttypes.System_Word_Size = 32 then
13944 Duration_32_Bits_On_Target := True;
13947 -- Set appropriate restrictions
13949 Set_Restriction (No_Finalization, N);
13950 Set_Restriction (No_Exception_Handlers, N);
13951 Set_Restriction (Max_Tasks, N, 0);
13952 Set_Restriction (No_Tasking, N);
13954 ------------------------
13955 -- No_Strict_Aliasing --
13956 ------------------------
13958 -- pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
13960 when Pragma_No_Strict_Aliasing => No_Strict_Aliasing : declare
13965 Check_At_Most_N_Arguments (1);
13967 if Arg_Count = 0 then
13968 Check_Valid_Configuration_Pragma;
13969 Opt.No_Strict_Aliasing := True;
13972 Check_Optional_Identifier (Arg2, Name_Entity);
13973 Check_Arg_Is_Local_Name (Arg1);
13974 E_Id := Entity (Get_Pragma_Arg (Arg1));
13976 if E_Id = Any_Type then
13978 elsif No (E_Id) or else not Is_Access_Type (E_Id) then
13979 Error_Pragma_Arg ("pragma% requires access type", Arg1);
13982 Set_No_Strict_Aliasing (Implementation_Base_Type (E_Id));
13984 end No_Strict_Aliasing;
13986 -----------------------
13987 -- Normalize_Scalars --
13988 -----------------------
13990 -- pragma Normalize_Scalars;
13992 when Pragma_Normalize_Scalars =>
13993 Check_Ada_83_Warning;
13994 Check_Arg_Count (0);
13995 Check_Valid_Configuration_Pragma;
13997 -- Normalize_Scalars creates false positives in CodePeer, and
13998 -- incorrect negative results in Alfa mode, so ignore this pragma
14001 if not (CodePeer_Mode or Alfa_Mode) then
14002 Normalize_Scalars := True;
14003 Init_Or_Norm_Scalars := True;
14010 -- pragma Obsolescent;
14012 -- pragma Obsolescent (
14013 -- [Message =>] static_string_EXPRESSION
14014 -- [,[Version =>] Ada_05]]);
14016 -- pragma Obsolescent (
14017 -- [Entity =>] NAME
14018 -- [,[Message =>] static_string_EXPRESSION
14019 -- [,[Version =>] Ada_05]] );
14021 when Pragma_Obsolescent => Obsolescent : declare
14025 procedure Set_Obsolescent (E : Entity_Id);
14026 -- Given an entity Ent, mark it as obsolescent if appropriate
14028 ---------------------
14029 -- Set_Obsolescent --
14030 ---------------------
14032 procedure Set_Obsolescent (E : Entity_Id) is
14041 -- Entity name was given
14043 if Present (Ename) then
14045 -- If entity name matches, we are fine. Save entity in
14046 -- pragma argument, for ASIS use.
14048 if Chars (Ename) = Chars (Ent) then
14049 Set_Entity (Ename, Ent);
14050 Generate_Reference (Ent, Ename);
14052 -- If entity name does not match, only possibility is an
14053 -- enumeration literal from an enumeration type declaration.
14055 elsif Ekind (Ent) /= E_Enumeration_Type then
14057 ("pragma % entity name does not match declaration");
14060 Ent := First_Literal (E);
14064 ("pragma % entity name does not match any "
14065 & "enumeration literal");
14067 elsif Chars (Ent) = Chars (Ename) then
14068 Set_Entity (Ename, Ent);
14069 Generate_Reference (Ent, Ename);
14073 Ent := Next_Literal (Ent);
14079 -- Ent points to entity to be marked
14081 if Arg_Count >= 1 then
14083 -- Deal with static string argument
14085 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
14086 S := Strval (Get_Pragma_Arg (Arg1));
14088 for J in 1 .. String_Length (S) loop
14089 if not In_Character_Range (Get_String_Char (S, J)) then
14091 ("pragma% argument does not allow wide characters",
14096 Obsolescent_Warnings.Append
14097 ((Ent => Ent, Msg => Strval (Get_Pragma_Arg (Arg1))));
14099 -- Check for Ada_05 parameter
14101 if Arg_Count /= 1 then
14102 Check_Arg_Count (2);
14105 Argx : constant Node_Id := Get_Pragma_Arg (Arg2);
14108 Check_Arg_Is_Identifier (Argx);
14110 if Chars (Argx) /= Name_Ada_05 then
14111 Error_Msg_Name_2 := Name_Ada_05;
14113 ("only allowed argument for pragma% is %", Argx);
14116 if Ada_Version_Explicit < Ada_2005
14117 or else not Warn_On_Ada_2005_Compatibility
14125 -- Set flag if pragma active
14128 Set_Is_Obsolescent (Ent);
14132 end Set_Obsolescent;
14134 -- Start of processing for pragma Obsolescent
14139 Check_At_Most_N_Arguments (3);
14141 -- See if first argument specifies an entity name
14145 (Chars (Arg1) = Name_Entity
14147 Nkind_In (Get_Pragma_Arg (Arg1), N_Character_Literal,
14149 N_Operator_Symbol))
14151 Ename := Get_Pragma_Arg (Arg1);
14153 -- Eliminate first argument, so we can share processing
14157 Arg_Count := Arg_Count - 1;
14159 -- No Entity name argument given
14165 if Arg_Count >= 1 then
14166 Check_Optional_Identifier (Arg1, Name_Message);
14168 if Arg_Count = 2 then
14169 Check_Optional_Identifier (Arg2, Name_Version);
14173 -- Get immediately preceding declaration
14176 while Present (Decl) and then Nkind (Decl) = N_Pragma loop
14180 -- Cases where we do not follow anything other than another pragma
14184 -- First case: library level compilation unit declaration with
14185 -- the pragma immediately following the declaration.
14187 if Nkind (Parent (N)) = N_Compilation_Unit_Aux then
14189 (Defining_Entity (Unit (Parent (Parent (N)))));
14192 -- Case 2: library unit placement for package
14196 Ent : constant Entity_Id := Find_Lib_Unit_Name;
14198 if Is_Package_Or_Generic_Package (Ent) then
14199 Set_Obsolescent (Ent);
14205 -- Cases where we must follow a declaration
14208 if Nkind (Decl) not in N_Declaration
14209 and then Nkind (Decl) not in N_Later_Decl_Item
14210 and then Nkind (Decl) not in N_Generic_Declaration
14211 and then Nkind (Decl) not in N_Renaming_Declaration
14214 ("pragma% misplaced, "
14215 & "must immediately follow a declaration");
14218 Set_Obsolescent (Defining_Entity (Decl));
14228 -- pragma Optimize (Time | Space | Off);
14230 -- The actual check for optimize is done in Gigi. Note that this
14231 -- pragma does not actually change the optimization setting, it
14232 -- simply checks that it is consistent with the pragma.
14234 when Pragma_Optimize =>
14235 Check_No_Identifiers;
14236 Check_Arg_Count (1);
14237 Check_Arg_Is_One_Of (Arg1, Name_Time, Name_Space, Name_Off);
14239 ------------------------
14240 -- Optimize_Alignment --
14241 ------------------------
14243 -- pragma Optimize_Alignment (Time | Space | Off);
14245 when Pragma_Optimize_Alignment => Optimize_Alignment : begin
14247 Check_No_Identifiers;
14248 Check_Arg_Count (1);
14249 Check_Valid_Configuration_Pragma;
14252 Nam : constant Name_Id := Chars (Get_Pragma_Arg (Arg1));
14256 Opt.Optimize_Alignment := 'T';
14258 Opt.Optimize_Alignment := 'S';
14260 Opt.Optimize_Alignment := 'O';
14262 Error_Pragma_Arg ("invalid argument for pragma%", Arg1);
14266 -- Set indication that mode is set locally. If we are in fact in a
14267 -- configuration pragma file, this setting is harmless since the
14268 -- switch will get reset anyway at the start of each unit.
14270 Optimize_Alignment_Local := True;
14271 end Optimize_Alignment;
14273 -------------------
14274 -- Overflow_Mode --
14275 -------------------
14277 -- pragma Overflow_Mode
14278 -- ([General => ] MODE [, [Assertions => ] MODE]);
14280 -- MODE := STRICT | MINIMIZED | ELIMINATED
14282 -- Note: ELIMINATED is allowed only if Long_Long_Integer'Size is 64
14283 -- since System.Bignums makes this assumption. This is true of nearly
14284 -- all (all?) targets.
14286 when Pragma_Overflow_Mode => Overflow_Mode : declare
14287 function Get_Overflow_Mode
14289 Arg : Node_Id) return Overflow_Mode_Type;
14290 -- Function to process one pragma argument, Arg. If an identifier
14291 -- is present, it must be Name. Mode type is returned if a valid
14292 -- argument exists, otherwise an error is signalled.
14294 -----------------------
14295 -- Get_Overflow_Mode --
14296 -----------------------
14298 function Get_Overflow_Mode
14300 Arg : Node_Id) return Overflow_Mode_Type
14302 Argx : constant Node_Id := Get_Pragma_Arg (Arg);
14305 Check_Optional_Identifier (Arg, Name);
14306 Check_Arg_Is_Identifier (Argx);
14308 if Chars (Argx) = Name_Strict then
14311 elsif Chars (Argx) = Name_Minimized then
14314 elsif Chars (Argx) = Name_Eliminated then
14315 if Ttypes.Standard_Long_Long_Integer_Size /= 64 then
14317 ("Eliminated not implemented on this target", Argx);
14323 Error_Pragma_Arg ("invalid argument for pragma%", Argx);
14325 end Get_Overflow_Mode;
14327 -- Start of processing for Overflow_Mode
14331 Check_At_Least_N_Arguments (1);
14332 Check_At_Most_N_Arguments (2);
14334 -- Process first argument
14336 Scope_Suppress.Overflow_Mode_General :=
14337 Get_Overflow_Mode (Name_General, Arg1);
14339 -- Case of only one argument
14341 if Arg_Count = 1 then
14342 Scope_Suppress.Overflow_Mode_Assertions :=
14343 Scope_Suppress.Overflow_Mode_General;
14345 -- Case of two arguments present
14348 Scope_Suppress.Overflow_Mode_Assertions :=
14349 Get_Overflow_Mode (Name_Assertions, Arg2);
14353 when Pragma_Overriding_Renamings =>
14354 Overriding_Renamings := True;
14360 -- pragma Ordered (first_enumeration_subtype_LOCAL_NAME);
14362 when Pragma_Ordered => Ordered : declare
14363 Assoc : constant Node_Id := Arg1;
14369 Check_No_Identifiers;
14370 Check_Arg_Count (1);
14371 Check_Arg_Is_Local_Name (Arg1);
14373 Type_Id := Get_Pragma_Arg (Assoc);
14374 Find_Type (Type_Id);
14375 Typ := Entity (Type_Id);
14377 if Typ = Any_Type then
14380 Typ := Underlying_Type (Typ);
14383 if not Is_Enumeration_Type (Typ) then
14384 Error_Pragma ("pragma% must specify enumeration type");
14387 Check_First_Subtype (Arg1);
14388 Set_Has_Pragma_Ordered (Base_Type (Typ));
14395 -- pragma Pack (first_subtype_LOCAL_NAME);
14397 when Pragma_Pack => Pack : declare
14398 Assoc : constant Node_Id := Arg1;
14402 Ignore : Boolean := False;
14405 Check_No_Identifiers;
14406 Check_Arg_Count (1);
14407 Check_Arg_Is_Local_Name (Arg1);
14409 Type_Id := Get_Pragma_Arg (Assoc);
14410 Find_Type (Type_Id);
14411 Typ := Entity (Type_Id);
14414 or else Rep_Item_Too_Early (Typ, N)
14418 Typ := Underlying_Type (Typ);
14421 if not Is_Array_Type (Typ) and then not Is_Record_Type (Typ) then
14422 Error_Pragma ("pragma% must specify array or record type");
14425 Check_First_Subtype (Arg1);
14426 Check_Duplicate_Pragma (Typ);
14430 if Is_Array_Type (Typ) then
14431 Ctyp := Component_Type (Typ);
14433 -- Ignore pack that does nothing
14435 if Known_Static_Esize (Ctyp)
14436 and then Known_Static_RM_Size (Ctyp)
14437 and then Esize (Ctyp) = RM_Size (Ctyp)
14438 and then Addressable (Esize (Ctyp))
14443 -- Process OK pragma Pack. Note that if there is a separate
14444 -- component clause present, the Pack will be cancelled. This
14445 -- processing is in Freeze.
14447 if not Rep_Item_Too_Late (Typ, N) then
14449 -- In the context of static code analysis, we do not need
14450 -- complex front-end expansions related to pragma Pack,
14451 -- so disable handling of pragma Pack in these cases.
14453 if CodePeer_Mode or Alfa_Mode then
14456 -- Don't attempt any packing for VM targets. We possibly
14457 -- could deal with some cases of array bit-packing, but we
14458 -- don't bother, since this is not a typical kind of
14459 -- representation in the VM context anyway (and would not
14460 -- for example work nicely with the debugger).
14462 elsif VM_Target /= No_VM then
14463 if not GNAT_Mode then
14465 ("??pragma% ignored in this configuration");
14468 -- Normal case where we do the pack action
14472 Set_Is_Packed (Base_Type (Typ));
14473 Set_Has_Non_Standard_Rep (Base_Type (Typ));
14476 Set_Has_Pragma_Pack (Base_Type (Typ));
14480 -- For record types, the pack is always effective
14482 else pragma Assert (Is_Record_Type (Typ));
14483 if not Rep_Item_Too_Late (Typ, N) then
14485 -- Ignore pack request with warning in VM mode (skip warning
14486 -- if we are compiling GNAT run time library).
14488 if VM_Target /= No_VM then
14489 if not GNAT_Mode then
14491 ("??pragma% ignored in this configuration");
14494 -- Normal case of pack request active
14497 Set_Is_Packed (Base_Type (Typ));
14498 Set_Has_Pragma_Pack (Base_Type (Typ));
14499 Set_Has_Non_Standard_Rep (Base_Type (Typ));
14511 -- There is nothing to do here, since we did all the processing for
14512 -- this pragma in Par.Prag (so that it works properly even in syntax
14515 when Pragma_Page =>
14518 ----------------------------------
14519 -- Partition_Elaboration_Policy --
14520 ----------------------------------
14522 -- pragma Partition_Elaboration_Policy (policy_IDENTIFIER);
14524 when Pragma_Partition_Elaboration_Policy => declare
14525 subtype PEP_Range is Name_Id
14526 range First_Partition_Elaboration_Policy_Name
14527 .. Last_Partition_Elaboration_Policy_Name;
14528 PEP_Val : PEP_Range;
14533 Check_Arg_Count (1);
14534 Check_No_Identifiers;
14535 Check_Arg_Is_Partition_Elaboration_Policy (Arg1);
14536 Check_Valid_Configuration_Pragma;
14537 PEP_Val := Chars (Get_Pragma_Arg (Arg1));
14540 when Name_Concurrent =>
14542 when Name_Sequential =>
14546 if Partition_Elaboration_Policy /= ' '
14547 and then Partition_Elaboration_Policy /= PEP
14549 Error_Msg_Sloc := Partition_Elaboration_Policy_Sloc;
14551 ("partition elaboration policy incompatible with policy#");
14553 -- Set new policy, but always preserve System_Location since we
14554 -- like the error message with the run time name.
14557 Partition_Elaboration_Policy := PEP;
14559 if Partition_Elaboration_Policy_Sloc /= System_Location then
14560 Partition_Elaboration_Policy_Sloc := Loc;
14569 -- pragma Passive [(PASSIVE_FORM)];
14571 -- PASSIVE_FORM ::= Semaphore | No
14573 when Pragma_Passive =>
14576 if Nkind (Parent (N)) /= N_Task_Definition then
14577 Error_Pragma ("pragma% must be within task definition");
14580 if Arg_Count /= 0 then
14581 Check_Arg_Count (1);
14582 Check_Arg_Is_One_Of (Arg1, Name_Semaphore, Name_No);
14585 ----------------------------------
14586 -- Preelaborable_Initialization --
14587 ----------------------------------
14589 -- pragma Preelaborable_Initialization (DIRECT_NAME);
14591 when Pragma_Preelaborable_Initialization => Preelab_Init : declare
14596 Check_Arg_Count (1);
14597 Check_No_Identifiers;
14598 Check_Arg_Is_Identifier (Arg1);
14599 Check_Arg_Is_Local_Name (Arg1);
14600 Check_First_Subtype (Arg1);
14601 Ent := Entity (Get_Pragma_Arg (Arg1));
14603 -- The pragma may come from an aspect on a private declaration,
14604 -- even if the freeze point at which this is analyzed in the
14605 -- private part after the full view.
14607 if Has_Private_Declaration (Ent)
14608 and then From_Aspect_Specification (N)
14612 elsif Is_Private_Type (Ent)
14613 or else Is_Protected_Type (Ent)
14614 or else (Is_Generic_Type (Ent) and then Is_Derived_Type (Ent))
14620 ("pragma % can only be applied to private, formal derived or "
14621 & "protected type",
14625 -- Give an error if the pragma is applied to a protected type that
14626 -- does not qualify (due to having entries, or due to components
14627 -- that do not qualify).
14629 if Is_Protected_Type (Ent)
14630 and then not Has_Preelaborable_Initialization (Ent)
14633 ("protected type & does not have preelaborable "
14634 & "initialization", Ent);
14636 -- Otherwise mark the type as definitely having preelaborable
14640 Set_Known_To_Have_Preelab_Init (Ent);
14643 if Has_Pragma_Preelab_Init (Ent)
14644 and then Warn_On_Redundant_Constructs
14646 Error_Pragma ("?r?duplicate pragma%!");
14648 Set_Has_Pragma_Preelab_Init (Ent);
14652 --------------------
14653 -- Persistent_BSS --
14654 --------------------
14656 -- pragma Persistent_BSS [(object_NAME)];
14658 when Pragma_Persistent_BSS => Persistent_BSS : declare
14665 Check_At_Most_N_Arguments (1);
14667 -- Case of application to specific object (one argument)
14669 if Arg_Count = 1 then
14670 Check_Arg_Is_Library_Level_Local_Name (Arg1);
14672 if not Is_Entity_Name (Get_Pragma_Arg (Arg1))
14674 Ekind_In (Entity (Get_Pragma_Arg (Arg1)), E_Variable,
14677 Error_Pragma_Arg ("pragma% only applies to objects", Arg1);
14680 Ent := Entity (Get_Pragma_Arg (Arg1));
14681 Decl := Parent (Ent);
14683 -- Check for duplication before inserting in list of
14684 -- representation items.
14686 Check_Duplicate_Pragma (Ent);
14688 if Rep_Item_Too_Late (Ent, N) then
14692 if Present (Expression (Decl)) then
14694 ("object for pragma% cannot have initialization", Arg1);
14697 if not Is_Potentially_Persistent_Type (Etype (Ent)) then
14699 ("object type for pragma% is not potentially persistent",
14704 Make_Linker_Section_Pragma
14705 (Ent, Sloc (N), ".persistent.bss");
14706 Insert_After (N, Prag);
14709 -- Case of use as configuration pragma with no arguments
14712 Check_Valid_Configuration_Pragma;
14713 Persistent_BSS_Mode := True;
14715 end Persistent_BSS;
14721 -- pragma Polling (ON | OFF);
14723 when Pragma_Polling =>
14725 Check_Arg_Count (1);
14726 Check_No_Identifiers;
14727 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
14728 Polling_Required := (Chars (Get_Pragma_Arg (Arg1)) = Name_On);
14730 -------------------
14731 -- Postcondition --
14732 -------------------
14734 -- pragma Postcondition ([Check =>] Boolean_EXPRESSION
14735 -- [,[Message =>] String_EXPRESSION]);
14737 when Pragma_Postcondition => Postcondition : declare
14742 Check_At_Least_N_Arguments (1);
14743 Check_At_Most_N_Arguments (2);
14744 Check_Optional_Identifier (Arg1, Name_Check);
14746 -- Verify the proper placement of the pragma. The remainder of the
14747 -- processing is found in Sem_Ch6/Sem_Ch7.
14749 Check_Precondition_Postcondition (In_Body);
14751 -- When the pragma is a source contruct and appears inside a body,
14752 -- preanalyze the boolean_expression to detect illegal forward
14756 -- pragma Postcondition (X'Old ...);
14759 if Comes_From_Source (N) and then In_Body then
14760 Preanalyze_Spec_Expression (Expression (Arg1), Any_Boolean);
14768 -- pragma Precondition ([Check =>] Boolean_EXPRESSION
14769 -- [,[Message =>] String_EXPRESSION]);
14771 when Pragma_Precondition => Precondition : declare
14776 Check_At_Least_N_Arguments (1);
14777 Check_At_Most_N_Arguments (2);
14778 Check_Optional_Identifier (Arg1, Name_Check);
14779 Check_Precondition_Postcondition (In_Body);
14781 -- If in spec, nothing more to do. If in body, then we convert the
14782 -- pragma to pragma Check (Precondition, cond [, msg]). Note we do
14783 -- this whether or not precondition checks are enabled. That works
14784 -- fine since pragma Check will do this check, and will also
14785 -- analyze the condition itself in the proper context.
14790 Chars => Name_Check,
14791 Pragma_Argument_Associations => New_List (
14792 Make_Pragma_Argument_Association (Loc,
14793 Expression => Make_Identifier (Loc, Name_Precondition)),
14795 Make_Pragma_Argument_Association (Sloc (Arg1),
14796 Expression => Relocate_Node (Get_Pragma_Arg (Arg1))))));
14798 if Arg_Count = 2 then
14799 Append_To (Pragma_Argument_Associations (N),
14800 Make_Pragma_Argument_Association (Sloc (Arg2),
14801 Expression => Relocate_Node (Get_Pragma_Arg (Arg2))));
14812 -- pragma Predicate
14813 -- ([Entity =>] type_LOCAL_NAME,
14814 -- [Check =>] EXPRESSION);
14816 when Pragma_Predicate => Predicate : declare
14821 pragma Unreferenced (Discard);
14825 Check_Arg_Count (2);
14826 Check_Optional_Identifier (Arg1, Name_Entity);
14827 Check_Optional_Identifier (Arg2, Name_Check);
14829 Check_Arg_Is_Local_Name (Arg1);
14831 Type_Id := Get_Pragma_Arg (Arg1);
14832 Find_Type (Type_Id);
14833 Typ := Entity (Type_Id);
14835 if Typ = Any_Type then
14839 -- The remaining processing is simply to link the pragma on to
14840 -- the rep item chain, for processing when the type is frozen.
14841 -- This is accomplished by a call to Rep_Item_Too_Late. We also
14842 -- mark the type as having predicates.
14844 Set_Has_Predicates (Typ);
14845 Discard := Rep_Item_Too_Late (Typ, N, FOnly => True);
14852 -- pragma Preelaborate [(library_unit_NAME)];
14854 -- Set the flag Is_Preelaborated of program unit name entity
14856 when Pragma_Preelaborate => Preelaborate : declare
14857 Pa : constant Node_Id := Parent (N);
14858 Pk : constant Node_Kind := Nkind (Pa);
14862 Check_Ada_83_Warning;
14863 Check_Valid_Library_Unit_Pragma;
14865 if Nkind (N) = N_Null_Statement then
14869 Ent := Find_Lib_Unit_Name;
14870 Check_Duplicate_Pragma (Ent);
14872 -- This filters out pragmas inside generic parent then
14873 -- show up inside instantiation
14876 and then not (Pk = N_Package_Specification
14877 and then Present (Generic_Parent (Pa)))
14879 if not Debug_Flag_U then
14880 Set_Is_Preelaborated (Ent);
14881 Set_Suppress_Elaboration_Warnings (Ent);
14886 ---------------------
14887 -- Preelaborate_05 --
14888 ---------------------
14890 -- pragma Preelaborate_05 [(library_unit_NAME)];
14892 -- This pragma is useable only in GNAT_Mode, where it is used like
14893 -- pragma Preelaborate but it is only effective in Ada 2005 mode
14894 -- (otherwise it is ignored). This is used to implement AI-362 which
14895 -- recategorizes some run-time packages in Ada 2005 mode.
14897 when Pragma_Preelaborate_05 => Preelaborate_05 : declare
14902 Check_Valid_Library_Unit_Pragma;
14904 if not GNAT_Mode then
14905 Error_Pragma ("pragma% only available in GNAT mode");
14908 if Nkind (N) = N_Null_Statement then
14912 -- This is one of the few cases where we need to test the value of
14913 -- Ada_Version_Explicit rather than Ada_Version (which is always
14914 -- set to Ada_2012 in a predefined unit), we need to know the
14915 -- explicit version set to know if this pragma is active.
14917 if Ada_Version_Explicit >= Ada_2005 then
14918 Ent := Find_Lib_Unit_Name;
14919 Set_Is_Preelaborated (Ent);
14920 Set_Suppress_Elaboration_Warnings (Ent);
14922 end Preelaborate_05;
14928 -- pragma Priority (EXPRESSION);
14930 when Pragma_Priority => Priority : declare
14931 P : constant Node_Id := Parent (N);
14936 Check_No_Identifiers;
14937 Check_Arg_Count (1);
14941 if Nkind (P) = N_Subprogram_Body then
14942 Check_In_Main_Program;
14944 Ent := Defining_Unit_Name (Specification (P));
14946 if Nkind (Ent) = N_Defining_Program_Unit_Name then
14947 Ent := Defining_Identifier (Ent);
14950 Arg := Get_Pragma_Arg (Arg1);
14951 Analyze_And_Resolve (Arg, Standard_Integer);
14955 if not Is_Static_Expression (Arg) then
14956 Flag_Non_Static_Expr
14957 ("main subprogram priority is not static!", Arg);
14960 -- If constraint error, then we already signalled an error
14962 elsif Raises_Constraint_Error (Arg) then
14965 -- Otherwise check in range
14969 Val : constant Uint := Expr_Value (Arg);
14973 or else Val > Expr_Value (Expression
14974 (Parent (RTE (RE_Max_Priority))))
14977 ("main subprogram priority is out of range", Arg1);
14983 (Current_Sem_Unit, UI_To_Int (Expr_Value (Arg)));
14985 -- Load an arbitrary entity from System.Tasking to make sure
14986 -- this package is implicitly with'ed, since we need to have
14987 -- the tasking run-time active for the pragma Priority to have
14991 Discard : Entity_Id;
14992 pragma Warnings (Off, Discard);
14994 Discard := RTE (RE_Task_List);
14997 -- Task or Protected, must be of type Integer
14999 elsif Nkind_In (P, N_Protected_Definition, N_Task_Definition) then
15000 Arg := Get_Pragma_Arg (Arg1);
15001 Ent := Defining_Identifier (Parent (P));
15003 -- The expression must be analyzed in the special manner
15004 -- described in "Handling of Default and Per-Object
15005 -- Expressions" in sem.ads.
15007 Preanalyze_Spec_Expression (Arg, RTE (RE_Any_Priority));
15009 if not Is_Static_Expression (Arg) then
15010 Check_Restriction (Static_Priorities, Arg);
15013 -- Anything else is incorrect
15019 -- Check duplicate pragma before we chain the pragma in the Rep
15020 -- Item chain of Ent.
15022 Check_Duplicate_Pragma (Ent);
15023 Record_Rep_Item (Ent, N);
15026 -----------------------------------
15027 -- Priority_Specific_Dispatching --
15028 -----------------------------------
15030 -- pragma Priority_Specific_Dispatching (
15031 -- policy_IDENTIFIER,
15032 -- first_priority_EXPRESSION,
15033 -- last_priority_EXPRESSION);
15035 when Pragma_Priority_Specific_Dispatching =>
15036 Priority_Specific_Dispatching : declare
15037 Prio_Id : constant Entity_Id := RTE (RE_Any_Priority);
15038 -- This is the entity System.Any_Priority;
15041 Lower_Bound : Node_Id;
15042 Upper_Bound : Node_Id;
15048 Check_Arg_Count (3);
15049 Check_No_Identifiers;
15050 Check_Arg_Is_Task_Dispatching_Policy (Arg1);
15051 Check_Valid_Configuration_Pragma;
15052 Get_Name_String (Chars (Get_Pragma_Arg (Arg1)));
15053 DP := Fold_Upper (Name_Buffer (1));
15055 Lower_Bound := Get_Pragma_Arg (Arg2);
15056 Check_Arg_Is_Static_Expression (Lower_Bound, Standard_Integer);
15057 Lower_Val := Expr_Value (Lower_Bound);
15059 Upper_Bound := Get_Pragma_Arg (Arg3);
15060 Check_Arg_Is_Static_Expression (Upper_Bound, Standard_Integer);
15061 Upper_Val := Expr_Value (Upper_Bound);
15063 -- It is not allowed to use Task_Dispatching_Policy and
15064 -- Priority_Specific_Dispatching in the same partition.
15066 if Task_Dispatching_Policy /= ' ' then
15067 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
15069 ("pragma% incompatible with Task_Dispatching_Policy#");
15071 -- Check lower bound in range
15073 elsif Lower_Val < Expr_Value (Type_Low_Bound (Prio_Id))
15075 Lower_Val > Expr_Value (Type_High_Bound (Prio_Id))
15078 ("first_priority is out of range", Arg2);
15080 -- Check upper bound in range
15082 elsif Upper_Val < Expr_Value (Type_Low_Bound (Prio_Id))
15084 Upper_Val > Expr_Value (Type_High_Bound (Prio_Id))
15087 ("last_priority is out of range", Arg3);
15089 -- Check that the priority range is valid
15091 elsif Lower_Val > Upper_Val then
15093 ("last_priority_expression must be greater than or equal to "
15094 & "first_priority_expression");
15096 -- Store the new policy, but always preserve System_Location since
15097 -- we like the error message with the run-time name.
15100 -- Check overlapping in the priority ranges specified in other
15101 -- Priority_Specific_Dispatching pragmas within the same
15102 -- partition. We can only check those we know about!
15105 Specific_Dispatching.First .. Specific_Dispatching.Last
15107 if Specific_Dispatching.Table (J).First_Priority in
15108 UI_To_Int (Lower_Val) .. UI_To_Int (Upper_Val)
15109 or else Specific_Dispatching.Table (J).Last_Priority in
15110 UI_To_Int (Lower_Val) .. UI_To_Int (Upper_Val)
15113 Specific_Dispatching.Table (J).Pragma_Loc;
15115 ("priority range overlaps with "
15116 & "Priority_Specific_Dispatching#");
15120 -- The use of Priority_Specific_Dispatching is incompatible
15121 -- with Task_Dispatching_Policy.
15123 if Task_Dispatching_Policy /= ' ' then
15124 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
15126 ("Priority_Specific_Dispatching incompatible "
15127 & "with Task_Dispatching_Policy#");
15130 -- The use of Priority_Specific_Dispatching forces ceiling
15133 if Locking_Policy /= ' ' and then Locking_Policy /= 'C' then
15134 Error_Msg_Sloc := Locking_Policy_Sloc;
15136 ("Priority_Specific_Dispatching incompatible "
15137 & "with Locking_Policy#");
15139 -- Set the Ceiling_Locking policy, but preserve System_Location
15140 -- since we like the error message with the run time name.
15143 Locking_Policy := 'C';
15145 if Locking_Policy_Sloc /= System_Location then
15146 Locking_Policy_Sloc := Loc;
15150 -- Add entry in the table
15152 Specific_Dispatching.Append
15153 ((Dispatching_Policy => DP,
15154 First_Priority => UI_To_Int (Lower_Val),
15155 Last_Priority => UI_To_Int (Upper_Val),
15156 Pragma_Loc => Loc));
15158 end Priority_Specific_Dispatching;
15164 -- pragma Profile (profile_IDENTIFIER);
15166 -- profile_IDENTIFIER => Restricted | Ravenscar | Rational
15168 when Pragma_Profile =>
15170 Check_Arg_Count (1);
15171 Check_Valid_Configuration_Pragma;
15172 Check_No_Identifiers;
15175 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
15178 if Chars (Argx) = Name_Ravenscar then
15179 Set_Ravenscar_Profile (N);
15181 elsif Chars (Argx) = Name_Restricted then
15182 Set_Profile_Restrictions
15184 N, Warn => Treat_Restrictions_As_Warnings);
15186 elsif Chars (Argx) = Name_Rational then
15187 Set_Rational_Profile;
15189 elsif Chars (Argx) = Name_No_Implementation_Extensions then
15190 Set_Profile_Restrictions
15191 (No_Implementation_Extensions,
15192 N, Warn => Treat_Restrictions_As_Warnings);
15195 Error_Pragma_Arg ("& is not a valid profile", Argx);
15199 ----------------------
15200 -- Profile_Warnings --
15201 ----------------------
15203 -- pragma Profile_Warnings (profile_IDENTIFIER);
15205 -- profile_IDENTIFIER => Restricted | Ravenscar
15207 when Pragma_Profile_Warnings =>
15209 Check_Arg_Count (1);
15210 Check_Valid_Configuration_Pragma;
15211 Check_No_Identifiers;
15214 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
15217 if Chars (Argx) = Name_Ravenscar then
15218 Set_Profile_Restrictions (Ravenscar, N, Warn => True);
15220 elsif Chars (Argx) = Name_Restricted then
15221 Set_Profile_Restrictions (Restricted, N, Warn => True);
15223 elsif Chars (Argx) = Name_No_Implementation_Extensions then
15224 Set_Profile_Restrictions
15225 (No_Implementation_Extensions, N, Warn => True);
15228 Error_Pragma_Arg ("& is not a valid profile", Argx);
15232 --------------------------
15233 -- Propagate_Exceptions --
15234 --------------------------
15236 -- pragma Propagate_Exceptions;
15238 -- Note: this pragma is obsolete and has no effect
15240 when Pragma_Propagate_Exceptions =>
15242 Check_Arg_Count (0);
15244 if In_Extended_Main_Source_Unit (N) then
15245 Propagate_Exceptions := True;
15252 -- pragma Psect_Object (
15253 -- [Internal =>] LOCAL_NAME,
15254 -- [, [External =>] EXTERNAL_SYMBOL]
15255 -- [, [Size =>] EXTERNAL_SYMBOL]);
15257 when Pragma_Psect_Object | Pragma_Common_Object =>
15258 Psect_Object : declare
15259 Args : Args_List (1 .. 3);
15260 Names : constant Name_List (1 .. 3) := (
15265 Internal : Node_Id renames Args (1);
15266 External : Node_Id renames Args (2);
15267 Size : Node_Id renames Args (3);
15269 Def_Id : Entity_Id;
15271 procedure Check_Too_Long (Arg : Node_Id);
15272 -- Posts message if the argument is an identifier with more
15273 -- than 31 characters, or a string literal with more than
15274 -- 31 characters, and we are operating under VMS
15276 --------------------
15277 -- Check_Too_Long --
15278 --------------------
15280 procedure Check_Too_Long (Arg : Node_Id) is
15281 X : constant Node_Id := Original_Node (Arg);
15284 if not Nkind_In (X, N_String_Literal, N_Identifier) then
15286 ("inappropriate argument for pragma %", Arg);
15289 if OpenVMS_On_Target then
15290 if (Nkind (X) = N_String_Literal
15291 and then String_Length (Strval (X)) > 31)
15293 (Nkind (X) = N_Identifier
15294 and then Length_Of_Name (Chars (X)) > 31)
15297 ("argument for pragma % is longer than 31 characters",
15301 end Check_Too_Long;
15303 -- Start of processing for Common_Object/Psect_Object
15307 Gather_Associations (Names, Args);
15308 Process_Extended_Import_Export_Internal_Arg (Internal);
15310 Def_Id := Entity (Internal);
15312 if not Ekind_In (Def_Id, E_Constant, E_Variable) then
15314 ("pragma% must designate an object", Internal);
15317 Check_Too_Long (Internal);
15319 if Is_Imported (Def_Id) or else Is_Exported (Def_Id) then
15321 ("cannot use pragma% for imported/exported object",
15325 if Is_Concurrent_Type (Etype (Internal)) then
15327 ("cannot specify pragma % for task/protected object",
15331 if Has_Rep_Pragma (Def_Id, Name_Common_Object)
15333 Has_Rep_Pragma (Def_Id, Name_Psect_Object)
15335 Error_Msg_N ("??duplicate Common/Psect_Object pragma", N);
15338 if Ekind (Def_Id) = E_Constant then
15340 ("cannot specify pragma % for a constant", Internal);
15343 if Is_Record_Type (Etype (Internal)) then
15349 Ent := First_Entity (Etype (Internal));
15350 while Present (Ent) loop
15351 Decl := Declaration_Node (Ent);
15353 if Ekind (Ent) = E_Component
15354 and then Nkind (Decl) = N_Component_Declaration
15355 and then Present (Expression (Decl))
15356 and then Warn_On_Export_Import
15359 ("?x?object for pragma % has defaults", Internal);
15369 if Present (Size) then
15370 Check_Too_Long (Size);
15373 if Present (External) then
15374 Check_Arg_Is_External_Name (External);
15375 Check_Too_Long (External);
15378 -- If all error tests pass, link pragma on to the rep item chain
15380 Record_Rep_Item (Def_Id, N);
15387 -- pragma Pure [(library_unit_NAME)];
15389 when Pragma_Pure => Pure : declare
15393 Check_Ada_83_Warning;
15394 Check_Valid_Library_Unit_Pragma;
15396 if Nkind (N) = N_Null_Statement then
15400 Ent := Find_Lib_Unit_Name;
15402 Set_Has_Pragma_Pure (Ent);
15403 Set_Suppress_Elaboration_Warnings (Ent);
15410 -- pragma Pure_05 [(library_unit_NAME)];
15412 -- This pragma is useable only in GNAT_Mode, where it is used like
15413 -- pragma Pure but it is only effective in Ada 2005 mode (otherwise
15414 -- it is ignored). It may be used after a pragma Preelaborate, in
15415 -- which case it overrides the effect of the pragma Preelaborate.
15416 -- This is used to implement AI-362 which recategorizes some run-time
15417 -- packages in Ada 2005 mode.
15419 when Pragma_Pure_05 => Pure_05 : declare
15424 Check_Valid_Library_Unit_Pragma;
15426 if not GNAT_Mode then
15427 Error_Pragma ("pragma% only available in GNAT mode");
15430 if Nkind (N) = N_Null_Statement then
15434 -- This is one of the few cases where we need to test the value of
15435 -- Ada_Version_Explicit rather than Ada_Version (which is always
15436 -- set to Ada_2012 in a predefined unit), we need to know the
15437 -- explicit version set to know if this pragma is active.
15439 if Ada_Version_Explicit >= Ada_2005 then
15440 Ent := Find_Lib_Unit_Name;
15441 Set_Is_Preelaborated (Ent, False);
15443 Set_Suppress_Elaboration_Warnings (Ent);
15451 -- pragma Pure_12 [(library_unit_NAME)];
15453 -- This pragma is useable only in GNAT_Mode, where it is used like
15454 -- pragma Pure but it is only effective in Ada 2012 mode (otherwise
15455 -- it is ignored). It may be used after a pragma Preelaborate, in
15456 -- which case it overrides the effect of the pragma Preelaborate.
15457 -- This is used to implement AI05-0212 which recategorizes some
15458 -- run-time packages in Ada 2012 mode.
15460 when Pragma_Pure_12 => Pure_12 : declare
15465 Check_Valid_Library_Unit_Pragma;
15467 if not GNAT_Mode then
15468 Error_Pragma ("pragma% only available in GNAT mode");
15471 if Nkind (N) = N_Null_Statement then
15475 -- This is one of the few cases where we need to test the value of
15476 -- Ada_Version_Explicit rather than Ada_Version (which is always
15477 -- set to Ada_2012 in a predefined unit), we need to know the
15478 -- explicit version set to know if this pragma is active.
15480 if Ada_Version_Explicit >= Ada_2012 then
15481 Ent := Find_Lib_Unit_Name;
15482 Set_Is_Preelaborated (Ent, False);
15484 Set_Suppress_Elaboration_Warnings (Ent);
15488 -------------------
15489 -- Pure_Function --
15490 -------------------
15492 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
15494 when Pragma_Pure_Function => Pure_Function : declare
15497 Def_Id : Entity_Id;
15498 Effective : Boolean := False;
15502 Check_Arg_Count (1);
15503 Check_Optional_Identifier (Arg1, Name_Entity);
15504 Check_Arg_Is_Local_Name (Arg1);
15505 E_Id := Get_Pragma_Arg (Arg1);
15507 if Error_Posted (E_Id) then
15511 -- Loop through homonyms (overloadings) of referenced entity
15513 E := Entity (E_Id);
15515 if Present (E) then
15517 Def_Id := Get_Base_Subprogram (E);
15519 if not Ekind_In (Def_Id, E_Function,
15520 E_Generic_Function,
15524 ("pragma% requires a function name", Arg1);
15527 Set_Is_Pure (Def_Id);
15529 if not Has_Pragma_Pure_Function (Def_Id) then
15530 Set_Has_Pragma_Pure_Function (Def_Id);
15534 exit when From_Aspect_Specification (N);
15536 exit when No (E) or else Scope (E) /= Current_Scope;
15540 and then Warn_On_Redundant_Constructs
15543 ("pragma Pure_Function on& is redundant?r?",
15549 --------------------
15550 -- Queuing_Policy --
15551 --------------------
15553 -- pragma Queuing_Policy (policy_IDENTIFIER);
15555 when Pragma_Queuing_Policy => declare
15559 Check_Ada_83_Warning;
15560 Check_Arg_Count (1);
15561 Check_No_Identifiers;
15562 Check_Arg_Is_Queuing_Policy (Arg1);
15563 Check_Valid_Configuration_Pragma;
15564 Get_Name_String (Chars (Get_Pragma_Arg (Arg1)));
15565 QP := Fold_Upper (Name_Buffer (1));
15567 if Queuing_Policy /= ' '
15568 and then Queuing_Policy /= QP
15570 Error_Msg_Sloc := Queuing_Policy_Sloc;
15571 Error_Pragma ("queuing policy incompatible with policy#");
15573 -- Set new policy, but always preserve System_Location since we
15574 -- like the error message with the run time name.
15577 Queuing_Policy := QP;
15579 if Queuing_Policy_Sloc /= System_Location then
15580 Queuing_Policy_Sloc := Loc;
15589 -- pragma Rational, for compatibility with foreign compiler
15591 when Pragma_Rational =>
15592 Set_Rational_Profile;
15594 -----------------------
15595 -- Relative_Deadline --
15596 -----------------------
15598 -- pragma Relative_Deadline (time_span_EXPRESSION);
15600 when Pragma_Relative_Deadline => Relative_Deadline : declare
15601 P : constant Node_Id := Parent (N);
15606 Check_No_Identifiers;
15607 Check_Arg_Count (1);
15609 Arg := Get_Pragma_Arg (Arg1);
15611 -- The expression must be analyzed in the special manner described
15612 -- in "Handling of Default and Per-Object Expressions" in sem.ads.
15614 Preanalyze_Spec_Expression (Arg, RTE (RE_Time_Span));
15618 if Nkind (P) = N_Subprogram_Body then
15619 Check_In_Main_Program;
15621 -- Only Task and subprogram cases allowed
15623 elsif Nkind (P) /= N_Task_Definition then
15627 -- Check duplicate pragma before we set the corresponding flag
15629 if Has_Relative_Deadline_Pragma (P) then
15630 Error_Pragma ("duplicate pragma% not allowed");
15633 -- Set Has_Relative_Deadline_Pragma only for tasks. Note that
15634 -- Relative_Deadline pragma node cannot be inserted in the Rep
15635 -- Item chain of Ent since it is rewritten by the expander as a
15636 -- procedure call statement that will break the chain.
15638 Set_Has_Relative_Deadline_Pragma (P, True);
15639 end Relative_Deadline;
15641 ------------------------
15642 -- Remote_Access_Type --
15643 ------------------------
15645 -- pragma Remote_Access_Type ([Entity =>] formal_type_LOCAL_NAME);
15647 when Pragma_Remote_Access_Type => Remote_Access_Type : declare
15652 Check_Arg_Count (1);
15653 Check_Optional_Identifier (Arg1, Name_Entity);
15654 Check_Arg_Is_Local_Name (Arg1);
15656 E := Entity (Get_Pragma_Arg (Arg1));
15658 if Nkind (Parent (E)) = N_Formal_Type_Declaration
15659 and then Ekind (E) = E_General_Access_Type
15660 and then Is_Class_Wide_Type (Directly_Designated_Type (E))
15661 and then Scope (Root_Type (Directly_Designated_Type (E)))
15663 and then Is_Valid_Remote_Object_Type
15664 (Root_Type (Directly_Designated_Type (E)))
15666 Set_Is_Remote_Types (E);
15670 ("pragma% applies only to formal access to classwide types",
15673 end Remote_Access_Type;
15675 ---------------------------
15676 -- Remote_Call_Interface --
15677 ---------------------------
15679 -- pragma Remote_Call_Interface [(library_unit_NAME)];
15681 when Pragma_Remote_Call_Interface => Remote_Call_Interface : declare
15682 Cunit_Node : Node_Id;
15683 Cunit_Ent : Entity_Id;
15687 Check_Ada_83_Warning;
15688 Check_Valid_Library_Unit_Pragma;
15690 if Nkind (N) = N_Null_Statement then
15694 Cunit_Node := Cunit (Current_Sem_Unit);
15695 K := Nkind (Unit (Cunit_Node));
15696 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
15698 if K = N_Package_Declaration
15699 or else K = N_Generic_Package_Declaration
15700 or else K = N_Subprogram_Declaration
15701 or else K = N_Generic_Subprogram_Declaration
15702 or else (K = N_Subprogram_Body
15703 and then Acts_As_Spec (Unit (Cunit_Node)))
15708 "pragma% must apply to package or subprogram declaration");
15711 Set_Is_Remote_Call_Interface (Cunit_Ent);
15712 end Remote_Call_Interface;
15718 -- pragma Remote_Types [(library_unit_NAME)];
15720 when Pragma_Remote_Types => Remote_Types : declare
15721 Cunit_Node : Node_Id;
15722 Cunit_Ent : Entity_Id;
15725 Check_Ada_83_Warning;
15726 Check_Valid_Library_Unit_Pragma;
15728 if Nkind (N) = N_Null_Statement then
15732 Cunit_Node := Cunit (Current_Sem_Unit);
15733 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
15735 if not Nkind_In (Unit (Cunit_Node), N_Package_Declaration,
15736 N_Generic_Package_Declaration)
15739 ("pragma% can only apply to a package declaration");
15742 Set_Is_Remote_Types (Cunit_Ent);
15749 -- pragma Ravenscar;
15751 when Pragma_Ravenscar =>
15753 Check_Arg_Count (0);
15754 Check_Valid_Configuration_Pragma;
15755 Set_Ravenscar_Profile (N);
15757 if Warn_On_Obsolescent_Feature then
15759 ("pragma Ravenscar is an obsolescent feature?j?", N);
15761 ("|use pragma Profile (Ravenscar) instead?j?", N);
15764 -------------------------
15765 -- Restricted_Run_Time --
15766 -------------------------
15768 -- pragma Restricted_Run_Time;
15770 when Pragma_Restricted_Run_Time =>
15772 Check_Arg_Count (0);
15773 Check_Valid_Configuration_Pragma;
15774 Set_Profile_Restrictions
15775 (Restricted, N, Warn => Treat_Restrictions_As_Warnings);
15777 if Warn_On_Obsolescent_Feature then
15779 ("pragma Restricted_Run_Time is an obsolescent feature?j?",
15782 ("|use pragma Profile (Restricted) instead?j?", N);
15789 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
15792 -- restriction_IDENTIFIER
15793 -- | restriction_parameter_IDENTIFIER => EXPRESSION
15795 when Pragma_Restrictions =>
15796 Process_Restrictions_Or_Restriction_Warnings
15797 (Warn => Treat_Restrictions_As_Warnings);
15799 --------------------------
15800 -- Restriction_Warnings --
15801 --------------------------
15803 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
15806 -- restriction_IDENTIFIER
15807 -- | restriction_parameter_IDENTIFIER => EXPRESSION
15809 when Pragma_Restriction_Warnings =>
15811 Process_Restrictions_Or_Restriction_Warnings (Warn => True);
15817 -- pragma Reviewable;
15819 when Pragma_Reviewable =>
15820 Check_Ada_83_Warning;
15821 Check_Arg_Count (0);
15823 -- Call dummy debugging function rv. This is done to assist front
15824 -- end debugging. By placing a Reviewable pragma in the source
15825 -- program, a breakpoint on rv catches this place in the source,
15826 -- allowing convenient stepping to the point of interest.
15830 --------------------------
15831 -- Short_Circuit_And_Or --
15832 --------------------------
15834 when Pragma_Short_Circuit_And_Or =>
15836 Check_Arg_Count (0);
15837 Check_Valid_Configuration_Pragma;
15838 Short_Circuit_And_Or := True;
15840 -------------------
15841 -- Share_Generic --
15842 -------------------
15844 -- pragma Share_Generic (NAME {, NAME});
15846 when Pragma_Share_Generic =>
15848 Process_Generic_List;
15854 -- pragma Shared (LOCAL_NAME);
15856 when Pragma_Shared =>
15858 Process_Atomic_Shared_Volatile;
15860 --------------------
15861 -- Shared_Passive --
15862 --------------------
15864 -- pragma Shared_Passive [(library_unit_NAME)];
15866 -- Set the flag Is_Shared_Passive of program unit name entity
15868 when Pragma_Shared_Passive => Shared_Passive : declare
15869 Cunit_Node : Node_Id;
15870 Cunit_Ent : Entity_Id;
15873 Check_Ada_83_Warning;
15874 Check_Valid_Library_Unit_Pragma;
15876 if Nkind (N) = N_Null_Statement then
15880 Cunit_Node := Cunit (Current_Sem_Unit);
15881 Cunit_Ent := Cunit_Entity (Current_Sem_Unit);
15883 if not Nkind_In (Unit (Cunit_Node), N_Package_Declaration,
15884 N_Generic_Package_Declaration)
15887 ("pragma% can only apply to a package declaration");
15890 Set_Is_Shared_Passive (Cunit_Ent);
15891 end Shared_Passive;
15893 -----------------------
15894 -- Short_Descriptors --
15895 -----------------------
15897 -- pragma Short_Descriptors;
15899 when Pragma_Short_Descriptors =>
15901 Check_Arg_Count (0);
15902 Check_Valid_Configuration_Pragma;
15903 Short_Descriptors := True;
15905 ------------------------------
15906 -- Simple_Storage_Pool_Type --
15907 ------------------------------
15909 -- pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
15911 when Pragma_Simple_Storage_Pool_Type =>
15912 Simple_Storage_Pool_Type : declare
15918 Check_Arg_Count (1);
15919 Check_Arg_Is_Library_Level_Local_Name (Arg1);
15921 Type_Id := Get_Pragma_Arg (Arg1);
15922 Find_Type (Type_Id);
15923 Typ := Entity (Type_Id);
15925 if Typ = Any_Type then
15929 -- We require the pragma to apply to a type declared in a package
15930 -- declaration, but not (immediately) within a package body.
15932 if Ekind (Current_Scope) /= E_Package
15933 or else In_Package_Body (Current_Scope)
15936 ("pragma% can only apply to type declared immediately "
15937 & "within a package declaration");
15940 -- A simple storage pool type must be an immutably limited record
15941 -- or private type. If the pragma is given for a private type,
15942 -- the full type is similarly restricted (which is checked later
15943 -- in Freeze_Entity).
15945 if Is_Record_Type (Typ)
15946 and then not Is_Immutably_Limited_Type (Typ)
15949 ("pragma% can only apply to explicitly limited record type");
15951 elsif Is_Private_Type (Typ) and then not Is_Limited_Type (Typ) then
15953 ("pragma% can only apply to a private type that is limited");
15955 elsif not Is_Record_Type (Typ)
15956 and then not Is_Private_Type (Typ)
15959 ("pragma% can only apply to limited record or private type");
15962 Record_Rep_Item (Typ, N);
15963 end Simple_Storage_Pool_Type;
15965 ----------------------
15966 -- Source_File_Name --
15967 ----------------------
15969 -- There are five forms for this pragma:
15971 -- pragma Source_File_Name (
15972 -- [UNIT_NAME =>] unit_NAME,
15973 -- BODY_FILE_NAME => STRING_LITERAL
15974 -- [, [INDEX =>] INTEGER_LITERAL]);
15976 -- pragma Source_File_Name (
15977 -- [UNIT_NAME =>] unit_NAME,
15978 -- SPEC_FILE_NAME => STRING_LITERAL
15979 -- [, [INDEX =>] INTEGER_LITERAL]);
15981 -- pragma Source_File_Name (
15982 -- BODY_FILE_NAME => STRING_LITERAL
15983 -- [, DOT_REPLACEMENT => STRING_LITERAL]
15984 -- [, CASING => CASING_SPEC]);
15986 -- pragma Source_File_Name (
15987 -- SPEC_FILE_NAME => STRING_LITERAL
15988 -- [, DOT_REPLACEMENT => STRING_LITERAL]
15989 -- [, CASING => CASING_SPEC]);
15991 -- pragma Source_File_Name (
15992 -- SUBUNIT_FILE_NAME => STRING_LITERAL
15993 -- [, DOT_REPLACEMENT => STRING_LITERAL]
15994 -- [, CASING => CASING_SPEC]);
15996 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
15998 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
15999 -- Source_File_Name (SFN), however their usage is exclusive: SFN can
16000 -- only be used when no project file is used, while SFNP can only be
16001 -- used when a project file is used.
16003 -- No processing here. Processing was completed during parsing, since
16004 -- we need to have file names set as early as possible. Units are
16005 -- loaded well before semantic processing starts.
16007 -- The only processing we defer to this point is the check for
16008 -- correct placement.
16010 when Pragma_Source_File_Name =>
16012 Check_Valid_Configuration_Pragma;
16014 ------------------------------
16015 -- Source_File_Name_Project --
16016 ------------------------------
16018 -- See Source_File_Name for syntax
16020 -- No processing here. Processing was completed during parsing, since
16021 -- we need to have file names set as early as possible. Units are
16022 -- loaded well before semantic processing starts.
16024 -- The only processing we defer to this point is the check for
16025 -- correct placement.
16027 when Pragma_Source_File_Name_Project =>
16029 Check_Valid_Configuration_Pragma;
16031 -- Check that a pragma Source_File_Name_Project is used only in a
16032 -- configuration pragmas file.
16034 -- Pragmas Source_File_Name_Project should only be generated by
16035 -- the Project Manager in configuration pragmas files.
16037 -- This is really an ugly test. It seems to depend on some
16038 -- accidental and undocumented property. At the very least it
16039 -- needs to be documented, but it would be better to have a
16040 -- clean way of testing if we are in a configuration file???
16042 if Present (Parent (N)) then
16044 ("pragma% can only appear in a configuration pragmas file");
16047 ----------------------
16048 -- Source_Reference --
16049 ----------------------
16051 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
16053 -- Nothing to do, all processing completed in Par.Prag, since we need
16054 -- the information for possible parser messages that are output.
16056 when Pragma_Source_Reference =>
16059 --------------------------------
16060 -- Static_Elaboration_Desired --
16061 --------------------------------
16063 -- pragma Static_Elaboration_Desired (DIRECT_NAME);
16065 when Pragma_Static_Elaboration_Desired =>
16067 Check_At_Most_N_Arguments (1);
16069 if Is_Compilation_Unit (Current_Scope)
16070 and then Ekind (Current_Scope) = E_Package
16072 Set_Static_Elaboration_Desired (Current_Scope, True);
16074 Error_Pragma ("pragma% must apply to a library-level package");
16081 -- pragma Storage_Size (EXPRESSION);
16083 when Pragma_Storage_Size => Storage_Size : declare
16084 P : constant Node_Id := Parent (N);
16088 Check_No_Identifiers;
16089 Check_Arg_Count (1);
16091 -- The expression must be analyzed in the special manner described
16092 -- in "Handling of Default Expressions" in sem.ads.
16094 Arg := Get_Pragma_Arg (Arg1);
16095 Preanalyze_Spec_Expression (Arg, Any_Integer);
16097 if not Is_Static_Expression (Arg) then
16098 Check_Restriction (Static_Storage_Size, Arg);
16101 if Nkind (P) /= N_Task_Definition then
16106 if Has_Storage_Size_Pragma (P) then
16107 Error_Pragma ("duplicate pragma% not allowed");
16109 Set_Has_Storage_Size_Pragma (P, True);
16112 Record_Rep_Item (Defining_Identifier (Parent (P)), N);
16120 -- pragma Storage_Unit (NUMERIC_LITERAL);
16122 -- Only permitted argument is System'Storage_Unit value
16124 when Pragma_Storage_Unit =>
16125 Check_No_Identifiers;
16126 Check_Arg_Count (1);
16127 Check_Arg_Is_Integer_Literal (Arg1);
16129 if Intval (Get_Pragma_Arg (Arg1)) /=
16130 UI_From_Int (Ttypes.System_Storage_Unit)
16132 Error_Msg_Uint_1 := UI_From_Int (Ttypes.System_Storage_Unit);
16134 ("the only allowed argument for pragma% is ^", Arg1);
16137 --------------------
16138 -- Stream_Convert --
16139 --------------------
16141 -- pragma Stream_Convert (
16142 -- [Entity =>] type_LOCAL_NAME,
16143 -- [Read =>] function_NAME,
16144 -- [Write =>] function NAME);
16146 when Pragma_Stream_Convert => Stream_Convert : declare
16148 procedure Check_OK_Stream_Convert_Function (Arg : Node_Id);
16149 -- Check that the given argument is the name of a local function
16150 -- of one argument that is not overloaded earlier in the current
16151 -- local scope. A check is also made that the argument is a
16152 -- function with one parameter.
16154 --------------------------------------
16155 -- Check_OK_Stream_Convert_Function --
16156 --------------------------------------
16158 procedure Check_OK_Stream_Convert_Function (Arg : Node_Id) is
16162 Check_Arg_Is_Local_Name (Arg);
16163 Ent := Entity (Get_Pragma_Arg (Arg));
16165 if Has_Homonym (Ent) then
16167 ("argument for pragma% may not be overloaded", Arg);
16170 if Ekind (Ent) /= E_Function
16171 or else No (First_Formal (Ent))
16172 or else Present (Next_Formal (First_Formal (Ent)))
16175 ("argument for pragma% must be function of one argument",
16178 end Check_OK_Stream_Convert_Function;
16180 -- Start of processing for Stream_Convert
16184 Check_Arg_Order ((Name_Entity, Name_Read, Name_Write));
16185 Check_Arg_Count (3);
16186 Check_Optional_Identifier (Arg1, Name_Entity);
16187 Check_Optional_Identifier (Arg2, Name_Read);
16188 Check_Optional_Identifier (Arg3, Name_Write);
16189 Check_Arg_Is_Local_Name (Arg1);
16190 Check_OK_Stream_Convert_Function (Arg2);
16191 Check_OK_Stream_Convert_Function (Arg3);
16194 Typ : constant Entity_Id :=
16195 Underlying_Type (Entity (Get_Pragma_Arg (Arg1)));
16196 Read : constant Entity_Id := Entity (Get_Pragma_Arg (Arg2));
16197 Write : constant Entity_Id := Entity (Get_Pragma_Arg (Arg3));
16200 Check_First_Subtype (Arg1);
16202 -- Check for too early or too late. Note that we don't enforce
16203 -- the rule about primitive operations in this case, since, as
16204 -- is the case for explicit stream attributes themselves, these
16205 -- restrictions are not appropriate. Note that the chaining of
16206 -- the pragma by Rep_Item_Too_Late is actually the critical
16207 -- processing done for this pragma.
16209 if Rep_Item_Too_Early (Typ, N)
16211 Rep_Item_Too_Late (Typ, N, FOnly => True)
16216 -- Return if previous error
16218 if Etype (Typ) = Any_Type
16220 Etype (Read) = Any_Type
16222 Etype (Write) = Any_Type
16229 if Underlying_Type (Etype (Read)) /= Typ then
16231 ("incorrect return type for function&", Arg2);
16234 if Underlying_Type (Etype (First_Formal (Write))) /= Typ then
16236 ("incorrect parameter type for function&", Arg3);
16239 if Underlying_Type (Etype (First_Formal (Read))) /=
16240 Underlying_Type (Etype (Write))
16243 ("result type of & does not match Read parameter type",
16247 end Stream_Convert;
16253 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
16255 -- This is processed by the parser since some of the style checks
16256 -- take place during source scanning and parsing. This means that
16257 -- we don't need to issue error messages here.
16259 when Pragma_Style_Checks => Style_Checks : declare
16260 A : constant Node_Id := Get_Pragma_Arg (Arg1);
16266 Check_No_Identifiers;
16268 -- Two argument form
16270 if Arg_Count = 2 then
16271 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
16278 E_Id := Get_Pragma_Arg (Arg2);
16281 if not Is_Entity_Name (E_Id) then
16283 ("second argument of pragma% must be entity name",
16287 E := Entity (E_Id);
16289 if not Ignore_Style_Checks_Pragmas then
16294 Set_Suppress_Style_Checks
16295 (E, Chars (Get_Pragma_Arg (Arg1)) = Name_Off);
16296 exit when No (Homonym (E));
16303 -- One argument form
16306 Check_Arg_Count (1);
16308 if Nkind (A) = N_String_Literal then
16312 Slen : constant Natural := Natural (String_Length (S));
16313 Options : String (1 .. Slen);
16319 C := Get_String_Char (S, Int (J));
16320 exit when not In_Character_Range (C);
16321 Options (J) := Get_Character (C);
16323 -- If at end of string, set options. As per discussion
16324 -- above, no need to check for errors, since we issued
16325 -- them in the parser.
16328 if not Ignore_Style_Checks_Pragmas then
16329 Set_Style_Check_Options (Options);
16339 elsif Nkind (A) = N_Identifier then
16340 if Chars (A) = Name_All_Checks then
16341 if not Ignore_Style_Checks_Pragmas then
16343 Set_GNAT_Style_Check_Options;
16345 Set_Default_Style_Check_Options;
16349 elsif Chars (A) = Name_On then
16350 if not Ignore_Style_Checks_Pragmas then
16351 Style_Check := True;
16354 elsif Chars (A) = Name_Off then
16355 if not Ignore_Style_Checks_Pragmas then
16356 Style_Check := False;
16367 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
16369 when Pragma_Subtitle =>
16371 Check_Arg_Count (1);
16372 Check_Optional_Identifier (Arg1, Name_Subtitle);
16373 Check_Arg_Is_Static_Expression (Arg1, Standard_String);
16380 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
16382 when Pragma_Suppress =>
16383 Process_Suppress_Unsuppress (True);
16389 -- pragma Suppress_All;
16391 -- The only check made here is that the pragma has no arguments.
16392 -- There are no placement rules, and the processing required (setting
16393 -- the Has_Pragma_Suppress_All flag in the compilation unit node was
16394 -- taken care of by the parser). Process_Compilation_Unit_Pragmas
16395 -- then creates and inserts a pragma Suppress (All_Checks).
16397 when Pragma_Suppress_All =>
16399 Check_Arg_Count (0);
16401 -------------------------
16402 -- Suppress_Debug_Info --
16403 -------------------------
16405 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
16407 when Pragma_Suppress_Debug_Info =>
16409 Check_Arg_Count (1);
16410 Check_Optional_Identifier (Arg1, Name_Entity);
16411 Check_Arg_Is_Local_Name (Arg1);
16412 Set_Debug_Info_Off (Entity (Get_Pragma_Arg (Arg1)));
16414 ----------------------------------
16415 -- Suppress_Exception_Locations --
16416 ----------------------------------
16418 -- pragma Suppress_Exception_Locations;
16420 when Pragma_Suppress_Exception_Locations =>
16422 Check_Arg_Count (0);
16423 Check_Valid_Configuration_Pragma;
16424 Exception_Locations_Suppressed := True;
16426 -----------------------------
16427 -- Suppress_Initialization --
16428 -----------------------------
16430 -- pragma Suppress_Initialization ([Entity =>] type_Name);
16432 when Pragma_Suppress_Initialization => Suppress_Init : declare
16438 Check_Arg_Count (1);
16439 Check_Optional_Identifier (Arg1, Name_Entity);
16440 Check_Arg_Is_Local_Name (Arg1);
16442 E_Id := Get_Pragma_Arg (Arg1);
16444 if Etype (E_Id) = Any_Type then
16448 E := Entity (E_Id);
16450 if not Is_Type (E) then
16451 Error_Pragma_Arg ("pragma% requires type or subtype", Arg1);
16454 if Rep_Item_Too_Early (E, N)
16456 Rep_Item_Too_Late (E, N, FOnly => True)
16461 -- For incomplete/private type, set flag on full view
16463 if Is_Incomplete_Or_Private_Type (E) then
16464 if No (Full_View (Base_Type (E))) then
16466 ("argument of pragma% cannot be an incomplete type", Arg1);
16468 Set_Suppress_Initialization (Full_View (Base_Type (E)));
16471 -- For first subtype, set flag on base type
16473 elsif Is_First_Subtype (E) then
16474 Set_Suppress_Initialization (Base_Type (E));
16476 -- For other than first subtype, set flag on subtype itself
16479 Set_Suppress_Initialization (E);
16487 -- pragma System_Name (DIRECT_NAME);
16489 -- Syntax check: one argument, which must be the identifier GNAT or
16490 -- the identifier GCC, no other identifiers are acceptable.
16492 when Pragma_System_Name =>
16494 Check_No_Identifiers;
16495 Check_Arg_Count (1);
16496 Check_Arg_Is_One_Of (Arg1, Name_Gcc, Name_Gnat);
16498 -----------------------------
16499 -- Task_Dispatching_Policy --
16500 -----------------------------
16502 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
16504 when Pragma_Task_Dispatching_Policy => declare
16508 Check_Ada_83_Warning;
16509 Check_Arg_Count (1);
16510 Check_No_Identifiers;
16511 Check_Arg_Is_Task_Dispatching_Policy (Arg1);
16512 Check_Valid_Configuration_Pragma;
16513 Get_Name_String (Chars (Get_Pragma_Arg (Arg1)));
16514 DP := Fold_Upper (Name_Buffer (1));
16516 if Task_Dispatching_Policy /= ' '
16517 and then Task_Dispatching_Policy /= DP
16519 Error_Msg_Sloc := Task_Dispatching_Policy_Sloc;
16521 ("task dispatching policy incompatible with policy#");
16523 -- Set new policy, but always preserve System_Location since we
16524 -- like the error message with the run time name.
16527 Task_Dispatching_Policy := DP;
16529 if Task_Dispatching_Policy_Sloc /= System_Location then
16530 Task_Dispatching_Policy_Sloc := Loc;
16539 -- pragma Task_Info (EXPRESSION);
16541 when Pragma_Task_Info => Task_Info : declare
16542 P : constant Node_Id := Parent (N);
16548 if Nkind (P) /= N_Task_Definition then
16549 Error_Pragma ("pragma% must appear in task definition");
16552 Check_No_Identifiers;
16553 Check_Arg_Count (1);
16555 Analyze_And_Resolve
16556 (Get_Pragma_Arg (Arg1), RTE (RE_Task_Info_Type));
16558 if Etype (Get_Pragma_Arg (Arg1)) = Any_Type then
16562 Ent := Defining_Identifier (Parent (P));
16564 -- Check duplicate pragma before we chain the pragma in the Rep
16565 -- Item chain of Ent.
16568 (Ent, Name_Task_Info, Check_Parents => False)
16570 Error_Pragma ("duplicate pragma% not allowed");
16573 Record_Rep_Item (Ent, N);
16580 -- pragma Task_Name (string_EXPRESSION);
16582 when Pragma_Task_Name => Task_Name : declare
16583 P : constant Node_Id := Parent (N);
16588 Check_No_Identifiers;
16589 Check_Arg_Count (1);
16591 Arg := Get_Pragma_Arg (Arg1);
16593 -- The expression is used in the call to Create_Task, and must be
16594 -- expanded there, not in the context of the current spec. It must
16595 -- however be analyzed to capture global references, in case it
16596 -- appears in a generic context.
16598 Preanalyze_And_Resolve (Arg, Standard_String);
16600 if Nkind (P) /= N_Task_Definition then
16604 Ent := Defining_Identifier (Parent (P));
16606 -- Check duplicate pragma before we chain the pragma in the Rep
16607 -- Item chain of Ent.
16610 (Ent, Name_Task_Name, Check_Parents => False)
16612 Error_Pragma ("duplicate pragma% not allowed");
16615 Record_Rep_Item (Ent, N);
16622 -- pragma Task_Storage (
16623 -- [Task_Type =>] LOCAL_NAME,
16624 -- [Top_Guard =>] static_integer_EXPRESSION);
16626 when Pragma_Task_Storage => Task_Storage : declare
16627 Args : Args_List (1 .. 2);
16628 Names : constant Name_List (1 .. 2) := (
16632 Task_Type : Node_Id renames Args (1);
16633 Top_Guard : Node_Id renames Args (2);
16639 Gather_Associations (Names, Args);
16641 if No (Task_Type) then
16643 ("missing task_type argument for pragma%");
16646 Check_Arg_Is_Local_Name (Task_Type);
16648 Ent := Entity (Task_Type);
16650 if not Is_Task_Type (Ent) then
16652 ("argument for pragma% must be task type", Task_Type);
16655 if No (Top_Guard) then
16657 ("pragma% takes two arguments", Task_Type);
16659 Check_Arg_Is_Static_Expression (Top_Guard, Any_Integer);
16662 Check_First_Subtype (Task_Type);
16664 if Rep_Item_Too_Late (Ent, N) then
16673 -- pragma Test_Case
16674 -- ([Name =>] Static_String_EXPRESSION
16675 -- ,[Mode =>] MODE_TYPE
16676 -- [, Requires => Boolean_EXPRESSION]
16677 -- [, Ensures => Boolean_EXPRESSION]);
16679 -- MODE_TYPE ::= Nominal | Robustness
16681 when Pragma_Test_Case =>
16682 Check_Contract_Or_Test_Case;
16684 --------------------------
16685 -- Thread_Local_Storage --
16686 --------------------------
16688 -- pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
16690 when Pragma_Thread_Local_Storage => Thread_Local_Storage : declare
16696 Check_Arg_Count (1);
16697 Check_Optional_Identifier (Arg1, Name_Entity);
16698 Check_Arg_Is_Library_Level_Local_Name (Arg1);
16700 Id := Get_Pragma_Arg (Arg1);
16703 if not Is_Entity_Name (Id)
16704 or else Ekind (Entity (Id)) /= E_Variable
16706 Error_Pragma_Arg ("local variable name required", Arg1);
16711 if Rep_Item_Too_Early (E, N)
16712 or else Rep_Item_Too_Late (E, N)
16717 Set_Has_Pragma_Thread_Local_Storage (E);
16718 Set_Has_Gigi_Rep_Item (E);
16719 end Thread_Local_Storage;
16725 -- pragma Time_Slice (static_duration_EXPRESSION);
16727 when Pragma_Time_Slice => Time_Slice : declare
16733 Check_Arg_Count (1);
16734 Check_No_Identifiers;
16735 Check_In_Main_Program;
16736 Check_Arg_Is_Static_Expression (Arg1, Standard_Duration);
16738 if not Error_Posted (Arg1) then
16740 while Present (Nod) loop
16741 if Nkind (Nod) = N_Pragma
16742 and then Pragma_Name (Nod) = Name_Time_Slice
16744 Error_Msg_Name_1 := Pname;
16745 Error_Msg_N ("duplicate pragma% not permitted", Nod);
16752 -- Process only if in main unit
16754 if Get_Source_Unit (Loc) = Main_Unit then
16755 Opt.Time_Slice_Set := True;
16756 Val := Expr_Value_R (Get_Pragma_Arg (Arg1));
16758 if Val <= Ureal_0 then
16759 Opt.Time_Slice_Value := 0;
16761 elsif Val > UR_From_Uint (UI_From_Int (1000)) then
16762 Opt.Time_Slice_Value := 1_000_000_000;
16765 Opt.Time_Slice_Value :=
16766 UI_To_Int (UR_To_Uint (Val * UI_From_Int (1_000_000)));
16775 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
16777 -- TITLING_OPTION ::=
16778 -- [Title =>] STRING_LITERAL
16779 -- | [Subtitle =>] STRING_LITERAL
16781 when Pragma_Title => Title : declare
16782 Args : Args_List (1 .. 2);
16783 Names : constant Name_List (1 .. 2) := (
16789 Gather_Associations (Names, Args);
16792 for J in 1 .. 2 loop
16793 if Present (Args (J)) then
16794 Check_Arg_Is_Static_Expression (Args (J), Standard_String);
16799 ---------------------
16800 -- Unchecked_Union --
16801 ---------------------
16803 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
16805 when Pragma_Unchecked_Union => Unchecked_Union : declare
16806 Assoc : constant Node_Id := Arg1;
16807 Type_Id : constant Node_Id := Get_Pragma_Arg (Assoc);
16817 Check_No_Identifiers;
16818 Check_Arg_Count (1);
16819 Check_Arg_Is_Local_Name (Arg1);
16821 Find_Type (Type_Id);
16823 Typ := Entity (Type_Id);
16826 or else Rep_Item_Too_Early (Typ, N)
16830 Typ := Underlying_Type (Typ);
16833 if Rep_Item_Too_Late (Typ, N) then
16837 Check_First_Subtype (Arg1);
16839 -- Note remaining cases are references to a type in the current
16840 -- declarative part. If we find an error, we post the error on
16841 -- the relevant type declaration at an appropriate point.
16843 if not Is_Record_Type (Typ) then
16844 Error_Msg_N ("unchecked union must be record type", Typ);
16847 elsif Is_Tagged_Type (Typ) then
16848 Error_Msg_N ("unchecked union must not be tagged", Typ);
16851 elsif not Has_Discriminants (Typ) then
16853 ("unchecked union must have one discriminant", Typ);
16856 -- Note: in previous versions of GNAT we used to check for limited
16857 -- types and give an error, but in fact the standard does allow
16858 -- Unchecked_Union on limited types, so this check was removed.
16860 -- Similarly, GNAT used to require that all discriminants have
16861 -- default values, but this is not mandated by the RM.
16863 -- Proceed with basic error checks completed
16866 Tdef := Type_Definition (Declaration_Node (Typ));
16867 Clist := Component_List (Tdef);
16869 -- Check presence of component list and variant part
16871 if No (Clist) or else No (Variant_Part (Clist)) then
16873 ("unchecked union must have variant part", Tdef);
16877 -- Check components
16879 Comp := First (Component_Items (Clist));
16880 while Present (Comp) loop
16881 Check_Component (Comp, Typ);
16885 -- Check variant part
16887 Vpart := Variant_Part (Clist);
16889 Variant := First (Variants (Vpart));
16890 while Present (Variant) loop
16891 Check_Variant (Variant, Typ);
16896 Set_Is_Unchecked_Union (Typ);
16897 Set_Convention (Typ, Convention_C);
16898 Set_Has_Unchecked_Union (Base_Type (Typ));
16899 Set_Is_Unchecked_Union (Base_Type (Typ));
16900 end Unchecked_Union;
16902 ------------------------
16903 -- Unimplemented_Unit --
16904 ------------------------
16906 -- pragma Unimplemented_Unit;
16908 -- Note: this only gives an error if we are generating code, or if
16909 -- we are in a generic library unit (where the pragma appears in the
16910 -- body, not in the spec).
16912 when Pragma_Unimplemented_Unit => Unimplemented_Unit : declare
16913 Cunitent : constant Entity_Id :=
16914 Cunit_Entity (Get_Source_Unit (Loc));
16915 Ent_Kind : constant Entity_Kind :=
16920 Check_Arg_Count (0);
16922 if Operating_Mode = Generate_Code
16923 or else Ent_Kind = E_Generic_Function
16924 or else Ent_Kind = E_Generic_Procedure
16925 or else Ent_Kind = E_Generic_Package
16927 Get_Name_String (Chars (Cunitent));
16928 Set_Casing (Mixed_Case);
16929 Write_Str (Name_Buffer (1 .. Name_Len));
16930 Write_Str (" is not supported in this configuration");
16932 raise Unrecoverable_Error;
16934 end Unimplemented_Unit;
16936 ------------------------
16937 -- Universal_Aliasing --
16938 ------------------------
16940 -- pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
16942 when Pragma_Universal_Aliasing => Universal_Alias : declare
16947 Check_Arg_Count (1);
16948 Check_Optional_Identifier (Arg2, Name_Entity);
16949 Check_Arg_Is_Local_Name (Arg1);
16950 E_Id := Entity (Get_Pragma_Arg (Arg1));
16952 if E_Id = Any_Type then
16954 elsif No (E_Id) or else not Is_Type (E_Id) then
16955 Error_Pragma_Arg ("pragma% requires type", Arg1);
16958 Set_Universal_Aliasing (Implementation_Base_Type (E_Id));
16959 Record_Rep_Item (E_Id, N);
16960 end Universal_Alias;
16962 --------------------
16963 -- Universal_Data --
16964 --------------------
16966 -- pragma Universal_Data [(library_unit_NAME)];
16968 when Pragma_Universal_Data =>
16971 -- If this is a configuration pragma, then set the universal
16972 -- addressing option, otherwise confirm that the pragma satisfies
16973 -- the requirements of library unit pragma placement and leave it
16974 -- to the GNAAMP back end to detect the pragma (avoids transitive
16975 -- setting of the option due to withed units).
16977 if Is_Configuration_Pragma then
16978 Universal_Addressing_On_AAMP := True;
16980 Check_Valid_Library_Unit_Pragma;
16983 if not AAMP_On_Target then
16984 Error_Pragma ("??pragma% ignored (applies only to AAMP)");
16991 -- pragma Unmodified (local_Name {, local_Name});
16993 when Pragma_Unmodified => Unmodified : declare
16994 Arg_Node : Node_Id;
16995 Arg_Expr : Node_Id;
16996 Arg_Ent : Entity_Id;
17000 Check_At_Least_N_Arguments (1);
17002 -- Loop through arguments
17005 while Present (Arg_Node) loop
17006 Check_No_Identifier (Arg_Node);
17008 -- Note: the analyze call done by Check_Arg_Is_Local_Name will
17009 -- in fact generate reference, so that the entity will have a
17010 -- reference, which will inhibit any warnings about it not
17011 -- being referenced, and also properly show up in the ali file
17012 -- as a reference. But this reference is recorded before the
17013 -- Has_Pragma_Unreferenced flag is set, so that no warning is
17014 -- generated for this reference.
17016 Check_Arg_Is_Local_Name (Arg_Node);
17017 Arg_Expr := Get_Pragma_Arg (Arg_Node);
17019 if Is_Entity_Name (Arg_Expr) then
17020 Arg_Ent := Entity (Arg_Expr);
17022 if not Is_Assignable (Arg_Ent) then
17024 ("pragma% can only be applied to a variable",
17027 Set_Has_Pragma_Unmodified (Arg_Ent);
17039 -- pragma Unreferenced (local_Name {, local_Name});
17041 -- or when used in a context clause:
17043 -- pragma Unreferenced (library_unit_NAME {, library_unit_NAME}
17045 when Pragma_Unreferenced => Unreferenced : declare
17046 Arg_Node : Node_Id;
17047 Arg_Expr : Node_Id;
17048 Arg_Ent : Entity_Id;
17053 Check_At_Least_N_Arguments (1);
17055 -- Check case of appearing within context clause
17057 if Is_In_Context_Clause then
17059 -- The arguments must all be units mentioned in a with clause
17060 -- in the same context clause. Note we already checked (in
17061 -- Par.Prag) that the arguments are either identifiers or
17062 -- selected components.
17065 while Present (Arg_Node) loop
17066 Citem := First (List_Containing (N));
17067 while Citem /= N loop
17068 if Nkind (Citem) = N_With_Clause
17070 Same_Name (Name (Citem), Get_Pragma_Arg (Arg_Node))
17072 Set_Has_Pragma_Unreferenced
17075 (Library_Unit (Citem))));
17077 (Get_Pragma_Arg (Arg_Node), Name (Citem));
17086 ("argument of pragma% is not withed unit", Arg_Node);
17092 -- Case of not in list of context items
17096 while Present (Arg_Node) loop
17097 Check_No_Identifier (Arg_Node);
17099 -- Note: the analyze call done by Check_Arg_Is_Local_Name
17100 -- will in fact generate reference, so that the entity will
17101 -- have a reference, which will inhibit any warnings about
17102 -- it not being referenced, and also properly show up in the
17103 -- ali file as a reference. But this reference is recorded
17104 -- before the Has_Pragma_Unreferenced flag is set, so that
17105 -- no warning is generated for this reference.
17107 Check_Arg_Is_Local_Name (Arg_Node);
17108 Arg_Expr := Get_Pragma_Arg (Arg_Node);
17110 if Is_Entity_Name (Arg_Expr) then
17111 Arg_Ent := Entity (Arg_Expr);
17113 -- If the entity is overloaded, the pragma applies to the
17114 -- most recent overloading, as documented. In this case,
17115 -- name resolution does not generate a reference, so it
17116 -- must be done here explicitly.
17118 if Is_Overloaded (Arg_Expr) then
17119 Generate_Reference (Arg_Ent, N);
17122 Set_Has_Pragma_Unreferenced (Arg_Ent);
17130 --------------------------
17131 -- Unreferenced_Objects --
17132 --------------------------
17134 -- pragma Unreferenced_Objects (local_Name {, local_Name});
17136 when Pragma_Unreferenced_Objects => Unreferenced_Objects : declare
17137 Arg_Node : Node_Id;
17138 Arg_Expr : Node_Id;
17142 Check_At_Least_N_Arguments (1);
17145 while Present (Arg_Node) loop
17146 Check_No_Identifier (Arg_Node);
17147 Check_Arg_Is_Local_Name (Arg_Node);
17148 Arg_Expr := Get_Pragma_Arg (Arg_Node);
17150 if not Is_Entity_Name (Arg_Expr)
17151 or else not Is_Type (Entity (Arg_Expr))
17154 ("argument for pragma% must be type or subtype", Arg_Node);
17157 Set_Has_Pragma_Unreferenced_Objects (Entity (Arg_Expr));
17160 end Unreferenced_Objects;
17162 ------------------------------
17163 -- Unreserve_All_Interrupts --
17164 ------------------------------
17166 -- pragma Unreserve_All_Interrupts;
17168 when Pragma_Unreserve_All_Interrupts =>
17170 Check_Arg_Count (0);
17172 if In_Extended_Main_Code_Unit (Main_Unit_Entity) then
17173 Unreserve_All_Interrupts := True;
17180 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
17182 when Pragma_Unsuppress =>
17184 Process_Suppress_Unsuppress (False);
17186 -------------------
17187 -- Use_VADS_Size --
17188 -------------------
17190 -- pragma Use_VADS_Size;
17192 when Pragma_Use_VADS_Size =>
17194 Check_Arg_Count (0);
17195 Check_Valid_Configuration_Pragma;
17196 Use_VADS_Size := True;
17198 ---------------------
17199 -- Validity_Checks --
17200 ---------------------
17202 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
17204 when Pragma_Validity_Checks => Validity_Checks : declare
17205 A : constant Node_Id := Get_Pragma_Arg (Arg1);
17211 Check_Arg_Count (1);
17212 Check_No_Identifiers;
17214 if Nkind (A) = N_String_Literal then
17218 Slen : constant Natural := Natural (String_Length (S));
17219 Options : String (1 .. Slen);
17225 C := Get_String_Char (S, Int (J));
17226 exit when not In_Character_Range (C);
17227 Options (J) := Get_Character (C);
17230 Set_Validity_Check_Options (Options);
17238 elsif Nkind (A) = N_Identifier then
17239 if Chars (A) = Name_All_Checks then
17240 Set_Validity_Check_Options ("a");
17241 elsif Chars (A) = Name_On then
17242 Validity_Checks_On := True;
17243 elsif Chars (A) = Name_Off then
17244 Validity_Checks_On := False;
17247 end Validity_Checks;
17253 -- pragma Volatile (LOCAL_NAME);
17255 when Pragma_Volatile =>
17256 Process_Atomic_Shared_Volatile;
17258 -------------------------
17259 -- Volatile_Components --
17260 -------------------------
17262 -- pragma Volatile_Components (array_LOCAL_NAME);
17264 -- Volatile is handled by the same circuit as Atomic_Components
17270 -- pragma Warnings (On | Off);
17271 -- pragma Warnings (On | Off, LOCAL_NAME);
17272 -- pragma Warnings (static_string_EXPRESSION);
17273 -- pragma Warnings (On | Off, STRING_LITERAL);
17275 when Pragma_Warnings => Warnings : begin
17277 Check_At_Least_N_Arguments (1);
17278 Check_No_Identifiers;
17280 -- If debug flag -gnatd.i is set, pragma is ignored
17282 if Debug_Flag_Dot_I then
17286 -- Process various forms of the pragma
17289 Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
17292 -- One argument case
17294 if Arg_Count = 1 then
17296 -- On/Off one argument case was processed by parser
17298 if Nkind (Argx) = N_Identifier
17300 (Chars (Argx) = Name_On
17302 Chars (Argx) = Name_Off)
17306 -- One argument case must be ON/OFF or static string expr
17308 elsif not Is_Static_String_Expression (Arg1) then
17310 ("argument of pragma% must be On/Off or static string "
17311 & "expression", Arg1);
17313 -- One argument string expression case
17317 Lit : constant Node_Id := Expr_Value_S (Argx);
17318 Str : constant String_Id := Strval (Lit);
17319 Len : constant Nat := String_Length (Str);
17327 while J <= Len loop
17328 C := Get_String_Char (Str, J);
17329 OK := In_Character_Range (C);
17332 Chr := Get_Character (C);
17334 -- Dash case: only -Wxxx is accepted
17341 C := Get_String_Char (Str, J);
17342 Chr := Get_Character (C);
17343 exit when Chr = 'W';
17348 elsif J < Len and then Chr = '.' then
17350 C := Get_String_Char (Str, J);
17351 Chr := Get_Character (C);
17353 if not Set_Dot_Warning_Switch (Chr) then
17355 ("invalid warning switch character "
17356 & '.' & Chr, Arg1);
17362 OK := Set_Warning_Switch (Chr);
17368 ("invalid warning switch character " & Chr,
17377 -- Two or more arguments (must be two)
17380 Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off);
17381 Check_At_Most_N_Arguments (2);
17389 E_Id := Get_Pragma_Arg (Arg2);
17392 -- In the expansion of an inlined body, a reference to
17393 -- the formal may be wrapped in a conversion if the
17394 -- actual is a conversion. Retrieve the real entity name.
17396 if (In_Instance_Body or In_Inlined_Body)
17397 and then Nkind (E_Id) = N_Unchecked_Type_Conversion
17399 E_Id := Expression (E_Id);
17402 -- Entity name case
17404 if Is_Entity_Name (E_Id) then
17405 E := Entity (E_Id);
17412 (E, (Chars (Get_Pragma_Arg (Arg1)) =
17415 -- For OFF case, make entry in warnings off
17416 -- pragma table for later processing. But we do
17417 -- not do that within an instance, since these
17418 -- warnings are about what is needed in the
17419 -- template, not an instance of it.
17421 if Chars (Get_Pragma_Arg (Arg1)) = Name_Off
17422 and then Warn_On_Warnings_Off
17423 and then not In_Instance
17425 Warnings_Off_Pragmas.Append ((N, E));
17428 if Is_Enumeration_Type (E) then
17432 Lit := First_Literal (E);
17433 while Present (Lit) loop
17434 Set_Warnings_Off (Lit);
17435 Next_Literal (Lit);
17440 exit when No (Homonym (E));
17445 -- Error if not entity or static string literal case
17447 elsif not Is_Static_String_Expression (Arg2) then
17449 ("second argument of pragma% must be entity name "
17450 & "or static string expression", Arg2);
17452 -- String literal case
17455 String_To_Name_Buffer
17456 (Strval (Expr_Value_S (Get_Pragma_Arg (Arg2))));
17458 -- Note on configuration pragma case: If this is a
17459 -- configuration pragma, then for an OFF pragma, we
17460 -- just set Config True in the call, which is all
17461 -- that needs to be done. For the case of ON, this
17462 -- is normally an error, unless it is canceling the
17463 -- effect of a previous OFF pragma in the same file.
17464 -- In any other case, an error will be signalled (ON
17465 -- with no matching OFF).
17467 -- Note: We set Used if we are inside a generic to
17468 -- disable the test that the non-config case actually
17469 -- cancels a warning. That's because we can't be sure
17470 -- there isn't an instantiation in some other unit
17471 -- where a warning is suppressed.
17473 -- We could do a little better here by checking if the
17474 -- generic unit we are inside is public, but for now
17475 -- we don't bother with that refinement.
17477 if Chars (Argx) = Name_Off then
17478 Set_Specific_Warning_Off
17479 (Loc, Name_Buffer (1 .. Name_Len),
17480 Config => Is_Configuration_Pragma,
17481 Used => Inside_A_Generic or else In_Instance);
17483 elsif Chars (Argx) = Name_On then
17484 Set_Specific_Warning_On
17485 (Loc, Name_Buffer (1 .. Name_Len), Err);
17489 ("??pragma Warnings On with no matching "
17490 & "Warnings Off", Loc);
17499 -------------------
17500 -- Weak_External --
17501 -------------------
17503 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
17505 when Pragma_Weak_External => Weak_External : declare
17510 Check_Arg_Count (1);
17511 Check_Optional_Identifier (Arg1, Name_Entity);
17512 Check_Arg_Is_Library_Level_Local_Name (Arg1);
17513 Ent := Entity (Get_Pragma_Arg (Arg1));
17515 if Rep_Item_Too_Early (Ent, N) then
17518 Ent := Underlying_Type (Ent);
17521 -- The only processing required is to link this item on to the
17522 -- list of rep items for the given entity. This is accomplished
17523 -- by the call to Rep_Item_Too_Late (when no error is detected
17524 -- and False is returned).
17526 if Rep_Item_Too_Late (Ent, N) then
17529 Set_Has_Gigi_Rep_Item (Ent);
17533 -----------------------------
17534 -- Wide_Character_Encoding --
17535 -----------------------------
17537 -- pragma Wide_Character_Encoding (IDENTIFIER);
17539 when Pragma_Wide_Character_Encoding =>
17542 -- Nothing to do, handled in parser. Note that we do not enforce
17543 -- configuration pragma placement, this pragma can appear at any
17544 -- place in the source, allowing mixed encodings within a single
17549 --------------------
17550 -- Unknown_Pragma --
17551 --------------------
17553 -- Should be impossible, since the case of an unknown pragma is
17554 -- separately processed before the case statement is entered.
17556 when Unknown_Pragma =>
17557 raise Program_Error;
17560 -- AI05-0144: detect dangerous order dependence. Disabled for now,
17561 -- until AI is formally approved.
17563 -- Check_Order_Dependence;
17566 when Pragma_Exit => null;
17567 end Analyze_Pragma;
17569 -------------------
17570 -- Check_Enabled --
17571 -------------------
17573 function Check_Enabled (Nam : Name_Id) return Boolean is
17577 -- Loop through entries in check policy list
17579 PP := Opt.Check_Policy_List;
17581 -- If there are no specific entries that matched, then we let the
17582 -- setting of assertions govern. Note that this provides the needed
17583 -- compatibility with the RM for the cases of assertion, invariant,
17584 -- precondition, predicate, and postcondition.
17587 return Assertions_Enabled;
17589 -- Here we have an entry see if it matches
17593 PPA : constant List_Id := Pragma_Argument_Associations (PP);
17596 if Nam = Chars (Get_Pragma_Arg (First (PPA))) then
17597 case (Chars (Get_Pragma_Arg (Last (PPA)))) is
17598 when Name_On | Name_Check =>
17600 when Name_Off | Name_Disable | Name_Ignore =>
17603 raise Program_Error;
17607 PP := Next_Pragma (PP);
17614 ---------------------------------
17615 -- Delay_Config_Pragma_Analyze --
17616 ---------------------------------
17618 function Delay_Config_Pragma_Analyze (N : Node_Id) return Boolean is
17620 return Pragma_Name (N) = Name_Interrupt_State
17622 Pragma_Name (N) = Name_Priority_Specific_Dispatching;
17623 end Delay_Config_Pragma_Analyze;
17625 -------------------------
17626 -- Get_Base_Subprogram --
17627 -------------------------
17629 function Get_Base_Subprogram (Def_Id : Entity_Id) return Entity_Id is
17630 Result : Entity_Id;
17633 -- Follow subprogram renaming chain
17637 if Is_Subprogram (Result)
17639 Nkind (Parent (Declaration_Node (Result))) =
17640 N_Subprogram_Renaming_Declaration
17641 and then Present (Alias (Result))
17643 Result := Alias (Result);
17647 end Get_Base_Subprogram;
17653 procedure Initialize is
17658 -----------------------------
17659 -- Is_Config_Static_String --
17660 -----------------------------
17662 function Is_Config_Static_String (Arg : Node_Id) return Boolean is
17664 function Add_Config_Static_String (Arg : Node_Id) return Boolean;
17665 -- This is an internal recursive function that is just like the outer
17666 -- function except that it adds the string to the name buffer rather
17667 -- than placing the string in the name buffer.
17669 ------------------------------
17670 -- Add_Config_Static_String --
17671 ------------------------------
17673 function Add_Config_Static_String (Arg : Node_Id) return Boolean is
17680 if Nkind (N) = N_Op_Concat then
17681 if Add_Config_Static_String (Left_Opnd (N)) then
17682 N := Right_Opnd (N);
17688 if Nkind (N) /= N_String_Literal then
17689 Error_Msg_N ("string literal expected for pragma argument", N);
17693 for J in 1 .. String_Length (Strval (N)) loop
17694 C := Get_String_Char (Strval (N), J);
17696 if not In_Character_Range (C) then
17698 ("string literal contains invalid wide character",
17699 Sloc (N) + 1 + Source_Ptr (J));
17703 Add_Char_To_Name_Buffer (Get_Character (C));
17708 end Add_Config_Static_String;
17710 -- Start of processing for Is_Config_Static_String
17715 return Add_Config_Static_String (Arg);
17716 end Is_Config_Static_String;
17718 -----------------------------------------
17719 -- Is_Non_Significant_Pragma_Reference --
17720 -----------------------------------------
17722 -- This function makes use of the following static table which indicates
17723 -- whether appearance of some name in a given pragma is to be considered
17724 -- as a reference for the purposes of warnings about unreferenced objects.
17726 -- -1 indicates that references in any argument position are significant
17727 -- 0 indicates that appearance in any argument is not significant
17728 -- +n indicates that appearance as argument n is significant, but all
17729 -- other arguments are not significant
17730 -- 99 special processing required (e.g. for pragma Check)
17732 Sig_Flags : constant array (Pragma_Id) of Int :=
17733 (Pragma_AST_Entry => -1,
17734 Pragma_Abort_Defer => -1,
17735 Pragma_Abstract_State => -1,
17736 Pragma_Ada_83 => -1,
17737 Pragma_Ada_95 => -1,
17738 Pragma_Ada_05 => -1,
17739 Pragma_Ada_2005 => -1,
17740 Pragma_Ada_12 => -1,
17741 Pragma_Ada_2012 => -1,
17742 Pragma_All_Calls_Remote => -1,
17743 Pragma_Annotate => -1,
17744 Pragma_Assert => -1,
17745 Pragma_Assert_And_Cut => -1,
17746 Pragma_Assertion_Policy => 0,
17747 Pragma_Assume => 0,
17748 Pragma_Assume_No_Invalid_Values => 0,
17749 Pragma_Attribute_Definition => +3,
17750 Pragma_Asynchronous => -1,
17751 Pragma_Atomic => 0,
17752 Pragma_Atomic_Components => 0,
17753 Pragma_Attach_Handler => -1,
17754 Pragma_Check => 99,
17755 Pragma_Check_Float_Overflow => 0,
17756 Pragma_Check_Name => 0,
17757 Pragma_Check_Policy => 0,
17758 Pragma_CIL_Constructor => -1,
17759 Pragma_CPP_Class => 0,
17760 Pragma_CPP_Constructor => 0,
17761 Pragma_CPP_Virtual => 0,
17762 Pragma_CPP_Vtable => 0,
17764 Pragma_C_Pass_By_Copy => 0,
17765 Pragma_Comment => 0,
17766 Pragma_Common_Object => -1,
17767 Pragma_Compile_Time_Error => -1,
17768 Pragma_Compile_Time_Warning => -1,
17769 Pragma_Compiler_Unit => 0,
17770 Pragma_Complete_Representation => 0,
17771 Pragma_Complex_Representation => 0,
17772 Pragma_Component_Alignment => -1,
17773 Pragma_Contract_Case => -1,
17774 Pragma_Contract_Cases => -1,
17775 Pragma_Controlled => 0,
17776 Pragma_Convention => 0,
17777 Pragma_Convention_Identifier => 0,
17778 Pragma_Debug => -1,
17779 Pragma_Debug_Policy => 0,
17780 Pragma_Detect_Blocking => -1,
17781 Pragma_Default_Storage_Pool => -1,
17782 Pragma_Depends => -1,
17783 Pragma_Disable_Atomic_Synchronization => -1,
17784 Pragma_Discard_Names => 0,
17785 Pragma_Dispatching_Domain => -1,
17786 Pragma_Elaborate => -1,
17787 Pragma_Elaborate_All => -1,
17788 Pragma_Elaborate_Body => -1,
17789 Pragma_Elaboration_Checks => -1,
17790 Pragma_Eliminate => -1,
17791 Pragma_Enable_Atomic_Synchronization => -1,
17792 Pragma_Export => -1,
17793 Pragma_Export_Exception => -1,
17794 Pragma_Export_Function => -1,
17795 Pragma_Export_Object => -1,
17796 Pragma_Export_Procedure => -1,
17797 Pragma_Export_Value => -1,
17798 Pragma_Export_Valued_Procedure => -1,
17799 Pragma_Extend_System => -1,
17800 Pragma_Extensions_Allowed => -1,
17801 Pragma_External => -1,
17802 Pragma_Favor_Top_Level => -1,
17803 Pragma_External_Name_Casing => -1,
17804 Pragma_Fast_Math => -1,
17805 Pragma_Finalize_Storage_Only => 0,
17806 Pragma_Float_Representation => 0,
17808 Pragma_Global => -1,
17809 Pragma_Ident => -1,
17810 Pragma_Implementation_Defined => -1,
17811 Pragma_Implemented => -1,
17812 Pragma_Implicit_Packing => 0,
17813 Pragma_Import => +2,
17814 Pragma_Import_Exception => 0,
17815 Pragma_Import_Function => 0,
17816 Pragma_Import_Object => 0,
17817 Pragma_Import_Procedure => 0,
17818 Pragma_Import_Valued_Procedure => 0,
17819 Pragma_Independent => 0,
17820 Pragma_Independent_Components => 0,
17821 Pragma_Initialize_Scalars => -1,
17822 Pragma_Inline => 0,
17823 Pragma_Inline_Always => 0,
17824 Pragma_Inline_Generic => 0,
17825 Pragma_Inspection_Point => -1,
17826 Pragma_Interface => +2,
17827 Pragma_Interface_Name => +2,
17828 Pragma_Interrupt_Handler => -1,
17829 Pragma_Interrupt_Priority => -1,
17830 Pragma_Interrupt_State => -1,
17831 Pragma_Invariant => -1,
17832 Pragma_Java_Constructor => -1,
17833 Pragma_Java_Interface => -1,
17834 Pragma_Keep_Names => 0,
17835 Pragma_License => -1,
17836 Pragma_Link_With => -1,
17837 Pragma_Linker_Alias => -1,
17838 Pragma_Linker_Constructor => -1,
17839 Pragma_Linker_Destructor => -1,
17840 Pragma_Linker_Options => -1,
17841 Pragma_Linker_Section => -1,
17843 Pragma_Lock_Free => -1,
17844 Pragma_Locking_Policy => -1,
17845 Pragma_Long_Float => -1,
17846 Pragma_Loop_Invariant => -1,
17847 Pragma_Loop_Optimize => -1,
17848 Pragma_Loop_Variant => -1,
17849 Pragma_Machine_Attribute => -1,
17851 Pragma_Main_Storage => -1,
17852 Pragma_Memory_Size => -1,
17853 Pragma_No_Return => 0,
17854 Pragma_No_Body => 0,
17855 Pragma_No_Inline => 0,
17856 Pragma_No_Run_Time => -1,
17857 Pragma_No_Strict_Aliasing => -1,
17858 Pragma_Normalize_Scalars => -1,
17859 Pragma_Obsolescent => 0,
17860 Pragma_Optimize => -1,
17861 Pragma_Optimize_Alignment => -1,
17862 Pragma_Overflow_Mode => 0,
17863 Pragma_Overriding_Renamings => 0,
17864 Pragma_Ordered => 0,
17867 Pragma_Partition_Elaboration_Policy => -1,
17868 Pragma_Passive => -1,
17869 Pragma_Preelaborable_Initialization => -1,
17870 Pragma_Polling => -1,
17871 Pragma_Persistent_BSS => 0,
17872 Pragma_Postcondition => -1,
17873 Pragma_Precondition => -1,
17874 Pragma_Predicate => -1,
17875 Pragma_Preelaborate => -1,
17876 Pragma_Preelaborate_05 => -1,
17877 Pragma_Priority => -1,
17878 Pragma_Priority_Specific_Dispatching => -1,
17879 Pragma_Profile => 0,
17880 Pragma_Profile_Warnings => 0,
17881 Pragma_Propagate_Exceptions => -1,
17882 Pragma_Psect_Object => -1,
17884 Pragma_Pure_05 => -1,
17885 Pragma_Pure_12 => -1,
17886 Pragma_Pure_Function => -1,
17887 Pragma_Queuing_Policy => -1,
17888 Pragma_Rational => -1,
17889 Pragma_Ravenscar => -1,
17890 Pragma_Relative_Deadline => -1,
17891 Pragma_Remote_Access_Type => -1,
17892 Pragma_Remote_Call_Interface => -1,
17893 Pragma_Remote_Types => -1,
17894 Pragma_Restricted_Run_Time => -1,
17895 Pragma_Restriction_Warnings => -1,
17896 Pragma_Restrictions => -1,
17897 Pragma_Reviewable => -1,
17898 Pragma_Short_Circuit_And_Or => -1,
17899 Pragma_Share_Generic => -1,
17900 Pragma_Shared => -1,
17901 Pragma_Shared_Passive => -1,
17902 Pragma_Short_Descriptors => 0,
17903 Pragma_Simple_Storage_Pool_Type => 0,
17904 Pragma_Source_File_Name => -1,
17905 Pragma_Source_File_Name_Project => -1,
17906 Pragma_Source_Reference => -1,
17907 Pragma_Storage_Size => -1,
17908 Pragma_Storage_Unit => -1,
17909 Pragma_Static_Elaboration_Desired => -1,
17910 Pragma_Stream_Convert => -1,
17911 Pragma_Style_Checks => -1,
17912 Pragma_Subtitle => -1,
17913 Pragma_Suppress => 0,
17914 Pragma_Suppress_Exception_Locations => 0,
17915 Pragma_Suppress_All => -1,
17916 Pragma_Suppress_Debug_Info => 0,
17917 Pragma_Suppress_Initialization => 0,
17918 Pragma_System_Name => -1,
17919 Pragma_Task_Dispatching_Policy => -1,
17920 Pragma_Task_Info => -1,
17921 Pragma_Task_Name => -1,
17922 Pragma_Task_Storage => 0,
17923 Pragma_Test_Case => -1,
17924 Pragma_Thread_Local_Storage => 0,
17925 Pragma_Time_Slice => -1,
17926 Pragma_Title => -1,
17927 Pragma_Unchecked_Union => 0,
17928 Pragma_Unimplemented_Unit => -1,
17929 Pragma_Universal_Aliasing => -1,
17930 Pragma_Universal_Data => -1,
17931 Pragma_Unmodified => -1,
17932 Pragma_Unreferenced => -1,
17933 Pragma_Unreferenced_Objects => -1,
17934 Pragma_Unreserve_All_Interrupts => -1,
17935 Pragma_Unsuppress => 0,
17936 Pragma_Use_VADS_Size => -1,
17937 Pragma_Validity_Checks => -1,
17938 Pragma_Volatile => 0,
17939 Pragma_Volatile_Components => 0,
17940 Pragma_Warnings => -1,
17941 Pragma_Weak_External => -1,
17942 Pragma_Wide_Character_Encoding => 0,
17943 Unknown_Pragma => 0);
17945 function Is_Non_Significant_Pragma_Reference (N : Node_Id) return Boolean is
17954 if Nkind (P) /= N_Pragma_Argument_Association then
17958 Id := Get_Pragma_Id (Parent (P));
17959 C := Sig_Flags (Id);
17971 -- For pragma Check, the first argument is not significant,
17972 -- the second and the third (if present) arguments are
17975 when Pragma_Check =>
17977 P = First (Pragma_Argument_Associations (Parent (P)));
17980 raise Program_Error;
17984 A := First (Pragma_Argument_Associations (Parent (P)));
17985 for J in 1 .. C - 1 loop
17993 return A = P; -- is this wrong way round ???
17996 end Is_Non_Significant_Pragma_Reference;
17998 ------------------------------
17999 -- Is_Pragma_String_Literal --
18000 ------------------------------
18002 -- This function returns true if the corresponding pragma argument is a
18003 -- static string expression. These are the only cases in which string
18004 -- literals can appear as pragma arguments. We also allow a string literal
18005 -- as the first argument to pragma Assert (although it will of course
18006 -- always generate a type error).
18008 function Is_Pragma_String_Literal (Par : Node_Id) return Boolean is
18009 Pragn : constant Node_Id := Parent (Par);
18010 Assoc : constant List_Id := Pragma_Argument_Associations (Pragn);
18011 Pname : constant Name_Id := Pragma_Name (Pragn);
18017 N := First (Assoc);
18024 if Pname = Name_Assert then
18027 elsif Pname = Name_Export then
18030 elsif Pname = Name_Ident then
18033 elsif Pname = Name_Import then
18036 elsif Pname = Name_Interface_Name then
18039 elsif Pname = Name_Linker_Alias then
18042 elsif Pname = Name_Linker_Section then
18045 elsif Pname = Name_Machine_Attribute then
18048 elsif Pname = Name_Source_File_Name then
18051 elsif Pname = Name_Source_Reference then
18054 elsif Pname = Name_Title then
18057 elsif Pname = Name_Subtitle then
18063 end Is_Pragma_String_Literal;
18065 -----------------------------------------
18066 -- Make_Aspect_For_PPC_In_Gen_Sub_Decl --
18067 -----------------------------------------
18069 procedure Make_Aspect_For_PPC_In_Gen_Sub_Decl (Decl : Node_Id) is
18070 Aspects : constant List_Id := New_List;
18071 Loc : constant Source_Ptr := Sloc (Decl);
18072 Or_Decl : constant Node_Id := Original_Node (Decl);
18074 Original_Aspects : List_Id;
18075 -- To capture global references, a copy of the created aspects must be
18076 -- inserted in the original tree.
18079 Prag_Arg_Ass : Node_Id;
18080 Prag_Id : Pragma_Id;
18083 -- Check for any PPC pragmas that appear within Decl
18085 Prag := Next (Decl);
18086 while Nkind (Prag) = N_Pragma loop
18087 Prag_Id := Get_Pragma_Id (Chars (Pragma_Identifier (Prag)));
18090 when Pragma_Postcondition | Pragma_Precondition =>
18091 Prag_Arg_Ass := First (Pragma_Argument_Associations (Prag));
18093 -- Make an aspect from any PPC pragma
18095 Append_To (Aspects,
18096 Make_Aspect_Specification (Loc,
18098 Make_Identifier (Loc, Chars (Pragma_Identifier (Prag))),
18100 Copy_Separate_Tree (Expression (Prag_Arg_Ass))));
18102 -- Generate the analysis information in the pragma expression
18103 -- and then set the pragma node analyzed to avoid any further
18106 Analyze (Expression (Prag_Arg_Ass));
18107 Set_Analyzed (Prag, True);
18109 when others => null;
18115 -- Set all new aspects into the generic declaration node
18117 if Is_Non_Empty_List (Aspects) then
18119 -- Create the list of aspects to be inserted in the original tree
18121 Original_Aspects := Copy_Separate_List (Aspects);
18123 -- Check if Decl already has aspects
18125 -- Attach the new lists of aspects to both the generic copy and the
18128 if Has_Aspects (Decl) then
18129 Append_List (Aspects, Aspect_Specifications (Decl));
18130 Append_List (Original_Aspects, Aspect_Specifications (Or_Decl));
18133 Set_Parent (Aspects, Decl);
18134 Set_Aspect_Specifications (Decl, Aspects);
18135 Set_Parent (Original_Aspects, Or_Decl);
18136 Set_Aspect_Specifications (Or_Decl, Original_Aspects);
18139 end Make_Aspect_For_PPC_In_Gen_Sub_Decl;
18141 -------------------------
18142 -- Preanalyze_CTC_Args --
18143 -------------------------
18145 procedure Preanalyze_CTC_Args (N, Arg_Req, Arg_Ens : Node_Id) is
18147 -- Preanalyze the boolean expressions, we treat these as spec
18148 -- expressions (i.e. similar to a default expression).
18150 if Present (Arg_Req) then
18151 Preanalyze_Assert_Expression
18152 (Get_Pragma_Arg (Arg_Req), Standard_Boolean);
18154 -- In ASIS mode, for a pragma generated from a source aspect, also
18155 -- analyze the original aspect expression.
18157 if ASIS_Mode and then Present (Corresponding_Aspect (N)) then
18158 Preanalyze_Assert_Expression
18159 (Original_Node (Get_Pragma_Arg (Arg_Req)), Standard_Boolean);
18163 if Present (Arg_Ens) then
18164 Preanalyze_Assert_Expression
18165 (Get_Pragma_Arg (Arg_Ens), Standard_Boolean);
18167 -- In ASIS mode, for a pragma generated from a source aspect, also
18168 -- analyze the original aspect expression.
18170 if ASIS_Mode and then Present (Corresponding_Aspect (N)) then
18171 Preanalyze_Assert_Expression
18172 (Original_Node (Get_Pragma_Arg (Arg_Ens)), Standard_Boolean);
18175 end Preanalyze_CTC_Args;
18177 --------------------------------------
18178 -- Process_Compilation_Unit_Pragmas --
18179 --------------------------------------
18181 procedure Process_Compilation_Unit_Pragmas (N : Node_Id) is
18183 -- A special check for pragma Suppress_All, a very strange DEC pragma,
18184 -- strange because it comes at the end of the unit. Rational has the
18185 -- same name for a pragma, but treats it as a program unit pragma, In
18186 -- GNAT we just decide to allow it anywhere at all. If it appeared then
18187 -- the flag Has_Pragma_Suppress_All was set on the compilation unit
18188 -- node, and we insert a pragma Suppress (All_Checks) at the start of
18189 -- the context clause to ensure the correct processing.
18191 if Has_Pragma_Suppress_All (N) then
18192 Prepend_To (Context_Items (N),
18193 Make_Pragma (Sloc (N),
18194 Chars => Name_Suppress,
18195 Pragma_Argument_Associations => New_List (
18196 Make_Pragma_Argument_Association (Sloc (N),
18197 Expression => Make_Identifier (Sloc (N), Name_All_Checks)))));
18200 -- Nothing else to do at the current time!
18202 end Process_Compilation_Unit_Pragmas;
18213 --------------------------------
18214 -- Set_Encoded_Interface_Name --
18215 --------------------------------
18217 procedure Set_Encoded_Interface_Name (E : Entity_Id; S : Node_Id) is
18218 Str : constant String_Id := Strval (S);
18219 Len : constant Int := String_Length (Str);
18224 Hex : constant array (0 .. 15) of Character := "0123456789abcdef";
18227 -- Stores encoded value of character code CC. The encoding we use an
18228 -- underscore followed by four lower case hex digits.
18234 procedure Encode is
18236 Store_String_Char (Get_Char_Code ('_'));
18238 (Get_Char_Code (Hex (Integer (CC / 2 ** 12))));
18240 (Get_Char_Code (Hex (Integer (CC / 2 ** 8 and 16#0F#))));
18242 (Get_Char_Code (Hex (Integer (CC / 2 ** 4 and 16#0F#))));
18244 (Get_Char_Code (Hex (Integer (CC and 16#0F#))));
18247 -- Start of processing for Set_Encoded_Interface_Name
18250 -- If first character is asterisk, this is a link name, and we leave it
18251 -- completely unmodified. We also ignore null strings (the latter case
18252 -- happens only in error cases) and no encoding should occur for Java or
18253 -- AAMP interface names.
18256 or else Get_String_Char (Str, 1) = Get_Char_Code ('*')
18257 or else VM_Target /= No_VM
18258 or else AAMP_On_Target
18260 Set_Interface_Name (E, S);
18265 CC := Get_String_Char (Str, J);
18267 exit when not In_Character_Range (CC);
18269 C := Get_Character (CC);
18271 exit when C /= '_' and then C /= '$'
18272 and then C not in '0' .. '9'
18273 and then C not in 'a' .. 'z'
18274 and then C not in 'A' .. 'Z';
18277 Set_Interface_Name (E, S);
18285 -- Here we need to encode. The encoding we use as follows:
18286 -- three underscores + four hex digits (lower case)
18290 for J in 1 .. String_Length (Str) loop
18291 CC := Get_String_Char (Str, J);
18293 if not In_Character_Range (CC) then
18296 C := Get_Character (CC);
18298 if C = '_' or else C = '$'
18299 or else C in '0' .. '9'
18300 or else C in 'a' .. 'z'
18301 or else C in 'A' .. 'Z'
18303 Store_String_Char (CC);
18310 Set_Interface_Name (E,
18311 Make_String_Literal (Sloc (S),
18312 Strval => End_String));
18314 end Set_Encoded_Interface_Name;
18316 -------------------
18317 -- Set_Unit_Name --
18318 -------------------
18320 procedure Set_Unit_Name (N : Node_Id; With_Item : Node_Id) is
18325 if Nkind (N) = N_Identifier
18326 and then Nkind (With_Item) = N_Identifier
18328 Set_Entity (N, Entity (With_Item));
18330 elsif Nkind (N) = N_Selected_Component then
18331 Change_Selected_Component_To_Expanded_Name (N);
18332 Set_Entity (N, Entity (With_Item));
18333 Set_Entity (Selector_Name (N), Entity (N));
18335 Pref := Prefix (N);
18336 Scop := Scope (Entity (N));
18337 while Nkind (Pref) = N_Selected_Component loop
18338 Change_Selected_Component_To_Expanded_Name (Pref);
18339 Set_Entity (Selector_Name (Pref), Scop);
18340 Set_Entity (Pref, Scop);
18341 Pref := Prefix (Pref);
18342 Scop := Scope (Scop);
18345 Set_Entity (Pref, Scop);