diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index b18a85ca3..336e5f7ec 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -78,7 +78,7 @@ static bool isEnumStart(const Token* tok) { if (!tok || tok->str() != "{") return false; - return (tok->strAt(-1) == "enum") || (tok->strAt(-2) == "enum"); + return (tok->strAt(-1) == "enum") || (tok->strAt(-2) == "enum") || Token::Match(tok->tokAt(-3), "enum class %name%"); } template diff --git a/test/test64bit.cpp b/test/test64bit.cpp index 9ea1bfcad..e506190f8 100644 --- a/test/test64bit.cpp +++ b/test/test64bit.cpp @@ -161,6 +161,16 @@ private: " int i = foo->p;\n" "}"); ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning a pointer to an integer is not portable.\n", errout.str()); + + check("struct S {\n" // #10145 + " enum class E { e1, e2 };\n" + " E e;\n" + " char* e1;\n" + "};\n" + "void f(S& s) {\n" + " s.e = S::E::e1;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void ptrcompare() {