]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Support qualified error names from Standard
authorViljar Indus <indus@adacore.com>
Wed, 8 Apr 2026 11:32:40 +0000 (14:32 +0300)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 2 Jun 2026 08:42:25 +0000 (10:42 +0200)
Typically nodes from Standard were not printed without the
fully qualified prefix names even when Error_Msg_Qual_Level was set.
However in some cases it makes sense to emphasize that the variable
is coming from Standard.

Add a new variable called Error_Msg_Qual_For_Standard to enable
qualified names for entities coming from Standard.

gcc/ada/ChangeLog:

* err_vars.ads (Error_Msg_Qual_For_Standard): New Variable.
* errout.ads (Error_Msg_Qual_For_Standard): Likewise.
* errout.adb (Set_Qualification): Print all qualified names
when Error_Msg_Qual_For_Standard is set.
* sem_util.adb (Normalize_Actuals): Improve error message.

gcc/ada/err_vars.ads
gcc/ada/errout.adb
gcc/ada/errout.ads
gcc/ada/sem_util.adb

index 45ff26a4d56956f23c490559147fa8b57f06358e..179c65a84cf79baf28754c4cd5b08766eabc2c3a 100644 (file)
@@ -55,6 +55,13 @@ package Err_Vars is
    --  not get reset by any Error_Msg call, so the caller is responsible
    --  for resetting it.
 
+   Error_Msg_Qual_For_Standard : Boolean := False;
+   --  Typically we do not want to specify the Standard package when presenting
+   --  entity names even when Error_Msg_Qual_Level is not zero. However
+   --  sometimes we want to emphasize the fact that it is the entity from
+   --  standard. Note that this value does not get reset by any Error_Msg call,
+   --  so the caller is responsible for resetting it.
+
    Current_Error_Source_File : Source_File_Index := No_Source_File;
    --  Id of current messages. Used to post file name when unit changes. This
    --  is initialized to Main_Source_File at the start of a compilation, which
index ab5aaf0b7374ac1a471bd4bff34492d383a4d50f..2c427b7515ed8e1ce2b19e50b1961d685b766190 100644 (file)
@@ -4129,7 +4129,10 @@ package body Errout is
 
    procedure Set_Qualification (N : Nat; E : Entity_Id) is
    begin
-      if N /= 0 and then Scope (E) /= Standard_Standard then
+      if N /= 0
+        and then
+          (Scope (E) /= Standard_Standard or else Error_Msg_Qual_For_Standard)
+      then
          Set_Qualification (N - 1, Scope (E));
          Set_Msg_Node (Scope (E));
          Set_Msg_Char ('.');
index be828d55c6972861fa49e6dd6dbe7dabc287c337..a9756f6b0891eb45342ed54e576dd0d95c577624 100644 (file)
@@ -483,6 +483,9 @@ package Errout is
    --  not get reset by any Error_Msg call, so the caller is responsible
    --  for resetting it.
 
+   Error_Msg_Qual_For_Standard : Boolean renames
+     Err_Vars.Error_Msg_Qual_For_Standard;
+
    Error_Msg_Warn : Boolean renames Err_Vars.Error_Msg_Warn;
    --  Used if current message contains a < insertion character to indicate
    --  if the current message is a warning message. Must be set appropriately
index 1745accfe5983dbdb3f495e77d292ccd522e1f99..5698b2f0fefa8d1dfc65efefea43d9e70c3e5ebf 100644 (file)
@@ -25986,10 +25986,12 @@ package body Sem_Util is
                   if Present (Homonym (S))
                     and then Sloc (Homonym (S)) = Standard_Location
                   then
+                     Error_Msg_Qual_For_Standard := True;
+                     Error_Msg_Qual_Level := 1;
                      Error_Msg_NE
-                       ("\\did you mean & in Standard'?",
-                        Name (N),
-                        Homonym (S));
+                       ("\\did you mean &'?", Name (N), Homonym (S));
+                     Error_Msg_Qual_For_Standard := False;
+                     Error_Msg_Qual_Level := 0;
                   end if;
                else
                   Error_Msg_N ("too many arguments in call to&", Name (N));