summaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2014-05-05 17:22:40 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2014-05-05 17:22:40 +0000
commit7d7e4e41740cfc814b87914b6e56c48110539a58 (patch)
tree3971f1a5b898fd3f9f89a8134640ab227c649f30 /gcc/go
parent7e7f8713ea1d2be35a20892f4fbd4c87149aa0ac (diff)
downloadgcc-7d7e4e41740cfc814b87914b6e56c48110539a58.tar.gz
compiler: Use backend interface for bound method expressions.
From-SVN: r210072
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/expressions.cc34
1 files changed, 12 insertions, 22 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 275bee53e0d..69af48c9d35 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -6736,12 +6736,9 @@ Bound_method_expression::do_get_tree(Translate_context* context)
Expression* ret = Expression::make_struct_composite_literal(st, vals, loc);
ret = Expression::make_heap_expression(ret, loc);
- tree ret_tree = ret->get_tree(context);
-
- Expression* nil_check = NULL;
-
// See whether the expression or any embedded pointers are nil.
+ Expression* nil_check = NULL;
Expression* expr = this->expr_;
if (this->method_->field_indexes() != NULL)
{
@@ -6764,26 +6761,19 @@ Bound_method_expression::do_get_tree(Translate_context* context)
nil_check = Expression::make_binary(OPERATOR_OROR, nil_check, n, loc);
}
+ Bexpression* bme = tree_to_expr(ret->get_tree(context));
if (nil_check != NULL)
{
- tree nil_check_tree = nil_check->get_tree(context);
- Expression* crash_expr =
- context->gogo()->runtime_error(RUNTIME_ERROR_NIL_DEREFERENCE, loc);
- tree crash = crash_expr->get_tree(context);
- if (ret_tree == error_mark_node
- || nil_check_tree == error_mark_node
- || crash == error_mark_node)
- return error_mark_node;
-
- ret_tree = fold_build2_loc(loc.gcc_location(), COMPOUND_EXPR,
- TREE_TYPE(ret_tree),
- build3_loc(loc.gcc_location(), COND_EXPR,
- void_type_node, nil_check_tree,
- crash, NULL_TREE),
- ret_tree);
- }
-
- return ret_tree;
+ Gogo* gogo = context->gogo();
+ Expression* crash =
+ gogo->runtime_error(RUNTIME_ERROR_NIL_DEREFERENCE, loc);
+ Bexpression* bcrash = tree_to_expr(crash->get_tree(context));
+ Btype* btype = ret->type()->get_backend(gogo);
+ Bexpression* bcheck = tree_to_expr(nil_check->get_tree(context));
+ bme = gogo->backend()->conditional_expression(btype, bcheck, bcrash,
+ bme, loc);
+ }
+ return expr_to_tree(bme);
}
// Dump ast representation of a bound method expression.