TestBufferOverrun: Added a test case that shouldn't generate error. Get address beyond array.

This commit is contained in:
Daniel Marjamäki 2008-11-05 07:48:07 +00:00
parent eb86a0fc34
commit b20c233599
1 changed files with 16 additions and 1 deletions

View File

@ -1,4 +1,4 @@
/* /*
* c++check - c/c++ syntax checking * c++check - c/c++ syntax checking
* Copyright (C) 2007 Daniel Marjamäki * Copyright (C) 2007 Daniel Marjamäki
* *
@ -62,6 +62,9 @@ private:
TEST_CASE( noerr2 ); TEST_CASE( noerr2 );
TEST_CASE( noerr3 ); TEST_CASE( noerr3 );
// Todo: Fix this.
//TEST_CASE( noerr4 );
TEST_CASE( array_index_1 ); TEST_CASE( array_index_1 );
TEST_CASE( array_index_2 ); TEST_CASE( array_index_2 );
TEST_CASE( array_index_3 ); TEST_CASE( array_index_3 );
@ -131,6 +134,18 @@ private:
} }
void noerr4()
{
// The memory isn't read or written and therefore there is no error.
check( "static void f()\n"
"{\n"
" char data[100];\n"
" const char *p = &data[100];\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}
void array_index_1() void array_index_1()
{ {
check("void f()\n" check("void f()\n"