[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:
parent
46f7217c50
commit
a92137a708
4 changed files with 24 additions and 8 deletions
|
|
@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
||||||
Version 4.0.0 (in progress)
|
Version 4.0.0 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2017-08-05: olly
|
||||||
|
[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.
|
||||||
|
|
||||||
2017-07-17: fflexo
|
2017-07-17: fflexo
|
||||||
[Java] #674 Add std_list.i to add support for std::list containers. The Java proxy
|
[Java] #674 Add std_list.i to add support for std::list containers. The Java proxy
|
||||||
extends java.util.AbstractSequentialList and makes the C++ std::list container look
|
extends java.util.AbstractSequentialList and makes the C++ std::list container look
|
||||||
|
|
|
||||||
|
|
@ -877,7 +877,8 @@ so in this case it is entirely possible to pass an int instead of a double to <t
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
SWIG correctly parses the new <tt>static_assert</tt> declarations.
|
SWIG correctly parses the new <tt>static_assert</tt> declarations (though 3.0.12 and earlier
|
||||||
|
had a bug which meant this wasn't accepted at file scope).
|
||||||
This is a C++ compile time directive so there isn't anything useful that SWIG can do with it.
|
This is a C++ compile time directive so there isn't anything useful that SWIG can do with it.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,22 @@
|
||||||
/* This test case checks whether SWIG correctly parses and ignores the
|
/* This test case checks whether SWIG correctly parses and ignores
|
||||||
keywords "static_assert()" inside the class or struct.
|
"static_assert()" in various places.
|
||||||
*/
|
*/
|
||||||
%module cpp11_static_assert
|
%module cpp11_static_assert
|
||||||
|
|
||||||
%inline %{
|
%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>
|
template <typename T>
|
||||||
struct Check1 {
|
struct Check1 {
|
||||||
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||||
|
Check1() {
|
||||||
|
static_assert(true);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
||||||
|
|
@ -2991,6 +2991,9 @@ c_declaration : c_decl {
|
||||||
SetFlag($$,"aliastemplate");
|
SetFlag($$,"aliastemplate");
|
||||||
add_symbols($$);
|
add_symbols($$);
|
||||||
}
|
}
|
||||||
|
| cpp_static_assert {
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
/* ------------------------------------------------------------
|
/* ------------------------------------------------------------
|
||||||
|
|
@ -4209,9 +4212,6 @@ cpp_temp_possible: c_decl {
|
||||||
| cpp_constructor_decl {
|
| cpp_constructor_decl {
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
| cpp_static_assert {
|
|
||||||
$$ = $1;
|
|
||||||
}
|
|
||||||
| cpp_template_decl {
|
| cpp_template_decl {
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -4469,7 +4469,6 @@ cpp_member : c_declaration { $$ = $1; }
|
||||||
default_arguments($$);
|
default_arguments($$);
|
||||||
}
|
}
|
||||||
| cpp_destructor_decl { $$ = $1; }
|
| cpp_destructor_decl { $$ = $1; }
|
||||||
| cpp_static_assert { $$ = $1; }
|
|
||||||
| cpp_protection_decl { $$ = $1; }
|
| cpp_protection_decl { $$ = $1; }
|
||||||
| cpp_swig_directive { $$ = $1; }
|
| cpp_swig_directive { $$ = $1; }
|
||||||
| cpp_conversion_operator { $$ = $1; }
|
| cpp_conversion_operator { $$ = $1; }
|
||||||
|
|
@ -4673,7 +4672,8 @@ cpp_catch_decl : CATCH LPAREN parms RPAREN LBRACE {
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
/* static_assert(bool, const char*); */
|
/* static_assert(bool, const char*); (C++11)
|
||||||
|
* static_assert(bool); (C++17) */
|
||||||
cpp_static_assert : STATIC_ASSERT LPAREN {
|
cpp_static_assert : STATIC_ASSERT LPAREN {
|
||||||
skip_balanced('(',')');
|
skip_balanced('(',')');
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue