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