summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wrestrict-13.c
blob: e4f00c7f2fb2c44cebd30a3856d81c36e2515b8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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);
}