diff options
author | Martin Sebor <msebor@redhat.com> | 2018-03-08 00:56:07 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2018-03-07 17:56:07 -0700 |
commit | 1b1a188198d510bc7400386c9f7fea650d1d7aba (patch) | |
tree | 1f7052a6c16f3baef2d15cb459d1f35748a9b52c /gcc | |
parent | 00df7c36f5c0d082f3ac4f240546d3c4d4812fdd (diff) | |
download | gcc-1b1a188198d510bc7400386c9f7fea650d1d7aba.zip gcc-1b1a188198d510bc7400386c9f7fea650d1d7aba.tar.gz gcc-1b1a188198d510bc7400386c9f7fea650d1d7aba.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wrestrict-13.c | 36 |
2 files changed, 46 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d795f0d..a6f89e1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-07 Martin Sebor <msebor@redhat.com> + + PR tree-optimization/83519 + * gcc.dg/Wrestrict-13.c: New test. + 2018-03-07 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/64124 @@ -12,6 +17,11 @@ 2018-03-07 Martin Sebor <msebor@redhat.com> + PR tree-optimization/84526 + * gcc.dg/Wrestrict-10.c: New test. + +2018-03-07 Martin Sebor <msebor@redhat.com> + PR tree-optimization/84468 * g++.dg/warn/Wstringop-truncation-2.C: New test. * gcc.dg/Wstringop-truncation.c: New test. diff --git a/gcc/testsuite/gcc.dg/Wrestrict-13.c b/gcc/testsuite/gcc.dg/Wrestrict-13.c new file mode 100644 index 0000000..e4f00c7 --- /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); +} |