]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Small tweak to error message for premature freezing of deferred constant
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 15 Jan 2026 23:31:16 +0000 (00:31 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 25 May 2026 08:28:10 +0000 (10:28 +0200)
The tweak is to add the name of the constant to the error message.  That's
a minor improvement in this simple case, but it will help for the same error
in a more complex case.

gcc/ada/ChangeLog:

* sem_res.adb (Resolve_Entity_Name): Add the name of the constant
to the error message for premature freezing of deferred constants.

gcc/ada/sem_res.adb

index 5b90d4ee7a145e4a061694aa5045e70dc73df87b..afe82549995d34357d495c2adaeb19616740676b 100644 (file)
@@ -8156,16 +8156,12 @@ package body Sem_Res is
            and then not Is_Imported (E)
            and then Nkind (Parent (E)) /= N_Object_Renaming_Declaration
            and then not Needs_Construction (Etype (E))
+           and then not No_Initialization (Parent (E))
+           and then not (Present (Full_View (E))
+                          and then No_Initialization (Parent (Full_View (E))))
          then
-            if No_Initialization (Parent (E))
-              or else (Present (Full_View (E))
-                        and then No_Initialization (Parent (Full_View (E))))
-            then
-               null;
-            else
-               Error_Msg_N
-                 ("deferred constant is frozen before completion", N);
-            end if;
+            Error_Msg_NE
+              ("deferred constant& is frozen before completion", N, E);
          end if;
 
          Eval_Entity_Name (N);