[clang] [HLSL] Add validation for the -enable-16bit-types option (PR #85340)

Joshua Batista via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 26 11:14:38 PDT 2024


================
@@ -0,0 +1,20 @@
+// RUN: not %clang_dxc -enable-16bit-types -T cs_6_0 -HV 2016 %s 2>&1  | FileCheck -check-prefix=both_invalid %s
+// RUN: not %clang_dxc -enable-16bit-types -T lib_6_4 -HV 2017 %s 2>&1 | FileCheck -check-prefix=HV_invalid %s
+// RUN: not %clang_dxc -enable-16bit-types -T cs_6_0 /HV 2021 %s 2>&1  | FileCheck -check-prefix=TP_invalid %s
+// RUN: %clang_dxc -enable-16bit-types -T lib_6_4 /HV 2021 %s 2>&1 -###   | FileCheck -check-prefix=valid %s
+
+
+// both_invalid: error: enable-16bit-types option only valid when target shader model [-T] is >= 6.2 and HLSL Version [-HV] is >= 2021
+// HV_invalid: error: enable-16bit-types option only valid when target shader model [-T] is >= 6.2 and HLSL Version [-HV] is >= 2021
+// TP_invalid: error: enable-16bit-types option only valid when target shader model [-T] is >= 6.2 and HLSL Version [-HV] is >= 2021
----------------
bob80905 wrote:

In the case that both requirements are not met, I don't think 2 diagnostics should be emitted. But I do think there is value to showing what the given values are. Maybe something like:
"16-bit types are only valid for shader model >= 6.2 and HLSL Version >= 2021, but shader model is '%1' and HLSL Version is '%2'" would be an improvement.
WDYT?

https://github.com/llvm/llvm-project/pull/85340


More information about the cfe-commits mailing list