compiler: use int type for len & cap in slice value
Slice value expression has backend type a struct of a pointer and
two ints. Make sure the len and cap are converted to int when
creating slice value expression.
Change-Id: I93dd83a59ed5c8df4d51db0319bfd59e099340a7
Reviewed-on: https://go-review.googlesource.com/c/156897
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/go/expressions.cc b/go/expressions.cc
index 71f1800..4854c3c 100644
--- a/go/expressions.cc
+++ b/go/expressions.cc
@@ -7821,8 +7821,10 @@
cap_arg);
mem = Expression::make_unsafe_cast(Type::make_pointer_type(et), mem,
loc);
- call = Expression::make_slice_value(type, mem, len_arg->copy(),
- cap_arg->copy(), loc);
+ Type* int_type = Type::lookup_integer_type("int");
+ len_arg = Expression::make_cast(int_type, len_arg->copy(), loc);
+ cap_arg = Expression::make_cast(int_type, cap_arg->copy(), loc);
+ call = Expression::make_slice_value(type, mem, len_arg, cap_arg, loc);
}
else if (is_map)
{