Skip to content

Commit

Permalink
Fix #12544 Crash in getDeallocFuncInfo() (#6187)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Mar 25, 2024
1 parent d8e4914 commit 82f05c8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/tokenlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,11 @@ static Token * createAstAtToken(Token *tok)
return endToken->previous();
}

if (cpp && ((!tok->previous() && tok->str() == "::") || Token::Match(tok->previous(), "[;{}] ::"))) {
AST_state state(cpp);
compileExpression(tok, state);
}

return tok;
}

Expand Down
2 changes: 1 addition & 1 deletion test/testfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ class TestFunctions : public TestFixture {
"{\n"
" ::getpwent();\n"
"}");
ASSERT_EQUALS("[test.cpp:3]: (warning) Return value of function getpwent() is not used.\n"
ASSERT_EQUALS("[test.cpp:3]: (warning) Return value of function ::getpwent() is not used.\n"
"[test.cpp:3]: (portability) Non reentrant function 'getpwent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getpwent_r'.\n", errout_str());

// Be quiet on function definitions
Expand Down
1 change: 1 addition & 0 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6541,6 +6541,7 @@ class TestTokenizer : public TestFixture {
ASSERT_EQUALS("PT.(", testAst("P->~T();")); // <- The "T" token::function() will be a destructor
ASSERT_EQUALS("double&(4[", testAst("void f(double(&)[4]) {}"));
ASSERT_EQUALS("voidu*", testAst("int* g ( void* (f) (void*), void* u);")); // #12475
ASSERT_EQUALS("f::(", testAst("::f();")); // #12544
}

void asttemplate() { // uninstantiated templates will have <,>,etc..
Expand Down

0 comments on commit 82f05c8

Please sign in to comment.