Fixed #7579 (varid not set properly in 'int b[] = { m * a[0] };')
This commit is contained in:
parent
f55040a987
commit
83b982064d
|
@ -2732,11 +2732,13 @@ void Tokenizer::setVarIdPass1()
|
|||
}
|
||||
}
|
||||
|
||||
if (tok == list.front() || Token::Match(tok, "[;{}]") ||
|
||||
if (!scopeStack.top().isStructInit &&
|
||||
(tok == list.front() ||
|
||||
Token::Match(tok, "[;{}]") ||
|
||||
(tok->str() == "(" && isFunctionHead(tok,"{")) ||
|
||||
(tok->str() == "(" && !scopeStack.top().isExecutable && isFunctionHead(tok,";:")) ||
|
||||
(tok->str() == "," && !scopeStack.top().isExecutable) ||
|
||||
(tok->isName() && tok->str().at(tok->str().length()-1U) == ':')) {
|
||||
(tok->isName() && tok->str().at(tok->str().length()-1U) == ':'))) {
|
||||
|
||||
// No variable declarations in sizeof
|
||||
if (Token::simpleMatch(tok->previous(), "sizeof (")) {
|
||||
|
|
|
@ -149,6 +149,7 @@ private:
|
|||
TEST_CASE(varid_header); // #6386
|
||||
TEST_CASE(varid_rangeBasedFor);
|
||||
TEST_CASE(varid_structinit); // #6406
|
||||
TEST_CASE(varid_arrayinit); // #7579
|
||||
|
||||
TEST_CASE(varidclass1);
|
||||
TEST_CASE(varidclass2);
|
||||
|
@ -2301,6 +2302,10 @@ private:
|
|||
"}"));
|
||||
}
|
||||
|
||||
void varid_arrayinit() { // #7579 - no variable declaration in rhs
|
||||
ASSERT_EQUALS("1: void foo ( int * a@1 ) { int b@2 [ 1 ] = { x * a@1 [ 0 ] } ; }\n", tokenize("void foo(int*a) { int b[] = { x*a[0] }; }"));
|
||||
}
|
||||
|
||||
void varidclass1() {
|
||||
const std::string actual = tokenize(
|
||||
"class Fred\n"
|
||||
|
|
Loading…
Reference in New Issue