Fix FP unusedVariable with arrays (#5319)
This commit is contained in:
parent
b9cc138e57
commit
5c6962c273
|
@ -8843,8 +8843,11 @@ void Tokenizer::simplifyAttribute()
|
|||
|
||||
// check if after variable name
|
||||
if (Token::Match(after, ";|=")) {
|
||||
if (Token::Match(tok->previous(), "%type%"))
|
||||
vartok = tok->previous();
|
||||
Token *prev = tok->previous();
|
||||
while (Token::simpleMatch(prev, "]"))
|
||||
prev = prev->link()->previous();
|
||||
if (Token::Match(prev, "%type%"))
|
||||
vartok = prev;
|
||||
}
|
||||
|
||||
// check if before variable name
|
||||
|
|
|
@ -5651,6 +5651,13 @@ private:
|
|||
" bool __attribute__((used)) test;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
functionVariableUsage("int foo()\n"
|
||||
"{\n"
|
||||
" char a[1] __attribute__((unused));\n"
|
||||
" char b[1][2] __attribute__((unused));\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvarFunction() {
|
||||
|
@ -6199,6 +6206,12 @@ private:
|
|||
" [[maybe_unused]] [[anotherattribute]] const int* = 1;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
functionVariableUsage("int main() {\n"
|
||||
" [[maybe_unused]] char a[1];\n"
|
||||
" [[maybe_unused]] char b[1][2];\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvarthrow() { // ticket #3687
|
||||
|
|
Loading…
Reference in New Issue