OSDN Git Service

Implement append([]byte, string...).
[pf3gnuchains/gcc-fork.git] / gcc / go / gofrontend / expressions.cc
index 2e31e80..e61dd3b 100644 (file)
@@ -33,7 +33,10 @@ extern "C"
 #include "import.h"
 #include "statements.h"
 #include "lex.h"
+#include "runtime.h"
+#include "backend.h"
 #include "expressions.h"
+#include "ast-dump.h"
 
 // Class Expression.
 
@@ -132,13 +135,13 @@ Expression::do_traverse(Traverse*)
 }
 
 // This virtual function is called by the parser if the value of this
-// expression is being discarded.  By default, we warn.  Expressions
-// with side effects override.
+// expression is being discarded.  By default, we give an error.
+// Expressions with side effects override.
 
 void
 Expression::do_discarding_value()
 {
-  this->warn_about_unused_value();
+  this->unused_value_error();
 }
 
 // This virtual function is called to export expressions.  This will
@@ -147,15 +150,15 @@ Expression::do_discarding_value()
 void
 Expression::do_export(Export*) const
 {
-  gcc_unreachable();
+  go_unreachable();
 }
 
-// Warn that the value of the expression is not used.
+// Give an error saying that the value of the expression is not used.
 
 void
-Expression::warn_about_unused_value()
+Expression::unused_value_error()
 {
-  warning_at(this->location(), OPT_Wunused_value, "value computed is not used");
+  error_at(this->location(), "value computed is not used");
 }
 
 // Note that this expression is an error.  This is called by children
@@ -205,23 +208,15 @@ Expression::convert_for_assignment(Translate_context* context, Type* lhs_type,
   if (lhs_type == rhs_type)
     return rhs_tree;
 
-  if (lhs_type->is_error_type() || rhs_type->is_error_type())
+  if (lhs_type->is_error() || rhs_type->is_error())
     return error_mark_node;
 
-  if (lhs_type->is_undefined() || rhs_type->is_undefined())
-    {
-      // Make sure we report the error.
-      lhs_type->base();
-      rhs_type->base();
-      return error_mark_node;
-    }
-
   if (rhs_tree == error_mark_node || TREE_TYPE(rhs_tree) == error_mark_node)
     return error_mark_node;
 
   Gogo* gogo = context->gogo();
 
-  tree lhs_type_tree = lhs_type->get_tree(gogo);
+  tree lhs_type_tree = type_to_tree(lhs_type->get_backend(gogo));
   if (lhs_type_tree == error_mark_node)
     return error_mark_node;
 
@@ -239,31 +234,30 @@ Expression::convert_for_assignment(Translate_context* context, Type* lhs_type,
   else if (rhs_type->interface_type() != NULL)
     return Expression::convert_interface_to_type(context, lhs_type, rhs_type,
                                                 rhs_tree, location);
-  else if (lhs_type->is_open_array_type()
-          && rhs_type->is_nil_type())
+  else if (lhs_type->is_slice_type() && rhs_type->is_nil_type())
     {
       // Assigning nil to an open array.
-      gcc_assert(TREE_CODE(lhs_type_tree) == RECORD_TYPE);
+      go_assert(TREE_CODE(lhs_type_tree) == RECORD_TYPE);
 
       VEC(constructor_elt,gc)* init = VEC_alloc(constructor_elt, gc, 3);
 
       constructor_elt* elt = VEC_quick_push(constructor_elt, init, NULL);
       tree field = TYPE_FIELDS(lhs_type_tree);
-      gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),
+      go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),
                        "__values") == 0);
       elt->index = field;
       elt->value = fold_convert(TREE_TYPE(field), null_pointer_node);
 
       elt = VEC_quick_push(constructor_elt, init, NULL);
       field = DECL_CHAIN(field);
-      gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),
+      go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),
                        "__count") == 0);
       elt->index = field;
       elt->value = fold_convert(TREE_TYPE(field), integer_zero_node);
 
       elt = VEC_quick_push(constructor_elt, init, NULL);
       field = DECL_CHAIN(field);
-      gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),
+      go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),
                        "__capacity") == 0);
       elt->index = field;
       elt->value = fold_convert(TREE_TYPE(field), integer_zero_node);
@@ -277,7 +271,7 @@ Expression::convert_for_assignment(Translate_context* context, Type* lhs_type,
     {
       // The left hand side should be a pointer type at the tree
       // level.
-      gcc_assert(POINTER_TYPE_P(lhs_type_tree));
+      go_assert(POINTER_TYPE_P(lhs_type_tree));
       return fold_convert(lhs_type_tree, null_pointer_node);
     }
   else if (lhs_type_tree == TREE_TYPE(rhs_tree))
@@ -295,14 +289,14 @@ Expression::convert_for_assignment(Translate_context* context, Type* lhs_type,
     {
       // This conversion must be permitted by Go, or we wouldn't have
       // gotten here.
-      gcc_assert(int_size_in_bytes(lhs_type_tree)
+      go_assert(int_size_in_bytes(lhs_type_tree)
                 == int_size_in_bytes(TREE_TYPE(rhs_tree)));
       return fold_build1_loc(location, VIEW_CONVERT_EXPR, lhs_type_tree,
                             rhs_tree);
     }
   else
     {
-      gcc_assert(useless_type_conversion_p(lhs_type_tree, TREE_TYPE(rhs_tree)));
+      go_assert(useless_type_conversion_p(lhs_type_tree, TREE_TYPE(rhs_tree)));
       return rhs_tree;
     }
 }
@@ -325,12 +319,15 @@ Expression::convert_type_to_interface(Translate_context* context,
   // When setting an interface to nil, we just set both fields to
   // NULL.
   if (rhs_type->is_nil_type())
-    return lhs_type->get_init_tree(gogo, false);
+    {
+      Btype* lhs_btype = lhs_type->get_backend(gogo);
+      return expr_to_tree(gogo->backend()->zero_expression(lhs_btype));
+    }
 
   // This should have been checked already.
-  gcc_assert(lhs_interface_type->implements_interface(rhs_type, NULL));
+  go_assert(lhs_interface_type->implements_interface(rhs_type, NULL));
 
-  tree lhs_type_tree = lhs_type->get_tree(gogo);
+  tree lhs_type_tree = type_to_tree(lhs_type->get_backend(gogo));
   if (lhs_type_tree == error_mark_node)
     return error_mark_node;
 
@@ -339,7 +336,7 @@ Expression::convert_type_to_interface(Translate_context* context,
   // Otherwise it is the interface method table for RHS_TYPE.
   tree first_field_value;
   if (lhs_is_empty)
-    first_field_value = rhs_type->type_descriptor_pointer(gogo);
+    first_field_value = rhs_type->type_descriptor_pointer(gogo, location);
   else
     {
       // Build the interface method table for this interface and this
@@ -371,14 +368,14 @@ Expression::convert_type_to_interface(Translate_context* context,
 
   constructor_elt* elt = VEC_quick_push(constructor_elt, init, NULL);
   tree field = TYPE_FIELDS(lhs_type_tree);
-  gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),
+  go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),
                    (lhs_is_empty ? "__type_descriptor" : "__methods")) == 0);
   elt->index = field;
   elt->value = fold_convert_loc(location, TREE_TYPE(field), first_field_value);
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
   field = DECL_CHAIN(field);
-  gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__object") == 0);
+  go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__object") == 0);
   elt->index = field;
 
   if (rhs_type->points_to() != NULL)
@@ -420,25 +417,25 @@ Expression::get_interface_type_descriptor(Translate_context*,
                                          source_location location)
 {
   tree rhs_type_tree = TREE_TYPE(rhs_tree);
-  gcc_assert(TREE_CODE(rhs_type_tree) == RECORD_TYPE);
+  go_assert(TREE_CODE(rhs_type_tree) == RECORD_TYPE);
   tree rhs_field = TYPE_FIELDS(rhs_type_tree);
   tree v = build3(COMPONENT_REF, TREE_TYPE(rhs_field), rhs_tree, rhs_field,
                  NULL_TREE);
   if (rhs_type->interface_type()->is_empty())
     {
-      gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)),
+      go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)),
                        "__type_descriptor") == 0);
       return v;
     }
 
-  gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), "__methods")
+  go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), "__methods")
             == 0);
-  gcc_assert(POINTER_TYPE_P(TREE_TYPE(v)));
+  go_assert(POINTER_TYPE_P(TREE_TYPE(v)));
   v = save_expr(v);
   tree v1 = build_fold_indirect_ref_loc(location, v);
-  gcc_assert(TREE_CODE(TREE_TYPE(v1)) == RECORD_TYPE);
+  go_assert(TREE_CODE(TREE_TYPE(v1)) == RECORD_TYPE);
   tree f = TYPE_FIELDS(TREE_TYPE(v1));
-  gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(f)), "__type_descriptor")
+  go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(f)), "__type_descriptor")
             == 0);
   v1 = build3(COMPONENT_REF, TREE_TYPE(f), v1, f, NULL_TREE);
 
@@ -463,7 +460,7 @@ Expression::convert_interface_to_interface(Translate_context* context,
   Interface_type* lhs_interface_type = lhs_type->interface_type();
   bool lhs_is_empty = lhs_interface_type->is_empty();
 
-  tree lhs_type_tree = lhs_type->get_tree(gogo);
+  tree lhs_type_tree = type_to_tree(lhs_type->get_backend(gogo));
   if (lhs_type_tree == error_mark_node)
     return error_mark_node;
 
@@ -496,7 +493,8 @@ Expression::convert_interface_to_interface(Translate_context* context,
   if (for_type_guard)
     {
       // A type assertion fails when converting a nil interface.
-      tree lhs_type_descriptor = lhs_type->type_descriptor_pointer(gogo);
+      tree lhs_type_descriptor = lhs_type->type_descriptor_pointer(gogo,
+                                                                  location);
       static tree assert_interface_decl;
       tree call = Gogo::call_builtin(&assert_interface_decl,
                                     location,
@@ -517,18 +515,19 @@ Expression::convert_interface_to_interface(Translate_context* context,
     {
       // A convertion to an empty interface always succeeds, and the
       // first field is just the type descriptor of the object.
-      gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),
+      go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),
                        "__type_descriptor") == 0);
-      gcc_assert(TREE_TYPE(field) == TREE_TYPE(rhs_type_descriptor));
+      go_assert(TREE_TYPE(field) == TREE_TYPE(rhs_type_descriptor));
       elt->value = rhs_type_descriptor;
     }
   else
     {
       // A conversion to a non-empty interface may fail, but unlike a
       // type assertion converting nil will always succeed.
-      gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__methods")
+      go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__methods")
                 == 0);
-      tree lhs_type_descriptor = lhs_type->type_descriptor_pointer(gogo);
+      tree lhs_type_descriptor = lhs_type->type_descriptor_pointer(gogo,
+                                                                  location);
       static tree convert_interface_decl;
       tree call = Gogo::call_builtin(&convert_interface_decl,
                                     location,
@@ -550,13 +549,13 @@ Expression::convert_interface_to_interface(Translate_context* context,
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
   field = DECL_CHAIN(field);
-  gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__object") == 0);
+  go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__object") == 0);
   elt->index = field;
 
   tree rhs_type_tree = TREE_TYPE(rhs_tree);
-  gcc_assert(TREE_CODE(rhs_type_tree) == RECORD_TYPE);
+  go_assert(TREE_CODE(rhs_type_tree) == RECORD_TYPE);
   tree rhs_field = DECL_CHAIN(TYPE_FIELDS(rhs_type_tree));
-  gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), "__object") == 0);
+  go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), "__object") == 0);
   elt->value = build3(COMPONENT_REF, TREE_TYPE(rhs_field), rhs_tree, rhs_field,
                      NULL_TREE);
 
@@ -574,7 +573,7 @@ Expression::convert_interface_to_type(Translate_context* context,
   Gogo* gogo = context->gogo();
   tree rhs_type_tree = TREE_TYPE(rhs_tree);
 
-  tree lhs_type_tree = lhs_type->get_tree(gogo);
+  tree lhs_type_tree = type_to_tree(lhs_type->get_backend(gogo));
   if (lhs_type_tree == error_mark_node)
     return error_mark_node;
 
@@ -582,7 +581,7 @@ Expression::convert_interface_to_type(Translate_context* context,
   // will panic with an appropriate runtime type error if the type is
   // not valid.
 
-  tree lhs_type_descriptor = lhs_type->type_descriptor_pointer(gogo);
+  tree lhs_type_descriptor = lhs_type->type_descriptor_pointer(gogo, location);
 
   if (!DECL_P(rhs_tree))
     rhs_tree = save_expr(rhs_tree);
@@ -591,7 +590,8 @@ Expression::convert_interface_to_type(Translate_context* context,
     Expression::get_interface_type_descriptor(context, rhs_type, rhs_tree,
                                              location);
 
-  tree rhs_inter_descriptor = rhs_type->type_descriptor_pointer(gogo);
+  tree rhs_inter_descriptor = rhs_type->type_descriptor_pointer(gogo,
+                                                               location);
 
   static tree check_interface_type_decl;
   tree call = Gogo::call_builtin(&check_interface_type_decl,
@@ -611,9 +611,9 @@ Expression::convert_interface_to_type(Translate_context* context,
   TREE_NOTHROW(check_interface_type_decl) = 0;
 
   // If the call succeeds, pull out the value.
-  gcc_assert(TREE_CODE(rhs_type_tree) == RECORD_TYPE);
+  go_assert(TREE_CODE(rhs_type_tree) == RECORD_TYPE);
   tree rhs_field = DECL_CHAIN(TYPE_FIELDS(rhs_type_tree));
-  gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), "__object") == 0);
+  go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), "__object") == 0);
   tree val = build3(COMPONENT_REF, TREE_TYPE(rhs_field), rhs_tree, rhs_field,
                    NULL_TREE);
 
@@ -672,7 +672,7 @@ Expression::integer_constant_tree(mpz_t val, tree type)
       return build_complex(type, real, imag);
     }
   else
-    gcc_unreachable();
+    go_unreachable();
 }
 
 // Return a tree for VAL in TYPE.
@@ -710,7 +710,7 @@ Expression::float_constant_tree(mpfr_t val, tree type)
       return build_complex(type, build_real(TREE_TYPE(type), r2), imag);
     }
   else
-    gcc_unreachable();
+    go_unreachable();
 }
 
 // Return a tree for REAL/IMAG in TYPE.
@@ -738,7 +738,7 @@ Expression::complex_constant_tree(mpfr_t real, mpfr_t imag, tree type)
                           build_real(TREE_TYPE(type), r4));
     }
   else
-    gcc_unreachable();
+    go_unreachable();
 }
 
 // Return a tree which evaluates to true if VAL, of arbitrary integer
@@ -761,8 +761,13 @@ Expression::check_bounds(tree val, tree bound_type, tree sofar,
        ret = NULL_TREE;
     }
 
-  if ((TYPE_UNSIGNED(val_type) && !TYPE_UNSIGNED(bound_type))
-      || TYPE_SIZE(val_type) > TYPE_SIZE(bound_type))
+  HOST_WIDE_INT val_type_size = int_size_in_bytes(val_type);
+  HOST_WIDE_INT bound_type_size = int_size_in_bytes(bound_type);
+  go_assert(val_type_size != -1 && bound_type_size != -1);
+  if (val_type_size > bound_type_size
+      || (val_type_size == bound_type_size
+         && TYPE_UNSIGNED(val_type)
+         && !TYPE_UNSIGNED(bound_type)))
     {
       tree max = TYPE_MAX_VALUE(bound_type);
       tree big = fold_build2_loc(loc, GT_EXPR, boolean_type_node, val,
@@ -785,6 +790,12 @@ Expression::check_bounds(tree val, tree bound_type, tree sofar,
                           sofar, ret);
 }
 
+void
+Expression::dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  this->do_dump_expression(ast_dump_context);
+}
+
 // Error expressions.  This are used to avoid cascading errors.
 
 class Error_expression : public Expression
@@ -844,8 +855,19 @@ class Error_expression : public Expression
   tree
   do_get_tree(Translate_context*)
   { return error_mark_node; }
+
+  void
+  do_dump_expression(Ast_dump_context*) const;
 };
 
+// Dump the ast representation for an error expression to a dump context.
+
+void
+Error_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->ostream() << "_Error_" ;
+}
+
 Expression*
 Expression::make_error(source_location location)
 {
@@ -887,13 +909,21 @@ Type_expression : public Expression
 
   tree
   do_get_tree(Translate_context*)
-  { gcc_unreachable(); }
+  { go_unreachable(); }
 
+  void do_dump_expression(Ast_dump_context*) const;
  private:
   // The type which we are representing as an expression.
   Type* type_;
 };
 
+void
+Type_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->dump_type(this->type_);
+}
+
 Expression*
 Expression::make_type(Type* type, source_location location)
 {
@@ -909,7 +939,7 @@ Parser_expression::do_type()
   // However, it can happen, at least when we have an invalid const
   // whose initializer refers to the const itself.  In that case we
   // may ask for the type when lowering the const itself.
-  gcc_assert(saw_errors());
+  go_assert(saw_errors());
   return Type::make_error_type();
 }
 
@@ -921,7 +951,8 @@ Parser_expression::do_type()
 // if necessary.
 
 Expression*
-Var_expression::do_lower(Gogo* gogo, Named_object* function, int)
+Var_expression::do_lower(Gogo* gogo, Named_object* function,
+                        Statement_inserter* inserter, int)
 {
   if (this->variable_->is_variable())
     {
@@ -930,20 +961,15 @@ Var_expression::do_lower(Gogo* gogo, Named_object* function, int)
       // reference to a variable which is local to an enclosing
       // function will be a reference to a field in a closure.
       if (var->is_global())
-       function = NULL;
-      var->lower_init_expression(gogo, function);
+       {
+         function = NULL;
+         inserter = NULL;
+       }
+      var->lower_init_expression(gogo, function, inserter);
     }
   return this;
 }
 
-// Return the name of the variable.
-
-const std::string&
-Var_expression::name() const
-{
-  return this->variable_->name();
-}
-
 // Return the type of a reference to a variable.
 
 Type*
@@ -954,7 +980,16 @@ Var_expression::do_type()
   else if (this->variable_->is_result_variable())
     return this->variable_->result_var_value()->type();
   else
-    gcc_unreachable();
+    go_unreachable();
+}
+
+// Determine the type of a reference to a variable.
+
+void
+Var_expression::do_determine_type(const Type_context*)
+{
+  if (this->variable_->is_variable())
+    this->variable_->var_value()->determine_type();
 }
 
 // Something takes the address of this variable.  This means that we
@@ -964,13 +999,23 @@ void
 Var_expression::do_address_taken(bool escapes)
 {
   if (!escapes)
-    ;
-  else if (this->variable_->is_variable())
-    this->variable_->var_value()->set_address_taken();
-  else if (this->variable_->is_result_variable())
-    this->variable_->result_var_value()->set_address_taken();
+    {
+      if (this->variable_->is_variable())
+       this->variable_->var_value()->set_non_escaping_address_taken();
+      else if (this->variable_->is_result_variable())
+       this->variable_->result_var_value()->set_non_escaping_address_taken();
+      else
+       go_unreachable();
+    }
   else
-    gcc_unreachable();
+    {
+      if (this->variable_->is_variable())
+       this->variable_->var_value()->set_address_taken();
+      else if (this->variable_->is_result_variable())
+       this->variable_->result_var_value()->set_address_taken();
+      else
+       go_unreachable();
+    }
 }
 
 // Get the tree for a reference to a variable.
@@ -978,7 +1023,32 @@ Var_expression::do_address_taken(bool escapes)
 tree
 Var_expression::do_get_tree(Translate_context* context)
 {
-  return this->variable_->get_tree(context->gogo(), context->function());
+  Bvariable* bvar = this->variable_->get_backend_variable(context->gogo(),
+                                                         context->function());
+  tree ret = var_to_tree(bvar);
+  if (ret == error_mark_node)
+    return error_mark_node;
+  bool is_in_heap;
+  if (this->variable_->is_variable())
+    is_in_heap = this->variable_->var_value()->is_in_heap();
+  else if (this->variable_->is_result_variable())
+    is_in_heap = this->variable_->result_var_value()->is_in_heap();
+  else
+    go_unreachable();
+  if (is_in_heap)
+    {
+      ret = build_fold_indirect_ref_loc(this->location(), ret);
+      TREE_THIS_NOTRAP(ret) = 1;
+    }
+  return ret;
+}
+
+// Ast dump for variable expression.
+
+void
+Var_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->ostream() << this->variable_->name() ;
 }
 
 // Make a reference to a variable in an expression.
@@ -1018,14 +1088,39 @@ 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)
+{
+  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 (!this->is_lvalue_
+      && POINTER_TYPE_P(TREE_TYPE(ret))
+      && VOID_TYPE_P(TREE_TYPE(TREE_TYPE(ret))))
+    {
+      Btype* type_btype = this->type()->base()->get_backend(context->gogo());
+      tree type_tree = type_to_tree(type_btype);
+      ret = fold_convert_loc(this->location(), type_tree, ret);
+    }
+  return ret;
+}
+
+// Ast dump for temporary reference.
+
+void
+Temporary_reference_expression::do_dump_expression(
+                                Ast_dump_context* ast_dump_context) const
 {
-  return this->statement_->get_decl();
+  ast_dump_context->dump_temp_variable_name(this->statement_);
 }
 
 // Make a reference to a temporary variable.
 
-Expression*
+Temporary_reference_expression*
 Expression::make_temporary_reference(Temporary_statement* statement,
                                     source_location location)
 {
@@ -1060,6 +1155,9 @@ class Sink_expression : public Expression
   tree
   do_get_tree(Translate_context*);
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+
  private:
   // The type of this sink variable.
   Type* type_;
@@ -1094,13 +1192,21 @@ Sink_expression::do_get_tree(Translate_context* context)
 {
   if (this->var_ == NULL_TREE)
     {
-      gcc_assert(this->type_ != NULL && !this->type_->is_sink_type());
-      this->var_ = create_tmp_var(this->type_->get_tree(context->gogo()),
-                                 "blank");
+      go_assert(this->type_ != NULL && !this->type_->is_sink_type());
+      Btype* bt = this->type_->get_backend(context->gogo());
+      this->var_ = create_tmp_var(type_to_tree(bt), "blank");
     }
   return this->var_;
 }
 
+// Ast dump for sink expression.
+
+void
+Sink_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->ostream() << "_" ;
+}
+
 // Make a sink expression.
 
 Expression*
@@ -1116,14 +1222,6 @@ Expression::make_sink(source_location location)
 // a function seems like it could work, though there might be little
 // point to it.
 
-// Return the name of the function.
-
-const std::string&
-Func_expression::name() const
-{
-  return this->function_->name();
-}
-
 // Traversal.
 
 int
@@ -1144,7 +1242,7 @@ Func_expression::do_type()
   else if (this->function_->is_function_declaration())
     return this->function_->func_declaration_value()->type();
   else
-    gcc_unreachable();
+    go_unreachable();
 }
 
 // Get the tree for a function expression without evaluating the
@@ -1159,7 +1257,7 @@ Func_expression::get_tree_without_closure(Gogo* gogo)
   else if (this->function_->is_function_declaration())
     fntype = this->function_->func_declaration_value()->type();
   else
-    gcc_unreachable();
+    go_unreachable();
 
   // Builtin functions are handled specially by Call_expression.  We
   // can't take their address.
@@ -1182,7 +1280,7 @@ Func_expression::get_tree_without_closure(Gogo* gogo)
   else if (no->is_function_declaration())
     fndecl = no->func_declaration_value()->get_or_make_decl(gogo, no, id);
   else
-    gcc_unreachable();
+    go_unreachable();
 
   if (fndecl == error_mark_node)
     return error_mark_node;
@@ -1203,7 +1301,7 @@ Func_expression::do_get_tree(Translate_context* context)
   if (fnaddr == error_mark_node)
     return error_mark_node;
 
-  gcc_assert(TREE_CODE(fnaddr) == ADDR_EXPR
+  go_assert(TREE_CODE(fnaddr) == ADDR_EXPR
             && TREE_CODE(TREE_OPERAND(fnaddr, 0)) == FUNCTION_DECL);
   TREE_ADDRESSABLE(TREE_OPERAND(fnaddr, 0)) = 1;
 
@@ -1211,7 +1309,7 @@ Func_expression::do_get_tree(Translate_context* context)
   if (!this->function_->is_function()
       || this->function_->func_value()->enclosing() == NULL)
     {
-      gcc_assert(this->closure_ == NULL);
+      go_assert(this->closure_ == NULL);
       return fnaddr;
     }
 
@@ -1229,7 +1327,7 @@ Func_expression::do_get_tree(Translate_context* context)
       closure_tree = closure->get_tree(context);
       if (closure_tree == error_mark_node)
        return error_mark_node;
-      gcc_assert(POINTER_TYPE_P(TREE_TYPE(closure_tree)));
+      go_assert(POINTER_TYPE_P(TREE_TYPE(closure_tree)));
     }
 
   // Now we need to build some code on the heap.  This code will load
@@ -1241,6 +1339,20 @@ Func_expression::do_get_tree(Translate_context* context)
   return gogo->make_trampoline(fnaddr, closure_tree, this->location());
 }
 
