Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s -std=c++0x |
Anders Carlsson | 76b1c84 | 2009-03-15 20:12:13 +0000 | [diff] [blame] | 2 | |
| 3 | #ifndef __GXX_EXPERIMENTAL_CXX0X__ |
| 4 | #define __CONCAT(__X, __Y) __CONCAT1(__X, __Y) |
| 5 | #define __CONCAT1(__X, __Y) __X ## __Y |
| 6 | |
| 7 | #define static_assert(__b, __m) \ |
| 8 | typedef int __CONCAT(__sa, __LINE__)[__b ? 1 : -1] |
| 9 | #endif |
| 10 | |
| 11 | template <int N> class IntArray { |
| 12 | int elems[N]; |
| 13 | }; |
| 14 | |
| 15 | static_assert(sizeof(IntArray<10>) == sizeof(int) * 10, "Array size mismatch"); |
| 16 | static_assert(sizeof(IntArray<1>) == sizeof(int) * 1, "Array size mismatch"); |
| 17 | |
| 18 | template <typename T> class TenElementArray { |
| 19 | int elems[10]; |
| 20 | }; |
| 21 | |
| 22 | static_assert(sizeof(TenElementArray<int>) == sizeof(int) * 10, "Array size mismatch"); |
| 23 | |
| 24 | template<typename T, int N> class Array { |
| 25 | T elems[N]; |
| 26 | }; |
| 27 | |
| 28 | static_assert(sizeof(Array<int, 10>) == sizeof(int) * 10, "Array size mismatch"); |