diff --git a/lib/checkother.cpp b/lib/checkother.cpp index a671d0b58..3d7826652 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2967,7 +2967,7 @@ void CheckOther::checkUnusedLabel() if (!tok->scope()->isExecutable()) tok = tok->scope()->bodyEnd; - if (Token::Match(tok, "{|}|; %name% :") && tok->strAt(1) != "default") { + if (Token::Match(tok, "{|}|; %name% :") && !tok->tokAt(1)->isKeyword()) { const std::string tmp("goto " + tok->strAt(1)); if (!Token::findsimplematch(scope->bodyStart->next(), tmp.c_str(), tmp.size(), scope->bodyEnd->previous())) unusedLabelError(tok->next(), tok->next()->scope()->type == Scope::eSwitch, hasIfdef); diff --git a/test/testother.cpp b/test/testother.cpp index 52183a2fa..59e47130f 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4071,6 +4071,11 @@ private: " return 1;\n" // <- clarify for tools that function does not continue.. "}"); ASSERT_EQUALS("", errout.str()); + + check("void f() {\n" + " enum : uint8_t { A, B } var = A;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); }