| 1 |
// { dg-options "-fdiagnostics-show-caret" } |
| 2 |
|
| 3 |
/* A collection of calls where argument 2 is of the wrong type. */ |
| 4 |
|
| 5 |
/* decl, with argname. */ |
| 6 |
|
| 7 |
extern int callee_1 (int one, const char *two, float three); // { dg-line callee_1 } |
| 8 |
|
| 9 |
int test_1 (int first, int second, float third) |
| 10 |
{ |
| 11 |
return callee_1 (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" } |
| 12 |
/* { dg-begin-multiline-output "" } |
| 13 |
return callee_1 (first, second, third); |
| 14 |
^~~~~~ |
| 15 |
| |
| 16 |
int |
| 17 |
{ dg-end-multiline-output "" } */ |
| 18 |
// { dg-message "initializing argument 2 of 'int callee_1\\(int, const char\\*, float\\)'" "" { target *-*-* } callee_1 } |
| 19 |
/* { dg-begin-multiline-output "" } |
| 20 |
extern int callee_1 (int one, const char *two, float three); |
| 21 |
~~~~~~~~~~~~^~~ |
| 22 |
{ dg-end-multiline-output "" } */ |
| 23 |
} |
| 24 |
|
| 25 |
/* decl, without argname. */ |
| 26 |
|
| 27 |
extern int callee_2 (int, const char *, float); // { dg-line callee_2 } |
| 28 |
|
| 29 |
int test_2 (int first, int second, float third) |
| 30 |
{ |
| 31 |
return callee_2 (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" } |
| 32 |
/* { dg-begin-multiline-output "" } |
| 33 |
return callee_2 (first, second, third); |
| 34 |
^~~~~~ |
| 35 |
| |
| 36 |
int |
| 37 |
{ dg-end-multiline-output "" } */ |
| 38 |
// { dg-message "initializing argument 2 of 'int callee_2\\(int, const char\\*, float\\)'" "" { target *-*-* } callee_2 } |
| 39 |
/* { dg-begin-multiline-output "" } |
| 40 |
extern int callee_2 (int, const char *, float); |
| 41 |
^~~~~~~~~~~~ |
| 42 |
{ dg-end-multiline-output "" } */ |
| 43 |
} |
| 44 |
|
| 45 |
/* defn, with argname. */ |
| 46 |
|
| 47 |
static int callee_3 (int one, const char *two, float three) // { dg-line callee_3 } |
| 48 |
{ |
| 49 |
return callee_2 (one, two, three); |
| 50 |
} |
| 51 |
|
| 52 |
int test_3 (int first, int second, float third) |
| 53 |
{ |
| 54 |
return callee_3 (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" } |
| 55 |
/* { dg-begin-multiline-output "" } |
| 56 |
return callee_3 (first, second, third); |
| 57 |
^~~~~~ |
| 58 |
| |
| 59 |
int |
| 60 |
{ dg-end-multiline-output "" } */ |
| 61 |
// { dg-message "initializing argument 2 of 'int callee_3\\(int, const char\\*, float\\)'" "" { target *-*-* } callee_3 } |
| 62 |
/* { dg-begin-multiline-output "" } |
| 63 |
static int callee_3 (int one, const char *two, float three) |
| 64 |
~~~~~~~~~~~~^~~ |
| 65 |
{ dg-end-multiline-output "" } */ |
| 66 |
} |
| 67 |
|
| 68 |
/* static member, with argname. */ |
| 69 |
|
| 70 |
struct s4 { static int member_1 (int one, const char *two, float three); }; |
| 71 |
|
| 72 |
int test_4 (int first, int second, float third) |
| 73 |
{ |
| 74 |
return s4::member_1 (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" } |
| 75 |
/* { dg-begin-multiline-output "" } |
| 76 |
return s4::member_1 (first, second, third); |
| 77 |
^~~~~~ |
| 78 |
| |
| 79 |
int |
| 80 |
{ dg-end-multiline-output "" } */ |
| 81 |
/* { dg-begin-multiline-output "" } |
| 82 |
struct s4 { static int member_1 (int one, const char *two, float three); }; |
| 83 |
~~~~~~~~~~~~^~~ |
| 84 |
{ dg-end-multiline-output "" } */ |
| 85 |
} |
| 86 |
|
| 87 |
/* non-static member, with argname. */ |
| 88 |
|
| 89 |
struct s5 { int member_1 (int one, const char *two, float three); }; |
| 90 |
|
| 91 |
int test_5 (int first, int second, float third) |
| 92 |
{ |
| 93 |
s5 inst; |
| 94 |
return inst.member_1 (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" } |
| 95 |
/* { dg-begin-multiline-output "" } |
| 96 |
return inst.member_1 (first, second, third); |
| 97 |
^~~~~~ |
| 98 |
| |
| 99 |
int |
| 100 |
{ dg-end-multiline-output "" } */ |
| 101 |
/* { dg-begin-multiline-output "" } |
| 102 |
struct s5 { int member_1 (int one, const char *two, float three); }; |
| 103 |
~~~~~~~~~~~~^~~ |
| 104 |
{ dg-end-multiline-output "" } */ |
| 105 |
} |
| 106 |
|
| 107 |
/* non-static member, with argname, via a ptr. */ |
| 108 |
|
| 109 |
struct s6 { int member_1 (int one, const char *two, float three); }; |
| 110 |
|
| 111 |
int test_6 (int first, int second, float third, s6 *ptr) |
| 112 |
{ |
| 113 |
return ptr->member_1 (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" } |
| 114 |
/* { dg-begin-multiline-output "" } |
| 115 |
return ptr->member_1 (first, second, third); |
| 116 |
^~~~~~ |
| 117 |
| |
| 118 |
int |
| 119 |
{ dg-end-multiline-output "" } */ |
| 120 |
/* { dg-begin-multiline-output "" } |
| 121 |
struct s6 { int member_1 (int one, const char *two, float three); }; |
| 122 |
~~~~~~~~~~~~^~~ |
| 123 |
{ dg-end-multiline-output "" } */ |
| 124 |
} |
| 125 |
|
| 126 |
/* Template function. */ |
| 127 |
|
| 128 |
template <typename T> |
| 129 |
int test_7 (int one, T two, float three); |
| 130 |
|
| 131 |
int test_7 (int first, int second, float third) |
| 132 |
{ |
| 133 |
return test_7 <const char *> (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" } |
| 134 |
/* { dg-begin-multiline-output "" } |
| 135 |
return test_7 <const char *> (first, second, third); |
| 136 |
^~~~~~ |
| 137 |
| |
| 138 |
int |
| 139 |
{ dg-end-multiline-output "" } */ |
| 140 |
/* { dg-begin-multiline-output "" } |
| 141 |
int test_7 (int one, T two, float three); |
| 142 |
~~^~~ |
| 143 |
{ dg-end-multiline-output "" } */ |
| 144 |
} |
| 145 |
|
| 146 |
/* Template class, static function. */ |
| 147 |
|
| 148 |
template <typename T> |
| 149 |
struct s8 { static int member_1 (int one, T two, float three); }; |
| 150 |
|
| 151 |
int test_8 (int first, int second, float third) |
| 152 |
{ |
| 153 |
return s8 <const char *>::member_1 (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" } |
| 154 |
/* { dg-begin-multiline-output "" } |
| 155 |
return s8 <const char *>::member_1 (first, second, third); |
| 156 |
^~~~~~ |
| 157 |
| |
| 158 |
int |
| 159 |
{ dg-end-multiline-output "" } */ |
| 160 |
/* { dg-begin-multiline-output "" } |
| 161 |
struct s8 { static int member_1 (int one, T two, float three); }; |
| 162 |
~~^~~ |
| 163 |
{ dg-end-multiline-output "" } */ |
| 164 |
} |
| 165 |
|
| 166 |
/* Template class, non-static function. */ |
| 167 |
|
| 168 |
template <typename T> |
| 169 |
struct s9 { int member_1 (int one, T two, float three); }; |
| 170 |
|
| 171 |
int test_9 (int first, int second, float third) |
| 172 |
{ |
| 173 |
s9 <const char *> inst; |
| 174 |
return inst.member_1 (first, second, third); // { dg-error "invalid conversion from 'int' to 'const char\\*'" } |
| 175 |
/* { dg-begin-multiline-output "" } |
| 176 |
return inst.member_1 (first, second, third); |
| 177 |
^~~~~~ |
| 178 |
| |
| 179 |
int |
| 180 |
{ dg-end-multiline-output "" } */ |
| 181 |
/* { dg-begin-multiline-output "" } |
| 182 |
struct s9 { int member_1 (int one, T two, float three); }; |
| 183 |
~~^~~ |
| 184 |
{ dg-end-multiline-output "" } */ |
| 185 |
} |
| 186 |
|
| 187 |
/* Callback with name. */ |
| 188 |
|
| 189 |
extern int callee_10 (int one, int (*two)(int, int), float three); // { dg-line callee_10 } |
| 190 |
|
| 191 |
int test_10 (int first, int second, float third) |
| 192 |
{ |
| 193 |
return callee_10 (first, second, third); // { dg-error "invalid conversion from 'int' to 'int \\(\\*\\)\\(int, int\\)'" } |
| 194 |
/* { dg-begin-multiline-output "" } |
| 195 |
return callee_10 (first, second, third); |
| 196 |
^~~~~~ |
| 197 |
| |
| 198 |
int |
| 199 |
{ dg-end-multiline-output "" } */ |
| 200 |
// { dg-message "initializing argument 2 of 'int callee_10\\(int, int \\(\\*\\)\\(int, int\\), float\\)'" "" { target *-*-* } callee_10 } |
| 201 |
/* { dg-begin-multiline-output "" } |
| 202 |
extern int callee_10 (int one, int (*two)(int, int), float three); |
| 203 |
~~~~~~^~~~~~~~~~~~~~ |
| 204 |
{ dg-end-multiline-output "" } */ |
| 205 |
} |
| 206 |
|
| 207 |
/* Callback without name. */ |
| 208 |
|
| 209 |
extern int callee_11 (int one, int (*)(int, int), float three); // { dg-line callee_11 } |
| 210 |
|
| 211 |
int test_11 (int first, int second, float third) |
| 212 |
{ |
| 213 |
return callee_11 (first, second, third); // { dg-error "invalid conversion from 'int' to 'int \\(\\*\\)\\(int, int\\)'" } |
| 214 |
/* { dg-begin-multiline-output "" } |
| 215 |
return callee_11 (first, second, third); |
| 216 |
^~~~~~ |
| 217 |
| |
| 218 |
int |
| 219 |
{ dg-end-multiline-output "" } */ |
| 220 |
// { dg-message "initializing argument 2 of 'int callee_11\\(int, int \\(\\*\\)\\(int, int\\), float\\)'" "" { target *-*-* } callee_11 } |
| 221 |
/* { dg-begin-multiline-output "" } |
| 222 |
extern int callee_11 (int one, int (*)(int, int), float three); |
| 223 |
^~~~~~~~~~~~~~~~~ |
| 224 |
{ dg-end-multiline-output "" } */ |
| 225 |
} |
| 226 |
|
| 227 |
/* Bad reference. */ |
| 228 |
|
| 229 |
struct s12; |
| 230 |
|
| 231 |
extern int callee_12 (int one, s12 &second, float three); // { dg-line callee_12 } |
| 232 |
|
| 233 |
int test_12 (int first, int second, float third) |
| 234 |
{ |
| 235 |
return callee_12 (first, second, third); // { dg-error "invalid initialization of reference of " } |
| 236 |
/* { dg-begin-multiline-output "" } |
| 237 |
return callee_12 (first, second, third); |
| 238 |
^~~~~~ |
| 239 |
{ dg-end-multiline-output "" } */ |
| 240 |
// { dg-message "in passing argument 2 of " "" { target *-*-* } callee_12 } |
| 241 |
/* { dg-begin-multiline-output "" } |
| 242 |
extern int callee_12 (int one, s12 &second, float three); |
| 243 |
~~~~~^~~~~~ |
| 244 |
{ dg-end-multiline-output "" } */ |
| 245 |
} |
| 246 |
|
| 247 |
/* Incomplete type. */ |
| 248 |
|
| 249 |
struct s13; |
| 250 |
|
| 251 |
extern int callee_13 (int one, s13 second, float three); // { dg-line callee_13 } |
| 252 |
|
| 253 |
int test_13 (int first, int second, float third) |
| 254 |
{ |
| 255 |
return callee_13 (first, second, third); // { dg-error "has incomplete type" } |
| 256 |
/* { dg-begin-multiline-output "" } |
| 257 |
return callee_13 (first, second, third); |
| 258 |
^~~~~~ |
| 259 |
{ dg-end-multiline-output "" } */ |
| 260 |
// { dg-message "declared here" "" { target *-*-* } callee_13 } |
| 261 |
/* { dg-begin-multiline-output "" } |
| 262 |
extern int callee_13 (int one, s13 second, float three); |
| 263 |
~~~~^~~~~~ |
| 264 |
{ dg-end-multiline-output "" } */ |
| 265 |
} |
| 266 |
|
| 267 |
|
| 268 |
// TODO: template callsite |