The newly introduced Finalizable aspect makes it possible to derive from
a type that is not tagged but has a Finalize primitive. This patch fixes
problems where overridings of the Finalize primitive were ignored.
gcc/ada/ChangeLog:
* exp_ch7.adb (Make_Final_Call): Tweak search of Finalize primitive.
* exp_util.adb (Finalize_Address): Likewise.
if Is_Untagged_Derivation (Typ) then
if Is_Protected_Type (Typ) then
Utyp := Corresponding_Record_Type (Root_Type (Base_Type (Typ)));
- else
- Utyp := Underlying_Type (Root_Type (Base_Type (Typ)));
- if Is_Protected_Type (Utyp) then
- Utyp := Corresponding_Record_Type (Utyp);
- end if;
+ else
+ declare
+ Root : constant Entity_Id :=
+ Underlying_Type (Root_Type (Base_Type (Typ)));
+ begin
+ if Is_Protected_Type (Root) then
+ Utyp := Corresponding_Record_Type (Root);
+ end if;
+ end;
end if;
Ref := Unchecked_Convert_To (Utyp, Ref);
Utyp := Corresponding_Record_Type (Root_Type (Btyp));
else
- Utyp := Underlying_Type (Root_Type (Btyp));
-
- if Is_Protected_Type (Utyp) then
- Utyp := Corresponding_Record_Type (Utyp);
- end if;
+ declare
+ Root : constant Entity_Id := Underlying_Type (Root_Type (Btyp));
+ begin
+ if Is_Protected_Type (Root) then
+ Utyp := Corresponding_Record_Type (Root);
+ else
+ while No (TSS (Utyp, TSS_Finalize_Address)) loop
+ Utyp := Underlying_Type (Base_Type (Etype (Utyp)));
+ end loop;
+ end if;
+ end;
end if;
end if;