diff options
| author | Sarah Spall <sarahspall@microsoft.com> | 2025-10-31 09:49:32 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-31 09:49:32 -0700 |
| commit | 42004193f4e22a61dc68f6414b82077edd1314e2 (patch) | |
| tree | ce352fd960e2389f5ca017371ac492d09f00ca69 /clang/lib/Frontend/CompilerInvocation.cpp | |
| parent | 7cd3be4a8b37838595563d3100619cdbc588da61 (diff) | |
[HLSL] Add NativeInt16Type langopt to control whether short type is supported. Enabled by default for all but HLSL. (#165584)
Add a new langopt NativeInt16Type to control support for 16 bit
integers.
Enable by default for all languages but HLSL.
HLSL defines uint16_t and int16_t as a typedef of short. If
-enable-16bit-types is not used, the typedefs don't exist so int16_t and
uint16_t can't be used. However, short was still allowed. This change
will produce an error 'unknown type name short' if -enable-16bit-types
isn't used.
Update failing tests.
Add new test.
Closes #81779
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
| -rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index bd36eb4ecf9d..1951e7f74748 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -4600,7 +4600,8 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args, // Validate that if fnative-half-type is given, that // the language standard is at least hlsl2018, and that // the target shader model is at least 6.2. - if (Args.getLastArg(OPT_fnative_half_type)) { + if (Args.getLastArg(OPT_fnative_half_type) || + Args.getLastArg(OPT_fnative_int16_type)) { const LangStandard &Std = LangStandard::getLangStandardForKind(Opts.LangStd); if (!(Opts.LangStd >= LangStandard::lang_hlsl2018 && @@ -4614,12 +4615,16 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args, Diags.Report(diag::err_drv_hlsl_bad_shader_unsupported) << VulkanEnv << T.getOSName() << T.str(); } - if (Args.getLastArg(OPT_fnative_half_type)) { + if (Args.getLastArg(OPT_fnative_half_type) || + Args.getLastArg(OPT_fnative_int16_type)) { + const char *Str = Args.getLastArg(OPT_fnative_half_type) + ? "-fnative-half-type" + : "-fnative-int16-type"; const LangStandard &Std = LangStandard::getLangStandardForKind(Opts.LangStd); if (!(Opts.LangStd >= LangStandard::lang_hlsl2018)) Diags.Report(diag::err_drv_hlsl_16bit_types_unsupported) - << "-fnative-half-type" << false << Std.getName(); + << Str << false << Std.getName(); } } else { llvm_unreachable("expected DXIL or SPIR-V target"); |
