]>
Commit | Line | Data |
---|---|---|
1486eb79 MS |
1 | /* PR tree-optimization/86196 - Bogus -Wrestrict on memcpy between array |
2 | elements at unequal indices | |
3 | { dg-do compile } | |
4 | { dg-options "-O2 -Wall" } */ | |
5 | ||
6 | typedef __SIZE_TYPE__ size_t; | |
7 | ||
8 | extern void* memcpy (void*, const void*, size_t); | |
9 | ||
10 | struct S | |
11 | { | |
12 | int n; | |
13 | void * p; | |
14 | }; | |
15 | ||
16 | /* Test case submitted in the PR. */ | |
17 | ||
18 | void pr86196_c0 (struct S * a, size_t n) | |
19 | { | |
20 | for (size_t i = 0, j = 0; i != n; ++i) | |
21 | { | |
22 | if (a[i].n == 0) | |
23 | { | |
24 | if (i != j) | |
25 | memcpy (&a[j], &a[i], sizeof (struct S)); /* { dg-bogus "\\\[-Wrestrict" } */ | |
26 | ++j; | |
27 | } | |
28 | } | |
29 | } | |
30 | ||
31 | /* Reduced test case. */ | |
32 | ||
33 | void pr86196_c1 (struct S *a, int i, int j) | |
34 | { | |
35 | if (i != j) | |
36 | memcpy (&a[j], &a[i], sizeof (struct S)); /* { dg-bogus "\\\[-Wrestrict" } */ | |
37 | } |