File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -770,7 +770,7 @@ struct ForwardTraversal {
770770 tryTraversal.updateRange (tok->next (), endBlock, depth - 1 );
771771 bool bail = tryTraversal.actions .isModified ();
772772 if (bail)
773- analyzer-> lowerToPossible ();
773+ return Break ();
774774
775775 while (Token::simpleMatch (endBlock, " } catch (" )) {
776776 Token* endCatch = endBlock->linkAt (2 );
Original file line number Diff line number Diff line change @@ -265,6 +265,7 @@ class TestOther : public TestFixture {
265265 TEST_CASE (moveCallback);
266266 TEST_CASE (moveClassVariable);
267267 TEST_CASE (forwardAndUsed);
268+ TEST_CASE (moveAndReference);
268269
269270 TEST_CASE (funcArgNamesDifferent);
270271 TEST_CASE (funcArgOrderDifferent);
@@ -10193,6 +10194,18 @@ class TestOther : public TestFixture {
1019310194 ASSERT_EQUALS (" [test.cpp:4]: (warning) Access of forwarded variable 't'.\n " , errout.str ());
1019410195 }
1019510196
10197+ void moveAndReference () { // #9791
10198+ check (" void g(std::string&&);\n "
10199+ " void h(const std::string&);\n "
10200+ " void f() {\n "
10201+ " std::string s;\n "
10202+ " const std::string& r = s;\n "
10203+ " g(std::move(s));\n "
10204+ " h(r);\n "
10205+ " }\n " );
10206+ ASSERT_EQUALS (" [test.cpp:7]: (warning) Access of moved variable 'r'.\n " , errout.str ());
10207+ }
10208+
1019610209 void funcArgNamesDifferent () {
1019710210 check (" void func1(int a, int b, int c);\n "
1019810211 " void func1(int a, int b, int c) { }\n "
Original file line number Diff line number Diff line change @@ -5407,6 +5407,18 @@ class TestUninitVar : public TestFixture {
54075407 " (void)p[i];\n "
54085408 " }\n " );
54095409 ASSERT_EQUALS (" " , errout.str ());
5410+
5411+ // #11492
5412+ valueFlowUninit (" void f() {\n "
5413+ " int i;\n "
5414+ " try {\n "
5415+ " i = 0;\n "
5416+ " }\n "
5417+ " catch (...) {\n "
5418+ " if (i) {}\n "
5419+ " }\n "
5420+ " }\n " );
5421+ ASSERT_EQUALS (" " , errout.str ());
54105422 }
54115423
54125424 void valueFlowUninitBreak () { // Do not show duplicate warnings about the same uninitialized value
You can’t perform that action at this time.
0 commit comments