diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 0f02016bd01..a023c4c7109 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2032,7 +2032,7 @@ void CheckClassImpl::virtualDestructor() } // Check if destructor is empty and non-empty .. - if (mSettings.standards.cpp <= Standards::CPP03) { + if (mSettings.standards.cpp == Standards::CPP03) { // Find the destructor const Function *destructor = scope->getDestructor(); diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index c2ce2db812b..10e6855d7a0 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -7550,10 +7550,13 @@ static const Token* parsedecl(const Token* type, else if (valuetype->typeScope->type == ScopeType::eEnum) { const Token * enum_type = valuetype->typeScope->enumType; if (enum_type) { + ValueType evt; if (enum_type->isSigned()) valuetype->sign = ValueType::Sign::SIGNED; else if (enum_type->isUnsigned()) valuetype->sign = ValueType::Sign::UNSIGNED; + else if (!enum_type->isStandardType() && parsedecl(enum_type, &evt, defaultSignedness, settings)) + *valuetype = evt; else valuetype->sign = defaultSignedness; // TODO: this is implementation-dependent might be separate from char const ValueType::Type t = ValueType::typeFromString(enum_type->str(), enum_type->isLong()); @@ -7728,8 +7731,10 @@ static const Token* parsedecl(const Token* type, valuetype->type = type->str() == "struct" ? ValueType::Type::RECORD : ValueType::Type::NONSTD; else if (!valuetype->typeScope && type->type() && type->type()->classScope && valuetype->type != ValueType::Type::SMART_POINTER) { if (type->type()->classScope->type == ScopeType::eEnum) { - valuetype->sign = ValueType::Sign::SIGNED; - valuetype->type = getEnumType(type->type()->classScope, settings.platform); + if (valuetype->type == ValueType::Type::UNKNOWN_TYPE) { + valuetype->sign = ValueType::Sign::SIGNED; + valuetype->type = getEnumType(type->type()->classScope, settings.platform); + } } else { valuetype->type = ValueType::Type::RECORD; } diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 4d989804b36..c417ac209e6 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -6650,6 +6650,13 @@ class TestCondition : public TestFixture { "[test.cpp:2:28]: (style) Comparing expression of type 'signed int' against value 2147483647. Condition is always false. [compareValueOutOfTypeRangeError]\n" "[test.cpp:7:17]: (style) Comparing expression of type 'signed int' against value 2147483647. Condition is always false. [compareValueOutOfTypeRangeError]\n", errout_str()); + + check("enum E : std::uint8_t {};\n" // #11243 + "void f(E e) {\n" + " if (e == 256) {}\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3:14]: (style) Comparing expression of type 'unsigned char' against value 256. Condition is always false. [compareValueOutOfTypeRangeError]\n", + errout_str()); } void knownConditionCast() { diff --git a/test/testio.cpp b/test/testio.cpp index ad95345e1fd..6e96d075320 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -3497,9 +3497,8 @@ class TestIO : public TestFixture { "void f(E e) {\n" " printf(\"%lu\", e);\n" "}\n"); - TODO_ASSERT_EQUALS("[test.cpp:3]: (warning) %lu in format string (no. 1) requires 'unsigned long' but the argument type is 'uint8_t'.\n", - "", - errout_str()); + ASSERT_EQUALS("[test.cpp:3]: (warning) %lu in format string (no. 1) requires 'unsigned long' but the argument type is 'unsigned char'.\n", + errout_str()); check("void f() {\n" " printf(\"%lu\", sizeof(char));\n"