instantiate-clang.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. // Test template instantiation for Clang-specific features.
  3. // ---------------------------------------------------------------------
  4. // Vector types
  5. // ---------------------------------------------------------------------
  6. typedef __attribute__(( ext_vector_type(2) )) double double2;
  7. typedef __attribute__(( ext_vector_type(4) )) double double4;
  8. template<typename T>
  9. struct ExtVectorAccess0 {
  10. void f(T v1, double4 v2) {
  11. v1.xy = v2.yx;
  12. }
  13. };
  14. template struct ExtVectorAccess0<double2>;
  15. template struct ExtVectorAccess0<double4>;
  16. typedef __attribute__(( ext_vector_type(2) )) double double2;
  17. template<typename T, typename U, int N, int M>
  18. struct ShuffleVector0 {
  19. void f(T t, U u, double2 a, double2 b) {
  20. (void)__builtin_shufflevector(t, u, N, M); // expected-error{{index}}
  21. (void)__builtin_shufflevector(a, b, N, M); // expected-error{{index}}
  22. (void)__builtin_shufflevector(a, b, 2, 1);
  23. }
  24. };
  25. template struct ShuffleVector0<double2, double2, 2, 1>;
  26. template struct ShuffleVector0<double2, double2, 4, 3>; // expected-note{{instantiation}}