Slightly better decltype() support for expressions

decltype now accepts C++ expressions instead of just an ID, such as:

  int i,j;
  ...  decltype(i+j) ...
  ...  decltype(&i) ...

These result in a warning for non-trivial expressions which SWIG cannot evaluate:

  Warning 344: Unable to deduce decltype for 'i+j'.

See 'Type Inference' in CPlusPlus.html for workarounds.

Issue #1589
Issue #1590
This commit is contained in:
William S Fulton 2022-11-26 01:16:20 +00:00
commit 2a1711e436
8 changed files with 85 additions and 14 deletions

View file

@ -9,10 +9,10 @@ a.j = 10
if a.j != 10:
raise RuntimeError("Assignment to a.j failed.")
b = a.foo(5)
b = a.get_int(5)
if b != 10:
raise RuntimeError("foo(5) should return 10.")
raise RuntimeError("get_int(5) should return 10.")
b = a.foo(6)
b = a.get_int(6)
if b != 0:
raise RuntimeError("foo(6) should return 0.")
raise RuntimeError("get_int(6) should return 0.")