@@ -5812,6 +5812,9 @@ package body Sem_Ch13 is
if ASIS_Mode then
null;
+ elsif Size <= 0 then
+ Error_Msg_N ("Object_Size must be positive", Expr);
+
elsif Is_Scalar_Type (U_Ent) then
if Size /= 8 and then Size /= 16 and then Size /= 32
and then UI_Mod (Size, 64) /= 0
new file mode 100644
@@ -0,0 +1,13 @@
+-- { dg-do compile }
+
+with Text_IO; use Text_IO;
+
+procedure Object_Size1 is
+ type Zero_Size_Type is (Solo);
+
+ for Zero_Size_Type'Size use 0;
+ for Zero_Size_Type'Object_Size use 0; -- { dg-error "Object_Size must be positive" }
+begin
+ Put_Line (Zero_Size_Type'Size'Image);
+ Put_Line (Zero_Size_Type'Object_Size'Image);
+end Object_Size1;