blob: 80707d13d20bda84ae4bed6d7ec231418a36e290 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x
Fariborz Jahanian249cead2009-10-01 20:39:51 +00002
3struct R {
4 R(int);
5};
6
7struct A {
8 A(R);
9};
10
John McCall79ab2c82011-02-14 18:34:10 +000011struct B { // expected-note 3 {{candidate constructor (the implicit copy constructor) not viable}}
12 B(A); // expected-note 3 {{candidate constructor not viable}}
Fariborz Jahanian249cead2009-10-01 20:39:51 +000013};
14
15int main () {
John McCall79ab2c82011-02-14 18:34:10 +000016 B(10); // expected-error {{no matching conversion for functional-style cast from 'int' to 'B'}}
17 (B)10; // expected-error {{no matching conversion for C-style cast from 'int' to 'B'}}
18 static_cast<B>(10); // expected-error {{no matching conversion for static_cast from 'int' to 'B'}} \\
Argyrios Kyrtzidis1b2ad2f2010-09-19 23:03:35 +000019 // expected-warning {{expression result unused}}
Fariborz Jahanian249cead2009-10-01 20:39:51 +000020}
21
Douglas Gregorb653c522009-11-06 01:14:41 +000022template<class T>
23struct X0 {
24 X0(const T &);
25};
26
27template<class T>
28X0<T> make_X0(const T &Val) {
29 return X0<T>(Val);
30}
31
32void test_X0() {
Douglas Gregor60c93c92010-02-09 07:26:29 +000033 const char array[2] = { 'a', 'b' };
Douglas Gregorb653c522009-11-06 01:14:41 +000034 make_X0(array);
35}
Douglas Gregor27591ff2009-11-06 05:48:00 +000036
37// PR5210 recovery
38class C {
39protected:
40 template <int> float* &f0(); // expected-note{{candidate}}
41 template <unsigned> float* &f0(); // expected-note{{candidate}}
42
43 void f1() {
44 static_cast<float*>(f0<0>()); // expected-error{{ambiguous}}
45 }
46};