aboutsummaryrefslogtreecommitdiff
path: root/gcc/treelang
diff options
context:
space:
mode:
authorJames A. Morrison <phython@gcc.gnu.org>2005-02-26 16:07:49 +0000
committerJames A. Morrison <phython@gcc.gnu.org>2005-02-26 16:07:49 +0000
commit8f273caa402145980c178d8c1766d9275d9a4624 (patch)
tree7a5a07fc1d3a44f2efd5a27fd29b215571d2832f /gcc/treelang
parent405adf67c7dbaf2503664633681306e8a60d7787 (diff)
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. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@95584 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/treelang')
-rw-r--r--gcc/treelang/ChangeLog10
-rw-r--r--gcc/treelang/parse.y10
-rw-r--r--gcc/treelang/treetree.c15
-rw-r--r--gcc/treelang/treetree.h3
4 files changed, 30 insertions, 8 deletions
diff --git a/gcc/treelang/ChangeLog b/gcc/treelang/ChangeLog
index d428afdabe4..eb5c55da451 100644
--- a/gcc/treelang/ChangeLog
+++ b/gcc/treelang/ChangeLog
@@ -1,5 +1,15 @@
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
diff --git a/gcc/treelang/parse.y b/gcc/treelang/parse.y
index abf2bcbf795..be443625221 100644
--- a/gcc/treelang/parse.y
+++ b/gcc/treelang/parse.y
@@ -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;
}
diff --git a/gcc/treelang/treetree.c b/gcc/treelang/treetree.c
index ac8c7a39494..aea6e0ba5cb 100644
--- a/gcc/treelang/treetree.c
+++ b/gcc/treelang/treetree.c
@@ -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;
}
diff --git a/gcc/treelang/treetree.h b/gcc/treelang/treetree.h
index 323509cf669..cb6891ebfdd 100644
--- a/gcc/treelang/treetree.h
+++ b/gcc/treelang/treetree.h
@@ -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);