]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
compiler: set varargs correctly for type of method expression
authorIan Lance Taylor <iant@golang.org>
Thu, 1 Oct 2020 22:11:22 +0000 (15:11 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 1 Oct 2020 23:10:17 +0000 (16:10 -0700)
Fixes golang/go#41737

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/258977

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/types.cc
libgo/go/reflect/all_test.go

index 8d9fda54619d8243f238d8a20f3bd296c813cd00..94827406df1915bbd84d948708e7ac1a855fb477 100644 (file)
@@ -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.
index 7f65b4a5db2e07b411b144d2310fb473a278e16e..e7a742f636650be420a7d46e3c7f2c88bc2552ab 100644 (file)
@@ -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
index ee37359814babfa94c3f14017b80220f9b8b2b2a..68efab6e145acbb9ef768cc11718a00186c2c1af 100644 (file)
@@ -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)