1 // Copyright 2013 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.
10 typedef struct foo foo_t;
11 typedef struct bar bar_t;
17 static int transform(int x) { return x; }
22 void fvi(void *p, int x) {}
37 C.malloc(s) // ERROR HERE
40 C.foop = x // ERROR HERE
42 // issue 13129: used to output error about C.unsignedshort with CC=clang
44 x1 = int(0) // ERROR HERE: C\.ushort
47 _ = C.fopen() // ERROR HERE
51 var _ rune = C.transform(x2) // ERROR HERE: C\.int
53 // issue 13635: used to output error about C.unsignedchar.
54 // This test tests all such types.
56 _ C.uchar = "uc" // ERROR HERE: C\.uchar
57 _ C.schar = "sc" // ERROR HERE: C\.schar
58 _ C.ushort = "us" // ERROR HERE: C\.ushort
59 _ C.uint = "ui" // ERROR HERE: C\.uint
60 _ C.ulong = "ul" // ERROR HERE: C\.ulong
61 _ C.longlong = "ll" // ERROR HERE: C\.longlong
62 _ C.ulonglong = "ull" // ERROR HERE: C\.ulonglong
63 _ C.complexfloat = "cf" // ERROR HERE: C\.complexfloat
64 _ C.complexdouble = "cd" // ERROR HERE: C\.complexdouble
68 // cgo converts C void* to Go unsafe.Pointer, so despite appearances C
69 // void** is Go *unsafe.Pointer. This test verifies that we detect the
70 // problem at build time.
75 C.F((**C.v)(unsafe.Pointer(p))) // ERROR HERE
82 _ = C.fvi(1) // ERROR HERE
84 // Issue 16591: Test that we detect an invalid call that was being
85 // hidden by a type conversion inserted by cgo checking.
89 C.fppi(p) // ERROR HERE
94 // typecheck reports at column 14 ('+'), but types2 reports at
96 // TODO(mdempsky): Investigate why, and see if types2 can be
97 // updated to match typecheck behavior.
98 return C.i + 1 // ERROR HERE: \b(10|14)\b
101 // typecheck reports at column 7 ('('), but types2 reports at
102 // column 8 ('i'). The types2 position is more correct, but
103 // updating typecheck here is fundamentally challenging because of
105 C.fi(i) // ERROR HERE: \b(7|8)\b
108 C.fi = C.fi // ERROR HERE