diff options
Diffstat (limited to 'gcc/ada/layout.adb')
-rw-r--r-- | gcc/ada/layout.adb | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb index df310323931..119d184041c 100644 --- a/gcc/ada/layout.adb +++ b/gcc/ada/layout.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2003 Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2004 Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -1980,11 +1980,13 @@ package body Layout is else declare - EsizV : SO_Ref; - RM_SizV : Node_Id; - Dchoice : Node_Id; - Discrim : Node_Id; - Dtest : Node_Id; + EsizV : SO_Ref; + RM_SizV : Node_Id; + Dchoice : Node_Id; + Discrim : Node_Id; + Dtest : Node_Id; + D_List : List_Id; + D_Entity : Entity_Id; begin RM_Siz_Expr := Empty; @@ -2052,16 +2054,6 @@ package body Layout is -- Otherwise construct the appropriate test else - -- Discriminant to be tested - - Discrim := - Make_Selected_Component (Loc, - Prefix => - Make_Identifier (Loc, Chars => Vname), - Selector_Name => - New_Occurrence_Of - (Entity (Name (Vpart)), Loc)); - -- The test to be used in general is a call to the -- discriminant checking function. However, it is -- definitely worth special casing the very common @@ -2072,6 +2064,16 @@ package body Layout is if No (Next (Dchoice)) and then Nkind (Dchoice) /= N_Range then + -- Discriminant to be tested + + Discrim := + Make_Selected_Component (Loc, + Prefix => + Make_Identifier (Loc, Chars => Vname), + Selector_Name => + New_Occurrence_Of + (Entity (Name (Vpart)), Loc)); + Dtest := Make_Op_Eq (Loc, Left_Opnd => Discrim, @@ -2083,6 +2085,25 @@ package body Layout is -- False when the passed discriminant value matches. else + -- The checking function takes all of the type's + -- discriminants as parameters, so a list of all + -- the selected discriminants must be constructed. + + D_List := New_List; + D_Entity := First_Discriminant (E); + while Present (D_Entity) loop + Append ( + Make_Selected_Component (Loc, + Prefix => + Make_Identifier (Loc, Chars => Vname), + Selector_Name => + New_Occurrence_Of + (D_Entity, Loc)), + D_List); + + D_Entity := Next_Discriminant (D_Entity); + end loop; + Dtest := Make_Op_Not (Loc, Right_Opnd => @@ -2091,7 +2112,7 @@ package body Layout is New_Occurrence_Of (Dcheck_Function (Var), Loc), Parameter_Associations => - New_List (Discrim))); + D_List)); end if; RM_Siz_Expr := |