+// Ast dump for function.
+
+void
+Func_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->ostream() << this->function_->name();
+  if (this->closure_ != NULL)
+    {
+      ast_dump_context->ostream() << " {closure =  ";
+      this->closure_->dump_expression(ast_dump_context);
+      ast_dump_context->ostream() << "}";
+    }
+}
+
 // Make a reference to a function in an expression.
 
 Expression*
@@ -1263,7 +1375,7 @@ Unknown_expression::name() const
 // Lower a reference to an unknown name.
 
 Expression*
-Unknown_expression::do_lower(Gogo*, Named_object*, int)
+Unknown_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
 {
   source_location location = this->location();
   Named_object* no = this->named_object_;
@@ -1305,16 +1417,24 @@ Unknown_expression::do_lower(Gogo*, Named_object*, int)
       error_at(location, "unexpected reference to package");
       return Expression::make_error(location);
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 }
 
+// Dump the ast representation for an unknown expression to a dump context.
+
+void
+Unknown_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->ostream() << "_Unknown_(" << this->named_object_->name()
+                             << ")";
+}
+
 // Make a reference to an unknown name.
 
 Expression*
 Expression::make_unknown_reference(Named_object* no, source_location location)
 {
-  gcc_assert(no->resolve()->is_unknown());
   return new Unknown_expression(no, location);
 }
 
@@ -1354,6 +1474,10 @@ class Boolean_expression : public Expression
   do_export(Export* exp) const
   { exp->write_c_string(this->val_ ? "true" : "false"); }
 
+  void
+  do_dump_expression(Ast_dump_context* ast_dump_context) const
+  { ast_dump_context->ostream() << (this->val_ ? "true" : "false"); }
+  
  private:
   // The constant.
   bool val_;
@@ -1442,16 +1566,17 @@ String_expression::do_get_tree(Translate_context* context)
   return context->gogo()->go_string_constant_tree(this->val_);
 }
 
-// Export a string expression.
+ // Write string literal to string dump.
 
 void
-String_expression::do_export(Export* exp) const
+String_expression::export_string(String_dump* exp,
+                                const String_expression* str)
 {
   std::string s;
-  s.reserve(this->val_.length() * 4 + 2);
+  s.reserve(str->val_.length() * 4 + 2);
   s += '"';
-  for (std::string::const_iterator p = this->val_.begin();
-       p != this->val_.end();
+  for (std::string::const_iterator p = str->val_.begin();
+       p != str->val_.end();
        ++p)
     {
       if (*p == '\\' || *p == '"')
@@ -1479,6 +1604,14 @@ String_expression::do_export(Export* exp) const
   exp->write_string(s);
 }
 
+// Export a string expression.
+
+void
+String_expression::do_export(Export* exp) const
+{
+  String_expression::export_string(exp, this);
+}
+
 // Import a string expression.
 
 Expression*
@@ -1521,6 +1654,14 @@ String_expression::do_import(Import* imp)
   return Expression::make_string(val, imp->location());
 }
 
+// Ast dump for string expression.
+
+void
+String_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  String_expression::export_string(ast_dump_context, this);
+}
+
 // Make a string expression.
 
 Expression*
@@ -1546,9 +1687,13 @@ class Integer_expression : public Expression
   static bool
   check_constant(mpz_t val, Type*, source_location);
 
-  // Write VAL to export data.
+  // Write VAL to string dump.
+  static void
+  export_integer(String_dump* exp, const mpz_t val);
+
+  // Write VAL to dump context.
   static void
-  export_integer(Export* exp, const mpz_t val);
+  dump_integer(Ast_dump_context* ast_dump_context, const mpz_t val);
 
  protected:
   bool
@@ -1578,6 +1723,9 @@ class Integer_expression : public Expression
   void
   do_export(Export*) const;
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+
  private:
   // The integer value.
   mpz_t val_;
@@ -1685,16 +1833,18 @@ Integer_expression::do_get_tree(Translate_context* context)
   Gogo* gogo = context->gogo();
   tree type;
   if (this->type_ != NULL && !this->type_->is_abstract())
-    type = this->type_->get_tree(gogo);
+    type = type_to_tree(this->type_->get_backend(gogo));
   else if (this->type_ != NULL && this->type_->float_type() != NULL)
     {
       // We are converting to an abstract floating point type.
-      type = Type::lookup_float_type("float64")->get_tree(gogo);
+      Type* ftype = Type::lookup_float_type("float64");
+      type = type_to_tree(ftype->get_backend(gogo));
     }
   else if (this->type_ != NULL && this->type_->complex_type() != NULL)
     {
       // We are converting to an abstract complex type.
-      type = Type::lookup_complex_type("complex128")->get_tree(gogo);
+      Type* ctype = Type::lookup_complex_type("complex128");
+      type = type_to_tree(ctype->get_backend(gogo));
     }
   else
     {
@@ -1704,9 +1854,15 @@ Integer_expression::do_get_tree(Translate_context* context)
       // not <=, because we need an extra bit for the sign bit.
       int bits = mpz_sizeinbase(this->val_, 2);
       if (bits < INT_TYPE_SIZE)
-       type = Type::lookup_integer_type("int")->get_tree(gogo);
+       {
+         Type* t = Type::lookup_integer_type("int");
+         type = type_to_tree(t->get_backend(gogo));
+       }
       else if (bits < 64)
-       type = Type::lookup_integer_type("int64")->get_tree(gogo);
+       {
+         Type* t = Type::lookup_integer_type("int64");
+         type = type_to_tree(t->get_backend(gogo));
+       }
       else
        type = long_long_integer_type_node;
     }
@@ -1716,7 +1872,7 @@ Integer_expression::do_get_tree(Translate_context* context)
 // Write VAL to export data.
 
 void
-Integer_expression::export_integer(Export* exp, const mpz_t val)
+Integer_expression::export_integer(String_dump* exp, const mpz_t val)
 {
   char* s = mpz_get_str(NULL, 10, val);
   exp->write_c_string(s);
@@ -1817,6 +1973,13 @@ Integer_expression::do_import(Import* imp)
       return ret;
     }
 }
+// Ast dump for integer expression.
+
+void
+Integer_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  Integer_expression::export_integer(ast_dump_context, this->val_);
+}
 
 // Build a new integer value.
 
@@ -1849,7 +2012,11 @@ class Float_expression : public Expression
 
   // Write VAL to export data.
   static void
-  export_float(Export* exp, const mpfr_t val);
+  export_float(String_dump* exp, const mpfr_t val);
+
+  // Write VAL to dump file.
+  static void
+  dump_float(Ast_dump_context* ast_dump_context, const mpfr_t val);
 
  protected:
   bool
@@ -1879,6 +2046,9 @@ class Float_expression : public Expression
   void
   do_export(Export*) const;
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+
  private:
   // The floating point value.
   mpfr_t val_;
@@ -1893,13 +2063,7 @@ Float_expression::constrain_float(mpfr_t val, Type* type)
 {
   Float_type* ftype = type->float_type();
   if (ftype != NULL && !ftype->is_abstract())
-    {
-      tree type_tree = ftype->type_tree();
-      REAL_VALUE_TYPE rvt;
-      real_from_mpfr(&rvt, val, type_tree, GMP_RNDN);
-      real_convert(&rvt, TYPE_MODE(type_tree), &rvt);
-      mpfr_from_real(val, &rvt, GMP_RNDN);
-    }
+    mpfr_prec_round(val, ftype->bits(), GMP_RNDN);
 }
 
 // Return a floating point constant value.
@@ -1970,7 +2134,7 @@ Float_expression::check_constant(mpfr_t val, Type* type,
       max_exp = 1024;
       break;
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
   if (exp > max_exp)
     {
@@ -1999,7 +2163,7 @@ Float_expression::do_check_types(Gogo*)
        this->report_error(_("floating point constant truncated to integer"));
       else
        {
-         gcc_assert(!integer_type->is_abstract());
+         go_assert(!integer_type->is_abstract());
          mpz_t ival;
          mpz_init(ival);
          mpfr_get_z(ival, this->val_, GMP_RNDN);
@@ -2018,26 +2182,27 @@ Float_expression::do_get_tree(Translate_context* context)
   Gogo* gogo = context->gogo();
   tree type;
   if (this->type_ != NULL && !this->type_->is_abstract())
-    type = this->type_->get_tree(gogo);
+    type = type_to_tree(this->type_->get_backend(gogo));
   else if (this->type_ != NULL && this->type_->integer_type() != NULL)
     {
       // We have an abstract integer type.  We just hope for the best.
-      type = Type::lookup_integer_type("int")->get_tree(gogo);
+      type = type_to_tree(Type::lookup_integer_type("int")->get_backend(gogo));
     }
   else
     {
       // If we still have an abstract type here, then this is being
       // used in a constant expression which didn't get reduced.  We
       // just use float64 and hope for the best.
-      type = Type::lookup_float_type("float64")->get_tree(gogo);
+      Type* ft = Type::lookup_float_type("float64");
+      type = type_to_tree(ft->get_backend(gogo));
     }
   return Expression::float_constant_tree(this->val_, type);
 }
 
-// Write a floating point number to export data.
+// Write a floating point number to a string dump.
 
 void
-Float_expression::export_float(Export *exp, const mpfr_t val)
+Float_expression::export_float(String_dump *exp, const mpfr_t val)
 {
   mp_exp_t exponent;
   char* s = mpfr_get_str(NULL, &exponent, 10, 0, val, GMP_RNDN);
@@ -2061,6 +2226,14 @@ Float_expression::do_export(Export* exp) const
   exp->write_c_string(" ");
 }
 
+// Dump a floating point number to the dump file.
+
+void
+Float_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  Float_expression::export_float(ast_dump_context, this->val_);
+}
+
 // Make a float expression.
 
 Expression*
@@ -2091,10 +2264,15 @@ class Complex_expression : public Expression
   static bool
   check_constant(mpfr_t real, mpfr_t imag, Type*, source_location);
 
-  // Write REAL/IMAG to export data.
+  // Write REAL/IMAG to string dump.
   static void
-  export_complex(Export* exp, const mpfr_t real, const mpfr_t val);
+  export_complex(String_dump* exp, const mpfr_t real, const mpfr_t val);
 
+  // Write REAL/IMAG to dump context.
+  static void
+  dump_complex(Ast_dump_context* ast_dump_context, 
+              const mpfr_t real, const mpfr_t val);
+  
  protected:
   bool
   do_is_constant() const
@@ -2125,6 +2303,9 @@ class Complex_expression : public Expression
   void
   do_export(Export*) const;
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+  
  private:
   // The real part.
   mpfr_t real_;
@@ -2142,16 +2323,8 @@ Complex_expression::constrain_complex(mpfr_t real, mpfr_t imag, Type* type)
   Complex_type* ctype = type->complex_type();
   if (ctype != NULL && !ctype->is_abstract())
     {
-      tree type_tree = ctype->type_tree();
-
-      REAL_VALUE_TYPE rvt;
-      real_from_mpfr(&rvt, real, TREE_TYPE(type_tree), GMP_RNDN);
-      real_convert(&rvt, TYPE_MODE(TREE_TYPE(type_tree)), &rvt);
-      mpfr_from_real(real, &rvt, GMP_RNDN);
-
-      real_from_mpfr(&rvt, imag, TREE_TYPE(type_tree), GMP_RNDN);
-      real_convert(&rvt, TYPE_MODE(TREE_TYPE(type_tree)), &rvt);
-      mpfr_from_real(imag, &rvt, GMP_RNDN);
+      mpfr_prec_round(real, ctype->bits() / 2, GMP_RNDN);
+      mpfr_prec_round(imag, ctype->bits() / 2, GMP_RNDN);
     }
 }
 
@@ -2218,7 +2391,7 @@ Complex_expression::check_constant(mpfr_t real, mpfr_t imag, Type* type,
       max_exp = 1024;
       break;
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 
   // A NaN or Infinity always fits in the range of the type.
@@ -2264,13 +2437,14 @@ Complex_expression::do_get_tree(Translate_context* context)
   Gogo* gogo = context->gogo();
   tree type;
   if (this->type_ != NULL && !this->type_->is_abstract())
-    type = this->type_->get_tree(gogo);
+    type = type_to_tree(this->type_->get_backend(gogo));
   else
     {
       // If we still have an abstract type here, this this is being
       // used in a constant expression which didn't get reduced.  We
       // just use complex128 and hope for the best.
-      type = Type::lookup_complex_type("complex128")->get_tree(gogo);
+      Type* ct = Type::lookup_complex_type("complex128");
+      type = type_to_tree(ct->get_backend(gogo));
     }
   return Expression::complex_constant_tree(this->real_, this->imag_, type);
 }
@@ -2278,7 +2452,7 @@ Complex_expression::do_get_tree(Translate_context* context)
 // Write REAL/IMAG to export data.
 
 void
-Complex_expression::export_complex(Export* exp, const mpfr_t real,
+Complex_expression::export_complex(String_dump* exp, const mpfr_t real,
                                   const mpfr_t imag)
 {
   if (!mpfr_zero_p(real))
@@ -2301,6 +2475,16 @@ Complex_expression::do_export(Export* exp) const
   exp->write_c_string(" ");
 }
 
+// Dump a complex expression to the dump file.
+
+void
+Complex_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  Complex_expression::export_complex(ast_dump_context,
+                                      this->real_,
+                                      this->imag_);
+}
+
 // Make a complex expression.
 
 Expression*
@@ -2350,10 +2534,6 @@ class Const_expression : public Expression
   named_object()
   { return this->constant_; }
 
-  const std::string&
-  name() const
-  { return this->constant_->name(); }
-
   // Check that the initializer does not refer to the constant itself.
   void
   check_for_init_loop();
@@ -2363,7 +2543,7 @@ class Const_expression : public Expression
   do_traverse(Traverse*);
 
   Expression*
-  do_lower(Gogo*, Named_object*, int);
+  do_lower(Gogo*, Named_object*, Statement_inserter*, int);
 
   bool
   do_is_constant() const
@@ -2406,6 +2586,9 @@ class Const_expression : public Expression
   do_export(Export* exp) const
   { this->constant_->const_value()->expr()->export_expression(exp); }
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+
  private:
   // The constant.
   Named_object* constant_;
@@ -2431,7 +2614,8 @@ Const_expression::do_traverse(Traverse* traverse)
 // predeclared constant iota into an integer value.
 
 Expression*
-Const_expression::do_lower(Gogo* gogo, Named_object*, int iota_value)
+Const_expression::do_lower(Gogo* gogo, Named_object*,
+                          Statement_inserter*, int iota_value)
 {
   if (this->constant_->const_value()->expr()->classification()
       == EXPRESSION_IOTA)
@@ -2639,7 +2823,7 @@ Const_expression::do_determine_type(const Type_context* context)
 void
 Const_expression::check_for_init_loop()
 {
-  if (this->type_ != NULL && this->type_->is_error_type())
+  if (this->type_ != NULL && this->type_->is_error())
     return;
 
   if (this->seen_)
@@ -2658,7 +2842,7 @@ Const_expression::check_for_init_loop()
 
   if (find_named_object.found())
     {
-      if (this->type_ == NULL || !this->type_->is_error_type())
+      if (this->type_ == NULL || !this->type_->is_error())
        {
          this->report_error(_("constant refers to itself"));
          this->type_ = Type::make_error_type();
@@ -2672,7 +2856,7 @@ Const_expression::check_for_init_loop()
 void
 Const_expression::do_check_types(Gogo*)
 {
-  if (this->type_ != NULL && this->type_->is_error_type())
+  if (this->type_ != NULL && this->type_->is_error())
     return;
 
   this->check_for_init_loop();
@@ -2720,7 +2904,7 @@ Const_expression::do_get_tree(Translate_context* context)
     type_tree = NULL_TREE;
   else
     {
-      type_tree = this->type_->get_tree(gogo);
+      type_tree = type_to_tree(this->type_->get_backend(gogo));
       if (type_tree == error_mark_node)
        return error_mark_node;
     }
@@ -2782,10 +2966,18 @@ Const_expression::do_get_tree(Translate_context* context)
   else if (TREE_CODE(type_tree) == COMPLEX_TYPE)
     ret = fold(convert_to_complex(type_tree, const_tree));
   else
-    gcc_unreachable();
+    go_unreachable();
   return ret;
 }
 
+// Dump ast representation for constant expression.
+
+void
+Const_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->ostream() << this->constant_->name();
+}
+
 // Make a reference to a constant in an expression.
 
 Expression*
@@ -2867,6 +3059,10 @@ class Nil_expression : public Expression
   void
   do_export(Export* exp) const
   { exp->write_c_string("nil"); }
+
+  void
+  do_dump_expression(Ast_dump_context* ast_dump_context) const
+  { ast_dump_context->ostream() << "nil"; }
 };
 
 // Import a nil expression.
@@ -2900,13 +3096,17 @@ class Iota_expression : public Parser_expression
 
  protected:
   Expression*
-  do_lower(Gogo*, Named_object*, int)
-  { gcc_unreachable(); }
+  do_lower(Gogo*, Named_object*, Statement_inserter*, int)
+  { go_unreachable(); }
 
   // There should only ever be one of these.
   Expression*
   do_copy()
-  { gcc_unreachable(); }
+  { go_unreachable(); }
+  
+  void
+  do_dump_expression(Ast_dump_context* ast_dump_context) const
+  { ast_dump_context->ostream() << "iota"; } 
 };
 
 // Make an iota expression.  This is only called for one case: the
@@ -2957,7 +3157,7 @@ class Type_conversion_expression : public Expression
   do_traverse(Traverse* traverse);
 
   Expression*
-  do_lower(Gogo*, Named_object*, int);
+  do_lower(Gogo*, Named_object*, Statement_inserter*, int);
 
   bool
   do_is_constant() const
@@ -3002,6 +3202,9 @@ class Type_conversion_expression : public Expression
   void
   do_export(Export*) const;
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+
  private:
   // The type to convert to.
   Type* type_;
@@ -3026,7 +3229,8 @@ Type_conversion_expression::do_traverse(Traverse* traverse)
 // Convert to a constant at lowering time.
 
 Expression*
-Type_conversion_expression::do_lower(Gogo*, Named_object*, int)
+Type_conversion_expression::do_lower(Gogo*, Named_object*,
+                                    Statement_inserter*, int)
 {
   Type* type = this->type_;
   Expression* val = this->expr_;
@@ -3110,7 +3314,7 @@ Type_conversion_expression::do_lower(Gogo*, Named_object*, int)
       mpfr_clear(imag);
     }
 
-  if (type->is_open_array_type() && type->named_type() == NULL)
+  if (type->is_slice_type() && type->named_type() == NULL)
     {
       Type* element_type = type->array_type()->element_type()->forwarded();
       bool is_byte = element_type == Type::lookup_integer_type("uint8");
@@ -3322,14 +3526,8 @@ Type_conversion_expression::do_check_types(Gogo*)
   Type* expr_type = this->expr_->type();
   std::string reason;
 
-  if (type->is_error_type()
-      || type->is_undefined()
-      || expr_type->is_error_type()
-      || expr_type->is_undefined())
+  if (type->is_error() || expr_type->is_error())
     {
-      // Make sure we emit an error for an undefined type.
-      type->base();
-      expr_type->base();
       this->set_is_error();
       return;
     }
@@ -3352,7 +3550,7 @@ tree
 Type_conversion_expression::do_get_tree(Translate_context* context)
 {
   Gogo* gogo = context->gogo();
-  tree type_tree = this->type_->get_tree(gogo);
+  tree type_tree = type_to_tree(this->type_->get_backend(gogo));
   tree expr_tree = this->expr_->get_tree(context);
 
   if (type_tree == error_mark_node
@@ -3376,7 +3574,7 @@ Type_conversion_expression::do_get_tree(Translate_context* context)
          || expr_type->is_unsafe_pointer_type())
        ret = fold(convert_to_integer(type_tree, expr_tree));
       else
-       gcc_unreachable();
+       go_unreachable();
     }
   else if (type->float_type() != NULL)
     {
@@ -3384,14 +3582,14 @@ Type_conversion_expression::do_get_tree(Translate_context* context)
          || expr_type->float_type() != NULL)
        ret = fold(convert_to_real(type_tree, expr_tree));
       else
-       gcc_unreachable();
+       go_unreachable();
     }
   else if (type->complex_type() != NULL)
     {
       if (expr_type->complex_type() != NULL)
        ret = fold(convert_to_complex(type_tree, expr_tree));
       else
-       gcc_unreachable();
+       go_unreachable();
     }
   else if (type->is_string_type()
           && expr_type->integer_type() != NULL)
@@ -3430,11 +3628,11 @@ Type_conversion_expression::do_get_tree(Translate_context* context)
        expr_tree = save_expr(expr_tree);
       Array_type* a = t->array_type();
       Type* e = a->element_type()->forwarded();
-      gcc_assert(e->integer_type() != NULL);
+      go_assert(e->integer_type() != NULL);
       tree valptr = fold_convert(const_ptr_type_node,
                                 a->value_pointer_tree(gogo, expr_tree));
       tree len = a->length_tree(gogo, expr_tree);
-      len = fold_convert_loc(this->location(), size_type_node, len);
+      len = fold_convert_loc(this->location(), integer_type_node, len);
       if (e->integer_type()->is_unsigned()
          && e->integer_type()->bits() == 8)
        {
@@ -3446,12 +3644,12 @@ Type_conversion_expression::do_get_tree(Translate_context* context)
                                   type_tree,
                                   const_ptr_type_node,
                                   valptr,
-                                  size_type_node,
+                                  integer_type_node,
                                   len);
        }
       else
        {
-         gcc_assert(e == Type::lookup_integer_type("int"));
+         go_assert(e == Type::lookup_integer_type("int"));
          static tree int_array_to_string_fndecl;
          ret = Gogo::call_builtin(&int_array_to_string_fndecl,
                                   this->location(),
@@ -3460,14 +3658,14 @@ Type_conversion_expression::do_get_tree(Translate_context* context)
                                   type_tree,
                                   const_ptr_type_node,
                                   valptr,
-                                  size_type_node,
+                                  integer_type_node,
                                   len);
        }
     }
