@@ -1154,6 +1154,7 @@ package body Trans.Chap3 is
11541154 El_Btype : Iir;
11551155
11561156 Has_New_Constraints : Boolean;
1157+ Has_Boxed_Elements : Boolean;
11571158
11581159 Rec : O_Element_List;
11591160 Field_Info : Ortho_Info_Acc;
@@ -1171,13 +1172,17 @@ package body Trans.Chap3 is
11711172 El_Tm_List := El_Blist;
11721173 end if ;
11731174 Has_New_Constraints := False;
1175+ Has_Boxed_Elements := False;
11741176 for I in Flist_First .. Flist_Last (El_List) loop
11751177 El := Get_Nth_Element (El_List, I);
11761178 El_Type := Get_Type (El);
11771179 if Is_Fully_Constrained_Type (El) then
11781180 El_Btype := Get_Type (Get_Nth_Element (El_Tm_List, I));
11791181 if not Is_Fully_Constrained_Type (El_Btype) then
11801182 Has_New_Constraints := True;
1183+ if Get_Type_Staticness (El_Type) = Locally then
1184+ Has_Boxed_Elements := True;
1185+ end if ;
11811186 Push_Identifier_Prefix (Mark, Get_Identifier (El));
11821187 Translate_Type_Definition (El_Type);
11831188 Pop_Identifier_Prefix (Mark);
@@ -1195,7 +1200,7 @@ package body Trans.Chap3 is
11951200 or else not Has_New_Constraints
11961201 then
11971202 -- The subtype is not completly constrained: it cannot be used to
1198- -- create objects, so wait until it is compltely constrained.
1203+ -- create objects, so wait until it is completly constrained.
11991204 -- The subtype is simply an alias.
12001205 -- In both cases, use the same representation as its type mark.
12011206 return ;
@@ -1209,37 +1214,43 @@ package body Trans.Chap3 is
12091214
12101215 -- Then create the record type, containing the base record and the
12111216 -- fields.
1212- Info.Ortho_Type (Mode_Signal) := O_Tnode_Null;
1213- for Kind in Mode_Value .. Type_To_Last_Object_Kind (Def) loop
1214- Start_Record_Type (Rec);
1215- New_Record_Field (Rec, Info.S.Box_Field (Kind), Wki_Base,
1216- Info.B.Base_Type (Kind));
1217- for I in Flist_First .. Flist_Last (El_Blist) loop
1218- B_El := Get_Nth_Element (El_Blist, I);
1219- El := Get_Nth_Element (El_List, I);
1220-
1221- -- This element has been locally constrained.
1222- if Is_Unbounded_Type (Get_Info (Get_Type (B_El)))
1223- and then
1224- Get_Type_Staticness (Get_Type(El)) = Locally
1225- then
1226- if Kind = Mode_Value then
1227- Field_Info := Add_Info (El, Kind_Field);
1228- else
1229- Field_Info := Get_Info (El);
1230- end if ;
1217+ if Has_Boxed_Elements then
1218+ Info.Ortho_Type (Mode_Signal) := O_Tnode_Null;
1219+ for Kind in Mode_Value .. Type_To_Last_Object_Kind (Def) loop
1220+ Start_Record_Type (Rec);
1221+ New_Record_Field (Rec, Info.S.Box_Field (Kind), Wki_Base,
1222+ Info.B.Base_Type (Kind));
1223+ for I in Flist_First .. Flist_Last (El_Blist) loop
1224+ B_El := Get_Nth_Element (El_Blist, I);
12311225 El := Get_Nth_Element (El_List, I);
1232- El_Tinfo := Get_Info (Get_Type (El));
1233- El_Tnode := El_Tinfo.Ortho_Type (Kind);
1234- New_Record_Field (Rec, Field_Info.Field_Node (Kind),
1235- Create_Identifier_Without_Prefix (El),
1236- El_Tnode);
1237- end if ;
1226+
1227+ -- This element has been locally constrained.
1228+ if Is_Unbounded_Type (Get_Info (Get_Type (B_El)))
1229+ and then Get_Type_Staticness (Get_Type(El)) = Locally
1230+ then
1231+ if Kind = Mode_Value then
1232+ Field_Info := Add_Info (El, Kind_Field);
1233+ else
1234+ Field_Info := Get_Info (El);
1235+ end if ;
1236+ El := Get_Nth_Element (El_List, I);
1237+ El_Tinfo := Get_Info (Get_Type (El));
1238+ El_Tnode := El_Tinfo.Ortho_Type (Kind);
1239+ New_Record_Field (Rec, Field_Info.Field_Node (Kind),
1240+ Create_Identifier_Without_Prefix (El),
1241+ El_Tnode);
1242+ end if ;
1243+ end loop ;
1244+ Finish_Record_Type (Rec, Info.Ortho_Type (Kind));
12381245 end loop ;
1239- Finish_Record_Type (Rec, Info.Ortho_Type (Kind));
1240- end loop ;
12411246
1242- Finish_Type_Definition (Info);
1247+ Finish_Type_Definition (Info);
1248+ else
1249+ -- This is a complex type as the size is not known at compile
1250+ -- time.
1251+ Info.Ortho_Type := Base_Info.B.Base_Type;
1252+ Info.Ortho_Ptr_Type := Base_Info.B.Base_Ptr_Type;
1253+ end if ;
12431254
12441255 if Get_Type_Staticness (Def) /= Locally then
12451256 Create_Size_Var (Def, Info);
0 commit comments