From 130cc52a42e09cc40bbb13f9210cef8ae09abef6 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 8 Oct 2026 17:08:14 +0200 Subject: [PATCH 1/5] Update testio.cpp --- test/testio.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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" From ad8a76d4cfd3924a80a97a6a0237bff25a9ddb14 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 8 Oct 2026 17:09:00 +0200 Subject: [PATCH 2/5] Update testcondition.cpp --- test/testcondition.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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() { From 4125d4b82d658b4ee9348a1ae0db79c41636860e Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 8 Oct 2026 17:11:16 +0200 Subject: [PATCH 3/5] Update symboldatabase.cpp --- lib/symboldatabase.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index c2ce2db812b..1e682328f24 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()); @@ -7727,12 +7730,8 @@ static const Token* parsedecl(const Token* type, } else if (!valuetype->typeScope && (type->str() == "struct" || type->str() == "enum") && valuetype->type != ValueType::Type::SMART_POINTER) 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); - } else { + if (type->type()->classScope->type != ScopeType::eEnum) valuetype->type = ValueType::Type::RECORD; - } valuetype->typeScope = type->type()->classScope; } else if (type->isName() && valuetype->sign != ValueType::Sign::UNKNOWN_SIGN && valuetype->pointer == 0U) return nullptr; From 8add06a3ee59cb7f44e1597f8ca3a1e4295e07d4 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Fri, 9 Oct 2026 22:26:47 +0200 Subject: [PATCH 4/5] Fix --- lib/symboldatabase.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 1e682328f24..10e6855d7a0 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -7730,8 +7730,14 @@ static const Token* parsedecl(const Token* type, } else if (!valuetype->typeScope && (type->str() == "struct" || type->str() == "enum") && valuetype->type != ValueType::Type::SMART_POINTER) 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) + if (type->type()->classScope->type == ScopeType::eEnum) { + 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; + } valuetype->typeScope = type->type()->classScope; } else if (type->isName() && valuetype->sign != ValueType::Sign::UNKNOWN_SIGN && valuetype->pointer == 0U) return nullptr; From 1b060fcc36ed34a1746e4e9d79cdadd9982f1b43 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Fri, 9 Oct 2026 23:21:08 +0200 Subject: [PATCH 5/5] Fix --- lib/checkclass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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();