diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index ec2df1ab2..0fc89d294 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9294,7 +9294,9 @@ void Tokenizer::simplifyAsm2() for (Token *tok = list.front(); tok; tok = tok->next()) { if (Token::simpleMatch(tok, "^ {")) { Token * start = tok; - while (start && !Token::Match(start, "[;{})=]")) { + while (start && !Token::Match(start, "[;{}=]")) { + if (start->link() && start->str() == ")") + start = start->link(); start = start->previous(); } if (start) @@ -9302,8 +9304,11 @@ void Tokenizer::simplifyAsm2() const Token *last = tok->next()->link(); if (start != tok) { last = last->next(); - while (last && !Token::Match(last->next(), "[;{})]")) + while (last && !Token::Match(last, "[;{})]")) { last = last->next(); + if (last && last->link() && last->str() == "(") + last = last->link()->next(); + } if (last) last = last->next(); } diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index bf99a4847..f96d86f1c 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -657,8 +657,8 @@ private: } void garbageCode58() { // #6732, #6762 - checkCode("{ }> {= ~A()^{} }P { }"); - checkCode("{= ~A()^{} }P { } { }> is"); + ASSERT_THROW(checkCode("{ }> {= ~A()^{} }P { }"), InternalError); + ASSERT_THROW(checkCode("{= ~A()^{} }P { } { }> is"), InternalError); } void garbageCode59() { // #6735 diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index e27a9cbd2..c0c0d40be 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -776,10 +776,11 @@ private: void tokenize28() { ASSERT_EQUALS("void f ( ) { asm ( \"^{}\" ) ; }", tokenizeAndStringify("void f() { ^{} }")); ASSERT_EQUALS("void f ( ) { asm ( \"x(^{});\" ) ; }", tokenizeAndStringify("void f() { x(^{}); }")); + ASSERT_EQUALS("void f ( ) { asm ( \"foo(A(),^{bar();});\" ) ; }", tokenizeAndStringify("void f() { foo(A(), ^{ bar(); }); }")); ASSERT_EQUALS("int f0 ( Args args ) {\n" - "asm ( \"return^{returnsizeof...(Args);}()\" ) ;\n" + "asm ( \"return^{returnsizeof...(Args);}()+\" ) ;\n" "\n" - "asm ( \"+^{returnsizeof...(args);}()\" ) ;\n" + "asm ( \"^{returnsizeof...(args);}\" ) ;\n" "\n" "\n" "} ;", tokenizeAndStringify("int f0(Args args) {\n"