[clang] [HLSL] Add NativeInt16Type langopt to control whether short type is supported. Enabled by default for all but HLSL. (PR #165584)

Sarah Spall via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 29 09:58:27 PDT 2025


================
@@ -4248,6 +4248,13 @@ void Parser::ParseDeclarationSpecifiers(
 
     // type-specifier
     case tok::kw_short:
+      if (!getLangOpts().NativeInt16Type) {
----------------
spall wrote:

int16_t and uint16_t are typedefs of short, and those typedefs were only generated if -enable-16bit-types was passed.  This should be the errors you are talking about.  The issue (which isn't clear from how the issue is written), is that users could still write their program using short 
```
export short allowed(short S) {return S+1;} // allowed because short is allowed
export uint16_t notAllowed(uint16_t U) {return U+ 1;} // not allowed because typedef of uint16_t  is missing
```
The point was to produce an error if a user used short when -enable-16bit-types is not passed. 

Half is still a valid type even if 16 bit types are not enabled. It is just a 32 bit float instead of 16 bits.

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


More information about the cfe-commits mailing list