This patch removes an incorrect predicate check applied to a view
conversion of a tagged object. Such a view conversion is an object
and can appear as the target of an assignment statement, in which
case no predicate check applies to the now-dead value.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* exp_ch4.adb (Expand_N_Type_Conversion): If the conversion is
the name of an assignment operation do not apply predicate check
to it prior to the assignment.
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -12748,7 +12748,16 @@ package body Exp_Ch4 is
-- guard is necessary to prevent infinite recursions when we generate
-- internal conversions for the purpose of checking predicates.
- if Predicate_Enabled (Target_Type)
+ -- A view conversion of a tagged object is an object and can appear
+ -- in an assignment context, in which case no predicate check applies
+ -- to the now-dead value.
+
+ if Nkind (Parent (N)) = N_Assignment_Statement
+ and then N = Name (Parent (N))
+ then
+ null;
+
+ elsif Predicate_Enabled (Target_Type)
and then Target_Type /= Operand_Type
and then Comes_From_Source (N)
then