This commit is contained in:
parent
759c16fcef
commit
a70d11adb6
|
@ -4560,7 +4560,7 @@ static const Token* skipPointers(const Token* tok)
|
||||||
static const Token* skipPointersAndQualifiers(const Token* tok)
|
static const Token* skipPointersAndQualifiers(const Token* tok)
|
||||||
{
|
{
|
||||||
tok = skipPointers(tok);
|
tok = skipPointers(tok);
|
||||||
while (Token::Match(tok, "const|volatile")) {
|
while (Token::Match(tok, "const|static|volatile")) {
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
tok = skipPointers(tok);
|
tok = skipPointers(tok);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10825,7 +10825,7 @@ void Tokenizer::simplifyStructDecl()
|
||||||
Token *restart = next;
|
Token *restart = next;
|
||||||
|
|
||||||
// check for named type
|
// 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->insertToken(";");
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
while (!Token::Match(start, "struct|class|union|enum")) {
|
while (!Token::Match(start, "struct|class|union|enum")) {
|
||||||
|
|
|
@ -2769,6 +2769,10 @@ private:
|
||||||
" a[i] = 0;\n"
|
" 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());
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1960,6 +1960,11 @@ private:
|
||||||
const char code2[] = "enum A {} (a);";
|
const char code2[] = "enum A {} (a);";
|
||||||
const char expected2[] = "enum A { } ; enum A a ;";
|
const char expected2[] = "enum A { } ; enum A a ;";
|
||||||
ASSERT_EQUALS(expected2, tokenizeAndStringify(code2));
|
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() {
|
void vardecl1() {
|
||||||
|
|
Loading…
Reference in New Issue