From: Ed Schonberg Date: Wed, 5 May 2021 12:50:23 +0000 (-0400) Subject: [Ada] Improper predicate check on view conversion X-Git-Tag: basepoints/gcc-13~6254 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f55784f8adc6033639840c609329d7b1facb2e71;p=thirdparty%2Fgcc.git [Ada] Improper predicate check on view conversion 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 index d608a30a6912..21b2c2225eb5 100644 --- 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