diff options
author | Julien Marrec <julien.marrec@gmail.com> | 2022-07-08 15:23:05 +1200 |
---|---|---|
committer | Olly Betts <olly@survex.com> | 2022-07-08 15:27:02 +1200 |
commit | d3759a9b36be36af5a7e01bf5853143dece4980f (patch) | |
tree | 5f91ff5f4cf5481478513e0ee0cc409b8b4ab13f /Source/CParse | |
parent | 5a96a39aa48fe35fa0bd0b92f5fb5615447ea6e8 (diff) | |
download | swig-d3759a9b36be36af5a7e01bf5853143dece4980f.tar.gz |
Avoid parse errors for C++ attributes
Just ignore anything in between [[ and ]] in the scanner, which is better
that failing with a parse error.
Fixes #1158
Fixes #2286
Diffstat (limited to 'Source/CParse')
-rw-r--r-- | Source/CParse/cscanner.c | 12 | ||||
-rw-r--r-- | Source/CParse/parser.y | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 155c7c81b..75f100d1c 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -354,6 +354,18 @@ static int yylook(void) { case SWIG_TOKEN_ELLIPSIS: return ELLIPSIS; + case SWIG_TOKEN_LLBRACKET: + do { + tok = Scanner_token(scan); + } while ((tok != SWIG_TOKEN_RRBRACKET) && (tok > 0)); + if (tok <= 0) { + Swig_error(cparse_file, cparse_line, "Unbalanced double brackets, missing closing (']]'). Reached end of input.\n"); + } + break; + + case SWIG_TOKEN_RRBRACKET: + return RRBRACKET; + /* Look for multi-character sequences */ case SWIG_TOKEN_RSTRING: diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index ddb9634b2..010df3c1c 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1613,6 +1613,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier) %token <type> TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_WCHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW TYPE_NON_ISO_INT8 TYPE_NON_ISO_INT16 TYPE_NON_ISO_INT32 TYPE_NON_ISO_INT64 %token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD ELLIPSIS %token CONST_QUAL VOLATILE REGISTER STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET +%token LLBRACKET RRBRACKET /* C++11 Attribute specifier sequence */ %token BEGINFILE ENDOFFILE %token ILLEGAL CONSTANT %token NAME RENAME NAMEWARN EXTEND PRAGMA FEATURE VARARGS |