blob: c2327c140d8e95ed44b948ad96282a64d214ee48 (
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
|
// Test for explicit conversion ops in various conversion situations.
// { dg-options "-std=c++0x" }
typedef void (*pfn)();
struct A
{
explicit operator int() const;
explicit operator pfn() const;
};
int main()
{
A a;
int i = a; // { dg-error "" }
const int &ir = a; // { dg-error "" }
a(); // { dg-error "" }
a + 1; // { dg-message "" } (error and note on same line)
int j (a);
(int)a;
static_cast<int>(a);
}
struct B
{
int i;
B(const A& a): i(a) { }
};
|