variable usage: fix false positives when __attribute__ is used. Ticket: #1792
This commit is contained in:
parent
7dba21858a
commit
ee7ad272d6
|
@ -104,6 +104,7 @@ void Token::deleteThis()
|
|||
_isName = _next->_isName;
|
||||
_isNumber = _next->_isNumber;
|
||||
_isBoolean = _next->_isBoolean;
|
||||
_isUnused = _next->_isUnused;
|
||||
_varId = _next->_varId;
|
||||
_fileIndex = _next->_fileIndex;
|
||||
_linenr = _next->_linenr;
|
||||
|
|
|
@ -7688,6 +7688,10 @@ void Tokenizer::simplifyAttribute()
|
|||
if (Token::Match(tok->previous(), "%type%"))
|
||||
tok->previous()->isUnused(true);
|
||||
}
|
||||
|
||||
// check if before variable name
|
||||
else if (Token::Match(tok->next()->link()->next(), "%type%"))
|
||||
tok->next()->link()->next()->isUnused(true);
|
||||
}
|
||||
|
||||
Token::eraseTokens(tok, tok->next()->link()->next());
|
||||
|
|
|
@ -1935,6 +1935,18 @@ private:
|
|||
" bool test __attribute__((unused)) = true;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
|
||||
functionVariableUsage("int foo()\n"
|
||||
"{\n"
|
||||
" bool __attribute__((unused)) test;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
|
||||
functionVariableUsage("int foo()\n"
|
||||
"{\n"
|
||||
" bool __attribute__((unused)) test = true;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue