File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -2785,6 +2785,8 @@ static bool isDecayedPointer(const Token *tok)
27852785 return false ;
27862786 if (!tok->astParent ())
27872787 return false ;
2788+ if (Token::simpleMatch (tok->astParent (), " =" ) && astIsRHS (tok))
2789+ return true ;
27882790 if (astIsPointer (tok->astParent ()) && !Token::simpleMatch (tok->astParent (), " return" ))
27892791 return true ;
27902792 if (tok->astParent ()->isConstOp ())
Original file line number Diff line number Diff line change @@ -743,6 +743,17 @@ class TestValueFlow : public TestFixture {
743743 lifetimes = lifetimeValues (code, " return" ); // don't crash
744744 ASSERT_EQUALS (true , lifetimes.empty ());
745745 }
746+
747+ {
748+ const char code[] = " void f() {\n " // #13076
749+ " char a[10];\n "
750+ " struct S s = { sizeof(a), 0 };\n "
751+ " s.p = a;\n "
752+ " }\n " ;
753+ lifetimes = lifetimeValues (code, " = a" );
754+ ASSERT_EQUALS (true , lifetimes.size () == 1 );
755+ ASSERT_EQUALS (true , lifetimes.front () == " a" );
756+ }
746757 }
747758
748759 void valueFlowArrayElement () {
You can’t perform that action at this time.
0 commit comments