parent
8d49fc252c
commit
49147f95fe
|
@ -1777,8 +1777,11 @@ static bool isConstStatement(const Token *tok, bool cpp)
|
|||
return true;
|
||||
if (Token::simpleMatch(tok->previous(), "sizeof ("))
|
||||
return true;
|
||||
if (isCPPCast(tok))
|
||||
if (isCPPCast(tok)) {
|
||||
if (Token::simpleMatch(tok->astOperand1(), "dynamic_cast") && Token::simpleMatch(tok->astOperand1()->next()->link()->previous(), "& >"))
|
||||
return false;
|
||||
return isWithoutSideEffects(cpp, tok) && isConstStatement(tok->astOperand2(), cpp);
|
||||
}
|
||||
else if (tok->isCast() && tok->next() && tok->next()->isStandardType())
|
||||
return isWithoutSideEffects(cpp, tok->astOperand1()) && isConstStatement(tok->astOperand1(), cpp);
|
||||
if (Token::simpleMatch(tok, "."))
|
||||
|
|
|
@ -283,6 +283,17 @@ private:
|
|||
" ((struct foo *)(0x1234))->xy = 1;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("bool f(const std::exception& e) {\n" // #10918
|
||||
" try {\n"
|
||||
" dynamic_cast<const InvalidTypeException&>(e);\n"
|
||||
" return true;\n"
|
||||
" }\n"
|
||||
" catch (...) {\n"
|
||||
" return false;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void increment() {
|
||||
|
|
Loading…
Reference in New Issue