1// { dg-do assemble } 2// g++ 1.37.1 bug 900514_03 3 4// g++ fails to flag ERRORs on the following erroneous code. 5 6// In Section 12.3.2 it says "Defining conversion by both a constructor and 7// a conversion function can lead to ambiguities." However in the case below, 8// the explicit cast syntax disambiguates the constructor as one which 9// invokes the type conversion operator rather than the conversion. 10 11// NO, IT DOESN'T. It's still ambiguous. --jason 2002-12-03 12 13// cfront 2.0 passes this test. 14 15// keywords: user-defined type conversion operator, constructor 16 17struct t_0_st_0; 18 19struct t_0_st_1 { // { dg-message "initializing" } 20 int member; 21 22 t_0_st_1 (t_0_st_0&);// { dg-message "note" } 23 t_0_st_1 (); 24}; 25 26struct t_0_st_0 { 27 int member; 28 29 operator t_0_st_1 ();// { dg-message "note" } 30}; 31 32t_0_st_0 t_0_st_0_obj0; 33 34void t_0_assignment () 35{ 36 t_0_st_1 t_0_st_1_obj0; 37 t_0_st_1 t_0_st_1_obj1; 38 t_0_st_1 t_0_st_1_obj2; 39 40 t_0_st_1_obj0 = t_0_st_0_obj0; // { dg-error "ambiguous" } caught 41 t_0_st_1_obj1 = t_0_st_1 (t_0_st_0_obj0); 42} 43 44void t_0_local_init () 45{ 46 t_0_st_1 t_0_st_1_obj0 = t_0_st_0_obj0; // { dg-error "ambiguous" } 47 t_0_st_1 t_0_st_1_obj1 = t_0_st_1 (t_0_st_0_obj0); 48} 49 50struct t_1_st_0; 51 52struct t_1_st_1 { 53 int member; 54 55 t_1_st_1 (t_1_st_0&); // { dg-message "note" } 56 t_1_st_1 (); 57 void operator= (t_1_st_1&); // { dg-message "operator=|no known conversion" } 58}; 59 60struct t_1_st_0 { 61 int member; 62 63 operator t_1_st_1 (); // { dg-message "note" } 64}; 65 66t_1_st_0 t_1_st_0_obj0; 67 68void t_1_assignment () 69{ 70 t_1_st_1 t_1_st_1_obj0; 71 t_1_st_1 t_1_st_1_obj1; 72 t_1_st_1 t_1_st_1_obj2; 73 74 t_1_st_1_obj0 = t_1_st_0_obj0; // { dg-error "no match|conversion" } 75 t_1_st_1_obj1 = t_1_st_1 (t_1_st_0_obj0); // { dg-error "no match|rvalue" } 76} 77 78void t_1_local_init () 79{ 80 t_1_st_1 t_1_st_1_obj0 = t_1_st_0_obj0; // { dg-error "ambiguous" } 81 t_1_st_1 t_1_st_1_obj1 = t_1_st_1 (t_1_st_0_obj0); 82} 83 84struct t_2_st_0; 85 86struct t_2_st_1 { // { dg-message "initializing" } 87 int member; 88 89 t_2_st_1 (t_2_st_0); // { dg-message "note" } 90 t_2_st_1 (); 91}; 92 93struct t_2_st_0 { 94 int member; 95 96 operator t_2_st_1 (); // { dg-message "note" } 97}; 98 99t_2_st_0 t_2_st_0_obj0; 100 101void t_2_assignment () 102{ 103 t_2_st_1 t_2_st_1_obj0; 104 t_2_st_1 t_2_st_1_obj1; 105 t_2_st_1 t_2_st_1_obj2; 106 107 t_2_st_1_obj0 = t_2_st_0_obj0; // { dg-error "ambiguous" } caught 108 t_2_st_1_obj1 = t_2_st_1 (t_2_st_0_obj0); 109} 110 111void t_2_local_init () 112{ 113 t_2_st_1 t_2_st_1_obj0 = t_2_st_0_obj0; // { dg-error "ambiguous" } 114 t_2_st_1 t_2_st_1_obj1 = t_2_st_1 (t_2_st_0_obj0); 115} 116