aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/expressions.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2011-04-19 21:52:41 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-04-19 21:52:41 +0000
commit9131ad67477de06fb420c24863b9c9abf2a16d80 (patch)
tree09b4493c30f3ccd5ea96ddd3dd3b139abdffcd5e /gcc/go/gofrontend/expressions.cc
parentf067961248ea104024f8b313ae39b3b95af1f8b5 (diff)
downloadgcc-9131ad67477de06fb420c24863b9c9abf2a16d80.zip
gcc-9131ad67477de06fb420c24863b9c9abf2a16d80.tar.gz
gcc-9131ad67477de06fb420c24863b9c9abf2a16d80.tar.bz2
Use backend interface for temporary variables.
* go-gcc.cc (Gcc_backend::temporary_variable): New function. From-SVN: r172737
Diffstat (limited to 'gcc/go/gofrontend/expressions.cc')
-rw-r--r--gcc/go/gofrontend/expressions.cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 9adcbc3..5f885ab 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -1029,9 +1029,22 @@ Temporary_reference_expression::do_address_taken(bool)
// Get a tree referring to the variable.
tree
-Temporary_reference_expression::do_get_tree(Translate_context*)
+Temporary_reference_expression::do_get_tree(Translate_context* context)
{
- return this->statement_->get_decl();
+ Bvariable* bvar = this->statement_->get_backend_variable(context);
+
+ // The gcc backend can't represent the same set of recursive types
+ // that the Go frontend can. In some cases this means that a
+ // temporary variable won't have the right backend type. Correct
+ // that here by adding a type cast. We need to use base() to push
+ // the circularity down one level.
+ tree ret = var_to_tree(bvar);
+ if (POINTER_TYPE_P(TREE_TYPE(ret)) && VOID_TYPE_P(TREE_TYPE(TREE_TYPE(ret))))
+ {
+ tree type_tree = this->type()->base()->get_tree(context->gogo());
+ ret = fold_convert_loc(this->location(), type_tree, ret);
+ }
+ return ret;
}
// Make a reference to a temporary variable.
@@ -8952,7 +8965,7 @@ Call_expression::do_get_tree(Translate_context* context)
// This is to support builtin math functions when using 80387 math.
tree excess_type = NULL_TREE;
- if (DECL_P(fndecl)
+ if (TREE_CODE(fndecl) == FUNCTION_DECL
&& DECL_IS_BUILTIN(fndecl)
&& DECL_BUILT_IN_CLASS(fndecl) == BUILT_IN_NORMAL
&& nargs > 0