From: Denis Mazzucato Date: Mon, 17 Nov 2025 10:54:10 +0000 (+0100) Subject: ada: Fix spurious error during record initialization of limited types X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d05f050e4b26df2de315d5462072c3f9a1337e2b;p=thirdparty%2Fgcc.git 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 --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