File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1603,15 +1603,11 @@ void CheckUnusedVar::checkStructMemberUsage()
16031603 // then don't warn about other struct members
16041604 bool structInUnionWithUsedMember = false ;
16051605 if (scope.type == ScopeType::eStruct && scope.nestedIn && scope.nestedIn ->type == ScopeType::eUnion) {
1606- for (const Variable &unionVar : scope.varlist ) {
1607- for (const Token *tok = mTokenizer ->tokens (); tok; tok = tok->next ()) {
1608- if (tok->variable () == &unionVar && tok != unionVar.nameToken ()) {
1609- structInUnionWithUsedMember = true ;
1610- break ;
1611- }
1612- }
1613- if (structInUnionWithUsedMember)
1606+ for (const Token *tok = mTokenizer ->tokens (); tok; tok = tok->next ()) {
1607+ if (tok->variable () && tok->variable ()->scope () == scope.nestedIn ) {
1608+ structInUnionWithUsedMember = true ;
16141609 break ;
1610+ }
16151611 }
16161612 }
16171613
@@ -1632,7 +1628,6 @@ void CheckUnusedVar::checkStructMemberUsage()
16321628 if (structInUnionWithUsedMember)
16331629 continue ;
16341630
1635-
16361631 // Check if the struct member variable is used anywhere in the file
16371632 bool use = false ;
16381633 for (const Token *tok = mTokenizer ->tokens (); tok; tok = tok->next ()) {
You can’t perform that action at this time.
0 commit comments