This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Fix source location info on loop


We were giving the source location info of the entry to the goto statement in 
a loop, which can confuse the debugger in some cases.

Fixed thusly, tested on i586-suse-linux, applied on the mainline.


2008-03-08  Eric Botcazou  <ebotcazou@adacore.com>

	* trans.c (Loop_Statement_to_gnu): Set the SLOC of the loop label
	from that of the front-end's end label.
	(gnat_gimplify_stmt) <LOOP_STMT>: Set the SLOC of the backward goto
	from that of the loop label.


-- 
Eric Botcazou
Index: trans.c
===================================================================
RCS file: /gnat.dev/cvs/Dev/gnat/trans.c,v
retrieving revision 1.68.2.243
retrieving revision 1.68.2.244
diff -u -r1.68.2.243 -r1.68.2.244
--- trans.c	31 Jan 2008 22:37:11 -0000	1.68.2.243
+++ trans.c	31 Jan 2008 23:37:43 -0000	1.68.2.244
@@ -1587,6 +1587,8 @@
   TREE_SIDE_EFFECTS (gnu_loop_stmt) = 1;
   LOOP_STMT_LABEL (gnu_loop_stmt) = create_artificial_label ();
   set_expr_location_from_node (gnu_loop_stmt, gnat_node);
+  Sloc_to_locus (Sloc (End_Label (gnat_node)),
+		 &DECL_SOURCE_LOCATION (LOOP_STMT_LABEL (gnu_loop_stmt)));
 
   /* Save the end label of this LOOP_STMT in a stack so that the corresponding
      N_Exit_Statement can find it.  */
@@ -5344,6 +5346,7 @@
       {
 	tree gnu_start_label = create_artificial_label ();
 	tree gnu_end_label = LOOP_STMT_LABEL (stmt);
+	tree t;
 
 	/* Set to emit the statements of the loop.  */
 	*stmt_p = NULL_TREE;
@@ -5380,9 +5383,10 @@
 	if (LOOP_STMT_UPDATE (stmt))
 	  append_to_statement_list (LOOP_STMT_UPDATE (stmt), stmt_p);
 
-	append_to_statement_list (build1 (GOTO_EXPR, void_type_node,
-					  gnu_start_label),
-				  stmt_p);
+	t = build1 (GOTO_EXPR, void_type_node, gnu_start_label);
+	set_expr_location (t, DECL_SOURCE_LOCATION (gnu_end_label));
+	append_to_statement_list (t, stmt_p);
+
 	append_to_statement_list (build1 (LABEL_EXPR, void_type_node,
 					  gnu_end_label),
 				  stmt_p);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]