1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 class X {
3 public:
4 explicit X(const X&); // expected-note {{candidate constructor}}
5 X(int*); // expected-note 3{{candidate constructor}}
6 explicit X(float*); // expected-note {{candidate constructor}}
7 };
8
9 class Y : public X { };
10
f(Y y,int * ip,float * fp)11 void f(Y y, int *ip, float *fp) {
12 X x1 = y; // expected-error{{no matching constructor for initialization of 'X'}}
13 X x2 = 0;
14 X x3 = ip;
15 X x4 = fp; // expected-error{{no viable conversion}}
16 X x2a(0); // expected-error{{call to constructor of 'X' is ambiguous}}
17 X x3a(ip);
18 X x4a(fp);
19 }
20
21 struct foo {
22 void bar(); // expected-note{{declared here}}
23 };
24
25 // PR3600
test(const foo * P)26 void test(const foo *P) { P->bar(); } // expected-error{{'bar' not viable: 'this' argument has type 'const foo', but function is not marked const}}
27
28 namespace PR6757 {
29 struct Foo {
30 Foo();
31 Foo(Foo&); // expected-note{{candidate constructor not viable}}
32 };
33
34 struct Bar {
35 operator const Foo&() const;
36 };
37
38 void f(Foo);
39
g(Foo foo)40 void g(Foo foo) {
41 f(Bar()); // expected-error{{no viable constructor copying parameter of type 'const PR6757::Foo'}}
42 f(foo);
43 }
44 }
45
46 namespace DR5 {
47 // Core issue 5: if a temporary is created in copy-initialization, it is of
48 // the cv-unqualified version of the destination type.
49 namespace Ex1 {
50 struct C { };
51 C c;
52 struct A {
53 A(const A&);
54 A(const C&);
55 };
56 const volatile A a = c; // ok
57 }
58
59 namespace Ex2 {
60 struct S {
61 S(S&&); // expected-warning {{C++11}}
62 S(int);
63 };
64 const S a(0);
65 const S b = 0;
66 }
67 }
68