================
@@ -3845,6 +3845,17 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl,
unsigned BuiltinID,
if (BuiltinCountedByRef(TheCall))
return ExprError();
break;
+
+ case Builtin::BIfeclearexcept:
+ case Builtin::BIferaiseexcept:
+ case Builtin::BIfetestexcept:
+ case Builtin::BIfegetround:
+ case Builtin::BIfesetround:
+ if (!TheCall->getFPFeaturesInEffect(getLangOpts()).getAllowFEnvAccess() &&
+ getLangOpts().getFPExceptionMode() != LangOptions::FPE_MayTrap) {
----------------
maarcosrmz wrote:
That was my initial approach. However, compiling the test program with the
command line flag '-ffp-exception-behavior=maytrap' still produced the
warnings this way. As far as I understand the behavior with this flag should be
equivalent to when the pragma is set, which is why I added the second line.
I've been trying to figure out what's happening and noticed that even with the
flag '-ffp-model=strict', AllowFEnvAccess is false. Although I would expect it
to be true given
[this](https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/LangOptions.h#L877-L882).
Example using only `if
(!TheCall->getFPFeaturesInEffect(getLangOpts()).getAllowFEnvAccess()) {...}`
(where '-ffp-exception-behavior=maytrap' leads to the same result as
'-ffp-model=strict'):
```sh
$ ./build/bin/clang test.c -lm -ffp-model=strict
test.c:8:3: warning: 'feclearexcept' used without enabling floating-point
exception behavior; use 'pragma STDCFENV_ACCESS ON' or compile with
'-ffp-exception-behavior=maytrap'
[-Wfenv-access]
8 | feclearexcept(FE_INVALID);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
[...]
```
Could I be setting something up incorrectly, leading to this rather odd
behavior?
https://github.com/llvm/llvm-project/pull/187860
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits