From 93d58cd3ed1cc2cf0490e95d43eed4e8de62763d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Dec 2014 16:56:31 +0000 Subject: [PATCH] Fix use of preprocessor null directive This was broken recently in commit 255c929c5636f54c16261bd92b8eea2005d61b11 for issue #217 --- Examples/test-suite/preproc.i | 17 +++++++++++++++++ Examples/test-suite/python/preproc_runme.py | 2 ++ Source/Preprocessor/cpp.c | 2 ++ 3 files changed, 21 insertions(+) diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i index e052bff28..779c41e97 100644 --- a/Examples/test-suite/preproc.i +++ b/Examples/test-suite/preproc.i @@ -346,3 +346,20 @@ int method(struct TypeNameTraits tnt) { return tnt.val; } %} + +/* Null directive */ +# /* comment 1 */ +# // comment 2 +# /** comment 3 */ +# /* comment 4 */ /*comment 5*/ +# /** comment 6 +# +# more comment 6 */ +# +# +# +int methodX(int x); +%{ +int methodX(int x) { return x+100; } +%} + diff --git a/Examples/test-suite/python/preproc_runme.py b/Examples/test-suite/python/preproc_runme.py index c989294b6..3049f00ab 100644 --- a/Examples/test-suite/python/preproc_runme.py +++ b/Examples/test-suite/python/preproc_runme.py @@ -12,3 +12,5 @@ if preproc.defined != 1: if 2*preproc.one != preproc.two: raise RuntimeError +if preproc.methodX(99) != 199: + raise RuntimeError diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 1ca549703..b556bce27 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -1768,6 +1768,8 @@ String *Preprocessor_parse(String *s) { } } else if (Equal(id, kpp_level)) { Swig_error(Getfile(s), Getline(id), "cpp debug: level = %d, startlevel = %d\n", level, start_level); + } else if (Equal(id, "")) { + /* Null directive */ } else { Swig_error(Getfile(s), Getline(id), "Unknown SWIG preprocessor directive: %s\n", id); }