From: Viljar Indus <in...@adacore.com>

The goal of this attribute is to raise a warning to an error when
the -gnatwE flag is used. This is similar to the existing warnings
as error behavior under the Warn_Err flag so it can be merged.

gcc/ada/ChangeLog:

        * errout.adb: Set Warn_Err as true if Is_Runtime_Error was
        set in the error message.
        * erroutc.adb: Remove instances of Warn_Runtime_Raise.
        * erroutc.ads: Likewise.
        * errutil.adb: Likewise.

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

---
 gcc/ada/errout.adb  | 31 ++++---------------------------
 gcc/ada/erroutc.adb |  1 -
 gcc/ada/erroutc.ads |  4 ----
 gcc/ada/errutil.adb |  1 -
 4 files changed, 4 insertions(+), 33 deletions(-)

diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index 644fd1fad37..8858df11737 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -1246,7 +1246,6 @@ package body Errout is
           Compile_Time_Pragma => Is_Compile_Time_Msg,
           Warn_Err            => False, -- reset below
           Warn_Chr            => Warning_Msg_Char,
-          Warn_Runtime_Raise  => Is_Runtime_Raise,
           Uncond              => Is_Unconditional_Msg,
           Msg_Cont            => Continuation,
           Deleted             => False,
@@ -1258,20 +1257,14 @@ package body Errout is
       Warn_Err :=
         Error_Msg_Kind in Warning | Style
         and then (Warning_Treated_As_Error (Msg_Buffer (1 .. Msglen))
-                  or else Warning_Treated_As_Error
-                            (Get_Warning_Tag (Cur_Msg)));
+                  or else Warning_Treated_As_Error (Get_Warning_Tag (Cur_Msg))
+                  or else Is_Runtime_Raise);
 
       --  Propagate Warn_Err to this message and preceding continuations.
-      --  Likewise, propagate Error_Msg_Kind and Is_Runtime_Raise, because the
-      --  current continued message could have been escalated from warning to
-      --  error.
 
       for J in reverse 1 .. Errors.Last loop
          Errors.Table (J).Warn_Err := Warn_Err;
 
-         Errors.Table (J).Kind := Error_Msg_Kind;
-         Errors.Table (J).Warn_Runtime_Raise := Is_Runtime_Raise;
-
          exit when not Errors.Table (J).Msg_Cont;
       end loop;
 
@@ -3587,28 +3580,13 @@ package body Errout is
                --  not remove style messages here. They are warning messages
                --  but not ones we want removed in this context.
 
-               and then (Errors.Table (E).Kind = Warning
-                           or else
-                         Errors.Table (E).Warn_Runtime_Raise)
+               and then Errors.Table (E).Kind = Warning
 
                --  Don't remove unconditional messages
 
                and then not Errors.Table (E).Uncond
             then
-               if Errors.Table (E).Kind = Warning then
-                  Warnings_Detected := Warnings_Detected - 1;
-               end if;
-
-               --  When warning about a runtime exception has been escalated
-               --  into error, the starting message has increased the total
-               --  errors counter, so here we decrease this counter.
-
-               if Errors.Table (E).Warn_Runtime_Raise
-                 and then not Errors.Table (E).Msg_Cont
-                 and then Warning_Mode = Treat_Run_Time_Warnings_As_Errors
-               then
-                  Total_Errors_Detected := Total_Errors_Detected - 1;
-               end if;
+               Warnings_Detected := Warnings_Detected - 1;
 
                return True;
 
@@ -4361,7 +4339,6 @@ package body Errout is
                   if Error_Msg_Kind = Warning
                     and then Warning_Mode = Treat_Run_Time_Warnings_As_Errors
                   then
-                     Error_Msg_Kind := Non_Serious_Error;
                      Is_Runtime_Raise := True;
                   end if;
 
diff --git a/gcc/ada/erroutc.adb b/gcc/ada/erroutc.adb
index c57205418de..9d22996204c 100644
--- a/gcc/ada/erroutc.adb
+++ b/gcc/ada/erroutc.adb
@@ -340,7 +340,6 @@ package body Erroutc is
       w ("  Col                = ", Int (E.Col));
       w ("  Kind               = ", E.Kind'Img);
       w ("  Warn_Err           = ", E.Warn_Err);
-      w ("  Warn_Runtime_Raise = ", E.Warn_Runtime_Raise);
       w ("  Warn_Chr           = '" & E.Warn_Chr & ''');
       w ("  Uncond             = ", E.Uncond);
       w ("  Msg_Cont           = ", E.Msg_Cont);
diff --git a/gcc/ada/erroutc.ads b/gcc/ada/erroutc.ads
index 9a70cfa6244..76cd0205fa8 100644
--- a/gcc/ada/erroutc.ads
+++ b/gcc/ada/erroutc.ads
@@ -228,10 +228,6 @@ package Erroutc is
       --  True if this is a warning message which is to be treated as an error
       --  as a result of a match with a Warning_As_Error pragma.
 
-      Warn_Runtime_Raise : Boolean;
-      --  True if this a warning about a constraint error that will be raised
-      --  at runtime.
-
       Warn_Chr : String (1 .. 2);
       --  See Warning_Msg_Char
 
diff --git a/gcc/ada/errutil.adb b/gcc/ada/errutil.adb
index 62cd8679cf1..1094e8ac317 100644
--- a/gcc/ada/errutil.adb
+++ b/gcc/ada/errutil.adb
@@ -211,7 +211,6 @@ package body Errutil is
             Col                 => Get_Column_Number (Sptr),
             Compile_Time_Pragma => Is_Compile_Time_Msg,
             Warn_Err            => Warning_Mode = Treat_As_Error,
-            Warn_Runtime_Raise  => Is_Runtime_Raise,
             Warn_Chr            => Warning_Msg_Char,
             Uncond              => Is_Unconditional_Msg,
             Msg_Cont            => Continuation,
-- 
2.43.0

Reply via email to