]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix crash with -gnatdJ and -gnatyz
authorRonan Desplanques <desplanques@adacore.com>
Wed, 14 Feb 2024 14:12:15 +0000 (15:12 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 14 May 2024 08:19:57 +0000 (10:19 +0200)
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.

gcc/ada/style.adb
gcc/ada/style.ads
gcc/ada/styleg.adb
gcc/ada/styleg.ads

index aaa668aab00050c9c5504997692596c02e59acd8..18b110b911d31c64af36f88bb5d7aef0c0be3153 100644 (file)
@@ -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 --
    ------------------------
index c0925e9ce3458b6f5c4f3e143c2d3008a7b382b0..9614242269cd813b500490932b03a7efbd2c26f6 100644 (file)
@@ -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.
 
index 287589f92da732f9895eb3549ac16283ca80dcdf..c405dec2b33251266b45d3b4e89b325e0c6344e3 100644 (file)
@@ -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 --
    ----------------------------
index 9028e85cc4ea18c52a08c0c6a0c03f14f9240044..a16ea5c596107d2950b5811d9b81945f35487931 100644 (file)
@@ -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