ada: Spurious error on nested call using the prefix notation
authorJavier Miranda <miranda@adacore.com>
Sat, 19 Nov 2022 19:46:31 +0000 (19:46 +0000)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 6 Dec 2022 13:58:49 +0000 (14:58 +0100)
gcc/ada/

* exp_ch6.adb
(Build_Static_Check_Helper_Call): Perform implicit type conversion
to ensure matching types and avoid reporting spurious errors.

gcc/ada/exp_ch6.adb

index 7555bf5..c026b63 100644 (file)
@@ -7552,9 +7552,10 @@ package body Exp_Ch6 is
 
             Remove_Side_Effects (A);
 
-            if Is_Controlling_Actual (A)
-              and then Etype (F) /= Etype (A)
-            then
+            --  Ensure matching types to avoid reporting spurious errors since
+            --  the called helper may have been built for a parent type.
+
+            if Etype (F) /= Etype (A) then
                Append_To (Actuals,
                  Unchecked_Convert_To (Etype (F), New_Copy_Tree (A)));
             else