Home | History | Annotate | Download | only in plugin1
      1 // Copyright 2016 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 package main
      6 
      7 // // No C code required.
      8 import "C"
      9 
     10 import (
     11 	"common"
     12 	"reflect"
     13 )
     14 
     15 func F() int {
     16 	_ = make([]byte, 1<<21) // trigger stack unwind, Issue #18190.
     17 	return 3
     18 }
     19 
     20 func ReadCommonX() int {
     21 	return common.X
     22 }
     23 
     24 var Seven int
     25 
     26 func call(fn func()) {
     27 	fn()
     28 }
     29 
     30 func g() {
     31 	common.X *= Seven
     32 }
     33 
     34 func init() {
     35 	Seven = 7
     36 	call(g)
     37 }
     38 
     39 type sameNameReusedInPlugins struct {
     40 	X string
     41 }
     42 
     43 type sameNameHolder struct {
     44 	F *sameNameReusedInPlugins
     45 }
     46 
     47 func UnexportedNameReuse() {
     48 	h := sameNameHolder{}
     49 	v := reflect.ValueOf(&h).Elem().Field(0)
     50 	newval := reflect.New(v.Type().Elem())
     51 	v.Set(newval)
     52 }
     53 
     54 func main() {
     55 	panic("plugin1.main called")
     56 }
     57