ValueType: Set ValueType for false/true

This commit is contained in:
Daniel Marjamäki 2019-03-09 17:27:27 +01:00
parent 5a32d2d017
commit 1b4895a579
2 changed files with 5 additions and 1 deletions

View File

@ -5348,6 +5348,8 @@ void SymbolDatabase::setValueTypeInTokenList()
}
}
setValueType(tok, ValueType(ValueType::Sign::UNKNOWN_SIGN, ValueType::Type::BOOL, 0U));
} else if (tok->isBoolean()) {
setValueType(tok, ValueType(ValueType::Sign::UNKNOWN_SIGN, ValueType::Type::BOOL, 0U));
} else if (tok->tokType() == Token::eChar)
setValueType(tok, ValueType(ValueType::Sign::UNKNOWN_SIGN, ValueType::Type::CHAR, 0U));
else if (tok->tokType() == Token::eString) {

View File

@ -5959,10 +5959,12 @@ private:
ASSERT_EQUALS("const char *", typeOf("int x; double y; a = (b ? \"a\" : \"b\");", "?"));
ASSERT_EQUALS("", typeOf("int x; double y; a = (b ? \"a\" : std::string(\"b\"));", "?"));
// Boolean operators
// Boolean operators/literals
ASSERT_EQUALS("bool", typeOf("a > b;", ">"));
ASSERT_EQUALS("bool", typeOf(";!b;", "!"));
ASSERT_EQUALS("bool", typeOf("c = a && b;", "&&"));
ASSERT_EQUALS("bool", typeOf("a = false;", "false"));
ASSERT_EQUALS("bool", typeOf("a = true;", "true"));
// shift => result has same type as lhs
ASSERT_EQUALS("signed int", typeOf("int x; a = x << 1U;", "<<"));