2 // g++ 1.37.1 bug 900514_03
4 // g++ fails to flag ERRORs on the following erroneous code.
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.
11 // NO, IT DOESN'T. It's still ambiguous. --jason 2002-12-03
13 // cfront 2.0 passes this test.
15 // keywords: user-defined type conversion operator, constructor
19 struct t_0_st_1 { // { dg-error "initializing" }
22 t_0_st_1 (t_0_st_0&);// { dg-message "note" }
29 operator t_0_st_1 ();// { dg-message "note" }
32 t_0_st_0 t_0_st_0_obj0; // { dg-message "candidate" }
34 void t_0_assignment ()
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;
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);
44 void t_0_local_init ()
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);
55 t_1_st_1 (t_1_st_0&); // { dg-message "note" }
57 void operator= (t_1_st_1&); // { dg-message "operator=|no known conversion" }
63 operator t_1_st_1 (); // { dg-message "note" }
66 t_1_st_0 t_1_st_0_obj0; // { dg-message "candidate" }
68 void t_1_assignment ()
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;
74 t_1_st_1_obj0 = t_1_st_0_obj0; // { dg-error "no match" }
75 // { dg-message "candidate" "candidate note" { target *-*-* } 74 }
76 t_1_st_1_obj1 = t_1_st_1 (t_1_st_0_obj0); // { dg-error "no match" }
77 // { dg-message "candidate" "candidate note" { target *-*-* } 76 }
80 void t_1_local_init ()
82 t_1_st_1 t_1_st_1_obj0 = t_1_st_0_obj0; // { dg-error "ambiguous" }
83 t_1_st_1 t_1_st_1_obj1 = t_1_st_1 (t_1_st_0_obj0);
88 struct t_2_st_1 { // { dg-error "initializing" }
91 t_2_st_1 (t_2_st_0); // { dg-message "note" }
98 operator t_2_st_1 (); // { dg-message "note" }
101 t_2_st_0 t_2_st_0_obj0; // { dg-message "candidate" }
103 void t_2_assignment ()
105 t_2_st_1 t_2_st_1_obj0;
106 t_2_st_1 t_2_st_1_obj1;
107 t_2_st_1 t_2_st_1_obj2;
109 t_2_st_1_obj0 = t_2_st_0_obj0; // { dg-error "ambiguous" } caught
110 t_2_st_1_obj1 = t_2_st_1 (t_2_st_0_obj0);
113 void t_2_local_init ()
115 t_2_st_1 t_2_st_1_obj0 = t_2_st_0_obj0; // { dg-error "ambiguous" }
116 t_2_st_1 t_2_st_1_obj1 = t_2_st_1 (t_2_st_0_obj0);