opnsense-src/test/SemaCXX/direct-initializer.cpp

51 lines
1.1 KiB
C++
Raw Normal View History

2010-01-01 05:34:51 -05:00
// RUN: %clang_cc1 -fsyntax-only -verify %s
2009-06-02 13:58:47 -04:00
int x(1);
int (x2)(1);
void f() {
int x(1);
int (x2)(1);
for (int x(1);;) {}
}
class Y {
explicit Y(float);
};
2010-01-15 10:39:40 -05:00
class X { // expected-note{{candidate constructor (the implicit copy constructor)}}
2009-06-02 13:58:47 -04:00
public:
2010-01-15 10:39:40 -05:00
explicit X(int); // expected-note{{candidate constructor}}
X(float, float, float); // expected-note{{candidate constructor}}
X(float, Y); // expected-note{{candidate constructor}}
2009-06-02 13:58:47 -04:00
};
2010-01-15 10:39:40 -05:00
class Z { // expected-note{{candidate constructor (the implicit copy constructor)}}
2009-06-02 13:58:47 -04:00
public:
2010-01-15 10:39:40 -05:00
Z(int); // expected-note{{candidate constructor}}
2009-06-02 13:58:47 -04:00
};
void g() {
X x1(5);
X x2(1.0, 3, 4.2);
2010-01-01 05:34:51 -05:00
X x3(1.0, 1.0); // expected-error{{no matching constructor for initialization of 'class X'}}
2009-06-02 13:58:47 -04:00
Y y(1.0);
X x4(3.14, y);
2010-01-01 05:34:51 -05:00
Z z; // expected-error{{no matching constructor for initialization of 'class Z'}}
2009-06-02 13:58:47 -04:00
}
2009-10-14 14:03:49 -04:00
struct Base {
operator int*() const;
};
struct Derived : Base {
2010-01-01 05:34:51 -05:00
operator int*(); // expected-note {{candidate function}}
2009-10-14 14:03:49 -04:00
};
void foo(const Derived cd, Derived d) {
2010-01-01 05:34:51 -05:00
int *pi = cd; // expected-error {{no viable conversion from 'struct Derived const' to 'int *'}}
2009-10-14 14:03:49 -04:00
int *ppi = d;
}