llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.83k stars 11k forks source link

Add support for C23 interchange float types (`_Float32`, `_Float64`, `_Float128`, ...) #97335

Open tgross35 opened 1 week ago

tgross35 commented 1 week ago

Newer versions of C allow the following relevant interchange types:

GCC currently supports all of these. Clang currently supports only _Float16, but should add the rest.

Link to the draft: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2601.pdf Link to demo: https://clang.godbolt.org/z/5xbq9919z

C++ also supports the same suffixes for the std types, https://en.cppreference.com/w/cpp/types/floating-point

It sounds like these can't simply be redefines of float and double, see https://github.com/llvm/llvm-project/issues/50110 (cc @AaronBallman)

llvmbot commented 1 week ago

@llvm/issue-subscribers-clang-frontend

Author: Trevor Gross (tgross35)

GCC supports `_Float32` and `_Float64` in both C and C++, with the associated `F32`, `F64`, and `F128` literal suffixes. Clang should add support for these to be compatible. It sounds like these can't simply be redefines of `float` and `double`, see https://github.com/llvm/llvm-project/issues/50110 (cc @AaronBallman)
pinskia commented 1 week ago

Note this is not exactly a GNU extension but for compatibility with GCC (via C23 defined extended floating point types).

tgross35 commented 1 week ago

Yes thanks, I updated the top post to give more context. It seems like GCC does not restrict these types to only --std=c23.