Commit b12d3a19 by James A. Morrison

parse.y (function_invocation, [...]): Pass location to tree_code_get_expression.

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.

From-SVN: r95584
parent 7bcf4240
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.
* treetree.c (tree_code_create_function_prototype): Don't set
TREE_USED and set TREE_PUBLIC, DECL_EXTERNAL, and TREE_STATIC
......
......@@ -675,7 +675,7 @@ NAME LEFT_PARENTHESIS expressions_with_commas_opt RIGHT_PARENTHESIS {
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;
}
;
......@@ -730,8 +730,9 @@ NAME {
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;
}
;
......@@ -920,7 +921,8 @@ make_plus_expression (struct prod_token_parm_item* tok,
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;
}
......
......@@ -589,6 +589,9 @@ tree_code_generate_return (tree type, tree exp)
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);
......@@ -647,7 +650,8 @@ tree_code_get_integer_value (unsigned char* chars, unsigned int length)
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;
......@@ -685,12 +689,13 @@ tree_code_get_expression (unsigned int exp_type,
/* 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;
......@@ -710,6 +715,10 @@ tree_code_get_expression (unsigned int exp_type,
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;
}
......
......@@ -33,7 +33,8 @@ tree tree_code_add_parameter (tree list, tree proto_exp, tree exp);
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);
......
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