introduce TDF_compare_debug, omit OBJ_TYPE_REF casts with it
[official-gcc.git] / libgo / misc / cgo / test / issue17537.go
blob777104e512209892d4fa856d9d791ad972dc9a35
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.
5 // Issue 17537. The void* cast introduced by cgo to avoid problems
6 // with const/volatile qualifiers breaks C preprocessor macros that
7 // emulate functions.
9 package cgotest
12 #include <stdlib.h>
14 typedef struct {
15 int i;
16 } S17537;
18 int I17537(S17537 *p);
20 #define I17537(p) ((p)->i)
22 // Calling this function used to fail without the cast.
23 const int F17537(const char **p) {
24 return **p;
27 // Calling this function used to trigger an error from the C compiler
28 // (issue 18298).
29 void F18298(const void *const *p) {
32 // Test that conversions between typedefs work as they used to.
33 typedef const void *T18298_1;
34 struct S18298 { int i; };
35 typedef const struct S18298 *T18298_2;
36 void G18298(T18298_1 t) {
39 import "C"
41 import "testing"
43 func test17537(t *testing.T) {
44 v := C.S17537{i: 17537}
45 if got, want := C.I17537(&v), C.int(17537); got != want {
46 t.Errorf("got %d, want %d", got, want)
49 p := (*C.char)(C.malloc(1))
50 *p = 17
51 if got, want := C.F17537(&p), C.int(17); got != want {
52 t.Errorf("got %d, want %d", got, want)
55 C.F18298(nil)
56 var v18298 C.T18298_2
57 C.G18298(C.T18298_1(v18298))