mirror of git://gcc.gnu.org/git/gcc.git
reflect: Fix reflect.Call with function following non-pointer.
From-SVN: r203052
This commit is contained in:
parent
62fecdd340
commit
2cb01a3972
|
@ -2406,6 +2406,15 @@ func TestVariadic(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFuncArg(t *testing.T) {
|
||||||
|
f1 := func(i int, f func(int) int) int { return f(i) }
|
||||||
|
f2 := func(i int) int { return i + 1 }
|
||||||
|
r := ValueOf(f1).Call([]Value{ValueOf(100), ValueOf(f2)})
|
||||||
|
if r[0].Int() != 101 {
|
||||||
|
t.Errorf("function returned %d, want 101", r[0].Int())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var tagGetTests = []struct {
|
var tagGetTests = []struct {
|
||||||
Tag StructTag
|
Tag StructTag
|
||||||
Key string
|
Key string
|
||||||
|
|
|
@ -433,7 +433,7 @@ func (v Value) call(op string, in []Value) []Value {
|
||||||
if v.flag&flagMethod != 0 {
|
if v.flag&flagMethod != 0 {
|
||||||
nin++
|
nin++
|
||||||
}
|
}
|
||||||
firstPointer := len(in) > 0 && Kind(t.In(0).(*rtype).kind) != Ptr && v.flag&flagMethod == 0 && isMethod(v.typ)
|
firstPointer := len(in) > 0 && t.In(0).Kind() != Ptr && v.flag&flagMethod == 0 && isMethod(v.typ)
|
||||||
params := make([]unsafe.Pointer, nin)
|
params := make([]unsafe.Pointer, nin)
|
||||||
off := 0
|
off := 0
|
||||||
if v.flag&flagMethod != 0 {
|
if v.flag&flagMethod != 0 {
|
||||||
|
@ -497,8 +497,10 @@ func isMethod(t *rtype) bool {
|
||||||
sawRet := false
|
sawRet := false
|
||||||
for i, c := range s {
|
for i, c := range s {
|
||||||
if c == '(' {
|
if c == '(' {
|
||||||
parens++
|
if parens == 0 {
|
||||||
params++
|
params++
|
||||||
|
}
|
||||||
|
parens++
|
||||||
} else if c == ')' {
|
} else if c == ')' {
|
||||||
parens--
|
parens--
|
||||||
} else if parens == 0 && c == ' ' && s[i+1] != '(' && !sawRet {
|
} else if parens == 0 && c == ' ' && s[i+1] != '(' && !sawRet {
|
||||||
|
|
Loading…
Reference in New Issue