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 (const Variable * var2 = tok2->variable()) {
|
||||||
if(!var2->scope())
|
if(!var2->scope())
|
||||||
return tok;
|
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;
|
const Token * endToken2 = var2->scope() != tok->scope() ? var2->scope()->bodyEnd : endToken;
|
||||||
if (!var2->isLocal() && !var2->isConst() && !var2->isArgument())
|
if (!var2->isLocal() && !var2->isConst() && !var2->isArgument())
|
||||||
return tok;
|
return tok;
|
||||||
|
|
|
@ -4576,6 +4576,16 @@ private:
|
||||||
" int32_t c = int32_t(a / b);\n"
|
" int32_t c = int32_t(a / b);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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() {
|
void checkSignOfUnsignedVariable() {
|
||||||
|
|
Loading…
Reference in New Issue