xref: /llvm-project/clang/test/SemaTemplate/instantiate-clang.cpp (revision c49cde6467f9bf200640db763152a9dc7f009520)
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 
3 // Test template instantiation for Clang-specific features.
4 
5 // ---------------------------------------------------------------------
6 // Vector types
7 // ---------------------------------------------------------------------
8 typedef __attribute__(( ext_vector_type(2) )) double double2;
9 typedef __attribute__(( ext_vector_type(4) )) double double4;
10 
11 template<typename T>
12 struct ExtVectorAccess0 {
fExtVectorAccess013   void f(T v1, double4 v2) {
14     v1.xy = v2.yx;
15   }
16 };
17 
18 template struct ExtVectorAccess0<double2>;
19 template struct ExtVectorAccess0<double4>;
20 
21 template<typename T>
22 struct ExtVectorAccess1 {
fExtVectorAccess123   void f(T *v1, double4 *v2) {
24     v1->xy = v2->yx;
25   }
26 };
27 
28 template struct ExtVectorAccess1<double2>;
29 template struct ExtVectorAccess1<double4>;
30 
31 template<typename T, typename U, int N, int M>
32 struct ShuffleVector0 {
fShuffleVector033   void f(T t, U u, double2 a, double2 b) {
34     (void)__builtin_shufflevector(t, u, N, M); // expected-error{{index}}
35     (void)__builtin_shufflevector(a, b, N, M); // expected-error{{index}}
36     (void)__builtin_shufflevector(a, b, 2, 1);
37   }
38 };
39 
40 template struct ShuffleVector0<double2, double2, 2, 1>;
41 template struct ShuffleVector0<double2, double2, 4, 3>; // expected-note{{instantiation}}
42 
43 
44