Add test coverage for #error and #warning

This replaces and extends the coverage lost by the removal of
errors testcase pp_deprecated.

See #2635
This commit is contained in:
Olly Betts 2023-06-15 09:20:24 +12:00
parent 736c052d7d
commit 365a540fdb
3 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,9 @@
%module xxx
#warning Print this warning
#error This is an error
#error Another error
#warning Another warning

View File

@ -0,0 +1,4 @@
pp_error_directive.i:3: Warning 204: CPP #warning, "Print this warning".
pp_error_directive.i:5: Error: CPP #error "This is an error". Use the -cpperraswarn option to continue swig processing.
pp_error_directive.i:7: Error: CPP #error "Another error". Use the -cpperraswarn option to continue swig processing.
pp_error_directive.i:9: Warning 204: CPP #warning, "Another warning".

View File

@ -124,6 +124,33 @@ void another_macro_checking(void) {
# wobble wobble
#endif
/* Check that #error is ignored inside an inactive conditional. */
#ifdef THIS_IS_NOT_DEFINED
# error should not trigger 1
#endif
#ifdef AAA
# define B
#else
# error should not trigger 2
#endif
#if 0
# error should not trigger 3
#endif
/* Check that #warning is ignored inside an inactive conditional. */
#ifdef THIS_IS_NOT_DEFINED
# warning should not trigger 1
#endif
#ifdef AAA
# define B
#else
# warning should not trigger 2
#endif
#if 0
# warning should not trigger 3
#endif
/* Regression test for https://sourceforge.net/p/swig/bugs/1163/
* ONE(1)(2) should expand to `2` but SWIG was expanding it to `TWO(2)`
* which results in the generated C wrapper failing to compile.