Skip to content

Commit 4c9eae0

Browse files
Update testautovariables.cpp
1 parent c4f754e commit 4c9eae0

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

test/testautovariables.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,7 @@ class TestAutoVariables : public TestFixture {
711711
" g(&s);\n"
712712
"}");
713713
ASSERT_EQUALS(
714-
"[test.cpp:4:5]: (error) Address of local auto-variable assigned to a function parameter. [autoVariables]\n"
715-
"[test.cpp:4:5]: (error) Address of local auto-variable assigned to a function parameter. [autoVariables]\n", // duplicate
714+
"[test.cpp:4:5]: (error) Address of local auto-variable assigned to a function parameter. [autoVariables]\n",
716715
errout_str());
717716
}
718717

@@ -4693,6 +4692,21 @@ class TestAutoVariables : public TestFixture {
46934692
"}\n");
46944693
ASSERT_EQUALS("", errout_str());
46954694

4695+
check("struct S {\n"
4696+
" int* a[1];\n"
4697+
" int* b[1][1];\n"
4698+
"};\n"
4699+
"void f(S* s) {\n"
4700+
" int i = 0;\n"
4701+
" s->a[0] = &i;\n"
4702+
"}\n"
4703+
"void g(S* s) {\n"
4704+
" int i = 0;\n"
4705+
" s->b[0][0] = &i;\n"
4706+
"}\n");
4707+
ASSERT_EQUALS("[test.cpp:7:5]: (error) Address of local auto-variable assigned to a function parameter. [autoVariables]\n"
4708+
"[test.cpp:11:5]: (error) Address of local auto-variable assigned to a function parameter. [autoVariables]\n",
4709+
errout_str());
46964710
}
46974711

46984712
void deadPointer() {

0 commit comments

Comments
 (0)