Skip to content
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/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4560,7 +4560,7 @@ static const Token* skipPointers(const Token* tok)
static const Token* skipPointersAndQualifiers(const Token* tok)
{
tok = skipPointers(tok);
while (Token::Match(tok, "const|volatile")) {
while (Token::Match(tok, "const|static|volatile")) {
tok = tok->next();
tok = skipPointers(tok);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10823,7 +10823,7 @@ void Tokenizer::simplifyStructDecl()
Token *restart = next;

// check for named type
if (Token::Match(tok->next(), "const| *|&| const| (| %type% )| ,|;|[|=|(|{")) {
if (Token::Match(tok->next(), "const|static|volatile| *|&| const| (| %type% )| ,|;|[|=|(|{")) {
tok->insertToken(";");
tok = tok->next();
while (!Token::Match(start, "struct|class|union|enum")) {
Expand Down
4 changes: 4 additions & 0 deletions test/testbufferoverrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2769,6 +2769,10 @@ class TestBufferOverrun : public TestFixture {
" a[i] = 0;\n"
"}");
ASSERT_EQUALS("[test.cpp:7]: (error) Array 'a[10]' accessed at index 10, which is out of bounds.\n", errout.str());

check("struct S { int b; } static e[1];\n" // #11052
"int f() { return e[1].b; }\n");
ASSERT_EQUALS("[test.cpp:2]: (error) Array 'e[1]' accessed at index 1, which is out of bounds.\n", errout.str());
}


Expand Down
5 changes: 5 additions & 0 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1960,6 +1960,11 @@ class TestTokenizer : public TestFixture {
const char code2[] = "enum A {} (a);";
const char expected2[] = "enum A { } ; enum A a ;";
ASSERT_EQUALS(expected2, tokenizeAndStringify(code2));

// #11052
const char code3[] = "struct a { int b; } static e[1];";
const char expected3[] = "struct a { int b ; } ; struct a static e [ 1 ] ;";
ASSERT_EQUALS(expected3, tokenizeAndStringify(code3));
}

void vardecl1() {
Expand Down