Fix 11578: FP accessMoved with range-based for loop (#4931)
* Fix 11578: FP accessMoved with range-based for loop * Format
This commit is contained in:
parent
86efca28a3
commit
d5e2ee411e
|
@ -413,7 +413,7 @@ struct ForwardTraversal {
|
||||||
return Break();
|
return Break();
|
||||||
if (stepTok && updateRecursive(stepTok) == Progress::Break)
|
if (stepTok && updateRecursive(stepTok) == Progress::Break)
|
||||||
return Break();
|
return Break();
|
||||||
if (condTok && updateRecursive(condTok) == Progress::Break)
|
if (condTok && !Token::simpleMatch(condTok, ":") && updateRecursive(condTok) == Progress::Break)
|
||||||
return Break();
|
return Break();
|
||||||
return Progress::Continue;
|
return Progress::Continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,6 +266,7 @@ private:
|
||||||
TEST_CASE(moveClassVariable);
|
TEST_CASE(moveClassVariable);
|
||||||
TEST_CASE(forwardAndUsed);
|
TEST_CASE(forwardAndUsed);
|
||||||
TEST_CASE(moveAndReference);
|
TEST_CASE(moveAndReference);
|
||||||
|
TEST_CASE(moveForRange);
|
||||||
|
|
||||||
TEST_CASE(funcArgNamesDifferent);
|
TEST_CASE(funcArgNamesDifferent);
|
||||||
TEST_CASE(funcArgOrderDifferent);
|
TEST_CASE(funcArgOrderDifferent);
|
||||||
|
@ -10342,6 +10343,18 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:7]: (warning) Access of moved variable 'r'.\n", errout.str());
|
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() {
|
void funcArgNamesDifferent() {
|
||||||
check("void func1(int a, int b, int c);\n"
|
check("void func1(int a, int b, int c);\n"
|
||||||
"void func1(int a, int b, int c) { }\n"
|
"void func1(int a, int b, int c) { }\n"
|
||||||
|
|
Loading…
Reference in New Issue