]> git.ipfire.org Git - thirdparty/gcc.git/commit
[Ada] Warn on Unchecked_Conversion to zero-sized array
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Aug 2019 09:49:12 +0000 (09:49 +0000)
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Aug 2019 09:49:12 +0000 (09:49 +0000)
commit5814355aa319bf588cbeb8bcd4b2d06ea23f1839
tree5b8faed21ae8afa0d01919098dd50a21ea2cb429
parent2d7d0768008a87291f0171c953b36894e079e971
[Ada] Warn on Unchecked_Conversion to zero-sized array

The compiler usually warns on Unchecked_Conversion between types with
mismatched sizes. This warning is now extended to the case where the
target type is a zero-sized array.

2019-08-20  Bob Duff  <duff@adacore.com>

gcc/ada/

* sem_ch13.adb (Is_Null_Array): New function, used to detect the
null array case; used to warn about uncheckedly converting to a
zero-sized array.  It is unfortunate that we can't just check
the size, and warn on all cases of converting from a
nonzero-sized type to a zero-sized one. That's because "0" means
two different things: "size is zero" and "size is unknown".
Until we fix that design flaw, we need this more targeted fix.

gcc/testsuite/

* gnat.dg/unchecked_convert14.adb: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@274725 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ada/ChangeLog
gcc/ada/sem_ch13.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/unchecked_convert14.adb [new file with mode: 0644]