| 1 |
// { dg-do assemble } |
| 2 |
// g++ 1.36.1 bug 900215_01 |
| 3 |
|
| 4 |
// g++ allows the definition of a type conversion operator `operator void' |
| 5 |
// for class types, but subsequently fails to generate calls (where needed) |
| 6 |
// for such type conversion operators. |
| 7 |
|
| 8 |
// Cfront 2.0 does generate such calls. |
| 9 |
|
| 10 |
// The following program exits with status 0 when compiled with Cfront 2.0 |
| 11 |
// but exits with status 1 when compiled with g++. |
| 12 |
|
| 13 |
// Cfront 2.0 passes this test. |
| 14 |
|
| 15 |
// 4/27/94 (jason): The pre-San Diego working paper prohibits operator |
| 16 |
// void, so we can go back to just ignoring void values. |
| 17 |
|
| 18 |
// keywords: user-defined type conversion operators, void type, explicit casts |
| 19 |
|
| 20 |
// 8/3/2000 (nathan): The std allows you to define such an op, but |
| 21 |
// it will never be called. [class.conv.fct]. Make it an unconditional warning. |
| 22 |
|
| 23 |
// { dg-options "-Wconversion" } |
| 24 |
|
| 25 |
struct struct0 { |
| 26 |
|
| 27 |
operator void (); // { dg-warning "3:converting .struct0. to .void. will never use a type conversion operator" } |
| 28 |
}; |
| 29 |
|
| 30 |
int exit_status = 1; |
| 31 |
|
| 32 |
struct0::operator void () |
| 33 |
{ |
| 34 |
exit_status = 0; |
| 35 |
} |
| 36 |
|
| 37 |
struct struct0 s0_object; |
| 38 |
|
| 39 |
int test () |
| 40 |
{ |
| 41 |
(void) s0_object; |
| 42 |
return exit_status; |
| 43 |
} |
| 44 |
|
| 45 |
int main () { return test (); } |