public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Marc Poulhi?s <dkm@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-4232] ada: Adjust number of errors when removing warning in dead code
Date: Tue, 22 Nov 2022 12:36:04 +0000 (GMT)	[thread overview]
Message-ID: <20221122123604.BD54E3858422@sourceware.org> (raw)

https://gcc.gnu.org/g:29b7e00589f1c1c00029928ac1b7ba8ff53288f5

commit r13-4232-g29b7e00589f1c1c00029928ac1b7ba8ff53288f5
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Mon Nov 7 15:17:40 2022 +0100

    ada: Adjust number of errors when removing warning in dead code
    
    When a warning about a runtime exception is emitted for a code in
    generic instance, we add continuation warnings "in instantiation ..."
    and only the original message increase the total number of errors.
    
    When removing these messages, e.g. after detecting that the code inside
    generic instance is dead, we must decrease the total number of errors,
    as otherwise the compiler exit status might stop gnatmake or gprbuild.
    
    gcc/ada/
    
            * errout.adb (To_Be_Removed): Decrease total number of errors when
            removing a warning that has been escalated into error.
            * erroutc.adb (dmsg): Print Warn_Runtime_Raise flag.

Diff:
---
 gcc/ada/errout.adb  | 11 +++++++++++
 gcc/ada/erroutc.adb | 35 ++++++++++++++++++-----------------
 2 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
index afa30674fa3..b30e8b51d15 100644
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -3351,6 +3351,17 @@ package body Errout is
                   Warning_Info_Messages := Warning_Info_Messages - 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;
+
                return True;
 
             --  No removal required
diff --git a/gcc/ada/erroutc.adb b/gcc/ada/erroutc.adb
index 7766c972730..d40c668be8a 100644
--- a/gcc/ada/erroutc.adb
+++ b/gcc/ada/erroutc.adb
@@ -312,32 +312,33 @@ package body Erroutc is
 
    begin
       w ("Dumping error message, Id = ", Int (Id));
-      w ("  Text     = ", E.Text.all);
-      w ("  Next     = ", Int (E.Next));
-      w ("  Prev     = ", Int (E.Prev));
-      w ("  Sfile    = ", Int (E.Sfile));
+      w ("  Text               = ", E.Text.all);
+      w ("  Next               = ", Int (E.Next));
+      w ("  Prev               = ", Int (E.Prev));
+      w ("  Sfile              = ", Int (E.Sfile));
 
       Write_Str
-        ("  Sptr     = ");
+        ("  Sptr               = ");
       Write_Location (E.Sptr.Ptr);  --  ??? Do not write the full span for now
       Write_Eol;
 
       Write_Str
-        ("  Optr     = ");
+        ("  Optr               = ");
       Write_Location (E.Optr.Ptr);
       Write_Eol;
 
-      w ("  Line     = ", Int (E.Line));
-      w ("  Col      = ", Int (E.Col));
-      w ("  Warn     = ", E.Warn);
-      w ("  Warn_Err = ", E.Warn_Err);
-      w ("  Warn_Chr = '" & E.Warn_Chr & ''');
-      w ("  Style    = ", E.Style);
-      w ("  Serious  = ", E.Serious);
-      w ("  Uncond   = ", E.Uncond);
-      w ("  Msg_Cont = ", E.Msg_Cont);
-      w ("  Deleted  = ", E.Deleted);
-      w ("  Node     = ", Int (E.Node));
+      w ("  Line               = ", Int (E.Line));
+      w ("  Col                = ", Int (E.Col));
+      w ("  Warn               = ", E.Warn);
+      w ("  Warn_Err           = ", E.Warn_Err);
+      w ("  Warn_Runtime_Raise = ", E.Warn_Runtime_Raise);
+      w ("  Warn_Chr           = '" & E.Warn_Chr & ''');
+      w ("  Style              = ", E.Style);
+      w ("  Serious            = ", E.Serious);
+      w ("  Uncond             = ", E.Uncond);
+      w ("  Msg_Cont           = ", E.Msg_Cont);
+      w ("  Deleted            = ", E.Deleted);
+      w ("  Node               = ", Int (E.Node));
 
       Write_Eol;
    end dmsg;

                 reply	other threads:[~2022-11-22 12:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221122123604.BD54E3858422@sourceware.org \
    --to=dkm@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).