OSDN Git Service

compiler: Don't check for hidden fields on struct assignments.
[pf3gnuchains/gcc-fork.git] / gcc / go / gofrontend / expressions.cc
index 433a6d7..7314288 100644 (file)
@@ -36,11 +36,12 @@ extern "C"
 #include "runtime.h"
 #include "backend.h"
 #include "expressions.h"
+#include "ast-dump.h"
 
 // Class Expression.
 
 Expression::Expression(Expression_classification classification,
-                      source_location location)
+                      Location location)
   : classification_(classification), location_(location)
 {
 }
@@ -134,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
@@ -152,12 +153,12 @@ Expression::do_export(Export*) const
   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
@@ -202,7 +203,7 @@ Expression::determine_type_no_context()
 tree
 Expression::convert_for_assignment(Translate_context* context, Type* lhs_type,
                                   Type* rhs_type, tree rhs_tree,
-                                  source_location location)
+                                  Location location)
 {
   if (lhs_type == rhs_type)
     return rhs_tree;
@@ -233,8 +234,7 @@ 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.
       go_assert(TREE_CODE(lhs_type_tree) == RECORD_TYPE);
@@ -283,7 +283,7 @@ Expression::convert_for_assignment(Translate_context* context, Type* lhs_type,
           || INTEGRAL_TYPE_P(lhs_type_tree)
           || SCALAR_FLOAT_TYPE_P(lhs_type_tree)
           || COMPLEX_FLOAT_TYPE_P(lhs_type_tree))
-    return fold_convert_loc(location, lhs_type_tree, rhs_tree);
+    return fold_convert_loc(location.gcc_location(), lhs_type_tree, rhs_tree);
   else if (TREE_CODE(lhs_type_tree) == RECORD_TYPE
           && TREE_CODE(TREE_TYPE(rhs_tree)) == RECORD_TYPE)
     {
@@ -291,8 +291,8 @@ Expression::convert_for_assignment(Translate_context* context, Type* lhs_type,
       // gotten here.
       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);
+      return fold_build1_loc(location.gcc_location(), VIEW_CONVERT_EXPR,
+                             lhs_type_tree, rhs_tree);
     }
   else
     {
@@ -307,7 +307,7 @@ Expression::convert_for_assignment(Translate_context* context, Type* lhs_type,
 tree
 Expression::convert_type_to_interface(Translate_context* context,
                                      Type* lhs_type, Type* rhs_type,
-                                     tree rhs_tree, source_location location)
+                                     tree rhs_tree, Location location)
 {
   Gogo* gogo = context->gogo();
   Interface_type* lhs_interface_type = lhs_type->interface_type();
@@ -356,8 +356,8 @@ Expression::convert_type_to_interface(Translate_context* context,
        method_table =
          rhs_named_type->interface_method_table(gogo, lhs_interface_type,
                                                 is_pointer);
-      first_field_value = fold_convert_loc(location, const_ptr_type_node,
-                                          method_table);
+      first_field_value = fold_convert_loc(location.gcc_location(),
+                                           const_ptr_type_node, method_table);
     }
   if (first_field_value == error_mark_node)
     return error_mark_node;
@@ -371,7 +371,8 @@ Expression::convert_type_to_interface(Translate_context* context,
   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->value = fold_convert_loc(location.gcc_location(), TREE_TYPE(field),
+                                first_field_value);
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
   field = DECL_CHAIN(field);
@@ -392,16 +393,17 @@ Expression::convert_type_to_interface(Translate_context* context,
   tree object_size = TYPE_SIZE_UNIT(TREE_TYPE(rhs_tree));
 
   tree space = gogo->allocate_memory(rhs_type, object_size, location);
-  space = fold_convert_loc(location, build_pointer_type(TREE_TYPE(rhs_tree)),
-                          space);
+  space = fold_convert_loc(location.gcc_location(),
+                           build_pointer_type(TREE_TYPE(rhs_tree)), space);
   space = save_expr(space);
 
-  tree ref = build_fold_indirect_ref_loc(location, space);
+  tree ref = build_fold_indirect_ref_loc(location.gcc_location(), space);
   TREE_THIS_NOTRAP(ref) = 1;
-  tree set = fold_build2_loc(location, MODIFY_EXPR, void_type_node,
-                            ref, rhs_tree);
+  tree set = fold_build2_loc(location.gcc_location(), MODIFY_EXPR,
+                             void_type_node, ref, rhs_tree);
 
-  elt->value = fold_convert_loc(location, TREE_TYPE(field), space);
+  elt->value = fold_convert_loc(location.gcc_location(), TREE_TYPE(field),
+                                space);
 
   return build2(COMPOUND_EXPR, lhs_type_tree, set,
                build_constructor(lhs_type_tree, init));
@@ -414,7 +416,7 @@ Expression::convert_type_to_interface(Translate_context* context,
 tree
 Expression::get_interface_type_descriptor(Translate_context*,
                                          Type* rhs_type, tree rhs_tree,
-                                         source_location location)
+                                         Location location)
 {
   tree rhs_type_tree = TREE_TYPE(rhs_tree);
   go_assert(TREE_CODE(rhs_type_tree) == RECORD_TYPE);
@@ -432,18 +434,20 @@ Expression::get_interface_type_descriptor(Translate_context*,
             == 0);
   go_assert(POINTER_TYPE_P(TREE_TYPE(v)));
   v = save_expr(v);
-  tree v1 = build_fold_indirect_ref_loc(location, v);
+  tree v1 = build_fold_indirect_ref_loc(location.gcc_location(), v);
   go_assert(TREE_CODE(TREE_TYPE(v1)) == RECORD_TYPE);
   tree f = TYPE_FIELDS(TREE_TYPE(v1));
   go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(f)), "__type_descriptor")
             == 0);
   v1 = build3(COMPONENT_REF, TREE_TYPE(f), v1, f, NULL_TREE);
 
-  tree eq = fold_build2_loc(location, EQ_EXPR, boolean_type_node, v,
-                           fold_convert_loc(location, TREE_TYPE(v),
-                                            null_pointer_node));
-  tree n = fold_convert_loc(location, TREE_TYPE(v1), null_pointer_node);
-  return fold_build3_loc(location, COND_EXPR, TREE_TYPE(v1),
+  tree eq = fold_build2_loc(location.gcc_location(), EQ_EXPR, boolean_type_node,
+                            v, fold_convert_loc(location.gcc_location(),
+                                                TREE_TYPE(v),
+                                                null_pointer_node));
+  tree n = fold_convert_loc(location.gcc_location(), TREE_TYPE(v1),
+                            null_pointer_node);
+  return fold_build3_loc(location.gcc_location(), COND_EXPR, TREE_TYPE(v1),
                         eq, n, v1);
 }
 
@@ -454,7 +458,7 @@ tree
 Expression::convert_interface_to_interface(Translate_context* context,
                                           Type *lhs_type, Type *rhs_type,
                                           tree rhs_tree, bool for_type_guard,
-                                          source_location location)
+                                          Location location)
 {
   Gogo* gogo = context->gogo();
   Interface_type* lhs_interface_type = lhs_type->interface_type();
@@ -509,7 +513,8 @@ Expression::convert_interface_to_interface(Translate_context* context,
        return error_mark_node;
       // This will panic if the interface conversion fails.
       TREE_NOTHROW(assert_interface_decl) = 0;
-      elt->value = fold_convert_loc(location, TREE_TYPE(field), call);
+      elt->value = fold_convert_loc(location.gcc_location(), TREE_TYPE(field),
+                                    call);
     }
   else if (lhs_is_empty)
     {
@@ -542,7 +547,8 @@ Expression::convert_interface_to_interface(Translate_context* context,
        return error_mark_node;
       // This will panic if the interface conversion fails.
       TREE_NOTHROW(convert_interface_decl) = 0;
-      elt->value = fold_convert_loc(location, TREE_TYPE(field), call);
+      elt->value = fold_convert_loc(location.gcc_location(), TREE_TYPE(field),
+                                    call);
     }
 
   // The second field is simply the object pointer.
@@ -568,7 +574,7 @@ Expression::convert_interface_to_interface(Translate_context* context,
 tree
 Expression::convert_interface_to_type(Translate_context* context,
                                      Type *lhs_type, Type* rhs_type,
-                                     tree rhs_tree, source_location location)
+                                     tree rhs_tree, Location location)
 {
   Gogo* gogo = context->gogo();
   tree rhs_type_tree = TREE_TYPE(rhs_tree);
@@ -621,12 +627,13 @@ Expression::convert_interface_to_type(Translate_context* context,
   // Otherwise it points to the value.
   if (lhs_type->points_to() == NULL)
     {
-      val = fold_convert_loc(location, build_pointer_type(lhs_type_tree), val);
-      val = build_fold_indirect_ref_loc(location, val);
+      val = fold_convert_loc(location.gcc_location(),
+                             build_pointer_type(lhs_type_tree), val);
+      val = build_fold_indirect_ref_loc(location.gcc_location(), val);
     }
 
   return build2(COMPOUND_EXPR, lhs_type_tree, call,
-               fold_convert_loc(location, lhs_type_tree, val));
+               fold_convert_loc(location.gcc_location(), lhs_type_tree, val));
 }
 
 // Convert an expression to a tree.  This is implemented by the child
@@ -748,14 +755,14 @@ Expression::complex_constant_tree(mpfr_t real, mpfr_t imag, tree type)
 
 tree
 Expression::check_bounds(tree val, tree bound_type, tree sofar,
-                        source_location loc)
+                        Location loc)
 {
   tree val_type = TREE_TYPE(val);
   tree ret = NULL_TREE;
 
   if (!TYPE_UNSIGNED(val_type))
     {
-      ret = fold_build2_loc(loc, LT_EXPR, boolean_type_node, val,
+      ret = fold_build2_loc(loc.gcc_location(), LT_EXPR, boolean_type_node, val,
                            build_int_cst(val_type, 0));
       if (ret == boolean_false_node)
        ret = NULL_TREE;
@@ -770,15 +777,16 @@ Expression::check_bounds(tree val, tree bound_type, tree sofar,
          && !TYPE_UNSIGNED(bound_type)))
     {
       tree max = TYPE_MAX_VALUE(bound_type);
-      tree big = fold_build2_loc(loc, GT_EXPR, boolean_type_node, val,
-                                fold_convert_loc(loc, val_type, max));
+      tree big = fold_build2_loc(loc.gcc_location(), GT_EXPR, boolean_type_node,
+                                 val, fold_convert_loc(loc.gcc_location(),
+                                                       val_type, max));
       if (big == boolean_false_node)
        ;
       else if (ret == NULL_TREE)
        ret = big;
       else
-       ret = fold_build2_loc(loc, TRUTH_OR_EXPR, boolean_type_node,
-                             ret, big);
+       ret = fold_build2_loc(loc.gcc_location(), TRUTH_OR_EXPR,
+                              boolean_type_node, ret, big);
     }
 
   if (ret == NULL_TREE)
@@ -786,16 +794,22 @@ Expression::check_bounds(tree val, tree bound_type, tree sofar,
   else if (sofar == NULL_TREE)
     return ret;
   else
-    return fold_build2_loc(loc, TRUTH_OR_EXPR, boolean_type_node,
+    return fold_build2_loc(loc.gcc_location(), TRUTH_OR_EXPR, boolean_type_node,
                           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
 {
  public:
-  Error_expression(source_location location)
+  Error_expression(Location location)
     : Expression(EXPRESSION_ERROR, location)
   { }
 
@@ -849,10 +863,21 @@ 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)
+Expression::make_error(Location location)
 {
   return new Error_expression(location);
 }
@@ -864,7 +889,7 @@ class
 Type_expression : public Expression
 {
  public:
-  Type_expression(Type* type, source_location location)
+  Type_expression(Type* type, Location location)
     : Expression(EXPRESSION_TYPE, location),
       type_(type)
   { }
@@ -894,13 +919,21 @@ Type_expression : public Expression
   do_get_tree(Translate_context*)
   { 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)
+Expression::make_type(Type* type, Location location)
 {
   return new Type_expression(type, location);
 }
@@ -1012,16 +1045,24 @@ Var_expression::do_get_tree(Translate_context* context)
     go_unreachable();
   if (is_in_heap)
     {
-      ret = build_fold_indirect_ref_loc(this->location(), ret);
+      ret = build_fold_indirect_ref_loc(this->location().gcc_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.
 
 Expression*
-Expression::make_var_reference(Named_object* var, source_location location)
+Expression::make_var_reference(Named_object* var, Location location)
 {
   if (var->is_sink())
     return Expression::make_sink(location);
@@ -1071,16 +1112,25 @@ Temporary_reference_expression::do_get_tree(Translate_context* context)
     {
       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);
+      ret = fold_convert_loc(this->location().gcc_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
+{
+  ast_dump_context->dump_temp_variable_name(this->statement_);
+}
+
 // Make a reference to a temporary variable.
 
 Temporary_reference_expression*
 Expression::make_temporary_reference(Temporary_statement* statement,
-                                    source_location location)
+                                    Location location)
 {
   return new Temporary_reference_expression(statement, location);
 }
@@ -1090,7 +1140,7 @@ Expression::make_temporary_reference(Temporary_statement* statement,
 class Sink_expression : public Expression
 {
  public:
-  Sink_expression(source_location location)
+  Sink_expression(Location location)
     : Expression(EXPRESSION_SINK, location),
       type_(NULL), var_(NULL_TREE)
   { }
@@ -1113,6 +1163,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_;
@@ -1154,10 +1207,18 @@ Sink_expression::do_get_tree(Translate_context* context)
   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*
-Expression::make_sink(source_location location)
+Expression::make_sink(Location location)
 {
   return new Sink_expression(location);
 }
@@ -1232,7 +1293,7 @@ Func_expression::get_tree_without_closure(Gogo* gogo)
   if (fndecl == error_mark_node)
     return error_mark_node;
 
-  return build_fold_addr_expr_loc(this->location(), fndecl);
+  return build_fold_addr_expr_loc(this->location().gcc_location(), fndecl);
 }
 
 // Get the tree for a function expression.  This is used when we take
@@ -1286,11 +1347,25 @@ 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*
 Expression::make_func_reference(Named_object* function, Expression* closure,
-                               source_location location)
+                               Location location)
 {
   return new Func_expression(function, closure, location);
 }
@@ -1310,7 +1385,7 @@ Unknown_expression::name() const
 Expression*
 Unknown_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
 {
-  source_location location = this->location();
+  Location location = this->location();
   Named_object* no = this->named_object_;
   Named_object* real;
   if (!no->is_unknown())
@@ -1354,12 +1429,20 @@ Unknown_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
     }
 }
 
+// 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)
+Expression::make_unknown_reference(Named_object* no, Location location)
 {
-  go_assert(no->resolve()->is_unknown());
   return new Unknown_expression(no, location);
 }
 
@@ -1368,7 +1451,7 @@ Expression::make_unknown_reference(Named_object* no, source_location location)
 class Boolean_expression : public Expression
 {
  public:
-  Boolean_expression(bool val, source_location location)
+  Boolean_expression(bool val, Location location)
     : Expression(EXPRESSION_BOOLEAN, location),
       val_(val), type_(NULL)
   { }
@@ -1399,6 +1482,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_;
@@ -1449,7 +1536,7 @@ Boolean_expression::do_import(Import* imp)
 // Make a boolean expression.
 
 Expression*
-Expression::make_boolean(bool val, source_location location)
+Expression::make_boolean(bool val, Location location)
 {
   return new Boolean_expression(val, location);
 }
@@ -1487,16 +1574,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 == '"')
@@ -1524,6 +1612,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*
@@ -1566,10 +1662,18 @@ 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*
-Expression::make_string(const std::string& val, source_location location)
+Expression::make_string(const std::string& val, Location location)
 {
   return new String_expression(val, location);
 }
@@ -1579,7 +1683,7 @@ Expression::make_string(const std::string& val, source_location location)
 class Integer_expression : public Expression
 {
  public:
-  Integer_expression(const mpz_t* val, Type* type, source_location location)
+  Integer_expression(const mpz_t* val, Type* type, Location location)
     : Expression(EXPRESSION_INTEGER, location),
       type_(type)
   { mpz_init_set(this->val_, *val); }
@@ -1589,11 +1693,15 @@ class Integer_expression : public Expression
 
   // Return whether VAL fits in the type.
   static bool
-  check_constant(mpz_t val, Type*, source_location);
+  check_constant(mpz_t val, Type*, 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
@@ -1623,6 +1731,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_;
@@ -1675,7 +1786,7 @@ Integer_expression::do_determine_type(const Type_context* context)
 
 bool
 Integer_expression::check_constant(mpz_t val, Type* type,
-                                  source_location location)
+                                  Location location)
 {
   if (type == NULL)
     return true;
@@ -1769,7 +1880,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);
@@ -1870,12 +1981,19 @@ 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.
 
 Expression*
 Expression::make_integer(const mpz_t* val, Type* type,
-                        source_location location)
+                        Location location)
 {
   return new Integer_expression(val, type, location);
 }
@@ -1885,7 +2003,7 @@ Expression::make_integer(const mpz_t* val, Type* type,
 class Float_expression : public Expression
 {
  public:
-  Float_expression(const mpfr_t* val, Type* type, source_location location)
+  Float_expression(const mpfr_t* val, Type* type, Location location)
     : Expression(EXPRESSION_FLOAT, location),
       type_(type)
   {
@@ -1898,11 +2016,15 @@ class Float_expression : public Expression
 
   // Return whether VAL fits in the type.
   static bool
-  check_constant(mpfr_t val, Type*, source_location);
+  check_constant(mpfr_t val, Type*, Location);
 
   // 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
@@ -1932,6 +2054,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_;
@@ -1994,7 +2119,7 @@ Float_expression::do_determine_type(const Type_context* context)
 
 bool
 Float_expression::check_constant(mpfr_t val, Type* type,
-                                source_location location)
+                                Location location)
 {
   if (type == NULL)
     return true;
@@ -2082,10 +2207,10 @@ Float_expression::do_get_tree(Translate_context* context)
   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);
@@ -2109,10 +2234,18 @@ 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*
-Expression::make_float(const mpfr_t* val, Type* type, source_location location)
+Expression::make_float(const mpfr_t* val, Type* type, Location location)
 {
   return new Float_expression(val, type, location);
 }
@@ -2123,7 +2256,7 @@ class Complex_expression : public Expression
 {
  public:
   Complex_expression(const mpfr_t* real, const mpfr_t* imag, Type* type,
-                    source_location location)
+                    Location location)
     : Expression(EXPRESSION_COMPLEX, location),
       type_(type)
   {
@@ -2137,12 +2270,17 @@ class Complex_expression : public Expression
 
   // Return whether REAL/IMAG fits in the type.
   static bool
-  check_constant(mpfr_t real, mpfr_t imag, Type*, source_location);
+  check_constant(mpfr_t real, mpfr_t imag, Type*, 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
@@ -2173,6 +2311,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_;
@@ -2240,7 +2381,7 @@ Complex_expression::do_determine_type(const Type_context* context)
 
 bool
 Complex_expression::check_constant(mpfr_t real, mpfr_t imag, Type* type,
-                                  source_location location)
+                                  Location location)
 {
   if (type == NULL)
     return true;
@@ -2319,7 +2460,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))
@@ -2342,11 +2483,21 @@ 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*
 Expression::make_complex(const mpfr_t* real, const mpfr_t* imag, Type* type,
-                        source_location location)
+                        Location location)
 {
   return new Complex_expression(real, imag, type, location);
 }
@@ -2382,7 +2533,7 @@ class Find_named_object : public Traverse
 class Const_expression : public Expression
 {
  public:
-  Const_expression(Named_object* constant, source_location location)
+  Const_expression(Named_object* constant, Location location)
     : Expression(EXPRESSION_CONST_REFERENCE, location),
       constant_(constant), type_(NULL), seen_(false)
   { }
@@ -2443,6 +2594,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_;
@@ -2824,11 +2978,19 @@ Const_expression::do_get_tree(Translate_context* context)
   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*
 Expression::make_const_reference(Named_object* constant,
-                                source_location location)
+                                Location location)
 {
   return new Const_expression(constant, location);
 }
@@ -2874,7 +3036,7 @@ Find_named_object::expression(Expression** pexpr)
 class Nil_expression : public Expression
 {
  public:
-  Nil_expression(source_location location)
+  Nil_expression(Location location)
     : Expression(EXPRESSION_NIL, location)
   { }
 
@@ -2905,6 +3067,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.
@@ -2919,7 +3085,7 @@ Nil_expression::do_import(Import* imp)
 // Make a nil expression.
 
 Expression*
-Expression::make_nil(source_location location)
+Expression::make_nil(Location location)
 {
   return new Nil_expression(location);
 }
@@ -2932,7 +3098,7 @@ Expression::make_nil(source_location location)
 class Iota_expression : public Parser_expression
 {
  public:
-  Iota_expression(source_location location)
+  Iota_expression(Location location)
     : Parser_expression(EXPRESSION_IOTA, location)
   { }
 
@@ -2945,6 +3111,10 @@ class Iota_expression : public Parser_expression
   Expression*
   do_copy()
   { 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
@@ -2953,7 +3123,7 @@ class Iota_expression : public Parser_expression
 Expression*
 Expression::make_iota()
 {
-  static Iota_expression iota_expression(UNKNOWN_LOCATION);
+  static Iota_expression iota_expression(Linemap::unknown_location());
   return &iota_expression;
 }
 
@@ -2963,7 +3133,7 @@ class Type_conversion_expression : public Expression
 {
  public:
   Type_conversion_expression(Type* type, Expression* expr,
-                            source_location location)
+                            Location location)
     : Expression(EXPRESSION_CONVERSION, location),
       type_(type), expr_(expr), may_convert_function_types_(false)
   { }
@@ -3040,6 +3210,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_;
@@ -3069,7 +3242,7 @@ Type_conversion_expression::do_lower(Gogo*, Named_object*,
 {
   Type* type = this->type_;
   Expression* val = this->expr_;
-  source_location location = this->location();
+  Location location = this->location();
 
   if (type->integer_type() != NULL)
     {
@@ -3149,7 +3322,7 @@ Type_conversion_expression::do_lower(Gogo*, Named_object*,
       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");
@@ -3467,7 +3640,8 @@ Type_conversion_expression::do_get_tree(Translate_context* context)
       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(), integer_type_node, len);
+      len = fold_convert_loc(this->location().gcc_location(), integer_type_node,
+                             len);
       if (e->integer_type()->is_unsigned()
          && e->integer_type()->bits() == 8)
        {
@@ -3497,7 +3671,7 @@ Type_conversion_expression::do_get_tree(Translate_context* context)
                                   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();
       go_assert(e->integer_type() != NULL);
@@ -3537,7 +3711,8 @@ Type_conversion_expression::do_get_tree(Translate_context* context)
   else if (this->may_convert_function_types_
           && type->function_type() != NULL
           && expr_type->function_type() != NULL)
-    ret = fold_convert_loc(this->location(), type_tree, expr_tree);
+    ret = fold_convert_loc(this->location().gcc_location(), type_tree,
+                           expr_tree);
   else
     ret = Expression::convert_for_assignment(context, type, expr_type,
                                             expr_tree, this->location());
@@ -3570,10 +3745,22 @@ 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*
-Expression::make_cast(Type* type, Expression* val, source_location location)
+Expression::make_cast(Type* type, Expression* val, Location location)
 {
   if (type->is_error_type() || val->is_error_expression())
     return Expression::make_error(location);
@@ -3586,7 +3773,7 @@ class Unsafe_type_conversion_expression : public Expression
 {
  public:
   Unsafe_type_conversion_expression(Type* type, Expression* expr,
-                                   source_location location)
+                                   Location location)
     : Expression(EXPRESSION_UNSAFE_CONVERSION, location),
       type_(type), expr_(expr)
   { }
@@ -3614,6 +3801,9 @@ class Unsafe_type_conversion_expression : public Expression
   tree
   do_get_tree(Translate_context*);
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+
  private:
   // The type to convert to.
   Type* type_;
@@ -3647,12 +3837,12 @@ Unsafe_type_conversion_expression::do_get_tree(Translate_context* context)
   if (type_tree == error_mark_node || expr_tree == error_mark_node)
     return error_mark_node;
 
-  source_location loc = this->location();
+  Location loc = this->location();
 
   bool use_view_convert = false;
-  if (t->is_open_array_type())
+  if (t->is_slice_type())
     {
-      go_assert(et->is_open_array_type());
+      go_assert(et->is_slice_type());
       use_view_convert = true;
     }
   else if (t->map_type() != NULL)
@@ -3663,7 +3853,7 @@ Unsafe_type_conversion_expression::do_get_tree(Translate_context* context)
     go_assert((et->points_to() != NULL
                && et->points_to()->channel_type() != NULL)
               || et->is_nil_type());
-  else if (t->is_unsafe_pointer_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);
@@ -3693,16 +3883,29 @@ Unsafe_type_conversion_expression::do_get_tree(Translate_context* context)
     go_unreachable();
 
   if (use_view_convert)
-    return fold_build1_loc(loc, VIEW_CONVERT_EXPR, type_tree, expr_tree);
+    return fold_build1_loc(loc.gcc_location(), VIEW_CONVERT_EXPR, type_tree,
+                           expr_tree);
   else
-    return fold_convert_loc(loc, type_tree, expr_tree);
+    return fold_convert_loc(loc.gcc_location(), 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)
+                            Location location)
 {
   return new Unsafe_type_conversion_expression(type, expr, location);
 }
@@ -3712,9 +3915,9 @@ Expression::make_unsafe_cast(Type* type, Expression* expr,
 class Unary_expression : public Expression
 {
  public:
-  Unary_expression(Operator op, Expression* expr, source_location location)
+  Unary_expression(Operator op, Expression* expr, Location location)
     : Expression(EXPRESSION_UNARY, location),
-      op_(op), escapes_(true), expr_(expr)
+      op_(op), escapes_(true), create_temp_(false), expr_(expr)
   { }
 
   // Return the operator.
@@ -3735,11 +3938,20 @@ class Unary_expression : public Expression
     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
   eval_integer(Operator op, Type* utype, mpz_t uval, mpz_t val,
-              source_location);
+              Location);
 
   // Apply unary opcode OP to UVAL, setting VAL.  Return true if this
   // could be done, false if not.
@@ -3792,6 +4004,10 @@ class Unary_expression : public Expression
   }
 
   bool
+  do_must_eval_subexpressions_in_order(int*) const
+  { return this->op_ == OPERATOR_MULT; }
+
+  bool
   do_is_addressable() const
   { return this->op_ == OPERATOR_MULT; }
 
@@ -3801,12 +4017,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_;
 };
@@ -3818,7 +4040,7 @@ class Unary_expression : public Expression
 Expression*
 Unary_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
 {
-  source_location loc = this->location();
+  Location loc = this->location();
   Operator op = this->op_;
   Expression* expr = this->expr_;
 
@@ -3959,7 +4181,7 @@ Unary_expression::do_is_constant() const
 
 bool
 Unary_expression::eval_integer(Operator op, Type* utype, mpz_t uval, mpz_t val,
-                              source_location location)
+                              Location location)
 {
   switch (op)
     {
@@ -4231,7 +4453,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;
@@ -4256,7 +4481,7 @@ Unary_expression::do_get_tree(Translate_context* context)
   if (expr == error_mark_node)
     return error_mark_node;
 
-  source_location loc = this->location();
+  Location loc = this->location();
   switch (this->op_)
     {
     case OPERATOR_PLUS:
@@ -4268,7 +4493,7 @@ Unary_expression::do_get_tree(Translate_context* context)
        tree compute_type = excess_precision_type(type);
        if (compute_type != NULL_TREE)
          expr = ::convert(compute_type, expr);
-       tree ret = fold_build1_loc(loc, NEGATE_EXPR,
+       tree ret = fold_build1_loc(loc.gcc_location(), NEGATE_EXPR,
                                   (compute_type != NULL_TREE
                                    ? compute_type
                                    : type),
@@ -4280,26 +4505,31 @@ Unary_expression::do_get_tree(Translate_context* context)
 
     case OPERATOR_NOT:
       if (TREE_CODE(TREE_TYPE(expr)) == BOOLEAN_TYPE)
-       return fold_build1_loc(loc, TRUTH_NOT_EXPR, TREE_TYPE(expr), expr);
+       return fold_build1_loc(loc.gcc_location(), TRUTH_NOT_EXPR,
+                               TREE_TYPE(expr), expr);
       else
-       return fold_build2_loc(loc, NE_EXPR, boolean_type_node, expr,
-                              build_int_cst(TREE_TYPE(expr), 0));
+       return fold_build2_loc(loc.gcc_location(), NE_EXPR, boolean_type_node,
+                               expr, build_int_cst(TREE_TYPE(expr), 0));
 
     case OPERATOR_XOR:
-      return fold_build1_loc(loc, BIT_NOT_EXPR, TREE_TYPE(expr), expr);
+      return fold_build1_loc(loc.gcc_location(), 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.
-      go_assert(TREE_CODE(expr) != CONSTRUCTOR || TREE_CONSTANT(expr));
-      go_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))
        {
-         tree decl = build_decl(this->location(), VAR_DECL,
+         tree decl = build_decl(this->location().gcc_location(), VAR_DECL,
                                 create_tmp_var_name("C"), TREE_TYPE(expr));
          DECL_EXTERNAL(decl) = 0;
          TREE_PUBLIC(decl) = 0;
@@ -4313,7 +4543,24 @@ Unary_expression::do_get_tree(Translate_context* context)
          expr = decl;
        }
 
-      return build_fold_addr_expr_loc(loc, expr);
+      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.gcc_location(), COMPOUND_EXPR,
+                           build_pointer_type(TREE_TYPE(expr)),
+                           build1_loc(loc.gcc_location(), DECL_EXPR,
+                                       void_type_node, tmp),
+                           build_fold_addr_expr_loc(loc.gcc_location(), tmp));
+       }
+
+      return build_fold_addr_expr_loc(loc.gcc_location(), expr);
 
     case OPERATOR_MULT:
       {
@@ -4328,15 +4575,18 @@ Unary_expression::do_get_tree(Translate_context* context)
          {
            if (!DECL_P(expr))
              expr = save_expr(expr);
-           tree compare = fold_build2_loc(loc, EQ_EXPR, boolean_type_node,
+           tree compare = fold_build2_loc(loc.gcc_location(), EQ_EXPR,
+                                           boolean_type_node,
                                           expr,
                                           fold_convert(TREE_TYPE(expr),
                                                        null_pointer_node));
            tree crash = Gogo::runtime_error(RUNTIME_ERROR_NIL_DEREFERENCE,
                                             loc);
-           expr = fold_build2_loc(loc, COMPOUND_EXPR, TREE_TYPE(expr),
-                                  build3(COND_EXPR, void_type_node,
-                                         compare, crash, NULL_TREE),
+           expr = fold_build2_loc(loc.gcc_location(), COMPOUND_EXPR,
+                                   TREE_TYPE(expr), build3(COND_EXPR,
+                                                           void_type_node,
+                                                           compare, crash,
+                                                           NULL_TREE),
                                   expr);
          }
 
@@ -4346,10 +4596,11 @@ Unary_expression::do_get_tree(Translate_context* context)
          {
            Type* pt = this->expr_->type()->points_to();
            tree ind = type_to_tree(pt->get_backend(context->gogo()));
-           expr = fold_convert_loc(loc, build_pointer_type(ind), expr);
+           expr = fold_convert_loc(loc.gcc_location(),
+                                    build_pointer_type(ind), expr);
          }
 
-       return build_fold_indirect_ref_loc(loc, expr);
+       return build_fold_indirect_ref_loc(loc.gcc_location(), expr);
       }
 
     default:
@@ -4412,10 +4663,21 @@ Unary_expression::do_import(Import* 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*
-Expression::make_unary(Operator op, Expression* expr, source_location location)
+Expression::make_unary(Operator op, Expression* expr, Location location)
 {
   return new Unary_expression(op, expr, location);
 }
@@ -4563,7 +4825,7 @@ Binary_expression::compare_complex(Operator op, Type* type,
 bool
 Binary_expression::eval_integer(Operator op, Type* left_type, mpz_t left_val,
                                Type* right_type, mpz_t right_val,
-                               source_location location, mpz_t val)
+                               Location location, mpz_t val)
 {
   bool is_shift_op = false;
   switch (op)
@@ -4703,7 +4965,7 @@ Binary_expression::eval_integer(Operator op, Type* left_type, mpz_t left_val,
 bool
 Binary_expression::eval_float(Operator op, Type* left_type, mpfr_t left_val,
                              Type* right_type, mpfr_t right_val,
-                             mpfr_t val, source_location location)
+                             mpfr_t val, Location location)
 {
   switch (op)
     {
@@ -4786,7 +5048,7 @@ Binary_expression::eval_complex(Operator op, Type* left_type,
                                Type *right_type,
                                mpfr_t right_real, mpfr_t right_imag,
                                mpfr_t real, mpfr_t imag,
-                               source_location location)
+                               Location location)
 {
   switch (op)
     {
@@ -5147,7 +5409,7 @@ Binary_expression::eval_complex(Operator op, Type* left_type,
 Expression*
 Binary_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
 {
-  source_location location = this->location();
+  Location location = this->location();
   Operator op = this->op_;
   Expression* left = this->left_;
   Expression* right = this->right_;
@@ -5430,6 +5692,50 @@ Binary_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
        return Expression::make_string(left_string + right_string, location);
     }
 
+  // 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;
 }
 
@@ -5591,7 +5897,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.
@@ -5698,14 +6004,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;
@@ -5738,10 +6038,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;
     }
@@ -5755,7 +6066,7 @@ Binary_expression::do_determine_type(const Type_context* context)
 
 bool
 Binary_expression::check_operator_type(Operator op, Type* type,
-                                      source_location location)
+                                      Location location)
 {
   switch (op)
     {
@@ -5929,7 +6240,7 @@ Binary_expression::do_check_types(Gogo*)
                {
                  this->report_error(_("negative shift count"));
                  mpz_set_ui(val, 0);
-                 source_location rloc = this->right_->location();
+                 Location rloc = this->right_->location();
                  this->right_ = Expression::make_integer(&val, right_type,
                                                          rloc);
                }
@@ -6061,12 +6372,13 @@ Binary_expression::do_get_tree(Translate_context* context)
          if (eval_saved == NULL_TREE)
            eval_saved = right;
          else
-           eval_saved = fold_build2_loc(this->location(), COMPOUND_EXPR,
+           eval_saved = fold_build2_loc(this->location().gcc_location(),
+                                         COMPOUND_EXPR,
                                         void_type_node, eval_saved, right);
        }
     }
 
-  tree ret = fold_build2_loc(this->location(),
+  tree ret = fold_build2_loc(this->location().gcc_location(),
                             code,
                             compute_type != NULL_TREE ? compute_type : type,
                             left, right);
@@ -6085,35 +6397,38 @@ Binary_expression::do_get_tree(Translate_context* context)
       tree compare = fold_build2(LT_EXPR, boolean_type_node, right,
                                 build_int_cst_type(TREE_TYPE(right), bits));
 
-      tree overflow_result = fold_convert_loc(this->location(),
+      tree overflow_result = fold_convert_loc(this->location().gcc_location(),
                                              TREE_TYPE(left),
                                              integer_zero_node);
       if (this->op_ == OPERATOR_RSHIFT
          && !this->left_->type()->integer_type()->is_unsigned())
        {
-         tree neg = fold_build2_loc(this->location(), LT_EXPR,
-                                    boolean_type_node, left,
-                                    fold_convert_loc(this->location(),
-                                                     TREE_TYPE(left),
-                                                     integer_zero_node));
-         tree neg_one = fold_build2_loc(this->location(),
-                                        MINUS_EXPR, TREE_TYPE(left),
-                                        fold_convert_loc(this->location(),
-                                                         TREE_TYPE(left),
-                                                         integer_zero_node),
-                                        fold_convert_loc(this->location(),
-                                                         TREE_TYPE(left),
-                                                         integer_one_node));
-         overflow_result = fold_build3_loc(this->location(), COND_EXPR,
-                                           TREE_TYPE(left), neg, neg_one,
-                                           overflow_result);
-       }
-
-      ret = fold_build3_loc(this->location(), COND_EXPR, TREE_TYPE(left),
-                           compare, ret, overflow_result);
+         tree neg =
+            fold_build2_loc(this->location().gcc_location(), LT_EXPR,
+                            boolean_type_node, left,
+                            fold_convert_loc(this->location().gcc_location(),
+                                             TREE_TYPE(left),
+                                             integer_zero_node));
+         tree neg_one =
+            fold_build2_loc(this->location().gcc_location(),
+                            MINUS_EXPR, TREE_TYPE(left),
+                            fold_convert_loc(this->location().gcc_location(),
+                                             TREE_TYPE(left),
+                                             integer_zero_node),
+                            fold_convert_loc(this->location().gcc_location(),
+                                             TREE_TYPE(left),
+                                             integer_one_node));
+         overflow_result =
+            fold_build3_loc(this->location().gcc_location(), COND_EXPR,
+                            TREE_TYPE(left), neg, neg_one,
+                            overflow_result);
+       }
+
+      ret = fold_build3_loc(this->location().gcc_location(), COND_EXPR,
+                            TREE_TYPE(left), compare, ret, overflow_result);
 
       if (eval_saved != NULL_TREE)
-       ret = fold_build2_loc(this->location(), COMPOUND_EXPR,
+       ret = fold_build2_loc(this->location().gcc_location(), COMPOUND_EXPR,
                              TREE_TYPE(ret), eval_saved, ret);
     }
 
@@ -6311,11 +6626,25 @@ 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*
 Expression::make_binary(Operator op, Expression* left, Expression* right,
-                       source_location location)
+                       Location location)
 {
   return new Binary_expression(op, left, right, location);
 }
@@ -6326,7 +6655,7 @@ tree
 Expression::comparison_tree(Translate_context* context, Operator op,
                            Type* left_type, tree left_tree,
                            Type* right_type, tree right_tree,
-                           source_location location)
+                           Location location)
 {
   enum tree_code code;
   switch (op)
@@ -6395,7 +6724,7 @@ Expression::comparison_tree(Translate_context* context, Operator op,
       else if (TREE_ADDRESSABLE(TREE_TYPE(right_tree)) || DECL_P(right_tree))
        {
          make_tmp = NULL_TREE;
-         arg = build_fold_addr_expr_loc(location, right_tree);
+         arg = build_fold_addr_expr_loc(location.gcc_location(), right_tree);
          if (DECL_P(right_tree))
            TREE_ADDRESSABLE(right_tree) = 1;
        }
@@ -6407,10 +6736,10 @@ Expression::comparison_tree(Translate_context* context, Operator op,
          DECL_INITIAL(tmp) = right_tree;
          TREE_ADDRESSABLE(tmp) = 1;
          make_tmp = build1(DECL_EXPR, void_type_node, tmp);
-         SET_EXPR_LOCATION(make_tmp, location);
-         arg = build_fold_addr_expr_loc(location, tmp);
+         SET_EXPR_LOCATION(make_tmp, location.gcc_location());
+         arg = build_fold_addr_expr_loc(location.gcc_location(), tmp);
        }
-      arg = fold_convert_loc(location, ptr_type_node, arg);
+      arg = fold_convert_loc(location.gcc_location(), ptr_type_node, arg);
 
       tree descriptor = right_type->type_descriptor_pointer(context->gogo(),
                                                            location);
@@ -6565,7 +6894,7 @@ Expression::comparison_tree(Translate_context* context, Operator op,
 
   tree ret = fold_build2(code, boolean_type_node, left_tree, right_tree);
   if (CAN_HAVE_LOCATION_P(ret))
-    SET_EXPR_LOCATION(ret, location);
+    SET_EXPR_LOCATION(ret, location.gcc_location());
   return ret;
 }
 
@@ -6576,9 +6905,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
@@ -6589,7 +6916,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.
@@ -6597,9 +6929,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
@@ -6614,14 +6944,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());
@@ -6643,11 +6971,30 @@ 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,
-                             source_location location)
+Expression::make_bound_method(Expression* expr, Named_object* method,
+                             Location location)
 {
   return new Bound_method_expression(expr, method, location);
 }
@@ -6659,7 +7006,7 @@ class Builtin_call_expression : public Call_expression
 {
  public:
   Builtin_call_expression(Gogo* gogo, Expression* fn, Expression_list* args,
-                         bool is_varargs, source_location location);
+                         bool is_varargs, Location location);
 
  protected:
   // This overrides Call_expression::do_lower.
@@ -6678,6 +7025,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();
 
@@ -6720,6 +7070,7 @@ class Builtin_call_expression : public Call_expression
       BUILTIN_CLOSE,
       BUILTIN_COMPLEX,
       BUILTIN_COPY,
+      BUILTIN_DELETE,
       BUILTIN_IMAG,
       BUILTIN_LEN,
       BUILTIN_MAKE,
@@ -6768,7 +7119,7 @@ Builtin_call_expression::Builtin_call_expression(Gogo* gogo,
                                                 Expression* fn,
                                                 Expression_list* args,
                                                 bool is_varargs,
-                                                source_location location)
+                                                Location location)
   : Call_expression(fn, args, is_varargs, location),
     gogo_(gogo), code_(BUILTIN_INVALID), seen_(false)
 {
@@ -6785,6 +7136,8 @@ Builtin_call_expression::Builtin_call_expression(Gogo* gogo,
     this->code_ = BUILTIN_COMPLEX;
   else if (name == "copy")
     this->code_ = BUILTIN_COPY;
+  else if (name == "delete")
+    this->code_ = BUILTIN_DELETE;
   else if (name == "imag")
     this->code_ = BUILTIN_IMAG;
   else if (name == "len")
@@ -6878,34 +7231,15 @@ Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function,
   if (this->classification() == EXPRESSION_ERROR)
     return this;
 
+  Location loc = this->location();
+
   if (this->is_varargs() && this->code_ != BUILTIN_APPEND)
     {
       this->report_error(_("invalid use of %<...%> with builtin function"));
-      return Expression::make_error(this->location());
+      return Expression::make_error(loc);
     }
 
-  if (this->code_ == BUILTIN_NEW)
-    {
-      const Expression_list* args = this->args();
-      if (args == NULL || args->size() < 1)
-       this->report_error(_("not enough arguments"));
-      else if (args->size() > 1)
-       this->report_error(_("too many arguments"));
-      else
-       {
-         Expression* arg = args->front();
-         if (!arg->is_type_expression())
-           {
-             error_at(arg->location(), "expected type");
-             this->set_is_error();
-           }
-         else
-           return Expression::make_allocation(arg->type(), this->location());
-       }
-    }
-  else if (this->code_ == BUILTIN_MAKE)
-    return this->lower_make();
-  else if (this->is_constant())
+  if (this->is_constant())
     {
       // We can only lower len and cap if there are no function calls
       // in the arguments.  Otherwise we have to make the call.
@@ -6926,8 +7260,7 @@ Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function,
       Type* type;
       if (this->integer_constant_value(true, ival, &type))
        {
-         Expression* ret = Expression::make_integer(&ival, type,
-                                                    this->location());
+         Expression* ret = Expression::make_integer(&ival, type, loc);
          mpz_clear(ival);
          return ret;
        }
@@ -6937,8 +7270,7 @@ Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function,
       mpfr_init(rval);
       if (this->float_constant_value(rval, &type))
        {
-         Expression* ret = Expression::make_float(&rval, type,
-                                                  this->location());
+         Expression* ret = Expression::make_float(&rval, type, loc);
          mpfr_clear(rval);
          return ret;
        }
@@ -6947,8 +7279,7 @@ Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function,
       mpfr_init(imag);
       if (this->complex_constant_value(rval, imag, &type))
        {
-         Expression* ret = Expression::make_complex(&rval, &imag, type,
-                                                    this->location());
+         Expression* ret = Expression::make_complex(&rval, &imag, type, loc);
          mpfr_clear(rval);
          mpfr_clear(imag);
          return ret;
@@ -6956,34 +7287,100 @@ Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function,
       mpfr_clear(rval);
       mpfr_clear(imag);
     }
-  else if (this->code_ == BUILTIN_RECOVER)
+
+  switch (this->code_)
     {
+    default:
+      break;
+
+    case BUILTIN_NEW:
+      {
+       const Expression_list* args = this->args();
+       if (args == NULL || args->size() < 1)
+         this->report_error(_("not enough arguments"));
+       else if (args->size() > 1)
+         this->report_error(_("too many arguments"));
+       else
+         {
+           Expression* arg = args->front();
+           if (!arg->is_type_expression())
+             {
+               error_at(arg->location(), "expected type");
+               this->set_is_error();
+             }
+           else
+             return Expression::make_allocation(arg->type(), loc);
+         }
+      }
+      break;
+
+    case BUILTIN_MAKE:
+      return this->lower_make();
+
+    case BUILTIN_RECOVER:
       if (function != NULL)
        function->func_value()->set_calls_recover();
       else
        {
          // Calling recover outside of a function always returns the
          // nil empty interface.
-         Type* eface = Type::make_interface_type(NULL, this->location());
-         return Expression::make_cast(eface,
-                                      Expression::make_nil(this->location()),
-                                      this->location());
+         Type* eface = Type::make_interface_type(NULL, loc);
+         return Expression::make_cast(eface, Expression::make_nil(loc), loc);
        }
-    }
-  else if (this->code_ == BUILTIN_APPEND)
-    {
-      // Lower the varargs.
-      const Expression_list* args = this->args();
-      if (args == NULL || args->empty())
-       return this;
-      Type* slice_type = args->front()->type();
-      if (!slice_type->is_open_array_type())
-       {
-         error_at(args->front()->location(), "argument 1 must be a slice");
-         this->set_is_error();
+      break;
+
+    case BUILTIN_APPEND:
+      {
+       // Lower the varargs.
+       const Expression_list* args = this->args();
+       if (args == NULL || args->empty())
          return this;
-       }
-      return this->lower_varargs(gogo, function, inserter, slice_type, 2);
+       Type* slice_type = args->front()->type();
+       if (!slice_type->is_slice_type())
+         {
+           error_at(args->front()->location(), "argument 1 must be a slice");
+           this->set_is_error();
+           return this;
+         }
+       this->lower_varargs(gogo, function, inserter, slice_type, 2);
+      }
+      break;
+
+    case BUILTIN_DELETE:
+      {
+       // Lower to a runtime function call.
+       const Expression_list* args = this->args();
+       if (args == NULL || args->size() < 2)
+         this->report_error(_("not enough arguments"));
+       else if (args->size() > 2)
+         this->report_error(_("too many arguments"));
+       else if (args->front()->type()->map_type() == NULL)
+         this->report_error(_("argument 1 must be a map"));
+       else
+         {
+           // Since this function returns no value it must appear in
+           // a statement by itself, so we don't have to worry about
+           // order of evaluation of values around it.  Evaluate the
+           // map first to get order of evaluation right.
+           Map_type* mt = args->front()->type()->map_type();
+           Temporary_statement* map_temp =
+             Statement::make_temporary(mt, args->front(), loc);
+           inserter->insert(map_temp);
+
+           Temporary_statement* key_temp =
+             Statement::make_temporary(mt->key_type(), args->back(), loc);
+           inserter->insert(key_temp);
+
+           Expression* e1 = Expression::make_temporary_reference(map_temp,
+                                                                 loc);
+           Expression* e2 = Expression::make_temporary_reference(key_temp,
+                                                                 loc);
+           e2 = Expression::make_unary(OPERATOR_AND, e2, loc);
+           return Runtime::make_call(Runtime::MAPDELETE, this->location(),
+                                     2, e1, e2);
+         }
+      }
+      break;
     }
 
   return this;
@@ -6994,7 +7391,7 @@ Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function,
 Expression*
 Builtin_call_expression::lower_make()
 {
-  source_location loc = this->location();
+  Location loc = this->location();
 
   const Expression_list* args = this->args();
   if (args == NULL || args->size() < 1)
@@ -7017,7 +7414,7 @@ Builtin_call_expression::lower_make()
   bool is_slice = false;
   bool is_map = false;
   bool is_chan = false;
-  if (type->is_open_array_type())
+  if (type->is_slice_type())
     is_slice = true;
   else if (type->map_type() != NULL)
     is_map = true;
@@ -7073,7 +7470,7 @@ Builtin_call_expression::lower_make()
       return Expression::make_error(this->location());
     }
 
-  source_location type_loc = first_arg->location();
+  Location type_loc = first_arg->location();
   Expression* type_arg;
   if (is_slice || is_chan)
     type_arg = Expression::make_type_descriptor(type, type_loc);
@@ -7229,7 +7626,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
@@ -7308,7 +7705,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
@@ -7487,10 +7884,13 @@ Builtin_call_expression::do_complex_constant_value(mpfr_t real, mpfr_t imag,
   return false;
 }
 
-// Return the type.
+// 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.
 
-Type*
-Builtin_call_expression::do_type()
+void
+Builtin_call_expression::do_discarding_value()
 {
   switch (this->code_)
     {
@@ -7498,11 +7898,47 @@ Builtin_call_expression::do_type()
     default:
       go_unreachable();
 
-    case BUILTIN_NEW:
+    case BUILTIN_APPEND:
+    case BUILTIN_CAP:
+    case BUILTIN_COMPLEX:
+    case BUILTIN_IMAG:
+    case BUILTIN_LEN:
     case BUILTIN_MAKE:
-      {
-       const Expression_list* args = this->args();
-       if (args == NULL || args->empty())
+    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_DELETE:
+    case BUILTIN_PANIC:
+    case BUILTIN_PRINT:
+    case BUILTIN_PRINTLN:
+    case BUILTIN_RECOVER:
+      break;
+    }
+}
+
+// Return the type.
+
+Type*
+Builtin_call_expression::do_type()
+{
+  switch (this->code_)
+    {
+    case BUILTIN_INVALID:
+    default:
+      go_unreachable();
+
+    case BUILTIN_NEW:
+    case BUILTIN_MAKE:
+      {
+       const Expression_list* args = this->args();
+       if (args == NULL || args->empty())
          return Type::make_error_type();
        return Type::make_pointer_type(args->front()->type());
       }
@@ -7516,13 +7952,14 @@ Builtin_call_expression::do_type()
       return Type::lookup_integer_type("int");
 
     case BUILTIN_CLOSE:
+    case BUILTIN_DELETE:
     case BUILTIN_PANIC:
     case BUILTIN_PRINT:
     case BUILTIN_PRINTLN:
       return Type::make_void_type();
 
     case BUILTIN_RECOVER:
-      return Type::make_interface_type(NULL, BUILTINS_LOCATION);
+      return Type::make_interface_type(NULL, Linemap::predeclared_location());
 
     case BUILTIN_APPEND:
       {
@@ -7717,7 +8154,7 @@ 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)
              {
@@ -7772,7 +8209,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 "
@@ -7787,6 +8224,8 @@ Builtin_call_expression::do_check_types(Gogo*)
        {
          if (this->one_arg()->type()->channel_type() == NULL)
            this->report_error(_("argument must be channel"));
+         else if (!this->one_arg()->type()->channel_type()->may_send())
+           this->report_error(_("cannot close receive-only channel"));
        }
       break;
 
@@ -7829,7 +8268,7 @@ Builtin_call_expression::do_check_types(Gogo*)
          break;
 
        Type* e1;
-       if (arg1_type->is_open_array_type())
+       if (arg1_type->is_slice_type())
          e1 = arg1_type->array_type()->element_type();
        else
          {
@@ -7838,7 +8277,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");
@@ -7866,6 +8305,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))
@@ -7924,7 +8374,7 @@ tree
 Builtin_call_expression::do_get_tree(Translate_context* context)
 {
   Gogo* gogo = context->gogo();
-  source_location location = this->location();
+  Location location = this->location();
   switch (this->code_)
     {
     case BUILTIN_INVALID:
@@ -7958,7 +8408,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
          {
            arg_type = arg_type->points_to();
            go_assert(arg_type->array_type() != NULL
-                      && !arg_type->is_open_array_type());
+                      && !arg_type->is_slice_type());
            go_assert(POINTER_TYPE_P(TREE_TYPE(arg_tree)));
            arg_tree = build_fold_indirect_ref(arg_tree);
          }
@@ -8095,7 +8545,8 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
                    fnname = "__go_print_uint64";
                    Type* itype = Type::lookup_integer_type("uint64");
                    Btype* bitype = itype->get_backend(gogo);
-                   arg = fold_convert_loc(location, type_to_tree(bitype), arg);
+                   arg = fold_convert_loc(location.gcc_location(),
+                                           type_to_tree(bitype), arg);
                  }
                else if (type->integer_type() != NULL)
                  {
@@ -8104,22 +8555,24 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
                    fnname = "__go_print_int64";
                    Type* itype = Type::lookup_integer_type("int64");
                    Btype* bitype = itype->get_backend(gogo);
-                   arg = fold_convert_loc(location, type_to_tree(bitype), arg);
+                   arg = fold_convert_loc(location.gcc_location(),
+                                           type_to_tree(bitype), arg);
                  }
                else if (type->float_type() != NULL)
                  {
                    static tree print_double_fndecl;
                    pfndecl = &print_double_fndecl;
                    fnname = "__go_print_double";
-                   arg = fold_convert_loc(location, double_type_node, arg);
+                   arg = fold_convert_loc(location.gcc_location(),
+                                           double_type_node, arg);
                  }
                else if (type->complex_type() != NULL)
                  {
                    static tree print_complex_fndecl;
                    pfndecl = &print_complex_fndecl;
                    fnname = "__go_print_complex";
-                   arg = fold_convert_loc(location, complex_double_type_node,
-                                          arg);
+                   arg = fold_convert_loc(location.gcc_location(),
+                                           complex_double_type_node, arg);
                  }
                else if (type->is_boolean_type())
                  {
@@ -8135,7 +8588,8 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
                    static tree print_pointer_fndecl;
                    pfndecl = &print_pointer_fndecl;
                    fnname = "__go_print_pointer";
-                   arg = fold_convert_loc(location, ptr_type_node, arg);
+                   arg = fold_convert_loc(location.gcc_location(),
+                                           ptr_type_node, arg);
                  }
                else if (type->interface_type() != NULL)
                  {
@@ -8152,7 +8606,7 @@ 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;
@@ -8198,7 +8652,8 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
        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);
+       Type *empty =
+         Type::make_interface_type(NULL, Linemap::predeclared_location());
        arg_tree = Expression::convert_for_assignment(context, empty,
                                                      arg->type(),
                                                      arg_tree, location);
@@ -8230,7 +8685,8 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
        if (arg_tree == error_mark_node)
          return error_mark_node;
 
-       Type *empty = Type::make_interface_type(NULL, BUILTINS_LOCATION);
+       Type *empty =
+         Type::make_interface_type(NULL, Linemap::predeclared_location());
        tree empty_tree = type_to_tree(empty->get_backend(context->gogo()));
 
        Type* nil_type = Type::make_nil_type();
@@ -8266,8 +8722,8 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
          }
        if (call == error_mark_node)
          return error_mark_node;
-       return fold_build3_loc(location, COND_EXPR, empty_tree, arg_tree,
-                              call, empty_nil_tree);
+       return fold_build3_loc(location.gcc_location(), COND_EXPR, empty_tree,
+                               arg_tree, call, empty_nil_tree);
       }
 
     case BUILTIN_CLOSE:
@@ -8331,7 +8787,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);
@@ -8349,9 +8805,10 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
 
        arg1_len = save_expr(arg1_len);
        arg2_len = save_expr(arg2_len);
-       tree len = fold_build3_loc(location, COND_EXPR, TREE_TYPE(arg1_len),
-                                  fold_build2_loc(location, LT_EXPR,
-                                                  boolean_type_node,
+       tree len = fold_build3_loc(location.gcc_location(), COND_EXPR,
+                                   TREE_TYPE(arg1_len),
+                                  fold_build2_loc(location.gcc_location(),
+                                                   LT_EXPR, boolean_type_node,
                                                   arg1_len, arg2_len),
                                   arg1_len, arg2_len);
        len = save_expr(len);
@@ -8362,15 +8819,18 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
        if (element_type_tree == error_mark_node)
          return error_mark_node;
        tree element_size = TYPE_SIZE_UNIT(element_type_tree);
-       tree bytecount = fold_convert_loc(location, TREE_TYPE(element_size),
-                                         len);
-       bytecount = fold_build2_loc(location, MULT_EXPR,
+       tree bytecount = fold_convert_loc(location.gcc_location(),
+                                          TREE_TYPE(element_size), len);
+       bytecount = fold_build2_loc(location.gcc_location(), MULT_EXPR,
                                    TREE_TYPE(element_size),
                                    bytecount, element_size);
-       bytecount = fold_convert_loc(location, size_type_node, bytecount);
+       bytecount = fold_convert_loc(location.gcc_location(), size_type_node,
+                                     bytecount);
 
-       arg1_val = fold_convert_loc(location, ptr_type_node, arg1_val);
-       arg2_val = fold_convert_loc(location, ptr_type_node, arg2_val);
+       arg1_val = fold_convert_loc(location.gcc_location(), ptr_type_node,
+                                    arg1_val);
+       arg2_val = fold_convert_loc(location.gcc_location(), ptr_type_node,
+                                    arg2_val);
 
        static tree copy_fndecl;
        tree call = Gogo::call_builtin(&copy_fndecl,
@@ -8387,8 +8847,8 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
        if (call == error_mark_node)
          return error_mark_node;
 
-       return fold_build2_loc(location, COMPOUND_EXPR, TREE_TYPE(len),
-                              call, len);
+       return fold_build2_loc(location.gcc_location(), COMPOUND_EXPR,
+                               TREE_TYPE(len), call, len);
       }
 
     case BUILTIN_APPEND:
@@ -8404,30 +8864,52 @@ 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);
-       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);
+           arg2_tree = save_expr(arg2_tree);
 
-       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);
-       element_size = fold_convert_loc(location, size_type_node,
+            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_val = fold_convert_loc(location.gcc_location(), ptr_type_node,
+                                    arg2_val);
+       arg2_len = fold_convert_loc(location.gcc_location(), size_type_node,
+                                    arg2_len);
+       element_size = fold_convert_loc(location.gcc_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;
@@ -8457,11 +8939,11 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
          return error_mark_node;
        go_assert(COMPLEX_FLOAT_TYPE_P(TREE_TYPE(arg_tree)));
        if (this->code_ == BUILTIN_REAL)
-         return fold_build1_loc(location, REALPART_EXPR,
+         return fold_build1_loc(location.gcc_location(), REALPART_EXPR,
                                 TREE_TYPE(TREE_TYPE(arg_tree)),
                                 arg_tree);
        else
-         return fold_build1_loc(location, IMAGPART_EXPR,
+         return fold_build1_loc(location.gcc_location(), IMAGPART_EXPR,
                                 TREE_TYPE(TREE_TYPE(arg_tree)),
                                 arg_tree);
       }
@@ -8477,7 +8959,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
        go_assert(TYPE_MAIN_VARIANT(TREE_TYPE(r))
                   == TYPE_MAIN_VARIANT(TREE_TYPE(i)));
        go_assert(SCALAR_FLOAT_TYPE_P(TREE_TYPE(r)));
-       return fold_build2_loc(location, COMPLEX_EXPR,
+       return fold_build2_loc(location.gcc_location(), COMPLEX_EXPR,
                               build_complex_type(TREE_TYPE(r)),
                               r, i);
       }
@@ -8565,12 +9047,14 @@ Expression*
 Call_expression::do_lower(Gogo* gogo, Named_object* function,
                          Statement_inserter* inserter, int)
 {
+  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();
@@ -8578,7 +9062,7 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function,
       && 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.
@@ -8622,8 +9106,7 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function,
           ++p)
        {
          Temporary_statement* temp = Statement::make_temporary(p->type(),
-                                                               NULL,
-                                                               p->location());
+                                                               NULL, loc);
          inserter->insert(temp);
          temps->push_back(temp);
        }
@@ -8639,8 +9122,58 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function,
       const Typed_identifier_list* parameters = fntype->parameters();
       go_assert(parameters != NULL && !parameters->empty());
       Type* varargs_type = parameters->back().type();
-      return this->lower_varargs(gogo, function, inserter, varargs_type,
-                                parameters->size());
+      this->lower_varargs(gogo, function, inserter, varargs_type,
+                         parameters->size());
+    }
+
+  // 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();
+
+      // 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();
+       }
+
+      // 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;
@@ -8653,24 +9186,24 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function,
 // calling; the last of these parameters will be the varargs
 // parameter.
 
-Expression*
+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();
+  Location loc = this->location();
 
   go_assert(param_count > 0);
-  go_assert(varargs_type->is_open_array_type());
+  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_;
@@ -8702,7 +9235,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
        {
@@ -8712,7 +9245,7 @@ Call_expression::lower_varargs(Gogo* gogo, Named_object* function,
            {
              // Check types here so that we get a better message.
              Type* patype = (*pa)->type();
-             source_location paloc = (*pa)->location();
+             Location paloc = (*pa)->location();
              if (!this->check_argument_type(i, element_type, patype,
                                             paloc, issued_error))
                continue;
@@ -8720,6 +9253,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);
        }
     }
@@ -8733,12 +9267,6 @@ Call_expression::lower_varargs(Gogo* gogo, Named_object* function,
   // 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, inserter, &ret);
-  go_assert(ret == this);
-  return ret;
 }
 
 // Get the function type.  This can return NULL in error cases.
@@ -8862,10 +9390,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);
@@ -8898,11 +9444,17 @@ Call_expression::determining_types()
 bool
 Call_expression::check_argument_type(int i, const Type* parameter_type,
                                     const Type* argument_type,
-                                    source_location argument_location,
+                                    Location argument_location,
                                     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)
        {
@@ -8932,35 +9484,28 @@ Call_expression::do_check_types(Gogo*)
       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.  The language permits copying
-         // hidden fields for a method receiver.
-         std::string reason;
-         if (!Type::are_assignable_hidden_ok(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();
            }
        }
     }
@@ -8975,25 +9520,30 @@ 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"));
     }
 }
 
@@ -9007,65 +9557,6 @@ Call_expression::do_must_eval_in_order() const
   return this->result_count() > 0;
 }
 
-// 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);
-      Btype* bfatype = fatype->get_backend(context->gogo());
-      first_arg = fold_convert(type_to_tree(bfatype), 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);
-}
-
 // Get the function and the first argument to use when calling an
 // interface method.
 
@@ -9102,38 +9593,49 @@ Call_expression::do_get_tree(Translate_context* context)
     return error_mark_node;
 
   Gogo* gogo = context->gogo();
-  source_location location = this->location();
+  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;
-  go_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();
-      go_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)
        {
          go_assert(pp != params->end());
          tree arg_val = (*pe)->get_tree(context);
@@ -9162,14 +9664,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
-    go_unreachable();
+    fn = this->interface_method_function(context, interface_method, &args[0]);
 
   if (fn == error_mark_node || TREE_TYPE(fn) == error_mark_node)
     {
@@ -9188,7 +9686,7 @@ Call_expression::do_get_tree(Translate_context* context)
       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);
+      fn = fold_convert_loc(location.gcc_location(), fnt, fn);
     }
 
   // This is to support builtin math functions when using 80387 math.
@@ -9211,7 +9709,8 @@ Call_expression::do_get_tree(Translate_context* context)
            excess_type = NULL_TREE;
          else
            {
-             fn = build_fold_addr_expr_loc(location, excess_fndecl);
+             fn = build_fold_addr_expr_loc(location.gcc_location(),
+                                            excess_fndecl);
              for (int i = 0; i < nargs; ++i)
                args[i] = ::convert(excess_type, args[i]);
            }
@@ -9222,7 +9721,7 @@ Call_expression::do_get_tree(Translate_context* context)
                              fn, nargs, args);
   delete[] args;
 
-  SET_EXPR_LOCATION(ret, location);
+  SET_EXPR_LOCATION(ret, location.gcc_location());
 
   if (has_closure)
     {
@@ -9238,7 +9737,7 @@ Call_expression::do_get_tree(Translate_context* context)
   if (TREE_TYPE(ret) == ptr_type_node)
     {
       tree t = type_to_tree(this->type()->base()->get_backend(gogo));
-      ret = fold_convert_loc(location, t, ret);
+      ret = fold_convert_loc(location.gcc_location(), t, ret);
     }
 
   if (excess_type != NULL_TREE)
@@ -9271,7 +9770,7 @@ Call_expression::set_results(Translate_context* context, tree call_tree)
       return call_tree;
     }
 
-  source_location loc = this->location();
+  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))
@@ -9286,10 +9785,10 @@ Call_expression::set_results(Translate_context* context, tree call_tree)
       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);
+      tree val_tree = build3_loc(loc.gcc_location(), COMPONENT_REF,
+                                 TREE_TYPE(field), call_tree, field, NULL_TREE);
+      tree set_tree = build2_loc(loc.gcc_location(), MODIFY_EXPR,
+                                 void_type_node, temp_tree, val_tree);
 
       append_to_statement_list(set_tree, &stmt_list);
     }
@@ -9298,11 +9797,24 @@ Call_expression::set_results(Translate_context* context, tree call_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*
 Expression::make_call(Expression* fn, Expression_list* args, bool is_varargs,
-                     source_location location)
+                     Location location)
 {
   return new Call_expression(fn, args, is_varargs, location);
 }
@@ -9344,6 +9856,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_;
@@ -9383,6 +9898,11 @@ 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();
     }
@@ -9443,6 +9963,19 @@ Call_result_expression::do_get_tree(Translate_context* context)
   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
 // multiple results.
 
@@ -9473,7 +10006,7 @@ Index_expression::do_traverse(Traverse* traverse)
 Expression*
 Index_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
 {
-  source_location location = this->location();
+  Location location = this->location();
   Expression* left = this->left_;
   Expression* start = this->start_;
   Expression* end = this->end_;
@@ -9490,7 +10023,7 @@ Index_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, 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);
@@ -9519,11 +10052,41 @@ Index_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, 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*
 Expression::make_index(Expression* left, Expression* start, Expression* end,
-                      source_location location)
+                      Location location)
 {
   return new Index_expression(left, start, end, location);
 }
@@ -9534,7 +10097,7 @@ class Array_index_expression : public Expression
 {
  public:
   Array_index_expression(Expression* array, Expression* start,
-                        Expression* end, source_location location)
+                        Expression* end, Location location)
     : Expression(EXPRESSION_ARRAY_INDEX, location),
       array_(array), start_(start), end_(end), type_(NULL)
   { }
@@ -9564,6 +10127,13 @@ class Array_index_expression : public Expression
   }
 
   bool
+  do_must_eval_subexpressions_in_order(int* skip) const
+  {
+    *skip = 1;
+    return true;
+  }
+
+  bool
   do_is_addressable() const;
 
   void
@@ -9573,6 +10143,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_;
@@ -9614,7 +10187,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.
@@ -9649,7 +10222,9 @@ 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();
@@ -9702,7 +10277,7 @@ 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())
+  if (this->end_ != NULL && !array_type->is_slice_type())
     {
       if (!this->array_->is_addressable())
        this->report_error(_("array is not addressable"));
@@ -9721,7 +10296,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
@@ -9735,7 +10310,7 @@ tree
 Array_index_expression::do_get_tree(Translate_context* context)
 {
   Gogo* gogo = context->gogo();
-  source_location loc = this->location();
+  Location loc = this->location();
 
   Array_type* array_type = this->array_->type()->array_type();
   if (array_type == NULL)
@@ -9773,9 +10348,10 @@ Array_index_expression::do_get_tree(Translate_context* context)
   bad_index = Expression::check_bounds(start_tree, length_type, bad_index,
                                       loc);
 
-  start_tree = fold_convert_loc(loc, length_type, start_tree);
-  bad_index = fold_build2_loc(loc, TRUTH_OR_EXPR, boolean_type_node, bad_index,
-                             fold_build2_loc(loc,
+  start_tree = fold_convert_loc(loc.gcc_location(), length_type, start_tree);
+  bad_index = fold_build2_loc(loc.gcc_location(), TRUTH_OR_EXPR,
+                              boolean_type_node, bad_index,
+                             fold_build2_loc(loc.gcc_location(),
                                              (this->end_ == NULL
                                               ? GE_EXPR
                                               : GT_EXPR),
@@ -9799,7 +10375,7 @@ Array_index_expression::do_get_tree(Translate_context* context)
                          build3(COND_EXPR, void_type_node,
                                 bad_index, crash, NULL_TREE),
                          start_tree);
-      start_tree = fold_convert_loc(loc, sizetype, start_tree);
+      start_tree = fold_convert_loc(loc.gcc_location(), sizetype, start_tree);
 
       if (array_type->length() != NULL)
        {
@@ -9817,9 +10393,9 @@ Array_index_expression::do_get_tree(Translate_context* context)
          if (element_type_tree == error_mark_node)
            return error_mark_node;
          tree element_size = TYPE_SIZE_UNIT(element_type_tree);
-         tree offset = fold_build2_loc(loc, MULT_EXPR, sizetype,
+         tree offset = fold_build2_loc(loc.gcc_location(), MULT_EXPR, sizetype,
                                        start_tree, element_size);
-         tree ptr = fold_build2_loc(loc, POINTER_PLUS_EXPR,
+         tree ptr = fold_build2_loc(loc.gcc_location(), POINTER_PLUS_EXPR,
                                     TREE_TYPE(values), values, offset);
          return build_fold_indirect_ref(ptr);
        }
@@ -9830,7 +10406,8 @@ Array_index_expression::do_get_tree(Translate_context* context)
   tree capacity_tree = array_type->capacity_tree(gogo, array_tree);
   if (capacity_tree == error_mark_node)
     return error_mark_node;
-  capacity_tree = fold_convert_loc(loc, length_type, capacity_tree);
+  capacity_tree = fold_convert_loc(loc.gcc_location(), length_type,
+                                   capacity_tree);
 
   tree end_tree;
   if (this->end_->is_nil_expression())
@@ -9848,18 +10425,19 @@ Array_index_expression::do_get_tree(Translate_context* context)
       bad_index = Expression::check_bounds(end_tree, length_type, bad_index,
                                           loc);
 
-      end_tree = fold_convert_loc(loc, length_type, end_tree);
+      end_tree = fold_convert_loc(loc.gcc_location(), length_type, end_tree);
 
       capacity_tree = save_expr(capacity_tree);
-      tree bad_end = fold_build2_loc(loc, TRUTH_OR_EXPR, boolean_type_node,
-                                    fold_build2_loc(loc, LT_EXPR,
-                                                    boolean_type_node,
+      tree bad_end = fold_build2_loc(loc.gcc_location(), TRUTH_OR_EXPR,
+                                     boolean_type_node,
+                                    fold_build2_loc(loc.gcc_location(),
+                                                     LT_EXPR, boolean_type_node,
                                                     end_tree, start_tree),
-                                    fold_build2_loc(loc, GT_EXPR,
-                                                    boolean_type_node,
+                                    fold_build2_loc(loc.gcc_location(),
+                                                     GT_EXPR, boolean_type_node,
                                                     end_tree, capacity_tree));
-      bad_index = fold_build2_loc(loc, TRUTH_OR_EXPR, boolean_type_node,
-                                 bad_index, bad_end);
+      bad_index = fold_build2_loc(loc.gcc_location(), TRUTH_OR_EXPR,
+                                  boolean_type_node, bad_index, bad_end);
     }
 
   Type* element_type = array_type->element_type();
@@ -9868,23 +10446,25 @@ Array_index_expression::do_get_tree(Translate_context* context)
     return error_mark_node;
   tree element_size = TYPE_SIZE_UNIT(element_type_tree);
 
-  tree offset = fold_build2_loc(loc, MULT_EXPR, sizetype,
-                               fold_convert_loc(loc, sizetype, start_tree),
+  tree offset = fold_build2_loc(loc.gcc_location(), MULT_EXPR, sizetype,
+                               fold_convert_loc(loc.gcc_location(), sizetype,
+                                                 start_tree),
                                element_size);
 
   tree value_pointer = array_type->value_pointer_tree(gogo, array_tree);
   if (value_pointer == error_mark_node)
     return error_mark_node;
 
-  value_pointer = fold_build2_loc(loc, POINTER_PLUS_EXPR,
+  value_pointer = fold_build2_loc(loc.gcc_location(), POINTER_PLUS_EXPR,
                                  TREE_TYPE(value_pointer),
                                  value_pointer, offset);
 
-  tree result_length_tree = fold_build2_loc(loc, MINUS_EXPR, length_type,
-                                           end_tree, start_tree);
+  tree result_length_tree = fold_build2_loc(loc.gcc_location(), MINUS_EXPR,
+                                            length_type, end_tree, start_tree);
 
-  tree result_capacity_tree = fold_build2_loc(loc, MINUS_EXPR, length_type,
-                                             capacity_tree, start_tree);
+  tree result_capacity_tree = fold_build2_loc(loc.gcc_location(), MINUS_EXPR,
+                                              length_type, capacity_tree,
+                                              start_tree);
 
   tree struct_tree = type_to_tree(this->type()->get_backend(gogo));
   go_assert(TREE_CODE(struct_tree) == RECORD_TYPE);
@@ -9901,13 +10481,15 @@ Array_index_expression::do_get_tree(Translate_context* context)
   field = DECL_CHAIN(field);
   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->value = fold_convert_loc(loc.gcc_location(), TREE_TYPE(field),
+                                result_length_tree);
 
   elt = VEC_quick_push(constructor_elt, init, NULL);
   field = DECL_CHAIN(field);
   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);
+  elt->value = fold_convert_loc(loc.gcc_location(), TREE_TYPE(field),
+                                result_capacity_tree);
 
   tree constructor = build_constructor(struct_tree, init);
 
@@ -9916,17 +10498,28 @@ Array_index_expression::do_get_tree(Translate_context* context)
       && TREE_CONSTANT(result_capacity_tree))
     TREE_CONSTANT(constructor) = 1;
 
-  return fold_build2_loc(loc, COMPOUND_EXPR, TREE_TYPE(constructor),
+  return fold_build2_loc(loc.gcc_location(), COMPOUND_EXPR,
+                         TREE_TYPE(constructor),
                         build3(COND_EXPR, void_type_node,
                                bad_index, crash, NULL_TREE),
                         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*
 Expression::make_array_index(Expression* array, Expression* start,
-                            Expression* end, source_location location)
+                            Expression* end, Location location)
 {
   // Taking a slice of a composite literal requires moving the literal
   // onto the heap.
@@ -9944,7 +10537,7 @@ class String_index_expression : public Expression
 {
  public:
   String_index_expression(Expression* string, Expression* start,
-                         Expression* end, source_location location)
+                         Expression* end, Location location)
     : Expression(EXPRESSION_STRING_INDEX, location),
       string_(string), start_(start), end_(end)
   { }
@@ -9973,9 +10566,19 @@ class String_index_expression : public Expression
                                         this->location());
   }
 
+  bool
+  do_must_eval_subexpressions_in_order(int* skip) const
+  {
+    *skip = 1;
+    return true;
+  }
+
   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_;
@@ -10072,7 +10675,7 @@ String_index_expression::do_check_types(Gogo*)
 tree
 String_index_expression::do_get_tree(Translate_context* context)
 {
-  source_location loc = this->location();
+  Location loc = this->location();
 
   tree string_tree = this->string_->get_tree(context);
   if (string_tree == error_mark_node)
@@ -10101,7 +10704,7 @@ String_index_expression::do_get_tree(Translate_context* context)
   bad_index = Expression::check_bounds(start_tree, length_type, bad_index,
                                       loc);
 
-  start_tree = fold_convert_loc(loc, length_type, start_tree);
+  start_tree = fold_convert_loc(loc.gcc_location(), length_type, start_tree);
 
   int code = (this->end_ == NULL
              ? RUNTIME_ERROR_STRING_INDEX_OUT_OF_BOUNDS
@@ -10110,17 +10713,19 @@ String_index_expression::do_get_tree(Translate_context* context)
 
   if (this->end_ == NULL)
     {
-      bad_index = fold_build2_loc(loc, TRUTH_OR_EXPR, boolean_type_node,
-                                 bad_index,
-                                 fold_build2_loc(loc, GE_EXPR,
+      bad_index = fold_build2_loc(loc.gcc_location(), TRUTH_OR_EXPR,
+                                  boolean_type_node, bad_index,
+                                 fold_build2_loc(loc.gcc_location(), GE_EXPR,
                                                  boolean_type_node,
                                                  start_tree, length_tree));
 
       tree bytes_tree = String_type::bytes_tree(context->gogo(), string_tree);
-      tree ptr = fold_build2_loc(loc, POINTER_PLUS_EXPR, TREE_TYPE(bytes_tree),
+      tree ptr = fold_build2_loc(loc.gcc_location(), POINTER_PLUS_EXPR,
+                                 TREE_TYPE(bytes_tree),
                                 bytes_tree,
-                                fold_convert_loc(loc, sizetype, start_tree));
-      tree index = build_fold_indirect_ref_loc(loc, ptr);
+                                fold_convert_loc(loc.gcc_location(), sizetype,
+                                                  start_tree));
+      tree index = build_fold_indirect_ref_loc(loc.gcc_location(), ptr);
 
       return build2(COMPOUND_EXPR, TREE_TYPE(index),
                    build3(COND_EXPR, void_type_node,
@@ -10145,7 +10750,8 @@ String_index_expression::do_get_tree(Translate_context* context)
          bad_index = Expression::check_bounds(end_tree, length_type,
                                               bad_index, loc);
 
-         end_tree = fold_convert_loc(loc, length_type, end_tree);
+         end_tree = fold_convert_loc(loc.gcc_location(), length_type,
+                                      end_tree);
        }
 
       static tree strslice_fndecl;
@@ -10176,11 +10782,21 @@ 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*
 Expression::make_string_index(Expression* string, Expression* start,
-                             Expression* end, source_location location)
+                             Expression* end, Location location)
 {
   return new String_index_expression(string, start, end, location);
 }
@@ -10336,14 +10952,16 @@ Map_index_expression::get_value_pointer(Translate_context* context,
     }
   else
     {
-      tmp = build_decl(this->location(), VAR_DECL, create_tmp_var_name("M"),
+      tmp = build_decl(this->location().gcc_location(), VAR_DECL,
+                       create_tmp_var_name("M"),
                       TREE_TYPE(index_tree));
       DECL_EXTERNAL(tmp) = 0;
       TREE_PUBLIC(tmp) = 0;
       TREE_STATIC(tmp) = 1;
       DECL_ARTIFICIAL(tmp) = 1;
       if (!TREE_CONSTANT(index_tree))
-       make_tmp = fold_build2_loc(this->location(), INIT_EXPR, void_type_node,
+       make_tmp = fold_build2_loc(this->location().gcc_location(),
+                                   INIT_EXPR, void_type_node,
                                   tmp, index_tree);
       else
        {
@@ -10354,9 +10972,10 @@ Map_index_expression::get_value_pointer(Translate_context* context,
        }
       rest_of_decl_compilation(tmp, 1, 0);
     }
-  tree tmpref = fold_convert_loc(this->location(), const_ptr_type_node,
-                                build_fold_addr_expr_loc(this->location(),
-                                                         tmp));
+  tree tmpref =
+    fold_convert_loc(this->location().gcc_location(), const_ptr_type_node,
+                     build_fold_addr_expr_loc(this->location().gcc_location(),
+                                              tmp));
 
   static tree map_index_fndecl;
   tree call = Gogo::call_builtin(&map_index_fndecl,
@@ -10384,17 +11003,28 @@ Map_index_expression::get_value_pointer(Translate_context* context,
     return error_mark_node;
   tree ptr_val_type_tree = build_pointer_type(val_type_tree);
 
-  tree ret = fold_convert_loc(this->location(), ptr_val_type_tree, call);
+  tree ret = fold_convert_loc(this->location().gcc_location(),
+                              ptr_val_type_tree, call);
   if (make_tmp != NULL_TREE)
     ret = build2(COMPOUND_EXPR, ptr_val_type_tree, make_tmp, ret);
   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*
 Expression::make_map_index(Expression* map, Expression* index,
-                          source_location location)
+                          Location location)
 {
   return new Map_index_expression(map, index, location);
 }
@@ -10456,11 +11086,21 @@ 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*
 Expression::make_field_reference(Expression* expr, unsigned int field_index,
-                                source_location location)
+                                Location location)
 {
   return new Field_reference_expression(expr, field_index, location);
 }
@@ -10602,12 +11242,22 @@ Interface_field_reference_expression::do_get_tree(Translate_context*)
   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.
 
 Expression*
 Expression::make_interface_field_reference(Expression* expr,
                                           const std::string& field,
-                                          source_location location)
+                                          Location location)
 {
   return new Interface_field_reference_expression(expr, field, location);
 }
@@ -10619,7 +11269,7 @@ class Selector_expression : public Parser_expression
 {
  public:
   Selector_expression(Expression* left, const std::string& name,
-                     source_location location)
+                     Location location)
     : Parser_expression(EXPRESSION_SELECTOR, location),
       left_(left), name_(name)
   { }
@@ -10639,6 +11289,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*);
@@ -10669,7 +11322,7 @@ Selector_expression::do_lower(Gogo* gogo, Named_object*, Statement_inserter*,
 Expression*
 Selector_expression::lower_method_expression(Gogo* gogo)
 {
-  source_location location = this->location();
+  Location location = this->location();
   Type* type = this->left_->type();
   const std::string& name(this->name_);
 
@@ -10832,7 +11485,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();
@@ -10859,11 +11512,22 @@ Selector_expression::lower_method_expression(Gogo* gogo)
   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*
 Expression::make_selector(Expression* left, const std::string& name,
-                         source_location location)
+                         Location location)
 {
   return new Selector_expression(left, name, location);
 }
@@ -10873,7 +11537,7 @@ Expression::make_selector(Expression* left, const std::string& name,
 class Allocation_expression : public Expression
 {
  public:
-  Allocation_expression(Type* type, source_location location)
+  Allocation_expression(Type* type, Location location)
     : Expression(EXPRESSION_ALLOCATION, location),
       type_(type)
   { }
@@ -10898,6 +11562,9 @@ 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_;
@@ -10919,10 +11586,21 @@ 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*
-Expression::make_allocation(Type* type, source_location location)
+Expression::make_allocation(Type* type, Location location)
 {
   return new Allocation_expression(type, location);
 }
@@ -10933,7 +11611,7 @@ class Struct_construction_expression : public Expression
 {
  public:
   Struct_construction_expression(Type* type, Expression_list* vals,
-                                source_location location)
+                                Location location)
     : Expression(EXPRESSION_STRUCT_CONSTRUCTION, location),
       type_(type), vals_(vals)
   { }
@@ -10973,6 +11651,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_;
@@ -11185,11 +11866,23 @@ 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)
+                                         Location location)
 {
   go_assert(type->struct_type() != NULL);
   return new Struct_construction_expression(type, vals, location);
@@ -11204,7 +11897,7 @@ class Array_construction_expression : public Expression
  protected:
   Array_construction_expression(Expression_classification classification,
                                Type* type, Expression_list* vals,
-                               source_location location)
+                               Location location)
     : Expression(classification, location),
       type_(type), vals_(vals)
   { }
@@ -11249,6 +11942,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_;
@@ -11337,7 +12033,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);
@@ -11422,6 +12118,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 :
@@ -11429,7 +12147,7 @@ class Fixed_array_construction_expression :
 {
  public:
   Fixed_array_construction_expression(Type* type, Expression_list* vals,
-                                     source_location location)
+                                     Location location)
     : Array_construction_expression(EXPRESSION_FIXED_ARRAY_CONSTRUCTION,
                                    type, vals, location)
   {
@@ -11450,6 +12168,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.
@@ -11462,13 +12183,29 @@ Fixed_array_construction_expression::do_get_tree(Translate_context* context)
   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
 {
  public:
   Open_array_construction_expression(Type* type, Expression_list* vals,
-                                    source_location location)
+                                    Location location)
     : Array_construction_expression(EXPRESSION_OPEN_ARRAY_CONSTRUCTION,
                                    type, vals, location)
   {
@@ -11559,7 +12296,7 @@ Open_array_construction_expression::do_get_tree(Translate_context* context)
 
   if (is_constant_initializer)
     {
-      tree tmp = build_decl(this->location(), VAR_DECL,
+      tree tmp = build_decl(this->location().gcc_location(), VAR_DECL,
                            create_tmp_var_name("C"), TREE_TYPE(values));
       DECL_EXTERNAL(tmp) = 0;
       TREE_PUBLIC(tmp) = 0;
@@ -11595,7 +12332,8 @@ Open_array_construction_expression::do_get_tree(Translate_context* context)
       space = save_expr(space);
 
       tree s = fold_convert(build_pointer_type(TREE_TYPE(values)), space);
-      tree ref = build_fold_indirect_ref_loc(this->location(), s);
+      tree ref = build_fold_indirect_ref_loc(this->location().gcc_location(),
+                                             s);
       TREE_THIS_NOTRAP(ref) = 1;
       set = build2(MODIFY_EXPR, void_type_node, ref, values);
     }
@@ -11644,9 +12382,9 @@ Open_array_construction_expression::do_get_tree(Translate_context* context)
 
 Expression*
 Expression::make_slice_composite_literal(Type* type, Expression_list* vals,
-                                        source_location location)
+                                        Location location)
 {
-  go_assert(type->is_open_array_type());
+  go_assert(type->is_slice_type());
   return new Open_array_construction_expression(type, vals, location);
 }
 
@@ -11656,7 +12394,7 @@ class Map_construction_expression : public Expression
 {
  public:
   Map_construction_expression(Type* type, Expression_list* vals,
-                             source_location location)
+                             Location location)
     : Expression(EXPRESSION_MAP_CONSTRUCTION, location),
       type_(type), vals_(vals)
   { go_assert(vals == NULL || vals->size() % 2 == 0); }
@@ -11688,6 +12426,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_;
@@ -11770,7 +12511,7 @@ tree
 Map_construction_expression::do_get_tree(Translate_context* context)
 {
   Gogo* gogo = context->gogo();
-  source_location loc = this->location();
+  Location loc = this->location();
 
   Map_type* mt = this->type_->map_type();
 
@@ -11782,7 +12523,8 @@ Map_construction_expression::do_get_tree(Translate_context* context)
   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);
+  tree key_field = build_decl(loc.gcc_location(), FIELD_DECL, id,
+                              key_type_tree);
   DECL_CONTEXT(key_field) = struct_type;
   TYPE_FIELDS(struct_type) = key_field;
 
@@ -11791,7 +12533,8 @@ Map_construction_expression::do_get_tree(Translate_context* context)
   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);
+  tree val_field = build_decl(loc.gcc_location(), FIELD_DECL, id,
+                              val_type_tree);
   DECL_CONTEXT(val_field) = struct_type;
   DECL_CHAIN(key_field) = val_field;
 
@@ -11863,19 +12606,21 @@ Map_construction_expression::do_get_tree(Translate_context* context)
        {
          tmp = create_tmp_var(array_type, get_name(array_type));
          DECL_INITIAL(tmp) = init;
-         make_tmp = fold_build1_loc(loc, DECL_EXPR, void_type_node, tmp);
+         make_tmp = fold_build1_loc(loc.gcc_location(), DECL_EXPR,
+                                     void_type_node, tmp);
          TREE_ADDRESSABLE(tmp) = 1;
        }
       else
        {
-         tmp = build_decl(loc, VAR_DECL, create_tmp_var_name("M"), array_type);
+         tmp = build_decl(loc.gcc_location(), VAR_DECL,
+                           create_tmp_var_name("M"), array_type);
          DECL_EXTERNAL(tmp) = 0;
          TREE_PUBLIC(tmp) = 0;
          TREE_STATIC(tmp) = 1;
          DECL_ARTIFICIAL(tmp) = 1;
          if (!TREE_CONSTANT(init))
-           make_tmp = fold_build2_loc(loc, INIT_EXPR, void_type_node, tmp,
-                                      init);
+           make_tmp = fold_build2_loc(loc.gcc_location(), INIT_EXPR,
+                                       void_type_node, tmp, init);
          else
            {
              TREE_READONLY(tmp) = 1;
@@ -11920,7 +12665,8 @@ Map_construction_expression::do_get_tree(Translate_context* context)
   if (make_tmp == NULL)
     ret = call;
   else
-    ret = fold_build2_loc(loc, COMPOUND_EXPR, type_tree, make_tmp, call);
+    ret = fold_build2_loc(loc.gcc_location(), COMPOUND_EXPR, type_tree,
+                          make_tmp, call);
   return ret;
 }
 
@@ -11941,6 +12687,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.
 
@@ -11948,7 +12705,7 @@ class Composite_literal_expression : public Parser_expression
 {
  public:
   Composite_literal_expression(Type* type, int depth, bool has_keys,
-                              Expression_list* vals, source_location location)
+                              Expression_list* vals, Location location)
     : Parser_expression(EXPRESSION_COMPOSITE_LITERAL, location),
       type_(type), depth_(depth), vals_(vals), has_keys_(has_keys)
   { }
@@ -11971,6 +12728,9 @@ class Composite_literal_expression : public Parser_expression
                                            this->location());
   }
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+  
  private:
   Expression*
   lower_struct(Gogo*, Type*);
@@ -12054,10 +12814,25 @@ Composite_literal_expression::do_lower(Gogo* gogo, Named_object* function,
 Expression*
 Composite_literal_expression::lower_struct(Gogo* gogo, Type* type)
 {
-  source_location location = this->location();
+  Location location = this->location();
   Struct_type* st = type->struct_type();
   if (this->vals_ == NULL || !this->has_keys_)
-    return new Struct_construction_expression(type, this->vals_, location);
+    {
+      if (this->vals_ != NULL && !this->vals_->empty())
+       {
+         std::string reason;
+         if (type->has_hidden_fields(NULL, &reason))
+           {
+             if (reason.empty())
+               error_at(this->location(),
+                        "implicit assignment of hidden field");
+             else
+               error_at(this->location(), "%s", reason.c_str());
+           }
+       }
+
+      return new Struct_construction_expression(type, this->vals_, location);
+    }
 
   size_t field_count = st->field_count();
   std::vector<Expression*> vals(field_count);
@@ -12130,6 +12905,16 @@ Composite_literal_expression::lower_struct(Gogo* gogo, 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);
@@ -12161,7 +12946,7 @@ Composite_literal_expression::lower_struct(Gogo* gogo, Type* type)
 
          // 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.
+         // the field name will be packed.  FIXME.
          if (!Gogo::is_hidden_name(name)
              && name[0] >= 'a'
              && name[0] <= 'z')
@@ -12194,6 +12979,26 @@ Composite_literal_expression::lower_struct(Gogo* gogo, Type* type)
          return Expression::make_error(location);
        }
 
+      if (type->named_type() != NULL
+         && type->named_type()->named_object()->package() != NULL
+         && Gogo::is_hidden_name(sf->field_name()))
+       error_at(name_expr->location(),
+                "assignment of unexported field %qs in %qs literal",
+                Gogo::message_name(sf->field_name()).c_str(),
+                type->named_type()->message_name().c_str());
+      else
+       {
+         std::string reason;
+         if (sf->type()->has_hidden_fields(NULL, &reason))
+           {
+             if (reason.empty())
+               error_at(name_expr->location(),
+                        "implicit assignment of hidden field");
+             else
+               error_at(name_expr->location(), "%s", reason.c_str());
+           }
+       }
+
       vals[index] = val;
     }
 
@@ -12210,7 +13015,7 @@ Composite_literal_expression::lower_struct(Gogo* gogo, Type* type)
 Expression*
 Composite_literal_expression::lower_array(Type* type)
 {
-  source_location location = this->location();
+  Location location = this->location();
   if (this->vals_ == NULL || !this->has_keys_)
     return this->make_array(type, this->vals_);
 
@@ -12321,7 +13126,7 @@ Composite_literal_expression::lower_array(Type* type)
 Expression*
 Composite_literal_expression::make_array(Type* type, Expression_list* vals)
 {
-  source_location location = this->location();
+  Location location = this->location();
   Array_type* at = type->array_type();
   if (at->length() != NULL && at->length()->is_nil_expression())
     {
@@ -12346,7 +13151,7 @@ Composite_literal_expression::lower_map(Gogo* gogo, Named_object* function,
                                        Statement_inserter* inserter,
                                        Type* type)
 {
-  source_location location = this->location();
+  Location location = this->location();
   if (this->vals_ != NULL)
     {
       if (!this->has_keys_)
@@ -12382,12 +13187,25 @@ 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*
 Expression::make_composite_literal(Type* type, int depth, bool has_keys,
                                   Expression_list* vals,
-                                  source_location location)
+                                  Location location)
 {
   return new Composite_literal_expression(type, depth, has_keys, vals,
                                          location);
@@ -12556,11 +13374,22 @@ 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*
 Expression::make_type_guard(Expression* expr, Type* type,
-                           source_location location)
+                           Location location)
 {
   return new Type_guard_expression(expr, type, location);
 }
@@ -12573,7 +13402,7 @@ Expression::make_type_guard(Expression* expr, Type* type,
 class Heap_composite_expression : public Expression
 {
  public:
-  Heap_composite_expression(Expression* expr, source_location location)
+  Heap_composite_expression(Expression* expr, Location location)
     : Expression(EXPRESSION_HEAP_COMPOSITE, location),
       expr_(expr)
   { }
@@ -12607,6 +13436,9 @@ class Heap_composite_expression : public Expression
   do_export(Export*) const
   { go_unreachable(); }
 
+  void
+  do_dump_expression(Ast_dump_context*) const;
+
  private:
   // The composite literal which is being put on the heap.
   Expression* expr_;
@@ -12626,19 +13458,31 @@ Heap_composite_expression::do_get_tree(Translate_context* context)
                                                expr_size, this->location());
   space = fold_convert(build_pointer_type(TREE_TYPE(expr_tree)), space);
   space = save_expr(space);
-  tree ref = build_fold_indirect_ref_loc(this->location(), space);
+  tree ref = build_fold_indirect_ref_loc(this->location().gcc_location(),
+                                         space);
   TREE_THIS_NOTRAP(ref) = 1;
   tree ret = build2(COMPOUND_EXPR, TREE_TYPE(space),
                    build2(MODIFY_EXPR, void_type_node, ref, expr_tree),
                    space);
-  SET_EXPR_LOCATION(ret, this->location());
+  SET_EXPR_LOCATION(ret, this->location().gcc_location());
   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*
-Expression::make_heap_composite(Expression* expr, source_location location)
+Expression::make_heap_composite(Expression* expr, Location location)
 {
   return new Heap_composite_expression(expr, location);
 }
@@ -12684,12 +13528,18 @@ Receive_expression::do_check_types(Gogo*)
 tree
 Receive_expression::do_get_tree(Translate_context* context)
 {
+  Location loc = this->location();
+
   Channel_type* channel_type = this->channel_->type()->channel_type();
   if (channel_type == NULL)
     {
       go_assert(this->channel_->type()->is_error());
       return error_mark_node;
     }
+
+  Expression* td = Expression::make_type_descriptor(channel_type, loc);
+  tree td_tree = td->get_tree(context);
+
   Type* element_type = channel_type->element_type();
   Btype* element_type_btype = element_type->get_backend(context->gogo());
   tree element_type_tree = type_to_tree(element_type_btype);
@@ -12698,14 +13548,22 @@ Receive_expression::do_get_tree(Translate_context* context)
   if (element_type_tree == error_mark_node || channel == error_mark_node)
     return error_mark_node;
 
-  return Gogo::receive_from_channel(element_type_tree, channel,
-                                   this->for_select_, this->location());
+  return Gogo::receive_from_channel(element_type_tree, td_tree, channel, loc);
+}
+
+// Dump ast representation for a receive expression.
+
+void
+Receive_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
+{
+  ast_dump_context->ostream() << " <- " ;
+  ast_dump_context->dump_expression(channel_);
 }
 
 // Make a receive expression.
 
 Receive_expression*
-Expression::make_receive(Expression* channel, source_location location)
+Expression::make_receive(Expression* channel, Location location)
 {
   return new Receive_expression(channel, location);
 }
@@ -12716,7 +13574,7 @@ Expression::make_receive(Expression* channel, source_location location)
 class Type_descriptor_expression : public Expression
 {
  public:
-  Type_descriptor_expression(Type* type, source_location location)
+  Type_descriptor_expression(Type* type, Location location)
     : Expression(EXPRESSION_TYPE_DESCRIPTOR, location),
       type_(type)
   { }
@@ -12741,15 +13599,27 @@ class Type_descriptor_expression : public Expression
                                                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*
-Expression::make_type_descriptor(Type* type, source_location location)
+Expression::make_type_descriptor(Type* type, Location location)
 {
   return new Type_descriptor_expression(type, location);
 }
@@ -12764,7 +13634,7 @@ class Type_info_expression : public Expression
 {
  public:
   Type_info_expression(Type* type, Type_info type_info)
-    : Expression(EXPRESSION_TYPE_INFO, BUILTINS_LOCATION),
+    : Expression(EXPRESSION_TYPE_INFO, Linemap::predeclared_location()),
       type_(type), type_info_(type_info)
   { }
 
@@ -12783,6 +13653,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_;
@@ -12834,6 +13707,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*
@@ -12850,7 +13740,8 @@ class Struct_field_offset_expression : public Expression
 {
  public:
   Struct_field_offset_expression(Struct_type* type, const Struct_field* field)
-    : Expression(EXPRESSION_STRUCT_FIELD_OFFSET, BUILTINS_LOCATION),
+    : Expression(EXPRESSION_STRUCT_FIELD_OFFSET,
+                Linemap::predeclared_location()),
       type_(type), field_(field)
   { }
 
@@ -12870,6 +13761,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_;
@@ -12906,6 +13800,20 @@ Struct_field_offset_expression::do_get_tree(Translate_context* context)
                          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*
@@ -12921,7 +13829,7 @@ Expression::make_struct_field_offset(Struct_type* type,
 class Map_descriptor_expression : public Expression
 {
  public:
-  Map_descriptor_expression(Map_type* type, source_location location)
+  Map_descriptor_expression(Map_type* type, Location location)
     : Expression(EXPRESSION_MAP_DESCRIPTOR, location),
       type_(type)
   { }
@@ -12946,15 +13854,29 @@ class Map_descriptor_expression : public Expression
                                               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)
+Expression::make_map_descriptor(Map_type* type, Location location)
 {
   return new Map_descriptor_expression(type, location);
 }
@@ -12964,7 +13886,7 @@ Expression::make_map_descriptor(Map_type* type, source_location location)
 class Label_addr_expression : public Expression
 {
  public:
-  Label_addr_expression(Label* label, source_location location)
+  Label_addr_expression(Label* label, Location location)
     : Expression(EXPRESSION_LABEL_ADDR, location),
       label_(label)
   { }
@@ -12988,6 +13910,10 @@ class Label_addr_expression : public Expression
     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_;
@@ -12996,7 +13922,7 @@ class Label_addr_expression : public Expression
 // Make an expression for the address of an unnamed label.
 
 Expression*
-Expression::make_label_addr(Label* label, source_location location)
+Expression::make_label_addr(Label* label, Location location)
 {
   return new Label_addr_expression(label, location);
 }