AssignmentOps.hlsl 975 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // RUN: %dxc -E main -T ps_6_0 -enable-templates %s | FileCheck %s
  2. // RUN: %dxc -E main -T ps_6_0 %s -enable-templates -DCHECK_DIAGNOSTICS | FileCheck %s -check-prefix=DIAG
  3. template<typename T0, typename T1>
  4. void assign(inout T0 t0, T1 t1) {
  5. t0 = t1;
  6. }
  7. struct S {
  8. int4 i4;
  9. float2 f2;
  10. float3x3 f3x3;
  11. bool4 b4;
  12. };
  13. void main() : SV_Target {
  14. int i;
  15. int1 i1;
  16. int2 i2;
  17. int3 i3;
  18. int4 i4;
  19. unsigned int j;
  20. unsigned int2x2 j2x2;
  21. float x;
  22. float3 x3;
  23. bool b;
  24. bool2 b2;
  25. S s, t;
  26. float4x3 f4arr[11];
  27. #ifdef CHECK_DIAGNOSTICS
  28. // DIAG-NOT: define void @main
  29. // DIAG: cannot implicitly convert
  30. assign(f4arr, x);
  31. // DIAG: warning: implicit truncation of vector type
  32. // DIAG: warning: implicit truncation of vector type
  33. assign(i, i4);
  34. assign(b, b2);
  35. // DIAG-NOT: error
  36. #else
  37. // CHECK: define void @main
  38. assign(i, j);
  39. assign(i, i1);
  40. assign(i, i1);
  41. assign(i, i1);
  42. assign(i2, i);
  43. assign(s, t);
  44. assign(s.i4, i4);
  45. #endif
  46. }