diff --git a/lib/forwardanalyzer.cpp b/lib/forwardanalyzer.cpp index 562b1206b..dfbfcd216 100644 --- a/lib/forwardanalyzer.cpp +++ b/lib/forwardanalyzer.cpp @@ -413,7 +413,7 @@ struct ForwardTraversal { return Break(); if (stepTok && updateRecursive(stepTok) == Progress::Break) return Break(); - if (condTok && updateRecursive(condTok) == Progress::Break) + if (condTok && !Token::simpleMatch(condTok, ":") && updateRecursive(condTok) == Progress::Break) return Break(); return Progress::Continue; } diff --git a/test/testother.cpp b/test/testother.cpp index 922d47696..25c612121 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -266,6 +266,7 @@ private: TEST_CASE(moveClassVariable); TEST_CASE(forwardAndUsed); TEST_CASE(moveAndReference); + TEST_CASE(moveForRange); TEST_CASE(funcArgNamesDifferent); TEST_CASE(funcArgOrderDifferent); @@ -10342,6 +10343,18 @@ private: ASSERT_EQUALS("[test.cpp:7]: (warning) Access of moved variable 'r'.\n", errout.str()); } + void moveForRange() + { + check("struct C {\n" + " void f() {\n" + " for (auto r : mCategory.find(std::move(mWhere))) {}\n" + " }\n" + " cif::category mCategory;\n" + " cif::condition mWhere;\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); + } + void funcArgNamesDifferent() { check("void func1(int a, int b, int c);\n" "void func1(int a, int b, int c) { }\n"