]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Improper predicate check on view conversion
authorEd Schonberg <schonberg@adacore.com>
Wed, 5 May 2021 12:50:23 +0000 (08:50 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 6 Jul 2021 14:46:53 +0000 (14:46 +0000)
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.

gcc/ada/exp_ch4.adb

index d608a30a6912036afac1cec756c2b2f982ab39f7..21b2c2225eb5bddef0ff163067e96ff424dd4b14 100644 (file)
@@ -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