From: Eric Botcazou <[email protected]>

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.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_res.adb | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 5b90d4ee7a1..afe82549995 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -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);
-- 
2.53.0

Reply via email to