Commit Graph

13 Commits

Author SHA1 Message Date
Olly Betts 3f4ed82945 Improve parsing of expressions related to functions calls
For example, the following no longer give parse errors:  `g().d()`,
`g().D`, `(f(1) < g(2))`, `sizeof f(a,b)`

Partly addresses #3197
2025-06-17 14:59:54 +12:00
Olly Betts 6dbf867d23 Fix handling of corner cases by previous change
Don't collapse runs of whitespace to a single space, instead replace
each whitespace with one space.

Leave the expression as-is if it contains one or more double quotes
as we don't want to change the value of string literals, and any
expression containing double quotes won't currently work in the context
where we need to replace newlines anyway.

Fixes #3127 better
2025-03-03 11:22:37 +13:00
Olly Betts 6eb2560e8d Stop removing `f` and `F` suffixes from float literals
This was resulting in incorrect generated C# and Java code.  For
some cases such as `#define CONSTANT 1.0f` this was a regression
introduced in 4.2.0 when we started more correctly wrapping these
as `float` rather than `double`.

Fixes #1917
2024-07-18 16:03:31 +12:00
Olly Betts 57ed628035 Improve parsing of sizeof(X)
Support parsing `sizeof(X)` for any expression or type X by skipping
balanced parentheses.  We don't need to actually parse X since the type
of sizeof is always size_t.

Fixes #2919
2024-06-06 10:36:12 +12:00
Olly Betts ed30a80d7f [php] Add runme for testcase constant_expr 2024-02-26 12:45:45 +13:00
William S Fulton afc75aef34 Visual C++ warning suppression 2023-12-30 21:11:02 +00:00
William S Fulton daeaa6ab11 Visual C++ warning fixes 2023-12-30 13:49:40 +00:00
Olly Betts 0ea0c8ccc8 Only suppress -Wbool-compare for GCC >= 5 2023-11-19 22:25:39 +13:00
Olly Betts f50cea31e0 Suppress -Wbool-comapre warnings in constant_expr_c testcase
We're deliberately testing constant expressions contains comparisons
here.
2023-11-19 21:45:30 +13:00
Olly Betts d506235a6d Fix testcase addition in previous commit 2023-11-19 21:15:46 +13:00
Olly Betts 967dd4e5c1 Fix dropping of parentheses around < and > expressions
We were dropping parentheses in these cases, which can change the value
of the expression.
2023-11-19 16:28:13 +13:00
Olly Betts 7ab24e7e86 Support most cases of sizeof applied to an expression
Previously there was only support for `sizeof(<type>)` and expressions
which syntactically look like a type (such as `sizeof(foo)`).

Fixes #2091.
2022-01-25 23:47:01 +13:00
Olly Betts f2de21eb83 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/
2022-01-25 14:09:41 +13:00