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]

PR java/40867 [4.5 Regression] FAIL: StackTrace2 output - source compiled test


It turns out that the Java FE was never properly converted to using
EXPR_LOCATIONs.  This results in all manner of weird results when
debugging, and caused this test failure.  Another five gold stars
for the regression test suite, I think!

Thanks to Richard Guenther for starting me on the right track.

Andrew.


2009-07-31  Andrew Haley  <aph@redhat.com>

	PR java/40867
	* decl.c (java_replace_references): Set EXPR_LOCATION on all
	generated expressions.
	(binding_level.loc): new field.
	(clear_binding_level): Initialize loc.
	(set_input_location): New function.
	(pushlevel): Set new binding_level.loc.
	(poplevel): Set EXPR_LOCATION on the new BIND_EXPR_BODY.
	(start_java_method): Set DECL_SOURCE_LOCATION of this new method.
	(java_add_stmt): Set the EXPR_LOCATION on all subtrees of new_stmt.


Index: decl.c
===================================================================
--- decl.c	(revision 149752)
+++ decl.c	(working copy)
@@ -349,6 +349,7 @@
 {
   if (TREE_CODE (*tp) == MODIFY_EXPR)
     {
+      source_location loc = EXPR_LOCATION (*tp);
       tree lhs = TREE_OPERAND (*tp, 0);
       /* This is specific to the bytecode compiler.  If a variable has
 	 LOCAL_SLOT_P set, replace an assignment to it with an assignment
@@ -361,9 +362,12 @@
 	  tree new_lhs = java_replace_reference (lhs, /* want_lvalue */ true);
 	  tree new_rhs = build1 (NOP_EXPR, TREE_TYPE (new_lhs),
 				 TREE_OPERAND (*tp, 1));
-	  *tp = build2 (MODIFY_EXPR, TREE_TYPE (new_lhs),
-			new_lhs, new_rhs);
-	  *tp = build1 (NOP_EXPR, TREE_TYPE (lhs), *tp);
+	  tree tem = build2 (MODIFY_EXPR, TREE_TYPE (new_lhs),
+			     new_lhs, new_rhs);
+	  *tp = build1 (NOP_EXPR, TREE_TYPE (lhs), tem);
+	  SET_EXPR_LOCATION (tem, loc);
+	  SET_EXPR_LOCATION (new_rhs, loc);
+	  SET_EXPR_LOCATION (*tp, loc);
 	}
     }
   if (TREE_CODE (*tp) == VAR_DECL)
@@ -418,6 +422,9 @@

     /* Binding depth at which this level began.  Used only for debugging.  */
     unsigned binding_depth;
+
+    /* The location at which this level began.  */
+    source_location loc;
   };

 #define NULL_BINDING_LEVEL (struct binding_level *) NULL
@@ -458,10 +465,11 @@
     NULL, /* stmts */
     NULL, /* exception_range */
     0, /* binding_depth */
+    0, /* loc */
   };

 tree java_global_trees[JTI_MAX];
-
+
 /* Build (and pushdecl) a "promoted type" for all standard
    types shorter than int.  */

@@ -1394,7 +1402,8 @@

   *newlevel = clear_binding_level;
   newlevel->level_chain = current_binding_level;
-  current_binding_level = newlevel;
+  newlevel->loc = input_location;
+  current_binding_level = newlevel;
 #if defined(DEBUG_JAVA_BINDING_LEVELS)
   newlevel->binding_depth = binding_depth;
   indent ();
@@ -1509,6 +1518,8 @@
 	  if (BIND_EXPR_BODY (bind) == NULL)
 	    BIND_EXPR_BODY (bind) = build_java_empty_stmt ();

+	  SET_EXPR_LOCATION (bind, current_binding_level->loc);
+
 	  current_binding_level->stmts = NULL;
 	}
       else
@@ -1876,6 +1887,7 @@
     type_map[i++] = NULL_TREE;

   build_result_decl (fndecl);
+  DECL_SOURCE_LOCATION (fndecl) = input_location;

   /* Push local variables.  */
   pushlevel (2);
@@ -2037,6 +2049,26 @@
     return stmt;
 }

+/* If this node is an expr, mark its input location.  Called from
+   walk_tree().  */
+
+static tree
+set_input_location (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
+		    void *data ATTRIBUTE_UNUSED)
+{
+  tree t = *tp;
+
+  if (CAN_HAVE_LOCATION_P (t))
+    {
+      if (EXPR_HAS_LOCATION(t))
+	return t;  /* Don't walk any further into this expr.   */
+      else
+	SET_EXPR_LOCATION (t, input_location);
+    }
+
+  return NULL_TREE;  /* Continue walking this expr.   */
+}
+
 /* Add a statement to the statement_list currently being constructed.
    If the statement_list is null, we don't create a singleton list.
    This is necessary because poplevel() assumes that adding a
@@ -2049,8 +2081,8 @@
   tree_stmt_iterator i;

   if (input_filename)
-    SET_EXPR_LOCATION (new_stmt, input_location);
-
+    walk_tree (&new_stmt, set_input_location, NULL, NULL);
+
   if (stmts == NULL)
     return current_binding_level->stmts = new_stmt;


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