view gcc/testsuite/gcc.dg/Wrestrict-13.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 84e7813d76e9
children
line wrap: on
line source

/* 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);
}