-  else if (type->is_open_array_type() && expr_type->is_string_type())
+  else if (type->is_slice_type() && expr_type->is_string_type())
     {
       Type* e = type->array_type()->element_type()->forwarded();
-      gcc_assert(e->integer_type() != NULL);
+      go_assert(e->integer_type() != NULL);
       if (e->integer_type()->is_unsigned()
          && e->integer_type()->bits() == 8)
        {
@@ -3482,7 +3680,7 @@ Type_conversion_expression::do_get_tree(Translate_context* context)
        }
       else
        {
-         gcc_assert(e == Type::lookup_integer_type("int"));
+         go_assert(e == Type::lookup_integer_type("int"));
          static tree string_to_int_array_fndecl;
          ret = Gogo::call_builtin(&string_to_int_array_fndecl,
                                   this->location(),
@@ -3537,6 +3735,18 @@ Type_conversion_expression::do_import(Import* imp)
   return Expression::make_cast(type, val, imp->location());
 }
 
+// Dump ast representation for a type conversion expression.
+
+void
+Type_conversion_expression::do_dump_expression(
+    Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->dump_type(this->type_);
+  ast_dump_context->ostream() << "(";
+  ast_dump_context->dump_expression(this->expr_);
+  ast_dump_context->ostream() << ") ";
+}
+
 // Make a type cast expression.
 
 Expression*
@@ -3547,6 +3757,148 @@ Expression::make_cast(Type* type, Expression* val, source_location location)
   return new Type_conversion_expression(type, val, location);
 }
 
+// An unsafe type conversion, used to pass values to builtin functions.
+
+class Unsafe_type_conversion_expression : public Expression
+{
+ public:
+  Unsafe_type_conversion_expression(Type* type, Expression* expr,
+                                   source_location location)
+    : Expression(EXPRESSION_UNSAFE_CONVERSION, location),
+      type_(type), expr_(expr)
+  { }
+
+ protected:
+  int
+  do_traverse(Traverse* traverse);
+
+  Type*
+  do_type()
+  { return this->type_; }
+
+  void
+  do_determine_type(const Type_context*)
+  { this->expr_->determine_type_no_context(); }
+
+  Expression*
+  do_copy()
+  {
+    return new Unsafe_type_conversion_expression(this->type_,
+                                                this->expr_->copy(),
+                                                this->location());
+  }
+
+  tree
+  do_get_tree(Translate_context*);
+
+  void
+  do_dump_expression(Ast_dump_context*) const;
+
+ private:
+  // The type to convert to.
+  Type* type_;
+  // The expression to convert.
+  Expression* expr_;
+};
+
+// Traversal.
+
+int
+Unsafe_type_conversion_expression::do_traverse(Traverse* traverse)
+{
+  if (Expression::traverse(&this->expr_, traverse) == TRAVERSE_EXIT
+      || Type::traverse(this->type_, traverse) == TRAVERSE_EXIT)
+    return TRAVERSE_EXIT;
+  return TRAVERSE_CONTINUE;
+}
+
+// Convert to backend representation.
+
+tree
+Unsafe_type_conversion_expression::do_get_tree(Translate_context* context)
+{
+  // We are only called for a limited number of cases.
+
+  Type* t = this->type_;
+  Type* et = this->expr_->type();
+
+  tree type_tree = type_to_tree(this->type_->get_backend(context->gogo()));
+  tree expr_tree = this->expr_->get_tree(context);
+  if (type_tree == error_mark_node || expr_tree == error_mark_node)
+    return error_mark_node;
+
+  source_location loc = this->location();
+
+  bool use_view_convert = false;
+  if (t->is_slice_type())
+    {
+      go_assert(et->is_slice_type());
+      use_view_convert = true;
+    }
+  else if (t->map_type() != NULL)
+    go_assert(et->map_type() != NULL);
+  else if (t->channel_type() != NULL)
+    go_assert(et->channel_type() != NULL);
+  else if (t->points_to() != NULL && t->points_to()->channel_type() != NULL)
+    go_assert((et->points_to() != NULL
+               && et->points_to()->channel_type() != NULL)
+              || et->is_nil_type());
+  else if (t->points_to() != NULL)
+    go_assert(et->points_to() != NULL || et->is_nil_type());
+  else if (et->is_unsafe_pointer_type())
+    go_assert(t->points_to() != NULL);
+  else if (t->interface_type() != NULL && !t->interface_type()->is_empty())
+    {
+      go_assert(et->interface_type() != NULL
+                && !et->interface_type()->is_empty());
+      use_view_convert = true;
+    }
+  else if (t->interface_type() != NULL && t->interface_type()->is_empty())
+    {
+      go_assert(et->interface_type() != NULL
+                && et->interface_type()->is_empty());
+      use_view_convert = true;
+    }
+  else if (t->integer_type() != NULL)
+    {
+      go_assert(et->is_boolean_type()
+                || et->integer_type() != NULL
+                || et->function_type() != NULL
+                || et->points_to() != NULL
+                || et->map_type() != NULL
+                || et->channel_type() != NULL);
+      return convert_to_integer(type_tree, expr_tree);
+    }
+  else
+    go_unreachable();
+
+  if (use_view_convert)
+    return fold_build1_loc(loc, VIEW_CONVERT_EXPR, type_tree, expr_tree);
+  else
+    return fold_convert_loc(loc, type_tree, expr_tree);
+}
+
+// Dump ast representation for an unsafe type conversion expression.
+
+void
+Unsafe_type_conversion_expression::do_dump_expression(
+    Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->dump_type(this->type_);
+  ast_dump_context->ostream() << "(";
+  ast_dump_context->dump_expression(this->expr_);
+  ast_dump_context->ostream() << ") ";
+}
+
+// Make an unsafe type conversion expression.
+
+Expression*
+Expression::make_unsafe_cast(Type* type, Expression* expr,
+                            source_location location)
+{
+  return new Unsafe_type_conversion_expression(type, expr, location);
+}
+
 // Unary expressions.
 
 class Unary_expression : public Expression
@@ -3554,7 +3906,7 @@ class Unary_expression : public Expression
  public:
   Unary_expression(Operator op, Expression* expr, source_location location)
     : Expression(EXPRESSION_UNARY, location),
-      op_(op), escapes_(true), expr_(expr)
+      op_(op), escapes_(true), create_temp_(false), expr_(expr)
   { }
 
   // Return the operator.
@@ -3571,10 +3923,19 @@ class Unary_expression : public Expression
   void
   set_does_not_escape()
   {
-    gcc_assert(this->op_ == OPERATOR_AND);
+    go_assert(this->op_ == OPERATOR_AND);
     this->escapes_ = false;
   }
 
+  // Record that this is an address expression which should create a
+  // temporary variable if necessary.  This is used for method calls.
+  void
+  set_create_temp()
+  {
+    go_assert(this->op_ == OPERATOR_AND);
+    this->create_temp_ = true;
+  }
+
   // Apply unary opcode OP to UVAL, setting VAL.  Return true if this
   // could be done, false if not.
   static bool
@@ -3601,7 +3962,7 @@ class Unary_expression : public Expression
   { return Expression::traverse(&this->expr_, traverse); }
 
   Expression*
-  do_lower(Gogo*, Named_object*, int);
+  do_lower(Gogo*, Named_object*, Statement_inserter*, int);
 
   bool
   do_is_constant() const;
@@ -3641,12 +4002,18 @@ class Unary_expression : public Expression
   void
   do_export(Export*) const;
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+
  private:
   // The unary operator to apply.
   Operator op_;
   // Normally true.  False if this is an address expression which does
   // not escape the current function.
   bool escapes_;
+  // True if this is an address expression which should create a
+  // temporary variable if necessary.
+  bool create_temp_;
   // The operand.
   Expression* expr_;
 };
@@ -3656,7 +4023,7 @@ class Unary_expression : public Expression
 // instead.
 
 Expression*
-Unary_expression::do_lower(Gogo*, Named_object*, int)
+Unary_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
 {
   source_location loc = this->location();
   Operator op = this->op_;
@@ -3694,6 +4061,14 @@ Unary_expression::do_lower(Gogo*, Named_object*, int)
        }
     }
 
+  // Catching an invalid indirection of unsafe.Pointer here avoid
+  // having to deal with TYPE_VOID in other places.
+  if (op == OPERATOR_MULT && expr->type()->is_unsafe_pointer_type())
+    {
+      error_at(this->location(), "invalid indirect of %<unsafe.Pointer%>");
+      return Expression::make_error(this->location());
+    }
+
   if (op == OPERATOR_PLUS || op == OPERATOR_MINUS
       || op == OPERATOR_NOT || op == OPERATOR_XOR)
     {
@@ -3823,7 +4198,7 @@ Unary_expression::eval_integer(Operator op, Type* utype, mpz_t uval, mpz_t val,
 
          size_t ecount;
          mpz_export(phwi, &ecount, -1, sizeof(HOST_WIDE_INT), 0, 0, uval);
-         gcc_assert(ecount <= count);
+         go_assert(ecount <= count);
 
          // Trim down to the number of words required by the type.
          size_t obits = utype->integer_type()->bits();
@@ -3831,7 +4206,7 @@ Unary_expression::eval_integer(Operator op, Type* utype, mpz_t uval, mpz_t val,
            ++obits;
          size_t ocount = ((obits + HOST_BITS_PER_WIDE_INT - 1)
                           / HOST_BITS_PER_WIDE_INT);
-         gcc_assert(ocount <= ocount);
+         go_assert(ocount <= count);
 
          for (size_t i = 0; i < ocount; ++i)
            phwi[i] = ~phwi[i];
@@ -3850,7 +4225,7 @@ Unary_expression::eval_integer(Operator op, Type* utype, mpz_t uval, mpz_t val,
     case OPERATOR_MULT:
       return false;
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 }
 
@@ -3874,7 +4249,7 @@ Unary_expression::eval_float(Operator op, mpfr_t uval, mpfr_t val)
     case OPERATOR_MULT:
       return false;
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 }
 
@@ -3901,7 +4276,7 @@ Unary_expression::eval_complex(Operator op, mpfr_t rval, mpfr_t ival,
     case OPERATOR_MULT:
       return false;
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 }
 
@@ -3987,7 +4362,7 @@ Unary_expression::do_type()
       }
 
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 }
 
@@ -4028,7 +4403,7 @@ Unary_expression::do_determine_type(const Type_context* context)
       break;
 
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 }
 
@@ -4038,7 +4413,7 @@ void
 Unary_expression::do_check_types(Gogo*)
 {
   Type* type = this->expr_->type();
-  if (type->is_error_type())
+  if (type->is_error())
     {
       this->set_is_error();
       return;
@@ -4063,7 +4438,10 @@ Unary_expression::do_check_types(Gogo*)
 
     case OPERATOR_AND:
       if (!this->expr_->is_addressable())
-       this->report_error(_("invalid operand for unary %<&%>"));
+       {
+         if (!this->create_temp_)
+           this->report_error(_("invalid operand for unary %<&%>"));
+       }
       else
        this->expr_->address_taken(this->escapes_);
       break;
@@ -4075,7 +4453,7 @@ Unary_expression::do_check_types(Gogo*)
       break;
 
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 }
 
@@ -4121,12 +4499,15 @@ Unary_expression::do_get_tree(Translate_context* context)
       return fold_build1_loc(loc, BIT_NOT_EXPR, TREE_TYPE(expr), expr);
 
     case OPERATOR_AND:
-      // We should not see a non-constant constructor here; cases
-      // where we would see one should have been moved onto the heap
-      // at parse time.  Taking the address of a nonconstant
-      // constructor will not do what the programmer expects.
-      gcc_assert(TREE_CODE(expr) != CONSTRUCTOR || TREE_CONSTANT(expr));
-      gcc_assert(TREE_CODE(expr) != ADDR_EXPR);
+      if (!this->create_temp_)
+       {
+         // We should not see a non-constant constructor here; cases
+         // where we would see one should have been moved onto the
+         // heap at parse time.  Taking the address of a nonconstant
+         // constructor will not do what the programmer expects.
+         go_assert(TREE_CODE(expr) != CONSTRUCTOR || TREE_CONSTANT(expr));
+         go_assert(TREE_CODE(expr) != ADDR_EXPR);
+       }
 
       // Build a decl for a constant constructor.
       if (TREE_CODE(expr) == CONSTRUCTOR && TREE_CONSTANT(expr))
@@ -4145,11 +4526,27 @@ Unary_expression::do_get_tree(Translate_context* context)
          expr = decl;
        }
 
+      if (this->create_temp_
+         && !TREE_ADDRESSABLE(TREE_TYPE(expr))
+         && !DECL_P(expr)
+         && TREE_CODE(expr) != INDIRECT_REF
+         && TREE_CODE(expr) != COMPONENT_REF)
+       {
+         tree tmp = create_tmp_var(TREE_TYPE(expr), get_name(expr));
+         DECL_IGNORED_P(tmp) = 1;
+         DECL_INITIAL(tmp) = expr;
+         TREE_ADDRESSABLE(tmp) = 1;
+         return build2_loc(loc, COMPOUND_EXPR,
+                           build_pointer_type(TREE_TYPE(expr)),
+                           build1_loc(loc, DECL_EXPR, void_type_node, tmp),
+                           build_fold_addr_expr_loc(loc, tmp));
+       }
+
       return build_fold_addr_expr_loc(loc, expr);
 
     case OPERATOR_MULT:
       {
-       gcc_assert(POINTER_TYPE_P(TREE_TYPE(expr)));
+       go_assert(POINTER_TYPE_P(TREE_TYPE(expr)));
 
        // If we are dereferencing the pointer to a large struct, we
        // need to check for nil.  We don't bother to check for small
@@ -4177,7 +4574,7 @@ Unary_expression::do_get_tree(Translate_context* context)
        if (TREE_TYPE(TREE_TYPE(expr)) == ptr_type_node)
          {
            Type* pt = this->expr_->type()->points_to();
-           tree ind = pt->get_tree(context->gogo());
+           tree ind = type_to_tree(pt->get_backend(context->gogo()));
            expr = fold_convert_loc(loc, build_pointer_type(ind), expr);
          }
 
@@ -4185,7 +4582,7 @@ Unary_expression::do_get_tree(Translate_context* context)
       }
 
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 }
 
@@ -4211,7 +4608,7 @@ Unary_expression::do_export(Export* exp) const
     case OPERATOR_AND:
     case OPERATOR_MULT:
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
   this->expr_->export_expression(exp);
 }
@@ -4237,13 +4634,24 @@ Unary_expression::do_import(Import* imp)
       op = OPERATOR_XOR;
       break;
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
   imp->require_c_string(" ");
   Expression* expr = Expression::import_expression(imp);
   return Expression::make_unary(op, expr, imp->location());
 }
 
+// Dump ast representation of an unary expression.
+
+void
+Unary_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->dump_operator(this->op_);
+  ast_dump_context->ostream() << "(";
+  ast_dump_context->dump_expression(this->expr_);
+  ast_dump_context->ostream() << ") ";
+}
+
 // Make a unary expression.
 
 Expression*
@@ -4302,7 +4710,7 @@ Binary_expression::compare_integer(Operator op, mpz_t left_val,
     case OPERATOR_GE:
       return i >= 0;
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 }
 
@@ -4342,7 +4750,7 @@ Binary_expression::compare_float(Operator op, Type* type, mpfr_t left_val,
     case OPERATOR_GE:
       return i >= 0;
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 }
 
@@ -4383,7 +4791,7 @@ Binary_expression::compare_complex(Operator op, Type* type,
     case OPERATOR_NOTEQ:
       return !is_equal;
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 }
 
@@ -4490,7 +4898,7 @@ Binary_expression::eval_integer(Operator op, Type* left_type, mpz_t left_val,
       }
       break;
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 
   Type* type = left_type;
@@ -4575,7 +4983,7 @@ Binary_expression::eval_float(Operator op, Type* left_type, mpfr_t left_val,
     case OPERATOR_RSHIFT:
       return false;
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 
   Type* type = left_type;
@@ -4934,7 +5342,7 @@ Binary_expression::eval_complex(Operator op, Type* left_type,
     case OPERATOR_RSHIFT:
       return false;
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 
   Type* type = left_type;
@@ -4977,7 +5385,7 @@ Binary_expression::eval_complex(Operator op, Type* left_type,
 // constants.
 
 Expression*
-Binary_expression::do_lower(Gogo*, Named_object*, int)
+Binary_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
 {
   source_location location = this->location();
   Operator op = this->op_;
@@ -5029,7 +5437,7 @@ Binary_expression::do_lower(Gogo*, Named_object*, int)
                                                right_type, right_val,
                                                location, val))
              {
-               gcc_assert(op != OPERATOR_OROR && op != OPERATOR_ANDAND);
+               go_assert(op != OPERATOR_OROR && op != OPERATOR_ANDAND);
                Type* type;
                if (op == OPERATOR_LSHIFT || op == OPERATOR_RSHIFT)
                  type = left_type;
@@ -5113,7 +5521,7 @@ Binary_expression::do_lower(Gogo*, Named_object*, int)
                                              right_type, right_val, val,
                                              location))
              {
-               gcc_assert(op != OPERATOR_OROR && op != OPERATOR_ANDAND
+               go_assert(op != OPERATOR_OROR && op != OPERATOR_ANDAND
                           && op != OPERATOR_LSHIFT && op != OPERATOR_RSHIFT);
                Type* type;
                if (left_type == NULL)
@@ -5204,7 +5612,7 @@ Binary_expression::do_lower(Gogo*, Named_object*, int)
                                                real, imag,
                                                location))
              {
-               gcc_assert(op != OPERATOR_OROR && op != OPERATOR_ANDAND
+               go_assert(op != OPERATOR_OROR && op != OPERATOR_ANDAND
                           && op != OPERATOR_LSHIFT && op != OPERATOR_RSHIFT);
                Type* type;
                if (left_type == NULL)
@@ -5262,9 +5670,53 @@ Binary_expression::do_lower(Gogo*, Named_object*, int)
        return Expression::make_string(left_string + right_string, location);
     }
 
-  return this;
-}
-
+  // Special case for shift of a floating point constant.
+  if (op == OPERATOR_LSHIFT || op == OPERATOR_RSHIFT)
+    {
+      mpfr_t left_val;
+      mpfr_init(left_val);
+      Type* left_type;
+      mpz_t right_val;
+      mpz_init(right_val);
+      Type* right_type;
+      if (left->float_constant_value(left_val, &left_type)
+         && right->integer_constant_value(false, right_val, &right_type)
+         && mpfr_integer_p(left_val)
+         && (left_type == NULL
+             || left_type->is_abstract()
+             || left_type->integer_type() != NULL))
+       {
+         mpz_t left_int;
+         mpz_init(left_int);
+         mpfr_get_z(left_int, left_val, GMP_RNDN);
+
+         mpz_t val;
+         mpz_init(val);
+
+         Expression* ret = NULL;
+         if (Binary_expression::eval_integer(op, left_type, left_int,
+                                             right_type, right_val,
+                                             location, val))
+           ret = Expression::make_integer(&val, left_type, location);
+
+         mpz_clear(left_int);
+         mpz_clear(val);
+
+         if (ret != NULL)
+           {
+             mpfr_clear(left_val);
+             mpz_clear(right_val);
+             return ret;
+           }
+       }
+
+      mpfr_clear(left_val);
+      mpz_clear(right_val);
+    }
+
+  return this;
+}
+
 // Return the integer constant value, if it has one.
 
 bool
@@ -5423,7 +5875,7 @@ Binary_expression::do_discarding_value()
   if (this->op_ == OPERATOR_OROR || this->op_ == OPERATOR_ANDAND)
     this->right_->discarding_value();
   else
-    this->warn_about_unused_value();
+    this->unused_value_error();
 }
 
 // Get type.
@@ -5458,9 +5910,9 @@ Binary_expression::do_type()
       {
        Type* left_type = this->left_->type();
        Type* right_type = this->right_->type();
-       if (left_type->is_error_type())
+       if (left_type->is_error())
          return left_type;
-       else if (right_type->is_error_type())
+       else if (right_type->is_error())
          return right_type;
        else if (!Type::are_compatible_for_binop(left_type, right_type))
          {
@@ -5492,7 +5944,7 @@ Binary_expression::do_type()
       return this->left_->type();
 
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 }
 
@@ -5530,14 +5982,8 @@ Binary_expression::do_determine_type(const Type_context* context)
   // Set the context for the left hand operand.
   if (is_shift_op)
     {
-      // The right hand operand plays no role in determining the type
-      // of the left hand operand.  A shift of an abstract integer in
-      // a string context gets special treatment, which may be a
-      // language bug.
-      if (subcontext.type != NULL
-         && subcontext.type->is_string_type()
-         && tleft->is_abstract())
-       error_at(this->location(), "shift of non-integer operand");
+      // The right hand operand of a shift plays no role in
+      // determining the type of the left hand operand.
     }
   else if (!tleft->is_abstract())
     subcontext.type = tleft;
@@ -5570,10 +6016,21 @@ Binary_expression::do_determine_type(const Type_context* context)
 
   this->left_->determine_type(&subcontext);
 
-  // The context for the right hand operand is the same as for the
-  // left hand operand, except for a shift operator.
   if (is_shift_op)
     {
+      // We may have inherited an unusable type for the shift operand.
+      // Give a useful error if that happened.
+      if (tleft->is_abstract()
+         && subcontext.type != NULL
+         && (this->left_->type()->integer_type() == NULL
+             || (subcontext.type->integer_type() == NULL
+                 && subcontext.type->float_type() == NULL
+                 && subcontext.type->complex_type() == NULL)))
+       this->report_error(("invalid context-determined non-integer type "
+                           "for shift operand"));
+
+      // The context for the right hand operand is the same as for the
+      // left hand operand, except for a shift operator.
       subcontext.type = Type::lookup_integer_type("uint");
       subcontext.may_be_abstract = false;
     }
@@ -5683,7 +6140,7 @@ Binary_expression::check_operator_type(Operator op, Type* type,
       break;
 
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 
   return true;
@@ -5699,7 +6156,7 @@ Binary_expression::do_check_types(Gogo*)
 
   Type* left_type = this->left_->type();
   Type* right_type = this->right_->type();
-  if (left_type->is_error_type() || right_type->is_error_type())
+  if (left_type->is_error() || right_type->is_error())
     {
       this->set_is_error();
       return;
@@ -5758,7 +6215,13 @@ Binary_expression::do_check_types(Gogo*)
          if (this->right_->integer_constant_value(true, val, &type))
            {
              if (mpz_sgn(val) < 0)
-               this->report_error(_("negative shift count"));
+               {
+                 this->report_error(_("negative shift count"));
+                 mpz_set_ui(val, 0);
+                 source_location rloc = this->right_->location();
+                 this->right_ = Expression::make_integer(&val, right_type,
+                                                         rloc);
+               }
            }
          mpz_clear(val);
        }
@@ -5843,15 +6306,16 @@ Binary_expression::do_get_tree(Translate_context* context)
       code = BIT_AND_EXPR;
       break;
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 
   tree type = use_left_type ? TREE_TYPE(left) : TREE_TYPE(right);
 
   if (this->left_->type()->is_string_type())
     {
-      gcc_assert(this->op_ == OPERATOR_PLUS);
-      tree string_type = Type::make_string_type()->get_tree(context->gogo());
+      go_assert(this->op_ == OPERATOR_PLUS);
+      Type* st = Type::make_string_type();
+      tree string_type = type_to_tree(st->get_backend(context->gogo()));
       static tree string_plus_decl;
       return Gogo::call_builtin(&string_plus_decl,
                                this->location(),
@@ -5903,8 +6367,8 @@ Binary_expression::do_get_tree(Translate_context* context)
   // This is not true in GENERIC, so we need to insert a conditional.
   if (is_shift_op)
     {
-      gcc_assert(INTEGRAL_TYPE_P(TREE_TYPE(left)));
-      gcc_assert(this->left_->type()->integer_type() != NULL);
+      go_assert(INTEGRAL_TYPE_P(TREE_TYPE(left)));
+      go_assert(this->left_->type()->integer_type() != NULL);
       int bits = TYPE_PRECISION(TREE_TYPE(left));
 
       tree compare = fold_build2(LT_EXPR, boolean_type_node, right,
@@ -6012,7 +6476,7 @@ Binary_expression::do_export(Export* exp) const
       exp->write_c_string(" &^ ");
       break;
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
   this->right_->export_expression(exp);
   exp->write_c_string(")");
@@ -6136,6 +6600,20 @@ Binary_expression::do_import(Import* imp)
   return Expression::make_binary(op, left, right, imp->location());
 }
 
+// Dump ast representation of a binary expression.
+
+void
+Binary_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->ostream() << "(";
+  ast_dump_context->dump_expression(this->left_);
+  ast_dump_context->ostream() << " ";
+  ast_dump_context->dump_operator(this->op_);
+  ast_dump_context->ostream() << " ";
+  ast_dump_context->dump_expression(this->right_);
+  ast_dump_context->ostream() << ") ";
+}
+
 // Make a binary expression.
 
 Expression*
@@ -6175,12 +6653,13 @@ Expression::comparison_tree(Translate_context* context, Operator op,
       code = GE_EXPR;
       break;
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 
   if (left_type->is_string_type() && right_type->is_string_type())
     {
-      tree string_type = Type::make_string_type()->get_tree(context->gogo());
+      Type* st = Type::make_string_type();
+      tree string_type = type_to_tree(st->get_backend(context->gogo()));
       static tree string_compare_decl;
       left_tree = Gogo::call_builtin(&string_compare_decl,
                                     location,
@@ -6236,7 +6715,8 @@ Expression::comparison_tree(Translate_context* context, Operator op,
        }
       arg = fold_convert_loc(location, ptr_type_node, arg);
 
-      tree descriptor = right_type->type_descriptor_pointer(context->gogo());
+      tree descriptor = right_type->type_descriptor_pointer(context->gogo(),
+                                                           location);
 
       if (left_type->interface_type()->is_empty())
        {
@@ -6325,12 +6805,12 @@ Expression::comparison_tree(Translate_context* context, Operator op,
        {
          if (left_type->interface_type()->is_empty())
            {
-             gcc_assert(op == OPERATOR_EQEQ || op == OPERATOR_NOTEQ);
+             go_assert(op == OPERATOR_EQEQ || op == OPERATOR_NOTEQ);
              std::swap(left_type, right_type);
              std::swap(left_tree, right_tree);
            }
-         gcc_assert(!left_type->interface_type()->is_empty());
-         gcc_assert(right_type->interface_type()->is_empty());
+         go_assert(!left_type->interface_type()->is_empty());
+         go_assert(right_type->interface_type()->is_empty());
          static tree interface_empty_compare_decl;
          left_tree = Gogo::call_builtin(&interface_empty_compare_decl,
                                         location,
@@ -6370,7 +6850,7 @@ Expression::comparison_tree(Translate_context* context, Operator op,
        {
          // An interface is nil if the first field is nil.
          tree left_type_tree = TREE_TYPE(left_tree);
-         gcc_assert(TREE_CODE(left_type_tree) == RECORD_TYPE);
+         go_assert(TREE_CODE(left_type_tree) == RECORD_TYPE);
          tree field = TYPE_FIELDS(left_type_tree);
          left_tree = build3(COMPONENT_REF, TREE_TYPE(field), left_tree,
                             field, NULL_TREE);
@@ -6378,7 +6858,7 @@ Expression::comparison_tree(Translate_context* context, Operator op,
        }
       else
        {
-         gcc_assert(POINTER_TYPE_P(TREE_TYPE(left_tree)));
+         go_assert(POINTER_TYPE_P(TREE_TYPE(left_tree)));
          right_tree = fold_convert(TREE_TYPE(left_tree), null_pointer_node);
        }
     }
@@ -6399,9 +6879,7 @@ Expression::comparison_tree(Translate_context* context, Operator op,
 int
 Bound_method_expression::do_traverse(Traverse* traverse)
 {
-  if (Expression::traverse(&this->expr_, traverse) == TRAVERSE_EXIT)
-    return TRAVERSE_EXIT;
-  return Expression::traverse(&this->method_, traverse);
+  return Expression::traverse(&this->expr_, traverse);
 }
 
 // Return the type of a bound method expression.  The type of this
@@ -6412,7 +6890,12 @@ Bound_method_expression::do_traverse(Traverse* traverse)
 Type*
 Bound_method_expression::do_type()
 {
-  return this->method_->type();
+  if (this->method_->is_function())
+    return this->method_->func_value()->type();
+  else if (this->method_->is_function_declaration())
+    return this->method_->func_declaration_value()->type();
+  else
+    return Type::make_error_type();
 }
 
 // Determine the types of a method expression.
@@ -6420,9 +6903,7 @@ Bound_method_expression::do_type()
 void
 Bound_method_expression::do_determine_type(const Type_context*)
 {
-  this->method_->determine_type_no_context();
-  Type* mtype = this->method_->type();
-  Function_type* fntype = mtype == NULL ? NULL : mtype->function_type();
+  Function_type* fntype = this->type()->function_type();
   if (fntype == NULL || !fntype->is_method())
     this->expr_->determine_type_no_context();
   else
@@ -6437,14 +6918,12 @@ Bound_method_expression::do_determine_type(const Type_context*)
 void
 Bound_method_expression::do_check_types(Gogo*)
 {
-  Type* type = this->method_->type()->deref();
-  if (type == NULL
-      || type->function_type() == NULL
-      || !type->function_type()->is_method())
+  if (!this->method_->is_function()
+      && !this->method_->is_function_declaration())
     this->report_error(_("object is not a method"));
   else
     {
-      Type* rtype = type->function_type()->receiver()->type()->deref();
+      Type* rtype = this->type()->function_type()->receiver()->type()->deref();
       Type* etype = (this->expr_type_ != NULL
                     ? this->expr_type_
                     : this->expr_->type());
@@ -6466,10 +6945,29 @@ Bound_method_expression::do_get_tree(Translate_context*)
   return error_mark_node;
 }
 
+// Dump ast representation of a bound method expression.
+
+void
+Bound_method_expression::do_dump_expression(Ast_dump_context* ast_dump_context)
+    const
+{
+  if (this->expr_type_ != NULL)
+    ast_dump_context->ostream() << "(";
+  ast_dump_context->dump_expression(this->expr_); 
+  if (this->expr_type_ != NULL) 
+    {
+      ast_dump_context->ostream() << ":";
+      ast_dump_context->dump_type(this->expr_type_);
+      ast_dump_context->ostream() << ")";
+    }
+    
+  ast_dump_context->ostream() << "." << this->method_->name();
+}
+
 // Make a method expression.
 
 Bound_method_expression*
-Expression::make_bound_method(Expression* expr, Expression* method,
+Expression::make_bound_method(Expression* expr, Named_object* method,
                              source_location location)
 {
   return new Bound_method_expression(expr, method, location);
@@ -6487,7 +6985,7 @@ class Builtin_call_expression : public Call_expression
  protected:
   // This overrides Call_expression::do_lower.
   Expression*
-  do_lower(Gogo*, Named_object*, int);
+  do_lower(Gogo*, Named_object*, Statement_inserter*, int);
 
   bool
   do_is_constant() const;
@@ -6501,6 +6999,9 @@ class Builtin_call_expression : public Call_expression
   bool
   do_complex_constant_value(mpfr_t, mpfr_t, Type**) const;
 
+  void
+  do_discarding_value();
+
   Type*
   do_type();
 
@@ -6541,7 +7042,6 @@ class Builtin_call_expression : public Call_expression
       BUILTIN_APPEND,
       BUILTIN_CAP,
       BUILTIN_CLOSE,
-      BUILTIN_CLOSED,
       BUILTIN_COMPLEX,
       BUILTIN_COPY,
       BUILTIN_IMAG,
@@ -6572,6 +7072,12 @@ class Builtin_call_expression : public Call_expression
   static Type*
   complex_type(Type*);
 
+  Expression*
+  lower_make();
+
+  bool
+  check_int_value(Expression*);
+
   // A pointer back to the general IR structure.  This avoids a global
   // variable, or passing it around everywhere.
   Gogo* gogo_;
@@ -6591,7 +7097,7 @@ Builtin_call_expression::Builtin_call_expression(Gogo* gogo,
     gogo_(gogo), code_(BUILTIN_INVALID), seen_(false)
 {
   Func_expression* fnexp = this->fn()->func_expression();
-  gcc_assert(fnexp != NULL);
+  go_assert(fnexp != NULL);
   const std::string& name(fnexp->named_object()->name());
   if (name == "append")
     this->code_ = BUILTIN_APPEND;
@@ -6599,8 +7105,6 @@ Builtin_call_expression::Builtin_call_expression(Gogo* gogo,
     this->code_ = BUILTIN_CAP;
   else if (name == "close")
     this->code_ = BUILTIN_CLOSE;
-  else if (name == "closed")
-    this->code_ = BUILTIN_CLOSED;
   else if (name == "complex")
     this->code_ = BUILTIN_COMPLEX;
   else if (name == "copy")
@@ -6630,7 +7134,7 @@ Builtin_call_expression::Builtin_call_expression(Gogo* gogo,
   else if (name == "Sizeof")
     this->code_ = BUILTIN_SIZEOF;
   else
-    gcc_unreachable();
+    go_unreachable();
 }
 
 // Return whether this is a call to recover.  This is a virtual
@@ -6650,7 +7154,7 @@ void
 Builtin_call_expression::do_set_recover_arg(Expression* arg)
 {
   const Expression_list* args = this->args();
-  gcc_assert(args == NULL || args->empty());
+  go_assert(args == NULL || args->empty());
   Expression_list* new_args = new Expression_list();
   new_args->push_back(arg);
   this->set_args(new_args);
@@ -6692,8 +7196,18 @@ Find_call_expression::expression(Expression** pexpr)
 // specific expressions.  We also convert to a constant if we can.
 
 Expression*
-Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function, int)
+Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function,
+                                 Statement_inserter* inserter, int)
 {
+  if (this->classification() == EXPRESSION_ERROR)
+    return this;
+
+  if (this->is_varargs() && this->code_ != BUILTIN_APPEND)
+    {
+      this->report_error(_("invalid use of %<...%> with builtin function"));
+      return Expression::make_error(this->location());
+    }
+
   if (this->code_ == BUILTIN_NEW)
     {
       const Expression_list* args = this->args();
@@ -6714,36 +7228,7 @@ Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function, int)
        }
     }
   else if (this->code_ == BUILTIN_MAKE)
-    {
-      const Expression_list* args = this->args();
-      if (args == NULL || args->size() < 1)
-       this->report_error(_("not enough arguments"));
-      else
-       {
-         Expression* arg = args->front();
-         if (!arg->is_type_expression())
-           {
-             error_at(arg->location(), "expected type");
-             this->set_is_error();
-           }
-         else
-           {
-             Expression_list* newargs;
-             if (args->size() == 1)
-               newargs = NULL;
-             else
-               {
-                 newargs = new Expression_list();
-                 Expression_list::const_iterator p = args->begin();
-                 ++p;
-                 for (; p != args->end(); ++p)
-                   newargs->push_back(*p);
-               }
-             return Expression::make_make(arg->type(), newargs,
-                                          this->location());
-           }
-       }
-    }
+    return this->lower_make();
   else if (this->is_constant())
     {
       // We can only lower len and cap if there are no function calls
@@ -6816,18 +7301,182 @@ Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function, int)
       if (args == NULL || args->empty())
        return this;
       Type* slice_type = args->front()->type();
-      if (!slice_type->is_open_array_type())
+      if (!slice_type->is_slice_type())
        {
          error_at(args->front()->location(), "argument 1 must be a slice");
          this->set_is_error();
          return this;
        }
-      return this->lower_varargs(gogo, function, slice_type, 2);
+      this->lower_varargs(gogo, function, inserter, slice_type, 2);
     }
 
   return this;
 }
 
+// Lower a make expression.
+
+Expression*
+Builtin_call_expression::lower_make()
+{
+  source_location loc = this->location();
+
+  const Expression_list* args = this->args();
+  if (args == NULL || args->size() < 1)
+    {
+      this->report_error(_("not enough arguments"));
+      return Expression::make_error(this->location());
+    }
+
+  Expression_list::const_iterator parg = args->begin();
+
+  Expression* first_arg = *parg;
+  if (!first_arg->is_type_expression())
+    {
+      error_at(first_arg->location(), "expected type");
+      this->set_is_error();
+      return Expression::make_error(this->location());
+    }
+  Type* type = first_arg->type();
+
+  bool is_slice = false;
+  bool is_map = false;
+  bool is_chan = false;
+  if (type->is_slice_type())
+    is_slice = true;
+  else if (type->map_type() != NULL)
+    is_map = true;
+  else if (type->channel_type() != NULL)
+    is_chan = true;
+  else
+    {
+      this->report_error(_("invalid type for make function"));
+      return Expression::make_error(this->location());
+    }
+
+  ++parg;
+  Expression* len_arg;
+  if (parg == args->end())
+    {
+      if (is_slice)
+       {
+         this->report_error(_("length required when allocating a slice"));
+         return Expression::make_error(this->location());
+       }
+
+      mpz_t zval;
+      mpz_init_set_ui(zval, 0);
+      len_arg = Expression::make_integer(&zval, NULL, loc);
+      mpz_clear(zval);
+    }
+  else
+    {
+      len_arg = *parg;
+      if (!this->check_int_value(len_arg))
+       {
+         this->report_error(_("bad size for make"));
+         return Expression::make_error(this->location());
+       }
+      ++parg;
+    }
+
+  Expression* cap_arg = NULL;
+  if (is_slice && parg != args->end())
+    {
+      cap_arg = *parg;
+      if (!this->check_int_value(cap_arg))
+       {
+         this->report_error(_("bad capacity when making slice"));
+         return Expression::make_error(this->location());
+       }
+      ++parg;
+    }
+
+  if (parg != args->end())
+    {
+      this->report_error(_("too many arguments to make"));
+      return Expression::make_error(this->location());
+    }
+
+  source_location type_loc = first_arg->location();
+  Expression* type_arg;
+  if (is_slice || is_chan)
+    type_arg = Expression::make_type_descriptor(type, type_loc);
+  else if (is_map)
+    type_arg = Expression::make_map_descriptor(type->map_type(), type_loc);
+  else
+    go_unreachable();
+
+  Expression* call;
+  if (is_slice)
+    {
+      if (cap_arg == NULL)
+       call = Runtime::make_call(Runtime::MAKESLICE1, loc, 2, type_arg,
+                                 len_arg);
+      else
+       call = Runtime::make_call(Runtime::MAKESLICE2, loc, 3, type_arg,
+                                 len_arg, cap_arg);
+    }
+  else if (is_map)
+    call = Runtime::make_call(Runtime::MAKEMAP, loc, 2, type_arg, len_arg);
+  else if (is_chan)
+    call = Runtime::make_call(Runtime::MAKECHAN, loc, 2, type_arg, len_arg);
+  else
+    go_unreachable();
+
+  return Expression::make_unsafe_cast(type, call, loc);
+}
+
+// Return whether an expression has an integer value.  Report an error
+// if not.  This is used when handling calls to the predeclared make
+// function.
+
+bool
+Builtin_call_expression::check_int_value(Expression* e)
+{
+  if (e->type()->integer_type() != NULL)
+    return true;
+
+  // Check for a floating point constant with integer value.
+  mpfr_t fval;
+  mpfr_init(fval);
+
+  Type* dummy;
+  if (e->float_constant_value(fval, &dummy) && mpfr_integer_p(fval))
+    {
+      mpz_t ival;
+      mpz_init(ival);
+
+      bool ok = false;
+
+      mpfr_clear_overflow();
+      mpfr_clear_erangeflag();
+      mpfr_get_z(ival, fval, GMP_RNDN);
+      if (!mpfr_overflow_p()
+         && !mpfr_erangeflag_p()
+         && mpz_sgn(ival) >= 0)
+       {
+         Named_type* ntype = Type::lookup_integer_type("int");
+         Integer_type* inttype = ntype->integer_type();
+         mpz_t max;
+         mpz_init_set_ui(max, 1);
+         mpz_mul_2exp(max, max, inttype->bits() - 1);
+         ok = mpz_cmp(ival, max) < 0;
+         mpz_clear(max);
+       }
+      mpz_clear(ival);
+
+      if (ok)
+       {
+         mpfr_clear(fval);
+         return true;
+       }
+    }
+
+  mpfr_clear(fval);
+
+  return false;
+}
+
 // Return the type of the real or imag functions, given the type of
 // the argument.  We need to map complex to float, complex64 to
 // float32, and complex128 to float64, so it has to be done by name.
@@ -6904,7 +7553,7 @@ Builtin_call_expression::do_is_constant() const
 
        if (arg_type->points_to() != NULL
            && arg_type->points_to()->array_type() != NULL
-           && !arg_type->points_to()->is_open_array_type())
+           && !arg_type->points_to()->is_slice_type())
          arg_type = arg_type->points_to();
 
        if (arg_type->array_type() != NULL
@@ -6983,7 +7632,7 @@ Builtin_call_expression::do_integer_constant_value(bool iota_is_constant,
 
       if (arg_type->points_to() != NULL
          && arg_type->points_to()->array_type() != NULL
-         && !arg_type->points_to()->is_open_array_type())
+         && !arg_type->points_to()->is_slice_type())
        arg_type = arg_type->points_to();
 
       if (arg_type->array_type() != NULL
@@ -7009,18 +7658,20 @@ Builtin_call_expression::do_integer_constant_value(bool iota_is_constant,
       if (arg == NULL)
        return false;
       Type* arg_type = arg->type();
-      if (arg_type->is_error_type() || arg_type->is_undefined())
+      if (arg_type->is_error())
        return false;
       if (arg_type->is_abstract())
        return false;
-      tree arg_type_tree = arg_type->get_tree(this->gogo_);
+      if (arg_type->named_type() != NULL)
+       arg_type->named_type()->convert(this->gogo_);
+      tree arg_type_tree = type_to_tree(arg_type->get_backend(this->gogo_));
       if (arg_type_tree == error_mark_node)
        return false;
       unsigned long val_long;
       if (this->code_ == BUILTIN_SIZEOF)
        {
          tree type_size = TYPE_SIZE_UNIT(arg_type_tree);
-         gcc_assert(TREE_CODE(type_size) == INTEGER_CST);
+         go_assert(TREE_CODE(type_size) == INTEGER_CST);
          if (TREE_INT_CST_HIGH(type_size) != 0)
            return false;
          unsigned HOST_WIDE_INT val_wide = TREE_INT_CST_LOW(type_size);
@@ -7040,7 +7691,7 @@ Builtin_call_expression::do_integer_constant_value(bool iota_is_constant,
            }
        }
       else
-       gcc_unreachable();
+       go_unreachable();
       mpz_set_ui(val, val_long);
       *ptype = NULL;
       return true;
@@ -7057,13 +7708,15 @@ Builtin_call_expression::do_integer_constant_value(bool iota_is_constant,
       Type* st = struct_expr->type();
       if (st->struct_type() == NULL)
        return false;
-      tree struct_tree = st->get_tree(this->gogo_);
-      gcc_assert(TREE_CODE(struct_tree) == RECORD_TYPE);
+      if (st->named_type() != NULL)
+       st->named_type()->convert(this->gogo_);
+      tree struct_tree = type_to_tree(st->get_backend(this->gogo_));
+      go_assert(TREE_CODE(struct_tree) == RECORD_TYPE);
       tree field = TYPE_FIELDS(struct_tree);
       for (unsigned int index = farg->field_index(); index > 0; --index)
        {
          field = DECL_CHAIN(field);
-         gcc_assert(field != NULL_TREE);
+         go_assert(field != NULL_TREE);
        }
       HOST_WIDE_INT offset_wide = int_byte_position (field);
       if (offset_wide < 0)
@@ -7158,6 +7811,44 @@ Builtin_call_expression::do_complex_constant_value(mpfr_t real, mpfr_t imag,
   return false;
 }
 
+// Give an error if we are discarding the value of an expression which
+// should not normally be discarded.  We don't give an error for
+// discarding the value of an ordinary function call, but we do for
+// builtin functions, purely for consistency with the gc compiler.
+
+void
+Builtin_call_expression::do_discarding_value()
+{
+  switch (this->code_)
+    {
+    case BUILTIN_INVALID:
+    default:
+      go_unreachable();
+
+    case BUILTIN_APPEND:
+    case BUILTIN_CAP:
+    case BUILTIN_COMPLEX:
+    case BUILTIN_IMAG:
+    case BUILTIN_LEN:
+    case BUILTIN_MAKE:
+    case BUILTIN_NEW:
+    case BUILTIN_REAL:
+    case BUILTIN_ALIGNOF:
+    case BUILTIN_OFFSETOF:
+    case BUILTIN_SIZEOF:
+      this->unused_value_error();
+      break;
+
+    case BUILTIN_CLOSE:
+    case BUILTIN_COPY:
+    case BUILTIN_PANIC:
+    case BUILTIN_PRINT:
+    case BUILTIN_PRINTLN:
+    case BUILTIN_RECOVER:
+      break;
+    }
+}
+
 // Return the type.
 
 Type*
@@ -7167,7 +7858,7 @@ Builtin_call_expression::do_type()
     {
     case BUILTIN_INVALID:
     default:
-      gcc_unreachable();
+      go_unreachable();
 
     case BUILTIN_NEW:
     case BUILTIN_MAKE:
@@ -7192,9 +7883,6 @@ Builtin_call_expression::do_type()
     case BUILTIN_PRINTLN:
       return Type::make_void_type();
 
-    case BUILTIN_CLOSED:
-      return Type::lookup_bool_type();
-
     case BUILTIN_RECOVER:
       return Type::make_interface_type(NULL, BUILTINS_LOCATION);
 
@@ -7246,6 +7934,9 @@ Builtin_call_expression::do_type()
 void
 Builtin_call_expression::do_determine_type(const Type_context* context)
 {
+  if (!this->determining_types())
+    return;
+
   this->fn()->determine_type_no_context();
 
   const Expression_list* args = this->args();
@@ -7330,7 +8021,7 @@ Builtin_call_expression::do_determine_type(const Type_context* context)
                  else if (atype->is_abstract_boolean_type())
                    want_type = Type::lookup_bool_type();
                  else
-                   gcc_unreachable();
+                   go_unreachable();
                  subcontext.type = want_type;
                }
            }
@@ -7358,8 +8049,7 @@ Builtin_call_expression::check_one_arg()
       return false;
     }
   if (args->front()->is_error_expression()
-      || args->front()->type()->is_error_type()
-      || args->front()->type()->is_undefined())
+      || args->front()->type()->is_error())
     {
       this->set_is_error();
       return false;
@@ -7389,11 +8079,11 @@ Builtin_call_expression::do_check_types(Gogo*)
            Type* arg_type = this->one_arg()->type();
            if (arg_type->points_to() != NULL
                && arg_type->points_to()->array_type() != NULL
-               && !arg_type->points_to()->is_open_array_type())
+               && !arg_type->points_to()->is_slice_type())
              arg_type = arg_type->points_to();
            if (this->code_ == BUILTIN_CAP)
              {
-               if (!arg_type->is_error_type()
+               if (!arg_type->is_error()
                    && arg_type->array_type() == NULL
                    && arg_type->channel_type() == NULL)
                  this->report_error(_("argument must be array or slice "
@@ -7401,7 +8091,7 @@ Builtin_call_expression::do_check_types(Gogo*)
              }
            else
              {
-               if (!arg_type->is_error_type()
+               if (!arg_type->is_error()
                    && !arg_type->is_string_type()
                    && arg_type->array_type() == NULL
                    && arg_type->map_type() == NULL
@@ -7433,7 +8123,7 @@ Builtin_call_expression::do_check_types(Gogo*)
                 ++p)
              {
                Type* type = (*p)->type();
-               if (type->is_error_type()
+               if (type->is_error()
                    || type->is_string_type()
                    || type->integer_type() != NULL
                    || type->float_type() != NULL
@@ -7444,7 +8134,7 @@ Builtin_call_expression::do_check_types(Gogo*)
                    || type->channel_type() != NULL
                    || type->map_type() != NULL
                    || type->function_type() != NULL
-                   || type->is_open_array_type())
+                   || type->is_slice_type())
                  ;
                else
                  this->report_error(_("unsupported argument type to "
@@ -7455,7 +8145,6 @@ Builtin_call_expression::do_check_types(Gogo*)
       break;
 
     case BUILTIN_CLOSE:
-    case BUILTIN_CLOSED:
       if (this->check_one_arg())
        {
          if (this->one_arg()->type()->channel_type() == NULL)
@@ -7498,11 +8187,11 @@ Builtin_call_expression::do_check_types(Gogo*)
          }
        Type* arg1_type = args->front()->type();
        Type* arg2_type = args->back()->type();
-       if (arg1_type->is_error_type() || arg2_type->is_error_type())
+       if (arg1_type->is_error() || arg2_type->is_error())
          break;
 
        Type* e1;
-       if (arg1_type->is_open_array_type())
+       if (arg1_type->is_slice_type())
          e1 = arg1_type->array_type()->element_type();
        else
          {
@@ -7511,7 +8200,7 @@ Builtin_call_expression::do_check_types(Gogo*)
          }
 
        Type* e2;
-       if (arg2_type->is_open_array_type())
+       if (arg2_type->is_slice_type())
          e2 = arg2_type->array_type()->element_type();
        else if (arg2_type->is_string_type())
          e2 = Type::lookup_integer_type("uint8");
@@ -7539,6 +8228,17 @@ Builtin_call_expression::do_check_types(Gogo*)
            this->report_error(_("too many arguments"));
            break;
          }
+
+       // The language permits appending a string to a []byte, as a
+       // special case.
+       if (args->back()->type()->is_string_type())
+         {
+           const Array_type* at = args->front()->type()->array_type();
+           const Type* e = at->element_type()->forwarded();
+           if (e == Type::lookup_integer_type("uint8"))
+             break;
+         }
+
        std::string reason;
        if (!Type::are_assignable(args->front()->type(), args->back()->type(),
                                  &reason))
@@ -7573,9 +8273,9 @@ Builtin_call_expression::do_check_types(Gogo*)
        else if (args->size() > 2)
          this->report_error(_("too many arguments"));
        else if (args->front()->is_error_expression()
-                || args->front()->type()->is_error_type()
+                || args->front()->type()->is_error()
                 || args->back()->is_error_expression()
-                || args->back()->type()->is_error_type())
+                || args->back()->type()->is_error())
          this->set_is_error();
        else if (!Type::are_identical(args->front()->type(),
                                      args->back()->type(), true, NULL))
@@ -7587,7 +8287,7 @@ Builtin_call_expression::do_check_types(Gogo*)
       break;
 
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 }
 
@@ -7603,19 +8303,19 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
     case BUILTIN_INVALID:
     case BUILTIN_NEW:
     case BUILTIN_MAKE:
-      gcc_unreachable();
+      go_unreachable();
 
     case BUILTIN_LEN:
     case BUILTIN_CAP:
       {
        const Expression_list* args = this->args();
-       gcc_assert(args != NULL && args->size() == 1);
+       go_assert(args != NULL && args->size() == 1);
        Expression* arg = *args->begin();
        Type* arg_type = arg->type();
 
        if (this->seen_)
          {
-           gcc_assert(saw_errors());
+           go_assert(saw_errors());
            return error_mark_node;
          }
        this->seen_ = true;
@@ -7630,9 +8330,9 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
        if (arg_type->points_to() != NULL)
          {
            arg_type = arg_type->points_to();
-           gcc_assert(arg_type->array_type() != NULL
-                      && !arg_type->is_open_array_type());
-           gcc_assert(POINTER_TYPE_P(TREE_TYPE(arg_tree)));
+           go_assert(arg_type->array_type() != NULL
+                      && !arg_type->is_slice_type());
+           go_assert(POINTER_TYPE_P(TREE_TYPE(arg_tree)));
            arg_tree = build_fold_indirect_ref(arg_tree);
          }
 
@@ -7645,7 +8345,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
              {
                if (this->seen_)
                  {
-                   gcc_assert(saw_errors());
+                   go_assert(saw_errors());
                    return error_mark_node;
                  }
                this->seen_ = true;
@@ -7654,28 +8354,30 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
              }
            else if (arg_type->map_type() != NULL)
              {
+               tree arg_type_tree = type_to_tree(arg_type->get_backend(gogo));
                static tree map_len_fndecl;
                val_tree = Gogo::call_builtin(&map_len_fndecl,
                                              location,
                                              "__go_map_len",
                                              1,
-                                             sizetype,
-                                             arg_type->get_tree(gogo),
+                                             integer_type_node,
+                                             arg_type_tree,
                                              arg_tree);
              }
            else if (arg_type->channel_type() != NULL)
              {
+               tree arg_type_tree = type_to_tree(arg_type->get_backend(gogo));
                static tree chan_len_fndecl;
                val_tree = Gogo::call_builtin(&chan_len_fndecl,
                                              location,
                                              "__go_chan_len",
                                              1,
-                                             sizetype,
-                                             arg_type->get_tree(gogo),
+                                             integer_type_node,
+                                             arg_type_tree,
                                              arg_tree);
              }
            else
-             gcc_unreachable();
+             go_unreachable();
          }
        else
          {
@@ -7683,7 +8385,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
              {
                if (this->seen_)
                  {
-                   gcc_assert(saw_errors());
+                   go_assert(saw_errors());
                    return error_mark_node;
                  }
                this->seen_ = true;
@@ -7693,23 +8395,25 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
              }
            else if (arg_type->channel_type() != NULL)
              {
+               tree arg_type_tree = type_to_tree(arg_type->get_backend(gogo));
                static tree chan_cap_fndecl;
                val_tree = Gogo::call_builtin(&chan_cap_fndecl,
                                              location,
                                              "__go_chan_cap",
                                              1,
-                                             sizetype,
-                                             arg_type->get_tree(gogo),
+                                             integer_type_node,
+                                             arg_type_tree,
                                              arg_tree);
              }
            else
-             gcc_unreachable();
+             go_unreachable();
          }
 
        if (val_tree == error_mark_node)
          return error_mark_node;
 
-       tree type_tree = Type::lookup_integer_type("int")->get_tree(gogo);
+       Type* int_type = Type::lookup_integer_type("int");
+       tree type_tree = type_to_tree(int_type->get_backend(gogo));
        if (type_tree == TREE_TYPE(val_tree))
          return val_tree;
        else
@@ -7763,8 +8467,8 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
                    pfndecl = &print_uint64_fndecl;
                    fnname = "__go_print_uint64";
                    Type* itype = Type::lookup_integer_type("uint64");
-                   arg = fold_convert_loc(location, itype->get_tree(gogo),
-                                          arg);
+                   Btype* bitype = itype->get_backend(gogo);
+                   arg = fold_convert_loc(location, type_to_tree(bitype), arg);
                  }
                else if (type->integer_type() != NULL)
                  {
@@ -7772,8 +8476,8 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
                    pfndecl = &print_int64_fndecl;
                    fnname = "__go_print_int64";
                    Type* itype = Type::lookup_integer_type("int64");
-                   arg = fold_convert_loc(location, itype->get_tree(gogo),
-                                          arg);
+                   Btype* bitype = itype->get_backend(gogo);
+                   arg = fold_convert_loc(location, type_to_tree(bitype), arg);
                  }
                else if (type->float_type() != NULL)
                  {
@@ -7821,14 +8525,14 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
                        fnname = "__go_print_interface";
                      }
                  }
-               else if (type->is_open_array_type())
+               else if (type->is_slice_type())
                  {
                    static tree print_slice_fndecl;
                    pfndecl = &print_slice_fndecl;
                    fnname = "__go_print_slice";
                  }
                else
-                 gcc_unreachable();
+                 go_unreachable();
 
                tree call = Gogo::call_builtin(pfndecl,
                                               location,
@@ -7862,7 +8566,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
     case BUILTIN_PANIC:
       {
        const Expression_list* args = this->args();
-       gcc_assert(args != NULL && args->size() == 1);
+       go_assert(args != NULL && args->size() == 1);
        Expression* arg = args->front();
        tree arg_tree = arg->get_tree(context);
        if (arg_tree == error_mark_node)
@@ -7893,14 +8597,14 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
        // The argument is set when building recover thunks.  It's a
        // boolean value which is true if we can recover a value now.
        const Expression_list* args = this->args();
-       gcc_assert(args != NULL && args->size() == 1);
+       go_assert(args != NULL && args->size() == 1);
        Expression* arg = args->front();
        tree arg_tree = arg->get_tree(context);
        if (arg_tree == error_mark_node)
          return error_mark_node;
 
        Type *empty = Type::make_interface_type(NULL, BUILTINS_LOCATION);
-       tree empty_tree = empty->get_tree(context->gogo());
+       tree empty_tree = type_to_tree(empty->get_backend(context->gogo()));
 
        Type* nil_type = Type::make_nil_type();
        Expression* nil = Expression::make_nil(location);
@@ -7940,36 +8644,21 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
       }
 
     case BUILTIN_CLOSE:
-    case BUILTIN_CLOSED:
       {
        const Expression_list* args = this->args();
-       gcc_assert(args != NULL && args->size() == 1);
+       go_assert(args != NULL && args->size() == 1);
        Expression* arg = args->front();
        tree arg_tree = arg->get_tree(context);
        if (arg_tree == error_mark_node)
          return error_mark_node;
-       if (this->code_ == BUILTIN_CLOSE)
-         {
-           static tree close_fndecl;
-           return Gogo::call_builtin(&close_fndecl,
-                                     location,
-                                     "__go_builtin_close",
-                                     1,
-                                     void_type_node,
-                                     TREE_TYPE(arg_tree),
-                                     arg_tree);
-         }
-       else
-         {
-           static tree closed_fndecl;
-           return Gogo::call_builtin(&closed_fndecl,
-                                     location,
-                                     "__go_builtin_closed",
-                                     1,
-                                     boolean_type_node,
-                                     TREE_TYPE(arg_tree),
-                                     arg_tree);
-         }
+       static tree close_fndecl;
+       return Gogo::call_builtin(&close_fndecl,
+                                 location,
+                                 "__go_builtin_close",
+                                 1,
+                                 void_type_node,
+                                 TREE_TYPE(arg_tree),
+                                 arg_tree);
       }
 
     case BUILTIN_SIZEOF:
@@ -7982,10 +8671,11 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
        bool b = this->integer_constant_value(true, val, &dummy);
        if (!b)
          {
-           gcc_assert(saw_errors());
+           go_assert(saw_errors());
            return error_mark_node;
          }
-       tree type = Type::lookup_integer_type("int")->get_tree(gogo);
+       Type* int_type = Type::lookup_integer_type("int");
+       tree type = type_to_tree(int_type->get_backend(gogo));
        tree ret = Expression::integer_constant_tree(val, type);
        mpz_clear(val);
        return ret;
@@ -7994,7 +8684,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
     case BUILTIN_COPY:
       {
        const Expression_list* args = this->args();
-       gcc_assert(args != NULL && args->size() == 2);
+       go_assert(args != NULL && args->size() == 2);
        Expression* arg1 = args->front();
        Expression* arg2 = args->back();
 
@@ -8014,7 +8704,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
        Type* arg2_type = arg2->type();
        tree arg2_val;
        tree arg2_len;
-       if (arg2_type->is_open_array_type())
+       if (arg2_type->is_slice_type())
          {
            at = arg2_type->array_type();
            arg2_tree = save_expr(arg2_tree);
@@ -8040,7 +8730,8 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
        len = save_expr(len);
 
        Type* element_type = at->element_type();
-       tree element_type_tree = element_type->get_tree(gogo);
+       Btype* element_btype = element_type->get_backend(gogo);
+       tree element_type_tree = type_to_tree(element_btype);
        if (element_type_tree == error_mark_node)
          return error_mark_node;
        tree element_size = TYPE_SIZE_UNIT(element_type_tree);
@@ -8076,7 +8767,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
     case BUILTIN_APPEND:
       {
        const Expression_list* args = this->args();
-       gcc_assert(args != NULL && args->size() == 2);
+       go_assert(args != NULL && args->size() == 2);
        Expression* arg1 = args->front();
        Expression* arg2 = args->back();
 
@@ -8086,30 +8777,50 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
          return error_mark_node;
 
        Array_type* at = arg1->type()->array_type();
-       Type* element_type = at->element_type();
+       Type* element_type = at->element_type()->forwarded();
 
-       arg2_tree = Expression::convert_for_assignment(context, at,
-                                                      arg2->type(),
-                                                      arg2_tree,
-                                                      location);
-       if (arg2_tree == error_mark_node)
-         return error_mark_node;
+       tree arg2_val;
+       tree arg2_len;
+       tree element_size;
+       if (arg2->type()->is_string_type()
+           && element_type == Type::lookup_integer_type("uint8"))
+         {
+           arg2_tree = save_expr(arg2_tree);
+           arg2_val = String_type::bytes_tree(gogo, arg2_tree);
+           arg2_len = String_type::length_tree(gogo, arg2_tree);
+           element_size = size_int(1);
+         }
+       else
+         {
+           arg2_tree = Expression::convert_for_assignment(context, at,
+                                                          arg2->type(),
+                                                          arg2_tree,
+                                                          location);
+           if (arg2_tree == error_mark_node)
+             return error_mark_node;
+
+           arg2_tree = save_expr(arg2_tree);
+
+            arg2_val = at->value_pointer_tree(gogo, arg2_tree);
+            arg2_len = at->length_tree(gogo, arg2_tree);
+
+            Btype* element_btype = element_type->get_backend(gogo);
+            tree element_type_tree = type_to_tree(element_btype);
+            if (element_type_tree == error_mark_node)
+              return error_mark_node;
+            element_size = TYPE_SIZE_UNIT(element_type_tree);
+         }
 
-       arg2_tree = save_expr(arg2_tree);
-       tree arg2_val = at->value_pointer_tree(gogo, arg2_tree);
-       tree arg2_len = at->length_tree(gogo, arg2_tree);
-       if (arg2_val == error_mark_node || arg2_len == error_mark_node)
-         return error_mark_node;
        arg2_val = fold_convert_loc(location, ptr_type_node, arg2_val);
        arg2_len = fold_convert_loc(location, size_type_node, arg2_len);
-
-       tree element_type_tree = element_type->get_tree(gogo);
-       if (element_type_tree == error_mark_node)
-         return error_mark_node;
-       tree element_size = TYPE_SIZE_UNIT(element_type_tree);
        element_size = fold_convert_loc(location, size_type_node,
                                        element_size);
 
+       if (arg2_val == error_mark_node
+           || arg2_len == error_mark_node
+           || element_size == error_mark_node)
+         return error_mark_node;
+
        // We rebuild the decl each time since the slice types may
        // change.
        tree append_fndecl = NULL_TREE;
@@ -8132,12 +8843,12 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
     case BUILTIN_IMAG:
       {
        const Expression_list* args = this->args();
-       gcc_assert(args != NULL && args->size() == 1);
+       go_assert(args != NULL && args->size() == 1);
        Expression* arg = args->front();
        tree arg_tree = arg->get_tree(context);
        if (arg_tree == error_mark_node)
          return error_mark_node;
-       gcc_assert(COMPLEX_FLOAT_TYPE_P(TREE_TYPE(arg_tree)));
+       go_assert(COMPLEX_FLOAT_TYPE_P(TREE_TYPE(arg_tree)));
        if (this->code_ == BUILTIN_REAL)
          return fold_build1_loc(location, REALPART_EXPR,
                                 TREE_TYPE(TREE_TYPE(arg_tree)),
@@ -8151,21 +8862,21 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
     case BUILTIN_COMPLEX:
       {
        const Expression_list* args = this->args();
-       gcc_assert(args != NULL && args->size() == 2);
+       go_assert(args != NULL && args->size() == 2);
        tree r = args->front()->get_tree(context);
        tree i = args->back()->get_tree(context);
        if (r == error_mark_node || i == error_mark_node)
          return error_mark_node;
-       gcc_assert(TYPE_MAIN_VARIANT(TREE_TYPE(r))
+       go_assert(TYPE_MAIN_VARIANT(TREE_TYPE(r))
                   == TYPE_MAIN_VARIANT(TREE_TYPE(i)));
-       gcc_assert(SCALAR_FLOAT_TYPE_P(TREE_TYPE(r)));
+       go_assert(SCALAR_FLOAT_TYPE_P(TREE_TYPE(r)));
        return fold_build2_loc(location, COMPLEX_EXPR,
                               build_complex_type(TREE_TYPE(r)),
                               r, i);
       }
 
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 }
 
@@ -8244,14 +8955,17 @@ Call_expression::do_traverse(Traverse* traverse)
 // Lower a call statement.
 
 Expression*
-Call_expression::do_lower(Gogo* gogo, Named_object* function, int)
+Call_expression::do_lower(Gogo* gogo, Named_object* function,
+                         Statement_inserter* inserter, int)
 {
-  // A type case can look like a function call.
+  source_location loc = this->location();
+
+  // A type cast can look like a function call.
   if (this->fn_->is_type_expression()
       && this->args_ != NULL
       && this->args_->size() == 1)
     return Expression::make_cast(this->fn_->type(), this->args_->front(),
-                                this->location());
+                                loc);
 
   // Recognize a call to a builtin function.
   Func_expression* fne = this->fn_->func_expression();
@@ -8259,7 +8973,7 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function, int)
       && fne->named_object()->is_function_declaration()
       && fne->named_object()->func_declaration_value()->type()->is_builtin())
     return new Builtin_call_expression(gogo, this->fn_, this->args_,
-                                      this->is_varargs_, this->location());
+                                      this->is_varargs_, loc);
 
   // Handle an argument which is a call to a function which returns
   // multiple results.
@@ -8281,12 +8995,35 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function, int)
          for (size_t i = 0; i < rc; ++i)
            args->push_back(Expression::make_call_result(call, i));
          // We can't return a new call expression here, because this
-         // one may be referenced by Call_result expressions.  FIXME.
-         delete this->args_;
+         // one may be referenced by Call_result expressions.  We
+         // also can't delete the old arguments, because we may still
+         // traverse them somewhere up the call stack.  FIXME.
          this->args_ = args;
        }
     }
 
+  // If this call returns multiple results, create a temporary
+  // variable for each result.
+  size_t rc = this->result_count();
+  if (rc > 1 && this->results_ == NULL)
+    {
+      std::vector<Temporary_statement*>* temps =
+       new std::vector<Temporary_statement*>;
+      temps->reserve(rc);
+      const Typed_identifier_list* results =
+       this->fn_->type()->function_type()->results();
+      for (Typed_identifier_list::const_iterator p = results->begin();
+          p != results->end();
+          ++p)
+       {
+         Temporary_statement* temp = Statement::make_temporary(p->type(),
+                                                               NULL, loc);
+         inserter->insert(temp);
+         temps->push_back(temp);
+       }
+      this->results_ = temps;
+    }
+
   // Handle a call to a varargs function by packaging up the extra
   // parameters.
   if (this->fn_->type()->function_type() != NULL
@@ -8294,39 +9031,90 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function, int)
     {
       Function_type* fntype = this->fn_->type()->function_type();
       const Typed_identifier_list* parameters = fntype->parameters();
-      gcc_assert(parameters != NULL && !parameters->empty());
+      go_assert(parameters != NULL && !parameters->empty());
       Type* varargs_type = parameters->back().type();
-      return this->lower_varargs(gogo, function, varargs_type,
-                                parameters->size());
+      this->lower_varargs(gogo, function, inserter, varargs_type,
+                         parameters->size());
     }
 
-  return this;
-}
+  // If this is call to a method, call the method directly passing the
+  // object as the first parameter.
+  Bound_method_expression* bme = this->fn_->bound_method_expression();
+  if (bme != NULL)
+    {
+      Named_object* method = bme->method();
+      Expression* first_arg = bme->first_argument();
 
-// Lower a call to a varargs function.  FUNCTION is the function in
-// which the call occurs--it's not the function we are calling.
-// VARARGS_TYPE is the type of the varargs parameter, a slice type.
-// PARAM_COUNT is the number of parameters of the function we are
-// calling; the last of these parameters will be the varargs
-// parameter.
+      // We always pass a pointer when calling a method.
+      if (first_arg->type()->points_to() == NULL
+         && !first_arg->type()->is_error())
+       {
+         first_arg = Expression::make_unary(OPERATOR_AND, first_arg, loc);
+         // We may need to create a temporary variable so that we can
+         // take the address.  We can't do that here because it will
+         // mess up the order of evaluation.
+         Unary_expression* ue = static_cast<Unary_expression*>(first_arg);
+         ue->set_create_temp();
+       }
 
-Expression*
+      // If we are calling a method which was inherited from an
+      // embedded struct, and the method did not get a stub, then the
+      // first type may be wrong.
+      Type* fatype = bme->first_argument_type();
+      if (fatype != NULL)
+       {
+         if (fatype->points_to() == NULL)
+           fatype = Type::make_pointer_type(fatype);
+         first_arg = Expression::make_unsafe_cast(fatype, first_arg, loc);
+       }
+
+      Expression_list* new_args = new Expression_list();
+      new_args->push_back(first_arg);
+      if (this->args_ != NULL)
+       {
+         for (Expression_list::const_iterator p = this->args_->begin();
+              p != this->args_->end();
+              ++p)
+           new_args->push_back(*p);
+       }
+
+      // We have to change in place because this structure may be
+      // referenced by Call_result_expressions.  We can't delete the
+      // old arguments, because we may be traversing them up in some
+      // caller.  FIXME.
+      this->args_ = new_args;
+      this->fn_ = Expression::make_func_reference(method, NULL,
+                                                 bme->location());
+    }
+
+  return this;
+}
+
+// Lower a call to a varargs function.  FUNCTION is the function in
+// which the call occurs--it's not the function we are calling.
+// VARARGS_TYPE is the type of the varargs parameter, a slice type.
+// PARAM_COUNT is the number of parameters of the function we are
+// calling; the last of these parameters will be the varargs
+// parameter.
+
+void
 Call_expression::lower_varargs(Gogo* gogo, Named_object* function,
+                              Statement_inserter* inserter,
                               Type* varargs_type, size_t param_count)
 {
   if (this->varargs_are_lowered_)
-    return this;
+    return;
 
   source_location loc = this->location();
 
-  gcc_assert(param_count > 0);
-  gcc_assert(varargs_type->is_open_array_type());
+  go_assert(param_count > 0);
+  go_assert(varargs_type->is_slice_type());
 
   size_t arg_count = this->args_ == NULL ? 0 : this->args_->size();
   if (arg_count < param_count - 1)
     {
       // Not enough arguments; will be caught in check_types.
-      return this;
+      return;
     }
 
   Expression_list* old_args = this->args_;
@@ -8334,7 +9122,7 @@ Call_expression::lower_varargs(Gogo* gogo, Named_object* function,
   bool push_empty_arg = false;
   if (old_args == NULL || old_args->empty())
     {
-      gcc_assert(param_count == 1);
+      go_assert(param_count == 1);
       push_empty_arg = true;
     }
   else
@@ -8358,7 +9146,7 @@ Call_expression::lower_varargs(Gogo* gogo, Named_object* function,
       else if (this->is_varargs_)
        {
          this->report_error(_("too many arguments"));
-         return this;
+         return;
        }
       else
        {
@@ -8376,6 +9164,7 @@ Call_expression::lower_varargs(Gogo* gogo, Named_object* function,
            }
          Expression* val =
            Expression::make_slice_composite_literal(varargs_type, vals, loc);
+         gogo->lower_expression(function, inserter, &val);
          new_args->push_back(val);
        }
     }
@@ -8384,21 +9173,14 @@ Call_expression::lower_varargs(Gogo* gogo, Named_object* function,
     new_args->push_back(Expression::make_nil(loc));
 
   // We can't return a new call expression here, because this one may
-  // be referenced by Call_result expressions.  FIXME.
-  if (old_args != NULL)
-    delete old_args;
+  // be referenced by Call_result expressions.  FIXME.  We can't
+  // delete OLD_ARGS because we may have both a Call_expression and a
+  // Builtin_call_expression which refer to them.  FIXME.
   this->args_ = new_args;
   this->varargs_are_lowered_ = true;
-
-  // Lower all the new subexpressions.
-  Expression* ret = this;
-  gogo->lower_expression(function, &ret);
-  gcc_assert(ret == this);
-  return ret;
 }
 
-// Get the function type.  Returns NULL if we don't know the type.  If
-// this returns NULL, and if_ERROR is true, issues an error.
+// Get the function type.  This can return NULL in error cases.
 
 Function_type*
 Call_expression::get_function_type() const
@@ -8419,6 +9201,16 @@ Call_expression::result_count() const
   return fntype->results()->size();
 }
 
+// Return the temporary which holds a result.
+
+Temporary_statement*
+Call_expression::result(size_t i) const
+{
+  go_assert(this->results_ != NULL
+           && this->results_->size() > i);
+  return (*this->results_)[i];
+}
+
 // Return whether this is a call to the predeclared function recover.
 
 bool
@@ -8446,7 +9238,22 @@ Call_expression::do_is_recover_call() const
 void
 Call_expression::do_set_recover_arg(Expression*)
 {
-  gcc_unreachable();
+  go_unreachable();
+}
+
+// We have found an error with this call expression; return true if
+// we should report it.
+
+bool
+Call_expression::issue_error()
+{
+  if (this->issued_error_)
+    return false;
+  else
+    {
+      this->issued_error_ = true;
+      return true;
+    }
 }
 
 // Get the type.
@@ -8481,6 +9288,9 @@ Call_expression::do_type()
 void
 Call_expression::do_determine_type(const Type_context*)
 {
+  if (!this->determining_types())
+    return;
+
   this->fn_->determine_type_no_context();
   Function_type* fntype = this->get_function_type();
   const Typed_identifier_list* parameters = NULL;
@@ -8491,10 +9301,28 @@ Call_expression::do_determine_type(const Type_context*)
       Typed_identifier_list::const_iterator pt;
       if (parameters != NULL)
        pt = parameters->begin();
+      bool first = true;
       for (Expression_list::const_iterator pa = this->args_->begin();
           pa != this->args_->end();
           ++pa)
        {
+         if (first)
+           {
+             first = false;
+             // If this is a method, the first argument is the
+             // receiver.
+             if (fntype != NULL && fntype->is_method())
+               {
+                 Type* rtype = fntype->receiver()->type();
+                 // The receiver is always passed as a pointer.
+                 if (rtype->points_to() == NULL)
+                   rtype = Type::make_pointer_type(rtype);
+                 Type_context subcontext(rtype, false);
+                 (*pa)->determine_type(&subcontext);
+                 continue;
+               }
+           }
+
          if (parameters != NULL && pt != parameters->end())
            {
              Type_context subcontext(pt->type(), false);
@@ -8507,6 +9335,21 @@ Call_expression::do_determine_type(const Type_context*)
     }
 }
 
+// Called when determining types for a Call_expression.  Return true
+// if we should go ahead, false if they have already been determined.
+
+bool
+Call_expression::determining_types()
+{
+  if (this->types_are_determined_)
+    return false;
+  else
+    {
+      this->types_are_determined_ = true;
+      return true;
+    }
+}
+
 // Check types for parameter I.
 
 bool
@@ -8516,7 +9359,13 @@ Call_expression::check_argument_type(int i, const Type* parameter_type,
                                     bool issued_error)
 {
   std::string reason;
-  if (!Type::are_assignable(parameter_type, argument_type, &reason))
+  bool ok;
+  if (this->are_hidden_fields_ok_)
+    ok = Type::are_assignable_hidden_ok(parameter_type, argument_type,
+                                       &reason);
+  else
+    ok = Type::are_assignable(parameter_type, argument_type, &reason);
+  if (!ok)
     {
       if (!issued_error)
        {
@@ -8541,39 +9390,33 @@ Call_expression::do_check_types(Gogo*)
   Function_type* fntype = this->get_function_type();
   if (fntype == NULL)
     {
-      if (!this->fn_->type()->is_error_type())
+      if (!this->fn_->type()->is_error())
        this->report_error(_("expected function"));
       return;
     }
 
-  if (fntype->is_method())
+  bool is_method = fntype->is_method();
+  if (is_method)
     {
-      // We don't support pointers to methods, so the function has to
-      // be a bound method expression.
-      Bound_method_expression* bme = this->fn_->bound_method_expression();
-      if (bme == NULL)
-       {
-         this->report_error(_("method call without object"));
-         return;
-       }
-      Type* first_arg_type = bme->first_argument()->type();
-      if (first_arg_type->points_to() == NULL)
+      go_assert(this->args_ != NULL && !this->args_->empty());
+      Type* rtype = fntype->receiver()->type();
+      Expression* first_arg = this->args_->front();
+      // The language permits copying hidden fields for a method
+      // receiver.  We dereference the values since receivers are
+      // always passed as pointers.
+      std::string reason;
+      if (!Type::are_assignable_hidden_ok(rtype->deref(),
+                                         first_arg->type()->deref(),
+                                         &reason))
        {
-         // When passing a value, we need to check that we are
-         // permitted to copy it.
-         std::string reason;
-         if (!Type::are_assignable(fntype->receiver()->type(),
-                                   first_arg_type, &reason))
+         if (reason.empty())
+           this->report_error(_("incompatible type for receiver"));
+         else
            {
-             if (reason.empty())
-               this->report_error(_("incompatible type for receiver"));
-             else
-               {
-                 error_at(this->location(),
-                          "incompatible type for receiver (%s)",
-                          reason.c_str());
-                 this->set_is_error();
-               }
+             error_at(this->location(),
+                      "incompatible type for receiver (%s)",
+                      reason.c_str());
+             this->set_is_error();
            }
        }
     }
@@ -8588,97 +9431,41 @@ Call_expression::do_check_types(Gogo*)
        this->report_error(_("not enough arguments"));
     }
   else if (parameters == NULL)
-    this->report_error(_("too many arguments"));
+    {
+      if (!is_method || this->args_->size() > 1)
+       this->report_error(_("too many arguments"));
+    }
   else
     {
       int i = 0;
-      Typed_identifier_list::const_iterator pt = parameters->begin();
-      for (Expression_list::const_iterator pa = this->args_->begin();
-          pa != this->args_->end();
-          ++pa, ++pt, ++i)
-       {
-         if (pt == parameters->end())
+      Expression_list::const_iterator pa = this->args_->begin();
+      if (is_method)
+       ++pa;
+      for (Typed_identifier_list::const_iterator pt = parameters->begin();
+          pt != parameters->end();
+          ++pt, ++pa, ++i)
+       {
+         if (pa == this->args_->end())
            {
-             this->report_error(_("too many arguments"));
+             this->report_error(_("not enough arguments"));
              return;
            }
          this->check_argument_type(i + 1, pt->type(), (*pa)->type(),
                                    (*pa)->location(), false);
        }
-      if (pt != parameters->end())
-       this->report_error(_("not enough arguments"));
+      if (pa != this->args_->end())
+       this->report_error(_("too many arguments"));
     }
 }
 
 // Return whether we have to use a temporary variable to ensure that
 // we evaluate this call expression in order.  If the call returns no
-// results then it will inevitably be executed last.  If the call
-// returns more than one result then it will be used with Call_result
-// expressions.  So we only have to use a temporary variable if the
-// call returns exactly one result.
+// results then it will inevitably be executed last.
 
 bool
 Call_expression::do_must_eval_in_order() const
 {
-  return this->result_count() == 1;
-}
-
-// Get the function and the first argument to use when calling a bound
-// method.
-
-tree
-Call_expression::bound_method_function(Translate_context* context,
-                                      Bound_method_expression* bound_method,
-                                      tree* first_arg_ptr)
-{
-  Expression* first_argument = bound_method->first_argument();
-  tree first_arg = first_argument->get_tree(context);
-  if (first_arg == error_mark_node)
-    return error_mark_node;
-
-  // We always pass a pointer to the first argument when calling a
-  // method.
-  if (first_argument->type()->points_to() == NULL)
-    {
-      tree pointer_to_arg_type = build_pointer_type(TREE_TYPE(first_arg));
-      if (TREE_ADDRESSABLE(TREE_TYPE(first_arg))
-         || DECL_P(first_arg)
-         || TREE_CODE(first_arg) == INDIRECT_REF
-         || TREE_CODE(first_arg) == COMPONENT_REF)
-       {
-         first_arg = build_fold_addr_expr(first_arg);
-         if (DECL_P(first_arg))
-           TREE_ADDRESSABLE(first_arg) = 1;
-       }
-      else
-       {
-         tree tmp = create_tmp_var(TREE_TYPE(first_arg),
-                                   get_name(first_arg));
-         DECL_IGNORED_P(tmp) = 0;
-         DECL_INITIAL(tmp) = first_arg;
-         first_arg = build2(COMPOUND_EXPR, pointer_to_arg_type,
-                            build1(DECL_EXPR, void_type_node, tmp),
-                            build_fold_addr_expr(tmp));
-         TREE_ADDRESSABLE(tmp) = 1;
-       }
-      if (first_arg == error_mark_node)
-       return error_mark_node;
-    }
-
-  Type* fatype = bound_method->first_argument_type();
-  if (fatype != NULL)
-    {
-      if (fatype->points_to() == NULL)
-       fatype = Type::make_pointer_type(fatype);
-      first_arg = fold_convert(fatype->get_tree(context->gogo()), first_arg);
-      if (first_arg == error_mark_node
-         || TREE_TYPE(first_arg) == error_mark_node)
-       return error_mark_node;
-    }
-
-  *first_arg_ptr = first_arg;
-
-  return bound_method->method()->get_tree(context);
+  return this->result_count() > 0;
 }
 
 // Get the function and the first argument to use when calling an
@@ -8720,37 +9507,48 @@ Call_expression::do_get_tree(Translate_context* context)
   source_location location = this->location();
 
   Func_expression* func = this->fn_->func_expression();
-  Bound_method_expression* bound_method = this->fn_->bound_method_expression();
   Interface_field_reference_expression* interface_method =
     this->fn_->interface_field_reference_expression();
   const bool has_closure = func != NULL && func->closure() != NULL;
-  const bool is_method = bound_method != NULL || interface_method != NULL;
-  gcc_assert(!fntype->is_method() || is_method);
+  const bool is_interface_method = interface_method != NULL;
 
   int nargs;
   tree* args;
   if (this->args_ == NULL || this->args_->empty())
     {
-      nargs = is_method ? 1 : 0;
+      nargs = is_interface_method ? 1 : 0;
       args = nargs == 0 ? NULL : new tree[nargs];
     }
+  else if (fntype->parameters() == NULL || fntype->parameters()->empty())
+    {
+      // Passing a receiver parameter.
+      go_assert(!is_interface_method
+               && fntype->is_method()
+               && this->args_->size() == 1);
+      nargs = 1;
+      args = new tree[nargs];
+      args[0] = this->args_->front()->get_tree(context);
+    }
   else
     {
       const Typed_identifier_list* params = fntype->parameters();
-      gcc_assert(params != NULL);
 
       nargs = this->args_->size();
-      int i = is_method ? 1 : 0;
+      int i = is_interface_method ? 1 : 0;
       nargs += i;
       args = new tree[nargs];
 
       Typed_identifier_list::const_iterator pp = params->begin();
-      Expression_list::const_iterator pe;
-      for (pe = this->args_->begin();
-          pe != this->args_->end();
-          ++pe, ++pp, ++i)
+      Expression_list::const_iterator pe = this->args_->begin();
+      if (!is_interface_method && fntype->is_method())
+       {
+         args[i] = (*pe)->get_tree(context);
+         ++pe;
+         ++i;
+       }
+      for (; pe != this->args_->end(); ++pe, ++pp, ++i)
        {
-         gcc_assert(pp != params->end());
+         go_assert(pp != params->end());
          tree arg_val = (*pe)->get_tree(context);
          args[i] = Expression::convert_for_assignment(context,
                                                       pp->type(),
@@ -8763,11 +9561,11 @@ Call_expression::do_get_tree(Translate_context* context)
              return error_mark_node;
            }
        }
-      gcc_assert(pp == params->end());
-      gcc_assert(i == nargs);
+      go_assert(pp == params->end());
+      go_assert(i == nargs);
     }
 
-  tree rettype = TREE_TYPE(TREE_TYPE(fntype->get_tree(gogo)));
+  tree rettype = TREE_TYPE(TREE_TYPE(type_to_tree(fntype->get_backend(gogo))));
   if (rettype == error_mark_node)
     {
       delete[] args;
@@ -8777,14 +9575,10 @@ Call_expression::do_get_tree(Translate_context* context)
   tree fn;
   if (has_closure)
     fn = func->get_tree_without_closure(gogo);
-  else if (!is_method)
+  else if (!is_interface_method)
     fn = this->fn_->get_tree(context);
-  else if (bound_method != NULL)
-    fn = this->bound_method_function(context, bound_method, &args[0]);
-  else if (interface_method != NULL)
-    fn = this->interface_method_function(context, interface_method, &args[0]);
   else
-    gcc_unreachable();
+    fn = this->interface_method_function(context, interface_method, &args[0]);
 
   if (fn == error_mark_node || TREE_TYPE(fn) == error_mark_node)
     {
@@ -8792,12 +9586,23 @@ Call_expression::do_get_tree(Translate_context* context)
       return error_mark_node;
     }
 
-  // This is to support builtin math functions when using 80387 math.
   tree fndecl = fn;
   if (TREE_CODE(fndecl) == ADDR_EXPR)
     fndecl = TREE_OPERAND(fndecl, 0);
+
+  // Add a type cast in case the type of the function is a recursive
+  // type which refers to itself.
+  if (!DECL_P(fndecl) || !DECL_IS_BUILTIN(fndecl))
+    {
+      tree fnt = type_to_tree(fntype->get_backend(gogo));
+      if (fnt == error_mark_node)
+       return error_mark_node;
+      fn = fold_convert_loc(location, fnt, fn);
+    }
+
+  // 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
@@ -8841,7 +9646,7 @@ Call_expression::do_get_tree(Translate_context* context)
   // to the correct type.
   if (TREE_TYPE(ret) == ptr_type_node)
     {
-      tree t = this->type()->get_tree(gogo);
+      tree t = type_to_tree(this->type()->base()->get_backend(gogo));
       ret = fold_convert_loc(location, t, ret);
     }
 
@@ -8852,16 +9657,69 @@ Call_expression::do_get_tree(Translate_context* context)
       ret = build1(NOP_EXPR, rettype, ret);
     }
 
-  // If there is more than one result, we will refer to the call
-  // multiple times.
-  if (fntype->results() != NULL && fntype->results()->size() > 1)
-    ret = save_expr(ret);
+  if (this->results_ != NULL)
+    ret = this->set_results(context, ret);
 
   this->tree_ = ret;
 
   return ret;
 }
 
+// Set the result variables if this call returns multiple results.
+
+tree
+Call_expression::set_results(Translate_context* context, tree call_tree)
+{
+  tree stmt_list = NULL_TREE;
+
+  call_tree = save_expr(call_tree);
+
+  if (TREE_CODE(TREE_TYPE(call_tree)) != RECORD_TYPE)
+    {
+      go_assert(saw_errors());
+      return call_tree;
+    }
+
+  source_location loc = this->location();
+  tree field = TYPE_FIELDS(TREE_TYPE(call_tree));
+  size_t rc = this->result_count();
+  for (size_t i = 0; i < rc; ++i, field = DECL_CHAIN(field))
+    {
+      go_assert(field != NULL_TREE);
+
+      Temporary_statement* temp = this->result(i);
+      Temporary_reference_expression* ref =
+       Expression::make_temporary_reference(temp, loc);
+      ref->set_is_lvalue();
+      tree temp_tree = ref->get_tree(context);
+      if (temp_tree == error_mark_node)
+       continue;
+
+      tree val_tree = build3_loc(loc, COMPONENT_REF, TREE_TYPE(field),
+                                call_tree, field, NULL_TREE);
+      tree set_tree = build2_loc(loc, MODIFY_EXPR, void_type_node, temp_tree,
+                                val_tree);
+
+      append_to_statement_list(set_tree, &stmt_list);
+    }
+  go_assert(field == NULL_TREE);
+
+  return save_expr(stmt_list);
+}
+
+// Dump ast representation for a call expressin.
+
+void
+Call_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  this->fn_->dump_expression(ast_dump_context);
+  ast_dump_context->ostream() << "(";
+  if (args_ != NULL)
+    ast_dump_context->dump_expression_list(this->args_);
+
+  ast_dump_context->ostream() << ") ";
+}
+
 // Make a call expression.
 
 Call_expression*
@@ -8908,6 +9766,9 @@ class Call_result_expression : public Expression
   tree
   do_get_tree(Translate_context*);
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+
  private:
   // The underlying call expression.
   Expression* call_;
@@ -8947,14 +9808,20 @@ Call_result_expression::do_type()
   Function_type* fntype = ce->get_function_type();
   if (fntype == NULL)
     {
+      if (ce->issue_error())
+       {
+         if (!ce->fn()->type()->is_error())
+           this->report_error(_("expected function"));
+       }
       this->set_is_error();
       return Type::make_error_type();
     }
   const Typed_identifier_list* results = fntype->results();
-  if (results == NULL)
+  if (results == NULL || results->size() < 2)
     {
-      this->report_error(_("number of results does not match "
-                          "number of values"));
+      if (ce->issue_error())
+       this->report_error(_("number of results does not match "
+                            "number of values"));
       return Type::make_error_type();
     }
   Typed_identifier_list::const_iterator pr = results->begin();
@@ -8966,8 +9833,9 @@ Call_result_expression::do_type()
     }
   if (pr == results->end())
     {
-      this->report_error(_("number of results does not match "
-                          "number of values"));
+      if (ce->issue_error())
+       this->report_error(_("number of results does not match "
+                            "number of values"));
       return Type::make_error_type();
     }
   return pr->type();
@@ -8988,31 +9856,34 @@ Call_result_expression::do_check_types(Gogo*)
 void
 Call_result_expression::do_determine_type(const Type_context*)
 {
-  if (this->index_ == 0)
-    this->call_->determine_type_no_context();
+  this->call_->determine_type_no_context();
 }
 
-// Return the tree.
+// Return the tree.  We just refer to the temporary set by the call
+// expression.  We don't do this at lowering time because it makes it
+// hard to evaluate the call at the right time.
 
 tree
 Call_result_expression::do_get_tree(Translate_context* context)
 {
-  tree call_tree = this->call_->get_tree(context);
-  if (call_tree == error_mark_node)
-    return error_mark_node;
-  if (TREE_CODE(TREE_TYPE(call_tree)) != RECORD_TYPE)
-    {
-      gcc_assert(saw_errors());
-      return error_mark_node;
-    }
-  tree field = TYPE_FIELDS(TREE_TYPE(call_tree));
-  for (unsigned int i = 0; i < this->index_; ++i)
-    {
-      gcc_assert(field != NULL_TREE);
-      field = DECL_CHAIN(field);
-    }
-  gcc_assert(field != NULL_TREE);
-  return build3(COMPONENT_REF, TREE_TYPE(field), call_tree, field, NULL_TREE);
+  Call_expression* ce = this->call_->call_expression();
+  go_assert(ce != NULL);
+  Temporary_statement* ts = ce->result(this->index_);
+  Expression* ref = Expression::make_temporary_reference(ts, this->location());
+  return ref->get_tree(context);
+}
+
+// Dump ast representation for a call result expression.
+
+void
+Call_result_expression::do_dump_expression(Ast_dump_context* ast_dump_context)
+    const
+{
+  // FIXME: Wouldn't it be better if the call is assigned to a temporary 
+  // (struct) and the fields are referenced instead.
+  ast_dump_context->ostream() << this->index_ << "@(";
+  ast_dump_context->dump_expression(this->call_);
+  ast_dump_context->ostream() << ")";
 }
 
 // Make a reference to a single result of a call which returns
@@ -9043,7 +9914,7 @@ Index_expression::do_traverse(Traverse* traverse)
 // expression into an array index, a string index, or a map index.
 
 Expression*
-Index_expression::do_lower(Gogo*, Named_object*, int)
+Index_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
 {
   source_location location = this->location();
   Expression* left = this->left_;
@@ -9051,7 +9922,7 @@ Index_expression::do_lower(Gogo*, Named_object*, int)
   Expression* end = this->end_;
 
   Type* type = left->type();
-  if (type->is_error_type())
+  if (type->is_error())
     return Expression::make_error(location);
   else if (left->is_type_expression())
     {
@@ -9062,7 +9933,7 @@ Index_expression::do_lower(Gogo*, Named_object*, int)
     return Expression::make_array_index(left, start, end, location);
   else if (type->points_to() != NULL
           && type->points_to()->array_type() != NULL
-          && !type->points_to()->is_open_array_type())
+          && !type->points_to()->is_slice_type())
     {
       Expression* deref = Expression::make_unary(OPERATOR_MULT, left,
                                                 location);
@@ -9077,8 +9948,8 @@ Index_expression::do_lower(Gogo*, Named_object*, int)
          error_at(location, "invalid slice of map");
          return Expression::make_error(location);
        }
-      Map_index_expression* ret= Expression::make_map_index(left, start,
-                                                           location);
+      Map_index_expression* ret = Expression::make_map_index(left, start,
+                                                            location);
       if (this->is_lvalue_)
        ret->set_is_lvalue();
       return ret;
@@ -9091,6 +9962,36 @@ Index_expression::do_lower(Gogo*, Named_object*, int)
     }
 }
 
+// Write an indexed expression (expr[expr:expr] or expr[expr]) to a
+// dump context
+
+void
+Index_expression::dump_index_expression(Ast_dump_context* ast_dump_context, 
+                                       const Expression* expr, 
+                                       const Expression* start,
+                                       const Expression* end)
+{
+  expr->dump_expression(ast_dump_context);
+  ast_dump_context->ostream() << "[";
+  start->dump_expression(ast_dump_context);
+  if (end != NULL)
+    {
+      ast_dump_context->ostream() << ":";
+      end->dump_expression(ast_dump_context);
+    }
+  ast_dump_context->ostream() << "]";
+}
+
+// Dump ast representation for an index expression.
+
+void
+Index_expression::do_dump_expression(Ast_dump_context* ast_dump_context) 
+    const
+{
+  Index_expression::dump_index_expression(ast_dump_context, this->left_, 
+                                          this->start_, this->end_);
+}
+
 // Make an index expression.
 
 Expression*
@@ -9145,6 +10046,9 @@ class Array_index_expression : public Expression
   tree
   do_get_tree(Translate_context*);
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+  
  private:
   // The array we are getting a value from.
   Expression* array_;
@@ -9186,7 +10090,7 @@ Array_index_expression::do_type()
        this->type_ = Type::make_error_type();
       else if (this->end_ == NULL)
        this->type_ = type->element_type();
-      else if (type->is_open_array_type())
+      else if (type->is_slice_type())
        {
          // A slice of a slice has the same type as the original
          // slice.
@@ -9221,13 +10125,15 @@ Array_index_expression::do_check_types(Gogo*)
     this->report_error(_("index must be integer"));
   if (this->end_ != NULL
       && this->end_->type()->integer_type() == NULL
-      && !this->end_->is_nil_expression())
+      && !this->end_->type()->is_error()
+      && !this->end_->is_nil_expression()
+      && !this->end_->is_error_expression())
     this->report_error(_("slice end must be integer"));
 
   Array_type* array_type = this->array_->type()->array_type();
   if (array_type == NULL)
     {
-      gcc_assert(this->array_->type()->is_error_type());
+      go_assert(this->array_->type()->is_error());
       return;
     }
 
@@ -9274,10 +10180,13 @@ Array_index_expression::do_check_types(Gogo*)
 
   // A slice of an array requires an addressable array.  A slice of a
   // slice is always possible.
-  if (this->end_ != NULL
-      && !array_type->is_open_array_type()
-      && !this->array_->is_addressable())
-    this->report_error(_("array is not addressable"));
+  if (this->end_ != NULL && !array_type->is_slice_type())
+    {
+      if (!this->array_->is_addressable())
+       this->report_error(_("array is not addressable"));
+      else
+       this->array_->address_taken(true);
+    }
 }
 
 // Return whether this expression is addressable.
@@ -9290,7 +10199,7 @@ Array_index_expression::do_is_addressable() const
     return false;
 
   // An index into a slice is addressable.
-  if (this->array_->type()->is_open_array_type())
+  if (this->array_->type()->is_slice_type())
     return true;
 
   // An index into an array is addressable if the array is
@@ -9309,11 +10218,11 @@ Array_index_expression::do_get_tree(Translate_context* context)
   Array_type* array_type = this->array_->type()->array_type();
   if (array_type == NULL)
     {
-      gcc_assert(this->array_->type()->is_error_type());
+      go_assert(this->array_->type()->is_error());
       return error_mark_node;
     }
 
-  tree type_tree = array_type->get_tree(gogo);
+  tree type_tree = type_to_tree(array_type->get_backend(gogo));
   if (type_tree == error_mark_node)
     return error_mark_node;
 
@@ -9380,7 +10289,9 @@ Array_index_expression::do_get_tree(Translate_context* context)
        {
          // Open array.
          tree values = array_type->value_pointer_tree(gogo, array_tree);
-         tree element_type_tree = array_type->element_type()->get_tree(gogo);
+         Type* element_type = array_type->element_type();
+         Btype* belement_type = element_type->get_backend(gogo);
+         tree element_type_tree = type_to_tree(belement_type);
          if (element_type_tree == error_mark_node)
            return error_mark_node;
          tree element_size = TYPE_SIZE_UNIT(element_type_tree);
@@ -9429,7 +10340,8 @@ Array_index_expression::do_get_tree(Translate_context* context)
                                  bad_index, bad_end);
     }
 
-  tree element_type_tree = array_type->element_type()->get_tree(gogo);
+  Type* element_type = array_type->element_type();
+  tree element_type_tree = type_to_tree(element_type->get_backend(gogo));
   if (element_type_tree == error_mark_node)
     return error_mark_node;
   tree element_size = TYPE_SIZE_UNIT(element_type_tree);
@@ -9452,26 +10364,26 @@ Array_index_expression::do_get_tree(Translate_context* context)
   tree result_capacity_tree = fold_build2_loc(loc, MINUS_EXPR, length_type,
                                              capacity_tree, start_tree);
 
-  tree struct_tree = this->type()->get_tree(gogo);
-  gcc_assert(TREE_CODE(struct_tree) == RECORD_TYPE);
+  tree struct_tree = type_to_tree(this->type()->get_backend(gogo));
+  go_assert(TREE_CODE(struct_tree) == RECORD_TYPE);
 
   VEC(constructor_elt,gc)* init = VEC_alloc(constructor_elt, gc, 3);
 
   constructor_elt* elt = VEC_quick_push(constructor_elt, init, NULL);
   tree field = TYPE_FIELDS(struct_tree);
-  gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__values") == 0);
+  go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__values") == 0);
   elt->index = field;
   elt->value = value_pointer;
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
   field = DECL_CHAIN(field);
-  gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0);
+  go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0);
   elt->index = field;
   elt->value = fold_convert_loc(loc, TREE_TYPE(field), result_length_tree);
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
   field = DECL_CHAIN(field);
-  gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__capacity") == 0);
+  go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__capacity") == 0);
   elt->index = field;
   elt->value = fold_convert_loc(loc, TREE_TYPE(field), result_capacity_tree);
 
@@ -9488,6 +10400,16 @@ Array_index_expression::do_get_tree(Translate_context* context)
                         constructor);
 }
 
+// Dump ast representation for an array index expression.
+
+void
+Array_index_expression::do_dump_expression(Ast_dump_context* ast_dump_context) 
+    const
+{
+  Index_expression::dump_index_expression(ast_dump_context, this->array_, 
+                                          this->start_, this->end_);
+}
+
 // Make an array index expression.  END may be NULL.
 
 Expression*
@@ -9542,6 +10464,9 @@ class String_index_expression : public Expression
   tree
   do_get_tree(Translate_context*);
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+
  private:
   // The string we are getting a value from.
   Expression* string_;
@@ -9742,6 +10667,16 @@ String_index_expression::do_get_tree(Translate_context* context)
     }
 }
 
+// Dump ast representation for a string index expression.
+
+void
+String_index_expression::do_dump_expression(Ast_dump_context* ast_dump_context)
+    const
+{
+  Index_expression::dump_index_expression(ast_dump_context, this->string_, 
+                                         this->start_, this->end_);
+}
+
 // Make a string index expression.  END may be NULL.
 
 Expression*
@@ -9760,7 +10695,7 @@ Map_index_expression::get_map_type() const
 {
   Map_type* mt = this->map_->type()->deref()->map_type();
   if (mt == NULL)
-    gcc_assert(saw_errors());
+    go_assert(saw_errors());
   return mt;
 }
 
@@ -9852,12 +10787,14 @@ Map_index_expression::do_get_tree(Translate_context* context)
     }
   else
     {
+      Gogo* gogo = context->gogo();
+      Btype* val_btype = type->val_type()->get_backend(gogo);
+      Bexpression* val_zero = gogo->backend()->zero_expression(val_btype);
       return fold_build3(COND_EXPR, val_type_tree,
                         fold_build2(EQ_EXPR, boolean_type_node, valptr,
                                     fold_convert(TREE_TYPE(valptr),
                                                  null_pointer_node)),
-                        type->val_type()->get_init_tree(context->gogo(),
-                                                        false),
+                        expr_to_tree(val_zero),
                         build_fold_indirect_ref(valptr));
     }
 }
@@ -9942,7 +10879,8 @@ Map_index_expression::get_value_pointer(Translate_context* context,
   // an uncomparable or unhashable type.
   TREE_NOTHROW(map_index_fndecl) = 0;
 
-  tree val_type_tree = type->val_type()->get_tree(context->gogo());
+  Type* val_type = type->val_type();
+  tree val_type_tree = type_to_tree(val_type->get_backend(context->gogo()));
   if (val_type_tree == error_mark_node)
     return error_mark_node;
   tree ptr_val_type_tree = build_pointer_type(val_type_tree);
@@ -9953,6 +10891,16 @@ Map_index_expression::get_value_pointer(Translate_context* context,
   return ret;
 }
 
+// Dump ast representation for a map index expression
+
+void
+Map_index_expression::do_dump_expression(Ast_dump_context* ast_dump_context) 
+    const
+{
+  Index_expression::dump_index_expression(ast_dump_context, 
+                                          this->map_, this->index_, NULL);
+}
+
 // Make a map index expression.
 
 Map_index_expression*
@@ -9970,10 +10918,10 @@ Type*
 Field_reference_expression::do_type()
 {
   Type* type = this->expr_->type();
-  if (type->is_error_type())
+  if (type->is_error())
     return type;
   Struct_type* struct_type = type->struct_type();
-  gcc_assert(struct_type != NULL);
+  go_assert(struct_type != NULL);
   return struct_type->field(this->field_index_)->type();
 }
 
@@ -9983,11 +10931,11 @@ void
 Field_reference_expression::do_check_types(Gogo*)
 {
   Type* type = this->expr_->type();
-  if (type->is_error_type())
+  if (type->is_error())
     return;
   Struct_type* struct_type = type->struct_type();
-  gcc_assert(struct_type != NULL);
-  gcc_assert(struct_type->field(this->field_index_) != NULL);
+  go_assert(struct_type != NULL);
+  go_assert(struct_type->field(this->field_index_) != NULL);
 }
 
 // Get a tree for a field reference.
@@ -9999,19 +10947,19 @@ Field_reference_expression::do_get_tree(Translate_context* context)
   if (struct_tree == error_mark_node
       || TREE_TYPE(struct_tree) == error_mark_node)
     return error_mark_node;
-  gcc_assert(TREE_CODE(TREE_TYPE(struct_tree)) == RECORD_TYPE);
+  go_assert(TREE_CODE(TREE_TYPE(struct_tree)) == RECORD_TYPE);
   tree field = TYPE_FIELDS(TREE_TYPE(struct_tree));
   if (field == NULL_TREE)
     {
       // This can happen for a type which refers to itself indirectly
       // and then turns out to be erroneous.
-      gcc_assert(saw_errors());
+      go_assert(saw_errors());
       return error_mark_node;
     }
   for (unsigned int i = this->field_index_; i > 0; --i)
     {
       field = DECL_CHAIN(field);
-      gcc_assert(field != NULL_TREE);
+      go_assert(field != NULL_TREE);
     }
   if (TREE_TYPE(field) == error_mark_node)
     return error_mark_node;
@@ -10019,6 +10967,16 @@ Field_reference_expression::do_get_tree(Translate_context* context)
                NULL_TREE);
 }
 
+// Dump ast representation for a field reference expression.
+
+void
+Field_reference_expression::do_dump_expression(
+    Ast_dump_context* ast_dump_context) const
+{
+  this->expr_->dump_expression(ast_dump_context);
+  ast_dump_context->ostream() << "." <<  this->field_index_;
+}
+
 // Make a reference to a qualified identifier in an expression.
 
 Field_reference_expression*
@@ -10040,16 +10998,16 @@ Interface_field_reference_expression::get_function_tree(Translate_context*,
     expr = build_fold_indirect_ref(expr);
 
   tree expr_type = TREE_TYPE(expr);
-  gcc_assert(TREE_CODE(expr_type) == RECORD_TYPE);
+  go_assert(TREE_CODE(expr_type) == RECORD_TYPE);
 
   tree field = TYPE_FIELDS(expr_type);
-  gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__methods") == 0);
+  go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__methods") == 0);
 
   tree table = build3(COMPONENT_REF, TREE_TYPE(field), expr, field, NULL_TREE);
-  gcc_assert(POINTER_TYPE_P(TREE_TYPE(table)));
+  go_assert(POINTER_TYPE_P(TREE_TYPE(table)));
 
   table = build_fold_indirect_ref(table);
-  gcc_assert(TREE_CODE(TREE_TYPE(table)) == RECORD_TYPE);
+  go_assert(TREE_CODE(TREE_TYPE(table)) == RECORD_TYPE);
 
   std::string name = Gogo::unpack_hidden_name(this->name_);
   for (field = DECL_CHAIN(TYPE_FIELDS(TREE_TYPE(table)));
@@ -10059,7 +11017,7 @@ Interface_field_reference_expression::get_function_tree(Translate_context*,
       if (name == IDENTIFIER_POINTER(DECL_NAME(field)))
        break;
     }
-  gcc_assert(field != NULL_TREE);
+  go_assert(field != NULL_TREE);
 
   return build3(COMPONENT_REF, TREE_TYPE(field), table, field, NULL_TREE);
 }
@@ -10076,10 +11034,10 @@ Interface_field_reference_expression::get_underlying_object_tree(
     expr = build_fold_indirect_ref(expr);
 
   tree expr_type = TREE_TYPE(expr);
-  gcc_assert(TREE_CODE(expr_type) == RECORD_TYPE);
+  go_assert(TREE_CODE(expr_type) == RECORD_TYPE);
 
   tree field = DECL_CHAIN(TYPE_FIELDS(expr_type));
-  gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__object") == 0);
+  go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__object") == 0);
 
   return build3(COMPONENT_REF, TREE_TYPE(field), expr, field, NULL_TREE);
 }
@@ -10135,7 +11093,10 @@ Interface_field_reference_expression::do_check_types(Gogo*)
 
   Interface_type* interface_type = type->interface_type();
   if (interface_type == NULL)
-    this->report_error(_("expected interface or pointer to interface"));
+    {
+      if (!type->is_error_type())
+       this->report_error(_("expected interface or pointer to interface"));
+    }
   else
     {
       const Typed_identifier* method =
@@ -10159,7 +11120,17 @@ Interface_field_reference_expression::do_check_types(Gogo*)
 tree
 Interface_field_reference_expression::do_get_tree(Translate_context*)
 {
-  gcc_unreachable();
+  go_unreachable();
+}
+
+// Dump ast representation for an interface field reference.
+
+void
+Interface_field_reference_expression::do_dump_expression(
+    Ast_dump_context* ast_dump_context) const
+{
+  this->expr_->dump_expression(ast_dump_context);
+  ast_dump_context->ostream() << "." << this->name_;
 }
 
 // Make a reference to a field in an interface.
@@ -10190,7 +11161,7 @@ class Selector_expression : public Parser_expression
   { return Expression::traverse(&this->left_, traverse); }
 
   Expression*
-  do_lower(Gogo*, Named_object*, int);
+  do_lower(Gogo*, Named_object*, Statement_inserter*, int);
 
   Expression*
   do_copy()
@@ -10199,6 +11170,9 @@ class Selector_expression : public Parser_expression
                                   this->location());
   }
 
+  void
+  do_dump_expression(Ast_dump_context* ast_dump_context) const;
+
  private:
   Expression*
   lower_method_expression(Gogo*);
@@ -10213,7 +11187,8 @@ class Selector_expression : public Parser_expression
 // hand side.
 
 Expression*
-Selector_expression::do_lower(Gogo* gogo, Named_object*, int)
+Selector_expression::do_lower(Gogo* gogo, Named_object*, Statement_inserter*,
+                             int)
 {
   Expression* left = this->left_;
   if (left->is_type_expression())
@@ -10251,20 +11226,30 @@ Selector_expression::lower_method_expression(Gogo* gogo)
 
   bool is_ambiguous;
   Method* method = nt->method_function(name, &is_ambiguous);
-  if (method == NULL)
+  const Typed_identifier* imethod = NULL;
+  if (method == NULL && !is_pointer)
+    {
+      Interface_type* it = nt->interface_type();
+      if (it != NULL)
+       imethod = it->find_method(name);
+    }
+
+  if (method == NULL && imethod == NULL)
     {
       if (!is_ambiguous)
-       error_at(location, "type %<%s%> has no method %<%s%>",
+       error_at(location, "type %<%s%s%> has no method %<%s%>",
+                is_pointer ? "*" : "",
                 nt->message_name().c_str(),
                 Gogo::message_name(name).c_str());
       else
-       error_at(location, "method %<%s%> is ambiguous in type %<%s%>",
+       error_at(location, "method %<%s%s%> is ambiguous in type %<%s%>",
                 Gogo::message_name(name).c_str(),
+                is_pointer ? "*" : "",
                 nt->message_name().c_str());
       return Expression::make_error(location);
     }
 
-  if (!is_pointer && !method->is_value_method())
+  if (method != NULL && !is_pointer && !method->is_value_method())
     {
       error_at(location, "method requires pointer (use %<(*%s).%s)%>",
               nt->message_name().c_str(),
@@ -10274,8 +11259,17 @@ Selector_expression::lower_method_expression(Gogo* gogo)
 
   // Build a new function type in which the receiver becomes the first
   // argument.
-  Function_type* method_type = method->type();
-  gcc_assert(method_type->is_method());
+  Function_type* method_type;
+  if (method != NULL)
+    {
+      method_type = method->type();
+      go_assert(method_type->is_method());
+    }
+  else
+    {
+      method_type = imethod->type()->function_type();
+      go_assert(method_type != NULL && !method_type->is_method());
+    }
 
   const char* const receiver_name = "$this";
   Typed_identifier_list* parameters = new Typed_identifier_list();
@@ -10314,7 +11308,7 @@ Selector_expression::lower_method_expression(Gogo* gogo)
   // simply reuse the existing function.  We use an internal hack to
   // get the right type.
 
-  if (is_pointer)
+  if (method != NULL && is_pointer)
     {
       Named_object* mno = (method->needs_stub_method()
                           ? method->stub_object()
@@ -10331,9 +11325,13 @@ Selector_expression::lower_method_expression(Gogo* gogo)
                                          location);
 
   Named_object* vno = gogo->lookup(receiver_name, NULL);
-  gcc_assert(vno != NULL);
+  go_assert(vno != NULL);
   Expression* ve = Expression::make_var_reference(vno, location);
-  Expression* bm = Type::bind_field_or_method(gogo, nt, ve, name, location);
+  Expression* bm;
+  if (method != NULL)
+    bm = Type::bind_field_or_method(gogo, nt, ve, name, location);
+  else
+    bm = Expression::make_interface_field_reference(ve, name, location);
 
   // Even though we found the method above, if it has an error type we
   // may see an error here.
@@ -10354,11 +11352,13 @@ Selector_expression::lower_method_expression(Gogo* gogo)
           ++p)
        {
          vno = gogo->lookup(p->name(), NULL);
-         gcc_assert(vno != NULL);
+         go_assert(vno != NULL);
          args->push_back(Expression::make_var_reference(vno, location));
        }
     }
 
+  gogo->start_block(location);
+
   Call_expression* call = Expression::make_call(bm, args,
                                                method_type->is_varargs(),
                                                location);
@@ -10366,7 +11366,7 @@ Selector_expression::lower_method_expression(Gogo* gogo)
   size_t count = call->result_count();
   Statement* s;
   if (count == 0)
-    s = Statement::make_statement(call);
+    s = Statement::make_statement(call, true);
   else
     {
       Expression_list* retvals = new Expression_list();
@@ -10377,16 +11377,33 @@ Selector_expression::lower_method_expression(Gogo* gogo)
          for (size_t i = 0; i < count; ++i)
            retvals->push_back(Expression::make_call_result(call, i));
        }
-      s = Statement::make_return_statement(no->func_value()->type()->results(),
-                                          retvals, location);
+      s = Statement::make_return_statement(retvals, location);
     }
   gogo->add_statement(s);
 
+  Block* b = gogo->finish_block(location);
+
+  gogo->add_block(b, location);
+
+  // Lower the call in case there are multiple results.
+  gogo->lower_block(no, b);
+
   gogo->finish_function(location);
 
   return Expression::make_func_reference(no, NULL, location);
 }
 
+// Dump the ast for a selector expression.
+
+void
+Selector_expression::do_dump_expression(Ast_dump_context* ast_dump_context) 
+    const
+{
+  ast_dump_context->dump_expression(this->left_);
+  ast_dump_context->ostream() << ".";
+  ast_dump_context->ostream() << this->name_;
+}
+                      
 // Make a selector expression.
 
 Expression*
@@ -10419,9 +11436,6 @@ class Allocation_expression : public Expression
   do_determine_type(const Type_context*)
   { }
 
-  void
-  do_check_types(Gogo*);
-
   Expression*
   do_copy()
   { return new Allocation_expression(this->type_, this->location()); }
@@ -10429,26 +11443,20 @@ class Allocation_expression : public Expression
   tree
   do_get_tree(Translate_context*);
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+  
  private:
   // The type we are allocating.
   Type* type_;
 };
 
-// Check the type of an allocation expression.
-
-void
-Allocation_expression::do_check_types(Gogo*)
-{
-  if (this->type_->function_type() != NULL)
-    this->report_error(_("invalid new of function type"));
-}
-
 // Return a tree for an allocation expression.
 
 tree
 Allocation_expression::do_get_tree(Translate_context* context)
 {
-  tree type_tree = this->type_->get_tree(context->gogo());
+  tree type_tree = type_to_tree(this->type_->get_backend(context->gogo()));
   if (type_tree == error_mark_node)
     return error_mark_node;
   tree size_tree = TYPE_SIZE_UNIT(type_tree);
@@ -10459,6 +11467,17 @@ Allocation_expression::do_get_tree(Translate_context* context)
   return fold_convert(build_pointer_type(type_tree), space);
 }
 
+// Dump ast representation for an allocation expression.
+
+void
+Allocation_expression::do_dump_expression(Ast_dump_context* ast_dump_context) 
+    const
+{
+  ast_dump_context->ostream() << "new(";
+  ast_dump_context->dump_type(this->type_);
+  ast_dump_context->ostream() << ")";
+}
+
 // Make an allocation expression.
 
 Expression*
@@ -10467,116 +11486,15 @@ Expression::make_allocation(Type* type, source_location location)
   return new Allocation_expression(type, location);
 }
 
-// Implement the builtin function make.
+// Construct a struct.
 
-class Make_expression : public Expression
+class Struct_construction_expression : public Expression
 {
  public:
-  Make_expression(Type* type, Expression_list* args, source_location location)
-    : Expression(EXPRESSION_MAKE, location),
-      type_(type), args_(args)
-  { }
-
- protected:
-  int
-  do_traverse(Traverse* traverse);
-
-  Type*
-  do_type()
-  { return this->type_; }
-
-  void
-  do_determine_type(const Type_context*);
-
-  void
-  do_check_types(Gogo*);
-
-  Expression*
-  do_copy()
-  {
-    return new Make_expression(this->type_, this->args_->copy(),
-                              this->location());
-  }
-
-  tree
-  do_get_tree(Translate_context*);
-
- private:
-  // The type we are making.
-  Type* type_;
-  // The arguments to pass to the make routine.
-  Expression_list* args_;
-};
-
-// Traversal.
-
-int
-Make_expression::do_traverse(Traverse* traverse)
-{
-  if (this->args_ != NULL
-      && this->args_->traverse(traverse) == TRAVERSE_EXIT)
-    return TRAVERSE_EXIT;
-  if (Type::traverse(this->type_, traverse) == TRAVERSE_EXIT)
-    return TRAVERSE_EXIT;
-  return TRAVERSE_CONTINUE;
-}
-
-// Set types of arguments.
-
-void
-Make_expression::do_determine_type(const Type_context*)
-{
-  if (this->args_ != NULL)
-    {
-      Type_context context(Type::lookup_integer_type("int"), false);
-      for (Expression_list::const_iterator pe = this->args_->begin();
-          pe != this->args_->end();
-          ++pe)
-       (*pe)->determine_type(&context);
-    }
-}
-
-// Check types for a make expression.
-
-void
-Make_expression::do_check_types(Gogo*)
-{
-  if (this->type_->channel_type() == NULL
-      && this->type_->map_type() == NULL
-      && (this->type_->array_type() == NULL
-         || this->type_->array_type()->length() != NULL))
-    this->report_error(_("invalid type for make function"));
-  else if (!this->type_->check_make_expression(this->args_, this->location()))
-    this->set_is_error();
-}
-
-// Return a tree for a make expression.
-
-tree
-Make_expression::do_get_tree(Translate_context* context)
-{
-  return this->type_->make_expression_tree(context, this->args_,
-                                          this->location());
-}
-
-// Make a make expression.
-
-Expression*
-Expression::make_make(Type* type, Expression_list* args,
-                     source_location location)
-{
-  return new Make_expression(type, args, location);
-}
-
-// Construct a struct.
-
-class Struct_construction_expression : public Expression
-{
- public:
-  Struct_construction_expression(Type* type, Expression_list* vals,
-                                source_location location)
-    : Expression(EXPRESSION_STRUCT_CONSTRUCTION, location),
-      type_(type), vals_(vals)
+  Struct_construction_expression(Type* type, Expression_list* vals,
+                                source_location location)
+    : Expression(EXPRESSION_STRUCT_CONSTRUCTION, location),
+      type_(type), vals_(vals)
   { }
 
   // Return whether this is a constant initializer.
@@ -10614,6 +11532,9 @@ class Struct_construction_expression : public Expression
   void
   do_export(Export*) const;
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+
  private:
   // The type of the struct to construct.
   Type* type_;
@@ -10739,7 +11660,7 @@ Struct_construction_expression::do_check_types(Gogo*)
          this->set_is_error();
        }
     }
-  gcc_assert(pv == this->vals_->end());
+  go_assert(pv == this->vals_->end());
 }
 
 // Return a tree for constructing a struct.
@@ -10750,12 +11671,15 @@ Struct_construction_expression::do_get_tree(Translate_context* context)
   Gogo* gogo = context->gogo();
 
   if (this->vals_ == NULL)
-    return this->type_->get_init_tree(gogo, false);
+    {
+      Btype* btype = this->type_->get_backend(gogo);
+      return expr_to_tree(gogo->backend()->zero_expression(btype));
+    }
 
-  tree type_tree = this->type_->get_tree(gogo);
+  tree type_tree = type_to_tree(this->type_->get_backend(gogo));
   if (type_tree == error_mark_node)
     return error_mark_node;
-  gcc_assert(TREE_CODE(type_tree) == RECORD_TYPE);
+  go_assert(TREE_CODE(type_tree) == RECORD_TYPE);
 
   bool is_constant = true;
   const Struct_field_list* fields = this->type_->struct_type()->fields();
@@ -10767,14 +11691,16 @@ Struct_construction_expression::do_get_tree(Translate_context* context)
        field != NULL_TREE;
        field = DECL_CHAIN(field), ++pf)
     {
-      gcc_assert(pf != fields->end());
+      go_assert(pf != fields->end());
+
+      Btype* fbtype = pf->type()->get_backend(gogo);
 
       tree val;
       if (pv == this->vals_->end())
-       val = pf->type()->get_init_tree(gogo, false);
+       val = expr_to_tree(gogo->backend()->zero_expression(fbtype));
       else if (*pv == NULL)
        {
-         val = pf->type()->get_init_tree(gogo, false);
+         val = expr_to_tree(gogo->backend()->zero_expression(fbtype));
          ++pv;
        }
       else
@@ -10795,7 +11721,7 @@ Struct_construction_expression::do_get_tree(Translate_context* context)
       if (!TREE_CONSTANT(val))
        is_constant = false;
     }
-  gcc_assert(pf == fields->end());
+  go_assert(pf == fields->end());
 
   tree ret = build_constructor(type_tree, elts);
   if (is_constant)
@@ -10821,13 +11747,25 @@ Struct_construction_expression::do_export(Export* exp) const
   exp->write_c_string(")");
 }
 
+// Dump ast representation of a struct construction expression.
+
+void
+Struct_construction_expression::do_dump_expression(
+    Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->dump_type(this->type_);
+  ast_dump_context->ostream() << "{";
+  ast_dump_context->dump_expression_list(this->vals_);
+  ast_dump_context->ostream() << "}";
+}
+
 // Make a struct composite literal.  This used by the thunk code.
 
 Expression*
 Expression::make_struct_composite_literal(Type* type, Expression_list* vals,
                                          source_location location)
 {
-  gcc_assert(type->struct_type() != NULL);
+  go_assert(type->struct_type() != NULL);
   return new Struct_construction_expression(type, vals, location);
 }
 
@@ -10885,6 +11823,9 @@ protected:
   tree
   get_constructor_tree(Translate_context* context, tree type_tree);
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+
  private:
   // The type of the array to construct.
   Type* type_;
@@ -10973,7 +11914,7 @@ Array_construction_expression::do_check_types(Gogo*)
     }
 
   Expression* length = at->length();
-  if (length != NULL)
+  if (length != NULL && !length->is_error_expression())
     {
       mpz_t val;
       mpz_init(val);
@@ -11009,7 +11950,12 @@ Array_construction_expression::get_constructor_tree(Translate_context* context,
          constructor_elt* elt = VEC_quick_push(constructor_elt, values, NULL);
          elt->index = size_int(i);
          if (*pv == NULL)
-           elt->value = element_type->get_init_tree(context->gogo(), false);
+           {
+             Gogo* gogo = context->gogo();
+             Btype* ebtype = element_type->get_backend(gogo);
+             Bexpression *zv = gogo->backend()->zero_expression(ebtype);
+             elt->value = expr_to_tree(zv);
+           }
          else
            {
              tree value_tree = (*pv)->get_tree(context);
@@ -11053,6 +11999,28 @@ Array_construction_expression::do_export(Export* exp) const
   exp->write_c_string(")");
 }
 
+// Dump ast representation of an array construction expressin.
+
+void
+Array_construction_expression::do_dump_expression(
+    Ast_dump_context* ast_dump_context) const
+{
+  Expression* length = this->type_->array_type() != NULL ?
+                        this->type_->array_type()->length() : NULL;
+
+  ast_dump_context->ostream() << "[" ;
+  if (length != NULL)
+    {
+      ast_dump_context->dump_expression(length);
+    }
+  ast_dump_context->ostream() << "]" ;
+  ast_dump_context->dump_type(this->type_);
+  ast_dump_context->ostream() << "{" ;
+  ast_dump_context->dump_expression_list(this->vals_);
+  ast_dump_context->ostream() << "}" ;
+
+}
+
 // Construct a fixed array.
 
 class Fixed_array_construction_expression :
@@ -11064,7 +12032,7 @@ class Fixed_array_construction_expression :
     : Array_construction_expression(EXPRESSION_FIXED_ARRAY_CONSTRUCTION,
                                    type, vals, location)
   {
-    gcc_assert(type->array_type() != NULL
+    go_assert(type->array_type() != NULL
               && type->array_type()->length() != NULL);
   }
 
@@ -11081,6 +12049,9 @@ class Fixed_array_construction_expression :
 
   tree
   do_get_tree(Translate_context*);
+
+  void
+  do_dump_expression(Ast_dump_context*);
 };
 
 // Return a tree for constructing a fixed array.
@@ -11088,10 +12059,27 @@ class Fixed_array_construction_expression :
 tree
 Fixed_array_construction_expression::do_get_tree(Translate_context* context)
 {
-  return this->get_constructor_tree(context,
-                                   this->type()->get_tree(context->gogo()));
+  Type* type = this->type();
+  Btype* btype = type->get_backend(context->gogo());
+  return this->get_constructor_tree(context, type_to_tree(btype));
 }
 
+// Dump ast representation of an array construction expressin.
+
+void
+Fixed_array_construction_expression::do_dump_expression(
+    Ast_dump_context* ast_dump_context)
+{
+
+  ast_dump_context->ostream() << "[";
+  ast_dump_context->dump_expression (this->type()->array_type()->length());
+  ast_dump_context->ostream() << "]";
+  ast_dump_context->dump_type(this->type());
+  ast_dump_context->ostream() << "{";
+  ast_dump_context->dump_expression_list(this->vals());
+  ast_dump_context->ostream() << "}";
+
+}
 // Construct an open array.
 
 class Open_array_construction_expression : public Array_construction_expression
@@ -11102,7 +12090,7 @@ class Open_array_construction_expression : public Array_construction_expression
     : Array_construction_expression(EXPRESSION_OPEN_ARRAY_CONSTRUCTION,
                                    type, vals, location)
   {
-    gcc_assert(type->array_type() != NULL
+    go_assert(type->array_type() != NULL
               && type->array_type()->length() == NULL);
   }
 
@@ -11131,12 +12119,13 @@ Open_array_construction_expression::do_get_tree(Translate_context* context)
   Array_type* array_type = this->type()->array_type();
   if (array_type == NULL)
     {
-      gcc_assert(this->type()->is_error_type());
+      go_assert(this->type()->is_error());
       return error_mark_node;
     }
 
   Type* element_type = array_type->element_type();
-  tree element_type_tree = element_type->get_tree(context->gogo());
+  Btype* belement_type = element_type->get_backend(context->gogo());
+  tree element_type_tree = type_to_tree(belement_type);
   if (element_type_tree == error_mark_node)
     return error_mark_node;
 
@@ -11153,7 +12142,9 @@ Open_array_construction_expression::do_get_tree(Translate_context* context)
       VEC(constructor_elt,gc)* vec = VEC_alloc(constructor_elt, gc, 1);
       constructor_elt* elt = VEC_quick_push(constructor_elt, vec, NULL);
       elt->index = size_int(0);
-      elt->value = element_type->get_init_tree(context->gogo(), false);
+      Gogo* gogo = context->gogo();
+      Btype* btype = element_type->get_backend(gogo);
+      elt->value = expr_to_tree(gogo->backend()->zero_expression(btype));
       values = build_constructor(constructor_type, vec);
       if (TREE_CONSTANT(elt->value))
        TREE_CONSTANT(values) = 1;
@@ -11229,28 +12220,28 @@ Open_array_construction_expression::do_get_tree(Translate_context* context)
 
   // Build a constructor for the open array.
 
-  tree type_tree = this->type()->get_tree(context->gogo());
+  tree type_tree = type_to_tree(this->type()->get_backend(context->gogo()));
   if (type_tree == error_mark_node)
     return error_mark_node;
-  gcc_assert(TREE_CODE(type_tree) == RECORD_TYPE);
+  go_assert(TREE_CODE(type_tree) == RECORD_TYPE);
 
   VEC(constructor_elt,gc)* init = VEC_alloc(constructor_elt, gc, 3);
 
   constructor_elt* elt = VEC_quick_push(constructor_elt, init, NULL);
   tree field = TYPE_FIELDS(type_tree);
-  gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__values") == 0);
+  go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__values") == 0);
   elt->index = field;
   elt->value = fold_convert(TREE_TYPE(field), space);
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
   field = DECL_CHAIN(field);
-  gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0);
+  go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0);
   elt->index = field;
   elt->value = fold_convert(TREE_TYPE(field), length_tree);
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
   field = DECL_CHAIN(field);
-  gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),"__capacity") == 0);
+  go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),"__capacity") == 0);
   elt->index = field;
   elt->value = fold_convert(TREE_TYPE(field), length_tree);
 
