xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/instantiate-array.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
2*f4a2713aSLionel Sambuc // expected-no-diagnostics
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc #ifndef __GXX_EXPERIMENTAL_CXX0X__
5*f4a2713aSLionel Sambuc #define __CONCAT(__X, __Y) __CONCAT1(__X, __Y)
6*f4a2713aSLionel Sambuc #define __CONCAT1(__X, __Y) __X ## __Y
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc #define static_assert(__b, __m) \
9*f4a2713aSLionel Sambuc   typedef int __CONCAT(__sa, __LINE__)[__b ? 1 : -1]
10*f4a2713aSLionel Sambuc #endif
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc template <int N> class IntArray {
13*f4a2713aSLionel Sambuc   int elems[N];
14*f4a2713aSLionel Sambuc };
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc static_assert(sizeof(IntArray<10>) == sizeof(int) * 10, "Array size mismatch");
17*f4a2713aSLionel Sambuc static_assert(sizeof(IntArray<1>) == sizeof(int) * 1, "Array size mismatch");
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc template <typename T> class TenElementArray {
20*f4a2713aSLionel Sambuc   int elems[10];
21*f4a2713aSLionel Sambuc };
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc static_assert(sizeof(TenElementArray<int>) == sizeof(int) * 10, "Array size mismatch");
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc template<typename T, int N> class Array {
26*f4a2713aSLionel Sambuc   T elems[N];
27*f4a2713aSLionel Sambuc };
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc static_assert(sizeof(Array<int, 10>) == sizeof(int) * 10, "Array size mismatch");
30