summaryrefslogtreecommitdiffstats
path: root/misc/cgo/testshared/testdata/exe/exe.go
blob: ee95f97bc99edbe6b946b18043c6d45c734fcebb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main

import (
	"os"
	"reflect"
	"runtime"

	"testshared/depBase"
)

// Having a function declared in the main package triggered
// golang.org/issue/18250
func DeclaredInMain() {
}

type C struct {
}

func F() *C {
	return nil
}

var slicePtr interface{} = &[]int{}

func main() {
	defer depBase.ImplementedInAsm()
	// This code below causes various go.itab.* symbols to be generated in
	// the executable. Similar code in ../depBase/dep.go results in
	// exercising https://golang.org/issues/17594
	reflect.TypeOf(os.Stdout).Elem()
	runtime.GC()
	depBase.V = depBase.F() + 1

	var c *C
	if reflect.TypeOf(F).Out(0) != reflect.TypeOf(c) {
		panic("bad reflection results, see golang.org/issue/18252")
	}

	sp := reflect.New(reflect.TypeOf(slicePtr).Elem())
	s := sp.Interface()

	if reflect.TypeOf(s) != reflect.TypeOf(slicePtr) {
		panic("bad reflection results, see golang.org/issue/18729")
	}
}