Ignore unknown preprocessor directives which are inside an inactive

conditional (github issue #394, reported by Dan Wilcox).
Regression introduced in 3.0.3.
This commit is contained in:
Olly Betts 2015-04-30 13:40:42 +12:00
commit d26a505dad
3 changed files with 24 additions and 1 deletions

View file

@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 3.0.6 (in progress)
===========================
2015-04-30: olly
Ignore unknown preprocessor directives which are inside an inactive
conditional (github issue #394, reported by Dan Wilcox).
Regression introduced in 3.0.3.
2015-04-27: vadz
[Python] Fix "default" typemap used after an argument with "numinputs=0" (#377).

View file

@ -107,3 +107,18 @@ void another_macro_checking(void) {
bumpf(10);
}
%}
/* Check that unknown preprocessor directives are ignored inside an inactive
* conditional (github issue #394).
*/
#ifdef APPLE_OPENGL
# import <OpenGLES/ES1/gl.h>
#endif
#ifdef AAA
# define B
#else
# wibble wibble
#endif
#if 0
# wobble wobble
#endif

View file

@ -1771,7 +1771,10 @@ String *Preprocessor_parse(String *s) {
} else if (Equal(id, "")) {
/* Null directive */
} else {
Swig_error(Getfile(s), Getline(id), "Unknown SWIG preprocessor directive: %s (if this is a block of target language code, delimit it with %%{ and %%})\n", id);
/* Ignore unknown preprocessor directives which are inside an inactive
* conditional (github issue #394). */
if (allow)
Swig_error(Getfile(s), Getline(id), "Unknown SWIG preprocessor directive: %s (if this is a block of target language code, delimit it with %%{ and %%})\n", id);
}
for (i = 0; i < cpp_lines; i++)
Putc('\n', ns);