diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 1994eb5f7..4ba2b7d2f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -6775,6 +6775,11 @@ void Tokenizer::simplifyGoto() } } + else if (indentlevel > 0 && tok->str() == "(") + { + tok = tok->link(); + } + else if (indentlevel == 0 && Token::Match(tok, ") const| {")) { gotos.clear(); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 672841070..8a55dd0e1 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -147,6 +147,7 @@ private: // Simplify goto.. TEST_CASE(goto1); + TEST_CASE(goto2); // Simplify nested strcat() calls TEST_CASE(strcat1); @@ -2778,6 +2779,12 @@ private: } } + void goto2() + { + // Don't simplify goto inside function call (macro) + const char code[] = "void f ( ) { slist_iter ( if ( a ) { goto dont_write ; } dont_write : ; x ( ) ; ) ; }"; + ASSERT_EQUALS(code, tok(code)); + } void strcat1() {