diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/Wstringop-overflow-37.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstringop-overflow-37.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-37.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-37.c index 339f904..46f8fed 100644 --- a/gcc/testsuite/gcc.dg/Wstringop-overflow-37.c +++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-37.c @@ -185,6 +185,18 @@ void test_note (const char *s) } { + char a[1][1][2]; // { dg-message "at offset 2 into " } + strncpy (a[0][1], s, 3); // { dg-warning "writing 3 bytes into a region of size 0 " } + sink (a); + } + + { + char a[1][2][2]; // { dg-message "destination object" } + strncpy (a[0][0], s, 3); // { dg-warning "writing 3 bytes into a region of size 2 " } + sink (a); + } + + { char a[1][2][2]; // { dg-message "at offset 2 into " } strncpy (a[0][1], s, 3); // { dg-warning "writing 3 bytes into a region of size 2 " } sink (a); @@ -192,7 +204,13 @@ void test_note (const char *s) { char a[1][2][2]; // { dg-message "at offset 4 into " } - strncpy (a[1][0], s, 3); // { dg-warning "writing 3 bytes into a region of size 2 " } + strncpy (a[1][0], s, 3); // { dg-warning "writing 3 bytes into a region of size 0 " } + sink (a); + } + + { + char a[2][1][2]; // { dg-message "at offset 2 into " } + strncpy (a[0][1], s, 3); // { dg-warning "writing 3 bytes into a region of size 0 " } sink (a); } |