summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlly Betts <olly@survex.com>2023-05-14 09:27:04 +1200
committerOlly Betts <olly@survex.com>2023-05-14 09:36:54 +1200
commit3f71e41c840ed9d8a3c7fd8754823495095e5cef (patch)
treeb8d1d01213ee8d6f1510db1c389233887dc3203d
parentf187fa9b5dd28ae18f1fa4ed1a901cccc2cdc35d (diff)
downloadswig-template-in-array-size-fix.tar.gz
Add test that `<(`...`)>` in expression is handledtemplate-in-array-size-fix
SWIG uses these internally in type strings so needs to rewrite them when they appear in expressions which get used in a type. This already happens, but really deserves test coverage.
-rw-r--r--Examples/test-suite/cpp11_constexpr.i9
1 files changed, 5 insertions, 4 deletions
diff --git a/Examples/test-suite/cpp11_constexpr.i b/Examples/test-suite/cpp11_constexpr.i
index a77248069..bb14de526 100644
--- a/Examples/test-suite/cpp11_constexpr.i
+++ b/Examples/test-suite/cpp11_constexpr.i
@@ -45,9 +45,7 @@ struct ConstExpressions {
constexpr friend bool operator==(ConstExpressions,ConstExpressions) { return true; }
friend constexpr bool operator!=(ConstExpressions,ConstExpressions) { return false; }
};
-%}
-%{
int Array10[AAA];
int Array20[BBB];
int Array30[CCC()];
@@ -61,9 +59,12 @@ int Array300[ConstExpressions::LLL];
// Regression test for https://github.com/swig/swig/issues/2486 fixed in 4.2.0
// (the array size is constexpr in C++11):
unsigned char myarray[std::numeric_limits<unsigned char>::max()];
-%}
+// Also check that `<(` and `)>` in the expression are handled, since these have
+// special meanings for SWIG's type system. SWIG should rewrite them as `< (`
+// and `) >` here to avoid problems.
+template<int N> constexpr int inc() { return N + 1; };
+unsigned char myarray2[inc<(1)>()];
-%{
// Test handling of ID PERIOD ID in constant expressions (supported since 4.1.0).
struct A {
int i;