blob: 9ca8d15b859cc8a47c28adb61117479a7dcd09c8 [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
11struct B {
12 B(A);
13};
14
15int main () {
John McCall7c2342d2010-03-10 11:27:22 +000016 B(10); // expected-error {{functional-style cast from 'int' to 'B' is not allowed}}
17 (B)10; // expected-error {{C-style cast from 'int' to 'B' is not allowed}}
Argyrios Kyrtzidis6dff2282010-09-19 21:21:44 +000018 static_cast<B>(10); // expected-error {{static_cast from 'int' to 'B' is not allowed}}
Fariborz Jahanian249cead2009-10-01 20:39:51 +000019}
20
Douglas Gregorb653c522009-11-06 01:14:41 +000021template<class T>
22struct X0 {
23 X0(const T &);
24};
25
26template<class T>
27X0<T> make_X0(const T &Val) {
28 return X0<T>(Val);
29}
30
31void test_X0() {
Douglas Gregor60c93c92010-02-09 07:26:29 +000032 const char array[2] = { 'a', 'b' };
Douglas Gregorb653c522009-11-06 01:14:41 +000033 make_X0(array);
34}
Douglas Gregor27591ff2009-11-06 05:48:00 +000035
36// PR5210 recovery
37class C {
38protected:
39 template <int> float* &f0(); // expected-note{{candidate}}
40 template <unsigned> float* &f0(); // expected-note{{candidate}}
41
42 void f1() {
43 static_cast<float*>(f0<0>()); // expected-error{{ambiguous}}
44 }
45};