[Ada] Do not set Current_Error_Node to a node without location

Message ID 20220519141626.GA3723539@adacore.com
State Committed
Commit b64c4968c7f3eb4c5ac0c56e6f11b10419dacd0c
Headers
Series [Ada] Do not set Current_Error_Node to a node without location |

Commit Message

Pierre-Marie de Rodat May 19, 2022, 2:16 p.m. UTC
  The message "No source file position information available" is displayed
in the bugbox when Current_Error_Node has no location, which is useless.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* gcc-interface/trans.cc (gnat_to_gnu): Do not set Current_Error_Node
	to a node without location.
  

Patch

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -6139,7 +6139,8 @@  gnat_to_gnu (Node_Id gnat_node)
   bool aa_sync;
 
   /* Save node number for error message and set location information.  */
-  Current_Error_Node = gnat_node;
+  if (Sloc (gnat_node) > No_Location)
+    Current_Error_Node = gnat_node;
   Sloc_to_locus (Sloc (gnat_node), &input_location);
 
   /* If we are only annotating types and this node is a statement, return