111
|
1 // Test for explicit conversion ops in various conversion situations.
|
|
2 // { dg-do compile { target c++11 } }
|
|
3
|
|
4 typedef void (*pfn)();
|
|
5
|
|
6 struct A
|
|
7 {
|
|
8 explicit operator int() const;
|
|
9 explicit operator pfn() const;
|
|
10 };
|
|
11
|
|
12 int main()
|
|
13 {
|
|
14 A a;
|
|
15 int i = a; // { dg-error "" }
|
|
16 const int &ir = a; // { dg-error "" }
|
|
17 a(); // { dg-error "" }
|
|
18 a + 1; // { dg-message "" } (error and note on same line)
|
|
19
|
|
20 int j (a);
|
|
21 (int)a;
|
|
22 static_cast<int>(a);
|
|
23 }
|
|
24
|
|
25 struct B
|
|
26 {
|
|
27 int i;
|
|
28 B(const A& a): i(a) { }
|
|
29 };
|