https://gcc.gnu.org/g:d05f050e4b26df2de315d5462072c3f9a1337e2b

commit r16-5662-gd05f050e4b26df2de315d5462072c3f9a1337e2b
Author: Denis Mazzucato <[email protected]>
Date:   Mon Nov 17 11:54:10 2025 +0100

    ada: Fix spurious error during record initialization of limited types
    
    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.

Diff:
---
 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 87e1b30369ea..e6bba80c5f19 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

Reply via email to