| 1 |
// PR c++/65168 |
| 2 |
// { dg-options "-Waddress" } |
| 3 |
|
| 4 |
void foo (void); |
| 5 |
|
| 6 |
int d; |
| 7 |
int &c = d; |
| 8 |
|
| 9 |
void |
| 10 |
bar (int &a) |
| 11 |
{ |
| 12 |
int &b = a; |
| 13 |
|
| 14 |
if ((int *)&a) // { dg-warning "7:the compiler can assume that the address of" } |
| 15 |
foo (); |
| 16 |
|
| 17 |
if (&b) // { dg-warning "7:the compiler can assume that the address of" } |
| 18 |
foo (); |
| 19 |
|
| 20 |
if (!&c) // { dg-warning "8:the address of" } |
| 21 |
foo (); |
| 22 |
|
| 23 |
if (!&(int &)(int &)a) // { dg-warning "8:the compiler can assume that the address of" } |
| 24 |
foo (); |
| 25 |
|
| 26 |
if (&a == 0) // { dg-warning "10:the compiler can assume that the address of" } |
| 27 |
foo (); |
| 28 |
|
| 29 |
if (&b != 0) // { dg-warning "10:the compiler can assume that the address of" } |
| 30 |
foo (); |
| 31 |
|
| 32 |
if (0 == &(int &)(int &)c) // { dg-warning "9:the address of" } |
| 33 |
foo (); |
| 34 |
|
| 35 |
if (&a != (int *)0) // { dg-warning "10:the compiler can assume that the address of" } |
| 36 |
foo (); |
| 37 |
} |
| 38 |
|
| 39 |
bool |
| 40 |
bar_1 (int &a) |
| 41 |
{ |
| 42 |
if (d == 5) |
| 43 |
return &a; // { dg-warning "12:the compiler can assume that the address of" } |
| 44 |
else |
| 45 |
return !&(int &)(int &)a; // { dg-warning "13:the compiler can assume that the address of" } |
| 46 |
} |