Skip to content

Commit a23be29

Browse files
committed
Implement checking the component size
Only check that the specified size matches the subtype width. Report otherwise.
1 parent 305497c commit a23be29

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

gnat2goto/driver/tree_walk.adb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4605,9 +4605,32 @@ package body Tree_Walk is
46054605
UI_From_Int (Int (Get_Width (Target_Type_Irep)))
46064606
and Entity_Esize = Expression_Value);
46074607
return;
4608+
elsif Attr_Id = "component_size" then
4609+
if not Is_Array_Type (Entity (N)) then
4610+
Report_Unhandled_Node_Empty (N, "Process_Declaration",
4611+
"Component size only supported for array types");
46084612
return;
46094613
end if;
4614+
declare
4615+
Array_Data : constant Irep :=
4616+
Get_Data_Component_From_Type (Target_Type_Irep);
4617+
Target_Subtype : constant Irep :=
4618+
Follow_Symbol_Type (Get_Subtype (Get_Type (Array_Data)),
4619+
Global_Symbol_Table);
4620+
Target_Subtype_Width : constant Uint :=
4621+
UI_From_Int (Int (Get_Width (Target_Subtype)));
4622+
begin
4623+
if Component_Size (Entity (N)) /= Expression_Value or
4624+
Target_Subtype_Width /= Expression_Value
4625+
then
4626+
Report_Unhandled_Node_Empty (N, "Process_Declaration",
4627+
"Having component sizes be different from the size of " &
4628+
"their underlying type is currently not supported");
4629+
end if;
4630+
end;
4631+
return;
46104632
end if;
4633+
46114634
Report_Unhandled_Node_Empty (N, "Process_Declaration",
46124635
"Representation clause unsupported: " & Attr_Id);
46134636
end Handle_Representation_Clause;

0 commit comments

Comments
 (0)