| 1 |
/* PR c/64279 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-Wduplicated-branches -O2" } */ |
| 4 |
|
| 5 |
void |
| 6 |
f (int *p) |
| 7 |
{ |
| 8 |
if (*p > 0) |
| 9 |
{ |
| 10 |
if (x == 0) /* { dg-error "undeclared|not declared" } */ |
| 11 |
*p = 5; |
| 12 |
else |
| 13 |
*p = 6; |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
void |
| 18 |
f2 (int *p) |
| 19 |
{ |
| 20 |
if (*p > 0) |
| 21 |
{ |
| 22 |
if (*p > 2) |
| 23 |
*p = x; /* { dg-error "undeclared|not declared" } */ |
| 24 |
else |
| 25 |
*p = 6; |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
void |
| 30 |
f3 (int *p) |
| 31 |
{ |
| 32 |
if (*p > 0) |
| 33 |
{ |
| 34 |
if (*p > 2) |
| 35 |
*p = 8; |
| 36 |
else |
| 37 |
*p = x; /* { dg-error "undeclared|not declared" } */ |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
void |
| 42 |
f4 (int *p) |
| 43 |
{ |
| 44 |
if (*p > 0) |
| 45 |
{ |
| 46 |
if (x == 0) /* { dg-error "undeclared|not declared" } */ |
| 47 |
*p = 5; |
| 48 |
else |
| 49 |
*p = 6; |
| 50 |
} |
| 51 |
else |
| 52 |
{ |
| 53 |
if (x == 0) /* { dg-error "not declared" "" { target c++ } } */ |
| 54 |
*p = 7; |
| 55 |
else |
| 56 |
*p = 6; |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
void |
| 61 |
f5 (int *p) |
| 62 |
{ |
| 63 |
if (*p > 0) |
| 64 |
{ |
| 65 |
if (*p > 2) |
| 66 |
*p = x; /* { dg-error "undeclared|not declared" } */ |
| 67 |
else |
| 68 |
*p = 6; |
| 69 |
} |
| 70 |
else |
| 71 |
{ |
| 72 |
if (x == 0) /* { dg-error "not declared" "" { target c++ } } */ |
| 73 |
*p = 5; |
| 74 |
else |
| 75 |
*p = 6; |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
void |
| 80 |
f6 (int *p) |
| 81 |
{ |
| 82 |
if (*p > 0) |
| 83 |
{ |
| 84 |
if (*p > 2) |
| 85 |
*p = 8; |
| 86 |
else |
| 87 |
*p = x; /* { dg-error "undeclared|not declared" } */ |
| 88 |
} |
| 89 |
else |
| 90 |
{ |
| 91 |
if (x == 0) /* { dg-error "not declared" "" { target c++ } } */ |
| 92 |
*p = 5; |
| 93 |
else |
| 94 |
*p = 6; |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
void |
| 99 |
f7 (int i) |
| 100 |
{ |
| 101 |
if (i > 5) |
| 102 |
({ x++; }); /* { dg-error "undeclared|not declared" } */ |
| 103 |
else |
| 104 |
({ i++; }); |
| 105 |
} |
| 106 |
|
| 107 |
void |
| 108 |
f8 (int i) |
| 109 |
{ |
| 110 |
if (i > 5) |
| 111 |
({ i++; }); |
| 112 |
else |
| 113 |
({ x++; }); /* { dg-error "undeclared|not declared" } */ |
| 114 |
} |