| 1 |
/* PR c/64279 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-Wduplicated-branches" } */ |
| 4 |
|
| 5 |
#define A 5 |
| 6 |
#define B 5 |
| 7 |
#define I i |
| 8 |
extern int a[10]; |
| 9 |
extern int g; |
| 10 |
|
| 11 |
int |
| 12 |
f (int i) |
| 13 |
{ |
| 14 |
if (i == 1) /* { dg-warning "this condition has identical branches" } */ |
| 15 |
return a[5]; |
| 16 |
else |
| 17 |
return a[5]; |
| 18 |
|
| 19 |
if (i == 2) /* { dg-bogus "this condition has identical branches" "" { xfail *-*-* } } */ |
| 20 |
return a[A]; |
| 21 |
else |
| 22 |
return a[5]; |
| 23 |
|
| 24 |
if (i == 3) /* { dg-bogus "this condition has identical branches" "" { xfail *-*-* } } */ |
| 25 |
return a[5]; |
| 26 |
else |
| 27 |
return a[A]; |
| 28 |
|
| 29 |
if (i == 4) /* { dg-warning "this condition has identical branches" } */ |
| 30 |
return a[A]; |
| 31 |
else |
| 32 |
return a[A]; |
| 33 |
|
| 34 |
if (i == 5) /* { dg-warning "this condition has identical branches" } */ |
| 35 |
return a[i]; |
| 36 |
else |
| 37 |
return a[i]; |
| 38 |
|
| 39 |
if (i == 6) /* { dg-bogus "this condition has identical branches" "" { xfail *-*-* } } */ |
| 40 |
return a[I]; |
| 41 |
else |
| 42 |
return a[i]; |
| 43 |
|
| 44 |
if (i == 7) /* { dg-bogus "this condition has identical branches" "" { xfail *-*-* } } */ |
| 45 |
return a[i]; |
| 46 |
else |
| 47 |
return a[I]; |
| 48 |
|
| 49 |
if (i == 8) /* { dg-warning "this condition has identical branches" } */ |
| 50 |
return a[I]; |
| 51 |
else |
| 52 |
return a[I]; |
| 53 |
|
| 54 |
if (i == 10) /* { dg-bogus "this condition has identical branches" "" { xfail *-*-* } } */ |
| 55 |
g += A; |
| 56 |
else |
| 57 |
g += B; |
| 58 |
|
| 59 |
if (i == 11) /* { dg-bogus "this condition has identical branches" "" { xfail *-*-* } } */ |
| 60 |
g += B; |
| 61 |
else |
| 62 |
g += A; |
| 63 |
|
| 64 |
if (i == 12) /* { dg-bogus "this condition has identical branches" "" { xfail *-*-* } } */ |
| 65 |
g += A; |
| 66 |
else |
| 67 |
g += 5; |
| 68 |
|
| 69 |
if (i == 12) /* { dg-bogus "this condition has identical branches" "" { xfail *-*-* } } */ |
| 70 |
g += 5; |
| 71 |
else |
| 72 |
g += A; |
| 73 |
} |