// RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s struct X0 { // expected-note {{candidate constructor (the implicit copy constructor) not viable}} #if __cplusplus >= 201103L // C++11 or later // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}} #endif X0(int); // expected-note{{candidate}} template X0(T); // expected-note {{candidate}} template X0(T*, U*); // expected-note {{candidate}} // PR4761 template X0() : f0(T::foo) {} // expected-note {{candidate}} int f0; }; void accept_X0(X0); void test_X0(int i, float f) { X0 x0a(i); X0 x0b(f); X0 x0c = i; X0 x0d = f; accept_X0(i); accept_X0(&i); accept_X0(f); accept_X0(&f); X0 x0e(&i, &f); X0 x0f(&f, &i); X0 x0g(f, &i); // expected-error{{no matching constructor}} } template struct X1 { X1(const X1&); template X1(const X1&); }; template struct Outer { typedef X1 A; A alloc; explicit Outer(const A& a) : alloc(a) { } }; void test_X1(X1 xi) { Outer oi(xi); Outer of(xi); } // PR4655 template struct A {}; template <> struct A{A(const A&);}; struct B { A x; B(B& a) : x(a.x) {} }; struct X2 { X2(); // expected-note{{candidate constructor}} X2(X2&); // expected-note {{candidate constructor}} template X2(T); // expected-note {{candidate template ignored: instantiation would take its own class type by value}} }; X2 test(bool Cond, X2 x2) { if (Cond) return x2; // okay, uses copy constructor return X2(); // expected-error{{no matching constructor}} } struct X3 { template X3(T); }; template<> X3::X3(X3); // expected-error{{must pass its first argument by reference}} struct X4 { X4(); ~X4(); X4(X4&); template X4(const T&, int = 17); }; X4 test_X4(bool Cond, X4 x4) { X4 a(x4, 17); // okay, constructor template X4 b(x4); // okay, copy constructor return X4(); } // Instantiation of a non-dependent use of a constructor struct DefaultCtorHasDefaultArg { explicit DefaultCtorHasDefaultArg(int i = 17); }; template void default_ctor_inst() { DefaultCtorHasDefaultArg def; } template void default_ctor_inst(); template struct X5 { X5(); X5(const T &); }; struct X6 { template X6(T); }; void test_X5_X6() { X5 tf; X5 tf2(tf); } namespace PR8182 { struct foo { foo(); template foo(T&); private: foo(const foo&); }; void test_foo() { foo f1; foo f2(f1); foo f3 = f1; } } // Don't blow out the stack trying to call an illegal constructor // instantiation. We intentionally allow implicit instantiations to // exist, so make sure they're unusable. // // rdar://19199836 namespace self_by_value { template struct A { A() {} A(const A &o) {} A(A o) {} }; void helper(A); void test1(A a) { helper(a); } void test2() { helper(A()); } } namespace self_by_value_2 { template struct A { A() {} // expected-note {{not viable: requires 0 arguments}} A(A &o) {} // expected-note {{not viable: expects an l-value}} A(A o) {} // expected-note {{ignored: instantiation takes its own class type by value}} }; void helper_A(A); // expected-note {{passing argument to parameter here}} void test_A() { helper_A(A()); // expected-error {{no matching constructor}} } } namespace self_by_value_3 { template struct A { A() {} A(A &o) {} A(A o) {} }; void helper_A(A); void test_A(A b) { helper_A(b); } }