Home | History | Annotate | Download | only in SemaCXX
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s
      2 
      3 int x(1);
      4 int (x2)(1);
      5 
      6 void f() {
      7   int x(1);
      8   int (x2)(1);
      9   for (int x(1);;) {}
     10 }
     11 
     12 class Y {
     13 public: explicit Y(float);
     14 };
     15 
     16 class X { // expected-note{{candidate constructor (the implicit copy constructor)}}
     17 public:
     18   explicit X(int); // expected-note{{candidate constructor}}
     19   X(float, float, float); // expected-note{{candidate constructor}}
     20   X(float, Y); // expected-note{{candidate constructor}}
     21 };
     22 
     23 class Z { // expected-note{{candidate constructor (the implicit copy constructor)}}
     24 public:
     25   Z(int); // expected-note{{candidate constructor}}
     26 };
     27 
     28 void g() {
     29   X x1(5);
     30   X x2(1.0, 3, 4.2);
     31   X x3(1.0, 1.0); // expected-error{{no matching constructor for initialization of 'X'}}
     32   Y y(1.0);
     33   X x4(3.14, y);
     34 
     35   Z z; // expected-error{{no matching constructor for initialization of 'Z'}}
     36 }
     37 
     38 struct Base {
     39    operator int*() const;
     40 };
     41 
     42 struct Derived : Base {
     43    operator int*(); // expected-note {{candidate function}}
     44 };
     45 
     46 void foo(const Derived cd, Derived d) {
     47         int *pi = cd;	// expected-error {{no viable conversion from 'const Derived' to 'int *'}}
     48         int *ppi = d;
     49 
     50 }
     51