| 1 |
/* PR c/102867 - -Waddress from macro expansion in readelf.c |
| 2 |
{ dg-do compile } |
| 3 |
{ dg-options "-Wall" } */ |
| 4 |
|
| 5 |
#define F(x) ((&x) != 0) |
| 6 |
|
| 7 |
int warn_nomacro (int *p, int i) |
| 8 |
{ |
| 9 |
return &p[i] != 0; // { dg-warning "-Waddress" } |
| 10 |
} |
| 11 |
|
| 12 |
int nowarn_macro_expansion (int *p, int i) |
| 13 |
{ |
| 14 |
// Verify that -Waddress isn't issued for code from macro expansion. |
| 15 |
return F (p[i]); // { dg-bogus "-Waddress" } |
| 16 |
} |
| 17 |
|
| 18 |
#define G(x, i) ((&x) + i) |
| 19 |
|
| 20 |
int warn_function_macro_expansion (int *p, int i) |
| 21 |
{ |
| 22 |
/* Verify that -Waddress is issued for code involving macro expansion |
| 23 |
where the comparison takes place outside the macro. */ |
| 24 |
return G (*p, i) != 0; // { dg-warning "-Waddress" } |
| 25 |
} |
| 26 |
|
| 27 |
#define malloc __builtin_malloc |
| 28 |
|
| 29 |
int warn_object_macro_expansion (int *p, int i) |
| 30 |
{ |
| 31 |
return malloc != 0; // { dg-warning "-Waddress" } |
| 32 |
} |