CheckStructMemberUsage: Added more cases
This commit is contained in:
parent
219d82e180
commit
58b1b5f101
|
@ -756,8 +756,14 @@ void CheckStructMemberUsage()
|
|||
if (structname && Match(tok, "[{;]"))
|
||||
{
|
||||
const char *varname = 0;
|
||||
if (Match(tok->next, "%type% %var% ;"))
|
||||
if (Match(tok->next, "%type% %var% [;[]"))
|
||||
varname = getstr( tok, 2 );
|
||||
else if (Match(tok->next, "%type% %type% %var% [;[]"))
|
||||
varname = getstr( tok, 2 );
|
||||
else if (Match(tok->next, "%type% * %var% [;[]"))
|
||||
varname = getstr( tok, 3 );
|
||||
else if (Match(tok->next, "%type% %type% * %var% [;[]"))
|
||||
varname = getstr( tok, 4 );
|
||||
else
|
||||
continue;
|
||||
|
||||
|
|
38
tests.cpp
38
tests.cpp
|
@ -935,6 +935,44 @@ static void unused_struct_member()
|
|||
__LINE__,
|
||||
"struct abc {int i;};",
|
||||
"[test.cpp:1]: struct member 'abc::i' is never read\n" );
|
||||
|
||||
check( CheckStructMemberUsage,
|
||||
__LINE__,
|
||||
"struct abc {unsigned int i;};",
|
||||
"[test.cpp:1]: struct member 'abc::i' is never read\n" );
|
||||
|
||||
check( CheckStructMemberUsage,
|
||||
__LINE__,
|
||||
"struct abc {int *i;};",
|
||||
"[test.cpp:1]: struct member 'abc::i' is never read\n" );
|
||||
|
||||
check( CheckStructMemberUsage,
|
||||
__LINE__,
|
||||
"struct abc {unsigned int *i;};",
|
||||
"[test.cpp:1]: struct member 'abc::i' is never read\n" );
|
||||
|
||||
check( CheckStructMemberUsage,
|
||||
__LINE__,
|
||||
"struct abc {int i[10];};",
|
||||
"[test.cpp:1]: struct member 'abc::i' is never read\n" );
|
||||
|
||||
check( CheckStructMemberUsage,
|
||||
__LINE__,
|
||||
"struct abc {unsigned int i[10];};",
|
||||
"[test.cpp:1]: struct member 'abc::i' is never read\n" );
|
||||
|
||||
|
||||
check( CheckStructMemberUsage,
|
||||
__LINE__,
|
||||
"struct abc {int *i[10];};",
|
||||
"[test.cpp:1]: struct member 'abc::i' is never read\n" );
|
||||
|
||||
check( CheckStructMemberUsage,
|
||||
__LINE__,
|
||||
"struct abc {unsigned int *i[10];};",
|
||||
"[test.cpp:1]: struct member 'abc::i' is never read\n" );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue