[AMDGPU] Removed superfluous predicate. NFC.
[llvm-project.git] / clang / test / SemaTemplate / ext-vector-type.cpp
blobf968c13f10238e97c8e349e8e0a35127cd2d273a
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 template<typename T, unsigned Length>
3 struct make1 {
4 typedef T __attribute__((ext_vector_type(Length))) type;
5 };
7 void test_make1() {
8 make1<int, 5>::type x;
9 x.x = 4;
12 template<typename T, unsigned Length>
13 struct make2 {
14 typedef T __attribute__((ext_vector_type(Length))) type; // expected-error{{zero vector size}}
17 int test_make2() {
18 make2<int, 0> x; // expected-note{{in instantiation of}}
21 template<typename T, unsigned Length>
22 struct make3 {
23 typedef T __attribute__((ext_vector_type(Length))) type; // expected-error{{invalid vector element type 's'}}
26 struct s {};
28 int test_make3() {
29 make3<s, 3>x; // expected-note{{in instantiation of}}
32 template<typename T, T Length>
33 struct make4 {
34 typedef T __attribute__((ext_vector_type(Length))) type;
37 int test_make4() {
38 make4<int, 4>::type x;
39 x.w = 7;
42 typedef int* int_ptr;
43 template<unsigned Length>
44 struct make5 {
45 typedef int_ptr __attribute__((ext_vector_type(Length))) type; // expected-error{{invalid vector element type}}
48 template<int Length>
49 struct make6 {
50 typedef int __attribute__((ext_vector_type(Length))) type;
53 int test_make6() {
54 make6<4>::type x;
55 x.w = 7;
57 make6<2>::type y;
58 y.x = -1;
59 y.w = -1; // expected-error{{vector component access exceeds type}}
62 namespace Deduction {
63 template<typename T> struct X0;
65 template<typename T, unsigned N>
66 struct X0<T __attribute__((ext_vector_type(N)))> {
67 static const unsigned value = 0;
70 template<typename T>
71 struct X0<T __attribute__((ext_vector_type(4)))> {
72 static const unsigned value = 1;
75 template<unsigned N>
76 struct X0<float __attribute__((ext_vector_type(N)))> {
77 static const unsigned value = 2;
80 template<>
81 struct X0<float __attribute__((ext_vector_type(4)))> {
82 static const unsigned value = 3;
85 typedef int __attribute__((ext_vector_type(2))) int2;
86 typedef int __attribute__((ext_vector_type(4))) int4;
87 typedef float __attribute__((ext_vector_type(2))) float2;
88 typedef float __attribute__((ext_vector_type(4))) float4;
90 int array0[X0<int2>::value == 0? 1 : -1];
91 int array1[X0<int4>::value == 1? 1 : -1];
92 int array2[X0<float2>::value == 2? 1 : -1];
93 int array3[X0<float4>::value == 3? 1 : -1];