#3030 add another regression test

This commit is contained in:
amai2012 2019-02-22 21:10:05 +01:00
parent 52c7a1b1c2
commit 7859d7d879
1 changed files with 9 additions and 0 deletions

View File

@ -802,6 +802,15 @@ private:
" return &q[1];\n" " return &q[1];\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("char *foo()\n"
"{\n"
"char q[] = \"AAAAAAAAAAAA\";\n"
"char *p;\n"
"p = &q[1];\n"
"return p;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3] -> [test.cpp:6]: (error) Returning pointer to local variable 'q' that will be invalid when returning.\n", errout.str());
} }
void returnLocalVariable4() { // x+y void returnLocalVariable4() { // x+y