@@ -11,6 +11,14 @@ struct is_same<T, T> {
11
11
static const bool value = true ;
12
12
};
13
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
+
14
22
struct SomeVals {
15
23
int2 X;
16
24
float2 Y;
@@ -23,22 +31,26 @@ static int2 SomeArr[] = {V}; // #SomeArr
23
31
// expected-warning@#SomeArr 2 {{implicit conversion turns floating-point number into integer: 'double' to 'int'}}
24
32
// expected-warning@#SomeArr 2 {{implicit conversion turns floating-point number into integer: 'float' to 'int'}}
25
33
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?" );
27
35
28
36
static int2 VecArr[] = {
29
37
int2 (0 ,1 ),
30
38
int2 (2 ,3 ),
31
39
int4 (4 ,5 ,6 ,7 ),
32
40
};
33
41
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!" );
35
43
36
44
static int4 V4Arr[] = {
37
45
int2 (0 ,1 ),
38
46
int2 (2 ,3 ),
39
47
};
40
48
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!" );
42
54
43
55
// expected-error@+1{{too few initializers in list for type 'int4[]' (aka 'vector<int, 4>[]') (expected 4 but found 2)}}
44
56
static int4 V4ArrTooSmall[] = {
@@ -51,3 +63,6 @@ static int4 V4ArrAlsoTooSmall[] = {
51
63
int2 (2 ,3 ),
52
64
int3 (4 ,5 ,6 ),
53
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 };
0 commit comments