Commit 239bca9d by Andrew Haley Committed by Andrew Haley

re PR middle-end/40867 (FAIL: StackTrace2 output - source compiled test)

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.

From-SVN: r150376
parent 267bd2b1
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.
2009-07-17 Richard Guenther <rguenther@suse.de>
PR c/40401
......
......@@ -349,6 +349,7 @@ java_replace_references (tree *tp, int *walk_subtrees,
{
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 @@ java_replace_references (tree *tp, int *walk_subtrees,
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 @@ struct GTY(())
/* 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 @@ static const struct binding_level clear_binding_level
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 @@ pushlevel (int unused ATTRIBUTE_UNUSED)
*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 @@ poplevel (int keep, int reverse, int functionbody)
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 @@ start_java_method (tree fndecl)
type_map[i++] = NULL_TREE;
build_result_decl (fndecl);
DECL_SOURCE_LOCATION (fndecl) = input_location;
/* Push local variables. */
pushlevel (2);
......@@ -2037,6 +2049,26 @@ add_stmt_to_compound (tree existing, tree type, tree stmt)
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 @@ java_add_stmt (tree new_stmt)
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment