From: Viljar Indus <[email protected]>
Expanding a function call that returns a controlled type
on the left-hand side of an assignment should be avoided.
Otherwise we will miss the diagnostic for
trying to assign something to a non-variable element.
gcc/ada/ChangeLog:
* exp_ch6.adb (Expand_Ctrl_Function_Call): Avoid expansion
of controlled types when the LHS is a function call.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/exp_ch6.adb | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index 7010256b1a9..7839b671632 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -5356,6 +5356,13 @@ package body Exp_Ch6 is
return;
end if;
+ -- Avoid expansions to catch an error when the function call is on the
+ -- left-hand side of an assignment.
+
+ if Nkind (Par) = N_Assignment_Statement and then N = Name (Par) then
+ return;
+ end if;
+
-- Resolution is now finished, make sure we don't start analysis again
-- because of the duplication.
--
2.43.0