ValueType: Changed type info for enums to 'signed int', that is what checks wants to see mostly.
This commit is contained in:
parent
1caa79c45f
commit
eac3660f46
|
@ -4228,7 +4228,12 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V
|
||||||
while (Token::Match(type->previous(), "%name%"))
|
while (Token::Match(type->previous(), "%name%"))
|
||||||
type = type->previous();
|
type = type->previous();
|
||||||
valuetype->sign = ValueType::Sign::UNKNOWN_SIGN;
|
valuetype->sign = ValueType::Sign::UNKNOWN_SIGN;
|
||||||
valuetype->type = valuetype->typeScope ? ValueType::Type::NONSTD : ValueType::Type::UNKNOWN_TYPE;
|
if (!valuetype->typeScope)
|
||||||
|
valuetype->type = ValueType::Type::UNKNOWN_TYPE;
|
||||||
|
else if (valuetype->typeScope->type == Scope::eEnum)
|
||||||
|
valuetype->type = ValueType::Type::INT;
|
||||||
|
else
|
||||||
|
valuetype->type = ValueType::Type::NONSTD;
|
||||||
while (Token::Match(type, "%name%|*|&|::") && !type->variable()) {
|
while (Token::Match(type, "%name%|*|&|::") && !type->variable()) {
|
||||||
if (type->isSigned())
|
if (type->isSigned())
|
||||||
valuetype->sign = ValueType::Sign::SIGNED;
|
valuetype->sign = ValueType::Sign::SIGNED;
|
||||||
|
@ -4252,7 +4257,7 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V
|
||||||
valuetype->type = ValueType::Type::FLOAT;
|
valuetype->type = ValueType::Type::FLOAT;
|
||||||
else if (type->str() == "double")
|
else if (type->str() == "double")
|
||||||
valuetype->type = type->isLong() ? ValueType::Type::LONGDOUBLE : ValueType::Type::DOUBLE;
|
valuetype->type = type->isLong() ? ValueType::Type::LONGDOUBLE : ValueType::Type::DOUBLE;
|
||||||
else if (type->str() == "struct" || type->str() == "enum")
|
else if (!valuetype->typeScope && (type->str() == "struct" || type->str() == "enum"))
|
||||||
valuetype->type = ValueType::Type::NONSTD;
|
valuetype->type = ValueType::Type::NONSTD;
|
||||||
else if (type->isName() && valuetype->sign != ValueType::Sign::UNKNOWN_SIGN && valuetype->pointer == 0U)
|
else if (type->isName() && valuetype->sign != ValueType::Sign::UNKNOWN_SIGN && valuetype->pointer == 0U)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -3220,8 +3220,8 @@ private:
|
||||||
ASSERT_EQUALS("signed int", typeOf("struct X {int i;}; void f(struct X x) { x.i }", "."));
|
ASSERT_EQUALS("signed int", typeOf("struct X {int i;}; void f(struct X x) { x.i }", "."));
|
||||||
ASSERT_EQUALS("signed int *", typeOf("int *p; a = p++;", "++"));
|
ASSERT_EQUALS("signed int *", typeOf("int *p; a = p++;", "++"));
|
||||||
ASSERT_EQUALS("signed int", typeOf("int x; a = x++;", "++"));
|
ASSERT_EQUALS("signed int", typeOf("int x; a = x++;", "++"));
|
||||||
ASSERT_EQUALS("AB *", typeOf("enum AB {A,B}; AB *ab; x=ab+2;", "+"));
|
ASSERT_EQUALS("signed int *", typeOf("enum AB {A,B}; AB *ab; x=ab+2;", "+"));
|
||||||
ASSERT_EQUALS("AB *", typeOf("enum AB {A,B}; enum AB *ab; x=ab+2;", "+"));
|
ASSERT_EQUALS("signed int *", typeOf("enum AB {A,B}; enum AB *ab; x=ab+2;", "+"));
|
||||||
ASSERT_EQUALS("AB *", typeOf("struct AB {int a; int b;}; AB ab; x=&ab;", "&"));
|
ASSERT_EQUALS("AB *", typeOf("struct AB {int a; int b;}; AB ab; x=&ab;", "&"));
|
||||||
ASSERT_EQUALS("AB *", typeOf("struct AB {int a; int b;}; struct AB ab; x=&ab;", "&"));
|
ASSERT_EQUALS("AB *", typeOf("struct AB {int a; int b;}; struct AB ab; x=&ab;", "&"));
|
||||||
ASSERT_EQUALS("A::BC *", typeOf("namespace A { struct BC { int b; int c; }; }; struct A::BC abc; x=&abc;", "&"));
|
ASSERT_EQUALS("A::BC *", typeOf("namespace A { struct BC { int b; int c; }; }; struct A::BC abc; x=&abc;", "&"));
|
||||||
|
|
Loading…
Reference in New Issue