diff options
Diffstat (limited to 'Examples/test-suite/preproc.i')
-rw-r--r-- | Examples/test-suite/preproc.i | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i index f236bfdff..215fdd0ef 100644 --- a/Examples/test-suite/preproc.i +++ b/Examples/test-suite/preproc.i @@ -16,8 +16,16 @@ //Suppress: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand] #pragma clang diagnostic ignored "-Wconstant-logical-operand" #endif +#if defined(_MSC_VER) + #pragma warning(disable: 4003) // not enough actual parameters for macro 'FOO2' +#endif %} +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) method; +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + /* check __cplusplus case */ %header %{ @@ -370,3 +378,75 @@ int methodX(int x); int methodX(int x) { return x+100; } %} +// Comma in macro - https://github.com/swig/swig/issues/974 (for /* */) +// and https://github.com/swig/swig/pull/1166 (for //) +%inline %{ +#define swig__attribute__(x) +#define TCX_PACKED(d) d swig__attribute__ ((__packed__)) + + +TCX_PACKED (typedef struct tcxMessageTestImpl +{ + int mHeader; /**< comment */ +}) tcxMessageTest; + + +TCX_PACKED (typedef struct tcxMessageBugImpl +{ + int mBid; /**< Bid price and size, check PresentMap if available in message */ +}) tcxMessageBug; + + +TCX_PACKED (typedef struct tcxMessageTestImpl2 +{ + int mHeader; ///< comment +}) tcxMessageTest2; + + +TCX_PACKED (typedef struct tcxMessageBugImpl2 +{ + int mBid; ///< Bid price and size, check PresentMap if available in message +}) tcxMessageBug2; + + +%} + +// Regression tests for https://github.com/swig/swig/pull/1111 +%{ +static int foo_func(int x) { return x; } +static int foo_func2() { return 0; } +static int bar_func() { return 0; } +static int baz_func(int a, int b, int c) { return a + b - c; } +%} +%inline %{ +#define FOO(X) int foo_func(X); +#define FOO2(X) int foo_func2(X); +#define BAR() int bar_func(); +#define BAR2() int bar_func2() +#define BAZ(A,B,C) baz_func(A+0,B,C) +#define FOOVAR(...) foo_func(__VA_ARGS__) +#define BARVAR(...) bar_func(__VA_ARGS__) +#define BAZVAR(...) baz_func(__VA_ARGS__) +// This has probably always worked, but make sure that the fix to accept +// an empty X doesn't cause this case to be incorrectly expanded: +const int FOO = 7; +// BAR was incorrectly expanded here, causing: +// Error: Syntax error in input(1). +const int BAR = 6; +// This has probably always worked, but make sure that the fix to accept +// an empty X doesn't stop a non-empty X from working: +FOO(int x) +// FOO() didn't used to get expanded here, causing: +// Syntax error in input(1). +FOO2() +// Check BAR2() still gets expanded here. +BAR2() { + // Regression test - this used to fail with: + // Error: Macro 'BAZ' expects 3 arguments + BAZ(,2,3); + BARVAR(); + FOOVAR(1); + BAZVAR(1,2,3); + return 0; +} +%} |