Skip to content

Commit

Permalink
Fix #12729 internalError with _Static_assert in C code (regression) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored May 14, 2024
1 parent ac626a2 commit eb4ceac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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

0 comments on commit eb4ceac

Please sign in to comment.