blob: 715855cfe98893b2f349bcfd4ab52c28c0e1a54c [file] [log] [blame]
// Test for explicit conversion ops in various conversion situations.
// { dg-do compile { target c++11 } }
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) { }
};