File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2518,8 +2518,6 @@ bool isMutableExpression(const Token* tok)
25182518 if (tok->astOperand1 () && Token::simpleMatch (tok, " [" ))
25192519 return isMutableExpression (tok->astOperand1 ());
25202520 if (const Variable* var = tok->variable ()) {
2521- if (var->nameToken () == tok)
2522- return false ;
25232521 if (var->isConst () && !var->isPointer () && (!var->isArray () || !var->isArgument ()))
25242522 return false ;
25252523 }
Original file line number Diff line number Diff line change @@ -12651,6 +12651,24 @@ class TestOther : public TestFixture {
1265112651 " }\n"
1265212652 "}\n");
1265312653 ASSERT_EQUALS("[test.cpp:4:36]: (warning) Access of moved variable 'l'. [accessMoved]\n", errout_str());
12654+
12655+ check("struct S {\n" // #13179
12656+ " operator bool() const { return !m.empty(); }\n"
12657+ " std::string m;\n"
12658+ "};\n"
12659+ "S get();\n"
12660+ "void set(S);\n"
12661+ "void f() {\n"
12662+ " while (S s = get()) {\n"
12663+ " set(std::move(s));\n"
12664+ " }\n"
12665+ "}\n"
12666+ "void g() {\n"
12667+ " while (S s{ get() }) {\n"
12668+ " set(std::move(s));\n"
12669+ " }\n"
12670+ "}\n");
12671+ ASSERT_EQUALS("", errout_str());
1265412672 }
1265512673
1265612674 void moveCallback()
You can’t perform that action at this time.
0 commit comments