Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7597,7 +7597,8 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, co
if (only_k_r_fpar && finishedwithkr) {
if (Token::Match(tok, "(|[|{")) {
tok = tok->link();
if (tok->next() && Token::Match(tok, ") !!{"))
// Don't step onto tokEnd: the loop increment would then step past it
if (tok->next() && tok->next() != tokEnd && Token::Match(tok, ") !!{"))
tok = tok->next();
else
continue;
Expand Down
6 changes: 6 additions & 0 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class TestTokenizer : public TestFixture {
TEST_CASE(vardecl34);
TEST_CASE(vardecl35);
TEST_CASE(vardecl36);
TEST_CASE(vardecl38);
TEST_CASE(vardecl_stl_1);
TEST_CASE(vardecl_stl_2);
TEST_CASE(vardecl_stl_3);
Expand Down Expand Up @@ -3081,6 +3082,11 @@ class TestTokenizer : public TestFixture {
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
}

void vardecl38() { // #15245 range ending in ')' before a braced initializer's '}'
ASSERT_EQUALS("int * q { new int [ 2 ] { ( 1 ) } } ;",
tokenizeAndStringify("int* q{new int[2]{(1)}};"));
}

void volatile_variables() {
{
const char code[] = "volatile int a=0;\n"
Expand Down
Loading