1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- This unit contains the semantic processing for all pragmas, both language
27 -- and implementation defined. For most pragmas, the parser only does the
28 -- most basic job of checking the syntax, so Sem_Prag also contains the code
29 -- to complete the syntax checks. Certain pragmas are handled partially or
30 -- completely by the parser (see Par.Prag for further details).
32 with Atree
; use Atree
;
33 with Casing
; use Casing
;
34 with Checks
; use Checks
;
35 with Csets
; use Csets
;
36 with Debug
; use Debug
;
37 with Einfo
; use Einfo
;
38 with Elists
; use Elists
;
39 with Errout
; use Errout
;
40 with Exp_Dist
; use Exp_Dist
;
42 with Lib
.Writ
; use Lib
.Writ
;
43 with Lib
.Xref
; use Lib
.Xref
;
44 with Namet
.Sp
; use Namet
.Sp
;
45 with Nlists
; use Nlists
;
46 with Nmake
; use Nmake
;
48 with Output
; use Output
;
49 with Restrict
; use Restrict
;
50 with Rident
; use Rident
;
51 with Rtsfind
; use Rtsfind
;
53 with Sem_Aux
; use Sem_Aux
;
54 with Sem_Ch3
; use Sem_Ch3
;
55 with Sem_Ch6
; use Sem_Ch6
;
56 with Sem_Ch8
; use Sem_Ch8
;
57 with Sem_Ch12
; use Sem_Ch12
;
58 with Sem_Ch13
; use Sem_Ch13
;
59 with Sem_Dist
; use Sem_Dist
;
60 with Sem_Elim
; use Sem_Elim
;
61 with Sem_Eval
; use Sem_Eval
;
62 with Sem_Intr
; use Sem_Intr
;
63 with Sem_Mech
; use Sem_Mech
;
64 with Sem_Res
; use Sem_Res
;
65 with Sem_Type
; use Sem_Type
;
66 with Sem_Util
; use Sem_Util
;
67 with Sem_VFpt
; use Sem_VFpt
;
68 with Sem_Warn
; use Sem_Warn
;
69 with Stand
; use Stand
;
70 with Sinfo
; use Sinfo
;
71 with Sinfo
.CN
; use Sinfo
.CN
;
72 with Sinput
; use Sinput
;
73 with Snames
; use Snames
;
74 with Stringt
; use Stringt
;
75 with Stylesw
; use Stylesw
;
77 with Targparm
; use Targparm
;
78 with Tbuild
; use Tbuild
;
80 with Uintp
; use Uintp
;
81 with Uname
; use Uname
;
82 with Urealp
; use Urealp
;
83 with Validsw
; use Validsw
;
85 package body Sem_Prag
is
87 ----------------------------------------------
88 -- Common Handling of Import-Export Pragmas --
89 ----------------------------------------------
91 -- In the following section, a number of Import_xxx and Export_xxx
92 -- pragmas are defined by GNAT. These are compatible with the DEC
93 -- pragmas of the same name, and all have the following common
94 -- form and processing:
97 -- [Internal =>] LOCAL_NAME
98 -- [, [External =>] EXTERNAL_SYMBOL]
99 -- [, other optional parameters ]);
102 -- [Internal =>] LOCAL_NAME
103 -- [, [External =>] EXTERNAL_SYMBOL]
104 -- [, other optional parameters ]);
106 -- EXTERNAL_SYMBOL ::=
108 -- | static_string_EXPRESSION
110 -- The internal LOCAL_NAME designates the entity that is imported or
111 -- exported, and must refer to an entity in the current declarative
112 -- part (as required by the rules for LOCAL_NAME).
114 -- The external linker name is designated by the External parameter if
115 -- given, or the Internal parameter if not (if there is no External
116 -- parameter, the External parameter is a copy of the Internal name).
118 -- If the External parameter is given as a string, then this string is
119 -- treated as an external name (exactly as though it had been given as an
120 -- External_Name parameter for a normal Import pragma).
122 -- If the External parameter is given as an identifier (or there is no
123 -- External parameter, so that the Internal identifier is used), then
124 -- the external name is the characters of the identifier, translated
125 -- to all upper case letters for OpenVMS versions of GNAT, and to all
126 -- lower case letters for all other versions
128 -- Note: the external name specified or implied by any of these special
129 -- Import_xxx or Export_xxx pragmas override an external or link name
130 -- specified in a previous Import or Export pragma.
132 -- Note: these and all other DEC-compatible GNAT pragmas allow full use of
133 -- named notation, following the standard rules for subprogram calls, i.e.
134 -- parameters can be given in any order if named notation is used, and
135 -- positional and named notation can be mixed, subject to the rule that all
136 -- positional parameters must appear first.
138 -- Note: All these pragmas are implemented exactly following the DEC design
139 -- and implementation and are intended to be fully compatible with the use
140 -- of these pragmas in the DEC Ada compiler.
142 --------------------------------------------
143 -- Checking for Duplicated External Names --
144 --------------------------------------------
146 -- It is suspicious if two separate Export pragmas use the same external
147 -- name. The following table is used to diagnose this situation so that
148 -- an appropriate warning can be issued.
150 -- The Node_Id stored is for the N_String_Literal node created to hold
151 -- the value of the external name. The Sloc of this node is used to
152 -- cross-reference the location of the duplication.
154 package Externals
is new Table
.Table
(
155 Table_Component_Type
=> Node_Id
,
156 Table_Index_Type
=> Int
,
157 Table_Low_Bound
=> 0,
158 Table_Initial
=> 100,
159 Table_Increment
=> 100,
160 Table_Name
=> "Name_Externals");
162 -------------------------------------
163 -- Local Subprograms and Variables --
164 -------------------------------------
166 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
;
167 -- This routine is used for possible casing adjustment of an explicit
168 -- external name supplied as a string literal (the node N), according to
169 -- the casing requirement of Opt.External_Name_Casing. If this is set to
170 -- As_Is, then the string literal is returned unchanged, but if it is set
171 -- to Uppercase or Lowercase, then a new string literal with appropriate
172 -- casing is constructed.
174 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
;
175 -- If Def_Id refers to a renamed subprogram, then the base subprogram (the
176 -- original one, following the renaming chain) is returned. Otherwise the
177 -- entity is returned unchanged. Should be in Einfo???
179 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
;
180 -- All the routines that check pragma arguments take either a pragma
181 -- argument association (in which case the expression of the argument
182 -- association is checked), or the expression directly. The function
183 -- Get_Pragma_Arg is a utility used to deal with these two cases. If Arg
184 -- is a pragma argument association node, then its expression is returned,
185 -- otherwise Arg is returned unchanged.
188 -- This is a dummy function called by the processing for pragma Reviewable.
189 -- It is there for assisting front end debugging. By placing a Reviewable
190 -- pragma in the source program, a breakpoint on rv catches this place in
191 -- the source, allowing convenient stepping to the point of interest.
193 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
);
194 -- Place semantic information on the argument of an Elaborate/Elaborate_All
195 -- pragma. Entity name for unit and its parents is taken from item in
196 -- previous with_clause that mentions the unit.
198 -------------------------------
199 -- Adjust_External_Name_Case --
200 -------------------------------
202 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
is
206 -- Adjust case of literal if required
208 if Opt
.External_Name_Exp_Casing
= As_Is
then
212 -- Copy existing string
218 for J
in 1 .. String_Length
(Strval
(N
)) loop
219 CC
:= Get_String_Char
(Strval
(N
), J
);
221 if Opt
.External_Name_Exp_Casing
= Uppercase
222 and then CC
>= Get_Char_Code
('a')
223 and then CC
<= Get_Char_Code
('z')
225 Store_String_Char
(CC
- 32);
227 elsif Opt
.External_Name_Exp_Casing
= Lowercase
228 and then CC
>= Get_Char_Code
('A')
229 and then CC
<= Get_Char_Code
('Z')
231 Store_String_Char
(CC
+ 32);
234 Store_String_Char
(CC
);
239 Make_String_Literal
(Sloc
(N
),
240 Strval
=> End_String
);
242 end Adjust_External_Name_Case
;
244 ------------------------------
245 -- Analyze_PPC_In_Decl_Part --
246 ------------------------------
248 procedure Analyze_PPC_In_Decl_Part
(N
: Node_Id
; S
: Entity_Id
) is
249 Arg1
: constant Node_Id
:=
250 First
(Pragma_Argument_Associations
(N
));
251 Arg2
: constant Node_Id
:= Next
(Arg1
);
254 -- Install formals and push subprogram spec onto scope stack so that we
255 -- can see the formals from the pragma.
260 -- Preanalyze the boolean expression, we treat this as a spec expression
261 -- (i.e. similar to a default expression).
263 Preanalyze_Spec_Expression
264 (Get_Pragma_Arg
(Arg1
), Standard_Boolean
);
266 -- If there is a message argument, analyze it the same way
268 if Present
(Arg2
) then
269 Preanalyze_Spec_Expression
270 (Get_Pragma_Arg
(Arg2
), Standard_String
);
273 -- Remove the subprogram from the scope stack now that the pre-analysis
274 -- of the precondition/postcondition is done.
277 end Analyze_PPC_In_Decl_Part
;
283 procedure Analyze_Pragma
(N
: Node_Id
) is
284 Loc
: constant Source_Ptr
:= Sloc
(N
);
285 Pname
: constant Name_Id
:= Pragma_Name
(N
);
288 Pragma_Exit
: exception;
289 -- This exception is used to exit pragma processing completely. It is
290 -- used when an error is detected, and no further processing is
291 -- required. It is also used if an earlier error has left the tree in
292 -- a state where the pragma should not be processed.
295 -- Number of pragma argument associations
301 -- First four pragma arguments (pragma argument association nodes, or
302 -- Empty if the corresponding argument does not exist).
304 type Name_List
is array (Natural range <>) of Name_Id
;
305 type Args_List
is array (Natural range <>) of Node_Id
;
306 -- Types used for arguments to Check_Arg_Order and Gather_Associations
308 procedure Ada_2005_Pragma
;
309 -- Called for pragmas defined in Ada 2005, that are not in Ada 95. In
310 -- Ada 95 mode, these are implementation defined pragmas, so should be
311 -- caught by the No_Implementation_Pragmas restriction
313 procedure Check_Ada_83_Warning
;
314 -- Issues a warning message for the current pragma if operating in Ada
315 -- 83 mode (used for language pragmas that are not a standard part of
316 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
319 procedure Check_Arg_Count
(Required
: Nat
);
320 -- Check argument count for pragma is equal to given parameter. If not,
321 -- then issue an error message and raise Pragma_Exit.
323 -- Note: all routines whose name is Check_Arg_Is_xxx take an argument
324 -- Arg which can either be a pragma argument association, in which case
325 -- the check is applied to the expression of the association or an
326 -- expression directly.
328 procedure Check_Arg_Is_External_Name
(Arg
: Node_Id
);
329 -- Check that an argument has the right form for an EXTERNAL_NAME
330 -- parameter of an extended import/export pragma. The rule is that the
331 -- name must be an identifier or string literal (in Ada 83 mode) or a
332 -- static string expression (in Ada 95 mode).
334 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
);
335 -- Check the specified argument Arg to make sure that it is an
336 -- identifier. If not give error and raise Pragma_Exit.
338 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
);
339 -- Check the specified argument Arg to make sure that it is an integer
340 -- literal. If not give error and raise Pragma_Exit.
342 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
);
343 -- Check the specified argument Arg to make sure that it has the proper
344 -- syntactic form for a local name and meets the semantic requirements
345 -- for a local name. The local name is analyzed as part of the
346 -- processing for this call. In addition, the local name is required
347 -- to represent an entity at the library level.
349 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
);
350 -- Check the specified argument Arg to make sure that it has the proper
351 -- syntactic form for a local name and meets the semantic requirements
352 -- for a local name. The local name is analyzed as part of the
353 -- processing for this call.
355 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
);
356 -- Check the specified argument Arg to make sure that it is a valid
357 -- locking policy name. If not give error and raise Pragma_Exit.
359 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
);
360 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
, N3
: Name_Id
);
361 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
, N3
, N4
: Name_Id
);
362 -- Check the specified argument Arg to make sure that it is an
363 -- identifier whose name matches either N1 or N2 (or N3 if present).
364 -- If not then give error and raise Pragma_Exit.
366 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
);
367 -- Check the specified argument Arg to make sure that it is a valid
368 -- queuing policy name. If not give error and raise Pragma_Exit.
370 procedure Check_Arg_Is_Static_Expression
372 Typ
: Entity_Id
:= Empty
);
373 -- Check the specified argument Arg to make sure that it is a static
374 -- expression of the given type (i.e. it will be analyzed and resolved
375 -- using this type, which can be any valid argument to Resolve, e.g.
376 -- Any_Integer is OK). If not, given error and raise Pragma_Exit. If
377 -- Typ is left Empty, then any static expression is allowed.
379 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
);
380 -- Check the specified argument Arg to make sure that it is a string
381 -- literal. If not give error and raise Pragma_Exit
383 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
);
384 -- Check the specified argument Arg to make sure that it is a valid task
385 -- dispatching policy name. If not give error and raise Pragma_Exit.
387 procedure Check_Arg_Order
(Names
: Name_List
);
388 -- Checks for an instance of two arguments with identifiers for the
389 -- current pragma which are not in the sequence indicated by Names,
390 -- and if so, generates a fatal message about bad order of arguments.
392 procedure Check_At_Least_N_Arguments
(N
: Nat
);
393 -- Check there are at least N arguments present
395 procedure Check_At_Most_N_Arguments
(N
: Nat
);
396 -- Check there are no more than N arguments present
398 procedure Check_Component
(Comp
: Node_Id
);
399 -- Examine Unchecked_Union component for correct use of per-object
400 -- constrained subtypes, and for restrictions on finalizable components.
402 procedure Check_Duplicated_Export_Name
(Nam
: Node_Id
);
403 -- Nam is an N_String_Literal node containing the external name set by
404 -- an Import or Export pragma (or extended Import or Export pragma).
405 -- This procedure checks for possible duplications if this is the export
406 -- case, and if found, issues an appropriate error message.
408 procedure Check_First_Subtype
(Arg
: Node_Id
);
409 -- Checks that Arg, whose expression is an entity name referencing a
410 -- subtype, does not reference a type that is not a first subtype.
412 procedure Check_In_Main_Program
;
413 -- Common checks for pragmas that appear within a main program
414 -- (Priority, Main_Storage, Time_Slice, Relative_Deadline).
416 procedure Check_Interrupt_Or_Attach_Handler
;
417 -- Common processing for first argument of pragma Interrupt_Handler or
418 -- pragma Attach_Handler.
420 procedure Check_Is_In_Decl_Part_Or_Package_Spec
;
421 -- Check that pragma appears in a declarative part, or in a package
422 -- specification, i.e. that it does not occur in a statement sequence
425 procedure Check_No_Identifier
(Arg
: Node_Id
);
426 -- Checks that the given argument does not have an identifier. If
427 -- an identifier is present, then an error message is issued, and
428 -- Pragma_Exit is raised.
430 procedure Check_No_Identifiers
;
431 -- Checks that none of the arguments to the pragma has an identifier.
432 -- If any argument has an identifier, then an error message is issued,
433 -- and Pragma_Exit is raised.
435 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
);
436 -- Checks if the given argument has an identifier, and if so, requires
437 -- it to match the given identifier name. If there is a non-matching
438 -- identifier, then an error message is given and Error_Pragmas raised.
440 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String);
441 -- Checks if the given argument has an identifier, and if so, requires
442 -- it to match the given identifier name. If there is a non-matching
443 -- identifier, then an error message is given and Error_Pragmas raised.
444 -- In this version of the procedure, the identifier name is given as
445 -- a string with lower case letters.
447 procedure Check_Precondition_Postcondition
(In_Body
: out Boolean);
448 -- Called to process a precondition or postcondition pragma. There are
451 -- The pragma appears after a subprogram spec
453 -- If the corresponding check is not enabled, the pragma is analyzed
454 -- but otherwise ignored and control returns with In_Body set False.
456 -- If the check is enabled, then the first step is to analyze the
457 -- pragma, but this is skipped if the subprogram spec appears within
458 -- a package specification (because this is the case where we delay
459 -- analysis till the end of the spec). Then (whether or not it was
460 -- analyzed), the pragma is chained to the subprogram in question
461 -- (using Spec_PPC_List and Next_Pragma) and control returns to the
462 -- caller with In_Body set False.
464 -- The pragma appears at the start of subprogram body declarations
466 -- In this case an immediate return to the caller is made with
467 -- In_Body set True, and the pragma is NOT analyzed.
469 -- In all other cases, an error message for bad placement is given
471 procedure Check_Static_Constraint
(Constr
: Node_Id
);
472 -- Constr is a constraint from an N_Subtype_Indication node from a
473 -- component constraint in an Unchecked_Union type. This routine checks
474 -- that the constraint is static as required by the restrictions for
477 procedure Check_Valid_Configuration_Pragma
;
478 -- Legality checks for placement of a configuration pragma
480 procedure Check_Valid_Library_Unit_Pragma
;
481 -- Legality checks for library unit pragmas. A special case arises for
482 -- pragmas in generic instances that come from copies of the original
483 -- library unit pragmas in the generic templates. In the case of other
484 -- than library level instantiations these can appear in contexts which
485 -- would normally be invalid (they only apply to the original template
486 -- and to library level instantiations), and they are simply ignored,
487 -- which is implemented by rewriting them as null statements.
489 procedure Check_Variant
(Variant
: Node_Id
);
490 -- Check Unchecked_Union variant for lack of nested variants and
491 -- presence of at least one component.
493 procedure Error_Pragma
(Msg
: String);
494 pragma No_Return
(Error_Pragma
);
495 -- Outputs error message for current pragma. The message contains a %
496 -- that will be replaced with the pragma name, and the flag is placed
497 -- on the pragma itself. Pragma_Exit is then raised.
499 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
);
500 pragma No_Return
(Error_Pragma_Arg
);
501 -- Outputs error message for current pragma. The message may contain
502 -- a % that will be replaced with the pragma name. The parameter Arg
503 -- may either be a pragma argument association, in which case the flag
504 -- is placed on the expression of this association, or an expression,
505 -- in which case the flag is placed directly on the expression. The
506 -- message is placed using Error_Msg_N, so the message may also contain
507 -- an & insertion character which will reference the given Arg value.
508 -- After placing the message, Pragma_Exit is raised.
510 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
);
511 pragma No_Return
(Error_Pragma_Arg
);
512 -- Similar to above form of Error_Pragma_Arg except that two messages
513 -- are provided, the second is a continuation comment starting with \.
515 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
);
516 pragma No_Return
(Error_Pragma_Arg_Ident
);
517 -- Outputs error message for current pragma. The message may contain
518 -- a % that will be replaced with the pragma name. The parameter Arg
519 -- must be a pragma argument association with a non-empty identifier
520 -- (i.e. its Chars field must be set), and the error message is placed
521 -- on the identifier. The message is placed using Error_Msg_N so
522 -- the message may also contain an & insertion character which will
523 -- reference the identifier. After placing the message, Pragma_Exit
526 procedure Error_Pragma_Ref
(Msg
: String; Ref
: Entity_Id
);
527 pragma No_Return
(Error_Pragma_Ref
);
528 -- Outputs error message for current pragma. The message may contain
529 -- a % that will be replaced with the pragma name. The parameter Ref
530 -- must be an entity whose name can be referenced by & and sloc by #.
531 -- After placing the message, Pragma_Exit is raised.
533 function Find_Lib_Unit_Name
return Entity_Id
;
534 -- Used for a library unit pragma to find the entity to which the
535 -- library unit pragma applies, returns the entity found.
537 procedure Find_Program_Unit_Name
(Id
: Node_Id
);
538 -- If the pragma is a compilation unit pragma, the id must denote the
539 -- compilation unit in the same compilation, and the pragma must appear
540 -- in the list of preceding or trailing pragmas. If it is a program
541 -- unit pragma that is not a compilation unit pragma, then the
542 -- identifier must be visible.
544 function Find_Unique_Parameterless_Procedure
546 Arg
: Node_Id
) return Entity_Id
;
547 -- Used for a procedure pragma to find the unique parameterless
548 -- procedure identified by Name, returns it if it exists, otherwise
549 -- errors out and uses Arg as the pragma argument for the message.
551 procedure Gather_Associations
553 Args
: out Args_List
);
554 -- This procedure is used to gather the arguments for a pragma that
555 -- permits arbitrary ordering of parameters using the normal rules
556 -- for named and positional parameters. The Names argument is a list
557 -- of Name_Id values that corresponds to the allowed pragma argument
558 -- association identifiers in order. The result returned in Args is
559 -- a list of corresponding expressions that are the pragma arguments.
560 -- Note that this is a list of expressions, not of pragma argument
561 -- associations (Gather_Associations has completely checked all the
562 -- optional identifiers when it returns). An entry in Args is Empty
563 -- on return if the corresponding argument is not present.
565 procedure GNAT_Pragma
;
566 -- Called for all GNAT defined pragmas to check the relevant restriction
567 -- (No_Implementation_Pragmas).
569 function Is_Before_First_Decl
570 (Pragma_Node
: Node_Id
;
571 Decls
: List_Id
) return Boolean;
572 -- Return True if Pragma_Node is before the first declarative item in
573 -- Decls where Decls is the list of declarative items.
575 function Is_Configuration_Pragma
return Boolean;
576 -- Determines if the placement of the current pragma is appropriate
577 -- for a configuration pragma.
579 function Is_In_Context_Clause
return Boolean;
580 -- Returns True if pragma appears within the context clause of a unit,
581 -- and False for any other placement (does not generate any messages).
583 function Is_Static_String_Expression
(Arg
: Node_Id
) return Boolean;
584 -- Analyzes the argument, and determines if it is a static string
585 -- expression, returns True if so, False if non-static or not String.
587 procedure Pragma_Misplaced
;
588 pragma No_Return
(Pragma_Misplaced
);
589 -- Issue fatal error message for misplaced pragma
591 procedure Process_Atomic_Shared_Volatile
;
592 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
593 -- Shared is an obsolete Ada 83 pragma, treated as being identical
594 -- in effect to pragma Atomic.
596 procedure Process_Compile_Time_Warning_Or_Error
;
597 -- Common processing for Compile_Time_Error and Compile_Time_Warning
599 procedure Process_Convention
600 (C
: out Convention_Id
;
601 Ent
: out Entity_Id
);
602 -- Common processing for Convention, Interface, Import and Export.
603 -- Checks first two arguments of pragma, and sets the appropriate
604 -- convention value in the specified entity or entities. On return
605 -- C is the convention, Ent is the referenced entity.
607 procedure Process_Extended_Import_Export_Exception_Pragma
608 (Arg_Internal
: Node_Id
;
609 Arg_External
: Node_Id
;
612 -- Common processing for the pragmas Import/Export_Exception. The three
613 -- arguments correspond to the three named parameters of the pragma. An
614 -- argument is empty if the corresponding parameter is not present in
617 procedure Process_Extended_Import_Export_Object_Pragma
618 (Arg_Internal
: Node_Id
;
619 Arg_External
: Node_Id
;
621 -- Common processing for the pragmas Import/Export_Object. The three
622 -- arguments correspond to the three named parameters of the pragmas. An
623 -- argument is empty if the corresponding parameter is not present in
626 procedure Process_Extended_Import_Export_Internal_Arg
627 (Arg_Internal
: Node_Id
:= Empty
);
628 -- Common processing for all extended Import and Export pragmas. The
629 -- argument is the pragma parameter for the Internal argument. If
630 -- Arg_Internal is empty or inappropriate, an error message is posted.
631 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
632 -- set to identify the referenced entity.
634 procedure Process_Extended_Import_Export_Subprogram_Pragma
635 (Arg_Internal
: Node_Id
;
636 Arg_External
: Node_Id
;
637 Arg_Parameter_Types
: Node_Id
;
638 Arg_Result_Type
: Node_Id
:= Empty
;
639 Arg_Mechanism
: Node_Id
;
640 Arg_Result_Mechanism
: Node_Id
:= Empty
;
641 Arg_First_Optional_Parameter
: Node_Id
:= Empty
);
642 -- Common processing for all extended Import and Export pragmas applying
643 -- to subprograms. The caller omits any arguments that do not apply to
644 -- the pragma in question (for example, Arg_Result_Type can be non-Empty
645 -- only in the Import_Function and Export_Function cases). The argument
646 -- names correspond to the allowed pragma association identifiers.
648 procedure Process_Generic_List
;
649 -- Common processing for Share_Generic and Inline_Generic
651 procedure Process_Import_Or_Interface
;
652 -- Common processing for Import of Interface
654 procedure Process_Inline
(Active
: Boolean);
655 -- Common processing for Inline and Inline_Always. The parameter
656 -- indicates if the inline pragma is active, i.e. if it should actually
657 -- cause inlining to occur.
659 procedure Process_Interface_Name
660 (Subprogram_Def
: Entity_Id
;
663 -- Given the last two arguments of pragma Import, pragma Export, or
664 -- pragma Interface_Name, performs validity checks and sets the
665 -- Interface_Name field of the given subprogram entity to the
666 -- appropriate external or link name, depending on the arguments given.
667 -- Ext_Arg is always present, but Link_Arg may be missing. Note that
668 -- Ext_Arg may represent the Link_Name if Link_Arg is missing, and
669 -- appropriate named notation is used for Ext_Arg. If neither Ext_Arg
670 -- nor Link_Arg is present, the interface name is set to the default
671 -- from the subprogram name.
673 procedure Process_Interrupt_Or_Attach_Handler
;
674 -- Common processing for Interrupt and Attach_Handler pragmas
676 procedure Process_Restrictions_Or_Restriction_Warnings
(Warn
: Boolean);
677 -- Common processing for Restrictions and Restriction_Warnings pragmas.
678 -- Warn is True for Restriction_Warnings, or for Restrictions if the
679 -- flag Treat_Restrictions_As_Warnings is set, and False if this flag
680 -- is not set in the Restrictions case.
682 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean);
683 -- Common processing for Suppress and Unsuppress. The boolean parameter
684 -- Suppress_Case is True for the Suppress case, and False for the
687 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
);
688 -- This procedure sets the Is_Exported flag for the given entity,
689 -- checking that the entity was not previously imported. Arg is
690 -- the argument that specified the entity. A check is also made
691 -- for exporting inappropriate entities.
693 procedure Set_Extended_Import_Export_External_Name
694 (Internal_Ent
: Entity_Id
;
695 Arg_External
: Node_Id
);
696 -- Common processing for all extended import export pragmas. The first
697 -- argument, Internal_Ent, is the internal entity, which has already
698 -- been checked for validity by the caller. Arg_External is from the
699 -- Import or Export pragma, and may be null if no External parameter
700 -- was present. If Arg_External is present and is a non-null string
701 -- (a null string is treated as the default), then the Interface_Name
702 -- field of Internal_Ent is set appropriately.
704 procedure Set_Imported
(E
: Entity_Id
);
705 -- This procedure sets the Is_Imported flag for the given entity,
706 -- checking that it is not previously exported or imported.
708 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
);
709 -- Mech is a parameter passing mechanism (see Import_Function syntax
710 -- for MECHANISM_NAME). This routine checks that the mechanism argument
711 -- has the right form, and if not issues an error message. If the
712 -- argument has the right form then the Mechanism field of Ent is
713 -- set appropriately.
715 procedure Set_Ravenscar_Profile
(N
: Node_Id
);
716 -- Activate the set of configuration pragmas and restrictions that make
717 -- up the Ravenscar Profile. N is the corresponding pragma node, which
718 -- is used for error messages on any constructs that violate the
721 ---------------------
722 -- Ada_2005_Pragma --
723 ---------------------
725 procedure Ada_2005_Pragma
is
727 if Ada_Version
<= Ada_95
then
728 Check_Restriction
(No_Implementation_Pragmas
, N
);
732 --------------------------
733 -- Check_Ada_83_Warning --
734 --------------------------
736 procedure Check_Ada_83_Warning
is
738 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
739 Error_Msg_N
("(Ada 83) pragma& is non-standard?", N
);
741 end Check_Ada_83_Warning
;
743 ---------------------
744 -- Check_Arg_Count --
745 ---------------------
747 procedure Check_Arg_Count
(Required
: Nat
) is
749 if Arg_Count
/= Required
then
750 Error_Pragma
("wrong number of arguments for pragma%");
754 --------------------------------
755 -- Check_Arg_Is_External_Name --
756 --------------------------------
758 procedure Check_Arg_Is_External_Name
(Arg
: Node_Id
) is
759 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
762 if Nkind
(Argx
) = N_Identifier
then
766 Analyze_And_Resolve
(Argx
, Standard_String
);
768 if Is_OK_Static_Expression
(Argx
) then
771 elsif Etype
(Argx
) = Any_Type
then
774 -- An interesting special case, if we have a string literal and
775 -- we are in Ada 83 mode, then we allow it even though it will
776 -- not be flagged as static. This allows expected Ada 83 mode
777 -- use of external names which are string literals, even though
778 -- technically these are not static in Ada 83.
780 elsif Ada_Version
= Ada_83
781 and then Nkind
(Argx
) = N_String_Literal
785 -- Static expression that raises Constraint_Error. This has
786 -- already been flagged, so just exit from pragma processing.
788 elsif Is_Static_Expression
(Argx
) then
791 -- Here we have a real error (non-static expression)
794 Error_Msg_Name_1
:= Pname
;
796 ("argument for pragma% must be a identifier or " &
797 "static string expression!", Argx
);
801 end Check_Arg_Is_External_Name
;
803 -----------------------------
804 -- Check_Arg_Is_Identifier --
805 -----------------------------
807 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
) is
808 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
810 if Nkind
(Argx
) /= N_Identifier
then
812 ("argument for pragma% must be identifier", Argx
);
814 end Check_Arg_Is_Identifier
;
816 ----------------------------------
817 -- Check_Arg_Is_Integer_Literal --
818 ----------------------------------
820 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
) is
821 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
823 if Nkind
(Argx
) /= N_Integer_Literal
then
825 ("argument for pragma% must be integer literal", Argx
);
827 end Check_Arg_Is_Integer_Literal
;
829 -------------------------------------------
830 -- Check_Arg_Is_Library_Level_Local_Name --
831 -------------------------------------------
835 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
836 -- | library_unit_NAME
838 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
) is
840 Check_Arg_Is_Local_Name
(Arg
);
842 if not Is_Library_Level_Entity
(Entity
(Expression
(Arg
)))
843 and then Comes_From_Source
(N
)
846 ("argument for pragma% must be library level entity", Arg
);
848 end Check_Arg_Is_Library_Level_Local_Name
;
850 -----------------------------
851 -- Check_Arg_Is_Local_Name --
852 -----------------------------
856 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
857 -- | library_unit_NAME
859 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
) is
860 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
865 if Nkind
(Argx
) not in N_Direct_Name
866 and then (Nkind
(Argx
) /= N_Attribute_Reference
867 or else Present
(Expressions
(Argx
))
868 or else Nkind
(Prefix
(Argx
)) /= N_Identifier
)
869 and then (not Is_Entity_Name
(Argx
)
870 or else not Is_Compilation_Unit
(Entity
(Argx
)))
872 Error_Pragma_Arg
("argument for pragma% must be local name", Argx
);
875 if Is_Entity_Name
(Argx
)
876 and then Scope
(Entity
(Argx
)) /= Current_Scope
879 ("pragma% argument must be in same declarative part", Arg
);
881 end Check_Arg_Is_Local_Name
;
883 ---------------------------------
884 -- Check_Arg_Is_Locking_Policy --
885 ---------------------------------
887 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
) is
888 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
891 Check_Arg_Is_Identifier
(Argx
);
893 if not Is_Locking_Policy_Name
(Chars
(Argx
)) then
895 ("& is not a valid locking policy name", Argx
);
897 end Check_Arg_Is_Locking_Policy
;
899 -------------------------
900 -- Check_Arg_Is_One_Of --
901 -------------------------
903 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
) is
904 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
907 Check_Arg_Is_Identifier
(Argx
);
909 if Chars
(Argx
) /= N1
and then Chars
(Argx
) /= N2
then
910 Error_Msg_Name_2
:= N1
;
911 Error_Msg_Name_3
:= N2
;
912 Error_Pragma_Arg
("argument for pragma% must be% or%", Argx
);
914 end Check_Arg_Is_One_Of
;
916 procedure Check_Arg_Is_One_Of
918 N1
, N2
, N3
: Name_Id
)
920 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
923 Check_Arg_Is_Identifier
(Argx
);
925 if Chars
(Argx
) /= N1
926 and then Chars
(Argx
) /= N2
927 and then Chars
(Argx
) /= N3
929 Error_Pragma_Arg
("invalid argument for pragma%", Argx
);
931 end Check_Arg_Is_One_Of
;
933 procedure Check_Arg_Is_One_Of
935 N1
, N2
, N3
, N4
: Name_Id
)
937 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
940 Check_Arg_Is_Identifier
(Argx
);
942 if Chars
(Argx
) /= N1
943 and then Chars
(Argx
) /= N2
944 and then Chars
(Argx
) /= N3
945 and then Chars
(Argx
) /= N4
947 Error_Pragma_Arg
("invalid argument for pragma%", Argx
);
949 end Check_Arg_Is_One_Of
;
951 ---------------------------------
952 -- Check_Arg_Is_Queuing_Policy --
953 ---------------------------------
955 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
) is
956 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
959 Check_Arg_Is_Identifier
(Argx
);
961 if not Is_Queuing_Policy_Name
(Chars
(Argx
)) then
963 ("& is not a valid queuing policy name", Argx
);
965 end Check_Arg_Is_Queuing_Policy
;
967 ------------------------------------
968 -- Check_Arg_Is_Static_Expression --
969 ------------------------------------
971 procedure Check_Arg_Is_Static_Expression
973 Typ
: Entity_Id
:= Empty
)
975 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
978 if Present
(Typ
) then
979 Analyze_And_Resolve
(Argx
, Typ
);
981 Analyze_And_Resolve
(Argx
);
984 if Is_OK_Static_Expression
(Argx
) then
987 elsif Etype
(Argx
) = Any_Type
then
990 -- An interesting special case, if we have a string literal and we
991 -- are in Ada 83 mode, then we allow it even though it will not be
992 -- flagged as static. This allows the use of Ada 95 pragmas like
993 -- Import in Ada 83 mode. They will of course be flagged with
994 -- warnings as usual, but will not cause errors.
996 elsif Ada_Version
= Ada_83
997 and then Nkind
(Argx
) = N_String_Literal
1001 -- Static expression that raises Constraint_Error. This has already
1002 -- been flagged, so just exit from pragma processing.
1004 elsif Is_Static_Expression
(Argx
) then
1007 -- Finally, we have a real error
1010 Error_Msg_Name_1
:= Pname
;
1011 Flag_Non_Static_Expr
1012 ("argument for pragma% must be a static expression!", Argx
);
1015 end Check_Arg_Is_Static_Expression
;
1017 ---------------------------------
1018 -- Check_Arg_Is_String_Literal --
1019 ---------------------------------
1021 procedure Check_Arg_Is_String_Literal
(Arg
: Node_Id
) is
1022 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1024 if Nkind
(Argx
) /= N_String_Literal
then
1026 ("argument for pragma% must be string literal", Argx
);
1028 end Check_Arg_Is_String_Literal
;
1030 ------------------------------------------
1031 -- Check_Arg_Is_Task_Dispatching_Policy --
1032 ------------------------------------------
1034 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
) is
1035 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1038 Check_Arg_Is_Identifier
(Argx
);
1040 if not Is_Task_Dispatching_Policy_Name
(Chars
(Argx
)) then
1042 ("& is not a valid task dispatching policy name", Argx
);
1044 end Check_Arg_Is_Task_Dispatching_Policy
;
1046 ---------------------
1047 -- Check_Arg_Order --
1048 ---------------------
1050 procedure Check_Arg_Order
(Names
: Name_List
) is
1053 Highest_So_Far
: Natural := 0;
1054 -- Highest index in Names seen do far
1058 for J
in 1 .. Arg_Count
loop
1059 if Chars
(Arg
) /= No_Name
then
1060 for K
in Names
'Range loop
1061 if Chars
(Arg
) = Names
(K
) then
1062 if K
< Highest_So_Far
then
1063 Error_Msg_Name_1
:= Pname
;
1065 ("parameters out of order for pragma%", Arg
);
1066 Error_Msg_Name_1
:= Names
(K
);
1067 Error_Msg_Name_2
:= Names
(Highest_So_Far
);
1068 Error_Msg_N
("\% must appear before %", Arg
);
1072 Highest_So_Far
:= K
;
1080 end Check_Arg_Order
;
1082 --------------------------------
1083 -- Check_At_Least_N_Arguments --
1084 --------------------------------
1086 procedure Check_At_Least_N_Arguments
(N
: Nat
) is
1088 if Arg_Count
< N
then
1089 Error_Pragma
("too few arguments for pragma%");
1091 end Check_At_Least_N_Arguments
;
1093 -------------------------------
1094 -- Check_At_Most_N_Arguments --
1095 -------------------------------
1097 procedure Check_At_Most_N_Arguments
(N
: Nat
) is
1100 if Arg_Count
> N
then
1102 for J
in 1 .. N
loop
1104 Error_Pragma_Arg
("too many arguments for pragma%", Arg
);
1107 end Check_At_Most_N_Arguments
;
1109 ---------------------
1110 -- Check_Component --
1111 ---------------------
1113 procedure Check_Component
(Comp
: Node_Id
) is
1115 if Nkind
(Comp
) = N_Component_Declaration
then
1117 Sindic
: constant Node_Id
:=
1118 Subtype_Indication
(Component_Definition
(Comp
));
1119 Typ
: constant Entity_Id
:=
1120 Etype
(Defining_Identifier
(Comp
));
1122 if Nkind
(Sindic
) = N_Subtype_Indication
then
1124 -- Ada 2005 (AI-216): If a component subtype is subject to
1125 -- a per-object constraint, then the component type shall
1126 -- be an Unchecked_Union.
1128 if Has_Per_Object_Constraint
(Defining_Identifier
(Comp
))
1130 not Is_Unchecked_Union
(Etype
(Subtype_Mark
(Sindic
)))
1132 Error_Msg_N
("component subtype subject to per-object" &
1133 " constraint must be an Unchecked_Union", Comp
);
1137 if Is_Controlled
(Typ
) then
1139 ("component of unchecked union cannot be controlled", Comp
);
1141 elsif Has_Task
(Typ
) then
1143 ("component of unchecked union cannot have tasks", Comp
);
1147 end Check_Component
;
1149 ----------------------------------
1150 -- Check_Duplicated_Export_Name --
1151 ----------------------------------
1153 procedure Check_Duplicated_Export_Name
(Nam
: Node_Id
) is
1154 String_Val
: constant String_Id
:= Strval
(Nam
);
1157 -- We allow duplicated export names in CIL, as they are always
1158 -- enclosed in a namespace that differentiates them, and overloaded
1159 -- entities are supported by the VM.
1161 if VM_Target
= CLI_Target
then
1165 -- We are only interested in the export case, and in the case of
1166 -- generics, it is the instance, not the template, that is the
1167 -- problem (the template will generate a warning in any case).
1169 if not Inside_A_Generic
1170 and then (Prag_Id
= Pragma_Export
1172 Prag_Id
= Pragma_Export_Procedure
1174 Prag_Id
= Pragma_Export_Valued_Procedure
1176 Prag_Id
= Pragma_Export_Function
)
1178 for J
in Externals
.First
.. Externals
.Last
loop
1179 if String_Equal
(String_Val
, Strval
(Externals
.Table
(J
))) then
1180 Error_Msg_Sloc
:= Sloc
(Externals
.Table
(J
));
1181 Error_Msg_N
("external name duplicates name given#", Nam
);
1186 Externals
.Append
(Nam
);
1188 end Check_Duplicated_Export_Name
;
1190 -------------------------
1191 -- Check_First_Subtype --
1192 -------------------------
1194 procedure Check_First_Subtype
(Arg
: Node_Id
) is
1195 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1197 if not Is_First_Subtype
(Entity
(Argx
)) then
1199 ("pragma% cannot apply to subtype", Argx
);
1201 end Check_First_Subtype
;
1203 ---------------------------
1204 -- Check_In_Main_Program --
1205 ---------------------------
1207 procedure Check_In_Main_Program
is
1208 P
: constant Node_Id
:= Parent
(N
);
1211 -- Must be at in subprogram body
1213 if Nkind
(P
) /= N_Subprogram_Body
then
1214 Error_Pragma
("% pragma allowed only in subprogram");
1216 -- Otherwise warn if obviously not main program
1218 elsif Present
(Parameter_Specifications
(Specification
(P
)))
1219 or else not Is_Compilation_Unit
(Defining_Entity
(P
))
1221 Error_Msg_Name_1
:= Pname
;
1223 ("?pragma% is only effective in main program", N
);
1225 end Check_In_Main_Program
;
1227 ---------------------------------------
1228 -- Check_Interrupt_Or_Attach_Handler --
1229 ---------------------------------------
1231 procedure Check_Interrupt_Or_Attach_Handler
is
1232 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
1233 Handler_Proc
, Proc_Scope
: Entity_Id
;
1238 if Prag_Id
= Pragma_Interrupt_Handler
then
1239 Check_Restriction
(No_Dynamic_Attachment
, N
);
1242 Handler_Proc
:= Find_Unique_Parameterless_Procedure
(Arg1_X
, Arg1
);
1243 Proc_Scope
:= Scope
(Handler_Proc
);
1245 -- On AAMP only, a pragma Interrupt_Handler is supported for
1246 -- nonprotected parameterless procedures.
1248 if not AAMP_On_Target
1249 or else Prag_Id
= Pragma_Attach_Handler
1251 if Ekind
(Proc_Scope
) /= E_Protected_Type
then
1253 ("argument of pragma% must be protected procedure", Arg1
);
1256 if Parent
(N
) /= Protected_Definition
(Parent
(Proc_Scope
)) then
1257 Error_Pragma
("pragma% must be in protected definition");
1261 if not Is_Library_Level_Entity
(Proc_Scope
)
1262 or else (AAMP_On_Target
1263 and then not Is_Library_Level_Entity
(Handler_Proc
))
1266 ("argument for pragma% must be library level entity", Arg1
);
1268 end Check_Interrupt_Or_Attach_Handler
;
1270 -------------------------------------------
1271 -- Check_Is_In_Decl_Part_Or_Package_Spec --
1272 -------------------------------------------
1274 procedure Check_Is_In_Decl_Part_Or_Package_Spec
is
1283 elsif Nkind
(P
) = N_Handled_Sequence_Of_Statements
then
1286 elsif Nkind_In
(P
, N_Package_Specification
,
1291 -- Note: the following tests seem a little peculiar, because
1292 -- they test for bodies, but if we were in the statement part
1293 -- of the body, we would already have hit the handled statement
1294 -- sequence, so the only way we get here is by being in the
1295 -- declarative part of the body.
1297 elsif Nkind_In
(P
, N_Subprogram_Body
,
1308 Error_Pragma
("pragma% is not in declarative part or package spec");
1309 end Check_Is_In_Decl_Part_Or_Package_Spec
;
1311 -------------------------
1312 -- Check_No_Identifier --
1313 -------------------------
1315 procedure Check_No_Identifier
(Arg
: Node_Id
) is
1317 if Chars
(Arg
) /= No_Name
then
1318 Error_Pragma_Arg_Ident
1319 ("pragma% does not permit identifier& here", Arg
);
1321 end Check_No_Identifier
;
1323 --------------------------
1324 -- Check_No_Identifiers --
1325 --------------------------
1327 procedure Check_No_Identifiers
is
1330 if Arg_Count
> 0 then
1332 while Present
(Arg_Node
) loop
1333 Check_No_Identifier
(Arg_Node
);
1337 end Check_No_Identifiers
;
1339 -------------------------------
1340 -- Check_Optional_Identifier --
1341 -------------------------------
1343 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
) is
1345 if Present
(Arg
) and then Chars
(Arg
) /= No_Name
then
1346 if Chars
(Arg
) /= Id
then
1347 Error_Msg_Name_1
:= Pname
;
1348 Error_Msg_Name_2
:= Id
;
1349 Error_Msg_N
("pragma% argument expects identifier%", Arg
);
1353 end Check_Optional_Identifier
;
1355 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String) is
1357 Name_Buffer
(1 .. Id
'Length) := Id
;
1358 Name_Len
:= Id
'Length;
1359 Check_Optional_Identifier
(Arg
, Name_Find
);
1360 end Check_Optional_Identifier
;
1362 --------------------------------------
1363 -- Check_Precondition_Postcondition --
1364 --------------------------------------
1366 procedure Check_Precondition_Postcondition
(In_Body
: out Boolean) is
1370 procedure Chain_PPC
(PO
: Node_Id
);
1371 -- If PO is a subprogram declaration node (or a generic subprogram
1372 -- declaration node), then the precondition/postcondition applies
1373 -- to this subprogram and the processing for the pragma is completed.
1374 -- Otherwise the pragma is misplaced.
1380 procedure Chain_PPC
(PO
: Node_Id
) is
1384 if not Nkind_In
(PO
, N_Subprogram_Declaration
,
1385 N_Generic_Subprogram_Declaration
)
1390 -- Here if we have subprogram or generic subprogram declaration
1392 S
:= Defining_Unit_Name
(Specification
(PO
));
1394 -- Analyze the pragma unless it appears within a package spec,
1395 -- which is the case where we delay the analysis of the PPC until
1396 -- the end of the package declarations (for details, see
1397 -- Analyze_Package_Specification.Analyze_PPCs).
1399 if not Is_Package_Or_Generic_Package
(Scope
(S
)) then
1400 Analyze_PPC_In_Decl_Part
(N
, S
);
1403 -- Chain spec PPC pragma to list for subprogram
1405 Set_Next_Pragma
(N
, Spec_PPC_List
(S
));
1406 Set_Spec_PPC_List
(S
, N
);
1408 -- Return indicating spec case
1414 -- Start of processing for Check_Precondition_Postcondition
1417 if not Is_List_Member
(N
) then
1421 -- Record whether pragma is enabled
1423 Set_PPC_Enabled
(N
, Check_Enabled
(Pname
));
1425 -- If we are within an inlined body, the legality of the pragma
1426 -- has been checked already.
1428 if In_Inlined_Body
then
1433 -- Search prior declarations
1436 while Present
(Prev
(P
)) loop
1439 -- If the previous node is a generic subprogram, do not go to to
1440 -- the original node, which is the unanalyzed tree: we need to
1441 -- attach the pre/postconditions to the analyzed version at this
1442 -- point. They get propagated to the original tree when analyzing
1443 -- the corresponding body.
1445 if Nkind
(P
) not in N_Generic_Declaration
then
1446 PO
:= Original_Node
(P
);
1451 -- Skip past prior pragma
1453 if Nkind
(PO
) = N_Pragma
then
1456 -- Skip stuff not coming from source
1458 elsif not Comes_From_Source
(PO
) then
1461 -- Only remaining possibility is subprogram declaration
1469 -- If we fall through loop, pragma is at start of list, so see if it
1470 -- is at the start of declarations of a subprogram body.
1472 if Nkind
(Parent
(N
)) = N_Subprogram_Body
1473 and then List_Containing
(N
) = Declarations
(Parent
(N
))
1475 if Operating_Mode
/= Generate_Code
1476 or else Inside_A_Generic
1479 -- Analyze expression in pragma, for correctness
1480 -- and for ASIS use.
1482 Preanalyze_Spec_Expression
1483 (Get_Pragma_Arg
(Arg1
), Standard_Boolean
);
1489 -- See if it is in the pragmas after a library level subprogram
1491 elsif Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
1492 Chain_PPC
(Unit
(Parent
(Parent
(N
))));
1496 -- If we fall through, pragma was misplaced
1499 end Check_Precondition_Postcondition
;
1501 -----------------------------
1502 -- Check_Static_Constraint --
1503 -----------------------------
1505 -- Note: for convenience in writing this procedure, in addition to
1506 -- the officially (i.e. by spec) allowed argument which is always a
1507 -- constraint, it also allows ranges and discriminant associations.
1508 -- Above is not clear ???
1510 procedure Check_Static_Constraint
(Constr
: Node_Id
) is
1512 procedure Require_Static
(E
: Node_Id
);
1513 -- Require given expression to be static expression
1515 --------------------
1516 -- Require_Static --
1517 --------------------
1519 procedure Require_Static
(E
: Node_Id
) is
1521 if not Is_OK_Static_Expression
(E
) then
1522 Flag_Non_Static_Expr
1523 ("non-static constraint not allowed in Unchecked_Union!", E
);
1528 -- Start of processing for Check_Static_Constraint
1531 case Nkind
(Constr
) is
1532 when N_Discriminant_Association
=>
1533 Require_Static
(Expression
(Constr
));
1536 Require_Static
(Low_Bound
(Constr
));
1537 Require_Static
(High_Bound
(Constr
));
1539 when N_Attribute_Reference
=>
1540 Require_Static
(Type_Low_Bound
(Etype
(Prefix
(Constr
))));
1541 Require_Static
(Type_High_Bound
(Etype
(Prefix
(Constr
))));
1543 when N_Range_Constraint
=>
1544 Check_Static_Constraint
(Range_Expression
(Constr
));
1546 when N_Index_Or_Discriminant_Constraint
=>
1550 IDC
:= First
(Constraints
(Constr
));
1551 while Present
(IDC
) loop
1552 Check_Static_Constraint
(IDC
);
1560 end Check_Static_Constraint
;
1562 --------------------------------------
1563 -- Check_Valid_Configuration_Pragma --
1564 --------------------------------------
1566 -- A configuration pragma must appear in the context clause of a
1567 -- compilation unit, and only other pragmas may precede it. Note that
1568 -- the test also allows use in a configuration pragma file.
1570 procedure Check_Valid_Configuration_Pragma
is
1572 if not Is_Configuration_Pragma
then
1573 Error_Pragma
("incorrect placement for configuration pragma%");
1575 end Check_Valid_Configuration_Pragma
;
1577 -------------------------------------
1578 -- Check_Valid_Library_Unit_Pragma --
1579 -------------------------------------
1581 procedure Check_Valid_Library_Unit_Pragma
is
1583 Parent_Node
: Node_Id
;
1584 Unit_Name
: Entity_Id
;
1585 Unit_Kind
: Node_Kind
;
1586 Unit_Node
: Node_Id
;
1587 Sindex
: Source_File_Index
;
1590 if not Is_List_Member
(N
) then
1594 Plist
:= List_Containing
(N
);
1595 Parent_Node
:= Parent
(Plist
);
1597 if Parent_Node
= Empty
then
1600 -- Case of pragma appearing after a compilation unit. In this case
1601 -- it must have an argument with the corresponding name and must
1602 -- be part of the following pragmas of its parent.
1604 elsif Nkind
(Parent_Node
) = N_Compilation_Unit_Aux
then
1605 if Plist
/= Pragmas_After
(Parent_Node
) then
1608 elsif Arg_Count
= 0 then
1610 ("argument required if outside compilation unit");
1613 Check_No_Identifiers
;
1614 Check_Arg_Count
(1);
1615 Unit_Node
:= Unit
(Parent
(Parent_Node
));
1616 Unit_Kind
:= Nkind
(Unit_Node
);
1618 Analyze
(Expression
(Arg1
));
1620 if Unit_Kind
= N_Generic_Subprogram_Declaration
1621 or else Unit_Kind
= N_Subprogram_Declaration
1623 Unit_Name
:= Defining_Entity
(Unit_Node
);
1625 elsif Unit_Kind
in N_Generic_Instantiation
then
1626 Unit_Name
:= Defining_Entity
(Unit_Node
);
1629 Unit_Name
:= Cunit_Entity
(Current_Sem_Unit
);
1632 if Chars
(Unit_Name
) /=
1633 Chars
(Entity
(Expression
(Arg1
)))
1636 ("pragma% argument is not current unit name", Arg1
);
1639 if Ekind
(Unit_Name
) = E_Package
1640 and then Present
(Renamed_Entity
(Unit_Name
))
1642 Error_Pragma
("pragma% not allowed for renamed package");
1646 -- Pragma appears other than after a compilation unit
1649 -- Here we check for the generic instantiation case and also
1650 -- for the case of processing a generic formal package. We
1651 -- detect these cases by noting that the Sloc on the node
1652 -- does not belong to the current compilation unit.
1654 Sindex
:= Source_Index
(Current_Sem_Unit
);
1656 if Loc
not in Source_First
(Sindex
) .. Source_Last
(Sindex
) then
1657 Rewrite
(N
, Make_Null_Statement
(Loc
));
1660 -- If before first declaration, the pragma applies to the
1661 -- enclosing unit, and the name if present must be this name.
1663 elsif Is_Before_First_Decl
(N
, Plist
) then
1664 Unit_Node
:= Unit_Declaration_Node
(Current_Scope
);
1665 Unit_Kind
:= Nkind
(Unit_Node
);
1667 if Nkind
(Parent
(Unit_Node
)) /= N_Compilation_Unit
then
1670 elsif Unit_Kind
= N_Subprogram_Body
1671 and then not Acts_As_Spec
(Unit_Node
)
1675 elsif Nkind
(Parent_Node
) = N_Package_Body
then
1678 elsif Nkind
(Parent_Node
) = N_Package_Specification
1679 and then Plist
= Private_Declarations
(Parent_Node
)
1683 elsif (Nkind
(Parent_Node
) = N_Generic_Package_Declaration
1684 or else Nkind
(Parent_Node
) =
1685 N_Generic_Subprogram_Declaration
)
1686 and then Plist
= Generic_Formal_Declarations
(Parent_Node
)
1690 elsif Arg_Count
> 0 then
1691 Analyze
(Expression
(Arg1
));
1693 if Entity
(Expression
(Arg1
)) /= Current_Scope
then
1695 ("name in pragma% must be enclosing unit", Arg1
);
1698 -- It is legal to have no argument in this context
1704 -- Error if not before first declaration. This is because a
1705 -- library unit pragma argument must be the name of a library
1706 -- unit (RM 10.1.5(7)), but the only names permitted in this
1707 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1708 -- generic subprogram declarations or generic instantiations.
1712 ("pragma% misplaced, must be before first declaration");
1716 end Check_Valid_Library_Unit_Pragma
;
1722 procedure Check_Variant
(Variant
: Node_Id
) is
1723 Clist
: constant Node_Id
:= Component_List
(Variant
);
1727 if not Is_Non_Empty_List
(Component_Items
(Clist
)) then
1729 ("Unchecked_Union may not have empty component list",
1734 Comp
:= First
(Component_Items
(Clist
));
1735 while Present
(Comp
) loop
1736 Check_Component
(Comp
);
1745 procedure Error_Pragma
(Msg
: String) is
1747 Error_Msg_Name_1
:= Pname
;
1748 Error_Msg_N
(Msg
, N
);
1752 ----------------------
1753 -- Error_Pragma_Arg --
1754 ----------------------
1756 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
) is
1758 Error_Msg_Name_1
:= Pname
;
1759 Error_Msg_N
(Msg
, Get_Pragma_Arg
(Arg
));
1761 end Error_Pragma_Arg
;
1763 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
) is
1765 Error_Msg_Name_1
:= Pname
;
1766 Error_Msg_N
(Msg1
, Get_Pragma_Arg
(Arg
));
1767 Error_Pragma_Arg
(Msg2
, Arg
);
1768 end Error_Pragma_Arg
;
1770 ----------------------------
1771 -- Error_Pragma_Arg_Ident --
1772 ----------------------------
1774 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
) is
1776 Error_Msg_Name_1
:= Pname
;
1777 Error_Msg_N
(Msg
, Arg
);
1779 end Error_Pragma_Arg_Ident
;
1781 ----------------------
1782 -- Error_Pragma_Ref --
1783 ----------------------
1785 procedure Error_Pragma_Ref
(Msg
: String; Ref
: Entity_Id
) is
1787 Error_Msg_Name_1
:= Pname
;
1788 Error_Msg_Sloc
:= Sloc
(Ref
);
1789 Error_Msg_NE
(Msg
, N
, Ref
);
1791 end Error_Pragma_Ref
;
1793 ------------------------
1794 -- Find_Lib_Unit_Name --
1795 ------------------------
1797 function Find_Lib_Unit_Name
return Entity_Id
is
1799 -- Return inner compilation unit entity, for case of nested
1800 -- categorization pragmas. This happens in generic unit.
1802 if Nkind
(Parent
(N
)) = N_Package_Specification
1803 and then Defining_Entity
(Parent
(N
)) /= Current_Scope
1805 return Defining_Entity
(Parent
(N
));
1807 return Current_Scope
;
1809 end Find_Lib_Unit_Name
;
1811 ----------------------------
1812 -- Find_Program_Unit_Name --
1813 ----------------------------
1815 procedure Find_Program_Unit_Name
(Id
: Node_Id
) is
1816 Unit_Name
: Entity_Id
;
1817 Unit_Kind
: Node_Kind
;
1818 P
: constant Node_Id
:= Parent
(N
);
1821 if Nkind
(P
) = N_Compilation_Unit
then
1822 Unit_Kind
:= Nkind
(Unit
(P
));
1824 if Unit_Kind
= N_Subprogram_Declaration
1825 or else Unit_Kind
= N_Package_Declaration
1826 or else Unit_Kind
in N_Generic_Declaration
1828 Unit_Name
:= Defining_Entity
(Unit
(P
));
1830 if Chars
(Id
) = Chars
(Unit_Name
) then
1831 Set_Entity
(Id
, Unit_Name
);
1832 Set_Etype
(Id
, Etype
(Unit_Name
));
1834 Set_Etype
(Id
, Any_Type
);
1836 ("cannot find program unit referenced by pragma%");
1840 Set_Etype
(Id
, Any_Type
);
1841 Error_Pragma
("pragma% inapplicable to this unit");
1847 end Find_Program_Unit_Name
;
1849 -----------------------------------------
1850 -- Find_Unique_Parameterless_Procedure --
1851 -----------------------------------------
1853 function Find_Unique_Parameterless_Procedure
1855 Arg
: Node_Id
) return Entity_Id
1857 Proc
: Entity_Id
:= Empty
;
1860 -- The body of this procedure needs some comments ???
1862 if not Is_Entity_Name
(Name
) then
1864 ("argument of pragma% must be entity name", Arg
);
1866 elsif not Is_Overloaded
(Name
) then
1867 Proc
:= Entity
(Name
);
1869 if Ekind
(Proc
) /= E_Procedure
1870 or else Present
(First_Formal
(Proc
)) then
1872 ("argument of pragma% must be parameterless procedure", Arg
);
1877 Found
: Boolean := False;
1879 Index
: Interp_Index
;
1882 Get_First_Interp
(Name
, Index
, It
);
1883 while Present
(It
.Nam
) loop
1886 if Ekind
(Proc
) = E_Procedure
1887 and then No
(First_Formal
(Proc
))
1891 Set_Entity
(Name
, Proc
);
1892 Set_Is_Overloaded
(Name
, False);
1895 ("ambiguous handler name for pragma% ", Arg
);
1899 Get_Next_Interp
(Index
, It
);
1904 ("argument of pragma% must be parameterless procedure",
1907 Proc
:= Entity
(Name
);
1913 end Find_Unique_Parameterless_Procedure
;
1915 -------------------------
1916 -- Gather_Associations --
1917 -------------------------
1919 procedure Gather_Associations
1921 Args
: out Args_List
)
1926 -- Initialize all parameters to Empty
1928 for J
in Args
'Range loop
1932 -- That's all we have to do if there are no argument associations
1934 if No
(Pragma_Argument_Associations
(N
)) then
1938 -- Otherwise first deal with any positional parameters present
1940 Arg
:= First
(Pragma_Argument_Associations
(N
));
1941 for Index
in Args
'Range loop
1942 exit when No
(Arg
) or else Chars
(Arg
) /= No_Name
;
1943 Args
(Index
) := Expression
(Arg
);
1947 -- Positional parameters all processed, if any left, then we
1948 -- have too many positional parameters.
1950 if Present
(Arg
) and then Chars
(Arg
) = No_Name
then
1952 ("too many positional associations for pragma%", Arg
);
1955 -- Process named parameters if any are present
1957 while Present
(Arg
) loop
1958 if Chars
(Arg
) = No_Name
then
1960 ("positional association cannot follow named association",
1964 for Index
in Names
'Range loop
1965 if Names
(Index
) = Chars
(Arg
) then
1966 if Present
(Args
(Index
)) then
1968 ("duplicate argument association for pragma%", Arg
);
1970 Args
(Index
) := Expression
(Arg
);
1975 if Index
= Names
'Last then
1976 Error_Msg_Name_1
:= Pname
;
1977 Error_Msg_N
("pragma% does not allow & argument", Arg
);
1979 -- Check for possible misspelling
1981 for Index1
in Names
'Range loop
1982 if Is_Bad_Spelling_Of
1983 (Chars
(Arg
), Names
(Index1
))
1985 Error_Msg_Name_1
:= Names
(Index1
);
1986 Error_Msg_N
-- CODEFIX
1987 ("\possible misspelling of%", Arg
);
1999 end Gather_Associations
;
2005 procedure GNAT_Pragma
is
2007 Check_Restriction
(No_Implementation_Pragmas
, N
);
2010 --------------------------
2011 -- Is_Before_First_Decl --
2012 --------------------------
2014 function Is_Before_First_Decl
2015 (Pragma_Node
: Node_Id
;
2016 Decls
: List_Id
) return Boolean
2018 Item
: Node_Id
:= First
(Decls
);
2021 -- Only other pragmas can come before this pragma
2024 if No
(Item
) or else Nkind
(Item
) /= N_Pragma
then
2027 elsif Item
= Pragma_Node
then
2033 end Is_Before_First_Decl
;
2035 -----------------------------
2036 -- Is_Configuration_Pragma --
2037 -----------------------------
2039 -- A configuration pragma must appear in the context clause of a
2040 -- compilation unit, and only other pragmas may precede it. Note that
2041 -- the test below also permits use in a configuration pragma file.
2043 function Is_Configuration_Pragma
return Boolean is
2044 Lis
: constant List_Id
:= List_Containing
(N
);
2045 Par
: constant Node_Id
:= Parent
(N
);
2049 -- If no parent, then we are in the configuration pragma file,
2050 -- so the placement is definitely appropriate.
2055 -- Otherwise we must be in the context clause of a compilation unit
2056 -- and the only thing allowed before us in the context list is more
2057 -- configuration pragmas.
2059 elsif Nkind
(Par
) = N_Compilation_Unit
2060 and then Context_Items
(Par
) = Lis
2067 elsif Nkind
(Prg
) /= N_Pragma
then
2077 end Is_Configuration_Pragma
;
2079 --------------------------
2080 -- Is_In_Context_Clause --
2081 --------------------------
2083 function Is_In_Context_Clause
return Boolean is
2085 Parent_Node
: Node_Id
;
2088 if not Is_List_Member
(N
) then
2092 Plist
:= List_Containing
(N
);
2093 Parent_Node
:= Parent
(Plist
);
2095 if Parent_Node
= Empty
2096 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
2097 or else Context_Items
(Parent_Node
) /= Plist
2104 end Is_In_Context_Clause
;
2106 ---------------------------------
2107 -- Is_Static_String_Expression --
2108 ---------------------------------
2110 function Is_Static_String_Expression
(Arg
: Node_Id
) return Boolean is
2111 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
2114 Analyze_And_Resolve
(Argx
);
2115 return Is_OK_Static_Expression
(Argx
)
2116 and then Nkind
(Argx
) = N_String_Literal
;
2117 end Is_Static_String_Expression
;
2119 ----------------------
2120 -- Pragma_Misplaced --
2121 ----------------------
2123 procedure Pragma_Misplaced
is
2125 Error_Pragma
("incorrect placement of pragma%");
2126 end Pragma_Misplaced
;
2128 ------------------------------------
2129 -- Process Atomic_Shared_Volatile --
2130 ------------------------------------
2132 procedure Process_Atomic_Shared_Volatile
is
2139 procedure Set_Atomic
(E
: Entity_Id
);
2140 -- Set given type as atomic, and if no explicit alignment was given,
2141 -- set alignment to unknown, since back end knows what the alignment
2142 -- requirements are for atomic arrays. Note: this step is necessary
2143 -- for derived types.
2149 procedure Set_Atomic
(E
: Entity_Id
) is
2153 if not Has_Alignment_Clause
(E
) then
2154 Set_Alignment
(E
, Uint_0
);
2158 -- Start of processing for Process_Atomic_Shared_Volatile
2161 Check_Ada_83_Warning
;
2162 Check_No_Identifiers
;
2163 Check_Arg_Count
(1);
2164 Check_Arg_Is_Local_Name
(Arg1
);
2165 E_Id
:= Expression
(Arg1
);
2167 if Etype
(E_Id
) = Any_Type
then
2172 D
:= Declaration_Node
(E
);
2176 if Rep_Item_Too_Early
(E
, N
)
2178 Rep_Item_Too_Late
(E
, N
)
2182 Check_First_Subtype
(Arg1
);
2185 if Prag_Id
/= Pragma_Volatile
then
2187 Set_Atomic
(Underlying_Type
(E
));
2188 Set_Atomic
(Base_Type
(E
));
2191 -- Attribute belongs on the base type. If the view of the type is
2192 -- currently private, it also belongs on the underlying type.
2194 Set_Is_Volatile
(Base_Type
(E
));
2195 Set_Is_Volatile
(Underlying_Type
(E
));
2197 Set_Treat_As_Volatile
(E
);
2198 Set_Treat_As_Volatile
(Underlying_Type
(E
));
2200 elsif K
= N_Object_Declaration
2201 or else (K
= N_Component_Declaration
2202 and then Original_Record_Component
(E
) = E
)
2204 if Rep_Item_Too_Late
(E
, N
) then
2208 if Prag_Id
/= Pragma_Volatile
then
2211 -- If the object declaration has an explicit initialization, a
2212 -- temporary may have to be created to hold the expression, to
2213 -- ensure that access to the object remain atomic.
2215 if Nkind
(Parent
(E
)) = N_Object_Declaration
2216 and then Present
(Expression
(Parent
(E
)))
2218 Set_Has_Delayed_Freeze
(E
);
2221 -- An interesting improvement here. If an object of type X is
2222 -- declared atomic, and the type X is not atomic, that's a
2223 -- pity, since it may not have appropriate alignment etc. We
2224 -- can rescue this in the special case where the object and
2225 -- type are in the same unit by just setting the type as
2226 -- atomic, so that the back end will process it as atomic.
2228 Utyp
:= Underlying_Type
(Etype
(E
));
2231 and then Sloc
(E
) > No_Location
2232 and then Sloc
(Utyp
) > No_Location
2234 Get_Source_File_Index
(Sloc
(E
)) =
2235 Get_Source_File_Index
(Sloc
(Underlying_Type
(Etype
(E
))))
2237 Set_Is_Atomic
(Underlying_Type
(Etype
(E
)));
2241 Set_Is_Volatile
(E
);
2242 Set_Treat_As_Volatile
(E
);
2246 ("inappropriate entity for pragma%", Arg1
);
2248 end Process_Atomic_Shared_Volatile
;
2250 -------------------------------------------
2251 -- Process_Compile_Time_Warning_Or_Error --
2252 -------------------------------------------
2254 procedure Process_Compile_Time_Warning_Or_Error
is
2255 Arg1x
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
2258 Check_Arg_Count
(2);
2259 Check_No_Identifiers
;
2260 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
2261 Analyze_And_Resolve
(Arg1x
, Standard_Boolean
);
2263 if Compile_Time_Known_Value
(Arg1x
) then
2264 if Is_True
(Expr_Value
(Get_Pragma_Arg
(Arg1
))) then
2266 Str
: constant String_Id
:=
2267 Strval
(Get_Pragma_Arg
(Arg2
));
2268 Len
: constant Int
:= String_Length
(Str
);
2273 Cent
: constant Entity_Id
:=
2274 Cunit_Entity
(Current_Sem_Unit
);
2276 Force
: constant Boolean :=
2277 Prag_Id
= Pragma_Compile_Time_Warning
2279 Is_Spec_Name
(Unit_Name
(Current_Sem_Unit
))
2280 and then (Ekind
(Cent
) /= E_Package
2281 or else not In_Private_Part
(Cent
));
2282 -- Set True if this is the warning case, and we are in the
2283 -- visible part of a package spec, or in a subprogram spec,
2284 -- in which case we want to force the client to see the
2285 -- warning, even though it is not in the main unit.
2288 -- Loop through segments of message separated by line feeds.
2289 -- We output these segments as separate messages with
2290 -- continuation marks for all but the first.
2295 Error_Msg_Strlen
:= 0;
2297 -- Loop to copy characters from argument to error message
2301 exit when Ptr
> Len
;
2302 CC
:= Get_String_Char
(Str
, Ptr
);
2305 -- Ignore wide chars ??? else store character
2307 if In_Character_Range
(CC
) then
2308 C
:= Get_Character
(CC
);
2309 exit when C
= ASCII
.LF
;
2310 Error_Msg_Strlen
:= Error_Msg_Strlen
+ 1;
2311 Error_Msg_String
(Error_Msg_Strlen
) := C
;
2315 -- Here with one line ready to go
2317 Error_Msg_Warn
:= Prag_Id
= Pragma_Compile_Time_Warning
;
2319 -- If this is a warning in a spec, then we want clients
2320 -- to see the warning, so mark the message with the
2321 -- special sequence !! to force the warning. In the case
2322 -- of a package spec, we do not force this if we are in
2323 -- the private part of the spec.
2326 if Cont
= False then
2327 Error_Msg_N
("<~!!", Arg1
);
2330 Error_Msg_N
("\<~!!", Arg1
);
2333 -- Error, rather than warning, or in a body, so we do not
2334 -- need to force visibility for client (error will be
2335 -- output in any case, and this is the situation in which
2336 -- we do not want a client to get a warning, since the
2337 -- warning is in the body or the spec private part.
2340 if Cont
= False then
2341 Error_Msg_N
("<~", Arg1
);
2344 Error_Msg_N
("\<~", Arg1
);
2348 exit when Ptr
> Len
;
2353 end Process_Compile_Time_Warning_Or_Error
;
2355 ------------------------
2356 -- Process_Convention --
2357 ------------------------
2359 procedure Process_Convention
2360 (C
: out Convention_Id
;
2361 Ent
: out Entity_Id
)
2367 Comp_Unit
: Unit_Number_Type
;
2369 procedure Set_Convention_From_Pragma
(E
: Entity_Id
);
2370 -- Set convention in entity E, and also flag that the entity has a
2371 -- convention pragma. If entity is for a private or incomplete type,
2372 -- also set convention and flag on underlying type. This procedure
2373 -- also deals with the special case of C_Pass_By_Copy convention.
2375 --------------------------------
2376 -- Set_Convention_From_Pragma --
2377 --------------------------------
2379 procedure Set_Convention_From_Pragma
(E
: Entity_Id
) is
2381 -- Ada 2005 (AI-430): Check invalid attempt to change convention
2382 -- for an overridden dispatching operation. Technically this is
2383 -- an amendment and should only be done in Ada 2005 mode. However,
2384 -- this is clearly a mistake, since the problem that is addressed
2385 -- by this AI is that there is a clear gap in the RM!
2387 if Is_Dispatching_Operation
(E
)
2388 and then Present
(Overridden_Operation
(E
))
2389 and then C
/= Convention
(Overridden_Operation
(E
))
2392 ("cannot change convention for " &
2393 "overridden dispatching operation",
2397 -- Set the convention
2399 Set_Convention
(E
, C
);
2400 Set_Has_Convention_Pragma
(E
);
2402 if Is_Incomplete_Or_Private_Type
(E
) then
2403 Set_Convention
(Underlying_Type
(E
), C
);
2404 Set_Has_Convention_Pragma
(Underlying_Type
(E
), True);
2407 -- A class-wide type should inherit the convention of the specific
2408 -- root type (although this isn't specified clearly by the RM).
2410 if Is_Type
(E
) and then Present
(Class_Wide_Type
(E
)) then
2411 Set_Convention
(Class_Wide_Type
(E
), C
);
2414 -- If the entity is a record type, then check for special case of
2415 -- C_Pass_By_Copy, which is treated the same as C except that the
2416 -- special record flag is set. This convention is only permitted
2417 -- on record types (see AI95-00131).
2419 if Cname
= Name_C_Pass_By_Copy
then
2420 if Is_Record_Type
(E
) then
2421 Set_C_Pass_By_Copy
(Base_Type
(E
));
2422 elsif Is_Incomplete_Or_Private_Type
(E
)
2423 and then Is_Record_Type
(Underlying_Type
(E
))
2425 Set_C_Pass_By_Copy
(Base_Type
(Underlying_Type
(E
)));
2428 ("C_Pass_By_Copy convention allowed only for record type",
2433 -- If the entity is a derived boolean type, check for the special
2434 -- case of convention C, C++, or Fortran, where we consider any
2435 -- nonzero value to represent true.
2437 if Is_Discrete_Type
(E
)
2438 and then Root_Type
(Etype
(E
)) = Standard_Boolean
2444 C
= Convention_Fortran
)
2446 Set_Nonzero_Is_True
(Base_Type
(E
));
2448 end Set_Convention_From_Pragma
;
2450 -- Start of processing for Process_Convention
2453 Check_At_Least_N_Arguments
(2);
2454 Check_Optional_Identifier
(Arg1
, Name_Convention
);
2455 Check_Arg_Is_Identifier
(Arg1
);
2456 Cname
:= Chars
(Expression
(Arg1
));
2458 -- C_Pass_By_Copy is treated as a synonym for convention C (this is
2459 -- tested again below to set the critical flag).
2460 if Cname
= Name_C_Pass_By_Copy
then
2463 -- Otherwise we must have something in the standard convention list
2465 elsif Is_Convention_Name
(Cname
) then
2466 C
:= Get_Convention_Id
(Chars
(Expression
(Arg1
)));
2468 -- In DEC VMS, it seems that there is an undocumented feature that
2469 -- any unrecognized convention is treated as the default, which for
2470 -- us is convention C. It does not seem so terrible to do this
2471 -- unconditionally, silently in the VMS case, and with a warning
2472 -- in the non-VMS case.
2475 if Warn_On_Export_Import
and not OpenVMS_On_Target
then
2477 ("?unrecognized convention name, C assumed",
2484 Check_Optional_Identifier
(Arg2
, Name_Entity
);
2485 Check_Arg_Is_Local_Name
(Arg2
);
2487 Id
:= Expression
(Arg2
);
2490 if not Is_Entity_Name
(Id
) then
2491 Error_Pragma_Arg
("entity name required", Arg2
);
2496 -- Set entity to return
2500 -- Go to renamed subprogram if present, since convention applies to
2501 -- the actual renamed entity, not to the renaming entity. If the
2502 -- subprogram is inherited, go to parent subprogram.
2504 if Is_Subprogram
(E
)
2505 and then Present
(Alias
(E
))
2507 if Nkind
(Parent
(Declaration_Node
(E
))) =
2508 N_Subprogram_Renaming_Declaration
2510 if Scope
(E
) /= Scope
(Alias
(E
)) then
2512 ("cannot apply pragma% to non-local entity&#", E
);
2517 elsif Nkind_In
(Parent
(E
), N_Full_Type_Declaration
,
2518 N_Private_Extension_Declaration
)
2519 and then Scope
(E
) = Scope
(Alias
(E
))
2523 -- Return the parent subprogram the entity was inherited from
2529 -- Check that we are not applying this to a specless body
2531 if Is_Subprogram
(E
)
2532 and then Nkind
(Parent
(Declaration_Node
(E
))) = N_Subprogram_Body
2535 ("pragma% requires separate spec and must come before body");
2538 -- Check that we are not applying this to a named constant
2540 if Ekind
(E
) = E_Named_Integer
2542 Ekind
(E
) = E_Named_Real
2544 Error_Msg_Name_1
:= Pname
;
2546 ("cannot apply pragma% to named constant!",
2547 Get_Pragma_Arg
(Arg2
));
2549 ("\supply appropriate type for&!", Arg2
);
2552 if Ekind
(E
) = E_Enumeration_Literal
then
2553 Error_Pragma
("enumeration literal not allowed for pragma%");
2556 -- Check for rep item appearing too early or too late
2558 if Etype
(E
) = Any_Type
2559 or else Rep_Item_Too_Early
(E
, N
)
2563 E
:= Underlying_Type
(E
);
2566 if Rep_Item_Too_Late
(E
, N
) then
2570 if Has_Convention_Pragma
(E
) then
2572 ("at most one Convention/Export/Import pragma is allowed", Arg2
);
2574 elsif Convention
(E
) = Convention_Protected
2575 or else Ekind
(Scope
(E
)) = E_Protected_Type
2578 ("a protected operation cannot be given a different convention",
2582 -- For Intrinsic, a subprogram is required
2584 if C
= Convention_Intrinsic
2585 and then not Is_Subprogram
(E
)
2586 and then not Is_Generic_Subprogram
(E
)
2589 ("second argument of pragma% must be a subprogram", Arg2
);
2592 -- For Stdcall, a subprogram, variable or subprogram type is required
2594 if C
= Convention_Stdcall
2595 and then not Is_Subprogram
(E
)
2596 and then not Is_Generic_Subprogram
(E
)
2597 and then Ekind
(E
) /= E_Variable
2600 and then Ekind
(Designated_Type
(E
)) = E_Subprogram_Type
)
2603 ("second argument of pragma% must be subprogram (type)",
2607 if not Is_Subprogram
(E
)
2608 and then not Is_Generic_Subprogram
(E
)
2610 Set_Convention_From_Pragma
(E
);
2614 Check_First_Subtype
(Arg2
);
2615 Set_Convention_From_Pragma
(Base_Type
(E
));
2617 -- For subprograms, we must set the convention on the
2618 -- internally generated directly designated type as well.
2620 if Ekind
(E
) = E_Access_Subprogram_Type
then
2621 Set_Convention_From_Pragma
(Directly_Designated_Type
(E
));
2625 -- For the subprogram case, set proper convention for all homonyms
2626 -- in same scope and the same declarative part, i.e. the same
2627 -- compilation unit.
2630 Comp_Unit
:= Get_Source_Unit
(E
);
2631 Set_Convention_From_Pragma
(E
);
2633 -- Treat a pragma Import as an implicit body, for GPS use
2635 if Prag_Id
= Pragma_Import
then
2636 Generate_Reference
(E
, Id
, 'b');
2639 -- Loop through the homonyms of the pragma argument's entity
2644 exit when No
(E1
) or else Scope
(E1
) /= Current_Scope
;
2646 -- Do not set the pragma on inherited operations or on formal
2649 if Comes_From_Source
(E1
)
2650 and then Comp_Unit
= Get_Source_Unit
(E1
)
2651 and then not Is_Formal_Subprogram
(E1
)
2652 and then Nkind
(Original_Node
(Parent
(E1
))) /=
2653 N_Full_Type_Declaration
2655 if Present
(Alias
(E1
))
2656 and then Scope
(E1
) /= Scope
(Alias
(E1
))
2659 ("cannot apply pragma% to non-local entity& declared#",
2663 Set_Convention_From_Pragma
(E1
);
2665 if Prag_Id
= Pragma_Import
then
2666 Generate_Reference
(E1
, Id
, 'b');
2671 end Process_Convention
;
2673 -----------------------------------------------------
2674 -- Process_Extended_Import_Export_Exception_Pragma --
2675 -----------------------------------------------------
2677 procedure Process_Extended_Import_Export_Exception_Pragma
2678 (Arg_Internal
: Node_Id
;
2679 Arg_External
: Node_Id
;
2687 if not OpenVMS_On_Target
then
2689 ("?pragma% ignored (applies only to Open'V'M'S)");
2692 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2693 Def_Id
:= Entity
(Arg_Internal
);
2695 if Ekind
(Def_Id
) /= E_Exception
then
2697 ("pragma% must refer to declared exception", Arg_Internal
);
2700 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2702 if Present
(Arg_Form
) then
2703 Check_Arg_Is_One_Of
(Arg_Form
, Name_Ada
, Name_VMS
);
2706 if Present
(Arg_Form
)
2707 and then Chars
(Arg_Form
) = Name_Ada
2711 Set_Is_VMS_Exception
(Def_Id
);
2712 Set_Exception_Code
(Def_Id
, No_Uint
);
2715 if Present
(Arg_Code
) then
2716 if not Is_VMS_Exception
(Def_Id
) then
2718 ("Code option for pragma% not allowed for Ada case",
2722 Check_Arg_Is_Static_Expression
(Arg_Code
, Any_Integer
);
2723 Code_Val
:= Expr_Value
(Arg_Code
);
2725 if not UI_Is_In_Int_Range
(Code_Val
) then
2727 ("Code option for pragma% must be in 32-bit range",
2731 Set_Exception_Code
(Def_Id
, Code_Val
);
2734 end Process_Extended_Import_Export_Exception_Pragma
;
2736 -------------------------------------------------
2737 -- Process_Extended_Import_Export_Internal_Arg --
2738 -------------------------------------------------
2740 procedure Process_Extended_Import_Export_Internal_Arg
2741 (Arg_Internal
: Node_Id
:= Empty
)
2744 if No
(Arg_Internal
) then
2745 Error_Pragma
("Internal parameter required for pragma%");
2748 if Nkind
(Arg_Internal
) = N_Identifier
then
2751 elsif Nkind
(Arg_Internal
) = N_Operator_Symbol
2752 and then (Prag_Id
= Pragma_Import_Function
2754 Prag_Id
= Pragma_Export_Function
)
2760 ("wrong form for Internal parameter for pragma%", Arg_Internal
);
2763 Check_Arg_Is_Local_Name
(Arg_Internal
);
2764 end Process_Extended_Import_Export_Internal_Arg
;
2766 --------------------------------------------------
2767 -- Process_Extended_Import_Export_Object_Pragma --
2768 --------------------------------------------------
2770 procedure Process_Extended_Import_Export_Object_Pragma
2771 (Arg_Internal
: Node_Id
;
2772 Arg_External
: Node_Id
;
2778 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2779 Def_Id
:= Entity
(Arg_Internal
);
2781 if Ekind
(Def_Id
) /= E_Constant
2782 and then Ekind
(Def_Id
) /= E_Variable
2785 ("pragma% must designate an object", Arg_Internal
);
2788 if Has_Rep_Pragma
(Def_Id
, Name_Common_Object
)
2790 Has_Rep_Pragma
(Def_Id
, Name_Psect_Object
)
2793 ("previous Common/Psect_Object applies, pragma % not permitted",
2797 if Rep_Item_Too_Late
(Def_Id
, N
) then
2801 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
2803 if Present
(Arg_Size
) then
2804 Check_Arg_Is_External_Name
(Arg_Size
);
2807 -- Export_Object case
2809 if Prag_Id
= Pragma_Export_Object
then
2810 if not Is_Library_Level_Entity
(Def_Id
) then
2812 ("argument for pragma% must be library level entity",
2816 if Ekind
(Current_Scope
) = E_Generic_Package
then
2817 Error_Pragma
("pragma& cannot appear in a generic unit");
2820 if not Size_Known_At_Compile_Time
(Etype
(Def_Id
)) then
2822 ("exported object must have compile time known size",
2826 if Warn_On_Export_Import
and then Is_Exported
(Def_Id
) then
2827 Error_Msg_N
("?duplicate Export_Object pragma", N
);
2829 Set_Exported
(Def_Id
, Arg_Internal
);
2832 -- Import_Object case
2835 if Is_Concurrent_Type
(Etype
(Def_Id
)) then
2837 ("cannot use pragma% for task/protected object",
2841 if Ekind
(Def_Id
) = E_Constant
then
2843 ("cannot import a constant", Arg_Internal
);
2846 if Warn_On_Export_Import
2847 and then Has_Discriminants
(Etype
(Def_Id
))
2850 ("imported value must be initialized?", Arg_Internal
);
2853 if Warn_On_Export_Import
2854 and then Is_Access_Type
(Etype
(Def_Id
))
2857 ("cannot import object of an access type?", Arg_Internal
);
2860 if Warn_On_Export_Import
2861 and then Is_Imported
(Def_Id
)
2864 ("?duplicate Import_Object pragma", N
);
2866 -- Check for explicit initialization present. Note that an
2867 -- initialization generated by the code generator, e.g. for an
2868 -- access type, does not count here.
2870 elsif Present
(Expression
(Parent
(Def_Id
)))
2873 (Original_Node
(Expression
(Parent
(Def_Id
))))
2875 Error_Msg_Sloc
:= Sloc
(Def_Id
);
2877 ("imported entities cannot be initialized (RM B.1(24))",
2878 "\no initialization allowed for & declared#", Arg1
);
2880 Set_Imported
(Def_Id
);
2881 Note_Possible_Modification
(Arg_Internal
, Sure
=> False);
2884 end Process_Extended_Import_Export_Object_Pragma
;
2886 ------------------------------------------------------
2887 -- Process_Extended_Import_Export_Subprogram_Pragma --
2888 ------------------------------------------------------
2890 procedure Process_Extended_Import_Export_Subprogram_Pragma
2891 (Arg_Internal
: Node_Id
;
2892 Arg_External
: Node_Id
;
2893 Arg_Parameter_Types
: Node_Id
;
2894 Arg_Result_Type
: Node_Id
:= Empty
;
2895 Arg_Mechanism
: Node_Id
;
2896 Arg_Result_Mechanism
: Node_Id
:= Empty
;
2897 Arg_First_Optional_Parameter
: Node_Id
:= Empty
)
2903 Ambiguous
: Boolean;
2907 function Same_Base_Type
2909 Formal
: Entity_Id
) return Boolean;
2910 -- Determines if Ptype references the type of Formal. Note that only
2911 -- the base types need to match according to the spec. Ptype here is
2912 -- the argument from the pragma, which is either a type name, or an
2913 -- access attribute.
2915 --------------------
2916 -- Same_Base_Type --
2917 --------------------
2919 function Same_Base_Type
2921 Formal
: Entity_Id
) return Boolean
2923 Ftyp
: constant Entity_Id
:= Base_Type
(Etype
(Formal
));
2927 -- Case where pragma argument is typ'Access
2929 if Nkind
(Ptype
) = N_Attribute_Reference
2930 and then Attribute_Name
(Ptype
) = Name_Access
2932 Pref
:= Prefix
(Ptype
);
2935 if not Is_Entity_Name
(Pref
)
2936 or else Entity
(Pref
) = Any_Type
2941 -- We have a match if the corresponding argument is of an
2942 -- anonymous access type, and its designated type matches the
2943 -- type of the prefix of the access attribute
2945 return Ekind
(Ftyp
) = E_Anonymous_Access_Type
2946 and then Base_Type
(Entity
(Pref
)) =
2947 Base_Type
(Etype
(Designated_Type
(Ftyp
)));
2949 -- Case where pragma argument is a type name
2954 if not Is_Entity_Name
(Ptype
)
2955 or else Entity
(Ptype
) = Any_Type
2960 -- We have a match if the corresponding argument is of the type
2961 -- given in the pragma (comparing base types)
2963 return Base_Type
(Entity
(Ptype
)) = Ftyp
;
2967 -- Start of processing for
2968 -- Process_Extended_Import_Export_Subprogram_Pragma
2971 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
2975 -- Loop through homonyms (overloadings) of the entity
2977 Hom_Id
:= Entity
(Arg_Internal
);
2978 while Present
(Hom_Id
) loop
2979 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
2981 -- We need a subprogram in the current scope
2983 if not Is_Subprogram
(Def_Id
)
2984 or else Scope
(Def_Id
) /= Current_Scope
2991 -- Pragma cannot apply to subprogram body
2993 if Is_Subprogram
(Def_Id
)
2994 and then Nkind
(Parent
(Declaration_Node
(Def_Id
))) =
2998 ("pragma% requires separate spec"
2999 & " and must come before body");
3002 -- Test result type if given, note that the result type
3003 -- parameter can only be present for the function cases.
3005 if Present
(Arg_Result_Type
)
3006 and then not Same_Base_Type
(Arg_Result_Type
, Def_Id
)
3010 elsif Etype
(Def_Id
) /= Standard_Void_Type
3012 (Pname
= Name_Export_Procedure
3014 Pname
= Name_Import_Procedure
)
3018 -- Test parameter types if given. Note that this parameter
3019 -- has not been analyzed (and must not be, since it is
3020 -- semantic nonsense), so we get it as the parser left it.
3022 elsif Present
(Arg_Parameter_Types
) then
3023 Check_Matching_Types
: declare
3028 Formal
:= First_Formal
(Def_Id
);
3030 if Nkind
(Arg_Parameter_Types
) = N_Null
then
3031 if Present
(Formal
) then
3035 -- A list of one type, e.g. (List) is parsed as
3036 -- a parenthesized expression.
3038 elsif Nkind
(Arg_Parameter_Types
) /= N_Aggregate
3039 and then Paren_Count
(Arg_Parameter_Types
) = 1
3042 or else Present
(Next_Formal
(Formal
))
3047 Same_Base_Type
(Arg_Parameter_Types
, Formal
);
3050 -- A list of more than one type is parsed as a aggregate
3052 elsif Nkind
(Arg_Parameter_Types
) = N_Aggregate
3053 and then Paren_Count
(Arg_Parameter_Types
) = 0
3055 Ptype
:= First
(Expressions
(Arg_Parameter_Types
));
3056 while Present
(Ptype
) or else Present
(Formal
) loop
3059 or else not Same_Base_Type
(Ptype
, Formal
)
3064 Next_Formal
(Formal
);
3069 -- Anything else is of the wrong form
3073 ("wrong form for Parameter_Types parameter",
3074 Arg_Parameter_Types
);
3076 end Check_Matching_Types
;
3079 -- Match is now False if the entry we found did not match
3080 -- either a supplied Parameter_Types or Result_Types argument
3086 -- Ambiguous case, the flag Ambiguous shows if we already
3087 -- detected this and output the initial messages.
3090 if not Ambiguous
then
3092 Error_Msg_Name_1
:= Pname
;
3094 ("pragma% does not uniquely identify subprogram!",
3096 Error_Msg_Sloc
:= Sloc
(Ent
);
3097 Error_Msg_N
("matching subprogram #!", N
);
3101 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3102 Error_Msg_N
("matching subprogram #!", N
);
3107 Hom_Id
:= Homonym
(Hom_Id
);
3110 -- See if we found an entry
3113 if not Ambiguous
then
3114 if Is_Generic_Subprogram
(Entity
(Arg_Internal
)) then
3116 ("pragma% cannot be given for generic subprogram");
3119 ("pragma% does not identify local subprogram");
3126 -- Import pragmas must be for imported entities
3128 if Prag_Id
= Pragma_Import_Function
3130 Prag_Id
= Pragma_Import_Procedure
3132 Prag_Id
= Pragma_Import_Valued_Procedure
3134 if not Is_Imported
(Ent
) then
3135 Error_Pragma
-- CODEFIX???
3136 ("pragma Import or Interface must precede pragma%");
3139 -- Here we have the Export case which can set the entity as exported
3141 -- But does not do so if the specified external name is null, since
3142 -- that is taken as a signal in DEC Ada 83 (with which we want to be
3143 -- compatible) to request no external name.
3145 elsif Nkind
(Arg_External
) = N_String_Literal
3146 and then String_Length
(Strval
(Arg_External
)) = 0
3150 -- In all other cases, set entity as exported
3153 Set_Exported
(Ent
, Arg_Internal
);
3156 -- Special processing for Valued_Procedure cases
3158 if Prag_Id
= Pragma_Import_Valued_Procedure
3160 Prag_Id
= Pragma_Export_Valued_Procedure
3162 Formal
:= First_Formal
(Ent
);
3165 Error_Pragma
("at least one parameter required for pragma%");
3167 elsif Ekind
(Formal
) /= E_Out_Parameter
then
3168 Error_Pragma
("first parameter must have mode out for pragma%");
3171 Set_Is_Valued_Procedure
(Ent
);
3175 Set_Extended_Import_Export_External_Name
(Ent
, Arg_External
);
3177 -- Process Result_Mechanism argument if present. We have already
3178 -- checked that this is only allowed for the function case.
3180 if Present
(Arg_Result_Mechanism
) then
3181 Set_Mechanism_Value
(Ent
, Arg_Result_Mechanism
);
3184 -- Process Mechanism parameter if present. Note that this parameter
3185 -- is not analyzed, and must not be analyzed since it is semantic
3186 -- nonsense, so we get it in exactly as the parser left it.
3188 if Present
(Arg_Mechanism
) then
3196 -- A single mechanism association without a formal parameter
3197 -- name is parsed as a parenthesized expression. All other
3198 -- cases are parsed as aggregates, so we rewrite the single
3199 -- parameter case as an aggregate for consistency.
3201 if Nkind
(Arg_Mechanism
) /= N_Aggregate
3202 and then Paren_Count
(Arg_Mechanism
) = 1
3204 Rewrite
(Arg_Mechanism
,
3205 Make_Aggregate
(Sloc
(Arg_Mechanism
),
3206 Expressions
=> New_List
(
3207 Relocate_Node
(Arg_Mechanism
))));
3210 -- Case of only mechanism name given, applies to all formals
3212 if Nkind
(Arg_Mechanism
) /= N_Aggregate
then
3213 Formal
:= First_Formal
(Ent
);
3214 while Present
(Formal
) loop
3215 Set_Mechanism_Value
(Formal
, Arg_Mechanism
);
3216 Next_Formal
(Formal
);
3219 -- Case of list of mechanism associations given
3222 if Null_Record_Present
(Arg_Mechanism
) then
3224 ("inappropriate form for Mechanism parameter",
3228 -- Deal with positional ones first
3230 Formal
:= First_Formal
(Ent
);
3232 if Present
(Expressions
(Arg_Mechanism
)) then
3233 Mname
:= First
(Expressions
(Arg_Mechanism
));
3234 while Present
(Mname
) loop
3237 ("too many mechanism associations", Mname
);
3240 Set_Mechanism_Value
(Formal
, Mname
);
3241 Next_Formal
(Formal
);
3246 -- Deal with named entries
3248 if Present
(Component_Associations
(Arg_Mechanism
)) then
3249 Massoc
:= First
(Component_Associations
(Arg_Mechanism
));
3250 while Present
(Massoc
) loop
3251 Choice
:= First
(Choices
(Massoc
));
3253 if Nkind
(Choice
) /= N_Identifier
3254 or else Present
(Next
(Choice
))
3257 ("incorrect form for mechanism association",
3261 Formal
:= First_Formal
(Ent
);
3265 ("parameter name & not present", Choice
);
3268 if Chars
(Choice
) = Chars
(Formal
) then
3270 (Formal
, Expression
(Massoc
));
3272 -- Set entity on identifier for ASIS
3274 Set_Entity
(Choice
, Formal
);
3279 Next_Formal
(Formal
);
3289 -- Process First_Optional_Parameter argument if present. We have
3290 -- already checked that this is only allowed for the Import case.
3292 if Present
(Arg_First_Optional_Parameter
) then
3293 if Nkind
(Arg_First_Optional_Parameter
) /= N_Identifier
then
3295 ("first optional parameter must be formal parameter name",
3296 Arg_First_Optional_Parameter
);
3299 Formal
:= First_Formal
(Ent
);
3303 ("specified formal parameter& not found",
3304 Arg_First_Optional_Parameter
);
3307 exit when Chars
(Formal
) =
3308 Chars
(Arg_First_Optional_Parameter
);
3310 Next_Formal
(Formal
);
3313 Set_First_Optional_Parameter
(Ent
, Formal
);
3315 -- Check specified and all remaining formals have right form
3317 while Present
(Formal
) loop
3318 if Ekind
(Formal
) /= E_In_Parameter
then
3320 ("optional formal& is not of mode in!",
3321 Arg_First_Optional_Parameter
, Formal
);
3324 Dval
:= Default_Value
(Formal
);
3328 ("optional formal& does not have default value!",
3329 Arg_First_Optional_Parameter
, Formal
);
3331 elsif Compile_Time_Known_Value_Or_Aggr
(Dval
) then
3336 ("default value for optional formal& is non-static!",
3337 Arg_First_Optional_Parameter
, Formal
);
3341 Set_Is_Optional_Parameter
(Formal
);
3342 Next_Formal
(Formal
);
3345 end Process_Extended_Import_Export_Subprogram_Pragma
;
3347 --------------------------
3348 -- Process_Generic_List --
3349 --------------------------
3351 procedure Process_Generic_List
is
3356 Check_No_Identifiers
;
3357 Check_At_Least_N_Arguments
(1);
3360 while Present
(Arg
) loop
3361 Exp
:= Expression
(Arg
);
3364 if not Is_Entity_Name
(Exp
)
3366 (not Is_Generic_Instance
(Entity
(Exp
))
3368 not Is_Generic_Unit
(Entity
(Exp
)))
3371 ("pragma% argument must be name of generic unit/instance",
3377 end Process_Generic_List
;
3379 ---------------------------------
3380 -- Process_Import_Or_Interface --
3381 ---------------------------------
3383 procedure Process_Import_Or_Interface
is
3389 Process_Convention
(C
, Def_Id
);
3390 Kill_Size_Check_Code
(Def_Id
);
3391 Note_Possible_Modification
(Expression
(Arg2
), Sure
=> False);
3393 if Ekind
(Def_Id
) = E_Variable
3395 Ekind
(Def_Id
) = E_Constant
3397 -- We do not permit Import to apply to a renaming declaration
3399 if Present
(Renamed_Object
(Def_Id
)) then
3401 ("pragma% not allowed for object renaming", Arg2
);
3403 -- User initialization is not allowed for imported object, but
3404 -- the object declaration may contain a default initialization,
3405 -- that will be discarded. Note that an explicit initialization
3406 -- only counts if it comes from source, otherwise it is simply
3407 -- the code generator making an implicit initialization explicit.
3409 elsif Present
(Expression
(Parent
(Def_Id
)))
3410 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
3412 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3414 ("no initialization allowed for declaration of& #",
3415 "\imported entities cannot be initialized (RM B.1(24))",
3419 Set_Imported
(Def_Id
);
3420 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3422 -- Note that we do not set Is_Public here. That's because we
3423 -- only want to set it if there is no address clause, and we
3424 -- don't know that yet, so we delay that processing till
3427 -- pragma Import completes deferred constants
3429 if Ekind
(Def_Id
) = E_Constant
then
3430 Set_Has_Completion
(Def_Id
);
3433 -- It is not possible to import a constant of an unconstrained
3434 -- array type (e.g. string) because there is no simple way to
3435 -- write a meaningful subtype for it.
3437 if Is_Array_Type
(Etype
(Def_Id
))
3438 and then not Is_Constrained
(Etype
(Def_Id
))
3441 ("imported constant& must have a constrained subtype",
3446 elsif Is_Subprogram
(Def_Id
)
3447 or else Is_Generic_Subprogram
(Def_Id
)
3449 -- If the name is overloaded, pragma applies to all of the
3450 -- denoted entities in the same declarative part.
3453 while Present
(Hom_Id
) loop
3454 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
3456 -- Ignore inherited subprograms because the pragma will
3457 -- apply to the parent operation, which is the one called.
3459 if Is_Overloadable
(Def_Id
)
3460 and then Present
(Alias
(Def_Id
))
3464 -- If it is not a subprogram, it must be in an outer scope and
3465 -- pragma does not apply.
3467 elsif not Is_Subprogram
(Def_Id
)
3468 and then not Is_Generic_Subprogram
(Def_Id
)
3472 -- Verify that the homonym is in the same declarative part (not
3473 -- just the same scope).
3475 elsif Parent
(Unit_Declaration_Node
(Def_Id
)) /= Parent
(N
)
3476 and then Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
3481 Set_Imported
(Def_Id
);
3483 -- Reject an Import applied to an abstract subprogram
3485 if Is_Subprogram
(Def_Id
)
3486 and then Is_Abstract_Subprogram
(Def_Id
)
3488 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3490 ("cannot import abstract subprogram& declared#",
3494 -- Special processing for Convention_Intrinsic
3496 if C
= Convention_Intrinsic
then
3498 -- Link_Name argument not allowed for intrinsic
3501 and then Chars
(Arg3
) = Name_Link_Name
3506 if Present
(Arg4
) then
3508 ("Link_Name argument not allowed for " &
3513 Set_Is_Intrinsic_Subprogram
(Def_Id
);
3515 -- If no external name is present, then check that this
3516 -- is a valid intrinsic subprogram. If an external name
3517 -- is present, then this is handled by the back end.
3520 Check_Intrinsic_Subprogram
(Def_Id
, Expression
(Arg2
));
3524 -- All interfaced procedures need an external symbol created
3525 -- for them since they are always referenced from another
3528 Set_Is_Public
(Def_Id
);
3530 -- Verify that the subprogram does not have a completion
3531 -- through a renaming declaration. For other completions the
3532 -- pragma appears as a too late representation.
3535 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Def_Id
);
3539 and then Nkind
(Decl
) = N_Subprogram_Declaration
3540 and then Present
(Corresponding_Body
(Decl
))
3541 and then Nkind
(Unit_Declaration_Node
3542 (Corresponding_Body
(Decl
))) =
3543 N_Subprogram_Renaming_Declaration
3545 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3547 ("cannot import&, renaming already provided for " &
3548 "declaration #", N
, Def_Id
);
3552 Set_Has_Completion
(Def_Id
);
3553 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3556 if Is_Compilation_Unit
(Hom_Id
) then
3558 -- Its possible homonyms are not affected by the pragma.
3559 -- Such homonyms might be present in the context of other
3560 -- units being compiled.
3565 Hom_Id
:= Homonym
(Hom_Id
);
3569 -- When the convention is Java or CIL, we also allow Import to be
3570 -- given for packages, generic packages, exceptions, record
3571 -- components, and access to subprograms.
3573 elsif (C
= Convention_Java
or else C
= Convention_CIL
)
3575 (Is_Package_Or_Generic_Package
(Def_Id
)
3576 or else Ekind
(Def_Id
) = E_Exception
3577 or else Ekind
(Def_Id
) = E_Access_Subprogram_Type
3578 or else Nkind
(Parent
(Def_Id
)) = N_Component_Declaration
)
3580 Set_Imported
(Def_Id
);
3581 Set_Is_Public
(Def_Id
);
3582 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3584 -- Import a CPP class
3586 elsif Is_Record_Type
(Def_Id
)
3587 and then C
= Convention_CPP
3589 -- Types treated as CPP classes are treated as limited, but we
3590 -- don't require them to be declared this way. A warning is
3591 -- issued to encourage the user to declare them as limited.
3592 -- This is not an error, for compatibility reasons, because
3593 -- these types have been supported this way for some time.
3595 if not Is_Limited_Type
(Def_Id
) then
3597 ("imported 'C'P'P type should be " &
3598 "explicitly declared limited?",
3599 Get_Pragma_Arg
(Arg2
));
3601 ("\type will be considered limited",
3602 Get_Pragma_Arg
(Arg2
));
3605 Set_Is_CPP_Class
(Def_Id
);
3606 Set_Is_Limited_Record
(Def_Id
);
3608 -- Imported CPP types must not have discriminants (because C++
3609 -- classes do not have discriminants).
3611 if Has_Discriminants
(Def_Id
) then
3613 ("imported 'C'P'P type cannot have discriminants",
3614 First
(Discriminant_Specifications
3615 (Declaration_Node
(Def_Id
))));
3618 -- Components of imported CPP types must not have default
3619 -- expressions because the constructor (if any) is on the
3623 Tdef
: constant Node_Id
:=
3624 Type_Definition
(Declaration_Node
(Def_Id
));
3629 if Nkind
(Tdef
) = N_Record_Definition
then
3630 Clist
:= Component_List
(Tdef
);
3633 pragma Assert
(Nkind
(Tdef
) = N_Derived_Type_Definition
);
3634 Clist
:= Component_List
(Record_Extension_Part
(Tdef
));
3637 if Present
(Clist
) then
3638 Comp
:= First
(Component_Items
(Clist
));
3639 while Present
(Comp
) loop
3640 if Present
(Expression
(Comp
)) then
3642 ("component of imported 'C'P'P type cannot have" &
3643 " default expression", Expression
(Comp
));
3653 ("second argument of pragma% must be object or subprogram",
3657 -- If this pragma applies to a compilation unit, then the unit, which
3658 -- is a subprogram, does not require (or allow) a body. We also do
3659 -- not need to elaborate imported procedures.
3661 if Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
3663 Cunit
: constant Node_Id
:= Parent
(Parent
(N
));
3665 Set_Body_Required
(Cunit
, False);
3668 end Process_Import_Or_Interface
;
3670 --------------------
3671 -- Process_Inline --
3672 --------------------
3674 procedure Process_Inline
(Active
: Boolean) is
3680 Effective
: Boolean := False;
3682 procedure Make_Inline
(Subp
: Entity_Id
);
3683 -- Subp is the defining unit name of the subprogram declaration. Set
3684 -- the flag, as well as the flag in the corresponding body, if there
3687 procedure Set_Inline_Flags
(Subp
: Entity_Id
);
3688 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp and also
3689 -- Has_Pragma_Inline_Always for the Inline_Always case.
3691 function Inlining_Not_Possible
(Subp
: Entity_Id
) return Boolean;
3692 -- Returns True if it can be determined at this stage that inlining
3693 -- is not possible, for example if the body is available and contains
3694 -- exception handlers, we prevent inlining, since otherwise we can
3695 -- get undefined symbols at link time. This function also emits a
3696 -- warning if front-end inlining is enabled and the pragma appears
3699 -- ??? is business with link symbols still valid, or does it relate
3700 -- to front end ZCX which is being phased out ???
3702 ---------------------------
3703 -- Inlining_Not_Possible --
3704 ---------------------------
3706 function Inlining_Not_Possible
(Subp
: Entity_Id
) return Boolean is
3707 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Subp
);
3711 if Nkind
(Decl
) = N_Subprogram_Body
then
3712 Stats
:= Handled_Statement_Sequence
(Decl
);
3713 return Present
(Exception_Handlers
(Stats
))
3714 or else Present
(At_End_Proc
(Stats
));
3716 elsif Nkind
(Decl
) = N_Subprogram_Declaration
3717 and then Present
(Corresponding_Body
(Decl
))
3719 if Front_End_Inlining
3720 and then Analyzed
(Corresponding_Body
(Decl
))
3722 Error_Msg_N
("pragma appears too late, ignored?", N
);
3725 -- If the subprogram is a renaming as body, the body is just a
3726 -- call to the renamed subprogram, and inlining is trivially
3730 Nkind
(Unit_Declaration_Node
(Corresponding_Body
(Decl
))) =
3731 N_Subprogram_Renaming_Declaration
3737 Handled_Statement_Sequence
3738 (Unit_Declaration_Node
(Corresponding_Body
(Decl
)));
3741 Present
(Exception_Handlers
(Stats
))
3742 or else Present
(At_End_Proc
(Stats
));
3746 -- If body is not available, assume the best, the check is
3747 -- performed again when compiling enclosing package bodies.
3751 end Inlining_Not_Possible
;
3757 procedure Make_Inline
(Subp
: Entity_Id
) is
3758 Kind
: constant Entity_Kind
:= Ekind
(Subp
);
3759 Inner_Subp
: Entity_Id
:= Subp
;
3762 -- Ignore if bad type, avoid cascaded error
3764 if Etype
(Subp
) = Any_Type
then
3768 -- Ignore if all inlining is suppressed
3770 elsif Suppress_All_Inlining
then
3774 -- If inlining is not possible, for now do not treat as an error
3776 elsif Inlining_Not_Possible
(Subp
) then
3780 -- Here we have a candidate for inlining, but we must exclude
3781 -- derived operations. Otherwise we would end up trying to inline
3782 -- a phantom declaration, and the result would be to drag in a
3783 -- body which has no direct inlining associated with it. That
3784 -- would not only be inefficient but would also result in the
3785 -- backend doing cross-unit inlining in cases where it was
3786 -- definitely inappropriate to do so.
3788 -- However, a simple Comes_From_Source test is insufficient, since
3789 -- we do want to allow inlining of generic instances which also do
3790 -- not come from source. We also need to recognize specs generated
3791 -- by the front-end for bodies that carry the pragma. Finally,
3792 -- predefined operators do not come from source but are not
3793 -- inlineable either.
3795 elsif Is_Generic_Instance
(Subp
)
3796 or else Nkind
(Parent
(Parent
(Subp
))) = N_Subprogram_Declaration
3800 elsif not Comes_From_Source
(Subp
)
3801 and then Scope
(Subp
) /= Standard_Standard
3807 -- The referenced entity must either be the enclosing entity, or
3808 -- an entity declared within the current open scope.
3810 if Present
(Scope
(Subp
))
3811 and then Scope
(Subp
) /= Current_Scope
3812 and then Subp
/= Current_Scope
3815 ("argument of% must be entity in current scope", Assoc
);
3819 -- Processing for procedure, operator or function. If subprogram
3820 -- is aliased (as for an instance) indicate that the renamed
3821 -- entity (if declared in the same unit) is inlined.
3823 if Is_Subprogram
(Subp
) then
3824 while Present
(Alias
(Inner_Subp
)) loop
3825 Inner_Subp
:= Alias
(Inner_Subp
);
3828 if In_Same_Source_Unit
(Subp
, Inner_Subp
) then
3829 Set_Inline_Flags
(Inner_Subp
);
3831 Decl
:= Parent
(Parent
(Inner_Subp
));
3833 if Nkind
(Decl
) = N_Subprogram_Declaration
3834 and then Present
(Corresponding_Body
(Decl
))
3836 Set_Inline_Flags
(Corresponding_Body
(Decl
));
3838 elsif Is_Generic_Instance
(Subp
) then
3840 -- Indicate that the body needs to be created for
3841 -- inlining subsequent calls. The instantiation node
3842 -- follows the declaration of the wrapper package
3845 if Scope
(Subp
) /= Standard_Standard
3847 Need_Subprogram_Instance_Body
3848 (Next
(Unit_Declaration_Node
(Scope
(Alias
(Subp
)))),
3858 -- For a generic subprogram set flag as well, for use at the point
3859 -- of instantiation, to determine whether the body should be
3862 elsif Is_Generic_Subprogram
(Subp
) then
3863 Set_Inline_Flags
(Subp
);
3866 -- Literals are by definition inlined
3868 elsif Kind
= E_Enumeration_Literal
then
3871 -- Anything else is an error
3875 ("expect subprogram name for pragma%", Assoc
);
3879 ----------------------
3880 -- Set_Inline_Flags --
3881 ----------------------
3883 procedure Set_Inline_Flags
(Subp
: Entity_Id
) is
3886 Set_Is_Inlined
(Subp
, True);
3889 if not Has_Pragma_Inline
(Subp
) then
3890 Set_Has_Pragma_Inline
(Subp
);
3894 if Prag_Id
= Pragma_Inline_Always
then
3895 Set_Has_Pragma_Inline_Always
(Subp
);
3897 end Set_Inline_Flags
;
3899 -- Start of processing for Process_Inline
3902 Check_No_Identifiers
;
3903 Check_At_Least_N_Arguments
(1);
3906 Inline_Processing_Required
:= True;
3910 while Present
(Assoc
) loop
3911 Subp_Id
:= Expression
(Assoc
);
3915 if Is_Entity_Name
(Subp_Id
) then
3916 Subp
:= Entity
(Subp_Id
);
3918 if Subp
= Any_Id
then
3920 -- If previous error, avoid cascaded errors
3928 while Present
(Homonym
(Subp
))
3929 and then Scope
(Homonym
(Subp
)) = Current_Scope
3931 Make_Inline
(Homonym
(Subp
));
3932 Subp
:= Homonym
(Subp
);
3939 ("inappropriate argument for pragma%", Assoc
);
3942 and then Warn_On_Redundant_Constructs
3943 and then not Suppress_All_Inlining
3945 if Inlining_Not_Possible
(Subp
) then
3947 ("pragma Inline for& is ignored?", N
, Entity
(Subp_Id
));
3950 ("pragma Inline for& is redundant?", N
, Entity
(Subp_Id
));
3958 ----------------------------
3959 -- Process_Interface_Name --
3960 ----------------------------
3962 procedure Process_Interface_Name
3963 (Subprogram_Def
: Entity_Id
;
3969 String_Val
: String_Id
;
3971 procedure Check_Form_Of_Interface_Name
3973 Ext_Name_Case
: Boolean);
3974 -- SN is a string literal node for an interface name. This routine
3975 -- performs some minimal checks that the name is reasonable. In
3976 -- particular that no spaces or other obviously incorrect characters
3977 -- appear. This is only a warning, since any characters are allowed.
3978 -- Ext_Name_Case is True for an External_Name, False for a Link_Name.
3980 ----------------------------------
3981 -- Check_Form_Of_Interface_Name --
3982 ----------------------------------
3984 procedure Check_Form_Of_Interface_Name
3986 Ext_Name_Case
: Boolean)
3988 S
: constant String_Id
:= Strval
(Expr_Value_S
(SN
));
3989 SL
: constant Nat
:= String_Length
(S
);
3994 Error_Msg_N
("interface name cannot be null string", SN
);
3997 for J
in 1 .. SL
loop
3998 C
:= Get_String_Char
(S
, J
);
4000 -- Look for dubious character and issue unconditional warning.
4001 -- Definitely dubious if not in character range.
4003 if not In_Character_Range
(C
)
4005 -- For all cases except CLI target,
4006 -- commas, spaces and slashes are dubious (in CLI, we use
4007 -- commas and backslashes in external names to specify
4008 -- assembly version and public key, while slashes and spaces
4009 -- can be used in names to mark nested classes and
4012 or else ((not Ext_Name_Case
or else VM_Target
/= CLI_Target
)
4013 and then (Get_Character
(C
) = ','
4015 Get_Character
(C
) = '\'))
4016 or else (VM_Target
/= CLI_Target
4017 and then (Get_Character
(C
) = ' '
4019 Get_Character
(C
) = '/'))
4022 ("?interface name contains illegal character",
4023 Sloc
(SN
) + Source_Ptr
(J
));
4026 end Check_Form_Of_Interface_Name
;
4028 -- Start of processing for Process_Interface_Name
4031 if No
(Link_Arg
) then
4032 if No
(Ext_Arg
) then
4033 if VM_Target
= CLI_Target
4034 and then Ekind
(Subprogram_Def
) = E_Package
4035 and then Nkind
(Parent
(Subprogram_Def
)) =
4036 N_Package_Specification
4037 and then Present
(Generic_Parent
(Parent
(Subprogram_Def
)))
4042 (Generic_Parent
(Parent
(Subprogram_Def
))));
4047 elsif Chars
(Ext_Arg
) = Name_Link_Name
then
4049 Link_Nam
:= Expression
(Ext_Arg
);
4052 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
4053 Ext_Nam
:= Expression
(Ext_Arg
);
4058 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
4059 Check_Optional_Identifier
(Link_Arg
, Name_Link_Name
);
4060 Ext_Nam
:= Expression
(Ext_Arg
);
4061 Link_Nam
:= Expression
(Link_Arg
);
4064 -- Check expressions for external name and link name are static
4066 if Present
(Ext_Nam
) then
4067 Check_Arg_Is_Static_Expression
(Ext_Nam
, Standard_String
);
4068 Check_Form_Of_Interface_Name
(Ext_Nam
, Ext_Name_Case
=> True);
4070 -- Verify that external name is not the name of a local entity,
4071 -- which would hide the imported one and could lead to run-time
4072 -- surprises. The problem can only arise for entities declared in
4073 -- a package body (otherwise the external name is fully qualified
4074 -- and will not conflict).
4082 if Prag_Id
= Pragma_Import
then
4083 String_To_Name_Buffer
(Strval
(Expr_Value_S
(Ext_Nam
)));
4085 E
:= Entity_Id
(Get_Name_Table_Info
(Nam
));
4087 if Nam
/= Chars
(Subprogram_Def
)
4088 and then Present
(E
)
4089 and then not Is_Overloadable
(E
)
4090 and then Is_Immediately_Visible
(E
)
4091 and then not Is_Imported
(E
)
4092 and then Ekind
(Scope
(E
)) = E_Package
4095 while Present
(Par
) loop
4096 if Nkind
(Par
) = N_Package_Body
then
4097 Error_Msg_Sloc
:= Sloc
(E
);
4099 ("imported entity is hidden by & declared#",
4104 Par
:= Parent
(Par
);
4111 if Present
(Link_Nam
) then
4112 Check_Arg_Is_Static_Expression
(Link_Nam
, Standard_String
);
4113 Check_Form_Of_Interface_Name
(Link_Nam
, Ext_Name_Case
=> False);
4116 -- If there is no link name, just set the external name
4118 if No
(Link_Nam
) then
4119 Link_Nam
:= Adjust_External_Name_Case
(Expr_Value_S
(Ext_Nam
));
4121 -- For the Link_Name case, the given literal is preceded by an
4122 -- asterisk, which indicates to GCC that the given name should be
4123 -- taken literally, and in particular that no prepending of
4124 -- underlines should occur, even in systems where this is the
4130 if VM_Target
= No_VM
then
4131 Store_String_Char
(Get_Char_Code
('*'));
4134 String_Val
:= Strval
(Expr_Value_S
(Link_Nam
));
4135 Store_String_Chars
(String_Val
);
4137 Make_String_Literal
(Sloc
(Link_Nam
),
4138 Strval
=> End_String
);
4141 Set_Encoded_Interface_Name
4142 (Get_Base_Subprogram
(Subprogram_Def
), Link_Nam
);
4143 Check_Duplicated_Export_Name
(Link_Nam
);
4144 end Process_Interface_Name
;
4146 -----------------------------------------
4147 -- Process_Interrupt_Or_Attach_Handler --
4148 -----------------------------------------
4150 procedure Process_Interrupt_Or_Attach_Handler
is
4151 Arg1_X
: constant Node_Id
:= Expression
(Arg1
);
4152 Handler_Proc
: constant Entity_Id
:= Entity
(Arg1_X
);
4153 Proc_Scope
: constant Entity_Id
:= Scope
(Handler_Proc
);
4156 Set_Is_Interrupt_Handler
(Handler_Proc
);
4158 -- If the pragma is not associated with a handler procedure within a
4159 -- protected type, then it must be for a nonprotected procedure for
4160 -- the AAMP target, in which case we don't associate a representation
4161 -- item with the procedure's scope.
4163 if Ekind
(Proc_Scope
) = E_Protected_Type
then
4164 if Prag_Id
= Pragma_Interrupt_Handler
4166 Prag_Id
= Pragma_Attach_Handler
4168 Record_Rep_Item
(Proc_Scope
, N
);
4171 end Process_Interrupt_Or_Attach_Handler
;
4173 --------------------------------------------------
4174 -- Process_Restrictions_Or_Restriction_Warnings --
4175 --------------------------------------------------
4177 -- Note: some of the simple identifier cases were handled in par-prag,
4178 -- but it is harmless (and more straightforward) to simply handle all
4179 -- cases here, even if it means we repeat a bit of work in some cases.
4181 procedure Process_Restrictions_Or_Restriction_Warnings
4185 R_Id
: Restriction_Id
;
4190 procedure Check_Unit_Name
(N
: Node_Id
);
4191 -- Checks unit name parameter for No_Dependence. Returns if it has
4192 -- an appropriate form, otherwise raises pragma argument error.
4194 ---------------------
4195 -- Check_Unit_Name --
4196 ---------------------
4198 procedure Check_Unit_Name
(N
: Node_Id
) is
4200 if Nkind
(N
) = N_Selected_Component
then
4201 Check_Unit_Name
(Prefix
(N
));
4202 Check_Unit_Name
(Selector_Name
(N
));
4204 elsif Nkind
(N
) = N_Identifier
then
4209 ("wrong form for unit name for No_Dependence", N
);
4211 end Check_Unit_Name
;
4213 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
4216 Check_Ada_83_Warning
;
4217 Check_At_Least_N_Arguments
(1);
4218 Check_Valid_Configuration_Pragma
;
4221 while Present
(Arg
) loop
4223 Expr
:= Expression
(Arg
);
4225 -- Case of no restriction identifier present
4227 if Id
= No_Name
then
4228 if Nkind
(Expr
) /= N_Identifier
then
4230 ("invalid form for restriction", Arg
);
4235 (Process_Restriction_Synonyms
(Expr
));
4237 if R_Id
not in All_Boolean_Restrictions
then
4238 Error_Msg_Name_1
:= Pname
;
4240 ("invalid restriction identifier&", Get_Pragma_Arg
(Arg
));
4242 -- Check for possible misspelling
4244 for J
in Restriction_Id
loop
4246 Rnm
: constant String := Restriction_Id
'Image (J
);
4249 Name_Buffer
(1 .. Rnm
'Length) := Rnm
;
4250 Name_Len
:= Rnm
'Length;
4251 Set_Casing
(All_Lower_Case
);
4253 if Is_Bad_Spelling_Of
(Chars
(Expr
), Name_Enter
) then
4255 (Identifier_Casing
(Current_Source_File
));
4256 Error_Msg_String
(1 .. Rnm
'Length) :=
4257 Name_Buffer
(1 .. Name_Len
);
4258 Error_Msg_Strlen
:= Rnm
'Length;
4259 Error_Msg_N
-- CODEFIX
4260 ("\possible misspelling of ""~""",
4261 Get_Pragma_Arg
(Arg
));
4270 if Implementation_Restriction
(R_Id
) then
4271 Check_Restriction
(No_Implementation_Restrictions
, Arg
);
4274 -- If this is a warning, then set the warning unless we already
4275 -- have a real restriction active (we never want a warning to
4276 -- override a real restriction).
4279 if not Restriction_Active
(R_Id
) then
4280 Set_Restriction
(R_Id
, N
);
4281 Restriction_Warnings
(R_Id
) := True;
4284 -- If real restriction case, then set it and make sure that the
4285 -- restriction warning flag is off, since a real restriction
4286 -- always overrides a warning.
4289 Set_Restriction
(R_Id
, N
);
4290 Restriction_Warnings
(R_Id
) := False;
4293 -- A very special case that must be processed here: pragma
4294 -- Restrictions (No_Exceptions) turns off all run-time
4295 -- checking. This is a bit dubious in terms of the formal
4296 -- language definition, but it is what is intended by RM
4297 -- H.4(12). Restriction_Warnings never affects generated code
4298 -- so this is done only in the real restriction case.
4300 if R_Id
= No_Exceptions
and then not Warn
then
4301 Scope_Suppress
:= (others => True);
4304 -- Case of No_Dependence => unit-name. Note that the parser
4305 -- already made the necessary entry in the No_Dependence table.
4307 elsif Id
= Name_No_Dependence
then
4308 Check_Unit_Name
(Expr
);
4310 -- All other cases of restriction identifier present
4313 R_Id
:= Get_Restriction_Id
(Process_Restriction_Synonyms
(Arg
));
4314 Analyze_And_Resolve
(Expr
, Any_Integer
);
4316 if R_Id
not in All_Parameter_Restrictions
then
4318 ("invalid restriction parameter identifier", Arg
);
4320 elsif not Is_OK_Static_Expression
(Expr
) then
4321 Flag_Non_Static_Expr
4322 ("value must be static expression!", Expr
);
4325 elsif not Is_Integer_Type
(Etype
(Expr
))
4326 or else Expr_Value
(Expr
) < 0
4329 ("value must be non-negative integer", Arg
);
4332 -- Restriction pragma is active
4334 Val
:= Expr_Value
(Expr
);
4336 if not UI_Is_In_Int_Range
(Val
) then
4338 ("pragma ignored, value too large?", Arg
);
4341 -- Warning case. If the real restriction is active, then we
4342 -- ignore the request, since warning never overrides a real
4343 -- restriction. Otherwise we set the proper warning. Note that
4344 -- this circuit sets the warning again if it is already set,
4345 -- which is what we want, since the constant may have changed.
4348 if not Restriction_Active
(R_Id
) then
4350 (R_Id
, N
, Integer (UI_To_Int
(Val
)));
4351 Restriction_Warnings
(R_Id
) := True;
4354 -- Real restriction case, set restriction and make sure warning
4355 -- flag is off since real restriction always overrides warning.
4358 Set_Restriction
(R_Id
, N
, Integer (UI_To_Int
(Val
)));
4359 Restriction_Warnings
(R_Id
) := False;
4365 end Process_Restrictions_Or_Restriction_Warnings
;
4367 ---------------------------------
4368 -- Process_Suppress_Unsuppress --
4369 ---------------------------------
4371 -- Note: this procedure makes entries in the check suppress data
4372 -- structures managed by Sem. See spec of package Sem for full
4373 -- details on how we handle recording of check suppression.
4375 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean) is
4380 In_Package_Spec
: constant Boolean :=
4381 Is_Package_Or_Generic_Package
(Current_Scope
)
4382 and then not In_Package_Body
(Current_Scope
);
4384 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
);
4385 -- Used to suppress a single check on the given entity
4387 --------------------------------
4388 -- Suppress_Unsuppress_Echeck --
4389 --------------------------------
4391 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
) is
4393 Set_Checks_May_Be_Suppressed
(E
);
4395 if In_Package_Spec
then
4396 Push_Global_Suppress_Stack_Entry
4399 Suppress
=> Suppress_Case
);
4402 Push_Local_Suppress_Stack_Entry
4405 Suppress
=> Suppress_Case
);
4408 -- If this is a first subtype, and the base type is distinct,
4409 -- then also set the suppress flags on the base type.
4411 if Is_First_Subtype
(E
)
4412 and then Etype
(E
) /= E
4414 Suppress_Unsuppress_Echeck
(Etype
(E
), C
);
4416 end Suppress_Unsuppress_Echeck
;
4418 -- Start of processing for Process_Suppress_Unsuppress
4421 -- Suppress/Unsuppress can appear as a configuration pragma, or in a
4422 -- declarative part or a package spec (RM 11.5(5)).
4424 if not Is_Configuration_Pragma
then
4425 Check_Is_In_Decl_Part_Or_Package_Spec
;
4428 Check_At_Least_N_Arguments
(1);
4429 Check_At_Most_N_Arguments
(2);
4430 Check_No_Identifier
(Arg1
);
4431 Check_Arg_Is_Identifier
(Arg1
);
4433 C
:= Get_Check_Id
(Chars
(Expression
(Arg1
)));
4435 if C
= No_Check_Id
then
4437 ("argument of pragma% is not valid check name", Arg1
);
4440 if not Suppress_Case
4441 and then (C
= All_Checks
or else C
= Overflow_Check
)
4443 Opt
.Overflow_Checks_Unsuppressed
:= True;
4446 if Arg_Count
= 1 then
4448 -- Make an entry in the local scope suppress table. This is the
4449 -- table that directly shows the current value of the scope
4450 -- suppress check for any check id value.
4452 if C
= All_Checks
then
4454 -- For All_Checks, we set all specific predefined checks with
4455 -- the exception of Elaboration_Check, which is handled
4456 -- specially because of not wanting All_Checks to have the
4457 -- effect of deactivating static elaboration order processing.
4459 for J
in Scope_Suppress
'Range loop
4460 if J
/= Elaboration_Check
then
4461 Scope_Suppress
(J
) := Suppress_Case
;
4465 -- If not All_Checks, and predefined check, then set appropriate
4466 -- scope entry. Note that we will set Elaboration_Check if this
4467 -- is explicitly specified.
4469 elsif C
in Predefined_Check_Id
then
4470 Scope_Suppress
(C
) := Suppress_Case
;
4473 -- Also make an entry in the Local_Entity_Suppress table
4475 Push_Local_Suppress_Stack_Entry
4478 Suppress
=> Suppress_Case
);
4480 -- Case of two arguments present, where the check is suppressed for
4481 -- a specified entity (given as the second argument of the pragma)
4484 Check_Optional_Identifier
(Arg2
, Name_On
);
4485 E_Id
:= Expression
(Arg2
);
4488 if not Is_Entity_Name
(E_Id
) then
4490 ("second argument of pragma% must be entity name", Arg2
);
4499 -- Enforce RM 11.5(7) which requires that for a pragma that
4500 -- appears within a package spec, the named entity must be
4501 -- within the package spec. We allow the package name itself
4502 -- to be mentioned since that makes sense, although it is not
4503 -- strictly allowed by 11.5(7).
4506 and then E
/= Current_Scope
4507 and then Scope
(E
) /= Current_Scope
4510 ("entity in pragma% is not in package spec (RM 11.5(7))",
4514 -- Loop through homonyms. As noted below, in the case of a package
4515 -- spec, only homonyms within the package spec are considered.
4518 Suppress_Unsuppress_Echeck
(E
, C
);
4520 if Is_Generic_Instance
(E
)
4521 and then Is_Subprogram
(E
)
4522 and then Present
(Alias
(E
))
4524 Suppress_Unsuppress_Echeck
(Alias
(E
), C
);
4527 -- Move to next homonym
4532 -- If we are within a package specification, the pragma only
4533 -- applies to homonyms in the same scope.
4535 exit when In_Package_Spec
4536 and then Scope
(E
) /= Current_Scope
;
4539 end Process_Suppress_Unsuppress
;
4545 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
) is
4547 if Is_Imported
(E
) then
4549 ("cannot export entity& that was previously imported", Arg
);
4551 elsif Present
(Address_Clause
(E
)) then
4553 ("cannot export entity& that has an address clause", Arg
);
4556 Set_Is_Exported
(E
);
4558 -- Generate a reference for entity explicitly, because the
4559 -- identifier may be overloaded and name resolution will not
4562 Generate_Reference
(E
, Arg
);
4564 -- Deal with exporting non-library level entity
4566 if not Is_Library_Level_Entity
(E
) then
4568 -- Not allowed at all for subprograms
4570 if Is_Subprogram
(E
) then
4571 Error_Pragma_Arg
("local subprogram& cannot be exported", Arg
);
4573 -- Otherwise set public and statically allocated
4577 Set_Is_Statically_Allocated
(E
);
4579 -- Warn if the corresponding W flag is set and the pragma comes
4580 -- from source. The latter may not be true e.g. on VMS where we
4581 -- expand export pragmas for exception codes associated with
4582 -- imported or exported exceptions. We do not want to generate
4583 -- a warning for something that the user did not write.
4585 if Warn_On_Export_Import
4586 and then Comes_From_Source
(Arg
)
4589 ("?& has been made static as a result of Export", Arg
, E
);
4591 ("\this usage is non-standard and non-portable", Arg
);
4596 if Warn_On_Export_Import
and then Is_Type
(E
) then
4598 ("exporting a type has no effect?", Arg
, E
);
4601 if Warn_On_Export_Import
and Inside_A_Generic
then
4603 ("all instances of& will have the same external name?", Arg
, E
);
4607 ----------------------------------------------
4608 -- Set_Extended_Import_Export_External_Name --
4609 ----------------------------------------------
4611 procedure Set_Extended_Import_Export_External_Name
4612 (Internal_Ent
: Entity_Id
;
4613 Arg_External
: Node_Id
)
4615 Old_Name
: constant Node_Id
:= Interface_Name
(Internal_Ent
);
4619 if No
(Arg_External
) then
4623 Check_Arg_Is_External_Name
(Arg_External
);
4625 if Nkind
(Arg_External
) = N_String_Literal
then
4626 if String_Length
(Strval
(Arg_External
)) = 0 then
4629 New_Name
:= Adjust_External_Name_Case
(Arg_External
);
4632 elsif Nkind
(Arg_External
) = N_Identifier
then
4633 New_Name
:= Get_Default_External_Name
(Arg_External
);
4635 -- Check_Arg_Is_External_Name should let through only identifiers and
4636 -- string literals or static string expressions (which are folded to
4637 -- string literals).
4640 raise Program_Error
;
4643 -- If we already have an external name set (by a prior normal Import
4644 -- or Export pragma), then the external names must match
4646 if Present
(Interface_Name
(Internal_Ent
)) then
4647 Check_Matching_Internal_Names
: declare
4648 S1
: constant String_Id
:= Strval
(Old_Name
);
4649 S2
: constant String_Id
:= Strval
(New_Name
);
4652 -- Called if names do not match
4658 procedure Mismatch
is
4660 Error_Msg_Sloc
:= Sloc
(Old_Name
);
4662 ("external name does not match that given #",
4666 -- Start of processing for Check_Matching_Internal_Names
4669 if String_Length
(S1
) /= String_Length
(S2
) then
4673 for J
in 1 .. String_Length
(S1
) loop
4674 if Get_String_Char
(S1
, J
) /= Get_String_Char
(S2
, J
) then
4679 end Check_Matching_Internal_Names
;
4681 -- Otherwise set the given name
4684 Set_Encoded_Interface_Name
(Internal_Ent
, New_Name
);
4685 Check_Duplicated_Export_Name
(New_Name
);
4687 end Set_Extended_Import_Export_External_Name
;
4693 procedure Set_Imported
(E
: Entity_Id
) is
4695 -- Error message if already imported or exported
4697 if Is_Exported
(E
) or else Is_Imported
(E
) then
4698 if Is_Exported
(E
) then
4699 Error_Msg_NE
("entity& was previously exported", N
, E
);
4701 Error_Msg_NE
("entity& was previously imported", N
, E
);
4704 Error_Msg_Name_1
:= Pname
;
4706 ("\(pragma% applies to all previous entities)", N
);
4708 Error_Msg_Sloc
:= Sloc
(E
);
4709 Error_Msg_NE
("\import not allowed for& declared#", N
, E
);
4711 -- Here if not previously imported or exported, OK to import
4714 Set_Is_Imported
(E
);
4716 -- If the entity is an object that is not at the library level,
4717 -- then it is statically allocated. We do not worry about objects
4718 -- with address clauses in this context since they are not really
4719 -- imported in the linker sense.
4722 and then not Is_Library_Level_Entity
(E
)
4723 and then No
(Address_Clause
(E
))
4725 Set_Is_Statically_Allocated
(E
);
4730 -------------------------
4731 -- Set_Mechanism_Value --
4732 -------------------------
4734 -- Note: the mechanism name has not been analyzed (and cannot indeed be
4735 -- analyzed, since it is semantic nonsense), so we get it in the exact
4736 -- form created by the parser.
4738 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
) is
4741 Mech_Name_Id
: Name_Id
;
4743 procedure Bad_Class
;
4744 -- Signal bad descriptor class name
4746 procedure Bad_Mechanism
;
4747 -- Signal bad mechanism name
4753 procedure Bad_Class
is
4755 Error_Pragma_Arg
("unrecognized descriptor class name", Class
);
4758 -------------------------
4759 -- Bad_Mechanism_Value --
4760 -------------------------
4762 procedure Bad_Mechanism
is
4764 Error_Pragma_Arg
("unrecognized mechanism name", Mech_Name
);
4767 -- Start of processing for Set_Mechanism_Value
4770 if Mechanism
(Ent
) /= Default_Mechanism
then
4772 ("mechanism for & has already been set", Mech_Name
, Ent
);
4775 -- MECHANISM_NAME ::= value | reference | descriptor |
4778 if Nkind
(Mech_Name
) = N_Identifier
then
4779 if Chars
(Mech_Name
) = Name_Value
then
4780 Set_Mechanism
(Ent
, By_Copy
);
4783 elsif Chars
(Mech_Name
) = Name_Reference
then
4784 Set_Mechanism
(Ent
, By_Reference
);
4787 elsif Chars
(Mech_Name
) = Name_Descriptor
then
4788 Check_VMS
(Mech_Name
);
4789 Set_Mechanism
(Ent
, By_Descriptor
);
4792 elsif Chars
(Mech_Name
) = Name_Short_Descriptor
then
4793 Check_VMS
(Mech_Name
);
4794 Set_Mechanism
(Ent
, By_Short_Descriptor
);
4797 elsif Chars
(Mech_Name
) = Name_Copy
then
4799 ("bad mechanism name, Value assumed", Mech_Name
);
4805 -- MECHANISM_NAME ::= descriptor (CLASS_NAME) |
4806 -- short_descriptor (CLASS_NAME)
4807 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4809 -- Note: this form is parsed as an indexed component
4811 elsif Nkind
(Mech_Name
) = N_Indexed_Component
then
4813 Class
:= First
(Expressions
(Mech_Name
));
4815 if Nkind
(Prefix
(Mech_Name
)) /= N_Identifier
4816 or else not (Chars
(Prefix
(Mech_Name
)) = Name_Descriptor
or else
4817 Chars
(Prefix
(Mech_Name
)) = Name_Short_Descriptor
)
4818 or else Present
(Next
(Class
))
4822 Mech_Name_Id
:= Chars
(Prefix
(Mech_Name
));
4825 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME) |
4826 -- short_descriptor (Class => CLASS_NAME)
4827 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
4829 -- Note: this form is parsed as a function call
4831 elsif Nkind
(Mech_Name
) = N_Function_Call
then
4833 Param
:= First
(Parameter_Associations
(Mech_Name
));
4835 if Nkind
(Name
(Mech_Name
)) /= N_Identifier
4836 or else not (Chars
(Name
(Mech_Name
)) = Name_Descriptor
or else
4837 Chars
(Name
(Mech_Name
)) = Name_Short_Descriptor
)
4838 or else Present
(Next
(Param
))
4839 or else No
(Selector_Name
(Param
))
4840 or else Chars
(Selector_Name
(Param
)) /= Name_Class
4844 Class
:= Explicit_Actual_Parameter
(Param
);
4845 Mech_Name_Id
:= Chars
(Name
(Mech_Name
));
4852 -- Fall through here with Class set to descriptor class name
4854 Check_VMS
(Mech_Name
);
4856 if Nkind
(Class
) /= N_Identifier
then
4859 elsif Mech_Name_Id
= Name_Descriptor
4860 and then Chars
(Class
) = Name_UBS
4862 Set_Mechanism
(Ent
, By_Descriptor_UBS
);
4864 elsif Mech_Name_Id
= Name_Descriptor
4865 and then Chars
(Class
) = Name_UBSB
4867 Set_Mechanism
(Ent
, By_Descriptor_UBSB
);
4869 elsif Mech_Name_Id
= Name_Descriptor
4870 and then Chars
(Class
) = Name_UBA
4872 Set_Mechanism
(Ent
, By_Descriptor_UBA
);
4874 elsif Mech_Name_Id
= Name_Descriptor
4875 and then Chars
(Class
) = Name_S
4877 Set_Mechanism
(Ent
, By_Descriptor_S
);
4879 elsif Mech_Name_Id
= Name_Descriptor
4880 and then Chars
(Class
) = Name_SB
4882 Set_Mechanism
(Ent
, By_Descriptor_SB
);
4884 elsif Mech_Name_Id
= Name_Descriptor
4885 and then Chars
(Class
) = Name_A
4887 Set_Mechanism
(Ent
, By_Descriptor_A
);
4889 elsif Mech_Name_Id
= Name_Descriptor
4890 and then Chars
(Class
) = Name_NCA
4892 Set_Mechanism
(Ent
, By_Descriptor_NCA
);
4894 elsif Mech_Name_Id
= Name_Short_Descriptor
4895 and then Chars
(Class
) = Name_UBS
4897 Set_Mechanism
(Ent
, By_Short_Descriptor_UBS
);
4899 elsif Mech_Name_Id
= Name_Short_Descriptor
4900 and then Chars
(Class
) = Name_UBSB
4902 Set_Mechanism
(Ent
, By_Short_Descriptor_UBSB
);
4904 elsif Mech_Name_Id
= Name_Short_Descriptor
4905 and then Chars
(Class
) = Name_UBA
4907 Set_Mechanism
(Ent
, By_Short_Descriptor_UBA
);
4909 elsif Mech_Name_Id
= Name_Short_Descriptor
4910 and then Chars
(Class
) = Name_S
4912 Set_Mechanism
(Ent
, By_Short_Descriptor_S
);
4914 elsif Mech_Name_Id
= Name_Short_Descriptor
4915 and then Chars
(Class
) = Name_SB
4917 Set_Mechanism
(Ent
, By_Short_Descriptor_SB
);
4919 elsif Mech_Name_Id
= Name_Short_Descriptor
4920 and then Chars
(Class
) = Name_A
4922 Set_Mechanism
(Ent
, By_Short_Descriptor_A
);
4924 elsif Mech_Name_Id
= Name_Short_Descriptor
4925 and then Chars
(Class
) = Name_NCA
4927 Set_Mechanism
(Ent
, By_Short_Descriptor_NCA
);
4932 end Set_Mechanism_Value
;
4934 ---------------------------
4935 -- Set_Ravenscar_Profile --
4936 ---------------------------
4938 -- The tasks to be done here are
4940 -- Set required policies
4942 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4943 -- pragma Locking_Policy (Ceiling_Locking)
4945 -- Set Detect_Blocking mode
4947 -- Set required restrictions (see System.Rident for detailed list)
4949 procedure Set_Ravenscar_Profile
(N
: Node_Id
) is
4951 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
4953 if Task_Dispatching_Policy
/= ' '
4954 and then Task_Dispatching_Policy
/= 'F'
4956 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
4957 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4959 -- Set the FIFO_Within_Priorities policy, but always preserve
4960 -- System_Location since we like the error message with the run time
4964 Task_Dispatching_Policy
:= 'F';
4966 if Task_Dispatching_Policy_Sloc
/= System_Location
then
4967 Task_Dispatching_Policy_Sloc
:= Loc
;
4971 -- pragma Locking_Policy (Ceiling_Locking)
4973 if Locking_Policy
/= ' '
4974 and then Locking_Policy
/= 'C'
4976 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
4977 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
4979 -- Set the Ceiling_Locking policy, but preserve System_Location since
4980 -- we like the error message with the run time name.
4983 Locking_Policy
:= 'C';
4985 if Locking_Policy_Sloc
/= System_Location
then
4986 Locking_Policy_Sloc
:= Loc
;
4990 -- pragma Detect_Blocking
4992 Detect_Blocking
:= True;
4994 -- Set the corresponding restrictions
4996 Set_Profile_Restrictions
4997 (Ravenscar
, N
, Warn
=> Treat_Restrictions_As_Warnings
);
4998 end Set_Ravenscar_Profile
;
5000 -- Start of processing for Analyze_Pragma
5003 -- Deal with unrecognized pragma
5005 if not Is_Pragma_Name
(Pname
) then
5006 if Warn_On_Unrecognized_Pragma
then
5007 Error_Msg_Name_1
:= Pname
;
5008 Error_Msg_N
("?unrecognized pragma%!", Pragma_Identifier
(N
));
5010 for PN
in First_Pragma_Name
.. Last_Pragma_Name
loop
5011 if Is_Bad_Spelling_Of
(Pname
, PN
) then
5012 Error_Msg_Name_1
:= PN
;
5013 Error_Msg_N
-- CODEFIX
5014 ("\?possible misspelling of %!", Pragma_Identifier
(N
));
5023 -- Here to start processing for recognized pragma
5025 Prag_Id
:= Get_Pragma_Id
(Pname
);
5034 if Present
(Pragma_Argument_Associations
(N
)) then
5035 Arg1
:= First
(Pragma_Argument_Associations
(N
));
5037 if Present
(Arg1
) then
5038 Arg2
:= Next
(Arg1
);
5040 if Present
(Arg2
) then
5041 Arg3
:= Next
(Arg2
);
5043 if Present
(Arg3
) then
5044 Arg4
:= Next
(Arg3
);
5050 -- Count number of arguments
5057 while Present
(Arg_Node
) loop
5058 Arg_Count
:= Arg_Count
+ 1;
5063 -- An enumeration type defines the pragmas that are supported by the
5064 -- implementation. Get_Pragma_Id (in package Prag) transforms a name
5065 -- into the corresponding enumeration value for the following case.
5073 -- pragma Abort_Defer;
5075 when Pragma_Abort_Defer
=>
5077 Check_Arg_Count
(0);
5079 -- The only required semantic processing is to check the
5080 -- placement. This pragma must appear at the start of the
5081 -- statement sequence of a handled sequence of statements.
5083 if Nkind
(Parent
(N
)) /= N_Handled_Sequence_Of_Statements
5084 or else N
/= First
(Statements
(Parent
(N
)))
5095 -- Note: this pragma also has some specific processing in Par.Prag
5096 -- because we want to set the Ada version mode during parsing.
5098 when Pragma_Ada_83
=>
5100 Check_Arg_Count
(0);
5102 -- We really should check unconditionally for proper configuration
5103 -- pragma placement, since we really don't want mixed Ada modes
5104 -- within a single unit, and the GNAT reference manual has always
5105 -- said this was a configuration pragma, but we did not check and
5106 -- are hesitant to add the check now.
5108 -- However, we really cannot tolerate mixing Ada 2005 with Ada 83
5109 -- or Ada 95, so we must check if we are in Ada 2005 mode.
5111 if Ada_Version
>= Ada_05
then
5112 Check_Valid_Configuration_Pragma
;
5115 -- Now set Ada 83 mode
5117 Ada_Version
:= Ada_83
;
5118 Ada_Version_Explicit
:= Ada_Version
;
5126 -- Note: this pragma also has some specific processing in Par.Prag
5127 -- because we want to set the Ada 83 version mode during parsing.
5129 when Pragma_Ada_95
=>
5131 Check_Arg_Count
(0);
5133 -- We really should check unconditionally for proper configuration
5134 -- pragma placement, since we really don't want mixed Ada modes
5135 -- within a single unit, and the GNAT reference manual has always
5136 -- said this was a configuration pragma, but we did not check and
5137 -- are hesitant to add the check now.
5139 -- However, we really cannot tolerate mixing Ada 2005 with Ada 83
5140 -- or Ada 95, so we must check if we are in Ada 2005 mode.
5142 if Ada_Version
>= Ada_05
then
5143 Check_Valid_Configuration_Pragma
;
5146 -- Now set Ada 95 mode
5148 Ada_Version
:= Ada_95
;
5149 Ada_Version_Explicit
:= Ada_Version
;
5151 ---------------------
5152 -- Ada_05/Ada_2005 --
5153 ---------------------
5156 -- pragma Ada_05 (LOCAL_NAME);
5159 -- pragma Ada_2005 (LOCAL_NAME):
5161 -- Note: these pragma also have some specific processing in Par.Prag
5162 -- because we want to set the Ada 2005 version mode during parsing.
5164 when Pragma_Ada_05 | Pragma_Ada_2005
=> declare
5170 if Arg_Count
= 1 then
5171 Check_Arg_Is_Local_Name
(Arg1
);
5172 E_Id
:= Expression
(Arg1
);
5174 if Etype
(E_Id
) = Any_Type
then
5178 Set_Is_Ada_2005_Only
(Entity
(E_Id
));
5181 Check_Arg_Count
(0);
5183 -- For Ada_2005 we unconditionally enforce the documented
5184 -- configuration pragma placement, since we do not want to
5185 -- tolerate mixed modes in a unit involving Ada 2005. That
5186 -- would cause real difficulties for those cases where there
5187 -- are incompatibilities between Ada 95 and Ada 2005.
5189 Check_Valid_Configuration_Pragma
;
5191 -- Now set Ada 2005 mode
5193 Ada_Version
:= Ada_05
;
5194 Ada_Version_Explicit
:= Ada_05
;
5198 ----------------------
5199 -- All_Calls_Remote --
5200 ----------------------
5202 -- pragma All_Calls_Remote [(library_package_NAME)];
5204 when Pragma_All_Calls_Remote
=> All_Calls_Remote
: declare
5205 Lib_Entity
: Entity_Id
;
5208 Check_Ada_83_Warning
;
5209 Check_Valid_Library_Unit_Pragma
;
5211 if Nkind
(N
) = N_Null_Statement
then
5215 Lib_Entity
:= Find_Lib_Unit_Name
;
5217 -- This pragma should only apply to a RCI unit (RM E.2.3(23))
5219 if Present
(Lib_Entity
)
5220 and then not Debug_Flag_U
5222 if not Is_Remote_Call_Interface
(Lib_Entity
) then
5223 Error_Pragma
("pragma% only apply to rci unit");
5225 -- Set flag for entity of the library unit
5228 Set_Has_All_Calls_Remote
(Lib_Entity
);
5232 end All_Calls_Remote
;
5238 -- pragma Annotate (IDENTIFIER [, IDENTIFIER {, ARG}]);
5239 -- ARG ::= NAME | EXPRESSION
5241 -- The first two arguments are by convention intended to refer to an
5242 -- external tool and a tool-specific function. These arguments are
5245 when Pragma_Annotate
=> Annotate
: begin
5247 Check_At_Least_N_Arguments
(1);
5248 Check_Arg_Is_Identifier
(Arg1
);
5255 -- Second unanalyzed parameter is optional
5261 while Present
(Arg
) loop
5262 Exp
:= Expression
(Arg
);
5265 if Is_Entity_Name
(Exp
) then
5268 elsif Nkind
(Exp
) = N_String_Literal
then
5269 Resolve
(Exp
, Standard_String
);
5271 elsif Is_Overloaded
(Exp
) then
5273 ("ambiguous argument for pragma%", Exp
);
5289 -- pragma Assert ([Check =>] Boolean_EXPRESSION
5290 -- [, [Message =>] Static_String_EXPRESSION]);
5292 when Pragma_Assert
=> Assert
: declare
5298 Check_At_Least_N_Arguments
(1);
5299 Check_At_Most_N_Arguments
(2);
5300 Check_Arg_Order
((Name_Check
, Name_Message
));
5301 Check_Optional_Identifier
(Arg1
, Name_Check
);
5303 -- We treat pragma Assert as equivalent to:
5305 -- pragma Check (Assertion, condition [, msg]);
5307 -- So rewrite pragma in this manner, and analyze the result
5309 Expr
:= Get_Pragma_Arg
(Arg1
);
5311 Make_Pragma_Argument_Association
(Loc
,
5313 Make_Identifier
(Loc
,
5314 Chars
=> Name_Assertion
)),
5316 Make_Pragma_Argument_Association
(Sloc
(Expr
),
5317 Expression
=> Expr
));
5319 if Arg_Count
> 1 then
5320 Check_Optional_Identifier
(Arg2
, Name_Message
);
5321 Analyze_And_Resolve
(Get_Pragma_Arg
(Arg2
), Standard_String
);
5322 Append_To
(Newa
, Relocate_Node
(Arg2
));
5327 Chars
=> Name_Check
,
5328 Pragma_Argument_Associations
=> Newa
));
5332 ----------------------
5333 -- Assertion_Policy --
5334 ----------------------
5336 -- pragma Assertion_Policy (Check | Ignore)
5338 when Pragma_Assertion_Policy
=> Assertion_Policy
: declare
5343 Check_Valid_Configuration_Pragma
;
5344 Check_Arg_Count
(1);
5345 Check_No_Identifiers
;
5346 Check_Arg_Is_One_Of
(Arg1
, Name_Check
, Name_Ignore
);
5348 -- We treat pragma Assertion_Policy as equivalent to:
5350 -- pragma Check_Policy (Assertion, policy)
5352 -- So rewrite the pragma in that manner and link on to the chain
5353 -- of Check_Policy pragmas, marking the pragma as analyzed.
5355 Policy
:= Get_Pragma_Arg
(Arg1
);
5359 Chars
=> Name_Check_Policy
,
5361 Pragma_Argument_Associations
=> New_List
(
5362 Make_Pragma_Argument_Association
(Loc
,
5364 Make_Identifier
(Loc
,
5365 Chars
=> Name_Assertion
)),
5367 Make_Pragma_Argument_Association
(Loc
,
5369 Make_Identifier
(Sloc
(Policy
),
5370 Chars
=> Chars
(Policy
))))));
5373 Set_Next_Pragma
(N
, Opt
.Check_Policy_List
);
5374 Opt
.Check_Policy_List
:= N
;
5375 end Assertion_Policy
;
5377 ------------------------------
5378 -- Assume_No_Invalid_Values --
5379 ------------------------------
5381 -- pragma Assume_No_Invalid_Values (On | Off);
5383 when Pragma_Assume_No_Invalid_Values
=>
5385 Check_Valid_Configuration_Pragma
;
5386 Check_Arg_Count
(1);
5387 Check_No_Identifiers
;
5388 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
5390 if Chars
(Expression
(Arg1
)) = Name_On
then
5391 Assume_No_Invalid_Values
:= True;
5393 Assume_No_Invalid_Values
:= False;
5400 -- pragma AST_Entry (entry_IDENTIFIER);
5402 when Pragma_AST_Entry
=> AST_Entry
: declare
5408 Check_Arg_Count
(1);
5409 Check_No_Identifiers
;
5410 Check_Arg_Is_Local_Name
(Arg1
);
5411 Ent
:= Entity
(Expression
(Arg1
));
5413 -- Note: the implementation of the AST_Entry pragma could handle
5414 -- the entry family case fine, but for now we are consistent with
5415 -- the DEC rules, and do not allow the pragma, which of course
5416 -- has the effect of also forbidding the attribute.
5418 if Ekind
(Ent
) /= E_Entry
then
5420 ("pragma% argument must be simple entry name", Arg1
);
5422 elsif Is_AST_Entry
(Ent
) then
5424 ("duplicate % pragma for entry", Arg1
);
5426 elsif Has_Homonym
(Ent
) then
5428 ("pragma% argument cannot specify overloaded entry", Arg1
);
5432 FF
: constant Entity_Id
:= First_Formal
(Ent
);
5435 if Present
(FF
) then
5436 if Present
(Next_Formal
(FF
)) then
5438 ("entry for pragma% can have only one argument",
5441 elsif Parameter_Mode
(FF
) /= E_In_Parameter
then
5443 ("entry parameter for pragma% must have mode IN",
5449 Set_Is_AST_Entry
(Ent
);
5457 -- pragma Asynchronous (LOCAL_NAME);
5459 when Pragma_Asynchronous
=> Asynchronous
: declare
5467 procedure Process_Async_Pragma
;
5468 -- Common processing for procedure and access-to-procedure case
5470 --------------------------
5471 -- Process_Async_Pragma --
5472 --------------------------
5474 procedure Process_Async_Pragma
is
5477 Set_Is_Asynchronous
(Nm
);
5481 -- The formals should be of mode IN (RM E.4.1(6))
5484 while Present
(S
) loop
5485 Formal
:= Defining_Identifier
(S
);
5487 if Nkind
(Formal
) = N_Defining_Identifier
5488 and then Ekind
(Formal
) /= E_In_Parameter
5491 ("pragma% procedure can only have IN parameter",
5498 Set_Is_Asynchronous
(Nm
);
5499 end Process_Async_Pragma
;
5501 -- Start of processing for pragma Asynchronous
5504 Check_Ada_83_Warning
;
5505 Check_No_Identifiers
;
5506 Check_Arg_Count
(1);
5507 Check_Arg_Is_Local_Name
(Arg1
);
5509 if Debug_Flag_U
then
5513 C_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
5514 Analyze
(Expression
(Arg1
));
5515 Nm
:= Entity
(Expression
(Arg1
));
5517 if not Is_Remote_Call_Interface
(C_Ent
)
5518 and then not Is_Remote_Types
(C_Ent
)
5520 -- This pragma should only appear in an RCI or Remote Types
5521 -- unit (RM E.4.1(4)).
5524 ("pragma% not in Remote_Call_Interface or " &
5525 "Remote_Types unit");
5528 if Ekind
(Nm
) = E_Procedure
5529 and then Nkind
(Parent
(Nm
)) = N_Procedure_Specification
5531 if not Is_Remote_Call_Interface
(Nm
) then
5533 ("pragma% cannot be applied on non-remote procedure",
5537 L
:= Parameter_Specifications
(Parent
(Nm
));
5538 Process_Async_Pragma
;
5541 elsif Ekind
(Nm
) = E_Function
then
5543 ("pragma% cannot be applied to function", Arg1
);
5545 elsif Is_Remote_Access_To_Subprogram_Type
(Nm
) then
5547 if Is_Record_Type
(Nm
) then
5549 -- A record type that is the Equivalent_Type for a remote
5550 -- access-to-subprogram type.
5552 N
:= Declaration_Node
(Corresponding_Remote_Type
(Nm
));
5555 -- A non-expanded RAS type (distribution is not enabled)
5557 N
:= Declaration_Node
(Nm
);
5560 if Nkind
(N
) = N_Full_Type_Declaration
5561 and then Nkind
(Type_Definition
(N
)) =
5562 N_Access_Procedure_Definition
5564 L
:= Parameter_Specifications
(Type_Definition
(N
));
5565 Process_Async_Pragma
;
5567 if Is_Asynchronous
(Nm
)
5568 and then Expander_Active
5569 and then Get_PCS_Name
/= Name_No_DSA
5571 RACW_Type_Is_Asynchronous
(Underlying_RACW_Type
(Nm
));
5576 ("pragma% cannot reference access-to-function type",
5580 -- Only other possibility is Access-to-class-wide type
5582 elsif Is_Access_Type
(Nm
)
5583 and then Is_Class_Wide_Type
(Designated_Type
(Nm
))
5585 Check_First_Subtype
(Arg1
);
5586 Set_Is_Asynchronous
(Nm
);
5587 if Expander_Active
then
5588 RACW_Type_Is_Asynchronous
(Nm
);
5592 Error_Pragma_Arg
("inappropriate argument for pragma%", Arg1
);
5600 -- pragma Atomic (LOCAL_NAME);
5602 when Pragma_Atomic
=>
5603 Process_Atomic_Shared_Volatile
;
5605 -----------------------
5606 -- Atomic_Components --
5607 -----------------------
5609 -- pragma Atomic_Components (array_LOCAL_NAME);
5611 -- This processing is shared by Volatile_Components
5613 when Pragma_Atomic_Components |
5614 Pragma_Volatile_Components
=>
5616 Atomic_Components
: declare
5623 Check_Ada_83_Warning
;
5624 Check_No_Identifiers
;
5625 Check_Arg_Count
(1);
5626 Check_Arg_Is_Local_Name
(Arg1
);
5627 E_Id
:= Expression
(Arg1
);
5629 if Etype
(E_Id
) = Any_Type
then
5635 if Rep_Item_Too_Early
(E
, N
)
5637 Rep_Item_Too_Late
(E
, N
)
5642 D
:= Declaration_Node
(E
);
5645 if (K
= N_Full_Type_Declaration
and then Is_Array_Type
(E
))
5647 ((Ekind
(E
) = E_Constant
or else Ekind
(E
) = E_Variable
)
5648 and then Nkind
(D
) = N_Object_Declaration
5649 and then Nkind
(Object_Definition
(D
)) =
5650 N_Constrained_Array_Definition
)
5652 -- The flag is set on the object, or on the base type
5654 if Nkind
(D
) /= N_Object_Declaration
then
5658 Set_Has_Volatile_Components
(E
);
5660 if Prag_Id
= Pragma_Atomic_Components
then
5661 Set_Has_Atomic_Components
(E
);
5663 if Is_Packed
(E
) then
5664 Set_Is_Packed
(E
, False);
5667 ("?Pack canceled, cannot pack atomic components",
5673 Error_Pragma_Arg
("inappropriate entity for pragma%", Arg1
);
5675 end Atomic_Components
;
5677 --------------------
5678 -- Attach_Handler --
5679 --------------------
5681 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
5683 when Pragma_Attach_Handler
=>
5684 Check_Ada_83_Warning
;
5685 Check_No_Identifiers
;
5686 Check_Arg_Count
(2);
5688 if No_Run_Time_Mode
then
5689 Error_Msg_CRT
("Attach_Handler pragma", N
);
5691 Check_Interrupt_Or_Attach_Handler
;
5693 -- The expression that designates the attribute may
5694 -- depend on a discriminant, and is therefore a per-
5695 -- object expression, to be expanded in the init proc.
5696 -- If expansion is enabled, perform semantic checks
5699 if Expander_Active
then
5701 Temp
: constant Node_Id
:=
5702 New_Copy_Tree
(Expression
(Arg2
));
5704 Set_Parent
(Temp
, N
);
5705 Preanalyze_And_Resolve
(Temp
, RTE
(RE_Interrupt_ID
));
5709 Analyze
(Expression
(Arg2
));
5710 Resolve
(Expression
(Arg2
), RTE
(RE_Interrupt_ID
));
5713 Process_Interrupt_Or_Attach_Handler
;
5716 --------------------
5717 -- C_Pass_By_Copy --
5718 --------------------
5720 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
5722 when Pragma_C_Pass_By_Copy
=> C_Pass_By_Copy
: declare
5728 Check_Valid_Configuration_Pragma
;
5729 Check_Arg_Count
(1);
5730 Check_Optional_Identifier
(Arg1
, "max_size");
5732 Arg
:= Expression
(Arg1
);
5733 Check_Arg_Is_Static_Expression
(Arg
, Any_Integer
);
5735 Val
:= Expr_Value
(Arg
);
5739 ("maximum size for pragma% must be positive", Arg1
);
5741 elsif UI_Is_In_Int_Range
(Val
) then
5742 Default_C_Record_Mechanism
:= UI_To_Int
(Val
);
5744 -- If a giant value is given, Int'Last will do well enough.
5745 -- If sometime someone complains that a record larger than
5746 -- two gigabytes is not copied, we will worry about it then!
5749 Default_C_Record_Mechanism
:= Mechanism_Type
'Last;
5757 -- pragma Check ([Name =>] Identifier,
5758 -- [Check =>] Boolean_Expression
5759 -- [,[Message =>] String_Expression]);
5761 when Pragma_Check
=> Check
: declare
5766 -- Set True if category of assertions referenced by Name enabled
5770 Check_At_Least_N_Arguments
(2);
5771 Check_At_Most_N_Arguments
(3);
5772 Check_Optional_Identifier
(Arg1
, Name_Name
);
5773 Check_Optional_Identifier
(Arg2
, Name_Check
);
5775 if Arg_Count
= 3 then
5776 Check_Optional_Identifier
(Arg3
, Name_Message
);
5777 Analyze_And_Resolve
(Get_Pragma_Arg
(Arg3
), Standard_String
);
5780 Check_Arg_Is_Identifier
(Arg1
);
5781 Check_On
:= Check_Enabled
(Chars
(Get_Pragma_Arg
(Arg1
)));
5783 -- If expansion is active and the check is not enabled then we
5784 -- rewrite the Check as:
5786 -- if False and then condition then
5790 -- The reason we do this rewriting during semantic analysis rather
5791 -- than as part of normal expansion is that we cannot analyze and
5792 -- expand the code for the boolean expression directly, or it may
5793 -- cause insertion of actions that would escape the attempt to
5794 -- suppress the check code.
5796 -- Note that the Sloc for the if statement corresponds to the
5797 -- argument condition, not the pragma itself. The reason for this
5798 -- is that we may generate a warning if the condition is False at
5799 -- compile time, and we do not want to delete this warning when we
5800 -- delete the if statement.
5802 Expr
:= Expression
(Arg2
);
5804 if Expander_Active
and then not Check_On
then
5805 Eloc
:= Sloc
(Expr
);
5808 Make_If_Statement
(Eloc
,
5810 Make_And_Then
(Eloc
,
5811 Left_Opnd
=> New_Occurrence_Of
(Standard_False
, Eloc
),
5812 Right_Opnd
=> Expr
),
5813 Then_Statements
=> New_List
(
5814 Make_Null_Statement
(Eloc
))));
5821 Analyze_And_Resolve
(Expr
, Any_Boolean
);
5829 -- pragma Check_Name (check_IDENTIFIER);
5831 when Pragma_Check_Name
=>
5832 Check_No_Identifiers
;
5834 Check_Valid_Configuration_Pragma
;
5835 Check_Arg_Count
(1);
5836 Check_Arg_Is_Identifier
(Arg1
);
5839 Nam
: constant Name_Id
:= Chars
(Expression
(Arg1
));
5842 for J
in Check_Names
.First
.. Check_Names
.Last
loop
5843 if Check_Names
.Table
(J
) = Nam
then
5848 Check_Names
.Append
(Nam
);
5855 -- pragma Check_Policy (
5856 -- [Name =>] IDENTIFIER,
5857 -- [Policy =>] POLICY_IDENTIFIER);
5859 -- POLICY_IDENTIFIER ::= ON | OFF | CHECK | IGNORE
5861 -- Note: this is a configuration pragma, but it is allowed to appear
5864 when Pragma_Check_Policy
=>
5866 Check_Arg_Count
(2);
5867 Check_Optional_Identifier
(Arg1
, Name_Name
);
5868 Check_Optional_Identifier
(Arg2
, Name_Policy
);
5870 (Arg2
, Name_On
, Name_Off
, Name_Check
, Name_Ignore
);
5872 -- A Check_Policy pragma can appear either as a configuration
5873 -- pragma, or in a declarative part or a package spec (see RM
5874 -- 11.5(5) for rules for Suppress/Unsuppress which are also
5875 -- followed for Check_Policy).
5877 if not Is_Configuration_Pragma
then
5878 Check_Is_In_Decl_Part_Or_Package_Spec
;
5881 Set_Next_Pragma
(N
, Opt
.Check_Policy_List
);
5882 Opt
.Check_Policy_List
:= N
;
5884 ---------------------
5885 -- CIL_Constructor --
5886 ---------------------
5888 -- pragma CIL_Constructor ([Entity =>] LOCAL_NAME);
5890 -- Processing for this pragma is shared with Java_Constructor
5896 -- pragma Comment (static_string_EXPRESSION)
5898 -- Processing for pragma Comment shares the circuitry for pragma
5899 -- Ident. The only differences are that Ident enforces a limit of 31
5900 -- characters on its argument, and also enforces limitations on
5901 -- placement for DEC compatibility. Pragma Comment shares neither of
5902 -- these restrictions.
5908 -- pragma Common_Object (
5909 -- [Internal =>] LOCAL_NAME
5910 -- [, [External =>] EXTERNAL_SYMBOL]
5911 -- [, [Size =>] EXTERNAL_SYMBOL]);
5913 -- Processing for this pragma is shared with Psect_Object
5915 ------------------------
5916 -- Compile_Time_Error --
5917 ------------------------
5919 -- pragma Compile_Time_Error
5920 -- (boolean_EXPRESSION, static_string_EXPRESSION);
5922 when Pragma_Compile_Time_Error
=>
5924 Process_Compile_Time_Warning_Or_Error
;
5926 --------------------------
5927 -- Compile_Time_Warning --
5928 --------------------------
5930 -- pragma Compile_Time_Warning
5931 -- (boolean_EXPRESSION, static_string_EXPRESSION);
5933 when Pragma_Compile_Time_Warning
=>
5935 Process_Compile_Time_Warning_Or_Error
;
5941 when Pragma_Compiler_Unit
=>
5943 Check_Arg_Count
(0);
5944 Set_Is_Compiler_Unit
(Get_Source_Unit
(N
));
5946 -----------------------------
5947 -- Complete_Representation --
5948 -----------------------------
5950 -- pragma Complete_Representation;
5952 when Pragma_Complete_Representation
=>
5954 Check_Arg_Count
(0);
5956 if Nkind
(Parent
(N
)) /= N_Record_Representation_Clause
then
5958 ("pragma & must appear within record representation clause");
5961 ----------------------------
5962 -- Complex_Representation --
5963 ----------------------------
5965 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
5967 when Pragma_Complex_Representation
=> Complex_Representation
: declare
5974 Check_Arg_Count
(1);
5975 Check_Optional_Identifier
(Arg1
, Name_Entity
);
5976 Check_Arg_Is_Local_Name
(Arg1
);
5977 E_Id
:= Expression
(Arg1
);
5979 if Etype
(E_Id
) = Any_Type
then
5985 if not Is_Record_Type
(E
) then
5987 ("argument for pragma% must be record type", Arg1
);
5990 Ent
:= First_Entity
(E
);
5993 or else No
(Next_Entity
(Ent
))
5994 or else Present
(Next_Entity
(Next_Entity
(Ent
)))
5995 or else not Is_Floating_Point_Type
(Etype
(Ent
))
5996 or else Etype
(Ent
) /= Etype
(Next_Entity
(Ent
))
5999 ("record for pragma% must have two fields of the same "
6000 & "floating-point type", Arg1
);
6003 Set_Has_Complex_Representation
(Base_Type
(E
));
6005 -- We need to treat the type has having a non-standard
6006 -- representation, for back-end purposes, even though in
6007 -- general a complex will have the default representation
6008 -- of a record with two real components.
6010 Set_Has_Non_Standard_Rep
(Base_Type
(E
));
6012 end Complex_Representation
;
6014 -------------------------
6015 -- Component_Alignment --
6016 -------------------------
6018 -- pragma Component_Alignment (
6019 -- [Form =>] ALIGNMENT_CHOICE
6020 -- [, [Name =>] type_LOCAL_NAME]);
6022 -- ALIGNMENT_CHOICE ::=
6024 -- | Component_Size_4
6028 when Pragma_Component_Alignment
=> Component_AlignmentP
: declare
6029 Args
: Args_List
(1 .. 2);
6030 Names
: constant Name_List
(1 .. 2) := (
6034 Form
: Node_Id
renames Args
(1);
6035 Name
: Node_Id
renames Args
(2);
6037 Atype
: Component_Alignment_Kind
;
6042 Gather_Associations
(Names
, Args
);
6045 Error_Pragma
("missing Form argument for pragma%");
6048 Check_Arg_Is_Identifier
(Form
);
6050 -- Get proper alignment, note that Default = Component_Size on all
6051 -- machines we have so far, and we want to set this value rather
6052 -- than the default value to indicate that it has been explicitly
6053 -- set (and thus will not get overridden by the default component
6054 -- alignment for the current scope)
6056 if Chars
(Form
) = Name_Component_Size
then
6057 Atype
:= Calign_Component_Size
;
6059 elsif Chars
(Form
) = Name_Component_Size_4
then
6060 Atype
:= Calign_Component_Size_4
;
6062 elsif Chars
(Form
) = Name_Default
then
6063 Atype
:= Calign_Component_Size
;
6065 elsif Chars
(Form
) = Name_Storage_Unit
then
6066 Atype
:= Calign_Storage_Unit
;
6070 ("invalid Form parameter for pragma%", Form
);
6073 -- Case with no name, supplied, affects scope table entry
6077 (Scope_Stack
.Last
).Component_Alignment_Default
:= Atype
;
6079 -- Case of name supplied
6082 Check_Arg_Is_Local_Name
(Name
);
6084 Typ
:= Entity
(Name
);
6087 or else Rep_Item_Too_Early
(Typ
, N
)
6091 Typ
:= Underlying_Type
(Typ
);
6094 if not Is_Record_Type
(Typ
)
6095 and then not Is_Array_Type
(Typ
)
6098 ("Name parameter of pragma% must identify record or " &
6099 "array type", Name
);
6102 -- An explicit Component_Alignment pragma overrides an
6103 -- implicit pragma Pack, but not an explicit one.
6105 if not Has_Pragma_Pack
(Base_Type
(Typ
)) then
6106 Set_Is_Packed
(Base_Type
(Typ
), False);
6107 Set_Component_Alignment
(Base_Type
(Typ
), Atype
);
6110 end Component_AlignmentP
;
6116 -- pragma Controlled (first_subtype_LOCAL_NAME);
6118 when Pragma_Controlled
=> Controlled
: declare
6122 Check_No_Identifiers
;
6123 Check_Arg_Count
(1);
6124 Check_Arg_Is_Local_Name
(Arg1
);
6125 Arg
:= Expression
(Arg1
);
6127 if not Is_Entity_Name
(Arg
)
6128 or else not Is_Access_Type
(Entity
(Arg
))
6130 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
6132 Set_Has_Pragma_Controlled
(Base_Type
(Entity
(Arg
)));
6140 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
6141 -- [Entity =>] LOCAL_NAME);
6143 when Pragma_Convention
=> Convention
: declare
6146 pragma Warnings
(Off
, C
);
6147 pragma Warnings
(Off
, E
);
6149 Check_Arg_Order
((Name_Convention
, Name_Entity
));
6150 Check_Ada_83_Warning
;
6151 Check_Arg_Count
(2);
6152 Process_Convention
(C
, E
);
6155 ---------------------------
6156 -- Convention_Identifier --
6157 ---------------------------
6159 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
6160 -- [Convention =>] convention_IDENTIFIER);
6162 when Pragma_Convention_Identifier
=> Convention_Identifier
: declare
6168 Check_Arg_Order
((Name_Name
, Name_Convention
));
6169 Check_Arg_Count
(2);
6170 Check_Optional_Identifier
(Arg1
, Name_Name
);
6171 Check_Optional_Identifier
(Arg2
, Name_Convention
);
6172 Check_Arg_Is_Identifier
(Arg1
);
6173 Check_Arg_Is_Identifier
(Arg2
);
6174 Idnam
:= Chars
(Expression
(Arg1
));
6175 Cname
:= Chars
(Expression
(Arg2
));
6177 if Is_Convention_Name
(Cname
) then
6178 Record_Convention_Identifier
6179 (Idnam
, Get_Convention_Id
(Cname
));
6182 ("second arg for % pragma must be convention", Arg2
);
6184 end Convention_Identifier
;
6190 -- pragma CPP_Class ([Entity =>] local_NAME)
6192 when Pragma_CPP_Class
=> CPP_Class
: declare
6197 if Warn_On_Obsolescent_Feature
then
6199 ("'G'N'A'T pragma cpp'_class is now obsolete; replace it" &
6200 " by pragma import?", N
);
6204 Check_Arg_Count
(1);
6205 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6206 Check_Arg_Is_Local_Name
(Arg1
);
6208 Arg
:= Expression
(Arg1
);
6211 if Etype
(Arg
) = Any_Type
then
6215 if not Is_Entity_Name
(Arg
)
6216 or else not Is_Type
(Entity
(Arg
))
6218 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
6221 Typ
:= Entity
(Arg
);
6223 if not Is_Tagged_Type
(Typ
) then
6224 Error_Pragma_Arg
("pragma% applicable to tagged types ", Arg1
);
6227 -- Types treated as CPP classes are treated as limited, but we
6228 -- don't require them to be declared this way. A warning is issued
6229 -- to encourage the user to declare them as limited. This is not
6230 -- an error, for compatibility reasons, because these types have
6231 -- been supported this way for some time.
6233 if not Is_Limited_Type
(Typ
) then
6235 ("imported 'C'P'P type should be " &
6236 "explicitly declared limited?",
6237 Get_Pragma_Arg
(Arg1
));
6239 ("\type will be considered limited",
6240 Get_Pragma_Arg
(Arg1
));
6243 Set_Is_CPP_Class
(Typ
);
6244 Set_Is_Limited_Record
(Typ
);
6245 Set_Convention
(Typ
, Convention_CPP
);
6247 -- Imported CPP types must not have discriminants (because C++
6248 -- classes do not have discriminants).
6250 if Has_Discriminants
(Typ
) then
6252 ("imported 'C'P'P type cannot have discriminants",
6253 First
(Discriminant_Specifications
6254 (Declaration_Node
(Typ
))));
6257 -- Components of imported CPP types must not have default
6258 -- expressions because the constructor (if any) is in the
6261 if Is_Incomplete_Or_Private_Type
(Typ
)
6262 and then No
(Underlying_Type
(Typ
))
6264 -- It should be an error to apply pragma CPP to a private
6265 -- type if the underlying type is not visible (as it is
6266 -- for any representation item). For now, for backward
6267 -- compatibility we do nothing but we cannot check components
6268 -- because they are not available at this stage. All this code
6269 -- will be removed when we cleanup this obsolete GNAT pragma???
6275 Tdef
: constant Node_Id
:=
6276 Type_Definition
(Declaration_Node
(Typ
));
6281 if Nkind
(Tdef
) = N_Record_Definition
then
6282 Clist
:= Component_List
(Tdef
);
6284 pragma Assert
(Nkind
(Tdef
) = N_Derived_Type_Definition
);
6285 Clist
:= Component_List
(Record_Extension_Part
(Tdef
));
6288 if Present
(Clist
) then
6289 Comp
:= First
(Component_Items
(Clist
));
6290 while Present
(Comp
) loop
6291 if Present
(Expression
(Comp
)) then
6293 ("component of imported 'C'P'P type cannot have" &
6294 " default expression", Expression
(Comp
));
6304 ---------------------
6305 -- CPP_Constructor --
6306 ---------------------
6308 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME
6309 -- [, [External_Name =>] static_string_EXPRESSION ]
6310 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6312 when Pragma_CPP_Constructor
=> CPP_Constructor
: declare
6316 Tag_Typ
: Entity_Id
;
6320 Check_At_Least_N_Arguments
(1);
6321 Check_At_Most_N_Arguments
(3);
6322 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6323 Check_Arg_Is_Local_Name
(Arg1
);
6325 Id
:= Expression
(Arg1
);
6326 Find_Program_Unit_Name
(Id
);
6328 -- If we did not find the name, we are done
6330 if Etype
(Id
) = Any_Type
then
6334 Def_Id
:= Entity
(Id
);
6336 if Ekind
(Def_Id
) = E_Function
6337 and then (Is_CPP_Class
(Etype
(Def_Id
))
6338 or else (Is_Class_Wide_Type
(Etype
(Def_Id
))
6340 Is_CPP_Class
(Root_Type
(Etype
(Def_Id
)))))
6342 if Arg_Count
>= 2 then
6343 Set_Imported
(Def_Id
);
6344 Set_Is_Public
(Def_Id
);
6345 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
6348 Set_Has_Completion
(Def_Id
);
6349 Set_Is_Constructor
(Def_Id
);
6351 -- Imported C++ constructors are not dispatching primitives
6352 -- because in C++ they don't have a dispatch table slot.
6353 -- However, in Ada the constructor has the profile of a
6354 -- function that returns a tagged type and therefore it has
6355 -- been treated as a primitive operation during semantic
6356 -- analysis. We now remove it from the list of primitive
6357 -- operations of the type.
6359 if Is_Tagged_Type
(Etype
(Def_Id
))
6360 and then not Is_Class_Wide_Type
(Etype
(Def_Id
))
6362 pragma Assert
(Is_Dispatching_Operation
(Def_Id
));
6363 Tag_Typ
:= Etype
(Def_Id
);
6365 Elmt
:= First_Elmt
(Primitive_Operations
(Tag_Typ
));
6366 while Present
(Elmt
) and then Node
(Elmt
) /= Def_Id
loop
6370 Remove_Elmt
(Primitive_Operations
(Tag_Typ
), Elmt
);
6371 Set_Is_Dispatching_Operation
(Def_Id
, False);
6374 -- For backward compatibility, if the constructor returns a
6375 -- class wide type, and we internally change the return type to
6376 -- the corresponding root type.
6378 if Is_Class_Wide_Type
(Etype
(Def_Id
)) then
6379 Set_Etype
(Def_Id
, Root_Type
(Etype
(Def_Id
)));
6383 ("pragma% requires function returning a 'C'P'P_Class type",
6386 end CPP_Constructor
;
6392 when Pragma_CPP_Virtual
=> CPP_Virtual
: declare
6396 if Warn_On_Obsolescent_Feature
then
6398 ("'G'N'A'T pragma cpp'_virtual is now obsolete and has " &
6407 when Pragma_CPP_Vtable
=> CPP_Vtable
: declare
6411 if Warn_On_Obsolescent_Feature
then
6413 ("'G'N'A'T pragma cpp'_vtable is now obsolete and has " &
6422 -- pragma Debug ([boolean_EXPRESSION,] PROCEDURE_CALL_STATEMENT);
6424 when Pragma_Debug
=> Debug
: declare
6432 (Boolean_Literals
(Debug_Pragmas_Enabled
and Expander_Active
),
6435 if Arg_Count
= 2 then
6438 Left_Opnd
=> Relocate_Node
(Cond
),
6439 Right_Opnd
=> Expression
(Arg1
));
6442 -- Rewrite into a conditional with an appropriate condition. We
6443 -- wrap the procedure call in a block so that overhead from e.g.
6444 -- use of the secondary stack does not generate execution overhead
6445 -- for suppressed conditions.
6447 Rewrite
(N
, Make_Implicit_If_Statement
(N
,
6449 Then_Statements
=> New_List
(
6450 Make_Block_Statement
(Loc
,
6451 Handled_Statement_Sequence
=>
6452 Make_Handled_Sequence_Of_Statements
(Loc
,
6453 Statements
=> New_List
(
6454 Relocate_Node
(Debug_Statement
(N
))))))));
6462 -- pragma Debug_Policy (Check | Ignore)
6464 when Pragma_Debug_Policy
=>
6466 Check_Arg_Count
(1);
6467 Check_Arg_Is_One_Of
(Arg1
, Name_Check
, Name_Ignore
);
6468 Debug_Pragmas_Enabled
:= Chars
(Expression
(Arg1
)) = Name_Check
;
6470 ---------------------
6471 -- Detect_Blocking --
6472 ---------------------
6474 -- pragma Detect_Blocking;
6476 when Pragma_Detect_Blocking
=>
6478 Check_Arg_Count
(0);
6479 Check_Valid_Configuration_Pragma
;
6480 Detect_Blocking
:= True;
6486 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
6488 when Pragma_Discard_Names
=> Discard_Names
: declare
6493 Check_Ada_83_Warning
;
6495 -- Deal with configuration pragma case
6497 if Arg_Count
= 0 and then Is_Configuration_Pragma
then
6498 Global_Discard_Names
:= True;
6501 -- Otherwise, check correct appropriate context
6504 Check_Is_In_Decl_Part_Or_Package_Spec
;
6506 if Arg_Count
= 0 then
6508 -- If there is no parameter, then from now on this pragma
6509 -- applies to any enumeration, exception or tagged type
6510 -- defined in the current declarative part, and recursively
6511 -- to any nested scope.
6513 Set_Discard_Names
(Current_Scope
);
6517 Check_Arg_Count
(1);
6518 Check_Optional_Identifier
(Arg1
, Name_On
);
6519 Check_Arg_Is_Local_Name
(Arg1
);
6521 E_Id
:= Expression
(Arg1
);
6523 if Etype
(E_Id
) = Any_Type
then
6529 if (Is_First_Subtype
(E
)
6531 (Is_Enumeration_Type
(E
) or else Is_Tagged_Type
(E
)))
6532 or else Ekind
(E
) = E_Exception
6534 Set_Discard_Names
(E
);
6537 ("inappropriate entity for pragma%", Arg1
);
6548 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
6550 when Pragma_Elaborate
=> Elaborate
: declare
6555 -- Pragma must be in context items list of a compilation unit
6557 if not Is_In_Context_Clause
then
6561 -- Must be at least one argument
6563 if Arg_Count
= 0 then
6564 Error_Pragma
("pragma% requires at least one argument");
6567 -- In Ada 83 mode, there can be no items following it in the
6568 -- context list except other pragmas and implicit with clauses
6569 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
6570 -- placement rule does not apply.
6572 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
6574 while Present
(Citem
) loop
6575 if Nkind
(Citem
) = N_Pragma
6576 or else (Nkind
(Citem
) = N_With_Clause
6577 and then Implicit_With
(Citem
))
6582 ("(Ada 83) pragma% must be at end of context clause");
6589 -- Finally, the arguments must all be units mentioned in a with
6590 -- clause in the same context clause. Note we already checked (in
6591 -- Par.Prag) that the arguments are all identifiers or selected
6595 Outer
: while Present
(Arg
) loop
6596 Citem
:= First
(List_Containing
(N
));
6597 Inner
: while Citem
/= N
loop
6598 if Nkind
(Citem
) = N_With_Clause
6599 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
6601 Set_Elaborate_Present
(Citem
, True);
6602 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
6604 -- With the pragma present, elaboration calls on
6605 -- subprograms from the named unit need no further
6606 -- checks, as long as the pragma appears in the current
6607 -- compilation unit. If the pragma appears in some unit
6608 -- in the context, there might still be a need for an
6609 -- Elaborate_All_Desirable from the current compilation
6610 -- to the named unit, so we keep the check enabled.
6612 if In_Extended_Main_Source_Unit
(N
) then
6613 Set_Suppress_Elaboration_Warnings
6614 (Entity
(Name
(Citem
)));
6625 ("argument of pragma% is not with'ed unit", Arg
);
6631 -- Give a warning if operating in static mode with -gnatwl
6632 -- (elaboration warnings enabled) switch set.
6634 if Elab_Warnings
and not Dynamic_Elaboration_Checks
then
6636 ("?use of pragma Elaborate may not be safe", N
);
6638 ("?use pragma Elaborate_All instead if possible", N
);
6646 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
6648 when Pragma_Elaborate_All
=> Elaborate_All
: declare
6653 Check_Ada_83_Warning
;
6655 -- Pragma must be in context items list of a compilation unit
6657 if not Is_In_Context_Clause
then
6661 -- Must be at least one argument
6663 if Arg_Count
= 0 then
6664 Error_Pragma
("pragma% requires at least one argument");
6667 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
6668 -- have to appear at the end of the context clause, but may
6669 -- appear mixed in with other items, even in Ada 83 mode.
6671 -- Final check: the arguments must all be units mentioned in
6672 -- a with clause in the same context clause. Note that we
6673 -- already checked (in Par.Prag) that all the arguments are
6674 -- either identifiers or selected components.
6677 Outr
: while Present
(Arg
) loop
6678 Citem
:= First
(List_Containing
(N
));
6679 Innr
: while Citem
/= N
loop
6680 if Nkind
(Citem
) = N_With_Clause
6681 and then Same_Name
(Name
(Citem
), Expression
(Arg
))
6683 Set_Elaborate_All_Present
(Citem
, True);
6684 Set_Unit_Name
(Expression
(Arg
), Name
(Citem
));
6686 -- Suppress warnings and elaboration checks on the named
6687 -- unit if the pragma is in the current compilation, as
6688 -- for pragma Elaborate.
6690 if In_Extended_Main_Source_Unit
(N
) then
6691 Set_Suppress_Elaboration_Warnings
6692 (Entity
(Name
(Citem
)));
6701 Set_Error_Posted
(N
);
6703 ("argument of pragma% is not with'ed unit", Arg
);
6710 --------------------
6711 -- Elaborate_Body --
6712 --------------------
6714 -- pragma Elaborate_Body [( library_unit_NAME )];
6716 when Pragma_Elaborate_Body
=> Elaborate_Body
: declare
6717 Cunit_Node
: Node_Id
;
6718 Cunit_Ent
: Entity_Id
;
6721 Check_Ada_83_Warning
;
6722 Check_Valid_Library_Unit_Pragma
;
6724 if Nkind
(N
) = N_Null_Statement
then
6728 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
6729 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
6731 if Nkind_In
(Unit
(Cunit_Node
), N_Package_Body
,
6734 Error_Pragma
("pragma% must refer to a spec, not a body");
6736 Set_Body_Required
(Cunit_Node
, True);
6737 Set_Has_Pragma_Elaborate_Body
(Cunit_Ent
);
6739 -- If we are in dynamic elaboration mode, then we suppress
6740 -- elaboration warnings for the unit, since it is definitely
6741 -- fine NOT to do dynamic checks at the first level (and such
6742 -- checks will be suppressed because no elaboration boolean
6743 -- is created for Elaborate_Body packages).
6745 -- But in the static model of elaboration, Elaborate_Body is
6746 -- definitely NOT good enough to ensure elaboration safety on
6747 -- its own, since the body may WITH other units that are not
6748 -- safe from an elaboration point of view, so a client must
6749 -- still do an Elaborate_All on such units.
6751 -- Debug flag -gnatdD restores the old behavior of 3.13, where
6752 -- Elaborate_Body always suppressed elab warnings.
6754 if Dynamic_Elaboration_Checks
or Debug_Flag_DD
then
6755 Set_Suppress_Elaboration_Warnings
(Cunit_Ent
);
6760 ------------------------
6761 -- Elaboration_Checks --
6762 ------------------------
6764 -- pragma Elaboration_Checks (Static | Dynamic);
6766 when Pragma_Elaboration_Checks
=>
6768 Check_Arg_Count
(1);
6769 Check_Arg_Is_One_Of
(Arg1
, Name_Static
, Name_Dynamic
);
6770 Dynamic_Elaboration_Checks
:=
6771 (Chars
(Get_Pragma_Arg
(Arg1
)) = Name_Dynamic
);
6777 -- pragma Eliminate (
6778 -- [Unit_Name =>] IDENTIFIER | SELECTED_COMPONENT,
6779 -- [,[Entity =>] IDENTIFIER |
6780 -- SELECTED_COMPONENT |
6782 -- [, OVERLOADING_RESOLUTION]);
6784 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
6787 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
6790 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
6792 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
6793 -- Result_Type => result_SUBTYPE_NAME]
6795 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
6796 -- SUBTYPE_NAME ::= STRING_LITERAL
6798 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
6799 -- SOURCE_TRACE ::= STRING_LITERAL
6801 when Pragma_Eliminate
=> Eliminate
: declare
6802 Args
: Args_List
(1 .. 5);
6803 Names
: constant Name_List
(1 .. 5) := (
6806 Name_Parameter_Types
,
6808 Name_Source_Location
);
6810 Unit_Name
: Node_Id
renames Args
(1);
6811 Entity
: Node_Id
renames Args
(2);
6812 Parameter_Types
: Node_Id
renames Args
(3);
6813 Result_Type
: Node_Id
renames Args
(4);
6814 Source_Location
: Node_Id
renames Args
(5);
6818 Check_Valid_Configuration_Pragma
;
6819 Gather_Associations
(Names
, Args
);
6821 if No
(Unit_Name
) then
6822 Error_Pragma
("missing Unit_Name argument for pragma%");
6826 and then (Present
(Parameter_Types
)
6828 Present
(Result_Type
)
6830 Present
(Source_Location
))
6832 Error_Pragma
("missing Entity argument for pragma%");
6835 if (Present
(Parameter_Types
)
6837 Present
(Result_Type
))
6839 Present
(Source_Location
)
6842 ("parameter profile and source location cannot " &
6843 "be used together in pragma%");
6846 Process_Eliminate_Pragma
6860 -- [ Convention =>] convention_IDENTIFIER,
6861 -- [ Entity =>] local_NAME
6862 -- [, [External_Name =>] static_string_EXPRESSION ]
6863 -- [, [Link_Name =>] static_string_EXPRESSION ]);
6865 when Pragma_Export
=> Export
: declare
6869 pragma Warnings
(Off
, C
);
6872 Check_Ada_83_Warning
;
6878 Check_At_Least_N_Arguments
(2);
6879 Check_At_Most_N_Arguments
(4);
6880 Process_Convention
(C
, Def_Id
);
6882 if Ekind
(Def_Id
) /= E_Constant
then
6883 Note_Possible_Modification
(Expression
(Arg2
), Sure
=> False);
6886 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
6887 Set_Exported
(Def_Id
, Arg2
);
6889 -- If the entity is a deferred constant, propagate the information
6890 -- to the full view, because gigi elaborates the full view only.
6892 if Ekind
(Def_Id
) = E_Constant
6893 and then Present
(Full_View
(Def_Id
))
6896 Id2
: constant Entity_Id
:= Full_View
(Def_Id
);
6898 Set_Is_Exported
(Id2
, Is_Exported
(Def_Id
));
6899 Set_First_Rep_Item
(Id2
, First_Rep_Item
(Def_Id
));
6900 Set_Interface_Name
(Id2
, Einfo
.Interface_Name
(Def_Id
));
6905 ----------------------
6906 -- Export_Exception --
6907 ----------------------
6909 -- pragma Export_Exception (
6910 -- [Internal =>] LOCAL_NAME
6911 -- [, [External =>] EXTERNAL_SYMBOL]
6912 -- [, [Form =>] Ada | VMS]
6913 -- [, [Code =>] static_integer_EXPRESSION]);
6915 when Pragma_Export_Exception
=> Export_Exception
: declare
6916 Args
: Args_List
(1 .. 4);
6917 Names
: constant Name_List
(1 .. 4) := (
6923 Internal
: Node_Id
renames Args
(1);
6924 External
: Node_Id
renames Args
(2);
6925 Form
: Node_Id
renames Args
(3);
6926 Code
: Node_Id
renames Args
(4);
6931 if Inside_A_Generic
then
6932 Error_Pragma
("pragma% cannot be used for generic entities");
6935 Gather_Associations
(Names
, Args
);
6936 Process_Extended_Import_Export_Exception_Pragma
(
6937 Arg_Internal
=> Internal
,
6938 Arg_External
=> External
,
6942 if not Is_VMS_Exception
(Entity
(Internal
)) then
6943 Set_Exported
(Entity
(Internal
), Internal
);
6945 end Export_Exception
;
6947 ---------------------
6948 -- Export_Function --
6949 ---------------------
6951 -- pragma Export_Function (
6952 -- [Internal =>] LOCAL_NAME
6953 -- [, [External =>] EXTERNAL_SYMBOL]
6954 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
6955 -- [, [Result_Type =>] TYPE_DESIGNATOR]
6956 -- [, [Mechanism =>] MECHANISM]
6957 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
6959 -- EXTERNAL_SYMBOL ::=
6961 -- | static_string_EXPRESSION
6963 -- PARAMETER_TYPES ::=
6965 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
6967 -- TYPE_DESIGNATOR ::=
6969 -- | subtype_Name ' Access
6973 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
6975 -- MECHANISM_ASSOCIATION ::=
6976 -- [formal_parameter_NAME =>] MECHANISM_NAME
6978 -- MECHANISM_NAME ::=
6981 -- | Descriptor [([Class =>] CLASS_NAME)]
6983 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
6985 when Pragma_Export_Function
=> Export_Function
: declare
6986 Args
: Args_List
(1 .. 6);
6987 Names
: constant Name_List
(1 .. 6) := (
6990 Name_Parameter_Types
,
6993 Name_Result_Mechanism
);
6995 Internal
: Node_Id
renames Args
(1);
6996 External
: Node_Id
renames Args
(2);
6997 Parameter_Types
: Node_Id
renames Args
(3);
6998 Result_Type
: Node_Id
renames Args
(4);
6999 Mechanism
: Node_Id
renames Args
(5);
7000 Result_Mechanism
: Node_Id
renames Args
(6);
7004 Gather_Associations
(Names
, Args
);
7005 Process_Extended_Import_Export_Subprogram_Pragma
(
7006 Arg_Internal
=> Internal
,
7007 Arg_External
=> External
,
7008 Arg_Parameter_Types
=> Parameter_Types
,
7009 Arg_Result_Type
=> Result_Type
,
7010 Arg_Mechanism
=> Mechanism
,
7011 Arg_Result_Mechanism
=> Result_Mechanism
);
7012 end Export_Function
;
7018 -- pragma Export_Object (
7019 -- [Internal =>] LOCAL_NAME
7020 -- [, [External =>] EXTERNAL_SYMBOL]
7021 -- [, [Size =>] EXTERNAL_SYMBOL]);
7023 -- EXTERNAL_SYMBOL ::=
7025 -- | static_string_EXPRESSION
7027 -- PARAMETER_TYPES ::=
7029 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7031 -- TYPE_DESIGNATOR ::=
7033 -- | subtype_Name ' Access
7037 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7039 -- MECHANISM_ASSOCIATION ::=
7040 -- [formal_parameter_NAME =>] MECHANISM_NAME
7042 -- MECHANISM_NAME ::=
7045 -- | Descriptor [([Class =>] CLASS_NAME)]
7047 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7049 when Pragma_Export_Object
=> Export_Object
: declare
7050 Args
: Args_List
(1 .. 3);
7051 Names
: constant Name_List
(1 .. 3) := (
7056 Internal
: Node_Id
renames Args
(1);
7057 External
: Node_Id
renames Args
(2);
7058 Size
: Node_Id
renames Args
(3);
7062 Gather_Associations
(Names
, Args
);
7063 Process_Extended_Import_Export_Object_Pragma
(
7064 Arg_Internal
=> Internal
,
7065 Arg_External
=> External
,
7069 ----------------------
7070 -- Export_Procedure --
7071 ----------------------
7073 -- pragma Export_Procedure (
7074 -- [Internal =>] LOCAL_NAME
7075 -- [, [External =>] EXTERNAL_SYMBOL]
7076 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7077 -- [, [Mechanism =>] MECHANISM]);
7079 -- EXTERNAL_SYMBOL ::=
7081 -- | static_string_EXPRESSION
7083 -- PARAMETER_TYPES ::=
7085 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7087 -- TYPE_DESIGNATOR ::=
7089 -- | subtype_Name ' Access
7093 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7095 -- MECHANISM_ASSOCIATION ::=
7096 -- [formal_parameter_NAME =>] MECHANISM_NAME
7098 -- MECHANISM_NAME ::=
7101 -- | Descriptor [([Class =>] CLASS_NAME)]
7103 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7105 when Pragma_Export_Procedure
=> Export_Procedure
: declare
7106 Args
: Args_List
(1 .. 4);
7107 Names
: constant Name_List
(1 .. 4) := (
7110 Name_Parameter_Types
,
7113 Internal
: Node_Id
renames Args
(1);
7114 External
: Node_Id
renames Args
(2);
7115 Parameter_Types
: Node_Id
renames Args
(3);
7116 Mechanism
: Node_Id
renames Args
(4);
7120 Gather_Associations
(Names
, Args
);
7121 Process_Extended_Import_Export_Subprogram_Pragma
(
7122 Arg_Internal
=> Internal
,
7123 Arg_External
=> External
,
7124 Arg_Parameter_Types
=> Parameter_Types
,
7125 Arg_Mechanism
=> Mechanism
);
7126 end Export_Procedure
;
7132 -- pragma Export_Value (
7133 -- [Value =>] static_integer_EXPRESSION,
7134 -- [Link_Name =>] static_string_EXPRESSION);
7136 when Pragma_Export_Value
=>
7138 Check_Arg_Order
((Name_Value
, Name_Link_Name
));
7139 Check_Arg_Count
(2);
7141 Check_Optional_Identifier
(Arg1
, Name_Value
);
7142 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
7144 Check_Optional_Identifier
(Arg2
, Name_Link_Name
);
7145 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
7147 -----------------------------
7148 -- Export_Valued_Procedure --
7149 -----------------------------
7151 -- pragma Export_Valued_Procedure (
7152 -- [Internal =>] LOCAL_NAME
7153 -- [, [External =>] EXTERNAL_SYMBOL,]
7154 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7155 -- [, [Mechanism =>] MECHANISM]);
7157 -- EXTERNAL_SYMBOL ::=
7159 -- | static_string_EXPRESSION
7161 -- PARAMETER_TYPES ::=
7163 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7165 -- TYPE_DESIGNATOR ::=
7167 -- | subtype_Name ' Access
7171 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7173 -- MECHANISM_ASSOCIATION ::=
7174 -- [formal_parameter_NAME =>] MECHANISM_NAME
7176 -- MECHANISM_NAME ::=
7179 -- | Descriptor [([Class =>] CLASS_NAME)]
7181 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7183 when Pragma_Export_Valued_Procedure
=>
7184 Export_Valued_Procedure
: declare
7185 Args
: Args_List
(1 .. 4);
7186 Names
: constant Name_List
(1 .. 4) := (
7189 Name_Parameter_Types
,
7192 Internal
: Node_Id
renames Args
(1);
7193 External
: Node_Id
renames Args
(2);
7194 Parameter_Types
: Node_Id
renames Args
(3);
7195 Mechanism
: Node_Id
renames Args
(4);
7199 Gather_Associations
(Names
, Args
);
7200 Process_Extended_Import_Export_Subprogram_Pragma
(
7201 Arg_Internal
=> Internal
,
7202 Arg_External
=> External
,
7203 Arg_Parameter_Types
=> Parameter_Types
,
7204 Arg_Mechanism
=> Mechanism
);
7205 end Export_Valued_Procedure
;
7211 -- pragma Extend_System ([Name =>] Identifier);
7213 when Pragma_Extend_System
=> Extend_System
: declare
7216 Check_Valid_Configuration_Pragma
;
7217 Check_Arg_Count
(1);
7218 Check_Optional_Identifier
(Arg1
, Name_Name
);
7219 Check_Arg_Is_Identifier
(Arg1
);
7221 Get_Name_String
(Chars
(Expression
(Arg1
)));
7224 and then Name_Buffer
(1 .. 4) = "aux_"
7226 if Present
(System_Extend_Pragma_Arg
) then
7227 if Chars
(Expression
(Arg1
)) =
7228 Chars
(Expression
(System_Extend_Pragma_Arg
))
7232 Error_Msg_Sloc
:= Sloc
(System_Extend_Pragma_Arg
);
7233 Error_Pragma
("pragma% conflicts with that #");
7237 System_Extend_Pragma_Arg
:= Arg1
;
7239 if not GNAT_Mode
then
7240 System_Extend_Unit
:= Arg1
;
7244 Error_Pragma
("incorrect name for pragma%, must be Aux_xxx");
7248 ------------------------
7249 -- Extensions_Allowed --
7250 ------------------------
7252 -- pragma Extensions_Allowed (ON | OFF);
7254 when Pragma_Extensions_Allowed
=>
7256 Check_Arg_Count
(1);
7257 Check_No_Identifiers
;
7258 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
7260 if Chars
(Expression
(Arg1
)) = Name_On
then
7261 Extensions_Allowed
:= True;
7263 Extensions_Allowed
:= False;
7270 -- pragma External (
7271 -- [ Convention =>] convention_IDENTIFIER,
7272 -- [ Entity =>] local_NAME
7273 -- [, [External_Name =>] static_string_EXPRESSION ]
7274 -- [, [Link_Name =>] static_string_EXPRESSION ]);
7276 when Pragma_External
=> External
: declare
7280 pragma Warnings
(Off
, C
);
7289 Check_At_Least_N_Arguments
(2);
7290 Check_At_Most_N_Arguments
(4);
7291 Process_Convention
(C
, Def_Id
);
7292 Note_Possible_Modification
(Expression
(Arg2
), Sure
=> False);
7293 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
7294 Set_Exported
(Def_Id
, Arg2
);
7297 --------------------------
7298 -- External_Name_Casing --
7299 --------------------------
7301 -- pragma External_Name_Casing (
7302 -- UPPERCASE | LOWERCASE
7303 -- [, AS_IS | UPPERCASE | LOWERCASE]);
7305 when Pragma_External_Name_Casing
=> External_Name_Casing
: declare
7308 Check_No_Identifiers
;
7310 if Arg_Count
= 2 then
7312 (Arg2
, Name_As_Is
, Name_Uppercase
, Name_Lowercase
);
7314 case Chars
(Get_Pragma_Arg
(Arg2
)) is
7316 Opt
.External_Name_Exp_Casing
:= As_Is
;
7318 when Name_Uppercase
=>
7319 Opt
.External_Name_Exp_Casing
:= Uppercase
;
7321 when Name_Lowercase
=>
7322 Opt
.External_Name_Exp_Casing
:= Lowercase
;
7329 Check_Arg_Count
(1);
7332 Check_Arg_Is_One_Of
(Arg1
, Name_Uppercase
, Name_Lowercase
);
7334 case Chars
(Get_Pragma_Arg
(Arg1
)) is
7335 when Name_Uppercase
=>
7336 Opt
.External_Name_Imp_Casing
:= Uppercase
;
7338 when Name_Lowercase
=>
7339 Opt
.External_Name_Imp_Casing
:= Lowercase
;
7344 end External_Name_Casing
;
7346 --------------------------
7347 -- Favor_Top_Level --
7348 --------------------------
7350 -- pragma Favor_Top_Level (type_NAME);
7352 when Pragma_Favor_Top_Level
=> Favor_Top_Level
: declare
7353 Named_Entity
: Entity_Id
;
7357 Check_No_Identifiers
;
7358 Check_Arg_Count
(1);
7359 Check_Arg_Is_Local_Name
(Arg1
);
7360 Named_Entity
:= Entity
(Expression
(Arg1
));
7362 -- If it's an access-to-subprogram type (in particular, not a
7363 -- subtype), set the flag on that type.
7365 if Is_Access_Subprogram_Type
(Named_Entity
) then
7366 Set_Can_Use_Internal_Rep
(Named_Entity
, False);
7368 -- Otherwise it's an error (name denotes the wrong sort of entity)
7372 ("access-to-subprogram type expected", Expression
(Arg1
));
7374 end Favor_Top_Level
;
7380 -- pragma Fast_Math;
7382 when Pragma_Fast_Math
=>
7384 Check_No_Identifiers
;
7385 Check_Valid_Configuration_Pragma
;
7388 ---------------------------
7389 -- Finalize_Storage_Only --
7390 ---------------------------
7392 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
7394 when Pragma_Finalize_Storage_Only
=> Finalize_Storage
: declare
7395 Assoc
: constant Node_Id
:= Arg1
;
7396 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
7401 Check_No_Identifiers
;
7402 Check_Arg_Count
(1);
7403 Check_Arg_Is_Local_Name
(Arg1
);
7405 Find_Type
(Type_Id
);
7406 Typ
:= Entity
(Type_Id
);
7409 or else Rep_Item_Too_Early
(Typ
, N
)
7413 Typ
:= Underlying_Type
(Typ
);
7416 if not Is_Controlled
(Typ
) then
7417 Error_Pragma
("pragma% must specify controlled type");
7420 Check_First_Subtype
(Arg1
);
7422 if Finalize_Storage_Only
(Typ
) then
7423 Error_Pragma
("duplicate pragma%, only one allowed");
7425 elsif not Rep_Item_Too_Late
(Typ
, N
) then
7426 Set_Finalize_Storage_Only
(Base_Type
(Typ
), True);
7428 end Finalize_Storage
;
7430 --------------------------
7431 -- Float_Representation --
7432 --------------------------
7434 -- pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
7436 -- FLOAT_REP ::= VAX_Float | IEEE_Float
7438 when Pragma_Float_Representation
=> Float_Representation
: declare
7446 if Arg_Count
= 1 then
7447 Check_Valid_Configuration_Pragma
;
7449 Check_Arg_Count
(2);
7450 Check_Optional_Identifier
(Arg2
, Name_Entity
);
7451 Check_Arg_Is_Local_Name
(Arg2
);
7454 Check_No_Identifier
(Arg1
);
7455 Check_Arg_Is_One_Of
(Arg1
, Name_VAX_Float
, Name_IEEE_Float
);
7457 if not OpenVMS_On_Target
then
7458 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
7460 ("?pragma% ignored (applies only to Open'V'M'S)");
7466 -- One argument case
7468 if Arg_Count
= 1 then
7469 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
7470 if Opt
.Float_Format
= 'I' then
7471 Error_Pragma
("'I'E'E'E format previously specified");
7474 Opt
.Float_Format
:= 'V';
7477 if Opt
.Float_Format
= 'V' then
7478 Error_Pragma
("'V'A'X format previously specified");
7481 Opt
.Float_Format
:= 'I';
7484 Set_Standard_Fpt_Formats
;
7486 -- Two argument case
7489 Argx
:= Get_Pragma_Arg
(Arg2
);
7491 if not Is_Entity_Name
(Argx
)
7492 or else not Is_Floating_Point_Type
(Entity
(Argx
))
7495 ("second argument of% pragma must be floating-point type",
7499 Ent
:= Entity
(Argx
);
7500 Digs
:= UI_To_Int
(Digits_Value
(Ent
));
7502 -- Two arguments, VAX_Float case
7504 if Chars
(Expression
(Arg1
)) = Name_VAX_Float
then
7506 when 6 => Set_F_Float
(Ent
);
7507 when 9 => Set_D_Float
(Ent
);
7508 when 15 => Set_G_Float
(Ent
);
7512 ("wrong digits value, must be 6,9 or 15", Arg2
);
7515 -- Two arguments, IEEE_Float case
7519 when 6 => Set_IEEE_Short
(Ent
);
7520 when 15 => Set_IEEE_Long
(Ent
);
7524 ("wrong digits value, must be 6 or 15", Arg2
);
7528 end Float_Representation
;
7534 -- pragma Ident (static_string_EXPRESSION)
7536 -- Note: pragma Comment shares this processing. Pragma Comment is
7537 -- identical to Ident, except that the restriction of the argument to
7538 -- 31 characters and the placement restrictions are not enforced for
7541 when Pragma_Ident | Pragma_Comment
=> Ident
: declare
7546 Check_Arg_Count
(1);
7547 Check_No_Identifiers
;
7548 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
7550 -- For pragma Ident, preserve DEC compatibility by requiring the
7551 -- pragma to appear in a declarative part or package spec.
7553 if Prag_Id
= Pragma_Ident
then
7554 Check_Is_In_Decl_Part_Or_Package_Spec
;
7557 Str
:= Expr_Value_S
(Expression
(Arg1
));
7564 GP
:= Parent
(Parent
(N
));
7566 if Nkind_In
(GP
, N_Package_Declaration
,
7567 N_Generic_Package_Declaration
)
7572 -- If we have a compilation unit, then record the ident value,
7573 -- checking for improper duplication.
7575 if Nkind
(GP
) = N_Compilation_Unit
then
7576 CS
:= Ident_String
(Current_Sem_Unit
);
7578 if Present
(CS
) then
7580 -- For Ident, we do not permit multiple instances
7582 if Prag_Id
= Pragma_Ident
then
7583 Error_Pragma
("duplicate% pragma not permitted");
7585 -- For Comment, we concatenate the string, unless we want
7586 -- to preserve the tree structure for ASIS.
7588 elsif not ASIS_Mode
then
7589 Start_String
(Strval
(CS
));
7590 Store_String_Char
(' ');
7591 Store_String_Chars
(Strval
(Str
));
7592 Set_Strval
(CS
, End_String
);
7596 -- In VMS, the effect of IDENT is achieved by passing
7597 -- IDENTIFICATION=name as a --for-linker switch.
7599 if OpenVMS_On_Target
then
7602 ("--for-linker=IDENTIFICATION=");
7603 String_To_Name_Buffer
(Strval
(Str
));
7604 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
7606 -- Only the last processed IDENT is saved. The main
7607 -- purpose is so an IDENT associated with a main
7608 -- procedure will be used in preference to an IDENT
7609 -- associated with a with'd package.
7611 Replace_Linker_Option_String
7612 (End_String
, "--for-linker=IDENTIFICATION=");
7615 Set_Ident_String
(Current_Sem_Unit
, Str
);
7618 -- For subunits, we just ignore the Ident, since in GNAT these
7619 -- are not separate object files, and hence not separate units
7620 -- in the unit table.
7622 elsif Nkind
(GP
) = N_Subunit
then
7625 -- Otherwise we have a misplaced pragma Ident, but we ignore
7626 -- this if we are in an instantiation, since it comes from
7627 -- a generic, and has no relevance to the instantiation.
7629 elsif Prag_Id
= Pragma_Ident
then
7630 if Instantiation_Location
(Loc
) = No_Location
then
7631 Error_Pragma
("pragma% only allowed at outer level");
7637 --------------------------
7638 -- Implemented_By_Entry --
7639 --------------------------
7641 -- pragma Implemented_By_Entry (DIRECT_NAME);
7643 when Pragma_Implemented_By_Entry
=> Implemented_By_Entry
: declare
7648 Check_Arg_Count
(1);
7649 Check_No_Identifiers
;
7650 Check_Arg_Is_Identifier
(Arg1
);
7651 Check_Arg_Is_Local_Name
(Arg1
);
7652 Ent
:= Entity
(Expression
(Arg1
));
7654 -- Pragma Implemented_By_Entry must be applied only to protected
7655 -- synchronized or task interface primitives.
7657 if (Ekind
(Ent
) /= E_Function
7658 and then Ekind
(Ent
) /= E_Procedure
)
7659 or else not Present
(First_Formal
(Ent
))
7660 or else not Is_Concurrent_Interface
(Etype
(First_Formal
(Ent
)))
7663 ("pragma % must be applied to a concurrent interface " &
7667 if Einfo
.Implemented_By_Entry
(Ent
)
7668 and then Warn_On_Redundant_Constructs
7670 Error_Pragma
("?duplicate pragma%!");
7672 Set_Implemented_By_Entry
(Ent
);
7675 end Implemented_By_Entry
;
7677 -----------------------
7678 -- Implicit_Packing --
7679 -----------------------
7681 -- pragma Implicit_Packing;
7683 when Pragma_Implicit_Packing
=>
7685 Check_Arg_Count
(0);
7686 Implicit_Packing
:= True;
7693 -- [Convention =>] convention_IDENTIFIER,
7694 -- [Entity =>] local_NAME
7695 -- [, [External_Name =>] static_string_EXPRESSION ]
7696 -- [, [Link_Name =>] static_string_EXPRESSION ]);
7698 when Pragma_Import
=>
7699 Check_Ada_83_Warning
;
7705 Check_At_Least_N_Arguments
(2);
7706 Check_At_Most_N_Arguments
(4);
7707 Process_Import_Or_Interface
;
7709 ----------------------
7710 -- Import_Exception --
7711 ----------------------
7713 -- pragma Import_Exception (
7714 -- [Internal =>] LOCAL_NAME
7715 -- [, [External =>] EXTERNAL_SYMBOL]
7716 -- [, [Form =>] Ada | VMS]
7717 -- [, [Code =>] static_integer_EXPRESSION]);
7719 when Pragma_Import_Exception
=> Import_Exception
: declare
7720 Args
: Args_List
(1 .. 4);
7721 Names
: constant Name_List
(1 .. 4) := (
7727 Internal
: Node_Id
renames Args
(1);
7728 External
: Node_Id
renames Args
(2);
7729 Form
: Node_Id
renames Args
(3);
7730 Code
: Node_Id
renames Args
(4);
7734 Gather_Associations
(Names
, Args
);
7736 if Present
(External
) and then Present
(Code
) then
7738 ("cannot give both External and Code options for pragma%");
7741 Process_Extended_Import_Export_Exception_Pragma
(
7742 Arg_Internal
=> Internal
,
7743 Arg_External
=> External
,
7747 if not Is_VMS_Exception
(Entity
(Internal
)) then
7748 Set_Imported
(Entity
(Internal
));
7750 end Import_Exception
;
7752 ---------------------
7753 -- Import_Function --
7754 ---------------------
7756 -- pragma Import_Function (
7757 -- [Internal =>] LOCAL_NAME,
7758 -- [, [External =>] EXTERNAL_SYMBOL]
7759 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7760 -- [, [Result_Type =>] SUBTYPE_MARK]
7761 -- [, [Mechanism =>] MECHANISM]
7762 -- [, [Result_Mechanism =>] MECHANISM_NAME]
7763 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
7765 -- EXTERNAL_SYMBOL ::=
7767 -- | static_string_EXPRESSION
7769 -- PARAMETER_TYPES ::=
7771 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7773 -- TYPE_DESIGNATOR ::=
7775 -- | subtype_Name ' Access
7779 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7781 -- MECHANISM_ASSOCIATION ::=
7782 -- [formal_parameter_NAME =>] MECHANISM_NAME
7784 -- MECHANISM_NAME ::=
7787 -- | Descriptor [([Class =>] CLASS_NAME)]
7789 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7791 when Pragma_Import_Function
=> Import_Function
: declare
7792 Args
: Args_List
(1 .. 7);
7793 Names
: constant Name_List
(1 .. 7) := (
7796 Name_Parameter_Types
,
7799 Name_Result_Mechanism
,
7800 Name_First_Optional_Parameter
);
7802 Internal
: Node_Id
renames Args
(1);
7803 External
: Node_Id
renames Args
(2);
7804 Parameter_Types
: Node_Id
renames Args
(3);
7805 Result_Type
: Node_Id
renames Args
(4);
7806 Mechanism
: Node_Id
renames Args
(5);
7807 Result_Mechanism
: Node_Id
renames Args
(6);
7808 First_Optional_Parameter
: Node_Id
renames Args
(7);
7812 Gather_Associations
(Names
, Args
);
7813 Process_Extended_Import_Export_Subprogram_Pragma
(
7814 Arg_Internal
=> Internal
,
7815 Arg_External
=> External
,
7816 Arg_Parameter_Types
=> Parameter_Types
,
7817 Arg_Result_Type
=> Result_Type
,
7818 Arg_Mechanism
=> Mechanism
,
7819 Arg_Result_Mechanism
=> Result_Mechanism
,
7820 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
7821 end Import_Function
;
7827 -- pragma Import_Object (
7828 -- [Internal =>] LOCAL_NAME
7829 -- [, [External =>] EXTERNAL_SYMBOL]
7830 -- [, [Size =>] EXTERNAL_SYMBOL]);
7832 -- EXTERNAL_SYMBOL ::=
7834 -- | static_string_EXPRESSION
7836 when Pragma_Import_Object
=> Import_Object
: declare
7837 Args
: Args_List
(1 .. 3);
7838 Names
: constant Name_List
(1 .. 3) := (
7843 Internal
: Node_Id
renames Args
(1);
7844 External
: Node_Id
renames Args
(2);
7845 Size
: Node_Id
renames Args
(3);
7849 Gather_Associations
(Names
, Args
);
7850 Process_Extended_Import_Export_Object_Pragma
(
7851 Arg_Internal
=> Internal
,
7852 Arg_External
=> External
,
7856 ----------------------
7857 -- Import_Procedure --
7858 ----------------------
7860 -- pragma Import_Procedure (
7861 -- [Internal =>] LOCAL_NAME
7862 -- [, [External =>] EXTERNAL_SYMBOL]
7863 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7864 -- [, [Mechanism =>] MECHANISM]
7865 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
7867 -- EXTERNAL_SYMBOL ::=
7869 -- | static_string_EXPRESSION
7871 -- PARAMETER_TYPES ::=
7873 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7875 -- TYPE_DESIGNATOR ::=
7877 -- | subtype_Name ' Access
7881 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7883 -- MECHANISM_ASSOCIATION ::=
7884 -- [formal_parameter_NAME =>] MECHANISM_NAME
7886 -- MECHANISM_NAME ::=
7889 -- | Descriptor [([Class =>] CLASS_NAME)]
7891 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7893 when Pragma_Import_Procedure
=> Import_Procedure
: declare
7894 Args
: Args_List
(1 .. 5);
7895 Names
: constant Name_List
(1 .. 5) := (
7898 Name_Parameter_Types
,
7900 Name_First_Optional_Parameter
);
7902 Internal
: Node_Id
renames Args
(1);
7903 External
: Node_Id
renames Args
(2);
7904 Parameter_Types
: Node_Id
renames Args
(3);
7905 Mechanism
: Node_Id
renames Args
(4);
7906 First_Optional_Parameter
: Node_Id
renames Args
(5);
7910 Gather_Associations
(Names
, Args
);
7911 Process_Extended_Import_Export_Subprogram_Pragma
(
7912 Arg_Internal
=> Internal
,
7913 Arg_External
=> External
,
7914 Arg_Parameter_Types
=> Parameter_Types
,
7915 Arg_Mechanism
=> Mechanism
,
7916 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
7917 end Import_Procedure
;
7919 -----------------------------
7920 -- Import_Valued_Procedure --
7921 -----------------------------
7923 -- pragma Import_Valued_Procedure (
7924 -- [Internal =>] LOCAL_NAME
7925 -- [, [External =>] EXTERNAL_SYMBOL]
7926 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7927 -- [, [Mechanism =>] MECHANISM]
7928 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
7930 -- EXTERNAL_SYMBOL ::=
7932 -- | static_string_EXPRESSION
7934 -- PARAMETER_TYPES ::=
7936 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7938 -- TYPE_DESIGNATOR ::=
7940 -- | subtype_Name ' Access
7944 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7946 -- MECHANISM_ASSOCIATION ::=
7947 -- [formal_parameter_NAME =>] MECHANISM_NAME
7949 -- MECHANISM_NAME ::=
7952 -- | Descriptor [([Class =>] CLASS_NAME)]
7954 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7956 when Pragma_Import_Valued_Procedure
=>
7957 Import_Valued_Procedure
: declare
7958 Args
: Args_List
(1 .. 5);
7959 Names
: constant Name_List
(1 .. 5) := (
7962 Name_Parameter_Types
,
7964 Name_First_Optional_Parameter
);
7966 Internal
: Node_Id
renames Args
(1);
7967 External
: Node_Id
renames Args
(2);
7968 Parameter_Types
: Node_Id
renames Args
(3);
7969 Mechanism
: Node_Id
renames Args
(4);
7970 First_Optional_Parameter
: Node_Id
renames Args
(5);
7974 Gather_Associations
(Names
, Args
);
7975 Process_Extended_Import_Export_Subprogram_Pragma
(
7976 Arg_Internal
=> Internal
,
7977 Arg_External
=> External
,
7978 Arg_Parameter_Types
=> Parameter_Types
,
7979 Arg_Mechanism
=> Mechanism
,
7980 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
7981 end Import_Valued_Procedure
;
7983 ------------------------
7984 -- Initialize_Scalars --
7985 ------------------------
7987 -- pragma Initialize_Scalars;
7989 when Pragma_Initialize_Scalars
=>
7991 Check_Arg_Count
(0);
7992 Check_Valid_Configuration_Pragma
;
7993 Check_Restriction
(No_Initialize_Scalars
, N
);
7995 -- Initialize_Scalars creates false positives in CodePeer,
7996 -- so ignore this pragma in this mode.
7998 if not Restriction_Active
(No_Initialize_Scalars
)
7999 and then not CodePeer_Mode
8001 Init_Or_Norm_Scalars
:= True;
8002 Initialize_Scalars
:= True;
8009 -- pragma Inline ( NAME {, NAME} );
8011 when Pragma_Inline
=>
8013 -- Pragma is active if inlining option is active
8015 Process_Inline
(Inline_Active
);
8021 -- pragma Inline_Always ( NAME {, NAME} );
8023 when Pragma_Inline_Always
=>
8025 Process_Inline
(True);
8027 --------------------
8028 -- Inline_Generic --
8029 --------------------
8031 -- pragma Inline_Generic (NAME {, NAME});
8033 when Pragma_Inline_Generic
=>
8035 Process_Generic_List
;
8037 ----------------------
8038 -- Inspection_Point --
8039 ----------------------
8041 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
8043 when Pragma_Inspection_Point
=> Inspection_Point
: declare
8048 if Arg_Count
> 0 then
8051 Exp
:= Expression
(Arg
);
8054 if not Is_Entity_Name
(Exp
)
8055 or else not Is_Object
(Entity
(Exp
))
8057 Error_Pragma_Arg
("object name required", Arg
);
8064 end Inspection_Point
;
8070 -- pragma Interface (
8071 -- [ Convention =>] convention_IDENTIFIER,
8072 -- [ Entity =>] local_NAME
8073 -- [, [External_Name =>] static_string_EXPRESSION ]
8074 -- [, [Link_Name =>] static_string_EXPRESSION ]);
8076 when Pragma_Interface
=>
8083 Check_At_Least_N_Arguments
(2);
8084 Check_At_Most_N_Arguments
(4);
8085 Process_Import_Or_Interface
;
8087 --------------------
8088 -- Interface_Name --
8089 --------------------
8091 -- pragma Interface_Name (
8092 -- [ Entity =>] local_NAME
8093 -- [,[External_Name =>] static_string_EXPRESSION ]
8094 -- [,[Link_Name =>] static_string_EXPRESSION ]);
8096 when Pragma_Interface_Name
=> Interface_Name
: declare
8105 ((Name_Entity
, Name_External_Name
, Name_Link_Name
));
8106 Check_At_Least_N_Arguments
(2);
8107 Check_At_Most_N_Arguments
(3);
8108 Id
:= Expression
(Arg1
);
8111 if not Is_Entity_Name
(Id
) then
8113 ("first argument for pragma% must be entity name", Arg1
);
8114 elsif Etype
(Id
) = Any_Type
then
8117 Def_Id
:= Entity
(Id
);
8120 -- Special DEC-compatible processing for the object case, forces
8121 -- object to be imported.
8123 if Ekind
(Def_Id
) = E_Variable
then
8124 Kill_Size_Check_Code
(Def_Id
);
8125 Note_Possible_Modification
(Id
, Sure
=> False);
8127 -- Initialization is not allowed for imported variable
8129 if Present
(Expression
(Parent
(Def_Id
)))
8130 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
8132 Error_Msg_Sloc
:= Sloc
(Def_Id
);
8134 ("no initialization allowed for declaration of& #",
8138 -- For compatibility, support VADS usage of providing both
8139 -- pragmas Interface and Interface_Name to obtain the effect
8140 -- of a single Import pragma.
8142 if Is_Imported
(Def_Id
)
8143 and then Present
(First_Rep_Item
(Def_Id
))
8144 and then Nkind
(First_Rep_Item
(Def_Id
)) = N_Pragma
8146 Pragma_Name
(First_Rep_Item
(Def_Id
)) = Name_Interface
8150 Set_Imported
(Def_Id
);
8153 Set_Is_Public
(Def_Id
);
8154 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
8157 -- Otherwise must be subprogram
8159 elsif not Is_Subprogram
(Def_Id
) then
8161 ("argument of pragma% is not subprogram", Arg1
);
8164 Check_At_Most_N_Arguments
(3);
8168 -- Loop through homonyms
8171 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
8173 if Is_Imported
(Def_Id
) then
8174 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
8178 Hom_Id
:= Homonym
(Hom_Id
);
8180 exit when No
(Hom_Id
)
8181 or else Scope
(Hom_Id
) /= Current_Scope
;
8186 ("argument of pragma% is not imported subprogram",
8192 -----------------------
8193 -- Interrupt_Handler --
8194 -----------------------
8196 -- pragma Interrupt_Handler (handler_NAME);
8198 when Pragma_Interrupt_Handler
=>
8199 Check_Ada_83_Warning
;
8200 Check_Arg_Count
(1);
8201 Check_No_Identifiers
;
8203 if No_Run_Time_Mode
then
8204 Error_Msg_CRT
("Interrupt_Handler pragma", N
);
8206 Check_Interrupt_Or_Attach_Handler
;
8207 Process_Interrupt_Or_Attach_Handler
;
8210 ------------------------
8211 -- Interrupt_Priority --
8212 ------------------------
8214 -- pragma Interrupt_Priority [(EXPRESSION)];
8216 when Pragma_Interrupt_Priority
=> Interrupt_Priority
: declare
8217 P
: constant Node_Id
:= Parent
(N
);
8221 Check_Ada_83_Warning
;
8223 if Arg_Count
/= 0 then
8224 Arg
:= Expression
(Arg1
);
8225 Check_Arg_Count
(1);
8226 Check_No_Identifiers
;
8228 -- The expression must be analyzed in the special manner
8229 -- described in "Handling of Default and Per-Object
8230 -- Expressions" in sem.ads.
8232 Preanalyze_Spec_Expression
(Arg
, RTE
(RE_Interrupt_Priority
));
8235 if not Nkind_In
(P
, N_Task_Definition
, N_Protected_Definition
) then
8239 elsif Has_Priority_Pragma
(P
) then
8240 Error_Pragma
("duplicate pragma% not allowed");
8243 Set_Has_Priority_Pragma
(P
, True);
8244 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
8246 end Interrupt_Priority
;
8248 ---------------------
8249 -- Interrupt_State --
8250 ---------------------
8252 -- pragma Interrupt_State (
8253 -- [Name =>] INTERRUPT_ID,
8254 -- [State =>] INTERRUPT_STATE);
8256 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
8257 -- INTERRUPT_STATE => System | Runtime | User
8259 -- Note: if the interrupt id is given as an identifier, then it must
8260 -- be one of the identifiers in Ada.Interrupts.Names. Otherwise it is
8261 -- given as a static integer expression which must be in the range of
8262 -- Ada.Interrupts.Interrupt_ID.
8264 when Pragma_Interrupt_State
=> Interrupt_State
: declare
8266 Int_Id
: constant Entity_Id
:= RTE
(RE_Interrupt_ID
);
8267 -- This is the entity Ada.Interrupts.Interrupt_ID;
8269 State_Type
: Character;
8270 -- Set to 's'/'r'/'u' for System/Runtime/User
8273 -- Index to entry in Interrupt_States table
8276 -- Value of interrupt
8278 Arg1X
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
8279 -- The first argument to the pragma
8281 Int_Ent
: Entity_Id
;
8282 -- Interrupt entity in Ada.Interrupts.Names
8286 Check_Arg_Order
((Name_Name
, Name_State
));
8287 Check_Arg_Count
(2);
8289 Check_Optional_Identifier
(Arg1
, Name_Name
);
8290 Check_Optional_Identifier
(Arg2
, Name_State
);
8291 Check_Arg_Is_Identifier
(Arg2
);
8293 -- First argument is identifier
8295 if Nkind
(Arg1X
) = N_Identifier
then
8297 -- Search list of names in Ada.Interrupts.Names
8299 Int_Ent
:= First_Entity
(RTE
(RE_Names
));
8301 if No
(Int_Ent
) then
8302 Error_Pragma_Arg
("invalid interrupt name", Arg1
);
8304 elsif Chars
(Int_Ent
) = Chars
(Arg1X
) then
8305 Int_Val
:= Expr_Value
(Constant_Value
(Int_Ent
));
8309 Next_Entity
(Int_Ent
);
8312 -- First argument is not an identifier, so it must be a static
8313 -- expression of type Ada.Interrupts.Interrupt_ID.
8316 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
8317 Int_Val
:= Expr_Value
(Arg1X
);
8319 if Int_Val
< Expr_Value
(Type_Low_Bound
(Int_Id
))
8321 Int_Val
> Expr_Value
(Type_High_Bound
(Int_Id
))
8324 ("value not in range of type " &
8325 """Ada.Interrupts.Interrupt_'I'D""", Arg1
);
8331 case Chars
(Get_Pragma_Arg
(Arg2
)) is
8332 when Name_Runtime
=> State_Type
:= 'r';
8333 when Name_System
=> State_Type
:= 's';
8334 when Name_User
=> State_Type
:= 'u';
8337 Error_Pragma_Arg
("invalid interrupt state", Arg2
);
8340 -- Check if entry is already stored
8342 IST_Num
:= Interrupt_States
.First
;
8344 -- If entry not found, add it
8346 if IST_Num
> Interrupt_States
.Last
then
8347 Interrupt_States
.Append
8348 ((Interrupt_Number
=> UI_To_Int
(Int_Val
),
8349 Interrupt_State
=> State_Type
,
8350 Pragma_Loc
=> Loc
));
8353 -- Case of entry for the same entry
8355 elsif Int_Val
= Interrupt_States
.Table
(IST_Num
).
8358 -- If state matches, done, no need to make redundant entry
8361 State_Type
= Interrupt_States
.Table
(IST_Num
).
8364 -- Otherwise if state does not match, error
8367 Interrupt_States
.Table
(IST_Num
).Pragma_Loc
;
8369 ("state conflicts with that given #", Arg2
);
8373 IST_Num
:= IST_Num
+ 1;
8375 end Interrupt_State
;
8377 ----------------------
8378 -- Java_Constructor --
8379 ----------------------
8381 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
8383 -- Also handles pragma CIL_Constructor
8385 when Pragma_CIL_Constructor | Pragma_Java_Constructor
=>
8386 Java_Constructor
: declare
8390 Convention
: Convention_Id
;
8394 Check_Arg_Count
(1);
8395 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8396 Check_Arg_Is_Local_Name
(Arg1
);
8398 Id
:= Expression
(Arg1
);
8399 Find_Program_Unit_Name
(Id
);
8401 -- If we did not find the name, we are done
8403 if Etype
(Id
) = Any_Type
then
8408 when Pragma_CIL_Constructor
=> Convention
:= Convention_CIL
;
8409 when Pragma_Java_Constructor
=> Convention
:= Convention_Java
;
8410 when others => null;
8413 Hom_Id
:= Entity
(Id
);
8415 -- Loop through homonyms
8418 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
8420 -- The constructor is required to be a function returning an
8421 -- access type whose designated type has convention Java/CIL.
8423 if Ekind
(Def_Id
) = E_Function
8425 (Is_Value_Type
(Etype
(Def_Id
))
8427 (Ekind
(Etype
(Def_Id
)) = E_Access_Subprogram_Type
8429 Atree
.Convention
(Etype
(Def_Id
)) = Convention
)
8431 (Ekind
(Etype
(Def_Id
)) in Access_Kind
8434 (Designated_Type
(Etype
(Def_Id
))) = Convention
8437 (Root_Type
(Designated_Type
(Etype
(Def_Id
)))) =
8440 Set_Is_Constructor
(Def_Id
);
8441 Set_Convention
(Def_Id
, Convention
);
8442 Set_Is_Imported
(Def_Id
);
8445 if Convention
= Convention_Java
then
8447 ("pragma% requires function returning a " &
8448 "'Java access type", Arg1
);
8450 pragma Assert
(Convention
= Convention_CIL
);
8452 ("pragma% requires function returning a " &
8453 "'C'I'L access type", Arg1
);
8457 Hom_Id
:= Homonym
(Hom_Id
);
8459 exit when No
(Hom_Id
) or else Scope
(Hom_Id
) /= Current_Scope
;
8461 end Java_Constructor
;
8463 ----------------------
8464 -- Java_Interface --
8465 ----------------------
8467 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
8469 when Pragma_Java_Interface
=> Java_Interface
: declare
8475 Check_Arg_Count
(1);
8476 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8477 Check_Arg_Is_Local_Name
(Arg1
);
8479 Arg
:= Expression
(Arg1
);
8482 if Etype
(Arg
) = Any_Type
then
8486 if not Is_Entity_Name
(Arg
)
8487 or else not Is_Type
(Entity
(Arg
))
8489 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
8492 Typ
:= Underlying_Type
(Entity
(Arg
));
8494 -- For now simply check some of the semantic constraints on the
8495 -- type. This currently leaves out some restrictions on interface
8496 -- types, namely that the parent type must be java.lang.Object.Typ
8497 -- and that all primitives of the type should be declared
8500 if not Is_Tagged_Type
(Typ
) or else not Is_Abstract_Type
(Typ
) then
8501 Error_Pragma_Arg
("pragma% requires an abstract "
8502 & "tagged type", Arg1
);
8504 elsif not Has_Discriminants
(Typ
)
8505 or else Ekind
(Etype
(First_Discriminant
(Typ
)))
8506 /= E_Anonymous_Access_Type
8508 not Is_Class_Wide_Type
8509 (Designated_Type
(Etype
(First_Discriminant
(Typ
))))
8512 ("type must have a class-wide access discriminant", Arg1
);
8520 -- pragma Keep_Names ([On => ] local_NAME);
8522 when Pragma_Keep_Names
=> Keep_Names
: declare
8527 Check_Arg_Count
(1);
8528 Check_Optional_Identifier
(Arg1
, Name_On
);
8529 Check_Arg_Is_Local_Name
(Arg1
);
8531 Arg
:= Expression
(Arg1
);
8534 if Etype
(Arg
) = Any_Type
then
8538 if not Is_Entity_Name
(Arg
)
8539 or else Ekind
(Entity
(Arg
)) /= E_Enumeration_Type
8542 ("pragma% requires a local enumeration type", Arg1
);
8545 Set_Discard_Names
(Entity
(Arg
), False);
8552 -- pragma License (RESTRICTED | UNRESTRICTED | GPL | MODIFIED_GPL);
8554 when Pragma_License
=>
8556 Check_Arg_Count
(1);
8557 Check_No_Identifiers
;
8558 Check_Valid_Configuration_Pragma
;
8559 Check_Arg_Is_Identifier
(Arg1
);
8562 Sind
: constant Source_File_Index
:=
8563 Source_Index
(Current_Sem_Unit
);
8566 case Chars
(Get_Pragma_Arg
(Arg1
)) is
8568 Set_License
(Sind
, GPL
);
8570 when Name_Modified_GPL
=>
8571 Set_License
(Sind
, Modified_GPL
);
8573 when Name_Restricted
=>
8574 Set_License
(Sind
, Restricted
);
8576 when Name_Unrestricted
=>
8577 Set_License
(Sind
, Unrestricted
);
8580 Error_Pragma_Arg
("invalid license name", Arg1
);
8588 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
8590 when Pragma_Link_With
=> Link_With
: declare
8596 if Operating_Mode
= Generate_Code
8597 and then In_Extended_Main_Source_Unit
(N
)
8599 Check_At_Least_N_Arguments
(1);
8600 Check_No_Identifiers
;
8601 Check_Is_In_Decl_Part_Or_Package_Spec
;
8602 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
8606 while Present
(Arg
) loop
8607 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
8609 -- Store argument, converting sequences of spaces to a
8610 -- single null character (this is one of the differences
8611 -- in processing between Link_With and Linker_Options).
8614 C
: constant Char_Code
:= Get_Char_Code
(' ');
8615 S
: constant String_Id
:=
8616 Strval
(Expr_Value_S
(Expression
(Arg
)));
8617 L
: constant Nat
:= String_Length
(S
);
8620 procedure Skip_Spaces
;
8621 -- Advance F past any spaces
8627 procedure Skip_Spaces
is
8629 while F
<= L
and then Get_String_Char
(S
, F
) = C
loop
8634 -- Start of processing for Arg_Store
8637 Skip_Spaces
; -- skip leading spaces
8639 -- Loop through characters, changing any embedded
8640 -- sequence of spaces to a single null character (this
8641 -- is how Link_With/Linker_Options differ)
8644 if Get_String_Char
(S
, F
) = C
then
8647 Store_String_Char
(ASCII
.NUL
);
8650 Store_String_Char
(Get_String_Char
(S
, F
));
8658 if Present
(Arg
) then
8659 Store_String_Char
(ASCII
.NUL
);
8663 Store_Linker_Option_String
(End_String
);
8671 -- pragma Linker_Alias (
8672 -- [Entity =>] LOCAL_NAME
8673 -- [Target =>] static_string_EXPRESSION);
8675 when Pragma_Linker_Alias
=>
8677 Check_Arg_Order
((Name_Entity
, Name_Target
));
8678 Check_Arg_Count
(2);
8679 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8680 Check_Optional_Identifier
(Arg2
, Name_Target
);
8681 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
8682 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
8684 -- The only processing required is to link this item on to the
8685 -- list of rep items for the given entity. This is accomplished
8686 -- by the call to Rep_Item_Too_Late (when no error is detected
8687 -- and False is returned).
8689 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
8692 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
8695 ------------------------
8696 -- Linker_Constructor --
8697 ------------------------
8699 -- pragma Linker_Constructor (procedure_LOCAL_NAME);
8701 -- Code is shared with Linker_Destructor
8703 -----------------------
8704 -- Linker_Destructor --
8705 -----------------------
8707 -- pragma Linker_Destructor (procedure_LOCAL_NAME);
8709 when Pragma_Linker_Constructor |
8710 Pragma_Linker_Destructor
=>
8711 Linker_Constructor
: declare
8717 Check_Arg_Count
(1);
8718 Check_No_Identifiers
;
8719 Check_Arg_Is_Local_Name
(Arg1
);
8720 Arg1_X
:= Expression
(Arg1
);
8722 Proc
:= Find_Unique_Parameterless_Procedure
(Arg1_X
, Arg1
);
8724 if not Is_Library_Level_Entity
(Proc
) then
8726 ("argument for pragma% must be library level entity", Arg1
);
8729 -- The only processing required is to link this item on to the
8730 -- list of rep items for the given entity. This is accomplished
8731 -- by the call to Rep_Item_Too_Late (when no error is detected
8732 -- and False is returned).
8734 if Rep_Item_Too_Late
(Proc
, N
) then
8737 Set_Has_Gigi_Rep_Item
(Proc
);
8739 end Linker_Constructor
;
8741 --------------------
8742 -- Linker_Options --
8743 --------------------
8745 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
8747 when Pragma_Linker_Options
=> Linker_Options
: declare
8751 Check_Ada_83_Warning
;
8752 Check_No_Identifiers
;
8753 Check_Arg_Count
(1);
8754 Check_Is_In_Decl_Part_Or_Package_Spec
;
8755 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
8756 Start_String
(Strval
(Expr_Value_S
(Expression
(Arg1
))));
8759 while Present
(Arg
) loop
8760 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
8761 Store_String_Char
(ASCII
.NUL
);
8762 Store_String_Chars
(Strval
(Expr_Value_S
(Expression
(Arg
))));
8766 if Operating_Mode
= Generate_Code
8767 and then In_Extended_Main_Source_Unit
(N
)
8769 Store_Linker_Option_String
(End_String
);
8773 --------------------
8774 -- Linker_Section --
8775 --------------------
8777 -- pragma Linker_Section (
8778 -- [Entity =>] LOCAL_NAME
8779 -- [Section =>] static_string_EXPRESSION);
8781 when Pragma_Linker_Section
=>
8783 Check_Arg_Order
((Name_Entity
, Name_Section
));
8784 Check_Arg_Count
(2);
8785 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8786 Check_Optional_Identifier
(Arg2
, Name_Section
);
8787 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
8788 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
8790 -- This pragma applies only to objects
8792 if not Is_Object
(Entity
(Expression
(Arg1
))) then
8793 Error_Pragma_Arg
("pragma% applies only to objects", Arg1
);
8796 -- The only processing required is to link this item on to the
8797 -- list of rep items for the given entity. This is accomplished
8798 -- by the call to Rep_Item_Too_Late (when no error is detected
8799 -- and False is returned).
8801 if Rep_Item_Too_Late
(Entity
(Expression
(Arg1
)), N
) then
8804 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
8811 -- pragma List (On | Off)
8813 -- There is nothing to do here, since we did all the processing for
8814 -- this pragma in Par.Prag (so that it works properly even in syntax
8820 --------------------
8821 -- Locking_Policy --
8822 --------------------
8824 -- pragma Locking_Policy (policy_IDENTIFIER);
8826 when Pragma_Locking_Policy
=> declare
8830 Check_Ada_83_Warning
;
8831 Check_Arg_Count
(1);
8832 Check_No_Identifiers
;
8833 Check_Arg_Is_Locking_Policy
(Arg1
);
8834 Check_Valid_Configuration_Pragma
;
8835 Get_Name_String
(Chars
(Expression
(Arg1
)));
8836 LP
:= Fold_Upper
(Name_Buffer
(1));
8838 if Locking_Policy
/= ' '
8839 and then Locking_Policy
/= LP
8841 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
8842 Error_Pragma
("locking policy incompatible with policy#");
8844 -- Set new policy, but always preserve System_Location since we
8845 -- like the error message with the run time name.
8848 Locking_Policy
:= LP
;
8850 if Locking_Policy_Sloc
/= System_Location
then
8851 Locking_Policy_Sloc
:= Loc
;
8860 -- pragma Long_Float (D_Float | G_Float);
8862 when Pragma_Long_Float
=>
8864 Check_Valid_Configuration_Pragma
;
8865 Check_Arg_Count
(1);
8866 Check_No_Identifier
(Arg1
);
8867 Check_Arg_Is_One_Of
(Arg1
, Name_D_Float
, Name_G_Float
);
8869 if not OpenVMS_On_Target
then
8870 Error_Pragma
("?pragma% ignored (applies only to Open'V'M'S)");
8875 if Chars
(Expression
(Arg1
)) = Name_D_Float
then
8876 if Opt
.Float_Format_Long
= 'G' then
8877 Error_Pragma
("G_Float previously specified");
8880 Opt
.Float_Format_Long
:= 'D';
8882 -- G_Float case (this is the default, does not need overriding)
8885 if Opt
.Float_Format_Long
= 'D' then
8886 Error_Pragma
("D_Float previously specified");
8889 Opt
.Float_Format_Long
:= 'G';
8892 Set_Standard_Fpt_Formats
;
8894 -----------------------
8895 -- Machine_Attribute --
8896 -----------------------
8898 -- pragma Machine_Attribute (
8899 -- [Entity =>] LOCAL_NAME,
8900 -- [Attribute_Name =>] static_string_EXPRESSION
8901 -- [, [Info =>] static_EXPRESSION] );
8903 when Pragma_Machine_Attribute
=> Machine_Attribute
: declare
8908 Check_Arg_Order
((Name_Entity
, Name_Attribute_Name
, Name_Info
));
8910 if Arg_Count
= 3 then
8911 Check_Optional_Identifier
(Arg3
, Name_Info
);
8912 Check_Arg_Is_Static_Expression
(Arg3
);
8914 Check_Arg_Count
(2);
8917 Check_Optional_Identifier
(Arg1
, Name_Entity
);
8918 Check_Optional_Identifier
(Arg2
, Name_Attribute_Name
);
8919 Check_Arg_Is_Local_Name
(Arg1
);
8920 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
8921 Def_Id
:= Entity
(Expression
(Arg1
));
8923 if Is_Access_Type
(Def_Id
) then
8924 Def_Id
:= Designated_Type
(Def_Id
);
8927 if Rep_Item_Too_Early
(Def_Id
, N
) then
8931 Def_Id
:= Underlying_Type
(Def_Id
);
8933 -- The only processing required is to link this item on to the
8934 -- list of rep items for the given entity. This is accomplished
8935 -- by the call to Rep_Item_Too_Late (when no error is detected
8936 -- and False is returned).
8938 if Rep_Item_Too_Late
(Def_Id
, N
) then
8941 Set_Has_Gigi_Rep_Item
(Entity
(Expression
(Arg1
)));
8943 end Machine_Attribute
;
8950 -- (MAIN_OPTION [, MAIN_OPTION]);
8953 -- [STACK_SIZE =>] static_integer_EXPRESSION
8954 -- | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
8955 -- | [TIME_SLICING_ENABLED =>] static_boolean_EXPRESSION
8957 when Pragma_Main
=> Main
: declare
8958 Args
: Args_List
(1 .. 3);
8959 Names
: constant Name_List
(1 .. 3) := (
8961 Name_Task_Stack_Size_Default
,
8962 Name_Time_Slicing_Enabled
);
8968 Gather_Associations
(Names
, Args
);
8970 for J
in 1 .. 2 loop
8971 if Present
(Args
(J
)) then
8972 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
8976 if Present
(Args
(3)) then
8977 Check_Arg_Is_Static_Expression
(Args
(3), Standard_Boolean
);
8981 while Present
(Nod
) loop
8982 if Nkind
(Nod
) = N_Pragma
8983 and then Pragma_Name
(Nod
) = Name_Main
8985 Error_Msg_Name_1
:= Pname
;
8986 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
8997 -- pragma Main_Storage
8998 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
9000 -- MAIN_STORAGE_OPTION ::=
9001 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
9002 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
9004 when Pragma_Main_Storage
=> Main_Storage
: declare
9005 Args
: Args_List
(1 .. 2);
9006 Names
: constant Name_List
(1 .. 2) := (
9007 Name_Working_Storage
,
9014 Gather_Associations
(Names
, Args
);
9016 for J
in 1 .. 2 loop
9017 if Present
(Args
(J
)) then
9018 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
9022 Check_In_Main_Program
;
9025 while Present
(Nod
) loop
9026 if Nkind
(Nod
) = N_Pragma
9027 and then Pragma_Name
(Nod
) = Name_Main_Storage
9029 Error_Msg_Name_1
:= Pname
;
9030 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
9041 -- pragma Memory_Size (NUMERIC_LITERAL)
9043 when Pragma_Memory_Size
=>
9046 -- Memory size is simply ignored
9048 Check_No_Identifiers
;
9049 Check_Arg_Count
(1);
9050 Check_Arg_Is_Integer_Literal
(Arg1
);
9058 -- The only correct use of this pragma is on its own in a file, in
9059 -- which case it is specially processed (see Gnat1drv.Check_Bad_Body
9060 -- and Frontend, which use Sinput.L.Source_File_Is_Pragma_No_Body to
9061 -- check for a file containing nothing but a No_Body pragma). If we
9062 -- attempt to process it during normal semantics processing, it means
9063 -- it was misplaced.
9065 when Pragma_No_Body
=>
9073 -- pragma No_Return (procedure_LOCAL_NAME {, procedure_Local_Name});
9075 when Pragma_No_Return
=> No_Return
: declare
9083 Check_At_Least_N_Arguments
(1);
9085 -- Loop through arguments of pragma
9088 while Present
(Arg
) loop
9089 Check_Arg_Is_Local_Name
(Arg
);
9090 Id
:= Expression
(Arg
);
9093 if not Is_Entity_Name
(Id
) then
9094 Error_Pragma_Arg
("entity name required", Arg
);
9097 if Etype
(Id
) = Any_Type
then
9101 -- Loop to find matching procedures
9106 and then Scope
(E
) = Current_Scope
9108 if Ekind
(E
) = E_Procedure
9109 or else Ekind
(E
) = E_Generic_Procedure
9113 -- Set flag on any alias as well
9115 if Is_Overloadable
(E
) and then Present
(Alias
(E
)) then
9116 Set_No_Return
(Alias
(E
));
9126 Error_Pragma_Arg
("no procedure & found for pragma%", Arg
);
9137 -- pragma No_Run_Time;
9139 -- Note: this pragma is retained for backwards compatibility. See
9140 -- body of Rtsfind for full details on its handling.
9142 when Pragma_No_Run_Time
=>
9144 Check_Valid_Configuration_Pragma
;
9145 Check_Arg_Count
(0);
9147 No_Run_Time_Mode
:= True;
9148 Configurable_Run_Time_Mode
:= True;
9150 -- Set Duration to 32 bits if word size is 32
9152 if Ttypes
.System_Word_Size
= 32 then
9153 Duration_32_Bits_On_Target
:= True;
9156 -- Set appropriate restrictions
9158 Set_Restriction
(No_Finalization
, N
);
9159 Set_Restriction
(No_Exception_Handlers
, N
);
9160 Set_Restriction
(Max_Tasks
, N
, 0);
9161 Set_Restriction
(No_Tasking
, N
);
9163 ------------------------
9164 -- No_Strict_Aliasing --
9165 ------------------------
9167 -- pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
9169 when Pragma_No_Strict_Aliasing
=> No_Strict_Aliasing
: declare
9174 Check_At_Most_N_Arguments
(1);
9176 if Arg_Count
= 0 then
9177 Check_Valid_Configuration_Pragma
;
9178 Opt
.No_Strict_Aliasing
:= True;
9181 Check_Optional_Identifier
(Arg2
, Name_Entity
);
9182 Check_Arg_Is_Local_Name
(Arg1
);
9183 E_Id
:= Entity
(Expression
(Arg1
));
9185 if E_Id
= Any_Type
then
9187 elsif No
(E_Id
) or else not Is_Access_Type
(E_Id
) then
9188 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
9191 Set_No_Strict_Aliasing
(Implementation_Base_Type
(E_Id
));
9193 end No_Strict_Aliasing
;
9195 -----------------------
9196 -- Normalize_Scalars --
9197 -----------------------
9199 -- pragma Normalize_Scalars;
9201 when Pragma_Normalize_Scalars
=>
9202 Check_Ada_83_Warning
;
9203 Check_Arg_Count
(0);
9204 Check_Valid_Configuration_Pragma
;
9206 -- Normalize_Scalars creates false positives in CodePeer, so
9207 -- ignore this pragma in this mode.
9209 if not CodePeer_Mode
then
9210 Normalize_Scalars
:= True;
9211 Init_Or_Norm_Scalars
:= True;
9218 -- pragma Obsolescent;
9220 -- pragma Obsolescent (
9221 -- [Message =>] static_string_EXPRESSION
9222 -- [,[Version =>] Ada_05]]);
9224 -- pragma Obsolescent (
9226 -- [,[Message =>] static_string_EXPRESSION
9227 -- [,[Version =>] Ada_05]] );
9229 when Pragma_Obsolescent
=> Obsolescent
: declare
9233 procedure Set_Obsolescent
(E
: Entity_Id
);
9234 -- Given an entity Ent, mark it as obsolescent if appropriate
9236 ---------------------
9237 -- Set_Obsolescent --
9238 ---------------------
9240 procedure Set_Obsolescent
(E
: Entity_Id
) is
9249 -- Entity name was given
9251 if Present
(Ename
) then
9253 -- If entity name matches, we are fine. Save entity in
9254 -- pragma argument, for ASIS use.
9256 if Chars
(Ename
) = Chars
(Ent
) then
9257 Set_Entity
(Ename
, Ent
);
9258 Generate_Reference
(Ent
, Ename
);
9260 -- If entity name does not match, only possibility is an
9261 -- enumeration literal from an enumeration type declaration.
9263 elsif Ekind
(Ent
) /= E_Enumeration_Type
then
9265 ("pragma % entity name does not match declaration");
9268 Ent
:= First_Literal
(E
);
9272 ("pragma % entity name does not match any " &
9273 "enumeration literal");
9275 elsif Chars
(Ent
) = Chars
(Ename
) then
9276 Set_Entity
(Ename
, Ent
);
9277 Generate_Reference
(Ent
, Ename
);
9281 Ent
:= Next_Literal
(Ent
);
9287 -- Ent points to entity to be marked
9289 if Arg_Count
>= 1 then
9291 -- Deal with static string argument
9293 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
9294 S
:= Strval
(Expression
(Arg1
));
9296 for J
in 1 .. String_Length
(S
) loop
9297 if not In_Character_Range
(Get_String_Char
(S
, J
)) then
9299 ("pragma% argument does not allow wide characters",
9304 Obsolescent_Warnings
.Append
9305 ((Ent
=> Ent
, Msg
=> Strval
(Expression
(Arg1
))));
9307 -- Check for Ada_05 parameter
9309 if Arg_Count
/= 1 then
9310 Check_Arg_Count
(2);
9313 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg2
);
9316 Check_Arg_Is_Identifier
(Argx
);
9318 if Chars
(Argx
) /= Name_Ada_05
then
9319 Error_Msg_Name_2
:= Name_Ada_05
;
9321 ("only allowed argument for pragma% is %", Argx
);
9324 if Ada_Version_Explicit
< Ada_05
9325 or else not Warn_On_Ada_2005_Compatibility
9333 -- Set flag if pragma active
9336 Set_Is_Obsolescent
(Ent
);
9340 end Set_Obsolescent
;
9342 -- Start of processing for pragma Obsolescent
9347 Check_At_Most_N_Arguments
(3);
9349 -- See if first argument specifies an entity name
9353 (Chars
(Arg1
) = Name_Entity
9355 Nkind_In
(Get_Pragma_Arg
(Arg1
), N_Character_Literal
,
9359 Ename
:= Get_Pragma_Arg
(Arg1
);
9361 -- Eliminate first argument, so we can share processing
9365 Arg_Count
:= Arg_Count
- 1;
9367 -- No Entity name argument given
9373 if Arg_Count
>= 1 then
9374 Check_Optional_Identifier
(Arg1
, Name_Message
);
9376 if Arg_Count
= 2 then
9377 Check_Optional_Identifier
(Arg2
, Name_Version
);
9381 -- Get immediately preceding declaration
9384 while Present
(Decl
) and then Nkind
(Decl
) = N_Pragma
loop
9388 -- Cases where we do not follow anything other than another pragma
9392 -- First case: library level compilation unit declaration with
9393 -- the pragma immediately following the declaration.
9395 if Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
9397 (Defining_Entity
(Unit
(Parent
(Parent
(N
)))));
9400 -- Case 2: library unit placement for package
9404 Ent
: constant Entity_Id
:= Find_Lib_Unit_Name
;
9406 if Is_Package_Or_Generic_Package
(Ent
) then
9407 Set_Obsolescent
(Ent
);
9413 -- Cases where we must follow a declaration
9416 if Nkind
(Decl
) not in N_Declaration
9417 and then Nkind
(Decl
) not in N_Later_Decl_Item
9418 and then Nkind
(Decl
) not in N_Generic_Declaration
9419 and then Nkind
(Decl
) not in N_Renaming_Declaration
9422 ("pragma% misplaced, "
9423 & "must immediately follow a declaration");
9426 Set_Obsolescent
(Defining_Entity
(Decl
));
9436 -- pragma Optimize (Time | Space | Off);
9438 -- The actual check for optimize is done in Gigi. Note that this
9439 -- pragma does not actually change the optimization setting, it
9440 -- simply checks that it is consistent with the pragma.
9442 when Pragma_Optimize
=>
9443 Check_No_Identifiers
;
9444 Check_Arg_Count
(1);
9445 Check_Arg_Is_One_Of
(Arg1
, Name_Time
, Name_Space
, Name_Off
);
9447 ------------------------
9448 -- Optimize_Alignment --
9449 ------------------------
9451 -- pragma Optimize_Alignment (Time | Space | Off);
9453 when Pragma_Optimize_Alignment
=>
9455 Check_No_Identifiers
;
9456 Check_Arg_Count
(1);
9457 Check_Valid_Configuration_Pragma
;
9460 Nam
: constant Name_Id
:= Chars
(Get_Pragma_Arg
(Arg1
));
9464 Opt
.Optimize_Alignment
:= 'T';
9466 Opt
.Optimize_Alignment
:= 'S';
9468 Opt
.Optimize_Alignment
:= 'O';
9470 Error_Pragma_Arg
("invalid argument for pragma%", Arg1
);
9474 -- Set indication that mode is set locally. If we are in fact in a
9475 -- configuration pragma file, this setting is harmless since the
9476 -- switch will get reset anyway at the start of each unit.
9478 Optimize_Alignment_Local
:= True;
9484 -- pragma Pack (first_subtype_LOCAL_NAME);
9486 when Pragma_Pack
=> Pack
: declare
9487 Assoc
: constant Node_Id
:= Arg1
;
9492 Check_No_Identifiers
;
9493 Check_Arg_Count
(1);
9494 Check_Arg_Is_Local_Name
(Arg1
);
9496 Type_Id
:= Expression
(Assoc
);
9497 Find_Type
(Type_Id
);
9498 Typ
:= Entity
(Type_Id
);
9501 or else Rep_Item_Too_Early
(Typ
, N
)
9505 Typ
:= Underlying_Type
(Typ
);
9508 if not Is_Array_Type
(Typ
) and then not Is_Record_Type
(Typ
) then
9509 Error_Pragma
("pragma% must specify array or record type");
9512 Check_First_Subtype
(Arg1
);
9514 if Has_Pragma_Pack
(Typ
) then
9515 Error_Pragma
("duplicate pragma%, only one allowed");
9519 elsif Is_Array_Type
(Typ
) then
9521 -- Pack not allowed for aliased or atomic components
9523 if Has_Aliased_Components
(Base_Type
(Typ
)) then
9525 ("pragma% ignored, cannot pack aliased components?");
9527 elsif Has_Atomic_Components
(Typ
)
9528 or else Is_Atomic
(Component_Type
(Typ
))
9531 ("?pragma% ignored, cannot pack atomic components");
9534 -- If we had an explicit component size given, then we do not
9535 -- let Pack override this given size. We also give a warning
9536 -- that Pack is being ignored unless we can tell for sure that
9537 -- the Pack would not have had any effect anyway.
9539 if Has_Component_Size_Clause
(Typ
) then
9540 if Known_Static_RM_Size
(Component_Type
(Typ
))
9542 RM_Size
(Component_Type
(Typ
)) = Component_Size
(Typ
)
9547 ("?pragma% ignored, explicit component size given");
9550 -- If no prior array component size given, Pack is effective
9553 if not Rep_Item_Too_Late
(Typ
, N
) then
9555 -- In the context of static code analysis, we do not need
9556 -- complex front-end expansions related to pragma Pack,
9557 -- so disable handling of pragma Pack in this case.
9559 if CodePeer_Mode
then
9562 -- For normal non-VM target, do the packing
9564 elsif VM_Target
= No_VM
then
9565 Set_Is_Packed
(Base_Type
(Typ
));
9566 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
9567 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
9569 -- If we ignore the pack, then warn about this, except
9570 -- that we suppress the warning in GNAT mode.
9572 elsif not GNAT_Mode
then
9574 ("?pragma% ignored in this configuration");
9579 -- For record types, the pack is always effective
9581 else pragma Assert
(Is_Record_Type
(Typ
));
9582 if not Rep_Item_Too_Late
(Typ
, N
) then
9583 if VM_Target
= No_VM
then
9584 Set_Is_Packed
(Base_Type
(Typ
));
9585 Set_Has_Pragma_Pack
(Base_Type
(Typ
));
9586 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
));
9588 elsif not GNAT_Mode
then
9589 Error_Pragma
("?pragma% ignored in this configuration");
9601 -- There is nothing to do here, since we did all the processing for
9602 -- this pragma in Par.Prag (so that it works properly even in syntax
9612 -- pragma Passive [(PASSIVE_FORM)];
9614 -- PASSIVE_FORM ::= Semaphore | No
9616 when Pragma_Passive
=>
9619 if Nkind
(Parent
(N
)) /= N_Task_Definition
then
9620 Error_Pragma
("pragma% must be within task definition");
9623 if Arg_Count
/= 0 then
9624 Check_Arg_Count
(1);
9625 Check_Arg_Is_One_Of
(Arg1
, Name_Semaphore
, Name_No
);
9628 ----------------------------------
9629 -- Preelaborable_Initialization --
9630 ----------------------------------
9632 -- pragma Preelaborable_Initialization (DIRECT_NAME);
9634 when Pragma_Preelaborable_Initialization
=> Preelab_Init
: declare
9639 Check_Arg_Count
(1);
9640 Check_No_Identifiers
;
9641 Check_Arg_Is_Identifier
(Arg1
);
9642 Check_Arg_Is_Local_Name
(Arg1
);
9643 Check_First_Subtype
(Arg1
);
9644 Ent
:= Entity
(Expression
(Arg1
));
9646 if not Is_Private_Type
(Ent
)
9647 and then not Is_Protected_Type
(Ent
)
9650 ("pragma % can only be applied to private or protected type",
9654 -- Give an error if the pragma is applied to a protected type that
9655 -- does not qualify (due to having entries, or due to components
9656 -- that do not qualify).
9658 if Is_Protected_Type
(Ent
)
9659 and then not Has_Preelaborable_Initialization
(Ent
)
9662 ("protected type & does not have preelaborable " &
9663 "initialization", Ent
);
9665 -- Otherwise mark the type as definitely having preelaborable
9669 Set_Known_To_Have_Preelab_Init
(Ent
);
9672 if Has_Pragma_Preelab_Init
(Ent
)
9673 and then Warn_On_Redundant_Constructs
9675 Error_Pragma
("?duplicate pragma%!");
9677 Set_Has_Pragma_Preelab_Init
(Ent
);
9681 --------------------
9682 -- Persistent_BSS --
9683 --------------------
9685 when Pragma_Persistent_BSS
=> Persistent_BSS
: declare
9692 Check_At_Most_N_Arguments
(1);
9694 -- Case of application to specific object (one argument)
9696 if Arg_Count
= 1 then
9697 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
9699 if not Is_Entity_Name
(Expression
(Arg1
))
9701 (Ekind
(Entity
(Expression
(Arg1
))) /= E_Variable
9702 and then Ekind
(Entity
(Expression
(Arg1
))) /= E_Constant
)
9704 Error_Pragma_Arg
("pragma% only applies to objects", Arg1
);
9707 Ent
:= Entity
(Expression
(Arg1
));
9708 Decl
:= Parent
(Ent
);
9710 if Rep_Item_Too_Late
(Ent
, N
) then
9714 if Present
(Expression
(Decl
)) then
9716 ("object for pragma% cannot have initialization", Arg1
);
9719 if not Is_Potentially_Persistent_Type
(Etype
(Ent
)) then
9721 ("object type for pragma% is not potentially persistent",
9726 Make_Linker_Section_Pragma
9727 (Ent
, Sloc
(N
), ".persistent.bss");
9728 Insert_After
(N
, Prag
);
9731 -- Case of use as configuration pragma with no arguments
9734 Check_Valid_Configuration_Pragma
;
9735 Persistent_BSS_Mode
:= True;
9743 -- pragma Polling (ON | OFF);
9745 when Pragma_Polling
=>
9747 Check_Arg_Count
(1);
9748 Check_No_Identifiers
;
9749 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
9750 Polling_Required
:= (Chars
(Expression
(Arg1
)) = Name_On
);
9756 -- pragma Postcondition ([Check =>] Boolean_Expression
9757 -- [,[Message =>] String_Expression]);
9759 when Pragma_Postcondition
=> Postcondition
: declare
9761 pragma Warnings
(Off
, In_Body
);
9765 Check_At_Least_N_Arguments
(1);
9766 Check_At_Most_N_Arguments
(2);
9767 Check_Optional_Identifier
(Arg1
, Name_Check
);
9769 -- All we need to do here is call the common check procedure,
9770 -- the remainder of the processing is found in Sem_Ch6/Sem_Ch7.
9772 Check_Precondition_Postcondition
(In_Body
);
9779 -- pragma Precondition ([Check =>] Boolean_Expression
9780 -- [,[Message =>] String_Expression]);
9782 when Pragma_Precondition
=> Precondition
: declare
9787 Check_At_Least_N_Arguments
(1);
9788 Check_At_Most_N_Arguments
(2);
9789 Check_Optional_Identifier
(Arg1
, Name_Check
);
9791 Check_Precondition_Postcondition
(In_Body
);
9793 -- If in spec, nothing more to do. If in body, then we convert the
9794 -- pragma to pragma Check (Precondition, cond [, msg]). Note we do
9795 -- this whether or not precondition checks are enabled. That works
9796 -- fine since pragma Check will do this check, and will also
9797 -- analyze the condition itself in the proper context.
9800 if Arg_Count
= 2 then
9801 Check_Optional_Identifier
(Arg3
, Name_Message
);
9802 Analyze_And_Resolve
(Get_Pragma_Arg
(Arg2
), Standard_String
);
9807 Chars
=> Name_Check
,
9808 Pragma_Argument_Associations
=> New_List
(
9809 Make_Pragma_Argument_Association
(Loc
,
9811 Make_Identifier
(Loc
,
9812 Chars
=> Name_Precondition
)),
9814 Make_Pragma_Argument_Association
(Sloc
(Arg1
),
9815 Expression
=> Relocate_Node
(Get_Pragma_Arg
(Arg1
))))));
9817 if Arg_Count
= 2 then
9818 Append_To
(Pragma_Argument_Associations
(N
),
9819 Make_Pragma_Argument_Association
(Sloc
(Arg2
),
9820 Expression
=> Relocate_Node
(Get_Pragma_Arg
(Arg2
))));
9831 -- pragma Preelaborate [(library_unit_NAME)];
9833 -- Set the flag Is_Preelaborated of program unit name entity
9835 when Pragma_Preelaborate
=> Preelaborate
: declare
9836 Pa
: constant Node_Id
:= Parent
(N
);
9837 Pk
: constant Node_Kind
:= Nkind
(Pa
);
9841 Check_Ada_83_Warning
;
9842 Check_Valid_Library_Unit_Pragma
;
9844 if Nkind
(N
) = N_Null_Statement
then
9848 Ent
:= Find_Lib_Unit_Name
;
9850 -- This filters out pragmas inside generic parent then
9851 -- show up inside instantiation
9854 and then not (Pk
= N_Package_Specification
9855 and then Present
(Generic_Parent
(Pa
)))
9857 if not Debug_Flag_U
then
9858 Set_Is_Preelaborated
(Ent
);
9859 Set_Suppress_Elaboration_Warnings
(Ent
);
9864 ---------------------
9865 -- Preelaborate_05 --
9866 ---------------------
9868 -- pragma Preelaborate_05 [(library_unit_NAME)];
9870 -- This pragma is useable only in GNAT_Mode, where it is used like
9871 -- pragma Preelaborate but it is only effective in Ada 2005 mode
9872 -- (otherwise it is ignored). This is used to implement AI-362 which
9873 -- recategorizes some run-time packages in Ada 2005 mode.
9875 when Pragma_Preelaborate_05
=> Preelaborate_05
: declare
9880 Check_Valid_Library_Unit_Pragma
;
9882 if not GNAT_Mode
then
9883 Error_Pragma
("pragma% only available in GNAT mode");
9886 if Nkind
(N
) = N_Null_Statement
then
9890 -- This is one of the few cases where we need to test the value of
9891 -- Ada_Version_Explicit rather than Ada_Version (which is always
9892 -- set to Ada_05 in a predefined unit), we need to know the
9893 -- explicit version set to know if this pragma is active.
9895 if Ada_Version_Explicit
>= Ada_05
then
9896 Ent
:= Find_Lib_Unit_Name
;
9897 Set_Is_Preelaborated
(Ent
);
9898 Set_Suppress_Elaboration_Warnings
(Ent
);
9900 end Preelaborate_05
;
9906 -- pragma Priority (EXPRESSION);
9908 when Pragma_Priority
=> Priority
: declare
9909 P
: constant Node_Id
:= Parent
(N
);
9913 Check_No_Identifiers
;
9914 Check_Arg_Count
(1);
9918 if Nkind
(P
) = N_Subprogram_Body
then
9919 Check_In_Main_Program
;
9921 Arg
:= Expression
(Arg1
);
9922 Analyze_And_Resolve
(Arg
, Standard_Integer
);
9926 if not Is_Static_Expression
(Arg
) then
9927 Flag_Non_Static_Expr
9928 ("main subprogram priority is not static!", Arg
);
9931 -- If constraint error, then we already signalled an error
9933 elsif Raises_Constraint_Error
(Arg
) then
9936 -- Otherwise check in range
9940 Val
: constant Uint
:= Expr_Value
(Arg
);
9944 or else Val
> Expr_Value
(Expression
9945 (Parent
(RTE
(RE_Max_Priority
))))
9948 ("main subprogram priority is out of range", Arg1
);
9954 (Current_Sem_Unit
, UI_To_Int
(Expr_Value
(Arg
)));
9956 -- Load an arbitrary entity from System.Tasking to make sure
9957 -- this package is implicitly with'ed, since we need to have
9958 -- the tasking run-time active for the pragma Priority to have
9962 Discard
: Entity_Id
;
9963 pragma Warnings
(Off
, Discard
);
9965 Discard
:= RTE
(RE_Task_List
);
9968 -- Task or Protected, must be of type Integer
9970 elsif Nkind_In
(P
, N_Protected_Definition
, N_Task_Definition
) then
9971 Arg
:= Expression
(Arg1
);
9973 -- The expression must be analyzed in the special manner
9974 -- described in "Handling of Default and Per-Object
9975 -- Expressions" in sem.ads.
9977 Preanalyze_Spec_Expression
(Arg
, Standard_Integer
);
9979 if not Is_Static_Expression
(Arg
) then
9980 Check_Restriction
(Static_Priorities
, Arg
);
9983 -- Anything else is incorrect
9989 if Has_Priority_Pragma
(P
) then
9990 Error_Pragma
("duplicate pragma% not allowed");
9992 Set_Has_Priority_Pragma
(P
, True);
9994 if Nkind_In
(P
, N_Protected_Definition
, N_Task_Definition
) then
9995 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
9996 -- exp_ch9 should use this ???
10001 -----------------------------------
10002 -- Priority_Specific_Dispatching --
10003 -----------------------------------
10005 -- pragma Priority_Specific_Dispatching (
10006 -- policy_IDENTIFIER,
10007 -- first_priority_EXPRESSION,
10008 -- last_priority_EXPRESSION);
10010 when Pragma_Priority_Specific_Dispatching
=>
10011 Priority_Specific_Dispatching
: declare
10012 Prio_Id
: constant Entity_Id
:= RTE
(RE_Any_Priority
);
10013 -- This is the entity System.Any_Priority;
10016 Lower_Bound
: Node_Id
;
10017 Upper_Bound
: Node_Id
;
10023 Check_Arg_Count
(3);
10024 Check_No_Identifiers
;
10025 Check_Arg_Is_Task_Dispatching_Policy
(Arg1
);
10026 Check_Valid_Configuration_Pragma
;
10027 Get_Name_String
(Chars
(Expression
(Arg1
)));
10028 DP
:= Fold_Upper
(Name_Buffer
(1));
10030 Lower_Bound
:= Expression
(Arg2
);
10031 Check_Arg_Is_Static_Expression
(Lower_Bound
, Standard_Integer
);
10032 Lower_Val
:= Expr_Value
(Lower_Bound
);
10034 Upper_Bound
:= Expression
(Arg3
);
10035 Check_Arg_Is_Static_Expression
(Upper_Bound
, Standard_Integer
);
10036 Upper_Val
:= Expr_Value
(Upper_Bound
);
10038 -- It is not allowed to use Task_Dispatching_Policy and
10039 -- Priority_Specific_Dispatching in the same partition.
10041 if Task_Dispatching_Policy
/= ' ' then
10042 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
10044 ("pragma% incompatible with Task_Dispatching_Policy#");
10046 -- Check lower bound in range
10048 elsif Lower_Val
< Expr_Value
(Type_Low_Bound
(Prio_Id
))
10050 Lower_Val
> Expr_Value
(Type_High_Bound
(Prio_Id
))
10053 ("first_priority is out of range", Arg2
);
10055 -- Check upper bound in range
10057 elsif Upper_Val
< Expr_Value
(Type_Low_Bound
(Prio_Id
))
10059 Upper_Val
> Expr_Value
(Type_High_Bound
(Prio_Id
))
10062 ("last_priority is out of range", Arg3
);
10064 -- Check that the priority range is valid
10066 elsif Lower_Val
> Upper_Val
then
10068 ("last_priority_expression must be greater than" &
10069 " or equal to first_priority_expression");
10071 -- Store the new policy, but always preserve System_Location since
10072 -- we like the error message with the run-time name.
10075 -- Check overlapping in the priority ranges specified in other
10076 -- Priority_Specific_Dispatching pragmas within the same
10077 -- partition. We can only check those we know about!
10080 Specific_Dispatching
.First
.. Specific_Dispatching
.Last
10082 if Specific_Dispatching
.Table
(J
).First_Priority
in
10083 UI_To_Int
(Lower_Val
) .. UI_To_Int
(Upper_Val
)
10084 or else Specific_Dispatching
.Table
(J
).Last_Priority
in
10085 UI_To_Int
(Lower_Val
) .. UI_To_Int
(Upper_Val
)
10088 Specific_Dispatching
.Table
(J
).Pragma_Loc
;
10090 ("priority range overlaps with "
10091 & "Priority_Specific_Dispatching#");
10095 -- The use of Priority_Specific_Dispatching is incompatible
10096 -- with Task_Dispatching_Policy.
10098 if Task_Dispatching_Policy
/= ' ' then
10099 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
10101 ("Priority_Specific_Dispatching incompatible "
10102 & "with Task_Dispatching_Policy#");
10105 -- The use of Priority_Specific_Dispatching forces ceiling
10108 if Locking_Policy
/= ' ' and then Locking_Policy
/= 'C' then
10109 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
10111 ("Priority_Specific_Dispatching incompatible "
10112 & "with Locking_Policy#");
10114 -- Set the Ceiling_Locking policy, but preserve System_Location
10115 -- since we like the error message with the run time name.
10118 Locking_Policy
:= 'C';
10120 if Locking_Policy_Sloc
/= System_Location
then
10121 Locking_Policy_Sloc
:= Loc
;
10125 -- Add entry in the table
10127 Specific_Dispatching
.Append
10128 ((Dispatching_Policy
=> DP
,
10129 First_Priority
=> UI_To_Int
(Lower_Val
),
10130 Last_Priority
=> UI_To_Int
(Upper_Val
),
10131 Pragma_Loc
=> Loc
));
10133 end Priority_Specific_Dispatching
;
10139 -- pragma Profile (profile_IDENTIFIER);
10141 -- profile_IDENTIFIER => Restricted | Ravenscar
10143 when Pragma_Profile
=>
10145 Check_Arg_Count
(1);
10146 Check_Valid_Configuration_Pragma
;
10147 Check_No_Identifiers
;
10150 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
10152 if Chars
(Argx
) = Name_Ravenscar
then
10153 Set_Ravenscar_Profile
(N
);
10154 elsif Chars
(Argx
) = Name_Restricted
then
10155 Set_Profile_Restrictions
10156 (Restricted
, N
, Warn
=> Treat_Restrictions_As_Warnings
);
10158 Error_Pragma_Arg
("& is not a valid profile", Argx
);
10162 ----------------------
10163 -- Profile_Warnings --
10164 ----------------------
10166 -- pragma Profile_Warnings (profile_IDENTIFIER);
10168 -- profile_IDENTIFIER => Restricted | Ravenscar
10170 when Pragma_Profile_Warnings
=>
10172 Check_Arg_Count
(1);
10173 Check_Valid_Configuration_Pragma
;
10174 Check_No_Identifiers
;
10177 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
10179 if Chars
(Argx
) = Name_Ravenscar
then
10180 Set_Profile_Restrictions
(Ravenscar
, N
, Warn
=> True);
10181 elsif Chars
(Argx
) = Name_Restricted
then
10182 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> True);
10184 Error_Pragma_Arg
("& is not a valid profile", Argx
);
10188 --------------------------
10189 -- Propagate_Exceptions --
10190 --------------------------
10192 -- pragma Propagate_Exceptions;
10194 -- Note: this pragma is obsolete and has no effect
10196 when Pragma_Propagate_Exceptions
=>
10198 Check_Arg_Count
(0);
10200 if In_Extended_Main_Source_Unit
(N
) then
10201 Propagate_Exceptions
:= True;
10208 -- pragma Psect_Object (
10209 -- [Internal =>] LOCAL_NAME,
10210 -- [, [External =>] EXTERNAL_SYMBOL]
10211 -- [, [Size =>] EXTERNAL_SYMBOL]);
10213 when Pragma_Psect_Object | Pragma_Common_Object
=>
10214 Psect_Object
: declare
10215 Args
: Args_List
(1 .. 3);
10216 Names
: constant Name_List
(1 .. 3) := (
10221 Internal
: Node_Id
renames Args
(1);
10222 External
: Node_Id
renames Args
(2);
10223 Size
: Node_Id
renames Args
(3);
10225 Def_Id
: Entity_Id
;
10227 procedure Check_Too_Long
(Arg
: Node_Id
);
10228 -- Posts message if the argument is an identifier with more
10229 -- than 31 characters, or a string literal with more than
10230 -- 31 characters, and we are operating under VMS
10232 --------------------
10233 -- Check_Too_Long --
10234 --------------------
10236 procedure Check_Too_Long
(Arg
: Node_Id
) is
10237 X
: constant Node_Id
:= Original_Node
(Arg
);
10240 if not Nkind_In
(X
, N_String_Literal
, N_Identifier
) then
10242 ("inappropriate argument for pragma %", Arg
);
10245 if OpenVMS_On_Target
then
10246 if (Nkind
(X
) = N_String_Literal
10247 and then String_Length
(Strval
(X
)) > 31)
10249 (Nkind
(X
) = N_Identifier
10250 and then Length_Of_Name
(Chars
(X
)) > 31)
10253 ("argument for pragma % is longer than 31 characters",
10257 end Check_Too_Long
;
10259 -- Start of processing for Common_Object/Psect_Object
10263 Gather_Associations
(Names
, Args
);
10264 Process_Extended_Import_Export_Internal_Arg
(Internal
);
10266 Def_Id
:= Entity
(Internal
);
10268 if Ekind
(Def_Id
) /= E_Constant
10269 and then Ekind
(Def_Id
) /= E_Variable
10272 ("pragma% must designate an object", Internal
);
10275 Check_Too_Long
(Internal
);
10277 if Is_Imported
(Def_Id
) or else Is_Exported
(Def_Id
) then
10279 ("cannot use pragma% for imported/exported object",
10283 if Is_Concurrent_Type
(Etype
(Internal
)) then
10285 ("cannot specify pragma % for task/protected object",
10289 if Has_Rep_Pragma
(Def_Id
, Name_Common_Object
)
10291 Has_Rep_Pragma
(Def_Id
, Name_Psect_Object
)
10293 Error_Msg_N
("?duplicate Common/Psect_Object pragma", N
);
10296 if Ekind
(Def_Id
) = E_Constant
then
10298 ("cannot specify pragma % for a constant", Internal
);
10301 if Is_Record_Type
(Etype
(Internal
)) then
10307 Ent
:= First_Entity
(Etype
(Internal
));
10308 while Present
(Ent
) loop
10309 Decl
:= Declaration_Node
(Ent
);
10311 if Ekind
(Ent
) = E_Component
10312 and then Nkind
(Decl
) = N_Component_Declaration
10313 and then Present
(Expression
(Decl
))
10314 and then Warn_On_Export_Import
10317 ("?object for pragma % has defaults", Internal
);
10327 if Present
(Size
) then
10328 Check_Too_Long
(Size
);
10331 if Present
(External
) then
10332 Check_Arg_Is_External_Name
(External
);
10333 Check_Too_Long
(External
);
10336 -- If all error tests pass, link pragma on to the rep item chain
10338 Record_Rep_Item
(Def_Id
, N
);
10345 -- pragma Pure [(library_unit_NAME)];
10347 when Pragma_Pure
=> Pure
: declare
10351 Check_Ada_83_Warning
;
10352 Check_Valid_Library_Unit_Pragma
;
10354 if Nkind
(N
) = N_Null_Statement
then
10358 Ent
:= Find_Lib_Unit_Name
;
10360 Set_Has_Pragma_Pure
(Ent
);
10361 Set_Suppress_Elaboration_Warnings
(Ent
);
10368 -- pragma Pure_05 [(library_unit_NAME)];
10370 -- This pragma is useable only in GNAT_Mode, where it is used like
10371 -- pragma Pure but it is only effective in Ada 2005 mode (otherwise
10372 -- it is ignored). It may be used after a pragma Preelaborate, in
10373 -- which case it overrides the effect of the pragma Preelaborate.
10374 -- This is used to implement AI-362 which recategorizes some run-time
10375 -- packages in Ada 2005 mode.
10377 when Pragma_Pure_05
=> Pure_05
: declare
10382 Check_Valid_Library_Unit_Pragma
;
10384 if not GNAT_Mode
then
10385 Error_Pragma
("pragma% only available in GNAT mode");
10388 if Nkind
(N
) = N_Null_Statement
then
10392 -- This is one of the few cases where we need to test the value of
10393 -- Ada_Version_Explicit rather than Ada_Version (which is always
10394 -- set to Ada_05 in a predefined unit), we need to know the
10395 -- explicit version set to know if this pragma is active.
10397 if Ada_Version_Explicit
>= Ada_05
then
10398 Ent
:= Find_Lib_Unit_Name
;
10399 Set_Is_Preelaborated
(Ent
, False);
10401 Set_Suppress_Elaboration_Warnings
(Ent
);
10405 -------------------
10406 -- Pure_Function --
10407 -------------------
10409 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
10411 when Pragma_Pure_Function
=> Pure_Function
: declare
10414 Def_Id
: Entity_Id
;
10415 Effective
: Boolean := False;
10419 Check_Arg_Count
(1);
10420 Check_Optional_Identifier
(Arg1
, Name_Entity
);
10421 Check_Arg_Is_Local_Name
(Arg1
);
10422 E_Id
:= Expression
(Arg1
);
10424 if Error_Posted
(E_Id
) then
10428 -- Loop through homonyms (overloadings) of referenced entity
10430 E
:= Entity
(E_Id
);
10432 if Present
(E
) then
10434 Def_Id
:= Get_Base_Subprogram
(E
);
10436 if Ekind
(Def_Id
) /= E_Function
10437 and then Ekind
(Def_Id
) /= E_Generic_Function
10438 and then Ekind
(Def_Id
) /= E_Operator
10441 ("pragma% requires a function name", Arg1
);
10444 Set_Is_Pure
(Def_Id
);
10446 if not Has_Pragma_Pure_Function
(Def_Id
) then
10447 Set_Has_Pragma_Pure_Function
(Def_Id
);
10452 exit when No
(E
) or else Scope
(E
) /= Current_Scope
;
10456 and then Warn_On_Redundant_Constructs
10458 Error_Msg_NE
("pragma Pure_Function on& is redundant?",
10464 --------------------
10465 -- Queuing_Policy --
10466 --------------------
10468 -- pragma Queuing_Policy (policy_IDENTIFIER);
10470 when Pragma_Queuing_Policy
=> declare
10474 Check_Ada_83_Warning
;
10475 Check_Arg_Count
(1);
10476 Check_No_Identifiers
;
10477 Check_Arg_Is_Queuing_Policy
(Arg1
);
10478 Check_Valid_Configuration_Pragma
;
10479 Get_Name_String
(Chars
(Expression
(Arg1
)));
10480 QP
:= Fold_Upper
(Name_Buffer
(1));
10482 if Queuing_Policy
/= ' '
10483 and then Queuing_Policy
/= QP
10485 Error_Msg_Sloc
:= Queuing_Policy_Sloc
;
10486 Error_Pragma
("queuing policy incompatible with policy#");
10488 -- Set new policy, but always preserve System_Location since we
10489 -- like the error message with the run time name.
10492 Queuing_Policy
:= QP
;
10494 if Queuing_Policy_Sloc
/= System_Location
then
10495 Queuing_Policy_Sloc
:= Loc
;
10500 -----------------------
10501 -- Relative_Deadline --
10502 -----------------------
10504 -- pragma Relative_Deadline (time_span_EXPRESSION);
10506 when Pragma_Relative_Deadline
=> Relative_Deadline
: declare
10507 P
: constant Node_Id
:= Parent
(N
);
10512 Check_No_Identifiers
;
10513 Check_Arg_Count
(1);
10515 Arg
:= Expression
(Arg1
);
10517 -- The expression must be analyzed in the special manner described
10518 -- in "Handling of Default and Per-Object Expressions" in sem.ads.
10520 Preanalyze_Spec_Expression
(Arg
, RTE
(RE_Time_Span
));
10524 if Nkind
(P
) = N_Subprogram_Body
then
10525 Check_In_Main_Program
;
10529 elsif Nkind
(P
) = N_Task_Definition
then
10532 -- Anything else is incorrect
10538 if Has_Relative_Deadline_Pragma
(P
) then
10539 Error_Pragma
("duplicate pragma% not allowed");
10541 Set_Has_Relative_Deadline_Pragma
(P
, True);
10543 if Nkind
(P
) = N_Task_Definition
then
10544 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
10547 end Relative_Deadline
;
10549 ---------------------------
10550 -- Remote_Call_Interface --
10551 ---------------------------
10553 -- pragma Remote_Call_Interface [(library_unit_NAME)];
10555 when Pragma_Remote_Call_Interface
=> Remote_Call_Interface
: declare
10556 Cunit_Node
: Node_Id
;
10557 Cunit_Ent
: Entity_Id
;
10561 Check_Ada_83_Warning
;
10562 Check_Valid_Library_Unit_Pragma
;
10564 if Nkind
(N
) = N_Null_Statement
then
10568 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
10569 K
:= Nkind
(Unit
(Cunit_Node
));
10570 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
10572 if K
= N_Package_Declaration
10573 or else K
= N_Generic_Package_Declaration
10574 or else K
= N_Subprogram_Declaration
10575 or else K
= N_Generic_Subprogram_Declaration
10576 or else (K
= N_Subprogram_Body
10577 and then Acts_As_Spec
(Unit
(Cunit_Node
)))
10582 "pragma% must apply to package or subprogram declaration");
10585 Set_Is_Remote_Call_Interface
(Cunit_Ent
);
10586 end Remote_Call_Interface
;
10592 -- pragma Remote_Types [(library_unit_NAME)];
10594 when Pragma_Remote_Types
=> Remote_Types
: declare
10595 Cunit_Node
: Node_Id
;
10596 Cunit_Ent
: Entity_Id
;
10599 Check_Ada_83_Warning
;
10600 Check_Valid_Library_Unit_Pragma
;
10602 if Nkind
(N
) = N_Null_Statement
then
10606 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
10607 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
10609 if not Nkind_In
(Unit
(Cunit_Node
), N_Package_Declaration
,
10610 N_Generic_Package_Declaration
)
10613 ("pragma% can only apply to a package declaration");
10616 Set_Is_Remote_Types
(Cunit_Ent
);
10623 -- pragma Ravenscar;
10625 when Pragma_Ravenscar
=>
10627 Check_Arg_Count
(0);
10628 Check_Valid_Configuration_Pragma
;
10629 Set_Ravenscar_Profile
(N
);
10631 if Warn_On_Obsolescent_Feature
then
10633 ("pragma Ravenscar is an obsolescent feature?", N
);
10635 ("|use pragma Profile (Ravenscar) instead", N
);
10638 -------------------------
10639 -- Restricted_Run_Time --
10640 -------------------------
10642 -- pragma Restricted_Run_Time;
10644 when Pragma_Restricted_Run_Time
=>
10646 Check_Arg_Count
(0);
10647 Check_Valid_Configuration_Pragma
;
10648 Set_Profile_Restrictions
10649 (Restricted
, N
, Warn
=> Treat_Restrictions_As_Warnings
);
10651 if Warn_On_Obsolescent_Feature
then
10653 ("pragma Restricted_Run_Time is an obsolescent feature?", N
);
10655 ("|use pragma Profile (Restricted) instead", N
);
10662 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
10665 -- restriction_IDENTIFIER
10666 -- | restriction_parameter_IDENTIFIER => EXPRESSION
10668 when Pragma_Restrictions
=>
10669 Process_Restrictions_Or_Restriction_Warnings
10670 (Warn
=> Treat_Restrictions_As_Warnings
);
10672 --------------------------
10673 -- Restriction_Warnings --
10674 --------------------------
10676 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
10679 -- restriction_IDENTIFIER
10680 -- | restriction_parameter_IDENTIFIER => EXPRESSION
10682 when Pragma_Restriction_Warnings
=>
10684 Process_Restrictions_Or_Restriction_Warnings
(Warn
=> True);
10690 -- pragma Reviewable;
10692 when Pragma_Reviewable
=>
10693 Check_Ada_83_Warning
;
10694 Check_Arg_Count
(0);
10696 -- Call dummy debugging function rv. This is done to assist front
10697 -- end debugging. By placing a Reviewable pragma in the source
10698 -- program, a breakpoint on rv catches this place in the source,
10699 -- allowing convenient stepping to the point of interest.
10703 --------------------------
10704 -- Short_Circuit_And_Or --
10705 --------------------------
10707 when Pragma_Short_Circuit_And_Or
=>
10709 Check_Arg_Count
(0);
10710 Check_Valid_Configuration_Pragma
;
10711 Short_Circuit_And_Or
:= True;
10713 -------------------
10714 -- Share_Generic --
10715 -------------------
10717 -- pragma Share_Generic (NAME {, NAME});
10719 when Pragma_Share_Generic
=>
10721 Process_Generic_List
;
10727 -- pragma Shared (LOCAL_NAME);
10729 when Pragma_Shared
=>
10731 Process_Atomic_Shared_Volatile
;
10733 --------------------
10734 -- Shared_Passive --
10735 --------------------
10737 -- pragma Shared_Passive [(library_unit_NAME)];
10739 -- Set the flag Is_Shared_Passive of program unit name entity
10741 when Pragma_Shared_Passive
=> Shared_Passive
: declare
10742 Cunit_Node
: Node_Id
;
10743 Cunit_Ent
: Entity_Id
;
10746 Check_Ada_83_Warning
;
10747 Check_Valid_Library_Unit_Pragma
;
10749 if Nkind
(N
) = N_Null_Statement
then
10753 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
10754 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
10756 if not Nkind_In
(Unit
(Cunit_Node
), N_Package_Declaration
,
10757 N_Generic_Package_Declaration
)
10760 ("pragma% can only apply to a package declaration");
10763 Set_Is_Shared_Passive
(Cunit_Ent
);
10764 end Shared_Passive
;
10766 ----------------------
10767 -- Source_File_Name --
10768 ----------------------
10770 -- There are five forms for this pragma:
10772 -- pragma Source_File_Name (
10773 -- [UNIT_NAME =>] unit_NAME,
10774 -- BODY_FILE_NAME => STRING_LITERAL
10775 -- [, [INDEX =>] INTEGER_LITERAL]);
10777 -- pragma Source_File_Name (
10778 -- [UNIT_NAME =>] unit_NAME,
10779 -- SPEC_FILE_NAME => STRING_LITERAL
10780 -- [, [INDEX =>] INTEGER_LITERAL]);
10782 -- pragma Source_File_Name (
10783 -- BODY_FILE_NAME => STRING_LITERAL
10784 -- [, DOT_REPLACEMENT => STRING_LITERAL]
10785 -- [, CASING => CASING_SPEC]);
10787 -- pragma Source_File_Name (
10788 -- SPEC_FILE_NAME => STRING_LITERAL
10789 -- [, DOT_REPLACEMENT => STRING_LITERAL]
10790 -- [, CASING => CASING_SPEC]);
10792 -- pragma Source_File_Name (
10793 -- SUBUNIT_FILE_NAME => STRING_LITERAL
10794 -- [, DOT_REPLACEMENT => STRING_LITERAL]
10795 -- [, CASING => CASING_SPEC]);
10797 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
10799 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
10800 -- Source_File_Name (SFN), however their usage is exclusive: SFN can
10801 -- only be used when no project file is used, while SFNP can only be
10802 -- used when a project file is used.
10804 -- No processing here. Processing was completed during parsing, since
10805 -- we need to have file names set as early as possible. Units are
10806 -- loaded well before semantic processing starts.
10808 -- The only processing we defer to this point is the check for
10809 -- correct placement.
10811 when Pragma_Source_File_Name
=>
10813 Check_Valid_Configuration_Pragma
;
10815 ------------------------------
10816 -- Source_File_Name_Project --
10817 ------------------------------
10819 -- See Source_File_Name for syntax
10821 -- No processing here. Processing was completed during parsing, since
10822 -- we need to have file names set as early as possible. Units are
10823 -- loaded well before semantic processing starts.
10825 -- The only processing we defer to this point is the check for
10826 -- correct placement.
10828 when Pragma_Source_File_Name_Project
=>
10830 Check_Valid_Configuration_Pragma
;
10832 -- Check that a pragma Source_File_Name_Project is used only in a
10833 -- configuration pragmas file.
10835 -- Pragmas Source_File_Name_Project should only be generated by
10836 -- the Project Manager in configuration pragmas files.
10838 -- This is really an ugly test. It seems to depend on some
10839 -- accidental and undocumented property. At the very least it
10840 -- needs to be documented, but it would be better to have a
10841 -- clean way of testing if we are in a configuration file???
10843 if Present
(Parent
(N
)) then
10845 ("pragma% can only appear in a configuration pragmas file");
10848 ----------------------
10849 -- Source_Reference --
10850 ----------------------
10852 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
10854 -- Nothing to do, all processing completed in Par.Prag, since we need
10855 -- the information for possible parser messages that are output.
10857 when Pragma_Source_Reference
=>
10860 --------------------------------
10861 -- Static_Elaboration_Desired --
10862 --------------------------------
10864 -- pragma Static_Elaboration_Desired (DIRECT_NAME);
10866 when Pragma_Static_Elaboration_Desired
=>
10868 Check_At_Most_N_Arguments
(1);
10870 if Is_Compilation_Unit
(Current_Scope
)
10871 and then Ekind
(Current_Scope
) = E_Package
10873 Set_Static_Elaboration_Desired
(Current_Scope
, True);
10875 Error_Pragma
("pragma% must apply to a library-level package");
10882 -- pragma Storage_Size (EXPRESSION);
10884 when Pragma_Storage_Size
=> Storage_Size
: declare
10885 P
: constant Node_Id
:= Parent
(N
);
10889 Check_No_Identifiers
;
10890 Check_Arg_Count
(1);
10892 -- The expression must be analyzed in the special manner described
10893 -- in "Handling of Default Expressions" in sem.ads.
10895 Arg
:= Expression
(Arg1
);
10896 Preanalyze_Spec_Expression
(Arg
, Any_Integer
);
10898 if not Is_Static_Expression
(Arg
) then
10899 Check_Restriction
(Static_Storage_Size
, Arg
);
10902 if Nkind
(P
) /= N_Task_Definition
then
10907 if Has_Storage_Size_Pragma
(P
) then
10908 Error_Pragma
("duplicate pragma% not allowed");
10910 Set_Has_Storage_Size_Pragma
(P
, True);
10913 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
10914 -- ??? exp_ch9 should use this!
10922 -- pragma Storage_Unit (NUMERIC_LITERAL);
10924 -- Only permitted argument is System'Storage_Unit value
10926 when Pragma_Storage_Unit
=>
10927 Check_No_Identifiers
;
10928 Check_Arg_Count
(1);
10929 Check_Arg_Is_Integer_Literal
(Arg1
);
10931 if Intval
(Expression
(Arg1
)) /=
10932 UI_From_Int
(Ttypes
.System_Storage_Unit
)
10934 Error_Msg_Uint_1
:= UI_From_Int
(Ttypes
.System_Storage_Unit
);
10936 ("the only allowed argument for pragma% is ^", Arg1
);
10939 --------------------
10940 -- Stream_Convert --
10941 --------------------
10943 -- pragma Stream_Convert (
10944 -- [Entity =>] type_LOCAL_NAME,
10945 -- [Read =>] function_NAME,
10946 -- [Write =>] function NAME);
10948 when Pragma_Stream_Convert
=> Stream_Convert
: declare
10950 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
);
10951 -- Check that the given argument is the name of a local function
10952 -- of one argument that is not overloaded earlier in the current
10953 -- local scope. A check is also made that the argument is a
10954 -- function with one parameter.
10956 --------------------------------------
10957 -- Check_OK_Stream_Convert_Function --
10958 --------------------------------------
10960 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
) is
10964 Check_Arg_Is_Local_Name
(Arg
);
10965 Ent
:= Entity
(Expression
(Arg
));
10967 if Has_Homonym
(Ent
) then
10969 ("argument for pragma% may not be overloaded", Arg
);
10972 if Ekind
(Ent
) /= E_Function
10973 or else No
(First_Formal
(Ent
))
10974 or else Present
(Next_Formal
(First_Formal
(Ent
)))
10977 ("argument for pragma% must be" &
10978 " function of one argument", Arg
);
10980 end Check_OK_Stream_Convert_Function
;
10982 -- Start of processing for Stream_Convert
10986 Check_Arg_Order
((Name_Entity
, Name_Read
, Name_Write
));
10987 Check_Arg_Count
(3);
10988 Check_Optional_Identifier
(Arg1
, Name_Entity
);
10989 Check_Optional_Identifier
(Arg2
, Name_Read
);
10990 Check_Optional_Identifier
(Arg3
, Name_Write
);
10991 Check_Arg_Is_Local_Name
(Arg1
);
10992 Check_OK_Stream_Convert_Function
(Arg2
);
10993 Check_OK_Stream_Convert_Function
(Arg3
);
10996 Typ
: constant Entity_Id
:=
10997 Underlying_Type
(Entity
(Expression
(Arg1
)));
10998 Read
: constant Entity_Id
:= Entity
(Expression
(Arg2
));
10999 Write
: constant Entity_Id
:= Entity
(Expression
(Arg3
));
11002 Check_First_Subtype
(Arg1
);
11004 -- Check for too early or too late. Note that we don't enforce
11005 -- the rule about primitive operations in this case, since, as
11006 -- is the case for explicit stream attributes themselves, these
11007 -- restrictions are not appropriate. Note that the chaining of
11008 -- the pragma by Rep_Item_Too_Late is actually the critical
11009 -- processing done for this pragma.
11011 if Rep_Item_Too_Early
(Typ
, N
)
11013 Rep_Item_Too_Late
(Typ
, N
, FOnly
=> True)
11018 -- Return if previous error
11020 if Etype
(Typ
) = Any_Type
11022 Etype
(Read
) = Any_Type
11024 Etype
(Write
) = Any_Type
11031 if Underlying_Type
(Etype
(Read
)) /= Typ
then
11033 ("incorrect return type for function&", Arg2
);
11036 if Underlying_Type
(Etype
(First_Formal
(Write
))) /= Typ
then
11038 ("incorrect parameter type for function&", Arg3
);
11041 if Underlying_Type
(Etype
(First_Formal
(Read
))) /=
11042 Underlying_Type
(Etype
(Write
))
11045 ("result type of & does not match Read parameter type",
11049 end Stream_Convert
;
11051 -------------------------
11052 -- Style_Checks (GNAT) --
11053 -------------------------
11055 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
11057 -- This is processed by the parser since some of the style checks
11058 -- take place during source scanning and parsing. This means that
11059 -- we don't need to issue error messages here.
11061 when Pragma_Style_Checks
=> Style_Checks
: declare
11062 A
: constant Node_Id
:= Expression
(Arg1
);
11068 Check_No_Identifiers
;
11070 -- Two argument form
11072 if Arg_Count
= 2 then
11073 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
11080 E_Id
:= Expression
(Arg2
);
11083 if not Is_Entity_Name
(E_Id
) then
11085 ("second argument of pragma% must be entity name",
11089 E
:= Entity
(E_Id
);
11095 Set_Suppress_Style_Checks
(E
,
11096 (Chars
(Expression
(Arg1
)) = Name_Off
));
11097 exit when No
(Homonym
(E
));
11103 -- One argument form
11106 Check_Arg_Count
(1);
11108 if Nkind
(A
) = N_String_Literal
then
11112 Slen
: constant Natural := Natural (String_Length
(S
));
11113 Options
: String (1 .. Slen
);
11119 C
:= Get_String_Char
(S
, Int
(J
));
11120 exit when not In_Character_Range
(C
);
11121 Options
(J
) := Get_Character
(C
);
11123 -- If at end of string, set options. As per discussion
11124 -- above, no need to check for errors, since we issued
11125 -- them in the parser.
11128 Set_Style_Check_Options
(Options
);
11136 elsif Nkind
(A
) = N_Identifier
then
11137 if Chars
(A
) = Name_All_Checks
then
11138 Set_Default_Style_Check_Options
;
11140 elsif Chars
(A
) = Name_On
then
11141 Style_Check
:= True;
11143 elsif Chars
(A
) = Name_Off
then
11144 Style_Check
:= False;
11154 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
11156 when Pragma_Subtitle
=>
11158 Check_Arg_Count
(1);
11159 Check_Optional_Identifier
(Arg1
, Name_Subtitle
);
11160 Check_Arg_Is_String_Literal
(Arg1
);
11166 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
11168 when Pragma_Suppress
=>
11169 Process_Suppress_Unsuppress
(True);
11175 -- pragma Suppress_All;
11177 -- The only check made here is that the pragma appears in the proper
11178 -- place, i.e. following a compilation unit. If indeed it appears in
11179 -- this context, then the parser has already inserted an equivalent
11180 -- pragma Suppress (All_Checks) to get the required effect.
11182 when Pragma_Suppress_All
=>
11184 Check_Arg_Count
(0);
11186 if Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
11187 or else not Is_List_Member
(N
)
11188 or else List_Containing
(N
) /= Pragmas_After
(Parent
(N
))
11191 ("misplaced pragma%, must follow compilation unit");
11194 -------------------------
11195 -- Suppress_Debug_Info --
11196 -------------------------
11198 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
11200 when Pragma_Suppress_Debug_Info
=>
11202 Check_Arg_Count
(1);
11203 Check_Optional_Identifier
(Arg1
, Name_Entity
);
11204 Check_Arg_Is_Local_Name
(Arg1
);
11205 Set_Debug_Info_Off
(Entity
(Get_Pragma_Arg
(Arg1
)));
11207 ----------------------------------
11208 -- Suppress_Exception_Locations --
11209 ----------------------------------
11211 -- pragma Suppress_Exception_Locations;
11213 when Pragma_Suppress_Exception_Locations
=>
11215 Check_Arg_Count
(0);
11216 Check_Valid_Configuration_Pragma
;
11217 Exception_Locations_Suppressed
:= True;
11219 -----------------------------
11220 -- Suppress_Initialization --
11221 -----------------------------
11223 -- pragma Suppress_Initialization ([Entity =>] type_Name);
11225 when Pragma_Suppress_Initialization
=> Suppress_Init
: declare
11231 Check_Arg_Count
(1);
11232 Check_Optional_Identifier
(Arg1
, Name_Entity
);
11233 Check_Arg_Is_Local_Name
(Arg1
);
11235 E_Id
:= Expression
(Arg1
);
11237 if Etype
(E_Id
) = Any_Type
then
11241 E
:= Entity
(E_Id
);
11243 if Is_Type
(E
) then
11244 if Is_Incomplete_Or_Private_Type
(E
) then
11245 if No
(Full_View
(Base_Type
(E
))) then
11247 ("argument of pragma% cannot be an incomplete type",
11250 Set_Suppress_Init_Proc
(Full_View
(Base_Type
(E
)));
11253 Set_Suppress_Init_Proc
(Base_Type
(E
));
11258 ("pragma% requires argument that is a type name", Arg1
);
11266 -- pragma System_Name (DIRECT_NAME);
11268 -- Syntax check: one argument, which must be the identifier GNAT or
11269 -- the identifier GCC, no other identifiers are acceptable.
11271 when Pragma_System_Name
=>
11273 Check_No_Identifiers
;
11274 Check_Arg_Count
(1);
11275 Check_Arg_Is_One_Of
(Arg1
, Name_Gcc
, Name_Gnat
);
11277 -----------------------------
11278 -- Task_Dispatching_Policy --
11279 -----------------------------
11281 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
11283 when Pragma_Task_Dispatching_Policy
=> declare
11287 Check_Ada_83_Warning
;
11288 Check_Arg_Count
(1);
11289 Check_No_Identifiers
;
11290 Check_Arg_Is_Task_Dispatching_Policy
(Arg1
);
11291 Check_Valid_Configuration_Pragma
;
11292 Get_Name_String
(Chars
(Expression
(Arg1
)));
11293 DP
:= Fold_Upper
(Name_Buffer
(1));
11295 if Task_Dispatching_Policy
/= ' '
11296 and then Task_Dispatching_Policy
/= DP
11298 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
11300 ("task dispatching policy incompatible with policy#");
11302 -- Set new policy, but always preserve System_Location since we
11303 -- like the error message with the run time name.
11306 Task_Dispatching_Policy
:= DP
;
11308 if Task_Dispatching_Policy_Sloc
/= System_Location
then
11309 Task_Dispatching_Policy_Sloc
:= Loc
;
11318 -- pragma Task_Info (EXPRESSION);
11320 when Pragma_Task_Info
=> Task_Info
: declare
11321 P
: constant Node_Id
:= Parent
(N
);
11326 if Nkind
(P
) /= N_Task_Definition
then
11327 Error_Pragma
("pragma% must appear in task definition");
11330 Check_No_Identifiers
;
11331 Check_Arg_Count
(1);
11333 Analyze_And_Resolve
(Expression
(Arg1
), RTE
(RE_Task_Info_Type
));
11335 if Etype
(Expression
(Arg1
)) = Any_Type
then
11339 if Has_Task_Info_Pragma
(P
) then
11340 Error_Pragma
("duplicate pragma% not allowed");
11342 Set_Has_Task_Info_Pragma
(P
, True);
11350 -- pragma Task_Name (string_EXPRESSION);
11352 when Pragma_Task_Name
=> Task_Name
: declare
11353 P
: constant Node_Id
:= Parent
(N
);
11357 Check_No_Identifiers
;
11358 Check_Arg_Count
(1);
11360 Arg
:= Expression
(Arg1
);
11362 -- The expression is used in the call to Create_Task, and must be
11363 -- expanded there, not in the context of the current spec. It must
11364 -- however be analyzed to capture global references, in case it
11365 -- appears in a generic context.
11367 Preanalyze_And_Resolve
(Arg
, Standard_String
);
11369 if Nkind
(P
) /= N_Task_Definition
then
11373 if Has_Task_Name_Pragma
(P
) then
11374 Error_Pragma
("duplicate pragma% not allowed");
11376 Set_Has_Task_Name_Pragma
(P
, True);
11377 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
11385 -- pragma Task_Storage (
11386 -- [Task_Type =>] LOCAL_NAME,
11387 -- [Top_Guard =>] static_integer_EXPRESSION);
11389 when Pragma_Task_Storage
=> Task_Storage
: declare
11390 Args
: Args_List
(1 .. 2);
11391 Names
: constant Name_List
(1 .. 2) := (
11395 Task_Type
: Node_Id
renames Args
(1);
11396 Top_Guard
: Node_Id
renames Args
(2);
11402 Gather_Associations
(Names
, Args
);
11404 if No
(Task_Type
) then
11406 ("missing task_type argument for pragma%");
11409 Check_Arg_Is_Local_Name
(Task_Type
);
11411 Ent
:= Entity
(Task_Type
);
11413 if not Is_Task_Type
(Ent
) then
11415 ("argument for pragma% must be task type", Task_Type
);
11418 if No
(Top_Guard
) then
11420 ("pragma% takes two arguments", Task_Type
);
11422 Check_Arg_Is_Static_Expression
(Top_Guard
, Any_Integer
);
11425 Check_First_Subtype
(Task_Type
);
11427 if Rep_Item_Too_Late
(Ent
, N
) then
11432 --------------------------
11433 -- Thread_Local_Storage --
11434 --------------------------
11436 -- pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
11438 when Pragma_Thread_Local_Storage
=> Thread_Local_Storage
: declare
11444 Check_Arg_Count
(1);
11445 Check_Optional_Identifier
(Arg1
, Name_Entity
);
11446 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
11448 Id
:= Expression
(Arg1
);
11451 if not Is_Entity_Name
(Id
)
11452 or else Ekind
(Entity
(Id
)) /= E_Variable
11454 Error_Pragma_Arg
("local variable name required", Arg1
);
11459 if Rep_Item_Too_Early
(E
, N
)
11460 or else Rep_Item_Too_Late
(E
, N
)
11465 Set_Has_Pragma_Thread_Local_Storage
(E
);
11466 Set_Has_Gigi_Rep_Item
(E
);
11467 end Thread_Local_Storage
;
11473 -- pragma Time_Slice (static_duration_EXPRESSION);
11475 when Pragma_Time_Slice
=> Time_Slice
: declare
11481 Check_Arg_Count
(1);
11482 Check_No_Identifiers
;
11483 Check_In_Main_Program
;
11484 Check_Arg_Is_Static_Expression
(Arg1
, Standard_Duration
);
11486 if not Error_Posted
(Arg1
) then
11488 while Present
(Nod
) loop
11489 if Nkind
(Nod
) = N_Pragma
11490 and then Pragma_Name
(Nod
) = Name_Time_Slice
11492 Error_Msg_Name_1
:= Pname
;
11493 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
11500 -- Process only if in main unit
11502 if Get_Source_Unit
(Loc
) = Main_Unit
then
11503 Opt
.Time_Slice_Set
:= True;
11504 Val
:= Expr_Value_R
(Expression
(Arg1
));
11506 if Val
<= Ureal_0
then
11507 Opt
.Time_Slice_Value
:= 0;
11509 elsif Val
> UR_From_Uint
(UI_From_Int
(1000)) then
11510 Opt
.Time_Slice_Value
:= 1_000_000_000
;
11513 Opt
.Time_Slice_Value
:=
11514 UI_To_Int
(UR_To_Uint
(Val
* UI_From_Int
(1_000_000
)));
11523 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
11525 -- TITLING_OPTION ::=
11526 -- [Title =>] STRING_LITERAL
11527 -- | [Subtitle =>] STRING_LITERAL
11529 when Pragma_Title
=> Title
: declare
11530 Args
: Args_List
(1 .. 2);
11531 Names
: constant Name_List
(1 .. 2) := (
11537 Gather_Associations
(Names
, Args
);
11539 for J
in 1 .. 2 loop
11540 if Present
(Args
(J
)) then
11541 Check_Arg_Is_String_Literal
(Args
(J
));
11546 ---------------------
11547 -- Unchecked_Union --
11548 ---------------------
11550 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
11552 when Pragma_Unchecked_Union
=> Unchecked_Union
: declare
11553 Assoc
: constant Node_Id
:= Arg1
;
11554 Type_Id
: constant Node_Id
:= Expression
(Assoc
);
11565 Check_No_Identifiers
;
11566 Check_Arg_Count
(1);
11567 Check_Arg_Is_Local_Name
(Arg1
);
11569 Find_Type
(Type_Id
);
11570 Typ
:= Entity
(Type_Id
);
11573 or else Rep_Item_Too_Early
(Typ
, N
)
11577 Typ
:= Underlying_Type
(Typ
);
11580 if Rep_Item_Too_Late
(Typ
, N
) then
11584 Check_First_Subtype
(Arg1
);
11586 -- Note remaining cases are references to a type in the current
11587 -- declarative part. If we find an error, we post the error on
11588 -- the relevant type declaration at an appropriate point.
11590 if not Is_Record_Type
(Typ
) then
11591 Error_Msg_N
("Unchecked_Union must be record type", Typ
);
11594 elsif Is_Tagged_Type
(Typ
) then
11595 Error_Msg_N
("Unchecked_Union must not be tagged", Typ
);
11598 elsif Is_Limited_Type
(Typ
) then
11600 ("Unchecked_Union must not be limited record type", Typ
);
11601 Explain_Limited_Type
(Typ
, Typ
);
11605 if not Has_Discriminants
(Typ
) then
11607 ("Unchecked_Union must have one discriminant", Typ
);
11611 Discr
:= First_Discriminant
(Typ
);
11612 while Present
(Discr
) loop
11613 if No
(Discriminant_Default_Value
(Discr
)) then
11615 ("Unchecked_Union discriminant must have default value",
11618 Next_Discriminant
(Discr
);
11621 Tdef
:= Type_Definition
(Declaration_Node
(Typ
));
11622 Clist
:= Component_List
(Tdef
);
11624 Comp
:= First
(Component_Items
(Clist
));
11625 while Present
(Comp
) loop
11626 Check_Component
(Comp
);
11630 if No
(Clist
) or else No
(Variant_Part
(Clist
)) then
11632 ("Unchecked_Union must have variant part",
11637 Vpart
:= Variant_Part
(Clist
);
11639 Variant
:= First
(Variants
(Vpart
));
11640 while Present
(Variant
) loop
11641 Check_Variant
(Variant
);
11646 Set_Is_Unchecked_Union
(Typ
, True);
11647 Set_Convention
(Typ
, Convention_C
);
11649 Set_Has_Unchecked_Union
(Base_Type
(Typ
), True);
11650 Set_Is_Unchecked_Union
(Base_Type
(Typ
), True);
11651 end Unchecked_Union
;
11653 ------------------------
11654 -- Unimplemented_Unit --
11655 ------------------------
11657 -- pragma Unimplemented_Unit;
11659 -- Note: this only gives an error if we are generating code, or if
11660 -- we are in a generic library unit (where the pragma appears in the
11661 -- body, not in the spec).
11663 when Pragma_Unimplemented_Unit
=> Unimplemented_Unit
: declare
11664 Cunitent
: constant Entity_Id
:=
11665 Cunit_Entity
(Get_Source_Unit
(Loc
));
11666 Ent_Kind
: constant Entity_Kind
:=
11671 Check_Arg_Count
(0);
11673 if Operating_Mode
= Generate_Code
11674 or else Ent_Kind
= E_Generic_Function
11675 or else Ent_Kind
= E_Generic_Procedure
11676 or else Ent_Kind
= E_Generic_Package
11678 Get_Name_String
(Chars
(Cunitent
));
11679 Set_Casing
(Mixed_Case
);
11680 Write_Str
(Name_Buffer
(1 .. Name_Len
));
11681 Write_Str
(" is not supported in this configuration");
11683 raise Unrecoverable_Error
;
11685 end Unimplemented_Unit
;
11687 ------------------------
11688 -- Universal_Aliasing --
11689 ------------------------
11691 -- pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
11693 when Pragma_Universal_Aliasing
=> Universal_Alias
: declare
11698 Check_Arg_Count
(1);
11699 Check_Optional_Identifier
(Arg2
, Name_Entity
);
11700 Check_Arg_Is_Local_Name
(Arg1
);
11701 E_Id
:= Entity
(Expression
(Arg1
));
11703 if E_Id
= Any_Type
then
11705 elsif No
(E_Id
) or else not Is_Type
(E_Id
) then
11706 Error_Pragma_Arg
("pragma% requires type", Arg1
);
11709 Set_Universal_Aliasing
(Implementation_Base_Type
(E_Id
));
11710 end Universal_Alias
;
11712 --------------------
11713 -- Universal_Data --
11714 --------------------
11716 -- pragma Universal_Data [(library_unit_NAME)];
11718 when Pragma_Universal_Data
=>
11721 -- If this is a configuration pragma, then set the universal
11722 -- addressing option, otherwise confirm that the pragma satisfies
11723 -- the requirements of library unit pragma placement and leave it
11724 -- to the GNAAMP back end to detect the pragma (avoids transitive
11725 -- setting of the option due to withed units).
11727 if Is_Configuration_Pragma
then
11728 Universal_Addressing_On_AAMP
:= True;
11730 Check_Valid_Library_Unit_Pragma
;
11733 if not AAMP_On_Target
then
11734 Error_Pragma
("?pragma% ignored (applies only to AAMP)");
11741 -- pragma Unmodified (local_Name {, local_Name});
11743 when Pragma_Unmodified
=> Unmodified
: declare
11744 Arg_Node
: Node_Id
;
11745 Arg_Expr
: Node_Id
;
11746 Arg_Ent
: Entity_Id
;
11750 Check_At_Least_N_Arguments
(1);
11752 -- Loop through arguments
11755 while Present
(Arg_Node
) loop
11756 Check_No_Identifier
(Arg_Node
);
11758 -- Note: the analyze call done by Check_Arg_Is_Local_Name will
11759 -- in fact generate reference, so that the entity will have a
11760 -- reference, which will inhibit any warnings about it not
11761 -- being referenced, and also properly show up in the ali file
11762 -- as a reference. But this reference is recorded before the
11763 -- Has_Pragma_Unreferenced flag is set, so that no warning is
11764 -- generated for this reference.
11766 Check_Arg_Is_Local_Name
(Arg_Node
);
11767 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
11769 if Is_Entity_Name
(Arg_Expr
) then
11770 Arg_Ent
:= Entity
(Arg_Expr
);
11772 if not Is_Assignable
(Arg_Ent
) then
11774 ("pragma% can only be applied to a variable",
11777 Set_Has_Pragma_Unmodified
(Arg_Ent
);
11789 -- pragma Unreferenced (local_Name {, local_Name});
11791 -- or when used in a context clause:
11793 -- pragma Unreferenced (library_unit_NAME {, library_unit_NAME}
11795 when Pragma_Unreferenced
=> Unreferenced
: declare
11796 Arg_Node
: Node_Id
;
11797 Arg_Expr
: Node_Id
;
11798 Arg_Ent
: Entity_Id
;
11803 Check_At_Least_N_Arguments
(1);
11805 -- Check case of appearing within context clause
11807 if Is_In_Context_Clause
then
11809 -- The arguments must all be units mentioned in a with clause
11810 -- in the same context clause. Note we already checked (in
11811 -- Par.Prag) that the arguments are either identifiers or
11812 -- selected components.
11815 while Present
(Arg_Node
) loop
11816 Citem
:= First
(List_Containing
(N
));
11817 while Citem
/= N
loop
11818 if Nkind
(Citem
) = N_With_Clause
11819 and then Same_Name
(Name
(Citem
), Expression
(Arg_Node
))
11821 Set_Has_Pragma_Unreferenced
11824 (Library_Unit
(Citem
))));
11825 Set_Unit_Name
(Expression
(Arg_Node
), Name
(Citem
));
11834 ("argument of pragma% is not with'ed unit", Arg_Node
);
11840 -- Case of not in list of context items
11844 while Present
(Arg_Node
) loop
11845 Check_No_Identifier
(Arg_Node
);
11847 -- Note: the analyze call done by Check_Arg_Is_Local_Name
11848 -- will in fact generate reference, so that the entity will
11849 -- have a reference, which will inhibit any warnings about
11850 -- it not being referenced, and also properly show up in the
11851 -- ali file as a reference. But this reference is recorded
11852 -- before the Has_Pragma_Unreferenced flag is set, so that
11853 -- no warning is generated for this reference.
11855 Check_Arg_Is_Local_Name
(Arg_Node
);
11856 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
11858 if Is_Entity_Name
(Arg_Expr
) then
11859 Arg_Ent
:= Entity
(Arg_Expr
);
11861 -- If the entity is overloaded, the pragma applies to the
11862 -- most recent overloading, as documented. In this case,
11863 -- name resolution does not generate a reference, so it
11864 -- must be done here explicitly.
11866 if Is_Overloaded
(Arg_Expr
) then
11867 Generate_Reference
(Arg_Ent
, N
);
11870 Set_Has_Pragma_Unreferenced
(Arg_Ent
);
11878 --------------------------
11879 -- Unreferenced_Objects --
11880 --------------------------
11882 -- pragma Unreferenced_Objects (local_Name {, local_Name});
11884 when Pragma_Unreferenced_Objects
=> Unreferenced_Objects
: declare
11885 Arg_Node
: Node_Id
;
11886 Arg_Expr
: Node_Id
;
11890 Check_At_Least_N_Arguments
(1);
11893 while Present
(Arg_Node
) loop
11894 Check_No_Identifier
(Arg_Node
);
11895 Check_Arg_Is_Local_Name
(Arg_Node
);
11896 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
11898 if not Is_Entity_Name
(Arg_Expr
)
11899 or else not Is_Type
(Entity
(Arg_Expr
))
11902 ("argument for pragma% must be type or subtype", Arg_Node
);
11905 Set_Has_Pragma_Unreferenced_Objects
(Entity
(Arg_Expr
));
11908 end Unreferenced_Objects
;
11910 ------------------------------
11911 -- Unreserve_All_Interrupts --
11912 ------------------------------
11914 -- pragma Unreserve_All_Interrupts;
11916 when Pragma_Unreserve_All_Interrupts
=>
11918 Check_Arg_Count
(0);
11920 if In_Extended_Main_Code_Unit
(Main_Unit_Entity
) then
11921 Unreserve_All_Interrupts
:= True;
11928 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
11930 when Pragma_Unsuppress
=>
11932 Process_Suppress_Unsuppress
(False);
11934 -------------------
11935 -- Use_VADS_Size --
11936 -------------------
11938 -- pragma Use_VADS_Size;
11940 when Pragma_Use_VADS_Size
=>
11942 Check_Arg_Count
(0);
11943 Check_Valid_Configuration_Pragma
;
11944 Use_VADS_Size
:= True;
11946 ---------------------
11947 -- Validity_Checks --
11948 ---------------------
11950 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
11952 when Pragma_Validity_Checks
=> Validity_Checks
: declare
11953 A
: constant Node_Id
:= Expression
(Arg1
);
11959 Check_Arg_Count
(1);
11960 Check_No_Identifiers
;
11962 if Nkind
(A
) = N_String_Literal
then
11966 Slen
: constant Natural := Natural (String_Length
(S
));
11967 Options
: String (1 .. Slen
);
11973 C
:= Get_String_Char
(S
, Int
(J
));
11974 exit when not In_Character_Range
(C
);
11975 Options
(J
) := Get_Character
(C
);
11978 Set_Validity_Check_Options
(Options
);
11986 elsif Nkind
(A
) = N_Identifier
then
11988 if Chars
(A
) = Name_All_Checks
then
11989 Set_Validity_Check_Options
("a");
11991 elsif Chars
(A
) = Name_On
then
11992 Validity_Checks_On
:= True;
11994 elsif Chars
(A
) = Name_Off
then
11995 Validity_Checks_On
:= False;
11999 end Validity_Checks
;
12005 -- pragma Volatile (LOCAL_NAME);
12007 when Pragma_Volatile
=>
12008 Process_Atomic_Shared_Volatile
;
12010 -------------------------
12011 -- Volatile_Components --
12012 -------------------------
12014 -- pragma Volatile_Components (array_LOCAL_NAME);
12016 -- Volatile is handled by the same circuit as Atomic_Components
12022 -- pragma Warnings (On | Off);
12023 -- pragma Warnings (On | Off, LOCAL_NAME);
12024 -- pragma Warnings (static_string_EXPRESSION);
12025 -- pragma Warnings (On | Off, STRING_LITERAL);
12027 when Pragma_Warnings
=> Warnings
: begin
12029 Check_At_Least_N_Arguments
(1);
12030 Check_No_Identifiers
;
12032 -- If debug flag -gnatd.i is set, pragma is ignored
12034 if Debug_Flag_Dot_I
then
12038 -- Process various forms of the pragma
12041 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
12044 -- One argument case
12046 if Arg_Count
= 1 then
12048 -- On/Off one argument case was processed by parser
12050 if Nkind
(Argx
) = N_Identifier
12052 (Chars
(Argx
) = Name_On
12054 Chars
(Argx
) = Name_Off
)
12058 -- One argument case must be ON/OFF or static string expr
12060 elsif not Is_Static_String_Expression
(Arg1
) then
12062 ("argument of pragma% must be On/Off or " &
12063 "static string expression", Arg2
);
12065 -- One argument string expression case
12069 Lit
: constant Node_Id
:= Expr_Value_S
(Argx
);
12070 Str
: constant String_Id
:= Strval
(Lit
);
12071 Len
: constant Nat
:= String_Length
(Str
);
12079 while J
<= Len
loop
12080 C
:= Get_String_Char
(Str
, J
);
12081 OK
:= In_Character_Range
(C
);
12084 Chr
:= Get_Character
(C
);
12088 if J
< Len
and then Chr
= '.' then
12090 C
:= Get_String_Char
(Str
, J
);
12091 Chr
:= Get_Character
(C
);
12093 if not Set_Dot_Warning_Switch
(Chr
) then
12095 ("invalid warning switch character " &
12102 OK
:= Set_Warning_Switch
(Chr
);
12108 ("invalid warning switch character " & Chr
,
12117 -- Two or more arguments (must be two)
12120 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
12121 Check_At_Most_N_Arguments
(2);
12129 E_Id
:= Expression
(Arg2
);
12132 -- In the expansion of an inlined body, a reference to
12133 -- the formal may be wrapped in a conversion if the
12134 -- actual is a conversion. Retrieve the real entity name.
12136 if (In_Instance_Body
12137 or else In_Inlined_Body
)
12138 and then Nkind
(E_Id
) = N_Unchecked_Type_Conversion
12140 E_Id
:= Expression
(E_Id
);
12143 -- Entity name case
12145 if Is_Entity_Name
(E_Id
) then
12146 E
:= Entity
(E_Id
);
12153 (E
, (Chars
(Expression
(Arg1
)) = Name_Off
));
12155 if Chars
(Expression
(Arg1
)) = Name_Off
12156 and then Warn_On_Warnings_Off
12158 Warnings_Off_Pragmas
.Append
((N
, E
));
12161 if Is_Enumeration_Type
(E
) then
12165 Lit
:= First_Literal
(E
);
12166 while Present
(Lit
) loop
12167 Set_Warnings_Off
(Lit
);
12168 Next_Literal
(Lit
);
12173 exit when No
(Homonym
(E
));
12178 -- Error if not entity or static string literal case
12180 elsif not Is_Static_String_Expression
(Arg2
) then
12182 ("second argument of pragma% must be entity " &
12183 "name or static string expression", Arg2
);
12185 -- String literal case
12188 String_To_Name_Buffer
12189 (Strval
(Expr_Value_S
(Expression
(Arg2
))));
12191 -- Note on configuration pragma case: If this is a
12192 -- configuration pragma, then for an OFF pragma, we
12193 -- just set Config True in the call, which is all
12194 -- that needs to be done. For the case of ON, this
12195 -- is normally an error, unless it is canceling the
12196 -- effect of a previous OFF pragma in the same file.
12197 -- In any other case, an error will be signalled (ON
12198 -- with no matching OFF).
12200 if Chars
(Argx
) = Name_Off
then
12201 Set_Specific_Warning_Off
12202 (Loc
, Name_Buffer
(1 .. Name_Len
),
12203 Config
=> Is_Configuration_Pragma
);
12205 elsif Chars
(Argx
) = Name_On
then
12206 Set_Specific_Warning_On
12207 (Loc
, Name_Buffer
(1 .. Name_Len
), Err
);
12211 ("?pragma Warnings On with no " &
12212 "matching Warnings Off",
12222 -------------------
12223 -- Weak_External --
12224 -------------------
12226 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
12228 when Pragma_Weak_External
=> Weak_External
: declare
12233 Check_Arg_Count
(1);
12234 Check_Optional_Identifier
(Arg1
, Name_Entity
);
12235 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
12236 Ent
:= Entity
(Expression
(Arg1
));
12238 if Rep_Item_Too_Early
(Ent
, N
) then
12241 Ent
:= Underlying_Type
(Ent
);
12244 -- The only processing required is to link this item on to the
12245 -- list of rep items for the given entity. This is accomplished
12246 -- by the call to Rep_Item_Too_Late (when no error is detected
12247 -- and False is returned).
12249 if Rep_Item_Too_Late
(Ent
, N
) then
12252 Set_Has_Gigi_Rep_Item
(Ent
);
12256 -----------------------------
12257 -- Wide_Character_Encoding --
12258 -----------------------------
12260 -- pragma Wide_Character_Encoding (IDENTIFIER);
12262 when Pragma_Wide_Character_Encoding
=>
12265 -- Nothing to do, handled in parser. Note that we do not enforce
12266 -- configuration pragma placement, this pragma can appear at any
12267 -- place in the source, allowing mixed encodings within a single
12272 --------------------
12273 -- Unknown_Pragma --
12274 --------------------
12276 -- Should be impossible, since the case of an unknown pragma is
12277 -- separately processed before the case statement is entered.
12279 when Unknown_Pragma
=>
12280 raise Program_Error
;
12284 when Pragma_Exit
=> null;
12285 end Analyze_Pragma
;
12287 -------------------
12288 -- Check_Enabled --
12289 -------------------
12291 function Check_Enabled
(Nam
: Name_Id
) return Boolean is
12295 PP
:= Opt
.Check_Policy_List
;
12298 return Assertions_Enabled
;
12301 Nam
= Chars
(Expression
(First
(Pragma_Argument_Associations
(PP
))))
12304 Chars
(Expression
(Last
(Pragma_Argument_Associations
(PP
))))
12306 when Name_On | Name_Check
=>
12308 when Name_Off | Name_Ignore
=>
12311 raise Program_Error
;
12315 PP
:= Next_Pragma
(PP
);
12320 ---------------------------------
12321 -- Delay_Config_Pragma_Analyze --
12322 ---------------------------------
12324 function Delay_Config_Pragma_Analyze
(N
: Node_Id
) return Boolean is
12326 return Pragma_Name
(N
) = Name_Interrupt_State
12328 Pragma_Name
(N
) = Name_Priority_Specific_Dispatching
;
12329 end Delay_Config_Pragma_Analyze
;
12331 -------------------------
12332 -- Get_Base_Subprogram --
12333 -------------------------
12335 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
is
12336 Result
: Entity_Id
;
12339 -- Follow subprogram renaming chain
12342 while Is_Subprogram
(Result
)
12344 (Is_Generic_Instance
(Result
)
12345 or else Nkind
(Parent
(Declaration_Node
(Result
))) =
12346 N_Subprogram_Renaming_Declaration
)
12347 and then Present
(Alias
(Result
))
12349 Result
:= Alias
(Result
);
12353 end Get_Base_Subprogram
;
12355 --------------------
12356 -- Get_Pragma_Arg --
12357 --------------------
12359 function Get_Pragma_Arg
(Arg
: Node_Id
) return Node_Id
is
12361 if Nkind
(Arg
) = N_Pragma_Argument_Association
then
12362 return Expression
(Arg
);
12366 end Get_Pragma_Arg
;
12372 procedure Initialize
is
12377 -----------------------------
12378 -- Is_Config_Static_String --
12379 -----------------------------
12381 function Is_Config_Static_String
(Arg
: Node_Id
) return Boolean is
12383 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean;
12384 -- This is an internal recursive function that is just like the outer
12385 -- function except that it adds the string to the name buffer rather
12386 -- than placing the string in the name buffer.
12388 ------------------------------
12389 -- Add_Config_Static_String --
12390 ------------------------------
12392 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean is
12399 if Nkind
(N
) = N_Op_Concat
then
12400 if Add_Config_Static_String
(Left_Opnd
(N
)) then
12401 N
:= Right_Opnd
(N
);
12407 if Nkind
(N
) /= N_String_Literal
then
12408 Error_Msg_N
("string literal expected for pragma argument", N
);
12412 for J
in 1 .. String_Length
(Strval
(N
)) loop
12413 C
:= Get_String_Char
(Strval
(N
), J
);
12415 if not In_Character_Range
(C
) then
12417 ("string literal contains invalid wide character",
12418 Sloc
(N
) + 1 + Source_Ptr
(J
));
12422 Add_Char_To_Name_Buffer
(Get_Character
(C
));
12427 end Add_Config_Static_String
;
12429 -- Start of processing for Is_Config_Static_String
12434 return Add_Config_Static_String
(Arg
);
12435 end Is_Config_Static_String
;
12437 -----------------------------------------
12438 -- Is_Non_Significant_Pragma_Reference --
12439 -----------------------------------------
12441 -- This function makes use of the following static table which indicates
12442 -- whether a given pragma is significant. A value of -1 in this table
12443 -- indicates that the reference is significant. A value of zero indicates
12444 -- than appearance as any argument is insignificant, a positive value
12445 -- indicates that appearance in that parameter position is significant.
12447 -- A value of 99 flags a special case requiring a special check (this is
12448 -- used for cases not covered by this standard encoding, e.g. pragma Check
12449 -- where the first argument is not significant, but the others are).
12451 Sig_Flags
: constant array (Pragma_Id
) of Int
:=
12452 (Pragma_AST_Entry
=> -1,
12453 Pragma_Abort_Defer
=> -1,
12454 Pragma_Ada_83
=> -1,
12455 Pragma_Ada_95
=> -1,
12456 Pragma_Ada_05
=> -1,
12457 Pragma_Ada_2005
=> -1,
12458 Pragma_All_Calls_Remote
=> -1,
12459 Pragma_Annotate
=> -1,
12460 Pragma_Assert
=> -1,
12461 Pragma_Assertion_Policy
=> 0,
12462 Pragma_Assume_No_Invalid_Values
=> 0,
12463 Pragma_Asynchronous
=> -1,
12464 Pragma_Atomic
=> 0,
12465 Pragma_Atomic_Components
=> 0,
12466 Pragma_Attach_Handler
=> -1,
12467 Pragma_Check
=> 99,
12468 Pragma_Check_Name
=> 0,
12469 Pragma_Check_Policy
=> 0,
12470 Pragma_CIL_Constructor
=> -1,
12471 Pragma_CPP_Class
=> 0,
12472 Pragma_CPP_Constructor
=> 0,
12473 Pragma_CPP_Virtual
=> 0,
12474 Pragma_CPP_Vtable
=> 0,
12475 Pragma_C_Pass_By_Copy
=> 0,
12476 Pragma_Comment
=> 0,
12477 Pragma_Common_Object
=> -1,
12478 Pragma_Compile_Time_Error
=> -1,
12479 Pragma_Compile_Time_Warning
=> -1,
12480 Pragma_Compiler_Unit
=> 0,
12481 Pragma_Complete_Representation
=> 0,
12482 Pragma_Complex_Representation
=> 0,
12483 Pragma_Component_Alignment
=> -1,
12484 Pragma_Controlled
=> 0,
12485 Pragma_Convention
=> 0,
12486 Pragma_Convention_Identifier
=> 0,
12487 Pragma_Debug
=> -1,
12488 Pragma_Debug_Policy
=> 0,
12489 Pragma_Detect_Blocking
=> -1,
12490 Pragma_Discard_Names
=> 0,
12491 Pragma_Elaborate
=> -1,
12492 Pragma_Elaborate_All
=> -1,
12493 Pragma_Elaborate_Body
=> -1,
12494 Pragma_Elaboration_Checks
=> -1,
12495 Pragma_Eliminate
=> -1,
12496 Pragma_Export
=> -1,
12497 Pragma_Export_Exception
=> -1,
12498 Pragma_Export_Function
=> -1,
12499 Pragma_Export_Object
=> -1,
12500 Pragma_Export_Procedure
=> -1,
12501 Pragma_Export_Value
=> -1,
12502 Pragma_Export_Valued_Procedure
=> -1,
12503 Pragma_Extend_System
=> -1,
12504 Pragma_Extensions_Allowed
=> -1,
12505 Pragma_External
=> -1,
12506 Pragma_Favor_Top_Level
=> -1,
12507 Pragma_External_Name_Casing
=> -1,
12508 Pragma_Fast_Math
=> -1,
12509 Pragma_Finalize_Storage_Only
=> 0,
12510 Pragma_Float_Representation
=> 0,
12511 Pragma_Ident
=> -1,
12512 Pragma_Implemented_By_Entry
=> -1,
12513 Pragma_Implicit_Packing
=> 0,
12514 Pragma_Import
=> +2,
12515 Pragma_Import_Exception
=> 0,
12516 Pragma_Import_Function
=> 0,
12517 Pragma_Import_Object
=> 0,
12518 Pragma_Import_Procedure
=> 0,
12519 Pragma_Import_Valued_Procedure
=> 0,
12520 Pragma_Initialize_Scalars
=> -1,
12521 Pragma_Inline
=> 0,
12522 Pragma_Inline_Always
=> 0,
12523 Pragma_Inline_Generic
=> 0,
12524 Pragma_Inspection_Point
=> -1,
12525 Pragma_Interface
=> +2,
12526 Pragma_Interface_Name
=> +2,
12527 Pragma_Interrupt_Handler
=> -1,
12528 Pragma_Interrupt_Priority
=> -1,
12529 Pragma_Interrupt_State
=> -1,
12530 Pragma_Java_Constructor
=> -1,
12531 Pragma_Java_Interface
=> -1,
12532 Pragma_Keep_Names
=> 0,
12533 Pragma_License
=> -1,
12534 Pragma_Link_With
=> -1,
12535 Pragma_Linker_Alias
=> -1,
12536 Pragma_Linker_Constructor
=> -1,
12537 Pragma_Linker_Destructor
=> -1,
12538 Pragma_Linker_Options
=> -1,
12539 Pragma_Linker_Section
=> -1,
12541 Pragma_Locking_Policy
=> -1,
12542 Pragma_Long_Float
=> -1,
12543 Pragma_Machine_Attribute
=> -1,
12545 Pragma_Main_Storage
=> -1,
12546 Pragma_Memory_Size
=> -1,
12547 Pragma_No_Return
=> 0,
12548 Pragma_No_Body
=> 0,
12549 Pragma_No_Run_Time
=> -1,
12550 Pragma_No_Strict_Aliasing
=> -1,
12551 Pragma_Normalize_Scalars
=> -1,
12552 Pragma_Obsolescent
=> 0,
12553 Pragma_Optimize
=> -1,
12554 Pragma_Optimize_Alignment
=> -1,
12557 Pragma_Passive
=> -1,
12558 Pragma_Preelaborable_Initialization
=> -1,
12559 Pragma_Polling
=> -1,
12560 Pragma_Persistent_BSS
=> 0,
12561 Pragma_Postcondition
=> -1,
12562 Pragma_Precondition
=> -1,
12563 Pragma_Preelaborate
=> -1,
12564 Pragma_Preelaborate_05
=> -1,
12565 Pragma_Priority
=> -1,
12566 Pragma_Priority_Specific_Dispatching
=> -1,
12567 Pragma_Profile
=> 0,
12568 Pragma_Profile_Warnings
=> 0,
12569 Pragma_Propagate_Exceptions
=> -1,
12570 Pragma_Psect_Object
=> -1,
12572 Pragma_Pure_05
=> -1,
12573 Pragma_Pure_Function
=> -1,
12574 Pragma_Queuing_Policy
=> -1,
12575 Pragma_Ravenscar
=> -1,
12576 Pragma_Relative_Deadline
=> -1,
12577 Pragma_Remote_Call_Interface
=> -1,
12578 Pragma_Remote_Types
=> -1,
12579 Pragma_Restricted_Run_Time
=> -1,
12580 Pragma_Restriction_Warnings
=> -1,
12581 Pragma_Restrictions
=> -1,
12582 Pragma_Reviewable
=> -1,
12583 Pragma_Short_Circuit_And_Or
=> -1,
12584 Pragma_Share_Generic
=> -1,
12585 Pragma_Shared
=> -1,
12586 Pragma_Shared_Passive
=> -1,
12587 Pragma_Source_File_Name
=> -1,
12588 Pragma_Source_File_Name_Project
=> -1,
12589 Pragma_Source_Reference
=> -1,
12590 Pragma_Storage_Size
=> -1,
12591 Pragma_Storage_Unit
=> -1,
12592 Pragma_Static_Elaboration_Desired
=> -1,
12593 Pragma_Stream_Convert
=> -1,
12594 Pragma_Style_Checks
=> -1,
12595 Pragma_Subtitle
=> -1,
12596 Pragma_Suppress
=> 0,
12597 Pragma_Suppress_Exception_Locations
=> 0,
12598 Pragma_Suppress_All
=> -1,
12599 Pragma_Suppress_Debug_Info
=> 0,
12600 Pragma_Suppress_Initialization
=> 0,
12601 Pragma_System_Name
=> -1,
12602 Pragma_Task_Dispatching_Policy
=> -1,
12603 Pragma_Task_Info
=> -1,
12604 Pragma_Task_Name
=> -1,
12605 Pragma_Task_Storage
=> 0,
12606 Pragma_Thread_Local_Storage
=> 0,
12607 Pragma_Time_Slice
=> -1,
12608 Pragma_Title
=> -1,
12609 Pragma_Unchecked_Union
=> 0,
12610 Pragma_Unimplemented_Unit
=> -1,
12611 Pragma_Universal_Aliasing
=> -1,
12612 Pragma_Universal_Data
=> -1,
12613 Pragma_Unmodified
=> -1,
12614 Pragma_Unreferenced
=> -1,
12615 Pragma_Unreferenced_Objects
=> -1,
12616 Pragma_Unreserve_All_Interrupts
=> -1,
12617 Pragma_Unsuppress
=> 0,
12618 Pragma_Use_VADS_Size
=> -1,
12619 Pragma_Validity_Checks
=> -1,
12620 Pragma_Volatile
=> 0,
12621 Pragma_Volatile_Components
=> 0,
12622 Pragma_Warnings
=> -1,
12623 Pragma_Weak_External
=> -1,
12624 Pragma_Wide_Character_Encoding
=> 0,
12625 Unknown_Pragma
=> 0);
12627 function Is_Non_Significant_Pragma_Reference
(N
: Node_Id
) return Boolean is
12636 if Nkind
(P
) /= N_Pragma_Argument_Association
then
12640 Id
:= Get_Pragma_Id
(Parent
(P
));
12641 C
:= Sig_Flags
(Id
);
12653 -- For pragma Check, the first argument is not significant,
12654 -- the second and the third (if present) arguments are
12657 when Pragma_Check
=>
12659 P
= First
(Pragma_Argument_Associations
(Parent
(P
)));
12662 raise Program_Error
;
12666 A
:= First
(Pragma_Argument_Associations
(Parent
(P
)));
12667 for J
in 1 .. C
- 1 loop
12675 return A
= P
; -- is this wrong way round ???
12678 end Is_Non_Significant_Pragma_Reference
;
12680 ------------------------------
12681 -- Is_Pragma_String_Literal --
12682 ------------------------------
12684 -- This function returns true if the corresponding pragma argument is a
12685 -- static string expression. These are the only cases in which string
12686 -- literals can appear as pragma arguments. We also allow a string literal
12687 -- as the first argument to pragma Assert (although it will of course
12688 -- always generate a type error).
12690 function Is_Pragma_String_Literal
(Par
: Node_Id
) return Boolean is
12691 Pragn
: constant Node_Id
:= Parent
(Par
);
12692 Assoc
: constant List_Id
:= Pragma_Argument_Associations
(Pragn
);
12693 Pname
: constant Name_Id
:= Pragma_Name
(Pragn
);
12699 N
:= First
(Assoc
);
12706 if Pname
= Name_Assert
then
12709 elsif Pname
= Name_Export
then
12712 elsif Pname
= Name_Ident
then
12715 elsif Pname
= Name_Import
then
12718 elsif Pname
= Name_Interface_Name
then
12721 elsif Pname
= Name_Linker_Alias
then
12724 elsif Pname
= Name_Linker_Section
then
12727 elsif Pname
= Name_Machine_Attribute
then
12730 elsif Pname
= Name_Source_File_Name
then
12733 elsif Pname
= Name_Source_Reference
then
12736 elsif Pname
= Name_Title
then
12739 elsif Pname
= Name_Subtitle
then
12745 end Is_Pragma_String_Literal
;
12747 --------------------------------------
12748 -- Process_Compilation_Unit_Pragmas --
12749 --------------------------------------
12751 procedure Process_Compilation_Unit_Pragmas
(N
: Node_Id
) is
12753 -- A special check for pragma Suppress_All, a very strange DEC pragma,
12754 -- strange because it comes at the end of the unit. If we have a pragma
12755 -- Suppress_All in the Pragmas_After of the current unit, then we insert
12756 -- a pragma Suppress (All_Checks) at the start of the context clause to
12757 -- ensure the correct processing.
12760 PA
: constant List_Id
:= Pragmas_After
(Aux_Decls_Node
(N
));
12764 if Present
(PA
) then
12766 while Present
(P
) loop
12767 if Pragma_Name
(P
) = Name_Suppress_All
then
12768 Prepend_To
(Context_Items
(N
),
12769 Make_Pragma
(Sloc
(P
),
12770 Chars
=> Name_Suppress
,
12771 Pragma_Argument_Associations
=> New_List
(
12772 Make_Pragma_Argument_Association
(Sloc
(P
),
12774 Make_Identifier
(Sloc
(P
),
12775 Chars
=> Name_All_Checks
)))));
12783 end Process_Compilation_Unit_Pragmas
;
12794 --------------------------------
12795 -- Set_Encoded_Interface_Name --
12796 --------------------------------
12798 procedure Set_Encoded_Interface_Name
(E
: Entity_Id
; S
: Node_Id
) is
12799 Str
: constant String_Id
:= Strval
(S
);
12800 Len
: constant Int
:= String_Length
(Str
);
12805 Hex
: constant array (0 .. 15) of Character := "0123456789abcdef";
12808 -- Stores encoded value of character code CC. The encoding we use an
12809 -- underscore followed by four lower case hex digits.
12815 procedure Encode
is
12817 Store_String_Char
(Get_Char_Code
('_'));
12819 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 12))));
12821 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 8 and 16#
0F#
))));
12823 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 4 and 16#
0F#
))));
12825 (Get_Char_Code
(Hex
(Integer (CC
and 16#
0F#
))));
12828 -- Start of processing for Set_Encoded_Interface_Name
12831 -- If first character is asterisk, this is a link name, and we leave it
12832 -- completely unmodified. We also ignore null strings (the latter case
12833 -- happens only in error cases) and no encoding should occur for Java or
12834 -- AAMP interface names.
12837 or else Get_String_Char
(Str
, 1) = Get_Char_Code
('*')
12838 or else VM_Target
/= No_VM
12839 or else AAMP_On_Target
12841 Set_Interface_Name
(E
, S
);
12846 CC
:= Get_String_Char
(Str
, J
);
12848 exit when not In_Character_Range
(CC
);
12850 C
:= Get_Character
(CC
);
12852 exit when C
/= '_' and then C
/= '$'
12853 and then C
not in '0' .. '9'
12854 and then C
not in 'a' .. 'z'
12855 and then C
not in 'A' .. 'Z';
12858 Set_Interface_Name
(E
, S
);
12866 -- Here we need to encode. The encoding we use as follows:
12867 -- three underscores + four hex digits (lower case)
12871 for J
in 1 .. String_Length
(Str
) loop
12872 CC
:= Get_String_Char
(Str
, J
);
12874 if not In_Character_Range
(CC
) then
12877 C
:= Get_Character
(CC
);
12879 if C
= '_' or else C
= '$'
12880 or else C
in '0' .. '9'
12881 or else C
in 'a' .. 'z'
12882 or else C
in 'A' .. 'Z'
12884 Store_String_Char
(CC
);
12891 Set_Interface_Name
(E
,
12892 Make_String_Literal
(Sloc
(S
),
12893 Strval
=> End_String
));
12895 end Set_Encoded_Interface_Name
;
12897 -------------------
12898 -- Set_Unit_Name --
12899 -------------------
12901 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
) is
12906 if Nkind
(N
) = N_Identifier
12907 and then Nkind
(With_Item
) = N_Identifier
12909 Set_Entity
(N
, Entity
(With_Item
));
12911 elsif Nkind
(N
) = N_Selected_Component
then
12912 Change_Selected_Component_To_Expanded_Name
(N
);
12913 Set_Entity
(N
, Entity
(With_Item
));
12914 Set_Entity
(Selector_Name
(N
), Entity
(N
));
12916 Pref
:= Prefix
(N
);
12917 Scop
:= Scope
(Entity
(N
));
12918 while Nkind
(Pref
) = N_Selected_Component
loop
12919 Change_Selected_Component_To_Expanded_Name
(Pref
);
12920 Set_Entity
(Selector_Name
(Pref
), Scop
);
12921 Set_Entity
(Pref
, Scop
);
12922 Pref
:= Prefix
(Pref
);
12923 Scop
:= Scope
(Scop
);
12926 Set_Entity
(Pref
, Scop
);