OLD | NEW |
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s | 1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s |
2 | 2 |
3 // C++03 requires that we check for a copy constructor when binding a | 3 // C++03 requires that we check for a copy constructor when binding a |
4 // reference to a reference-compatible rvalue, since we are allowed to | 4 // reference to a reference-compatible rvalue, since we are allowed to |
5 // make a copy. C++0x does not permit the copy, so ensure that we | 5 // make a copy. C++0x does not permit the copy, so ensure that we |
6 // don't diagnose cases where the copy constructor is unavailable. | 6 // don't diagnose cases where the copy constructor is unavailable. |
7 | 7 |
8 struct X1 { | 8 struct X1 { |
9 X1(); | 9 X1(); |
10 explicit X1(const X1&); | 10 explicit X1(const X1&); |
(...skipping 30 matching lines...) Expand all Loading... |
41 void g2(const X2&); | 41 void g2(const X2&); |
42 void g3(const X3&); | 42 void g3(const X3&); |
43 void g4(const X4<int>&); | 43 void g4(const X4<int>&); |
44 | 44 |
45 void test() { | 45 void test() { |
46 g1(X1()); | 46 g1(X1()); |
47 g2(X2()); | 47 g2(X2()); |
48 g3(X3()); | 48 g3(X3()); |
49 g4(X4<int>()); | 49 g4(X4<int>()); |
50 } | 50 } |
| 51 |
| 52 // Check that unavailable copy constructors do not cause SFINAE failures. |
| 53 template<int> struct int_c { }; |
| 54 |
| 55 template<typename T> T f(const T&); |
| 56 |
| 57 template<typename T> |
| 58 int &g(int_c<sizeof(f(T()))> * = 0); // expected-note{{candidate function [with
T = X3]}} |
| 59 |
| 60 template<typename T> float &g(); // expected-note{{candidate function [with T =
X3]}} |
| 61 |
| 62 void h() { |
| 63 float &fp = g<X3>(); // expected-error{{call to 'g' is ambiguous}} |
| 64 } |
OLD | NEW |