public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Consistent suppression for warnings inside null loops
@ 2022-01-07 16:27 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-01-07 16:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

[-- Attachment #1: Type: text/plain, Size: 556 bytes --]

Warnings for nodes inside null loops were suppressed if posted with
Error_Msg_NLE and emitted if posted with other error-reporting routines.
This was inconsistent and error-prone.

Part of removing quotes around exception names in messages, because
messages without quotes will be now emitted by Error_Msg and not by
Error_Msg_NLE.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* errout.adb (Error_Msg): Move warning suppression code from
	Error_Msg_NLE
	(Error_Msg_NLE): Warning suppression is now done by the internal
	call to Error_Msg.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1771 bytes --]

diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -440,6 +440,28 @@ package body Errout is
         and then Warnings_Detected >= Maximum_Messages
       then
          return;
+
+      --  Suppress warnings inside a loop that is known to be null or is
+      --  probably null (i.e. when loop executes only if invalid values
+      --  present). In either case warnings in the loop are likely to be junk.
+
+      elsif Is_Warning_Msg and then Present (N) then
+
+         declare
+            P : Node_Id;
+
+         begin
+            P := Parent (N);
+            while Present (P) loop
+               if Nkind (P) = N_Loop_Statement
+                 and then Suppress_Loop_Warnings (P)
+               then
+                  return;
+               end if;
+
+               P := Parent (P);
+            end loop;
+         end;
       end if;
 
       --  The idea at this stage is that we have two kinds of messages
@@ -1490,26 +1512,6 @@ package body Errout is
             Last_Killed := True;
             return;
          end if;
-
-         --  Suppress if inside loop that is known to be null or is probably
-         --  null (case where loop executes only if invalid values present).
-         --  In either case warnings in the loop are likely to be junk.
-
-         declare
-            P : Node_Id;
-
-         begin
-            P := Parent (N);
-            while Present (P) loop
-               if Nkind (P) = N_Loop_Statement
-                 and then Suppress_Loop_Warnings (P)
-               then
-                  return;
-               end if;
-
-               P := Parent (P);
-            end loop;
-         end;
       end if;
 
       --  Test for message to be output



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-07 16:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07 16:27 [Ada] Consistent suppression for warnings inside null loops Pierre-Marie de Rodat

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).