Go patch committed: Set varargs correctly for type of method expression
Ian Lance Taylor
iant@golang.org
Thu Oct 1 23:32:57 GMT 2020
This Go frontend patch set varargs correctly for the type of method
expression. This fixes https://golang.org/issue/41737. Bootstrapped
and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline
and GCC 10 branch.
Ian
-------------- next part --------------
8e23cd3a2d23ad851938bf7015fc97539d65a8c6
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 8d9fda54619..94827406df1 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-c9c084bce713e258721e12041a351ec8ad33ad17
+801c458a562d22260ff176c26d65639dd32c8a90
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index 7f65b4a5db2..e7a742f6366 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -5350,8 +5350,12 @@ Function_type::copy_with_receiver_as_param(bool want_pointer_receiver) const
++p)
new_params->push_back(*p);
}
- return Type::make_function_type(NULL, new_params, this->results_,
- this->location_);
+ Function_type* ret = Type::make_function_type(NULL, new_params,
+ this->results_,
+ this->location_);
+ if (this->is_varargs_)
+ ret->set_is_varargs();
+ return ret;
}
// Make a copy of a function type ignoring any receiver and adding a
diff --git a/libgo/go/reflect/all_test.go b/libgo/go/reflect/all_test.go
index ee37359814b..68efab6e145 100644
--- a/libgo/go/reflect/all_test.go
+++ b/libgo/go/reflect/all_test.go
@@ -2396,8 +2396,14 @@ func TestVariadicMethodValue(t *testing.T) {
points := []Point{{20, 21}, {22, 23}, {24, 25}}
want := int64(p.TotalDist(points[0], points[1], points[2]))
+ // Variadic method of type.
+ tfunc := TypeOf((func(Point, ...Point) int)(nil))
+ if tt := TypeOf(p).Method(4).Type; tt != tfunc {
+ t.Errorf("Variadic Method Type from TypeOf is %s; want %s", tt, tfunc)
+ }
+
// Curried method of value.
- tfunc := TypeOf((func(...Point) int)(nil))
+ tfunc = TypeOf((func(...Point) int)(nil))
v := ValueOf(p).Method(4)
if tt := v.Type(); tt != tfunc {
t.Errorf("Variadic Method Type is %s; want %s", tt, tfunc)
More information about the Gcc-patches
mailing list