Skip to content

Commit 0deb8a8

Browse files
committed
Add another testcase for swig#1384
A string in parentheses could be treated as an integer (depending on the state the stack was left in by previously evaluated expressions).
1 parent 81caed4 commit 0deb8a8

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Examples/test-suite/errors/pp_expressions_bad.i

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,13 @@
4141
#if(1)
4242
#warning Warning okay: #if(1)
4343
#endif
44+
45+
/* The SWIG preprocessor support strings with equality/inequality tests.
46+
* Check error cases.
47+
*/
48+
#if "TWO" == 1
49+
#endif
50+
51+
/* This didn't fail prior with SWIG < 4.1. Github #1384. */
52+
#if 1 == ("TWO")
53+
#endif

Examples/test-suite/errors/pp_expressions_bad.stderr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ pp_expressions_bad.i:30: Error: Extraneous #endif.
1717
pp_expressions_bad.i:32: Error: Unknown SWIG preprocessor directive: if456e (if this is a block of target language code, delimit it with %{ and %})
1818
pp_expressions_bad.i:33: Error: Extraneous #endif.
1919
pp_expressions_bad.i:42: Warning 204: CPP #warning, "Warning okay: #if(1)".
20+
pp_expressions_bad.i:48: Warning 202: Could not evaluate expression '"TWO" == 1'
21+
pp_expressions_bad.i:48: Warning 202: Error: 'Can't mix strings and integers in expression'
22+
pp_expressions_bad.i:52: Warning 202: Could not evaluate expression '1 == ("TWO")'
23+
pp_expressions_bad.i:52: Warning 202: Error: 'Can't mix strings and integers in expression'

0 commit comments

Comments
 (0)