diff options
-rw-r--r-- | CHANGES.current | 4 | ||||
-rw-r--r-- | Examples/test-suite/default_arg_expressions.i | 4 | ||||
-rw-r--r-- | Source/CParse/parser.y | 8 |
3 files changed, 11 insertions, 5 deletions
diff --git a/CHANGES.current b/CHANGES.current index e268b30ea..ba8bc36ef 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.2.0 (in progress) =========================== +2022-11-25: olly + #2447 Fix undefined behaviour in swig's parser when handling + default parameter expressions containing method calls. + 2022-11-22: wsfulton #1037 Fix seg fault handling template parameter expressions containing '<=' or '>='. diff --git a/Examples/test-suite/default_arg_expressions.i b/Examples/test-suite/default_arg_expressions.i index 99d54c3b9..ce4d3f4a1 100644 --- a/Examples/test-suite/default_arg_expressions.i +++ b/Examples/test-suite/default_arg_expressions.i @@ -29,7 +29,7 @@ struct TfToken { struct Tokens { const TfToken face; const TfToken *pface; - const TfToken& g_face() const { return face; } + const TfToken& g_face(int = 0, int = 0) const { return face; } const TfToken* g_pface() const { return pface; } Tokens() : face(), pface(&face) {} }; @@ -68,4 +68,6 @@ void CreateMaterialBindSubsetu(int num = UsdGeomTokensPtr->g_pface()->g_val().g_ void CreateMaterialBindSubsetv(int num = UsdGeomTokensPtr->g_pface()->g_ptr()->g_val()) {} void CreateMaterialBindSubsetw(int num = UsdGeomTokensPtr->g_face().g_val().g_val()) {} void CreateMaterialBindSubsetx(int num = UsdGeomTokens.g_face().g_val().g_val()) {} +void CreateMaterialBindSubsety(int num = UsdGeomTokens.g_face(1).g_val().g_val()) {} +void CreateMaterialBindSubsetz(int num = UsdGeomTokens.g_face(1,2).g_val().g_val()) {} %} diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 61fac2b2e..7b5df73ee 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -6582,7 +6582,7 @@ exprmem : ID ARROW ID { $$.type = 0; } | ID ARROW ID LPAREN callparms RPAREN { - $$.val = NewStringf("%s->%s(%s)", $1, $3, $5); + $$.val = NewStringf("%s->%s(%s)", $1, $3, $5.val); $$.type = 0; } | exprmem ARROW ID { @@ -6591,14 +6591,14 @@ exprmem : ID ARROW ID { } | exprmem ARROW ID LPAREN callparms RPAREN { $$ = $1; - Printf($$.val, "->%s(%s)", $3, $5); + Printf($$.val, "->%s(%s)", $3, $5.val); } | ID PERIOD ID { $$.val = NewStringf("%s.%s", $1, $3); $$.type = 0; } | ID PERIOD ID LPAREN callparms RPAREN { - $$.val = NewStringf("%s.%s(%s)", $1, $3, $5); + $$.val = NewStringf("%s.%s(%s)", $1, $3, $5.val); $$.type = 0; } | exprmem PERIOD ID { @@ -6607,7 +6607,7 @@ exprmem : ID ARROW ID { } | exprmem PERIOD ID LPAREN callparms RPAREN { $$ = $1; - Printf($$.val, ".%s(%s)", $3, $5); + Printf($$.val, ".%s(%s)", $3, $5.val); } ; |