Fix issue 8709: crash with switch statement with followVar (#1362)
* Fix crash with switch statement * Update comment
This commit is contained in:
parent
0e5fabf4dc
commit
93be440f92
|
@ -206,6 +206,9 @@ static const Token * followVariableExpression(const Token * tok, bool cpp)
|
|||
if (const Variable * var2 = tok2->variable()) {
|
||||
if(!var2->scope())
|
||||
return tok;
|
||||
// FIXME This is a quick fix. Fix SymbolDatabase so typeStartToken points at the variable declaration and not a case statement
|
||||
if(Token::simpleMatch(var2->typeStartToken(), "case"))
|
||||
return tok;
|
||||
const Token * endToken2 = var2->scope() != tok->scope() ? var2->scope()->bodyEnd : endToken;
|
||||
if (!var2->isLocal() && !var2->isConst() && !var2->isArgument())
|
||||
return tok;
|
||||
|
|
|
@ -4576,6 +4576,16 @@ private:
|
|||
" int32_t c = int32_t(a / b);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Issue #8709
|
||||
check("a b;\n"
|
||||
"void c() {\n"
|
||||
" switch (d) { case b:; }\n"
|
||||
" double e(b);\n"
|
||||
" if(e <= 0) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
}
|
||||
|
||||
void checkSignOfUnsignedVariable() {
|
||||
|
|
Loading…
Reference in New Issue