instantiate-array.cpp 811 B

1234567891011121314151617181920212223242526272829
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
  2. // expected-no-diagnostics
  3. #ifndef __GXX_EXPERIMENTAL_CXX0X__
  4. #define __CONCAT(__X, __Y) __CONCAT1(__X, __Y)
  5. #define __CONCAT1(__X, __Y) __X ## __Y
  6. #define static_assert(__b, __m) \
  7. typedef int __CONCAT(__sa, __LINE__)[__b ? 1 : -1]
  8. #endif
  9. template <int N> class IntArray {
  10. int elems[N];
  11. };
  12. static_assert(sizeof(IntArray<10>) == sizeof(int) * 10, "Array size mismatch");
  13. static_assert(sizeof(IntArray<1>) == sizeof(int) * 1, "Array size mismatch");
  14. template <typename T> class TenElementArray {
  15. int elems[10];
  16. };
  17. static_assert(sizeof(TenElementArray<int>) == sizeof(int) * 10, "Array size mismatch");
  18. template<typename T, int N> class Array {
  19. T elems[N];
  20. };
  21. static_assert(sizeof(Array<int, 10>) == sizeof(int) * 10, "Array size mismatch");