[COMMITTED] ada: Fix handling of pragma Warnings (Toolname, Off/On)

Message ID 20230515094249.1407836-1-poulhies@adacore.com
State Accepted
Headers
Series [COMMITTED] ada: Fix handling of pragma Warnings (Toolname, Off/On) |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Marc Poulhiès May 15, 2023, 9:42 a.m. UTC
  From: Yannick Moy <moy@adacore.com>

Pragma Warnings On/Off with a preceding toolname (which could be GNAT
or GNATprove) was ignored due an error in accessing the expression of
a pragma association in the parser. Now fixed.

gcc/ada/

	* par-prag.adb (First_Arg_Is_Matching_Tool_Name): Fix access to
	expression in pragma association.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/par-prag.adb | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
  

Patch

diff --git a/gcc/ada/par-prag.adb b/gcc/ada/par-prag.adb
index 3a9764adec3..e78f97d11fb 100644
--- a/gcc/ada/par-prag.adb
+++ b/gcc/ada/par-prag.adb
@@ -1150,13 +1150,14 @@  begin
          -------------------------------------
 
          function First_Arg_Is_Matching_Tool_Name return Boolean is
+            Expr : constant Node_Id := Get_Pragma_Arg (Arg1);
          begin
-            return Nkind (Arg1) = N_Identifier
+            return Nkind (Expr) = N_Identifier
 
               --  Return True if the tool name is GNAT, and we're not in
               --  GNATprove or CodePeer mode...
 
-              and then ((Chars (Arg1) = Name_Gnat
+              and then ((Chars (Expr) = Name_Gnat
                           and then not
                             (CodePeer_Mode or GNATprove_Mode))
 
@@ -1164,7 +1165,7 @@  begin
               --  mode.
 
                         or else
-                        (Chars (Arg1) = Name_Gnatprove
+                        (Chars (Expr) = Name_Gnatprove
                           and then GNATprove_Mode));
          end First_Arg_Is_Matching_Tool_Name;
 
@@ -1189,7 +1190,7 @@  begin
          --------------
 
          function Last_Arg return Node_Id is
-               Last_Arg : Node_Id;
+            Last_Arg : Node_Id;
 
          begin
             if Arg_Count = 1 then