1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2010, 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_Ch7
; use Exp_Ch7
;
41 with Exp_Dist
; use Exp_Dist
;
43 with Lib
.Writ
; use Lib
.Writ
;
44 with Lib
.Xref
; use Lib
.Xref
;
45 with Namet
.Sp
; use Namet
.Sp
;
46 with Nlists
; use Nlists
;
47 with Nmake
; use Nmake
;
49 with Output
; use Output
;
50 with Par_SCO
; use Par_SCO
;
51 with Restrict
; use Restrict
;
52 with Rident
; use Rident
;
53 with Rtsfind
; use Rtsfind
;
55 with Sem_Aux
; use Sem_Aux
;
56 with Sem_Ch3
; use Sem_Ch3
;
57 with Sem_Ch6
; use Sem_Ch6
;
58 with Sem_Ch8
; use Sem_Ch8
;
59 with Sem_Ch12
; use Sem_Ch12
;
60 with Sem_Ch13
; use Sem_Ch13
;
61 with Sem_Disp
; use Sem_Disp
;
62 with Sem_Dist
; use Sem_Dist
;
63 with Sem_Elim
; use Sem_Elim
;
64 with Sem_Eval
; use Sem_Eval
;
65 with Sem_Intr
; use Sem_Intr
;
66 with Sem_Mech
; use Sem_Mech
;
67 with Sem_Res
; use Sem_Res
;
68 with Sem_Type
; use Sem_Type
;
69 with Sem_Util
; use Sem_Util
;
70 with Sem_VFpt
; use Sem_VFpt
;
71 with Sem_Warn
; use Sem_Warn
;
72 with Stand
; use Stand
;
73 with Sinfo
; use Sinfo
;
74 with Sinfo
.CN
; use Sinfo
.CN
;
75 with Sinput
; use Sinput
;
76 with Snames
; use Snames
;
77 with Stringt
; use Stringt
;
78 with Stylesw
; use Stylesw
;
80 with Targparm
; use Targparm
;
81 with Tbuild
; use Tbuild
;
83 with Uintp
; use Uintp
;
84 with Uname
; use Uname
;
85 with Urealp
; use Urealp
;
86 with Validsw
; use Validsw
;
88 package body Sem_Prag
is
90 ----------------------------------------------
91 -- Common Handling of Import-Export Pragmas --
92 ----------------------------------------------
94 -- In the following section, a number of Import_xxx and Export_xxx pragmas
95 -- are defined by GNAT. These are compatible with the DEC pragmas of the
96 -- same name, and all have the following common form and processing:
99 -- [Internal =>] LOCAL_NAME
100 -- [, [External =>] EXTERNAL_SYMBOL]
101 -- [, other optional parameters ]);
104 -- [Internal =>] LOCAL_NAME
105 -- [, [External =>] EXTERNAL_SYMBOL]
106 -- [, other optional parameters ]);
108 -- EXTERNAL_SYMBOL ::=
110 -- | static_string_EXPRESSION
112 -- The internal LOCAL_NAME designates the entity that is imported or
113 -- exported, and must refer to an entity in the current declarative
114 -- part (as required by the rules for LOCAL_NAME).
116 -- The external linker name is designated by the External parameter if
117 -- given, or the Internal parameter if not (if there is no External
118 -- parameter, the External parameter is a copy of the Internal name).
120 -- If the External parameter is given as a string, then this string is
121 -- treated as an external name (exactly as though it had been given as an
122 -- External_Name parameter for a normal Import pragma).
124 -- If the External parameter is given as an identifier (or there is no
125 -- External parameter, so that the Internal identifier is used), then
126 -- the external name is the characters of the identifier, translated
127 -- to all upper case letters for OpenVMS versions of GNAT, and to all
128 -- lower case letters for all other versions
130 -- Note: the external name specified or implied by any of these special
131 -- Import_xxx or Export_xxx pragmas override an external or link name
132 -- specified in a previous Import or Export pragma.
134 -- Note: these and all other DEC-compatible GNAT pragmas allow full use of
135 -- named notation, following the standard rules for subprogram calls, i.e.
136 -- parameters can be given in any order if named notation is used, and
137 -- positional and named notation can be mixed, subject to the rule that all
138 -- positional parameters must appear first.
140 -- Note: All these pragmas are implemented exactly following the DEC design
141 -- and implementation and are intended to be fully compatible with the use
142 -- of these pragmas in the DEC Ada compiler.
144 --------------------------------------------
145 -- Checking for Duplicated External Names --
146 --------------------------------------------
148 -- It is suspicious if two separate Export pragmas use the same external
149 -- name. The following table is used to diagnose this situation so that
150 -- an appropriate warning can be issued.
152 -- The Node_Id stored is for the N_String_Literal node created to hold
153 -- the value of the external name. The Sloc of this node is used to
154 -- cross-reference the location of the duplication.
156 package Externals
is new Table
.Table
(
157 Table_Component_Type
=> Node_Id
,
158 Table_Index_Type
=> Int
,
159 Table_Low_Bound
=> 0,
160 Table_Initial
=> 100,
161 Table_Increment
=> 100,
162 Table_Name
=> "Name_Externals");
164 -------------------------------------
165 -- Local Subprograms and Variables --
166 -------------------------------------
168 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
;
169 -- This routine is used for possible casing adjustment of an explicit
170 -- external name supplied as a string literal (the node N), according to
171 -- the casing requirement of Opt.External_Name_Casing. If this is set to
172 -- As_Is, then the string literal is returned unchanged, but if it is set
173 -- to Uppercase or Lowercase, then a new string literal with appropriate
174 -- casing is constructed.
176 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
;
177 -- If Def_Id refers to a renamed subprogram, then the base subprogram (the
178 -- original one, following the renaming chain) is returned. Otherwise the
179 -- entity is returned unchanged. Should be in Einfo???
182 -- This is a dummy function called by the processing for pragma Reviewable.
183 -- It is there for assisting front end debugging. By placing a Reviewable
184 -- pragma in the source program, a breakpoint on rv catches this place in
185 -- the source, allowing convenient stepping to the point of interest.
187 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
);
188 -- Place semantic information on the argument of an Elaborate/Elaborate_All
189 -- pragma. Entity name for unit and its parents is taken from item in
190 -- previous with_clause that mentions the unit.
192 -------------------------------
193 -- Adjust_External_Name_Case --
194 -------------------------------
196 function Adjust_External_Name_Case
(N
: Node_Id
) return Node_Id
is
200 -- Adjust case of literal if required
202 if Opt
.External_Name_Exp_Casing
= As_Is
then
206 -- Copy existing string
212 for J
in 1 .. String_Length
(Strval
(N
)) loop
213 CC
:= Get_String_Char
(Strval
(N
), J
);
215 if Opt
.External_Name_Exp_Casing
= Uppercase
216 and then CC
>= Get_Char_Code
('a')
217 and then CC
<= Get_Char_Code
('z')
219 Store_String_Char
(CC
- 32);
221 elsif Opt
.External_Name_Exp_Casing
= Lowercase
222 and then CC
>= Get_Char_Code
('A')
223 and then CC
<= Get_Char_Code
('Z')
225 Store_String_Char
(CC
+ 32);
228 Store_String_Char
(CC
);
233 Make_String_Literal
(Sloc
(N
),
234 Strval
=> End_String
);
236 end Adjust_External_Name_Case
;
238 ------------------------------
239 -- Analyze_PPC_In_Decl_Part --
240 ------------------------------
242 procedure Analyze_PPC_In_Decl_Part
(N
: Node_Id
; S
: Entity_Id
) is
243 Arg1
: constant Node_Id
:= First
(Pragma_Argument_Associations
(N
));
246 -- Install formals and push subprogram spec onto scope stack so that we
247 -- can see the formals from the pragma.
252 -- Preanalyze the boolean expression, we treat this as a spec expression
253 -- (i.e. similar to a default expression).
255 Preanalyze_Spec_Expression
256 (Get_Pragma_Arg
(Arg1
), Standard_Boolean
);
258 -- Remove the subprogram from the scope stack now that the pre-analysis
259 -- of the precondition/postcondition is done.
262 end Analyze_PPC_In_Decl_Part
;
268 procedure Analyze_Pragma
(N
: Node_Id
) is
269 Loc
: constant Source_Ptr
:= Sloc
(N
);
270 Pname
: constant Name_Id
:= Pragma_Name
(N
);
273 Sense
: constant Boolean := not Aspect_Cancel
(N
);
274 -- Sense is True if we have the normal case of a pragma that is active
275 -- and turns the corresponding aspect on. It is false only for the case
276 -- of a pragma coming from an aspect which is explicitly turned off by
277 -- using aspect => False. If Sense is False, the effect of the pragma
278 -- is to turn the corresponding aspect off.
280 Pragma_Exit
: exception;
281 -- This exception is used to exit pragma processing completely. It is
282 -- used when an error is detected, and no further processing is
283 -- required. It is also used if an earlier error has left the tree in
284 -- a state where the pragma should not be processed.
287 -- Number of pragma argument associations
293 -- First four pragma arguments (pragma argument association nodes, or
294 -- Empty if the corresponding argument does not exist).
296 type Name_List
is array (Natural range <>) of Name_Id
;
297 type Args_List
is array (Natural range <>) of Node_Id
;
298 -- Types used for arguments to Check_Arg_Order and Gather_Associations
300 procedure Ada_2005_Pragma
;
301 -- Called for pragmas defined in Ada 2005, that are not in Ada 95. In
302 -- Ada 95 mode, these are implementation defined pragmas, so should be
303 -- caught by the No_Implementation_Pragmas restriction.
305 procedure Ada_2012_Pragma
;
306 -- Called for pragmas defined in Ada 2012, that are not in Ada 95 or 05.
307 -- In Ada 95 or 05 mode, these are implementation defined pragmas, so
308 -- should be caught by the No_Implementation_Pragmas restriction.
310 procedure Check_Ada_83_Warning
;
311 -- Issues a warning message for the current pragma if operating in Ada
312 -- 83 mode (used for language pragmas that are not a standard part of
313 -- Ada 83). This procedure does not raise Error_Pragma. Also notes use
316 procedure Check_Arg_Count
(Required
: Nat
);
317 -- Check argument count for pragma is equal to given parameter. If not,
318 -- then issue an error message and raise Pragma_Exit.
320 -- Note: all routines whose name is Check_Arg_Is_xxx take an argument
321 -- Arg which can either be a pragma argument association, in which case
322 -- the check is applied to the expression of the association or an
323 -- expression directly.
325 procedure Check_Arg_Is_External_Name
(Arg
: Node_Id
);
326 -- Check that an argument has the right form for an EXTERNAL_NAME
327 -- parameter of an extended import/export pragma. The rule is that the
328 -- name must be an identifier or string literal (in Ada 83 mode) or a
329 -- static string expression (in Ada 95 mode).
331 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
);
332 -- Check the specified argument Arg to make sure that it is an
333 -- identifier. If not give error and raise Pragma_Exit.
335 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
);
336 -- Check the specified argument Arg to make sure that it is an integer
337 -- literal. If not give error and raise Pragma_Exit.
339 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
);
340 -- Check the specified argument Arg to make sure that it has the proper
341 -- syntactic form for a local name and meets the semantic requirements
342 -- for a local name. The local name is analyzed as part of the
343 -- processing for this call. In addition, the local name is required
344 -- to represent an entity at the library level.
346 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
);
347 -- Check the specified argument Arg to make sure that it has the proper
348 -- syntactic form for a local name and meets the semantic requirements
349 -- for a local name. The local name is analyzed as part of the
350 -- processing for this call.
352 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
);
353 -- Check the specified argument Arg to make sure that it is a valid
354 -- locking policy name. If not give error and raise Pragma_Exit.
356 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
);
357 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
, N3
: Name_Id
);
358 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
, N3
, N4
: Name_Id
);
359 -- Check the specified argument Arg to make sure that it is an
360 -- identifier whose name matches either N1 or N2 (or N3 if present).
361 -- If not then give error and raise Pragma_Exit.
363 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
);
364 -- Check the specified argument Arg to make sure that it is a valid
365 -- queuing policy name. If not give error and raise Pragma_Exit.
367 procedure Check_Arg_Is_Static_Expression
369 Typ
: Entity_Id
:= Empty
);
370 -- Check the specified argument Arg to make sure that it is a static
371 -- expression of the given type (i.e. it will be analyzed and resolved
372 -- using this type, which can be any valid argument to Resolve, e.g.
373 -- Any_Integer is OK). If not, given error and raise Pragma_Exit. If
374 -- Typ is left Empty, then any static expression is allowed.
376 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
);
377 -- Check the specified argument Arg to make sure that it is a valid task
378 -- dispatching policy name. If not give error and raise Pragma_Exit.
380 procedure Check_Arg_Order
(Names
: Name_List
);
381 -- Checks for an instance of two arguments with identifiers for the
382 -- current pragma which are not in the sequence indicated by Names,
383 -- and if so, generates a fatal message about bad order of arguments.
385 procedure Check_At_Least_N_Arguments
(N
: Nat
);
386 -- Check there are at least N arguments present
388 procedure Check_At_Most_N_Arguments
(N
: Nat
);
389 -- Check there are no more than N arguments present
391 procedure Check_Component
394 In_Variant_Part
: Boolean := False);
395 -- Examine an Unchecked_Union component for correct use of per-object
396 -- constrained subtypes, and for restrictions on finalizable components.
397 -- UU_Typ is the related Unchecked_Union type. Flag In_Variant_Part
398 -- should be set when Comp comes from a record variant.
400 procedure Check_Duplicate_Pragma
(E
: Entity_Id
);
401 -- Check if a pragma of the same name as the current pragma is already
402 -- chained as a rep pragma to the given entity. If so give a message
403 -- about the duplicate, and then raise Pragma_Exit so does not return.
404 -- Also checks for delayed aspect specification node in the chain.
406 procedure Check_Duplicated_Export_Name
(Nam
: Node_Id
);
407 -- Nam is an N_String_Literal node containing the external name set by
408 -- an Import or Export pragma (or extended Import or Export pragma).
409 -- This procedure checks for possible duplications if this is the export
410 -- case, and if found, issues an appropriate error message.
412 procedure Check_First_Subtype
(Arg
: Node_Id
);
413 -- Checks that Arg, whose expression is an entity name, references a
416 procedure Check_In_Main_Program
;
417 -- Common checks for pragmas that appear within a main program
418 -- (Priority, Main_Storage, Time_Slice, Relative_Deadline, CPU).
420 procedure Check_Interrupt_Or_Attach_Handler
;
421 -- Common processing for first argument of pragma Interrupt_Handler or
422 -- pragma Attach_Handler.
424 procedure Check_Is_In_Decl_Part_Or_Package_Spec
;
425 -- Check that pragma appears in a declarative part, or in a package
426 -- specification, i.e. that it does not occur in a statement sequence
429 procedure Check_No_Identifier
(Arg
: Node_Id
);
430 -- Checks that the given argument does not have an identifier. If
431 -- an identifier is present, then an error message is issued, and
432 -- Pragma_Exit is raised.
434 procedure Check_No_Identifiers
;
435 -- Checks that none of the arguments to the pragma has an identifier.
436 -- If any argument has an identifier, then an error message is issued,
437 -- and Pragma_Exit is raised.
439 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
);
440 -- Checks if the given argument has an identifier, and if so, requires
441 -- it to match the given identifier name. If there is a non-matching
442 -- identifier, then an error message is given and Error_Pragmas raised.
444 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String);
445 -- Checks if the given argument has an identifier, and if so, requires
446 -- it to match the given identifier name. If there is a non-matching
447 -- identifier, then an error message is given and Error_Pragmas raised.
448 -- In this version of the procedure, the identifier name is given as
449 -- a string with lower case letters.
451 procedure Check_Precondition_Postcondition
(In_Body
: out Boolean);
452 -- Called to process a precondition or postcondition pragma. There are
455 -- The pragma appears after a subprogram spec
457 -- If the corresponding check is not enabled, the pragma is analyzed
458 -- but otherwise ignored and control returns with In_Body set False.
460 -- If the check is enabled, then the first step is to analyze the
461 -- pragma, but this is skipped if the subprogram spec appears within
462 -- a package specification (because this is the case where we delay
463 -- analysis till the end of the spec). Then (whether or not it was
464 -- analyzed), the pragma is chained to the subprogram in question
465 -- (using Spec_PPC_List and Next_Pragma) and control returns to the
466 -- caller with In_Body set False.
468 -- The pragma appears at the start of subprogram body declarations
470 -- In this case an immediate return to the caller is made with
471 -- In_Body set True, and the pragma is NOT analyzed.
473 -- In all other cases, an error message for bad placement is given
475 procedure Check_Static_Constraint
(Constr
: Node_Id
);
476 -- Constr is a constraint from an N_Subtype_Indication node from a
477 -- component constraint in an Unchecked_Union type. This routine checks
478 -- that the constraint is static as required by the restrictions for
481 procedure Check_Valid_Configuration_Pragma
;
482 -- Legality checks for placement of a configuration pragma
484 procedure Check_Valid_Library_Unit_Pragma
;
485 -- Legality checks for library unit pragmas. A special case arises for
486 -- pragmas in generic instances that come from copies of the original
487 -- library unit pragmas in the generic templates. In the case of other
488 -- than library level instantiations these can appear in contexts which
489 -- would normally be invalid (they only apply to the original template
490 -- and to library level instantiations), and they are simply ignored,
491 -- which is implemented by rewriting them as null statements.
493 procedure Check_Variant
(Variant
: Node_Id
; UU_Typ
: Entity_Id
);
494 -- Check an Unchecked_Union variant for lack of nested variants and
495 -- presence of at least one component. UU_Typ is the related Unchecked_
498 procedure Error_Pragma
(Msg
: String);
499 pragma No_Return
(Error_Pragma
);
500 -- Outputs error message for current pragma. The message contains a %
501 -- that will be replaced with the pragma name, and the flag is placed
502 -- on the pragma itself. Pragma_Exit is then raised.
504 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
);
505 pragma No_Return
(Error_Pragma_Arg
);
506 -- Outputs error message for current pragma. The message may contain
507 -- a % that will be replaced with the pragma name. The parameter Arg
508 -- may either be a pragma argument association, in which case the flag
509 -- is placed on the expression of this association, or an expression,
510 -- in which case the flag is placed directly on the expression. The
511 -- message is placed using Error_Msg_N, so the message may also contain
512 -- an & insertion character which will reference the given Arg value.
513 -- After placing the message, Pragma_Exit is raised.
515 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
);
516 pragma No_Return
(Error_Pragma_Arg
);
517 -- Similar to above form of Error_Pragma_Arg except that two messages
518 -- are provided, the second is a continuation comment starting with \.
520 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
);
521 pragma No_Return
(Error_Pragma_Arg_Ident
);
522 -- Outputs error message for current pragma. The message may contain
523 -- a % that will be replaced with the pragma name. The parameter Arg
524 -- must be a pragma argument association with a non-empty identifier
525 -- (i.e. its Chars field must be set), and the error message is placed
526 -- on the identifier. The message is placed using Error_Msg_N so
527 -- the message may also contain an & insertion character which will
528 -- reference the identifier. After placing the message, Pragma_Exit
531 procedure Error_Pragma_Ref
(Msg
: String; Ref
: Entity_Id
);
532 pragma No_Return
(Error_Pragma_Ref
);
533 -- Outputs error message for current pragma. The message may contain
534 -- a % that will be replaced with the pragma name. The parameter Ref
535 -- must be an entity whose name can be referenced by & and sloc by #.
536 -- After placing the message, Pragma_Exit is raised.
538 function Find_Lib_Unit_Name
return Entity_Id
;
539 -- Used for a library unit pragma to find the entity to which the
540 -- library unit pragma applies, returns the entity found.
542 procedure Find_Program_Unit_Name
(Id
: Node_Id
);
543 -- If the pragma is a compilation unit pragma, the id must denote the
544 -- compilation unit in the same compilation, and the pragma must appear
545 -- in the list of preceding or trailing pragmas. If it is a program
546 -- unit pragma that is not a compilation unit pragma, then the
547 -- identifier must be visible.
549 function Find_Unique_Parameterless_Procedure
551 Arg
: Node_Id
) return Entity_Id
;
552 -- Used for a procedure pragma to find the unique parameterless
553 -- procedure identified by Name, returns it if it exists, otherwise
554 -- errors out and uses Arg as the pragma argument for the message.
556 procedure Fix_Error
(Msg
: in out String);
557 -- This is called prior to issuing an error message. Msg is a string
558 -- which typically contains the substring pragma. If the current pragma
559 -- comes from an aspect, each such "pragma" substring is replaced with
560 -- the characters "aspect", and if Error_Msg_Name_1 is Name_Precondition
561 -- (resp Name_Postcondition) it is changed to Name_Pre (resp Name_Post).
563 procedure Gather_Associations
565 Args
: out Args_List
);
566 -- This procedure is used to gather the arguments for a pragma that
567 -- permits arbitrary ordering of parameters using the normal rules
568 -- for named and positional parameters. The Names argument is a list
569 -- of Name_Id values that corresponds to the allowed pragma argument
570 -- association identifiers in order. The result returned in Args is
571 -- a list of corresponding expressions that are the pragma arguments.
572 -- Note that this is a list of expressions, not of pragma argument
573 -- associations (Gather_Associations has completely checked all the
574 -- optional identifiers when it returns). An entry in Args is Empty
575 -- on return if the corresponding argument is not present.
577 procedure GNAT_Pragma
;
578 -- Called for all GNAT defined pragmas to check the relevant restriction
579 -- (No_Implementation_Pragmas).
581 function Is_Before_First_Decl
582 (Pragma_Node
: Node_Id
;
583 Decls
: List_Id
) return Boolean;
584 -- Return True if Pragma_Node is before the first declarative item in
585 -- Decls where Decls is the list of declarative items.
587 function Is_Configuration_Pragma
return Boolean;
588 -- Determines if the placement of the current pragma is appropriate
589 -- for a configuration pragma.
591 function Is_In_Context_Clause
return Boolean;
592 -- Returns True if pragma appears within the context clause of a unit,
593 -- and False for any other placement (does not generate any messages).
595 function Is_Static_String_Expression
(Arg
: Node_Id
) return Boolean;
596 -- Analyzes the argument, and determines if it is a static string
597 -- expression, returns True if so, False if non-static or not String.
599 procedure Pragma_Misplaced
;
600 pragma No_Return
(Pragma_Misplaced
);
601 -- Issue fatal error message for misplaced pragma
603 procedure Process_Atomic_Shared_Volatile
;
604 -- Common processing for pragmas Atomic, Shared, Volatile. Note that
605 -- Shared is an obsolete Ada 83 pragma, treated as being identical
606 -- in effect to pragma Atomic.
608 procedure Process_Compile_Time_Warning_Or_Error
;
609 -- Common processing for Compile_Time_Error and Compile_Time_Warning
611 procedure Process_Convention
612 (C
: out Convention_Id
;
613 Ent
: out Entity_Id
);
614 -- Common processing for Convention, Interface, Import and Export.
615 -- Checks first two arguments of pragma, and sets the appropriate
616 -- convention value in the specified entity or entities. On return
617 -- C is the convention, Ent is the referenced entity.
619 procedure Process_Extended_Import_Export_Exception_Pragma
620 (Arg_Internal
: Node_Id
;
621 Arg_External
: Node_Id
;
624 -- Common processing for the pragmas Import/Export_Exception. The three
625 -- arguments correspond to the three named parameters of the pragma. An
626 -- argument is empty if the corresponding parameter is not present in
629 procedure Process_Extended_Import_Export_Object_Pragma
630 (Arg_Internal
: Node_Id
;
631 Arg_External
: Node_Id
;
633 -- Common processing for the pragmas Import/Export_Object. The three
634 -- arguments correspond to the three named parameters of the pragmas. An
635 -- argument is empty if the corresponding parameter is not present in
638 procedure Process_Extended_Import_Export_Internal_Arg
639 (Arg_Internal
: Node_Id
:= Empty
);
640 -- Common processing for all extended Import and Export pragmas. The
641 -- argument is the pragma parameter for the Internal argument. If
642 -- Arg_Internal is empty or inappropriate, an error message is posted.
643 -- Otherwise, on normal return, the Entity_Field of Arg_Internal is
644 -- set to identify the referenced entity.
646 procedure Process_Extended_Import_Export_Subprogram_Pragma
647 (Arg_Internal
: Node_Id
;
648 Arg_External
: Node_Id
;
649 Arg_Parameter_Types
: Node_Id
;
650 Arg_Result_Type
: Node_Id
:= Empty
;
651 Arg_Mechanism
: Node_Id
;
652 Arg_Result_Mechanism
: Node_Id
:= Empty
;
653 Arg_First_Optional_Parameter
: Node_Id
:= Empty
);
654 -- Common processing for all extended Import and Export pragmas applying
655 -- to subprograms. The caller omits any arguments that do not apply to
656 -- the pragma in question (for example, Arg_Result_Type can be non-Empty
657 -- only in the Import_Function and Export_Function cases). The argument
658 -- names correspond to the allowed pragma association identifiers.
660 procedure Process_Generic_List
;
661 -- Common processing for Share_Generic and Inline_Generic
663 procedure Process_Import_Or_Interface
;
664 -- Common processing for Import of Interface
666 procedure Process_Inline
(Active
: Boolean);
667 -- Common processing for Inline and Inline_Always. The parameter
668 -- indicates if the inline pragma is active, i.e. if it should actually
669 -- cause inlining to occur.
671 procedure Process_Interface_Name
672 (Subprogram_Def
: Entity_Id
;
675 -- Given the last two arguments of pragma Import, pragma Export, or
676 -- pragma Interface_Name, performs validity checks and sets the
677 -- Interface_Name field of the given subprogram entity to the
678 -- appropriate external or link name, depending on the arguments given.
679 -- Ext_Arg is always present, but Link_Arg may be missing. Note that
680 -- Ext_Arg may represent the Link_Name if Link_Arg is missing, and
681 -- appropriate named notation is used for Ext_Arg. If neither Ext_Arg
682 -- nor Link_Arg is present, the interface name is set to the default
683 -- from the subprogram name.
685 procedure Process_Interrupt_Or_Attach_Handler
;
686 -- Common processing for Interrupt and Attach_Handler pragmas
688 procedure Process_Restrictions_Or_Restriction_Warnings
(Warn
: Boolean);
689 -- Common processing for Restrictions and Restriction_Warnings pragmas.
690 -- Warn is True for Restriction_Warnings, or for Restrictions if the
691 -- flag Treat_Restrictions_As_Warnings is set, and False if this flag
692 -- is not set in the Restrictions case.
694 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean);
695 -- Common processing for Suppress and Unsuppress. The boolean parameter
696 -- Suppress_Case is True for the Suppress case, and False for the
699 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
);
700 -- This procedure sets the Is_Exported flag for the given entity,
701 -- checking that the entity was not previously imported. Arg is
702 -- the argument that specified the entity. A check is also made
703 -- for exporting inappropriate entities.
705 procedure Set_Extended_Import_Export_External_Name
706 (Internal_Ent
: Entity_Id
;
707 Arg_External
: Node_Id
);
708 -- Common processing for all extended import export pragmas. The first
709 -- argument, Internal_Ent, is the internal entity, which has already
710 -- been checked for validity by the caller. Arg_External is from the
711 -- Import or Export pragma, and may be null if no External parameter
712 -- was present. If Arg_External is present and is a non-null string
713 -- (a null string is treated as the default), then the Interface_Name
714 -- field of Internal_Ent is set appropriately.
716 procedure Set_Imported
(E
: Entity_Id
);
717 -- This procedure sets the Is_Imported flag for the given entity,
718 -- checking that it is not previously exported or imported.
720 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
);
721 -- Mech is a parameter passing mechanism (see Import_Function syntax
722 -- for MECHANISM_NAME). This routine checks that the mechanism argument
723 -- has the right form, and if not issues an error message. If the
724 -- argument has the right form then the Mechanism field of Ent is
725 -- set appropriately.
727 procedure Set_Ravenscar_Profile
(N
: Node_Id
);
728 -- Activate the set of configuration pragmas and restrictions that make
729 -- up the Ravenscar Profile. N is the corresponding pragma node, which
730 -- is used for error messages on any constructs that violate the
733 ---------------------
734 -- Ada_2005_Pragma --
735 ---------------------
737 procedure Ada_2005_Pragma
is
739 if Ada_Version
<= Ada_95
then
740 Check_Restriction
(No_Implementation_Pragmas
, N
);
744 ---------------------
745 -- Ada_2012_Pragma --
746 ---------------------
748 procedure Ada_2012_Pragma
is
750 if Ada_Version
<= Ada_2005
then
751 Check_Restriction
(No_Implementation_Pragmas
, N
);
755 --------------------------
756 -- Check_Ada_83_Warning --
757 --------------------------
759 procedure Check_Ada_83_Warning
is
761 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
762 Error_Msg_N
("(Ada 83) pragma& is non-standard?", N
);
764 end Check_Ada_83_Warning
;
766 ---------------------
767 -- Check_Arg_Count --
768 ---------------------
770 procedure Check_Arg_Count
(Required
: Nat
) is
772 if Arg_Count
/= Required
then
773 Error_Pragma
("wrong number of arguments for pragma%");
777 --------------------------------
778 -- Check_Arg_Is_External_Name --
779 --------------------------------
781 procedure Check_Arg_Is_External_Name
(Arg
: Node_Id
) is
782 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
785 if Nkind
(Argx
) = N_Identifier
then
789 Analyze_And_Resolve
(Argx
, Standard_String
);
791 if Is_OK_Static_Expression
(Argx
) then
794 elsif Etype
(Argx
) = Any_Type
then
797 -- An interesting special case, if we have a string literal and
798 -- we are in Ada 83 mode, then we allow it even though it will
799 -- not be flagged as static. This allows expected Ada 83 mode
800 -- use of external names which are string literals, even though
801 -- technically these are not static in Ada 83.
803 elsif Ada_Version
= Ada_83
804 and then Nkind
(Argx
) = N_String_Literal
808 -- Static expression that raises Constraint_Error. This has
809 -- already been flagged, so just exit from pragma processing.
811 elsif Is_Static_Expression
(Argx
) then
814 -- Here we have a real error (non-static expression)
817 Error_Msg_Name_1
:= Pname
;
821 "argument for pragma% must be a identifier or "
822 & "static string expression!";
825 Flag_Non_Static_Expr
(Msg
, Argx
);
830 end Check_Arg_Is_External_Name
;
832 -----------------------------
833 -- Check_Arg_Is_Identifier --
834 -----------------------------
836 procedure Check_Arg_Is_Identifier
(Arg
: Node_Id
) is
837 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
839 if Nkind
(Argx
) /= N_Identifier
then
841 ("argument for pragma% must be identifier", Argx
);
843 end Check_Arg_Is_Identifier
;
845 ----------------------------------
846 -- Check_Arg_Is_Integer_Literal --
847 ----------------------------------
849 procedure Check_Arg_Is_Integer_Literal
(Arg
: Node_Id
) is
850 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
852 if Nkind
(Argx
) /= N_Integer_Literal
then
854 ("argument for pragma% must be integer literal", Argx
);
856 end Check_Arg_Is_Integer_Literal
;
858 -------------------------------------------
859 -- Check_Arg_Is_Library_Level_Local_Name --
860 -------------------------------------------
864 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
865 -- | library_unit_NAME
867 procedure Check_Arg_Is_Library_Level_Local_Name
(Arg
: Node_Id
) is
869 Check_Arg_Is_Local_Name
(Arg
);
871 if not Is_Library_Level_Entity
(Entity
(Get_Pragma_Arg
(Arg
)))
872 and then Comes_From_Source
(N
)
875 ("argument for pragma% must be library level entity", Arg
);
877 end Check_Arg_Is_Library_Level_Local_Name
;
879 -----------------------------
880 -- Check_Arg_Is_Local_Name --
881 -----------------------------
885 -- | DIRECT_NAME'ATTRIBUTE_DESIGNATOR
886 -- | library_unit_NAME
888 procedure Check_Arg_Is_Local_Name
(Arg
: Node_Id
) is
889 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
894 if Nkind
(Argx
) not in N_Direct_Name
895 and then (Nkind
(Argx
) /= N_Attribute_Reference
896 or else Present
(Expressions
(Argx
))
897 or else Nkind
(Prefix
(Argx
)) /= N_Identifier
)
898 and then (not Is_Entity_Name
(Argx
)
899 or else not Is_Compilation_Unit
(Entity
(Argx
)))
901 Error_Pragma_Arg
("argument for pragma% must be local name", Argx
);
904 -- No further check required if not an entity name
906 if not Is_Entity_Name
(Argx
) then
912 Ent
: constant Entity_Id
:= Entity
(Argx
);
913 Scop
: constant Entity_Id
:= Scope
(Ent
);
915 -- Case of a pragma applied to a compilation unit: pragma must
916 -- occur immediately after the program unit in the compilation.
918 if Is_Compilation_Unit
(Ent
) then
920 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Ent
);
922 -- Case of pragma placed immediately after spec
924 if Parent
(N
) = Aux_Decls_Node
(Parent
(Decl
)) then
927 -- Case of pragma placed immediately after body
929 elsif Nkind
(Decl
) = N_Subprogram_Declaration
930 and then Present
(Corresponding_Body
(Decl
))
934 (Parent
(Unit_Declaration_Node
935 (Corresponding_Body
(Decl
))));
937 -- All other cases are illegal
944 -- Special restricted placement rule from 10.2.1(11.8/2)
946 elsif Is_Generic_Formal
(Ent
)
947 and then Prag_Id
= Pragma_Preelaborable_Initialization
949 OK
:= List_Containing
(N
) =
950 Generic_Formal_Declarations
951 (Unit_Declaration_Node
(Scop
));
953 -- Default case, just check that the pragma occurs in the scope
954 -- of the entity denoted by the name.
957 OK
:= Current_Scope
= Scop
;
962 ("pragma% argument must be in same declarative part", Arg
);
966 end Check_Arg_Is_Local_Name
;
968 ---------------------------------
969 -- Check_Arg_Is_Locking_Policy --
970 ---------------------------------
972 procedure Check_Arg_Is_Locking_Policy
(Arg
: Node_Id
) is
973 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
976 Check_Arg_Is_Identifier
(Argx
);
978 if not Is_Locking_Policy_Name
(Chars
(Argx
)) then
979 Error_Pragma_Arg
("& is not a valid locking policy name", Argx
);
981 end Check_Arg_Is_Locking_Policy
;
983 -------------------------
984 -- Check_Arg_Is_One_Of --
985 -------------------------
987 procedure Check_Arg_Is_One_Of
(Arg
: Node_Id
; N1
, N2
: Name_Id
) is
988 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
991 Check_Arg_Is_Identifier
(Argx
);
993 if Chars
(Argx
) /= N1
and then Chars
(Argx
) /= N2
then
994 Error_Msg_Name_2
:= N1
;
995 Error_Msg_Name_3
:= N2
;
996 Error_Pragma_Arg
("argument for pragma% must be% or%", Argx
);
998 end Check_Arg_Is_One_Of
;
1000 procedure Check_Arg_Is_One_Of
1002 N1
, N2
, N3
: Name_Id
)
1004 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1007 Check_Arg_Is_Identifier
(Argx
);
1009 if Chars
(Argx
) /= N1
1010 and then Chars
(Argx
) /= N2
1011 and then Chars
(Argx
) /= N3
1013 Error_Pragma_Arg
("invalid argument for pragma%", Argx
);
1015 end Check_Arg_Is_One_Of
;
1017 procedure Check_Arg_Is_One_Of
1019 N1
, N2
, N3
, N4
: Name_Id
)
1021 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1024 Check_Arg_Is_Identifier
(Argx
);
1026 if Chars
(Argx
) /= N1
1027 and then Chars
(Argx
) /= N2
1028 and then Chars
(Argx
) /= N3
1029 and then Chars
(Argx
) /= N4
1031 Error_Pragma_Arg
("invalid argument for pragma%", Argx
);
1033 end Check_Arg_Is_One_Of
;
1034 ---------------------------------
1035 -- Check_Arg_Is_Queuing_Policy --
1036 ---------------------------------
1038 procedure Check_Arg_Is_Queuing_Policy
(Arg
: Node_Id
) is
1039 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1042 Check_Arg_Is_Identifier
(Argx
);
1044 if not Is_Queuing_Policy_Name
(Chars
(Argx
)) then
1045 Error_Pragma_Arg
("& is not a valid queuing policy name", Argx
);
1047 end Check_Arg_Is_Queuing_Policy
;
1049 ------------------------------------
1050 -- Check_Arg_Is_Static_Expression --
1051 ------------------------------------
1053 procedure Check_Arg_Is_Static_Expression
1055 Typ
: Entity_Id
:= Empty
)
1057 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1060 if Present
(Typ
) then
1061 Analyze_And_Resolve
(Argx
, Typ
);
1063 Analyze_And_Resolve
(Argx
);
1066 if Is_OK_Static_Expression
(Argx
) then
1069 elsif Etype
(Argx
) = Any_Type
then
1072 -- An interesting special case, if we have a string literal and we
1073 -- are in Ada 83 mode, then we allow it even though it will not be
1074 -- flagged as static. This allows the use of Ada 95 pragmas like
1075 -- Import in Ada 83 mode. They will of course be flagged with
1076 -- warnings as usual, but will not cause errors.
1078 elsif Ada_Version
= Ada_83
1079 and then Nkind
(Argx
) = N_String_Literal
1083 -- Static expression that raises Constraint_Error. This has already
1084 -- been flagged, so just exit from pragma processing.
1086 elsif Is_Static_Expression
(Argx
) then
1089 -- Finally, we have a real error
1092 Error_Msg_Name_1
:= Pname
;
1096 "argument for pragma% must be a static expression!";
1099 Flag_Non_Static_Expr
(Msg
, Argx
);
1104 end Check_Arg_Is_Static_Expression
;
1106 ------------------------------------------
1107 -- Check_Arg_Is_Task_Dispatching_Policy --
1108 ------------------------------------------
1110 procedure Check_Arg_Is_Task_Dispatching_Policy
(Arg
: Node_Id
) is
1111 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1114 Check_Arg_Is_Identifier
(Argx
);
1116 if not Is_Task_Dispatching_Policy_Name
(Chars
(Argx
)) then
1118 ("& is not a valid task dispatching policy name", Argx
);
1120 end Check_Arg_Is_Task_Dispatching_Policy
;
1122 ---------------------
1123 -- Check_Arg_Order --
1124 ---------------------
1126 procedure Check_Arg_Order
(Names
: Name_List
) is
1129 Highest_So_Far
: Natural := 0;
1130 -- Highest index in Names seen do far
1134 for J
in 1 .. Arg_Count
loop
1135 if Chars
(Arg
) /= No_Name
then
1136 for K
in Names
'Range loop
1137 if Chars
(Arg
) = Names
(K
) then
1138 if K
< Highest_So_Far
then
1139 Error_Msg_Name_1
:= Pname
;
1141 ("parameters out of order for pragma%", Arg
);
1142 Error_Msg_Name_1
:= Names
(K
);
1143 Error_Msg_Name_2
:= Names
(Highest_So_Far
);
1144 Error_Msg_N
("\% must appear before %", Arg
);
1148 Highest_So_Far
:= K
;
1156 end Check_Arg_Order
;
1158 --------------------------------
1159 -- Check_At_Least_N_Arguments --
1160 --------------------------------
1162 procedure Check_At_Least_N_Arguments
(N
: Nat
) is
1164 if Arg_Count
< N
then
1165 Error_Pragma
("too few arguments for pragma%");
1167 end Check_At_Least_N_Arguments
;
1169 -------------------------------
1170 -- Check_At_Most_N_Arguments --
1171 -------------------------------
1173 procedure Check_At_Most_N_Arguments
(N
: Nat
) is
1176 if Arg_Count
> N
then
1178 for J
in 1 .. N
loop
1180 Error_Pragma_Arg
("too many arguments for pragma%", Arg
);
1183 end Check_At_Most_N_Arguments
;
1185 ---------------------
1186 -- Check_Component --
1187 ---------------------
1189 procedure Check_Component
1192 In_Variant_Part
: Boolean := False)
1194 Comp_Id
: constant Entity_Id
:= Defining_Identifier
(Comp
);
1195 Sindic
: constant Node_Id
:=
1196 Subtype_Indication
(Component_Definition
(Comp
));
1197 Typ
: constant Entity_Id
:= Etype
(Comp_Id
);
1199 function Inside_Generic_Body
(Id
: Entity_Id
) return Boolean;
1200 -- Determine whether entity Id appears inside a generic body.
1201 -- Shouldn't this be in a more general place ???
1203 -------------------------
1204 -- Inside_Generic_Body --
1205 -------------------------
1207 function Inside_Generic_Body
(Id
: Entity_Id
) return Boolean is
1212 while Present
(S
) and then S
/= Standard_Standard
loop
1213 if Ekind
(S
) = E_Generic_Package
1214 and then In_Package_Body
(S
)
1223 end Inside_Generic_Body
;
1225 -- Start of processing for Check_Component
1228 -- Ada 2005 (AI-216): If a component subtype is subject to a per-
1229 -- object constraint, then the component type shall be an Unchecked_
1232 if Nkind
(Sindic
) = N_Subtype_Indication
1233 and then Has_Per_Object_Constraint
(Comp_Id
)
1234 and then not Is_Unchecked_Union
(Etype
(Subtype_Mark
(Sindic
)))
1237 ("component subtype subject to per-object constraint " &
1238 "must be an Unchecked_Union", Comp
);
1240 -- Ada 2012 (AI05-0026): For an unchecked union type declared within
1241 -- the body of a generic unit, or within the body of any of its
1242 -- descendant library units, no part of the type of a component
1243 -- declared in a variant_part of the unchecked union type shall be of
1244 -- a formal private type or formal private extension declared within
1245 -- the formal part of the generic unit.
1247 elsif Ada_Version
>= Ada_2012
1248 and then Inside_Generic_Body
(UU_Typ
)
1249 and then In_Variant_Part
1250 and then Is_Private_Type
(Typ
)
1251 and then Is_Generic_Type
(Typ
)
1254 ("component of Unchecked_Union cannot be of generic type", Comp
);
1256 elsif Needs_Finalization
(Typ
) then
1258 ("component of Unchecked_Union cannot be controlled", Comp
);
1260 elsif Has_Task
(Typ
) then
1262 ("component of Unchecked_Union cannot have tasks", Comp
);
1264 end Check_Component
;
1266 ----------------------------
1267 -- Check_Duplicate_Pragma --
1268 ----------------------------
1270 procedure Check_Duplicate_Pragma
(E
: Entity_Id
) is
1274 -- Nothing to do if this pragma comes from an aspect specification,
1275 -- since we could not be duplicating a pragma, and we dealt with the
1276 -- case of duplicated aspects in Analyze_Aspect_Specifications.
1278 if From_Aspect_Specification
(N
) then
1282 -- Otherwise current pragma may duplicate previous pragma or a
1283 -- previously given aspect specification for the same pragma.
1285 P
:= Get_Rep_Item_For_Entity
(E
, Pragma_Name
(N
));
1288 Error_Msg_Name_1
:= Pragma_Name
(N
);
1289 Error_Msg_Sloc
:= Sloc
(P
);
1291 if Nkind
(P
) = N_Aspect_Specification
1292 or else From_Aspect_Specification
(P
)
1294 Error_Msg_NE
("aspect% for & previously given#", N
, E
);
1296 Error_Msg_NE
("pragma% for & duplicates pragma#", N
, E
);
1301 end Check_Duplicate_Pragma
;
1303 ----------------------------------
1304 -- Check_Duplicated_Export_Name --
1305 ----------------------------------
1307 procedure Check_Duplicated_Export_Name
(Nam
: Node_Id
) is
1308 String_Val
: constant String_Id
:= Strval
(Nam
);
1311 -- We are only interested in the export case, and in the case of
1312 -- generics, it is the instance, not the template, that is the
1313 -- problem (the template will generate a warning in any case).
1315 if not Inside_A_Generic
1316 and then (Prag_Id
= Pragma_Export
1318 Prag_Id
= Pragma_Export_Procedure
1320 Prag_Id
= Pragma_Export_Valued_Procedure
1322 Prag_Id
= Pragma_Export_Function
)
1324 for J
in Externals
.First
.. Externals
.Last
loop
1325 if String_Equal
(String_Val
, Strval
(Externals
.Table
(J
))) then
1326 Error_Msg_Sloc
:= Sloc
(Externals
.Table
(J
));
1327 Error_Msg_N
("external name duplicates name given#", Nam
);
1332 Externals
.Append
(Nam
);
1334 end Check_Duplicated_Export_Name
;
1336 -------------------------
1337 -- Check_First_Subtype --
1338 -------------------------
1340 procedure Check_First_Subtype
(Arg
: Node_Id
) is
1341 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
1342 Ent
: constant Entity_Id
:= Entity
(Argx
);
1345 if Is_First_Subtype
(Ent
) then
1348 elsif Is_Type
(Ent
) then
1350 ("pragma% cannot apply to subtype", Argx
);
1352 elsif Is_Object
(Ent
) then
1354 ("pragma% cannot apply to object, requires a type", Argx
);
1358 ("pragma% cannot apply to&, requires a type", Argx
);
1360 end Check_First_Subtype
;
1362 ---------------------------
1363 -- Check_In_Main_Program --
1364 ---------------------------
1366 procedure Check_In_Main_Program
is
1367 P
: constant Node_Id
:= Parent
(N
);
1370 -- Must be at in subprogram body
1372 if Nkind
(P
) /= N_Subprogram_Body
then
1373 Error_Pragma
("% pragma allowed only in subprogram");
1375 -- Otherwise warn if obviously not main program
1377 elsif Present
(Parameter_Specifications
(Specification
(P
)))
1378 or else not Is_Compilation_Unit
(Defining_Entity
(P
))
1380 Error_Msg_Name_1
:= Pname
;
1382 ("?pragma% is only effective in main program", N
);
1384 end Check_In_Main_Program
;
1386 ---------------------------------------
1387 -- Check_Interrupt_Or_Attach_Handler --
1388 ---------------------------------------
1390 procedure Check_Interrupt_Or_Attach_Handler
is
1391 Arg1_X
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
1392 Handler_Proc
, Proc_Scope
: Entity_Id
;
1397 if Prag_Id
= Pragma_Interrupt_Handler
then
1398 Check_Restriction
(No_Dynamic_Attachment
, N
);
1401 Handler_Proc
:= Find_Unique_Parameterless_Procedure
(Arg1_X
, Arg1
);
1402 Proc_Scope
:= Scope
(Handler_Proc
);
1404 -- On AAMP only, a pragma Interrupt_Handler is supported for
1405 -- nonprotected parameterless procedures.
1407 if not AAMP_On_Target
1408 or else Prag_Id
= Pragma_Attach_Handler
1410 if Ekind
(Proc_Scope
) /= E_Protected_Type
then
1412 ("argument of pragma% must be protected procedure", Arg1
);
1415 if Parent
(N
) /= Protected_Definition
(Parent
(Proc_Scope
)) then
1416 Error_Pragma
("pragma% must be in protected definition");
1420 if not Is_Library_Level_Entity
(Proc_Scope
)
1421 or else (AAMP_On_Target
1422 and then not Is_Library_Level_Entity
(Handler_Proc
))
1425 ("argument for pragma% must be library level entity", Arg1
);
1428 -- AI05-0033: A pragma cannot appear within a generic body, because
1429 -- instance can be in a nested scope. The check that protected type
1430 -- is itself a library-level declaration is done elsewhere.
1432 -- Note: we omit this check in Codepeer mode to properly handle code
1433 -- prior to AI-0033 (pragmas don't matter to codepeer in any case).
1435 if Inside_A_Generic
then
1436 if Ekind
(Scope
(Current_Scope
)) = E_Generic_Package
1437 and then In_Package_Body
(Scope
(Current_Scope
))
1438 and then not CodePeer_Mode
1440 Error_Pragma
("pragma% cannot be used inside a generic");
1443 end Check_Interrupt_Or_Attach_Handler
;
1445 -------------------------------------------
1446 -- Check_Is_In_Decl_Part_Or_Package_Spec --
1447 -------------------------------------------
1449 procedure Check_Is_In_Decl_Part_Or_Package_Spec
is
1458 elsif Nkind
(P
) = N_Handled_Sequence_Of_Statements
then
1461 elsif Nkind_In
(P
, N_Package_Specification
,
1466 -- Note: the following tests seem a little peculiar, because
1467 -- they test for bodies, but if we were in the statement part
1468 -- of the body, we would already have hit the handled statement
1469 -- sequence, so the only way we get here is by being in the
1470 -- declarative part of the body.
1472 elsif Nkind_In
(P
, N_Subprogram_Body
,
1483 Error_Pragma
("pragma% is not in declarative part or package spec");
1484 end Check_Is_In_Decl_Part_Or_Package_Spec
;
1486 -------------------------
1487 -- Check_No_Identifier --
1488 -------------------------
1490 procedure Check_No_Identifier
(Arg
: Node_Id
) is
1492 if Nkind
(Arg
) = N_Pragma_Argument_Association
1493 and then Chars
(Arg
) /= No_Name
1495 Error_Pragma_Arg_Ident
1496 ("pragma% does not permit identifier& here", Arg
);
1498 end Check_No_Identifier
;
1500 --------------------------
1501 -- Check_No_Identifiers --
1502 --------------------------
1504 procedure Check_No_Identifiers
is
1507 if Arg_Count
> 0 then
1509 while Present
(Arg_Node
) loop
1510 Check_No_Identifier
(Arg_Node
);
1514 end Check_No_Identifiers
;
1516 -------------------------------
1517 -- Check_Optional_Identifier --
1518 -------------------------------
1520 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: Name_Id
) is
1523 and then Nkind
(Arg
) = N_Pragma_Argument_Association
1524 and then Chars
(Arg
) /= No_Name
1526 if Chars
(Arg
) /= Id
then
1527 Error_Msg_Name_1
:= Pname
;
1528 Error_Msg_Name_2
:= Id
;
1529 Error_Msg_N
("pragma% argument expects identifier%", Arg
);
1533 end Check_Optional_Identifier
;
1535 procedure Check_Optional_Identifier
(Arg
: Node_Id
; Id
: String) is
1537 Name_Buffer
(1 .. Id
'Length) := Id
;
1538 Name_Len
:= Id
'Length;
1539 Check_Optional_Identifier
(Arg
, Name_Find
);
1540 end Check_Optional_Identifier
;
1542 --------------------------------------
1543 -- Check_Precondition_Postcondition --
1544 --------------------------------------
1546 procedure Check_Precondition_Postcondition
(In_Body
: out Boolean) is
1550 procedure Chain_PPC
(PO
: Node_Id
);
1551 -- If PO is a subprogram declaration node (or a generic subprogram
1552 -- declaration node), then the precondition/postcondition applies
1553 -- to this subprogram and the processing for the pragma is completed.
1554 -- Otherwise the pragma is misplaced.
1560 procedure Chain_PPC
(PO
: Node_Id
) is
1565 if Nkind
(PO
) = N_Abstract_Subprogram_Declaration
then
1566 if not From_Aspect_Specification
(N
) then
1568 ("pragma% cannot be applied to abstract subprogram");
1570 elsif Class_Present
(N
) then
1575 ("aspect % requires ''Class for abstract subprogram");
1578 elsif not Nkind_In
(PO
, N_Subprogram_Declaration
,
1579 N_Generic_Subprogram_Declaration
,
1580 N_Entry_Declaration
)
1585 -- Here if we have [generic] subprogram or entry declaration
1587 if Nkind
(PO
) = N_Entry_Declaration
then
1588 S
:= Defining_Entity
(PO
);
1590 S
:= Defining_Unit_Name
(Specification
(PO
));
1593 -- Make sure we do not have the case of a precondition pragma when
1594 -- the Pre'Class aspect is present.
1596 -- We do this by looking at pragmas already chained to the entity
1597 -- since the aspect derived pragma will be put on this list first.
1599 if Pragma_Name
(N
) = Name_Precondition
then
1600 if not From_Aspect_Specification
(N
) then
1601 P
:= Spec_PPC_List
(S
);
1602 while Present
(P
) loop
1603 if Pragma_Name
(P
) = Name_Precondition
1604 and then From_Aspect_Specification
(P
)
1605 and then Class_Present
(P
)
1607 Error_Msg_Sloc
:= Sloc
(P
);
1609 ("pragma% not allowed, `Pre''Class` aspect given#");
1612 P
:= Next_Pragma
(P
);
1617 -- Similarly check for Pre with inherited Pre'Class. Note that
1618 -- we cover the aspect case as well here.
1620 if Pragma_Name
(N
) = Name_Precondition
1621 and then not Class_Present
(N
)
1624 Inherited
: constant Subprogram_List
:=
1625 Inherited_Subprograms
(S
);
1629 for J
in Inherited
'Range loop
1630 P
:= Spec_PPC_List
(Inherited
(J
));
1631 while Present
(P
) loop
1632 if Pragma_Name
(P
) = Name_Precondition
1633 and then Class_Present
(P
)
1635 Error_Msg_Sloc
:= Sloc
(P
);
1637 ("pragma% not allowed, `Pre''Class` "
1638 & "aspect inherited from#");
1641 P
:= Next_Pragma
(P
);
1647 -- Note: we do not analye the pragma at this point. Instead we
1648 -- delay this analysis until the end of the declarative part in
1649 -- which the pragma appears. This implements the required delay
1650 -- in this analysis, allowing forward references. The analysis
1651 -- happens at the end of Analyze_Declarations.
1653 -- Chain spec PPC pragma to list for subprogram
1655 Set_Next_Pragma
(N
, Spec_PPC_List
(S
));
1656 Set_Spec_PPC_List
(S
, N
);
1658 -- Return indicating spec case
1664 -- Start of processing for Check_Precondition_Postcondition
1667 if not Is_List_Member
(N
) then
1671 -- Preanalyze message argument if present. Visibility in this
1672 -- argument is established at the point of pragma occurrence.
1674 if Arg_Count
= 2 then
1675 Check_Optional_Identifier
(Arg2
, Name_Message
);
1676 Preanalyze_Spec_Expression
1677 (Get_Pragma_Arg
(Arg2
), Standard_String
);
1680 -- Record if pragma is enabled
1682 if Check_Enabled
(Pname
) then
1683 Set_Pragma_Enabled
(N
);
1684 Set_SCO_Pragma_Enabled
(Loc
);
1687 -- If we are within an inlined body, the legality of the pragma
1688 -- has been checked already.
1690 if In_Inlined_Body
then
1695 -- Search prior declarations
1698 while Present
(Prev
(P
)) loop
1701 -- If the previous node is a generic subprogram, do not go to to
1702 -- the original node, which is the unanalyzed tree: we need to
1703 -- attach the pre/postconditions to the analyzed version at this
1704 -- point. They get propagated to the original tree when analyzing
1705 -- the corresponding body.
1707 if Nkind
(P
) not in N_Generic_Declaration
then
1708 PO
:= Original_Node
(P
);
1713 -- Skip past prior pragma
1715 if Nkind
(PO
) = N_Pragma
then
1718 -- Skip stuff not coming from source
1720 elsif not Comes_From_Source
(PO
) then
1723 -- Only remaining possibility is subprogram declaration
1731 -- If we fall through loop, pragma is at start of list, so see if it
1732 -- is at the start of declarations of a subprogram body.
1734 if Nkind
(Parent
(N
)) = N_Subprogram_Body
1735 and then List_Containing
(N
) = Declarations
(Parent
(N
))
1737 if Operating_Mode
/= Generate_Code
1738 or else Inside_A_Generic
1740 -- Analyze pragma expression for correctness and for ASIS use
1742 Preanalyze_Spec_Expression
1743 (Get_Pragma_Arg
(Arg1
), Standard_Boolean
);
1749 -- See if it is in the pragmas after a library level subprogram
1751 elsif Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
1752 Chain_PPC
(Unit
(Parent
(Parent
(N
))));
1756 -- If we fall through, pragma was misplaced
1759 end Check_Precondition_Postcondition
;
1761 -----------------------------
1762 -- Check_Static_Constraint --
1763 -----------------------------
1765 -- Note: for convenience in writing this procedure, in addition to
1766 -- the officially (i.e. by spec) allowed argument which is always a
1767 -- constraint, it also allows ranges and discriminant associations.
1768 -- Above is not clear ???
1770 procedure Check_Static_Constraint
(Constr
: Node_Id
) is
1772 procedure Require_Static
(E
: Node_Id
);
1773 -- Require given expression to be static expression
1775 --------------------
1776 -- Require_Static --
1777 --------------------
1779 procedure Require_Static
(E
: Node_Id
) is
1781 if not Is_OK_Static_Expression
(E
) then
1782 Flag_Non_Static_Expr
1783 ("non-static constraint not allowed in Unchecked_Union!", E
);
1788 -- Start of processing for Check_Static_Constraint
1791 case Nkind
(Constr
) is
1792 when N_Discriminant_Association
=>
1793 Require_Static
(Expression
(Constr
));
1796 Require_Static
(Low_Bound
(Constr
));
1797 Require_Static
(High_Bound
(Constr
));
1799 when N_Attribute_Reference
=>
1800 Require_Static
(Type_Low_Bound
(Etype
(Prefix
(Constr
))));
1801 Require_Static
(Type_High_Bound
(Etype
(Prefix
(Constr
))));
1803 when N_Range_Constraint
=>
1804 Check_Static_Constraint
(Range_Expression
(Constr
));
1806 when N_Index_Or_Discriminant_Constraint
=>
1810 IDC
:= First
(Constraints
(Constr
));
1811 while Present
(IDC
) loop
1812 Check_Static_Constraint
(IDC
);
1820 end Check_Static_Constraint
;
1822 --------------------------------------
1823 -- Check_Valid_Configuration_Pragma --
1824 --------------------------------------
1826 -- A configuration pragma must appear in the context clause of a
1827 -- compilation unit, and only other pragmas may precede it. Note that
1828 -- the test also allows use in a configuration pragma file.
1830 procedure Check_Valid_Configuration_Pragma
is
1832 if not Is_Configuration_Pragma
then
1833 Error_Pragma
("incorrect placement for configuration pragma%");
1835 end Check_Valid_Configuration_Pragma
;
1837 -------------------------------------
1838 -- Check_Valid_Library_Unit_Pragma --
1839 -------------------------------------
1841 procedure Check_Valid_Library_Unit_Pragma
is
1843 Parent_Node
: Node_Id
;
1844 Unit_Name
: Entity_Id
;
1845 Unit_Kind
: Node_Kind
;
1846 Unit_Node
: Node_Id
;
1847 Sindex
: Source_File_Index
;
1850 if not Is_List_Member
(N
) then
1854 Plist
:= List_Containing
(N
);
1855 Parent_Node
:= Parent
(Plist
);
1857 if Parent_Node
= Empty
then
1860 -- Case of pragma appearing after a compilation unit. In this case
1861 -- it must have an argument with the corresponding name and must
1862 -- be part of the following pragmas of its parent.
1864 elsif Nkind
(Parent_Node
) = N_Compilation_Unit_Aux
then
1865 if Plist
/= Pragmas_After
(Parent_Node
) then
1868 elsif Arg_Count
= 0 then
1870 ("argument required if outside compilation unit");
1873 Check_No_Identifiers
;
1874 Check_Arg_Count
(1);
1875 Unit_Node
:= Unit
(Parent
(Parent_Node
));
1876 Unit_Kind
:= Nkind
(Unit_Node
);
1878 Analyze
(Get_Pragma_Arg
(Arg1
));
1880 if Unit_Kind
= N_Generic_Subprogram_Declaration
1881 or else Unit_Kind
= N_Subprogram_Declaration
1883 Unit_Name
:= Defining_Entity
(Unit_Node
);
1885 elsif Unit_Kind
in N_Generic_Instantiation
then
1886 Unit_Name
:= Defining_Entity
(Unit_Node
);
1889 Unit_Name
:= Cunit_Entity
(Current_Sem_Unit
);
1892 if Chars
(Unit_Name
) /=
1893 Chars
(Entity
(Get_Pragma_Arg
(Arg1
)))
1896 ("pragma% argument is not current unit name", Arg1
);
1899 if Ekind
(Unit_Name
) = E_Package
1900 and then Present
(Renamed_Entity
(Unit_Name
))
1902 Error_Pragma
("pragma% not allowed for renamed package");
1906 -- Pragma appears other than after a compilation unit
1909 -- Here we check for the generic instantiation case and also
1910 -- for the case of processing a generic formal package. We
1911 -- detect these cases by noting that the Sloc on the node
1912 -- does not belong to the current compilation unit.
1914 Sindex
:= Source_Index
(Current_Sem_Unit
);
1916 if Loc
not in Source_First
(Sindex
) .. Source_Last
(Sindex
) then
1917 Rewrite
(N
, Make_Null_Statement
(Loc
));
1920 -- If before first declaration, the pragma applies to the
1921 -- enclosing unit, and the name if present must be this name.
1923 elsif Is_Before_First_Decl
(N
, Plist
) then
1924 Unit_Node
:= Unit_Declaration_Node
(Current_Scope
);
1925 Unit_Kind
:= Nkind
(Unit_Node
);
1927 if Nkind
(Parent
(Unit_Node
)) /= N_Compilation_Unit
then
1930 elsif Unit_Kind
= N_Subprogram_Body
1931 and then not Acts_As_Spec
(Unit_Node
)
1935 elsif Nkind
(Parent_Node
) = N_Package_Body
then
1938 elsif Nkind
(Parent_Node
) = N_Package_Specification
1939 and then Plist
= Private_Declarations
(Parent_Node
)
1943 elsif (Nkind
(Parent_Node
) = N_Generic_Package_Declaration
1944 or else Nkind
(Parent_Node
) =
1945 N_Generic_Subprogram_Declaration
)
1946 and then Plist
= Generic_Formal_Declarations
(Parent_Node
)
1950 elsif Arg_Count
> 0 then
1951 Analyze
(Get_Pragma_Arg
(Arg1
));
1953 if Entity
(Get_Pragma_Arg
(Arg1
)) /= Current_Scope
then
1955 ("name in pragma% must be enclosing unit", Arg1
);
1958 -- It is legal to have no argument in this context
1964 -- Error if not before first declaration. This is because a
1965 -- library unit pragma argument must be the name of a library
1966 -- unit (RM 10.1.5(7)), but the only names permitted in this
1967 -- context are (RM 10.1.5(6)) names of subprogram declarations,
1968 -- generic subprogram declarations or generic instantiations.
1972 ("pragma% misplaced, must be before first declaration");
1976 end Check_Valid_Library_Unit_Pragma
;
1982 procedure Check_Variant
(Variant
: Node_Id
; UU_Typ
: Entity_Id
) is
1983 Clist
: constant Node_Id
:= Component_List
(Variant
);
1987 if not Is_Non_Empty_List
(Component_Items
(Clist
)) then
1989 ("Unchecked_Union may not have empty component list",
1994 Comp
:= First
(Component_Items
(Clist
));
1995 while Present
(Comp
) loop
1996 Check_Component
(Comp
, UU_Typ
, In_Variant_Part
=> True);
2005 procedure Error_Pragma
(Msg
: String) is
2006 MsgF
: String := Msg
;
2008 Error_Msg_Name_1
:= Pname
;
2010 Error_Msg_N
(MsgF
, N
);
2014 ----------------------
2015 -- Error_Pragma_Arg --
2016 ----------------------
2018 procedure Error_Pragma_Arg
(Msg
: String; Arg
: Node_Id
) is
2019 MsgF
: String := Msg
;
2021 Error_Msg_Name_1
:= Pname
;
2023 Error_Msg_N
(MsgF
, Get_Pragma_Arg
(Arg
));
2025 end Error_Pragma_Arg
;
2027 procedure Error_Pragma_Arg
(Msg1
, Msg2
: String; Arg
: Node_Id
) is
2028 MsgF
: String := Msg1
;
2030 Error_Msg_Name_1
:= Pname
;
2032 Error_Msg_N
(MsgF
, Get_Pragma_Arg
(Arg
));
2033 Error_Pragma_Arg
(Msg2
, Arg
);
2034 end Error_Pragma_Arg
;
2036 ----------------------------
2037 -- Error_Pragma_Arg_Ident --
2038 ----------------------------
2040 procedure Error_Pragma_Arg_Ident
(Msg
: String; Arg
: Node_Id
) is
2041 MsgF
: String := Msg
;
2043 Error_Msg_Name_1
:= Pname
;
2045 Error_Msg_N
(MsgF
, Arg
);
2047 end Error_Pragma_Arg_Ident
;
2049 ----------------------
2050 -- Error_Pragma_Ref --
2051 ----------------------
2053 procedure Error_Pragma_Ref
(Msg
: String; Ref
: Entity_Id
) is
2054 MsgF
: String := Msg
;
2056 Error_Msg_Name_1
:= Pname
;
2058 Error_Msg_Sloc
:= Sloc
(Ref
);
2059 Error_Msg_NE
(MsgF
, N
, Ref
);
2061 end Error_Pragma_Ref
;
2063 ------------------------
2064 -- Find_Lib_Unit_Name --
2065 ------------------------
2067 function Find_Lib_Unit_Name
return Entity_Id
is
2069 -- Return inner compilation unit entity, for case of nested
2070 -- categorization pragmas. This happens in generic unit.
2072 if Nkind
(Parent
(N
)) = N_Package_Specification
2073 and then Defining_Entity
(Parent
(N
)) /= Current_Scope
2075 return Defining_Entity
(Parent
(N
));
2077 return Current_Scope
;
2079 end Find_Lib_Unit_Name
;
2081 ----------------------------
2082 -- Find_Program_Unit_Name --
2083 ----------------------------
2085 procedure Find_Program_Unit_Name
(Id
: Node_Id
) is
2086 Unit_Name
: Entity_Id
;
2087 Unit_Kind
: Node_Kind
;
2088 P
: constant Node_Id
:= Parent
(N
);
2091 if Nkind
(P
) = N_Compilation_Unit
then
2092 Unit_Kind
:= Nkind
(Unit
(P
));
2094 if Unit_Kind
= N_Subprogram_Declaration
2095 or else Unit_Kind
= N_Package_Declaration
2096 or else Unit_Kind
in N_Generic_Declaration
2098 Unit_Name
:= Defining_Entity
(Unit
(P
));
2100 if Chars
(Id
) = Chars
(Unit_Name
) then
2101 Set_Entity
(Id
, Unit_Name
);
2102 Set_Etype
(Id
, Etype
(Unit_Name
));
2104 Set_Etype
(Id
, Any_Type
);
2106 ("cannot find program unit referenced by pragma%");
2110 Set_Etype
(Id
, Any_Type
);
2111 Error_Pragma
("pragma% inapplicable to this unit");
2117 end Find_Program_Unit_Name
;
2119 -----------------------------------------
2120 -- Find_Unique_Parameterless_Procedure --
2121 -----------------------------------------
2123 function Find_Unique_Parameterless_Procedure
2125 Arg
: Node_Id
) return Entity_Id
2127 Proc
: Entity_Id
:= Empty
;
2130 -- The body of this procedure needs some comments ???
2132 if not Is_Entity_Name
(Name
) then
2134 ("argument of pragma% must be entity name", Arg
);
2136 elsif not Is_Overloaded
(Name
) then
2137 Proc
:= Entity
(Name
);
2139 if Ekind
(Proc
) /= E_Procedure
2140 or else Present
(First_Formal
(Proc
))
2143 ("argument of pragma% must be parameterless procedure", Arg
);
2148 Found
: Boolean := False;
2150 Index
: Interp_Index
;
2153 Get_First_Interp
(Name
, Index
, It
);
2154 while Present
(It
.Nam
) loop
2157 if Ekind
(Proc
) = E_Procedure
2158 and then No
(First_Formal
(Proc
))
2162 Set_Entity
(Name
, Proc
);
2163 Set_Is_Overloaded
(Name
, False);
2166 ("ambiguous handler name for pragma% ", Arg
);
2170 Get_Next_Interp
(Index
, It
);
2175 ("argument of pragma% must be parameterless procedure",
2178 Proc
:= Entity
(Name
);
2184 end Find_Unique_Parameterless_Procedure
;
2190 procedure Fix_Error
(Msg
: in out String) is
2192 if From_Aspect_Specification
(N
) then
2193 for J
in Msg
'First .. Msg
'Last - 5 loop
2194 if Msg
(J
.. J
+ 5) = "pragma" then
2195 Msg
(J
.. J
+ 5) := "aspect";
2199 if Error_Msg_Name_1
= Name_Precondition
then
2200 Error_Msg_Name_1
:= Name_Pre
;
2201 elsif Error_Msg_Name_1
= Name_Postcondition
then
2202 Error_Msg_Name_1
:= Name_Post
;
2207 -------------------------
2208 -- Gather_Associations --
2209 -------------------------
2211 procedure Gather_Associations
2213 Args
: out Args_List
)
2218 -- Initialize all parameters to Empty
2220 for J
in Args
'Range loop
2224 -- That's all we have to do if there are no argument associations
2226 if No
(Pragma_Argument_Associations
(N
)) then
2230 -- Otherwise first deal with any positional parameters present
2232 Arg
:= First
(Pragma_Argument_Associations
(N
));
2233 for Index
in Args
'Range loop
2234 exit when No
(Arg
) or else Chars
(Arg
) /= No_Name
;
2235 Args
(Index
) := Get_Pragma_Arg
(Arg
);
2239 -- Positional parameters all processed, if any left, then we
2240 -- have too many positional parameters.
2242 if Present
(Arg
) and then Chars
(Arg
) = No_Name
then
2244 ("too many positional associations for pragma%", Arg
);
2247 -- Process named parameters if any are present
2249 while Present
(Arg
) loop
2250 if Chars
(Arg
) = No_Name
then
2252 ("positional association cannot follow named association",
2256 for Index
in Names
'Range loop
2257 if Names
(Index
) = Chars
(Arg
) then
2258 if Present
(Args
(Index
)) then
2260 ("duplicate argument association for pragma%", Arg
);
2262 Args
(Index
) := Get_Pragma_Arg
(Arg
);
2267 if Index
= Names
'Last then
2268 Error_Msg_Name_1
:= Pname
;
2269 Error_Msg_N
("pragma% does not allow & argument", Arg
);
2271 -- Check for possible misspelling
2273 for Index1
in Names
'Range loop
2274 if Is_Bad_Spelling_Of
2275 (Chars
(Arg
), Names
(Index1
))
2277 Error_Msg_Name_1
:= Names
(Index1
);
2278 Error_Msg_N
-- CODEFIX
2279 ("\possible misspelling of%", Arg
);
2291 end Gather_Associations
;
2297 procedure GNAT_Pragma
is
2299 Check_Restriction
(No_Implementation_Pragmas
, N
);
2302 --------------------------
2303 -- Is_Before_First_Decl --
2304 --------------------------
2306 function Is_Before_First_Decl
2307 (Pragma_Node
: Node_Id
;
2308 Decls
: List_Id
) return Boolean
2310 Item
: Node_Id
:= First
(Decls
);
2313 -- Only other pragmas can come before this pragma
2316 if No
(Item
) or else Nkind
(Item
) /= N_Pragma
then
2319 elsif Item
= Pragma_Node
then
2325 end Is_Before_First_Decl
;
2327 -----------------------------
2328 -- Is_Configuration_Pragma --
2329 -----------------------------
2331 -- A configuration pragma must appear in the context clause of a
2332 -- compilation unit, and only other pragmas may precede it. Note that
2333 -- the test below also permits use in a configuration pragma file.
2335 function Is_Configuration_Pragma
return Boolean is
2336 Lis
: constant List_Id
:= List_Containing
(N
);
2337 Par
: constant Node_Id
:= Parent
(N
);
2341 -- If no parent, then we are in the configuration pragma file,
2342 -- so the placement is definitely appropriate.
2347 -- Otherwise we must be in the context clause of a compilation unit
2348 -- and the only thing allowed before us in the context list is more
2349 -- configuration pragmas.
2351 elsif Nkind
(Par
) = N_Compilation_Unit
2352 and then Context_Items
(Par
) = Lis
2359 elsif Nkind
(Prg
) /= N_Pragma
then
2369 end Is_Configuration_Pragma
;
2371 --------------------------
2372 -- Is_In_Context_Clause --
2373 --------------------------
2375 function Is_In_Context_Clause
return Boolean is
2377 Parent_Node
: Node_Id
;
2380 if not Is_List_Member
(N
) then
2384 Plist
:= List_Containing
(N
);
2385 Parent_Node
:= Parent
(Plist
);
2387 if Parent_Node
= Empty
2388 or else Nkind
(Parent_Node
) /= N_Compilation_Unit
2389 or else Context_Items
(Parent_Node
) /= Plist
2396 end Is_In_Context_Clause
;
2398 ---------------------------------
2399 -- Is_Static_String_Expression --
2400 ---------------------------------
2402 function Is_Static_String_Expression
(Arg
: Node_Id
) return Boolean is
2403 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg
);
2406 Analyze_And_Resolve
(Argx
);
2407 return Is_OK_Static_Expression
(Argx
)
2408 and then Nkind
(Argx
) = N_String_Literal
;
2409 end Is_Static_String_Expression
;
2411 ----------------------
2412 -- Pragma_Misplaced --
2413 ----------------------
2415 procedure Pragma_Misplaced
is
2417 Error_Pragma
("incorrect placement of pragma%");
2418 end Pragma_Misplaced
;
2420 ------------------------------------
2421 -- Process Atomic_Shared_Volatile --
2422 ------------------------------------
2424 procedure Process_Atomic_Shared_Volatile
is
2431 procedure Set_Atomic
(E
: Entity_Id
);
2432 -- Set given type as atomic, and if no explicit alignment was given,
2433 -- set alignment to unknown, since back end knows what the alignment
2434 -- requirements are for atomic arrays. Note: this step is necessary
2435 -- for derived types.
2441 procedure Set_Atomic
(E
: Entity_Id
) is
2443 Set_Is_Atomic
(E
, Sense
);
2445 if Sense
and then not Has_Alignment_Clause
(E
) then
2446 Set_Alignment
(E
, Uint_0
);
2450 -- Start of processing for Process_Atomic_Shared_Volatile
2453 Check_Ada_83_Warning
;
2454 Check_No_Identifiers
;
2455 Check_Arg_Count
(1);
2456 Check_Arg_Is_Local_Name
(Arg1
);
2457 E_Id
:= Get_Pragma_Arg
(Arg1
);
2459 if Etype
(E_Id
) = Any_Type
then
2464 D
:= Declaration_Node
(E
);
2467 -- Check duplicate before we chain ourselves!
2469 Check_Duplicate_Pragma
(E
);
2471 -- Now check appropriateness of the entity
2474 if Rep_Item_Too_Early
(E
, N
)
2476 Rep_Item_Too_Late
(E
, N
)
2480 Check_First_Subtype
(Arg1
);
2483 if Prag_Id
/= Pragma_Volatile
then
2485 Set_Atomic
(Underlying_Type
(E
));
2486 Set_Atomic
(Base_Type
(E
));
2489 -- Attribute belongs on the base type. If the view of the type is
2490 -- currently private, it also belongs on the underlying type.
2492 Set_Is_Volatile
(Base_Type
(E
), Sense
);
2493 Set_Is_Volatile
(Underlying_Type
(E
), Sense
);
2495 Set_Treat_As_Volatile
(E
, Sense
);
2496 Set_Treat_As_Volatile
(Underlying_Type
(E
), Sense
);
2498 elsif K
= N_Object_Declaration
2499 or else (K
= N_Component_Declaration
2500 and then Original_Record_Component
(E
) = E
)
2502 if Rep_Item_Too_Late
(E
, N
) then
2506 if Prag_Id
/= Pragma_Volatile
then
2507 Set_Is_Atomic
(E
, Sense
);
2509 -- If the object declaration has an explicit initialization, a
2510 -- temporary may have to be created to hold the expression, to
2511 -- ensure that access to the object remain atomic.
2513 if Nkind
(Parent
(E
)) = N_Object_Declaration
2514 and then Present
(Expression
(Parent
(E
)))
2517 Set_Has_Delayed_Freeze
(E
);
2520 -- An interesting improvement here. If an object of type X is
2521 -- declared atomic, and the type X is not atomic, that's a
2522 -- pity, since it may not have appropriate alignment etc. We
2523 -- can rescue this in the special case where the object and
2524 -- type are in the same unit by just setting the type as
2525 -- atomic, so that the back end will process it as atomic.
2527 Utyp
:= Underlying_Type
(Etype
(E
));
2530 and then Sloc
(E
) > No_Location
2531 and then Sloc
(Utyp
) > No_Location
2533 Get_Source_File_Index
(Sloc
(E
)) =
2534 Get_Source_File_Index
(Sloc
(Underlying_Type
(Etype
(E
))))
2536 Set_Is_Atomic
(Underlying_Type
(Etype
(E
)), Sense
);
2540 Set_Is_Volatile
(E
);
2541 Set_Treat_As_Volatile
(E
);
2545 ("inappropriate entity for pragma%", Arg1
);
2547 end Process_Atomic_Shared_Volatile
;
2549 -------------------------------------------
2550 -- Process_Compile_Time_Warning_Or_Error --
2551 -------------------------------------------
2553 procedure Process_Compile_Time_Warning_Or_Error
is
2554 Arg1x
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
2557 Check_Arg_Count
(2);
2558 Check_No_Identifiers
;
2559 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
2560 Analyze_And_Resolve
(Arg1x
, Standard_Boolean
);
2562 if Compile_Time_Known_Value
(Arg1x
) then
2563 if Is_True
(Expr_Value
(Get_Pragma_Arg
(Arg1
))) then
2565 Str
: constant String_Id
:=
2566 Strval
(Get_Pragma_Arg
(Arg2
));
2567 Len
: constant Int
:= String_Length
(Str
);
2572 Cent
: constant Entity_Id
:=
2573 Cunit_Entity
(Current_Sem_Unit
);
2575 Force
: constant Boolean :=
2576 Prag_Id
= Pragma_Compile_Time_Warning
2578 Is_Spec_Name
(Unit_Name
(Current_Sem_Unit
))
2579 and then (Ekind
(Cent
) /= E_Package
2580 or else not In_Private_Part
(Cent
));
2581 -- Set True if this is the warning case, and we are in the
2582 -- visible part of a package spec, or in a subprogram spec,
2583 -- in which case we want to force the client to see the
2584 -- warning, even though it is not in the main unit.
2587 -- Loop through segments of message separated by line feeds.
2588 -- We output these segments as separate messages with
2589 -- continuation marks for all but the first.
2594 Error_Msg_Strlen
:= 0;
2596 -- Loop to copy characters from argument to error message
2600 exit when Ptr
> Len
;
2601 CC
:= Get_String_Char
(Str
, Ptr
);
2604 -- Ignore wide chars ??? else store character
2606 if In_Character_Range
(CC
) then
2607 C
:= Get_Character
(CC
);
2608 exit when C
= ASCII
.LF
;
2609 Error_Msg_Strlen
:= Error_Msg_Strlen
+ 1;
2610 Error_Msg_String
(Error_Msg_Strlen
) := C
;
2614 -- Here with one line ready to go
2616 Error_Msg_Warn
:= Prag_Id
= Pragma_Compile_Time_Warning
;
2618 -- If this is a warning in a spec, then we want clients
2619 -- to see the warning, so mark the message with the
2620 -- special sequence !! to force the warning. In the case
2621 -- of a package spec, we do not force this if we are in
2622 -- the private part of the spec.
2625 if Cont
= False then
2626 Error_Msg_N
("<~!!", Arg1
);
2629 Error_Msg_N
("\<~!!", Arg1
);
2632 -- Error, rather than warning, or in a body, so we do not
2633 -- need to force visibility for client (error will be
2634 -- output in any case, and this is the situation in which
2635 -- we do not want a client to get a warning, since the
2636 -- warning is in the body or the spec private part).
2639 if Cont
= False then
2640 Error_Msg_N
("<~", Arg1
);
2643 Error_Msg_N
("\<~", Arg1
);
2647 exit when Ptr
> Len
;
2652 end Process_Compile_Time_Warning_Or_Error
;
2654 ------------------------
2655 -- Process_Convention --
2656 ------------------------
2658 procedure Process_Convention
2659 (C
: out Convention_Id
;
2660 Ent
: out Entity_Id
)
2666 Comp_Unit
: Unit_Number_Type
;
2668 procedure Diagnose_Multiple_Pragmas
(S
: Entity_Id
);
2669 -- Called if we have more than one Export/Import/Convention pragma.
2670 -- This is generally illegal, but we have a special case of allowing
2671 -- Import and Interface to coexist if they specify the convention in
2672 -- a consistent manner. We are allowed to do this, since Interface is
2673 -- an implementation defined pragma, and we choose to do it since we
2674 -- know Rational allows this combination. S is the entity id of the
2675 -- subprogram in question. This procedure also sets the special flag
2676 -- Import_Interface_Present in both pragmas in the case where we do
2677 -- have matching Import and Interface pragmas.
2679 procedure Set_Convention_From_Pragma
(E
: Entity_Id
);
2680 -- Set convention in entity E, and also flag that the entity has a
2681 -- convention pragma. If entity is for a private or incomplete type,
2682 -- also set convention and flag on underlying type. This procedure
2683 -- also deals with the special case of C_Pass_By_Copy convention.
2685 -------------------------------
2686 -- Diagnose_Multiple_Pragmas --
2687 -------------------------------
2689 procedure Diagnose_Multiple_Pragmas
(S
: Entity_Id
) is
2690 Pdec
: constant Node_Id
:= Declaration_Node
(S
);
2694 function Same_Convention
(Decl
: Node_Id
) return Boolean;
2695 -- Decl is a pragma node. This function returns True if this
2696 -- pragma has a first argument that is an identifier with a
2697 -- Chars field corresponding to the Convention_Id C.
2699 function Same_Name
(Decl
: Node_Id
) return Boolean;
2700 -- Decl is a pragma node. This function returns True if this
2701 -- pragma has a second argument that is an identifier with a
2702 -- Chars field that matches the Chars of the current subprogram.
2704 ---------------------
2705 -- Same_Convention --
2706 ---------------------
2708 function Same_Convention
(Decl
: Node_Id
) return Boolean is
2709 Arg1
: constant Node_Id
:=
2710 First
(Pragma_Argument_Associations
(Decl
));
2713 if Present
(Arg1
) then
2715 Arg
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
2717 if Nkind
(Arg
) = N_Identifier
2718 and then Is_Convention_Name
(Chars
(Arg
))
2719 and then Get_Convention_Id
(Chars
(Arg
)) = C
2727 end Same_Convention
;
2733 function Same_Name
(Decl
: Node_Id
) return Boolean is
2734 Arg1
: constant Node_Id
:=
2735 First
(Pragma_Argument_Associations
(Decl
));
2743 Arg2
:= Next
(Arg1
);
2750 Arg
: constant Node_Id
:= Get_Pragma_Arg
(Arg2
);
2752 if Nkind
(Arg
) = N_Identifier
2753 and then Chars
(Arg
) = Chars
(S
)
2762 -- Start of processing for Diagnose_Multiple_Pragmas
2767 -- Definitely give message if we have Convention/Export here
2769 if Prag_Id
= Pragma_Convention
or else Prag_Id
= Pragma_Export
then
2772 -- If we have an Import or Export, scan back from pragma to
2773 -- find any previous pragma applying to the same procedure.
2774 -- The scan will be terminated by the start of the list, or
2775 -- hitting the subprogram declaration. This won't allow one
2776 -- pragma to appear in the public part and one in the private
2777 -- part, but that seems very unlikely in practice.
2781 while Present
(Decl
) and then Decl
/= Pdec
loop
2783 -- Look for pragma with same name as us
2785 if Nkind
(Decl
) = N_Pragma
2786 and then Same_Name
(Decl
)
2788 -- Give error if same as our pragma or Export/Convention
2790 if Pragma_Name
(Decl
) = Name_Export
2792 Pragma_Name
(Decl
) = Name_Convention
2794 Pragma_Name
(Decl
) = Pragma_Name
(N
)
2798 -- Case of Import/Interface or the other way round
2800 elsif Pragma_Name
(Decl
) = Name_Interface
2802 Pragma_Name
(Decl
) = Name_Import
2804 -- Here we know that we have Import and Interface. It
2805 -- doesn't matter which way round they are. See if
2806 -- they specify the same convention. If so, all OK,
2807 -- and set special flags to stop other messages
2809 if Same_Convention
(Decl
) then
2810 Set_Import_Interface_Present
(N
);
2811 Set_Import_Interface_Present
(Decl
);
2814 -- If different conventions, special message
2817 Error_Msg_Sloc
:= Sloc
(Decl
);
2819 ("convention differs from that given#", Arg1
);
2829 -- Give message if needed if we fall through those tests
2833 ("at most one Convention/Export/Import pragma is allowed",
2836 end Diagnose_Multiple_Pragmas
;
2838 --------------------------------
2839 -- Set_Convention_From_Pragma --
2840 --------------------------------
2842 procedure Set_Convention_From_Pragma
(E
: Entity_Id
) is
2844 -- Ada 2005 (AI-430): Check invalid attempt to change convention
2845 -- for an overridden dispatching operation. Technically this is
2846 -- an amendment and should only be done in Ada 2005 mode. However,
2847 -- this is clearly a mistake, since the problem that is addressed
2848 -- by this AI is that there is a clear gap in the RM!
2850 if Is_Dispatching_Operation
(E
)
2851 and then Present
(Overridden_Operation
(E
))
2852 and then C
/= Convention
(Overridden_Operation
(E
))
2855 ("cannot change convention for " &
2856 "overridden dispatching operation",
2860 -- Set the convention
2862 Set_Convention
(E
, C
);
2863 Set_Has_Convention_Pragma
(E
);
2865 if Is_Incomplete_Or_Private_Type
(E
) then
2866 Set_Convention
(Underlying_Type
(E
), C
);
2867 Set_Has_Convention_Pragma
(Underlying_Type
(E
), True);
2870 -- A class-wide type should inherit the convention of the specific
2871 -- root type (although this isn't specified clearly by the RM).
2873 if Is_Type
(E
) and then Present
(Class_Wide_Type
(E
)) then
2874 Set_Convention
(Class_Wide_Type
(E
), C
);
2877 -- If the entity is a record type, then check for special case of
2878 -- C_Pass_By_Copy, which is treated the same as C except that the
2879 -- special record flag is set. This convention is only permitted
2880 -- on record types (see AI95-00131).
2882 if Cname
= Name_C_Pass_By_Copy
then
2883 if Is_Record_Type
(E
) then
2884 Set_C_Pass_By_Copy
(Base_Type
(E
));
2885 elsif Is_Incomplete_Or_Private_Type
(E
)
2886 and then Is_Record_Type
(Underlying_Type
(E
))
2888 Set_C_Pass_By_Copy
(Base_Type
(Underlying_Type
(E
)));
2891 ("C_Pass_By_Copy convention allowed only for record type",
2896 -- If the entity is a derived boolean type, check for the special
2897 -- case of convention C, C++, or Fortran, where we consider any
2898 -- nonzero value to represent true.
2900 if Is_Discrete_Type
(E
)
2901 and then Root_Type
(Etype
(E
)) = Standard_Boolean
2907 C
= Convention_Fortran
)
2909 Set_Nonzero_Is_True
(Base_Type
(E
));
2911 end Set_Convention_From_Pragma
;
2913 -- Start of processing for Process_Convention
2916 Check_At_Least_N_Arguments
(2);
2917 Check_Optional_Identifier
(Arg1
, Name_Convention
);
2918 Check_Arg_Is_Identifier
(Arg1
);
2919 Cname
:= Chars
(Get_Pragma_Arg
(Arg1
));
2921 -- C_Pass_By_Copy is treated as a synonym for convention C (this is
2922 -- tested again below to set the critical flag).
2924 if Cname
= Name_C_Pass_By_Copy
then
2927 -- Otherwise we must have something in the standard convention list
2929 elsif Is_Convention_Name
(Cname
) then
2930 C
:= Get_Convention_Id
(Chars
(Get_Pragma_Arg
(Arg1
)));
2932 -- In DEC VMS, it seems that there is an undocumented feature that
2933 -- any unrecognized convention is treated as the default, which for
2934 -- us is convention C. It does not seem so terrible to do this
2935 -- unconditionally, silently in the VMS case, and with a warning
2936 -- in the non-VMS case.
2939 if Warn_On_Export_Import
and not OpenVMS_On_Target
then
2941 ("?unrecognized convention name, C assumed",
2942 Get_Pragma_Arg
(Arg1
));
2948 Check_Optional_Identifier
(Arg2
, Name_Entity
);
2949 Check_Arg_Is_Local_Name
(Arg2
);
2951 Id
:= Get_Pragma_Arg
(Arg2
);
2954 if not Is_Entity_Name
(Id
) then
2955 Error_Pragma_Arg
("entity name required", Arg2
);
2960 -- Set entity to return
2964 -- Go to renamed subprogram if present, since convention applies to
2965 -- the actual renamed entity, not to the renaming entity. If the
2966 -- subprogram is inherited, go to parent subprogram.
2968 if Is_Subprogram
(E
)
2969 and then Present
(Alias
(E
))
2971 if Nkind
(Parent
(Declaration_Node
(E
))) =
2972 N_Subprogram_Renaming_Declaration
2974 if Scope
(E
) /= Scope
(Alias
(E
)) then
2976 ("cannot apply pragma% to non-local entity&#", E
);
2981 elsif Nkind_In
(Parent
(E
), N_Full_Type_Declaration
,
2982 N_Private_Extension_Declaration
)
2983 and then Scope
(E
) = Scope
(Alias
(E
))
2987 -- Return the parent subprogram the entity was inherited from
2993 -- Check that we are not applying this to a specless body
2995 if Is_Subprogram
(E
)
2996 and then Nkind
(Parent
(Declaration_Node
(E
))) = N_Subprogram_Body
2999 ("pragma% requires separate spec and must come before body");
3002 -- Check that we are not applying this to a named constant
3004 if Ekind_In
(E
, E_Named_Integer
, E_Named_Real
) then
3005 Error_Msg_Name_1
:= Pname
;
3007 ("cannot apply pragma% to named constant!",
3008 Get_Pragma_Arg
(Arg2
));
3010 ("\supply appropriate type for&!", Arg2
);
3013 if Ekind
(E
) = E_Enumeration_Literal
then
3014 Error_Pragma
("enumeration literal not allowed for pragma%");
3017 -- Check for rep item appearing too early or too late
3019 if Etype
(E
) = Any_Type
3020 or else Rep_Item_Too_Early
(E
, N
)
3024 E
:= Underlying_Type
(E
);
3027 if Rep_Item_Too_Late
(E
, N
) then
3031 if Has_Convention_Pragma
(E
) then
3032 Diagnose_Multiple_Pragmas
(E
);
3034 elsif Convention
(E
) = Convention_Protected
3035 or else Ekind
(Scope
(E
)) = E_Protected_Type
3038 ("a protected operation cannot be given a different convention",
3042 -- For Intrinsic, a subprogram is required
3044 if C
= Convention_Intrinsic
3045 and then not Is_Subprogram
(E
)
3046 and then not Is_Generic_Subprogram
(E
)
3049 ("second argument of pragma% must be a subprogram", Arg2
);
3052 -- For Stdcall, a subprogram, variable or subprogram type is required
3054 if C
= Convention_Stdcall
3055 and then not Is_Subprogram
(E
)
3056 and then not Is_Generic_Subprogram
(E
)
3057 and then Ekind
(E
) /= E_Variable
3060 and then Ekind
(Designated_Type
(E
)) = E_Subprogram_Type
)
3063 ("second argument of pragma% must be subprogram (type)",
3067 if not Is_Subprogram
(E
)
3068 and then not Is_Generic_Subprogram
(E
)
3070 Set_Convention_From_Pragma
(E
);
3073 Check_First_Subtype
(Arg2
);
3074 Set_Convention_From_Pragma
(Base_Type
(E
));
3076 -- For subprograms, we must set the convention on the
3077 -- internally generated directly designated type as well.
3079 if Ekind
(E
) = E_Access_Subprogram_Type
then
3080 Set_Convention_From_Pragma
(Directly_Designated_Type
(E
));
3084 -- For the subprogram case, set proper convention for all homonyms
3085 -- in same scope and the same declarative part, i.e. the same
3086 -- compilation unit.
3089 Comp_Unit
:= Get_Source_Unit
(E
);
3090 Set_Convention_From_Pragma
(E
);
3092 -- Treat a pragma Import as an implicit body, for GPS use
3094 if Prag_Id
= Pragma_Import
then
3095 Generate_Reference
(E
, Id
, 'b');
3098 -- Loop through the homonyms of the pragma argument's entity
3103 exit when No
(E1
) or else Scope
(E1
) /= Current_Scope
;
3105 -- Do not set the pragma on inherited operations or on formal
3108 if Comes_From_Source
(E1
)
3109 and then Comp_Unit
= Get_Source_Unit
(E1
)
3110 and then not Is_Formal_Subprogram
(E1
)
3111 and then Nkind
(Original_Node
(Parent
(E1
))) /=
3112 N_Full_Type_Declaration
3114 if Present
(Alias
(E1
))
3115 and then Scope
(E1
) /= Scope
(Alias
(E1
))
3118 ("cannot apply pragma% to non-local entity& declared#",
3122 Set_Convention_From_Pragma
(E1
);
3124 if Prag_Id
= Pragma_Import
then
3125 Generate_Reference
(E1
, Id
, 'b');
3129 -- For aspect case, do NOT apply to homonyms
3131 exit when From_Aspect_Specification
(N
);
3134 end Process_Convention
;
3136 -----------------------------------------------------
3137 -- Process_Extended_Import_Export_Exception_Pragma --
3138 -----------------------------------------------------
3140 procedure Process_Extended_Import_Export_Exception_Pragma
3141 (Arg_Internal
: Node_Id
;
3142 Arg_External
: Node_Id
;
3150 if not OpenVMS_On_Target
then
3152 ("?pragma% ignored (applies only to Open'V'M'S)");
3155 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
3156 Def_Id
:= Entity
(Arg_Internal
);
3158 if Ekind
(Def_Id
) /= E_Exception
then
3160 ("pragma% must refer to declared exception", Arg_Internal
);
3163 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
3165 if Present
(Arg_Form
) then
3166 Check_Arg_Is_One_Of
(Arg_Form
, Name_Ada
, Name_VMS
);
3169 if Present
(Arg_Form
)
3170 and then Chars
(Arg_Form
) = Name_Ada
3174 Set_Is_VMS_Exception
(Def_Id
);
3175 Set_Exception_Code
(Def_Id
, No_Uint
);
3178 if Present
(Arg_Code
) then
3179 if not Is_VMS_Exception
(Def_Id
) then
3181 ("Code option for pragma% not allowed for Ada case",
3185 Check_Arg_Is_Static_Expression
(Arg_Code
, Any_Integer
);
3186 Code_Val
:= Expr_Value
(Arg_Code
);
3188 if not UI_Is_In_Int_Range
(Code_Val
) then
3190 ("Code option for pragma% must be in 32-bit range",
3194 Set_Exception_Code
(Def_Id
, Code_Val
);
3197 end Process_Extended_Import_Export_Exception_Pragma
;
3199 -------------------------------------------------
3200 -- Process_Extended_Import_Export_Internal_Arg --
3201 -------------------------------------------------
3203 procedure Process_Extended_Import_Export_Internal_Arg
3204 (Arg_Internal
: Node_Id
:= Empty
)
3207 if No
(Arg_Internal
) then
3208 Error_Pragma
("Internal parameter required for pragma%");
3211 if Nkind
(Arg_Internal
) = N_Identifier
then
3214 elsif Nkind
(Arg_Internal
) = N_Operator_Symbol
3215 and then (Prag_Id
= Pragma_Import_Function
3217 Prag_Id
= Pragma_Export_Function
)
3223 ("wrong form for Internal parameter for pragma%", Arg_Internal
);
3226 Check_Arg_Is_Local_Name
(Arg_Internal
);
3227 end Process_Extended_Import_Export_Internal_Arg
;
3229 --------------------------------------------------
3230 -- Process_Extended_Import_Export_Object_Pragma --
3231 --------------------------------------------------
3233 procedure Process_Extended_Import_Export_Object_Pragma
3234 (Arg_Internal
: Node_Id
;
3235 Arg_External
: Node_Id
;
3241 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
3242 Def_Id
:= Entity
(Arg_Internal
);
3244 if not Ekind_In
(Def_Id
, E_Constant
, E_Variable
) then
3246 ("pragma% must designate an object", Arg_Internal
);
3249 if Has_Rep_Pragma
(Def_Id
, Name_Common_Object
)
3251 Has_Rep_Pragma
(Def_Id
, Name_Psect_Object
)
3254 ("previous Common/Psect_Object applies, pragma % not permitted",
3258 if Rep_Item_Too_Late
(Def_Id
, N
) then
3262 Set_Extended_Import_Export_External_Name
(Def_Id
, Arg_External
);
3264 if Present
(Arg_Size
) then
3265 Check_Arg_Is_External_Name
(Arg_Size
);
3268 -- Export_Object case
3270 if Prag_Id
= Pragma_Export_Object
then
3271 if not Is_Library_Level_Entity
(Def_Id
) then
3273 ("argument for pragma% must be library level entity",
3277 if Ekind
(Current_Scope
) = E_Generic_Package
then
3278 Error_Pragma
("pragma& cannot appear in a generic unit");
3281 if not Size_Known_At_Compile_Time
(Etype
(Def_Id
)) then
3283 ("exported object must have compile time known size",
3287 if Warn_On_Export_Import
and then Is_Exported
(Def_Id
) then
3288 Error_Msg_N
("?duplicate Export_Object pragma", N
);
3290 Set_Exported
(Def_Id
, Arg_Internal
);
3293 -- Import_Object case
3296 if Is_Concurrent_Type
(Etype
(Def_Id
)) then
3298 ("cannot use pragma% for task/protected object",
3302 if Ekind
(Def_Id
) = E_Constant
then
3304 ("cannot import a constant", Arg_Internal
);
3307 if Warn_On_Export_Import
3308 and then Has_Discriminants
(Etype
(Def_Id
))
3311 ("imported value must be initialized?", Arg_Internal
);
3314 if Warn_On_Export_Import
3315 and then Is_Access_Type
(Etype
(Def_Id
))
3318 ("cannot import object of an access type?", Arg_Internal
);
3321 if Warn_On_Export_Import
3322 and then Is_Imported
(Def_Id
)
3325 ("?duplicate Import_Object pragma", N
);
3327 -- Check for explicit initialization present. Note that an
3328 -- initialization generated by the code generator, e.g. for an
3329 -- access type, does not count here.
3331 elsif Present
(Expression
(Parent
(Def_Id
)))
3334 (Original_Node
(Expression
(Parent
(Def_Id
))))
3336 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3338 ("imported entities cannot be initialized (RM B.1(24))",
3339 "\no initialization allowed for & declared#", Arg1
);
3341 Set_Imported
(Def_Id
);
3342 Note_Possible_Modification
(Arg_Internal
, Sure
=> False);
3345 end Process_Extended_Import_Export_Object_Pragma
;
3347 ------------------------------------------------------
3348 -- Process_Extended_Import_Export_Subprogram_Pragma --
3349 ------------------------------------------------------
3351 procedure Process_Extended_Import_Export_Subprogram_Pragma
3352 (Arg_Internal
: Node_Id
;
3353 Arg_External
: Node_Id
;
3354 Arg_Parameter_Types
: Node_Id
;
3355 Arg_Result_Type
: Node_Id
:= Empty
;
3356 Arg_Mechanism
: Node_Id
;
3357 Arg_Result_Mechanism
: Node_Id
:= Empty
;
3358 Arg_First_Optional_Parameter
: Node_Id
:= Empty
)
3364 Ambiguous
: Boolean;
3368 function Same_Base_Type
3370 Formal
: Entity_Id
) return Boolean;
3371 -- Determines if Ptype references the type of Formal. Note that only
3372 -- the base types need to match according to the spec. Ptype here is
3373 -- the argument from the pragma, which is either a type name, or an
3374 -- access attribute.
3376 --------------------
3377 -- Same_Base_Type --
3378 --------------------
3380 function Same_Base_Type
3382 Formal
: Entity_Id
) return Boolean
3384 Ftyp
: constant Entity_Id
:= Base_Type
(Etype
(Formal
));
3388 -- Case where pragma argument is typ'Access
3390 if Nkind
(Ptype
) = N_Attribute_Reference
3391 and then Attribute_Name
(Ptype
) = Name_Access
3393 Pref
:= Prefix
(Ptype
);
3396 if not Is_Entity_Name
(Pref
)
3397 or else Entity
(Pref
) = Any_Type
3402 -- We have a match if the corresponding argument is of an
3403 -- anonymous access type, and its designated type matches the
3404 -- type of the prefix of the access attribute
3406 return Ekind
(Ftyp
) = E_Anonymous_Access_Type
3407 and then Base_Type
(Entity
(Pref
)) =
3408 Base_Type
(Etype
(Designated_Type
(Ftyp
)));
3410 -- Case where pragma argument is a type name
3415 if not Is_Entity_Name
(Ptype
)
3416 or else Entity
(Ptype
) = Any_Type
3421 -- We have a match if the corresponding argument is of the type
3422 -- given in the pragma (comparing base types)
3424 return Base_Type
(Entity
(Ptype
)) = Ftyp
;
3428 -- Start of processing for
3429 -- Process_Extended_Import_Export_Subprogram_Pragma
3432 Process_Extended_Import_Export_Internal_Arg
(Arg_Internal
);
3436 -- Loop through homonyms (overloadings) of the entity
3438 Hom_Id
:= Entity
(Arg_Internal
);
3439 while Present
(Hom_Id
) loop
3440 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
3442 -- We need a subprogram in the current scope
3444 if not Is_Subprogram
(Def_Id
)
3445 or else Scope
(Def_Id
) /= Current_Scope
3452 -- Pragma cannot apply to subprogram body
3454 if Is_Subprogram
(Def_Id
)
3455 and then Nkind
(Parent
(Declaration_Node
(Def_Id
))) =
3459 ("pragma% requires separate spec"
3460 & " and must come before body");
3463 -- Test result type if given, note that the result type
3464 -- parameter can only be present for the function cases.
3466 if Present
(Arg_Result_Type
)
3467 and then not Same_Base_Type
(Arg_Result_Type
, Def_Id
)
3471 elsif Etype
(Def_Id
) /= Standard_Void_Type
3473 (Pname
= Name_Export_Procedure
3475 Pname
= Name_Import_Procedure
)
3479 -- Test parameter types if given. Note that this parameter
3480 -- has not been analyzed (and must not be, since it is
3481 -- semantic nonsense), so we get it as the parser left it.
3483 elsif Present
(Arg_Parameter_Types
) then
3484 Check_Matching_Types
: declare
3489 Formal
:= First_Formal
(Def_Id
);
3491 if Nkind
(Arg_Parameter_Types
) = N_Null
then
3492 if Present
(Formal
) then
3496 -- A list of one type, e.g. (List) is parsed as
3497 -- a parenthesized expression.
3499 elsif Nkind
(Arg_Parameter_Types
) /= N_Aggregate
3500 and then Paren_Count
(Arg_Parameter_Types
) = 1
3503 or else Present
(Next_Formal
(Formal
))
3508 Same_Base_Type
(Arg_Parameter_Types
, Formal
);
3511 -- A list of more than one type is parsed as a aggregate
3513 elsif Nkind
(Arg_Parameter_Types
) = N_Aggregate
3514 and then Paren_Count
(Arg_Parameter_Types
) = 0
3516 Ptype
:= First
(Expressions
(Arg_Parameter_Types
));
3517 while Present
(Ptype
) or else Present
(Formal
) loop
3520 or else not Same_Base_Type
(Ptype
, Formal
)
3525 Next_Formal
(Formal
);
3530 -- Anything else is of the wrong form
3534 ("wrong form for Parameter_Types parameter",
3535 Arg_Parameter_Types
);
3537 end Check_Matching_Types
;
3540 -- Match is now False if the entry we found did not match
3541 -- either a supplied Parameter_Types or Result_Types argument
3547 -- Ambiguous case, the flag Ambiguous shows if we already
3548 -- detected this and output the initial messages.
3551 if not Ambiguous
then
3553 Error_Msg_Name_1
:= Pname
;
3555 ("pragma% does not uniquely identify subprogram!",
3557 Error_Msg_Sloc
:= Sloc
(Ent
);
3558 Error_Msg_N
("matching subprogram #!", N
);
3562 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3563 Error_Msg_N
("matching subprogram #!", N
);
3568 Hom_Id
:= Homonym
(Hom_Id
);
3571 -- See if we found an entry
3574 if not Ambiguous
then
3575 if Is_Generic_Subprogram
(Entity
(Arg_Internal
)) then
3577 ("pragma% cannot be given for generic subprogram");
3580 ("pragma% does not identify local subprogram");
3587 -- Import pragmas must be for imported entities
3589 if Prag_Id
= Pragma_Import_Function
3591 Prag_Id
= Pragma_Import_Procedure
3593 Prag_Id
= Pragma_Import_Valued_Procedure
3595 if not Is_Imported
(Ent
) then
3597 ("pragma Import or Interface must precede pragma%");
3600 -- Here we have the Export case which can set the entity as exported
3602 -- But does not do so if the specified external name is null, since
3603 -- that is taken as a signal in DEC Ada 83 (with which we want to be
3604 -- compatible) to request no external name.
3606 elsif Nkind
(Arg_External
) = N_String_Literal
3607 and then String_Length
(Strval
(Arg_External
)) = 0
3611 -- In all other cases, set entity as exported
3614 Set_Exported
(Ent
, Arg_Internal
);
3617 -- Special processing for Valued_Procedure cases
3619 if Prag_Id
= Pragma_Import_Valued_Procedure
3621 Prag_Id
= Pragma_Export_Valued_Procedure
3623 Formal
:= First_Formal
(Ent
);
3626 Error_Pragma
("at least one parameter required for pragma%");
3628 elsif Ekind
(Formal
) /= E_Out_Parameter
then
3629 Error_Pragma
("first parameter must have mode out for pragma%");
3632 Set_Is_Valued_Procedure
(Ent
);
3636 Set_Extended_Import_Export_External_Name
(Ent
, Arg_External
);
3638 -- Process Result_Mechanism argument if present. We have already
3639 -- checked that this is only allowed for the function case.
3641 if Present
(Arg_Result_Mechanism
) then
3642 Set_Mechanism_Value
(Ent
, Arg_Result_Mechanism
);
3645 -- Process Mechanism parameter if present. Note that this parameter
3646 -- is not analyzed, and must not be analyzed since it is semantic
3647 -- nonsense, so we get it in exactly as the parser left it.
3649 if Present
(Arg_Mechanism
) then
3657 -- A single mechanism association without a formal parameter
3658 -- name is parsed as a parenthesized expression. All other
3659 -- cases are parsed as aggregates, so we rewrite the single
3660 -- parameter case as an aggregate for consistency.
3662 if Nkind
(Arg_Mechanism
) /= N_Aggregate
3663 and then Paren_Count
(Arg_Mechanism
) = 1
3665 Rewrite
(Arg_Mechanism
,
3666 Make_Aggregate
(Sloc
(Arg_Mechanism
),
3667 Expressions
=> New_List
(
3668 Relocate_Node
(Arg_Mechanism
))));
3671 -- Case of only mechanism name given, applies to all formals
3673 if Nkind
(Arg_Mechanism
) /= N_Aggregate
then
3674 Formal
:= First_Formal
(Ent
);
3675 while Present
(Formal
) loop
3676 Set_Mechanism_Value
(Formal
, Arg_Mechanism
);
3677 Next_Formal
(Formal
);
3680 -- Case of list of mechanism associations given
3683 if Null_Record_Present
(Arg_Mechanism
) then
3685 ("inappropriate form for Mechanism parameter",
3689 -- Deal with positional ones first
3691 Formal
:= First_Formal
(Ent
);
3693 if Present
(Expressions
(Arg_Mechanism
)) then
3694 Mname
:= First
(Expressions
(Arg_Mechanism
));
3695 while Present
(Mname
) loop
3698 ("too many mechanism associations", Mname
);
3701 Set_Mechanism_Value
(Formal
, Mname
);
3702 Next_Formal
(Formal
);
3707 -- Deal with named entries
3709 if Present
(Component_Associations
(Arg_Mechanism
)) then
3710 Massoc
:= First
(Component_Associations
(Arg_Mechanism
));
3711 while Present
(Massoc
) loop
3712 Choice
:= First
(Choices
(Massoc
));
3714 if Nkind
(Choice
) /= N_Identifier
3715 or else Present
(Next
(Choice
))
3718 ("incorrect form for mechanism association",
3722 Formal
:= First_Formal
(Ent
);
3726 ("parameter name & not present", Choice
);
3729 if Chars
(Choice
) = Chars
(Formal
) then
3731 (Formal
, Expression
(Massoc
));
3733 -- Set entity on identifier (needed by ASIS)
3735 Set_Entity
(Choice
, Formal
);
3740 Next_Formal
(Formal
);
3750 -- Process First_Optional_Parameter argument if present. We have
3751 -- already checked that this is only allowed for the Import case.
3753 if Present
(Arg_First_Optional_Parameter
) then
3754 if Nkind
(Arg_First_Optional_Parameter
) /= N_Identifier
then
3756 ("first optional parameter must be formal parameter name",
3757 Arg_First_Optional_Parameter
);
3760 Formal
:= First_Formal
(Ent
);
3764 ("specified formal parameter& not found",
3765 Arg_First_Optional_Parameter
);
3768 exit when Chars
(Formal
) =
3769 Chars
(Arg_First_Optional_Parameter
);
3771 Next_Formal
(Formal
);
3774 Set_First_Optional_Parameter
(Ent
, Formal
);
3776 -- Check specified and all remaining formals have right form
3778 while Present
(Formal
) loop
3779 if Ekind
(Formal
) /= E_In_Parameter
then
3781 ("optional formal& is not of mode in!",
3782 Arg_First_Optional_Parameter
, Formal
);
3785 Dval
:= Default_Value
(Formal
);
3789 ("optional formal& does not have default value!",
3790 Arg_First_Optional_Parameter
, Formal
);
3792 elsif Compile_Time_Known_Value_Or_Aggr
(Dval
) then
3797 ("default value for optional formal& is non-static!",
3798 Arg_First_Optional_Parameter
, Formal
);
3802 Set_Is_Optional_Parameter
(Formal
);
3803 Next_Formal
(Formal
);
3806 end Process_Extended_Import_Export_Subprogram_Pragma
;
3808 --------------------------
3809 -- Process_Generic_List --
3810 --------------------------
3812 procedure Process_Generic_List
is
3817 Check_No_Identifiers
;
3818 Check_At_Least_N_Arguments
(1);
3821 while Present
(Arg
) loop
3822 Exp
:= Get_Pragma_Arg
(Arg
);
3825 if not Is_Entity_Name
(Exp
)
3827 (not Is_Generic_Instance
(Entity
(Exp
))
3829 not Is_Generic_Unit
(Entity
(Exp
)))
3832 ("pragma% argument must be name of generic unit/instance",
3838 end Process_Generic_List
;
3840 ---------------------------------
3841 -- Process_Import_Or_Interface --
3842 ---------------------------------
3844 procedure Process_Import_Or_Interface
is
3850 Process_Convention
(C
, Def_Id
);
3851 Kill_Size_Check_Code
(Def_Id
);
3852 Note_Possible_Modification
(Get_Pragma_Arg
(Arg2
), Sure
=> False);
3854 if Ekind_In
(Def_Id
, E_Variable
, E_Constant
) then
3856 -- We do not permit Import to apply to a renaming declaration
3858 if Present
(Renamed_Object
(Def_Id
)) then
3860 ("pragma% not allowed for object renaming", Arg2
);
3862 -- User initialization is not allowed for imported object, but
3863 -- the object declaration may contain a default initialization,
3864 -- that will be discarded. Note that an explicit initialization
3865 -- only counts if it comes from source, otherwise it is simply
3866 -- the code generator making an implicit initialization explicit.
3868 elsif Present
(Expression
(Parent
(Def_Id
)))
3869 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
3871 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3873 ("no initialization allowed for declaration of& #",
3874 "\imported entities cannot be initialized (RM B.1(24))",
3878 Set_Imported
(Def_Id
);
3879 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
3881 -- Note that we do not set Is_Public here. That's because we
3882 -- only want to set it if there is no address clause, and we
3883 -- don't know that yet, so we delay that processing till
3886 -- pragma Import completes deferred constants
3888 if Ekind
(Def_Id
) = E_Constant
then
3889 Set_Has_Completion
(Def_Id
);
3892 -- It is not possible to import a constant of an unconstrained
3893 -- array type (e.g. string) because there is no simple way to
3894 -- write a meaningful subtype for it.
3896 if Is_Array_Type
(Etype
(Def_Id
))
3897 and then not Is_Constrained
(Etype
(Def_Id
))
3900 ("imported constant& must have a constrained subtype",
3905 elsif Is_Subprogram
(Def_Id
)
3906 or else Is_Generic_Subprogram
(Def_Id
)
3908 -- If the name is overloaded, pragma applies to all of the denoted
3909 -- entities in the same declarative part.
3912 while Present
(Hom_Id
) loop
3913 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
3915 -- Ignore inherited subprograms because the pragma will apply
3916 -- to the parent operation, which is the one called.
3918 if Is_Overloadable
(Def_Id
)
3919 and then Present
(Alias
(Def_Id
))
3923 -- If it is not a subprogram, it must be in an outer scope and
3924 -- pragma does not apply.
3926 elsif not Is_Subprogram
(Def_Id
)
3927 and then not Is_Generic_Subprogram
(Def_Id
)
3931 -- The pragma does not apply to primitives of interfaces
3933 elsif Is_Dispatching_Operation
(Def_Id
)
3934 and then Present
(Find_Dispatching_Type
(Def_Id
))
3935 and then Is_Interface
(Find_Dispatching_Type
(Def_Id
))
3939 -- Verify that the homonym is in the same declarative part (not
3940 -- just the same scope).
3942 elsif Parent
(Unit_Declaration_Node
(Def_Id
)) /= Parent
(N
)
3943 and then Nkind
(Parent
(N
)) /= N_Compilation_Unit_Aux
3948 Set_Imported
(Def_Id
);
3950 -- Reject an Import applied to an abstract subprogram
3952 if Is_Subprogram
(Def_Id
)
3953 and then Is_Abstract_Subprogram
(Def_Id
)
3955 Error_Msg_Sloc
:= Sloc
(Def_Id
);
3957 ("cannot import abstract subprogram& declared#",
3961 -- Special processing for Convention_Intrinsic
3963 if C
= Convention_Intrinsic
then
3965 -- Link_Name argument not allowed for intrinsic
3968 and then Chars
(Arg3
) = Name_Link_Name
3973 if Present
(Arg4
) then
3975 ("Link_Name argument not allowed for " &
3980 Set_Is_Intrinsic_Subprogram
(Def_Id
);
3982 -- If no external name is present, then check that this
3983 -- is a valid intrinsic subprogram. If an external name
3984 -- is present, then this is handled by the back end.
3987 Check_Intrinsic_Subprogram
3988 (Def_Id
, Get_Pragma_Arg
(Arg2
));
3992 -- All interfaced procedures need an external symbol created
3993 -- for them since they are always referenced from another
3996 Set_Is_Public
(Def_Id
);
3998 -- Verify that the subprogram does not have a completion
3999 -- through a renaming declaration. For other completions the
4000 -- pragma appears as a too late representation.
4003 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Def_Id
);
4007 and then Nkind
(Decl
) = N_Subprogram_Declaration
4008 and then Present
(Corresponding_Body
(Decl
))
4009 and then Nkind
(Unit_Declaration_Node
4010 (Corresponding_Body
(Decl
))) =
4011 N_Subprogram_Renaming_Declaration
4013 Error_Msg_Sloc
:= Sloc
(Def_Id
);
4015 ("cannot import&, renaming already provided for " &
4016 "declaration #", N
, Def_Id
);
4020 Set_Has_Completion
(Def_Id
);
4021 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
4024 if Is_Compilation_Unit
(Hom_Id
) then
4026 -- Its possible homonyms are not affected by the pragma.
4027 -- Such homonyms might be present in the context of other
4028 -- units being compiled.
4033 Hom_Id
:= Homonym
(Hom_Id
);
4037 -- When the convention is Java or CIL, we also allow Import to be
4038 -- given for packages, generic packages, exceptions, record
4039 -- components, and access to subprograms.
4041 elsif (C
= Convention_Java
or else C
= Convention_CIL
)
4043 (Is_Package_Or_Generic_Package
(Def_Id
)
4044 or else Ekind
(Def_Id
) = E_Exception
4045 or else Ekind
(Def_Id
) = E_Access_Subprogram_Type
4046 or else Nkind
(Parent
(Def_Id
)) = N_Component_Declaration
)
4048 Set_Imported
(Def_Id
);
4049 Set_Is_Public
(Def_Id
);
4050 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
4052 -- Import a CPP class
4054 elsif Is_Record_Type
(Def_Id
)
4055 and then C
= Convention_CPP
4057 -- Types treated as CPP classes are treated as limited, but we
4058 -- don't require them to be declared this way. A warning is issued
4059 -- to encourage the user to declare them as limited. This is not
4060 -- an error, for compatibility reasons, because these types have
4061 -- been supported this way for some time.
4063 if not Is_Limited_Type
(Def_Id
) then
4065 ("imported 'C'P'P type should be " &
4066 "explicitly declared limited?",
4067 Get_Pragma_Arg
(Arg2
));
4069 ("\type will be considered limited",
4070 Get_Pragma_Arg
(Arg2
));
4073 Set_Is_CPP_Class
(Def_Id
);
4074 Set_Is_Limited_Record
(Def_Id
);
4076 -- Imported CPP types must not have discriminants (because C++
4077 -- classes do not have discriminants).
4079 if Has_Discriminants
(Def_Id
) then
4081 ("imported 'C'P'P type cannot have discriminants",
4082 First
(Discriminant_Specifications
4083 (Declaration_Node
(Def_Id
))));
4086 -- Components of imported CPP types must not have default
4087 -- expressions because the constructor (if any) is on the
4091 Tdef
: constant Node_Id
:=
4092 Type_Definition
(Declaration_Node
(Def_Id
));
4097 if Nkind
(Tdef
) = N_Record_Definition
then
4098 Clist
:= Component_List
(Tdef
);
4101 pragma Assert
(Nkind
(Tdef
) = N_Derived_Type_Definition
);
4102 Clist
:= Component_List
(Record_Extension_Part
(Tdef
));
4105 if Present
(Clist
) then
4106 Comp
:= First
(Component_Items
(Clist
));
4107 while Present
(Comp
) loop
4108 if Present
(Expression
(Comp
)) then
4110 ("component of imported 'C'P'P type cannot have" &
4111 " default expression", Expression
(Comp
));
4121 ("second argument of pragma% must be object or subprogram",
4125 -- If this pragma applies to a compilation unit, then the unit, which
4126 -- is a subprogram, does not require (or allow) a body. We also do
4127 -- not need to elaborate imported procedures.
4129 if Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
4131 Cunit
: constant Node_Id
:= Parent
(Parent
(N
));
4133 Set_Body_Required
(Cunit
, False);
4136 end Process_Import_Or_Interface
;
4138 --------------------
4139 -- Process_Inline --
4140 --------------------
4142 procedure Process_Inline
(Active
: Boolean) is
4148 Effective
: Boolean := False;
4150 procedure Make_Inline
(Subp
: Entity_Id
);
4151 -- Subp is the defining unit name of the subprogram declaration. Set
4152 -- the flag, as well as the flag in the corresponding body, if there
4155 procedure Set_Inline_Flags
(Subp
: Entity_Id
);
4156 -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp and also
4157 -- Has_Pragma_Inline_Always for the Inline_Always case.
4159 function Inlining_Not_Possible
(Subp
: Entity_Id
) return Boolean;
4160 -- Returns True if it can be determined at this stage that inlining
4161 -- is not possible, for example if the body is available and contains
4162 -- exception handlers, we prevent inlining, since otherwise we can
4163 -- get undefined symbols at link time. This function also emits a
4164 -- warning if front-end inlining is enabled and the pragma appears
4167 -- ??? is business with link symbols still valid, or does it relate
4168 -- to front end ZCX which is being phased out ???
4170 ---------------------------
4171 -- Inlining_Not_Possible --
4172 ---------------------------
4174 function Inlining_Not_Possible
(Subp
: Entity_Id
) return Boolean is
4175 Decl
: constant Node_Id
:= Unit_Declaration_Node
(Subp
);
4179 if Nkind
(Decl
) = N_Subprogram_Body
then
4180 Stats
:= Handled_Statement_Sequence
(Decl
);
4181 return Present
(Exception_Handlers
(Stats
))
4182 or else Present
(At_End_Proc
(Stats
));
4184 elsif Nkind
(Decl
) = N_Subprogram_Declaration
4185 and then Present
(Corresponding_Body
(Decl
))
4187 if Front_End_Inlining
4188 and then Analyzed
(Corresponding_Body
(Decl
))
4190 Error_Msg_N
("pragma appears too late, ignored?", N
);
4193 -- If the subprogram is a renaming as body, the body is just a
4194 -- call to the renamed subprogram, and inlining is trivially
4198 Nkind
(Unit_Declaration_Node
(Corresponding_Body
(Decl
))) =
4199 N_Subprogram_Renaming_Declaration
4205 Handled_Statement_Sequence
4206 (Unit_Declaration_Node
(Corresponding_Body
(Decl
)));
4209 Present
(Exception_Handlers
(Stats
))
4210 or else Present
(At_End_Proc
(Stats
));
4214 -- If body is not available, assume the best, the check is
4215 -- performed again when compiling enclosing package bodies.
4219 end Inlining_Not_Possible
;
4225 procedure Make_Inline
(Subp
: Entity_Id
) is
4226 Kind
: constant Entity_Kind
:= Ekind
(Subp
);
4227 Inner_Subp
: Entity_Id
:= Subp
;
4230 -- Ignore if bad type, avoid cascaded error
4232 if Etype
(Subp
) = Any_Type
then
4236 -- Ignore if all inlining is suppressed
4238 elsif Suppress_All_Inlining
then
4242 -- If inlining is not possible, for now do not treat as an error
4244 elsif Inlining_Not_Possible
(Subp
) then
4248 -- Here we have a candidate for inlining, but we must exclude
4249 -- derived operations. Otherwise we would end up trying to inline
4250 -- a phantom declaration, and the result would be to drag in a
4251 -- body which has no direct inlining associated with it. That
4252 -- would not only be inefficient but would also result in the
4253 -- backend doing cross-unit inlining in cases where it was
4254 -- definitely inappropriate to do so.
4256 -- However, a simple Comes_From_Source test is insufficient, since
4257 -- we do want to allow inlining of generic instances which also do
4258 -- not come from source. We also need to recognize specs generated
4259 -- by the front-end for bodies that carry the pragma. Finally,
4260 -- predefined operators do not come from source but are not
4261 -- inlineable either.
4263 elsif Is_Generic_Instance
(Subp
)
4264 or else Nkind
(Parent
(Parent
(Subp
))) = N_Subprogram_Declaration
4268 elsif not Comes_From_Source
(Subp
)
4269 and then Scope
(Subp
) /= Standard_Standard
4275 -- The referenced entity must either be the enclosing entity, or
4276 -- an entity declared within the current open scope.
4278 if Present
(Scope
(Subp
))
4279 and then Scope
(Subp
) /= Current_Scope
4280 and then Subp
/= Current_Scope
4283 ("argument of% must be entity in current scope", Assoc
);
4287 -- Processing for procedure, operator or function. If subprogram
4288 -- is aliased (as for an instance) indicate that the renamed
4289 -- entity (if declared in the same unit) is inlined.
4291 if Is_Subprogram
(Subp
) then
4297 Inner_Subp
:= Ultimate_Alias
(Inner_Subp
);
4299 if In_Same_Source_Unit
(Subp
, Inner_Subp
) then
4300 Set_Inline_Flags
(Inner_Subp
);
4302 Decl
:= Parent
(Parent
(Inner_Subp
));
4304 if Nkind
(Decl
) = N_Subprogram_Declaration
4305 and then Present
(Corresponding_Body
(Decl
))
4307 Set_Inline_Flags
(Corresponding_Body
(Decl
));
4309 elsif Is_Generic_Instance
(Subp
) then
4311 -- Indicate that the body needs to be created for
4312 -- inlining subsequent calls. The instantiation node
4313 -- follows the declaration of the wrapper package
4316 if Scope
(Subp
) /= Standard_Standard
4318 Need_Subprogram_Instance_Body
4319 (Next
(Unit_Declaration_Node
(Scope
(Alias
(Subp
)))),
4329 -- For a generic subprogram set flag as well, for use at the point
4330 -- of instantiation, to determine whether the body should be
4333 elsif Is_Generic_Subprogram
(Subp
) then
4334 Set_Inline_Flags
(Subp
);
4337 -- Literals are by definition inlined
4339 elsif Kind
= E_Enumeration_Literal
then
4342 -- Anything else is an error
4346 ("expect subprogram name for pragma%", Assoc
);
4350 ----------------------
4351 -- Set_Inline_Flags --
4352 ----------------------
4354 procedure Set_Inline_Flags
(Subp
: Entity_Id
) is
4357 Set_Is_Inlined
(Subp
, Sense
);
4360 if not Has_Pragma_Inline
(Subp
) then
4361 Set_Has_Pragma_Inline
(Subp
, Sense
);
4365 if Prag_Id
= Pragma_Inline_Always
then
4366 Set_Has_Pragma_Inline_Always
(Subp
, Sense
);
4368 end Set_Inline_Flags
;
4370 -- Start of processing for Process_Inline
4373 Check_No_Identifiers
;
4374 Check_At_Least_N_Arguments
(1);
4377 Inline_Processing_Required
:= True;
4381 while Present
(Assoc
) loop
4382 Subp_Id
:= Get_Pragma_Arg
(Assoc
);
4386 if Is_Entity_Name
(Subp_Id
) then
4387 Subp
:= Entity
(Subp_Id
);
4389 if Subp
= Any_Id
then
4391 -- If previous error, avoid cascaded errors
4399 if not From_Aspect_Specification
(N
) then
4400 while Present
(Homonym
(Subp
))
4401 and then Scope
(Homonym
(Subp
)) = Current_Scope
4403 Make_Inline
(Homonym
(Subp
));
4404 Subp
:= Homonym
(Subp
);
4412 ("inappropriate argument for pragma%", Assoc
);
4415 and then Warn_On_Redundant_Constructs
4416 and then not Suppress_All_Inlining
4418 if Inlining_Not_Possible
(Subp
) then
4420 ("pragma Inline for& is ignored?", N
, Entity
(Subp_Id
));
4423 ("pragma Inline for& is redundant?", N
, Entity
(Subp_Id
));
4431 ----------------------------
4432 -- Process_Interface_Name --
4433 ----------------------------
4435 procedure Process_Interface_Name
4436 (Subprogram_Def
: Entity_Id
;
4442 String_Val
: String_Id
;
4444 procedure Check_Form_Of_Interface_Name
4446 Ext_Name_Case
: Boolean);
4447 -- SN is a string literal node for an interface name. This routine
4448 -- performs some minimal checks that the name is reasonable. In
4449 -- particular that no spaces or other obviously incorrect characters
4450 -- appear. This is only a warning, since any characters are allowed.
4451 -- Ext_Name_Case is True for an External_Name, False for a Link_Name.
4453 ----------------------------------
4454 -- Check_Form_Of_Interface_Name --
4455 ----------------------------------
4457 procedure Check_Form_Of_Interface_Name
4459 Ext_Name_Case
: Boolean)
4461 S
: constant String_Id
:= Strval
(Expr_Value_S
(SN
));
4462 SL
: constant Nat
:= String_Length
(S
);
4467 Error_Msg_N
("interface name cannot be null string", SN
);
4470 for J
in 1 .. SL
loop
4471 C
:= Get_String_Char
(S
, J
);
4473 -- Look for dubious character and issue unconditional warning.
4474 -- Definitely dubious if not in character range.
4476 if not In_Character_Range
(C
)
4478 -- For all cases except CLI target,
4479 -- commas, spaces and slashes are dubious (in CLI, we use
4480 -- commas and backslashes in external names to specify
4481 -- assembly version and public key, while slashes and spaces
4482 -- can be used in names to mark nested classes and
4485 or else ((not Ext_Name_Case
or else VM_Target
/= CLI_Target
)
4486 and then (Get_Character
(C
) = ','
4488 Get_Character
(C
) = '\'))
4489 or else (VM_Target
/= CLI_Target
4490 and then (Get_Character
(C
) = ' '
4492 Get_Character
(C
) = '/'))
4495 ("?interface name contains illegal character",
4496 Sloc
(SN
) + Source_Ptr
(J
));
4499 end Check_Form_Of_Interface_Name
;
4501 -- Start of processing for Process_Interface_Name
4504 if No
(Link_Arg
) then
4505 if No
(Ext_Arg
) then
4506 if VM_Target
= CLI_Target
4507 and then Ekind
(Subprogram_Def
) = E_Package
4508 and then Nkind
(Parent
(Subprogram_Def
)) =
4509 N_Package_Specification
4510 and then Present
(Generic_Parent
(Parent
(Subprogram_Def
)))
4515 (Generic_Parent
(Parent
(Subprogram_Def
))));
4520 elsif Chars
(Ext_Arg
) = Name_Link_Name
then
4522 Link_Nam
:= Expression
(Ext_Arg
);
4525 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
4526 Ext_Nam
:= Expression
(Ext_Arg
);
4531 Check_Optional_Identifier
(Ext_Arg
, Name_External_Name
);
4532 Check_Optional_Identifier
(Link_Arg
, Name_Link_Name
);
4533 Ext_Nam
:= Expression
(Ext_Arg
);
4534 Link_Nam
:= Expression
(Link_Arg
);
4537 -- Check expressions for external name and link name are static
4539 if Present
(Ext_Nam
) then
4540 Check_Arg_Is_Static_Expression
(Ext_Nam
, Standard_String
);
4541 Check_Form_Of_Interface_Name
(Ext_Nam
, Ext_Name_Case
=> True);
4543 -- Verify that external name is not the name of a local entity,
4544 -- which would hide the imported one and could lead to run-time
4545 -- surprises. The problem can only arise for entities declared in
4546 -- a package body (otherwise the external name is fully qualified
4547 -- and will not conflict).
4555 if Prag_Id
= Pragma_Import
then
4556 String_To_Name_Buffer
(Strval
(Expr_Value_S
(Ext_Nam
)));
4558 E
:= Entity_Id
(Get_Name_Table_Info
(Nam
));
4560 if Nam
/= Chars
(Subprogram_Def
)
4561 and then Present
(E
)
4562 and then not Is_Overloadable
(E
)
4563 and then Is_Immediately_Visible
(E
)
4564 and then not Is_Imported
(E
)
4565 and then Ekind
(Scope
(E
)) = E_Package
4568 while Present
(Par
) loop
4569 if Nkind
(Par
) = N_Package_Body
then
4570 Error_Msg_Sloc
:= Sloc
(E
);
4572 ("imported entity is hidden by & declared#",
4577 Par
:= Parent
(Par
);
4584 if Present
(Link_Nam
) then
4585 Check_Arg_Is_Static_Expression
(Link_Nam
, Standard_String
);
4586 Check_Form_Of_Interface_Name
(Link_Nam
, Ext_Name_Case
=> False);
4589 -- If there is no link name, just set the external name
4591 if No
(Link_Nam
) then
4592 Link_Nam
:= Adjust_External_Name_Case
(Expr_Value_S
(Ext_Nam
));
4594 -- For the Link_Name case, the given literal is preceded by an
4595 -- asterisk, which indicates to GCC that the given name should be
4596 -- taken literally, and in particular that no prepending of
4597 -- underlines should occur, even in systems where this is the
4603 if VM_Target
= No_VM
then
4604 Store_String_Char
(Get_Char_Code
('*'));
4607 String_Val
:= Strval
(Expr_Value_S
(Link_Nam
));
4608 Store_String_Chars
(String_Val
);
4610 Make_String_Literal
(Sloc
(Link_Nam
),
4611 Strval
=> End_String
);
4614 Set_Encoded_Interface_Name
4615 (Get_Base_Subprogram
(Subprogram_Def
), Link_Nam
);
4617 -- We allow duplicated export names in CIL, as they are always
4618 -- enclosed in a namespace that differentiates them, and overloaded
4619 -- entities are supported by the VM.
4621 if Convention
(Subprogram_Def
) /= Convention_CIL
then
4622 Check_Duplicated_Export_Name
(Link_Nam
);
4624 end Process_Interface_Name
;
4626 -----------------------------------------
4627 -- Process_Interrupt_Or_Attach_Handler --
4628 -----------------------------------------
4630 procedure Process_Interrupt_Or_Attach_Handler
is
4631 Arg1_X
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
4632 Handler_Proc
: constant Entity_Id
:= Entity
(Arg1_X
);
4633 Proc_Scope
: constant Entity_Id
:= Scope
(Handler_Proc
);
4636 Set_Is_Interrupt_Handler
(Handler_Proc
);
4638 -- If the pragma is not associated with a handler procedure within a
4639 -- protected type, then it must be for a nonprotected procedure for
4640 -- the AAMP target, in which case we don't associate a representation
4641 -- item with the procedure's scope.
4643 if Ekind
(Proc_Scope
) = E_Protected_Type
then
4644 if Prag_Id
= Pragma_Interrupt_Handler
4646 Prag_Id
= Pragma_Attach_Handler
4648 Record_Rep_Item
(Proc_Scope
, N
);
4651 end Process_Interrupt_Or_Attach_Handler
;
4653 --------------------------------------------------
4654 -- Process_Restrictions_Or_Restriction_Warnings --
4655 --------------------------------------------------
4657 -- Note: some of the simple identifier cases were handled in par-prag,
4658 -- but it is harmless (and more straightforward) to simply handle all
4659 -- cases here, even if it means we repeat a bit of work in some cases.
4661 procedure Process_Restrictions_Or_Restriction_Warnings
4665 R_Id
: Restriction_Id
;
4670 procedure Check_Unit_Name
(N
: Node_Id
);
4671 -- Checks unit name parameter for No_Dependence. Returns if it has
4672 -- an appropriate form, otherwise raises pragma argument error.
4674 ---------------------
4675 -- Check_Unit_Name --
4676 ---------------------
4678 procedure Check_Unit_Name
(N
: Node_Id
) is
4680 if Nkind
(N
) = N_Selected_Component
then
4681 Check_Unit_Name
(Prefix
(N
));
4682 Check_Unit_Name
(Selector_Name
(N
));
4684 elsif Nkind
(N
) = N_Identifier
then
4689 ("wrong form for unit name for No_Dependence", N
);
4691 end Check_Unit_Name
;
4693 -- Start of processing for Process_Restrictions_Or_Restriction_Warnings
4696 -- Ignore all Restrictions pragma in CodePeer mode
4698 if CodePeer_Mode
then
4702 Check_Ada_83_Warning
;
4703 Check_At_Least_N_Arguments
(1);
4704 Check_Valid_Configuration_Pragma
;
4707 while Present
(Arg
) loop
4709 Expr
:= Get_Pragma_Arg
(Arg
);
4711 -- Case of no restriction identifier present
4713 if Id
= No_Name
then
4714 if Nkind
(Expr
) /= N_Identifier
then
4716 ("invalid form for restriction", Arg
);
4721 (Process_Restriction_Synonyms
(Expr
));
4723 if R_Id
not in All_Boolean_Restrictions
then
4724 Error_Msg_Name_1
:= Pname
;
4726 ("invalid restriction identifier&", Get_Pragma_Arg
(Arg
));
4728 -- Check for possible misspelling
4730 for J
in Restriction_Id
loop
4732 Rnm
: constant String := Restriction_Id
'Image (J
);
4735 Name_Buffer
(1 .. Rnm
'Length) := Rnm
;
4736 Name_Len
:= Rnm
'Length;
4737 Set_Casing
(All_Lower_Case
);
4739 if Is_Bad_Spelling_Of
(Chars
(Expr
), Name_Enter
) then
4741 (Identifier_Casing
(Current_Source_File
));
4742 Error_Msg_String
(1 .. Rnm
'Length) :=
4743 Name_Buffer
(1 .. Name_Len
);
4744 Error_Msg_Strlen
:= Rnm
'Length;
4745 Error_Msg_N
-- CODEFIX
4746 ("\possible misspelling of ""~""",
4747 Get_Pragma_Arg
(Arg
));
4756 if Implementation_Restriction
(R_Id
) then
4757 Check_Restriction
(No_Implementation_Restrictions
, Arg
);
4760 -- If this is a warning, then set the warning unless we already
4761 -- have a real restriction active (we never want a warning to
4762 -- override a real restriction).
4765 if not Restriction_Active
(R_Id
) then
4766 Set_Restriction
(R_Id
, N
);
4767 Restriction_Warnings
(R_Id
) := True;
4770 -- If real restriction case, then set it and make sure that the
4771 -- restriction warning flag is off, since a real restriction
4772 -- always overrides a warning.
4775 Set_Restriction
(R_Id
, N
);
4776 Restriction_Warnings
(R_Id
) := False;
4779 -- Check for obsolescent restrictions in Ada 2005 mode
4782 and then Ada_Version
>= Ada_2005
4783 and then (R_Id
= No_Asynchronous_Control
4785 R_Id
= No_Unchecked_Deallocation
4787 R_Id
= No_Unchecked_Conversion
)
4789 Check_Restriction
(No_Obsolescent_Features
, N
);
4792 -- A very special case that must be processed here: pragma
4793 -- Restrictions (No_Exceptions) turns off all run-time
4794 -- checking. This is a bit dubious in terms of the formal
4795 -- language definition, but it is what is intended by RM
4796 -- H.4(12). Restriction_Warnings never affects generated code
4797 -- so this is done only in the real restriction case.
4799 if R_Id
= No_Exceptions
and then not Warn
then
4800 Scope_Suppress
:= (others => True);
4803 -- Case of No_Dependence => unit-name. Note that the parser
4804 -- already made the necessary entry in the No_Dependence table.
4806 elsif Id
= Name_No_Dependence
then
4807 Check_Unit_Name
(Expr
);
4809 -- All other cases of restriction identifier present
4812 R_Id
:= Get_Restriction_Id
(Process_Restriction_Synonyms
(Arg
));
4813 Analyze_And_Resolve
(Expr
, Any_Integer
);
4815 if R_Id
not in All_Parameter_Restrictions
then
4817 ("invalid restriction parameter identifier", Arg
);
4819 elsif not Is_OK_Static_Expression
(Expr
) then
4820 Flag_Non_Static_Expr
4821 ("value must be static expression!", Expr
);
4824 elsif not Is_Integer_Type
(Etype
(Expr
))
4825 or else Expr_Value
(Expr
) < 0
4828 ("value must be non-negative integer", Arg
);
4831 -- Restriction pragma is active
4833 Val
:= Expr_Value
(Expr
);
4835 if not UI_Is_In_Int_Range
(Val
) then
4837 ("pragma ignored, value too large?", Arg
);
4840 -- Warning case. If the real restriction is active, then we
4841 -- ignore the request, since warning never overrides a real
4842 -- restriction. Otherwise we set the proper warning. Note that
4843 -- this circuit sets the warning again if it is already set,
4844 -- which is what we want, since the constant may have changed.
4847 if not Restriction_Active
(R_Id
) then
4849 (R_Id
, N
, Integer (UI_To_Int
(Val
)));
4850 Restriction_Warnings
(R_Id
) := True;
4853 -- Real restriction case, set restriction and make sure warning
4854 -- flag is off since real restriction always overrides warning.
4857 Set_Restriction
(R_Id
, N
, Integer (UI_To_Int
(Val
)));
4858 Restriction_Warnings
(R_Id
) := False;
4864 end Process_Restrictions_Or_Restriction_Warnings
;
4866 ---------------------------------
4867 -- Process_Suppress_Unsuppress --
4868 ---------------------------------
4870 -- Note: this procedure makes entries in the check suppress data
4871 -- structures managed by Sem. See spec of package Sem for full
4872 -- details on how we handle recording of check suppression.
4874 procedure Process_Suppress_Unsuppress
(Suppress_Case
: Boolean) is
4879 In_Package_Spec
: constant Boolean :=
4880 Is_Package_Or_Generic_Package
(Current_Scope
)
4881 and then not In_Package_Body
(Current_Scope
);
4883 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
);
4884 -- Used to suppress a single check on the given entity
4886 --------------------------------
4887 -- Suppress_Unsuppress_Echeck --
4888 --------------------------------
4890 procedure Suppress_Unsuppress_Echeck
(E
: Entity_Id
; C
: Check_Id
) is
4892 Set_Checks_May_Be_Suppressed
(E
);
4894 if In_Package_Spec
then
4895 Push_Global_Suppress_Stack_Entry
4898 Suppress
=> Suppress_Case
);
4901 Push_Local_Suppress_Stack_Entry
4904 Suppress
=> Suppress_Case
);
4907 -- If this is a first subtype, and the base type is distinct,
4908 -- then also set the suppress flags on the base type.
4910 if Is_First_Subtype
(E
)
4911 and then Etype
(E
) /= E
4913 Suppress_Unsuppress_Echeck
(Etype
(E
), C
);
4915 end Suppress_Unsuppress_Echeck
;
4917 -- Start of processing for Process_Suppress_Unsuppress
4920 -- Ignore pragma Suppress/Unsuppress in codepeer mode on user code:
4921 -- we want to generate checks for analysis purposes, as set by -gnatC
4923 if CodePeer_Mode
and then Comes_From_Source
(N
) then
4927 -- Suppress/Unsuppress can appear as a configuration pragma, or in a
4928 -- declarative part or a package spec (RM 11.5(5)).
4930 if not Is_Configuration_Pragma
then
4931 Check_Is_In_Decl_Part_Or_Package_Spec
;
4934 Check_At_Least_N_Arguments
(1);
4935 Check_At_Most_N_Arguments
(2);
4936 Check_No_Identifier
(Arg1
);
4937 Check_Arg_Is_Identifier
(Arg1
);
4939 C
:= Get_Check_Id
(Chars
(Get_Pragma_Arg
(Arg1
)));
4941 if C
= No_Check_Id
then
4943 ("argument of pragma% is not valid check name", Arg1
);
4946 if not Suppress_Case
4947 and then (C
= All_Checks
or else C
= Overflow_Check
)
4949 Opt
.Overflow_Checks_Unsuppressed
:= True;
4952 if Arg_Count
= 1 then
4954 -- Make an entry in the local scope suppress table. This is the
4955 -- table that directly shows the current value of the scope
4956 -- suppress check for any check id value.
4958 if C
= All_Checks
then
4960 -- For All_Checks, we set all specific predefined checks with
4961 -- the exception of Elaboration_Check, which is handled
4962 -- specially because of not wanting All_Checks to have the
4963 -- effect of deactivating static elaboration order processing.
4965 for J
in Scope_Suppress
'Range loop
4966 if J
/= Elaboration_Check
then
4967 Scope_Suppress
(J
) := Suppress_Case
;
4971 -- If not All_Checks, and predefined check, then set appropriate
4972 -- scope entry. Note that we will set Elaboration_Check if this
4973 -- is explicitly specified.
4975 elsif C
in Predefined_Check_Id
then
4976 Scope_Suppress
(C
) := Suppress_Case
;
4979 -- Also make an entry in the Local_Entity_Suppress table
4981 Push_Local_Suppress_Stack_Entry
4984 Suppress
=> Suppress_Case
);
4986 -- Case of two arguments present, where the check is suppressed for
4987 -- a specified entity (given as the second argument of the pragma)
4990 -- This is obsolescent in Ada 2005 mode
4992 if Ada_Version
>= Ada_2005
then
4993 Check_Restriction
(No_Obsolescent_Features
, Arg2
);
4996 Check_Optional_Identifier
(Arg2
, Name_On
);
4997 E_Id
:= Get_Pragma_Arg
(Arg2
);
5000 if not Is_Entity_Name
(E_Id
) then
5002 ("second argument of pragma% must be entity name", Arg2
);
5011 -- Enforce RM 11.5(7) which requires that for a pragma that
5012 -- appears within a package spec, the named entity must be
5013 -- within the package spec. We allow the package name itself
5014 -- to be mentioned since that makes sense, although it is not
5015 -- strictly allowed by 11.5(7).
5018 and then E
/= Current_Scope
5019 and then Scope
(E
) /= Current_Scope
5022 ("entity in pragma% is not in package spec (RM 11.5(7))",
5026 -- Loop through homonyms. As noted below, in the case of a package
5027 -- spec, only homonyms within the package spec are considered.
5030 Suppress_Unsuppress_Echeck
(E
, C
);
5032 if Is_Generic_Instance
(E
)
5033 and then Is_Subprogram
(E
)
5034 and then Present
(Alias
(E
))
5036 Suppress_Unsuppress_Echeck
(Alias
(E
), C
);
5039 -- Move to next homonym if not aspect spec case
5041 exit when From_Aspect_Specification
(N
);
5045 -- If we are within a package specification, the pragma only
5046 -- applies to homonyms in the same scope.
5048 exit when In_Package_Spec
5049 and then Scope
(E
) /= Current_Scope
;
5052 end Process_Suppress_Unsuppress
;
5058 procedure Set_Exported
(E
: Entity_Id
; Arg
: Node_Id
) is
5060 if Is_Imported
(E
) then
5062 ("cannot export entity& that was previously imported", Arg
);
5064 elsif Present
(Address_Clause
(E
)) and then not CodePeer_Mode
then
5066 ("cannot export entity& that has an address clause", Arg
);
5069 Set_Is_Exported
(E
);
5071 -- Generate a reference for entity explicitly, because the
5072 -- identifier may be overloaded and name resolution will not
5075 Generate_Reference
(E
, Arg
);
5077 -- Deal with exporting non-library level entity
5079 if not Is_Library_Level_Entity
(E
) then
5081 -- Not allowed at all for subprograms
5083 if Is_Subprogram
(E
) then
5084 Error_Pragma_Arg
("local subprogram& cannot be exported", Arg
);
5086 -- Otherwise set public and statically allocated
5090 Set_Is_Statically_Allocated
(E
);
5092 -- Warn if the corresponding W flag is set and the pragma comes
5093 -- from source. The latter may not be true e.g. on VMS where we
5094 -- expand export pragmas for exception codes associated with
5095 -- imported or exported exceptions. We do not want to generate
5096 -- a warning for something that the user did not write.
5098 if Warn_On_Export_Import
5099 and then Comes_From_Source
(Arg
)
5102 ("?& has been made static as a result of Export", Arg
, E
);
5104 ("\this usage is non-standard and non-portable", Arg
);
5109 if Warn_On_Export_Import
and then Is_Type
(E
) then
5110 Error_Msg_NE
("exporting a type has no effect?", Arg
, E
);
5113 if Warn_On_Export_Import
and Inside_A_Generic
then
5115 ("all instances of& will have the same external name?", Arg
, E
);
5119 ----------------------------------------------
5120 -- Set_Extended_Import_Export_External_Name --
5121 ----------------------------------------------
5123 procedure Set_Extended_Import_Export_External_Name
5124 (Internal_Ent
: Entity_Id
;
5125 Arg_External
: Node_Id
)
5127 Old_Name
: constant Node_Id
:= Interface_Name
(Internal_Ent
);
5131 if No
(Arg_External
) then
5135 Check_Arg_Is_External_Name
(Arg_External
);
5137 if Nkind
(Arg_External
) = N_String_Literal
then
5138 if String_Length
(Strval
(Arg_External
)) = 0 then
5141 New_Name
:= Adjust_External_Name_Case
(Arg_External
);
5144 elsif Nkind
(Arg_External
) = N_Identifier
then
5145 New_Name
:= Get_Default_External_Name
(Arg_External
);
5147 -- Check_Arg_Is_External_Name should let through only identifiers and
5148 -- string literals or static string expressions (which are folded to
5149 -- string literals).
5152 raise Program_Error
;
5155 -- If we already have an external name set (by a prior normal Import
5156 -- or Export pragma), then the external names must match
5158 if Present
(Interface_Name
(Internal_Ent
)) then
5159 Check_Matching_Internal_Names
: declare
5160 S1
: constant String_Id
:= Strval
(Old_Name
);
5161 S2
: constant String_Id
:= Strval
(New_Name
);
5164 -- Called if names do not match
5170 procedure Mismatch
is
5172 Error_Msg_Sloc
:= Sloc
(Old_Name
);
5174 ("external name does not match that given #",
5178 -- Start of processing for Check_Matching_Internal_Names
5181 if String_Length
(S1
) /= String_Length
(S2
) then
5185 for J
in 1 .. String_Length
(S1
) loop
5186 if Get_String_Char
(S1
, J
) /= Get_String_Char
(S2
, J
) then
5191 end Check_Matching_Internal_Names
;
5193 -- Otherwise set the given name
5196 Set_Encoded_Interface_Name
(Internal_Ent
, New_Name
);
5197 Check_Duplicated_Export_Name
(New_Name
);
5199 end Set_Extended_Import_Export_External_Name
;
5205 procedure Set_Imported
(E
: Entity_Id
) is
5207 -- Error message if already imported or exported
5209 if Is_Exported
(E
) or else Is_Imported
(E
) then
5211 -- Error if being set Exported twice
5213 if Is_Exported
(E
) then
5214 Error_Msg_NE
("entity& was previously exported", N
, E
);
5216 -- OK if Import/Interface case
5218 elsif Import_Interface_Present
(N
) then
5221 -- Error if being set Imported twice
5224 Error_Msg_NE
("entity& was previously imported", N
, E
);
5227 Error_Msg_Name_1
:= Pname
;
5229 ("\(pragma% applies to all previous entities)", N
);
5231 Error_Msg_Sloc
:= Sloc
(E
);
5232 Error_Msg_NE
("\import not allowed for& declared#", N
, E
);
5234 -- Here if not previously imported or exported, OK to import
5237 Set_Is_Imported
(E
);
5239 -- If the entity is an object that is not at the library level,
5240 -- then it is statically allocated. We do not worry about objects
5241 -- with address clauses in this context since they are not really
5242 -- imported in the linker sense.
5245 and then not Is_Library_Level_Entity
(E
)
5246 and then No
(Address_Clause
(E
))
5248 Set_Is_Statically_Allocated
(E
);
5255 -------------------------
5256 -- Set_Mechanism_Value --
5257 -------------------------
5259 -- Note: the mechanism name has not been analyzed (and cannot indeed be
5260 -- analyzed, since it is semantic nonsense), so we get it in the exact
5261 -- form created by the parser.
5263 procedure Set_Mechanism_Value
(Ent
: Entity_Id
; Mech_Name
: Node_Id
) is
5266 Mech_Name_Id
: Name_Id
;
5268 procedure Bad_Class
;
5269 -- Signal bad descriptor class name
5271 procedure Bad_Mechanism
;
5272 -- Signal bad mechanism name
5278 procedure Bad_Class
is
5280 Error_Pragma_Arg
("unrecognized descriptor class name", Class
);
5283 -------------------------
5284 -- Bad_Mechanism_Value --
5285 -------------------------
5287 procedure Bad_Mechanism
is
5289 Error_Pragma_Arg
("unrecognized mechanism name", Mech_Name
);
5292 -- Start of processing for Set_Mechanism_Value
5295 if Mechanism
(Ent
) /= Default_Mechanism
then
5297 ("mechanism for & has already been set", Mech_Name
, Ent
);
5300 -- MECHANISM_NAME ::= value | reference | descriptor |
5303 if Nkind
(Mech_Name
) = N_Identifier
then
5304 if Chars
(Mech_Name
) = Name_Value
then
5305 Set_Mechanism
(Ent
, By_Copy
);
5308 elsif Chars
(Mech_Name
) = Name_Reference
then
5309 Set_Mechanism
(Ent
, By_Reference
);
5312 elsif Chars
(Mech_Name
) = Name_Descriptor
then
5313 Check_VMS
(Mech_Name
);
5315 -- Descriptor => Short_Descriptor if pragma was given
5317 if Short_Descriptors
then
5318 Set_Mechanism
(Ent
, By_Short_Descriptor
);
5320 Set_Mechanism
(Ent
, By_Descriptor
);
5325 elsif Chars
(Mech_Name
) = Name_Short_Descriptor
then
5326 Check_VMS
(Mech_Name
);
5327 Set_Mechanism
(Ent
, By_Short_Descriptor
);
5330 elsif Chars
(Mech_Name
) = Name_Copy
then
5332 ("bad mechanism name, Value assumed", Mech_Name
);
5338 -- MECHANISM_NAME ::= descriptor (CLASS_NAME) |
5339 -- short_descriptor (CLASS_NAME)
5340 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
5342 -- Note: this form is parsed as an indexed component
5344 elsif Nkind
(Mech_Name
) = N_Indexed_Component
then
5345 Class
:= First
(Expressions
(Mech_Name
));
5347 if Nkind
(Prefix
(Mech_Name
)) /= N_Identifier
5348 or else not (Chars
(Prefix
(Mech_Name
)) = Name_Descriptor
or else
5349 Chars
(Prefix
(Mech_Name
)) = Name_Short_Descriptor
)
5350 or else Present
(Next
(Class
))
5354 Mech_Name_Id
:= Chars
(Prefix
(Mech_Name
));
5356 -- Change Descriptor => Short_Descriptor if pragma was given
5358 if Mech_Name_Id
= Name_Descriptor
5359 and then Short_Descriptors
5361 Mech_Name_Id
:= Name_Short_Descriptor
;
5365 -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME) |
5366 -- short_descriptor (Class => CLASS_NAME)
5367 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
5369 -- Note: this form is parsed as a function call
5371 elsif Nkind
(Mech_Name
) = N_Function_Call
then
5372 Param
:= First
(Parameter_Associations
(Mech_Name
));
5374 if Nkind
(Name
(Mech_Name
)) /= N_Identifier
5375 or else not (Chars
(Name
(Mech_Name
)) = Name_Descriptor
or else
5376 Chars
(Name
(Mech_Name
)) = Name_Short_Descriptor
)
5377 or else Present
(Next
(Param
))
5378 or else No
(Selector_Name
(Param
))
5379 or else Chars
(Selector_Name
(Param
)) /= Name_Class
5383 Class
:= Explicit_Actual_Parameter
(Param
);
5384 Mech_Name_Id
:= Chars
(Name
(Mech_Name
));
5391 -- Fall through here with Class set to descriptor class name
5393 Check_VMS
(Mech_Name
);
5395 if Nkind
(Class
) /= N_Identifier
then
5398 elsif Mech_Name_Id
= Name_Descriptor
5399 and then Chars
(Class
) = Name_UBS
5401 Set_Mechanism
(Ent
, By_Descriptor_UBS
);
5403 elsif Mech_Name_Id
= Name_Descriptor
5404 and then Chars
(Class
) = Name_UBSB
5406 Set_Mechanism
(Ent
, By_Descriptor_UBSB
);
5408 elsif Mech_Name_Id
= Name_Descriptor
5409 and then Chars
(Class
) = Name_UBA
5411 Set_Mechanism
(Ent
, By_Descriptor_UBA
);
5413 elsif Mech_Name_Id
= Name_Descriptor
5414 and then Chars
(Class
) = Name_S
5416 Set_Mechanism
(Ent
, By_Descriptor_S
);
5418 elsif Mech_Name_Id
= Name_Descriptor
5419 and then Chars
(Class
) = Name_SB
5421 Set_Mechanism
(Ent
, By_Descriptor_SB
);
5423 elsif Mech_Name_Id
= Name_Descriptor
5424 and then Chars
(Class
) = Name_A
5426 Set_Mechanism
(Ent
, By_Descriptor_A
);
5428 elsif Mech_Name_Id
= Name_Descriptor
5429 and then Chars
(Class
) = Name_NCA
5431 Set_Mechanism
(Ent
, By_Descriptor_NCA
);
5433 elsif Mech_Name_Id
= Name_Short_Descriptor
5434 and then Chars
(Class
) = Name_UBS
5436 Set_Mechanism
(Ent
, By_Short_Descriptor_UBS
);
5438 elsif Mech_Name_Id
= Name_Short_Descriptor
5439 and then Chars
(Class
) = Name_UBSB
5441 Set_Mechanism
(Ent
, By_Short_Descriptor_UBSB
);
5443 elsif Mech_Name_Id
= Name_Short_Descriptor
5444 and then Chars
(Class
) = Name_UBA
5446 Set_Mechanism
(Ent
, By_Short_Descriptor_UBA
);
5448 elsif Mech_Name_Id
= Name_Short_Descriptor
5449 and then Chars
(Class
) = Name_S
5451 Set_Mechanism
(Ent
, By_Short_Descriptor_S
);
5453 elsif Mech_Name_Id
= Name_Short_Descriptor
5454 and then Chars
(Class
) = Name_SB
5456 Set_Mechanism
(Ent
, By_Short_Descriptor_SB
);
5458 elsif Mech_Name_Id
= Name_Short_Descriptor
5459 and then Chars
(Class
) = Name_A
5461 Set_Mechanism
(Ent
, By_Short_Descriptor_A
);
5463 elsif Mech_Name_Id
= Name_Short_Descriptor
5464 and then Chars
(Class
) = Name_NCA
5466 Set_Mechanism
(Ent
, By_Short_Descriptor_NCA
);
5471 end Set_Mechanism_Value
;
5473 ---------------------------
5474 -- Set_Ravenscar_Profile --
5475 ---------------------------
5477 -- The tasks to be done here are
5479 -- Set required policies
5481 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
5482 -- pragma Locking_Policy (Ceiling_Locking)
5484 -- Set Detect_Blocking mode
5486 -- Set required restrictions (see System.Rident for detailed list)
5488 -- Set the No_Dependence rules
5489 -- No_Dependence => Ada.Asynchronous_Task_Control
5490 -- No_Dependence => Ada.Calendar
5491 -- No_Dependence => Ada.Execution_Time.Group_Budget
5492 -- No_Dependence => Ada.Execution_Time.Timers
5493 -- No_Dependence => Ada.Task_Attributes
5494 -- No_Dependence => System.Multiprocessors.Dispatching_Domains
5496 procedure Set_Ravenscar_Profile
(N
: Node_Id
) is
5497 Prefix_Entity
: Entity_Id
;
5498 Selector_Entity
: Entity_Id
;
5499 Prefix_Node
: Node_Id
;
5503 -- pragma Task_Dispatching_Policy (FIFO_Within_Priorities)
5505 if Task_Dispatching_Policy
/= ' '
5506 and then Task_Dispatching_Policy
/= 'F'
5508 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
5509 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
5511 -- Set the FIFO_Within_Priorities policy, but always preserve
5512 -- System_Location since we like the error message with the run time
5516 Task_Dispatching_Policy
:= 'F';
5518 if Task_Dispatching_Policy_Sloc
/= System_Location
then
5519 Task_Dispatching_Policy_Sloc
:= Loc
;
5523 -- pragma Locking_Policy (Ceiling_Locking)
5525 if Locking_Policy
/= ' '
5526 and then Locking_Policy
/= 'C'
5528 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
5529 Error_Pragma
("Profile (Ravenscar) incompatible with policy#");
5531 -- Set the Ceiling_Locking policy, but preserve System_Location since
5532 -- we like the error message with the run time name.
5535 Locking_Policy
:= 'C';
5537 if Locking_Policy_Sloc
/= System_Location
then
5538 Locking_Policy_Sloc
:= Loc
;
5542 -- pragma Detect_Blocking
5544 Detect_Blocking
:= True;
5546 -- Set the corresponding restrictions
5548 Set_Profile_Restrictions
5549 (Ravenscar
, N
, Warn
=> Treat_Restrictions_As_Warnings
);
5551 -- Set the No_Dependence restrictions
5553 -- The following No_Dependence restrictions:
5554 -- No_Dependence => Ada.Asynchronous_Task_Control
5555 -- No_Dependence => Ada.Calendar
5556 -- No_Dependence => Ada.Task_Attributes
5557 -- are already set by previous call to Set_Profile_Restrictions.
5559 -- Set the following restrictions which were added to Ada 2005:
5560 -- No_Dependence => Ada.Execution_Time.Group_Budget
5561 -- No_Dependence => Ada.Execution_Time.Timers
5563 if Ada_Version
>= Ada_2005
then
5564 Name_Buffer
(1 .. 3) := "ada";
5567 Prefix_Entity
:= Make_Identifier
(Loc
, Name_Find
);
5569 Name_Buffer
(1 .. 14) := "execution_time";
5572 Selector_Entity
:= Make_Identifier
(Loc
, Name_Find
);
5575 Make_Selected_Component
5577 Prefix
=> Prefix_Entity
,
5578 Selector_Name
=> Selector_Entity
);
5580 Name_Buffer
(1 .. 13) := "group_budgets";
5583 Selector_Entity
:= Make_Identifier
(Loc
, Name_Find
);
5586 Make_Selected_Component
5588 Prefix
=> Prefix_Node
,
5589 Selector_Name
=> Selector_Entity
);
5591 Set_Restriction_No_Dependence
5593 Warn
=> Treat_Restrictions_As_Warnings
,
5594 Profile
=> Ravenscar
);
5596 Name_Buffer
(1 .. 6) := "timers";
5599 Selector_Entity
:= Make_Identifier
(Loc
, Name_Find
);
5602 Make_Selected_Component
5604 Prefix
=> Prefix_Node
,
5605 Selector_Name
=> Selector_Entity
);
5607 Set_Restriction_No_Dependence
5609 Warn
=> Treat_Restrictions_As_Warnings
,
5610 Profile
=> Ravenscar
);
5613 -- Set the following restrictions which was added to Ada 2012 (see
5615 -- No_Dependence => System.Multiprocessors.Dispatching_Domains
5617 if Ada_Version
>= Ada_2012
then
5618 Name_Buffer
(1 .. 6) := "system";
5621 Prefix_Entity
:= Make_Identifier
(Loc
, Name_Find
);
5623 Name_Buffer
(1 .. 15) := "multiprocessors";
5626 Selector_Entity
:= Make_Identifier
(Loc
, Name_Find
);
5629 Make_Selected_Component
5631 Prefix
=> Prefix_Entity
,
5632 Selector_Name
=> Selector_Entity
);
5634 Name_Buffer
(1 .. 19) := "dispatching_domains";
5637 Selector_Entity
:= Make_Identifier
(Loc
, Name_Find
);
5640 Make_Selected_Component
5642 Prefix
=> Prefix_Node
,
5643 Selector_Name
=> Selector_Entity
);
5645 Set_Restriction_No_Dependence
5647 Warn
=> Treat_Restrictions_As_Warnings
,
5648 Profile
=> Ravenscar
);
5650 end Set_Ravenscar_Profile
;
5652 -- Start of processing for Analyze_Pragma
5655 -- Deal with unrecognized pragma
5657 if not Is_Pragma_Name
(Pname
) then
5658 if Warn_On_Unrecognized_Pragma
then
5659 Error_Msg_Name_1
:= Pname
;
5660 Error_Msg_N
("?unrecognized pragma%!", Pragma_Identifier
(N
));
5662 for PN
in First_Pragma_Name
.. Last_Pragma_Name
loop
5663 if Is_Bad_Spelling_Of
(Pname
, PN
) then
5664 Error_Msg_Name_1
:= PN
;
5665 Error_Msg_N
-- CODEFIX
5666 ("\?possible misspelling of %!", Pragma_Identifier
(N
));
5675 -- Here to start processing for recognized pragma
5677 Prag_Id
:= Get_Pragma_Id
(Pname
);
5686 if Present
(Pragma_Argument_Associations
(N
)) then
5687 Arg1
:= First
(Pragma_Argument_Associations
(N
));
5689 if Present
(Arg1
) then
5690 Arg2
:= Next
(Arg1
);
5692 if Present
(Arg2
) then
5693 Arg3
:= Next
(Arg2
);
5695 if Present
(Arg3
) then
5696 Arg4
:= Next
(Arg3
);
5702 -- Count number of arguments
5709 while Present
(Arg_Node
) loop
5710 Arg_Count
:= Arg_Count
+ 1;
5715 -- An enumeration type defines the pragmas that are supported by the
5716 -- implementation. Get_Pragma_Id (in package Prag) transforms a name
5717 -- into the corresponding enumeration value for the following case.
5725 -- pragma Abort_Defer;
5727 when Pragma_Abort_Defer
=>
5729 Check_Arg_Count
(0);
5731 -- The only required semantic processing is to check the
5732 -- placement. This pragma must appear at the start of the
5733 -- statement sequence of a handled sequence of statements.
5735 if Nkind
(Parent
(N
)) /= N_Handled_Sequence_Of_Statements
5736 or else N
/= First
(Statements
(Parent
(N
)))
5747 -- Note: this pragma also has some specific processing in Par.Prag
5748 -- because we want to set the Ada version mode during parsing.
5750 when Pragma_Ada_83
=>
5752 Check_Arg_Count
(0);
5754 -- We really should check unconditionally for proper configuration
5755 -- pragma placement, since we really don't want mixed Ada modes
5756 -- within a single unit, and the GNAT reference manual has always
5757 -- said this was a configuration pragma, but we did not check and
5758 -- are hesitant to add the check now.
5760 -- However, we really cannot tolerate mixing Ada 2005 or Ada 2012
5761 -- with Ada 83 or Ada 95, so we must check if we are in Ada 2005
5762 -- or Ada 2012 mode.
5764 if Ada_Version
>= Ada_2005
then
5765 Check_Valid_Configuration_Pragma
;
5768 -- Now set Ada 83 mode
5770 Ada_Version
:= Ada_83
;
5771 Ada_Version_Explicit
:= Ada_Version
;
5779 -- Note: this pragma also has some specific processing in Par.Prag
5780 -- because we want to set the Ada 83 version mode during parsing.
5782 when Pragma_Ada_95
=>
5784 Check_Arg_Count
(0);
5786 -- We really should check unconditionally for proper configuration
5787 -- pragma placement, since we really don't want mixed Ada modes
5788 -- within a single unit, and the GNAT reference manual has always
5789 -- said this was a configuration pragma, but we did not check and
5790 -- are hesitant to add the check now.
5792 -- However, we really cannot tolerate mixing Ada 2005 with Ada 83
5793 -- or Ada 95, so we must check if we are in Ada 2005 mode.
5795 if Ada_Version
>= Ada_2005
then
5796 Check_Valid_Configuration_Pragma
;
5799 -- Now set Ada 95 mode
5801 Ada_Version
:= Ada_95
;
5802 Ada_Version_Explicit
:= Ada_Version
;
5804 ---------------------
5805 -- Ada_05/Ada_2005 --
5806 ---------------------
5809 -- pragma Ada_05 (LOCAL_NAME);
5812 -- pragma Ada_2005 (LOCAL_NAME):
5814 -- Note: these pragmas also have some specific processing in Par.Prag
5815 -- because we want to set the Ada 2005 version mode during parsing.
5817 when Pragma_Ada_05 | Pragma_Ada_2005
=> declare
5823 if Arg_Count
= 1 then
5824 Check_Arg_Is_Local_Name
(Arg1
);
5825 E_Id
:= Get_Pragma_Arg
(Arg1
);
5827 if Etype
(E_Id
) = Any_Type
then
5831 Set_Is_Ada_2005_Only
(Entity
(E_Id
));
5834 Check_Arg_Count
(0);
5836 -- For Ada_2005 we unconditionally enforce the documented
5837 -- configuration pragma placement, since we do not want to
5838 -- tolerate mixed modes in a unit involving Ada 2005. That
5839 -- would cause real difficulties for those cases where there
5840 -- are incompatibilities between Ada 95 and Ada 2005.
5842 Check_Valid_Configuration_Pragma
;
5844 -- Now set appropriate Ada mode
5847 Ada_Version
:= Ada_2005
;
5849 Ada_Version
:= Ada_Version_Default
;
5852 Ada_Version_Explicit
:= Ada_2005
;
5856 ---------------------
5857 -- Ada_12/Ada_2012 --
5858 ---------------------
5861 -- pragma Ada_12 (LOCAL_NAME);
5864 -- pragma Ada_2012 (LOCAL_NAME):
5866 -- Note: these pragmas also have some specific processing in Par.Prag
5867 -- because we want to set the Ada 2012 version mode during parsing.
5869 when Pragma_Ada_12 | Pragma_Ada_2012
=> declare
5875 if Arg_Count
= 1 then
5876 Check_Arg_Is_Local_Name
(Arg1
);
5877 E_Id
:= Get_Pragma_Arg
(Arg1
);
5879 if Etype
(E_Id
) = Any_Type
then
5883 Set_Is_Ada_2012_Only
(Entity
(E_Id
));
5886 Check_Arg_Count
(0);
5888 -- For Ada_2012 we unconditionally enforce the documented
5889 -- configuration pragma placement, since we do not want to
5890 -- tolerate mixed modes in a unit involving Ada 2012. That
5891 -- would cause real difficulties for those cases where there
5892 -- are incompatibilities between Ada 95 and Ada 2012. We could
5893 -- allow mixing of Ada 2005 and Ada 2012 but it's not worth it.
5895 Check_Valid_Configuration_Pragma
;
5897 -- Now set appropriate Ada mode
5900 Ada_Version
:= Ada_2012
;
5902 Ada_Version
:= Ada_Version_Default
;
5905 Ada_Version_Explicit
:= Ada_2012
;
5909 ----------------------
5910 -- All_Calls_Remote --
5911 ----------------------
5913 -- pragma All_Calls_Remote [(library_package_NAME)];
5915 when Pragma_All_Calls_Remote
=> All_Calls_Remote
: declare
5916 Lib_Entity
: Entity_Id
;
5919 Check_Ada_83_Warning
;
5920 Check_Valid_Library_Unit_Pragma
;
5922 if Nkind
(N
) = N_Null_Statement
then
5926 Lib_Entity
:= Find_Lib_Unit_Name
;
5928 -- This pragma should only apply to a RCI unit (RM E.2.3(23))
5930 if Present
(Lib_Entity
)
5931 and then not Debug_Flag_U
5933 if not Is_Remote_Call_Interface
(Lib_Entity
) then
5934 Error_Pragma
("pragma% only apply to rci unit");
5936 -- Set flag for entity of the library unit
5939 Set_Has_All_Calls_Remote
(Lib_Entity
);
5943 end All_Calls_Remote
;
5949 -- pragma Annotate (IDENTIFIER [, IDENTIFIER {, ARG}]);
5950 -- ARG ::= NAME | EXPRESSION
5952 -- The first two arguments are by convention intended to refer to an
5953 -- external tool and a tool-specific function. These arguments are
5956 when Pragma_Annotate
=> Annotate
: begin
5958 Check_At_Least_N_Arguments
(1);
5959 Check_Arg_Is_Identifier
(Arg1
);
5960 Check_No_Identifiers
;
5968 -- Second unanalyzed parameter is optional
5974 while Present
(Arg
) loop
5975 Exp
:= Get_Pragma_Arg
(Arg
);
5978 if Is_Entity_Name
(Exp
) then
5981 -- For string literals, we assume Standard_String as the
5982 -- type, unless the string contains wide or wide_wide
5985 elsif Nkind
(Exp
) = N_String_Literal
then
5986 if Has_Wide_Wide_Character
(Exp
) then
5987 Resolve
(Exp
, Standard_Wide_Wide_String
);
5988 elsif Has_Wide_Character
(Exp
) then
5989 Resolve
(Exp
, Standard_Wide_String
);
5991 Resolve
(Exp
, Standard_String
);
5994 elsif Is_Overloaded
(Exp
) then
5996 ("ambiguous argument for pragma%", Exp
);
6012 -- pragma Assert ([Check =>] Boolean_EXPRESSION
6013 -- [, [Message =>] Static_String_EXPRESSION]);
6015 when Pragma_Assert
=> Assert
: declare
6021 Check_At_Least_N_Arguments
(1);
6022 Check_At_Most_N_Arguments
(2);
6023 Check_Arg_Order
((Name_Check
, Name_Message
));
6024 Check_Optional_Identifier
(Arg1
, Name_Check
);
6026 -- We treat pragma Assert as equivalent to:
6028 -- pragma Check (Assertion, condition [, msg]);
6030 -- So rewrite pragma in this manner, and analyze the result
6032 Expr
:= Get_Pragma_Arg
(Arg1
);
6034 Make_Pragma_Argument_Association
(Loc
,
6035 Expression
=> Make_Identifier
(Loc
, Name_Assertion
)),
6037 Make_Pragma_Argument_Association
(Sloc
(Expr
),
6038 Expression
=> Expr
));
6040 if Arg_Count
> 1 then
6041 Check_Optional_Identifier
(Arg2
, Name_Message
);
6042 Analyze_And_Resolve
(Get_Pragma_Arg
(Arg2
), Standard_String
);
6043 Append_To
(Newa
, Relocate_Node
(Arg2
));
6048 Chars
=> Name_Check
,
6049 Pragma_Argument_Associations
=> Newa
));
6053 ----------------------
6054 -- Assertion_Policy --
6055 ----------------------
6057 -- pragma Assertion_Policy (Check | Ignore)
6059 when Pragma_Assertion_Policy
=> Assertion_Policy
: declare
6064 Check_Valid_Configuration_Pragma
;
6065 Check_Arg_Count
(1);
6066 Check_No_Identifiers
;
6067 Check_Arg_Is_One_Of
(Arg1
, Name_Check
, Name_Ignore
);
6069 -- We treat pragma Assertion_Policy as equivalent to:
6071 -- pragma Check_Policy (Assertion, policy)
6073 -- So rewrite the pragma in that manner and link on to the chain
6074 -- of Check_Policy pragmas, marking the pragma as analyzed.
6076 Policy
:= Get_Pragma_Arg
(Arg1
);
6080 Chars
=> Name_Check_Policy
,
6082 Pragma_Argument_Associations
=> New_List
(
6083 Make_Pragma_Argument_Association
(Loc
,
6084 Expression
=> Make_Identifier
(Loc
, Name_Assertion
)),
6086 Make_Pragma_Argument_Association
(Loc
,
6088 Make_Identifier
(Sloc
(Policy
), Chars
(Policy
))))));
6091 Set_Next_Pragma
(N
, Opt
.Check_Policy_List
);
6092 Opt
.Check_Policy_List
:= N
;
6093 end Assertion_Policy
;
6095 ------------------------------
6096 -- Assume_No_Invalid_Values --
6097 ------------------------------
6099 -- pragma Assume_No_Invalid_Values (On | Off);
6101 when Pragma_Assume_No_Invalid_Values
=>
6103 Check_Valid_Configuration_Pragma
;
6104 Check_Arg_Count
(1);
6105 Check_No_Identifiers
;
6106 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
6108 if Chars
(Get_Pragma_Arg
(Arg1
)) = Name_On
then
6109 Assume_No_Invalid_Values
:= True;
6111 Assume_No_Invalid_Values
:= False;
6118 -- pragma AST_Entry (entry_IDENTIFIER);
6120 when Pragma_AST_Entry
=> AST_Entry
: declare
6126 Check_Arg_Count
(1);
6127 Check_No_Identifiers
;
6128 Check_Arg_Is_Local_Name
(Arg1
);
6129 Ent
:= Entity
(Get_Pragma_Arg
(Arg1
));
6131 -- Note: the implementation of the AST_Entry pragma could handle
6132 -- the entry family case fine, but for now we are consistent with
6133 -- the DEC rules, and do not allow the pragma, which of course
6134 -- has the effect of also forbidding the attribute.
6136 if Ekind
(Ent
) /= E_Entry
then
6138 ("pragma% argument must be simple entry name", Arg1
);
6140 elsif Is_AST_Entry
(Ent
) then
6142 ("duplicate % pragma for entry", Arg1
);
6144 elsif Has_Homonym
(Ent
) then
6146 ("pragma% argument cannot specify overloaded entry", Arg1
);
6150 FF
: constant Entity_Id
:= First_Formal
(Ent
);
6153 if Present
(FF
) then
6154 if Present
(Next_Formal
(FF
)) then
6156 ("entry for pragma% can have only one argument",
6159 elsif Parameter_Mode
(FF
) /= E_In_Parameter
then
6161 ("entry parameter for pragma% must have mode IN",
6167 Set_Is_AST_Entry
(Ent
);
6175 -- pragma Asynchronous (LOCAL_NAME);
6177 when Pragma_Asynchronous
=> Asynchronous
: declare
6185 procedure Process_Async_Pragma
;
6186 -- Common processing for procedure and access-to-procedure case
6188 --------------------------
6189 -- Process_Async_Pragma --
6190 --------------------------
6192 procedure Process_Async_Pragma
is
6195 Set_Is_Asynchronous
(Nm
);
6199 -- The formals should be of mode IN (RM E.4.1(6))
6202 while Present
(S
) loop
6203 Formal
:= Defining_Identifier
(S
);
6205 if Nkind
(Formal
) = N_Defining_Identifier
6206 and then Ekind
(Formal
) /= E_In_Parameter
6209 ("pragma% procedure can only have IN parameter",
6216 Set_Is_Asynchronous
(Nm
);
6217 end Process_Async_Pragma
;
6219 -- Start of processing for pragma Asynchronous
6222 Check_Ada_83_Warning
;
6223 Check_No_Identifiers
;
6224 Check_Arg_Count
(1);
6225 Check_Arg_Is_Local_Name
(Arg1
);
6227 if Debug_Flag_U
then
6231 C_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
6232 Analyze
(Get_Pragma_Arg
(Arg1
));
6233 Nm
:= Entity
(Get_Pragma_Arg
(Arg1
));
6235 if not Is_Remote_Call_Interface
(C_Ent
)
6236 and then not Is_Remote_Types
(C_Ent
)
6238 -- This pragma should only appear in an RCI or Remote Types
6239 -- unit (RM E.4.1(4)).
6242 ("pragma% not in Remote_Call_Interface or " &
6243 "Remote_Types unit");
6246 if Ekind
(Nm
) = E_Procedure
6247 and then Nkind
(Parent
(Nm
)) = N_Procedure_Specification
6249 if not Is_Remote_Call_Interface
(Nm
) then
6251 ("pragma% cannot be applied on non-remote procedure",
6255 L
:= Parameter_Specifications
(Parent
(Nm
));
6256 Process_Async_Pragma
;
6259 elsif Ekind
(Nm
) = E_Function
then
6261 ("pragma% cannot be applied to function", Arg1
);
6263 elsif Is_Remote_Access_To_Subprogram_Type
(Nm
) then
6265 if Is_Record_Type
(Nm
) then
6267 -- A record type that is the Equivalent_Type for a remote
6268 -- access-to-subprogram type.
6270 N
:= Declaration_Node
(Corresponding_Remote_Type
(Nm
));
6273 -- A non-expanded RAS type (distribution is not enabled)
6275 N
:= Declaration_Node
(Nm
);
6278 if Nkind
(N
) = N_Full_Type_Declaration
6279 and then Nkind
(Type_Definition
(N
)) =
6280 N_Access_Procedure_Definition
6282 L
:= Parameter_Specifications
(Type_Definition
(N
));
6283 Process_Async_Pragma
;
6285 if Is_Asynchronous
(Nm
)
6286 and then Expander_Active
6287 and then Get_PCS_Name
/= Name_No_DSA
6289 RACW_Type_Is_Asynchronous
(Underlying_RACW_Type
(Nm
));
6294 ("pragma% cannot reference access-to-function type",
6298 -- Only other possibility is Access-to-class-wide type
6300 elsif Is_Access_Type
(Nm
)
6301 and then Is_Class_Wide_Type
(Designated_Type
(Nm
))
6303 Check_First_Subtype
(Arg1
);
6304 Set_Is_Asynchronous
(Nm
);
6305 if Expander_Active
then
6306 RACW_Type_Is_Asynchronous
(Nm
);
6310 Error_Pragma_Arg
("inappropriate argument for pragma%", Arg1
);
6318 -- pragma Atomic (LOCAL_NAME);
6320 when Pragma_Atomic
=>
6321 Process_Atomic_Shared_Volatile
;
6323 -----------------------
6324 -- Atomic_Components --
6325 -----------------------
6327 -- pragma Atomic_Components (array_LOCAL_NAME);
6329 -- This processing is shared by Volatile_Components
6331 when Pragma_Atomic_Components |
6332 Pragma_Volatile_Components
=>
6334 Atomic_Components
: declare
6341 Check_Ada_83_Warning
;
6342 Check_No_Identifiers
;
6343 Check_Arg_Count
(1);
6344 Check_Arg_Is_Local_Name
(Arg1
);
6345 E_Id
:= Get_Pragma_Arg
(Arg1
);
6347 if Etype
(E_Id
) = Any_Type
then
6353 Check_Duplicate_Pragma
(E
);
6355 if Rep_Item_Too_Early
(E
, N
)
6357 Rep_Item_Too_Late
(E
, N
)
6362 D
:= Declaration_Node
(E
);
6365 if (K
= N_Full_Type_Declaration
and then Is_Array_Type
(E
))
6367 ((Ekind
(E
) = E_Constant
or else Ekind
(E
) = E_Variable
)
6368 and then Nkind
(D
) = N_Object_Declaration
6369 and then Nkind
(Object_Definition
(D
)) =
6370 N_Constrained_Array_Definition
)
6372 -- The flag is set on the object, or on the base type
6374 if Nkind
(D
) /= N_Object_Declaration
then
6378 Set_Has_Volatile_Components
(E
, Sense
);
6380 if Prag_Id
= Pragma_Atomic_Components
then
6381 Set_Has_Atomic_Components
(E
, Sense
);
6385 Error_Pragma_Arg
("inappropriate entity for pragma%", Arg1
);
6387 end Atomic_Components
;
6389 --------------------
6390 -- Attach_Handler --
6391 --------------------
6393 -- pragma Attach_Handler (handler_NAME, EXPRESSION);
6395 when Pragma_Attach_Handler
=>
6396 Check_Ada_83_Warning
;
6397 Check_No_Identifiers
;
6398 Check_Arg_Count
(2);
6400 if No_Run_Time_Mode
then
6401 Error_Msg_CRT
("Attach_Handler pragma", N
);
6403 Check_Interrupt_Or_Attach_Handler
;
6405 -- The expression that designates the attribute may depend on a
6406 -- discriminant, and is therefore a per- object expression, to
6407 -- be expanded in the init proc. If expansion is enabled, then
6408 -- perform semantic checks on a copy only.
6410 if Expander_Active
then
6412 Temp
: constant Node_Id
:=
6413 New_Copy_Tree
(Get_Pragma_Arg
(Arg2
));
6415 Set_Parent
(Temp
, N
);
6416 Preanalyze_And_Resolve
(Temp
, RTE
(RE_Interrupt_ID
));
6420 Analyze
(Get_Pragma_Arg
(Arg2
));
6421 Resolve
(Get_Pragma_Arg
(Arg2
), RTE
(RE_Interrupt_ID
));
6424 Process_Interrupt_Or_Attach_Handler
;
6427 --------------------
6428 -- C_Pass_By_Copy --
6429 --------------------
6431 -- pragma C_Pass_By_Copy ([Max_Size =>] static_integer_EXPRESSION);
6433 when Pragma_C_Pass_By_Copy
=> C_Pass_By_Copy
: declare
6439 Check_Valid_Configuration_Pragma
;
6440 Check_Arg_Count
(1);
6441 Check_Optional_Identifier
(Arg1
, "max_size");
6443 Arg
:= Get_Pragma_Arg
(Arg1
);
6444 Check_Arg_Is_Static_Expression
(Arg
, Any_Integer
);
6446 Val
:= Expr_Value
(Arg
);
6450 ("maximum size for pragma% must be positive", Arg1
);
6452 elsif UI_Is_In_Int_Range
(Val
) then
6453 Default_C_Record_Mechanism
:= UI_To_Int
(Val
);
6455 -- If a giant value is given, Int'Last will do well enough.
6456 -- If sometime someone complains that a record larger than
6457 -- two gigabytes is not copied, we will worry about it then!
6460 Default_C_Record_Mechanism
:= Mechanism_Type
'Last;
6468 -- pragma Check ([Name =>] Identifier,
6469 -- [Check =>] Boolean_Expression
6470 -- [,[Message =>] String_Expression]);
6472 when Pragma_Check
=> Check
: declare
6477 -- Set True if category of assertions referenced by Name enabled
6481 Check_At_Least_N_Arguments
(2);
6482 Check_At_Most_N_Arguments
(3);
6483 Check_Optional_Identifier
(Arg1
, Name_Name
);
6484 Check_Optional_Identifier
(Arg2
, Name_Check
);
6486 if Arg_Count
= 3 then
6487 Check_Optional_Identifier
(Arg3
, Name_Message
);
6488 Analyze_And_Resolve
(Get_Pragma_Arg
(Arg3
), Standard_String
);
6491 Check_Arg_Is_Identifier
(Arg1
);
6493 -- Indicate if pragma is enabled. The Original_Node reference here
6494 -- is to deal with pragma Assert rewritten as a Check pragma.
6496 Check_On
:= Check_Enabled
(Chars
(Get_Pragma_Arg
(Arg1
)));
6499 Set_Pragma_Enabled
(N
);
6500 Set_Pragma_Enabled
(Original_Node
(N
));
6501 Set_SCO_Pragma_Enabled
(Loc
);
6504 -- If expansion is active and the check is not enabled then we
6505 -- rewrite the Check as:
6507 -- if False and then condition then
6511 -- The reason we do this rewriting during semantic analysis rather
6512 -- than as part of normal expansion is that we cannot analyze and
6513 -- expand the code for the boolean expression directly, or it may
6514 -- cause insertion of actions that would escape the attempt to
6515 -- suppress the check code.
6517 -- Note that the Sloc for the if statement corresponds to the
6518 -- argument condition, not the pragma itself. The reason for this
6519 -- is that we may generate a warning if the condition is False at
6520 -- compile time, and we do not want to delete this warning when we
6521 -- delete the if statement.
6523 Expr
:= Get_Pragma_Arg
(Arg2
);
6525 if Expander_Active
and then not Check_On
then
6526 Eloc
:= Sloc
(Expr
);
6529 Make_If_Statement
(Eloc
,
6531 Make_And_Then
(Eloc
,
6532 Left_Opnd
=> New_Occurrence_Of
(Standard_False
, Eloc
),
6533 Right_Opnd
=> Expr
),
6534 Then_Statements
=> New_List
(
6535 Make_Null_Statement
(Eloc
))));
6542 Analyze_And_Resolve
(Expr
, Any_Boolean
);
6550 -- pragma Check_Name (check_IDENTIFIER);
6552 when Pragma_Check_Name
=>
6553 Check_No_Identifiers
;
6555 Check_Valid_Configuration_Pragma
;
6556 Check_Arg_Count
(1);
6557 Check_Arg_Is_Identifier
(Arg1
);
6560 Nam
: constant Name_Id
:= Chars
(Get_Pragma_Arg
(Arg1
));
6563 for J
in Check_Names
.First
.. Check_Names
.Last
loop
6564 if Check_Names
.Table
(J
) = Nam
then
6569 Check_Names
.Append
(Nam
);
6576 -- pragma Check_Policy (
6577 -- [Name =>] IDENTIFIER,
6578 -- [Policy =>] POLICY_IDENTIFIER);
6580 -- POLICY_IDENTIFIER ::= ON | OFF | CHECK | IGNORE
6582 -- Note: this is a configuration pragma, but it is allowed to appear
6585 when Pragma_Check_Policy
=>
6587 Check_Arg_Count
(2);
6588 Check_Optional_Identifier
(Arg1
, Name_Name
);
6589 Check_Optional_Identifier
(Arg2
, Name_Policy
);
6591 (Arg2
, Name_On
, Name_Off
, Name_Check
, Name_Ignore
);
6593 -- A Check_Policy pragma can appear either as a configuration
6594 -- pragma, or in a declarative part or a package spec (see RM
6595 -- 11.5(5) for rules for Suppress/Unsuppress which are also
6596 -- followed for Check_Policy).
6598 if not Is_Configuration_Pragma
then
6599 Check_Is_In_Decl_Part_Or_Package_Spec
;
6602 Set_Next_Pragma
(N
, Opt
.Check_Policy_List
);
6603 Opt
.Check_Policy_List
:= N
;
6605 ---------------------
6606 -- CIL_Constructor --
6607 ---------------------
6609 -- pragma CIL_Constructor ([Entity =>] LOCAL_NAME);
6611 -- Processing for this pragma is shared with Java_Constructor
6617 -- pragma Comment (static_string_EXPRESSION)
6619 -- Processing for pragma Comment shares the circuitry for pragma
6620 -- Ident. The only differences are that Ident enforces a limit of 31
6621 -- characters on its argument, and also enforces limitations on
6622 -- placement for DEC compatibility. Pragma Comment shares neither of
6623 -- these restrictions.
6629 -- pragma Common_Object (
6630 -- [Internal =>] LOCAL_NAME
6631 -- [, [External =>] EXTERNAL_SYMBOL]
6632 -- [, [Size =>] EXTERNAL_SYMBOL]);
6634 -- Processing for this pragma is shared with Psect_Object
6636 ------------------------
6637 -- Compile_Time_Error --
6638 ------------------------
6640 -- pragma Compile_Time_Error
6641 -- (boolean_EXPRESSION, static_string_EXPRESSION);
6643 when Pragma_Compile_Time_Error
=>
6645 Process_Compile_Time_Warning_Or_Error
;
6647 --------------------------
6648 -- Compile_Time_Warning --
6649 --------------------------
6651 -- pragma Compile_Time_Warning
6652 -- (boolean_EXPRESSION, static_string_EXPRESSION);
6654 when Pragma_Compile_Time_Warning
=>
6656 Process_Compile_Time_Warning_Or_Error
;
6662 when Pragma_Compiler_Unit
=>
6664 Check_Arg_Count
(0);
6665 Set_Is_Compiler_Unit
(Get_Source_Unit
(N
));
6667 -----------------------------
6668 -- Complete_Representation --
6669 -----------------------------
6671 -- pragma Complete_Representation;
6673 when Pragma_Complete_Representation
=>
6675 Check_Arg_Count
(0);
6677 if Nkind
(Parent
(N
)) /= N_Record_Representation_Clause
then
6679 ("pragma & must appear within record representation clause");
6682 ----------------------------
6683 -- Complex_Representation --
6684 ----------------------------
6686 -- pragma Complex_Representation ([Entity =>] LOCAL_NAME);
6688 when Pragma_Complex_Representation
=> Complex_Representation
: declare
6695 Check_Arg_Count
(1);
6696 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6697 Check_Arg_Is_Local_Name
(Arg1
);
6698 E_Id
:= Get_Pragma_Arg
(Arg1
);
6700 if Etype
(E_Id
) = Any_Type
then
6706 if not Is_Record_Type
(E
) then
6708 ("argument for pragma% must be record type", Arg1
);
6711 Ent
:= First_Entity
(E
);
6714 or else No
(Next_Entity
(Ent
))
6715 or else Present
(Next_Entity
(Next_Entity
(Ent
)))
6716 or else not Is_Floating_Point_Type
(Etype
(Ent
))
6717 or else Etype
(Ent
) /= Etype
(Next_Entity
(Ent
))
6720 ("record for pragma% must have two fields of the same "
6721 & "floating-point type", Arg1
);
6724 Set_Has_Complex_Representation
(Base_Type
(E
));
6726 -- We need to treat the type has having a non-standard
6727 -- representation, for back-end purposes, even though in
6728 -- general a complex will have the default representation
6729 -- of a record with two real components.
6731 Set_Has_Non_Standard_Rep
(Base_Type
(E
));
6733 end Complex_Representation
;
6735 -------------------------
6736 -- Component_Alignment --
6737 -------------------------
6739 -- pragma Component_Alignment (
6740 -- [Form =>] ALIGNMENT_CHOICE
6741 -- [, [Name =>] type_LOCAL_NAME]);
6743 -- ALIGNMENT_CHOICE ::=
6745 -- | Component_Size_4
6749 when Pragma_Component_Alignment
=> Component_AlignmentP
: declare
6750 Args
: Args_List
(1 .. 2);
6751 Names
: constant Name_List
(1 .. 2) := (
6755 Form
: Node_Id
renames Args
(1);
6756 Name
: Node_Id
renames Args
(2);
6758 Atype
: Component_Alignment_Kind
;
6763 Gather_Associations
(Names
, Args
);
6766 Error_Pragma
("missing Form argument for pragma%");
6769 Check_Arg_Is_Identifier
(Form
);
6771 -- Get proper alignment, note that Default = Component_Size on all
6772 -- machines we have so far, and we want to set this value rather
6773 -- than the default value to indicate that it has been explicitly
6774 -- set (and thus will not get overridden by the default component
6775 -- alignment for the current scope)
6777 if Chars
(Form
) = Name_Component_Size
then
6778 Atype
:= Calign_Component_Size
;
6780 elsif Chars
(Form
) = Name_Component_Size_4
then
6781 Atype
:= Calign_Component_Size_4
;
6783 elsif Chars
(Form
) = Name_Default
then
6784 Atype
:= Calign_Component_Size
;
6786 elsif Chars
(Form
) = Name_Storage_Unit
then
6787 Atype
:= Calign_Storage_Unit
;
6791 ("invalid Form parameter for pragma%", Form
);
6794 -- Case with no name, supplied, affects scope table entry
6798 (Scope_Stack
.Last
).Component_Alignment_Default
:= Atype
;
6800 -- Case of name supplied
6803 Check_Arg_Is_Local_Name
(Name
);
6805 Typ
:= Entity
(Name
);
6808 or else Rep_Item_Too_Early
(Typ
, N
)
6812 Typ
:= Underlying_Type
(Typ
);
6815 if not Is_Record_Type
(Typ
)
6816 and then not Is_Array_Type
(Typ
)
6819 ("Name parameter of pragma% must identify record or " &
6820 "array type", Name
);
6823 -- An explicit Component_Alignment pragma overrides an
6824 -- implicit pragma Pack, but not an explicit one.
6826 if not Has_Pragma_Pack
(Base_Type
(Typ
)) then
6827 Set_Is_Packed
(Base_Type
(Typ
), False);
6828 Set_Component_Alignment
(Base_Type
(Typ
), Atype
);
6831 end Component_AlignmentP
;
6837 -- pragma Controlled (first_subtype_LOCAL_NAME);
6839 when Pragma_Controlled
=> Controlled
: declare
6843 Check_No_Identifiers
;
6844 Check_Arg_Count
(1);
6845 Check_Arg_Is_Local_Name
(Arg1
);
6846 Arg
:= Get_Pragma_Arg
(Arg1
);
6848 if not Is_Entity_Name
(Arg
)
6849 or else not Is_Access_Type
(Entity
(Arg
))
6851 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
6853 Set_Has_Pragma_Controlled
(Base_Type
(Entity
(Arg
)));
6861 -- pragma Convention ([Convention =>] convention_IDENTIFIER,
6862 -- [Entity =>] LOCAL_NAME);
6864 when Pragma_Convention
=> Convention
: declare
6867 pragma Warnings
(Off
, C
);
6868 pragma Warnings
(Off
, E
);
6870 Check_Arg_Order
((Name_Convention
, Name_Entity
));
6871 Check_Ada_83_Warning
;
6872 Check_Arg_Count
(2);
6873 Process_Convention
(C
, E
);
6876 ---------------------------
6877 -- Convention_Identifier --
6878 ---------------------------
6880 -- pragma Convention_Identifier ([Name =>] IDENTIFIER,
6881 -- [Convention =>] convention_IDENTIFIER);
6883 when Pragma_Convention_Identifier
=> Convention_Identifier
: declare
6889 Check_Arg_Order
((Name_Name
, Name_Convention
));
6890 Check_Arg_Count
(2);
6891 Check_Optional_Identifier
(Arg1
, Name_Name
);
6892 Check_Optional_Identifier
(Arg2
, Name_Convention
);
6893 Check_Arg_Is_Identifier
(Arg1
);
6894 Check_Arg_Is_Identifier
(Arg2
);
6895 Idnam
:= Chars
(Get_Pragma_Arg
(Arg1
));
6896 Cname
:= Chars
(Get_Pragma_Arg
(Arg2
));
6898 if Is_Convention_Name
(Cname
) then
6899 Record_Convention_Identifier
6900 (Idnam
, Get_Convention_Id
(Cname
));
6903 ("second arg for % pragma must be convention", Arg2
);
6905 end Convention_Identifier
;
6911 -- pragma CPP_Class ([Entity =>] local_NAME)
6913 when Pragma_CPP_Class
=> CPP_Class
: declare
6918 if Warn_On_Obsolescent_Feature
then
6920 ("'G'N'A'T pragma cpp'_class is now obsolete; replace it" &
6921 " by pragma import?", N
);
6925 Check_Arg_Count
(1);
6926 Check_Optional_Identifier
(Arg1
, Name_Entity
);
6927 Check_Arg_Is_Local_Name
(Arg1
);
6929 Arg
:= Get_Pragma_Arg
(Arg1
);
6932 if Etype
(Arg
) = Any_Type
then
6936 if not Is_Entity_Name
(Arg
)
6937 or else not Is_Type
(Entity
(Arg
))
6939 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
6942 Typ
:= Entity
(Arg
);
6944 if not Is_Tagged_Type
(Typ
) then
6945 Error_Pragma_Arg
("pragma% applicable to tagged types ", Arg1
);
6948 -- Types treated as CPP classes are treated as limited, but we
6949 -- don't require them to be declared this way. A warning is issued
6950 -- to encourage the user to declare them as limited. This is not
6951 -- an error, for compatibility reasons, because these types have
6952 -- been supported this way for some time.
6954 if not Is_Limited_Type
(Typ
) then
6956 ("imported 'C'P'P type should be " &
6957 "explicitly declared limited?",
6958 Get_Pragma_Arg
(Arg1
));
6960 ("\type will be considered limited",
6961 Get_Pragma_Arg
(Arg1
));
6964 Set_Is_CPP_Class
(Typ
);
6965 Set_Is_Limited_Record
(Typ
);
6966 Set_Convention
(Typ
, Convention_CPP
);
6968 -- Imported CPP types must not have discriminants (because C++
6969 -- classes do not have discriminants).
6971 if Has_Discriminants
(Typ
) then
6973 ("imported 'C'P'P type cannot have discriminants",
6974 First
(Discriminant_Specifications
6975 (Declaration_Node
(Typ
))));
6978 -- Components of imported CPP types must not have default
6979 -- expressions because the constructor (if any) is in the
6982 if Is_Incomplete_Or_Private_Type
(Typ
)
6983 and then No
(Underlying_Type
(Typ
))
6985 -- It should be an error to apply pragma CPP to a private
6986 -- type if the underlying type is not visible (as it is
6987 -- for any representation item). For now, for backward
6988 -- compatibility we do nothing but we cannot check components
6989 -- because they are not available at this stage. All this code
6990 -- will be removed when we cleanup this obsolete GNAT pragma???
6996 Tdef
: constant Node_Id
:=
6997 Type_Definition
(Declaration_Node
(Typ
));
7002 if Nkind
(Tdef
) = N_Record_Definition
then
7003 Clist
:= Component_List
(Tdef
);
7005 pragma Assert
(Nkind
(Tdef
) = N_Derived_Type_Definition
);
7006 Clist
:= Component_List
(Record_Extension_Part
(Tdef
));
7009 if Present
(Clist
) then
7010 Comp
:= First
(Component_Items
(Clist
));
7011 while Present
(Comp
) loop
7012 if Present
(Expression
(Comp
)) then
7014 ("component of imported 'C'P'P type cannot have" &
7015 " default expression", Expression
(Comp
));
7025 ---------------------
7026 -- CPP_Constructor --
7027 ---------------------
7029 -- pragma CPP_Constructor ([Entity =>] LOCAL_NAME
7030 -- [, [External_Name =>] static_string_EXPRESSION ]
7031 -- [, [Link_Name =>] static_string_EXPRESSION ]);
7033 when Pragma_CPP_Constructor
=> CPP_Constructor
: declare
7037 Tag_Typ
: Entity_Id
;
7041 Check_At_Least_N_Arguments
(1);
7042 Check_At_Most_N_Arguments
(3);
7043 Check_Optional_Identifier
(Arg1
, Name_Entity
);
7044 Check_Arg_Is_Local_Name
(Arg1
);
7046 Id
:= Get_Pragma_Arg
(Arg1
);
7047 Find_Program_Unit_Name
(Id
);
7049 -- If we did not find the name, we are done
7051 if Etype
(Id
) = Any_Type
then
7055 Def_Id
:= Entity
(Id
);
7057 -- Check if already defined as constructor
7059 if Is_Constructor
(Def_Id
) then
7061 ("?duplicate argument for pragma 'C'P'P_Constructor", Arg1
);
7065 if Ekind
(Def_Id
) = E_Function
7066 and then (Is_CPP_Class
(Etype
(Def_Id
))
7067 or else (Is_Class_Wide_Type
(Etype
(Def_Id
))
7069 Is_CPP_Class
(Root_Type
(Etype
(Def_Id
)))))
7071 if Arg_Count
>= 2 then
7072 Set_Imported
(Def_Id
);
7073 Set_Is_Public
(Def_Id
);
7074 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
7077 Set_Has_Completion
(Def_Id
);
7078 Set_Is_Constructor
(Def_Id
);
7080 -- Imported C++ constructors are not dispatching primitives
7081 -- because in C++ they don't have a dispatch table slot.
7082 -- However, in Ada the constructor has the profile of a
7083 -- function that returns a tagged type and therefore it has
7084 -- been treated as a primitive operation during semantic
7085 -- analysis. We now remove it from the list of primitive
7086 -- operations of the type.
7088 if Is_Tagged_Type
(Etype
(Def_Id
))
7089 and then not Is_Class_Wide_Type
(Etype
(Def_Id
))
7091 pragma Assert
(Is_Dispatching_Operation
(Def_Id
));
7092 Tag_Typ
:= Etype
(Def_Id
);
7094 Elmt
:= First_Elmt
(Primitive_Operations
(Tag_Typ
));
7095 while Present
(Elmt
) and then Node
(Elmt
) /= Def_Id
loop
7099 Remove_Elmt
(Primitive_Operations
(Tag_Typ
), Elmt
);
7100 Set_Is_Dispatching_Operation
(Def_Id
, False);
7103 -- For backward compatibility, if the constructor returns a
7104 -- class wide type, and we internally change the return type to
7105 -- the corresponding root type.
7107 if Is_Class_Wide_Type
(Etype
(Def_Id
)) then
7108 Set_Etype
(Def_Id
, Root_Type
(Etype
(Def_Id
)));
7112 ("pragma% requires function returning a 'C'P'P_Class type",
7115 end CPP_Constructor
;
7121 when Pragma_CPP_Virtual
=> CPP_Virtual
: declare
7125 if Warn_On_Obsolescent_Feature
then
7127 ("'G'N'A'T pragma cpp'_virtual is now obsolete and has " &
7136 when Pragma_CPP_Vtable
=> CPP_Vtable
: declare
7140 if Warn_On_Obsolescent_Feature
then
7142 ("'G'N'A'T pragma cpp'_vtable is now obsolete and has " &
7151 -- pragma CPU (EXPRESSION);
7153 when Pragma_CPU
=> CPU
: declare
7154 P
: constant Node_Id
:= Parent
(N
);
7159 Check_No_Identifiers
;
7160 Check_Arg_Count
(1);
7164 if Nkind
(P
) = N_Subprogram_Body
then
7165 Check_In_Main_Program
;
7167 Arg
:= Get_Pragma_Arg
(Arg1
);
7168 Analyze_And_Resolve
(Arg
, Any_Integer
);
7172 if not Is_Static_Expression
(Arg
) then
7173 Flag_Non_Static_Expr
7174 ("main subprogram affinity is not static!", Arg
);
7177 -- If constraint error, then we already signalled an error
7179 elsif Raises_Constraint_Error
(Arg
) then
7182 -- Otherwise check in range
7186 CPU_Id
: constant Entity_Id
:= RTE
(RE_CPU_Range
);
7187 -- This is the entity System.Multiprocessors.CPU_Range;
7189 Val
: constant Uint
:= Expr_Value
(Arg
);
7192 if Val
< Expr_Value
(Type_Low_Bound
(CPU_Id
))
7194 Val
> Expr_Value
(Type_High_Bound
(CPU_Id
))
7197 ("main subprogram CPU is out of range", Arg1
);
7203 (Current_Sem_Unit
, UI_To_Int
(Expr_Value
(Arg
)));
7207 elsif Nkind
(P
) = N_Task_Definition
then
7208 Arg
:= Get_Pragma_Arg
(Arg1
);
7210 -- The expression must be analyzed in the special manner
7211 -- described in "Handling of Default and Per-Object
7212 -- Expressions" in sem.ads.
7214 Preanalyze_Spec_Expression
(Arg
, RTE
(RE_CPU_Range
));
7216 -- Anything else is incorrect
7222 if Has_Pragma_CPU
(P
) then
7223 Error_Pragma
("duplicate pragma% not allowed");
7225 Set_Has_Pragma_CPU
(P
, True);
7227 if Nkind
(P
) = N_Task_Definition
then
7228 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
7237 -- pragma Debug ([boolean_EXPRESSION,] PROCEDURE_CALL_STATEMENT);
7239 when Pragma_Debug
=> Debug
: declare
7247 (Boolean_Literals
(Debug_Pragmas_Enabled
and Expander_Active
),
7250 if Arg_Count
= 2 then
7253 Left_Opnd
=> Relocate_Node
(Cond
),
7254 Right_Opnd
=> Get_Pragma_Arg
(Arg1
));
7257 -- Rewrite into a conditional with an appropriate condition. We
7258 -- wrap the procedure call in a block so that overhead from e.g.
7259 -- use of the secondary stack does not generate execution overhead
7260 -- for suppressed conditions.
7262 Rewrite
(N
, Make_Implicit_If_Statement
(N
,
7264 Then_Statements
=> New_List
(
7265 Make_Block_Statement
(Loc
,
7266 Handled_Statement_Sequence
=>
7267 Make_Handled_Sequence_Of_Statements
(Loc
,
7268 Statements
=> New_List
(
7269 Relocate_Node
(Debug_Statement
(N
))))))));
7277 -- pragma Debug_Policy (Check | Ignore)
7279 when Pragma_Debug_Policy
=>
7281 Check_Arg_Count
(1);
7282 Check_Arg_Is_One_Of
(Arg1
, Name_Check
, Name_Ignore
);
7283 Debug_Pragmas_Enabled
:=
7284 Chars
(Get_Pragma_Arg
(Arg1
)) = Name_Check
;
7286 ---------------------
7287 -- Detect_Blocking --
7288 ---------------------
7290 -- pragma Detect_Blocking;
7292 when Pragma_Detect_Blocking
=>
7294 Check_Arg_Count
(0);
7295 Check_Valid_Configuration_Pragma
;
7296 Detect_Blocking
:= True;
7298 --------------------------
7299 -- Default_Storage_Pool --
7300 --------------------------
7302 -- pragma Default_Storage_Pool (storage_pool_NAME | null);
7304 when Pragma_Default_Storage_Pool
=>
7306 Check_Arg_Count
(1);
7308 -- Default_Storage_Pool can appear as a configuration pragma, or
7309 -- in a declarative part or a package spec.
7311 if not Is_Configuration_Pragma
then
7312 Check_Is_In_Decl_Part_Or_Package_Spec
;
7315 -- Case of Default_Storage_Pool (null);
7317 if Nkind
(Expression
(Arg1
)) = N_Null
then
7318 Analyze
(Expression
(Arg1
));
7320 -- This is an odd case, this is not really an expression, so
7321 -- we don't have a type for it. So just set the type to Empty.
7323 Set_Etype
(Expression
(Arg1
), Empty
);
7325 -- Case of Default_Storage_Pool (storage_pool_NAME);
7328 -- If it's a configuration pragma, then the only allowed
7329 -- argument is "null".
7331 if Is_Configuration_Pragma
then
7332 Error_Pragma_Arg
("NULL expected", Arg1
);
7335 -- The expected type for a non-"null" argument is
7336 -- Root_Storage_Pool'Class.
7339 (Get_Pragma_Arg
(Arg1
),
7340 Typ
=> Class_Wide_Type
(RTE
(RE_Root_Storage_Pool
)));
7343 -- Finally, record the pool name (or null). Freeze.Freeze_Entity
7344 -- for an access type will use this information to set the
7345 -- appropriate attributes of the access type.
7347 Default_Pool
:= Expression
(Arg1
);
7353 when Pragma_Dimension
=>
7355 Check_Arg_Count
(4);
7356 Check_No_Identifiers
;
7357 Check_Arg_Is_Local_Name
(Arg1
);
7359 if not Is_Type
(Arg1
) then
7360 Error_Pragma
("first argument for pragma% must be subtype");
7363 Check_Arg_Is_Static_Expression
(Arg2
, Standard_Integer
);
7364 Check_Arg_Is_Static_Expression
(Arg3
, Standard_Integer
);
7365 Check_Arg_Is_Static_Expression
(Arg4
, Standard_Integer
);
7371 -- pragma Discard_Names [([On =>] LOCAL_NAME)];
7373 when Pragma_Discard_Names
=> Discard_Names
: declare
7378 Check_Ada_83_Warning
;
7380 -- Deal with configuration pragma case
7382 if Arg_Count
= 0 and then Is_Configuration_Pragma
then
7383 Global_Discard_Names
:= True;
7386 -- Otherwise, check correct appropriate context
7389 Check_Is_In_Decl_Part_Or_Package_Spec
;
7391 if Arg_Count
= 0 then
7393 -- If there is no parameter, then from now on this pragma
7394 -- applies to any enumeration, exception or tagged type
7395 -- defined in the current declarative part, and recursively
7396 -- to any nested scope.
7398 Set_Discard_Names
(Current_Scope
, Sense
);
7402 Check_Arg_Count
(1);
7403 Check_Optional_Identifier
(Arg1
, Name_On
);
7404 Check_Arg_Is_Local_Name
(Arg1
);
7406 E_Id
:= Get_Pragma_Arg
(Arg1
);
7408 if Etype
(E_Id
) = Any_Type
then
7414 if (Is_First_Subtype
(E
)
7416 (Is_Enumeration_Type
(E
) or else Is_Tagged_Type
(E
)))
7417 or else Ekind
(E
) = E_Exception
7419 Set_Discard_Names
(E
, Sense
);
7422 ("inappropriate entity for pragma%", Arg1
);
7433 -- pragma Elaborate (library_unit_NAME {, library_unit_NAME});
7435 when Pragma_Elaborate
=> Elaborate
: declare
7440 -- Pragma must be in context items list of a compilation unit
7442 if not Is_In_Context_Clause
then
7446 -- Must be at least one argument
7448 if Arg_Count
= 0 then
7449 Error_Pragma
("pragma% requires at least one argument");
7452 -- In Ada 83 mode, there can be no items following it in the
7453 -- context list except other pragmas and implicit with clauses
7454 -- (e.g. those added by use of Rtsfind). In Ada 95 mode, this
7455 -- placement rule does not apply.
7457 if Ada_Version
= Ada_83
and then Comes_From_Source
(N
) then
7459 while Present
(Citem
) loop
7460 if Nkind
(Citem
) = N_Pragma
7461 or else (Nkind
(Citem
) = N_With_Clause
7462 and then Implicit_With
(Citem
))
7467 ("(Ada 83) pragma% must be at end of context clause");
7474 -- Finally, the arguments must all be units mentioned in a with
7475 -- clause in the same context clause. Note we already checked (in
7476 -- Par.Prag) that the arguments are all identifiers or selected
7480 Outer
: while Present
(Arg
) loop
7481 Citem
:= First
(List_Containing
(N
));
7482 Inner
: while Citem
/= N
loop
7483 if Nkind
(Citem
) = N_With_Clause
7484 and then Same_Name
(Name
(Citem
), Get_Pragma_Arg
(Arg
))
7486 Set_Elaborate_Present
(Citem
, True);
7487 Set_Unit_Name
(Get_Pragma_Arg
(Arg
), Name
(Citem
));
7489 -- With the pragma present, elaboration calls on
7490 -- subprograms from the named unit need no further
7491 -- checks, as long as the pragma appears in the current
7492 -- compilation unit. If the pragma appears in some unit
7493 -- in the context, there might still be a need for an
7494 -- Elaborate_All_Desirable from the current compilation
7495 -- to the named unit, so we keep the check enabled.
7497 if In_Extended_Main_Source_Unit
(N
) then
7498 Set_Suppress_Elaboration_Warnings
7499 (Entity
(Name
(Citem
)));
7510 ("argument of pragma% is not with'ed unit", Arg
);
7516 -- Give a warning if operating in static mode with -gnatwl
7517 -- (elaboration warnings enabled) switch set.
7519 if Elab_Warnings
and not Dynamic_Elaboration_Checks
then
7521 ("?use of pragma Elaborate may not be safe", N
);
7523 ("?use pragma Elaborate_All instead if possible", N
);
7531 -- pragma Elaborate_All (library_unit_NAME {, library_unit_NAME});
7533 when Pragma_Elaborate_All
=> Elaborate_All
: declare
7538 Check_Ada_83_Warning
;
7540 -- Pragma must be in context items list of a compilation unit
7542 if not Is_In_Context_Clause
then
7546 -- Must be at least one argument
7548 if Arg_Count
= 0 then
7549 Error_Pragma
("pragma% requires at least one argument");
7552 -- Note: unlike pragma Elaborate, pragma Elaborate_All does not
7553 -- have to appear at the end of the context clause, but may
7554 -- appear mixed in with other items, even in Ada 83 mode.
7556 -- Final check: the arguments must all be units mentioned in
7557 -- a with clause in the same context clause. Note that we
7558 -- already checked (in Par.Prag) that all the arguments are
7559 -- either identifiers or selected components.
7562 Outr
: while Present
(Arg
) loop
7563 Citem
:= First
(List_Containing
(N
));
7564 Innr
: while Citem
/= N
loop
7565 if Nkind
(Citem
) = N_With_Clause
7566 and then Same_Name
(Name
(Citem
), Get_Pragma_Arg
(Arg
))
7568 Set_Elaborate_All_Present
(Citem
, True);
7569 Set_Unit_Name
(Get_Pragma_Arg
(Arg
), Name
(Citem
));
7571 -- Suppress warnings and elaboration checks on the named
7572 -- unit if the pragma is in the current compilation, as
7573 -- for pragma Elaborate.
7575 if In_Extended_Main_Source_Unit
(N
) then
7576 Set_Suppress_Elaboration_Warnings
7577 (Entity
(Name
(Citem
)));
7586 Set_Error_Posted
(N
);
7588 ("argument of pragma% is not with'ed unit", Arg
);
7595 --------------------
7596 -- Elaborate_Body --
7597 --------------------
7599 -- pragma Elaborate_Body [( library_unit_NAME )];
7601 when Pragma_Elaborate_Body
=> Elaborate_Body
: declare
7602 Cunit_Node
: Node_Id
;
7603 Cunit_Ent
: Entity_Id
;
7606 Check_Ada_83_Warning
;
7607 Check_Valid_Library_Unit_Pragma
;
7609 if Nkind
(N
) = N_Null_Statement
then
7613 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
7614 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
7616 if Nkind_In
(Unit
(Cunit_Node
), N_Package_Body
,
7619 Error_Pragma
("pragma% must refer to a spec, not a body");
7621 Set_Body_Required
(Cunit_Node
, True);
7622 Set_Has_Pragma_Elaborate_Body
(Cunit_Ent
);
7624 -- If we are in dynamic elaboration mode, then we suppress
7625 -- elaboration warnings for the unit, since it is definitely
7626 -- fine NOT to do dynamic checks at the first level (and such
7627 -- checks will be suppressed because no elaboration boolean
7628 -- is created for Elaborate_Body packages).
7630 -- But in the static model of elaboration, Elaborate_Body is
7631 -- definitely NOT good enough to ensure elaboration safety on
7632 -- its own, since the body may WITH other units that are not
7633 -- safe from an elaboration point of view, so a client must
7634 -- still do an Elaborate_All on such units.
7636 -- Debug flag -gnatdD restores the old behavior of 3.13, where
7637 -- Elaborate_Body always suppressed elab warnings.
7639 if Dynamic_Elaboration_Checks
or Debug_Flag_DD
then
7640 Set_Suppress_Elaboration_Warnings
(Cunit_Ent
);
7645 ------------------------
7646 -- Elaboration_Checks --
7647 ------------------------
7649 -- pragma Elaboration_Checks (Static | Dynamic);
7651 when Pragma_Elaboration_Checks
=>
7653 Check_Arg_Count
(1);
7654 Check_Arg_Is_One_Of
(Arg1
, Name_Static
, Name_Dynamic
);
7655 Dynamic_Elaboration_Checks
:=
7656 (Chars
(Get_Pragma_Arg
(Arg1
)) = Name_Dynamic
);
7662 -- pragma Eliminate (
7663 -- [Unit_Name =>] IDENTIFIER | SELECTED_COMPONENT,
7664 -- [,[Entity =>] IDENTIFIER |
7665 -- SELECTED_COMPONENT |
7667 -- [, OVERLOADING_RESOLUTION]);
7669 -- OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
7672 -- PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
7675 -- PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
7677 -- FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
7678 -- Result_Type => result_SUBTYPE_NAME]
7680 -- PARAMETER_TYPES ::= (SUBTYPE_NAME {, SUBTYPE_NAME})
7681 -- SUBTYPE_NAME ::= STRING_LITERAL
7683 -- SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
7684 -- SOURCE_TRACE ::= STRING_LITERAL
7686 when Pragma_Eliminate
=> Eliminate
: declare
7687 Args
: Args_List
(1 .. 5);
7688 Names
: constant Name_List
(1 .. 5) := (
7691 Name_Parameter_Types
,
7693 Name_Source_Location
);
7695 Unit_Name
: Node_Id
renames Args
(1);
7696 Entity
: Node_Id
renames Args
(2);
7697 Parameter_Types
: Node_Id
renames Args
(3);
7698 Result_Type
: Node_Id
renames Args
(4);
7699 Source_Location
: Node_Id
renames Args
(5);
7703 Check_Valid_Configuration_Pragma
;
7704 Gather_Associations
(Names
, Args
);
7706 if No
(Unit_Name
) then
7707 Error_Pragma
("missing Unit_Name argument for pragma%");
7711 and then (Present
(Parameter_Types
)
7713 Present
(Result_Type
)
7715 Present
(Source_Location
))
7717 Error_Pragma
("missing Entity argument for pragma%");
7720 if (Present
(Parameter_Types
)
7722 Present
(Result_Type
))
7724 Present
(Source_Location
)
7727 ("parameter profile and source location cannot " &
7728 "be used together in pragma%");
7731 Process_Eliminate_Pragma
7745 -- [ Convention =>] convention_IDENTIFIER,
7746 -- [ Entity =>] local_NAME
7747 -- [, [External_Name =>] static_string_EXPRESSION ]
7748 -- [, [Link_Name =>] static_string_EXPRESSION ]);
7750 when Pragma_Export
=> Export
: declare
7754 pragma Warnings
(Off
, C
);
7757 Check_Ada_83_Warning
;
7763 Check_At_Least_N_Arguments
(2);
7764 Check_At_Most_N_Arguments
(4);
7765 Process_Convention
(C
, Def_Id
);
7767 if Ekind
(Def_Id
) /= E_Constant
then
7768 Note_Possible_Modification
7769 (Get_Pragma_Arg
(Arg2
), Sure
=> False);
7772 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
7773 Set_Exported
(Def_Id
, Arg2
);
7775 -- If the entity is a deferred constant, propagate the information
7776 -- to the full view, because gigi elaborates the full view only.
7778 if Ekind
(Def_Id
) = E_Constant
7779 and then Present
(Full_View
(Def_Id
))
7782 Id2
: constant Entity_Id
:= Full_View
(Def_Id
);
7784 Set_Is_Exported
(Id2
, Is_Exported
(Def_Id
));
7785 Set_First_Rep_Item
(Id2
, First_Rep_Item
(Def_Id
));
7786 Set_Interface_Name
(Id2
, Einfo
.Interface_Name
(Def_Id
));
7791 ----------------------
7792 -- Export_Exception --
7793 ----------------------
7795 -- pragma Export_Exception (
7796 -- [Internal =>] LOCAL_NAME
7797 -- [, [External =>] EXTERNAL_SYMBOL]
7798 -- [, [Form =>] Ada | VMS]
7799 -- [, [Code =>] static_integer_EXPRESSION]);
7801 when Pragma_Export_Exception
=> Export_Exception
: declare
7802 Args
: Args_List
(1 .. 4);
7803 Names
: constant Name_List
(1 .. 4) := (
7809 Internal
: Node_Id
renames Args
(1);
7810 External
: Node_Id
renames Args
(2);
7811 Form
: Node_Id
renames Args
(3);
7812 Code
: Node_Id
renames Args
(4);
7817 if Inside_A_Generic
then
7818 Error_Pragma
("pragma% cannot be used for generic entities");
7821 Gather_Associations
(Names
, Args
);
7822 Process_Extended_Import_Export_Exception_Pragma
(
7823 Arg_Internal
=> Internal
,
7824 Arg_External
=> External
,
7828 if not Is_VMS_Exception
(Entity
(Internal
)) then
7829 Set_Exported
(Entity
(Internal
), Internal
);
7831 end Export_Exception
;
7833 ---------------------
7834 -- Export_Function --
7835 ---------------------
7837 -- pragma Export_Function (
7838 -- [Internal =>] LOCAL_NAME
7839 -- [, [External =>] EXTERNAL_SYMBOL]
7840 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7841 -- [, [Result_Type =>] TYPE_DESIGNATOR]
7842 -- [, [Mechanism =>] MECHANISM]
7843 -- [, [Result_Mechanism =>] MECHANISM_NAME]);
7845 -- EXTERNAL_SYMBOL ::=
7847 -- | static_string_EXPRESSION
7849 -- PARAMETER_TYPES ::=
7851 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7853 -- TYPE_DESIGNATOR ::=
7855 -- | subtype_Name ' Access
7859 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7861 -- MECHANISM_ASSOCIATION ::=
7862 -- [formal_parameter_NAME =>] MECHANISM_NAME
7864 -- MECHANISM_NAME ::=
7867 -- | Descriptor [([Class =>] CLASS_NAME)]
7869 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7871 when Pragma_Export_Function
=> Export_Function
: declare
7872 Args
: Args_List
(1 .. 6);
7873 Names
: constant Name_List
(1 .. 6) := (
7876 Name_Parameter_Types
,
7879 Name_Result_Mechanism
);
7881 Internal
: Node_Id
renames Args
(1);
7882 External
: Node_Id
renames Args
(2);
7883 Parameter_Types
: Node_Id
renames Args
(3);
7884 Result_Type
: Node_Id
renames Args
(4);
7885 Mechanism
: Node_Id
renames Args
(5);
7886 Result_Mechanism
: Node_Id
renames Args
(6);
7890 Gather_Associations
(Names
, Args
);
7891 Process_Extended_Import_Export_Subprogram_Pragma
(
7892 Arg_Internal
=> Internal
,
7893 Arg_External
=> External
,
7894 Arg_Parameter_Types
=> Parameter_Types
,
7895 Arg_Result_Type
=> Result_Type
,
7896 Arg_Mechanism
=> Mechanism
,
7897 Arg_Result_Mechanism
=> Result_Mechanism
);
7898 end Export_Function
;
7904 -- pragma Export_Object (
7905 -- [Internal =>] LOCAL_NAME
7906 -- [, [External =>] EXTERNAL_SYMBOL]
7907 -- [, [Size =>] EXTERNAL_SYMBOL]);
7909 -- EXTERNAL_SYMBOL ::=
7911 -- | static_string_EXPRESSION
7913 -- PARAMETER_TYPES ::=
7915 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7917 -- TYPE_DESIGNATOR ::=
7919 -- | subtype_Name ' Access
7923 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7925 -- MECHANISM_ASSOCIATION ::=
7926 -- [formal_parameter_NAME =>] MECHANISM_NAME
7928 -- MECHANISM_NAME ::=
7931 -- | Descriptor [([Class =>] CLASS_NAME)]
7933 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7935 when Pragma_Export_Object
=> Export_Object
: declare
7936 Args
: Args_List
(1 .. 3);
7937 Names
: constant Name_List
(1 .. 3) := (
7942 Internal
: Node_Id
renames Args
(1);
7943 External
: Node_Id
renames Args
(2);
7944 Size
: Node_Id
renames Args
(3);
7948 Gather_Associations
(Names
, Args
);
7949 Process_Extended_Import_Export_Object_Pragma
(
7950 Arg_Internal
=> Internal
,
7951 Arg_External
=> External
,
7955 ----------------------
7956 -- Export_Procedure --
7957 ----------------------
7959 -- pragma Export_Procedure (
7960 -- [Internal =>] LOCAL_NAME
7961 -- [, [External =>] EXTERNAL_SYMBOL]
7962 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
7963 -- [, [Mechanism =>] MECHANISM]);
7965 -- EXTERNAL_SYMBOL ::=
7967 -- | static_string_EXPRESSION
7969 -- PARAMETER_TYPES ::=
7971 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
7973 -- TYPE_DESIGNATOR ::=
7975 -- | subtype_Name ' Access
7979 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
7981 -- MECHANISM_ASSOCIATION ::=
7982 -- [formal_parameter_NAME =>] MECHANISM_NAME
7984 -- MECHANISM_NAME ::=
7987 -- | Descriptor [([Class =>] CLASS_NAME)]
7989 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
7991 when Pragma_Export_Procedure
=> Export_Procedure
: declare
7992 Args
: Args_List
(1 .. 4);
7993 Names
: constant Name_List
(1 .. 4) := (
7996 Name_Parameter_Types
,
7999 Internal
: Node_Id
renames Args
(1);
8000 External
: Node_Id
renames Args
(2);
8001 Parameter_Types
: Node_Id
renames Args
(3);
8002 Mechanism
: Node_Id
renames Args
(4);
8006 Gather_Associations
(Names
, Args
);
8007 Process_Extended_Import_Export_Subprogram_Pragma
(
8008 Arg_Internal
=> Internal
,
8009 Arg_External
=> External
,
8010 Arg_Parameter_Types
=> Parameter_Types
,
8011 Arg_Mechanism
=> Mechanism
);
8012 end Export_Procedure
;
8018 -- pragma Export_Value (
8019 -- [Value =>] static_integer_EXPRESSION,
8020 -- [Link_Name =>] static_string_EXPRESSION);
8022 when Pragma_Export_Value
=>
8024 Check_Arg_Order
((Name_Value
, Name_Link_Name
));
8025 Check_Arg_Count
(2);
8027 Check_Optional_Identifier
(Arg1
, Name_Value
);
8028 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
8030 Check_Optional_Identifier
(Arg2
, Name_Link_Name
);
8031 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
8033 -----------------------------
8034 -- Export_Valued_Procedure --
8035 -----------------------------
8037 -- pragma Export_Valued_Procedure (
8038 -- [Internal =>] LOCAL_NAME
8039 -- [, [External =>] EXTERNAL_SYMBOL,]
8040 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
8041 -- [, [Mechanism =>] MECHANISM]);
8043 -- EXTERNAL_SYMBOL ::=
8045 -- | static_string_EXPRESSION
8047 -- PARAMETER_TYPES ::=
8049 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
8051 -- TYPE_DESIGNATOR ::=
8053 -- | subtype_Name ' Access
8057 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
8059 -- MECHANISM_ASSOCIATION ::=
8060 -- [formal_parameter_NAME =>] MECHANISM_NAME
8062 -- MECHANISM_NAME ::=
8065 -- | Descriptor [([Class =>] CLASS_NAME)]
8067 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
8069 when Pragma_Export_Valued_Procedure
=>
8070 Export_Valued_Procedure
: declare
8071 Args
: Args_List
(1 .. 4);
8072 Names
: constant Name_List
(1 .. 4) := (
8075 Name_Parameter_Types
,
8078 Internal
: Node_Id
renames Args
(1);
8079 External
: Node_Id
renames Args
(2);
8080 Parameter_Types
: Node_Id
renames Args
(3);
8081 Mechanism
: Node_Id
renames Args
(4);
8085 Gather_Associations
(Names
, Args
);
8086 Process_Extended_Import_Export_Subprogram_Pragma
(
8087 Arg_Internal
=> Internal
,
8088 Arg_External
=> External
,
8089 Arg_Parameter_Types
=> Parameter_Types
,
8090 Arg_Mechanism
=> Mechanism
);
8091 end Export_Valued_Procedure
;
8097 -- pragma Extend_System ([Name =>] Identifier);
8099 when Pragma_Extend_System
=> Extend_System
: declare
8102 Check_Valid_Configuration_Pragma
;
8103 Check_Arg_Count
(1);
8104 Check_Optional_Identifier
(Arg1
, Name_Name
);
8105 Check_Arg_Is_Identifier
(Arg1
);
8107 Get_Name_String
(Chars
(Get_Pragma_Arg
(Arg1
)));
8110 and then Name_Buffer
(1 .. 4) = "aux_"
8112 if Present
(System_Extend_Pragma_Arg
) then
8113 if Chars
(Get_Pragma_Arg
(Arg1
)) =
8114 Chars
(Expression
(System_Extend_Pragma_Arg
))
8118 Error_Msg_Sloc
:= Sloc
(System_Extend_Pragma_Arg
);
8119 Error_Pragma
("pragma% conflicts with that #");
8123 System_Extend_Pragma_Arg
:= Arg1
;
8125 if not GNAT_Mode
then
8126 System_Extend_Unit
:= Arg1
;
8130 Error_Pragma
("incorrect name for pragma%, must be Aux_xxx");
8134 ------------------------
8135 -- Extensions_Allowed --
8136 ------------------------
8138 -- pragma Extensions_Allowed (ON | OFF);
8140 when Pragma_Extensions_Allowed
=>
8142 Check_Arg_Count
(1);
8143 Check_No_Identifiers
;
8144 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
8146 if Chars
(Get_Pragma_Arg
(Arg1
)) = Name_On
then
8147 Extensions_Allowed
:= True;
8148 Ada_Version
:= Ada_Version_Type
'Last;
8151 Extensions_Allowed
:= False;
8152 Ada_Version
:= Ada_Version_Explicit
;
8159 -- pragma External (
8160 -- [ Convention =>] convention_IDENTIFIER,
8161 -- [ Entity =>] local_NAME
8162 -- [, [External_Name =>] static_string_EXPRESSION ]
8163 -- [, [Link_Name =>] static_string_EXPRESSION ]);
8165 when Pragma_External
=> External
: declare
8169 pragma Warnings
(Off
, C
);
8178 Check_At_Least_N_Arguments
(2);
8179 Check_At_Most_N_Arguments
(4);
8180 Process_Convention
(C
, Def_Id
);
8181 Note_Possible_Modification
8182 (Get_Pragma_Arg
(Arg2
), Sure
=> False);
8183 Process_Interface_Name
(Def_Id
, Arg3
, Arg4
);
8184 Set_Exported
(Def_Id
, Arg2
);
8187 --------------------------
8188 -- External_Name_Casing --
8189 --------------------------
8191 -- pragma External_Name_Casing (
8192 -- UPPERCASE | LOWERCASE
8193 -- [, AS_IS | UPPERCASE | LOWERCASE]);
8195 when Pragma_External_Name_Casing
=> External_Name_Casing
: declare
8198 Check_No_Identifiers
;
8200 if Arg_Count
= 2 then
8202 (Arg2
, Name_As_Is
, Name_Uppercase
, Name_Lowercase
);
8204 case Chars
(Get_Pragma_Arg
(Arg2
)) is
8206 Opt
.External_Name_Exp_Casing
:= As_Is
;
8208 when Name_Uppercase
=>
8209 Opt
.External_Name_Exp_Casing
:= Uppercase
;
8211 when Name_Lowercase
=>
8212 Opt
.External_Name_Exp_Casing
:= Lowercase
;
8219 Check_Arg_Count
(1);
8222 Check_Arg_Is_One_Of
(Arg1
, Name_Uppercase
, Name_Lowercase
);
8224 case Chars
(Get_Pragma_Arg
(Arg1
)) is
8225 when Name_Uppercase
=>
8226 Opt
.External_Name_Imp_Casing
:= Uppercase
;
8228 when Name_Lowercase
=>
8229 Opt
.External_Name_Imp_Casing
:= Lowercase
;
8234 end External_Name_Casing
;
8236 --------------------------
8237 -- Favor_Top_Level --
8238 --------------------------
8240 -- pragma Favor_Top_Level (type_NAME);
8242 when Pragma_Favor_Top_Level
=> Favor_Top_Level
: declare
8243 Named_Entity
: Entity_Id
;
8247 Check_No_Identifiers
;
8248 Check_Arg_Count
(1);
8249 Check_Arg_Is_Local_Name
(Arg1
);
8250 Named_Entity
:= Entity
(Get_Pragma_Arg
(Arg1
));
8252 -- If it's an access-to-subprogram type (in particular, not a
8253 -- subtype), set the flag on that type.
8255 if Is_Access_Subprogram_Type
(Named_Entity
) then
8257 Set_Can_Use_Internal_Rep
(Named_Entity
, False);
8260 -- Otherwise it's an error (name denotes the wrong sort of entity)
8264 ("access-to-subprogram type expected",
8265 Get_Pragma_Arg
(Arg1
));
8267 end Favor_Top_Level
;
8273 -- pragma Fast_Math;
8275 when Pragma_Fast_Math
=>
8277 Check_No_Identifiers
;
8278 Check_Valid_Configuration_Pragma
;
8281 ---------------------------
8282 -- Finalize_Storage_Only --
8283 ---------------------------
8285 -- pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
8287 when Pragma_Finalize_Storage_Only
=> Finalize_Storage
: declare
8288 Assoc
: constant Node_Id
:= Arg1
;
8289 Type_Id
: constant Node_Id
:= Get_Pragma_Arg
(Assoc
);
8294 Check_No_Identifiers
;
8295 Check_Arg_Count
(1);
8296 Check_Arg_Is_Local_Name
(Arg1
);
8298 Find_Type
(Type_Id
);
8299 Typ
:= Entity
(Type_Id
);
8302 or else Rep_Item_Too_Early
(Typ
, N
)
8306 Typ
:= Underlying_Type
(Typ
);
8309 if not Is_Controlled
(Typ
) then
8310 Error_Pragma
("pragma% must specify controlled type");
8313 Check_First_Subtype
(Arg1
);
8315 if Finalize_Storage_Only
(Typ
) then
8316 Error_Pragma
("duplicate pragma%, only one allowed");
8318 elsif not Rep_Item_Too_Late
(Typ
, N
) then
8319 Set_Finalize_Storage_Only
(Base_Type
(Typ
), True);
8321 end Finalize_Storage
;
8323 --------------------------
8324 -- Float_Representation --
8325 --------------------------
8327 -- pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
8329 -- FLOAT_REP ::= VAX_Float | IEEE_Float
8331 when Pragma_Float_Representation
=> Float_Representation
: declare
8339 if Arg_Count
= 1 then
8340 Check_Valid_Configuration_Pragma
;
8342 Check_Arg_Count
(2);
8343 Check_Optional_Identifier
(Arg2
, Name_Entity
);
8344 Check_Arg_Is_Local_Name
(Arg2
);
8347 Check_No_Identifier
(Arg1
);
8348 Check_Arg_Is_One_Of
(Arg1
, Name_VAX_Float
, Name_IEEE_Float
);
8350 if not OpenVMS_On_Target
then
8351 if Chars
(Get_Pragma_Arg
(Arg1
)) = Name_VAX_Float
then
8353 ("?pragma% ignored (applies only to Open'V'M'S)");
8359 -- One argument case
8361 if Arg_Count
= 1 then
8362 if Chars
(Get_Pragma_Arg
(Arg1
)) = Name_VAX_Float
then
8363 if Opt
.Float_Format
= 'I' then
8364 Error_Pragma
("'I'E'E'E format previously specified");
8367 Opt
.Float_Format
:= 'V';
8370 if Opt
.Float_Format
= 'V' then
8371 Error_Pragma
("'V'A'X format previously specified");
8374 Opt
.Float_Format
:= 'I';
8377 Set_Standard_Fpt_Formats
;
8379 -- Two argument case
8382 Argx
:= Get_Pragma_Arg
(Arg2
);
8384 if not Is_Entity_Name
(Argx
)
8385 or else not Is_Floating_Point_Type
(Entity
(Argx
))
8388 ("second argument of% pragma must be floating-point type",
8392 Ent
:= Entity
(Argx
);
8393 Digs
:= UI_To_Int
(Digits_Value
(Ent
));
8395 -- Two arguments, VAX_Float case
8397 if Chars
(Get_Pragma_Arg
(Arg1
)) = Name_VAX_Float
then
8399 when 6 => Set_F_Float
(Ent
);
8400 when 9 => Set_D_Float
(Ent
);
8401 when 15 => Set_G_Float
(Ent
);
8405 ("wrong digits value, must be 6,9 or 15", Arg2
);
8408 -- Two arguments, IEEE_Float case
8412 when 6 => Set_IEEE_Short
(Ent
);
8413 when 15 => Set_IEEE_Long
(Ent
);
8417 ("wrong digits value, must be 6 or 15", Arg2
);
8421 end Float_Representation
;
8427 -- pragma Ident (static_string_EXPRESSION)
8429 -- Note: pragma Comment shares this processing. Pragma Comment is
8430 -- identical to Ident, except that the restriction of the argument to
8431 -- 31 characters and the placement restrictions are not enforced for
8434 when Pragma_Ident | Pragma_Comment
=> Ident
: declare
8439 Check_Arg_Count
(1);
8440 Check_No_Identifiers
;
8441 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
8444 -- For pragma Ident, preserve DEC compatibility by requiring the
8445 -- pragma to appear in a declarative part or package spec.
8447 if Prag_Id
= Pragma_Ident
then
8448 Check_Is_In_Decl_Part_Or_Package_Spec
;
8451 Str
:= Expr_Value_S
(Get_Pragma_Arg
(Arg1
));
8458 GP
:= Parent
(Parent
(N
));
8460 if Nkind_In
(GP
, N_Package_Declaration
,
8461 N_Generic_Package_Declaration
)
8466 -- If we have a compilation unit, then record the ident value,
8467 -- checking for improper duplication.
8469 if Nkind
(GP
) = N_Compilation_Unit
then
8470 CS
:= Ident_String
(Current_Sem_Unit
);
8472 if Present
(CS
) then
8474 -- For Ident, we do not permit multiple instances
8476 if Prag_Id
= Pragma_Ident
then
8477 Error_Pragma
("duplicate% pragma not permitted");
8479 -- For Comment, we concatenate the string, unless we want
8480 -- to preserve the tree structure for ASIS.
8482 elsif not ASIS_Mode
then
8483 Start_String
(Strval
(CS
));
8484 Store_String_Char
(' ');
8485 Store_String_Chars
(Strval
(Str
));
8486 Set_Strval
(CS
, End_String
);
8490 -- In VMS, the effect of IDENT is achieved by passing
8491 -- --identification=name as a --for-linker switch.
8493 if OpenVMS_On_Target
then
8496 ("--for-linker=--identification=");
8497 String_To_Name_Buffer
(Strval
(Str
));
8498 Store_String_Chars
(Name_Buffer
(1 .. Name_Len
));
8500 -- Only the last processed IDENT is saved. The main
8501 -- purpose is so an IDENT associated with a main
8502 -- procedure will be used in preference to an IDENT
8503 -- associated with a with'd package.
8505 Replace_Linker_Option_String
8506 (End_String
, "--for-linker=--identification=");
8509 Set_Ident_String
(Current_Sem_Unit
, Str
);
8512 -- For subunits, we just ignore the Ident, since in GNAT these
8513 -- are not separate object files, and hence not separate units
8514 -- in the unit table.
8516 elsif Nkind
(GP
) = N_Subunit
then
8519 -- Otherwise we have a misplaced pragma Ident, but we ignore
8520 -- this if we are in an instantiation, since it comes from
8521 -- a generic, and has no relevance to the instantiation.
8523 elsif Prag_Id
= Pragma_Ident
then
8524 if Instantiation_Location
(Loc
) = No_Location
then
8525 Error_Pragma
("pragma% only allowed at outer level");
8535 -- pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
8536 -- implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
8538 when Pragma_Implemented
=> Implemented
: declare
8539 Proc_Id
: Entity_Id
;
8544 Check_Arg_Count
(2);
8545 Check_No_Identifiers
;
8546 Check_Arg_Is_Identifier
(Arg1
);
8547 Check_Arg_Is_Local_Name
(Arg1
);
8549 (Arg2
, Name_By_Any
, Name_By_Entry
, Name_By_Protected_Procedure
);
8551 -- Extract the name of the local procedure
8553 Proc_Id
:= Entity
(Get_Pragma_Arg
(Arg1
));
8555 -- Ada 2012 (AI05-0030): The procedure_LOCAL_NAME must denote a
8556 -- primitive procedure of a synchronized tagged type.
8558 if Ekind
(Proc_Id
) = E_Procedure
8559 and then Is_Primitive
(Proc_Id
)
8560 and then Present
(First_Formal
(Proc_Id
))
8562 Typ
:= Etype
(First_Formal
(Proc_Id
));
8564 if Is_Tagged_Type
(Typ
)
8567 -- Check for a protected, a synchronized or a task interface
8569 ((Is_Interface
(Typ
)
8570 and then Is_Synchronized_Interface
(Typ
))
8572 -- Check for a protected type or a task type that implements
8576 (Is_Concurrent_Record_Type
(Typ
)
8577 and then Present
(Interfaces
(Typ
)))
8579 -- Check for a private record extension with keyword
8583 (Ekind_In
(Typ
, E_Record_Type_With_Private
,
8584 E_Record_Subtype_With_Private
)
8585 and then Synchronized_Present
(Parent
(Typ
))))
8590 ("controlling formal must be of synchronized " &
8591 "tagged type", Arg1
);
8595 -- Procedures declared inside a protected type must be accepted
8597 elsif Ekind
(Proc_Id
) = E_Procedure
8598 and then Is_Protected_Type
(Scope
(Proc_Id
))
8602 -- The first argument is not a primitive procedure
8606 ("pragma % must be applied to a primitive procedure", Arg1
);
8610 -- Ada 2012 (AI05-0030): Cannot apply the implementation_kind
8611 -- By_Protected_Procedure to the primitive procedure of a task
8614 if Chars
(Arg2
) = Name_By_Protected_Procedure
8615 and then Is_Interface
(Typ
)
8616 and then Is_Task_Interface
(Typ
)
8619 ("implementation kind By_Protected_Procedure cannot be " &
8620 "applied to a task interface primitive", Arg2
);
8624 Record_Rep_Item
(Proc_Id
, N
);
8627 ----------------------
8628 -- Implicit_Packing --
8629 ----------------------
8631 -- pragma Implicit_Packing;
8633 when Pragma_Implicit_Packing
=>
8635 Check_Arg_Count
(0);
8636 Implicit_Packing
:= True;
8643 -- [Convention =>] convention_IDENTIFIER,
8644 -- [Entity =>] local_NAME
8645 -- [, [External_Name =>] static_string_EXPRESSION ]
8646 -- [, [Link_Name =>] static_string_EXPRESSION ]);
8648 when Pragma_Import
=>
8649 Check_Ada_83_Warning
;
8655 Check_At_Least_N_Arguments
(2);
8656 Check_At_Most_N_Arguments
(4);
8657 Process_Import_Or_Interface
;
8659 ----------------------
8660 -- Import_Exception --
8661 ----------------------
8663 -- pragma Import_Exception (
8664 -- [Internal =>] LOCAL_NAME
8665 -- [, [External =>] EXTERNAL_SYMBOL]
8666 -- [, [Form =>] Ada | VMS]
8667 -- [, [Code =>] static_integer_EXPRESSION]);
8669 when Pragma_Import_Exception
=> Import_Exception
: declare
8670 Args
: Args_List
(1 .. 4);
8671 Names
: constant Name_List
(1 .. 4) := (
8677 Internal
: Node_Id
renames Args
(1);
8678 External
: Node_Id
renames Args
(2);
8679 Form
: Node_Id
renames Args
(3);
8680 Code
: Node_Id
renames Args
(4);
8684 Gather_Associations
(Names
, Args
);
8686 if Present
(External
) and then Present
(Code
) then
8688 ("cannot give both External and Code options for pragma%");
8691 Process_Extended_Import_Export_Exception_Pragma
(
8692 Arg_Internal
=> Internal
,
8693 Arg_External
=> External
,
8697 if not Is_VMS_Exception
(Entity
(Internal
)) then
8698 Set_Imported
(Entity
(Internal
));
8700 end Import_Exception
;
8702 ---------------------
8703 -- Import_Function --
8704 ---------------------
8706 -- pragma Import_Function (
8707 -- [Internal =>] LOCAL_NAME,
8708 -- [, [External =>] EXTERNAL_SYMBOL]
8709 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
8710 -- [, [Result_Type =>] SUBTYPE_MARK]
8711 -- [, [Mechanism =>] MECHANISM]
8712 -- [, [Result_Mechanism =>] MECHANISM_NAME]
8713 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
8715 -- EXTERNAL_SYMBOL ::=
8717 -- | static_string_EXPRESSION
8719 -- PARAMETER_TYPES ::=
8721 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
8723 -- TYPE_DESIGNATOR ::=
8725 -- | subtype_Name ' Access
8729 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
8731 -- MECHANISM_ASSOCIATION ::=
8732 -- [formal_parameter_NAME =>] MECHANISM_NAME
8734 -- MECHANISM_NAME ::=
8737 -- | Descriptor [([Class =>] CLASS_NAME)]
8739 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
8741 when Pragma_Import_Function
=> Import_Function
: declare
8742 Args
: Args_List
(1 .. 7);
8743 Names
: constant Name_List
(1 .. 7) := (
8746 Name_Parameter_Types
,
8749 Name_Result_Mechanism
,
8750 Name_First_Optional_Parameter
);
8752 Internal
: Node_Id
renames Args
(1);
8753 External
: Node_Id
renames Args
(2);
8754 Parameter_Types
: Node_Id
renames Args
(3);
8755 Result_Type
: Node_Id
renames Args
(4);
8756 Mechanism
: Node_Id
renames Args
(5);
8757 Result_Mechanism
: Node_Id
renames Args
(6);
8758 First_Optional_Parameter
: Node_Id
renames Args
(7);
8762 Gather_Associations
(Names
, Args
);
8763 Process_Extended_Import_Export_Subprogram_Pragma
(
8764 Arg_Internal
=> Internal
,
8765 Arg_External
=> External
,
8766 Arg_Parameter_Types
=> Parameter_Types
,
8767 Arg_Result_Type
=> Result_Type
,
8768 Arg_Mechanism
=> Mechanism
,
8769 Arg_Result_Mechanism
=> Result_Mechanism
,
8770 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
8771 end Import_Function
;
8777 -- pragma Import_Object (
8778 -- [Internal =>] LOCAL_NAME
8779 -- [, [External =>] EXTERNAL_SYMBOL]
8780 -- [, [Size =>] EXTERNAL_SYMBOL]);
8782 -- EXTERNAL_SYMBOL ::=
8784 -- | static_string_EXPRESSION
8786 when Pragma_Import_Object
=> Import_Object
: declare
8787 Args
: Args_List
(1 .. 3);
8788 Names
: constant Name_List
(1 .. 3) := (
8793 Internal
: Node_Id
renames Args
(1);
8794 External
: Node_Id
renames Args
(2);
8795 Size
: Node_Id
renames Args
(3);
8799 Gather_Associations
(Names
, Args
);
8800 Process_Extended_Import_Export_Object_Pragma
(
8801 Arg_Internal
=> Internal
,
8802 Arg_External
=> External
,
8806 ----------------------
8807 -- Import_Procedure --
8808 ----------------------
8810 -- pragma Import_Procedure (
8811 -- [Internal =>] LOCAL_NAME
8812 -- [, [External =>] EXTERNAL_SYMBOL]
8813 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
8814 -- [, [Mechanism =>] MECHANISM]
8815 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
8817 -- EXTERNAL_SYMBOL ::=
8819 -- | static_string_EXPRESSION
8821 -- PARAMETER_TYPES ::=
8823 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
8825 -- TYPE_DESIGNATOR ::=
8827 -- | subtype_Name ' Access
8831 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
8833 -- MECHANISM_ASSOCIATION ::=
8834 -- [formal_parameter_NAME =>] MECHANISM_NAME
8836 -- MECHANISM_NAME ::=
8839 -- | Descriptor [([Class =>] CLASS_NAME)]
8841 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
8843 when Pragma_Import_Procedure
=> Import_Procedure
: declare
8844 Args
: Args_List
(1 .. 5);
8845 Names
: constant Name_List
(1 .. 5) := (
8848 Name_Parameter_Types
,
8850 Name_First_Optional_Parameter
);
8852 Internal
: Node_Id
renames Args
(1);
8853 External
: Node_Id
renames Args
(2);
8854 Parameter_Types
: Node_Id
renames Args
(3);
8855 Mechanism
: Node_Id
renames Args
(4);
8856 First_Optional_Parameter
: Node_Id
renames Args
(5);
8860 Gather_Associations
(Names
, Args
);
8861 Process_Extended_Import_Export_Subprogram_Pragma
(
8862 Arg_Internal
=> Internal
,
8863 Arg_External
=> External
,
8864 Arg_Parameter_Types
=> Parameter_Types
,
8865 Arg_Mechanism
=> Mechanism
,
8866 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
8867 end Import_Procedure
;
8869 -----------------------------
8870 -- Import_Valued_Procedure --
8871 -----------------------------
8873 -- pragma Import_Valued_Procedure (
8874 -- [Internal =>] LOCAL_NAME
8875 -- [, [External =>] EXTERNAL_SYMBOL]
8876 -- [, [Parameter_Types =>] (PARAMETER_TYPES)]
8877 -- [, [Mechanism =>] MECHANISM]
8878 -- [, [First_Optional_Parameter =>] IDENTIFIER]);
8880 -- EXTERNAL_SYMBOL ::=
8882 -- | static_string_EXPRESSION
8884 -- PARAMETER_TYPES ::=
8886 -- | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
8888 -- TYPE_DESIGNATOR ::=
8890 -- | subtype_Name ' Access
8894 -- | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
8896 -- MECHANISM_ASSOCIATION ::=
8897 -- [formal_parameter_NAME =>] MECHANISM_NAME
8899 -- MECHANISM_NAME ::=
8902 -- | Descriptor [([Class =>] CLASS_NAME)]
8904 -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
8906 when Pragma_Import_Valued_Procedure
=>
8907 Import_Valued_Procedure
: declare
8908 Args
: Args_List
(1 .. 5);
8909 Names
: constant Name_List
(1 .. 5) := (
8912 Name_Parameter_Types
,
8914 Name_First_Optional_Parameter
);
8916 Internal
: Node_Id
renames Args
(1);
8917 External
: Node_Id
renames Args
(2);
8918 Parameter_Types
: Node_Id
renames Args
(3);
8919 Mechanism
: Node_Id
renames Args
(4);
8920 First_Optional_Parameter
: Node_Id
renames Args
(5);
8924 Gather_Associations
(Names
, Args
);
8925 Process_Extended_Import_Export_Subprogram_Pragma
(
8926 Arg_Internal
=> Internal
,
8927 Arg_External
=> External
,
8928 Arg_Parameter_Types
=> Parameter_Types
,
8929 Arg_Mechanism
=> Mechanism
,
8930 Arg_First_Optional_Parameter
=> First_Optional_Parameter
);
8931 end Import_Valued_Procedure
;
8937 -- pragma Independent (LOCAL_NAME);
8939 when Pragma_Independent
=> Independent
: declare
8946 Check_Ada_83_Warning
;
8948 Check_No_Identifiers
;
8949 Check_Arg_Count
(1);
8950 Check_Arg_Is_Local_Name
(Arg1
);
8951 E_Id
:= Get_Pragma_Arg
(Arg1
);
8953 if Etype
(E_Id
) = Any_Type
then
8958 D
:= Declaration_Node
(E
);
8961 -- Check duplicate before we chain ourselves!
8963 Check_Duplicate_Pragma
(E
);
8965 -- Check appropriate entity
8968 if Rep_Item_Too_Early
(E
, N
)
8970 Rep_Item_Too_Late
(E
, N
)
8974 Check_First_Subtype
(Arg1
);
8977 elsif K
= N_Object_Declaration
8978 or else (K
= N_Component_Declaration
8979 and then Original_Record_Component
(E
) = E
)
8981 if Rep_Item_Too_Late
(E
, N
) then
8987 ("inappropriate entity for pragma%", Arg1
);
8990 Independence_Checks
.Append
((N
, E
));
8993 ----------------------------
8994 -- Independent_Components --
8995 ----------------------------
8997 -- pragma Atomic_Components (array_LOCAL_NAME);
8999 -- This processing is shared by Volatile_Components
9001 when Pragma_Independent_Components
=> Independent_Components
: declare
9008 Check_Ada_83_Warning
;
9010 Check_No_Identifiers
;
9011 Check_Arg_Count
(1);
9012 Check_Arg_Is_Local_Name
(Arg1
);
9013 E_Id
:= Get_Pragma_Arg
(Arg1
);
9015 if Etype
(E_Id
) = Any_Type
then
9021 -- Check duplicate before we chain ourselves!
9023 Check_Duplicate_Pragma
(E
);
9025 -- Check appropriate entity
9027 if Rep_Item_Too_Early
(E
, N
)
9029 Rep_Item_Too_Late
(E
, N
)
9034 D
:= Declaration_Node
(E
);
9037 if (K
= N_Full_Type_Declaration
9038 and then (Is_Array_Type
(E
) or else Is_Record_Type
(E
)))
9040 ((Ekind
(E
) = E_Constant
or else Ekind
(E
) = E_Variable
)
9041 and then Nkind
(D
) = N_Object_Declaration
9042 and then Nkind
(Object_Definition
(D
)) =
9043 N_Constrained_Array_Definition
)
9045 Independence_Checks
.Append
((N
, E
));
9048 Error_Pragma_Arg
("inappropriate entity for pragma%", Arg1
);
9050 end Independent_Components
;
9052 ------------------------
9053 -- Initialize_Scalars --
9054 ------------------------
9056 -- pragma Initialize_Scalars;
9058 when Pragma_Initialize_Scalars
=>
9060 Check_Arg_Count
(0);
9061 Check_Valid_Configuration_Pragma
;
9062 Check_Restriction
(No_Initialize_Scalars
, N
);
9064 -- Initialize_Scalars creates false positives in CodePeer,
9065 -- so ignore this pragma in this mode.
9067 if not Restriction_Active
(No_Initialize_Scalars
)
9068 and then not CodePeer_Mode
9070 Init_Or_Norm_Scalars
:= True;
9071 Initialize_Scalars
:= True;
9078 -- pragma Inline ( NAME {, NAME} );
9080 when Pragma_Inline
=>
9082 -- Pragma is active if inlining option is active
9084 Process_Inline
(Inline_Active
);
9090 -- pragma Inline_Always ( NAME {, NAME} );
9092 when Pragma_Inline_Always
=>
9095 -- Pragma always active unless in CodePeer mode, since this causes
9096 -- walk order issues.
9098 if not CodePeer_Mode
then
9099 Process_Inline
(True);
9102 --------------------
9103 -- Inline_Generic --
9104 --------------------
9106 -- pragma Inline_Generic (NAME {, NAME});
9108 when Pragma_Inline_Generic
=>
9110 Process_Generic_List
;
9112 ----------------------
9113 -- Inspection_Point --
9114 ----------------------
9116 -- pragma Inspection_Point [(object_NAME {, object_NAME})];
9118 when Pragma_Inspection_Point
=> Inspection_Point
: declare
9123 if Arg_Count
> 0 then
9126 Exp
:= Get_Pragma_Arg
(Arg
);
9129 if not Is_Entity_Name
(Exp
)
9130 or else not Is_Object
(Entity
(Exp
))
9132 Error_Pragma_Arg
("object name required", Arg
);
9139 end Inspection_Point
;
9145 -- pragma Interface (
9146 -- [ Convention =>] convention_IDENTIFIER,
9147 -- [ Entity =>] local_NAME
9148 -- [, [External_Name =>] static_string_EXPRESSION ]
9149 -- [, [Link_Name =>] static_string_EXPRESSION ]);
9151 when Pragma_Interface
=>
9158 Check_At_Least_N_Arguments
(2);
9159 Check_At_Most_N_Arguments
(4);
9160 Process_Import_Or_Interface
;
9162 -- In Ada 2005, the permission to use Interface (a reserved word)
9163 -- as a pragma name is considered an obsolescent feature.
9165 if Ada_Version
>= Ada_2005
then
9167 (No_Obsolescent_Features
, Pragma_Identifier
(N
));
9170 --------------------
9171 -- Interface_Name --
9172 --------------------
9174 -- pragma Interface_Name (
9175 -- [ Entity =>] local_NAME
9176 -- [,[External_Name =>] static_string_EXPRESSION ]
9177 -- [,[Link_Name =>] static_string_EXPRESSION ]);
9179 when Pragma_Interface_Name
=> Interface_Name
: declare
9188 ((Name_Entity
, Name_External_Name
, Name_Link_Name
));
9189 Check_At_Least_N_Arguments
(2);
9190 Check_At_Most_N_Arguments
(3);
9191 Id
:= Get_Pragma_Arg
(Arg1
);
9194 if not Is_Entity_Name
(Id
) then
9196 ("first argument for pragma% must be entity name", Arg1
);
9197 elsif Etype
(Id
) = Any_Type
then
9200 Def_Id
:= Entity
(Id
);
9203 -- Special DEC-compatible processing for the object case, forces
9204 -- object to be imported.
9206 if Ekind
(Def_Id
) = E_Variable
then
9207 Kill_Size_Check_Code
(Def_Id
);
9208 Note_Possible_Modification
(Id
, Sure
=> False);
9210 -- Initialization is not allowed for imported variable
9212 if Present
(Expression
(Parent
(Def_Id
)))
9213 and then Comes_From_Source
(Expression
(Parent
(Def_Id
)))
9215 Error_Msg_Sloc
:= Sloc
(Def_Id
);
9217 ("no initialization allowed for declaration of& #",
9221 -- For compatibility, support VADS usage of providing both
9222 -- pragmas Interface and Interface_Name to obtain the effect
9223 -- of a single Import pragma.
9225 if Is_Imported
(Def_Id
)
9226 and then Present
(First_Rep_Item
(Def_Id
))
9227 and then Nkind
(First_Rep_Item
(Def_Id
)) = N_Pragma
9229 Pragma_Name
(First_Rep_Item
(Def_Id
)) = Name_Interface
9233 Set_Imported
(Def_Id
);
9236 Set_Is_Public
(Def_Id
);
9237 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
9240 -- Otherwise must be subprogram
9242 elsif not Is_Subprogram
(Def_Id
) then
9244 ("argument of pragma% is not subprogram", Arg1
);
9247 Check_At_Most_N_Arguments
(3);
9251 -- Loop through homonyms
9254 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
9256 if Is_Imported
(Def_Id
) then
9257 Process_Interface_Name
(Def_Id
, Arg2
, Arg3
);
9261 exit when From_Aspect_Specification
(N
);
9262 Hom_Id
:= Homonym
(Hom_Id
);
9264 exit when No
(Hom_Id
)
9265 or else Scope
(Hom_Id
) /= Current_Scope
;
9270 ("argument of pragma% is not imported subprogram",
9276 -----------------------
9277 -- Interrupt_Handler --
9278 -----------------------
9280 -- pragma Interrupt_Handler (handler_NAME);
9282 when Pragma_Interrupt_Handler
=>
9283 Check_Ada_83_Warning
;
9284 Check_Arg_Count
(1);
9285 Check_No_Identifiers
;
9287 if No_Run_Time_Mode
then
9288 Error_Msg_CRT
("Interrupt_Handler pragma", N
);
9290 Check_Interrupt_Or_Attach_Handler
;
9291 Process_Interrupt_Or_Attach_Handler
;
9294 ------------------------
9295 -- Interrupt_Priority --
9296 ------------------------
9298 -- pragma Interrupt_Priority [(EXPRESSION)];
9300 when Pragma_Interrupt_Priority
=> Interrupt_Priority
: declare
9301 P
: constant Node_Id
:= Parent
(N
);
9305 Check_Ada_83_Warning
;
9307 if Arg_Count
/= 0 then
9308 Arg
:= Get_Pragma_Arg
(Arg1
);
9309 Check_Arg_Count
(1);
9310 Check_No_Identifiers
;
9312 -- The expression must be analyzed in the special manner
9313 -- described in "Handling of Default and Per-Object
9314 -- Expressions" in sem.ads.
9316 Preanalyze_Spec_Expression
(Arg
, RTE
(RE_Interrupt_Priority
));
9319 if not Nkind_In
(P
, N_Task_Definition
, N_Protected_Definition
) then
9323 elsif Has_Pragma_Priority
(P
) then
9324 Error_Pragma
("duplicate pragma% not allowed");
9327 Set_Has_Pragma_Priority
(P
, True);
9328 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
9330 end Interrupt_Priority
;
9332 ---------------------
9333 -- Interrupt_State --
9334 ---------------------
9336 -- pragma Interrupt_State (
9337 -- [Name =>] INTERRUPT_ID,
9338 -- [State =>] INTERRUPT_STATE);
9340 -- INTERRUPT_ID => IDENTIFIER | static_integer_EXPRESSION
9341 -- INTERRUPT_STATE => System | Runtime | User
9343 -- Note: if the interrupt id is given as an identifier, then it must
9344 -- be one of the identifiers in Ada.Interrupts.Names. Otherwise it is
9345 -- given as a static integer expression which must be in the range of
9346 -- Ada.Interrupts.Interrupt_ID.
9348 when Pragma_Interrupt_State
=> Interrupt_State
: declare
9350 Int_Id
: constant Entity_Id
:= RTE
(RE_Interrupt_ID
);
9351 -- This is the entity Ada.Interrupts.Interrupt_ID;
9353 State_Type
: Character;
9354 -- Set to 's'/'r'/'u' for System/Runtime/User
9357 -- Index to entry in Interrupt_States table
9360 -- Value of interrupt
9362 Arg1X
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
9363 -- The first argument to the pragma
9365 Int_Ent
: Entity_Id
;
9366 -- Interrupt entity in Ada.Interrupts.Names
9370 Check_Arg_Order
((Name_Name
, Name_State
));
9371 Check_Arg_Count
(2);
9373 Check_Optional_Identifier
(Arg1
, Name_Name
);
9374 Check_Optional_Identifier
(Arg2
, Name_State
);
9375 Check_Arg_Is_Identifier
(Arg2
);
9377 -- First argument is identifier
9379 if Nkind
(Arg1X
) = N_Identifier
then
9381 -- Search list of names in Ada.Interrupts.Names
9383 Int_Ent
:= First_Entity
(RTE
(RE_Names
));
9385 if No
(Int_Ent
) then
9386 Error_Pragma_Arg
("invalid interrupt name", Arg1
);
9388 elsif Chars
(Int_Ent
) = Chars
(Arg1X
) then
9389 Int_Val
:= Expr_Value
(Constant_Value
(Int_Ent
));
9393 Next_Entity
(Int_Ent
);
9396 -- First argument is not an identifier, so it must be a static
9397 -- expression of type Ada.Interrupts.Interrupt_ID.
9400 Check_Arg_Is_Static_Expression
(Arg1
, Any_Integer
);
9401 Int_Val
:= Expr_Value
(Arg1X
);
9403 if Int_Val
< Expr_Value
(Type_Low_Bound
(Int_Id
))
9405 Int_Val
> Expr_Value
(Type_High_Bound
(Int_Id
))
9408 ("value not in range of type " &
9409 """Ada.Interrupts.Interrupt_'I'D""", Arg1
);
9415 case Chars
(Get_Pragma_Arg
(Arg2
)) is
9416 when Name_Runtime
=> State_Type
:= 'r';
9417 when Name_System
=> State_Type
:= 's';
9418 when Name_User
=> State_Type
:= 'u';
9421 Error_Pragma_Arg
("invalid interrupt state", Arg2
);
9424 -- Check if entry is already stored
9426 IST_Num
:= Interrupt_States
.First
;
9428 -- If entry not found, add it
9430 if IST_Num
> Interrupt_States
.Last
then
9431 Interrupt_States
.Append
9432 ((Interrupt_Number
=> UI_To_Int
(Int_Val
),
9433 Interrupt_State
=> State_Type
,
9434 Pragma_Loc
=> Loc
));
9437 -- Case of entry for the same entry
9439 elsif Int_Val
= Interrupt_States
.Table
(IST_Num
).
9442 -- If state matches, done, no need to make redundant entry
9445 State_Type
= Interrupt_States
.Table
(IST_Num
).
9448 -- Otherwise if state does not match, error
9451 Interrupt_States
.Table
(IST_Num
).Pragma_Loc
;
9453 ("state conflicts with that given #", Arg2
);
9457 IST_Num
:= IST_Num
+ 1;
9459 end Interrupt_State
;
9466 -- ([Entity =>] type_LOCAL_NAME,
9467 -- [Check =>] EXPRESSION
9468 -- [,[Message =>] String_Expression]);
9470 when Pragma_Invariant
=> Invariant
: declare
9475 pragma Unreferenced
(Discard
);
9479 Check_At_Least_N_Arguments
(2);
9480 Check_At_Most_N_Arguments
(3);
9481 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9482 Check_Optional_Identifier
(Arg2
, Name_Check
);
9484 if Arg_Count
= 3 then
9485 Check_Optional_Identifier
(Arg3
, Name_Message
);
9486 Check_Arg_Is_Static_Expression
(Arg3
, Standard_String
);
9489 Check_Arg_Is_Local_Name
(Arg1
);
9491 Type_Id
:= Get_Pragma_Arg
(Arg1
);
9492 Find_Type
(Type_Id
);
9493 Typ
:= Entity
(Type_Id
);
9495 if Typ
= Any_Type
then
9498 elsif not Ekind_In
(Typ
, E_Private_Type
,
9499 E_Record_Type_With_Private
,
9500 E_Limited_Private_Type
)
9503 ("pragma% only allowed for private type", Arg1
);
9506 -- Note that the type has at least one invariant, and also that
9507 -- it has inheritable invariants if we have Invariant'Class.
9509 Set_Has_Invariants
(Typ
);
9511 if Class_Present
(N
) then
9512 Set_Has_Inheritable_Invariants
(Typ
);
9515 -- The remaining processing is simply to link the pragma on to
9516 -- the rep item chain, for processing when the type is frozen.
9517 -- This is accomplished by a call to Rep_Item_Too_Late.
9519 Discard
:= Rep_Item_Too_Late
(Typ
, N
, FOnly
=> True);
9522 ----------------------
9523 -- Java_Constructor --
9524 ----------------------
9526 -- pragma Java_Constructor ([Entity =>] LOCAL_NAME);
9528 -- Also handles pragma CIL_Constructor
9530 when Pragma_CIL_Constructor | Pragma_Java_Constructor
=>
9531 Java_Constructor
: declare
9532 Convention
: Convention_Id
;
9536 This_Formal
: Entity_Id
;
9540 Check_Arg_Count
(1);
9541 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9542 Check_Arg_Is_Local_Name
(Arg1
);
9544 Id
:= Get_Pragma_Arg
(Arg1
);
9545 Find_Program_Unit_Name
(Id
);
9547 -- If we did not find the name, we are done
9549 if Etype
(Id
) = Any_Type
then
9553 -- Check wrong use of pragma in wrong VM target
9555 if VM_Target
= No_VM
then
9558 elsif VM_Target
= CLI_Target
9559 and then Prag_Id
= Pragma_Java_Constructor
9561 Error_Pragma
("must use pragma 'C'I'L_'Constructor");
9563 elsif VM_Target
= JVM_Target
9564 and then Prag_Id
= Pragma_CIL_Constructor
9566 Error_Pragma
("must use pragma 'Java_'Constructor");
9570 when Pragma_CIL_Constructor
=> Convention
:= Convention_CIL
;
9571 when Pragma_Java_Constructor
=> Convention
:= Convention_Java
;
9572 when others => null;
9575 Hom_Id
:= Entity
(Id
);
9577 -- Loop through homonyms
9580 Def_Id
:= Get_Base_Subprogram
(Hom_Id
);
9582 -- The constructor is required to be a function
9584 if Ekind
(Def_Id
) /= E_Function
then
9585 if VM_Target
= JVM_Target
then
9587 ("pragma% requires function returning a " &
9588 "'Java access type", Def_Id
);
9591 ("pragma% requires function returning a " &
9592 "'C'I'L access type", Def_Id
);
9596 -- Check arguments: For tagged type the first formal must be
9597 -- named "this" and its type must be a named access type
9598 -- designating a class-wide tagged type that has convention
9599 -- CIL/Java. The first formal must also have a null default
9600 -- value. For example:
9602 -- type Typ is tagged ...
9603 -- type Ref is access all Typ;
9604 -- pragma Convention (CIL, Typ);
9606 -- function New_Typ (This : Ref) return Ref;
9607 -- function New_Typ (This : Ref; I : Integer) return Ref;
9608 -- pragma Cil_Constructor (New_Typ);
9610 -- Reason: The first formal must NOT be a primitive of the
9613 -- This rule also applies to constructors of delegates used
9614 -- to interface with standard target libraries. For example:
9616 -- type Delegate is access procedure ...
9617 -- pragma Import (CIL, Delegate, ...);
9619 -- function new_Delegate
9620 -- (This : Delegate := null; ... ) return Delegate;
9622 -- For value-types this rule does not apply.
9624 if not Is_Value_Type
(Etype
(Def_Id
)) then
9625 if No
(First_Formal
(Def_Id
)) then
9626 Error_Msg_Name_1
:= Pname
;
9627 Error_Msg_N
("% function must have parameters", Def_Id
);
9631 -- In the JRE library we have several occurrences in which
9632 -- the "this" parameter is not the first formal.
9634 This_Formal
:= First_Formal
(Def_Id
);
9636 -- In the JRE library we have several occurrences in which
9637 -- the "this" parameter is not the first formal. Search for
9640 if VM_Target
= JVM_Target
then
9641 while Present
(This_Formal
)
9642 and then Get_Name_String
(Chars
(This_Formal
)) /= "this"
9644 Next_Formal
(This_Formal
);
9647 if No
(This_Formal
) then
9648 This_Formal
:= First_Formal
(Def_Id
);
9652 -- Warning: The first parameter should be named "this".
9653 -- We temporarily allow it because we have the following
9654 -- case in the Java runtime (file s-osinte.ads) ???
9656 -- function new_Thread
9657 -- (Self_Id : System.Address) return Thread_Id;
9658 -- pragma Java_Constructor (new_Thread);
9660 if VM_Target
= JVM_Target
9661 and then Get_Name_String
(Chars
(First_Formal
(Def_Id
)))
9663 and then Etype
(First_Formal
(Def_Id
)) = RTE
(RE_Address
)
9667 elsif Get_Name_String
(Chars
(This_Formal
)) /= "this" then
9668 Error_Msg_Name_1
:= Pname
;
9670 ("first formal of % function must be named `this`",
9671 Parent
(This_Formal
));
9673 elsif not Is_Access_Type
(Etype
(This_Formal
)) then
9674 Error_Msg_Name_1
:= Pname
;
9676 ("first formal of % function must be an access type",
9677 Parameter_Type
(Parent
(This_Formal
)));
9679 -- For delegates the type of the first formal must be a
9680 -- named access-to-subprogram type (see previous example)
9682 elsif Ekind
(Etype
(Def_Id
)) = E_Access_Subprogram_Type
9683 and then Ekind
(Etype
(This_Formal
))
9684 /= E_Access_Subprogram_Type
9686 Error_Msg_Name_1
:= Pname
;
9688 ("first formal of % function must be a named access" &
9689 " to subprogram type",
9690 Parameter_Type
(Parent
(This_Formal
)));
9692 -- Warning: We should reject anonymous access types because
9693 -- the constructor must not be handled as a primitive of the
9694 -- tagged type. We temporarily allow it because this profile
9695 -- is currently generated by cil2ada???
9697 elsif Ekind
(Etype
(Def_Id
)) /= E_Access_Subprogram_Type
9698 and then not Ekind_In
(Etype
(This_Formal
),
9700 E_General_Access_Type
,
9701 E_Anonymous_Access_Type
)
9703 Error_Msg_Name_1
:= Pname
;
9705 ("first formal of % function must be a named access" &
9707 Parameter_Type
(Parent
(This_Formal
)));
9709 elsif Atree
.Convention
9710 (Designated_Type
(Etype
(This_Formal
))) /= Convention
9712 Error_Msg_Name_1
:= Pname
;
9714 if Convention
= Convention_Java
then
9716 ("pragma% requires convention 'Cil in designated" &
9718 Parameter_Type
(Parent
(This_Formal
)));
9721 ("pragma% requires convention 'Java in designated" &
9723 Parameter_Type
(Parent
(This_Formal
)));
9726 elsif No
(Expression
(Parent
(This_Formal
)))
9727 or else Nkind
(Expression
(Parent
(This_Formal
))) /= N_Null
9729 Error_Msg_Name_1
:= Pname
;
9731 ("pragma% requires first formal with default `null`",
9732 Parameter_Type
(Parent
(This_Formal
)));
9736 -- Check result type: the constructor must be a function
9738 -- * a value type (only allowed in the CIL compiler)
9739 -- * an access-to-subprogram type with convention Java/CIL
9740 -- * an access-type designating a type that has convention
9743 if Is_Value_Type
(Etype
(Def_Id
)) then
9746 -- Access-to-subprogram type with convention Java/CIL
9748 elsif Ekind
(Etype
(Def_Id
)) = E_Access_Subprogram_Type
then
9749 if Atree
.Convention
(Etype
(Def_Id
)) /= Convention
then
9750 if Convention
= Convention_Java
then
9752 ("pragma% requires function returning a " &
9753 "'Java access type", Arg1
);
9755 pragma Assert
(Convention
= Convention_CIL
);
9757 ("pragma% requires function returning a " &
9758 "'C'I'L access type", Arg1
);
9762 elsif Ekind
(Etype
(Def_Id
)) in Access_Kind
then
9763 if not Ekind_In
(Etype
(Def_Id
), E_Access_Type
,
9764 E_General_Access_Type
)
9767 (Designated_Type
(Etype
(Def_Id
))) /= Convention
9769 Error_Msg_Name_1
:= Pname
;
9771 if Convention
= Convention_Java
then
9773 ("pragma% requires function returning a named" &
9774 "'Java access type", Arg1
);
9777 ("pragma% requires function returning a named" &
9778 "'C'I'L access type", Arg1
);
9783 Set_Is_Constructor
(Def_Id
);
9784 Set_Convention
(Def_Id
, Convention
);
9785 Set_Is_Imported
(Def_Id
);
9787 exit when From_Aspect_Specification
(N
);
9788 Hom_Id
:= Homonym
(Hom_Id
);
9790 exit when No
(Hom_Id
) or else Scope
(Hom_Id
) /= Current_Scope
;
9792 end Java_Constructor
;
9794 ----------------------
9795 -- Java_Interface --
9796 ----------------------
9798 -- pragma Java_Interface ([Entity =>] LOCAL_NAME);
9800 when Pragma_Java_Interface
=> Java_Interface
: declare
9806 Check_Arg_Count
(1);
9807 Check_Optional_Identifier
(Arg1
, Name_Entity
);
9808 Check_Arg_Is_Local_Name
(Arg1
);
9810 Arg
:= Get_Pragma_Arg
(Arg1
);
9813 if Etype
(Arg
) = Any_Type
then
9817 if not Is_Entity_Name
(Arg
)
9818 or else not Is_Type
(Entity
(Arg
))
9820 Error_Pragma_Arg
("pragma% requires a type mark", Arg1
);
9823 Typ
:= Underlying_Type
(Entity
(Arg
));
9825 -- For now simply check some of the semantic constraints on the
9826 -- type. This currently leaves out some restrictions on interface
9827 -- types, namely that the parent type must be java.lang.Object.Typ
9828 -- and that all primitives of the type should be declared
9831 if not Is_Tagged_Type
(Typ
) or else not Is_Abstract_Type
(Typ
) then
9832 Error_Pragma_Arg
("pragma% requires an abstract "
9833 & "tagged type", Arg1
);
9835 elsif not Has_Discriminants
(Typ
)
9836 or else Ekind
(Etype
(First_Discriminant
(Typ
)))
9837 /= E_Anonymous_Access_Type
9839 not Is_Class_Wide_Type
9840 (Designated_Type
(Etype
(First_Discriminant
(Typ
))))
9843 ("type must have a class-wide access discriminant", Arg1
);
9851 -- pragma Keep_Names ([On => ] local_NAME);
9853 when Pragma_Keep_Names
=> Keep_Names
: declare
9858 Check_Arg_Count
(1);
9859 Check_Optional_Identifier
(Arg1
, Name_On
);
9860 Check_Arg_Is_Local_Name
(Arg1
);
9862 Arg
:= Get_Pragma_Arg
(Arg1
);
9865 if Etype
(Arg
) = Any_Type
then
9869 if not Is_Entity_Name
(Arg
)
9870 or else Ekind
(Entity
(Arg
)) /= E_Enumeration_Type
9873 ("pragma% requires a local enumeration type", Arg1
);
9876 Set_Discard_Names
(Entity
(Arg
), False);
9883 -- pragma License (RESTRICTED | UNRESTRICTED | GPL | MODIFIED_GPL);
9885 when Pragma_License
=>
9887 Check_Arg_Count
(1);
9888 Check_No_Identifiers
;
9889 Check_Valid_Configuration_Pragma
;
9890 Check_Arg_Is_Identifier
(Arg1
);
9893 Sind
: constant Source_File_Index
:=
9894 Source_Index
(Current_Sem_Unit
);
9897 case Chars
(Get_Pragma_Arg
(Arg1
)) is
9899 Set_License
(Sind
, GPL
);
9901 when Name_Modified_GPL
=>
9902 Set_License
(Sind
, Modified_GPL
);
9904 when Name_Restricted
=>
9905 Set_License
(Sind
, Restricted
);
9907 when Name_Unrestricted
=>
9908 Set_License
(Sind
, Unrestricted
);
9911 Error_Pragma_Arg
("invalid license name", Arg1
);
9919 -- pragma Link_With (string_EXPRESSION {, string_EXPRESSION});
9921 when Pragma_Link_With
=> Link_With
: declare
9927 if Operating_Mode
= Generate_Code
9928 and then In_Extended_Main_Source_Unit
(N
)
9930 Check_At_Least_N_Arguments
(1);
9931 Check_No_Identifiers
;
9932 Check_Is_In_Decl_Part_Or_Package_Spec
;
9933 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
9937 while Present
(Arg
) loop
9938 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
9940 -- Store argument, converting sequences of spaces to a
9941 -- single null character (this is one of the differences
9942 -- in processing between Link_With and Linker_Options).
9945 C
: constant Char_Code
:= Get_Char_Code
(' ');
9946 S
: constant String_Id
:=
9947 Strval
(Expr_Value_S
(Get_Pragma_Arg
(Arg
)));
9948 L
: constant Nat
:= String_Length
(S
);
9951 procedure Skip_Spaces
;
9952 -- Advance F past any spaces
9958 procedure Skip_Spaces
is
9960 while F
<= L
and then Get_String_Char
(S
, F
) = C
loop
9965 -- Start of processing for Arg_Store
9968 Skip_Spaces
; -- skip leading spaces
9970 -- Loop through characters, changing any embedded
9971 -- sequence of spaces to a single null character (this
9972 -- is how Link_With/Linker_Options differ)
9975 if Get_String_Char
(S
, F
) = C
then
9978 Store_String_Char
(ASCII
.NUL
);
9981 Store_String_Char
(Get_String_Char
(S
, F
));
9989 if Present
(Arg
) then
9990 Store_String_Char
(ASCII
.NUL
);
9994 Store_Linker_Option_String
(End_String
);
10002 -- pragma Linker_Alias (
10003 -- [Entity =>] LOCAL_NAME
10004 -- [Target =>] static_string_EXPRESSION);
10006 when Pragma_Linker_Alias
=>
10008 Check_Arg_Order
((Name_Entity
, Name_Target
));
10009 Check_Arg_Count
(2);
10010 Check_Optional_Identifier
(Arg1
, Name_Entity
);
10011 Check_Optional_Identifier
(Arg2
, Name_Target
);
10012 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
10013 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
10015 -- The only processing required is to link this item on to the
10016 -- list of rep items for the given entity. This is accomplished
10017 -- by the call to Rep_Item_Too_Late (when no error is detected
10018 -- and False is returned).
10020 if Rep_Item_Too_Late
(Entity
(Get_Pragma_Arg
(Arg1
)), N
) then
10023 Set_Has_Gigi_Rep_Item
(Entity
(Get_Pragma_Arg
(Arg1
)));
10026 ------------------------
10027 -- Linker_Constructor --
10028 ------------------------
10030 -- pragma Linker_Constructor (procedure_LOCAL_NAME);
10032 -- Code is shared with Linker_Destructor
10034 -----------------------
10035 -- Linker_Destructor --
10036 -----------------------
10038 -- pragma Linker_Destructor (procedure_LOCAL_NAME);
10040 when Pragma_Linker_Constructor |
10041 Pragma_Linker_Destructor
=>
10042 Linker_Constructor
: declare
10048 Check_Arg_Count
(1);
10049 Check_No_Identifiers
;
10050 Check_Arg_Is_Local_Name
(Arg1
);
10051 Arg1_X
:= Get_Pragma_Arg
(Arg1
);
10053 Proc
:= Find_Unique_Parameterless_Procedure
(Arg1_X
, Arg1
);
10055 if not Is_Library_Level_Entity
(Proc
) then
10057 ("argument for pragma% must be library level entity", Arg1
);
10060 -- The only processing required is to link this item on to the
10061 -- list of rep items for the given entity. This is accomplished
10062 -- by the call to Rep_Item_Too_Late (when no error is detected
10063 -- and False is returned).
10065 if Rep_Item_Too_Late
(Proc
, N
) then
10068 Set_Has_Gigi_Rep_Item
(Proc
);
10070 end Linker_Constructor
;
10072 --------------------
10073 -- Linker_Options --
10074 --------------------
10076 -- pragma Linker_Options (string_EXPRESSION {, string_EXPRESSION});
10078 when Pragma_Linker_Options
=> Linker_Options
: declare
10082 Check_Ada_83_Warning
;
10083 Check_No_Identifiers
;
10084 Check_Arg_Count
(1);
10085 Check_Is_In_Decl_Part_Or_Package_Spec
;
10086 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
10087 Start_String
(Strval
(Expr_Value_S
(Get_Pragma_Arg
(Arg1
))));
10090 while Present
(Arg
) loop
10091 Check_Arg_Is_Static_Expression
(Arg
, Standard_String
);
10092 Store_String_Char
(ASCII
.NUL
);
10094 (Strval
(Expr_Value_S
(Get_Pragma_Arg
(Arg
))));
10098 if Operating_Mode
= Generate_Code
10099 and then In_Extended_Main_Source_Unit
(N
)
10101 Store_Linker_Option_String
(End_String
);
10103 end Linker_Options
;
10105 --------------------
10106 -- Linker_Section --
10107 --------------------
10109 -- pragma Linker_Section (
10110 -- [Entity =>] LOCAL_NAME
10111 -- [Section =>] static_string_EXPRESSION);
10113 when Pragma_Linker_Section
=>
10115 Check_Arg_Order
((Name_Entity
, Name_Section
));
10116 Check_Arg_Count
(2);
10117 Check_Optional_Identifier
(Arg1
, Name_Entity
);
10118 Check_Optional_Identifier
(Arg2
, Name_Section
);
10119 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
10120 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
10122 -- This pragma applies only to objects
10124 if not Is_Object
(Entity
(Get_Pragma_Arg
(Arg1
))) then
10125 Error_Pragma_Arg
("pragma% applies only to objects", Arg1
);
10128 -- The only processing required is to link this item on to the
10129 -- list of rep items for the given entity. This is accomplished
10130 -- by the call to Rep_Item_Too_Late (when no error is detected
10131 -- and False is returned).
10133 if Rep_Item_Too_Late
(Entity
(Get_Pragma_Arg
(Arg1
)), N
) then
10136 Set_Has_Gigi_Rep_Item
(Entity
(Get_Pragma_Arg
(Arg1
)));
10143 -- pragma List (On | Off)
10145 -- There is nothing to do here, since we did all the processing for
10146 -- this pragma in Par.Prag (so that it works properly even in syntax
10149 when Pragma_List
=>
10152 --------------------
10153 -- Locking_Policy --
10154 --------------------
10156 -- pragma Locking_Policy (policy_IDENTIFIER);
10158 when Pragma_Locking_Policy
=> declare
10162 Check_Ada_83_Warning
;
10163 Check_Arg_Count
(1);
10164 Check_No_Identifiers
;
10165 Check_Arg_Is_Locking_Policy
(Arg1
);
10166 Check_Valid_Configuration_Pragma
;
10167 Get_Name_String
(Chars
(Get_Pragma_Arg
(Arg1
)));
10168 LP
:= Fold_Upper
(Name_Buffer
(1));
10170 if Locking_Policy
/= ' '
10171 and then Locking_Policy
/= LP
10173 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
10174 Error_Pragma
("locking policy incompatible with policy#");
10176 -- Set new policy, but always preserve System_Location since we
10177 -- like the error message with the run time name.
10180 Locking_Policy
:= LP
;
10182 if Locking_Policy_Sloc
/= System_Location
then
10183 Locking_Policy_Sloc
:= Loc
;
10192 -- pragma Long_Float (D_Float | G_Float);
10194 when Pragma_Long_Float
=>
10196 Check_Valid_Configuration_Pragma
;
10197 Check_Arg_Count
(1);
10198 Check_No_Identifier
(Arg1
);
10199 Check_Arg_Is_One_Of
(Arg1
, Name_D_Float
, Name_G_Float
);
10201 if not OpenVMS_On_Target
then
10202 Error_Pragma
("?pragma% ignored (applies only to Open'V'M'S)");
10207 if Chars
(Get_Pragma_Arg
(Arg1
)) = Name_D_Float
then
10208 if Opt
.Float_Format_Long
= 'G' then
10209 Error_Pragma
("G_Float previously specified");
10212 Opt
.Float_Format_Long
:= 'D';
10214 -- G_Float case (this is the default, does not need overriding)
10217 if Opt
.Float_Format_Long
= 'D' then
10218 Error_Pragma
("D_Float previously specified");
10221 Opt
.Float_Format_Long
:= 'G';
10224 Set_Standard_Fpt_Formats
;
10226 -----------------------
10227 -- Machine_Attribute --
10228 -----------------------
10230 -- pragma Machine_Attribute (
10231 -- [Entity =>] LOCAL_NAME,
10232 -- [Attribute_Name =>] static_string_EXPRESSION
10233 -- [, [Info =>] static_EXPRESSION] );
10235 when Pragma_Machine_Attribute
=> Machine_Attribute
: declare
10236 Def_Id
: Entity_Id
;
10240 Check_Arg_Order
((Name_Entity
, Name_Attribute_Name
, Name_Info
));
10242 if Arg_Count
= 3 then
10243 Check_Optional_Identifier
(Arg3
, Name_Info
);
10244 Check_Arg_Is_Static_Expression
(Arg3
);
10246 Check_Arg_Count
(2);
10249 Check_Optional_Identifier
(Arg1
, Name_Entity
);
10250 Check_Optional_Identifier
(Arg2
, Name_Attribute_Name
);
10251 Check_Arg_Is_Local_Name
(Arg1
);
10252 Check_Arg_Is_Static_Expression
(Arg2
, Standard_String
);
10253 Def_Id
:= Entity
(Get_Pragma_Arg
(Arg1
));
10255 if Is_Access_Type
(Def_Id
) then
10256 Def_Id
:= Designated_Type
(Def_Id
);
10259 if Rep_Item_Too_Early
(Def_Id
, N
) then
10263 Def_Id
:= Underlying_Type
(Def_Id
);
10265 -- The only processing required is to link this item on to the
10266 -- list of rep items for the given entity. This is accomplished
10267 -- by the call to Rep_Item_Too_Late (when no error is detected
10268 -- and False is returned).
10270 if Rep_Item_Too_Late
(Def_Id
, N
) then
10273 Set_Has_Gigi_Rep_Item
(Entity
(Get_Pragma_Arg
(Arg1
)));
10275 end Machine_Attribute
;
10282 -- (MAIN_OPTION [, MAIN_OPTION]);
10285 -- [STACK_SIZE =>] static_integer_EXPRESSION
10286 -- | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
10287 -- | [TIME_SLICING_ENABLED =>] static_boolean_EXPRESSION
10289 when Pragma_Main
=> Main
: declare
10290 Args
: Args_List
(1 .. 3);
10291 Names
: constant Name_List
(1 .. 3) := (
10293 Name_Task_Stack_Size_Default
,
10294 Name_Time_Slicing_Enabled
);
10300 Gather_Associations
(Names
, Args
);
10302 for J
in 1 .. 2 loop
10303 if Present
(Args
(J
)) then
10304 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
10308 if Present
(Args
(3)) then
10309 Check_Arg_Is_Static_Expression
(Args
(3), Standard_Boolean
);
10313 while Present
(Nod
) loop
10314 if Nkind
(Nod
) = N_Pragma
10315 and then Pragma_Name
(Nod
) = Name_Main
10317 Error_Msg_Name_1
:= Pname
;
10318 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
10329 -- pragma Main_Storage
10330 -- (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
10332 -- MAIN_STORAGE_OPTION ::=
10333 -- [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
10334 -- | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
10336 when Pragma_Main_Storage
=> Main_Storage
: declare
10337 Args
: Args_List
(1 .. 2);
10338 Names
: constant Name_List
(1 .. 2) := (
10339 Name_Working_Storage
,
10346 Gather_Associations
(Names
, Args
);
10348 for J
in 1 .. 2 loop
10349 if Present
(Args
(J
)) then
10350 Check_Arg_Is_Static_Expression
(Args
(J
), Any_Integer
);
10354 Check_In_Main_Program
;
10357 while Present
(Nod
) loop
10358 if Nkind
(Nod
) = N_Pragma
10359 and then Pragma_Name
(Nod
) = Name_Main_Storage
10361 Error_Msg_Name_1
:= Pname
;
10362 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
10373 -- pragma Memory_Size (NUMERIC_LITERAL)
10375 when Pragma_Memory_Size
=>
10378 -- Memory size is simply ignored
10380 Check_No_Identifiers
;
10381 Check_Arg_Count
(1);
10382 Check_Arg_Is_Integer_Literal
(Arg1
);
10390 -- The only correct use of this pragma is on its own in a file, in
10391 -- which case it is specially processed (see Gnat1drv.Check_Bad_Body
10392 -- and Frontend, which use Sinput.L.Source_File_Is_Pragma_No_Body to
10393 -- check for a file containing nothing but a No_Body pragma). If we
10394 -- attempt to process it during normal semantics processing, it means
10395 -- it was misplaced.
10397 when Pragma_No_Body
=>
10405 -- pragma No_Return (procedure_LOCAL_NAME {, procedure_Local_Name});
10407 when Pragma_No_Return
=> No_Return
: declare
10415 Check_At_Least_N_Arguments
(1);
10417 -- Loop through arguments of pragma
10420 while Present
(Arg
) loop
10421 Check_Arg_Is_Local_Name
(Arg
);
10422 Id
:= Get_Pragma_Arg
(Arg
);
10425 if not Is_Entity_Name
(Id
) then
10426 Error_Pragma_Arg
("entity name required", Arg
);
10429 if Etype
(Id
) = Any_Type
then
10433 -- Loop to find matching procedures
10438 and then Scope
(E
) = Current_Scope
10440 if Ekind_In
(E
, E_Procedure
, E_Generic_Procedure
) then
10443 -- Set flag on any alias as well
10445 if Is_Overloadable
(E
) and then Present
(Alias
(E
)) then
10446 Set_No_Return
(Alias
(E
));
10452 exit when From_Aspect_Specification
(N
);
10457 Error_Pragma_Arg
("no procedure & found for pragma%", Arg
);
10468 -- pragma No_Run_Time;
10470 -- Note: this pragma is retained for backwards compatibility. See
10471 -- body of Rtsfind for full details on its handling.
10473 when Pragma_No_Run_Time
=>
10475 Check_Valid_Configuration_Pragma
;
10476 Check_Arg_Count
(0);
10478 No_Run_Time_Mode
:= True;
10479 Configurable_Run_Time_Mode
:= True;
10481 -- Set Duration to 32 bits if word size is 32
10483 if Ttypes
.System_Word_Size
= 32 then
10484 Duration_32_Bits_On_Target
:= True;
10487 -- Set appropriate restrictions
10489 Set_Restriction
(No_Finalization
, N
);
10490 Set_Restriction
(No_Exception_Handlers
, N
);
10491 Set_Restriction
(Max_Tasks
, N
, 0);
10492 Set_Restriction
(No_Tasking
, N
);
10494 ------------------------
10495 -- No_Strict_Aliasing --
10496 ------------------------
10498 -- pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
10500 when Pragma_No_Strict_Aliasing
=> No_Strict_Aliasing
: declare
10505 Check_At_Most_N_Arguments
(1);
10507 if Arg_Count
= 0 then
10508 Check_Valid_Configuration_Pragma
;
10509 Opt
.No_Strict_Aliasing
:= True;
10512 Check_Optional_Identifier
(Arg2
, Name_Entity
);
10513 Check_Arg_Is_Local_Name
(Arg1
);
10514 E_Id
:= Entity
(Get_Pragma_Arg
(Arg1
));
10516 if E_Id
= Any_Type
then
10518 elsif No
(E_Id
) or else not Is_Access_Type
(E_Id
) then
10519 Error_Pragma_Arg
("pragma% requires access type", Arg1
);
10522 Set_No_Strict_Aliasing
(Implementation_Base_Type
(E_Id
));
10524 end No_Strict_Aliasing
;
10526 -----------------------
10527 -- Normalize_Scalars --
10528 -----------------------
10530 -- pragma Normalize_Scalars;
10532 when Pragma_Normalize_Scalars
=>
10533 Check_Ada_83_Warning
;
10534 Check_Arg_Count
(0);
10535 Check_Valid_Configuration_Pragma
;
10537 -- Normalize_Scalars creates false positives in CodePeer, so
10538 -- ignore this pragma in this mode.
10540 if not CodePeer_Mode
then
10541 Normalize_Scalars
:= True;
10542 Init_Or_Norm_Scalars
:= True;
10549 -- pragma Obsolescent;
10551 -- pragma Obsolescent (
10552 -- [Message =>] static_string_EXPRESSION
10553 -- [,[Version =>] Ada_05]]);
10555 -- pragma Obsolescent (
10556 -- [Entity =>] NAME
10557 -- [,[Message =>] static_string_EXPRESSION
10558 -- [,[Version =>] Ada_05]] );
10560 when Pragma_Obsolescent
=> Obsolescent
: declare
10564 procedure Set_Obsolescent
(E
: Entity_Id
);
10565 -- Given an entity Ent, mark it as obsolescent if appropriate
10567 ---------------------
10568 -- Set_Obsolescent --
10569 ---------------------
10571 procedure Set_Obsolescent
(E
: Entity_Id
) is
10580 -- Entity name was given
10582 if Present
(Ename
) then
10584 -- If entity name matches, we are fine. Save entity in
10585 -- pragma argument, for ASIS use.
10587 if Chars
(Ename
) = Chars
(Ent
) then
10588 Set_Entity
(Ename
, Ent
);
10589 Generate_Reference
(Ent
, Ename
);
10591 -- If entity name does not match, only possibility is an
10592 -- enumeration literal from an enumeration type declaration.
10594 elsif Ekind
(Ent
) /= E_Enumeration_Type
then
10596 ("pragma % entity name does not match declaration");
10599 Ent
:= First_Literal
(E
);
10603 ("pragma % entity name does not match any " &
10604 "enumeration literal");
10606 elsif Chars
(Ent
) = Chars
(Ename
) then
10607 Set_Entity
(Ename
, Ent
);
10608 Generate_Reference
(Ent
, Ename
);
10612 Ent
:= Next_Literal
(Ent
);
10618 -- Ent points to entity to be marked
10620 if Arg_Count
>= 1 then
10622 -- Deal with static string argument
10624 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
10625 S
:= Strval
(Get_Pragma_Arg
(Arg1
));
10627 for J
in 1 .. String_Length
(S
) loop
10628 if not In_Character_Range
(Get_String_Char
(S
, J
)) then
10630 ("pragma% argument does not allow wide characters",
10635 Obsolescent_Warnings
.Append
10636 ((Ent
=> Ent
, Msg
=> Strval
(Get_Pragma_Arg
(Arg1
))));
10638 -- Check for Ada_05 parameter
10640 if Arg_Count
/= 1 then
10641 Check_Arg_Count
(2);
10644 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg2
);
10647 Check_Arg_Is_Identifier
(Argx
);
10649 if Chars
(Argx
) /= Name_Ada_05
then
10650 Error_Msg_Name_2
:= Name_Ada_05
;
10652 ("only allowed argument for pragma% is %", Argx
);
10655 if Ada_Version_Explicit
< Ada_2005
10656 or else not Warn_On_Ada_2005_Compatibility
10664 -- Set flag if pragma active
10667 Set_Is_Obsolescent
(Ent
);
10671 end Set_Obsolescent
;
10673 -- Start of processing for pragma Obsolescent
10678 Check_At_Most_N_Arguments
(3);
10680 -- See if first argument specifies an entity name
10684 (Chars
(Arg1
) = Name_Entity
10686 Nkind_In
(Get_Pragma_Arg
(Arg1
), N_Character_Literal
,
10688 N_Operator_Symbol
))
10690 Ename
:= Get_Pragma_Arg
(Arg1
);
10692 -- Eliminate first argument, so we can share processing
10696 Arg_Count
:= Arg_Count
- 1;
10698 -- No Entity name argument given
10704 if Arg_Count
>= 1 then
10705 Check_Optional_Identifier
(Arg1
, Name_Message
);
10707 if Arg_Count
= 2 then
10708 Check_Optional_Identifier
(Arg2
, Name_Version
);
10712 -- Get immediately preceding declaration
10715 while Present
(Decl
) and then Nkind
(Decl
) = N_Pragma
loop
10719 -- Cases where we do not follow anything other than another pragma
10723 -- First case: library level compilation unit declaration with
10724 -- the pragma immediately following the declaration.
10726 if Nkind
(Parent
(N
)) = N_Compilation_Unit_Aux
then
10728 (Defining_Entity
(Unit
(Parent
(Parent
(N
)))));
10731 -- Case 2: library unit placement for package
10735 Ent
: constant Entity_Id
:= Find_Lib_Unit_Name
;
10737 if Is_Package_Or_Generic_Package
(Ent
) then
10738 Set_Obsolescent
(Ent
);
10744 -- Cases where we must follow a declaration
10747 if Nkind
(Decl
) not in N_Declaration
10748 and then Nkind
(Decl
) not in N_Later_Decl_Item
10749 and then Nkind
(Decl
) not in N_Generic_Declaration
10750 and then Nkind
(Decl
) not in N_Renaming_Declaration
10753 ("pragma% misplaced, "
10754 & "must immediately follow a declaration");
10757 Set_Obsolescent
(Defining_Entity
(Decl
));
10767 -- pragma Optimize (Time | Space | Off);
10769 -- The actual check for optimize is done in Gigi. Note that this
10770 -- pragma does not actually change the optimization setting, it
10771 -- simply checks that it is consistent with the pragma.
10773 when Pragma_Optimize
=>
10774 Check_No_Identifiers
;
10775 Check_Arg_Count
(1);
10776 Check_Arg_Is_One_Of
(Arg1
, Name_Time
, Name_Space
, Name_Off
);
10778 ------------------------
10779 -- Optimize_Alignment --
10780 ------------------------
10782 -- pragma Optimize_Alignment (Time | Space | Off);
10784 when Pragma_Optimize_Alignment
=> Optimize_Alignment
: begin
10786 Check_No_Identifiers
;
10787 Check_Arg_Count
(1);
10788 Check_Valid_Configuration_Pragma
;
10791 Nam
: constant Name_Id
:= Chars
(Get_Pragma_Arg
(Arg1
));
10795 Opt
.Optimize_Alignment
:= 'T';
10797 Opt
.Optimize_Alignment
:= 'S';
10799 Opt
.Optimize_Alignment
:= 'O';
10801 Error_Pragma_Arg
("invalid argument for pragma%", Arg1
);
10805 -- Set indication that mode is set locally. If we are in fact in a
10806 -- configuration pragma file, this setting is harmless since the
10807 -- switch will get reset anyway at the start of each unit.
10809 Optimize_Alignment_Local
:= True;
10810 end Optimize_Alignment
;
10816 -- pragma Ordered (first_enumeration_subtype_LOCAL_NAME);
10818 when Pragma_Ordered
=> Ordered
: declare
10819 Assoc
: constant Node_Id
:= Arg1
;
10825 Check_No_Identifiers
;
10826 Check_Arg_Count
(1);
10827 Check_Arg_Is_Local_Name
(Arg1
);
10829 Type_Id
:= Get_Pragma_Arg
(Assoc
);
10830 Find_Type
(Type_Id
);
10831 Typ
:= Entity
(Type_Id
);
10833 if Typ
= Any_Type
then
10836 Typ
:= Underlying_Type
(Typ
);
10839 if not Is_Enumeration_Type
(Typ
) then
10840 Error_Pragma
("pragma% must specify enumeration type");
10843 Check_First_Subtype
(Arg1
);
10844 Set_Has_Pragma_Ordered
(Base_Type
(Typ
));
10851 -- pragma Pack (first_subtype_LOCAL_NAME);
10853 when Pragma_Pack
=> Pack
: declare
10854 Assoc
: constant Node_Id
:= Arg1
;
10858 Ignore
: Boolean := False;
10861 Check_No_Identifiers
;
10862 Check_Arg_Count
(1);
10863 Check_Arg_Is_Local_Name
(Arg1
);
10865 Type_Id
:= Get_Pragma_Arg
(Assoc
);
10866 Find_Type
(Type_Id
);
10867 Typ
:= Entity
(Type_Id
);
10870 or else Rep_Item_Too_Early
(Typ
, N
)
10874 Typ
:= Underlying_Type
(Typ
);
10877 if not Is_Array_Type
(Typ
) and then not Is_Record_Type
(Typ
) then
10878 Error_Pragma
("pragma% must specify array or record type");
10881 Check_First_Subtype
(Arg1
);
10882 Check_Duplicate_Pragma
(Typ
);
10886 if Is_Array_Type
(Typ
) then
10887 Ctyp
:= Component_Type
(Typ
);
10889 -- Ignore pack that does nothing
10891 if Known_Static_Esize
(Ctyp
)
10892 and then Known_Static_RM_Size
(Ctyp
)
10893 and then Esize
(Ctyp
) = RM_Size
(Ctyp
)
10894 and then Addressable
(Esize
(Ctyp
))
10899 -- Process OK pragma Pack. Note that if there is a separate
10900 -- component clause present, the Pack will be cancelled. This
10901 -- processing is in Freeze.
10903 if not Rep_Item_Too_Late
(Typ
, N
) then
10905 -- In the context of static code analysis, we do not need
10906 -- complex front-end expansions related to pragma Pack,
10907 -- so disable handling of pragma Pack in this case.
10909 if CodePeer_Mode
then
10912 -- Don't attempt any packing for VM targets. We possibly
10913 -- could deal with some cases of array bit-packing, but we
10914 -- don't bother, since this is not a typical kind of
10915 -- representation in the VM context anyway (and would not
10916 -- for example work nicely with the debugger).
10918 elsif VM_Target
/= No_VM
then
10919 if not GNAT_Mode
then
10921 ("?pragma% ignored in this configuration");
10924 -- Normal case where we do the pack action
10928 Set_Is_Packed
(Base_Type
(Typ
), Sense
);
10929 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
), Sense
);
10932 Set_Has_Pragma_Pack
(Base_Type
(Typ
), Sense
);
10934 -- Complete reset action for Aspect_Cancel case
10936 if Sense
= False then
10938 -- Cancel size unless explicitly set
10940 if not Has_Size_Clause
(Typ
)
10941 and then not Has_Object_Size_Clause
(Typ
)
10943 Set_Esize
(Typ
, Uint_0
);
10944 Set_RM_Size
(Typ
, Uint_0
);
10945 Set_Alignment
(Typ
, Uint_0
);
10946 Set_Packed_Array_Type
(Typ
, Empty
);
10949 -- Reset component size unless explicitly set
10951 if not Has_Component_Size_Clause
(Typ
) then
10952 if Known_Static_Esize
(Ctyp
)
10953 and then Known_Static_RM_Size
(Ctyp
)
10954 and then Esize
(Ctyp
) = RM_Size
(Ctyp
)
10955 and then Addressable
(Esize
(Ctyp
))
10958 (Base_Type
(Typ
), Esize
(Ctyp
));
10961 (Base_Type
(Typ
), Uint_0
);
10968 -- For record types, the pack is always effective
10970 else pragma Assert
(Is_Record_Type
(Typ
));
10971 if not Rep_Item_Too_Late
(Typ
, N
) then
10973 -- Ignore pack request with warning in VM mode (skip warning
10974 -- if we are compiling GNAT run time library).
10976 if VM_Target
/= No_VM
then
10977 if not GNAT_Mode
then
10979 ("?pragma% ignored in this configuration");
10982 -- Normal case of pack request active
10985 Set_Is_Packed
(Base_Type
(Typ
), Sense
);
10986 Set_Has_Pragma_Pack
(Base_Type
(Typ
), Sense
);
10987 Set_Has_Non_Standard_Rep
(Base_Type
(Typ
), Sense
);
10989 -- Complete reset action for Aspect_Cancel case
10991 if Sense
= False then
10993 -- Cancel size if not explicitly given
10995 if not Has_Size_Clause
(Typ
)
10996 and then not Has_Object_Size_Clause
(Typ
)
10998 Set_Esize
(Typ
, Uint_0
);
10999 Set_Alignment
(Typ
, Uint_0
);
11013 -- There is nothing to do here, since we did all the processing for
11014 -- this pragma in Par.Prag (so that it works properly even in syntax
11017 when Pragma_Page
=>
11024 -- pragma Passive [(PASSIVE_FORM)];
11026 -- PASSIVE_FORM ::= Semaphore | No
11028 when Pragma_Passive
=>
11031 if Nkind
(Parent
(N
)) /= N_Task_Definition
then
11032 Error_Pragma
("pragma% must be within task definition");
11035 if Arg_Count
/= 0 then
11036 Check_Arg_Count
(1);
11037 Check_Arg_Is_One_Of
(Arg1
, Name_Semaphore
, Name_No
);
11040 ----------------------------------
11041 -- Preelaborable_Initialization --
11042 ----------------------------------
11044 -- pragma Preelaborable_Initialization (DIRECT_NAME);
11046 when Pragma_Preelaborable_Initialization
=> Preelab_Init
: declare
11051 Check_Arg_Count
(1);
11052 Check_No_Identifiers
;
11053 Check_Arg_Is_Identifier
(Arg1
);
11054 Check_Arg_Is_Local_Name
(Arg1
);
11055 Check_First_Subtype
(Arg1
);
11056 Ent
:= Entity
(Get_Pragma_Arg
(Arg1
));
11058 if not (Is_Private_Type
(Ent
)
11060 Is_Protected_Type
(Ent
)
11062 (Is_Generic_Type
(Ent
) and then Is_Derived_Type
(Ent
)))
11065 ("pragma % can only be applied to private, formal derived or "
11066 & "protected type",
11070 -- Give an error if the pragma is applied to a protected type that
11071 -- does not qualify (due to having entries, or due to components
11072 -- that do not qualify).
11074 if Is_Protected_Type
(Ent
)
11075 and then not Has_Preelaborable_Initialization
(Ent
)
11078 ("protected type & does not have preelaborable " &
11079 "initialization", Ent
);
11081 -- Otherwise mark the type as definitely having preelaborable
11085 Set_Known_To_Have_Preelab_Init
(Ent
);
11088 if Has_Pragma_Preelab_Init
(Ent
)
11089 and then Warn_On_Redundant_Constructs
11091 Error_Pragma
("?duplicate pragma%!");
11093 Set_Has_Pragma_Preelab_Init
(Ent
);
11097 --------------------
11098 -- Persistent_BSS --
11099 --------------------
11101 -- pragma Persistent_BSS [(object_NAME)];
11103 when Pragma_Persistent_BSS
=> Persistent_BSS
: declare
11110 Check_At_Most_N_Arguments
(1);
11112 -- Case of application to specific object (one argument)
11114 if Arg_Count
= 1 then
11115 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
11117 if not Is_Entity_Name
(Get_Pragma_Arg
(Arg1
))
11119 Ekind_In
(Entity
(Get_Pragma_Arg
(Arg1
)), E_Variable
,
11122 Error_Pragma_Arg
("pragma% only applies to objects", Arg1
);
11125 Ent
:= Entity
(Get_Pragma_Arg
(Arg1
));
11126 Decl
:= Parent
(Ent
);
11128 if Rep_Item_Too_Late
(Ent
, N
) then
11132 if Present
(Expression
(Decl
)) then
11134 ("object for pragma% cannot have initialization", Arg1
);
11137 if not Is_Potentially_Persistent_Type
(Etype
(Ent
)) then
11139 ("object type for pragma% is not potentially persistent",
11143 Check_Duplicate_Pragma
(Ent
);
11147 Make_Linker_Section_Pragma
11148 (Ent
, Sloc
(N
), ".persistent.bss");
11149 Insert_After
(N
, Prag
);
11153 -- Case of use as configuration pragma with no arguments
11156 Check_Valid_Configuration_Pragma
;
11157 Persistent_BSS_Mode
:= True;
11159 end Persistent_BSS
;
11165 -- pragma Polling (ON | OFF);
11167 when Pragma_Polling
=>
11169 Check_Arg_Count
(1);
11170 Check_No_Identifiers
;
11171 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
11172 Polling_Required
:= (Chars
(Get_Pragma_Arg
(Arg1
)) = Name_On
);
11174 -------------------
11175 -- Postcondition --
11176 -------------------
11178 -- pragma Postcondition ([Check =>] Boolean_Expression
11179 -- [,[Message =>] String_Expression]);
11181 when Pragma_Postcondition
=> Postcondition
: declare
11183 pragma Warnings
(Off
, In_Body
);
11187 Check_At_Least_N_Arguments
(1);
11188 Check_At_Most_N_Arguments
(2);
11189 Check_Optional_Identifier
(Arg1
, Name_Check
);
11191 -- All we need to do here is call the common check procedure,
11192 -- the remainder of the processing is found in Sem_Ch6/Sem_Ch7.
11194 Check_Precondition_Postcondition
(In_Body
);
11201 -- pragma Precondition ([Check =>] Boolean_Expression
11202 -- [,[Message =>] String_Expression]);
11204 when Pragma_Precondition
=> Precondition
: declare
11209 Check_At_Least_N_Arguments
(1);
11210 Check_At_Most_N_Arguments
(2);
11211 Check_Optional_Identifier
(Arg1
, Name_Check
);
11212 Check_Precondition_Postcondition
(In_Body
);
11214 -- If in spec, nothing more to do. If in body, then we convert the
11215 -- pragma to pragma Check (Precondition, cond [, msg]). Note we do
11216 -- this whether or not precondition checks are enabled. That works
11217 -- fine since pragma Check will do this check, and will also
11218 -- analyze the condition itself in the proper context.
11223 Chars
=> Name_Check
,
11224 Pragma_Argument_Associations
=> New_List
(
11225 Make_Pragma_Argument_Association
(Loc
,
11226 Expression
=> Make_Identifier
(Loc
, Name_Precondition
)),
11228 Make_Pragma_Argument_Association
(Sloc
(Arg1
),
11229 Expression
=> Relocate_Node
(Get_Pragma_Arg
(Arg1
))))));
11231 if Arg_Count
= 2 then
11232 Append_To
(Pragma_Argument_Associations
(N
),
11233 Make_Pragma_Argument_Association
(Sloc
(Arg2
),
11234 Expression
=> Relocate_Node
(Get_Pragma_Arg
(Arg2
))));
11245 -- pragma Predicate
11246 -- ([Entity =>] type_LOCAL_NAME,
11247 -- [Check =>] EXPRESSION);
11249 when Pragma_Predicate
=> Predicate
: declare
11254 pragma Unreferenced
(Discard
);
11258 Check_Arg_Count
(2);
11259 Check_Optional_Identifier
(Arg1
, Name_Entity
);
11260 Check_Optional_Identifier
(Arg2
, Name_Check
);
11262 Check_Arg_Is_Local_Name
(Arg1
);
11264 Type_Id
:= Get_Pragma_Arg
(Arg1
);
11265 Find_Type
(Type_Id
);
11266 Typ
:= Entity
(Type_Id
);
11268 if Typ
= Any_Type
then
11272 -- The remaining processing is simply to link the pragma on to
11273 -- the rep item chain, for processing when the type is frozen.
11274 -- This is accomplished by a call to Rep_Item_Too_Late. We also
11275 -- mark the type as having predicates.
11277 Set_Has_Predicates
(Typ
);
11278 Discard
:= Rep_Item_Too_Late
(Typ
, N
, FOnly
=> True);
11285 -- pragma Preelaborate [(library_unit_NAME)];
11287 -- Set the flag Is_Preelaborated of program unit name entity
11289 when Pragma_Preelaborate
=> Preelaborate
: declare
11290 Pa
: constant Node_Id
:= Parent
(N
);
11291 Pk
: constant Node_Kind
:= Nkind
(Pa
);
11295 Check_Ada_83_Warning
;
11296 Check_Valid_Library_Unit_Pragma
;
11298 if Nkind
(N
) = N_Null_Statement
then
11302 Ent
:= Find_Lib_Unit_Name
;
11303 Check_Duplicate_Pragma
(Ent
);
11305 -- This filters out pragmas inside generic parent then
11306 -- show up inside instantiation
11309 and then not (Pk
= N_Package_Specification
11310 and then Present
(Generic_Parent
(Pa
)))
11312 if not Debug_Flag_U
then
11313 Set_Is_Preelaborated
(Ent
, Sense
);
11314 Set_Suppress_Elaboration_Warnings
(Ent
, Sense
);
11319 ---------------------
11320 -- Preelaborate_05 --
11321 ---------------------
11323 -- pragma Preelaborate_05 [(library_unit_NAME)];
11325 -- This pragma is useable only in GNAT_Mode, where it is used like
11326 -- pragma Preelaborate but it is only effective in Ada 2005 mode
11327 -- (otherwise it is ignored). This is used to implement AI-362 which
11328 -- recategorizes some run-time packages in Ada 2005 mode.
11330 when Pragma_Preelaborate_05
=> Preelaborate_05
: declare
11335 Check_Valid_Library_Unit_Pragma
;
11337 if not GNAT_Mode
then
11338 Error_Pragma
("pragma% only available in GNAT mode");
11341 if Nkind
(N
) = N_Null_Statement
then
11345 -- This is one of the few cases where we need to test the value of
11346 -- Ada_Version_Explicit rather than Ada_Version (which is always
11347 -- set to Ada_2012 in a predefined unit), we need to know the
11348 -- explicit version set to know if this pragma is active.
11350 if Ada_Version_Explicit
>= Ada_2005
then
11351 Ent
:= Find_Lib_Unit_Name
;
11352 Set_Is_Preelaborated
(Ent
);
11353 Set_Suppress_Elaboration_Warnings
(Ent
);
11355 end Preelaborate_05
;
11361 -- pragma Priority (EXPRESSION);
11363 when Pragma_Priority
=> Priority
: declare
11364 P
: constant Node_Id
:= Parent
(N
);
11368 Check_No_Identifiers
;
11369 Check_Arg_Count
(1);
11373 if Nkind
(P
) = N_Subprogram_Body
then
11374 Check_In_Main_Program
;
11376 Arg
:= Get_Pragma_Arg
(Arg1
);
11377 Analyze_And_Resolve
(Arg
, Standard_Integer
);
11381 if not Is_Static_Expression
(Arg
) then
11382 Flag_Non_Static_Expr
11383 ("main subprogram priority is not static!", Arg
);
11386 -- If constraint error, then we already signalled an error
11388 elsif Raises_Constraint_Error
(Arg
) then
11391 -- Otherwise check in range
11395 Val
: constant Uint
:= Expr_Value
(Arg
);
11399 or else Val
> Expr_Value
(Expression
11400 (Parent
(RTE
(RE_Max_Priority
))))
11403 ("main subprogram priority is out of range", Arg1
);
11409 (Current_Sem_Unit
, UI_To_Int
(Expr_Value
(Arg
)));
11411 -- Load an arbitrary entity from System.Tasking to make sure
11412 -- this package is implicitly with'ed, since we need to have
11413 -- the tasking run-time active for the pragma Priority to have
11417 Discard
: Entity_Id
;
11418 pragma Warnings
(Off
, Discard
);
11420 Discard
:= RTE
(RE_Task_List
);
11423 -- Task or Protected, must be of type Integer
11425 elsif Nkind_In
(P
, N_Protected_Definition
, N_Task_Definition
) then
11426 Arg
:= Get_Pragma_Arg
(Arg1
);
11428 -- The expression must be analyzed in the special manner
11429 -- described in "Handling of Default and Per-Object
11430 -- Expressions" in sem.ads.
11432 Preanalyze_Spec_Expression
(Arg
, Standard_Integer
);
11434 if not Is_Static_Expression
(Arg
) then
11435 Check_Restriction
(Static_Priorities
, Arg
);
11438 -- Anything else is incorrect
11444 if Has_Pragma_Priority
(P
) then
11445 Error_Pragma
("duplicate pragma% not allowed");
11447 Set_Has_Pragma_Priority
(P
, True);
11449 if Nkind_In
(P
, N_Protected_Definition
, N_Task_Definition
) then
11450 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
11451 -- exp_ch9 should use this ???
11456 -----------------------------------
11457 -- Priority_Specific_Dispatching --
11458 -----------------------------------
11460 -- pragma Priority_Specific_Dispatching (
11461 -- policy_IDENTIFIER,
11462 -- first_priority_EXPRESSION,
11463 -- last_priority_EXPRESSION);
11465 when Pragma_Priority_Specific_Dispatching
=>
11466 Priority_Specific_Dispatching
: declare
11467 Prio_Id
: constant Entity_Id
:= RTE
(RE_Any_Priority
);
11468 -- This is the entity System.Any_Priority;
11471 Lower_Bound
: Node_Id
;
11472 Upper_Bound
: Node_Id
;
11478 Check_Arg_Count
(3);
11479 Check_No_Identifiers
;
11480 Check_Arg_Is_Task_Dispatching_Policy
(Arg1
);
11481 Check_Valid_Configuration_Pragma
;
11482 Get_Name_String
(Chars
(Get_Pragma_Arg
(Arg1
)));
11483 DP
:= Fold_Upper
(Name_Buffer
(1));
11485 Lower_Bound
:= Get_Pragma_Arg
(Arg2
);
11486 Check_Arg_Is_Static_Expression
(Lower_Bound
, Standard_Integer
);
11487 Lower_Val
:= Expr_Value
(Lower_Bound
);
11489 Upper_Bound
:= Get_Pragma_Arg
(Arg3
);
11490 Check_Arg_Is_Static_Expression
(Upper_Bound
, Standard_Integer
);
11491 Upper_Val
:= Expr_Value
(Upper_Bound
);
11493 -- It is not allowed to use Task_Dispatching_Policy and
11494 -- Priority_Specific_Dispatching in the same partition.
11496 if Task_Dispatching_Policy
/= ' ' then
11497 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
11499 ("pragma% incompatible with Task_Dispatching_Policy#");
11501 -- Check lower bound in range
11503 elsif Lower_Val
< Expr_Value
(Type_Low_Bound
(Prio_Id
))
11505 Lower_Val
> Expr_Value
(Type_High_Bound
(Prio_Id
))
11508 ("first_priority is out of range", Arg2
);
11510 -- Check upper bound in range
11512 elsif Upper_Val
< Expr_Value
(Type_Low_Bound
(Prio_Id
))
11514 Upper_Val
> Expr_Value
(Type_High_Bound
(Prio_Id
))
11517 ("last_priority is out of range", Arg3
);
11519 -- Check that the priority range is valid
11521 elsif Lower_Val
> Upper_Val
then
11523 ("last_priority_expression must be greater than" &
11524 " or equal to first_priority_expression");
11526 -- Store the new policy, but always preserve System_Location since
11527 -- we like the error message with the run-time name.
11530 -- Check overlapping in the priority ranges specified in other
11531 -- Priority_Specific_Dispatching pragmas within the same
11532 -- partition. We can only check those we know about!
11535 Specific_Dispatching
.First
.. Specific_Dispatching
.Last
11537 if Specific_Dispatching
.Table
(J
).First_Priority
in
11538 UI_To_Int
(Lower_Val
) .. UI_To_Int
(Upper_Val
)
11539 or else Specific_Dispatching
.Table
(J
).Last_Priority
in
11540 UI_To_Int
(Lower_Val
) .. UI_To_Int
(Upper_Val
)
11543 Specific_Dispatching
.Table
(J
).Pragma_Loc
;
11545 ("priority range overlaps with "
11546 & "Priority_Specific_Dispatching#");
11550 -- The use of Priority_Specific_Dispatching is incompatible
11551 -- with Task_Dispatching_Policy.
11553 if Task_Dispatching_Policy
/= ' ' then
11554 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
11556 ("Priority_Specific_Dispatching incompatible "
11557 & "with Task_Dispatching_Policy#");
11560 -- The use of Priority_Specific_Dispatching forces ceiling
11563 if Locking_Policy
/= ' ' and then Locking_Policy
/= 'C' then
11564 Error_Msg_Sloc
:= Locking_Policy_Sloc
;
11566 ("Priority_Specific_Dispatching incompatible "
11567 & "with Locking_Policy#");
11569 -- Set the Ceiling_Locking policy, but preserve System_Location
11570 -- since we like the error message with the run time name.
11573 Locking_Policy
:= 'C';
11575 if Locking_Policy_Sloc
/= System_Location
then
11576 Locking_Policy_Sloc
:= Loc
;
11580 -- Add entry in the table
11582 Specific_Dispatching
.Append
11583 ((Dispatching_Policy
=> DP
,
11584 First_Priority
=> UI_To_Int
(Lower_Val
),
11585 Last_Priority
=> UI_To_Int
(Upper_Val
),
11586 Pragma_Loc
=> Loc
));
11588 end Priority_Specific_Dispatching
;
11594 -- pragma Profile (profile_IDENTIFIER);
11596 -- profile_IDENTIFIER => Restricted | Ravenscar
11598 when Pragma_Profile
=>
11600 Check_Arg_Count
(1);
11601 Check_Valid_Configuration_Pragma
;
11602 Check_No_Identifiers
;
11605 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
11607 if Chars
(Argx
) = Name_Ravenscar
then
11608 Set_Ravenscar_Profile
(N
);
11609 elsif Chars
(Argx
) = Name_Restricted
then
11610 Set_Profile_Restrictions
11611 (Restricted
, N
, Warn
=> Treat_Restrictions_As_Warnings
);
11613 Error_Pragma_Arg
("& is not a valid profile", Argx
);
11617 ----------------------
11618 -- Profile_Warnings --
11619 ----------------------
11621 -- pragma Profile_Warnings (profile_IDENTIFIER);
11623 -- profile_IDENTIFIER => Restricted | Ravenscar
11625 when Pragma_Profile_Warnings
=>
11627 Check_Arg_Count
(1);
11628 Check_Valid_Configuration_Pragma
;
11629 Check_No_Identifiers
;
11632 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
11634 if Chars
(Argx
) = Name_Ravenscar
then
11635 Set_Profile_Restrictions
(Ravenscar
, N
, Warn
=> True);
11636 elsif Chars
(Argx
) = Name_Restricted
then
11637 Set_Profile_Restrictions
(Restricted
, N
, Warn
=> True);
11639 Error_Pragma_Arg
("& is not a valid profile", Argx
);
11643 --------------------------
11644 -- Propagate_Exceptions --
11645 --------------------------
11647 -- pragma Propagate_Exceptions;
11649 -- Note: this pragma is obsolete and has no effect
11651 when Pragma_Propagate_Exceptions
=>
11653 Check_Arg_Count
(0);
11655 if In_Extended_Main_Source_Unit
(N
) then
11656 Propagate_Exceptions
:= True;
11663 -- pragma Psect_Object (
11664 -- [Internal =>] LOCAL_NAME,
11665 -- [, [External =>] EXTERNAL_SYMBOL]
11666 -- [, [Size =>] EXTERNAL_SYMBOL]);
11668 when Pragma_Psect_Object | Pragma_Common_Object
=>
11669 Psect_Object
: declare
11670 Args
: Args_List
(1 .. 3);
11671 Names
: constant Name_List
(1 .. 3) := (
11676 Internal
: Node_Id
renames Args
(1);
11677 External
: Node_Id
renames Args
(2);
11678 Size
: Node_Id
renames Args
(3);
11680 Def_Id
: Entity_Id
;
11682 procedure Check_Too_Long
(Arg
: Node_Id
);
11683 -- Posts message if the argument is an identifier with more
11684 -- than 31 characters, or a string literal with more than
11685 -- 31 characters, and we are operating under VMS
11687 --------------------
11688 -- Check_Too_Long --
11689 --------------------
11691 procedure Check_Too_Long
(Arg
: Node_Id
) is
11692 X
: constant Node_Id
:= Original_Node
(Arg
);
11695 if not Nkind_In
(X
, N_String_Literal
, N_Identifier
) then
11697 ("inappropriate argument for pragma %", Arg
);
11700 if OpenVMS_On_Target
then
11701 if (Nkind
(X
) = N_String_Literal
11702 and then String_Length
(Strval
(X
)) > 31)
11704 (Nkind
(X
) = N_Identifier
11705 and then Length_Of_Name
(Chars
(X
)) > 31)
11708 ("argument for pragma % is longer than 31 characters",
11712 end Check_Too_Long
;
11714 -- Start of processing for Common_Object/Psect_Object
11718 Gather_Associations
(Names
, Args
);
11719 Process_Extended_Import_Export_Internal_Arg
(Internal
);
11721 Def_Id
:= Entity
(Internal
);
11723 if not Ekind_In
(Def_Id
, E_Constant
, E_Variable
) then
11725 ("pragma% must designate an object", Internal
);
11728 Check_Too_Long
(Internal
);
11730 if Is_Imported
(Def_Id
) or else Is_Exported
(Def_Id
) then
11732 ("cannot use pragma% for imported/exported object",
11736 if Is_Concurrent_Type
(Etype
(Internal
)) then
11738 ("cannot specify pragma % for task/protected object",
11742 if Has_Rep_Pragma
(Def_Id
, Name_Common_Object
)
11744 Has_Rep_Pragma
(Def_Id
, Name_Psect_Object
)
11746 Error_Msg_N
("?duplicate Common/Psect_Object pragma", N
);
11749 if Ekind
(Def_Id
) = E_Constant
then
11751 ("cannot specify pragma % for a constant", Internal
);
11754 if Is_Record_Type
(Etype
(Internal
)) then
11760 Ent
:= First_Entity
(Etype
(Internal
));
11761 while Present
(Ent
) loop
11762 Decl
:= Declaration_Node
(Ent
);
11764 if Ekind
(Ent
) = E_Component
11765 and then Nkind
(Decl
) = N_Component_Declaration
11766 and then Present
(Expression
(Decl
))
11767 and then Warn_On_Export_Import
11770 ("?object for pragma % has defaults", Internal
);
11780 if Present
(Size
) then
11781 Check_Too_Long
(Size
);
11784 if Present
(External
) then
11785 Check_Arg_Is_External_Name
(External
);
11786 Check_Too_Long
(External
);
11789 -- If all error tests pass, link pragma on to the rep item chain
11791 Record_Rep_Item
(Def_Id
, N
);
11798 -- pragma Pure [(library_unit_NAME)];
11800 when Pragma_Pure
=> Pure
: declare
11804 Check_Ada_83_Warning
;
11805 Check_Valid_Library_Unit_Pragma
;
11807 if Nkind
(N
) = N_Null_Statement
then
11811 Ent
:= Find_Lib_Unit_Name
;
11813 Set_Has_Pragma_Pure
(Ent
);
11814 Set_Suppress_Elaboration_Warnings
(Ent
);
11821 -- pragma Pure_05 [(library_unit_NAME)];
11823 -- This pragma is useable only in GNAT_Mode, where it is used like
11824 -- pragma Pure but it is only effective in Ada 2005 mode (otherwise
11825 -- it is ignored). It may be used after a pragma Preelaborate, in
11826 -- which case it overrides the effect of the pragma Preelaborate.
11827 -- This is used to implement AI-362 which recategorizes some run-time
11828 -- packages in Ada 2005 mode.
11830 when Pragma_Pure_05
=> Pure_05
: declare
11835 Check_Valid_Library_Unit_Pragma
;
11837 if not GNAT_Mode
then
11838 Error_Pragma
("pragma% only available in GNAT mode");
11841 if Nkind
(N
) = N_Null_Statement
then
11845 -- This is one of the few cases where we need to test the value of
11846 -- Ada_Version_Explicit rather than Ada_Version (which is always
11847 -- set to Ada_2012 in a predefined unit), we need to know the
11848 -- explicit version set to know if this pragma is active.
11850 if Ada_Version_Explicit
>= Ada_2005
then
11851 Ent
:= Find_Lib_Unit_Name
;
11852 Set_Is_Preelaborated
(Ent
, False);
11854 Set_Suppress_Elaboration_Warnings
(Ent
);
11858 -------------------
11859 -- Pure_Function --
11860 -------------------
11862 -- pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
11864 when Pragma_Pure_Function
=> Pure_Function
: declare
11867 Def_Id
: Entity_Id
;
11868 Effective
: Boolean := False;
11872 Check_Arg_Count
(1);
11873 Check_Optional_Identifier
(Arg1
, Name_Entity
);
11874 Check_Arg_Is_Local_Name
(Arg1
);
11875 E_Id
:= Get_Pragma_Arg
(Arg1
);
11877 if Error_Posted
(E_Id
) then
11881 -- Loop through homonyms (overloadings) of referenced entity
11883 E
:= Entity
(E_Id
);
11885 if Present
(E
) then
11887 Def_Id
:= Get_Base_Subprogram
(E
);
11889 if not Ekind_In
(Def_Id
, E_Function
,
11890 E_Generic_Function
,
11894 ("pragma% requires a function name", Arg1
);
11897 Set_Is_Pure
(Def_Id
, Sense
);
11899 if not Has_Pragma_Pure_Function
(Def_Id
) then
11900 Set_Has_Pragma_Pure_Function
(Def_Id
, Sense
);
11901 Effective
:= Sense
;
11904 exit when From_Aspect_Specification
(N
);
11906 exit when No
(E
) or else Scope
(E
) /= Current_Scope
;
11909 if Sense
and then not Effective
11910 and then Warn_On_Redundant_Constructs
11913 ("pragma Pure_Function on& is redundant?",
11919 --------------------
11920 -- Queuing_Policy --
11921 --------------------
11923 -- pragma Queuing_Policy (policy_IDENTIFIER);
11925 when Pragma_Queuing_Policy
=> declare
11929 Check_Ada_83_Warning
;
11930 Check_Arg_Count
(1);
11931 Check_No_Identifiers
;
11932 Check_Arg_Is_Queuing_Policy
(Arg1
);
11933 Check_Valid_Configuration_Pragma
;
11934 Get_Name_String
(Chars
(Get_Pragma_Arg
(Arg1
)));
11935 QP
:= Fold_Upper
(Name_Buffer
(1));
11937 if Queuing_Policy
/= ' '
11938 and then Queuing_Policy
/= QP
11940 Error_Msg_Sloc
:= Queuing_Policy_Sloc
;
11941 Error_Pragma
("queuing policy incompatible with policy#");
11943 -- Set new policy, but always preserve System_Location since we
11944 -- like the error message with the run time name.
11947 Queuing_Policy
:= QP
;
11949 if Queuing_Policy_Sloc
/= System_Location
then
11950 Queuing_Policy_Sloc
:= Loc
;
11955 -----------------------
11956 -- Relative_Deadline --
11957 -----------------------
11959 -- pragma Relative_Deadline (time_span_EXPRESSION);
11961 when Pragma_Relative_Deadline
=> Relative_Deadline
: declare
11962 P
: constant Node_Id
:= Parent
(N
);
11967 Check_No_Identifiers
;
11968 Check_Arg_Count
(1);
11970 Arg
:= Get_Pragma_Arg
(Arg1
);
11972 -- The expression must be analyzed in the special manner described
11973 -- in "Handling of Default and Per-Object Expressions" in sem.ads.
11975 Preanalyze_Spec_Expression
(Arg
, RTE
(RE_Time_Span
));
11979 if Nkind
(P
) = N_Subprogram_Body
then
11980 Check_In_Main_Program
;
11984 elsif Nkind
(P
) = N_Task_Definition
then
11987 -- Anything else is incorrect
11993 if Has_Relative_Deadline_Pragma
(P
) then
11994 Error_Pragma
("duplicate pragma% not allowed");
11996 Set_Has_Relative_Deadline_Pragma
(P
, True);
11998 if Nkind
(P
) = N_Task_Definition
then
11999 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
12002 end Relative_Deadline
;
12004 ---------------------------
12005 -- Remote_Call_Interface --
12006 ---------------------------
12008 -- pragma Remote_Call_Interface [(library_unit_NAME)];
12010 when Pragma_Remote_Call_Interface
=> Remote_Call_Interface
: declare
12011 Cunit_Node
: Node_Id
;
12012 Cunit_Ent
: Entity_Id
;
12016 Check_Ada_83_Warning
;
12017 Check_Valid_Library_Unit_Pragma
;
12019 if Nkind
(N
) = N_Null_Statement
then
12023 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
12024 K
:= Nkind
(Unit
(Cunit_Node
));
12025 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
12027 if K
= N_Package_Declaration
12028 or else K
= N_Generic_Package_Declaration
12029 or else K
= N_Subprogram_Declaration
12030 or else K
= N_Generic_Subprogram_Declaration
12031 or else (K
= N_Subprogram_Body
12032 and then Acts_As_Spec
(Unit
(Cunit_Node
)))
12037 "pragma% must apply to package or subprogram declaration");
12040 Set_Is_Remote_Call_Interface
(Cunit_Ent
);
12041 end Remote_Call_Interface
;
12047 -- pragma Remote_Types [(library_unit_NAME)];
12049 when Pragma_Remote_Types
=> Remote_Types
: declare
12050 Cunit_Node
: Node_Id
;
12051 Cunit_Ent
: Entity_Id
;
12054 Check_Ada_83_Warning
;
12055 Check_Valid_Library_Unit_Pragma
;
12057 if Nkind
(N
) = N_Null_Statement
then
12061 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
12062 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
12064 if not Nkind_In
(Unit
(Cunit_Node
), N_Package_Declaration
,
12065 N_Generic_Package_Declaration
)
12068 ("pragma% can only apply to a package declaration");
12071 Set_Is_Remote_Types
(Cunit_Ent
);
12078 -- pragma Ravenscar;
12080 when Pragma_Ravenscar
=>
12082 Check_Arg_Count
(0);
12083 Check_Valid_Configuration_Pragma
;
12084 Set_Ravenscar_Profile
(N
);
12086 if Warn_On_Obsolescent_Feature
then
12087 Error_Msg_N
("pragma Ravenscar is an obsolescent feature?", N
);
12088 Error_Msg_N
("|use pragma Profile (Ravenscar) instead", N
);
12091 -------------------------
12092 -- Restricted_Run_Time --
12093 -------------------------
12095 -- pragma Restricted_Run_Time;
12097 when Pragma_Restricted_Run_Time
=>
12099 Check_Arg_Count
(0);
12100 Check_Valid_Configuration_Pragma
;
12101 Set_Profile_Restrictions
12102 (Restricted
, N
, Warn
=> Treat_Restrictions_As_Warnings
);
12104 if Warn_On_Obsolescent_Feature
then
12106 ("pragma Restricted_Run_Time is an obsolescent feature?", N
);
12107 Error_Msg_N
("|use pragma Profile (Restricted) instead", N
);
12114 -- pragma Restrictions (RESTRICTION {, RESTRICTION});
12117 -- restriction_IDENTIFIER
12118 -- | restriction_parameter_IDENTIFIER => EXPRESSION
12120 when Pragma_Restrictions
=>
12121 Process_Restrictions_Or_Restriction_Warnings
12122 (Warn
=> Treat_Restrictions_As_Warnings
);
12124 --------------------------
12125 -- Restriction_Warnings --
12126 --------------------------
12128 -- pragma Restriction_Warnings (RESTRICTION {, RESTRICTION});
12131 -- restriction_IDENTIFIER
12132 -- | restriction_parameter_IDENTIFIER => EXPRESSION
12134 when Pragma_Restriction_Warnings
=>
12136 Process_Restrictions_Or_Restriction_Warnings
(Warn
=> True);
12142 -- pragma Reviewable;
12144 when Pragma_Reviewable
=>
12145 Check_Ada_83_Warning
;
12146 Check_Arg_Count
(0);
12148 -- Call dummy debugging function rv. This is done to assist front
12149 -- end debugging. By placing a Reviewable pragma in the source
12150 -- program, a breakpoint on rv catches this place in the source,
12151 -- allowing convenient stepping to the point of interest.
12155 --------------------------
12156 -- Short_Circuit_And_Or --
12157 --------------------------
12159 when Pragma_Short_Circuit_And_Or
=>
12161 Check_Arg_Count
(0);
12162 Check_Valid_Configuration_Pragma
;
12163 Short_Circuit_And_Or
:= True;
12165 -------------------
12166 -- Share_Generic --
12167 -------------------
12169 -- pragma Share_Generic (NAME {, NAME});
12171 when Pragma_Share_Generic
=>
12173 Process_Generic_List
;
12179 -- pragma Shared (LOCAL_NAME);
12181 when Pragma_Shared
=>
12183 Process_Atomic_Shared_Volatile
;
12185 --------------------
12186 -- Shared_Passive --
12187 --------------------
12189 -- pragma Shared_Passive [(library_unit_NAME)];
12191 -- Set the flag Is_Shared_Passive of program unit name entity
12193 when Pragma_Shared_Passive
=> Shared_Passive
: declare
12194 Cunit_Node
: Node_Id
;
12195 Cunit_Ent
: Entity_Id
;
12198 Check_Ada_83_Warning
;
12199 Check_Valid_Library_Unit_Pragma
;
12201 if Nkind
(N
) = N_Null_Statement
then
12205 Cunit_Node
:= Cunit
(Current_Sem_Unit
);
12206 Cunit_Ent
:= Cunit_Entity
(Current_Sem_Unit
);
12208 if not Nkind_In
(Unit
(Cunit_Node
), N_Package_Declaration
,
12209 N_Generic_Package_Declaration
)
12212 ("pragma% can only apply to a package declaration");
12215 Set_Is_Shared_Passive
(Cunit_Ent
);
12216 end Shared_Passive
;
12218 -----------------------
12219 -- Short_Descriptors --
12220 -----------------------
12222 -- pragma Short_Descriptors;
12224 when Pragma_Short_Descriptors
=>
12226 Check_Arg_Count
(0);
12227 Check_Valid_Configuration_Pragma
;
12228 Short_Descriptors
:= True;
12230 ----------------------
12231 -- Source_File_Name --
12232 ----------------------
12234 -- There are five forms for this pragma:
12236 -- pragma Source_File_Name (
12237 -- [UNIT_NAME =>] unit_NAME,
12238 -- BODY_FILE_NAME => STRING_LITERAL
12239 -- [, [INDEX =>] INTEGER_LITERAL]);
12241 -- pragma Source_File_Name (
12242 -- [UNIT_NAME =>] unit_NAME,
12243 -- SPEC_FILE_NAME => STRING_LITERAL
12244 -- [, [INDEX =>] INTEGER_LITERAL]);
12246 -- pragma Source_File_Name (
12247 -- BODY_FILE_NAME => STRING_LITERAL
12248 -- [, DOT_REPLACEMENT => STRING_LITERAL]
12249 -- [, CASING => CASING_SPEC]);
12251 -- pragma Source_File_Name (
12252 -- SPEC_FILE_NAME => STRING_LITERAL
12253 -- [, DOT_REPLACEMENT => STRING_LITERAL]
12254 -- [, CASING => CASING_SPEC]);
12256 -- pragma Source_File_Name (
12257 -- SUBUNIT_FILE_NAME => STRING_LITERAL
12258 -- [, DOT_REPLACEMENT => STRING_LITERAL]
12259 -- [, CASING => CASING_SPEC]);
12261 -- CASING_SPEC ::= Uppercase | Lowercase | Mixedcase
12263 -- Pragma Source_File_Name_Project (SFNP) is equivalent to pragma
12264 -- Source_File_Name (SFN), however their usage is exclusive: SFN can
12265 -- only be used when no project file is used, while SFNP can only be
12266 -- used when a project file is used.
12268 -- No processing here. Processing was completed during parsing, since
12269 -- we need to have file names set as early as possible. Units are
12270 -- loaded well before semantic processing starts.
12272 -- The only processing we defer to this point is the check for
12273 -- correct placement.
12275 when Pragma_Source_File_Name
=>
12277 Check_Valid_Configuration_Pragma
;
12279 ------------------------------
12280 -- Source_File_Name_Project --
12281 ------------------------------
12283 -- See Source_File_Name for syntax
12285 -- No processing here. Processing was completed during parsing, since
12286 -- we need to have file names set as early as possible. Units are
12287 -- loaded well before semantic processing starts.
12289 -- The only processing we defer to this point is the check for
12290 -- correct placement.
12292 when Pragma_Source_File_Name_Project
=>
12294 Check_Valid_Configuration_Pragma
;
12296 -- Check that a pragma Source_File_Name_Project is used only in a
12297 -- configuration pragmas file.
12299 -- Pragmas Source_File_Name_Project should only be generated by
12300 -- the Project Manager in configuration pragmas files.
12302 -- This is really an ugly test. It seems to depend on some
12303 -- accidental and undocumented property. At the very least it
12304 -- needs to be documented, but it would be better to have a
12305 -- clean way of testing if we are in a configuration file???
12307 if Present
(Parent
(N
)) then
12309 ("pragma% can only appear in a configuration pragmas file");
12312 ----------------------
12313 -- Source_Reference --
12314 ----------------------
12316 -- pragma Source_Reference (INTEGER_LITERAL [, STRING_LITERAL]);
12318 -- Nothing to do, all processing completed in Par.Prag, since we need
12319 -- the information for possible parser messages that are output.
12321 when Pragma_Source_Reference
=>
12324 --------------------------------
12325 -- Static_Elaboration_Desired --
12326 --------------------------------
12328 -- pragma Static_Elaboration_Desired (DIRECT_NAME);
12330 when Pragma_Static_Elaboration_Desired
=>
12332 Check_At_Most_N_Arguments
(1);
12334 if Is_Compilation_Unit
(Current_Scope
)
12335 and then Ekind
(Current_Scope
) = E_Package
12337 Set_Static_Elaboration_Desired
(Current_Scope
, True);
12339 Error_Pragma
("pragma% must apply to a library-level package");
12346 -- pragma Storage_Size (EXPRESSION);
12348 when Pragma_Storage_Size
=> Storage_Size
: declare
12349 P
: constant Node_Id
:= Parent
(N
);
12353 Check_No_Identifiers
;
12354 Check_Arg_Count
(1);
12356 -- The expression must be analyzed in the special manner described
12357 -- in "Handling of Default Expressions" in sem.ads.
12359 Arg
:= Get_Pragma_Arg
(Arg1
);
12360 Preanalyze_Spec_Expression
(Arg
, Any_Integer
);
12362 if not Is_Static_Expression
(Arg
) then
12363 Check_Restriction
(Static_Storage_Size
, Arg
);
12366 if Nkind
(P
) /= N_Task_Definition
then
12371 if Has_Storage_Size_Pragma
(P
) then
12372 Error_Pragma
("duplicate pragma% not allowed");
12374 Set_Has_Storage_Size_Pragma
(P
, True);
12377 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
12378 -- ??? exp_ch9 should use this!
12386 -- pragma Storage_Unit (NUMERIC_LITERAL);
12388 -- Only permitted argument is System'Storage_Unit value
12390 when Pragma_Storage_Unit
=>
12391 Check_No_Identifiers
;
12392 Check_Arg_Count
(1);
12393 Check_Arg_Is_Integer_Literal
(Arg1
);
12395 if Intval
(Get_Pragma_Arg
(Arg1
)) /=
12396 UI_From_Int
(Ttypes
.System_Storage_Unit
)
12398 Error_Msg_Uint_1
:= UI_From_Int
(Ttypes
.System_Storage_Unit
);
12400 ("the only allowed argument for pragma% is ^", Arg1
);
12403 --------------------
12404 -- Stream_Convert --
12405 --------------------
12407 -- pragma Stream_Convert (
12408 -- [Entity =>] type_LOCAL_NAME,
12409 -- [Read =>] function_NAME,
12410 -- [Write =>] function NAME);
12412 when Pragma_Stream_Convert
=> Stream_Convert
: declare
12414 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
);
12415 -- Check that the given argument is the name of a local function
12416 -- of one argument that is not overloaded earlier in the current
12417 -- local scope. A check is also made that the argument is a
12418 -- function with one parameter.
12420 --------------------------------------
12421 -- Check_OK_Stream_Convert_Function --
12422 --------------------------------------
12424 procedure Check_OK_Stream_Convert_Function
(Arg
: Node_Id
) is
12428 Check_Arg_Is_Local_Name
(Arg
);
12429 Ent
:= Entity
(Get_Pragma_Arg
(Arg
));
12431 if Has_Homonym
(Ent
) then
12433 ("argument for pragma% may not be overloaded", Arg
);
12436 if Ekind
(Ent
) /= E_Function
12437 or else No
(First_Formal
(Ent
))
12438 or else Present
(Next_Formal
(First_Formal
(Ent
)))
12441 ("argument for pragma% must be" &
12442 " function of one argument", Arg
);
12444 end Check_OK_Stream_Convert_Function
;
12446 -- Start of processing for Stream_Convert
12450 Check_Arg_Order
((Name_Entity
, Name_Read
, Name_Write
));
12451 Check_Arg_Count
(3);
12452 Check_Optional_Identifier
(Arg1
, Name_Entity
);
12453 Check_Optional_Identifier
(Arg2
, Name_Read
);
12454 Check_Optional_Identifier
(Arg3
, Name_Write
);
12455 Check_Arg_Is_Local_Name
(Arg1
);
12456 Check_OK_Stream_Convert_Function
(Arg2
);
12457 Check_OK_Stream_Convert_Function
(Arg3
);
12460 Typ
: constant Entity_Id
:=
12461 Underlying_Type
(Entity
(Get_Pragma_Arg
(Arg1
)));
12462 Read
: constant Entity_Id
:= Entity
(Get_Pragma_Arg
(Arg2
));
12463 Write
: constant Entity_Id
:= Entity
(Get_Pragma_Arg
(Arg3
));
12466 Check_First_Subtype
(Arg1
);
12468 -- Check for too early or too late. Note that we don't enforce
12469 -- the rule about primitive operations in this case, since, as
12470 -- is the case for explicit stream attributes themselves, these
12471 -- restrictions are not appropriate. Note that the chaining of
12472 -- the pragma by Rep_Item_Too_Late is actually the critical
12473 -- processing done for this pragma.
12475 if Rep_Item_Too_Early
(Typ
, N
)
12477 Rep_Item_Too_Late
(Typ
, N
, FOnly
=> True)
12482 -- Return if previous error
12484 if Etype
(Typ
) = Any_Type
12486 Etype
(Read
) = Any_Type
12488 Etype
(Write
) = Any_Type
12495 if Underlying_Type
(Etype
(Read
)) /= Typ
then
12497 ("incorrect return type for function&", Arg2
);
12500 if Underlying_Type
(Etype
(First_Formal
(Write
))) /= Typ
then
12502 ("incorrect parameter type for function&", Arg3
);
12505 if Underlying_Type
(Etype
(First_Formal
(Read
))) /=
12506 Underlying_Type
(Etype
(Write
))
12509 ("result type of & does not match Read parameter type",
12513 end Stream_Convert
;
12515 -------------------------
12516 -- Style_Checks (GNAT) --
12517 -------------------------
12519 -- pragma Style_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
12521 -- This is processed by the parser since some of the style checks
12522 -- take place during source scanning and parsing. This means that
12523 -- we don't need to issue error messages here.
12525 when Pragma_Style_Checks
=> Style_Checks
: declare
12526 A
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
12532 Check_No_Identifiers
;
12534 -- Two argument form
12536 if Arg_Count
= 2 then
12537 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
12544 E_Id
:= Get_Pragma_Arg
(Arg2
);
12547 if not Is_Entity_Name
(E_Id
) then
12549 ("second argument of pragma% must be entity name",
12553 E
:= Entity
(E_Id
);
12559 Set_Suppress_Style_Checks
(E
,
12560 (Chars
(Get_Pragma_Arg
(Arg1
)) = Name_Off
));
12561 exit when No
(Homonym
(E
));
12567 -- One argument form
12570 Check_Arg_Count
(1);
12572 if Nkind
(A
) = N_String_Literal
then
12576 Slen
: constant Natural := Natural (String_Length
(S
));
12577 Options
: String (1 .. Slen
);
12583 C
:= Get_String_Char
(S
, Int
(J
));
12584 exit when not In_Character_Range
(C
);
12585 Options
(J
) := Get_Character
(C
);
12587 -- If at end of string, set options. As per discussion
12588 -- above, no need to check for errors, since we issued
12589 -- them in the parser.
12592 Set_Style_Check_Options
(Options
);
12600 elsif Nkind
(A
) = N_Identifier
then
12601 if Chars
(A
) = Name_All_Checks
then
12603 Set_GNAT_Style_Check_Options
;
12605 Set_Default_Style_Check_Options
;
12608 elsif Chars
(A
) = Name_On
then
12609 Style_Check
:= True;
12611 elsif Chars
(A
) = Name_Off
then
12612 Style_Check
:= False;
12622 -- pragma Subtitle ([Subtitle =>] STRING_LITERAL);
12624 when Pragma_Subtitle
=>
12626 Check_Arg_Count
(1);
12627 Check_Optional_Identifier
(Arg1
, Name_Subtitle
);
12628 Check_Arg_Is_Static_Expression
(Arg1
, Standard_String
);
12635 -- pragma Suppress (IDENTIFIER [, [On =>] NAME]);
12637 when Pragma_Suppress
=>
12638 Process_Suppress_Unsuppress
(True);
12644 -- pragma Suppress_All;
12646 -- The only check made here is that the pragma has no arguments.
12647 -- There are no placement rules, and the processing required (setting
12648 -- the Has_Pragma_Suppress_All flag in the compilation unit node was
12649 -- taken care of by the parser). Process_Compilation_Unit_Pragmas
12650 -- then creates and inserts a pragma Suppress (All_Checks).
12652 when Pragma_Suppress_All
=>
12654 Check_Arg_Count
(0);
12656 -------------------------
12657 -- Suppress_Debug_Info --
12658 -------------------------
12660 -- pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
12662 when Pragma_Suppress_Debug_Info
=>
12664 Check_Arg_Count
(1);
12665 Check_Optional_Identifier
(Arg1
, Name_Entity
);
12666 Check_Arg_Is_Local_Name
(Arg1
);
12667 Set_Debug_Info_Off
(Entity
(Get_Pragma_Arg
(Arg1
)), Sense
);
12669 ----------------------------------
12670 -- Suppress_Exception_Locations --
12671 ----------------------------------
12673 -- pragma Suppress_Exception_Locations;
12675 when Pragma_Suppress_Exception_Locations
=>
12677 Check_Arg_Count
(0);
12678 Check_Valid_Configuration_Pragma
;
12679 Exception_Locations_Suppressed
:= True;
12681 -----------------------------
12682 -- Suppress_Initialization --
12683 -----------------------------
12685 -- pragma Suppress_Initialization ([Entity =>] type_Name);
12687 when Pragma_Suppress_Initialization
=> Suppress_Init
: declare
12693 Check_Arg_Count
(1);
12694 Check_Optional_Identifier
(Arg1
, Name_Entity
);
12695 Check_Arg_Is_Local_Name
(Arg1
);
12697 E_Id
:= Get_Pragma_Arg
(Arg1
);
12699 if Etype
(E_Id
) = Any_Type
then
12703 E
:= Entity
(E_Id
);
12705 if Is_Type
(E
) then
12706 if Is_Incomplete_Or_Private_Type
(E
) then
12707 if No
(Full_View
(Base_Type
(E
))) then
12709 ("argument of pragma% cannot be an incomplete type",
12712 Set_Suppress_Init_Proc
(Full_View
(Base_Type
(E
)));
12715 Set_Suppress_Init_Proc
(Base_Type
(E
));
12720 ("pragma% requires argument that is a type name", Arg1
);
12728 -- pragma System_Name (DIRECT_NAME);
12730 -- Syntax check: one argument, which must be the identifier GNAT or
12731 -- the identifier GCC, no other identifiers are acceptable.
12733 when Pragma_System_Name
=>
12735 Check_No_Identifiers
;
12736 Check_Arg_Count
(1);
12737 Check_Arg_Is_One_Of
(Arg1
, Name_Gcc
, Name_Gnat
);
12739 -----------------------------
12740 -- Task_Dispatching_Policy --
12741 -----------------------------
12743 -- pragma Task_Dispatching_Policy (policy_IDENTIFIER);
12745 when Pragma_Task_Dispatching_Policy
=> declare
12749 Check_Ada_83_Warning
;
12750 Check_Arg_Count
(1);
12751 Check_No_Identifiers
;
12752 Check_Arg_Is_Task_Dispatching_Policy
(Arg1
);
12753 Check_Valid_Configuration_Pragma
;
12754 Get_Name_String
(Chars
(Get_Pragma_Arg
(Arg1
)));
12755 DP
:= Fold_Upper
(Name_Buffer
(1));
12757 if Task_Dispatching_Policy
/= ' '
12758 and then Task_Dispatching_Policy
/= DP
12760 Error_Msg_Sloc
:= Task_Dispatching_Policy_Sloc
;
12762 ("task dispatching policy incompatible with policy#");
12764 -- Set new policy, but always preserve System_Location since we
12765 -- like the error message with the run time name.
12768 Task_Dispatching_Policy
:= DP
;
12770 if Task_Dispatching_Policy_Sloc
/= System_Location
then
12771 Task_Dispatching_Policy_Sloc
:= Loc
;
12780 -- pragma Task_Info (EXPRESSION);
12782 when Pragma_Task_Info
=> Task_Info
: declare
12783 P
: constant Node_Id
:= Parent
(N
);
12788 if Nkind
(P
) /= N_Task_Definition
then
12789 Error_Pragma
("pragma% must appear in task definition");
12792 Check_No_Identifiers
;
12793 Check_Arg_Count
(1);
12795 Analyze_And_Resolve
12796 (Get_Pragma_Arg
(Arg1
), RTE
(RE_Task_Info_Type
));
12798 if Etype
(Get_Pragma_Arg
(Arg1
)) = Any_Type
then
12802 if Has_Task_Info_Pragma
(P
) then
12803 Error_Pragma
("duplicate pragma% not allowed");
12805 Set_Has_Task_Info_Pragma
(P
, True);
12813 -- pragma Task_Name (string_EXPRESSION);
12815 when Pragma_Task_Name
=> Task_Name
: declare
12816 P
: constant Node_Id
:= Parent
(N
);
12820 Check_No_Identifiers
;
12821 Check_Arg_Count
(1);
12823 Arg
:= Get_Pragma_Arg
(Arg1
);
12825 -- The expression is used in the call to Create_Task, and must be
12826 -- expanded there, not in the context of the current spec. It must
12827 -- however be analyzed to capture global references, in case it
12828 -- appears in a generic context.
12830 Preanalyze_And_Resolve
(Arg
, Standard_String
);
12832 if Nkind
(P
) /= N_Task_Definition
then
12836 if Has_Task_Name_Pragma
(P
) then
12837 Error_Pragma
("duplicate pragma% not allowed");
12839 Set_Has_Task_Name_Pragma
(P
, True);
12840 Record_Rep_Item
(Defining_Identifier
(Parent
(P
)), N
);
12848 -- pragma Task_Storage (
12849 -- [Task_Type =>] LOCAL_NAME,
12850 -- [Top_Guard =>] static_integer_EXPRESSION);
12852 when Pragma_Task_Storage
=> Task_Storage
: declare
12853 Args
: Args_List
(1 .. 2);
12854 Names
: constant Name_List
(1 .. 2) := (
12858 Task_Type
: Node_Id
renames Args
(1);
12859 Top_Guard
: Node_Id
renames Args
(2);
12865 Gather_Associations
(Names
, Args
);
12867 if No
(Task_Type
) then
12869 ("missing task_type argument for pragma%");
12872 Check_Arg_Is_Local_Name
(Task_Type
);
12874 Ent
:= Entity
(Task_Type
);
12876 if not Is_Task_Type
(Ent
) then
12878 ("argument for pragma% must be task type", Task_Type
);
12881 if No
(Top_Guard
) then
12883 ("pragma% takes two arguments", Task_Type
);
12885 Check_Arg_Is_Static_Expression
(Top_Guard
, Any_Integer
);
12888 Check_First_Subtype
(Task_Type
);
12890 if Rep_Item_Too_Late
(Ent
, N
) then
12895 --------------------------
12896 -- Thread_Local_Storage --
12897 --------------------------
12899 -- pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
12901 when Pragma_Thread_Local_Storage
=> Thread_Local_Storage
: declare
12907 Check_Arg_Count
(1);
12908 Check_Optional_Identifier
(Arg1
, Name_Entity
);
12909 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
12911 Id
:= Get_Pragma_Arg
(Arg1
);
12914 if not Is_Entity_Name
(Id
)
12915 or else Ekind
(Entity
(Id
)) /= E_Variable
12917 Error_Pragma_Arg
("local variable name required", Arg1
);
12922 if Rep_Item_Too_Early
(E
, N
)
12923 or else Rep_Item_Too_Late
(E
, N
)
12928 Set_Has_Pragma_Thread_Local_Storage
(E
);
12929 Set_Has_Gigi_Rep_Item
(E
);
12930 end Thread_Local_Storage
;
12936 -- pragma Time_Slice (static_duration_EXPRESSION);
12938 when Pragma_Time_Slice
=> Time_Slice
: declare
12944 Check_Arg_Count
(1);
12945 Check_No_Identifiers
;
12946 Check_In_Main_Program
;
12947 Check_Arg_Is_Static_Expression
(Arg1
, Standard_Duration
);
12949 if not Error_Posted
(Arg1
) then
12951 while Present
(Nod
) loop
12952 if Nkind
(Nod
) = N_Pragma
12953 and then Pragma_Name
(Nod
) = Name_Time_Slice
12955 Error_Msg_Name_1
:= Pname
;
12956 Error_Msg_N
("duplicate pragma% not permitted", Nod
);
12963 -- Process only if in main unit
12965 if Get_Source_Unit
(Loc
) = Main_Unit
then
12966 Opt
.Time_Slice_Set
:= True;
12967 Val
:= Expr_Value_R
(Get_Pragma_Arg
(Arg1
));
12969 if Val
<= Ureal_0
then
12970 Opt
.Time_Slice_Value
:= 0;
12972 elsif Val
> UR_From_Uint
(UI_From_Int
(1000)) then
12973 Opt
.Time_Slice_Value
:= 1_000_000_000
;
12976 Opt
.Time_Slice_Value
:=
12977 UI_To_Int
(UR_To_Uint
(Val
* UI_From_Int
(1_000_000
)));
12986 -- pragma Title (TITLING_OPTION [, TITLING OPTION]);
12988 -- TITLING_OPTION ::=
12989 -- [Title =>] STRING_LITERAL
12990 -- | [Subtitle =>] STRING_LITERAL
12992 when Pragma_Title
=> Title
: declare
12993 Args
: Args_List
(1 .. 2);
12994 Names
: constant Name_List
(1 .. 2) := (
13000 Gather_Associations
(Names
, Args
);
13003 for J
in 1 .. 2 loop
13004 if Present
(Args
(J
)) then
13005 Check_Arg_Is_Static_Expression
(Args
(J
), Standard_String
);
13010 ---------------------
13011 -- Unchecked_Union --
13012 ---------------------
13014 -- pragma Unchecked_Union (first_subtype_LOCAL_NAME)
13016 when Pragma_Unchecked_Union
=> Unchecked_Union
: declare
13017 Assoc
: constant Node_Id
:= Arg1
;
13018 Type_Id
: constant Node_Id
:= Get_Pragma_Arg
(Assoc
);
13029 Check_No_Identifiers
;
13030 Check_Arg_Count
(1);
13031 Check_Arg_Is_Local_Name
(Arg1
);
13033 Find_Type
(Type_Id
);
13034 Typ
:= Entity
(Type_Id
);
13037 or else Rep_Item_Too_Early
(Typ
, N
)
13041 Typ
:= Underlying_Type
(Typ
);
13044 if Rep_Item_Too_Late
(Typ
, N
) then
13048 Check_First_Subtype
(Arg1
);
13050 -- Note remaining cases are references to a type in the current
13051 -- declarative part. If we find an error, we post the error on
13052 -- the relevant type declaration at an appropriate point.
13054 if not Is_Record_Type
(Typ
) then
13055 Error_Msg_N
("Unchecked_Union must be record type", Typ
);
13058 elsif Is_Tagged_Type
(Typ
) then
13059 Error_Msg_N
("Unchecked_Union must not be tagged", Typ
);
13062 elsif Is_Limited_Type
(Typ
) then
13064 ("Unchecked_Union must not be limited record type", Typ
);
13065 Explain_Limited_Type
(Typ
, Typ
);
13069 if not Has_Discriminants
(Typ
) then
13071 ("Unchecked_Union must have one discriminant", Typ
);
13075 Discr
:= First_Discriminant
(Typ
);
13076 while Present
(Discr
) loop
13077 if No
(Discriminant_Default_Value
(Discr
)) then
13079 ("Unchecked_Union discriminant must have default value",
13083 Next_Discriminant
(Discr
);
13086 Tdef
:= Type_Definition
(Declaration_Node
(Typ
));
13087 Clist
:= Component_List
(Tdef
);
13089 Comp
:= First
(Component_Items
(Clist
));
13090 while Present
(Comp
) loop
13091 Check_Component
(Comp
, Typ
);
13095 if No
(Clist
) or else No
(Variant_Part
(Clist
)) then
13097 ("Unchecked_Union must have variant part",
13102 Vpart
:= Variant_Part
(Clist
);
13104 Variant
:= First
(Variants
(Vpart
));
13105 while Present
(Variant
) loop
13106 Check_Variant
(Variant
, Typ
);
13111 Set_Is_Unchecked_Union
(Typ
, Sense
);
13114 Set_Convention
(Typ
, Convention_C
);
13117 Set_Has_Unchecked_Union
(Base_Type
(Typ
), Sense
);
13118 Set_Is_Unchecked_Union
(Base_Type
(Typ
), Sense
);
13119 end Unchecked_Union
;
13121 ------------------------
13122 -- Unimplemented_Unit --
13123 ------------------------
13125 -- pragma Unimplemented_Unit;
13127 -- Note: this only gives an error if we are generating code, or if
13128 -- we are in a generic library unit (where the pragma appears in the
13129 -- body, not in the spec).
13131 when Pragma_Unimplemented_Unit
=> Unimplemented_Unit
: declare
13132 Cunitent
: constant Entity_Id
:=
13133 Cunit_Entity
(Get_Source_Unit
(Loc
));
13134 Ent_Kind
: constant Entity_Kind
:=
13139 Check_Arg_Count
(0);
13141 if Operating_Mode
= Generate_Code
13142 or else Ent_Kind
= E_Generic_Function
13143 or else Ent_Kind
= E_Generic_Procedure
13144 or else Ent_Kind
= E_Generic_Package
13146 Get_Name_String
(Chars
(Cunitent
));
13147 Set_Casing
(Mixed_Case
);
13148 Write_Str
(Name_Buffer
(1 .. Name_Len
));
13149 Write_Str
(" is not supported in this configuration");
13151 raise Unrecoverable_Error
;
13153 end Unimplemented_Unit
;
13155 ------------------------
13156 -- Universal_Aliasing --
13157 ------------------------
13159 -- pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
13161 when Pragma_Universal_Aliasing
=> Universal_Alias
: declare
13166 Check_Arg_Count
(1);
13167 Check_Optional_Identifier
(Arg2
, Name_Entity
);
13168 Check_Arg_Is_Local_Name
(Arg1
);
13169 E_Id
:= Entity
(Get_Pragma_Arg
(Arg1
));
13171 if E_Id
= Any_Type
then
13173 elsif No
(E_Id
) or else not Is_Type
(E_Id
) then
13174 Error_Pragma_Arg
("pragma% requires type", Arg1
);
13177 Set_Universal_Aliasing
(Implementation_Base_Type
(E_Id
), Sense
);
13178 end Universal_Alias
;
13180 --------------------
13181 -- Universal_Data --
13182 --------------------
13184 -- pragma Universal_Data [(library_unit_NAME)];
13186 when Pragma_Universal_Data
=>
13189 -- If this is a configuration pragma, then set the universal
13190 -- addressing option, otherwise confirm that the pragma satisfies
13191 -- the requirements of library unit pragma placement and leave it
13192 -- to the GNAAMP back end to detect the pragma (avoids transitive
13193 -- setting of the option due to withed units).
13195 if Is_Configuration_Pragma
then
13196 Universal_Addressing_On_AAMP
:= True;
13198 Check_Valid_Library_Unit_Pragma
;
13201 if not AAMP_On_Target
then
13202 Error_Pragma
("?pragma% ignored (applies only to AAMP)");
13209 -- pragma Unmodified (local_Name {, local_Name});
13211 when Pragma_Unmodified
=> Unmodified
: declare
13212 Arg_Node
: Node_Id
;
13213 Arg_Expr
: Node_Id
;
13214 Arg_Ent
: Entity_Id
;
13218 Check_At_Least_N_Arguments
(1);
13220 -- Loop through arguments
13223 while Present
(Arg_Node
) loop
13224 Check_No_Identifier
(Arg_Node
);
13226 -- Note: the analyze call done by Check_Arg_Is_Local_Name will
13227 -- in fact generate reference, so that the entity will have a
13228 -- reference, which will inhibit any warnings about it not
13229 -- being referenced, and also properly show up in the ali file
13230 -- as a reference. But this reference is recorded before the
13231 -- Has_Pragma_Unreferenced flag is set, so that no warning is
13232 -- generated for this reference.
13234 Check_Arg_Is_Local_Name
(Arg_Node
);
13235 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
13237 if Is_Entity_Name
(Arg_Expr
) then
13238 Arg_Ent
:= Entity
(Arg_Expr
);
13240 if not Is_Assignable
(Arg_Ent
) then
13242 ("pragma% can only be applied to a variable",
13245 Set_Has_Pragma_Unmodified
(Arg_Ent
, Sense
);
13257 -- pragma Unreferenced (local_Name {, local_Name});
13259 -- or when used in a context clause:
13261 -- pragma Unreferenced (library_unit_NAME {, library_unit_NAME}
13263 when Pragma_Unreferenced
=> Unreferenced
: declare
13264 Arg_Node
: Node_Id
;
13265 Arg_Expr
: Node_Id
;
13266 Arg_Ent
: Entity_Id
;
13271 Check_At_Least_N_Arguments
(1);
13273 -- Check case of appearing within context clause
13275 if Is_In_Context_Clause
then
13277 -- The arguments must all be units mentioned in a with clause
13278 -- in the same context clause. Note we already checked (in
13279 -- Par.Prag) that the arguments are either identifiers or
13280 -- selected components.
13283 while Present
(Arg_Node
) loop
13284 Citem
:= First
(List_Containing
(N
));
13285 while Citem
/= N
loop
13286 if Nkind
(Citem
) = N_With_Clause
13288 Same_Name
(Name
(Citem
), Get_Pragma_Arg
(Arg_Node
))
13290 Set_Has_Pragma_Unreferenced
13293 (Library_Unit
(Citem
))));
13295 (Get_Pragma_Arg
(Arg_Node
), Name
(Citem
));
13304 ("argument of pragma% is not with'ed unit", Arg_Node
);
13310 -- Case of not in list of context items
13314 while Present
(Arg_Node
) loop
13315 Check_No_Identifier
(Arg_Node
);
13317 -- Note: the analyze call done by Check_Arg_Is_Local_Name
13318 -- will in fact generate reference, so that the entity will
13319 -- have a reference, which will inhibit any warnings about
13320 -- it not being referenced, and also properly show up in the
13321 -- ali file as a reference. But this reference is recorded
13322 -- before the Has_Pragma_Unreferenced flag is set, so that
13323 -- no warning is generated for this reference.
13325 Check_Arg_Is_Local_Name
(Arg_Node
);
13326 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
13328 if Is_Entity_Name
(Arg_Expr
) then
13329 Arg_Ent
:= Entity
(Arg_Expr
);
13331 -- If the entity is overloaded, the pragma applies to the
13332 -- most recent overloading, as documented. In this case,
13333 -- name resolution does not generate a reference, so it
13334 -- must be done here explicitly.
13336 if Is_Overloaded
(Arg_Expr
) then
13337 Generate_Reference
(Arg_Ent
, N
);
13340 Set_Has_Pragma_Unreferenced
(Arg_Ent
, Sense
);
13348 --------------------------
13349 -- Unreferenced_Objects --
13350 --------------------------
13352 -- pragma Unreferenced_Objects (local_Name {, local_Name});
13354 when Pragma_Unreferenced_Objects
=> Unreferenced_Objects
: declare
13355 Arg_Node
: Node_Id
;
13356 Arg_Expr
: Node_Id
;
13360 Check_At_Least_N_Arguments
(1);
13363 while Present
(Arg_Node
) loop
13364 Check_No_Identifier
(Arg_Node
);
13365 Check_Arg_Is_Local_Name
(Arg_Node
);
13366 Arg_Expr
:= Get_Pragma_Arg
(Arg_Node
);
13368 if not Is_Entity_Name
(Arg_Expr
)
13369 or else not Is_Type
(Entity
(Arg_Expr
))
13372 ("argument for pragma% must be type or subtype", Arg_Node
);
13375 Set_Has_Pragma_Unreferenced_Objects
(Entity
(Arg_Expr
), Sense
);
13378 end Unreferenced_Objects
;
13380 ------------------------------
13381 -- Unreserve_All_Interrupts --
13382 ------------------------------
13384 -- pragma Unreserve_All_Interrupts;
13386 when Pragma_Unreserve_All_Interrupts
=>
13388 Check_Arg_Count
(0);
13390 if In_Extended_Main_Code_Unit
(Main_Unit_Entity
) then
13391 Unreserve_All_Interrupts
:= True;
13398 -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
13400 when Pragma_Unsuppress
=>
13402 Process_Suppress_Unsuppress
(False);
13404 -------------------
13405 -- Use_VADS_Size --
13406 -------------------
13408 -- pragma Use_VADS_Size;
13410 when Pragma_Use_VADS_Size
=>
13412 Check_Arg_Count
(0);
13413 Check_Valid_Configuration_Pragma
;
13414 Use_VADS_Size
:= True;
13416 ---------------------
13417 -- Validity_Checks --
13418 ---------------------
13420 -- pragma Validity_Checks (On | Off | ALL_CHECKS | STRING_LITERAL);
13422 when Pragma_Validity_Checks
=> Validity_Checks
: declare
13423 A
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
13429 Check_Arg_Count
(1);
13430 Check_No_Identifiers
;
13432 if Nkind
(A
) = N_String_Literal
then
13436 Slen
: constant Natural := Natural (String_Length
(S
));
13437 Options
: String (1 .. Slen
);
13443 C
:= Get_String_Char
(S
, Int
(J
));
13444 exit when not In_Character_Range
(C
);
13445 Options
(J
) := Get_Character
(C
);
13448 Set_Validity_Check_Options
(Options
);
13456 elsif Nkind
(A
) = N_Identifier
then
13458 if Chars
(A
) = Name_All_Checks
then
13459 Set_Validity_Check_Options
("a");
13461 elsif Chars
(A
) = Name_On
then
13462 Validity_Checks_On
:= True;
13464 elsif Chars
(A
) = Name_Off
then
13465 Validity_Checks_On
:= False;
13469 end Validity_Checks
;
13475 -- pragma Volatile (LOCAL_NAME);
13477 when Pragma_Volatile
=>
13478 Process_Atomic_Shared_Volatile
;
13480 -------------------------
13481 -- Volatile_Components --
13482 -------------------------
13484 -- pragma Volatile_Components (array_LOCAL_NAME);
13486 -- Volatile is handled by the same circuit as Atomic_Components
13492 -- pragma Warnings (On | Off);
13493 -- pragma Warnings (On | Off, LOCAL_NAME);
13494 -- pragma Warnings (static_string_EXPRESSION);
13495 -- pragma Warnings (On | Off, STRING_LITERAL);
13497 when Pragma_Warnings
=> Warnings
: begin
13499 Check_At_Least_N_Arguments
(1);
13500 Check_No_Identifiers
;
13502 -- If debug flag -gnatd.i is set, pragma is ignored
13504 if Debug_Flag_Dot_I
then
13508 -- Process various forms of the pragma
13511 Argx
: constant Node_Id
:= Get_Pragma_Arg
(Arg1
);
13514 -- One argument case
13516 if Arg_Count
= 1 then
13518 -- On/Off one argument case was processed by parser
13520 if Nkind
(Argx
) = N_Identifier
13522 (Chars
(Argx
) = Name_On
13524 Chars
(Argx
) = Name_Off
)
13528 -- One argument case must be ON/OFF or static string expr
13530 elsif not Is_Static_String_Expression
(Arg1
) then
13532 ("argument of pragma% must be On/Off or " &
13533 "static string expression", Arg1
);
13535 -- One argument string expression case
13539 Lit
: constant Node_Id
:= Expr_Value_S
(Argx
);
13540 Str
: constant String_Id
:= Strval
(Lit
);
13541 Len
: constant Nat
:= String_Length
(Str
);
13549 while J
<= Len
loop
13550 C
:= Get_String_Char
(Str
, J
);
13551 OK
:= In_Character_Range
(C
);
13554 Chr
:= Get_Character
(C
);
13558 if J
< Len
and then Chr
= '.' then
13560 C
:= Get_String_Char
(Str
, J
);
13561 Chr
:= Get_Character
(C
);
13563 if not Set_Dot_Warning_Switch
(Chr
) then
13565 ("invalid warning switch character " &
13572 OK
:= Set_Warning_Switch
(Chr
);
13578 ("invalid warning switch character " & Chr
,
13587 -- Two or more arguments (must be two)
13590 Check_Arg_Is_One_Of
(Arg1
, Name_On
, Name_Off
);
13591 Check_At_Most_N_Arguments
(2);
13599 E_Id
:= Get_Pragma_Arg
(Arg2
);
13602 -- In the expansion of an inlined body, a reference to
13603 -- the formal may be wrapped in a conversion if the
13604 -- actual is a conversion. Retrieve the real entity name.
13606 if (In_Instance_Body
13607 or else In_Inlined_Body
)
13608 and then Nkind
(E_Id
) = N_Unchecked_Type_Conversion
13610 E_Id
:= Expression
(E_Id
);
13613 -- Entity name case
13615 if Is_Entity_Name
(E_Id
) then
13616 E
:= Entity
(E_Id
);
13623 (E
, (Chars
(Get_Pragma_Arg
(Arg1
)) =
13626 if Chars
(Get_Pragma_Arg
(Arg1
)) = Name_Off
13627 and then Warn_On_Warnings_Off
13629 Warnings_Off_Pragmas
.Append
((N
, E
));
13632 if Is_Enumeration_Type
(E
) then
13636 Lit
:= First_Literal
(E
);
13637 while Present
(Lit
) loop
13638 Set_Warnings_Off
(Lit
);
13639 Next_Literal
(Lit
);
13644 exit when No
(Homonym
(E
));
13649 -- Error if not entity or static string literal case
13651 elsif not Is_Static_String_Expression
(Arg2
) then
13653 ("second argument of pragma% must be entity " &
13654 "name or static string expression", Arg2
);
13656 -- String literal case
13659 String_To_Name_Buffer
13660 (Strval
(Expr_Value_S
(Get_Pragma_Arg
(Arg2
))));
13662 -- Note on configuration pragma case: If this is a
13663 -- configuration pragma, then for an OFF pragma, we
13664 -- just set Config True in the call, which is all
13665 -- that needs to be done. For the case of ON, this
13666 -- is normally an error, unless it is canceling the
13667 -- effect of a previous OFF pragma in the same file.
13668 -- In any other case, an error will be signalled (ON
13669 -- with no matching OFF).
13671 if Chars
(Argx
) = Name_Off
then
13672 Set_Specific_Warning_Off
13673 (Loc
, Name_Buffer
(1 .. Name_Len
),
13674 Config
=> Is_Configuration_Pragma
);
13676 elsif Chars
(Argx
) = Name_On
then
13677 Set_Specific_Warning_On
13678 (Loc
, Name_Buffer
(1 .. Name_Len
), Err
);
13682 ("?pragma Warnings On with no " &
13683 "matching Warnings Off",
13693 -------------------
13694 -- Weak_External --
13695 -------------------
13697 -- pragma Weak_External ([Entity =>] LOCAL_NAME);
13699 when Pragma_Weak_External
=> Weak_External
: declare
13704 Check_Arg_Count
(1);
13705 Check_Optional_Identifier
(Arg1
, Name_Entity
);
13706 Check_Arg_Is_Library_Level_Local_Name
(Arg1
);
13707 Ent
:= Entity
(Get_Pragma_Arg
(Arg1
));
13709 if Rep_Item_Too_Early
(Ent
, N
) then
13712 Ent
:= Underlying_Type
(Ent
);
13715 -- The only processing required is to link this item on to the
13716 -- list of rep items for the given entity. This is accomplished
13717 -- by the call to Rep_Item_Too_Late (when no error is detected
13718 -- and False is returned).
13720 if Rep_Item_Too_Late
(Ent
, N
) then
13723 Set_Has_Gigi_Rep_Item
(Ent
);
13727 -----------------------------
13728 -- Wide_Character_Encoding --
13729 -----------------------------
13731 -- pragma Wide_Character_Encoding (IDENTIFIER);
13733 when Pragma_Wide_Character_Encoding
=>
13736 -- Nothing to do, handled in parser. Note that we do not enforce
13737 -- configuration pragma placement, this pragma can appear at any
13738 -- place in the source, allowing mixed encodings within a single
13743 --------------------
13744 -- Unknown_Pragma --
13745 --------------------
13747 -- Should be impossible, since the case of an unknown pragma is
13748 -- separately processed before the case statement is entered.
13750 when Unknown_Pragma
=>
13751 raise Program_Error
;
13754 -- AI05-0144: detect dangerous order dependence. Disabled for now,
13755 -- until AI is formally approved.
13757 -- Check_Order_Dependence;
13760 when Pragma_Exit
=> null;
13761 end Analyze_Pragma
;
13763 -------------------
13764 -- Check_Enabled --
13765 -------------------
13767 function Check_Enabled
(Nam
: Name_Id
) return Boolean is
13771 -- Loop through entries in check policy list
13773 PP
:= Opt
.Check_Policy_List
;
13775 -- If there are no specific entries that matched, then we let the
13776 -- setting of assertions govern. Note that this provides the needed
13777 -- compatibility with the RM for the cases of assertion, invariant,
13778 -- precondition, predicate, and postcondition.
13781 return Assertions_Enabled
;
13783 -- Here we have an entry see if it matches
13787 PPA
: constant List_Id
:= Pragma_Argument_Associations
(PP
);
13790 if Nam
= Chars
(Get_Pragma_Arg
(First
(PPA
))) then
13791 case (Chars
(Get_Pragma_Arg
(Last
(PPA
)))) is
13792 when Name_On | Name_Check
=>
13794 when Name_Off | Name_Ignore
=>
13797 raise Program_Error
;
13801 PP
:= Next_Pragma
(PP
);
13808 ---------------------------------
13809 -- Delay_Config_Pragma_Analyze --
13810 ---------------------------------
13812 function Delay_Config_Pragma_Analyze
(N
: Node_Id
) return Boolean is
13814 return Pragma_Name
(N
) = Name_Interrupt_State
13816 Pragma_Name
(N
) = Name_Priority_Specific_Dispatching
;
13817 end Delay_Config_Pragma_Analyze
;
13819 -------------------------
13820 -- Get_Base_Subprogram --
13821 -------------------------
13823 function Get_Base_Subprogram
(Def_Id
: Entity_Id
) return Entity_Id
is
13824 Result
: Entity_Id
;
13827 -- Follow subprogram renaming chain
13830 while Is_Subprogram
(Result
)
13832 (Is_Generic_Instance
(Result
)
13833 or else Nkind
(Parent
(Declaration_Node
(Result
))) =
13834 N_Subprogram_Renaming_Declaration
)
13835 and then Present
(Alias
(Result
))
13837 Result
:= Alias
(Result
);
13841 end Get_Base_Subprogram
;
13847 procedure Initialize
is
13852 -----------------------------
13853 -- Is_Config_Static_String --
13854 -----------------------------
13856 function Is_Config_Static_String
(Arg
: Node_Id
) return Boolean is
13858 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean;
13859 -- This is an internal recursive function that is just like the outer
13860 -- function except that it adds the string to the name buffer rather
13861 -- than placing the string in the name buffer.
13863 ------------------------------
13864 -- Add_Config_Static_String --
13865 ------------------------------
13867 function Add_Config_Static_String
(Arg
: Node_Id
) return Boolean is
13874 if Nkind
(N
) = N_Op_Concat
then
13875 if Add_Config_Static_String
(Left_Opnd
(N
)) then
13876 N
:= Right_Opnd
(N
);
13882 if Nkind
(N
) /= N_String_Literal
then
13883 Error_Msg_N
("string literal expected for pragma argument", N
);
13887 for J
in 1 .. String_Length
(Strval
(N
)) loop
13888 C
:= Get_String_Char
(Strval
(N
), J
);
13890 if not In_Character_Range
(C
) then
13892 ("string literal contains invalid wide character",
13893 Sloc
(N
) + 1 + Source_Ptr
(J
));
13897 Add_Char_To_Name_Buffer
(Get_Character
(C
));
13902 end Add_Config_Static_String
;
13904 -- Start of processing for Is_Config_Static_String
13909 return Add_Config_Static_String
(Arg
);
13910 end Is_Config_Static_String
;
13912 -----------------------------------------
13913 -- Is_Non_Significant_Pragma_Reference --
13914 -----------------------------------------
13916 -- This function makes use of the following static table which indicates
13917 -- whether a given pragma is significant.
13919 -- -1 indicates that references in any argument position are significant
13920 -- 0 indicates that appearence in any argument is not significant
13921 -- +n indicates that appearence as argument n is significant, but all
13922 -- other arguments are not significant
13923 -- 99 special processing required (e.g. for pragma Check)
13925 Sig_Flags
: constant array (Pragma_Id
) of Int
:=
13926 (Pragma_AST_Entry
=> -1,
13927 Pragma_Abort_Defer
=> -1,
13928 Pragma_Ada_83
=> -1,
13929 Pragma_Ada_95
=> -1,
13930 Pragma_Ada_05
=> -1,
13931 Pragma_Ada_2005
=> -1,
13932 Pragma_Ada_12
=> -1,
13933 Pragma_Ada_2012
=> -1,
13934 Pragma_All_Calls_Remote
=> -1,
13935 Pragma_Annotate
=> -1,
13936 Pragma_Assert
=> -1,
13937 Pragma_Assertion_Policy
=> 0,
13938 Pragma_Assume_No_Invalid_Values
=> 0,
13939 Pragma_Asynchronous
=> -1,
13940 Pragma_Atomic
=> 0,
13941 Pragma_Atomic_Components
=> 0,
13942 Pragma_Attach_Handler
=> -1,
13943 Pragma_Check
=> 99,
13944 Pragma_Check_Name
=> 0,
13945 Pragma_Check_Policy
=> 0,
13946 Pragma_CIL_Constructor
=> -1,
13947 Pragma_CPP_Class
=> 0,
13948 Pragma_CPP_Constructor
=> 0,
13949 Pragma_CPP_Virtual
=> 0,
13950 Pragma_CPP_Vtable
=> 0,
13952 Pragma_C_Pass_By_Copy
=> 0,
13953 Pragma_Comment
=> 0,
13954 Pragma_Common_Object
=> -1,
13955 Pragma_Compile_Time_Error
=> -1,
13956 Pragma_Compile_Time_Warning
=> -1,
13957 Pragma_Compiler_Unit
=> 0,
13958 Pragma_Complete_Representation
=> 0,
13959 Pragma_Complex_Representation
=> 0,
13960 Pragma_Component_Alignment
=> -1,
13961 Pragma_Controlled
=> 0,
13962 Pragma_Convention
=> 0,
13963 Pragma_Convention_Identifier
=> 0,
13964 Pragma_Debug
=> -1,
13965 Pragma_Debug_Policy
=> 0,
13966 Pragma_Detect_Blocking
=> -1,
13967 Pragma_Default_Storage_Pool
=> -1,
13968 Pragma_Dimension
=> -1,
13969 Pragma_Discard_Names
=> 0,
13970 Pragma_Elaborate
=> -1,
13971 Pragma_Elaborate_All
=> -1,
13972 Pragma_Elaborate_Body
=> -1,
13973 Pragma_Elaboration_Checks
=> -1,
13974 Pragma_Eliminate
=> -1,
13975 Pragma_Export
=> -1,
13976 Pragma_Export_Exception
=> -1,
13977 Pragma_Export_Function
=> -1,
13978 Pragma_Export_Object
=> -1,
13979 Pragma_Export_Procedure
=> -1,
13980 Pragma_Export_Value
=> -1,
13981 Pragma_Export_Valued_Procedure
=> -1,
13982 Pragma_Extend_System
=> -1,
13983 Pragma_Extensions_Allowed
=> -1,
13984 Pragma_External
=> -1,
13985 Pragma_Favor_Top_Level
=> -1,
13986 Pragma_External_Name_Casing
=> -1,
13987 Pragma_Fast_Math
=> -1,
13988 Pragma_Finalize_Storage_Only
=> 0,
13989 Pragma_Float_Representation
=> 0,
13990 Pragma_Ident
=> -1,
13991 Pragma_Implemented
=> -1,
13992 Pragma_Implicit_Packing
=> 0,
13993 Pragma_Import
=> +2,
13994 Pragma_Import_Exception
=> 0,
13995 Pragma_Import_Function
=> 0,
13996 Pragma_Import_Object
=> 0,
13997 Pragma_Import_Procedure
=> 0,
13998 Pragma_Import_Valued_Procedure
=> 0,
13999 Pragma_Independent
=> 0,
14000 Pragma_Independent_Components
=> 0,
14001 Pragma_Initialize_Scalars
=> -1,
14002 Pragma_Inline
=> 0,
14003 Pragma_Inline_Always
=> 0,
14004 Pragma_Inline_Generic
=> 0,
14005 Pragma_Inspection_Point
=> -1,
14006 Pragma_Interface
=> +2,
14007 Pragma_Interface_Name
=> +2,
14008 Pragma_Interrupt_Handler
=> -1,
14009 Pragma_Interrupt_Priority
=> -1,
14010 Pragma_Interrupt_State
=> -1,
14011 Pragma_Invariant
=> -1,
14012 Pragma_Java_Constructor
=> -1,
14013 Pragma_Java_Interface
=> -1,
14014 Pragma_Keep_Names
=> 0,
14015 Pragma_License
=> -1,
14016 Pragma_Link_With
=> -1,
14017 Pragma_Linker_Alias
=> -1,
14018 Pragma_Linker_Constructor
=> -1,
14019 Pragma_Linker_Destructor
=> -1,
14020 Pragma_Linker_Options
=> -1,
14021 Pragma_Linker_Section
=> -1,
14023 Pragma_Locking_Policy
=> -1,
14024 Pragma_Long_Float
=> -1,
14025 Pragma_Machine_Attribute
=> -1,
14027 Pragma_Main_Storage
=> -1,
14028 Pragma_Memory_Size
=> -1,
14029 Pragma_No_Return
=> 0,
14030 Pragma_No_Body
=> 0,
14031 Pragma_No_Run_Time
=> -1,
14032 Pragma_No_Strict_Aliasing
=> -1,
14033 Pragma_Normalize_Scalars
=> -1,
14034 Pragma_Obsolescent
=> 0,
14035 Pragma_Optimize
=> -1,
14036 Pragma_Optimize_Alignment
=> -1,
14037 Pragma_Ordered
=> 0,
14040 Pragma_Passive
=> -1,
14041 Pragma_Preelaborable_Initialization
=> -1,
14042 Pragma_Polling
=> -1,
14043 Pragma_Persistent_BSS
=> 0,
14044 Pragma_Postcondition
=> -1,
14045 Pragma_Precondition
=> -1,
14046 Pragma_Predicate
=> -1,
14047 Pragma_Preelaborate
=> -1,
14048 Pragma_Preelaborate_05
=> -1,
14049 Pragma_Priority
=> -1,
14050 Pragma_Priority_Specific_Dispatching
=> -1,
14051 Pragma_Profile
=> 0,
14052 Pragma_Profile_Warnings
=> 0,
14053 Pragma_Propagate_Exceptions
=> -1,
14054 Pragma_Psect_Object
=> -1,
14056 Pragma_Pure_05
=> -1,
14057 Pragma_Pure_Function
=> -1,
14058 Pragma_Queuing_Policy
=> -1,
14059 Pragma_Ravenscar
=> -1,
14060 Pragma_Relative_Deadline
=> -1,
14061 Pragma_Remote_Call_Interface
=> -1,
14062 Pragma_Remote_Types
=> -1,
14063 Pragma_Restricted_Run_Time
=> -1,
14064 Pragma_Restriction_Warnings
=> -1,
14065 Pragma_Restrictions
=> -1,
14066 Pragma_Reviewable
=> -1,
14067 Pragma_Short_Circuit_And_Or
=> -1,
14068 Pragma_Share_Generic
=> -1,
14069 Pragma_Shared
=> -1,
14070 Pragma_Shared_Passive
=> -1,
14071 Pragma_Short_Descriptors
=> 0,
14072 Pragma_Source_File_Name
=> -1,
14073 Pragma_Source_File_Name_Project
=> -1,
14074 Pragma_Source_Reference
=> -1,
14075 Pragma_Storage_Size
=> -1,
14076 Pragma_Storage_Unit
=> -1,
14077 Pragma_Static_Elaboration_Desired
=> -1,
14078 Pragma_Stream_Convert
=> -1,
14079 Pragma_Style_Checks
=> -1,
14080 Pragma_Subtitle
=> -1,
14081 Pragma_Suppress
=> 0,
14082 Pragma_Suppress_Exception_Locations
=> 0,
14083 Pragma_Suppress_All
=> -1,
14084 Pragma_Suppress_Debug_Info
=> 0,
14085 Pragma_Suppress_Initialization
=> 0,
14086 Pragma_System_Name
=> -1,
14087 Pragma_Task_Dispatching_Policy
=> -1,
14088 Pragma_Task_Info
=> -1,
14089 Pragma_Task_Name
=> -1,
14090 Pragma_Task_Storage
=> 0,
14091 Pragma_Thread_Local_Storage
=> 0,
14092 Pragma_Time_Slice
=> -1,
14093 Pragma_Title
=> -1,
14094 Pragma_Unchecked_Union
=> 0,
14095 Pragma_Unimplemented_Unit
=> -1,
14096 Pragma_Universal_Aliasing
=> -1,
14097 Pragma_Universal_Data
=> -1,
14098 Pragma_Unmodified
=> -1,
14099 Pragma_Unreferenced
=> -1,
14100 Pragma_Unreferenced_Objects
=> -1,
14101 Pragma_Unreserve_All_Interrupts
=> -1,
14102 Pragma_Unsuppress
=> 0,
14103 Pragma_Use_VADS_Size
=> -1,
14104 Pragma_Validity_Checks
=> -1,
14105 Pragma_Volatile
=> 0,
14106 Pragma_Volatile_Components
=> 0,
14107 Pragma_Warnings
=> -1,
14108 Pragma_Weak_External
=> -1,
14109 Pragma_Wide_Character_Encoding
=> 0,
14110 Unknown_Pragma
=> 0);
14112 function Is_Non_Significant_Pragma_Reference
(N
: Node_Id
) return Boolean is
14121 if Nkind
(P
) /= N_Pragma_Argument_Association
then
14125 Id
:= Get_Pragma_Id
(Parent
(P
));
14126 C
:= Sig_Flags
(Id
);
14138 -- For pragma Check, the first argument is not significant,
14139 -- the second and the third (if present) arguments are
14142 when Pragma_Check
=>
14144 P
= First
(Pragma_Argument_Associations
(Parent
(P
)));
14147 raise Program_Error
;
14151 A
:= First
(Pragma_Argument_Associations
(Parent
(P
)));
14152 for J
in 1 .. C
- 1 loop
14160 return A
= P
; -- is this wrong way round ???
14163 end Is_Non_Significant_Pragma_Reference
;
14165 ------------------------------
14166 -- Is_Pragma_String_Literal --
14167 ------------------------------
14169 -- This function returns true if the corresponding pragma argument is a
14170 -- static string expression. These are the only cases in which string
14171 -- literals can appear as pragma arguments. We also allow a string literal
14172 -- as the first argument to pragma Assert (although it will of course
14173 -- always generate a type error).
14175 function Is_Pragma_String_Literal
(Par
: Node_Id
) return Boolean is
14176 Pragn
: constant Node_Id
:= Parent
(Par
);
14177 Assoc
: constant List_Id
:= Pragma_Argument_Associations
(Pragn
);
14178 Pname
: constant Name_Id
:= Pragma_Name
(Pragn
);
14184 N
:= First
(Assoc
);
14191 if Pname
= Name_Assert
then
14194 elsif Pname
= Name_Export
then
14197 elsif Pname
= Name_Ident
then
14200 elsif Pname
= Name_Import
then
14203 elsif Pname
= Name_Interface_Name
then
14206 elsif Pname
= Name_Linker_Alias
then
14209 elsif Pname
= Name_Linker_Section
then
14212 elsif Pname
= Name_Machine_Attribute
then
14215 elsif Pname
= Name_Source_File_Name
then
14218 elsif Pname
= Name_Source_Reference
then
14221 elsif Pname
= Name_Title
then
14224 elsif Pname
= Name_Subtitle
then
14230 end Is_Pragma_String_Literal
;
14232 --------------------------------------
14233 -- Process_Compilation_Unit_Pragmas --
14234 --------------------------------------
14236 procedure Process_Compilation_Unit_Pragmas
(N
: Node_Id
) is
14238 -- A special check for pragma Suppress_All, a very strange DEC pragma,
14239 -- strange because it comes at the end of the unit. Rational has the
14240 -- same name for a pragma, but treats it as a program unit pragma, In
14241 -- GNAT we just decide to allow it anywhere at all. If it appeared then
14242 -- the flag Has_Pragma_Suppress_All was set on the compilation unit
14243 -- node, and we insert a pragma Suppress (All_Checks) at the start of
14244 -- the context clause to ensure the correct processing.
14246 if Has_Pragma_Suppress_All
(N
) then
14247 Prepend_To
(Context_Items
(N
),
14248 Make_Pragma
(Sloc
(N
),
14249 Chars
=> Name_Suppress
,
14250 Pragma_Argument_Associations
=> New_List
(
14251 Make_Pragma_Argument_Association
(Sloc
(N
),
14252 Expression
=> Make_Identifier
(Sloc
(N
), Name_All_Checks
)))));
14255 -- Nothing else to do at the current time!
14257 end Process_Compilation_Unit_Pragmas
;
14268 --------------------------------
14269 -- Set_Encoded_Interface_Name --
14270 --------------------------------
14272 procedure Set_Encoded_Interface_Name
(E
: Entity_Id
; S
: Node_Id
) is
14273 Str
: constant String_Id
:= Strval
(S
);
14274 Len
: constant Int
:= String_Length
(Str
);
14279 Hex
: constant array (0 .. 15) of Character := "0123456789abcdef";
14282 -- Stores encoded value of character code CC. The encoding we use an
14283 -- underscore followed by four lower case hex digits.
14289 procedure Encode
is
14291 Store_String_Char
(Get_Char_Code
('_'));
14293 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 12))));
14295 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 8 and 16#
0F#
))));
14297 (Get_Char_Code
(Hex
(Integer (CC
/ 2 ** 4 and 16#
0F#
))));
14299 (Get_Char_Code
(Hex
(Integer (CC
and 16#
0F#
))));
14302 -- Start of processing for Set_Encoded_Interface_Name
14305 -- If first character is asterisk, this is a link name, and we leave it
14306 -- completely unmodified. We also ignore null strings (the latter case
14307 -- happens only in error cases) and no encoding should occur for Java or
14308 -- AAMP interface names.
14311 or else Get_String_Char
(Str
, 1) = Get_Char_Code
('*')
14312 or else VM_Target
/= No_VM
14313 or else AAMP_On_Target
14315 Set_Interface_Name
(E
, S
);
14320 CC
:= Get_String_Char
(Str
, J
);
14322 exit when not In_Character_Range
(CC
);
14324 C
:= Get_Character
(CC
);
14326 exit when C
/= '_' and then C
/= '$'
14327 and then C
not in '0' .. '9'
14328 and then C
not in 'a' .. 'z'
14329 and then C
not in 'A' .. 'Z';
14332 Set_Interface_Name
(E
, S
);
14340 -- Here we need to encode. The encoding we use as follows:
14341 -- three underscores + four hex digits (lower case)
14345 for J
in 1 .. String_Length
(Str
) loop
14346 CC
:= Get_String_Char
(Str
, J
);
14348 if not In_Character_Range
(CC
) then
14351 C
:= Get_Character
(CC
);
14353 if C
= '_' or else C
= '$'
14354 or else C
in '0' .. '9'
14355 or else C
in 'a' .. 'z'
14356 or else C
in 'A' .. 'Z'
14358 Store_String_Char
(CC
);
14365 Set_Interface_Name
(E
,
14366 Make_String_Literal
(Sloc
(S
),
14367 Strval
=> End_String
));
14369 end Set_Encoded_Interface_Name
;
14371 -------------------
14372 -- Set_Unit_Name --
14373 -------------------
14375 procedure Set_Unit_Name
(N
: Node_Id
; With_Item
: Node_Id
) is
14380 if Nkind
(N
) = N_Identifier
14381 and then Nkind
(With_Item
) = N_Identifier
14383 Set_Entity
(N
, Entity
(With_Item
));
14385 elsif Nkind
(N
) = N_Selected_Component
then
14386 Change_Selected_Component_To_Expanded_Name
(N
);
14387 Set_Entity
(N
, Entity
(With_Item
));
14388 Set_Entity
(Selector_Name
(N
), Entity
(N
));
14390 Pref
:= Prefix
(N
);
14391 Scop
:= Scope
(Entity
(N
));
14392 while Nkind
(Pref
) = N_Selected_Component
loop
14393 Change_Selected_Component_To_Expanded_Name
(Pref
);
14394 Set_Entity
(Selector_Name
(Pref
), Scop
);
14395 Set_Entity
(Pref
, Scop
);
14396 Pref
:= Prefix
(Pref
);
14397 Scop
:= Scope
(Scop
);
14400 Set_Entity
(Pref
, Scop
);