Merge pull request #1111 from ojwb/empty-arglist-macros
Fix handling of macro with empty argument list
This commit is contained in:
commit
59ebe27a95
6 changed files with 68 additions and 24 deletions
|
|
@ -50,9 +50,9 @@
|
|||
%shared_ptr(Space::Bottom3)
|
||||
|
||||
%include "swiginterface.i"
|
||||
SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(SWIGEMPTYHACK, Space::ABase1)
|
||||
SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(SWIGEMPTYHACK, Space::CBase1)
|
||||
SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(SWIGEMPTYHACK, Space::CBase2)
|
||||
SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(, Space::ABase1)
|
||||
SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(, Space::CBase1)
|
||||
SWIG_SHARED_PTR_INTERFACE_TYPEMAPS(, Space::CBase2)
|
||||
%interface_impl(Space::ABase1)
|
||||
%interface_impl(Space::CBase1)
|
||||
%interface_impl(Space::CBase2)
|
||||
|
|
|
|||
|
|
@ -388,3 +388,42 @@ TCX_PACKED (typedef struct tcxMessageBugImpl
|
|||
}) tcxMessageBug;
|
||||
%}
|
||||
|
||||
// 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;
|
||||
}
|
||||
%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue