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
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) {
27 // Calling this function used to trigger an error from the C compiler
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) {
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))
51 if got
, want
:= C
.F17537(&p
), C
.int(17); got
!= want
{
52 t
.Errorf("got %d, want %d", got
, want
)
57 C
.G18298(C
.T18298_1(v18298
))