69 lines · plain
1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -finclude-default-header -verify -Wdouble-promotion -Wconversion %s2 3// Some helpers!4template <typename T, typename U>5struct is_same {6 static const bool value = false;7};8 9template <typename T>10struct is_same<T, T> {11 static const bool value = true;12};13 14template<typename T>15struct remove_addrspace {16 using type = __decltype((T)0);17};18 19template <typename T, typename V>20using is_same_ignore_addrspace = is_same<typename remove_addrspace<T>::type, typename remove_addrspace<V>::type>;21 22struct SomeVals {23 int2 X;24 float2 Y;25 double2 D;26};27 28static SomeVals V = {1,2,3,4,5,6};29 30static int2 SomeArr[] = {V}; // #SomeArr31// 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 36static 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 44static 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 51static 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)}}56static 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)}}61static 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)}}68static int ArrOfArrTooSmall[][2] = { 1, 2, 3, 4, 5 };69