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

Natalie Chouinard via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 26 11:01:40 PDT 2024


================
@@ -4284,11 +4284,25 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
           Diags.Report(diag::err_drv_hlsl_bad_shader_unsupported)
               << ShaderModel << T.getOSName() << T.str();
         }
+        // validate that if fnative-half-type is given, that
+        // the language standard is at least hlsl2021, and that
+        // the target shader model is at least 6.2
+        if (Args.getLastArg(OPT_fnative_half_type)) {
+          if (!(Opts.LangStd >= LangStandard::lang_hlsl2021 &&
+                T.getOSVersion() >= VersionTuple(6, 2)))
+            Diags.Report(diag::err_drv_dxc_enable_16bit_types_option_invalid);
----------------
sudonatalie wrote:

Hm, I assume `enable-16bit-types` is the DXC compatibility driver flag and `fnative_half_type` is the plain clang flag. I don't have an opinion here but it might be worth thinking about in general how to handle selecting different error messages for these cases since they'll probably be common and it could be a bit confusing if the user uses A but the error message is for B.

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


More information about the cfe-commits mailing list