dependent-sized_array.hlsl 574 B

12345678910111213141516171819202122232425262728
  1. // RUN: %dxc -E main -T ps_6_0 -enable-templates %s | FileCheck %s
  2. // CHECK: error: 'a3' declared as an array with a negative size
  3. template<int N>
  4. void f() {
  5. int a[] = { 1, 2, 3, N };
  6. uint numAs = sizeof(a) / sizeof(int);
  7. }
  8. template void f<17>();
  9. template<int N>
  10. void f1() {
  11. int a0[] = {}; // expected-warning{{zero}}
  12. int a1[] = { 1, 2, 3, N };
  13. int a3[sizeof(a1)/sizeof(int) != 4? 1 : -1]; // expected-error{{negative}}
  14. }
  15. namespace PR13788 {
  16. template <uint __N>
  17. struct S {
  18. int V;
  19. };
  20. template <int N>
  21. void foo() {
  22. S<0> arr[N] = {{ 4 }};
  23. }
  24. }