From: Martin Sebor Date: Thu, 8 Mar 2018 00:56:07 +0000 (+0000) Subject: PR tree-optimization/83519 - missing -Wrestrict on an overlapping strcpy to a non... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1b1a188198d510bc7400386c9f7fea650d1d7aba;p=gcc.git PR tree-optimization/83519 - missing -Wrestrict on an overlapping strcpy to a non-member array gcc/testsuite/ChangeLog: * gcc.dg/Wrestrict-13.c: New test. From-SVN: r258348 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d795f0d9a71..a6f89e15dcf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-07 Martin Sebor + + PR tree-optimization/83519 + * gcc.dg/Wrestrict-13.c: New test. + 2018-03-07 Steven G. Kargl PR fortran/64124 @@ -10,6 +15,11 @@ PR target/82411 * gcc.target/powerpc/ppc-sdata-2.c: Skip if -mno-readonly-in-sdata. +2018-03-07 Martin Sebor + + PR tree-optimization/84526 + * gcc.dg/Wrestrict-10.c: New test. + 2018-03-07 Martin Sebor PR tree-optimization/84468 diff --git a/gcc/testsuite/gcc.dg/Wrestrict-13.c b/gcc/testsuite/gcc.dg/Wrestrict-13.c new file mode 100644 index 00000000000..e4f00c7f2fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wrestrict-13.c @@ -0,0 +1,36 @@ +/* PR tree-optimization/83519 - missing -Wrestrict on an overlapping + strcpy to a non-member array + { dg-do compile } + { dg-options "-O2 -Wall -Wrestrict" } */ + +extern char* stpcpy (char*, const char*); // work around bug 82429 + +struct S { char a[17]; }; + +void f (struct S *p, const char *s) +{ + __builtin_strcpy (p->a, "0123456789abcdef"); + + __builtin_strcpy (p->a, p->a + 4); /* { dg-warning "\\\[-Wrestrict]" } */ +} + +char a[17]; + +void g (const char *s) +{ + __builtin_strcpy (a, "0123456789abcdef"); + + __builtin_strcpy (a, a + 4); /* { dg-warning "\\\[-Wrestrict]" } */ +} + +void h (const char *s) +{ + char a[17]; + + __builtin_strcpy (a, "0123456789abcdef"); + + __builtin_strcpy (a, a + 4); /* { dg-warning "\\\[-Wrestrict]" } */ + + extern void sink (void*); + sink (a); +}