diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index ac8a23ba1..73e645ed9 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -4914,8 +4914,9 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype) vt.constness |= 1; setValueType(autoTok, vt); setAutoTokenProperties(autoTok); - setValueType(var1Tok, *vt2); - setValueType(parent->previous(), *vt2); + setValueType(var1Tok, vt); + if (var1Tok != parent->previous()) + setValueType(parent->previous(), *vt2); Variable *var = const_cast(parent->previous()->variable()); if (var) { var->setValueType(*vt2); diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 58a6914ec..93b2f1b73 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -6094,6 +6094,7 @@ private: ASSERT_EQUALS("signed int *", typeOf("; auto data = new (std::nothrow) int[100];", "data")); 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?) + ASSERT_EQUALS("const signed int", typeOf("; const auto x = 3;", "x")); // Variable declaration ASSERT_EQUALS("char *", typeOf("; char abc[] = \"abc\";", "[")); @@ -6617,7 +6618,7 @@ private: vartok = Token::findsimplematch(autotok, "v4 ="); ASSERT(db && vartok && vartok->valueType()); if (db && vartok && vartok->valueType()) { - TODO_ASSERT_EQUALS(1, 0, vartok->valueType()->constness); + ASSERT_EQUALS(1, vartok->valueType()->constness); ASSERT_EQUALS(1, vartok->valueType()->pointer); ASSERT_EQUALS(ValueType::SIGNED, vartok->valueType()->sign); ASSERT_EQUALS(ValueType::INT, vartok->valueType()->type); @@ -6707,7 +6708,7 @@ private: vartok = Token::findsimplematch(autotok, "v9 ="); ASSERT(db && vartok && vartok->valueType()); if (db && vartok && vartok->valueType()) { - TODO_ASSERT_EQUALS(1, 0, vartok->valueType()->constness); + ASSERT_EQUALS(1, vartok->valueType()->constness); ASSERT_EQUALS(1, vartok->valueType()->pointer); ASSERT_EQUALS(ValueType::SIGNED, vartok->valueType()->sign); ASSERT_EQUALS(ValueType::INT, vartok->valueType()->type);