1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2
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
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.
7
8struct X1 {
9  X1();
10  explicit X1(const X1&);
11};
12
13struct X2 {
14  X2();
15
16private:
17  X2(const X2&);
18};
19
20struct X3 {
21  X3();
22
23private:
24  X3(X3&);
25};
26
27template<typename T>
28T get_value_badly() {
29  double *dp = 0;
30  T *tp = dp;
31  return T();
32}
33
34template<typename T>
35struct X4 {
36  X4();
37  X4(const X4&, T = get_value_badly<T>());
38};
39
40void g1(const X1&);
41void g2(const X2&);
42void g3(const X3&);
43void g4(const X4<int>&);
44
45void test() {
46  g1(X1());
47  g2(X2());
48  g3(X3());
49  g4(X4<int>());
50}
51
52// Check that unavailable copy constructors do not cause SFINAE failures.
53template<int> struct int_c { };
54
55template<typename T> T f(const T&);
56
57template<typename T>
58int &g(int_c<sizeof(f(T()))> * = 0);  // expected-note{{candidate function [with T = X3]}}
59
60template<typename T> float &g();  // expected-note{{candidate function [with T = X3]}}
61
62void h() {
63  float &fp = g<X3>();  // expected-error{{call to 'g' is ambiguous}}
64}
65