]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Update -gnatwk error messages with Diagnostic_Id-s
authorViljar Indus <indus@adacore.com>
Wed, 3 Dec 2025 09:49:45 +0000 (11:49 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 9 Jan 2026 10:57:19 +0000 (11:57 +0100)
Add new entries to the Diagnostic_Id-s and entries to the diagnostic
repository for error messages that are activated by -gnatwk.

gcc/ada/ChangeLog:

* errid-diagnostic_repository.ads: Update the diagnostic repository.
* errid-switch_repository.ads: Update the switch repository.
* errid.ads: Add new Diagnostic_Id-s.
* sem_warn.adb (Check_References): Add Diagnostic_Id-s for
error messages triggered by -gnatwk.

gcc/ada/errid-diagnostic_repository.ads
gcc/ada/errid-switch_repository.ads
gcc/ada/errid.ads
gcc/ada/sem_warn.adb

index b81911211361c0e759a39ebe79c23a243421ae50..7b95400d0e42fb11259bc72548af6a4a975337bb 100644 (file)
@@ -82,5 +82,17 @@ package Errid.Diagnostic_Repository is
       GNAT0006         =>
         (Status   => Active,
          Human_Id => new String'("Mixed_Container_Aggregate_Error"),
-         Switch   => No_Switch_Id));
+         Switch   => No_Switch_Id),
+     GNAT0007         =>
+        (Status   => Active,
+         Human_Id => new String'("Volatile_Not_Modifed_Warning"),
+         Switch   => gnatwk),
+     GNAT0008         =>
+        (Status   => Active,
+         Human_Id => new String'("Variable_Not_Modifed_Warning"),
+         Switch   => gnatwk),
+     GNAT0009         =>
+        (Status   => Active,
+         Human_Id => new String'("In_Out_Not_Modifed_Warning"),
+         Switch   => gnatwk));
 end Errid.Diagnostic_Repository;
index 73e23588882fda1f45e600afac40bb5488187271..59e926294f82c531b24cb2ccff2348fc46ff4b2e 100644 (file)
@@ -120,7 +120,8 @@ package Errid.Switch_Repository is
          Short_Name        => new String'("gnatwk"),
          Description       => null,
          Documentation_Url => null,
-         Diagnostics       => null),
+         Diagnostics       =>
+           new Diagnostic_Id_Array'(GNAT0007, GNAT0008, GNAT0009)),
       gnatwl             =>
         (Human_Id          => new String'("Elab_Warnings"),
          Status            => Active,
index 312dd013a47fadb4fe83d14f33f523174a9ab048..eb67414e62c0921096d91aff9ed28813c2e30de2 100644 (file)
@@ -36,7 +36,10 @@ package Errid is
       GNAT0003,
       GNAT0004,
       GNAT0005,
-      GNAT0006);
+      GNAT0006,
+      GNAT0007,
+      GNAT0008,
+      GNAT0009);
 
    type Diagnostic_Id_Array is array (Positive range <>) of Diagnostic_Id;
    type Diagnostic_Id_Array_Access is access Diagnostic_Id_Array;
index d121e6985862af0aae11ece8bcd72946a9a730a5..9c7c59e8643a7f30f12286aa11b54c3d02ead405 100644 (file)
@@ -28,6 +28,7 @@ with Atree;          use Atree;
 with Debug;          use Debug;
 with Einfo.Entities; use Einfo.Entities;
 with Einfo.Utils;    use Einfo.Utils;
+with Errid;          use Errid;
 with Errout;         use Errout;
 with Exp_Code;       use Exp_Code;
 with Lib;            use Lib;
@@ -1310,7 +1311,9 @@ package body Sem_Warn is
                   then
                      Error_Msg_N
                        ("?k?& is not modified, consider pragma Export for "
-                        & "volatile variable!", E1);
+                        & "volatile variable!",
+                        E1,
+                        GNAT0007);
 
                   --  Another special case, Exception_Occurrence, this catches
                   --  the case of exception choice (and a bit more too, but not
@@ -1330,7 +1333,8 @@ package body Sem_Warn is
                   then
                      Error_Msg_N -- CODEFIX
                        ("?k?& is not modified, could be declared constant!",
-                        E1);
+                        E1,
+                        GNAT0008);
                   end if;
 
                --  Other cases of a variable or parameter never set in source
@@ -3102,7 +3106,9 @@ package body Sem_Warn is
                if not Is_Trivial_Subprogram (Scope (E1)) then
                   if Warn_On_Constant then
                      Error_Msg_N
-                       ("?k?formal parameter & is not modified!", E1);
+                       ("?k?formal parameter & is not modified!",
+                        E1,
+                        GNAT0009);
                      Error_Msg_N
                        ("\?k?mode could be IN instead of `IN OUT`!", E1);