diff --git a/lib/checkpostfixoperator.h b/lib/checkpostfixoperator.h index a993554a7..fe22749ce 100644 --- a/lib/checkpostfixoperator.h +++ b/lib/checkpostfixoperator.h @@ -50,13 +50,15 @@ public: : Check(myName(), tokenizer, settings, errorLogger) { } - void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) { + void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) { if (tokenizer->isC()) return; CheckPostfixOperator checkPostfixOperator(tokenizer, settings, errorLogger); checkPostfixOperator.postfixOperator(); } + void runSimplifiedChecks(const Tokenizer * /*tokenizer*/, const Settings * /*settings*/, ErrorLogger * /*errorLogger*/) { + } /** Check postfix operators */ void postfixOperator(); diff --git a/test/testpostfixoperator.cpp b/test/testpostfixoperator.cpp index 53498635c..d8043e448 100644 --- a/test/testpostfixoperator.cpp +++ b/test/testpostfixoperator.cpp @@ -40,7 +40,6 @@ private: Tokenizer tokenizer(&settings, this); std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); - tokenizer.simplifyTokenList2(); // Check for postfix operators.. CheckPostfixOperator checkPostfixOperator(&tokenizer, &settings, this); @@ -59,6 +58,7 @@ private: TEST_CASE(testtemplate); // #4686 TEST_CASE(testmember); TEST_CASE(testcomma); + TEST_CASE(testauto); // #8350 } void testsimple() { @@ -352,6 +352,18 @@ private: "}"); ASSERT_EQUALS("", errout.str()); } + + void testauto() { // #8350 + check("enum class Color { Red = 0, Green = 1, };\n" + "int fun(const Color color) {\n" + " auto a = 0;\n" + " for (auto i = static_cast(color); i < 10; i++) {\n" + " a += i;\n" + " }\n" + " return a;\n" + "}"); + ASSERT_EQUALS("", errout.str()); + } }; REGISTER_TEST(TestPostfixOperator)