]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix spurious error during record initialization of limited types
authorDenis Mazzucato <mazzucato@adacore.com>
Mon, 17 Nov 2025 10:54:10 +0000 (11:54 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 27 Nov 2025 12:57:44 +0000 (13:57 +0100)
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.

gcc/ada/sem_ch5.adb

index 87e1b30369ea6c65e4cfff1b59fc23ff28e36316..e6bba80c5f1938c48e59056773b6d9009a38b330 100644 (file)
@@ -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