@@ -11273,7 +12264,7 @@ Expression*
 Expression::make_slice_composite_literal(Type* type, Expression_list* vals,
                                         source_location location)
 {
-  gcc_assert(type->is_open_array_type());
+  go_assert(type->is_slice_type());
   return new Open_array_construction_expression(type, vals, location);
 }
 
@@ -11286,7 +12277,7 @@ class Map_construction_expression : public Expression
                              source_location location)
     : Expression(EXPRESSION_MAP_CONSTRUCTION, location),
       type_(type), vals_(vals)
-  { gcc_assert(vals == NULL || vals->size() % 2 == 0); }
+  { go_assert(vals == NULL || vals->size() % 2 == 0); }
 
  protected:
   int
@@ -11315,6 +12306,9 @@ class Map_construction_expression : public Expression
   void
   do_export(Export*) const;
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+  
  private:
   // The type of the map to construct.
   Type* type_;
@@ -11406,7 +12400,7 @@ Map_construction_expression::do_get_tree(Translate_context* context)
 
   Type* key_type = mt->key_type();
   tree id = get_identifier("__key");
-  tree key_type_tree = key_type->get_tree(gogo);
+  tree key_type_tree = type_to_tree(key_type->get_backend(gogo));
   if (key_type_tree == error_mark_node)
     return error_mark_node;
   tree key_field = build_decl(loc, FIELD_DECL, id, key_type_tree);
