diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-11-28 03:00:13 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-11-28 03:00:13 -0500 |
| commit | 8d5c4a67a7dfe2e1fc07f84515d59405c4100b5c (patch) | |
| tree | 9e0a7501730d34fd8fe0dafdadb172733008e162 /test | |
| parent | 1ab84a27d374e666463c606dc1cd1c4972b52a74 (diff) | |
| parent | e745544dacc5bda010fc65e5c8b81cb3b5249223 (diff) | |
| download | zig-8d5c4a67a7dfe2e1fc07f84515d59405c4100b5c.tar.gz zig-8d5c4a67a7dfe2e1fc07f84515d59405c4100b5c.zip | |
Merge branch 'dimenus-c-field-expr'
Diffstat (limited to 'test')
| -rw-r--r-- | test/translate_c.zig | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/translate_c.zig b/test/translate_c.zig index 198d813af1..2fe4944de6 100644 --- a/test/translate_c.zig +++ b/test/translate_c.zig @@ -1046,6 +1046,44 @@ pub fn addCases(cases: &tests.TranslateCContext) { \\ return x + 13; \\} ); + + cases.add("macros with field targets", + \\typedef unsigned int GLbitfield; + \\typedef void (*PFNGLCLEARPROC) (GLbitfield mask); + \\typedef void(*OpenGLProc)(void); + \\union OpenGLProcs { + \\ OpenGLProc ptr[1]; + \\ struct { + \\ PFNGLCLEARPROC Clear; + \\ } gl; + \\}; + \\extern union OpenGLProcs glProcs; + \\#define glClearUnion glProcs.gl.Clear + \\#define glClearPFN PFNGLCLEARPROC + , + \\pub const GLbitfield = c_uint; + , + \\pub const PFNGLCLEARPROC = ?extern fn(GLbitfield); + , + \\pub const OpenGLProc = ?extern fn(); + , + \\pub const union_OpenGLProcs = extern union { + \\ ptr: [1]OpenGLProc, + \\ gl: extern struct { + \\ Clear: PFNGLCLEARPROC, + \\ }, + \\}; + , + \\pub extern var glProcs: union_OpenGLProcs; + , + \\pub const glClearPFN = PFNGLCLEARPROC; + , + \\pub inline fn glClearUnion(arg0: GLbitfield) { + \\ (??glProcs.gl.Clear)(arg0) + \\} + , + \\pub const OpenGLProcs = union_OpenGLProcs; + ); cases.add("switch statement with no default", \\int foo(int x) { |
