1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2005, 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 with Atree
; use Atree
;
28 with Debug
; use Debug
;
29 with Einfo
; use Einfo
;
30 with Elists
; use Elists
;
31 with Errout
; use Errout
;
32 with Exp_Ch7
; use Exp_Ch7
;
33 with Exp_Ch11
; use Exp_Ch11
;
34 with Exp_Pakd
; use Exp_Pakd
;
35 with Exp_Util
; use Exp_Util
;
36 with Exp_Tss
; use Exp_Tss
;
37 with Layout
; use Layout
;
38 with Lib
.Xref
; use Lib
.Xref
;
39 with Nlists
; use Nlists
;
40 with Nmake
; use Nmake
;
42 with Restrict
; use Restrict
;
43 with Rident
; use Rident
;
45 with Sem_Cat
; use Sem_Cat
;
46 with Sem_Ch6
; use Sem_Ch6
;
47 with Sem_Ch7
; use Sem_Ch7
;
48 with Sem_Ch8
; use Sem_Ch8
;
49 with Sem_Ch13
; use Sem_Ch13
;
50 with Sem_Eval
; use Sem_Eval
;
51 with Sem_Mech
; use Sem_Mech
;
52 with Sem_Prag
; use Sem_Prag
;
53 with Sem_Res
; use Sem_Res
;
54 with Sem_Util
; use Sem_Util
;
55 with Sinfo
; use Sinfo
;
56 with Snames
; use Snames
;
57 with Stand
; use Stand
;
58 with Targparm
; use Targparm
;
59 with Tbuild
; use Tbuild
;
60 with Ttypes
; use Ttypes
;
61 with Uintp
; use Uintp
;
62 with Urealp
; use Urealp
;
64 package body Freeze
is
66 -----------------------
67 -- Local Subprograms --
68 -----------------------
70 procedure Adjust_Esize_For_Alignment
(Typ
: Entity_Id
);
71 -- Typ is a type that is being frozen. If no size clause is given,
72 -- but a default Esize has been computed, then this default Esize is
73 -- adjusted up if necessary to be consistent with a given alignment,
74 -- but never to a value greater than Long_Long_Integer'Size. This
75 -- is used for all discrete types and for fixed-point types.
77 procedure Build_And_Analyze_Renamed_Body
80 After
: in out Node_Id
);
81 -- Build body for a renaming declaration, insert in tree and analyze.
83 procedure Check_Address_Clause
(E
: Entity_Id
);
84 -- Apply legality checks to address clauses for object declarations,
85 -- at the point the object is frozen.
87 procedure Check_Strict_Alignment
(E
: Entity_Id
);
88 -- E is a base type. If E is tagged or has a component that is aliased
89 -- or tagged or contains something this is aliased or tagged, set
92 procedure Check_Unsigned_Type
(E
: Entity_Id
);
93 pragma Inline
(Check_Unsigned_Type
);
94 -- If E is a fixed-point or discrete type, then all the necessary work
95 -- to freeze it is completed except for possible setting of the flag
96 -- Is_Unsigned_Type, which is done by this procedure. The call has no
97 -- effect if the entity E is not a discrete or fixed-point type.
99 procedure Freeze_And_Append
102 Result
: in out List_Id
);
103 -- Freezes Ent using Freeze_Entity, and appends the resulting list of
104 -- nodes to Result, modifying Result from No_List if necessary.
106 procedure Freeze_Enumeration_Type
(Typ
: Entity_Id
);
107 -- Freeze enumeration type. The Esize field is set as processing
108 -- proceeds (i.e. set by default when the type is declared and then
109 -- adjusted by rep clauses. What this procedure does is to make sure
110 -- that if a foreign convention is specified, and no specific size
111 -- is given, then the size must be at least Integer'Size.
113 procedure Freeze_Static_Object
(E
: Entity_Id
);
114 -- If an object is frozen which has Is_Statically_Allocated set, then
115 -- all referenced types must also be marked with this flag. This routine
116 -- is in charge of meeting this requirement for the object entity E.
118 procedure Freeze_Subprogram
(E
: Entity_Id
);
119 -- Perform freezing actions for a subprogram (create extra formals,
120 -- and set proper default mechanism values). Note that this routine
121 -- is not called for internal subprograms, for which neither of these
122 -- actions is needed (or desirable, we do not want for example to have
123 -- these extra formals present in initialization procedures, where they
124 -- would serve no purpose). In this call E is either a subprogram or
125 -- a subprogram type (i.e. an access to a subprogram).
127 function Is_Fully_Defined
(T
: Entity_Id
) return Boolean;
128 -- True if T is not private and has no private components, or has a full
129 -- view. Used to determine whether the designated type of an access type
130 -- should be frozen when the access type is frozen. This is done when an
131 -- allocator is frozen, or an expression that may involve attributes of
132 -- the designated type. Otherwise freezing the access type does not freeze
133 -- the designated type.
135 procedure Process_Default_Expressions
137 After
: in out Node_Id
);
138 -- This procedure is called for each subprogram to complete processing
139 -- of default expressions at the point where all types are known to be
140 -- frozen. The expressions must be analyzed in full, to make sure that
141 -- all error processing is done (they have only been pre-analyzed). If
142 -- the expression is not an entity or literal, its analysis may generate
143 -- code which must not be executed. In that case we build a function
144 -- body to hold that code. This wrapper function serves no other purpose
145 -- (it used to be called to evaluate the default, but now the default is
146 -- inlined at each point of call).
148 procedure Set_Component_Alignment_If_Not_Set
(Typ
: Entity_Id
);
149 -- Typ is a record or array type that is being frozen. This routine
150 -- sets the default component alignment from the scope stack values
151 -- if the alignment is otherwise not specified.
153 procedure Check_Debug_Info_Needed
(T
: Entity_Id
);
154 -- As each entity is frozen, this routine is called to deal with the
155 -- setting of Debug_Info_Needed for the entity. This flag is set if
156 -- the entity comes from source, or if we are in Debug_Generated_Code
157 -- mode or if the -gnatdV debug flag is set. However, it never sets
158 -- the flag if Debug_Info_Off is set.
160 procedure Set_Debug_Info_Needed
(T
: Entity_Id
);
161 -- Sets the Debug_Info_Needed flag on entity T if not already set, and
162 -- also on any entities that are needed by T (for an object, the type
163 -- of the object is needed, and for a type, the subsidiary types are
164 -- needed -- see body for details). Never has any effect on T if the
165 -- Debug_Info_Off flag is set.
167 procedure Undelay_Type
(T
: Entity_Id
);
168 -- T is a type of a component that we know to be an Itype.
169 -- We don't want this to have a Freeze_Node, so ensure it doesn't.
170 -- Do the same for any Full_View or Corresponding_Record_Type.
172 procedure Warn_Overlay
176 -- Expr is the expression for an address clause for entity Nam whose type
177 -- is Typ. If Typ has a default initialization, and there is no explicit
178 -- initialization in the source declaration, check whether the address
179 -- clause might cause overlaying of an entity, and emit a warning on the
180 -- side effect that the initialization will cause.
182 -------------------------------
183 -- Adjust_Esize_For_Alignment --
184 -------------------------------
186 procedure Adjust_Esize_For_Alignment
(Typ
: Entity_Id
) is
190 if Known_Esize
(Typ
) and then Known_Alignment
(Typ
) then
191 Align
:= Alignment_In_Bits
(Typ
);
193 if Align
> Esize
(Typ
)
194 and then Align
<= Standard_Long_Long_Integer_Size
196 Set_Esize
(Typ
, Align
);
199 end Adjust_Esize_For_Alignment
;
201 ------------------------------------
202 -- Build_And_Analyze_Renamed_Body --
203 ------------------------------------
205 procedure Build_And_Analyze_Renamed_Body
208 After
: in out Node_Id
)
210 Body_Node
: constant Node_Id
:= Build_Renamed_Body
(Decl
, New_S
);
213 Insert_After
(After
, Body_Node
);
214 Mark_Rewrite_Insertion
(Body_Node
);
217 end Build_And_Analyze_Renamed_Body
;
219 ------------------------
220 -- Build_Renamed_Body --
221 ------------------------
223 function Build_Renamed_Body
225 New_S
: Entity_Id
) return Node_Id
227 Loc
: constant Source_Ptr
:= Sloc
(New_S
);
228 -- We use for the source location of the renamed body, the location
229 -- of the spec entity. It might seem more natural to use the location
230 -- of the renaming declaration itself, but that would be wrong, since
231 -- then the body we create would look as though it was created far
232 -- too late, and this could cause problems with elaboration order
233 -- analysis, particularly in connection with instantiations.
235 N
: constant Node_Id
:= Unit_Declaration_Node
(New_S
);
236 Nam
: constant Node_Id
:= Name
(N
);
238 Spec
: constant Node_Id
:= New_Copy_Tree
(Specification
(Decl
));
239 Actuals
: List_Id
:= No_List
;
244 O_Formal
: Entity_Id
;
245 Param_Spec
: Node_Id
;
248 -- Determine the entity being renamed, which is the target of the
249 -- call statement. If the name is an explicit dereference, this is
250 -- a renaming of a subprogram type rather than a subprogram. The
251 -- name itself is fully analyzed.
253 if Nkind
(Nam
) = N_Selected_Component
then
254 Old_S
:= Entity
(Selector_Name
(Nam
));
256 elsif Nkind
(Nam
) = N_Explicit_Dereference
then
257 Old_S
:= Etype
(Nam
);
259 elsif Nkind
(Nam
) = N_Indexed_Component
then
260 if Is_Entity_Name
(Prefix
(Nam
)) then
261 Old_S
:= Entity
(Prefix
(Nam
));
263 Old_S
:= Entity
(Selector_Name
(Prefix
(Nam
)));
266 elsif Nkind
(Nam
) = N_Character_Literal
then
267 Old_S
:= Etype
(New_S
);
270 Old_S
:= Entity
(Nam
);
273 if Is_Entity_Name
(Nam
) then
275 -- If the renamed entity is a predefined operator, retain full
276 -- name to ensure its visibility.
278 if Ekind
(Old_S
) = E_Operator
279 and then Nkind
(Nam
) = N_Expanded_Name
281 Call_Name
:= New_Copy
(Name
(N
));
283 Call_Name
:= New_Reference_To
(Old_S
, Loc
);
287 Call_Name
:= New_Copy
(Name
(N
));
289 -- The original name may have been overloaded, but
290 -- is fully resolved now.
292 Set_Is_Overloaded
(Call_Name
, False);
295 -- For simple renamings, subsequent calls can be expanded directly
296 -- as called to the renamed entity. The body must be generated in
297 -- any case for calls they may appear elsewhere.
299 if (Ekind
(Old_S
) = E_Function
300 or else Ekind
(Old_S
) = E_Procedure
)
301 and then Nkind
(Decl
) = N_Subprogram_Declaration
303 Set_Body_To_Inline
(Decl
, Old_S
);
306 -- The body generated for this renaming is an internal artifact, and
307 -- does not constitute a freeze point for the called entity.
309 Set_Must_Not_Freeze
(Call_Name
);
311 Formal
:= First_Formal
(Defining_Entity
(Decl
));
313 if Present
(Formal
) then
316 while Present
(Formal
) loop
317 Append
(New_Reference_To
(Formal
, Loc
), Actuals
);
318 Next_Formal
(Formal
);
322 -- If the renamed entity is an entry, inherit its profile. For
323 -- other renamings as bodies, both profiles must be subtype
324 -- conformant, so it is not necessary to replace the profile given
325 -- in the declaration. However, default values that are aggregates
326 -- are rewritten when partially analyzed, so we recover the original
327 -- aggregate to insure that subsequent conformity checking works.
328 -- Similarly, if the default expression was constant-folded, recover
329 -- the original expression.
331 Formal
:= First_Formal
(Defining_Entity
(Decl
));
333 if Present
(Formal
) then
334 O_Formal
:= First_Formal
(Old_S
);
335 Param_Spec
:= First
(Parameter_Specifications
(Spec
));
337 while Present
(Formal
) loop
338 if Is_Entry
(Old_S
) then
340 if Nkind
(Parameter_Type
(Param_Spec
)) /=
343 Set_Etype
(Formal
, Etype
(O_Formal
));
344 Set_Entity
(Parameter_Type
(Param_Spec
), Etype
(O_Formal
));
347 elsif Nkind
(Default_Value
(O_Formal
)) = N_Aggregate
348 or else Nkind
(Original_Node
(Default_Value
(O_Formal
))) /=
349 Nkind
(Default_Value
(O_Formal
))
351 Set_Expression
(Param_Spec
,
352 New_Copy_Tree
(Original_Node
(Default_Value
(O_Formal
))));
355 Next_Formal
(Formal
);
356 Next_Formal
(O_Formal
);
361 -- If the renamed entity is a function, the generated body contains a
362 -- return statement. Otherwise, build a procedure call. If the entity is
363 -- an entry, subsequent analysis of the call will transform it into the
364 -- proper entry or protected operation call. If the renamed entity is
365 -- a character literal, return it directly.
367 if Ekind
(Old_S
) = E_Function
368 or else Ekind
(Old_S
) = E_Operator
369 or else (Ekind
(Old_S
) = E_Subprogram_Type
370 and then Etype
(Old_S
) /= Standard_Void_Type
)
373 Make_Return_Statement
(Loc
,
375 Make_Function_Call
(Loc
,
377 Parameter_Associations
=> Actuals
));
379 elsif Ekind
(Old_S
) = E_Enumeration_Literal
then
381 Make_Return_Statement
(Loc
,
382 Expression
=> New_Occurrence_Of
(Old_S
, Loc
));
384 elsif Nkind
(Nam
) = N_Character_Literal
then
386 Make_Return_Statement
(Loc
,
387 Expression
=> Call_Name
);
391 Make_Procedure_Call_Statement
(Loc
,
393 Parameter_Associations
=> Actuals
);
396 -- Create entities for subprogram body and formals.
398 Set_Defining_Unit_Name
(Spec
,
399 Make_Defining_Identifier
(Loc
, Chars
=> Chars
(New_S
)));
401 Param_Spec
:= First
(Parameter_Specifications
(Spec
));
403 while Present
(Param_Spec
) loop
404 Set_Defining_Identifier
(Param_Spec
,
405 Make_Defining_Identifier
(Loc
,
406 Chars
=> Chars
(Defining_Identifier
(Param_Spec
))));
411 Make_Subprogram_Body
(Loc
,
412 Specification
=> Spec
,
413 Declarations
=> New_List
,
414 Handled_Statement_Sequence
=>
415 Make_Handled_Sequence_Of_Statements
(Loc
,
416 Statements
=> New_List
(Call_Node
)));
418 if Nkind
(Decl
) /= N_Subprogram_Declaration
then
420 Make_Subprogram_Declaration
(Loc
,
421 Specification
=> Specification
(N
)));
424 -- Link the body to the entity whose declaration it completes. If
425 -- the body is analyzed when the renamed entity is frozen, it may be
426 -- necessary to restore the proper scope (see package Exp_Ch13).
428 if Nkind
(N
) = N_Subprogram_Renaming_Declaration
429 and then Present
(Corresponding_Spec
(N
))
431 Set_Corresponding_Spec
(Body_Node
, Corresponding_Spec
(N
));
433 Set_Corresponding_Spec
(Body_Node
, New_S
);
437 end Build_Renamed_Body
;
439 --------------------------
440 -- Check_Address_Clause --
441 --------------------------
443 procedure Check_Address_Clause
(E
: Entity_Id
) is
444 Addr
: constant Node_Id
:= Address_Clause
(E
);
446 Decl
: constant Node_Id
:= Declaration_Node
(E
);
447 Typ
: constant Entity_Id
:= Etype
(E
);
450 if Present
(Addr
) then
451 Expr
:= Expression
(Addr
);
453 -- If we have no initialization of any kind, then we don't
454 -- need to place any restrictions on the address clause, because
455 -- the object will be elaborated after the address clause is
456 -- evaluated. This happens if the declaration has no initial
457 -- expression, or the type has no implicit initialization, or
458 -- the object is imported.
460 -- The same holds for all initialized scalar types and all
461 -- access types. Packed bit arrays of size up to 64 are
462 -- represented using a modular type with an initialization
463 -- (to zero) and can be processed like other initialized
466 -- If the type is controlled, code to attach the object to a
467 -- finalization chain is generated at the point of declaration,
468 -- and therefore the elaboration of the object cannot be delayed:
469 -- the address expression must be a constant.
471 if (No
(Expression
(Decl
))
472 and then not Controlled_Type
(Typ
)
474 (not Has_Non_Null_Base_Init_Proc
(Typ
)
475 or else Is_Imported
(E
)))
478 (Present
(Expression
(Decl
))
479 and then Is_Scalar_Type
(Typ
))
485 (Is_Bit_Packed_Array
(Typ
)
487 Is_Modular_Integer_Type
(Packed_Array_Type
(Typ
)))
491 -- Otherwise, we require the address clause to be constant
492 -- because the call to the initialization procedure (or the
493 -- attach code) has to happen at the point of the declaration.
496 Check_Constant_Address_Clause
(Expr
, E
);
497 Set_Has_Delayed_Freeze
(E
, False);
500 if not Error_Posted
(Expr
)
501 and then not Controlled_Type
(Typ
)
503 Warn_Overlay
(Expr
, Typ
, Name
(Addr
));
506 end Check_Address_Clause
;
508 -----------------------------
509 -- Check_Compile_Time_Size --
510 -----------------------------
512 procedure Check_Compile_Time_Size
(T
: Entity_Id
) is
514 procedure Set_Small_Size
(T
: Entity_Id
; S
: Uint
);
515 -- Sets the compile time known size (32 bits or less) in the Esize
516 -- field, of T checking for a size clause that was given which attempts
517 -- to give a smaller size.
519 function Size_Known
(T
: Entity_Id
) return Boolean;
520 -- Recursive function that does all the work
522 function Static_Discriminated_Components
(T
: Entity_Id
) return Boolean;
523 -- If T is a constrained subtype, its size is not known if any of its
524 -- discriminant constraints is not static and it is not a null record.
525 -- The test is conservative and doesn't check that the components are
526 -- in fact constrained by non-static discriminant values. Could be made
533 procedure Set_Small_Size
(T
: Entity_Id
; S
: Uint
) is
538 elsif Has_Size_Clause
(T
) then
539 if RM_Size
(T
) < S
then
540 Error_Msg_Uint_1
:= S
;
542 ("size for & is too small, minimum is ^",
545 elsif Unknown_Esize
(T
) then
549 -- Set sizes if not set already
552 if Unknown_Esize
(T
) then
556 if Unknown_RM_Size
(T
) then
566 function Size_Known
(T
: Entity_Id
) return Boolean is
574 if Size_Known_At_Compile_Time
(T
) then
577 elsif Is_Scalar_Type
(T
)
578 or else Is_Task_Type
(T
)
580 return not Is_Generic_Type
(T
);
582 elsif Is_Array_Type
(T
) then
583 if Ekind
(T
) = E_String_Literal_Subtype
then
584 Set_Small_Size
(T
, Component_Size
(T
)
585 * String_Literal_Length
(T
));
588 elsif not Is_Constrained
(T
) then
591 -- Don't do any recursion on type with error posted, since
592 -- we may have a malformed type that leads us into a loop
594 elsif Error_Posted
(T
) then
597 elsif not Size_Known
(Component_Type
(T
)) then
601 -- Check for all indexes static, and also compute possible
602 -- size (in case it is less than 32 and may be packable).
605 Esiz
: Uint
:= Component_Size
(T
);
609 Index
:= First_Index
(T
);
610 while Present
(Index
) loop
611 if Nkind
(Index
) = N_Range
then
612 Get_Index_Bounds
(Index
, Low
, High
);
614 elsif Error_Posted
(Scalar_Range
(Etype
(Index
))) then
618 Low
:= Type_Low_Bound
(Etype
(Index
));
619 High
:= Type_High_Bound
(Etype
(Index
));
622 if not Compile_Time_Known_Value
(Low
)
623 or else not Compile_Time_Known_Value
(High
)
624 or else Etype
(Index
) = Any_Type
629 Dim
:= Expr_Value
(High
) - Expr_Value
(Low
) + 1;
641 Set_Small_Size
(T
, Esiz
);
645 elsif Is_Access_Type
(T
) then
648 elsif Is_Private_Type
(T
)
649 and then not Is_Generic_Type
(T
)
650 and then Present
(Underlying_Type
(T
))
652 -- Don't do any recursion on type with error posted, since
653 -- we may have a malformed type that leads us into a loop
655 if Error_Posted
(T
) then
658 return Size_Known
(Underlying_Type
(T
));
661 elsif Is_Record_Type
(T
) then
663 -- A class-wide type is never considered to have a known size
665 if Is_Class_Wide_Type
(T
) then
668 -- A subtype of a variant record must not have non-static
669 -- discriminanted components.
671 elsif T
/= Base_Type
(T
)
672 and then not Static_Discriminated_Components
(T
)
676 -- Don't do any recursion on type with error posted, since
677 -- we may have a malformed type that leads us into a loop
679 elsif Error_Posted
(T
) then
683 -- Now look at the components of the record
686 -- The following two variables are used to keep track of
687 -- the size of packed records if we can tell the size of
688 -- the packed record in the front end. Packed_Size_Known
689 -- is True if so far we can figure out the size. It is
690 -- initialized to True for a packed record, unless the
691 -- record has discriminants. The reason we eliminate the
692 -- discriminated case is that we don't know the way the
693 -- back end lays out discriminated packed records. If
694 -- Packed_Size_Known is True, then Packed_Size is the
695 -- size in bits so far.
697 Packed_Size_Known
: Boolean :=
699 and then not Has_Discriminants
(T
);
701 Packed_Size
: Uint
:= Uint_0
;
704 -- Test for variant part present
706 if Has_Discriminants
(T
)
707 and then Present
(Parent
(T
))
708 and then Nkind
(Parent
(T
)) = N_Full_Type_Declaration
709 and then Nkind
(Type_Definition
(Parent
(T
))) =
711 and then not Null_Present
(Type_Definition
(Parent
(T
)))
712 and then Present
(Variant_Part
713 (Component_List
(Type_Definition
(Parent
(T
)))))
715 -- If variant part is present, and type is unconstrained,
716 -- then we must have defaulted discriminants, or a size
717 -- clause must be present for the type, or else the size
718 -- is definitely not known at compile time.
720 if not Is_Constrained
(T
)
722 No
(Discriminant_Default_Value
723 (First_Discriminant
(T
)))
724 and then Unknown_Esize
(T
)
730 -- Loop through components
732 Comp
:= First_Entity
(T
);
733 while Present
(Comp
) loop
734 if Ekind
(Comp
) = E_Component
736 Ekind
(Comp
) = E_Discriminant
738 Ctyp
:= Etype
(Comp
);
740 -- We do not know the packed size if there is a
741 -- component clause present (we possibly could,
742 -- but this would only help in the case of a record
743 -- with partial rep clauses. That's because in the
744 -- case of full rep clauses, the size gets figured
745 -- out anyway by a different circuit).
747 if Present
(Component_Clause
(Comp
)) then
748 Packed_Size_Known
:= False;
751 -- We need to identify a component that is an array
752 -- where the index type is an enumeration type with
753 -- non-standard representation, and some bound of the
754 -- type depends on a discriminant.
756 -- This is because gigi computes the size by doing a
757 -- substituation of the appropriate discriminant value
758 -- in the size expression for the base type, and gigi
759 -- is not clever enough to evaluate the resulting
760 -- expression (which involves a call to rep_to_pos)
763 -- It would be nice if gigi would either recognize that
764 -- this expression can be computed at compile time, or
765 -- alternatively figured out the size from the subtype
766 -- directly, where all the information is at hand ???
768 if Is_Array_Type
(Etype
(Comp
))
769 and then Present
(Packed_Array_Type
(Etype
(Comp
)))
772 Ocomp
: constant Entity_Id
:=
773 Original_Record_Component
(Comp
);
774 OCtyp
: constant Entity_Id
:= Etype
(Ocomp
);
780 Ind
:= First_Index
(OCtyp
);
781 while Present
(Ind
) loop
782 Indtyp
:= Etype
(Ind
);
784 if Is_Enumeration_Type
(Indtyp
)
785 and then Has_Non_Standard_Rep
(Indtyp
)
787 Lo
:= Type_Low_Bound
(Indtyp
);
788 Hi
:= Type_High_Bound
(Indtyp
);
790 if Is_Entity_Name
(Lo
)
792 Ekind
(Entity
(Lo
)) = E_Discriminant
796 elsif Is_Entity_Name
(Hi
)
798 Ekind
(Entity
(Hi
)) = E_Discriminant
809 -- Clearly size of record is not known if the size of
810 -- one of the components is not known.
812 if not Size_Known
(Ctyp
) then
816 -- Accumulate packed size if possible
818 if Packed_Size_Known
then
820 -- We can only deal with elementary types, since for
821 -- non-elementary components, alignment enters into
822 -- the picture, and we don't know enough to handle
823 -- proper alignment in this context. Packed arrays
824 -- count as elementary if the representation is a
827 if Is_Elementary_Type
(Ctyp
)
828 or else (Is_Array_Type
(Ctyp
)
830 Present
(Packed_Array_Type
(Ctyp
))
832 Is_Modular_Integer_Type
833 (Packed_Array_Type
(Ctyp
)))
835 -- If RM_Size is known and static, then we can
836 -- keep accumulating the packed size.
838 if Known_Static_RM_Size
(Ctyp
) then
840 -- A little glitch, to be removed sometime ???
841 -- gigi does not understand zero sizes yet.
843 if RM_Size
(Ctyp
) = Uint_0
then
844 Packed_Size_Known
:= False;
846 -- Normal case where we can keep accumulating
847 -- the packed array size.
850 Packed_Size
:= Packed_Size
+ RM_Size
(Ctyp
);
853 -- If we have a field whose RM_Size is not known
854 -- then we can't figure out the packed size here.
857 Packed_Size_Known
:= False;
860 -- If we have a non-elementary type we can't figure
861 -- out the packed array size (alignment issues).
864 Packed_Size_Known
:= False;
872 if Packed_Size_Known
then
873 Set_Small_Size
(T
, Packed_Size
);
884 -------------------------------------
885 -- Static_Discriminated_Components --
886 -------------------------------------
888 function Static_Discriminated_Components
889 (T
: Entity_Id
) return Boolean
891 Constraint
: Elmt_Id
;
894 if Has_Discriminants
(T
)
895 and then Present
(Discriminant_Constraint
(T
))
896 and then Present
(First_Component
(T
))
898 Constraint
:= First_Elmt
(Discriminant_Constraint
(T
));
899 while Present
(Constraint
) loop
900 if not Compile_Time_Known_Value
(Node
(Constraint
)) then
904 Next_Elmt
(Constraint
);
909 end Static_Discriminated_Components
;
911 -- Start of processing for Check_Compile_Time_Size
914 Set_Size_Known_At_Compile_Time
(T
, Size_Known
(T
));
915 end Check_Compile_Time_Size
;
917 -----------------------------
918 -- Check_Debug_Info_Needed --
919 -----------------------------
921 procedure Check_Debug_Info_Needed
(T
: Entity_Id
) is
923 if Needs_Debug_Info
(T
) or else Debug_Info_Off
(T
) then
926 elsif Comes_From_Source
(T
)
927 or else Debug_Generated_Code
928 or else Debug_Flag_VV
930 Set_Debug_Info_Needed
(T
);
932 end Check_Debug_Info_Needed
;
934 ----------------------------
935 -- Check_Strict_Alignment --
936 ----------------------------
938 procedure Check_Strict_Alignment
(E
: Entity_Id
) is
942 if Is_Tagged_Type
(E
) or else Is_Concurrent_Type
(E
) then
943 Set_Strict_Alignment
(E
);
945 elsif Is_Array_Type
(E
) then
946 Set_Strict_Alignment
(E
, Strict_Alignment
(Component_Type
(E
)));
948 elsif Is_Record_Type
(E
) then
949 if Is_Limited_Record
(E
) then
950 Set_Strict_Alignment
(E
);
954 Comp
:= First_Component
(E
);
956 while Present
(Comp
) loop
957 if not Is_Type
(Comp
)
958 and then (Strict_Alignment
(Etype
(Comp
))
959 or else Is_Aliased
(Comp
))
961 Set_Strict_Alignment
(E
);
965 Next_Component
(Comp
);
968 end Check_Strict_Alignment
;
970 -------------------------
971 -- Check_Unsigned_Type --
972 -------------------------
974 procedure Check_Unsigned_Type
(E
: Entity_Id
) is
975 Ancestor
: Entity_Id
;
980 if not Is_Discrete_Or_Fixed_Point_Type
(E
) then
984 -- Do not attempt to analyze case where range was in error
986 if Error_Posted
(Scalar_Range
(E
)) then
990 -- The situation that is non trivial is something like
992 -- subtype x1 is integer range -10 .. +10;
993 -- subtype x2 is x1 range 0 .. V1;
994 -- subtype x3 is x2 range V2 .. V3;
995 -- subtype x4 is x3 range V4 .. V5;
997 -- where Vn are variables. Here the base type is signed, but we still
998 -- know that x4 is unsigned because of the lower bound of x2.
1000 -- The only way to deal with this is to look up the ancestor chain
1004 if Ancestor
= Any_Type
or else Etype
(Ancestor
) = Any_Type
then
1008 Lo_Bound
:= Type_Low_Bound
(Ancestor
);
1010 if Compile_Time_Known_Value
(Lo_Bound
) then
1012 if Expr_Rep_Value
(Lo_Bound
) >= 0 then
1013 Set_Is_Unsigned_Type
(E
, True);
1019 Ancestor
:= Ancestor_Subtype
(Ancestor
);
1021 -- If no ancestor had a static lower bound, go to base type
1023 if No
(Ancestor
) then
1025 -- Note: the reason we still check for a compile time known
1026 -- value for the base type is that at least in the case of
1027 -- generic formals, we can have bounds that fail this test,
1028 -- and there may be other cases in error situations.
1030 Btyp
:= Base_Type
(E
);
1032 if Btyp
= Any_Type
or else Etype
(Btyp
) = Any_Type
then
1036 Lo_Bound
:= Type_Low_Bound
(Base_Type
(E
));
1038 if Compile_Time_Known_Value
(Lo_Bound
)
1039 and then Expr_Rep_Value
(Lo_Bound
) >= 0
1041 Set_Is_Unsigned_Type
(E
, True);
1048 end Check_Unsigned_Type
;
1050 -----------------------------
1051 -- Expand_Atomic_Aggregate --
1052 -----------------------------
1054 procedure Expand_Atomic_Aggregate
(E
: Entity_Id
; Typ
: Entity_Id
) is
1055 Loc
: constant Source_Ptr
:= Sloc
(E
);
1060 if (Nkind
(Parent
(E
)) = N_Object_Declaration
1061 or else Nkind
(Parent
(E
)) = N_Assignment_Statement
)
1062 and then Comes_From_Source
(Parent
(E
))
1063 and then Nkind
(E
) = N_Aggregate
1066 Make_Defining_Identifier
(Loc
,
1067 New_Internal_Name
('T'));
1070 Make_Object_Declaration
(Loc
,
1071 Defining_Identifier
=> Temp
,
1072 Object_definition
=> New_Occurrence_Of
(Typ
, Loc
),
1073 Expression
=> Relocate_Node
(E
));
1074 Insert_Before
(Parent
(E
), New_N
);
1077 Set_Expression
(Parent
(E
), New_Occurrence_Of
(Temp
, Loc
));
1079 -- To prevent the temporary from being constant-folded (which
1080 -- would lead to the same piecemeal assignment on the original
1081 -- target) indicate to the back-end that the temporary is a
1082 -- variable with real storage. See description of this flag
1083 -- in Einfo, and the notes on N_Assignment_Statement and
1084 -- N_Object_Declaration in Sinfo.
1086 Set_Is_True_Constant
(Temp
, False);
1088 end Expand_Atomic_Aggregate
;
1094 -- Note: the easy coding for this procedure would be to just build a
1095 -- single list of freeze nodes and then insert them and analyze them
1096 -- all at once. This won't work, because the analysis of earlier freeze
1097 -- nodes may recursively freeze types which would otherwise appear later
1098 -- on in the freeze list. So we must analyze and expand the freeze nodes
1099 -- as they are generated.
1101 procedure Freeze_All
(From
: Entity_Id
; After
: in out Node_Id
) is
1102 Loc
: constant Source_Ptr
:= Sloc
(After
);
1106 procedure Freeze_All_Ent
(From
: Entity_Id
; After
: in out Node_Id
);
1107 -- This is the internal recursive routine that does freezing of
1108 -- entities (but NOT the analysis of default expressions, which
1109 -- should not be recursive, we don't want to analyze those till
1110 -- we are sure that ALL the types are frozen).
1112 --------------------
1113 -- Freeze_All_Ent --
1114 --------------------
1116 procedure Freeze_All_Ent
1118 After
: in out Node_Id
)
1124 procedure Process_Flist
;
1125 -- If freeze nodes are present, insert and analyze, and reset
1126 -- cursor for next insertion.
1132 procedure Process_Flist
is
1134 if Is_Non_Empty_List
(Flist
) then
1135 Lastn
:= Next
(After
);
1136 Insert_List_After_And_Analyze
(After
, Flist
);
1138 if Present
(Lastn
) then
1139 After
:= Prev
(Lastn
);
1141 After
:= Last
(List_Containing
(After
));
1146 -- Start or processing for Freeze_All_Ent
1150 while Present
(E
) loop
1152 -- If the entity is an inner package which is not a package
1153 -- renaming, then its entities must be frozen at this point.
1154 -- Note that such entities do NOT get frozen at the end of
1155 -- the nested package itself (only library packages freeze).
1157 -- Same is true for task declarations, where anonymous records
1158 -- created for entry parameters must be frozen.
1160 if Ekind
(E
) = E_Package
1161 and then No
(Renamed_Object
(E
))
1162 and then not Is_Child_Unit
(E
)
1163 and then not Is_Frozen
(E
)
1166 Install_Visible_Declarations
(E
);
1167 Install_Private_Declarations
(E
);
1169 Freeze_All
(First_Entity
(E
), After
);
1171 End_Package_Scope
(E
);
1173 elsif Ekind
(E
) in Task_Kind
1175 (Nkind
(Parent
(E
)) = N_Task_Type_Declaration
1177 Nkind
(Parent
(E
)) = N_Single_Task_Declaration
)
1180 Freeze_All
(First_Entity
(E
), After
);
1183 -- For a derived tagged type, we must ensure that all the
1184 -- primitive operations of the parent have been frozen, so
1185 -- that their addresses will be in the parent's dispatch table
1186 -- at the point it is inherited.
1188 elsif Ekind
(E
) = E_Record_Type
1189 and then Is_Tagged_Type
(E
)
1190 and then Is_Tagged_Type
(Etype
(E
))
1191 and then Is_Derived_Type
(E
)
1194 Prim_List
: constant Elist_Id
:=
1195 Primitive_Operations
(Etype
(E
));
1201 Prim
:= First_Elmt
(Prim_List
);
1203 while Present
(Prim
) loop
1204 Subp
:= Node
(Prim
);
1206 if Comes_From_Source
(Subp
)
1207 and then not Is_Frozen
(Subp
)
1209 Flist
:= Freeze_Entity
(Subp
, Loc
);
1218 if not Is_Frozen
(E
) then
1219 Flist
:= Freeze_Entity
(E
, Loc
);
1223 -- If an incomplete type is still not frozen, this may be
1224 -- a premature freezing because of a body declaration that
1225 -- follows. Indicate where the freezing took place.
1227 -- If the freezing is caused by the end of the current
1228 -- declarative part, it is a Taft Amendment type, and there
1231 if not Is_Frozen
(E
)
1232 and then Ekind
(E
) = E_Incomplete_Type
1235 Bod
: constant Node_Id
:= Next
(After
);
1238 if (Nkind
(Bod
) = N_Subprogram_Body
1239 or else Nkind
(Bod
) = N_Entry_Body
1240 or else Nkind
(Bod
) = N_Package_Body
1241 or else Nkind
(Bod
) = N_Protected_Body
1242 or else Nkind
(Bod
) = N_Task_Body
1243 or else Nkind
(Bod
) in N_Body_Stub
)
1245 List_Containing
(After
) = List_Containing
(Parent
(E
))
1247 Error_Msg_Sloc
:= Sloc
(Next
(After
));
1249 ("type& is frozen# before its full declaration",
1259 -- Start of processing for Freeze_All
1262 Freeze_All_Ent
(From
, After
);
1264 -- Now that all types are frozen, we can deal with default expressions
1265 -- that require us to build a default expression functions. This is the
1266 -- point at which such functions are constructed (after all types that
1267 -- might be used in such expressions have been frozen).
1269 -- We also add finalization chains to access types whose designated
1270 -- types are controlled. This is normally done when freezing the type,
1271 -- but this misses recursive type definitions where the later members
1272 -- of the recursion introduce controlled components (e.g. 5624-001).
1274 -- Loop through entities
1277 while Present
(E
) loop
1278 if Is_Subprogram
(E
) then
1280 if not Default_Expressions_Processed
(E
) then
1281 Process_Default_Expressions
(E
, After
);
1284 if not Has_Completion
(E
) then
1285 Decl
:= Unit_Declaration_Node
(E
);
1287 if Nkind
(Decl
) = N_Subprogram_Renaming_Declaration
then
1288 Build_And_Analyze_Renamed_Body
(Decl
, E
, After
);
1290 elsif Nkind
(Decl
) = N_Subprogram_Declaration
1291 and then Present
(Corresponding_Body
(Decl
))
1293 Nkind
(Unit_Declaration_Node
(Corresponding_Body
(Decl
)))
1294 = N_Subprogram_Renaming_Declaration
1296 Build_And_Analyze_Renamed_Body
1297 (Decl
, Corresponding_Body
(Decl
), After
);
1301 elsif Ekind
(E
) in Task_Kind
1303 (Nkind
(Parent
(E
)) = N_Task_Type_Declaration
1305 Nkind
(Parent
(E
)) = N_Single_Task_Declaration
)
1310 Ent
:= First_Entity
(E
);
1312 while Present
(Ent
) loop
1315 and then not Default_Expressions_Processed
(Ent
)
1317 Process_Default_Expressions
(Ent
, After
);
1324 elsif Is_Access_Type
(E
)
1325 and then Comes_From_Source
(E
)
1326 and then Ekind
(Directly_Designated_Type
(E
)) = E_Incomplete_Type
1327 and then Controlled_Type
(Designated_Type
(E
))
1328 and then No
(Associated_Final_Chain
(E
))
1330 Build_Final_List
(Parent
(E
), E
);
1337 -----------------------
1338 -- Freeze_And_Append --
1339 -----------------------
1341 procedure Freeze_And_Append
1344 Result
: in out List_Id
)
1346 L
: constant List_Id
:= Freeze_Entity
(Ent
, Loc
);
1348 if Is_Non_Empty_List
(L
) then
1349 if Result
= No_List
then
1352 Append_List
(L
, Result
);
1355 end Freeze_And_Append
;
1361 procedure Freeze_Before
(N
: Node_Id
; T
: Entity_Id
) is
1362 Freeze_Nodes
: constant List_Id
:= Freeze_Entity
(T
, Sloc
(N
));
1364 if Is_Non_Empty_List
(Freeze_Nodes
) then
1365 Insert_Actions
(N
, Freeze_Nodes
);
1373 function Freeze_Entity
(E
: Entity_Id
; Loc
: Source_Ptr
) return List_Id
is
1374 Test_E
: Entity_Id
:= E
;
1382 procedure Check_Current_Instance
(Comp_Decl
: Node_Id
);
1383 -- Check that an Access or Unchecked_Access attribute with
1384 -- a prefix which is the current instance type can only be
1385 -- applied when the type is limited.
1387 function After_Last_Declaration
return Boolean;
1388 -- If Loc is a freeze_entity that appears after the last declaration
1389 -- in the scope, inhibit error messages on late completion.
1391 procedure Freeze_Record_Type
(Rec
: Entity_Id
);
1392 -- Freeze each component, handle some representation clauses, and
1393 -- freeze primitive operations if this is a tagged type.
1395 ----------------------------
1396 -- After_Last_Declaration --
1397 ----------------------------
1399 function After_Last_Declaration
return Boolean is
1400 Spec
: constant Node_Id
:= Parent
(Current_Scope
);
1403 if Nkind
(Spec
) = N_Package_Specification
then
1404 if Present
(Private_Declarations
(Spec
)) then
1405 return Loc
>= Sloc
(Last
(Private_Declarations
(Spec
)));
1407 elsif Present
(Visible_Declarations
(Spec
)) then
1408 return Loc
>= Sloc
(Last
(Visible_Declarations
(Spec
)));
1416 end After_Last_Declaration
;
1418 ----------------------------
1419 -- Check_Current_Instance --
1420 ----------------------------
1422 procedure Check_Current_Instance
(Comp_Decl
: Node_Id
) is
1424 function Process
(N
: Node_Id
) return Traverse_Result
;
1425 -- Process routine to apply check to given node.
1431 function Process
(N
: Node_Id
) return Traverse_Result
is
1434 when N_Attribute_Reference
=>
1435 if (Attribute_Name
(N
) = Name_Access
1437 Attribute_Name
(N
) = Name_Unchecked_Access
)
1438 and then Is_Entity_Name
(Prefix
(N
))
1439 and then Is_Type
(Entity
(Prefix
(N
)))
1440 and then Entity
(Prefix
(N
)) = E
1443 ("current instance must be a limited type", Prefix
(N
));
1449 when others => return OK
;
1453 procedure Traverse
is new Traverse_Proc
(Process
);
1455 -- Start of processing for Check_Current_Instance
1458 Traverse
(Comp_Decl
);
1459 end Check_Current_Instance
;
1461 ------------------------
1462 -- Freeze_Record_Type --
1463 ------------------------
1465 procedure Freeze_Record_Type
(Rec
: Entity_Id
) is
1472 Unplaced_Component
: Boolean := False;
1473 -- Set True if we find at least one component with no component
1474 -- clause (used to warn about useless Pack pragmas).
1476 Placed_Component
: Boolean := False;
1477 -- Set True if we find at least one component with a component
1478 -- clause (used to warn about useless Bit_Order pragmas).
1480 procedure Check_Itype
(Desig
: Entity_Id
);
1481 -- If the component subtype is an access to a constrained subtype
1482 -- of an already frozen type, make the subtype frozen as well. It
1483 -- might otherwise be frozen in the wrong scope, and a freeze node
1484 -- on subtype has no effect.
1490 procedure Check_Itype
(Desig
: Entity_Id
) is
1492 if not Is_Frozen
(Desig
)
1493 and then Is_Frozen
(Base_Type
(Desig
))
1495 Set_Is_Frozen
(Desig
);
1497 -- In addition, add an Itype_Reference to ensure that the
1498 -- access subtype is elaborated early enough. This cannot
1499 -- be done if the subtype may depend on discriminants.
1501 if Ekind
(Comp
) = E_Component
1502 and then Is_Itype
(Etype
(Comp
))
1503 and then not Has_Discriminants
(Rec
)
1505 IR
:= Make_Itype_Reference
(Sloc
(Comp
));
1506 Set_Itype
(IR
, Desig
);
1509 Result
:= New_List
(IR
);
1511 Append
(IR
, Result
);
1517 -- Start of processing for Freeze_Record_Type
1520 -- If this is a subtype of a controlled type, declared without
1521 -- a constraint, the _controller may not appear in the component
1522 -- list if the parent was not frozen at the point of subtype
1523 -- declaration. Inherit the _controller component now.
1525 if Rec
/= Base_Type
(Rec
)
1526 and then Has_Controlled_Component
(Rec
)
1528 if Nkind
(Parent
(Rec
)) = N_Subtype_Declaration
1529 and then Is_Entity_Name
(Subtype_Indication
(Parent
(Rec
)))
1531 Set_First_Entity
(Rec
, First_Entity
(Base_Type
(Rec
)));
1533 -- If this is an internal type without a declaration, as for a
1534 -- record component, the base type may not yet be frozen, and its
1535 -- controller has not been created. Add an explicit freeze node
1536 -- for the itype, so it will be frozen after the base type.
1538 elsif Is_Itype
(Rec
)
1539 and then Has_Delayed_Freeze
(Base_Type
(Rec
))
1541 Nkind
(Associated_Node_For_Itype
(Rec
)) =
1542 N_Component_Declaration
1544 Ensure_Freeze_Node
(Rec
);
1548 -- Freeze components and embedded subtypes.
1550 Comp
:= First_Entity
(Rec
);
1553 while Present
(Comp
) loop
1555 -- First handle the (real) component case.
1557 if Ekind
(Comp
) = E_Component
1558 or else Ekind
(Comp
) = E_Discriminant
1561 CC
: constant Node_Id
:= Component_Clause
(Comp
);
1564 -- Freezing a record type freezes the type of each of its
1565 -- components. However, if the type of the component is
1566 -- part of this record, we do not want or need a separate
1567 -- Freeze_Node. Note that Is_Itype is wrong because that's
1568 -- also set in private type cases. We also can't check
1569 -- for the Scope being exactly Rec because of private types
1570 -- and record extensions.
1571 if Is_Itype
(Etype
(Comp
))
1572 and then Is_Record_Type
(Underlying_Type
1573 (Scope
(Etype
(Comp
))))
1575 Undelay_Type
(Etype
(Comp
));
1578 Freeze_And_Append
(Etype
(Comp
), Loc
, Result
);
1580 -- Check for error of component clause given for variable
1581 -- sized type. We have to delay this test till this point,
1582 -- since the component type has to be frozen for us to know
1583 -- if it is variable length. We omit this test in a generic
1584 -- context, it will be applied at instantiation time.
1586 if Present
(CC
) then
1587 Placed_Component
:= True;
1589 if Inside_A_Generic
then
1592 elsif not Size_Known_At_Compile_Time
1593 (Underlying_Type
(Etype
(Comp
)))
1596 ("component clause not allowed for variable " &
1597 "length component", CC
);
1601 Unplaced_Component
:= True;
1604 -- Case of component requires byte alignment
1606 if Must_Be_On_Byte_Boundary
(Etype
(Comp
)) then
1608 -- Set the enclosing record to also require byte align
1610 Set_Must_Be_On_Byte_Boundary
(Rec
);
1612 -- Check for component clause that is inconsistent
1613 -- with the required byte boundary alignment.
1616 and then Normalized_First_Bit
(Comp
) mod
1617 System_Storage_Unit
/= 0
1620 ("component & must be byte aligned",
1621 Component_Name
(Component_Clause
(Comp
)));
1625 -- If component clause is present, then deal with the
1626 -- non-default bit order case. We cannot do this before
1627 -- the freeze point, because there is no required order
1628 -- for the component clause and the bit_order clause.
1630 -- We only do this processing for the base type, and in
1631 -- fact that's important, since otherwise if there are
1632 -- record subtypes, we could reverse the bits once for
1633 -- each subtype, which would be incorrect.
1636 and then Reverse_Bit_Order
(Rec
)
1637 and then Ekind
(E
) = E_Record_Type
1640 CFB
: constant Uint
:= Component_Bit_Offset
(Comp
);
1641 CSZ
: constant Uint
:= Esize
(Comp
);
1642 CLC
: constant Node_Id
:= Component_Clause
(Comp
);
1643 Pos
: constant Node_Id
:= Position
(CLC
);
1644 FB
: constant Node_Id
:= First_Bit
(CLC
);
1646 Storage_Unit_Offset
: constant Uint
:=
1647 CFB
/ System_Storage_Unit
;
1649 Start_Bit
: constant Uint
:=
1650 CFB
mod System_Storage_Unit
;
1653 -- Cases where field goes over storage unit boundary
1655 if Start_Bit
+ CSZ
> System_Storage_Unit
then
1657 -- Allow multi-byte field but generate warning
1659 if Start_Bit
mod System_Storage_Unit
= 0
1660 and then CSZ
mod System_Storage_Unit
= 0
1663 ("multi-byte field specified with non-standard"
1664 & " Bit_Order?", CLC
);
1666 if Bytes_Big_Endian
then
1668 ("bytes are not reversed "
1669 & "(component is big-endian)?", CLC
);
1672 ("bytes are not reversed "
1673 & "(component is little-endian)?", CLC
);
1676 -- Do not allow non-contiguous field
1680 ("attempt to specify non-contiguous field"
1681 & " not permitted", CLC
);
1683 ("\(caused by non-standard Bit_Order "
1684 & "specified)", CLC
);
1687 -- Case where field fits in one storage unit
1690 -- Give warning if suspicious component clause
1692 if Intval
(FB
) >= System_Storage_Unit
then
1694 ("?Bit_Order clause does not affect " &
1695 "byte ordering", Pos
);
1697 Intval
(Pos
) + Intval
(FB
) /
1698 System_Storage_Unit
;
1700 ("?position normalized to ^ before bit " &
1701 "order interpreted", Pos
);
1704 -- Here is where we fix up the Component_Bit_Offset
1705 -- value to account for the reverse bit order.
1706 -- Some examples of what needs to be done are:
1708 -- First_Bit .. Last_Bit Component_Bit_Offset
1711 -- 0 .. 0 7 .. 7 0 7
1712 -- 0 .. 1 6 .. 7 0 6
1713 -- 0 .. 2 5 .. 7 0 5
1714 -- 0 .. 7 0 .. 7 0 4
1716 -- 1 .. 1 6 .. 6 1 6
1717 -- 1 .. 4 3 .. 6 1 3
1718 -- 4 .. 7 0 .. 3 4 0
1720 -- The general rule is that the first bit is
1721 -- is obtained by subtracting the old ending bit
1722 -- from storage_unit - 1.
1724 Set_Component_Bit_Offset
1726 (Storage_Unit_Offset
* System_Storage_Unit
) +
1727 (System_Storage_Unit
- 1) -
1728 (Start_Bit
+ CSZ
- 1));
1730 Set_Normalized_First_Bit
1732 Component_Bit_Offset
(Comp
) mod
1733 System_Storage_Unit
);
1740 -- If the component is an Itype with Delayed_Freeze and is
1741 -- either a record or array subtype and its base type has not
1742 -- yet been frozen, we must remove this from the entity list
1743 -- of this record and put it on the entity list of the scope of
1744 -- its base type. Note that we know that this is not the type
1745 -- of a component since we cleared Has_Delayed_Freeze for it
1746 -- in the previous loop. Thus this must be the Designated_Type
1747 -- of an access type, which is the type of a component.
1749 and then Is_Type
(Scope
(Comp
))
1750 and then Is_Composite_Type
(Comp
)
1751 and then Base_Type
(Comp
) /= Comp
1752 and then Has_Delayed_Freeze
(Comp
)
1753 and then not Is_Frozen
(Base_Type
(Comp
))
1756 Will_Be_Frozen
: Boolean := False;
1757 S
: Entity_Id
:= Scope
(Rec
);
1760 -- We have a pretty bad kludge here. Suppose Rec is a
1761 -- subtype being defined in a subprogram that's created
1762 -- as part of the freezing of Rec'Base. In that case,
1763 -- we know that Comp'Base must have already been frozen by
1764 -- the time we get to elaborate this because Gigi doesn't
1765 -- elaborate any bodies until it has elaborated all of the
1766 -- declarative part. But Is_Frozen will not be set at this
1767 -- point because we are processing code in lexical order.
1769 -- We detect this case by going up the Scope chain of
1770 -- Rec and seeing if we have a subprogram scope before
1771 -- reaching the top of the scope chain or that of Comp'Base.
1772 -- If we do, then mark that Comp'Base will actually be
1773 -- frozen. If so, we merely undelay it.
1774 while Present
(S
) loop
1775 if Is_Subprogram
(S
) then
1776 Will_Be_Frozen
:= True;
1778 elsif S
= Scope
(Base_Type
(Comp
)) then
1785 if Will_Be_Frozen
then
1786 Undelay_Type
(Comp
);
1788 if Present
(Prev
) then
1789 Set_Next_Entity
(Prev
, Next_Entity
(Comp
));
1791 Set_First_Entity
(Rec
, Next_Entity
(Comp
));
1794 -- Insert in entity list of scope of base type (which
1795 -- must be an enclosing scope, because still unfrozen).
1797 Append_Entity
(Comp
, Scope
(Base_Type
(Comp
)));
1801 -- If the component is an access type with an allocator
1802 -- as default value, the designated type will be frozen
1803 -- by the corresponding expression in init_proc. In order
1804 -- to place the freeze node for the designated type before
1805 -- that for the current record type, freeze it now.
1807 -- Same process if the component is an array of access types,
1808 -- initialized with an aggregate. If the designated type is
1809 -- private, it cannot contain allocators, and it is premature
1810 -- to freeze the type, so we check for this as well.
1812 elsif Is_Access_Type
(Etype
(Comp
))
1813 and then Present
(Parent
(Comp
))
1814 and then Present
(Expression
(Parent
(Comp
)))
1815 and then Nkind
(Expression
(Parent
(Comp
))) = N_Allocator
1818 Alloc
: constant Node_Id
:= Expression
(Parent
(Comp
));
1821 -- If component is pointer to a classwide type, freeze
1822 -- the specific type in the expression being allocated.
1823 -- The expression may be a subtype indication, in which
1824 -- case freeze the subtype mark.
1826 if Is_Class_Wide_Type
(Designated_Type
(Etype
(Comp
))) then
1827 if Is_Entity_Name
(Expression
(Alloc
)) then
1829 (Entity
(Expression
(Alloc
)), Loc
, Result
);
1831 Nkind
(Expression
(Alloc
)) = N_Subtype_Indication
1834 (Entity
(Subtype_Mark
(Expression
(Alloc
))),
1838 elsif Is_Itype
(Designated_Type
(Etype
(Comp
))) then
1839 Check_Itype
(Designated_Type
(Etype
(Comp
)));
1843 (Designated_Type
(Etype
(Comp
)), Loc
, Result
);
1847 elsif Is_Access_Type
(Etype
(Comp
))
1848 and then Is_Itype
(Designated_Type
(Etype
(Comp
)))
1850 Check_Itype
(Designated_Type
(Etype
(Comp
)));
1852 elsif Is_Array_Type
(Etype
(Comp
))
1853 and then Is_Access_Type
(Component_Type
(Etype
(Comp
)))
1854 and then Present
(Parent
(Comp
))
1855 and then Nkind
(Parent
(Comp
)) = N_Component_Declaration
1856 and then Present
(Expression
(Parent
(Comp
)))
1857 and then Nkind
(Expression
(Parent
(Comp
))) = N_Aggregate
1858 and then Is_Fully_Defined
1859 (Designated_Type
(Component_Type
(Etype
(Comp
))))
1863 (Component_Type
(Etype
(Comp
))), Loc
, Result
);
1870 -- Check for useless pragma Bit_Order
1872 if not Placed_Component
and then Reverse_Bit_Order
(Rec
) then
1873 ADC
:= Get_Attribute_Definition_Clause
(Rec
, Attribute_Bit_Order
);
1874 Error_Msg_N
("?Bit_Order specification has no effect", ADC
);
1875 Error_Msg_N
("\?since no component clauses were specified", ADC
);
1878 -- Check for useless pragma Pack when all components placed
1881 and then not Unplaced_Component
1882 and then Warn_On_Redundant_Constructs
1885 ("?pragma Pack has no effect, no unplaced components",
1886 Get_Rep_Pragma
(Rec
, Name_Pack
));
1887 Set_Is_Packed
(Rec
, False);
1890 -- If this is the record corresponding to a remote type,
1891 -- freeze the remote type here since that is what we are
1892 -- semantically freezing. This prevents having the freeze
1893 -- node for that type in an inner scope.
1895 -- Also, Check for controlled components and unchecked unions.
1896 -- Finally, enforce the restriction that access attributes with
1897 -- a current instance prefix can only apply to limited types.
1899 if Ekind
(Rec
) = E_Record_Type
then
1900 if Present
(Corresponding_Remote_Type
(Rec
)) then
1902 (Corresponding_Remote_Type
(Rec
), Loc
, Result
);
1905 Comp
:= First_Component
(Rec
);
1906 while Present
(Comp
) loop
1907 if Has_Controlled_Component
(Etype
(Comp
))
1908 or else (Chars
(Comp
) /= Name_uParent
1909 and then Is_Controlled
(Etype
(Comp
)))
1910 or else (Is_Protected_Type
(Etype
(Comp
))
1912 (Corresponding_Record_Type
(Etype
(Comp
)))
1913 and then Has_Controlled_Component
1914 (Corresponding_Record_Type
(Etype
(Comp
))))
1916 Set_Has_Controlled_Component
(Rec
);
1920 if Has_Unchecked_Union
(Etype
(Comp
)) then
1921 Set_Has_Unchecked_Union
(Rec
);
1924 if Has_Per_Object_Constraint
(Comp
)
1925 and then not Is_Limited_Type
(Rec
)
1927 -- Scan component declaration for likely misuses of
1928 -- current instance, either in a constraint or in a
1929 -- default expression.
1931 Check_Current_Instance
(Parent
(Comp
));
1934 Next_Component
(Comp
);
1938 Set_Component_Alignment_If_Not_Set
(Rec
);
1940 -- For first subtypes, check if there are any fixed-point
1941 -- fields with component clauses, where we must check the size.
1942 -- This is not done till the freeze point, since for fixed-point
1943 -- types, we do not know the size until the type is frozen.
1944 -- Similar processing applies to bit packed arrays.
1946 if Is_First_Subtype
(Rec
) then
1947 Comp
:= First_Component
(Rec
);
1949 while Present
(Comp
) loop
1950 if Present
(Component_Clause
(Comp
))
1951 and then (Is_Fixed_Point_Type
(Etype
(Comp
))
1953 Is_Bit_Packed_Array
(Etype
(Comp
)))
1956 (Component_Name
(Component_Clause
(Comp
)),
1962 Next_Component
(Comp
);
1965 end Freeze_Record_Type
;
1967 -- Start of processing for Freeze_Entity
1970 -- We are going to test for various reasons why this entity need
1971 -- not be frozen here, but in the case of an Itype that's defined
1972 -- within a record, that test actually applies to the record.
1973 if Is_Itype
(E
) and then Is_Record_Type
(Scope
(E
)) then
1974 Test_E
:= Scope
(E
);
1975 elsif Is_Itype
(E
) and then Present
(Underlying_Type
(Scope
(E
)))
1976 and then Is_Record_Type
(Underlying_Type
(Scope
(E
)))
1978 Test_E
:= Underlying_Type
(Scope
(E
));
1981 -- Do not freeze if already frozen since we only need one freeze node
1983 if Is_Frozen
(E
) then
1986 -- It is improper to freeze an external entity within a generic
1987 -- because its freeze node will appear in a non-valid context.
1988 -- The entity will be frozen in the proper scope after the current
1989 -- generic is analyzed.
1991 elsif Inside_A_Generic
and then External_Ref_In_Generic
(Test_E
) then
1994 -- Do not freeze a global entity within an inner scope created during
1995 -- expansion. A call to subprogram E within some internal procedure
1996 -- (a stream attribute for example) might require freezing E, but the
1997 -- freeze node must appear in the same declarative part as E itself.
1998 -- The two-pass elaboration mechanism in gigi guarantees that E will
1999 -- be frozen before the inner call is elaborated. We exclude constants
2000 -- from this test, because deferred constants may be frozen early, and
2001 -- must be diagnosed (see e.g. 1522-005). If the enclosing subprogram
2002 -- comes from source, or is a generic instance, then the freeze point
2003 -- is the one mandated by the language. and we freze the entity.
2005 elsif In_Open_Scopes
(Scope
(Test_E
))
2006 and then Scope
(Test_E
) /= Current_Scope
2007 and then Ekind
(Test_E
) /= E_Constant
2010 S
: Entity_Id
:= Current_Scope
;
2013 while Present
(S
) loop
2014 if Is_Overloadable
(S
) then
2015 if Comes_From_Source
(S
)
2016 or else Is_Generic_Instance
(S
)
2028 -- Similarly, an inlined instance body may make reference to global
2029 -- entities, but these references cannot be the proper freezing point
2030 -- for them, and the the absence of inlining freezing will take place
2031 -- in their own scope. Normally instance bodies are analyzed after
2032 -- the enclosing compilation, and everything has been frozen at the
2033 -- proper place, but with front-end inlining an instance body is
2034 -- compiled before the end of the enclosing scope, and as a result
2035 -- out-of-order freezing must be prevented.
2037 elsif Front_End_Inlining
2038 and then In_Instance_Body
2039 and then Present
(Scope
(Test_E
))
2042 S
: Entity_Id
:= Scope
(Test_E
);
2044 while Present
(S
) loop
2045 if Is_Generic_Instance
(S
) then
2058 -- Here to freeze the entity
2063 -- Case of entity being frozen is other than a type
2065 if not Is_Type
(E
) then
2067 -- If entity is exported or imported and does not have an external
2068 -- name, now is the time to provide the appropriate default name.
2069 -- Skip this if the entity is stubbed, since we don't need a name
2070 -- for any stubbed routine.
2072 if (Is_Imported
(E
) or else Is_Exported
(E
))
2073 and then No
(Interface_Name
(E
))
2074 and then Convention
(E
) /= Convention_Stubbed
2076 Set_Encoded_Interface_Name
2077 (E
, Get_Default_External_Name
(E
));
2079 -- Special processing for atomic objects appearing in object decls
2082 and then Nkind
(Parent
(E
)) = N_Object_Declaration
2083 and then Present
(Expression
(Parent
(E
)))
2086 Expr
: constant Node_Id
:= Expression
(Parent
(E
));
2089 -- If expression is an aggregate, assign to a temporary to
2090 -- ensure that the actual assignment is done atomically rather
2091 -- than component-wise (the assignment to the temp may be done
2092 -- component-wise, but that is harmless.
2094 if Nkind
(Expr
) = N_Aggregate
then
2095 Expand_Atomic_Aggregate
(Expr
, Etype
(E
));
2097 -- If the expression is a reference to a record or array
2098 -- object entity, then reset Is_True_Constant to False so
2099 -- that the compiler will not optimize away the intermediate
2100 -- object, which we need in this case for the same reason
2101 -- (to ensure that the actual assignment is atomic, rather
2102 -- than component-wise).
2104 elsif Is_Entity_Name
(Expr
)
2105 and then (Is_Record_Type
(Etype
(Expr
))
2107 Is_Array_Type
(Etype
(Expr
)))
2109 Set_Is_True_Constant
(Entity
(Expr
), False);
2114 -- For a subprogram, freeze all parameter types and also the return
2115 -- type (RM 13.14(14)). However skip this for internal subprograms.
2116 -- This is also the point where any extra formal parameters are
2117 -- created since we now know whether the subprogram will use
2118 -- a foreign convention.
2120 if Is_Subprogram
(E
) then
2121 if not Is_Internal
(E
) then
2124 Warn_Node
: Node_Id
;
2126 function Is_Fat_C_Ptr_Type
(T
: Entity_Id
) return Boolean;
2127 -- Determines if given type entity is a fat pointer type
2128 -- used as an argument type or return type to a subprogram
2129 -- with C or C++ convention set.
2131 --------------------------
2132 -- Is_Fat_C_Access_Type --
2133 --------------------------
2135 function Is_Fat_C_Ptr_Type
(T
: Entity_Id
) return Boolean is
2137 return (Convention
(E
) = Convention_C
2139 Convention
(E
) = Convention_CPP
)
2140 and then Is_Access_Type
(T
)
2141 and then Esize
(T
) > Ttypes
.System_Address_Size
;
2142 end Is_Fat_C_Ptr_Type
;
2145 -- Loop through formals
2147 Formal
:= First_Formal
(E
);
2148 while Present
(Formal
) loop
2149 F_Type
:= Etype
(Formal
);
2150 Freeze_And_Append
(F_Type
, Loc
, Result
);
2152 if Is_Private_Type
(F_Type
)
2153 and then Is_Private_Type
(Base_Type
(F_Type
))
2154 and then No
(Full_View
(Base_Type
(F_Type
)))
2155 and then not Is_Generic_Type
(F_Type
)
2156 and then not Is_Derived_Type
(F_Type
)
2158 -- If the type of a formal is incomplete, subprogram
2159 -- is being frozen prematurely. Within an instance
2160 -- (but not within a wrapper package) this is an
2161 -- an artifact of our need to regard the end of an
2162 -- instantiation as a freeze point. Otherwise it is
2163 -- a definite error.
2165 -- and then not Is_Wrapper_Package (Current_Scope) ???
2168 Set_Is_Frozen
(E
, False);
2171 elsif not After_Last_Declaration
then
2172 Error_Msg_Node_1
:= F_Type
;
2174 ("type& must be fully defined before this point",
2179 -- Check bad use of fat C pointer
2181 if Warn_On_Export_Import
and then
2182 Is_Fat_C_Ptr_Type
(F_Type
)
2184 Error_Msg_Qual_Level
:= 1;
2186 ("?type of & does not correspond to C pointer",
2188 Error_Msg_Qual_Level
:= 0;
2191 -- Check for unconstrained array in exported foreign
2194 if Convention
(E
) in Foreign_Convention
2195 and then not Is_Imported
(E
)
2196 and then Is_Array_Type
(F_Type
)
2197 and then not Is_Constrained
(F_Type
)
2198 and then Warn_On_Export_Import
2200 Error_Msg_Qual_Level
:= 1;
2202 -- If this is an inherited operation, place the
2203 -- warning on the derived type declaration, rather
2204 -- than on the original subprogram.
2206 if Nkind
(Original_Node
(Parent
(E
))) =
2207 N_Full_Type_Declaration
2209 Warn_Node
:= Parent
(E
);
2211 if Formal
= First_Formal
(E
) then
2213 ("?in inherited operation&!", Warn_Node
, E
);
2216 Warn_Node
:= Formal
;
2220 ("?type of argument& is unconstrained array",
2223 ("?foreign caller must pass bounds explicitly",
2225 Error_Msg_Qual_Level
:= 0;
2228 Next_Formal
(Formal
);
2231 -- Check return type
2233 if Ekind
(E
) = E_Function
then
2234 Freeze_And_Append
(Etype
(E
), Loc
, Result
);
2236 if Warn_On_Export_Import
2237 and then Is_Fat_C_Ptr_Type
(Etype
(E
))
2240 ("?return type of& does not correspond to C pointer",
2243 elsif Is_Array_Type
(Etype
(E
))
2244 and then not Is_Constrained
(Etype
(E
))
2245 and then not Is_Imported
(E
)
2246 and then Convention
(E
) in Foreign_Convention
2247 and then Warn_On_Export_Import
2250 ("?foreign convention function& should not " &
2251 "return unconstrained array", E
);
2257 -- Must freeze its parent first if it is a derived subprogram
2259 if Present
(Alias
(E
)) then
2260 Freeze_And_Append
(Alias
(E
), Loc
, Result
);
2263 -- If the return type requires a transient scope, and we are on
2264 -- a target allowing functions to return with a depressed stack
2265 -- pointer, then we mark the function as requiring this treatment.
2267 if Ekind
(E
) = E_Function
2268 and then Functions_Return_By_DSP_On_Target
2269 and then Requires_Transient_Scope
(Etype
(E
))
2271 Set_Function_Returns_With_DSP
(E
);
2274 if not Is_Internal
(E
) then
2275 Freeze_Subprogram
(E
);
2278 -- Here for other than a subprogram or type
2281 -- If entity has a type, and it is not a generic unit, then
2282 -- freeze it first (RM 13.14(10))
2284 if Present
(Etype
(E
))
2285 and then Ekind
(E
) /= E_Generic_Function
2287 Freeze_And_Append
(Etype
(E
), Loc
, Result
);
2290 -- Special processing for objects created by object declaration
2292 if Nkind
(Declaration_Node
(E
)) = N_Object_Declaration
then
2294 -- For object created by object declaration, perform required
2295 -- categorization (preelaborate and pure) checks. Defer these
2296 -- checks to freeze time since pragma Import inhibits default
2297 -- initialization and thus pragma Import affects these checks.
2299 Validate_Object_Declaration
(Declaration_Node
(E
));
2301 -- If there is an address clause, check it is valid
2303 Check_Address_Clause
(E
);
2305 -- For imported objects, set Is_Public unless there is also
2306 -- an address clause, which means that there is no external
2307 -- symbol needed for the Import (Is_Public may still be set
2308 -- for other unrelated reasons). Note that we delayed this
2309 -- processing till freeze time so that we can be sure not
2310 -- to set the flag if there is an address clause. If there
2311 -- is such a clause, then the only purpose of the import
2312 -- pragma is to suppress implicit initialization.
2315 and then not Present
(Address_Clause
(E
))
2321 -- Check that a constant which has a pragma Volatile[_Components]
2322 -- or Atomic[_Components] also has a pragma Import (RM C.6(13))
2324 -- Note: Atomic[_Components] also sets Volatile[_Components]
2326 if Ekind
(E
) = E_Constant
2327 and then (Has_Volatile_Components
(E
) or else Is_Volatile
(E
))
2328 and then not Is_Imported
(E
)
2330 -- Make sure we actually have a pragma, and have not merely
2331 -- inherited the indication from elsewhere (e.g. an address
2332 -- clause, which is not good enough in RM terms!)
2334 if Has_Rep_Pragma
(E
, Name_Atomic
)
2336 Has_Rep_Pragma
(E
, Name_Atomic_Components
)
2339 ("stand alone atomic constant must be " &
2340 "imported ('R'M 'C.6(13))", E
);
2342 elsif Has_Rep_Pragma
(E
, Name_Volatile
)
2344 Has_Rep_Pragma
(E
, Name_Volatile_Components
)
2347 ("stand alone volatile constant must be " &
2348 "imported ('R'M 'C.6(13))", E
);
2352 -- Static objects require special handling
2354 if (Ekind
(E
) = E_Constant
or else Ekind
(E
) = E_Variable
)
2355 and then Is_Statically_Allocated
(E
)
2357 Freeze_Static_Object
(E
);
2360 -- Remaining step is to layout objects
2362 if Ekind
(E
) = E_Variable
2364 Ekind
(E
) = E_Constant
2366 Ekind
(E
) = E_Loop_Parameter
2374 -- Case of a type or subtype being frozen
2377 -- The type may be defined in a generic unit. This can occur when
2378 -- freezing a generic function that returns the type (which is
2379 -- defined in a parent unit). It is clearly meaningless to freeze
2380 -- this type. However, if it is a subtype, its size may be determi-
2381 -- nable and used in subsequent checks, so might as well try to
2384 if Present
(Scope
(E
))
2385 and then Is_Generic_Unit
(Scope
(E
))
2387 Check_Compile_Time_Size
(E
);
2391 -- Deal with special cases of freezing for subtype
2393 if E
/= Base_Type
(E
) then
2395 -- If ancestor subtype present, freeze that first.
2396 -- Note that this will also get the base type frozen.
2398 Atype
:= Ancestor_Subtype
(E
);
2400 if Present
(Atype
) then
2401 Freeze_And_Append
(Atype
, Loc
, Result
);
2403 -- Otherwise freeze the base type of the entity before
2404 -- freezing the entity itself, (RM 13.14(15)).
2406 elsif E
/= Base_Type
(E
) then
2407 Freeze_And_Append
(Base_Type
(E
), Loc
, Result
);
2410 -- For a derived type, freeze its parent type first (RM 13.14(15))
2412 elsif Is_Derived_Type
(E
) then
2413 Freeze_And_Append
(Etype
(E
), Loc
, Result
);
2414 Freeze_And_Append
(First_Subtype
(Etype
(E
)), Loc
, Result
);
2417 -- For array type, freeze index types and component type first
2418 -- before freezing the array (RM 13.14(15)).
2420 if Is_Array_Type
(E
) then
2422 Ctyp
: constant Entity_Id
:= Component_Type
(E
);
2425 Non_Standard_Enum
: Boolean := False;
2426 -- Set true if any of the index types is an enumeration
2427 -- type with a non-standard representation.
2430 Freeze_And_Append
(Ctyp
, Loc
, Result
);
2432 Indx
:= First_Index
(E
);
2433 while Present
(Indx
) loop
2434 Freeze_And_Append
(Etype
(Indx
), Loc
, Result
);
2436 if Is_Enumeration_Type
(Etype
(Indx
))
2437 and then Has_Non_Standard_Rep
(Etype
(Indx
))
2439 Non_Standard_Enum
:= True;
2445 -- Processing that is done only for base types
2447 if Ekind
(E
) = E_Array_Type
then
2449 -- Propagate flags for component type
2451 if Is_Controlled
(Component_Type
(E
))
2452 or else Has_Controlled_Component
(Ctyp
)
2454 Set_Has_Controlled_Component
(E
);
2457 if Has_Unchecked_Union
(Component_Type
(E
)) then
2458 Set_Has_Unchecked_Union
(E
);
2461 -- If packing was requested or if the component size was set
2462 -- explicitly, then see if bit packing is required. This
2463 -- processing is only done for base types, since all the
2464 -- representation aspects involved are type-related. This
2465 -- is not just an optimization, if we start processing the
2466 -- subtypes, they intefere with the settings on the base
2467 -- type (this is because Is_Packed has a slightly different
2468 -- meaning before and after freezing).
2475 if (Is_Packed
(E
) or else Has_Pragma_Pack
(E
))
2476 and then not Has_Atomic_Components
(E
)
2477 and then Known_Static_RM_Size
(Ctyp
)
2479 Csiz
:= UI_Max
(RM_Size
(Ctyp
), 1);
2481 elsif Known_Component_Size
(E
) then
2482 Csiz
:= Component_Size
(E
);
2484 elsif not Known_Static_Esize
(Ctyp
) then
2488 Esiz
:= Esize
(Ctyp
);
2490 -- We can set the component size if it is less than
2491 -- 16, rounding it up to the next storage unit size.
2495 elsif Esiz
<= 16 then
2501 -- Set component size up to match alignment if
2502 -- it would otherwise be less than the alignment.
2503 -- This deals with cases of types whose alignment
2504 -- exceeds their sizes (padded types).
2508 A
: constant Uint
:= Alignment_In_Bits
(Ctyp
);
2519 if 1 <= Csiz
and then Csiz
<= 64 then
2521 -- We set the component size for all cases 1-64
2523 Set_Component_Size
(Base_Type
(E
), Csiz
);
2525 -- Check for base type of 8,16,32 bits, where the
2526 -- subtype has a length one less than the base type
2527 -- and is unsigned (e.g. Natural subtype of Integer)
2529 -- In such cases, if a component size was not set
2530 -- explicitly, then generate a warning.
2532 if Has_Pragma_Pack
(E
)
2533 and then not Has_Component_Size_Clause
(E
)
2535 (Csiz
= 7 or else Csiz
= 15 or else Csiz
= 31)
2536 and then Esize
(Base_Type
(Ctyp
)) = Csiz
+ 1
2538 Error_Msg_Uint_1
:= Csiz
;
2540 Get_Rep_Pragma
(First_Subtype
(E
), Name_Pack
);
2542 if Present
(Pnod
) then
2544 ("pragma Pack causes component size to be ^?",
2547 ("\use Component_Size to set desired value",
2552 -- Actual packing is not needed for 8,16,32,64
2553 -- Also not needed for 24 if alignment is 1
2559 or else (Csiz
= 24 and then Alignment
(Ctyp
) = 1)
2561 -- Here the array was requested to be packed, but
2562 -- the packing request had no effect, so Is_Packed
2565 -- Note: semantically this means that we lose
2566 -- track of the fact that a derived type inherited
2567 -- a pack pragma that was non-effective, but that
2570 -- We regard a Pack pragma as a request to set a
2571 -- representation characteristic, and this request
2574 Set_Is_Packed
(Base_Type
(E
), False);
2576 -- In all other cases, packing is indeed needed
2579 Set_Has_Non_Standard_Rep
(Base_Type
(E
));
2580 Set_Is_Bit_Packed_Array
(Base_Type
(E
));
2581 Set_Is_Packed
(Base_Type
(E
));
2586 -- Processing that is done only for subtypes
2589 -- Acquire alignment from base type
2591 if Unknown_Alignment
(E
) then
2592 Set_Alignment
(E
, Alignment
(Base_Type
(E
)));
2596 -- For bit-packed arrays, check the size
2598 if Is_Bit_Packed_Array
(E
)
2599 and then Known_Esize
(E
)
2603 SizC
: constant Node_Id
:= Size_Clause
(E
);
2606 -- It is not clear if it is possible to have no size
2607 -- clause at this stage, but this is not worth worrying
2608 -- about. Post the error on the entity name in the size
2609 -- clause if present, else on the type entity itself.
2611 if Present
(SizC
) then
2612 Check_Size
(Name
(SizC
), E
, Esize
(E
), Discard
);
2614 Check_Size
(E
, E
, Esize
(E
), Discard
);
2619 -- Check one common case of a size given where the array
2620 -- needs to be packed, but was not so the size cannot be
2621 -- honored. This would of course be caught by the backend,
2622 -- and indeed we don't catch all cases. The point is that
2623 -- we can give a better error message in those cases that
2624 -- we do catch with the circuitry here.
2628 Ctyp
: constant Entity_Id
:= Component_Type
(E
);
2631 if Present
(Size_Clause
(E
))
2632 and then Known_Static_Esize
(E
)
2633 and then not Is_Bit_Packed_Array
(E
)
2634 and then not Has_Pragma_Pack
(E
)
2635 and then Number_Dimensions
(E
) = 1
2636 and then not Has_Component_Size_Clause
(E
)
2637 and then Known_Static_Esize
(Ctyp
)
2639 Get_Index_Bounds
(First_Index
(E
), Lo
, Hi
);
2641 if Compile_Time_Known_Value
(Lo
)
2642 and then Compile_Time_Known_Value
(Hi
)
2643 and then Known_Static_RM_Size
(Ctyp
)
2644 and then RM_Size
(Ctyp
) < 64
2647 Lov
: constant Uint
:= Expr_Value
(Lo
);
2648 Hiv
: constant Uint
:= Expr_Value
(Hi
);
2649 Len
: constant Uint
:=
2650 UI_Max
(Uint_0
, Hiv
- Lov
+ 1);
2651 Rsiz
: constant Uint
:= RM_Size
(Ctyp
);
2653 -- What we are looking for here is the situation
2654 -- where the Esize given would be exactly right
2655 -- if there was a pragma Pack (resulting in the
2656 -- component size being the same as the RM_Size).
2657 -- Furthermore, the component type size must be
2658 -- an odd size (not a multiple of storage unit)
2661 if Esize
(E
) = Len
* Rsiz
2662 and then Rsiz
mod System_Storage_Unit
/= 0
2665 ("size given for& too small",
2666 Size_Clause
(E
), E
);
2668 ("\explicit pragma Pack is required",
2676 -- If any of the index types was an enumeration type with
2677 -- a non-standard rep clause, then we indicate that the
2678 -- array type is always packed (even if it is not bit packed).
2680 if Non_Standard_Enum
then
2681 Set_Has_Non_Standard_Rep
(Base_Type
(E
));
2682 Set_Is_Packed
(Base_Type
(E
));
2685 Set_Component_Alignment_If_Not_Set
(E
);
2687 -- If the array is packed, we must create the packed array
2688 -- type to be used to actually implement the type. This is
2689 -- only needed for real array types (not for string literal
2690 -- types, since they are present only for the front end).
2693 and then Ekind
(E
) /= E_String_Literal_Subtype
2695 Create_Packed_Array_Type
(E
);
2696 Freeze_And_Append
(Packed_Array_Type
(E
), Loc
, Result
);
2698 -- Size information of packed array type is copied to the
2699 -- array type, since this is really the representation.
2701 Set_Size_Info
(E
, Packed_Array_Type
(E
));
2702 Set_RM_Size
(E
, RM_Size
(Packed_Array_Type
(E
)));
2705 -- For non-packed arrays set the alignment of the array
2706 -- to the alignment of the component type if it is unknown.
2707 -- Skip this in the atomic case, since atomic arrays may
2708 -- need larger alignments.
2710 if not Is_Packed
(E
)
2711 and then Unknown_Alignment
(E
)
2712 and then Known_Alignment
(Ctyp
)
2713 and then Known_Static_Component_Size
(E
)
2714 and then Known_Static_Esize
(Ctyp
)
2715 and then Esize
(Ctyp
) = Component_Size
(E
)
2716 and then not Is_Atomic
(E
)
2718 Set_Alignment
(E
, Alignment
(Component_Type
(E
)));
2722 -- For a class-wide type, the corresponding specific type is
2723 -- frozen as well (RM 13.14(15))
2725 elsif Is_Class_Wide_Type
(E
) then
2726 Freeze_And_Append
(Root_Type
(E
), Loc
, Result
);
2728 -- If the Class_Wide_Type is an Itype (when type is the anonymous
2729 -- parent of a derived type) and it is a library-level entity,
2730 -- generate an itype reference for it. Otherwise, its first
2731 -- explicit reference may be in an inner scope, which will be
2732 -- rejected by the back-end.
2735 and then Is_Compilation_Unit
(Scope
(E
))
2738 Ref
: constant Node_Id
:= Make_Itype_Reference
(Loc
);
2743 Result
:= New_List
(Ref
);
2745 Append
(Ref
, Result
);
2750 -- The equivalent type associated with a class-wide subtype
2751 -- needs to be frozen to ensure that its layout is done.
2752 -- Class-wide subtypes are currently only frozen on targets
2753 -- requiring front-end layout (see New_Class_Wide_Subtype
2754 -- and Make_CW_Equivalent_Type in exp_util.adb).
2756 if Ekind
(E
) = E_Class_Wide_Subtype
2757 and then Present
(Equivalent_Type
(E
))
2759 Freeze_And_Append
(Equivalent_Type
(E
), Loc
, Result
);
2762 -- For a record (sub)type, freeze all the component types (RM
2763 -- 13.14(15). We test for E_Record_(sub)Type here, rather than
2764 -- using Is_Record_Type, because we don't want to attempt the
2765 -- freeze for the case of a private type with record extension
2766 -- (we will do that later when the full type is frozen).
2768 elsif Ekind
(E
) = E_Record_Type
2769 or else Ekind
(E
) = E_Record_Subtype
2771 Freeze_Record_Type
(E
);
2773 -- For a concurrent type, freeze corresponding record type. This
2774 -- does not correpond to any specific rule in the RM, but the
2775 -- record type is essentially part of the concurrent type.
2776 -- Freeze as well all local entities. This includes record types
2777 -- created for entry parameter blocks, and whatever local entities
2778 -- may appear in the private part.
2780 elsif Is_Concurrent_Type
(E
) then
2781 if Present
(Corresponding_Record_Type
(E
)) then
2783 (Corresponding_Record_Type
(E
), Loc
, Result
);
2786 Comp
:= First_Entity
(E
);
2788 while Present
(Comp
) loop
2789 if Is_Type
(Comp
) then
2790 Freeze_And_Append
(Comp
, Loc
, Result
);
2792 elsif (Ekind
(Comp
)) /= E_Function
then
2793 if Is_Itype
(Etype
(Comp
))
2794 and then Underlying_Type
(Scope
(Etype
(Comp
))) = E
2796 Undelay_Type
(Etype
(Comp
));
2799 Freeze_And_Append
(Etype
(Comp
), Loc
, Result
);
2805 -- Private types are required to point to the same freeze node
2806 -- as their corresponding full views. The freeze node itself
2807 -- has to point to the partial view of the entity (because
2808 -- from the partial view, we can retrieve the full view, but
2809 -- not the reverse). However, in order to freeze correctly,
2810 -- we need to freeze the full view. If we are freezing at the
2811 -- end of a scope (or within the scope of the private type),
2812 -- the partial and full views will have been swapped, the
2813 -- full view appears first in the entity chain and the swapping
2814 -- mechanism ensures that the pointers are properly set (on
2817 -- If we encounter the partial view before the full view
2818 -- (e.g. when freezing from another scope), we freeze the
2819 -- full view, and then set the pointers appropriately since
2820 -- we cannot rely on swapping to fix things up (subtypes in an
2821 -- outer scope might not get swapped).
2823 elsif Is_Incomplete_Or_Private_Type
(E
)
2824 and then not Is_Generic_Type
(E
)
2826 -- Case of full view present
2828 if Present
(Full_View
(E
)) then
2830 -- If full view has already been frozen, then no
2831 -- further processing is required
2833 if Is_Frozen
(Full_View
(E
)) then
2835 Set_Has_Delayed_Freeze
(E
, False);
2836 Set_Freeze_Node
(E
, Empty
);
2837 Check_Debug_Info_Needed
(E
);
2839 -- Otherwise freeze full view and patch the pointers
2840 -- so that the freeze node will elaborate both views
2845 Full
: constant Entity_Id
:= Full_View
(E
);
2848 if Is_Private_Type
(Full
)
2849 and then Present
(Underlying_Full_View
(Full
))
2852 (Underlying_Full_View
(Full
), Loc
, Result
);
2855 Freeze_And_Append
(Full
, Loc
, Result
);
2857 if Has_Delayed_Freeze
(E
) then
2858 F_Node
:= Freeze_Node
(Full
);
2860 if Present
(F_Node
) then
2861 Set_Freeze_Node
(E
, F_Node
);
2862 Set_Entity
(F_Node
, E
);
2865 -- {Incomplete,Private}_Subtypes
2866 -- with Full_Views constrained by discriminants
2868 Set_Has_Delayed_Freeze
(E
, False);
2869 Set_Freeze_Node
(E
, Empty
);
2874 Check_Debug_Info_Needed
(E
);
2877 -- AI-117 requires that the convention of a partial view
2878 -- be the same as the convention of the full view. Note
2879 -- that this is a recognized breach of privacy, but it's
2880 -- essential for logical consistency of representation,
2881 -- and the lack of a rule in RM95 was an oversight.
2883 Set_Convention
(E
, Convention
(Full_View
(E
)));
2885 Set_Size_Known_At_Compile_Time
(E
,
2886 Size_Known_At_Compile_Time
(Full_View
(E
)));
2888 -- Size information is copied from the full view to the
2889 -- incomplete or private view for consistency
2891 -- We skip this is the full view is not a type. This is
2892 -- very strange of course, and can only happen as a result
2893 -- of certain illegalities, such as a premature attempt to
2894 -- derive from an incomplete type.
2896 if Is_Type
(Full_View
(E
)) then
2897 Set_Size_Info
(E
, Full_View
(E
));
2898 Set_RM_Size
(E
, RM_Size
(Full_View
(E
)));
2903 -- Case of no full view present. If entity is derived or subtype,
2904 -- it is safe to freeze, correctness depends on the frozen status
2905 -- of parent. Otherwise it is either premature usage, or a Taft
2906 -- amendment type, so diagnosis is at the point of use and the
2907 -- type might be frozen later.
2909 elsif E
/= Base_Type
(E
)
2910 or else Is_Derived_Type
(E
)
2915 Set_Is_Frozen
(E
, False);
2919 -- For access subprogram, freeze types of all formals, the return
2920 -- type was already frozen, since it is the Etype of the function.
2922 elsif Ekind
(E
) = E_Subprogram_Type
then
2923 Formal
:= First_Formal
(E
);
2924 while Present
(Formal
) loop
2925 Freeze_And_Append
(Etype
(Formal
), Loc
, Result
);
2926 Next_Formal
(Formal
);
2929 -- If the return type requires a transient scope, and we are on
2930 -- a target allowing functions to return with a depressed stack
2931 -- pointer, then we mark the function as requiring this treatment.
2933 if Functions_Return_By_DSP_On_Target
2934 and then Requires_Transient_Scope
(Etype
(E
))
2936 Set_Function_Returns_With_DSP
(E
);
2939 Freeze_Subprogram
(E
);
2941 -- For access to a protected subprogram, freeze the equivalent
2942 -- type (however this is not set if we are not generating code)
2943 -- or if this is an anonymous type used just for resolution).
2945 elsif Ekind
(E
) = E_Access_Protected_Subprogram_Type
2946 and then Operating_Mode
= Generate_Code
2947 and then Present
(Equivalent_Type
(E
))
2949 Freeze_And_Append
(Equivalent_Type
(E
), Loc
, Result
);
2952 -- Generic types are never seen by the back-end, and are also not
2953 -- processed by the expander (since the expander is turned off for
2954 -- generic processing), so we never need freeze nodes for them.
2956 if Is_Generic_Type
(E
) then
2960 -- Some special processing for non-generic types to complete
2961 -- representation details not known till the freeze point.
2963 if Is_Fixed_Point_Type
(E
) then
2964 Freeze_Fixed_Point_Type
(E
);
2966 -- Some error checks required for ordinary fixed-point type.
2967 -- Defer these till the freeze-point since we need the small
2968 -- and range values. We only do these checks for base types
2970 if Is_Ordinary_Fixed_Point_Type
(E
)
2971 and then E
= Base_Type
(E
)
2973 if Small_Value
(E
) < Ureal_2_M_80
then
2974 Error_Msg_Name_1
:= Name_Small
;
2976 ("`&''%` is too small, minimum is 2.0'*'*(-80)", E
);
2978 elsif Small_Value
(E
) > Ureal_2_80
then
2979 Error_Msg_Name_1
:= Name_Small
;
2981 ("`&''%` is too large, maximum is 2.0'*'*80", E
);
2984 if Expr_Value_R
(Type_Low_Bound
(E
)) < Ureal_M_10_36
then
2985 Error_Msg_Name_1
:= Name_First
;
2987 ("`&''%` is too small, minimum is -10.0'*'*36", E
);
2990 if Expr_Value_R
(Type_High_Bound
(E
)) > Ureal_10_36
then
2991 Error_Msg_Name_1
:= Name_Last
;
2993 ("`&''%` is too large, maximum is 10.0'*'*36", E
);
2997 elsif Is_Enumeration_Type
(E
) then
2998 Freeze_Enumeration_Type
(E
);
3000 elsif Is_Integer_Type
(E
) then
3001 Adjust_Esize_For_Alignment
(E
);
3003 elsif Is_Access_Type
(E
)
3004 and then No
(Associated_Storage_Pool
(E
))
3006 Check_Restriction
(No_Standard_Storage_Pools
, E
);
3009 if Is_Composite_Type
(E
) then
3011 -- AI-117 requires that all new primitives of a tagged type
3012 -- must inherit the convention of the full view of the type.
3013 -- Inherited and overriding operations are defined to inherit
3014 -- the convention of their parent or overridden subprogram
3015 -- (also specified in AI-117), and that will have occurred
3016 -- earlier (in Derive_Subprogram and New_Overloaded_Entity).
3017 -- Here we set the convention of primitives that are still
3018 -- convention Ada, which will ensure that any new primitives
3019 -- inherit the type's convention. Class-wide types can have
3020 -- a foreign convention inherited from their specific type,
3021 -- but are excluded from this since they don't have any
3022 -- associated primitives.
3024 if Is_Tagged_Type
(E
)
3025 and then not Is_Class_Wide_Type
(E
)
3026 and then Convention
(E
) /= Convention_Ada
3029 Prim_List
: constant Elist_Id
:= Primitive_Operations
(E
);
3032 Prim
:= First_Elmt
(Prim_List
);
3033 while Present
(Prim
) loop
3034 if Convention
(Node
(Prim
)) = Convention_Ada
then
3035 Set_Convention
(Node
(Prim
), Convention
(E
));
3044 -- Generate primitive operation references for a tagged type
3046 if Is_Tagged_Type
(E
)
3047 and then not Is_Class_Wide_Type
(E
)
3050 Prim_List
: constant Elist_Id
:= Primitive_Operations
(E
);
3055 Prim
:= First_Elmt
(Prim_List
);
3056 while Present
(Prim
) loop
3059 -- If the operation is derived, get the original for
3060 -- cross-reference purposes (it is the original for
3061 -- which we want the xref, and for which the comes
3062 -- from source test needs to be performed).
3064 while Present
(Alias
(Ent
)) loop
3068 Generate_Reference
(E
, Ent
, 'p', Set_Ref
=> False);
3072 -- If we get an exception, then something peculiar has happened
3073 -- probably as a result of a previous error. Since this is only
3074 -- for non-critical cross-references, ignore the error.
3077 when others => null;
3081 -- Now that all types from which E may depend are frozen, see
3082 -- if the size is known at compile time, if it must be unsigned,
3083 -- or if strict alignent is required
3085 Check_Compile_Time_Size
(E
);
3086 Check_Unsigned_Type
(E
);
3088 if Base_Type
(E
) = E
then
3089 Check_Strict_Alignment
(E
);
3092 -- Do not allow a size clause for a type which does not have a size
3093 -- that is known at compile time
3095 if Has_Size_Clause
(E
)
3096 and then not Size_Known_At_Compile_Time
(E
)
3098 -- Supress this message if errors posted on E, even if we are
3099 -- in all errors mode, since this is often a junk message
3101 if not Error_Posted
(E
) then
3103 ("size clause not allowed for variable length type",
3108 -- Remaining process is to set/verify the representation information,
3109 -- in particular the size and alignment values. This processing is
3110 -- not required for generic types, since generic types do not play
3111 -- any part in code generation, and so the size and alignment values
3112 -- for such types are irrelevant.
3114 if Is_Generic_Type
(E
) then
3117 -- Otherwise we call the layout procedure
3123 -- End of freeze processing for type entities
3126 -- Here is where we logically freeze the current entity. If it has a
3127 -- freeze node, then this is the point at which the freeze node is
3128 -- linked into the result list.
3130 if Has_Delayed_Freeze
(E
) then
3132 -- If a freeze node is already allocated, use it, otherwise allocate
3133 -- a new one. The preallocation happens in the case of anonymous base
3134 -- types, where we preallocate so that we can set First_Subtype_Link.
3135 -- Note that we reset the Sloc to the current freeze location.
3137 if Present
(Freeze_Node
(E
)) then
3138 F_Node
:= Freeze_Node
(E
);
3139 Set_Sloc
(F_Node
, Loc
);
3142 F_Node
:= New_Node
(N_Freeze_Entity
, Loc
);
3143 Set_Freeze_Node
(E
, F_Node
);
3144 Set_Access_Types_To_Process
(F_Node
, No_Elist
);
3145 Set_TSS_Elist
(F_Node
, No_Elist
);
3146 Set_Actions
(F_Node
, No_List
);
3149 Set_Entity
(F_Node
, E
);
3151 if Result
= No_List
then
3152 Result
:= New_List
(F_Node
);
3154 Append
(F_Node
, Result
);
3157 -- A final pass over record types with discriminants. If the type
3158 -- has an incomplete declaration, there may be constrained access
3159 -- subtypes declared elsewhere, which do not depend on the discrimi-
3160 -- nants of the type, and which are used as component types (i.e.
3161 -- the full view is a recursive type). The designated types of these
3162 -- subtypes can only be elaborated after the type itself, and they
3163 -- need an itype reference.
3165 if Ekind
(E
) = E_Record_Type
3166 and then Has_Discriminants
(E
)
3174 Comp
:= First_Component
(E
);
3176 while Present
(Comp
) loop
3177 Typ
:= Etype
(Comp
);
3179 if Ekind
(Comp
) = E_Component
3180 and then Is_Access_Type
(Typ
)
3181 and then Scope
(Typ
) /= E
3182 and then Base_Type
(Designated_Type
(Typ
)) = E
3183 and then Is_Itype
(Designated_Type
(Typ
))
3185 IR
:= Make_Itype_Reference
(Sloc
(Comp
));
3186 Set_Itype
(IR
, Designated_Type
(Typ
));
3187 Append
(IR
, Result
);
3190 Next_Component
(Comp
);
3196 -- When a type is frozen, the first subtype of the type is frozen as
3197 -- well (RM 13.14(15)). This has to be done after freezing the type,
3198 -- since obviously the first subtype depends on its own base type.
3201 Freeze_And_Append
(First_Subtype
(E
), Loc
, Result
);
3203 -- If we just froze a tagged non-class wide record, then freeze the
3204 -- corresponding class-wide type. This must be done after the tagged
3205 -- type itself is frozen, because the class-wide type refers to the
3206 -- tagged type which generates the class.
3208 if Is_Tagged_Type
(E
)
3209 and then not Is_Class_Wide_Type
(E
)
3210 and then Present
(Class_Wide_Type
(E
))
3212 Freeze_And_Append
(Class_Wide_Type
(E
), Loc
, Result
);
3216 Check_Debug_Info_Needed
(E
);
3218 -- Special handling for subprograms
3220 if Is_Subprogram
(E
) then
3222 -- If subprogram has address clause then reset Is_Public flag, since
3223 -- we do not want the backend to generate external references.
3225 if Present
(Address_Clause
(E
))
3226 and then not Is_Library_Level_Entity
(E
)
3228 Set_Is_Public
(E
, False);
3230 -- If no address clause and not intrinsic, then for imported
3231 -- subprogram in main unit, generate descriptor if we are in
3232 -- Propagate_Exceptions mode.
3234 elsif Propagate_Exceptions
3235 and then Is_Imported
(E
)
3236 and then not Is_Intrinsic_Subprogram
(E
)
3237 and then Convention
(E
) /= Convention_Stubbed
3239 if Result
= No_List
then
3240 Result
:= Empty_List
;
3243 Generate_Subprogram_Descriptor_For_Imported_Subprogram
3251 -----------------------------
3252 -- Freeze_Enumeration_Type --
3253 -----------------------------
3255 procedure Freeze_Enumeration_Type
(Typ
: Entity_Id
) is
3257 if Has_Foreign_Convention
(Typ
)
3258 and then not Has_Size_Clause
(Typ
)
3259 and then Esize
(Typ
) < Standard_Integer_Size
3261 Init_Esize
(Typ
, Standard_Integer_Size
);
3263 Adjust_Esize_For_Alignment
(Typ
);
3265 end Freeze_Enumeration_Type
;
3267 -----------------------
3268 -- Freeze_Expression --
3269 -----------------------
3271 procedure Freeze_Expression
(N
: Node_Id
) is
3272 In_Def_Exp
: constant Boolean := In_Default_Expression
;
3275 Desig_Typ
: Entity_Id
;
3279 Freeze_Outside
: Boolean := False;
3280 -- This flag is set true if the entity must be frozen outside the
3281 -- current subprogram. This happens in the case of expander generated
3282 -- subprograms (_Init_Proc, _Input, _Output, _Read, _Write) which do
3283 -- not freeze all entities like other bodies, but which nevertheless
3284 -- may reference entities that have to be frozen before the body and
3285 -- obviously cannot be frozen inside the body.
3287 function In_Exp_Body
(N
: Node_Id
) return Boolean;
3288 -- Given an N_Handled_Sequence_Of_Statements node N, determines whether
3289 -- it is the handled statement sequence of an expander generated
3290 -- subprogram (init proc, or stream subprogram). If so, it returns
3291 -- True, otherwise False.
3297 function In_Exp_Body
(N
: Node_Id
) return Boolean is
3301 if Nkind
(N
) = N_Subprogram_Body
then
3307 if Nkind
(P
) /= N_Subprogram_Body
then
3311 P
:= Defining_Unit_Name
(Specification
(P
));
3313 if Nkind
(P
) = N_Defining_Identifier
3314 and then (Is_Init_Proc
(P
) or else
3315 Is_TSS
(P
, TSS_Stream_Input
) or else
3316 Is_TSS
(P
, TSS_Stream_Output
) or else
3317 Is_TSS
(P
, TSS_Stream_Read
) or else
3318 Is_TSS
(P
, TSS_Stream_Write
))
3327 -- Start of processing for Freeze_Expression
3330 -- Immediate return if freezing is inhibited. This flag is set by
3331 -- the analyzer to stop freezing on generated expressions that would
3332 -- cause freezing if they were in the source program, but which are
3333 -- not supposed to freeze, since they are created.
3335 if Must_Not_Freeze
(N
) then
3339 -- If expression is non-static, then it does not freeze in a default
3340 -- expression, see section "Handling of Default Expressions" in the
3341 -- spec of package Sem for further details. Note that we have to
3342 -- make sure that we actually have a real expression (if we have
3343 -- a subtype indication, we can't test Is_Static_Expression!)
3346 and then Nkind
(N
) in N_Subexpr
3347 and then not Is_Static_Expression
(N
)
3352 -- Freeze type of expression if not frozen already
3356 if Nkind
(N
) in N_Has_Etype
then
3357 if not Is_Frozen
(Etype
(N
)) then
3360 -- Base type may be an derived numeric type that is frozen at
3361 -- the point of declaration, but first_subtype is still unfrozen.
3363 elsif not Is_Frozen
(First_Subtype
(Etype
(N
))) then
3364 Typ
:= First_Subtype
(Etype
(N
));
3368 -- For entity name, freeze entity if not frozen already. A special
3369 -- exception occurs for an identifier that did not come from source.
3370 -- We don't let such identifiers freeze a non-internal entity, i.e.
3371 -- an entity that did come from source, since such an identifier was
3372 -- generated by the expander, and cannot have any semantic effect on
3373 -- the freezing semantics. For example, this stops the parameter of
3374 -- an initialization procedure from freezing the variable.
3376 if Is_Entity_Name
(N
)
3377 and then not Is_Frozen
(Entity
(N
))
3378 and then (Nkind
(N
) /= N_Identifier
3379 or else Comes_From_Source
(N
)
3380 or else not Comes_From_Source
(Entity
(N
)))
3387 -- For an allocator freeze designated type if not frozen already.
3389 -- For an aggregate whose component type is an access type, freeze
3390 -- the designated type now, so that its freeze does not appear within
3391 -- the loop that might be created in the expansion of the aggregate.
3392 -- If the designated type is a private type without full view, the
3393 -- expression cannot contain an allocator, so the type is not frozen.
3399 Desig_Typ
:= Designated_Type
(Etype
(N
));
3402 if Is_Array_Type
(Etype
(N
))
3403 and then Is_Access_Type
(Component_Type
(Etype
(N
)))
3405 Desig_Typ
:= Designated_Type
(Component_Type
(Etype
(N
)));
3408 when N_Selected_Component |
3409 N_Indexed_Component |
3412 if Is_Access_Type
(Etype
(Prefix
(N
))) then
3413 Desig_Typ
:= Designated_Type
(Etype
(Prefix
(N
)));
3420 if Desig_Typ
/= Empty
3421 and then (Is_Frozen
(Desig_Typ
)
3422 or else (not Is_Fully_Defined
(Desig_Typ
)))
3427 -- All done if nothing needs freezing
3431 and then No
(Desig_Typ
)
3436 -- Loop for looking at the right place to insert the freeze nodes
3437 -- exiting from the loop when it is appropriate to insert the freeze
3438 -- node before the current node P.
3440 -- Also checks some special exceptions to the freezing rules. These
3441 -- cases result in a direct return, bypassing the freeze action.
3445 Parent_P
:= Parent
(P
);
3447 -- If we don't have a parent, then we are not in a well-formed
3448 -- tree. This is an unusual case, but there are some legitimate
3449 -- situations in which this occurs, notably when the expressions
3450 -- in the range of a type declaration are resolved. We simply
3451 -- ignore the freeze request in this case. Is this right ???
3453 if No
(Parent_P
) then
3457 -- See if we have got to an appropriate point in the tree
3459 case Nkind
(Parent_P
) is
3461 -- A special test for the exception of (RM 13.14(8)) for the
3462 -- case of per-object expressions (RM 3.8(18)) occurring in a
3463 -- component definition or a discrete subtype definition. Note
3464 -- that we test for a component declaration which includes both
3465 -- cases we are interested in, and furthermore the tree does not
3466 -- have explicit nodes for either of these two constructs.
3468 when N_Component_Declaration
=>
3470 -- The case we want to test for here is an identifier that is
3471 -- a per-object expression, this is either a discriminant that
3472 -- appears in a context other than the component declaration
3473 -- or it is a reference to the type of the enclosing construct.
3475 -- For either of these cases, we skip the freezing
3477 if not In_Default_Expression
3478 and then Nkind
(N
) = N_Identifier
3479 and then (Present
(Entity
(N
)))
3481 -- We recognize the discriminant case by just looking for
3482 -- a reference to a discriminant. It can only be one for
3483 -- the enclosing construct. Skip freezing in this case.
3485 if Ekind
(Entity
(N
)) = E_Discriminant
then
3488 -- For the case of a reference to the enclosing record,
3489 -- (or task or protected type), we look for a type that
3490 -- matches the current scope.
3492 elsif Entity
(N
) = Current_Scope
then
3497 -- If we have an enumeration literal that appears as the
3498 -- choice in the aggregate of an enumeration representation
3499 -- clause, then freezing does not occur (RM 13.14(10)).
3501 when N_Enumeration_Representation_Clause
=>
3503 -- The case we are looking for is an enumeration literal
3505 if (Nkind
(N
) = N_Identifier
or Nkind
(N
) = N_Character_Literal
)
3506 and then Is_Enumeration_Type
(Etype
(N
))
3508 -- If enumeration literal appears directly as the choice,
3509 -- do not freeze (this is the normal non-overloade case)
3511 if Nkind
(Parent
(N
)) = N_Component_Association
3512 and then First
(Choices
(Parent
(N
))) = N
3516 -- If enumeration literal appears as the name of a
3517 -- function which is the choice, then also do not freeze.
3518 -- This happens in the overloaded literal case, where the
3519 -- enumeration literal is temporarily changed to a function
3520 -- call for overloading analysis purposes.
3522 elsif Nkind
(Parent
(N
)) = N_Function_Call
3524 Nkind
(Parent
(Parent
(N
))) = N_Component_Association
3526 First
(Choices
(Parent
(Parent
(N
)))) = Parent
(N
)
3532 -- Normally if the parent is a handled sequence of statements,
3533 -- then the current node must be a statement, and that is an
3534 -- appropriate place to insert a freeze node.
3536 when N_Handled_Sequence_Of_Statements
=>
3538 -- An exception occurs when the sequence of statements is
3539 -- for an expander generated body that did not do the usual
3540 -- freeze all operation. In this case we usually want to
3541 -- freeze outside this body, not inside it, and we skip
3542 -- past the subprogram body that we are inside.
3544 if In_Exp_Body
(Parent_P
) then
3546 -- However, we *do* want to freeze at this point if we have
3547 -- an entity to freeze, and that entity is declared *inside*
3548 -- the body of the expander generated procedure. This case
3549 -- is recognized by the scope of the type, which is either
3550 -- the spec for some enclosing body, or (in the case of
3551 -- init_procs, for which there are no separate specs) the
3555 Subp
: constant Node_Id
:= Parent
(Parent_P
);
3559 if Nkind
(Subp
) = N_Subprogram_Body
then
3560 Cspc
:= Corresponding_Spec
(Subp
);
3562 if (Present
(Typ
) and then Scope
(Typ
) = Cspc
)
3564 (Present
(Nam
) and then Scope
(Nam
) = Cspc
)
3569 and then Scope
(Typ
) = Current_Scope
3570 and then Current_Scope
= Defining_Entity
(Subp
)
3577 -- If not that exception to the exception, then this is
3578 -- where we delay the freeze till outside the body.
3580 Parent_P
:= Parent
(Parent_P
);
3581 Freeze_Outside
:= True;
3583 -- Here if normal case where we are in handled statement
3584 -- sequence and want to do the insertion right there.
3590 -- If parent is a body or a spec or a block, then the current
3591 -- node is a statement or declaration and we can insert the
3592 -- freeze node before it.
3594 when N_Package_Specification |
3600 N_Block_Statement
=> exit;
3602 -- The expander is allowed to define types in any statements list,
3603 -- so any of the following parent nodes also mark a freezing point
3604 -- if the actual node is in a list of statements or declarations.
3606 when N_Exception_Handler |
3609 N_Case_Statement_Alternative |
3610 N_Compilation_Unit_Aux |
3611 N_Selective_Accept |
3612 N_Accept_Alternative |
3613 N_Delay_Alternative |
3614 N_Conditional_Entry_Call |
3615 N_Entry_Call_Alternative |
3616 N_Triggering_Alternative |
3620 exit when Is_List_Member
(P
);
3622 -- Note: The N_Loop_Statement is a special case. A type that
3623 -- appears in the source can never be frozen in a loop (this
3624 -- occurs only because of a loop expanded by the expander),
3625 -- so we keep on going. Otherwise we terminate the search.
3626 -- Same is true of any entity which comes from source. (if they
3627 -- have a predefined type, that type does not appear to come
3628 -- from source, but the entity should not be frozen here).
3630 when N_Loop_Statement
=>
3631 exit when not Comes_From_Source
(Etype
(N
))
3632 and then (No
(Nam
) or else not Comes_From_Source
(Nam
));
3634 -- For all other cases, keep looking at parents
3640 -- We fall through the case if we did not yet find the proper
3641 -- place in the free for inserting the freeze node, so climb!
3646 -- If the expression appears in a record or an initialization
3647 -- procedure, the freeze nodes are collected and attached to
3648 -- the current scope, to be inserted and analyzed on exit from
3649 -- the scope, to insure that generated entities appear in the
3650 -- correct scope. If the expression is a default for a discriminant
3651 -- specification, the scope is still void. The expression can also
3652 -- appear in the discriminant part of a private or concurrent type.
3654 -- The other case requiring this special handling is if we are in
3655 -- a default expression, since in that case we are about to freeze
3656 -- a static type, and the freeze scope needs to be the outer scope,
3657 -- not the scope of the subprogram with the default parameter.
3659 -- For default expressions in generic units, the Move_Freeze_Nodes
3660 -- mechanism (see sem_ch12.adb) takes care of placing them at the
3661 -- proper place, after the generic unit.
3663 if (In_Def_Exp
and not Inside_A_Generic
)
3664 or else Freeze_Outside
3665 or else (Is_Type
(Current_Scope
)
3666 and then (not Is_Concurrent_Type
(Current_Scope
)
3667 or else not Has_Completion
(Current_Scope
)))
3668 or else Ekind
(Current_Scope
) = E_Void
3671 Loc
: constant Source_Ptr
:= Sloc
(Current_Scope
);
3672 Freeze_Nodes
: List_Id
:= No_List
;
3675 if Present
(Desig_Typ
) then
3676 Freeze_And_Append
(Desig_Typ
, Loc
, Freeze_Nodes
);
3679 if Present
(Typ
) then
3680 Freeze_And_Append
(Typ
, Loc
, Freeze_Nodes
);
3683 if Present
(Nam
) then
3684 Freeze_And_Append
(Nam
, Loc
, Freeze_Nodes
);
3687 if Is_Non_Empty_List
(Freeze_Nodes
) then
3688 if No
(Scope_Stack
.Table
3689 (Scope_Stack
.Last
).Pending_Freeze_Actions
)
3692 (Scope_Stack
.Last
).Pending_Freeze_Actions
:=
3695 Append_List
(Freeze_Nodes
, Scope_Stack
.Table
3696 (Scope_Stack
.Last
).Pending_Freeze_Actions
);
3704 -- Now we have the right place to do the freezing. First, a special
3705 -- adjustment, if we are in default expression analysis mode, these
3706 -- freeze actions must not be thrown away (normally all inserted
3707 -- actions are thrown away in this mode. However, the freeze actions
3708 -- are from static expressions and one of the important reasons we
3709 -- are doing this special analysis is to get these freeze actions.
3710 -- Therefore we turn off the In_Default_Expression mode to propagate
3711 -- these freeze actions. This also means they get properly analyzed
3714 In_Default_Expression
:= False;
3716 -- Freeze the designated type of an allocator (RM 13.14(13))
3718 if Present
(Desig_Typ
) then
3719 Freeze_Before
(P
, Desig_Typ
);
3722 -- Freeze type of expression (RM 13.14(10)). Note that we took care of
3723 -- the enumeration representation clause exception in the loop above.
3725 if Present
(Typ
) then
3726 Freeze_Before
(P
, Typ
);
3729 -- Freeze name if one is present (RM 13.14(11))
3731 if Present
(Nam
) then
3732 Freeze_Before
(P
, Nam
);
3735 In_Default_Expression
:= In_Def_Exp
;
3736 end Freeze_Expression
;
3738 -----------------------------
3739 -- Freeze_Fixed_Point_Type --
3740 -----------------------------
3742 -- Certain fixed-point types and subtypes, including implicit base
3743 -- types and declared first subtypes, have not yet set up a range.
3744 -- This is because the range cannot be set until the Small and Size
3745 -- values are known, and these are not known till the type is frozen.
3747 -- To signal this case, Scalar_Range contains an unanalyzed syntactic
3748 -- range whose bounds are unanalyzed real literals. This routine will
3749 -- recognize this case, and transform this range node into a properly
3750 -- typed range with properly analyzed and resolved values.
3752 procedure Freeze_Fixed_Point_Type
(Typ
: Entity_Id
) is
3753 Rng
: constant Node_Id
:= Scalar_Range
(Typ
);
3754 Lo
: constant Node_Id
:= Low_Bound
(Rng
);
3755 Hi
: constant Node_Id
:= High_Bound
(Rng
);
3756 Btyp
: constant Entity_Id
:= Base_Type
(Typ
);
3757 Brng
: constant Node_Id
:= Scalar_Range
(Btyp
);
3758 BLo
: constant Node_Id
:= Low_Bound
(Brng
);
3759 BHi
: constant Node_Id
:= High_Bound
(Brng
);
3760 Small
: constant Ureal
:= Small_Value
(Typ
);
3767 function Fsize
(Lov
, Hiv
: Ureal
) return Nat
;
3768 -- Returns size of type with given bounds. Also leaves these
3769 -- bounds set as the current bounds of the Typ.
3775 function Fsize
(Lov
, Hiv
: Ureal
) return Nat
is
3777 Set_Realval
(Lo
, Lov
);
3778 Set_Realval
(Hi
, Hiv
);
3779 return Minimum_Size
(Typ
);
3782 -- Start of processing for Freeze_Fixed_Point_Type
3785 -- If Esize of a subtype has not previously been set, set it now
3787 if Unknown_Esize
(Typ
) then
3788 Atype
:= Ancestor_Subtype
(Typ
);
3790 if Present
(Atype
) then
3791 Set_Esize
(Typ
, Esize
(Atype
));
3793 Set_Esize
(Typ
, Esize
(Base_Type
(Typ
)));
3797 -- Immediate return if the range is already analyzed. This means
3798 -- that the range is already set, and does not need to be computed
3801 if Analyzed
(Rng
) then
3805 -- Immediate return if either of the bounds raises Constraint_Error
3807 if Raises_Constraint_Error
(Lo
)
3808 or else Raises_Constraint_Error
(Hi
)
3813 Loval
:= Realval
(Lo
);
3814 Hival
:= Realval
(Hi
);
3816 -- Ordinary fixed-point case
3818 if Is_Ordinary_Fixed_Point_Type
(Typ
) then
3820 -- For the ordinary fixed-point case, we are allowed to fudge the
3821 -- end-points up or down by small. Generally we prefer to fudge
3822 -- up, i.e. widen the bounds for non-model numbers so that the
3823 -- end points are included. However there are cases in which this
3824 -- cannot be done, and indeed cases in which we may need to narrow
3825 -- the bounds. The following circuit makes the decision.
3827 -- Note: our terminology here is that Incl_EP means that the
3828 -- bounds are widened by Small if necessary to include the end
3829 -- points, and Excl_EP means that the bounds are narrowed by
3830 -- Small to exclude the end-points if this reduces the size.
3832 -- Note that in the Incl case, all we care about is including the
3833 -- end-points. In the Excl case, we want to narrow the bounds as
3834 -- much as permitted by the RM, to give the smallest possible size.
3837 Loval_Incl_EP
: Ureal
;
3838 Hival_Incl_EP
: Ureal
;
3840 Loval_Excl_EP
: Ureal
;
3841 Hival_Excl_EP
: Ureal
;
3847 First_Subt
: Entity_Id
;
3852 -- First step. Base types are required to be symmetrical. Right
3853 -- now, the base type range is a copy of the first subtype range.
3854 -- This will be corrected before we are done, but right away we
3855 -- need to deal with the case where both bounds are non-negative.
3856 -- In this case, we set the low bound to the negative of the high
3857 -- bound, to make sure that the size is computed to include the
3858 -- required sign. Note that we do not need to worry about the
3859 -- case of both bounds negative, because the sign will be dealt
3860 -- with anyway. Furthermore we can't just go making such a bound
3861 -- symmetrical, since in a twos-complement system, there is an
3862 -- extra negative value which could not be accomodated on the
3866 and then not UR_Is_Negative
(Loval
)
3867 and then Hival
> Loval
3870 Set_Realval
(Lo
, Loval
);
3873 -- Compute the fudged bounds. If the number is a model number,
3874 -- then we do nothing to include it, but we are allowed to
3875 -- backoff to the next adjacent model number when we exclude
3876 -- it. If it is not a model number then we straddle the two
3877 -- values with the model numbers on either side.
3879 Model_Num
:= UR_Trunc
(Loval
/ Small
) * Small
;
3881 if Loval
= Model_Num
then
3882 Loval_Incl_EP
:= Model_Num
;
3884 Loval_Incl_EP
:= Model_Num
- Small
;
3887 -- The low value excluding the end point is Small greater, but
3888 -- we do not do this exclusion if the low value is positive,
3889 -- since it can't help the size and could actually hurt by
3890 -- crossing the high bound.
3892 if UR_Is_Negative
(Loval_Incl_EP
) then
3893 Loval_Excl_EP
:= Loval_Incl_EP
+ Small
;
3895 Loval_Excl_EP
:= Loval_Incl_EP
;
3898 -- Similar processing for upper bound and high value
3900 Model_Num
:= UR_Trunc
(Hival
/ Small
) * Small
;
3902 if Hival
= Model_Num
then
3903 Hival_Incl_EP
:= Model_Num
;
3905 Hival_Incl_EP
:= Model_Num
+ Small
;
3908 if UR_Is_Positive
(Hival_Incl_EP
) then
3909 Hival_Excl_EP
:= Hival_Incl_EP
- Small
;
3911 Hival_Excl_EP
:= Hival_Incl_EP
;
3914 -- One further adjustment is needed. In the case of subtypes,
3915 -- we cannot go outside the range of the base type, or we get
3916 -- peculiarities, and the base type range is already set. This
3917 -- only applies to the Incl values, since clearly the Excl
3918 -- values are already as restricted as they are allowed to be.
3921 Loval_Incl_EP
:= UR_Max
(Loval_Incl_EP
, Realval
(BLo
));
3922 Hival_Incl_EP
:= UR_Min
(Hival_Incl_EP
, Realval
(BHi
));
3925 -- Get size including and excluding end points
3927 Size_Incl_EP
:= Fsize
(Loval_Incl_EP
, Hival_Incl_EP
);
3928 Size_Excl_EP
:= Fsize
(Loval_Excl_EP
, Hival_Excl_EP
);
3930 -- No need to exclude end-points if it does not reduce size
3932 if Fsize
(Loval_Incl_EP
, Hival_Excl_EP
) = Size_Excl_EP
then
3933 Loval_Excl_EP
:= Loval_Incl_EP
;
3936 if Fsize
(Loval_Excl_EP
, Hival_Incl_EP
) = Size_Excl_EP
then
3937 Hival_Excl_EP
:= Hival_Incl_EP
;
3940 -- Now we set the actual size to be used. We want to use the
3941 -- bounds fudged up to include the end-points but only if this
3942 -- can be done without violating a specifically given size
3943 -- size clause or causing an unacceptable increase in size.
3945 -- Case of size clause given
3947 if Has_Size_Clause
(Typ
) then
3949 -- Use the inclusive size only if it is consistent with
3950 -- the explicitly specified size.
3952 if Size_Incl_EP
<= RM_Size
(Typ
) then
3953 Actual_Lo
:= Loval_Incl_EP
;
3954 Actual_Hi
:= Hival_Incl_EP
;
3955 Actual_Size
:= Size_Incl_EP
;
3957 -- If the inclusive size is too large, we try excluding
3958 -- the end-points (will be caught later if does not work).
3961 Actual_Lo
:= Loval_Excl_EP
;
3962 Actual_Hi
:= Hival_Excl_EP
;
3963 Actual_Size
:= Size_Excl_EP
;
3966 -- Case of size clause not given
3969 -- If we have a base type whose corresponding first subtype
3970 -- has an explicit size that is large enough to include our
3971 -- end-points, then do so. There is no point in working hard
3972 -- to get a base type whose size is smaller than the specified
3973 -- size of the first subtype.
3975 First_Subt
:= First_Subtype
(Typ
);
3977 if Has_Size_Clause
(First_Subt
)
3978 and then Size_Incl_EP
<= Esize
(First_Subt
)
3980 Actual_Size
:= Size_Incl_EP
;
3981 Actual_Lo
:= Loval_Incl_EP
;
3982 Actual_Hi
:= Hival_Incl_EP
;
3984 -- If excluding the end-points makes the size smaller and
3985 -- results in a size of 8,16,32,64, then we take the smaller
3986 -- size. For the 64 case, this is compulsory. For the other
3987 -- cases, it seems reasonable. We like to include end points
3988 -- if we can, but not at the expense of moving to the next
3989 -- natural boundary of size.
3991 elsif Size_Incl_EP
/= Size_Excl_EP
3993 (Size_Excl_EP
= 8 or else
3994 Size_Excl_EP
= 16 or else
3995 Size_Excl_EP
= 32 or else
3998 Actual_Size
:= Size_Excl_EP
;
3999 Actual_Lo
:= Loval_Excl_EP
;
4000 Actual_Hi
:= Hival_Excl_EP
;
4002 -- Otherwise we can definitely include the end points
4005 Actual_Size
:= Size_Incl_EP
;
4006 Actual_Lo
:= Loval_Incl_EP
;
4007 Actual_Hi
:= Hival_Incl_EP
;
4010 -- One pathological case: normally we never fudge a low
4011 -- bound down, since it would seem to increase the size
4012 -- (if it has any effect), but for ranges containing a
4013 -- single value, or no values, the high bound can be
4014 -- small too large. Consider:
4016 -- type t is delta 2.0**(-14)
4017 -- range 131072.0 .. 0;
4019 -- That lower bound is *just* outside the range of 32
4020 -- bits, and does need fudging down in this case. Note
4021 -- that the bounds will always have crossed here, since
4022 -- the high bound will be fudged down if necessary, as
4025 -- type t is delta 2.0**(-14)
4026 -- range 131072.0 .. 131072.0;
4028 -- So we can detect the situation by looking for crossed
4029 -- bounds, and if the bounds are crossed, and the low
4030 -- bound is greater than zero, we will always back it
4031 -- off by small, since this is completely harmless.
4033 if Actual_Lo
> Actual_Hi
then
4034 if UR_Is_Positive
(Actual_Lo
) then
4035 Actual_Lo
:= Loval_Incl_EP
- Small
;
4036 Actual_Size
:= Fsize
(Actual_Lo
, Actual_Hi
);
4038 -- And of course, we need to do exactly the same parallel
4039 -- fudge for flat ranges in the negative region.
4041 elsif UR_Is_Negative
(Actual_Hi
) then
4042 Actual_Hi
:= Hival_Incl_EP
+ Small
;
4043 Actual_Size
:= Fsize
(Actual_Lo
, Actual_Hi
);
4048 Set_Realval
(Lo
, Actual_Lo
);
4049 Set_Realval
(Hi
, Actual_Hi
);
4052 -- For the decimal case, none of this fudging is required, since there
4053 -- are no end-point problems in the decimal case (the end-points are
4054 -- always included).
4057 Actual_Size
:= Fsize
(Loval
, Hival
);
4060 -- At this stage, the actual size has been calculated and the proper
4061 -- required bounds are stored in the low and high bounds.
4063 if Actual_Size
> 64 then
4064 Error_Msg_Uint_1
:= UI_From_Int
(Actual_Size
);
4066 ("size required (^) for type& too large, maximum is 64", Typ
);
4070 -- Check size against explicit given size
4072 if Has_Size_Clause
(Typ
) then
4073 if Actual_Size
> RM_Size
(Typ
) then
4074 Error_Msg_Uint_1
:= RM_Size
(Typ
);
4075 Error_Msg_Uint_2
:= UI_From_Int
(Actual_Size
);
4077 ("size given (^) for type& too small, minimum is ^",
4078 Size_Clause
(Typ
), Typ
);
4081 Actual_Size
:= UI_To_Int
(Esize
(Typ
));
4084 -- Increase size to next natural boundary if no size clause given
4087 if Actual_Size
<= 8 then
4089 elsif Actual_Size
<= 16 then
4091 elsif Actual_Size
<= 32 then
4097 Init_Esize
(Typ
, Actual_Size
);
4098 Adjust_Esize_For_Alignment
(Typ
);
4101 -- If we have a base type, then expand the bounds so that they
4102 -- extend to the full width of the allocated size in bits, to
4103 -- avoid junk range checks on intermediate computations.
4105 if Base_Type
(Typ
) = Typ
then
4106 Set_Realval
(Lo
, -(Small
* (Uint_2
** (Actual_Size
- 1))));
4107 Set_Realval
(Hi
, (Small
* (Uint_2
** (Actual_Size
- 1) - 1)));
4110 -- Final step is to reanalyze the bounds using the proper type
4111 -- and set the Corresponding_Integer_Value fields of the literals.
4113 Set_Etype
(Lo
, Empty
);
4114 Set_Analyzed
(Lo
, False);
4117 -- Resolve with universal fixed if the base type, and the base
4118 -- type if it is a subtype. Note we can't resolve the base type
4119 -- with itself, that would be a reference before definition.
4122 Resolve
(Lo
, Universal_Fixed
);
4127 -- Set corresponding integer value for bound
4129 Set_Corresponding_Integer_Value
4130 (Lo
, UR_To_Uint
(Realval
(Lo
) / Small
));
4132 -- Similar processing for high bound
4134 Set_Etype
(Hi
, Empty
);
4135 Set_Analyzed
(Hi
, False);
4139 Resolve
(Hi
, Universal_Fixed
);
4144 Set_Corresponding_Integer_Value
4145 (Hi
, UR_To_Uint
(Realval
(Hi
) / Small
));
4147 -- Set type of range to correspond to bounds
4149 Set_Etype
(Rng
, Etype
(Lo
));
4151 -- Set Esize to calculated size if not set already
4153 if Unknown_Esize
(Typ
) then
4154 Init_Esize
(Typ
, Actual_Size
);
4157 -- Set RM_Size if not already set. If already set, check value
4160 Minsiz
: constant Uint
:= UI_From_Int
(Minimum_Size
(Typ
));
4163 if RM_Size
(Typ
) /= Uint_0
then
4164 if RM_Size
(Typ
) < Minsiz
then
4165 Error_Msg_Uint_1
:= RM_Size
(Typ
);
4166 Error_Msg_Uint_2
:= Minsiz
;
4168 ("size given (^) for type& too small, minimum is ^",
4169 Size_Clause
(Typ
), Typ
);
4173 Set_RM_Size
(Typ
, Minsiz
);
4176 end Freeze_Fixed_Point_Type
;
4182 procedure Freeze_Itype
(T
: Entity_Id
; N
: Node_Id
) is
4186 Set_Has_Delayed_Freeze
(T
);
4187 L
:= Freeze_Entity
(T
, Sloc
(N
));
4189 if Is_Non_Empty_List
(L
) then
4190 Insert_Actions
(N
, L
);
4194 --------------------------
4195 -- Freeze_Static_Object --
4196 --------------------------
4198 procedure Freeze_Static_Object
(E
: Entity_Id
) is
4200 Cannot_Be_Static
: exception;
4201 -- Exception raised if the type of a static object cannot be made
4202 -- static. This happens if the type depends on non-global objects.
4204 procedure Ensure_Expression_Is_SA
(N
: Node_Id
);
4205 -- Called to ensure that an expression used as part of a type
4206 -- definition is statically allocatable, which means that the type
4207 -- of the expression is statically allocatable, and the expression
4208 -- is either static, or a reference to a library level constant.
4210 procedure Ensure_Type_Is_SA
(Typ
: Entity_Id
);
4211 -- Called to mark a type as static, checking that it is possible
4212 -- to set the type as static. If it is not possible, then the
4213 -- exception Cannot_Be_Static is raised.
4215 -----------------------------
4216 -- Ensure_Expression_Is_SA --
4217 -----------------------------
4219 procedure Ensure_Expression_Is_SA
(N
: Node_Id
) is
4223 Ensure_Type_Is_SA
(Etype
(N
));
4225 if Is_Static_Expression
(N
) then
4228 elsif Nkind
(N
) = N_Identifier
then
4232 and then Ekind
(Ent
) = E_Constant
4233 and then Is_Library_Level_Entity
(Ent
)
4239 raise Cannot_Be_Static
;
4240 end Ensure_Expression_Is_SA
;
4242 -----------------------
4243 -- Ensure_Type_Is_SA --
4244 -----------------------
4246 procedure Ensure_Type_Is_SA
(Typ
: Entity_Id
) is
4251 -- If type is library level, we are all set
4253 if Is_Library_Level_Entity
(Typ
) then
4257 -- We are also OK if the type is already marked as statically
4258 -- allocated, which means we processed it before.
4260 if Is_Statically_Allocated
(Typ
) then
4264 -- Mark type as statically allocated
4266 Set_Is_Statically_Allocated
(Typ
);
4268 -- Check that it is safe to statically allocate this type
4270 if Is_Scalar_Type
(Typ
) or else Is_Real_Type
(Typ
) then
4271 Ensure_Expression_Is_SA
(Type_Low_Bound
(Typ
));
4272 Ensure_Expression_Is_SA
(Type_High_Bound
(Typ
));
4274 elsif Is_Array_Type
(Typ
) then
4275 N
:= First_Index
(Typ
);
4276 while Present
(N
) loop
4277 Ensure_Type_Is_SA
(Etype
(N
));
4281 Ensure_Type_Is_SA
(Component_Type
(Typ
));
4283 elsif Is_Access_Type
(Typ
) then
4284 if Ekind
(Designated_Type
(Typ
)) = E_Subprogram_Type
then
4288 T
: constant Entity_Id
:= Etype
(Designated_Type
(Typ
));
4291 if T
/= Standard_Void_Type
then
4292 Ensure_Type_Is_SA
(T
);
4295 F
:= First_Formal
(Designated_Type
(Typ
));
4297 while Present
(F
) loop
4298 Ensure_Type_Is_SA
(Etype
(F
));
4304 Ensure_Type_Is_SA
(Designated_Type
(Typ
));
4307 elsif Is_Record_Type
(Typ
) then
4308 C
:= First_Entity
(Typ
);
4310 while Present
(C
) loop
4311 if Ekind
(C
) = E_Discriminant
4312 or else Ekind
(C
) = E_Component
4314 Ensure_Type_Is_SA
(Etype
(C
));
4316 elsif Is_Type
(C
) then
4317 Ensure_Type_Is_SA
(C
);
4323 elsif Ekind
(Typ
) = E_Subprogram_Type
then
4324 Ensure_Type_Is_SA
(Etype
(Typ
));
4326 C
:= First_Formal
(Typ
);
4327 while Present
(C
) loop
4328 Ensure_Type_Is_SA
(Etype
(C
));
4333 raise Cannot_Be_Static
;
4335 end Ensure_Type_Is_SA
;
4337 -- Start of processing for Freeze_Static_Object
4340 Ensure_Type_Is_SA
(Etype
(E
));
4342 -- Reset True_Constant flag, since something strange is going on
4343 -- with the scoping here, and our simple value tracing may not
4344 -- be sufficient for this indication to be reliable. We kill the
4345 -- Constant_Value indication for the same reason.
4347 Set_Is_True_Constant
(E
, False);
4348 Set_Current_Value
(E
, Empty
);
4351 when Cannot_Be_Static
=>
4353 -- If the object that cannot be static is imported or exported,
4354 -- then we give an error message saying that this object cannot
4355 -- be imported or exported.
4357 if Is_Imported
(E
) then
4359 ("& cannot be imported (local type is not constant)", E
);
4361 -- Otherwise must be exported, something is wrong if compiler
4362 -- is marking something as statically allocated which cannot be).
4364 else pragma Assert
(Is_Exported
(E
));
4366 ("& cannot be exported (local type is not constant)", E
);
4368 end Freeze_Static_Object
;
4370 -----------------------
4371 -- Freeze_Subprogram --
4372 -----------------------
4374 procedure Freeze_Subprogram
(E
: Entity_Id
) is
4379 -- Subprogram may not have an address clause unless it is imported
4381 if Present
(Address_Clause
(E
)) then
4382 if not Is_Imported
(E
) then
4384 ("address clause can only be given " &
4385 "for imported subprogram",
4386 Name
(Address_Clause
(E
)));
4390 -- Reset the Pure indication on an imported subprogram unless an
4391 -- explicit Pure_Function pragma was present. We do this because
4392 -- otherwise it is an insidious error to call a non-pure function
4393 -- from a pure unit and have calls mysteriously optimized away.
4394 -- What happens here is that the Import can bypass the normal
4395 -- check to ensure that pure units call only pure subprograms.
4398 and then Is_Pure
(E
)
4399 and then not Has_Pragma_Pure_Function
(E
)
4401 Set_Is_Pure
(E
, False);
4404 -- For non-foreign convention subprograms, this is where we create
4405 -- the extra formals (for accessibility level and constrained bit
4406 -- information). We delay this till the freeze point precisely so
4407 -- that we know the convention!
4409 if not Has_Foreign_Convention
(E
) then
4410 Create_Extra_Formals
(E
);
4413 -- If this is convention Ada and a Valued_Procedure, that's odd
4415 if Ekind
(E
) = E_Procedure
4416 and then Is_Valued_Procedure
(E
)
4417 and then Convention
(E
) = Convention_Ada
4418 and then Warn_On_Export_Import
4421 ("?Valued_Procedure has no effect for convention Ada", E
);
4422 Set_Is_Valued_Procedure
(E
, False);
4425 -- Case of foreign convention
4430 -- For foreign conventions, warn about return of an
4431 -- unconstrained array.
4433 -- Note: we *do* allow a return by descriptor for the VMS case,
4434 -- though here there is probably more to be done ???
4436 if Ekind
(E
) = E_Function
then
4437 Retype
:= Underlying_Type
(Etype
(E
));
4439 -- If no return type, probably some other error, e.g. a
4440 -- missing full declaration, so ignore.
4445 -- If the return type is generic, we have emitted a warning
4446 -- earlier on, and there is nothing else to check here.
4447 -- Specific instantiations may lead to erroneous behavior.
4449 elsif Is_Generic_Type
(Etype
(E
)) then
4452 elsif Is_Array_Type
(Retype
)
4453 and then not Is_Constrained
(Retype
)
4454 and then Mechanism
(E
) not in Descriptor_Codes
4455 and then Warn_On_Export_Import
4458 ("?foreign convention function& should not return " &
4459 "unconstrained array", E
);
4464 -- If any of the formals for an exported foreign convention
4465 -- subprogram have defaults, then emit an appropriate warning
4466 -- since this is odd (default cannot be used from non-Ada code)
4468 if Is_Exported
(E
) then
4469 F
:= First_Formal
(E
);
4470 while Present
(F
) loop
4471 if Warn_On_Export_Import
4472 and then Present
(Default_Value
(F
))
4475 ("?parameter cannot be defaulted in non-Ada call",
4484 -- For VMS, descriptor mechanisms for parameters are allowed only
4485 -- for imported subprograms.
4487 if OpenVMS_On_Target
then
4488 if not Is_Imported
(E
) then
4489 F
:= First_Formal
(E
);
4490 while Present
(F
) loop
4491 if Mechanism
(F
) in Descriptor_Codes
then
4493 ("descriptor mechanism for parameter not permitted", F
);
4495 ("\can only be used for imported subprogram", F
);
4502 end Freeze_Subprogram
;
4504 ----------------------
4505 -- Is_Fully_Defined --
4506 ----------------------
4508 function Is_Fully_Defined
(T
: Entity_Id
) return Boolean is
4510 if Ekind
(T
) = E_Class_Wide_Type
then
4511 return Is_Fully_Defined
(Etype
(T
));
4513 elsif Is_Array_Type
(T
) then
4514 return Is_Fully_Defined
(Component_Type
(T
));
4516 elsif Is_Record_Type
(T
)
4517 and not Is_Private_Type
(T
)
4519 -- Verify that the record type has no components with
4520 -- private types without completion.
4526 Comp
:= First_Component
(T
);
4528 while Present
(Comp
) loop
4529 if not Is_Fully_Defined
(Etype
(Comp
)) then
4533 Next_Component
(Comp
);
4538 else return not Is_Private_Type
(T
)
4539 or else Present
(Full_View
(Base_Type
(T
)));
4541 end Is_Fully_Defined
;
4543 ---------------------------------
4544 -- Process_Default_Expressions --
4545 ---------------------------------
4547 procedure Process_Default_Expressions
4549 After
: in out Node_Id
)
4551 Loc
: constant Source_Ptr
:= Sloc
(E
);
4558 Set_Default_Expressions_Processed
(E
);
4560 -- A subprogram instance and its associated anonymous subprogram
4561 -- share their signature. The default expression functions are defined
4562 -- in the wrapper packages for the anonymous subprogram, and should
4563 -- not be generated again for the instance.
4565 if Is_Generic_Instance
(E
)
4566 and then Present
(Alias
(E
))
4567 and then Default_Expressions_Processed
(Alias
(E
))
4572 Formal
:= First_Formal
(E
);
4574 while Present
(Formal
) loop
4575 if Present
(Default_Value
(Formal
)) then
4577 -- We work with a copy of the default expression because we
4578 -- do not want to disturb the original, since this would mess
4579 -- up the conformance checking.
4581 Dcopy
:= New_Copy_Tree
(Default_Value
(Formal
));
4583 -- The analysis of the expression may generate insert actions,
4584 -- which of course must not be executed. We wrap those actions
4585 -- in a procedure that is not called, and later on eliminated.
4586 -- The following cases have no side-effects, and are analyzed
4589 if Nkind
(Dcopy
) = N_Identifier
4590 or else Nkind
(Dcopy
) = N_Expanded_Name
4591 or else Nkind
(Dcopy
) = N_Integer_Literal
4592 or else (Nkind
(Dcopy
) = N_Real_Literal
4593 and then not Vax_Float
(Etype
(Dcopy
)))
4594 or else Nkind
(Dcopy
) = N_Character_Literal
4595 or else Nkind
(Dcopy
) = N_String_Literal
4596 or else Nkind
(Dcopy
) = N_Null
4597 or else (Nkind
(Dcopy
) = N_Attribute_Reference
4599 Attribute_Name
(Dcopy
) = Name_Null_Parameter
)
4602 -- If there is no default function, we must still do a full
4603 -- analyze call on the default value, to ensure that all
4604 -- error checks are performed, e.g. those associated with
4605 -- static evaluation. Note that this branch will always be
4606 -- taken if the analyzer is turned off (but we still need the
4609 -- Note: the setting of parent here is to meet the requirement
4610 -- that we can only analyze the expression while attached to
4611 -- the tree. Really the requirement is that the parent chain
4612 -- be set, we don't actually need to be in the tree.
4614 Set_Parent
(Dcopy
, Declaration_Node
(Formal
));
4617 -- Default expressions are resolved with their own type if the
4618 -- context is generic, to avoid anomalies with private types.
4620 if Ekind
(Scope
(E
)) = E_Generic_Package
then
4623 Resolve
(Dcopy
, Etype
(Formal
));
4626 -- If that resolved expression will raise constraint error,
4627 -- then flag the default value as raising constraint error.
4628 -- This allows a proper error message on the calls.
4630 if Raises_Constraint_Error
(Dcopy
) then
4631 Set_Raises_Constraint_Error
(Default_Value
(Formal
));
4634 -- If the default is a parameterless call, we use the name of
4635 -- the called function directly, and there is no body to build.
4637 elsif Nkind
(Dcopy
) = N_Function_Call
4638 and then No
(Parameter_Associations
(Dcopy
))
4642 -- Else construct and analyze the body of a wrapper procedure
4643 -- that contains an object declaration to hold the expression.
4644 -- Given that this is done only to complete the analysis, it
4645 -- simpler to build a procedure than a function which might
4646 -- involve secondary stack expansion.
4650 Make_Defining_Identifier
(Loc
, New_Internal_Name
('D'));
4653 Make_Subprogram_Body
(Loc
,
4655 Make_Procedure_Specification
(Loc
,
4656 Defining_Unit_Name
=> Dnam
),
4658 Declarations
=> New_List
(
4659 Make_Object_Declaration
(Loc
,
4660 Defining_Identifier
=>
4661 Make_Defining_Identifier
(Loc
,
4662 New_Internal_Name
('T')),
4663 Object_Definition
=>
4664 New_Occurrence_Of
(Etype
(Formal
), Loc
),
4665 Expression
=> New_Copy_Tree
(Dcopy
))),
4667 Handled_Statement_Sequence
=>
4668 Make_Handled_Sequence_Of_Statements
(Loc
,
4669 Statements
=> New_List
));
4671 Set_Scope
(Dnam
, Scope
(E
));
4672 Set_Assignment_OK
(First
(Declarations
(Dbody
)));
4673 Set_Is_Eliminated
(Dnam
);
4674 Insert_After
(After
, Dbody
);
4680 Next_Formal
(Formal
);
4683 end Process_Default_Expressions
;
4685 ----------------------------------------
4686 -- Set_Component_Alignment_If_Not_Set --
4687 ----------------------------------------
4689 procedure Set_Component_Alignment_If_Not_Set
(Typ
: Entity_Id
) is
4691 -- Ignore if not base type, subtypes don't need anything
4693 if Typ
/= Base_Type
(Typ
) then
4697 -- Do not override existing representation
4699 if Is_Packed
(Typ
) then
4702 elsif Has_Specified_Layout
(Typ
) then
4705 elsif Component_Alignment
(Typ
) /= Calign_Default
then
4709 Set_Component_Alignment
4710 (Typ
, Scope_Stack
.Table
4711 (Scope_Stack
.Last
).Component_Alignment_Default
);
4713 end Set_Component_Alignment_If_Not_Set
;
4715 ---------------------------
4716 -- Set_Debug_Info_Needed --
4717 ---------------------------
4719 procedure Set_Debug_Info_Needed
(T
: Entity_Id
) is
4722 or else Needs_Debug_Info
(T
)
4723 or else Debug_Info_Off
(T
)
4727 Set_Needs_Debug_Info
(T
);
4730 if Is_Object
(T
) then
4731 Set_Debug_Info_Needed
(Etype
(T
));
4733 elsif Is_Type
(T
) then
4734 Set_Debug_Info_Needed
(Etype
(T
));
4736 if Is_Record_Type
(T
) then
4738 Ent
: Entity_Id
:= First_Entity
(T
);
4740 while Present
(Ent
) loop
4741 Set_Debug_Info_Needed
(Ent
);
4746 elsif Is_Array_Type
(T
) then
4747 Set_Debug_Info_Needed
(Component_Type
(T
));
4750 Indx
: Node_Id
:= First_Index
(T
);
4752 while Present
(Indx
) loop
4753 Set_Debug_Info_Needed
(Etype
(Indx
));
4754 Indx
:= Next_Index
(Indx
);
4758 if Is_Packed
(T
) then
4759 Set_Debug_Info_Needed
(Packed_Array_Type
(T
));
4762 elsif Is_Access_Type
(T
) then
4763 Set_Debug_Info_Needed
(Directly_Designated_Type
(T
));
4765 elsif Is_Private_Type
(T
) then
4766 Set_Debug_Info_Needed
(Full_View
(T
));
4768 elsif Is_Protected_Type
(T
) then
4769 Set_Debug_Info_Needed
(Corresponding_Record_Type
(T
));
4772 end Set_Debug_Info_Needed
;
4778 procedure Undelay_Type
(T
: Entity_Id
) is
4780 Set_Has_Delayed_Freeze
(T
, False);
4781 Set_Freeze_Node
(T
, Empty
);
4783 -- Since we don't want T to have a Freeze_Node, we don't want its
4784 -- Full_View or Corresponding_Record_Type to have one either.
4786 -- ??? Fundamentally, this whole handling is a kludge. What we really
4787 -- want is to be sure that for an Itype that's part of record R and
4788 -- is a subtype of type T, that it's frozen after the later of the
4789 -- freeze points of R and T. We have no way of doing that directly,
4790 -- so what we do is force most such Itypes to be frozen as part of
4791 -- freezing R via this procedure and only delay the ones that need
4792 -- to be delayed (mostly the designated types of access types that are
4793 -- defined as part of the record).
4795 if Is_Private_Type
(T
)
4796 and then Present
(Full_View
(T
))
4797 and then Is_Itype
(Full_View
(T
))
4798 and then Is_Record_Type
(Scope
(Full_View
(T
)))
4800 Undelay_Type
(Full_View
(T
));
4803 if Is_Concurrent_Type
(T
)
4804 and then Present
(Corresponding_Record_Type
(T
))
4805 and then Is_Itype
(Corresponding_Record_Type
(T
))
4806 and then Is_Record_Type
(Scope
(Corresponding_Record_Type
(T
)))
4808 Undelay_Type
(Corresponding_Record_Type
(T
));
4816 procedure Warn_Overlay
4821 Ent
: constant Entity_Id
:= Entity
(Nam
);
4822 -- The object to which the address clause applies.
4825 Old
: Entity_Id
:= Empty
;
4829 -- No warning if address clause overlay warnings are off
4831 if not Address_Clause_Overlay_Warnings
then
4835 -- No warning if there is an explicit initialization
4837 Init
:= Original_Node
(Expression
(Declaration_Node
(Ent
)));
4839 if Present
(Init
) and then Comes_From_Source
(Init
) then
4843 -- We only give the warning for non-imported entities of a type
4844 -- for which a non-null base init proc is defined (or for access
4845 -- types which have implicit null initialization).
4848 and then (Has_Non_Null_Base_Init_Proc
(Typ
)
4849 or else Is_Access_Type
(Typ
))
4850 and then not Is_Imported
(Ent
)
4852 if Nkind
(Expr
) = N_Attribute_Reference
4853 and then Is_Entity_Name
(Prefix
(Expr
))
4855 Old
:= Entity
(Prefix
(Expr
));
4857 elsif Is_Entity_Name
(Expr
)
4858 and then Ekind
(Entity
(Expr
)) = E_Constant
4860 Decl
:= Declaration_Node
(Entity
(Expr
));
4862 if Nkind
(Decl
) = N_Object_Declaration
4863 and then Present
(Expression
(Decl
))
4864 and then Nkind
(Expression
(Decl
)) = N_Attribute_Reference
4865 and then Is_Entity_Name
(Prefix
(Expression
(Decl
)))
4867 Old
:= Entity
(Prefix
(Expression
(Decl
)));
4869 elsif Nkind
(Expr
) = N_Function_Call
then
4873 -- A function call (most likely to To_Address) is probably not
4874 -- an overlay, so skip warning. Ditto if the function call was
4875 -- inlined and transformed into an entity.
4877 elsif Nkind
(Original_Node
(Expr
)) = N_Function_Call
then
4881 Decl
:= Next
(Parent
(Expr
));
4883 -- If a pragma Import follows, we assume that it is for the current
4884 -- target of the address clause, and skip the warning.
4887 and then Nkind
(Decl
) = N_Pragma
4888 and then Chars
(Decl
) = Name_Import
4893 if Present
(Old
) then
4894 Error_Msg_Node_2
:= Old
;
4896 ("default initialization of & may modify &?",
4900 ("default initialization of & may modify overlaid storage?",
4904 -- Add friendly warning if initialization comes from a packed array
4907 if Is_Record_Type
(Typ
) then
4912 Comp
:= First_Component
(Typ
);
4914 while Present
(Comp
) loop
4915 if Nkind
(Parent
(Comp
)) = N_Component_Declaration
4916 and then Present
(Expression
(Parent
(Comp
)))
4919 elsif Is_Array_Type
(Etype
(Comp
))
4920 and then Present
(Packed_Array_Type
(Etype
(Comp
)))
4923 ("packed array component& will be initialized to zero?",
4927 Next_Component
(Comp
);
4934 ("use pragma Import for & to " &
4935 "suppress initialization ('R'M B.1(24))?",