From e4d2e9d2afb1149ff19e624245e99996854b98a8 Mon Sep 17 00:00:00 2001 From: IOBYTE Date: Wed, 16 Oct 2019 14:56:53 -0400 Subject: [PATCH] Fix #9421 (syntaxError on incomplete code (from z3)) (#2274) --- lib/tokenize.cpp | 2 +- test/testtokenize.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index b73b40880..f1c977e6e 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -6166,7 +6166,7 @@ void Tokenizer::simplifyFunctionParameters() // Find the function e.g. foo( x ) or foo( x, y ) else if (Token::Match(tok, "%name% ( %name% [,)]") && - !(tok->strAt(-1) == ":" || tok->strAt(-1) == ",")) { + !(tok->strAt(-1) == ":" || tok->strAt(-1) == "," || tok->strAt(-1) == "::")) { // We have found old style function, now we need to change it // First step: Get list of argument names in parentheses diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 384395ed4..947b9d575 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -226,6 +226,7 @@ private: TEST_CASE(simplifyFunctionParameters1); // #3721 TEST_CASE(simplifyFunctionParameters2); // #4430 TEST_CASE(simplifyFunctionParameters3); // #4436 + TEST_CASE(simplifyFunctionParameters4); // #9421 TEST_CASE(simplifyFunctionParametersMultiTemplate); TEST_CASE(simplifyFunctionParametersErrors); @@ -3176,6 +3177,11 @@ private: ASSERT_EQUALS(code, tokenizeAndStringify(code)); } + void simplifyFunctionParameters4() { // #9421 + const char code[] = "int foo :: bar ( int , int ) const ;"; + ASSERT_EQUALS(code, tokenizeAndStringify(code)); + } + void simplifyFunctionParametersMultiTemplate() { const char code[] = "template < typename T1 > template < typename T2 > " "void A < T1 > :: foo ( T2 ) { }";