@@ -304,6 +304,7 @@ class TestOther : public TestFixture {
304304 TEST_CASE(moveForRange);
305305 TEST_CASE(moveTernary);
306306 TEST_CASE(movePointerAlias);
307+ TEST_CASE(moveOutparam);
307308
308309 TEST_CASE(funcArgNamesDifferent);
309310 TEST_CASE(funcArgOrderDifferent);
@@ -12550,7 +12551,8 @@ class TestOther : public TestFixture {
1255012551 " A c = a;\n"
1255112552 "}");
1255212553 ASSERT_EQUALS("[test.cpp:4:7]: (warning, inconclusive) Access of moved variable 'a'. [accessMoved]\n"
12553- "[test.cpp:5:11]: (warning, inconclusive) Access of moved variable 'a'. [accessMoved]\n", errout_str());
12554+ "[test.cpp:5:11]: (warning, inconclusive) Access of moved variable 'a'. [accessMoved]\n",
12555+ errout_str());
1255412556 }
1255512557
1255612558 void moveAndReturn() {
@@ -12730,6 +12732,27 @@ class TestOther : public TestFixture {
1273012732 ASSERT_EQUALS("[test.cpp:5:8]: (warning) Access of moved variable '.'. [accessMoved]\n", errout_str());
1273112733 }
1273212734
12735+ void moveOutparam()
12736+ {
12737+ check("void f(std::vector<std::string>& v) {\n" // #11300
12738+ " std::string l;\n"
12739+ " while (std::getline(std::cin, l)) {\n"
12740+ " if (!l.empty()) {\n"
12741+ " v.emplace_back(std::move(l));\n"
12742+ " }\n"
12743+ " }\n"
12744+ "}\n");
12745+ ASSERT_EQUALS("", errout_str());
12746+
12747+ check("void f(std::ifstream& fin, std::set<std::string>& s) {\n"
12748+ " std::string line;\n"
12749+ " while (std::getline(fin, line)) {\n"
12750+ " s.emplace(std::move(line));\n"
12751+ " }\n"
12752+ "}\n");
12753+ ASSERT_EQUALS("", errout_str());
12754+ }
12755+
1273312756 void funcArgNamesDifferent() {
1273412757 check("void func1(int a, int b, int c);\n"
1273512758 "void func1(int a, int b, int c) { }\n"
0 commit comments