freebsd-nq/test/SemaCXX/copy-initialization.cpp

24 lines
600 B
C++
Raw Normal View History

2010-01-01 10:34:51 +00:00
// RUN: %clang_cc1 -fsyntax-only -verify %s
2009-06-02 17:58:47 +00:00
class X {
public:
explicit X(const X&);
2010-01-15 15:39:40 +00:00
X(int*); // expected-note 2{{candidate constructor}}
2009-06-02 17:58:47 +00:00
explicit X(float*);
};
class Y : public X { };
void f(Y y, int *ip, float *fp) {
2010-01-01 10:34:51 +00:00
X x1 = y; // expected-error{{no matching constructor for initialization of 'class X'}}
2009-06-02 17:58:47 +00:00
X x2 = 0;
X x3 = ip;
2010-01-01 10:34:51 +00:00
X x4 = fp; // expected-error{{no viable conversion}}
2009-06-02 17:58:47 +00:00
}
struct foo {
void bar();
};
// PR3600
void test(const foo *P) { P->bar(); } // expected-error{{cannot initialize object parameter of type 'struct foo' with an expression of type 'struct foo const'}}