[Ada] Remove misleading warning/suggestion in membership test
authorEd Schonberg <schonberg@adacore.com>
Mon, 22 Jul 2019 13:58:27 +0000 (13:58 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Mon, 22 Jul 2019 13:58:27 +0000 (13:58 +0000)
commitad277369b236a39fff13c87a51a8e67f7562a80a
treec1024ac2b531153bfb6a22989c8d9ff4e3dcfa63
parenta211917585ca978a84123c4c934f2f68bb545bcd
[Ada] Remove misleading warning/suggestion in membership test

This patch removes a warning on a membership test whose right operand is
given by a range. In many cases the check can be replaced by the use of
attribute 'Valid, but if the bounds of range are type conversion this
replacement would be invorrect and the warning and suggestion are
misleading.

2019-07-22  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* exp_ch4.adb (Expand_N_In): Do not suggest the use of attribute
'Valid as a replacement for a range check on a discrete type
when the bounds of the range are given by type conversions,
because in such a case there are distinct types involved and the
subbested attribute replacement would be misplaced.

gcc/testsuite/

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

From-SVN: r273694
gcc/ada/ChangeLog
gcc/ada/exp_ch4.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/warn26.adb [new file with mode: 0644]