-9c8581187b1c1a30036263728370f31cb846a274
+3dbf51c01c5d0acbf9ae47f77166fa9935881749
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
return Expression::make_error(loc);
}
+ // Avoid copy for string([]byte) conversions used in map keys.
+ // mapaccess doesn't keep the reference, so this is safe.
+ Type_conversion_expression* ce = this->index_->conversion_expression();
+ if (ce != NULL && ce->type()->is_string_type()
+ && ce->expr()->type()->is_slice_type())
+ ce->set_no_copy(true);
+
if (!Type::are_identical(mt->key_type(), this->index_->type(),
Type::COMPARE_ERRORS | Type::COMPARE_TAGS,
NULL))
if (map_type == NULL)
return Statement::make_error_statement(loc);
+ // Avoid copy for string([]byte) conversions used in map keys.
+ // mapaccess doesn't keep the reference, so this is safe.
+ Type_conversion_expression* ce = map_index->index()->conversion_expression();
+ if (ce != NULL && ce->type()->is_string_type()
+ && ce->expr()->type()->is_slice_type())
+ ce->set_no_copy(true);
+
Block* b = new Block(enclosing, loc);
// Move out any subexpressions to make sure that functions are
+2019-05-09 Cherry Zhang <cherryyz@google.com>
+
+ * go.dg/mapstring.go: New test.
+
2019-05-09 Richard Earnshaw <rearnsha@arm.com>
PR target/90405
--- /dev/null
+// { dg-do compile }
+// { dg-options "-fgo-debug-optimization" }
+
+package p
+
+func F(m map[string]int, a, b []byte) int {
+ x := m[string(a)] // { dg-error "no copy string\\(\\\[\\\]byte\\)" }
+ y, ok := m[string(b)] // { dg-error "no copy string\\(\\\[\\\]byte\\)" }
+ _ = ok
+ return x + y
+}