[clang] [flang] [flang] Add UNSIGNED (PR #113504)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 24 06:36:41 PDT 2024


================
@@ -400,6 +400,69 @@ constexpr TypeBuilderFunc getModel<bool &>() {
     return fir::ReferenceType::get(f(context));
   };
 }
+template <>
+constexpr TypeBuilderFunc getModel<unsigned short>() {
+  return getModel<short>();
----------------
jeanPerier wrote:

I think we need to keep track of the unsigned aspect in the signature because the LLVM signature for unsigned short is different than for signed short (`zeroext` attribute vs `signext` attribute)

See  https://godbolt.org/z/Yo94sdxE9, that shows `clang -emit-llvm` output for:
```
short test_signed(short x) {return x;}
unsigned short test_unsigned(unsigned short x) {return x;}
```

LLVM:
```
define dso_local signext i16 @test_signed(i16 noundef signext)
define dso_local zeroext i16 @test_unsigned(i16 noundef zeroext)
```

These attributes are important (flang used to not generate signext for short, and this caused a [bug in gamess](https://github.com/llvm/llvm-project/commit/ff794116f9815979f9a3a1195aff9be49334da7a)).

The same concern probably applies to BIND(C) contexts.


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


More information about the cfe-commits mailing list