Source file src/cmd/cgo/internal/testshared/testdata/depBase/dep.go

     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 depBase
     6  
     7  import (
     8  	"os"
     9  	"reflect"
    10  
    11  	"testshared/depBaseInternal"
    12  )
    13  
    14  // Issue 61973: indirect dependencies are not initialized.
    15  func init() {
    16  	if !depBaseInternal.Initialized {
    17  		panic("depBaseInternal not initialized")
    18  	}
    19  	if os.Stdout == nil {
    20  		panic("os.Stdout is nil")
    21  	}
    22  
    23  	Initialized = true
    24  }
    25  
    26  var Initialized bool
    27  
    28  var SlicePtr interface{} = &[]int{}
    29  
    30  var V int = 1
    31  
    32  var HasMask []string = []string{"hi"}
    33  
    34  type HasProg struct {
    35  	array [1024]*byte
    36  }
    37  
    38  type Dep struct {
    39  	X int
    40  }
    41  
    42  func (d *Dep) Method() int {
    43  	// This code below causes various go.itab.* symbols to be generated in
    44  	// the shared library. Similar code in ../exe/exe.go results in
    45  	// exercising https://golang.org/issues/17594
    46  	reflect.TypeOf(os.Stdout).Elem()
    47  	return 10
    48  }
    49  
    50  func F() int {
    51  	defer func() {}()
    52  	return V
    53  }
    54  
    55  func H() {
    56  	// Issue 67635: deadcoded closures causes linker crash.
    57  	func() { F() }()
    58  }
    59  

View as plain text