xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/enum-argument.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 enum Enum { val = 1 };
5*f4a2713aSLionel Sambuc template <Enum v> struct C {
6*f4a2713aSLionel Sambuc   typedef C<v> Self;
7*f4a2713aSLionel Sambuc };
8*f4a2713aSLionel Sambuc template struct C<val>;
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc template<typename T>
11*f4a2713aSLionel Sambuc struct get_size {
12*f4a2713aSLionel Sambuc   static const unsigned value = sizeof(T);
13*f4a2713aSLionel Sambuc };
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc template<typename T>
16*f4a2713aSLionel Sambuc struct X0 {
17*f4a2713aSLionel Sambuc   enum {
18*f4a2713aSLionel Sambuc     Val1 = get_size<T>::value,
19*f4a2713aSLionel Sambuc     Val2,
20*f4a2713aSLionel Sambuc     SumOfValues = Val1 + Val2
21*f4a2713aSLionel Sambuc   };
22*f4a2713aSLionel Sambuc };
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc X0<int> x0i;
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc namespace rdar8020920 {
27*f4a2713aSLionel Sambuc   template<typename T>
28*f4a2713aSLionel Sambuc   struct X {
29*f4a2713aSLionel Sambuc     enum { e0 = 32 };
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc     unsigned long long bitfield : e0;
32*f4a2713aSLionel Sambuc 
frdar8020920::X33*f4a2713aSLionel Sambuc     void f(int j) {
34*f4a2713aSLionel Sambuc       bitfield + j;
35*f4a2713aSLionel Sambuc     }
36*f4a2713aSLionel Sambuc   };
37*f4a2713aSLionel Sambuc }
38