@@ -11415,7 +12409,7 @@ Map_construction_expression::do_get_tree(Translate_context* context)
 
   Type* val_type = mt->val_type();
   id = get_identifier("__val");
-  tree val_type_tree = val_type->get_tree(gogo);
+  tree val_type_tree = type_to_tree(val_type->get_backend(gogo));
   if (val_type_tree == error_mark_node)
     return error_mark_node;
   tree val_field = build_decl(loc, FIELD_DECL, id, val_type_tree);
@@ -11516,9 +12510,9 @@ Map_construction_expression::do_get_tree(Translate_context* context)
       valaddr = build_fold_addr_expr(tmp);
     }
 
-  tree descriptor = gogo->map_descriptor(mt);
+  tree descriptor = mt->map_descriptor_pointer(gogo, loc);
 
-  tree type_tree = this->type_->get_tree(gogo);
+  tree type_tree = type_to_tree(this->type_->get_backend(gogo));
   if (type_tree == error_mark_node)
     return error_mark_node;
 
@@ -11568,6 +12562,17 @@ Map_construction_expression::do_export(Export* exp) const
   exp->write_c_string(")");
 }
 
+// Dump ast representation for a map construction expression.
+
+void
+Map_construction_expression::do_dump_expression(
+    Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->ostream() << "{" ;
+  ast_dump_context->dump_expression_list(this->vals_, true);
+  ast_dump_context->ostream() << "}";
+}
+
 // A general composite literal.  This is lowered to a type specific
 // version.
 
