Fix #1940536, overactive preprocessor which was expanding defined(...) outside of #if and #elif preprocessor directives.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12441 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2011-02-07 07:29:55 +00:00
commit 63af0a2d72
5 changed files with 54 additions and 4 deletions

View file

@ -493,6 +493,7 @@ C_TEST_CASES += \
overload_extendc \
preproc \
preproc_constants_c \
preproc_defined \
preproc_line_file \
ret_by_value \
simple_array \

View file

@ -0,0 +1,36 @@
%module preproc_defined
// Check 'defined' passes through the preprocessor without being processed like '#if defined(ABC)' would be (SF bug #1940536)
%define DEFINED_MACRO
%{
int defined(int b) {
return b > 10;
}
int vvv = -1;
void fn(int val) {
if (defined(val))
vvv = 1;
else
vvv = 0;
}
%}
%enddef
DEFINED_MACRO
%{
int checking(void) {
fn(11);
int okay = (vvv == 1);
fn(9);
okay = okay && (vvv == 0);
return okay; /* should be 1 */
}
%}
%inline %{
int call_checking(void) {
return checking();
}
%}

View file

@ -0,0 +1,4 @@
import preproc_defined
if preproc_defined.call_checking() != 1:
raise RuntimeError