| 1 |
/* PR c/33925 - missing -Waddress with the address of an inline function |
| 2 |
{ dg-do compile } |
| 3 |
{ dg-options "-Wall" } |
| 4 |
{ dg-require-weak "" } */ |
| 5 |
|
| 6 |
extern inline int eifn (void); |
| 7 |
extern inline int eifn_def (void) { return 0; } |
| 8 |
|
| 9 |
static inline int sifn (void); |
| 10 |
static inline int sifn_def (void) { return 0; } |
| 11 |
|
| 12 |
inline int ifn (void); |
| 13 |
inline int ifn_def (void) { return 0; } |
| 14 |
|
| 15 |
extern __attribute__ ((weak)) int ewfn (void); |
| 16 |
extern __attribute__ ((weak)) int ewfn_def (void) { return 0; } |
| 17 |
|
| 18 |
__attribute__ ((weak)) int wfn (void); |
| 19 |
__attribute__ ((weak)) int wfn_def (void) { return 0; } |
| 20 |
|
| 21 |
static __attribute__((weakref ("ewfn"))) int swrfn (void); |
| 22 |
|
| 23 |
void test_function_eqz (int *p) |
| 24 |
{ |
| 25 |
*p++ = eifn == 0; // { dg-warning "-Waddress" } |
| 26 |
*p++ = eifn_def == 0; // { dg-warning "-Waddress" } |
| 27 |
*p++ = sifn == 0; // { dg-warning "-Waddress" } |
| 28 |
*p++ = sifn_def == 0; // { dg-warning "-Waddress" } |
| 29 |
*p++ = ifn == 0; // { dg-warning "-Waddress" } |
| 30 |
*p++ = ifn_def == 0; // { dg-warning "-Waddress" } |
| 31 |
*p++ = ewfn == 0; |
| 32 |
*p++ = ewfn_def == 0; // { dg-warning "-Waddress" } |
| 33 |
*p++ = wfn == 0; |
| 34 |
*p++ = wfn_def == 0; // { dg-warning "-Waddress" } |
| 35 |
*p++ = swrfn == 0; |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
int test_function_if (int i) |
| 40 |
{ |
| 41 |
if (eifn) // { dg-warning "-Waddress" } |
| 42 |
i++; |
| 43 |
if (eifn_def) // { dg-warning "-Waddress" } |
| 44 |
i++; |
| 45 |
if (sifn) // { dg-warning "-Waddress" } |
| 46 |
i++; |
| 47 |
if (sifn_def) // { dg-warning "-Waddress" } |
| 48 |
i++; |
| 49 |
if (ifn) // { dg-warning "-Waddress" } |
| 50 |
i++; |
| 51 |
if (ifn_def) // { dg-warning "-Waddress" } |
| 52 |
i++; |
| 53 |
if (ewfn) |
| 54 |
i++; |
| 55 |
if (ewfn_def) // { dg-warning "-Waddress" } |
| 56 |
i++; |
| 57 |
if (wfn) |
| 58 |
i++; |
| 59 |
if(wfn_def) // { dg-warning "-Waddress" } |
| 60 |
i++; |
| 61 |
if (swrfn) |
| 62 |
i++; |
| 63 |
return i; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
extern int ei; |
| 68 |
extern int ei_def = 1; |
| 69 |
|
| 70 |
static int si; |
| 71 |
static int si_def = 1; |
| 72 |
|
| 73 |
int i; |
| 74 |
int i_def = 1; |
| 75 |
|
| 76 |
extern __attribute__ ((weak)) int ewi; // declaration (may be null) |
| 77 |
extern __attribute__ ((weak)) int ewi_def = 1; |
| 78 |
|
| 79 |
__attribute__ ((weak)) int wi; // definition (cannot be bull) |
| 80 |
__attribute__ ((weak)) int wi_def = 1; |
| 81 |
|
| 82 |
static __attribute__((weakref ("ewi"))) int swri; |
| 83 |
|
| 84 |
void test_scalar (int *p) |
| 85 |
{ |
| 86 |
*p++ = &ei == 0; // { dg-warning "-Waddress" } |
| 87 |
*p++ = &ei_def == 0; // { dg-warning "-Waddress" } |
| 88 |
*p++ = &si == 0; // { dg-warning "-Waddress" } |
| 89 |
*p++ = &si_def == 0; // { dg-warning "-Waddress" } |
| 90 |
*p++ = &i == 0; // { dg-warning "-Waddress" } |
| 91 |
*p++ = &i_def == 0; // { dg-warning "-Waddress" } |
| 92 |
*p++ = &ewi == 0; |
| 93 |
*p++ = &ewi_def == 0; // { dg-warning "-Waddress" } |
| 94 |
*p++ = &wi == 0; // { dg-warning "-Waddress" } |
| 95 |
*p++ = &wi_def == 0; // { dg-warning "-Waddress" } |
| 96 |
*p++ = &swri == 0; |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
extern int eia[]; |
| 101 |
extern int eia_def[] = { 1 }; |
| 102 |
|
| 103 |
static int sia[1]; |
| 104 |
static int sia_def[1] = { 1 }; |
| 105 |
|
| 106 |
int ia[1]; |
| 107 |
int ia_def[] = { 1 }; |
| 108 |
|
| 109 |
extern __attribute__ ((weak)) int ewia[]; |
| 110 |
extern __attribute__ ((weak)) int ewia_def[] = { 1 }; |
| 111 |
|
| 112 |
__attribute__ ((weak)) int wia[1]; // definition (cannot be null) |
| 113 |
__attribute__ ((weak)) int wia_def[] = { 1 }; |
| 114 |
|
| 115 |
static __attribute__((weakref ("ewia"))) int swria[1]; |
| 116 |
|
| 117 |
void test_array (int *p) |
| 118 |
{ |
| 119 |
*p++ = eia == 0; // { dg-warning "-Waddress" } |
| 120 |
*p++ = eia_def == 0; // { dg-warning "-Waddress" } |
| 121 |
*p++ = sia == 0; // { dg-warning "-Waddress" } |
| 122 |
*p++ = sia_def == 0; // { dg-warning "-Waddress" } |
| 123 |
*p++ = ia == 0; // { dg-warning "-Waddress" } |
| 124 |
*p++ = ia_def == 0; // { dg-warning "-Waddress" } |
| 125 |
*p++ = ewia == 0; |
| 126 |
*p++ = ewia_def == 0; // { dg-warning "-Waddress" } |
| 127 |
*p++ = wia == 0; // { dg-warning "-Waddress" } |
| 128 |
*p++ = wia_def == 0; // { dg-warning "-Waddress" } |
| 129 |
*p++ = swria == 0; |
| 130 |
} |
| 131 |
|
| 132 |
/* { dg-prune-output "never defined" } |
| 133 |
{ dg-prune-output "initialized and declared 'extern'" } */ |