Tokenizer::setVarId: Minor fix of sizeof handling
This commit is contained in:
parent
4871cef351
commit
4ae8e4f382
|
@ -2679,6 +2679,12 @@ void Tokenizer::setVarId()
|
|||
if (tok == list.front() || Token::Match(tok, "[;{}]") ||
|
||||
(Token::Match(tok,"[(,]") && (!executableScope.top() || Token::simpleMatch(tok->link(), ") {"))) ||
|
||||
(tok->isName() && tok->str().at(tok->str().length()-1U) == ':')) {
|
||||
|
||||
// No variable declarations in sizeof
|
||||
if (Token::Match(tok->previous(), "sizeof (")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// locate the variable name..
|
||||
const Token *tok2 = (tok->isName()) ? tok : tok->next();
|
||||
|
||||
|
|
|
@ -223,6 +223,7 @@ private:
|
|||
TEST_CASE(varidStl);
|
||||
TEST_CASE(varid_delete);
|
||||
TEST_CASE(varid_functions);
|
||||
TEST_CASE(varid_sizeof);
|
||||
TEST_CASE(varid_reference_to_containers);
|
||||
TEST_CASE(varid_in_class1);
|
||||
TEST_CASE(varid_in_class2);
|
||||
|
@ -3437,6 +3438,13 @@ private:
|
|||
|
||||
}
|
||||
|
||||
void varid_sizeof() {
|
||||
const char code[] = "x = sizeof(a*b);";
|
||||
const char expected[] = "\n\n##file 0\n"
|
||||
"1: x = sizeof ( a * b ) ;\n";
|
||||
ASSERT_EQUALS(expected, tokenizeDebugListing(code,false,"test.c"));
|
||||
}
|
||||
|
||||
void varid_reference_to_containers() {
|
||||
const std::string actual = tokenizeDebugListing(
|
||||
"void f()\n"
|
||||
|
|
Loading…
Reference in New Issue