summaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2013-10-01 03:12:15 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2013-10-01 03:12:15 +0000
commitfc502d2f0103d453242454e6097e9d7ca3103e45 (patch)
tree4447732d9d4c8bb77dbef74ce06fa4020dfe93e8 /libgo
parentc6c774f8fae6f26daf19787786aa03ebc6cf5005 (diff)
downloadgcc-fc502d2f0103d453242454e6097e9d7ca3103e45.tar.gz
reflect: Fix reflect.Call with function following non-pointer.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203052 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/reflect/all_test.go9
-rw-r--r--libgo/go/reflect/value.go6
2 files changed, 13 insertions, 2 deletions
diff --git a/libgo/go/reflect/all_test.go b/libgo/go/reflect/all_test.go
index 1fed58570f2..140a068b9ca 100644
--- a/libgo/go/reflect/all_test.go
+++ b/libgo/go/reflect/all_test.go
@@ -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 {
Tag StructTag
Key string
diff --git a/libgo/go/reflect/value.go b/libgo/go/reflect/value.go
index 9901ed6a4c6..b199f70888c 100644
--- a/libgo/go/reflect/value.go
+++ b/libgo/go/reflect/value.go
@@ -433,7 +433,7 @@ func (v Value) call(op string, in []Value) []Value {
if v.flag&flagMethod != 0 {
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)
off := 0
if v.flag&flagMethod != 0 {
@@ -497,8 +497,10 @@ func isMethod(t *rtype) bool {
sawRet := false
for i, c := range s {
if c == '(' {
+ if parens == 0 {
+ params++
+ }
parens++
- params++
} else if c == ')' {
parens--
} else if parens == 0 && c == ' ' && s[i+1] != '(' && !sawRet {