From d3a5a908c67bc77d30013a408dbfb69b12ffde8f Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 6 May 2026 11:12:46 +0200 Subject: [PATCH 1/4] Update checkio.cpp --- lib/checkio.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/checkio.cpp b/lib/checkio.cpp index 0e1d0395146..b63c5decca9 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -1539,9 +1539,9 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * arg, const Settings &settings, if (element && isStdVectorOrString()) { // isStdVectorOrString sets type token if true element = false; // not really an array element } else if (variableInfo->isEnumType()) { - if (variableInfo->type() && variableInfo->type()->classScope && variableInfo->type()->classScope->enumType) + if (variableInfo->type() && variableInfo->type()->classScope && variableInfo->type()->classScope->enumType && variableInfo->type()->classScope->enumType->isStandardType()) typeToken = variableInfo->type()->classScope->enumType; - else { + else if (!variableInfo->type()->classScope->enumType) { tempToken = new Token(tok1); tempToken->str("int"); typeToken = tempToken; From 51ba8547a38fa26e24d4c669130b53e104428fd2 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 6 May 2026 11:14:47 +0200 Subject: [PATCH 2/4] Update testio.cpp --- test/testio.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/testio.cpp b/test/testio.cpp index ec6a87a1e16..2efce4a97af 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -3371,6 +3371,20 @@ class TestIO : public TestFixture { "}"); ASSERT_EQUALS("", errout_str()); + check("enum E : uint8_t { E0 }; \n" + "void f(E e) {\n" + " printf(\"%hhu\", e);\n" + "}"); + ASSERT_EQUALS("", errout_str()); + + check("enum E : uint8_t { E0 }; \n" + "void f(E e) {\n" + " printf(\"%lu\", e);\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()); + check("void f() {\n" " printf(\"%lu\", sizeof(char));\n" "}\n", dinit(CheckOptions, $.portability = true, $.platform = Platform::Type::Win64)); From 4ad6cb1e46d56264939a250f05ac9473a0a4acd6 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 6 May 2026 11:15:31 +0200 Subject: [PATCH 3/4] Update testio.cpp --- test/testio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testio.cpp b/test/testio.cpp index 2efce4a97af..02180f12376 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -3371,7 +3371,7 @@ class TestIO : public TestFixture { "}"); ASSERT_EQUALS("", errout_str()); - check("enum E : uint8_t { E0 }; \n" + check("enum E : uint8_t { E0 }; \n" // #7959 "void f(E e) {\n" " printf(\"%hhu\", e);\n" "}"); From 20d3a29041b32ad63315f98b56bac6042198fdaf Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 6 May 2026 11:23:12 +0200 Subject: [PATCH 4/4] Update checkio.cpp --- lib/checkio.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/checkio.cpp b/lib/checkio.cpp index b63c5decca9..8b3c835caf3 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -1539,9 +1539,10 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * arg, const Settings &settings, if (element && isStdVectorOrString()) { // isStdVectorOrString sets type token if true element = false; // not really an array element } else if (variableInfo->isEnumType()) { - if (variableInfo->type() && variableInfo->type()->classScope && variableInfo->type()->classScope->enumType && variableInfo->type()->classScope->enumType->isStandardType()) + const bool hasEnumType = variableInfo->type() && variableInfo->type()->classScope && variableInfo->type()->classScope->enumType; + if (hasEnumType && variableInfo->type()->classScope->enumType->isStandardType()) typeToken = variableInfo->type()->classScope->enumType; - else if (!variableInfo->type()->classScope->enumType) { + else if (!hasEnumType) { tempToken = new Token(tok1); tempToken->str("int"); typeToken = tempToken;