comparison gcc/testsuite/gcc.dg/Warray-bounds-37.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* PR tree-optimization/88800 - Spurious -Werror=array-bounds for non-taken
2 branch
3 { dg-do compile }
4 { dg-options "-O2 -Wall" } */
5
6 extern void* memmove (void*, const void*, __SIZE_TYPE__);
7
8 struct A
9 {
10 const char *s;
11 int n;
12 };
13
14 void f (void*);
15
16 struct B
17 {
18 char d[5];
19 int n;
20 };
21
22 __attribute__ ((always_inline)) inline void
23 g (struct B *p, struct A a)
24 {
25 int i = a.n;
26 if (i <= 5)
27 p->n = i;
28 else {
29 p->n = -1;
30 f (p);
31 }
32
33 if (p->n >= 0)
34 memmove (p->d, a.s, a.n); /* { dg-bogus "\\\[-Warray-bounds" } */
35 }
36
37 void h (void)
38 {
39 char c[8] = "";
40
41 struct A a;
42 a.s = c;
43 a.n = 8;
44
45 struct B b;
46 g (&b, a);
47 }