@@ -2164,7 +2164,7 @@ static bool isConstStatement(const Token *tok, const Library& library, bool isNe
21642164 return isConstStatement (tok->astOperand1 (), library) && isConstStatement (tok->astOperand2 (), library);
21652165 if (Token::Match (tok, " !|~|%cop%" ) && (tok->astOperand1 () || tok->astOperand2 ()))
21662166 return true ;
2167- if (Token::simpleMatch (tok->previous (), " sizeof (" ))
2167+ if (Token::Match (tok->previous (), " sizeof|alignof|noexcept|typeid (" ))
21682168 return true ;
21692169 if (isCPPCast (tok)) {
21702170 if (Token::simpleMatch (tok->astOperand1 (), " dynamic_cast" ) && Token::simpleMatch (tok->astOperand1 ()->linkAt (1 )->previous (), " & >" ))
@@ -2299,6 +2299,7 @@ void CheckOther::checkIncompleteStatement()
22992299 if (!Token::simpleMatch (tok->astParent (), " ;" ) && !Token::simpleMatch (rtok, " ;" ) &&
23002300 !Token::Match (tok->previous (), " ;|}|{ %any% ;" ) &&
23012301 !(tok->isCpp () && tok->isCast () && !tok->astParent ()) &&
2302+ !(!tok->astParent () && Token::Match (tok->previous (), " %name% () && tok->previous()->isKeyword()) &&
23022303 !Token::simpleMatch(tok->tokAt(-2), " for (" ) &&
23032304 !Token::Match(tok->tokAt(-1), " %var% [" ) &&
23042305 !(tok->str() == " ," && tok->astParent() && tok->astParent()->isAssignmentOp()))
@@ -2361,7 +2362,9 @@ void CheckOther::constStatementError(const Token *tok, const std::string &type,
23612362 else if (tok->str() == " [" && !tok->astParent())
23622363 msg = " Redundant code: Found unused lambda." ;
23632364 else if (Token::Match(tok, " %name%|::" ))
2364- msg = " Redundant code: Found unused function." ;
2365+ msg = " Redundant code: Found unused function." ;
2366+ else if (Token::Match(tok->previous(), " %name% (" ))
2367+ msg = " Redundant code: Found unused ' " + tok->strAt(-1) + "' expression." ;
23652368 else if (mSettings->debugwarnings) {
23662369 reportError(tok, Severity::debug, " debug" , " constStatementError not handled." );
23672370 return;
0 commit comments