Commit Graph

10 Commits

Author SHA1 Message Date
William S Fulton 56b768f258 Fix -Wunused-variable warnings in testcases 2025-06-21 23:24:42 +01:00
Olly Betts ada653aaf0 Suppress unhelpful GCC/clang warnings in new tests 2024-10-27 15:04:52 +13:00
Olly Betts 4e315cdd7c Fix precedence of casts
Casts should have the same high precedence as unary plus and minus, but
actually had a lower precedence than anything else.

This could lead to the wrong type being deduced in obscure cases, but
also prevented SWIG deducing a type for expressions such as (0)*1+2
which SWIG parses as a cast and then fixes up afterwards.

A bug fixed in 4.3.0 made this latter problem manifest more often
(previously type deduction happened to work for (0)*1+2 due to an
internal field not getting cleared properly).

Fixes #3058
2024-10-27 10:02:11 +13:00
Olly Betts 7a8c9fdfa8 Straighten out handling of char and string constants
Fixes #904
Fixes #1907
Fixes #2579
Fixes #2990
2024-08-17 16:12:45 +12:00
Olly Betts 3452d08cd8 Support parsing `noexcept(X)` in expressions
Missing C++11 feature.
2024-07-26 12:31:44 +12:00
Olly Betts 3a6d124751 Extend type deduction
SWIG can now deduce the type of an expression including variables, and
the deduced type for unary & is now correct (it was the type of the
subexpression & was applied to).
2023-12-04 17:10:30 +13:00
Olly Betts 997616e652 Improve type deduction
Create a new T_UNKNOWN type code and use this for the cases where
we previously abused T_INT.  This means we can now reliably deduce
`int` when we see T_INT.

Fix the deduced result types of unary plus and unary minus which weren't
getting integer promotion applied to them.

Fix the deduced result type of the C++ logical not operator which was
`int` but should be `bool`.
2023-11-18 18:27:29 +13:00
William S Fulton c074c6a63a auto type warning improvements
WARN_CPP11_AUTO and WARN_CPP14_AUTO warning message tweaks.
Add the ignored variable to the parse tree so that the explicit warning
features work for WARN_CPP11_AUTO.
2023-06-10 18:17:55 +01:00
Olly Betts 7ba44dc62d Support deducing type of some expressions
This change only supports expressions involving literals of built-in
types, and `int` expressions aren't supported (due to the parser
currently setting .type=T_INT when in situations where that isn't
or may not be the correct type).
2023-05-25 11:50:47 +12:00
Olly Betts 6ad80c25ba Support parsing C++11 auto variables
This uses the existing type deduction code from decltype so has the same
limitations, and such variables will only actually be wrapped when SWIG
can deduce the type.

Fixes #1125
2023-05-25 10:31:22 +12:00