diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-09-21 17:37:50 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-09-21 17:37:50 +0000 |
commit | e6f8e5901625f2c77ea317a3d770c52d966b5e77 (patch) | |
tree | 72d064eacaba81463aeeb1607f050c5b0151b34a /gcc | |
parent | bd352290bcbe1c80ce47ea3aa4d66d17a6e8d482 (diff) | |
download | gcc-e6f8e5901625f2c77ea317a3d770c52d966b5e77.zip gcc-e6f8e5901625f2c77ea317a3d770c52d966b5e77.tar.gz gcc-e6f8e5901625f2c77ea317a3d770c52d966b5e77.tar.bz2 |
Support nil maps.
From-SVN: r179054
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/runtime.def | 4 | ||||
-rw-r--r-- | gcc/go/gofrontend/statements.cc | 12 |
2 files changed, 9 insertions, 7 deletions
diff --git a/gcc/go/gofrontend/runtime.def b/gcc/go/gofrontend/runtime.def index a7828ed..a72942d 100644 --- a/gcc/go/gofrontend/runtime.def +++ b/gcc/go/gofrontend/runtime.def @@ -87,8 +87,8 @@ DEF_GO_RUNTIME(MAP_INDEX, "__go_map_index", P3(MAP, POINTER, BOOL), R1(POINTER)) // Look up a key in a map returning whether it is present. -DEF_GO_RUNTIME(MAPACCESS2, "runtime.mapaccess2", P3(MAP, POINTER, POINTER), - R1(BOOL)) +DEF_GO_RUNTIME(MAPACCESS2, "runtime.mapaccess2", + P4(TYPE, MAP, POINTER, POINTER), R1(BOOL)) // Tuple assignment to a map element. DEF_GO_RUNTIME(MAPASSIGN2, "runtime.mapassign2", diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc index deb5d52..8c1f168 100644 --- a/gcc/go/gofrontend/statements.cc +++ b/gcc/go/gofrontend/statements.cc @@ -1085,14 +1085,16 @@ Tuple_map_assignment_statement::do_lower(Gogo*, Named_object*, Statement::make_temporary(Type::lookup_bool_type(), NULL, loc); b->add_statement(present_temp); - // present_temp = mapaccess2(MAP, &key_temp, &val_temp) + // present_temp = mapaccess2(DESCRIPTOR, MAP, &key_temp, &val_temp) + Expression* a1 = Expression::make_type_descriptor(map_type, loc); + Expression* a2 = map_index->map(); Temporary_reference_expression* ref = Expression::make_temporary_reference(key_temp, loc); - Expression* a1 = Expression::make_unary(OPERATOR_AND, ref, loc); + Expression* a3 = Expression::make_unary(OPERATOR_AND, ref, loc); ref = Expression::make_temporary_reference(val_temp, loc); - Expression* a2 = Expression::make_unary(OPERATOR_AND, ref, loc); - Expression* call = Runtime::make_call(Runtime::MAPACCESS2, loc, 3, - map_index->map(), a1, a2); + Expression* a4 = Expression::make_unary(OPERATOR_AND, ref, loc); + Expression* call = Runtime::make_call(Runtime::MAPACCESS2, loc, 4, + a1, a2, a3, a4); ref = Expression::make_temporary_reference(present_temp, loc); ref->set_is_lvalue(); |