dependent-sized_array.cpp 506 B

12345678910111213141516171819202122232425262728
  1. // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
  2. template<int N>
  3. void f() {
  4. int a[] = { 1, 2, 3, N };
  5. unsigned numAs = sizeof(a) / sizeof(int);
  6. }
  7. template void f<17>();
  8. template<int N>
  9. void f1() {
  10. int a0[] = {}; // expected-warning{{zero}}
  11. int a1[] = { 1, 2, 3, N };
  12. int a3[sizeof(a1)/sizeof(int) != 4? 1 : -1]; // expected-error{{negative}}
  13. }
  14. namespace PR13788 {
  15. template <unsigned __N>
  16. struct S {
  17. int V;
  18. };
  19. template <int N>
  20. void foo() {
  21. S<0> arr[N] = {{ 4 }};
  22. }
  23. }