Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/checkautovariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ static bool isAutoVar(const Token *tok)
} while (Token::Match(tok, "%name% .|::"));
if (Token::Match(tok, "%name% ("))
return false;
if (tok->variable() && tok->variable()->isPointer())
return false;
}
return true;
}
Expand Down
12 changes: 12 additions & 0 deletions test/testautovariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class TestAutoVariables : public TestFixture {
TEST_CASE(testautovar14); // ticket #4776 - assignment of function parameter, goto
TEST_CASE(testautovar15); // ticket #6538
TEST_CASE(testautovar16); // ticket #8114
TEST_CASE(testautovar17);
TEST_CASE(testautovar_array1);
TEST_CASE(testautovar_array2);
TEST_CASE(testautovar_array3);
Expand Down Expand Up @@ -504,6 +505,17 @@ class TestAutoVariables : public TestFixture {
ASSERT_EQUALS("", errout_str());
}

void testautovar17() {
check("struct S { int* p; };\n" // #14257
"int a[10];\n"
"void f(int** q) {\n"
" S s;\n"
" s.p = a;\n"
" *q = &s.p[0];\n"
"}\n");
ASSERT_EQUALS("", errout_str());
}

void testautovar_array1() {
check("void func1(int* arr[2])\n"
"{\n"
Expand Down