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 @@ -9543,9 +9543,27 @@ void Tokenizer::simplifyCPPAttribute()
95439543 Token* head = skipCPPOrAlignAttribute (tok)->next ();
95449544 while (isCPPAttribute (head) || isAlignAttribute (head))
95459545 head = skipCPPOrAlignAttribute (head)->next ();
9546+
95469547 if (!head)
95479548 syntaxError (tok);
9548- head->isAttributeMaybeUnused (true );
9549+
9550+ while (Token::Match (head->next (), " %name%|*|&|&&|const|static|inline|volatile" ))
9551+ head = head->next ();
9552+ if (Token::Match (head, " %name%" ) && !Token::Match (head, " auto [" ))
9553+ head->isAttributeMaybeUnused (true );
9554+ else if (Token::Match (tok->previous (), " %name%" ) && Token::Match (tok->link (), " ] [;={]" )) {
9555+ tok->previous ()->isAttributeMaybeUnused (true );
9556+ } else {
9557+ if (Token::simpleMatch (head->next (), " [" )) {
9558+ head = head->next ();
9559+ const Token *end = head->link ();
9560+ for (head = head->next (); end && head != end; head = head->next ()) {
9561+ if (Token::Match (head, " %name%" )) {
9562+ head->isAttributeMaybeUnused (true );
9563+ }
9564+ }
9565+ }
9566+ }
95499567 } else if (Token::findsimplematch (tok->tokAt (2 ), " unused" , tok->link ())) {
95509568 Token* head = skipCPPOrAlignAttribute (tok)->next ();
95519569 while (isCPPAttribute (head) || isAlignAttribute (head))
You can’t perform that action at this time.
0 commit comments