diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2021-12-13 14:07:42 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2022-01-07 16:24:08 +0000 |
commit | c8e99971b643c1b0610175bba047cd789c571c74 (patch) | |
tree | 75d8c05194a7c9f636f5e1850e5b2154fffa74ca | |
parent | e8a52167ea10797308ecc0497127ba0ce44b707b (diff) | |
download | gcc-c8e99971b643c1b0610175bba047cd789c571c74.zip gcc-c8e99971b643c1b0610175bba047cd789c571c74.tar.gz gcc-c8e99971b643c1b0610175bba047cd789c571c74.tar.bz2 |
[Ada] Consistent suppression for warnings inside null loops
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.
-rw-r--r-- | gcc/ada/errout.adb | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index 8ae6f17..66ff1d2 100644 --- 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 |