Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #12729 internalError with _Static_assert in C code (regression) #6403

Merged
merged 2 commits into from
May 14, 2024
Merged
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
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const Token * Tokenizer::isFunctionHead(const Token *tok, const std::string &end
tok = tok->link();
if (tok->str() != ")")
return nullptr;
if (!tok->isCpp() && !Token::Match(tok->link()->previous(), "%name%|)"))
if (!tok->isCpp() && !Token::Match(tok->link()->previous(), "%name%|(|)"))
return nullptr;
if (Token::Match(tok, ") ;|{|[")) {
tok = tok->next();
Expand Down
4 changes: 4 additions & 0 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,10 @@ class TestVarID : public TestFixture {
const char code3[] = "extern void (*arr[10])(uint32_t some);\n";
const char expected3[] = "1: extern void ( * arr@1 [ 10 ] ) ( uint32_t some@2 ) ;\n";
ASSERT_EQUALS(expected3, tokenize(code3, true));

const char code4[] = "_Static_assert(sizeof((struct S){0}.i) == 4);\n"; // #12729
const char expected4[] = "1: _Static_assert ( sizeof ( ( struct S ) { 0 } . i ) == 4 ) ;\n";
ASSERT_EQUALS(expected4, tokenize(code4, false));
}

void varid71() {
Expand Down
Loading