aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/explicit2.C
blob: 715855cfe98893b2f349bcfd4ab52c28c0e1a54c (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-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) { }
};