@@ -11,6 +11,14 @@ struct is_same<T, T> {
1111 static const bool value = true ;
1212};
1313
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+
1422struct SomeVals {
1523 int2 X;
1624 float2 Y;
@@ -23,22 +31,26 @@ static int2 SomeArr[] = {V}; // #SomeArr
2331// expected-warning@#SomeArr 2 {{implicit conversion turns floating-point number into integer: 'double' to 'int'}}
2432// expected-warning@#SomeArr 2 {{implicit conversion turns floating-point number into integer: 'float' to 'int'}}
2533
26- _Static_assert (is_same <__decltype (SomeArr), int2 [3 ]>::value, "What is this even?" );
34+ _Static_assert (is_same_ignore_addrspace <__decltype (SomeArr), int2 [3 ]>::value, "What is this even?" );
2735
2836static int2 VecArr[] = {
2937 int2 (0 ,1 ),
3038 int2 (2 ,3 ),
3139 int4 (4 ,5 ,6 ,7 ),
3240 };
3341
34- _Static_assert (is_same <__decltype (VecArr), int2 [4 ]>::value, "One vec, two vec, three vecs, FOUR!" );
42+ _Static_assert (is_same_ignore_addrspace <__decltype (VecArr), int2 [4 ]>::value, "One vec, two vec, three vecs, FOUR!" );
3543
3644static int4 V4Arr[] = {
3745 int2 (0 ,1 ),
3846 int2 (2 ,3 ),
3947};
4048
41- _Static_assert (is_same<__decltype (V4Arr), int4 [1 ]>::value, "One!" );
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!" );
4254
4355// expected-error@+1{{too few initializers in list for type 'int4[]' (aka 'vector<int, 4>[]') (expected 4 but found 2)}}
4456static int4 V4ArrTooSmall[] = {
@@ -51,3 +63,6 @@ static int4 V4ArrAlsoTooSmall[] = {
5163 int2 (2 ,3 ),
5264 int3 (4 ,5 ,6 ),
5365};
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 };
0 commit comments