* [COMMITTED] ada: Fix crash with -gnatdJ and -gnatyz
@ 2024-05-14 8:23 Marc Poulhiès
0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2024-05-14 8:23 UTC (permalink / raw)
To: gcc-patches; +Cc: Ronan Desplanques
From: Ronan Desplanques <desplanques@adacore.com>
This patch makes it so -gnatyz style checks reports specify a node
ID. That is required since those checks are sometimes made during
semantic analysis of short-circuit operators, where the Current_Node
mechanism that -gnatdJ uses is not operational.
Check_Xtra_Parens_Precedence is moved from Styleg to Style to make
this possible.
gcc/ada/
* styleg.ads (Check_Xtra_Parens_Precedence): Moved ...
* style.ads (Check_Xtra_Parens_Precedence): ... here. Also
replace corresponding renaming.
* styleg.adb (Check_Xtra_Parens_Precedence): Moved ...
* style.adb (Check_Xtra_Parens_Precedence): here. Also use
Errout.Error_Msg and pass it a node parameter.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/style.adb | 22 ++++++++++++++++++++++
gcc/ada/style.ads | 3 +--
gcc/ada/styleg.adb | 22 ----------------------
gcc/ada/styleg.ads | 4 ----
4 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/gcc/ada/style.adb b/gcc/ada/style.adb
index aaa668aab00..18b110b911d 100644
--- a/gcc/ada/style.adb
+++ b/gcc/ada/style.adb
@@ -337,6 +337,28 @@ package body Style is
end if;
end Check_Identifier;
+ ----------------------------------
+ -- Check_Xtra_Parens_Precedence --
+ ----------------------------------
+
+ procedure Check_Xtra_Parens_Precedence (N : Node_Id) is
+ begin
+ if Style_Check_Xtra_Parens_Precedence
+ and then
+ Paren_Count (N) >
+ (if Nkind (N) in N_Case_Expression
+ | N_Expression_With_Actions
+ | N_If_Expression
+ | N_Quantified_Expression
+ | N_Raise_Expression
+ then 1
+ else 0)
+ then
+ Error_Msg -- CODEFIX
+ ("(style) redundant parentheses?z?", First_Sloc (N), N);
+ end if;
+ end Check_Xtra_Parens_Precedence;
+
------------------------
-- Missing_Overriding --
------------------------
diff --git a/gcc/ada/style.ads b/gcc/ada/style.ads
index c0925e9ce34..9614242269c 100644
--- a/gcc/ada/style.ads
+++ b/gcc/ada/style.ads
@@ -196,8 +196,7 @@ package Style is
-- Called after scanning an entire expression (N) that does not require an
-- extra level of parentheses.
- procedure Check_Xtra_Parens_Precedence (N : Node_Id)
- renames Style_Inst.Check_Xtra_Parens_Precedence;
+ procedure Check_Xtra_Parens_Precedence (N : Node_Id);
-- Called after scanning a subexpression (N) that does not require an
-- extra level of parentheses according to operator precedence rules.
diff --git a/gcc/ada/styleg.adb b/gcc/ada/styleg.adb
index 287589f92da..c405dec2b33 100644
--- a/gcc/ada/styleg.adb
+++ b/gcc/ada/styleg.adb
@@ -1054,28 +1054,6 @@ package body Styleg is
end if;
end Check_Xtra_Parens;
- ----------------------------------
- -- Check_Xtra_Parens_Precedence --
- ----------------------------------
-
- procedure Check_Xtra_Parens_Precedence (N : Node_Id) is
- begin
- if Style_Check_Xtra_Parens_Precedence
- and then
- Paren_Count (N) >
- (if Nkind (N) in N_Case_Expression
- | N_Expression_With_Actions
- | N_If_Expression
- | N_Quantified_Expression
- | N_Raise_Expression
- then 1
- else 0)
- then
- Error_Msg -- CODEFIX
- ("(style) redundant parentheses?z?", Errout.First_Sloc (N));
- end if;
- end Check_Xtra_Parens_Precedence;
-
----------------------------
-- Determine_Token_Casing --
----------------------------
diff --git a/gcc/ada/styleg.ads b/gcc/ada/styleg.ads
index 9028e85cc4e..a16ea5c5961 100644
--- a/gcc/ada/styleg.ads
+++ b/gcc/ada/styleg.ads
@@ -160,10 +160,6 @@ package Styleg is
-- Called after scanning an entire expression (N) that does not require an
-- extra level of parentheses.
- procedure Check_Xtra_Parens_Precedence (N : Node_Id);
- -- Called after scanning a subexpression (N) that does not require an
- -- extra level of parentheses according to operator precedence rules.
-
function Mode_In_Check return Boolean;
pragma Inline (Mode_In_Check);
-- Determines whether style checking is active and the Mode_In_Check is
--
2.43.2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-05-14 8:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-14 8:23 [COMMITTED] ada: Fix crash with -gnatdJ and -gnatyz 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).