| 1 |
/* PR middle-end/101671 - pr83510 fails with -Os because threader confuses |
| 2 |
-Warray-bounds |
| 3 |
{ dg-do compile } |
| 4 |
{ dg-options "-Os -Wall" } */ |
| 5 |
|
| 6 |
extern int f (void); |
| 7 |
extern void sink (unsigned int); |
| 8 |
|
| 9 |
unsigned int a[10]; |
| 10 |
|
| 11 |
static unsigned int g (int i, int j) |
| 12 |
{ |
| 13 |
if (i == 9) |
| 14 |
return j; |
| 15 |
else if (i == 10) |
| 16 |
return a[i]; // no warning here |
| 17 |
return 0; |
| 18 |
} |
| 19 |
|
| 20 |
void test_g (int j) |
| 21 |
{ |
| 22 |
for (int i = 0; i < 10; i++) |
| 23 |
{ |
| 24 |
if (f ()) |
| 25 |
sink (g (i, j)); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
static unsigned int h (int i, int j) |
| 30 |
{ |
| 31 |
switch (i) |
| 32 |
{ |
| 33 |
case 9: |
| 34 |
return j; |
| 35 |
case 10: |
| 36 |
return a[i]; // { dg-bogus "-Warray-bounds" "pr101671" } |
| 37 |
} |
| 38 |
return 0; |
| 39 |
} |
| 40 |
|
| 41 |
void test_h (int j) |
| 42 |
{ |
| 43 |
for (int i = 0; i < 10; i++) |
| 44 |
{ |
| 45 |
if (f ()) |
| 46 |
sink (h (i, j)); |
| 47 |
} |
| 48 |
} |