diff options
Diffstat (limited to 'cgo/testdata')
-rw-r--r-- | cgo/testdata/const.go | 13 | ||||
-rw-r--r-- | cgo/testdata/const.out.go | 3 | ||||
-rw-r--r-- | cgo/testdata/errors.go | 8 | ||||
-rw-r--r-- | cgo/testdata/errors.out.go | 4 |
4 files changed, 28 insertions, 0 deletions
diff --git a/cgo/testdata/const.go b/cgo/testdata/const.go index 258942235..d5a7dfd39 100644 --- a/cgo/testdata/const.go +++ b/cgo/testdata/const.go @@ -3,13 +3,26 @@ package main /* #define foo 3 #define bar foo + #define unreferenced 4 #define referenced unreferenced + +#define fnlike() 5 +#define fnlike_val fnlike() +#define square(n) (n*n) +#define square_val square(20) +#define add(a, b) (a + b) +#define add_val add(3, 5) */ import "C" const ( Foo = C.foo Bar = C.bar + Baz = C.referenced + + fnlike = C.fnlike_val + square = C.square_val + add = C.add_val ) diff --git a/cgo/testdata/const.out.go b/cgo/testdata/const.out.go index fb0bbeeba..e7ee15380 100644 --- a/cgo/testdata/const.out.go +++ b/cgo/testdata/const.out.go @@ -49,3 +49,6 @@ const C.foo = 3 const C.bar = C.foo const C.unreferenced = 4 const C.referenced = C.unreferenced +const C.fnlike_val = 5 +const C.square_val = (20 * 20) +const C.add_val = (3 + 5) diff --git a/cgo/testdata/errors.go b/cgo/testdata/errors.go index e5e809881..75828ce0f 100644 --- a/cgo/testdata/errors.go +++ b/cgo/testdata/errors.go @@ -26,6 +26,11 @@ import "C" // #warning another warning import "C" +// #define add(a, b) (a+b) +// #define add_toomuch add(1, 2, 3) +// #define add_toolittle add(1) +import "C" + // Make sure that errors for the following lines won't change with future // additions to the CGo preamble. // @@ -51,4 +56,7 @@ var ( // constants passed by a command line parameter _ = C.SOME_PARAM_CONST_invalid _ = C.SOME_PARAM_CONST_valid + + _ = C.add_toomuch + _ = C.add_toolittle ) diff --git a/cgo/testdata/errors.out.go b/cgo/testdata/errors.out.go index 43a6a65c9..baadba68d 100644 --- a/cgo/testdata/errors.out.go +++ b/cgo/testdata/errors.out.go @@ -7,6 +7,8 @@ // testdata/errors.go:16:33: unexpected token ), expected end of expression // testdata/errors.go:17:34: unexpected token ), expected end of expression // -: unexpected token INT, expected end of expression +// testdata/errors.go:30:35: unexpected number of parameters: expected 2, got 3 +// testdata/errors.go:31:31: unexpected number of parameters: expected 2, got 1 // Type checking errors after CGo processing: // testdata/errors.go:102: cannot use 2 << 10 (untyped int constant 2048) as C.char value in variable declaration (overflows) @@ -17,6 +19,8 @@ // testdata/errors.go:114: undefined: C.SOME_CONST_b // testdata/errors.go:116: undefined: C.SOME_CONST_startspace // testdata/errors.go:119: undefined: C.SOME_PARAM_CONST_invalid +// testdata/errors.go:122: undefined: C.add_toomuch +// testdata/errors.go:123: undefined: C.add_toolittle package main |