From: Denis Mazzucato <[email protected]>
This patch fixes the spurious error regarding assignment to limited types.
Inside record initialization, the assignment calling a constructor is actually
its initialization, and is considered legal.
gcc/ada/ChangeLog:
* sem_ch5.adb: Skip check for assignment that doesn't come from source.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_ch5.adb | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index 87e1b30369e..e6bba80c5f1 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -668,12 +668,13 @@ package body Sem_Ch5 is
-- Error of assigning to limited type. We do however allow this in
-- certain cases where the front end generates the assignments.
-- Comes_From_Source test is needed to allow compiler-generated
- -- streaming/put_image subprograms, which may ignore privacy.
+ -- constructor calls or streaming/put_image subprograms, which may
+ -- ignore privacy.
elsif Is_Limited_Type (T1)
and then not Assignment_OK (Lhs)
and then not Assignment_OK (Original_Node (Lhs))
- and then (Comes_From_Source (N) or Is_Immutably_Limited_Type (T1))
+ and then Comes_From_Source (N)
then
-- CPP constructors can only be called in declarations
--
2.51.0