Added support for C++0x static_assert().
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@11369 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ee8bebb668
commit
72708ea173
4 changed files with 34 additions and 2 deletions
|
|
@ -402,7 +402,8 @@ CPP_TEST_CASES += \
|
||||||
CPP0X_TEST_CASES = \
|
CPP0X_TEST_CASES = \
|
||||||
cpp0x_template_double_brackets \
|
cpp0x_template_double_brackets \
|
||||||
cpp0x_explicit_conversion_operators \
|
cpp0x_explicit_conversion_operators \
|
||||||
cpp0x_raw_string_literals
|
cpp0x_raw_string_literals \
|
||||||
|
cpp0x_static_assert
|
||||||
# cpp0x_constexpr # not supported by any compilers yet
|
# cpp0x_constexpr # not supported by any compilers yet
|
||||||
|
|
||||||
# Broken C++0x test cases.
|
# Broken C++0x test cases.
|
||||||
|
|
|
||||||
17
Examples/test-suite/cpp0x_static_assert.i
Normal file
17
Examples/test-suite/cpp0x_static_assert.i
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
/* This test case checks whether swig correctly parses and ignores the
|
||||||
|
keywords "static_assert()" inside the class or struct.
|
||||||
|
*/
|
||||||
|
%module static_assert
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
template <typename T>
|
||||||
|
struct Check1 {
|
||||||
|
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class Check2 {
|
||||||
|
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
@ -634,6 +634,8 @@ int yylex(void) {
|
||||||
return (CONSTEXPR);
|
return (CONSTEXPR);
|
||||||
if (strcmp(yytext, "virtual") == 0)
|
if (strcmp(yytext, "virtual") == 0)
|
||||||
return (VIRTUAL);
|
return (VIRTUAL);
|
||||||
|
if (strcmp(yytext, "static_assert") == 0)
|
||||||
|
return (STATIC_ASSERT);
|
||||||
if (strcmp(yytext, "operator") == 0) {
|
if (strcmp(yytext, "operator") == 0) {
|
||||||
int nexttok;
|
int nexttok;
|
||||||
String *s = NewString("operator ");
|
String *s = NewString("operator ");
|
||||||
|
|
|
||||||
|
|
@ -1493,6 +1493,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
|
||||||
%token NAME RENAME NAMEWARN EXTEND PRAGMA FEATURE VARARGS
|
%token NAME RENAME NAMEWARN EXTEND PRAGMA FEATURE VARARGS
|
||||||
%token ENUM
|
%token ENUM
|
||||||
%token CLASS TYPENAME PRIVATE PUBLIC PROTECTED COLON STATIC VIRTUAL FRIEND THROW CATCH EXPLICIT CONSTEXPR
|
%token CLASS TYPENAME PRIVATE PUBLIC PROTECTED COLON STATIC VIRTUAL FRIEND THROW CATCH EXPLICIT CONSTEXPR
|
||||||
|
%token STATIC_ASSERT
|
||||||
%token USING
|
%token USING
|
||||||
%token <node> NAMESPACE
|
%token <node> NAMESPACE
|
||||||
%token NATIVE INLINE
|
%token NATIVE INLINE
|
||||||
|
|
@ -1539,7 +1540,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
|
||||||
/* C++ declarations */
|
/* C++ declarations */
|
||||||
%type <node> cpp_declaration cpp_class_decl cpp_forward_class_decl cpp_template_decl;
|
%type <node> cpp_declaration cpp_class_decl cpp_forward_class_decl cpp_template_decl;
|
||||||
%type <node> cpp_members cpp_member;
|
%type <node> cpp_members cpp_member;
|
||||||
%type <node> cpp_constructor_decl cpp_destructor_decl cpp_protection_decl cpp_conversion_operator;
|
%type <node> cpp_constructor_decl cpp_destructor_decl cpp_protection_decl cpp_conversion_operator cpp_static_assert;
|
||||||
%type <node> cpp_swig_directive cpp_temp_possible cpp_nested cpp_opt_declarators ;
|
%type <node> cpp_swig_directive cpp_temp_possible cpp_nested cpp_opt_declarators ;
|
||||||
%type <node> cpp_using_decl cpp_namespace_decl cpp_catch_decl ;
|
%type <node> cpp_using_decl cpp_namespace_decl cpp_catch_decl ;
|
||||||
%type <node> kwargs options;
|
%type <node> kwargs options;
|
||||||
|
|
@ -3864,6 +3865,9 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
@ -4110,6 +4114,7 @@ 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; }
|
||||||
|
|
@ -4281,6 +4286,13 @@ cpp_catch_decl : CATCH LPAREN parms RPAREN LBRACE {
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
/* static_assert(bool, const char*); */
|
||||||
|
cpp_static_assert : STATIC_ASSERT LPAREN {
|
||||||
|
skip_balanced('(',')');
|
||||||
|
$$ = 0;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
/* public: */
|
/* public: */
|
||||||
cpp_protection_decl : PUBLIC COLON {
|
cpp_protection_decl : PUBLIC COLON {
|
||||||
$$ = new_node("access");
|
$$ = new_node("access");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue