+2005-02-26 James A. Morrison <phython@gcc.gnu.org>
+
+ * parse.y (function_invocation, variable-ref, make_plus_expression):
+ Pass location to tree_code_get_expression.
+ * treetree.c (tree_code_generate_return): Set EXPR_LOCUS on retval.
+ (tree_code_get_expression): Wrap variable references in NOP_EXPRs and
+ set EXPR_LOCATION on ret1.
+ * treetree.h (tree_code_get_expression): Take the location of the
+ expression as an argument.
+
2005-02-26 James A. Morrison <phython@gcc.gnu.org>
* treelang.texi: Treelang does have warnings.
type = tree_code_get_type (NUMERIC_TYPE (prod));
prod->tp.pro.code = tree_code_get_expression (EXP_FUNCTION_INVOCATION, type,
proto->tp.pro.code, parms,
- NULL);
+ NULL, tok->tp.tok.location);
$$ = prod;
}
;
OP1 (prod) = $1;
prod->tp.pro.code =
- tree_code_get_expression (EXP_REFERENCE, type,
- symbol_table_entry->tp.pro.code, NULL, NULL);
+ tree_code_get_expression (EXP_REFERENCE, type,
+ symbol_table_entry->tp.pro.code, NULL, NULL,
+ tok->tp.tok.location);
$$ = prod;
}
;
prod->tp.pro.code = tree_code_get_expression (prod_code, type,
op1->tp.pro.code,
- op2->tp.pro.code, NULL);
+ op2->tp.pro.code, NULL,
+ tok->tp.tok.location);
return prod;
}
TREE_SIDE_EFFECTS (setret) = 1;
TREE_USED (setret) = 1;
setret = build1 (RETURN_EXPR, type, setret);
+ /* Use EXPR_LOCUS so we don't lose any information about the file we
+ are compiling. */
+ SET_EXPR_LOCUS (setret, EXPR_LOCUS (exp));
}
else
setret = build1 (RETURN_EXPR, type, NULL_TREE);
tree
tree_code_get_expression (unsigned int exp_type,
tree type, tree op1, tree op2,
- tree op3 ATTRIBUTE_UNUSED)
+ tree op3 ATTRIBUTE_UNUSED,
+ location_t loc)
{
tree ret1;
int operator;
/* Reference to a variable. This is dead easy, just return the
decl for the variable. If the TYPE is different than the
- variable type, convert it. */
+ variable type, convert it. However, to keep accurate location
+ information we wrap it in a NOP_EXPR is is easily stripped. */
case EXP_REFERENCE:
gcc_assert (op1);
TREE_USED (op1) = 1;
if (type == TREE_TYPE (op1))
- ret1 = op1;
+ ret1 = build1 (NOP_EXPR, type, op1);
else
ret1 = fold (build1 (CONVERT_EXPR, type, op1));
break;
gcc_unreachable ();
}
+ /* Declarations already have a location and constants can be shared so they
+ shouldn't a location set on them. */
+ if (! DECL_P (ret1) && ! TREE_CONSTANT (ret1))
+ SET_EXPR_LOCATION (ret1, loc);
return ret1;
}
tree tree_code_get_integer_value (unsigned char *chars, unsigned int length);
void tree_code_generate_return (tree type, tree exp);
void tree_ggc_storage_always_used (void *m);
-tree tree_code_get_expression (unsigned int exp_type, tree type, tree op1, tree op2, tree op3);
+tree tree_code_get_expression (unsigned int exp_type, tree type, tree op1,
+ tree op2, tree op3, location_t loc);
tree tree_code_get_numeric_type (unsigned int size1, unsigned int sign1);
void tree_code_create_function_initial (tree prev_saved,
location_t loc);