ext_vector_components.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. typedef __attribute__(( ext_vector_type(2) )) float float2;
  3. typedef __attribute__(( ext_vector_type(3) )) float float3;
  4. typedef __attribute__(( ext_vector_type(4) )) float float4;
  5. typedef __attribute__(( ext_vector_type(16) )) float float16;
  6. static float4 vec4_0 = (float4)0.5f;
  7. static void test() {
  8. float2 vec2, vec2_2;
  9. float3 vec3;
  10. float4 vec4, vec4_2, *vec4p;
  11. float16 vec16;
  12. float f;
  13. vec2.z; // expected-error {{vector component access exceeds type 'float2'}}
  14. vec2.xyzw; // expected-error {{vector component access exceeds type 'float2'}}
  15. vec4.xyzw; // expected-warning {{expression result unused}}
  16. vec4.xyzc; // expected-error {{illegal vector component name 'c'}}
  17. vec4.s01z; // expected-error {{illegal vector component name 'z'}}
  18. vec2 = vec4.s01; // legal, shorten
  19. vec2 = vec4.S01; // legal, shorten
  20. vec3 = vec4.xyz; // legal, shorten
  21. f = vec2.x; // legal, shorten
  22. f = vec4.xy.x; // legal, shorten
  23. vec4_2.xyzx = vec4.xyzw; // expected-error {{vector is not assignable (contains duplicate components)}}
  24. vec4_2.xyzz = vec4.xyzw; // expected-error {{vector is not assignable (contains duplicate components)}}
  25. vec4_2.xyyw = vec4.xyzw; // expected-error {{vector is not assignable (contains duplicate components)}}
  26. vec2.x = f;
  27. vec2.xx = vec2_2.xy; // expected-error {{vector is not assignable (contains duplicate components)}}
  28. vec2.yx = vec2_2.xy;
  29. vec4 = (float4){ 1,2,3,4 };
  30. vec4.xy.w; // expected-error {{vector component access exceeds type 'float2'}}
  31. vec4.s06; // expected-error {{vector component access exceeds type 'float4'}}
  32. vec4.x = vec16.sf;
  33. vec4.x = vec16.sF;
  34. vec4p->yz = vec4p->xy;
  35. }
  36. float2 lo(float3 x) { return x.lo; }
  37. float2 hi(float3 x) { return x.hi; }
  38. float2 ev(float3 x) { return x.even; }
  39. float2 od(float3 x) { return x.odd; }