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