Fix preprocessor breakages introduced in rev 12441 which was fixing defined() being expanded outside of #if and #elif preprocessor directives

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12455 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2011-02-12 23:27:50 +00:00
commit 16ba0aca53
4 changed files with 182 additions and 70 deletions

View file

@ -34,3 +34,75 @@ int call_checking(void) {
return checking();
}
%}
/*****************************************************************************/
/* Check #if/#elif defined() macro expansions
Also checks #if/#elif defined() works correctly within macros... this is not
standard C, but is now relied on in the SWIG library. */
/*****************************************************************************/
#define AAA
#define BBB
#define CCC
#if defined(AAA)\
&& defined(BBB) \
&& defined(CCC)
%{
void thing(int i) {}
void stuff(int i) {}
struct Defined {
int defined;
};
void bumpf(int i) {}
%}
#else
#endif
%define ANOTHER_MACRO(TYPE)
#if defined(AAA) && defined(BBB) && defined(CCC)
void thing(TYPE) {}
#else
void thing_not(TYPE) {}
#endif
#if defined(AAA) &&\
defined(BBB) \\
&& defined(CCC)
void stuff(TYPE) {}
#else
void stuff_not(TYPE);
#endif
#if defined(0)
void defined_not(TYPE);
#elif defined(AAA) && defined( BBB ) && defined(CCC)
struct Defined {
int defined;
};
#else
void defined_not(TYPE);
#endif
#if !( defined(AAA) \
defined(BBB) \\
&& defined(CCC) )
void bumpf_not(TYPE);
#else
void bumpf(TYPE) {}
#endif
%enddef
ANOTHER_MACRO(int)
%{
void another_macro_checking(void) {
struct Defined d;
d.defined = 10;
thing(10);
stuff(10);
bumpf(10);
}
%}

View file

@ -2,3 +2,10 @@ import preproc_defined
if preproc_defined.call_checking() != 1:
raise RuntimeError
d = preproc_defined.Defined()
d.defined = 10
preproc_defined.thing(10)
preproc_defined.stuff(10)
preproc_defined.bumpf(10)