Match: Optimize log (x) CMP CST and exp (x) CMP CST operations
[official-gcc.git] / gcc / testsuite / gcc.dg / Warray-bounds-16.c
blob20008f6fee0a4f6dc1e1953dbbbfc08801db8556
1 /* { dg-do compile } */
2 /* { dg-options "-O3 -Warray-bounds" } */
4 typedef struct foo {
5 unsigned char foo_size;
6 int buf[4];
7 const char* bar;
8 } foo;
10 const foo *get_foo(int index);
12 static int foo_loop(const foo *myfoo) {
13 int i;
14 if (myfoo->foo_size < 3)
15 return 0;
16 for (i = 0; i < myfoo->foo_size; i++) {
17 if (myfoo->buf[i] != 1) /* { dg-bogus "above array bounds" } */
18 return 0;
21 return 1;
24 static int run_foo(void) {
25 int i;
26 for (i = 0; i < 1; i++) {
27 const foo *myfoo = get_foo(i);
28 if (foo_loop(myfoo))
29 return 0;
31 return -1;
34 typedef struct hack {
35 int (*func)(void);
36 } hack;
38 hack myhack = {
39 .func = run_foo,