introduce TDF_compare_debug, omit OBJ_TYPE_REF casts with it
[official-gcc.git] / libgo / misc / cgo / test / issue9557.go
blob4e8922a69c60c88caf6468fa291ffae72dc1d01c
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.
10 package cgotest
12 // struct issue9557_t {
13 // int a;
14 // } test9557bar = { 42 };
16 // struct issue9557_t *issue9557foo = &test9557bar;
17 import "C"
18 import "testing"
20 func test9557(t *testing.T) {
21 // implicitly dereference a Go variable
22 foo := C.issue9557foo
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)