Parse common cases of < and > comparisons

Adding full support for these in expressions seems hard to do without
introducing conflicts into the parser grammar, but in fact all reported
cases have had parentheses around the comparison and we can support that
with a few restrictions on the left side of `<`.

Fixes #80 and #635.  Also https://sourceforge.net/p/swig/bugs/1139/
This commit is contained in:
Olly Betts 2021-09-29 17:51:02 +13:00
commit f2de21eb83
14 changed files with 98 additions and 20 deletions

View file

@ -1,11 +1,17 @@
%module constant_expr;
/* Tests of constant expressions. */
/* Tests of constant expressions (C++ version). */
%include "constant_expr_c.i"
%inline %{
/* % didn't work in SWIG 1.3.40 and earlier. */
const int X = 123%7;
#define FOO 12 % 9
double d_array[12 % 9];
// Testcase from https://sourceforge.net/p/swig/bugs/1139/
template<typename Tp>
struct SizeInfo {
enum {
isLarge = (sizeof(Tp)>sizeof(void*)),
isPointer = false
};
};
%}