diff options
author | Andrew Haley <aph@redhat.com> | 2009-08-03 17:55:11 +0000 |
---|---|---|
committer | Andrew Haley <aph@gcc.gnu.org> | 2009-08-03 17:55:11 +0000 |
commit | 239bca9def334ad1537f26613869bb0f4f0a04be (patch) | |
tree | 2b8fe4e8aa3a69488ece71fb4cb159ce67c494f1 /gcc/java/decl.c | |
parent | 267bd2b15edda2e1c1d9102037f6b6c79fa03b3e (diff) | |
download | gcc-239bca9def334ad1537f26613869bb0f4f0a04be.zip gcc-239bca9def334ad1537f26613869bb0f4f0a04be.tar.gz gcc-239bca9def334ad1537f26613869bb0f4f0a04be.tar.bz2 |
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
Diffstat (limited to 'gcc/java/decl.c')
-rw-r--r-- | gcc/java/decl.c | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 8c327fa..4ab67d6 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -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; |