[clang] Add clang warning if fp exception functions are called without appropriate flags/pragmas (PR #199009)

Marcos Ramirez Joos via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 17 12:35:10 PDT 2026


maarcosrmz wrote:

I created #224384 to fix the error triggered when building subprojects that include libc headers using FP environment functions, e.g. flang in our case. If @lntue's suggestion of avoiding any access to the FP environment inside libc when building these subprojects holds for all uses, this fix should prevent similar errors in the future. (@lntue, I would appreciate it if you could take a look at that PR.)

On a different note, the approach used [here](https://github.com/llvm/llvm-project/blob/main/flang/include/flang/Common/fp-control.h#L24-L32) breaks compilation for compilers that do not support the pragma (see [this](https://godbolt.org/z/svMoz4Kx6)). I therefore believe flang might need to follow libc (see https://github.com/llvm/llvm-project/pull/200268) in determining at build configuration time whether the pragma should be used. I suggest we do the same in flang and flang-rt, and in particular in [flang/lib/Evaluate/host.cpp](https://github.com/llvm/llvm-project/blob/main/flang/lib/Evaluate/host.cpp) and [llvm/lib/Analysis/ConstantFolding.cpp](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/ConstantFolding.cpp). @efriedma-quic, if there are no objections I will go ahead with this.



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


More information about the cfe-commits mailing list