1 // Copyright 2015 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.
5 // cgo rewrote C.var to *_Cvar_var, but left
6 // C.var.field as _Cvar.var.field. It now rewrites
7 // the latter as (*_Cvar_var).field.
8 // See https://golang.org/issue/9557.
12 // struct issue9557_t {
14 // } test9557bar = { 42 };
16 // struct issue9557_t *issue9557foo = &test9557bar;
20 func test9557(t
*testing
.T
) {
21 // implicitly dereference a Go variable
23 if v
:= foo
.a
; v
!= 42 {
24 t
.Fatalf("foo.a expected 42, but got %d", v
)
27 // explicitly dereference a C variable
28 if v
:= (*C
.issue9557foo
).a
; v
!= 42 {
29 t
.Fatalf("(*C.issue9557foo).a expected 42, but is %d", v
)
32 // implicitly dereference a C variable
33 if v
:= C
.issue9557foo
.a
; v
!= 42 {
34 t
.Fatalf("C.issue9557foo.a expected 42, but is %d", v
)