ValueType: Support logical operators
This commit is contained in:
parent
35317695d4
commit
618ea498e9
|
@ -3890,7 +3890,7 @@ void SymbolDatabase::setValueTypeInTokenList(Token *tokens, bool cpp, char defau
|
|||
}
|
||||
::setValueType(tok, ValueType(sign, type, 0U), cpp, defsign);
|
||||
}
|
||||
} else if (tok->isComparisonOp())
|
||||
} else if (tok->isComparisonOp() || tok->tokType() == Token::eLogicalOp)
|
||||
::setValueType(tok, ValueType(ValueType::Sign::UNKNOWN_SIGN, ValueType::Type::BOOL, 0U), cpp, defsign);
|
||||
else if (tok->tokType() == Token::eChar)
|
||||
::setValueType(tok, ValueType(ValueType::Sign::UNKNOWN_SIGN, ValueType::Type::CHAR, 0U), cpp, defsign);
|
||||
|
|
|
@ -3207,6 +3207,11 @@ 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
|
||||
ASSERT_EQUALS("bool", typeOf("a > b;", ">"));
|
||||
ASSERT_EQUALS("bool", typeOf("!b;", "!"));
|
||||
ASSERT_EQUALS("bool", typeOf("c = a && b;", "&&"));
|
||||
|
||||
// shift => result has same type as lhs
|
||||
ASSERT_EQUALS("signed int", typeOf("int x; a = x << 1U;", "<<"));
|
||||
ASSERT_EQUALS("signed int", typeOf("int x; a = x >> 1U;", ">>"));
|
||||
|
|
Loading…
Reference in New Issue