(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
Wrestrict-13.c
       1  /* PR tree-optimization/83519 - missing -Wrestrict on an overlapping
       2     strcpy to a non-member array
       3     { dg-do compile }
       4     { dg-options "-O2 -Wall -Wrestrict" }  */
       5  
       6  extern char* stpcpy (char*, const char*);   // work around bug 82429
       7  
       8  struct S { char a[17]; };
       9  
      10  void f (struct S *p, const char *s)
      11  {
      12    __builtin_strcpy (p->a, "0123456789abcdef");
      13  
      14    __builtin_strcpy (p->a, p->a + 4);    /* { dg-warning "\\\[-Wrestrict]" } */
      15  }
      16  
      17  char a[17];
      18  
      19  void g (const char *s)
      20  {
      21    __builtin_strcpy (a, "0123456789abcdef");
      22  
      23    __builtin_strcpy (a, a + 4);          /* { dg-warning "\\\[-Wrestrict]" } */
      24  }
      25  
      26  void h (const char *s)
      27  {
      28     char a[17];
      29  
      30    __builtin_strcpy (a, "0123456789abcdef");
      31  
      32    __builtin_strcpy (a, a + 4);          /* { dg-warning "\\\[-Wrestrict]" } */
      33  
      34    extern void sink (void*);
      35    sink (a);
      36  }