File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ class TestAutoVariables : public TestFixture {
6969 TEST_CASE (testautovar15); // ticket #6538
7070 TEST_CASE (testautovar16); // ticket #8114
7171 TEST_CASE (testautovar17);
72+ TEST_CASE (testautovar18);
7273 TEST_CASE (testautovar_array1);
7374 TEST_CASE (testautovar_array2);
7475 TEST_CASE (testautovar_array3);
@@ -516,6 +517,15 @@ class TestAutoVariables : public TestFixture {
516517 ASSERT_EQUALS (" " , errout_str ());
517518 }
518519
520+ void testautovar18 () {
521+ check (" struct S { int* p; };\n "
522+ " void foo(struct S* s) {\n "
523+ " int x;\n "
524+ " s[2].p = &x;\n "
525+ " }\n " );
526+ ASSERT_EQUALS (" [test.cpp:4:5]: (error) Address of local auto-variable assigned to a function parameter. [autoVariables]\n " , errout_str ());
527+ }
528+
519529 void testautovar_array1 () {
520530 check (" void func1(int* arr[2])\n "
521531 " {\n "
You can’t perform that action at this time.
0 commit comments