@@ -11585,7 +12590,7 @@ class Composite_literal_expression : public Parser_expression
   do_traverse(Traverse* traverse);
 
   Expression*
-  do_lower(Gogo*, Named_object*, int);
+  do_lower(Gogo*, Named_object*, Statement_inserter*, int);
 
   Expression*
   do_copy()
@@ -11598,9 +12603,12 @@ class Composite_literal_expression : public Parser_expression
                                            this->location());
   }
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+  
  private:
   Expression*
-  lower_struct(Type*);
+  lower_struct(Gogo*, Type*);
 
   Expression*
   lower_array(Type*);
@@ -11609,7 +12617,7 @@ class Composite_literal_expression : public Parser_expression
   make_array(Type*, Expression_list*);
 
   Expression*
-  lower_map(Gogo*, Named_object*, Type*);
+  lower_map(Gogo*, Named_object*, Statement_inserter*, Type*);
 
   // The type of the composite literal.
   Type* type_;
@@ -11638,7 +12646,8 @@ Composite_literal_expression::do_traverse(Traverse* traverse)
 // the type.
 
 Expression*
-Composite_literal_expression::do_lower(Gogo* gogo, Named_object* function, int)
+Composite_literal_expression::do_lower(Gogo* gogo, Named_object* function,
+                                      Statement_inserter* inserter, int)
 {
   Type* type = this->type_;
 
@@ -11650,7 +12659,7 @@ Composite_literal_expression::do_lower(Gogo* gogo, Named_object* function, int)
        type = type->map_type()->val_type();
       else
        {
-         if (!type->is_error_type())
+         if (!type->is_error())
            error_at(this->location(),
                     ("may only omit types within composite literals "
                      "of slice, array, or map type"));
@@ -11658,14 +12667,14 @@ Composite_literal_expression::do_lower(Gogo* gogo, Named_object* function, int)
        }
     }
 
