Add another testcase for #1384

A string in parentheses could be treated as an integer (depending on
the state the stack was left in by previously evaluated expressions).
This commit is contained in:
Olly Betts 2022-02-24 08:30:32 +13:00
commit 0deb8a855d
2 changed files with 14 additions and 0 deletions

View file

@ -41,3 +41,13 @@
#if(1)
#warning Warning okay: #if(1)
#endif
/* The SWIG preprocessor support strings with equality/inequality tests.
* Check error cases.
*/
#if "TWO" == 1
#endif
/* This didn't fail prior with SWIG < 4.1. Github #1384. */
#if 1 == ("TWO")
#endif

View file

@ -17,3 +17,7 @@ pp_expressions_bad.i:30: Error: Extraneous #endif.
pp_expressions_bad.i:32: Error: Unknown SWIG preprocessor directive: if456e (if this is a block of target language code, delimit it with %{ and %})
pp_expressions_bad.i:33: Error: Extraneous #endif.
pp_expressions_bad.i:42: Warning 204: CPP #warning, "Warning okay: #if(1)".
pp_expressions_bad.i:48: Warning 202: Could not evaluate expression '"TWO" == 1'
pp_expressions_bad.i:48: Warning 202: Error: 'Can't mix strings and integers in expression'
pp_expressions_bad.i:52: Warning 202: Could not evaluate expression '1 == ("TWO")'
pp_expressions_bad.i:52: Warning 202: Error: 'Can't mix strings and integers in expression'