From 51948daf1ceb71db9d5682df42c6da079acaf3d7 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Thu, 6 Dec 2018 06:46:25 -0700 Subject: [PATCH] Drop duplicate half of doubly-applied test. From-SVN: r266854 --- gcc/testsuite/gcc.dg/Wstringop-truncation-5.c | 64 ------------------- 1 file changed, 64 deletions(-) diff --git a/gcc/testsuite/gcc.dg/Wstringop-truncation-5.c b/gcc/testsuite/gcc.dg/Wstringop-truncation-5.c index dbb5e1fed32b..f66c0ce1e3f1 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'; -} -- 2.39.2