SymbolDatabase: Fix TODO assertions

This commit is contained in:
Daniel Marjamäki 2019-02-24 19:11:18 +01:00
parent d218fa5919
commit d84d8885f7
2 changed files with 18 additions and 8 deletions

View File

@ -4837,8 +4837,14 @@ void SymbolDatabase::setValueType(Token *tok, const Variable &var)
valuetype.bits = var.nameToken()->bits(); valuetype.bits = var.nameToken()->bits();
valuetype.pointer = var.dimensions().size(); valuetype.pointer = var.dimensions().size();
valuetype.typeScope = var.typeScope(); valuetype.typeScope = var.typeScope();
if (parsedecl(var.typeStartToken(), &valuetype, mDefaultSignedness, mSettings)) if (parsedecl(var.typeStartToken(), &valuetype, mDefaultSignedness, mSettings)) {
if (tok->str() == "." && tok->astOperand1()) {
const ValueType * const vt = tok->astOperand1()->valueType();
if (vt && (vt->constness & 1) != 0)
valuetype.constness |= 1;
}
setValueType(tok, valuetype); setValueType(tok, valuetype);
}
} }
void SymbolDatabase::setValueType(Token *tok, const Enumerator &enumerator) void SymbolDatabase::setValueType(Token *tok, const Enumerator &enumerator)
@ -4908,15 +4914,19 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)
autoTok = var1Tok->tokAt(-2); autoTok = var1Tok->tokAt(-2);
if (autoTok) { if (autoTok) {
ValueType vt(*vt2); ValueType vt(*vt2);
if (vt.constness & (1 << vt.pointer))
vt.constness &= ~(1 << vt.pointer);
if (autoTok->strAt(1) == "*" && vt.pointer) if (autoTok->strAt(1) == "*" && vt.pointer)
vt.pointer--; vt.pointer--;
if (autoTok->strAt(-1) == "const") if (autoTok->strAt(-1) == "const")
vt.constness |= 1; vt.constness |= 1;
setValueType(autoTok, vt); setValueType(autoTok, vt);
setAutoTokenProperties(autoTok); setAutoTokenProperties(autoTok);
if (vt2->pointer > vt.pointer)
vt.pointer++;
setValueType(var1Tok, vt); setValueType(var1Tok, vt);
if (var1Tok != parent->previous()) if (var1Tok != parent->previous())
setValueType(parent->previous(), *vt2); setValueType(parent->previous(), vt);
Variable *var = const_cast<Variable *>(parent->previous()->variable()); Variable *var = const_cast<Variable *>(parent->previous()->variable());
if (var) { if (var) {
ValueType vt2_(*vt2); ValueType vt2_(*vt2);

View File

@ -6593,7 +6593,7 @@ private:
autotok = Token::findsimplematch(autotok, "auto v3"); autotok = Token::findsimplematch(autotok, "auto v3");
ASSERT(db && autotok && autotok->valueType()); ASSERT(db && autotok && autotok->valueType());
if (db && autotok && autotok->valueType()) { if (db && autotok && autotok->valueType()) {
TODO_ASSERT_EQUALS(1, 0, autotok->valueType()->constness); ASSERT_EQUALS(1, autotok->valueType()->constness);
ASSERT_EQUALS(1, autotok->valueType()->pointer); ASSERT_EQUALS(1, autotok->valueType()->pointer);
ASSERT_EQUALS(ValueType::SIGNED, autotok->valueType()->sign); ASSERT_EQUALS(ValueType::SIGNED, autotok->valueType()->sign);
ASSERT_EQUALS(ValueType::INT, autotok->valueType()->type); ASSERT_EQUALS(ValueType::INT, autotok->valueType()->type);
@ -6601,7 +6601,7 @@ private:
vartok = Token::findsimplematch(autotok, "v3 ="); vartok = Token::findsimplematch(autotok, "v3 =");
ASSERT(db && vartok && vartok->valueType()); ASSERT(db && vartok && vartok->valueType());
if (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(1, vartok->valueType()->pointer);
ASSERT_EQUALS(ValueType::SIGNED, vartok->valueType()->sign); ASSERT_EQUALS(ValueType::SIGNED, vartok->valueType()->sign);
ASSERT_EQUALS(ValueType::INT, vartok->valueType()->type); ASSERT_EQUALS(ValueType::INT, vartok->valueType()->type);
@ -6637,7 +6637,7 @@ private:
vartok = Token::findsimplematch(autotok, "v5 ="); vartok = Token::findsimplematch(autotok, "v5 =");
ASSERT(db && vartok && vartok->valueType()); ASSERT(db && vartok && vartok->valueType());
if (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(1, vartok->valueType()->pointer);
ASSERT_EQUALS(ValueType::SIGNED, vartok->valueType()->sign); ASSERT_EQUALS(ValueType::SIGNED, vartok->valueType()->sign);
ASSERT_EQUALS(ValueType::INT, vartok->valueType()->type); ASSERT_EQUALS(ValueType::INT, vartok->valueType()->type);
@ -6683,7 +6683,7 @@ private:
autotok = Token::findsimplematch(autotok, "auto v8"); autotok = Token::findsimplematch(autotok, "auto v8");
ASSERT(db && autotok && autotok->valueType()); ASSERT(db && autotok && autotok->valueType());
if (db && autotok && autotok->valueType()) { if (db && autotok && autotok->valueType()) {
TODO_ASSERT_EQUALS(1, 0, autotok->valueType()->constness); ASSERT_EQUALS(1, autotok->valueType()->constness);
ASSERT_EQUALS(1, autotok->valueType()->pointer); ASSERT_EQUALS(1, autotok->valueType()->pointer);
ASSERT_EQUALS(ValueType::SIGNED, autotok->valueType()->sign); ASSERT_EQUALS(ValueType::SIGNED, autotok->valueType()->sign);
ASSERT_EQUALS(ValueType::INT, autotok->valueType()->type); ASSERT_EQUALS(ValueType::INT, autotok->valueType()->type);
@ -6691,7 +6691,7 @@ private:
vartok = Token::findsimplematch(autotok, "v8 ="); vartok = Token::findsimplematch(autotok, "v8 =");
ASSERT(db && vartok && vartok->valueType()); ASSERT(db && vartok && vartok->valueType());
if (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(1, vartok->valueType()->pointer);
ASSERT_EQUALS(ValueType::SIGNED, vartok->valueType()->sign); ASSERT_EQUALS(ValueType::SIGNED, vartok->valueType()->sign);
ASSERT_EQUALS(ValueType::INT, vartok->valueType()->type); ASSERT_EQUALS(ValueType::INT, vartok->valueType()->type);
@ -6727,7 +6727,7 @@ private:
vartok = Token::findsimplematch(autotok, "v10 ="); vartok = Token::findsimplematch(autotok, "v10 =");
ASSERT(db && vartok && vartok->valueType()); ASSERT(db && vartok && vartok->valueType());
if (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(1, vartok->valueType()->pointer);
ASSERT_EQUALS(ValueType::SIGNED, vartok->valueType()->sign); ASSERT_EQUALS(ValueType::SIGNED, vartok->valueType()->sign);
ASSERT_EQUALS(ValueType::INT, vartok->valueType()->type); ASSERT_EQUALS(ValueType::INT, vartok->valueType()->type);