[C++11] Allow static_assert at the top level

And disallow it right after template<T>).

Fixes https://github.com/swig/swig/issues/1031 reported by Artem V L.
This commit is contained in:
Olly Betts 2017-08-04 14:09:30 +12:00
commit a92137a708
4 changed files with 24 additions and 8 deletions

View file

@ -1,12 +1,22 @@
/* This test case checks whether SWIG correctly parses and ignores the
keywords "static_assert()" inside the class or struct.
/* This test case checks whether SWIG correctly parses and ignores
"static_assert()" in various places.
*/
%module cpp11_static_assert
%inline %{
static_assert(sizeof(int) >= 2, "What? int size is invalid!");
namespace dummy {
// C++17 allows the message to be omitted, so check that works too.
static_assert(sizeof(int) >= sizeof(short));
}
template <typename T>
struct Check1 {
static_assert(sizeof(int) <= sizeof(T), "not big enough");
Check1() {
static_assert(true);
}
};
template <typename T>