-  if (type->is_error_type())
+  if (type->is_error())
     return Expression::make_error(this->location());
   else if (type->struct_type() != NULL)
-    return this->lower_struct(type);
+    return this->lower_struct(gogo, type);
   else if (type->array_type() != NULL)
     return this->lower_array(type);
   else if (type->map_type() != NULL)
-    return this->lower_map(gogo, function, type);
+    return this->lower_map(gogo, function, inserter, type);
   else
     {
       error_at(this->location(),
@@ -11678,7 +12687,7 @@ Composite_literal_expression::do_lower(Gogo* gogo, Named_object* function, int)
 // Lower a struct composite literal.
 
 Expression*
-Composite_literal_expression::lower_struct(Type* type)
+Composite_literal_expression::lower_struct(Gogo* gogo, Type* type)
 {
   source_location location = this->location();
   Struct_type* st = type->struct_type();
@@ -11693,7 +12702,7 @@ Composite_literal_expression::lower_struct(Type* type)
       Expression* name_expr = *p;
 
       ++p;
-      gcc_assert(p != this->vals_->end());
+      go_assert(p != this->vals_->end());
       Expression* val = *p;
 
       ++p;
@@ -11706,6 +12715,7 @@ Composite_literal_expression::lower_struct(Type* type)
 
       bool bad_key = false;
       std::string name;
+      const Named_object* no = NULL;
       switch (name_expr->classification())
        {
        case EXPRESSION_UNKNOWN_REFERENCE:
@@ -11713,7 +12723,7 @@ Composite_literal_expression::lower_struct(Type* type)
          break;
 
        case EXPRESSION_CONST_REFERENCE:
-         name = static_cast<Const_expression*>(name_expr)->name();
+         no = static_cast<Const_expression*>(name_expr)->named_object();
          break;
 
        case EXPRESSION_TYPE:
@@ -11723,16 +12733,16 @@ Composite_literal_expression::lower_struct(Type* type)
            if (nt == NULL)
              bad_key = true;
            else
-             name = nt->name();
+             no = nt->named_object();
          }
          break;
 
        case EXPRESSION_VAR_REFERENCE:
-         name = name_expr->var_expression()->name();
+         no = name_expr->var_expression()->named_object();
          break;
 
        case EXPRESSION_FUNC_REFERENCE:
-         name = name_expr->func_expression()->name();
+         no = name_expr->func_expression()->named_object();
          break;
 
        case EXPRESSION_UNARY:
@@ -11755,6 +12765,16 @@ Composite_literal_expression::lower_struct(Type* type)
                      {
                        const Struct_field* sf = st->field(fre->field_index());
                        name = sf->field_name();
+
+                       // See below.  FIXME.
+                       if (!Gogo::is_hidden_name(name)
+                           && name[0] >= 'a'
+                           && name[0] <= 'z')
+                         {
+                           if (gogo->lookup_global(name.c_str()) != NULL)
+                             name = gogo->pack_hidden_name(name, false);
+                         }
+
                        char buf[20];
                        snprintf(buf, sizeof buf, "%u", fre->field_index());
                        size_t buflen = strlen(buf);
@@ -11780,6 +12800,23 @@ Composite_literal_expression::lower_struct(Type* type)
          return Expression::make_error(location);
        }
 
+      if (no != NULL)
+       {
+         name = no->name();
+
+         // A predefined name won't be packed.  If it starts with a
+         // lower case letter we need to check for that case, because
+         // the field name will be packed.  FIXME.
+         if (!Gogo::is_hidden_name(name)
+             && name[0] >= 'a'
+             && name[0] <= 'z')
+           {
+             Named_object* gno = gogo->lookup_global(name.c_str());
+             if (gno == no)
+               name = gogo->pack_hidden_name(name, false);
+           }
+       }
+
       unsigned int index;
       const Struct_field* sf = st->find_local_field(name, &index);
       if (sf == NULL)
@@ -11831,7 +12868,7 @@ Composite_literal_expression::lower_array(Type* type)
       Expression* index_expr = *p;
 
       ++p;
-      gcc_assert(p != this->vals_->end());
+      go_assert(p != this->vals_->end());
       Expression* val = *p;
 
       ++p;
@@ -11840,6 +12877,7 @@ Composite_literal_expression::lower_array(Type* type)
        {
          mpz_t ival;
          mpz_init(ival);
+
          Type* dummy;
          if (!index_expr->integer_constant_value(true, ival, &dummy))
            {
@@ -11848,12 +12886,14 @@ Composite_literal_expression::lower_array(Type* type)
                       "index expression is not integer constant");
              return Expression::make_error(location);
            }
+
          if (mpz_sgn(ival) < 0)
            {
              mpz_clear(ival);
              error_at(index_expr->location(), "index expression is negative");
              return Expression::make_error(location);
            }
+
          index = mpz_get_ui(ival);
          if (mpz_cmp_ui(ival, index) != 0)
            {
@@ -11861,7 +12901,30 @@ Composite_literal_expression::lower_array(Type* type)
              error_at(index_expr->location(), "index value overflow");
              return Expression::make_error(location);
            }
+
+         Named_type* ntype = Type::lookup_integer_type("int");
+         Integer_type* inttype = ntype->integer_type();
+         mpz_t max;
+         mpz_init_set_ui(max, 1);
+         mpz_mul_2exp(max, max, inttype->bits() - 1);
+         bool ok = mpz_cmp(ival, max) < 0;
+         mpz_clear(max);
+         if (!ok)
+           {
+             mpz_clear(ival);
+             error_at(index_expr->location(), "index value overflow");
+             return Expression::make_error(location);
+           }
+
          mpz_clear(ival);
+
+         // FIXME: Our representation isn't very good; this avoids
+         // thrashing.
+         if (index > 0x1000000)
+           {
+             error_at(index_expr->location(), "index too large for compiler");
+             return Expression::make_error(location);
+           }
        }
 
       if (index == vals.size())
@@ -11925,6 +12988,7 @@ Composite_literal_expression::make_array(Type* type, Expression_list* vals)
 
 Expression*
 Composite_literal_expression::lower_map(Gogo* gogo, Named_object* function,
+                                       Statement_inserter* inserter,
                                        Type* type)
 {
   source_location location = this->location();
@@ -11953,8 +13017,8 @@ Composite_literal_expression::lower_map(Gogo* gogo, Named_object* function,
          if ((*p)->unknown_expression() != NULL)
            {
              (*p)->unknown_expression()->clear_is_composite_literal_key();
-             gogo->lower_expression(function, &*p);
-             gcc_assert((*p)->is_error_expression());
+             gogo->lower_expression(function, inserter, &*p);
+             go_assert((*p)->is_error_expression());
              return Expression::make_error(location);
            }
        }
@@ -11963,6 +13027,19 @@ Composite_literal_expression::lower_map(Gogo* gogo, Named_object* function,
   return new Map_construction_expression(type, this->vals_, location);
 }
 
+// Dump ast representation for a composite literal expression.
+
+void
+Composite_literal_expression::do_dump_expression(
+                               Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->ostream() << "composite(";
+  ast_dump_context->dump_type(this->type_);
+  ast_dump_context->ostream() << ", {";
+  ast_dump_context->dump_expression_list(this->vals_, this->has_keys_);
+  ast_dump_context->ostream() << "})";
+}
+
 // Make a composite literal expression.
 
 Expression*
@@ -12079,7 +13156,7 @@ Type_guard_expression::do_check_types(Gogo*)
     }
   else if (expr_type->interface_type() == NULL)
     {
-      if (!expr_type->is_error_type() && !this->type_->is_error_type())
+      if (!expr_type->is_error() && !this->type_->is_error())
        this->report_error(_("type assertion only valid for interface types"));
       this->set_is_error();
     }
@@ -12089,7 +13166,7 @@ Type_guard_expression::do_check_types(Gogo*)
       if (!expr_type->interface_type()->implements_interface(this->type_,
                                                             &reason))
        {
-         if (!this->type_->is_error_type())
+         if (!this->type_->is_error())
            {
              if (reason.empty())
                this->report_error(_("impossible type assertion: "
@@ -12120,10 +13197,12 @@ Type_guard_expression::do_get_tree(Translate_context* context)
           || expr_type->integer_type() != NULL))
       || (expr_type->is_unsafe_pointer_type()
          && this->type_->points_to() != NULL))
-    return convert_to_pointer(this->type_->get_tree(gogo), expr_tree);
+    return convert_to_pointer(type_to_tree(this->type_->get_backend(gogo)),
+                             expr_tree);
   else if (expr_type->is_unsafe_pointer_type()
           && this->type_->integer_type() != NULL)
-    return convert_to_integer(this->type_->get_tree(gogo), expr_tree);
+    return convert_to_integer(type_to_tree(this->type_->get_backend(gogo)),
+                             expr_tree);
   else if (this->type_->interface_type() != NULL)
     return Expression::convert_interface_to_interface(context, this->type_,
                                                      this->expr_->type(),
@@ -12135,6 +13214,17 @@ Type_guard_expression::do_get_tree(Translate_context* context)
                                              this->location());
 }
 
+// Dump ast representation for a type guard expression.
+
+void
+Type_guard_expression::do_dump_expression(Ast_dump_context* ast_dump_context) 
+    const
+{
+  this->expr_->dump_expression(ast_dump_context);
+  ast_dump_context->ostream() <<  ".";
+  ast_dump_context->dump_type(this->type_);
+}
+
 // Make a type guard expression.
 
 Expression*
@@ -12184,7 +13274,10 @@ class Heap_composite_expression : public Expression
   // this in global scope.
   void
   do_export(Export*) const
-  { gcc_unreachable(); }
+  { go_unreachable(); }
+
+  void
+  do_dump_expression(Ast_dump_context*) const;
 
  private:
   // The composite literal which is being put on the heap.
@@ -12200,7 +13293,7 @@ Heap_composite_expression::do_get_tree(Translate_context* context)
   if (expr_tree == error_mark_node)
     return error_mark_node;
   tree expr_size = TYPE_SIZE_UNIT(TREE_TYPE(expr_tree));
-  gcc_assert(TREE_CODE(expr_size) == INTEGER_CST);
+  go_assert(TREE_CODE(expr_size) == INTEGER_CST);
   tree space = context->gogo()->allocate_memory(this->expr_->type(),
                                                expr_size, this->location());
   space = fold_convert(build_pointer_type(TREE_TYPE(expr_tree)), space);
@@ -12214,6 +13307,17 @@ Heap_composite_expression::do_get_tree(Translate_context* context)
   return ret;
 }
 
+// Dump ast representation for a heap composite expression.
+
+void
+Heap_composite_expression::do_dump_expression(
+    Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->ostream() << "&(";
+  ast_dump_context->dump_expression(this->expr_);
+  ast_dump_context->ostream() << ")";
+}
+
 // Allocate a composite literal on the heap.
 
 Expression*
@@ -12241,7 +13345,7 @@ void
 Receive_expression::do_check_types(Gogo*)
 {
   Type* type = this->channel_->type();
-  if (type->is_error_type())
+  if (type->is_error())
     {
       this->set_is_error();
       return;
@@ -12264,9 +13368,14 @@ tree
 Receive_expression::do_get_tree(Translate_context* context)
 {
   Channel_type* channel_type = this->channel_->type()->channel_type();
-  gcc_assert(channel_type != NULL);
+  if (channel_type == NULL)
+    {
+      go_assert(this->channel_->type()->is_error());
+      return error_mark_node;
+    }
   Type* element_type = channel_type->element_type();
-  tree element_type_tree = element_type->get_tree(context->gogo());
+  Btype* element_type_btype = element_type->get_backend(context->gogo());
+  tree element_type_tree = type_to_tree(element_type_btype);
 
   tree channel = this->channel_->get_tree(context);
   if (element_type_tree == error_mark_node || channel == error_mark_node)
@@ -12276,106 +13385,21 @@ Receive_expression::do_get_tree(Translate_context* context)
                                    this->for_select_, this->location());
 }
 
-// Make a receive expression.
-
-Receive_expression*
-Expression::make_receive(Expression* channel, source_location location)
-{
-  return new Receive_expression(channel, location);
-}
-
-// Class Send_expression.
-
-// Traversal.
-
-int
-Send_expression::do_traverse(Traverse* traverse)
-{
-  if (Expression::traverse(&this->channel_, traverse) == TRAVERSE_EXIT)
-    return TRAVERSE_EXIT;
-  return Expression::traverse(&this->val_, traverse);
-}
-
-// Get the type.
-
-Type*
-Send_expression::do_type()
-{
-  return Type::lookup_bool_type();
-}
-
-// Set types.
+// Dump ast representation for a receive expression.
 
 void
-Send_expression::do_determine_type(const Type_context*)
+Receive_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
 {
-  this->channel_->determine_type_no_context();
-
-  Type* type = this->channel_->type();
-  Type_context subcontext;
-  if (type->channel_type() != NULL)
-    subcontext.type = type->channel_type()->element_type();
-  this->val_->determine_type(&subcontext);
-}
-
-// Check types.
-
-void
-Send_expression::do_check_types(Gogo*)
-{
-  Type* type = this->channel_->type();
-  if (type->is_error_type())
-    {
-      this->set_is_error();
-      return;
-    }
-  Channel_type* channel_type = type->channel_type();
-  if (channel_type == NULL)
-    {
-      error_at(this->location(), "left operand of %<<-%> must be channel");
-      this->set_is_error();
-      return;
-    }
-  Type* element_type = channel_type->element_type();
-  if (element_type != NULL
-      && !Type::are_assignable(element_type, this->val_->type(), NULL))
-    {
-      this->report_error(_("incompatible types in send"));
-      return;
-    }
-  if (!channel_type->may_send())
-    {
-      this->report_error(_("invalid send on receive-only channel"));
-      return;
-    }
-}
-
-// Get a tree for a send expression.
-
-tree
-Send_expression::do_get_tree(Translate_context* context)
-{
-  tree channel = this->channel_->get_tree(context);
-  tree val = this->val_->get_tree(context);
-  if (channel == error_mark_node || val == error_mark_node)
-    return error_mark_node;
-  Channel_type* channel_type = this->channel_->type()->channel_type();
-  val = Expression::convert_for_assignment(context,
-                                          channel_type->element_type(),
-                                          this->val_->type(),
-                                          val,
-                                          this->location());
-  return Gogo::send_on_channel(channel, val, this->is_value_discarded_,
-                              this->for_select_, this->location());
+  ast_dump_context->ostream() << " <- " ;
+  ast_dump_context->dump_expression(channel_);
 }
 
-// Make a send expression
+// Make a receive expression.
 
-Send_expression*
-Expression::make_send(Expression* channel, Expression* val,
-                     source_location location)
+Receive_expression*
+Expression::make_receive(Expression* channel, source_location location)
 {
-  return new Send_expression(channel, val, location);
+  return new Receive_expression(channel, location);
 }
 
 // An expression which evaluates to a pointer to the type descriptor
@@ -12404,13 +13428,28 @@ class Type_descriptor_expression : public Expression
 
   tree
   do_get_tree(Translate_context* context)
-  { return this->type_->type_descriptor_pointer(context->gogo()); }
+  {
+    return this->type_->type_descriptor_pointer(context->gogo(),
+                                               this->location());
+  }
+
+  void
+  do_dump_expression(Ast_dump_context*) const;
 
  private:
   // The type for which this is the descriptor.
   Type* type_;
 };
 
+// Dump ast representation for a type descriptor expression.
+
+void
+Type_descriptor_expression::do_dump_expression(
+    Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->dump_type(this->type_);
+}
+
 // Make a type descriptor expression.
 
 Expression*
@@ -12448,6 +13487,9 @@ class Type_info_expression : public Expression
   tree
   do_get_tree(Translate_context* context);
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+
  private:
   // The type for which we are getting information.
   Type* type_;
@@ -12469,7 +13511,7 @@ Type_info_expression::do_type()
     case TYPE_INFO_FIELD_ALIGNMENT:
       return Type::lookup_integer_type("uint8");
     default:
-      gcc_unreachable();
+      go_unreachable();
     }
 }
 
@@ -12478,12 +13520,12 @@ Type_info_expression::do_type()
 tree
 Type_info_expression::do_get_tree(Translate_context* context)
 {
-  tree type_tree = this->type_->get_tree(context->gogo());
+  tree type_tree = type_to_tree(this->type_->get_backend(context->gogo()));
   if (type_tree == error_mark_node)
     return error_mark_node;
 
-  tree val_type_tree = this->type()->get_tree(context->gogo());
-  gcc_assert(val_type_tree != error_mark_node);
+  tree val_type_tree = type_to_tree(this->type()->get_backend(context->gogo()));
+  go_assert(val_type_tree != error_mark_node);
 
   if (this->type_info_ == TYPE_INFO_SIZE)
     return fold_convert_loc(BUILTINS_LOCATION, val_type_tree,
@@ -12499,6 +13541,23 @@ Type_info_expression::do_get_tree(Translate_context* context)
     }
 }
 
+// Dump ast representation for a type info expression.
+
+void
+Type_info_expression::do_dump_expression(
+    Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->ostream() << "typeinfo(";
+  ast_dump_context->dump_type(this->type_);
+  ast_dump_context->ostream() << ",";
+  ast_dump_context->ostream() << 
+    (this->type_info_ == TYPE_INFO_ALIGNMENT ? "alignment" 
+    : this->type_info_ == TYPE_INFO_FIELD_ALIGNMENT ? "field alignment"
+    : this->type_info_ == TYPE_INFO_SIZE ? "size "
+    : "unknown");
+  ast_dump_context->ostream() << ")";
+}
+
 // Make a type info expression.
 
 Expression*
@@ -12535,6 +13594,9 @@ class Struct_field_offset_expression : public Expression
   tree
   do_get_tree(Translate_context* context);
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+  
  private:
   // The type of the struct.
   Struct_type* type_;
@@ -12547,12 +13609,12 @@ class Struct_field_offset_expression : public Expression
 tree
 Struct_field_offset_expression::do_get_tree(Translate_context* context)
 {
-  tree type_tree = this->type_->get_tree(context->gogo());
+  tree type_tree = type_to_tree(this->type_->get_backend(context->gogo()));
   if (type_tree == error_mark_node)
     return error_mark_node;
 
-  tree val_type_tree = this->type()->get_tree(context->gogo());
-  gcc_assert(val_type_tree != error_mark_node);
+  tree val_type_tree = type_to_tree(this->type()->get_backend(context->gogo()));
+  go_assert(val_type_tree != error_mark_node);
 
   const Struct_field_list* fields = this->type_->fields();
   tree struct_field_tree = TYPE_FIELDS(type_tree);
@@ -12561,16 +13623,30 @@ Struct_field_offset_expression::do_get_tree(Translate_context* context)
        p != fields->end();
        ++p, struct_field_tree = DECL_CHAIN(struct_field_tree))
     {
-      gcc_assert(struct_field_tree != NULL_TREE);
+      go_assert(struct_field_tree != NULL_TREE);
       if (&*p == this->field_)
        break;
     }
-  gcc_assert(&*p == this->field_);
+  go_assert(&*p == this->field_);
 
   return fold_convert_loc(BUILTINS_LOCATION, val_type_tree,
                          byte_position(struct_field_tree));
 }
 
+// Dump ast representation for a struct field offset expression.
+
+void
+Struct_field_offset_expression::do_dump_expression(
+    Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->ostream() <<  "unsafe.Offsetof(";
+  ast_dump_context->dump_type(this->type_);
+  ast_dump_context->ostream() << '.';
+  ast_dump_context->ostream() <<
+    Gogo::message_name(this->field_->field_name());
+  ast_dump_context->ostream() << ")";
+}
+
 // Make an expression for a struct field offset.
 
 Expression*
@@ -12580,6 +13656,64 @@ Expression::make_struct_field_offset(Struct_type* type,
   return new Struct_field_offset_expression(type, field);
 }
 
+// An expression which evaluates to a pointer to the map descriptor of
+// a map type.
+
+class Map_descriptor_expression : public Expression
+{
+ public:
+  Map_descriptor_expression(Map_type* type, source_location location)
+    : Expression(EXPRESSION_MAP_DESCRIPTOR, location),
+      type_(type)
+  { }
+
+ protected:
+  Type*
+  do_type()
+  { return Type::make_pointer_type(Map_type::make_map_descriptor_type()); }
+
+  void
+  do_determine_type(const Type_context*)
+  { }
+
+  Expression*
+  do_copy()
+  { return this; }
+
+  tree
+  do_get_tree(Translate_context* context)
+  {
+    return this->type_->map_descriptor_pointer(context->gogo(),
+                                              this->location());
+  }
+
+  void
+  do_dump_expression(Ast_dump_context*) const;
+ private:
+  // The type for which this is the descriptor.
+  Map_type* type_;
+};
+
+// Dump ast representation for a map descriptor expression.
+
+void
+Map_descriptor_expression::do_dump_expression(
+    Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->ostream() << "map_descriptor(";
+  ast_dump_context->dump_type(this->type_);
+  ast_dump_context->ostream() << ")";
+}
+
+// Make a map descriptor expression.
+
+Expression*
+Expression::make_map_descriptor(Map_type* type, source_location location)
+{
+  return new Map_descriptor_expression(type, location);
+}
+
 // An expression which evaluates to the address of an unnamed label.
 
 class Label_addr_expression : public Expression
@@ -12604,9 +13738,15 @@ class Label_addr_expression : public Expression
   { return new Label_addr_expression(this->label_, this->location()); }
 
   tree
-  do_get_tree(Translate_context*)
-  { return this->label_->get_addr(this->location()); }
+  do_get_tree(Translate_context* context)
+  {
+    return expr_to_tree(this->label_->get_addr(context, this->location()));
+  }
 
+  void
+  do_dump_expression(Ast_dump_context* ast_dump_context) const
+  { ast_dump_context->ostream() << this->label_->name(); }
+  
  private:
   // The label whose address we are taking.
   Label* label_;