Skip to content

Commit eb4ceac

Browse files
Fix #12729 internalError with _Static_assert in C code (regression) (#6403)
1 parent ac626a2 commit eb4ceac

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const Token * Tokenizer::isFunctionHead(const Token *tok, const std::string &end
102102
tok = tok->link();
103103
if (tok->str() != ")")
104104
return nullptr;
105-
if (!tok->isCpp() && !Token::Match(tok->link()->previous(), "%name%|)"))
105+
if (!tok->isCpp() && !Token::Match(tok->link()->previous(), "%name%|(|)"))
106106
return nullptr;
107107
if (Token::Match(tok, ") ;|{|[")) {
108108
tok = tok->next();

test/testvarid.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,10 @@ class TestVarID : public TestFixture {
12941294
const char code3[] = "extern void (*arr[10])(uint32_t some);\n";
12951295
const char expected3[] = "1: extern void ( * arr@1 [ 10 ] ) ( uint32_t some@2 ) ;\n";
12961296
ASSERT_EQUALS(expected3, tokenize(code3, true));
1297+
1298+
const char code4[] = "_Static_assert(sizeof((struct S){0}.i) == 4);\n"; // #12729
1299+
const char expected4[] = "1: _Static_assert ( sizeof ( ( struct S ) { 0 } . i ) == 4 ) ;\n";
1300+
ASSERT_EQUALS(expected4, tokenize(code4, false));
12971301
}
12981302

12991303
void varid71() {

0 commit comments

Comments
 (0)