File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1338,7 +1338,7 @@ void CheckClass::privateFunctions()
13381338
13391339 while (!privateFuncs.empty ()) {
13401340 const auto & pf = privateFuncs.front ();
1341- if (pf->retDef && pf-> retDef ->isAttributeMaybeUnused ()) {
1341+ if (pf->token ->isAttributeMaybeUnused ()) {
13421342 privateFuncs.pop_front ();
13431343 continue ;
13441344 }
Original file line number Diff line number Diff line change @@ -1606,7 +1606,7 @@ void CheckUnusedVar::checkStructMemberUsage()
16061606 if (isInherited && !var.isPrivate ())
16071607 continue ;
16081608
1609- if (!var.nameToken () || var.nameToken ()->isAttributeUnused () || var.nameToken ()->isAnonymous ())
1609+ if (!var.nameToken () || var.nameToken ()->isAttributeUnused () || var.nameToken ()->isAttributeMaybeUnused () || var. nameToken ()-> isAnonymous ())
16101610 continue ;
16111611
16121612 if (mTokenizer ->isVarUsedInTemplate (var.declarationId ()))
Original file line number Diff line number Diff line change @@ -2357,8 +2357,11 @@ void Variable::evaluate(const Settings& settings)
23572357 const Library & lib = settings.library ;
23582358
23592359 bool isContainer = false ;
2360- if (mNameToken )
2360+ if (mNameToken ) {
23612361 setFlag (fIsArray , arrayDimensions (settings, isContainer));
2362+ setFlag (fIsMaybeUnused , mNameToken ->isAttributeMaybeUnused ());
2363+ }
2364+
23622365
23632366 if (mTypeStartToken )
23642367 setValueType (ValueType::parseDecl (mTypeStartToken ,settings));
@@ -2395,10 +2398,6 @@ void Variable::evaluate(const Settings& settings)
23952398 setFlag (fIsReference , true ); // Set also fIsReference
23962399 }
23972400
2398- if (tok->isAttributeMaybeUnused ()) {
2399- setFlag (fIsMaybeUnused , true );
2400- }
2401-
24022401 if (tok->str () == " <" && tok->link ())
24032402 tok = tok->link ();
24042403 else
Original file line number Diff line number Diff line change @@ -9542,7 +9542,15 @@ void Tokenizer::simplifyCPPAttribute()
95429542 Token* head = skipCPPOrAlignAttribute (tok)->next ();
95439543 while (isCPPAttribute (head) || isAlignAttribute (head))
95449544 head = skipCPPOrAlignAttribute (head)->next ();
9545- head->isAttributeMaybeUnused (true );
9545+ while (Token::Match (head->next (), " %name%|*|&|&&|const|static|inline|volatile" ))
9546+ head = head->next ();
9547+ if (Token::Match (head, " %name%" ))
9548+ head->isAttributeMaybeUnused (true );
9549+ else {
9550+ if (Token::Match (tok->previous (), " %name%" ) && Token::Match (tok->link (), " ] [;={]" )) {
9551+ tok->previous ()->isAttributeMaybeUnused (true );
9552+ }
9553+ }
95469554 } else if (Token::findsimplematch (tok->tokAt (2 ), " unused" , tok->link ())) {
95479555 Token* head = skipCPPOrAlignAttribute (tok)->next ();
95489556 while (isCPPAttribute (head) || isAlignAttribute (head))
You can’t perform that action at this time.
0 commit comments