PR tree-optimization/83519 - missing -Wrestrict on an overlapping strcpy to a non...
authorMartin Sebor <msebor@redhat.com>
Thu, 8 Mar 2018 00:56:07 +0000 (00:56 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Thu, 8 Mar 2018 00:56:07 +0000 (17:56 -0700)
gcc/testsuite/ChangeLog:

* gcc.dg/Wrestrict-13.c: New test.

From-SVN: r258348

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wrestrict-13.c [new file with mode: 0644]

index d795f0d9a71fc4018eb57901c36183c8237f3b32..a6f89e15dcf1c7bfda3475458860b7bfb333c6b5 100644 (file)
@@ -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
        PR target/82411
        * gcc.target/powerpc/ppc-sdata-2.c: Skip if -mno-readonly-in-sdata.
 
+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
diff --git a/gcc/testsuite/gcc.dg/Wrestrict-13.c b/gcc/testsuite/gcc.dg/Wrestrict-13.c
new file mode 100644 (file)
index 0000000..e4f00c7
--- /dev/null
@@ -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);
+}