2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2009-08-22 02:42:58 +08:00
|
|
|
struct X0 { // expected-note{{candidate}}
|
|
|
|
X0(int); // expected-note{{candidate}}
|
2009-12-16 16:11:27 +08:00
|
|
|
template<typename T> X0(T); // expected-note {{candidate}}
|
|
|
|
template<typename T, typename U> X0(T*, U*); // expected-note {{candidate}}
|
2009-08-24 19:57:43 +08:00
|
|
|
|
|
|
|
// PR4761
|
2009-12-16 16:11:27 +08:00
|
|
|
template<typename T> X0() : f0(T::foo) {} // expected-note {{candidate}}
|
2009-08-24 19:57:43 +08:00
|
|
|
int f0;
|
2009-08-22 02:42:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
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}}
|
|
|
|
}
|
2009-09-16 02:26:13 +08:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
struct X1 {
|
|
|
|
X1(const X1&);
|
|
|
|
template<typename U> X1(const X1<U>&);
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
struct Outer {
|
|
|
|
typedef X1<T> A;
|
|
|
|
|
|
|
|
A alloc;
|
|
|
|
|
|
|
|
explicit Outer(const A& a) : alloc(a) { }
|
|
|
|
};
|
|
|
|
|
|
|
|
void test_X1(X1<int> xi) {
|
|
|
|
Outer<int> oi(xi);
|
|
|
|
Outer<float> of(xi);
|
|
|
|
}
|
2009-09-16 05:14:05 +08:00
|
|
|
|
|
|
|
// PR4655
|
|
|
|
template<class C> struct A {};
|
|
|
|
template <> struct A<int>{A(const A<int>&);};
|
|
|
|
struct B { A<int> x; B(B& a) : x(a.x) {} };
|
2009-11-03 09:35:08 +08:00
|
|
|
|
2009-11-14 09:20:54 +08:00
|
|
|
struct X2 {
|
2010-01-06 17:43:14 +08:00
|
|
|
X2(); // expected-note{{candidate constructor}}
|
|
|
|
X2(X2&); // expected-note {{candidate constructor}}
|
2009-11-14 09:20:54 +08:00
|
|
|
template<typename T> X2(T);
|
|
|
|
};
|
|
|
|
|
|
|
|
X2 test(bool Cond, X2 x2) {
|
|
|
|
if (Cond)
|
|
|
|
return x2; // okay, uses copy constructor
|
|
|
|
|
Switch the initialization required by return statements over to the
new InitializationSequence. This fixes some bugs (e.g., PR5808),
changed some diagnostics, and caused more churn than expected. What's
new:
- InitializationSequence now has a "C conversion sequence" category
and step kind, which falls back to
- Changed the diagnostics for returns to always have the result type
of the function first and the type of the expression second.
CheckSingleAssignmentConstraints to peform checking in C.
- Improved ASTs for initialization of return values. The ASTs now
capture all of the temporaries we need to create, but
intentionally do not bind the tempoary that is actually returned,
so that it won't get destroyed twice.
- Make sure to perform an (elidable!) copy of the class object that
is returned from a class.
- Fix copy elision in CodeGen to properly see through the
subexpressions that occur with elidable copies.
- Give "new" its own entity kind; as with return values and thrown
objects, we don't bind the expression so we don't call a
destructor for it.
Note that, with this patch, I've broken returning move-only types in
C++0x. We'll fix it later, when we tackle NRVO.
llvm-svn: 91669
2009-12-18 13:02:21 +08:00
|
|
|
return X2(); // expected-error{{no matching constructor}}
|
2009-11-14 09:20:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct X3 {
|
|
|
|
template<typename T> X3(T);
|
|
|
|
};
|
|
|
|
|
|
|
|
template<> X3::X3(X3); // expected-error{{must pass its first argument by reference}}
|
|
|
|
|
|
|
|
struct X4 {
|
2010-11-09 01:16:59 +08:00
|
|
|
X4();
|
2009-11-14 09:20:54 +08:00
|
|
|
~X4();
|
2010-11-09 01:16:59 +08:00
|
|
|
X4(X4&);
|
2009-11-14 09:20:54 +08:00
|
|
|
template<typename T> 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
|
2010-11-09 01:16:59 +08:00
|
|
|
return X4();
|
2009-11-14 09:20:54 +08:00
|
|
|
}
|
2009-12-15 03:27:10 +08:00
|
|
|
|
|
|
|
// Instantiation of a non-dependent use of a constructor
|
|
|
|
struct DefaultCtorHasDefaultArg {
|
|
|
|
explicit DefaultCtorHasDefaultArg(int i = 17);
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void default_ctor_inst() {
|
|
|
|
DefaultCtorHasDefaultArg def;
|
|
|
|
}
|
|
|
|
|
|
|
|
template void default_ctor_inst<int>();
|
2010-04-18 06:01:05 +08:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
struct X5 {
|
|
|
|
X5();
|
|
|
|
X5(const T &);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct X6 {
|
|
|
|
template<typename T> X6(T);
|
|
|
|
};
|
|
|
|
|
|
|
|
void test_X5_X6() {
|
|
|
|
X5<X6> tf;
|
|
|
|
X5<X6> tf2(tf);
|
|
|
|
}
|
2010-11-09 01:16:59 +08:00
|
|
|
|
|
|
|
namespace PR8182 {
|
|
|
|
struct foo {
|
|
|
|
foo();
|
|
|
|
template<class T> foo(T&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
foo(const foo&);
|
|
|
|
};
|
|
|
|
|
|
|
|
void test_foo() {
|
|
|
|
foo f1;
|
|
|
|
foo f2(f1);
|
|
|
|
foo f3 = f1;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|