* [COMMITTED] ada: Spurious warning about negative modular literal
@ 2023-09-05 11:08 Marc Poulhiès
0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-09-05 11:08 UTC (permalink / raw)
To: gcc-patches; +Cc: Steve Baird
From: Steve Baird <baird@adacore.com>
If -gnatw.m is enabled, the compiler generates a warning if a unary
minus operator of a modular type is applied to an integer literal.
This warning was being incorrectly generated in some cases where no integer
literal is present in the source code.
gcc/ada/
* sem_res.adb (Resolve_Unary_Op): In deciding whether to emit a
warning about a modular type's unary minus operator being applied
to an integer literal, ignore integer literals for which
Comes_From_Source is False.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_res.adb | 1 +
1 file changed, 1 insertion(+)
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 9755e4d14a6..c708d04fc32 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -12671,6 +12671,7 @@ package body Sem_Res is
if Warn_On_Suspicious_Modulus_Value
and then Nkind (N) = N_Op_Minus
and then Nkind (R) = N_Integer_Literal
+ and then Comes_From_Source (R)
and then Is_Modular_Integer_Type (B_Typ)
and then Nkind (Parent (N)) not in N_Qualified_Expression
| N_Type_Conversion
--
2.40.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-09-05 11:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-05 11:08 [COMMITTED] ada: Spurious warning about negative modular literal Marc Poulhiès
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).