xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/instantiate-decl-init.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc // expected-no-diagnostics
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc // PR5426 - the non-dependent obj would be fully processed and wrapped in a
5*f4a2713aSLionel Sambuc // CXXConstructExpr at definition time, which would lead to a failure at
6*f4a2713aSLionel Sambuc // instantiation time.
7*f4a2713aSLionel Sambuc struct arg {
8*f4a2713aSLionel Sambuc   arg();
9*f4a2713aSLionel Sambuc };
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc struct oldstylemove {
12*f4a2713aSLionel Sambuc   oldstylemove(oldstylemove&);
13*f4a2713aSLionel Sambuc   oldstylemove(const arg&);
14*f4a2713aSLionel Sambuc };
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc template <typename T>
17*f4a2713aSLionel Sambuc void fn(T t, const arg& arg) {
18*f4a2713aSLionel Sambuc   oldstylemove obj(arg);
19*f4a2713aSLionel Sambuc }
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc void test() {
22*f4a2713aSLionel Sambuc   fn(1, arg());
23*f4a2713aSLionel Sambuc }
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc struct X0 { };
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc struct X1 {
28*f4a2713aSLionel Sambuc   explicit X1(const X0 &x0 = X0());
29*f4a2713aSLionel Sambuc };
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc template<typename T>
32*f4a2713aSLionel Sambuc void f0() {
33*f4a2713aSLionel Sambuc   X1 x1;
34*f4a2713aSLionel Sambuc }
35*f4a2713aSLionel Sambuc 
36*f4a2713aSLionel Sambuc template void f0<int>();
37*f4a2713aSLionel Sambuc template void f0<float>();
38*f4a2713aSLionel Sambuc 
39*f4a2713aSLionel Sambuc struct NonTrivial {
40*f4a2713aSLionel Sambuc   NonTrivial();
41*f4a2713aSLionel Sambuc   ~NonTrivial();
42*f4a2713aSLionel Sambuc };
43*f4a2713aSLionel Sambuc 
44*f4a2713aSLionel Sambuc template<int N> void f1() {
45*f4a2713aSLionel Sambuc   NonTrivial array[N];
46*f4a2713aSLionel Sambuc }
47*f4a2713aSLionel Sambuc template<> void f1<2>();
48