Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/checkio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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 {
else if (!hasEnumType) {
tempToken = new Token(tok1);
tempToken->str("int");
typeToken = tempToken;
Expand Down
14 changes: 14 additions & 0 deletions test/testio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3371,6 +3371,20 @@ class TestIO : public TestFixture {
"}");
ASSERT_EQUALS("", errout_str());

check("enum E : uint8_t { E0 }; \n" // #7959
"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));
Expand Down
Loading