This patch fixes an error in the compiler whereby returning an anonymous
access discriminant of an anonymous access formal within a function that
returns an anonymous access type may cause a malformed accessibility
check to be generated.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

        * exp_ch4.adb (Expand_N_Type_Conversion): Use the unexpanded
        operand when generating accessibility checks.
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
@@ -12258,7 +12258,7 @@ package body Exp_Ch4 is
 
             else
                Apply_Accessibility_Check
-                 (Operand_Acc, Target_Type, Insert_Node => Operand);
+                 (Operand, Target_Type, Insert_Node => Operand);
             end if;
 
          --  If the level of the operand type is statically deeper than the


Reply via email to