Debian Codegraph @

clang/test/SemaHLSL/Language/InitIncompleteArrays.hlsl

raw
1 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -finclude-default-header -verify -Wdouble-promotion -Wconversion %s
2
3 // Some helpers!
4 template <typename T, typename U>
5 struct is_same {
6 static const bool value = false;
7 };
8
9 template <typename T>
10 struct is_same<T, T> {
11 static const bool value = true;
12 };
13
14 template<typename T>
15 struct remove_addrspace {
16 using type = __decltype((T)0);
17 };
18
19 template <typename T, typename V>
20 using is_same_ignore_addrspace = is_same<typename remove_addrspace<T>::type, typename remove_addrspace<V>::type>;
21
22 struct SomeVals {
23 int2 X;
24 float2 Y;
25 double2 D;
26 };
27
28 static SomeVals V = {1,2,3,4,5,6};
29
30 static int2 SomeArr[] = {V}; // #SomeArr
31 // expected-warning@#SomeArr 2 {{implicit conversion turns floating-point number into integer: 'double' to 'int'}}
32 // expected-warning@#SomeArr 2 {{implicit conversion turns floating-point number into integer: 'float' to 'int'}}
33
34 _Static_assert(is_same_ignore_addrspace<__decltype(SomeArr), int2[3]>::value, "What is this even?");
35
36 static int2 VecArr[] = {
37 int2(0,1),
38 int2(2,3),
39 int4(4,5,6,7),
40 };
41
42 _Static_assert(is_same_ignore_addrspace<__decltype(VecArr), int2[4]>::value, "One vec, two vec, three vecs, FOUR!");
43
44 static int4 V4Arr[] = {
45 int2(0,1),
46 int2(2,3),
47 };
48
49 _Static_assert(is_same_ignore_addrspace<__decltype(V4Arr), int4[1]>::value, "One!");
50
51 static int ArrOfArr[][4] = { 1, 2, 3, 4, 5, 6, 7, 8 };
52
53 _Static_assert(is_same_ignore_addrspace<__decltype(ArrOfArr), int[2][4]>::value, "Two arrays of four!");
54
55 // expected-error@+1{{too few initializers in list for type 'int4[]' (aka 'vector<int, 4>[]') (expected 4 but found 2)}}
56 static int4 V4ArrTooSmall[] = {
57 int2(0,1),
58 };
59
60 // expected-error@+1{{too few initializers in list for type 'int4[]' (aka 'vector<int, 4>[]') (expected 8 but found 7)}}
61 static int4 V4ArrAlsoTooSmall[] = {
62 int2(0,1),
63 int2(2,3),
64 int3(4,5,6),
65 };
66
67 // expected-error@+1{{too few initializers in list for type 'int[][2]' (expected 6 but found 5)}}
68 static int ArrOfArrTooSmall[][2] = { 1, 2, 3, 4, 5 };