[Ada] Missing error on tagged type conversion
authorJavier Miranda <miranda@adacore.com>
Tue, 10 May 2022 17:18:30 +0000 (17:18 +0000)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 6 Jul 2022 13:29:48 +0000 (13:29 +0000)
commit28add0a4c82f52631b434e1e126588cd3f5b7782
tree14d8b2b51395764b1b4b49d1f482964db375eebd
parent3202e9f88fd286a8fc4814abeaa2238d70f4d585
[Ada] Missing error on tagged type conversion

The compiler does not report an error on a type conversion to/from a
tagged type whose parent type is an interface type and there is no
relationship between the source and target types. This bug has been
dormant since January/2016.

This patch also improves the text of errors reported on interface type
conversions suggesting how to fix these errors.

gcc/ada/

* sem_res.adb (Resolve_Type_Conversion): Code cleanup since the
previous static check has been moved to Valid_Tagged_Conversion.
(Valid_Tagged_Conversion): Fix the code checking conversion
to/from interface types since incorrectly returns True when the
parent type of the operand type (or the target type) is an
interface type; add missing static checks on interface type
conversions.
gcc/ada/sem_res.adb