xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/instantiate-declref-ice.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc // expected-no-diagnostics
3*f4a2713aSLionel Sambuc template<int i> struct x {
4*f4a2713aSLionel Sambuc   static const int j = i;
5*f4a2713aSLionel Sambuc   x<j>* y;
6*f4a2713aSLionel Sambuc };
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc template<int i>
9*f4a2713aSLionel Sambuc const int x<i>::j;
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc int array0[x<2>::j];
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc template<typename T>
14*f4a2713aSLionel Sambuc struct X0 {
15*f4a2713aSLionel Sambuc   static const unsigned value = sizeof(T);
16*f4a2713aSLionel Sambuc };
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc template<typename T>
19*f4a2713aSLionel Sambuc const unsigned X0<T>::value;
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc int array1[X0<int>::value == sizeof(int)? 1 : -1];
22*f4a2713aSLionel Sambuc 
testX0()23*f4a2713aSLionel Sambuc const unsigned& testX0() { return X0<int>::value; }
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc int array2[X0<int>::value == sizeof(int)? 1 : -1];
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc template<typename T>
28*f4a2713aSLionel Sambuc struct X1 {
29*f4a2713aSLionel Sambuc   static const unsigned value;
30*f4a2713aSLionel Sambuc };
31*f4a2713aSLionel Sambuc 
32*f4a2713aSLionel Sambuc template<typename T>
33*f4a2713aSLionel Sambuc const unsigned X1<T>::value = sizeof(T);
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc int array3[X1<int>::value == sizeof(int)? 1 : -1];
36