From: Bob Duff Date: Tue, 20 Aug 2019 09:48:57 +0000 (+0000) Subject: [Ada] Object_Size clause specifying 0 bits is illegal X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=afdc759841f8f4f464f3d5a2ba8e05e9a8e41d72;p=gcc.git [Ada] Object_Size clause specifying 0 bits is illegal The patch gives an error message on "for T'Object_Size use 0;". 2019-08-20 Bob Duff gcc/ada/ * sem_ch13.adb (Object_Size): Give an error for zero. It really rubs me the wrong way that we don't honor "for T'Object_Size use 0;", but it's not important enough to fix. In any case, if we're not going to obey the clause, we should give an error. gcc/testsuite/ * gnat.dg/object_size1.adb: New testcase. From-SVN: r274722 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 558d5e072d2..61befab3f33 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2019-08-20 Bob Duff + + * sem_ch13.adb (Object_Size): Give an error for zero. It really + rubs me the wrong way that we don't honor "for T'Object_Size use + 0;", but it's not important enough to fix. In any case, if we're + not going to obey the clause, we should give an error. + 2019-08-20 Bob Duff * errout.adb (Error_Msg_Internal): Set Warn_Err in case of diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 4a07478757d..dec542b1d89 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e4cc820f0f7..89406642e92 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-08-20 Bob Duff + + * gnat.dg/object_size1.adb: New testcase. + 2019-08-20 Eric Botcazou * gcc.c-torture/execute/20190820-1.c: New test. diff --git a/gcc/testsuite/gnat.dg/object_size1.adb b/gcc/testsuite/gnat.dg/object_size1.adb new file mode 100644 index 00000000000..85c6962c565 --- /dev/null +++ b/gcc/testsuite/gnat.dg/object_size1.adb @@ -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;