diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2018-01-05 07:58:25 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2018-01-05 07:58:25 +0000 |
commit | ef378407d064142672ccb55cbff47723a14f162c (patch) | |
tree | 4606bf2226c125d15428f91127d3a4d742b1e10b | |
parent | cd9b7c3c34def07db975a2b706e425afc6500adb (diff) | |
download | swig-ef378407d064142672ccb55cbff47723a14f162c.tar.gz |
Fix parsing of default argument expressions containing ->.
-rw-r--r-- | CHANGES.current | 4 | ||||
-rw-r--r-- | Examples/test-suite/common.mk | 1 | ||||
-rw-r--r-- | Source/CParse/parser.y | 30 |
3 files changed, 33 insertions, 2 deletions
diff --git a/CHANGES.current b/CHANGES.current index ac04b3b29..5e7fbbf6e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-01-05: wsfulton + Fix default arguments using expressions containing -> syntax error. Problem reported on + swig-user mailing list. + 2017-12-30: wsfulton [Python] Replace pep8 with pycodestyle for checking the Python code style when running Python tests. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index db9b13433..d798a6853 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -164,6 +164,7 @@ CPP_TEST_CASES += \ cpp_typedef \ curiously_recurring_template_pattern \ default_args \ + default_arg_expressions \ default_arg_values \ default_constructor \ defvalue_constructor \ diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 857cecd0e..0c8d95ecd 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1604,7 +1604,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier) %type <type> type rawtype type_right anon_bitfield_type decltype ; %type <bases> base_list inherit raw_inherit; %type <dtype> definetype def_args etype default_delete deleted_definition explicit_default; -%type <dtype> expr exprnum exprcompound valexpr; +%type <dtype> expr exprnum exprcompound valexpr exprmem; %type <id> ename ; %type <id> less_valparms_greater; %type <str> type_qualifier; @@ -6266,7 +6266,33 @@ expr : valexpr { $$ = $1; } } ; -valexpr : exprnum { $$ = $1; } +/* simple member access expressions */ +exprmem : ID ARROW ID { + $$.val = NewStringf("%s->%s", $1, $3); + $$.type = 0; + } + | exprmem ARROW ID { + $$ = $1; + Printf($$.val, "->%s", $3); + } +/* This generates a shift-reduce + | ID PERIOD ID { + $$.val = NewStringf("%s.%s", $1, $3); + $$.type = 0; + } +*/ + | exprmem PERIOD ID { + $$ = $1; + Printf($$.val, ".%s", $3); + } + ; + +valexpr : exprnum { + $$ = $1; + } + | exprmem { + $$ = $1; + } | string { $$.val = $1; $$.type = T_STRING; |