1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Atree; use Atree;
27 with Debug; use Debug;
28 with Elists; use Elists;
29 with Einfo; use Einfo;
30 with Exp_Disp; use Exp_Disp;
31 with Exp_Util; use Exp_Util;
32 with Exp_Ch7; use Exp_Ch7;
33 with Exp_Tss; use Exp_Tss;
34 with Errout; use Errout;
35 with Lib.Xref; use Lib.Xref;
36 with Namet; use Namet;
37 with Nlists; use Nlists;
38 with Nmake; use Nmake;
40 with Output; use Output;
41 with Restrict; use Restrict;
42 with Rident; use Rident;
44 with Sem_Aux; use Sem_Aux;
45 with Sem_Ch3; use Sem_Ch3;
46 with Sem_Ch6; use Sem_Ch6;
47 with Sem_Eval; use Sem_Eval;
48 with Sem_Type; use Sem_Type;
49 with Sem_Util; use Sem_Util;
50 with Snames; use Snames;
51 with Stand; use Stand;
52 with Sinfo; use Sinfo;
53 with Tbuild; use Tbuild;
54 with Uintp; use Uintp;
56 package body Sem_Disp is
58 -----------------------
59 -- Local Subprograms --
60 -----------------------
62 procedure Add_Dispatching_Operation
63 (Tagged_Type : Entity_Id;
65 -- Add New_Op in the list of primitive operations of Tagged_Type
67 function Check_Controlling_Type
69 Subp : Entity_Id) return Entity_Id;
70 -- T is the tagged type of a formal parameter or the result of Subp.
71 -- If the subprogram has a controlling parameter or result that matches
72 -- the type, then returns the tagged type of that parameter or result
73 -- (returning the designated tagged type in the case of an access
74 -- parameter); otherwise returns empty.
76 -------------------------------
77 -- Add_Dispatching_Operation --
78 -------------------------------
80 procedure Add_Dispatching_Operation
81 (Tagged_Type : Entity_Id;
84 List : constant Elist_Id := Primitive_Operations (Tagged_Type);
87 -- The dispatching operation may already be on the list, if it is the
88 -- wrapper for an inherited function of a null extension (see Exp_Ch3
89 -- for the construction of function wrappers). The list of primitive
90 -- operations must not contain duplicates.
92 Append_Unique_Elmt (New_Op, List);
93 end Add_Dispatching_Operation;
95 -------------------------------
96 -- Check_Controlling_Formals --
97 -------------------------------
99 procedure Check_Controlling_Formals
104 Ctrl_Type : Entity_Id;
107 Formal := First_Formal (Subp);
109 while Present (Formal) loop
110 Ctrl_Type := Check_Controlling_Type (Etype (Formal), Subp);
112 if Present (Ctrl_Type) then
114 -- When the controlling type is concurrent and declared within a
115 -- generic or inside an instance, use its corresponding record
118 if Is_Concurrent_Type (Ctrl_Type)
119 and then Present (Corresponding_Record_Type (Ctrl_Type))
121 Ctrl_Type := Corresponding_Record_Type (Ctrl_Type);
124 if Ctrl_Type = Typ then
125 Set_Is_Controlling_Formal (Formal);
127 -- Ada 2005 (AI-231): Anonymous access types used in
128 -- controlling parameters exclude null because it is necessary
129 -- to read the tag to dispatch, and null has no tag.
131 if Ekind (Etype (Formal)) = E_Anonymous_Access_Type then
132 Set_Can_Never_Be_Null (Etype (Formal));
133 Set_Is_Known_Non_Null (Etype (Formal));
136 -- Check that the parameter's nominal subtype statically
137 -- matches the first subtype.
139 if Ekind (Etype (Formal)) = E_Anonymous_Access_Type then
140 if not Subtypes_Statically_Match
141 (Typ, Designated_Type (Etype (Formal)))
144 ("parameter subtype does not match controlling type",
148 elsif not Subtypes_Statically_Match (Typ, Etype (Formal)) then
150 ("parameter subtype does not match controlling type",
154 if Present (Default_Value (Formal)) then
156 -- In Ada 2005, access parameters can have defaults
158 if Ekind (Etype (Formal)) = E_Anonymous_Access_Type
159 and then Ada_Version < Ada_05
162 ("default not allowed for controlling access parameter",
163 Default_Value (Formal));
165 elsif not Is_Tag_Indeterminate (Default_Value (Formal)) then
167 ("default expression must be a tag indeterminate" &
168 " function call", Default_Value (Formal));
172 elsif Comes_From_Source (Subp) then
174 ("operation can be dispatching in only one type", Subp);
178 Next_Formal (Formal);
181 if Present (Etype (Subp)) then
182 Ctrl_Type := Check_Controlling_Type (Etype (Subp), Subp);
184 if Present (Ctrl_Type) then
185 if Ctrl_Type = Typ then
186 Set_Has_Controlling_Result (Subp);
188 -- Check that result subtype statically matches first subtype
189 -- (Ada 2005): Subp may have a controlling access result.
191 if Subtypes_Statically_Match (Typ, Etype (Subp))
192 or else (Ekind (Etype (Subp)) = E_Anonymous_Access_Type
194 Subtypes_Statically_Match
195 (Typ, Designated_Type (Etype (Subp))))
201 ("result subtype does not match controlling type", Subp);
204 elsif Comes_From_Source (Subp) then
206 ("operation can be dispatching in only one type", Subp);
210 end Check_Controlling_Formals;
212 ----------------------------
213 -- Check_Controlling_Type --
214 ----------------------------
216 function Check_Controlling_Type
218 Subp : Entity_Id) return Entity_Id
220 Tagged_Type : Entity_Id := Empty;
223 if Is_Tagged_Type (T) then
224 if Is_First_Subtype (T) then
227 Tagged_Type := Base_Type (T);
230 elsif Ekind (T) = E_Anonymous_Access_Type
231 and then Is_Tagged_Type (Designated_Type (T))
233 if Ekind (Designated_Type (T)) /= E_Incomplete_Type then
234 if Is_First_Subtype (Designated_Type (T)) then
235 Tagged_Type := Designated_Type (T);
237 Tagged_Type := Base_Type (Designated_Type (T));
240 -- Ada 2005: an incomplete type can be tagged. An operation with an
241 -- access parameter of the type is dispatching.
243 elsif Scope (Designated_Type (T)) = Current_Scope then
244 Tagged_Type := Designated_Type (T);
246 -- Ada 2005 (AI-50217)
248 elsif From_With_Type (Designated_Type (T))
249 and then Present (Non_Limited_View (Designated_Type (T)))
251 if Is_First_Subtype (Non_Limited_View (Designated_Type (T))) then
252 Tagged_Type := Non_Limited_View (Designated_Type (T));
254 Tagged_Type := Base_Type (Non_Limited_View
255 (Designated_Type (T)));
260 if No (Tagged_Type) or else Is_Class_Wide_Type (Tagged_Type) then
263 -- The dispatching type and the primitive operation must be defined in
264 -- the same scope, except in the case of internal operations and formal
265 -- abstract subprograms.
267 elsif ((Scope (Subp) = Scope (Tagged_Type) or else Is_Internal (Subp))
268 and then (not Is_Generic_Type (Tagged_Type)
269 or else not Comes_From_Source (Subp)))
271 (Is_Formal_Subprogram (Subp) and then Is_Abstract_Subprogram (Subp))
273 (Nkind (Parent (Parent (Subp))) = N_Subprogram_Renaming_Declaration
275 Present (Corresponding_Formal_Spec (Parent (Parent (Subp))))
277 Is_Abstract_Subprogram (Subp))
284 end Check_Controlling_Type;
286 ----------------------------
287 -- Check_Dispatching_Call --
288 ----------------------------
290 procedure Check_Dispatching_Call (N : Node_Id) is
291 Loc : constant Source_Ptr := Sloc (N);
294 Control : Node_Id := Empty;
296 Subp_Entity : Entity_Id;
297 Indeterm_Ancestor_Call : Boolean := False;
298 Indeterm_Ctrl_Type : Entity_Id;
300 Static_Tag : Node_Id := Empty;
301 -- If a controlling formal has a statically tagged actual, the tag of
302 -- this actual is to be used for any tag-indeterminate actual.
304 procedure Check_Dispatching_Context;
305 -- If the call is tag-indeterminate and the entity being called is
306 -- abstract, verify that the context is a call that will eventually
307 -- provide a tag for dispatching, or has provided one already.
309 -------------------------------
310 -- Check_Dispatching_Context --
311 -------------------------------
313 procedure Check_Dispatching_Context is
314 Subp : constant Entity_Id := Entity (Name (N));
318 if Is_Abstract_Subprogram (Subp)
319 and then No (Controlling_Argument (N))
321 if Present (Alias (Subp))
322 and then not Is_Abstract_Subprogram (Alias (Subp))
323 and then No (DTC_Entity (Subp))
325 -- Private overriding of inherited abstract operation, call is
328 Set_Entity (Name (N), Alias (Subp));
334 while Present (Par) loop
336 if (Nkind (Par) = N_Function_Call or else
337 Nkind (Par) = N_Procedure_Call_Statement or else
338 Nkind (Par) = N_Assignment_Statement or else
339 Nkind (Par) = N_Op_Eq or else
340 Nkind (Par) = N_Op_Ne)
341 and then Is_Tagged_Type (Etype (Subp))
345 elsif Nkind (Par) = N_Qualified_Expression
346 or else Nkind (Par) = N_Unchecked_Type_Conversion
351 if Ekind (Subp) = E_Function then
353 ("call to abstract function must be dispatching", N);
355 -- This error can occur for a procedure in the case of a
356 -- call to an abstract formal procedure with a statically
361 ("call to abstract procedure must be dispatching",
370 end Check_Dispatching_Context;
372 -- Start of processing for Check_Dispatching_Call
375 -- Find a controlling argument, if any
377 if Present (Parameter_Associations (N)) then
378 Actual := First_Actual (N);
380 Subp_Entity := Entity (Name (N));
381 Formal := First_Formal (Subp_Entity);
383 while Present (Actual) loop
384 Control := Find_Controlling_Arg (Actual);
385 exit when Present (Control);
387 -- Check for the case where the actual is a tag-indeterminate call
388 -- whose result type is different than the tagged type associated
389 -- with the containing call, but is an ancestor of the type.
391 if Is_Controlling_Formal (Formal)
392 and then Is_Tag_Indeterminate (Actual)
393 and then Base_Type (Etype (Actual)) /= Base_Type (Etype (Formal))
394 and then Is_Ancestor (Etype (Actual), Etype (Formal))
396 Indeterm_Ancestor_Call := True;
397 Indeterm_Ctrl_Type := Etype (Formal);
399 -- If the formal is controlling but the actual is not, the type
400 -- of the actual is statically known, and may be used as the
401 -- controlling tag for some other tag-indeterminate actual.
403 elsif Is_Controlling_Formal (Formal)
404 and then Is_Entity_Name (Actual)
405 and then Is_Tagged_Type (Etype (Actual))
407 Static_Tag := Actual;
410 Next_Actual (Actual);
411 Next_Formal (Formal);
414 -- If the call doesn't have a controlling actual but does have an
415 -- indeterminate actual that requires dispatching treatment, then an
416 -- object is needed that will serve as the controlling argument for a
417 -- dispatching call on the indeterminate actual. This can only occur
418 -- in the unusual situation of a default actual given by a
419 -- tag-indeterminate call and where the type of the call is an
420 -- ancestor of the type associated with a containing call to an
421 -- inherited operation (see AI-239).
423 -- Rather than create an object of the tagged type, which would be
424 -- problematic for various reasons (default initialization,
425 -- discriminants), the tag of the containing call's associated tagged
426 -- type is directly used to control the dispatching.
429 and then Indeterm_Ancestor_Call
430 and then No (Static_Tag)
433 Make_Attribute_Reference (Loc,
434 Prefix => New_Occurrence_Of (Indeterm_Ctrl_Type, Loc),
435 Attribute_Name => Name_Tag);
440 if Present (Control) then
442 -- Verify that no controlling arguments are statically tagged
445 Write_Str ("Found Dispatching call");
450 Actual := First_Actual (N);
452 while Present (Actual) loop
453 if Actual /= Control then
455 if not Is_Controlling_Actual (Actual) then
456 null; -- Can be anything
458 elsif Is_Dynamically_Tagged (Actual) then
459 null; -- Valid parameter
461 elsif Is_Tag_Indeterminate (Actual) then
463 -- The tag is inherited from the enclosing call (the node
464 -- we are currently analyzing). Explicitly expand the
465 -- actual, since the previous call to Expand (from
466 -- Resolve_Call) had no way of knowing about the required
469 Propagate_Tag (Control, Actual);
473 ("controlling argument is not dynamically tagged",
479 Next_Actual (Actual);
482 -- Mark call as a dispatching call
484 Set_Controlling_Argument (N, Control);
485 Check_Restriction (No_Dispatching_Calls, N);
487 -- If there is a statically tagged actual and a tag-indeterminate
488 -- call to a function of the ancestor (such as that provided by a
489 -- default), then treat this as a dispatching call and propagate
490 -- the tag to the tag-indeterminate call(s).
492 elsif Present (Static_Tag) and then Indeterm_Ancestor_Call then
494 Make_Attribute_Reference (Loc,
496 New_Occurrence_Of (Etype (Static_Tag), Loc),
497 Attribute_Name => Name_Tag);
501 Actual := First_Actual (N);
502 Formal := First_Formal (Subp_Entity);
503 while Present (Actual) loop
504 if Is_Tag_Indeterminate (Actual)
505 and then Is_Controlling_Formal (Formal)
507 Propagate_Tag (Control, Actual);
510 Next_Actual (Actual);
511 Next_Formal (Formal);
514 Check_Dispatching_Context;
517 -- The call is not dispatching, so check that there aren't any
518 -- tag-indeterminate abstract calls left.
520 Actual := First_Actual (N);
521 while Present (Actual) loop
522 if Is_Tag_Indeterminate (Actual) then
524 -- Function call case
526 if Nkind (Original_Node (Actual)) = N_Function_Call then
527 Func := Entity (Name (Original_Node (Actual)));
529 -- If the actual is an attribute then it can't be abstract
530 -- (the only current case of a tag-indeterminate attribute
531 -- is the stream Input attribute).
534 Nkind (Original_Node (Actual)) = N_Attribute_Reference
538 -- Only other possibility is a qualified expression whose
539 -- constituent expression is itself a call.
545 (Expression (Original_Node (Actual)))));
548 if Present (Func) and then Is_Abstract_Subprogram (Func) then
550 "call to abstract function must be dispatching", N);
554 Next_Actual (Actual);
557 Check_Dispatching_Context;
561 -- If dispatching on result, the enclosing call, if any, will
562 -- determine the controlling argument. Otherwise this is the
563 -- primitive operation of the root type.
565 Check_Dispatching_Context;
567 end Check_Dispatching_Call;
569 ---------------------------------
570 -- Check_Dispatching_Operation --
571 ---------------------------------
573 procedure Check_Dispatching_Operation (Subp, Old_Subp : Entity_Id) is
574 Tagged_Type : Entity_Id;
575 Has_Dispatching_Parent : Boolean := False;
576 Body_Is_Last_Primitive : Boolean := False;
578 function Is_Visibly_Controlled (T : Entity_Id) return Boolean;
579 -- Check whether T is derived from a visibly controlled type.
580 -- This is true if the root type is declared in Ada.Finalization.
581 -- If T is derived instead from a private type whose full view
582 -- is controlled, an explicit Initialize/Adjust/Finalize subprogram
583 -- does not override the inherited one.
585 ---------------------------
586 -- Is_Visibly_Controlled --
587 ---------------------------
589 function Is_Visibly_Controlled (T : Entity_Id) return Boolean is
590 Root : constant Entity_Id := Root_Type (T);
592 return Chars (Scope (Root)) = Name_Finalization
593 and then Chars (Scope (Scope (Root))) = Name_Ada
594 and then Scope (Scope (Scope (Root))) = Standard_Standard;
595 end Is_Visibly_Controlled;
597 -- Start of processing for Check_Dispatching_Operation
600 if Ekind (Subp) /= E_Procedure and then Ekind (Subp) /= E_Function then
604 Set_Is_Dispatching_Operation (Subp, False);
605 Tagged_Type := Find_Dispatching_Type (Subp);
609 if Ada_Version = Ada_05
610 and then Present (Tagged_Type)
611 and then Is_Concurrent_Type (Tagged_Type)
613 -- Protect the frontend against previously detected errors
615 if No (Corresponding_Record_Type (Tagged_Type)) then
619 Tagged_Type := Corresponding_Record_Type (Tagged_Type);
622 -- (AI-345): The task body procedure is not a primitive of the tagged
625 if Present (Tagged_Type)
626 and then Is_Concurrent_Record_Type (Tagged_Type)
627 and then Present (Corresponding_Concurrent_Type (Tagged_Type))
628 and then Is_Task_Type (Corresponding_Concurrent_Type (Tagged_Type))
629 and then Subp = Get_Task_Body_Procedure
630 (Corresponding_Concurrent_Type (Tagged_Type))
635 -- If Subp is derived from a dispatching operation then it should
636 -- always be treated as dispatching. In this case various checks
637 -- below will be bypassed. Makes sure that late declarations for
638 -- inherited private subprograms are treated as dispatching, even
639 -- if the associated tagged type is already frozen.
641 Has_Dispatching_Parent :=
642 Present (Alias (Subp))
643 and then Is_Dispatching_Operation (Alias (Subp));
645 if No (Tagged_Type) then
647 -- Ada 2005 (AI-251): Check that Subp is not a primitive associated
648 -- with an abstract interface type unless the interface acts as a
649 -- parent type in a derivation. If the interface type is a formal
650 -- type then the operation is not primitive and therefore legal.
657 E := First_Entity (Subp);
658 while Present (E) loop
660 -- For an access parameter, check designated type.
662 if Ekind (Etype (E)) = E_Anonymous_Access_Type then
663 Typ := Designated_Type (Etype (E));
668 if Comes_From_Source (Subp)
669 and then Is_Interface (Typ)
670 and then not Is_Class_Wide_Type (Typ)
671 and then not Is_Derived_Type (Typ)
672 and then not Is_Generic_Type (Typ)
673 and then not In_Instance
675 Error_Msg_N ("?declaration of& is too late!", Subp);
677 ("\spec should appear immediately after declaration of &!",
685 -- In case of functions check also the result type
687 if Ekind (Subp) = E_Function then
688 if Is_Access_Type (Etype (Subp)) then
689 Typ := Designated_Type (Etype (Subp));
694 if not Is_Class_Wide_Type (Typ)
695 and then Is_Interface (Typ)
696 and then not Is_Derived_Type (Typ)
698 Error_Msg_N ("?declaration of& is too late!", Subp);
700 ("\spec should appear immediately after declaration of &!",
708 -- The subprograms build internally after the freezing point (such as
709 -- init procs, interface thunks, type support subprograms, and Offset
710 -- to top functions for accessing interface components in variable
711 -- size tagged types) are not primitives.
713 elsif Is_Frozen (Tagged_Type)
714 and then not Comes_From_Source (Subp)
715 and then not Has_Dispatching_Parent
717 -- Complete decoration if internally built subprograms that override
718 -- a dispatching primitive. These entities correspond with the
721 -- 1. Ada 2005 (AI-391): Wrapper functions built by the expander
722 -- to override functions of nonabstract null extensions. These
723 -- primitives were added to the list of primitives of the tagged
724 -- type by Make_Controlling_Function_Wrappers. However, attribute
725 -- Is_Dispatching_Operation must be set to true.
727 -- 2. Subprograms associated with stream attributes (built by
728 -- New_Stream_Subprogram)
730 if Present (Old_Subp)
731 and then Is_Overriding_Operation (Subp)
732 and then Is_Dispatching_Operation (Old_Subp)
735 ((Ekind (Subp) = E_Function
736 and then Is_Dispatching_Operation (Old_Subp)
737 and then Is_Null_Extension (Base_Type (Etype (Subp))))
738 or else Get_TSS_Name (Subp) = TSS_Stream_Read
739 or else Get_TSS_Name (Subp) = TSS_Stream_Write);
741 Set_Is_Dispatching_Operation (Subp);
746 -- The operation may be a child unit, whose scope is the defining
747 -- package, but which is not a primitive operation of the type.
749 elsif Is_Child_Unit (Subp) then
752 -- If the subprogram is not defined in a package spec, the only case
753 -- where it can be a dispatching op is when it overrides an operation
754 -- before the freezing point of the type.
756 elsif ((not Is_Package_Or_Generic_Package (Scope (Subp)))
757 or else In_Package_Body (Scope (Subp)))
758 and then not Has_Dispatching_Parent
760 if not Comes_From_Source (Subp)
761 or else (Present (Old_Subp) and then not Is_Frozen (Tagged_Type))
765 -- If the type is already frozen, the overriding is not allowed
766 -- except when Old_Subp is not a dispatching operation (which can
767 -- occur when Old_Subp was inherited by an untagged type). However,
768 -- a body with no previous spec freezes the type "after" its
769 -- declaration, and therefore is a legal overriding (unless the type
770 -- has already been frozen). Only the first such body is legal.
772 elsif Present (Old_Subp)
773 and then Is_Dispatching_Operation (Old_Subp)
775 if Comes_From_Source (Subp)
777 (Nkind (Unit_Declaration_Node (Subp)) = N_Subprogram_Body
778 or else Nkind (Unit_Declaration_Node (Subp)) in N_Body_Stub)
781 Subp_Body : constant Node_Id := Unit_Declaration_Node (Subp);
782 Decl_Item : Node_Id := Next (Parent (Tagged_Type));
785 -- ??? The checks here for whether the type has been
786 -- frozen prior to the new body are not complete. It's
787 -- not simple to check frozenness at this point since
788 -- the body has already caused the type to be prematurely
789 -- frozen in Analyze_Declarations, but we're forced to
790 -- recheck this here because of the odd rule interpretation
791 -- that allows the overriding if the type wasn't frozen
792 -- prior to the body. The freezing action should probably
793 -- be delayed until after the spec is seen, but that's
794 -- a tricky change to the delicate freezing code.
796 -- Look at each declaration following the type up until the
797 -- new subprogram body. If any of the declarations is a body
798 -- then the type has been frozen already so the overriding
799 -- primitive is illegal.
801 while Present (Decl_Item)
802 and then (Decl_Item /= Subp_Body)
804 if Comes_From_Source (Decl_Item)
805 and then (Nkind (Decl_Item) in N_Proper_Body
806 or else Nkind (Decl_Item) in N_Body_Stub)
808 Error_Msg_N ("overriding of& is too late!", Subp);
810 ("\spec should appear immediately after the type!",
818 -- If the subprogram doesn't follow in the list of
819 -- declarations including the type then the type has
820 -- definitely been frozen already and the body is illegal.
822 if No (Decl_Item) then
823 Error_Msg_N ("overriding of& is too late!", Subp);
825 ("\spec should appear immediately after the type!",
828 elsif Is_Frozen (Subp) then
830 -- The subprogram body declares a primitive operation.
831 -- if the subprogram is already frozen, we must update
832 -- its dispatching information explicitly here. The
833 -- information is taken from the overridden subprogram.
834 -- We must also generate a cross-reference entry because
835 -- references to other primitives were already created
836 -- when type was frozen.
838 Body_Is_Last_Primitive := True;
840 if Present (DTC_Entity (Old_Subp)) then
841 Set_DTC_Entity (Subp, DTC_Entity (Old_Subp));
842 Set_DT_Position (Subp, DT_Position (Old_Subp));
844 if not Restriction_Active (No_Dispatching_Calls) then
845 if Building_Static_DT (Tagged_Type) then
847 -- If the static dispatch table has not been
848 -- built then there is nothing else to do now;
849 -- otherwise we notify that we cannot build the
850 -- static dispatch table.
852 if Has_Dispatch_Table (Tagged_Type) then
854 ("overriding of& is too late for building" &
855 " static dispatch tables!", Subp);
857 ("\spec should appear immediately after" &
862 Insert_Actions_After (Subp_Body,
863 Register_Primitive (Sloc (Subp_Body),
867 -- Indicate that this is an overriding operation,
868 -- and replace the overriden entry in the list of
869 -- primitive operations, which is used for xref
870 -- generation subsequently.
872 Generate_Reference (Tagged_Type, Subp, 'P', False);
873 Override_Dispatching_Operation
874 (Tagged_Type, Old_Subp, Subp);
881 Error_Msg_N ("overriding of& is too late!", Subp);
883 ("\subprogram spec should appear immediately after the type!",
887 -- If the type is not frozen yet and we are not in the overriding
888 -- case it looks suspiciously like an attempt to define a primitive
889 -- operation, which requires the declaration to be in a package spec
892 elsif not Is_Frozen (Tagged_Type) then
894 ("?not dispatching (must be defined in a package spec)", Subp);
897 -- When the type is frozen, it is legitimate to define a new
898 -- non-primitive operation.
904 -- Now, we are sure that the scope is a package spec. If the subprogram
905 -- is declared after the freezing point of the type that's an error
907 elsif Is_Frozen (Tagged_Type) and then not Has_Dispatching_Parent then
908 Error_Msg_N ("this primitive operation is declared too late", Subp);
910 ("?no primitive operations for& after this line",
911 Freeze_Node (Tagged_Type),
916 Check_Controlling_Formals (Tagged_Type, Subp);
918 -- Now it should be a correct primitive operation, put it in the list
920 if Present (Old_Subp) then
922 -- If the type has interfaces we complete this check after we set
923 -- attribute Is_Dispatching_Operation.
925 Check_Subtype_Conformant (Subp, Old_Subp);
927 if (Chars (Subp) = Name_Initialize
928 or else Chars (Subp) = Name_Adjust
929 or else Chars (Subp) = Name_Finalize)
930 and then Is_Controlled (Tagged_Type)
931 and then not Is_Visibly_Controlled (Tagged_Type)
933 Set_Is_Overriding_Operation (Subp, False);
935 ("operation does not override inherited&?", Subp, Subp);
937 Override_Dispatching_Operation (Tagged_Type, Old_Subp, Subp);
938 Set_Is_Overriding_Operation (Subp);
940 -- Ada 2005 (AI-251): In case of late overriding of a primitive
941 -- that covers abstract interface subprograms we must register it
942 -- in all the secondary dispatch tables associated with abstract
943 -- interfaces. We do this now only if not building static tables.
944 -- Otherwise the patch code is emitted after those tables are
945 -- built, to prevent access_before_elaboration in gigi.
947 if Body_Is_Last_Primitive then
949 Subp_Body : constant Node_Id := Unit_Declaration_Node (Subp);
954 Elmt := First_Elmt (Primitive_Operations (Tagged_Type));
955 while Present (Elmt) loop
958 if Present (Alias (Prim))
959 and then Present (Interface_Alias (Prim))
960 and then Alias (Prim) = Subp
961 and then not Building_Static_DT (Tagged_Type)
963 Insert_Actions_After (Subp_Body,
964 Register_Primitive (Sloc (Subp_Body), Prim => Prim));
970 -- Redisplay the contents of the updated dispatch table
972 if Debug_Flag_ZZ then
973 Write_Str ("Late overriding: ");
974 Write_DT (Tagged_Type);
980 -- If no old subprogram, then we add this as a dispatching operation,
981 -- but we avoid doing this if an error was posted, to prevent annoying
984 elsif not Error_Posted (Subp) then
985 Add_Dispatching_Operation (Tagged_Type, Subp);
988 Set_Is_Dispatching_Operation (Subp, True);
990 -- Ada 2005 (AI-251): If the type implements interfaces we must check
991 -- subtype conformance against all the interfaces covered by this
994 if Present (Old_Subp)
995 and then Has_Interfaces (Tagged_Type)
998 Ifaces_List : Elist_Id;
999 Iface_Elmt : Elmt_Id;
1000 Iface_Prim_Elmt : Elmt_Id;
1001 Iface_Prim : Entity_Id;
1002 Ret_Typ : Entity_Id;
1005 Collect_Interfaces (Tagged_Type, Ifaces_List);
1007 Iface_Elmt := First_Elmt (Ifaces_List);
1008 while Present (Iface_Elmt) loop
1009 if not Is_Ancestor (Node (Iface_Elmt), Tagged_Type) then
1011 First_Elmt (Primitive_Operations (Node (Iface_Elmt)));
1012 while Present (Iface_Prim_Elmt) loop
1013 Iface_Prim := Node (Iface_Prim_Elmt);
1015 if Is_Interface_Conformant
1016 (Tagged_Type, Iface_Prim, Subp)
1018 -- Handle procedures, functions whose return type
1019 -- matches, or functions not returning interfaces
1021 if Ekind (Subp) = E_Procedure
1022 or else Etype (Iface_Prim) = Etype (Subp)
1023 or else not Is_Interface (Etype (Iface_Prim))
1025 Check_Subtype_Conformant
1027 Old_Id => Iface_Prim,
1029 Skip_Controlling_Formals => True);
1031 -- Handle functions returning interfaces
1033 elsif Implements_Interface
1034 (Etype (Subp), Etype (Iface_Prim))
1036 -- Temporarily force both entities to return the
1037 -- same type. Required because Subtype_Conformant
1038 -- does not handle this case.
1040 Ret_Typ := Etype (Iface_Prim);
1041 Set_Etype (Iface_Prim, Etype (Subp));
1043 Check_Subtype_Conformant
1045 Old_Id => Iface_Prim,
1047 Skip_Controlling_Formals => True);
1049 Set_Etype (Iface_Prim, Ret_Typ);
1053 Next_Elmt (Iface_Prim_Elmt);
1057 Next_Elmt (Iface_Elmt);
1062 if not Body_Is_Last_Primitive then
1063 Set_DT_Position (Subp, No_Uint);
1065 elsif Has_Controlled_Component (Tagged_Type)
1067 (Chars (Subp) = Name_Initialize
1068 or else Chars (Subp) = Name_Adjust
1069 or else Chars (Subp) = Name_Finalize)
1072 F_Node : constant Node_Id := Freeze_Node (Tagged_Type);
1076 Old_Spec : Entity_Id;
1078 C_Names : constant array (1 .. 3) of Name_Id :=
1083 D_Names : constant array (1 .. 3) of TSS_Name_Type :=
1084 (TSS_Deep_Initialize,
1089 -- Remove previous controlled function, which was constructed
1090 -- and analyzed when the type was frozen. This requires
1091 -- removing the body of the redefined primitive, as well as
1092 -- its specification if needed (there is no spec created for
1093 -- Deep_Initialize, see exp_ch3.adb). We must also dismantle
1094 -- the exception information that may have been generated for
1095 -- it when front end zero-cost tables are enabled.
1097 for J in D_Names'Range loop
1098 Old_P := TSS (Tagged_Type, D_Names (J));
1101 and then Chars (Subp) = C_Names (J)
1103 Old_Bod := Unit_Declaration_Node (Old_P);
1105 Set_Is_Eliminated (Old_P);
1106 Set_Scope (Old_P, Scope (Current_Scope));
1108 if Nkind (Old_Bod) = N_Subprogram_Body
1109 and then Present (Corresponding_Spec (Old_Bod))
1111 Old_Spec := Corresponding_Spec (Old_Bod);
1112 Set_Has_Completion (Old_Spec, False);
1117 Build_Late_Proc (Tagged_Type, Chars (Subp));
1119 -- The new operation is added to the actions of the freeze
1120 -- node for the type, but this node has already been analyzed,
1121 -- so we must retrieve and analyze explicitly the new body.
1124 and then Present (Actions (F_Node))
1126 Decl := Last (Actions (F_Node));
1131 end Check_Dispatching_Operation;
1133 ------------------------------------------
1134 -- Check_Operation_From_Incomplete_Type --
1135 ------------------------------------------
1137 procedure Check_Operation_From_Incomplete_Type
1141 Full : constant Entity_Id := Full_View (Typ);
1142 Parent_Typ : constant Entity_Id := Etype (Full);
1143 Old_Prim : constant Elist_Id := Primitive_Operations (Parent_Typ);
1144 New_Prim : constant Elist_Id := Primitive_Operations (Full);
1146 Prev : Elmt_Id := No_Elmt;
1148 function Derives_From (Proc : Entity_Id) return Boolean;
1149 -- Check that Subp has the signature of an operation derived from Proc.
1150 -- Subp has an access parameter that designates Typ.
1156 function Derives_From (Proc : Entity_Id) return Boolean is
1160 if Chars (Proc) /= Chars (Subp) then
1164 F1 := First_Formal (Proc);
1165 F2 := First_Formal (Subp);
1167 while Present (F1) and then Present (F2) loop
1169 if Ekind (Etype (F1)) = E_Anonymous_Access_Type then
1171 if Ekind (Etype (F2)) /= E_Anonymous_Access_Type then
1174 elsif Designated_Type (Etype (F1)) = Parent_Typ
1175 and then Designated_Type (Etype (F2)) /= Full
1180 elsif Ekind (Etype (F2)) = E_Anonymous_Access_Type then
1183 elsif Etype (F1) /= Etype (F2) then
1191 return No (F1) and then No (F2);
1194 -- Start of processing for Check_Operation_From_Incomplete_Type
1197 -- The operation may override an inherited one, or may be a new one
1198 -- altogether. The inherited operation will have been hidden by the
1199 -- current one at the point of the type derivation, so it does not
1200 -- appear in the list of primitive operations of the type. We have to
1201 -- find the proper place of insertion in the list of primitive opera-
1202 -- tions by iterating over the list for the parent type.
1204 Op1 := First_Elmt (Old_Prim);
1205 Op2 := First_Elmt (New_Prim);
1207 while Present (Op1) and then Present (Op2) loop
1209 if Derives_From (Node (Op1)) then
1213 -- Avoid adding it to the list of primitives if already there!
1215 if Node (Op2) /= Subp then
1216 Prepend_Elmt (Subp, New_Prim);
1220 Insert_Elmt_After (Subp, Prev);
1231 -- Operation is a new primitive
1233 Append_Elmt (Subp, New_Prim);
1234 end Check_Operation_From_Incomplete_Type;
1236 ---------------------------------------
1237 -- Check_Operation_From_Private_View --
1238 ---------------------------------------
1240 procedure Check_Operation_From_Private_View (Subp, Old_Subp : Entity_Id) is
1241 Tagged_Type : Entity_Id;
1244 if Is_Dispatching_Operation (Alias (Subp)) then
1245 Set_Scope (Subp, Current_Scope);
1246 Tagged_Type := Find_Dispatching_Type (Subp);
1248 -- Add Old_Subp to primitive operations if not already present.
1250 if Present (Tagged_Type) and then Is_Tagged_Type (Tagged_Type) then
1251 Append_Unique_Elmt (Old_Subp, Primitive_Operations (Tagged_Type));
1253 -- If Old_Subp isn't already marked as dispatching then
1254 -- this is the case of an operation of an untagged private
1255 -- type fulfilled by a tagged type that overrides an
1256 -- inherited dispatching operation, so we set the necessary
1257 -- dispatching attributes here.
1259 if not Is_Dispatching_Operation (Old_Subp) then
1261 -- If the untagged type has no discriminants, and the full
1262 -- view is constrained, there will be a spurious mismatch
1263 -- of subtypes on the controlling arguments, because the tagged
1264 -- type is the internal base type introduced in the derivation.
1265 -- Use the original type to verify conformance, rather than the
1268 if not Comes_From_Source (Tagged_Type)
1269 and then Has_Discriminants (Tagged_Type)
1274 Formal := First_Formal (Old_Subp);
1275 while Present (Formal) loop
1276 if Tagged_Type = Base_Type (Etype (Formal)) then
1277 Tagged_Type := Etype (Formal);
1280 Next_Formal (Formal);
1284 if Tagged_Type = Base_Type (Etype (Old_Subp)) then
1285 Tagged_Type := Etype (Old_Subp);
1289 Check_Controlling_Formals (Tagged_Type, Old_Subp);
1290 Set_Is_Dispatching_Operation (Old_Subp, True);
1291 Set_DT_Position (Old_Subp, No_Uint);
1294 -- If the old subprogram is an explicit renaming of some other
1295 -- entity, it is not overridden by the inherited subprogram.
1296 -- Otherwise, update its alias and other attributes.
1298 if Present (Alias (Old_Subp))
1299 and then Nkind (Unit_Declaration_Node (Old_Subp))
1300 /= N_Subprogram_Renaming_Declaration
1302 Set_Alias (Old_Subp, Alias (Subp));
1304 -- The derived subprogram should inherit the abstractness
1305 -- of the parent subprogram (except in the case of a function
1306 -- returning the type). This sets the abstractness properly
1307 -- for cases where a private extension may have inherited
1308 -- an abstract operation, but the full type is derived from
1309 -- a descendant type and inherits a nonabstract version.
1311 if Etype (Subp) /= Tagged_Type then
1312 Set_Is_Abstract_Subprogram
1313 (Old_Subp, Is_Abstract_Subprogram (Alias (Subp)));
1318 end Check_Operation_From_Private_View;
1320 --------------------------
1321 -- Find_Controlling_Arg --
1322 --------------------------
1324 function Find_Controlling_Arg (N : Node_Id) return Node_Id is
1325 Orig_Node : constant Node_Id := Original_Node (N);
1329 if Nkind (Orig_Node) = N_Qualified_Expression then
1330 return Find_Controlling_Arg (Expression (Orig_Node));
1333 -- Dispatching on result case. If expansion is disabled, the node still
1334 -- has the structure of a function call. However, if the function name
1335 -- is an operator and the call was given in infix form, the original
1336 -- node has no controlling result and we must examine the current node.
1338 if Nkind (N) = N_Function_Call
1339 and then Present (Controlling_Argument (N))
1340 and then Has_Controlling_Result (Entity (Name (N)))
1342 return Controlling_Argument (N);
1344 -- If expansion is enabled, the call may have been transformed into
1345 -- an indirect call, and we need to recover the original node.
1347 elsif Nkind (Orig_Node) = N_Function_Call
1348 and then Present (Controlling_Argument (Orig_Node))
1349 and then Has_Controlling_Result (Entity (Name (Orig_Node)))
1351 return Controlling_Argument (Orig_Node);
1355 elsif Is_Controlling_Actual (N)
1357 (Nkind (Parent (N)) = N_Qualified_Expression
1358 and then Is_Controlling_Actual (Parent (N)))
1362 if Is_Access_Type (Typ) then
1363 -- In the case of an Access attribute, use the type of
1364 -- the prefix, since in the case of an actual for an
1365 -- access parameter, the attribute's type may be of a
1366 -- specific designated type, even though the prefix
1367 -- type is class-wide.
1369 if Nkind (N) = N_Attribute_Reference then
1370 Typ := Etype (Prefix (N));
1372 -- An allocator is dispatching if the type of qualified
1373 -- expression is class_wide, in which case this is the
1374 -- controlling type.
1376 elsif Nkind (Orig_Node) = N_Allocator
1377 and then Nkind (Expression (Orig_Node)) = N_Qualified_Expression
1379 Typ := Etype (Expression (Orig_Node));
1382 Typ := Designated_Type (Typ);
1386 if Is_Class_Wide_Type (Typ)
1388 (Nkind (Parent (N)) = N_Qualified_Expression
1389 and then Is_Access_Type (Etype (N))
1390 and then Is_Class_Wide_Type (Designated_Type (Etype (N))))
1397 end Find_Controlling_Arg;
1399 ---------------------------
1400 -- Find_Dispatching_Type --
1401 ---------------------------
1403 function Find_Dispatching_Type (Subp : Entity_Id) return Entity_Id is
1404 A_Formal : Entity_Id;
1406 Ctrl_Type : Entity_Id;
1409 if Present (DTC_Entity (Subp)) then
1410 return Scope (DTC_Entity (Subp));
1412 -- For subprograms internally generated by derivations of tagged types
1413 -- use the alias subprogram as a reference to locate the dispatching
1416 elsif not Comes_From_Source (Subp)
1417 and then Present (Alias (Subp))
1418 and then Is_Dispatching_Operation (Alias (Subp))
1420 if Ekind (Alias (Subp)) = E_Function
1421 and then Has_Controlling_Result (Alias (Subp))
1423 return Check_Controlling_Type (Etype (Subp), Subp);
1426 Formal := First_Formal (Subp);
1427 A_Formal := First_Formal (Alias (Subp));
1428 while Present (A_Formal) loop
1429 if Is_Controlling_Formal (A_Formal) then
1430 return Check_Controlling_Type (Etype (Formal), Subp);
1433 Next_Formal (Formal);
1434 Next_Formal (A_Formal);
1437 pragma Assert (False);
1444 Formal := First_Formal (Subp);
1445 while Present (Formal) loop
1446 Ctrl_Type := Check_Controlling_Type (Etype (Formal), Subp);
1448 if Present (Ctrl_Type) then
1452 Next_Formal (Formal);
1455 -- The subprogram may also be dispatching on result
1457 if Present (Etype (Subp)) then
1458 return Check_Controlling_Type (Etype (Subp), Subp);
1463 end Find_Dispatching_Type;
1465 ---------------------------------------
1466 -- Find_Primitive_Covering_Interface --
1467 ---------------------------------------
1469 function Find_Primitive_Covering_Interface
1470 (Tagged_Type : Entity_Id;
1471 Iface_Prim : Entity_Id) return Entity_Id
1476 pragma Assert (Is_Interface (Find_Dispatching_Type (Iface_Prim))
1477 or else (Present (Alias (Iface_Prim))
1480 (Find_Dispatching_Type (Ultimate_Alias (Iface_Prim)))));
1482 E := Current_Entity (Iface_Prim);
1483 while Present (E) loop
1484 if Is_Subprogram (E)
1485 and then Is_Dispatching_Operation (E)
1486 and then Is_Interface_Conformant (Tagged_Type, Iface_Prim, E)
1495 end Find_Primitive_Covering_Interface;
1497 ---------------------------
1498 -- Is_Dynamically_Tagged --
1499 ---------------------------
1501 function Is_Dynamically_Tagged (N : Node_Id) return Boolean is
1503 if Nkind (N) = N_Error then
1506 return Find_Controlling_Arg (N) /= Empty;
1508 end Is_Dynamically_Tagged;
1510 --------------------------
1511 -- Is_Tag_Indeterminate --
1512 --------------------------
1514 function Is_Tag_Indeterminate (N : Node_Id) return Boolean is
1517 Orig_Node : constant Node_Id := Original_Node (N);
1520 if Nkind (Orig_Node) = N_Function_Call
1521 and then Is_Entity_Name (Name (Orig_Node))
1523 Nam := Entity (Name (Orig_Node));
1525 if not Has_Controlling_Result (Nam) then
1528 -- An explicit dereference means that the call has already been
1529 -- expanded and there is no tag to propagate.
1531 elsif Nkind (N) = N_Explicit_Dereference then
1534 -- If there are no actuals, the call is tag-indeterminate
1536 elsif No (Parameter_Associations (Orig_Node)) then
1540 Actual := First_Actual (Orig_Node);
1541 while Present (Actual) loop
1542 if Is_Controlling_Actual (Actual)
1543 and then not Is_Tag_Indeterminate (Actual)
1545 return False; -- one operand is dispatching
1548 Next_Actual (Actual);
1554 elsif Nkind (Orig_Node) = N_Qualified_Expression then
1555 return Is_Tag_Indeterminate (Expression (Orig_Node));
1557 -- Case of a call to the Input attribute (possibly rewritten), which is
1558 -- always tag-indeterminate except when its prefix is a Class attribute.
1560 elsif Nkind (Orig_Node) = N_Attribute_Reference
1562 Get_Attribute_Id (Attribute_Name (Orig_Node)) = Attribute_Input
1564 Nkind (Prefix (Orig_Node)) /= N_Attribute_Reference
1568 -- In Ada 2005 a function that returns an anonymous access type can
1569 -- dispatching, and the dereference of a call to such a function
1570 -- is also tag-indeterminate.
1572 elsif Nkind (Orig_Node) = N_Explicit_Dereference
1573 and then Ada_Version >= Ada_05
1575 return Is_Tag_Indeterminate (Prefix (Orig_Node));
1580 end Is_Tag_Indeterminate;
1582 ------------------------------------
1583 -- Override_Dispatching_Operation --
1584 ------------------------------------
1586 procedure Override_Dispatching_Operation
1587 (Tagged_Type : Entity_Id;
1588 Prev_Op : Entity_Id;
1595 -- Diagnose failure to match No_Return in parent (Ada-2005, AI-414, but
1596 -- we do it unconditionally in Ada 95 now, since this is our pragma!)
1598 if No_Return (Prev_Op) and then not No_Return (New_Op) then
1599 Error_Msg_N ("procedure & must have No_Return pragma", New_Op);
1600 Error_Msg_N ("\since overridden procedure has No_Return", New_Op);
1603 -- If there is no previous operation to override, the type declaration
1604 -- was malformed, and an error must have been emitted already.
1606 Elmt := First_Elmt (Primitive_Operations (Tagged_Type));
1607 while Present (Elmt)
1608 and then Node (Elmt) /= Prev_Op
1617 Replace_Elmt (Elmt, New_Op);
1619 if Ada_Version >= Ada_05
1620 and then Has_Interfaces (Tagged_Type)
1622 -- Ada 2005 (AI-251): Update the attribute alias of all the aliased
1623 -- entities of the overridden primitive to reference New_Op, and also
1624 -- propagate the proper value of Is_Abstract_Subprogram. Verify
1625 -- that the new operation is subtype conformant with the interface
1626 -- operations that it implements (for operations inherited from the
1627 -- parent itself, this check is made when building the derived type).
1629 -- Note: This code is only executed in case of late overriding
1631 Elmt := First_Elmt (Primitive_Operations (Tagged_Type));
1632 while Present (Elmt) loop
1633 Prim := Node (Elmt);
1635 if Prim = New_Op then
1638 -- Note: The check on Is_Subprogram protects the frontend against
1639 -- reading attributes in entities that are not yet fully decorated
1641 elsif Is_Subprogram (Prim)
1642 and then Present (Interface_Alias (Prim))
1643 and then Alias (Prim) = Prev_Op
1644 and then Present (Etype (New_Op))
1646 Set_Alias (Prim, New_Op);
1647 Check_Subtype_Conformant (New_Op, Prim);
1648 Set_Is_Abstract_Subprogram (Prim,
1649 Is_Abstract_Subprogram (New_Op));
1651 -- Ensure that this entity will be expanded to fill the
1652 -- corresponding entry in its dispatch table.
1654 if not Is_Abstract_Subprogram (Prim) then
1655 Set_Has_Delayed_Freeze (Prim);
1663 if (not Is_Package_Or_Generic_Package (Current_Scope))
1664 or else not In_Private_Part (Current_Scope)
1666 -- Not a private primitive
1670 else pragma Assert (Is_Inherited_Operation (Prev_Op));
1672 -- Make the overriding operation into an alias of the implicit one.
1673 -- In this fashion a call from outside ends up calling the new body
1674 -- even if non-dispatching, and a call from inside calls the
1675 -- overriding operation because it hides the implicit one. To
1676 -- indicate that the body of Prev_Op is never called, set its
1677 -- dispatch table entity to Empty.
1679 Set_Alias (Prev_Op, New_Op);
1680 Set_DTC_Entity (Prev_Op, Empty);
1683 end Override_Dispatching_Operation;
1689 procedure Propagate_Tag (Control : Node_Id; Actual : Node_Id) is
1690 Call_Node : Node_Id;
1694 if Nkind (Actual) = N_Function_Call then
1695 Call_Node := Actual;
1697 elsif Nkind (Actual) = N_Identifier
1698 and then Nkind (Original_Node (Actual)) = N_Function_Call
1700 -- Call rewritten as object declaration when stack-checking
1701 -- is enabled. Propagate tag to expression in declaration, which
1702 -- is original call.
1704 Call_Node := Expression (Parent (Entity (Actual)));
1706 -- Ada 2005: If this is a dereference of a call to a function with a
1707 -- dispatching access-result, the tag is propagated when the dereference
1708 -- itself is expanded (see exp_ch6.adb) and there is nothing else to do.
1710 elsif Nkind (Actual) = N_Explicit_Dereference
1711 and then Nkind (Original_Node (Prefix (Actual))) = N_Function_Call
1715 -- Only other possibilities are parenthesized or qualified expression,
1716 -- or an expander-generated unchecked conversion of a function call to
1717 -- a stream Input attribute.
1720 Call_Node := Expression (Actual);
1723 -- Do not set the Controlling_Argument if already set. This happens
1724 -- in the special case of _Input (see Exp_Attr, case Input).
1726 if No (Controlling_Argument (Call_Node)) then
1727 Set_Controlling_Argument (Call_Node, Control);
1730 Arg := First_Actual (Call_Node);
1732 while Present (Arg) loop
1733 if Is_Tag_Indeterminate (Arg) then
1734 Propagate_Tag (Control, Arg);
1740 -- Expansion of dispatching calls is suppressed when VM_Target, because
1741 -- the VM back-ends directly handle the generation of dispatching
1742 -- calls and would have to undo any expansion to an indirect call.
1744 if Tagged_Type_Expansion then
1745 Expand_Dispatching_Call (Call_Node);
1747 -- Expansion of a dispatching call results in an indirect call, which in
1748 -- turn causes current values to be killed (see Resolve_Call), so on VM
1749 -- targets we do the call here to ensure consistent warnings between VM
1750 -- and non-VM targets.
1753 Kill_Current_Values;