Fixed #7931 (crash: SymbolDatabase: Variable::setFlag)

This commit is contained in:
Daniel Marjamäki 2017-03-01 17:13:22 +01:00
parent 7eee6af4ce
commit 51b5f1c286
2 changed files with 4 additions and 1 deletions

View File

@ -4470,7 +4470,9 @@ static void setValueType(Token *tok, const ValueType &valuetype, bool cpp, Value
setAutoTokenProperties(autoTok); setAutoTokenProperties(autoTok);
setValueType(var1Tok, *vt2, cpp, defaultSignedness, settings); setValueType(var1Tok, *vt2, cpp, defaultSignedness, settings);
setValueType(parent->previous(), *vt2, cpp, defaultSignedness, settings); setValueType(parent->previous(), *vt2, cpp, defaultSignedness, settings);
const_cast<Variable *>(parent->previous()->variable())->setFlags(*vt2); const Variable *var = parent->previous()->variable();
if (var)
const_cast<Variable *>(var)->setFlags(*vt2);
} }
} }
return; return;

View File

@ -4309,6 +4309,7 @@ private:
ASSERT_EQUALS("signed int *", typeOf("; auto *p = (int *)0;", "p")); ASSERT_EQUALS("signed int *", typeOf("; auto *p = (int *)0;", "p"));
ASSERT_EQUALS("signed int *", typeOf("; auto data = new int[100];", "data")); ASSERT_EQUALS("signed int *", typeOf("; auto data = new int[100];", "data"));
ASSERT_EQUALS("const signed short", typeOf("short values[10]; void f() { for (const auto *x : values); }", "x")); ASSERT_EQUALS("const signed short", typeOf("short values[10]; void f() { for (const auto *x : values); }", "x"));
ASSERT_EQUALS("signed int *", typeOf("MACRO(test) void test() { auto x = (int*)y; }", "x")); // #7931 (garbage?)
} }
void variadic1() { // #7453 void variadic1() { // #7453