diff options
author | Jeff Law <law@gcc.gnu.org> | 2018-12-06 06:46:25 -0700 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2018-12-06 06:46:25 -0700 |
commit | 51948daf1ceb71db9d5682df42c6da079acaf3d7 (patch) | |
tree | 5f04b64af9d2f7a87fe2c3018488846ccc46a910 | |
parent | 44d6626ced36c5bec93ae6d72d29373e9f6aa36a (diff) | |
download | gcc-51948daf1ceb71db9d5682df42c6da079acaf3d7.zip gcc-51948daf1ceb71db9d5682df42c6da079acaf3d7.tar.gz gcc-51948daf1ceb71db9d5682df42c6da079acaf3d7.tar.bz2 |
Drop duplicate half of doubly-applied test.
From-SVN: r266854
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstringop-truncation-5.c | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/gcc/testsuite/gcc.dg/Wstringop-truncation-5.c b/gcc/testsuite/gcc.dg/Wstringop-truncation-5.c index dbb5e1f..f66c0ce 100644 --- a/gcc/testsuite/gcc.dg/Wstringop-truncation-5.c +++ b/gcc/testsuite/gcc.dg/Wstringop-truncation-5.c @@ -62,67 +62,3 @@ void test_compound_literal (struct S *s) strncpy (s->a, (char[]){ STR }, sizeof s->a - 1); s->a [sizeof s->a - 1] = '\0'; } -/* PR tree-optimization/87028 - false positive -Wstringop-truncation - strncpy with global variable source string - { dg-do compile } - { dg-options "-O2 -Wstringop-truncation" } */ - -char *strncpy (char *, const char *, __SIZE_TYPE__); - -#define STR "1234567890" - -struct S -{ - char a[5], b[5]; -}; - -const char arr[] = STR; -const char* const ptr = STR; - -const char arr2[][10] = { "123", STR }; - -void test_literal (struct S *s) -{ - strncpy (s->a, STR, sizeof s->a - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ - s->a[sizeof s->a - 1] = '\0'; -} - -void test_global_arr (struct S *s) -{ - strncpy (s->a, arr, sizeof s->a - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ - s->a [sizeof s->a - 1] = '\0'; -} - -void test_global_arr2 (struct S *s) -{ - strncpy (s->a, arr2[1], sizeof s->a - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ - s->a [sizeof s->a - 1] = '\0'; - - strncpy (s->b, arr2[0], sizeof s->a - 1); -} - -void test_global_ptr (struct S *s) -{ - strncpy (s->a, ptr, sizeof s->a - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ - s->a [sizeof s->a - 1] = '\0'; -} - -void test_local_arr (struct S *s) -{ - const char arr[] = STR; - strncpy (s->a, arr, sizeof s->a - 1); - s->a [sizeof s->a - 1] = '\0'; -} - -void test_local_ptr (struct S *s) -{ - const char* const ptr = STR; - strncpy (s->a, ptr, sizeof s->a - 1); /* { dg-bogus "\\\[-Wstringop-truncation]" } */ - s->a [sizeof s->a - 1] = '\0'; -} - -void test_compound_literal (struct S *s) -{ - strncpy (s->a, (char[]){ STR }, sizeof s->a - 1); - s->a [sizeof s->a - 1] = '\0'; -} |