[Ada] Warn on Unchecked_Conversion to zero-sized array
authorBob Duff <duff@adacore.com>
Tue, 20 Aug 2019 09:49:12 +0000 (09:49 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 20 Aug 2019 09:49:12 +0000 (09:49 +0000)
commitd21ae867a5a83c7c5dd11a2e51d0c4b2ff9e41b8
tree5b8faed21ae8afa0d01919098dd50a21ea2cb429
parentcbdb0df117deb12a8e7d63e1cf2b53415b8e92e2
[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.

From-SVN: r274725
gcc/ada/ChangeLog
gcc/ada/sem_ch13.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/unchecked_convert14.adb [new file with mode: 0644]