File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ static bool isPtrArg(const Token *tok)
5858static bool isArrayArg (const Token *tok, const Settings& settings)
5959{
6060 const Variable *var = tok->variable ();
61- return (var && var->isArgument () && var->isArray () && ! settings.library .isentrypoint (var->scope ()->className ));
61+ return (var && var->isArgument () && var->isArray () && (!var-> scope () || ! settings.library .isentrypoint (var->scope ()->className ) ));
6262}
6363
6464static bool isArrayVar (const Token *tok)
Original file line number Diff line number Diff line change @@ -165,6 +165,7 @@ class TestAutoVariables : public TestFixture {
165165 TEST_CASE (invalidLifetime);
166166 TEST_CASE (deadPointer);
167167 TEST_CASE (splitNamespaceAuto); // crash #10473
168+ TEST_CASE (incompleteTypeArray);
168169 }
169170
170171
@@ -4696,6 +4697,14 @@ class TestAutoVariables : public TestFixture {
46964697 ASSERT_EQUALS (" " , errout_str ());
46974698 }
46984699
4700+ void incompleteTypeArray () { // #13787
4701+ check (" struct S (*a[10]);\n "
4702+ " void f(int i, struct S* p) {\n "
4703+ " a[i] = &p[i];\n "
4704+ " }\n " );
4705+ ASSERT_EQUALS (" " , errout_str ()); // don't crash
4706+ }
4707+
46994708};
47004709
47014710REGISTER_TEST (TestAutoVariables)
You can’t perform that action at this time.
0 commit comments