https://github.com/maarcosrmz updated 
https://github.com/llvm/llvm-project/pull/187860

>From 67c5c319f0ba67f5cf1bf664ff9583ce37437956 Mon Sep 17 00:00:00 2001
From: Marcos Ramirez Joos <[email protected]>
Date: Wed, 11 Mar 2026 21:55:35 +0100
Subject: [PATCH 1/5] Added warning for feclearexcept, feraiseexcept,
 fetestexcept, fegetround, and fesetround being used without appropriate
 flags/pragmas (#128239)

---
 clang/include/clang/Basic/BuiltinHeaders.def  |  1 +
 clang/include/clang/Basic/Builtins.td         | 25 +++++++++++++++++++
 .../clang/Basic/DiagnosticSemaKinds.td        |  5 ++++
 clang/lib/Sema/SemaChecking.cpp               | 11 ++++++++
 4 files changed, 42 insertions(+)

diff --git a/clang/include/clang/Basic/BuiltinHeaders.def 
b/clang/include/clang/Basic/BuiltinHeaders.def
index bca40c0e4deea..a375b71f6bce6 100644
--- a/clang/include/clang/Basic/BuiltinHeaders.def
+++ b/clang/include/clang/Basic/BuiltinHeaders.def
@@ -17,6 +17,7 @@ HEADER(BLOCKS_H, "Blocks.h")
 HEADER(COMPLEX_H, "complex.h")
 HEADER(CTYPE_H, "ctype.h")
 HEADER(EMMINTRIN_H, "emmintrin.h")
+HEADER(FENV_H, "fenv.h")
 HEADER(FOUNDATION_NSOBJCRUNTIME_H, "Foundation/NSObjCRuntime.h")
 HEADER(IMMINTRIN_H, "immintrin.h")
 HEADER(INTRIN_H, "intrin.h")
diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index f1743c7286def..510241f03102b 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4409,6 +4409,31 @@ def BlockObjectDispose : LibBuiltin<"blocks.h"> {
 }
 // FIXME: Also declare NSConcreteGlobalBlock and NSConcreteStackBlock.
 
+def FeClearExcept : LibBuiltin<"fenv.h"> {
+  let Spellings = ["feclearexcept"];
+  let Prototype = "int(int)";
+}
+
+def FeRaiseExcept : LibBuiltin<"fenv.h"> {
+  let Spellings = ["feraiseexcept"];
+  let Prototype = "int(int)";
+}
+
+def FeTestExcept : LibBuiltin<"fenv.h"> {
+  let Spellings = ["fetestexcept"];
+  let Prototype = "int(int)";
+}
+
+def FeGetRound : LibBuiltin<"fenv.h"> {
+  let Spellings = ["fegetround"];
+  let Prototype = "int()";
+}
+
+def FeSetRound : LibBuiltin<"fenv.h"> {
+  let Spellings = ["fesetround"];
+  let Prototype = "int(int)";
+}
+
 def __Addressof : LangBuiltin<"CXX_LANG"> {
   let Spellings = ["__addressof"];
   let Attributes = [FunctionWithoutBuiltinPrefix, NoThrow, Const,
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 4d352f1def04b..71af7b5e18fe1 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1035,6 +1035,11 @@ def err_ptrauth_indirect_goto_addrlabel_arithmetic : 
Error<
   "%select{subtraction|addition}0 of address-of-label expressions is not "
   "supported with ptrauth indirect gotos">;
 
+def warn_fe_access_without_fenv_access : Warning<
+  "'%0' used without enabling floating-point exception behavior; use 'pragma 
STDC "
+  "FENV_ACCESS ON' or compile with '-ffp-exception-behavior=maytrap'">,
+  InGroup<DiagGroup<"fenv-access">>;
+
 // __ptrauth qualifier
 def err_ptrauth_qualifier_invalid : Error<
   "%select{return type|parameter type|property}1 may not be qualified with "
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index de8b965144971..7f80880d83273 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3843,6 +3843,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()).getExceptionMode() ==
+        LangOptions::FPE_Ignore) {
+      Diag(TheCall->getBeginLoc(), diag::warn_fe_access_without_fenv_access)
+          << FDecl->getName() << TheCall->getSourceRange();
+    }
   }
 
   if (getLangOpts().HLSL && HLSL().CheckBuiltinFunctionCall(BuiltinID, 
TheCall))

>From e8d5e58b8f8576a28691377d93e586ff08ccef67 Mon Sep 17 00:00:00 2001
From: Marcos Ramirez Joos <[email protected]>
Date: Fri, 27 Mar 2026 20:10:25 +0100
Subject: [PATCH 2/5] Added regression tests for fenv access warning

---
 clang/test/Sema/fenv-access.c | 37 +++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 clang/test/Sema/fenv-access.c

diff --git a/clang/test/Sema/fenv-access.c b/clang/test/Sema/fenv-access.c
new file mode 100644
index 0000000000000..57d4debfa9c73
--- /dev/null
+++ b/clang/test/Sema/fenv-access.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -verify -Wfenv-access %s
+// RUN: %clang_cc1 -verify -Wfenv-access -ffp-exception-behavior=maytrap 
-DNO_WARN %s
+// RUN: %clang_cc1 -verify -Wfenv-access -ffp-exception-behavior=strict 
-DNO_WARN %s
+
+int feclearexcept(int excepts);
+int feraiseexcept(int excepts);
+int fetestexcept(int excepts);
+int fegetround(void);
+int fesetround(int rounding_mode);
+
+#define FE_INVALID 1
+
+void test_fenv_access_off(void) {
+#ifdef NO_WARN
+  // expected-no-diagnostics
+  feclearexcept(FE_INVALID);
+  feraiseexcept(FE_INVALID);
+  fetestexcept(FE_INVALID);
+  fegetround();
+  fesetround(0);
+#else 
+  feclearexcept(FE_INVALID); // expected-warning {{'feclearexcept' used 
without enabling floating-point exception behavior; use 'pragma STDC 
FENV_ACCESS ON' or compile with '-ffp-exception-behavior=maytrap'}}
+  feraiseexcept(FE_INVALID); // expected-warning {{'feraiseexcept' used 
without enabling floating-point exception behavior; use 'pragma STDC 
FENV_ACCESS ON' or compile with '-ffp-exception-behavior=maytrap'}}
+  fetestexcept(FE_INVALID); // expected-warning {{'fetestexcept' used without 
enabling floating-point exception behavior; use 'pragma STDC FENV_ACCESS ON' or 
compile with '-ffp-exception-behavior=maytrap'}}
+  fegetround(); // expected-warning {{'fegetround' used without enabling 
floating-point exception behavior; use 'pragma STDC FENV_ACCESS ON' or compile 
with '-ffp-exception-behavior=maytrap'}}
+  fesetround(0); // expected-warning {{'fesetround' used without enabling 
floating-point exception behavior; use 'pragma STDC FENV_ACCESS ON' or compile 
with '-ffp-exception-behavior=maytrap'}}
+#endif
+}
+
+void test_fenv_access_on(void) {
+  #pragma STDC FENV_ACCESS ON
+  feclearexcept(FE_INVALID);
+  feraiseexcept(FE_INVALID);
+  fetestexcept(FE_INVALID);
+  fegetround();
+  fesetround(0);
+}

>From 81530e3625327996c4641d7a6ba514030f7c66cb Mon Sep 17 00:00:00 2001
From: Marcos Ramirez Joos <[email protected]>
Date: Sun, 29 Mar 2026 13:21:47 +0200
Subject: [PATCH 3/5] Added builtin types fexcept_t and fenv_t (fenv.h)

---
 clang/include/clang/AST/ASTContext.h          | 37 ++++++++++++++++++-
 clang/include/clang/Basic/TokenKinds.def      |  2 +
 .../include/clang/Serialization/ASTBitCodes.h |  8 +++-
 clang/lib/AST/ASTContext.cpp                  | 19 ++++++++++
 clang/lib/Sema/SemaDecl.cpp                   |  8 ++++
 clang/lib/Serialization/ASTReader.cpp         | 36 ++++++++++++++++++
 clang/lib/Serialization/ASTWriter.cpp         |  2 +
 clang/utils/TableGen/ClangBuiltinsEmitter.cpp |  2 +
 8 files changed, 112 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index ba1b58489c327..213d723e547c1 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -497,6 +497,12 @@ class ASTContext : public RefCountedBase<ASTContext> {
   /// The type for the C ucontext_t type.
   TypeDecl *ucontext_tDecl = nullptr;
 
+  /// The type for the C fexcept_t type.
+  TypeDecl *fexcept_tDecl = nullptr;
+
+  /// The type for the C fenv_t type.
+  TypeDecl *fenv_tDecl = nullptr;
+
   /// Type for the Block descriptor for Blocks CodeGen.
   ///
   /// Since this is only used for generation of debug info, it is not
@@ -2334,6 +2340,32 @@ class ASTContext : public RefCountedBase<ASTContext> {
     return QualType();
   }
 
+  /// Set the type for the C fexcept_t type.
+  void setfexcept_tDecl(TypeDecl *fexcept_tDecl) {
+    this->fexcept_tDecl = fexcept_tDecl;
+  }
+
+  /// Retrieve the C fexcept_t type.
+  QualType getfexcept_tType() const {
+    if (fexcept_tDecl)
+      return getTypeDeclType(ElaboratedTypeKeyword::None,
+                             /*Qualifier=*/std::nullopt, fexcept_tDecl);
+    return QualType();
+  }
+
+  /// Set the type for the C fenv_t type.
+  void setfenv_tDecl(TypeDecl *fenv_tDecl) {
+    this->fenv_tDecl = fenv_tDecl;
+  }
+
+  /// Retrieve the C fenv_t type.
+  QualType getfenv_tType() const {
+    if (fenv_tDecl)
+      return getTypeDeclType(ElaboratedTypeKeyword::None,
+                             /*Qualifier=*/std::nullopt, fenv_tDecl);
+    return QualType();
+  }
+
   /// The result type of logical operations, '<', '>', '!=', etc.
   CanQualType getLogicalOperationType() const {
     return getLangOpts().CPlusPlus ? BoolTy : IntTy;
@@ -2614,7 +2646,10 @@ class ASTContext : public RefCountedBase<ASTContext> {
     GE_Missing_setjmp,
 
     /// Missing a type from <ucontext.h>
-    GE_Missing_ucontext
+    GE_Missing_ucontext,
+
+    /// Missing a type from <fenv.h>
+    GE_Missing_fenv
   };
 
   QualType DecodeTypeStr(const char *&Str, const ASTContext &Context,
diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 8b9f613037718..9a2e5c1c198e1 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -873,6 +873,8 @@ NOTABLE_IDENTIFIER(FILE)
 NOTABLE_IDENTIFIER(jmp_buf)
 NOTABLE_IDENTIFIER(sigjmp_buf)
 NOTABLE_IDENTIFIER(ucontext_t)
+NOTABLE_IDENTIFIER(fexcept_t)
+NOTABLE_IDENTIFIER(fenv_t)
 NOTABLE_IDENTIFIER(float_t)
 NOTABLE_IDENTIFIER(double_t)
 
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index 4e8fe1d32d42e..c6e5357ae147b 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1214,7 +1214,13 @@ enum SpecialTypeIDs {
   SPECIAL_TYPE_OBJC_SEL_REDEFINITION = 6,
 
   /// C ucontext_t typedef type
-  SPECIAL_TYPE_UCONTEXT_T = 7
+  SPECIAL_TYPE_UCONTEXT_T = 7,
+
+  /// C fexcept_t typedef type
+  SPECIAL_TYPE_FEXCEPT_T = 8,
+
+  /// C fenv_t typedef type
+  SPECIAL_TYPE_FENV_T = 9
 };
 
 /// The number of special type IDs.
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index a8cfdca1cb96d..64df8879979c9 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -12822,6 +12822,25 @@ static QualType DecodeTypeFromStr(const char *&Str, 
const ASTContext &Context,
   case 'm':
     Type = Context.MFloat8Ty;
     break;
+  case 'T':
+    switch (*Str++) {
+      case 'x': {
+        Type = Context.getfexcept_tType();
+        break;
+      }
+      case 'e': {
+        Type = Context.getfenv_tType();
+        break;
+      }
+      default: { 
+        llvm_unreachable("Unexpected target builtin type"); 
+      }
+    }
+    if (Type.isNull()) {
+      Error = ASTContext::GE_Missing_fenv;
+      return {};
+    }
+    break;
   }
 
   // If there are modifiers and if we're allowed to parse them, go for it.
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 2951fd09294d8..45de3d89e3bb1 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2377,6 +2377,8 @@ static StringRef getHeaderName(Builtin::Context 
&BuiltinInfo, unsigned ID,
     return "setjmp.h";
   case ASTContext::GE_Missing_ucontext:
     return "ucontext.h";
+  case ASTContext::GE_Missing_fenv:
+    return "fenv.h";
   }
   llvm_unreachable("unhandled error kind");
 }
@@ -6994,6 +6996,12 @@ Sema::ActOnTypedefNameDecl(Scope *S, DeclContext *DC, 
TypedefNameDecl *NewTD,
       case tok::NotableIdentifierKind::ucontext_t:
         Context.setucontext_tDecl(NewTD);
         break;
+      case tok::NotableIdentifierKind::fexcept_t:
+        Context.setfexcept_tDecl(NewTD);
+        break;
+      case tok::NotableIdentifierKind::fenv_t:
+        Context.setfenv_tDecl(NewTD);
+        break;
       case tok::NotableIdentifierKind::float_t:
       case tok::NotableIdentifierKind::double_t:
         NewTD->addAttr(AvailableOnlyInDefaultEvalMethodAttr::Create(Context));
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 7c3a6fceb3623..0293273fd35cc 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -5689,6 +5689,42 @@ void ASTReader::InitializeContext() {
         }
       }
     }
+
+    if (TypeID Fexcept_t = SpecialTypes[SPECIAL_TYPE_FEXCEPT_T]) {
+      QualType Fexcept_tType = GetType(Fexcept_t);
+      if (Fexcept_tType.isNull()) {
+        Error("fexcept_t type is NULL");
+        return;
+      }
+
+      if (!Context.fexcept_tDecl) {
+        if (const TypedefType *Typedef = Fexcept_tType->getAs<TypedefType>())
+          Context.setfexcept_tDecl(Typedef->getDecl());
+        else {
+          const TagType *Tag = Fexcept_tType->getAs<TagType>();
+          assert(Tag && "Invalid fexcept_t type in AST file");
+          Context.setfexcept_tDecl(Tag->getDecl());
+        }
+      }
+    }
+
+    if (TypeID Fenv_t = SpecialTypes[SPECIAL_TYPE_FENV_T]) {
+      QualType Fenv_tType = GetType(Fenv_t);
+      if (Fenv_tType.isNull()) {
+        Error("fenv_t type is NULL");
+        return;
+      }
+
+      if (!Context.fenv_tDecl) {
+        if (const TypedefType *Typedef = Fenv_tType->getAs<TypedefType>())
+          Context.setfenv_tDecl(Typedef->getDecl());
+        else {
+          const TagType *Tag = Fenv_tType->getAs<TagType>();
+          assert(Tag && "Invalid fenv_t type in AST file");
+          Context.setfenv_tDecl(Tag->getDecl());
+        }
+      }
+    }
   }
 
   ReadPragmaDiagnosticMappings(Context.getDiagnostics());
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 9f05daaf65850..b7255b724f76c 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -6109,6 +6109,8 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema *SemaPtr, 
StringRef isysroot,
     AddTypeRef(Context, Context.ObjCClassRedefinitionType, SpecialTypes);
     AddTypeRef(Context, Context.ObjCSelRedefinitionType, SpecialTypes);
     AddTypeRef(Context, Context.getucontext_tType(), SpecialTypes);
+    AddTypeRef(Context, Context.getfexcept_tType(), SpecialTypes);
+    AddTypeRef(Context, Context.getfenv_tType(), SpecialTypes);
   }
 
   if (SemaPtr)
diff --git a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp 
b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
index f628a993a23cc..d31ff1bb1482e 100644
--- a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
+++ b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
@@ -374,6 +374,8 @@ class PrototypeParser {
                                .Case("uint64_t", "UWi")
                                .Case("void", "v")
                                .Case("wchar_t", "w")
+                               .Case("fexcept_t", "Tx")
+                               .Case("fenv_t", "Te")
                                .Case("...", ".")
                                .Default("error");
       if (ReturnTypeVal == "error")

>From abd5e4e90d236b891f42b83ca2bc16cc8b60eb08 Mon Sep 17 00:00:00 2001
From: Marcos Ramirez Joos <[email protected]>
Date: Sun, 29 Mar 2026 15:28:56 +0200
Subject: [PATCH 4/5] Added warning for fegetexceptflag, fesetexceptflag,
 fegetenv, feholdexcept, fesetenv, feupdateenv being used without appropriate
 flags/pragmas (#128239)

---
 clang/include/clang/Basic/Builtins.td | 30 +++++++++++++++++++++++++++
 clang/lib/Sema/SemaChecking.cpp       |  6 ++++++
 2 files changed, 36 insertions(+)

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 510241f03102b..16f4d0bde22cb 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4414,11 +4414,21 @@ def FeClearExcept : LibBuiltin<"fenv.h"> {
   let Prototype = "int(int)";
 }
 
+def FeGetExceptFlag : LibBuiltin<"fenv.h"> {
+  let Spellings = ["fegetexceptflag"];
+  let Prototype = "int(fexcept_t*, int)";
+}
+
 def FeRaiseExcept : LibBuiltin<"fenv.h"> {
   let Spellings = ["feraiseexcept"];
   let Prototype = "int(int)";
 }
 
+def FeSetExceptFlag : LibBuiltin<"fenv.h"> {
+  let Spellings = ["fesetexceptflag"];
+  let Prototype = "int(fexcept_t const*, int)";
+}
+
 def FeTestExcept : LibBuiltin<"fenv.h"> {
   let Spellings = ["fetestexcept"];
   let Prototype = "int(int)";
@@ -4434,6 +4444,26 @@ def FeSetRound : LibBuiltin<"fenv.h"> {
   let Prototype = "int(int)";
 }
 
+def FeGetEnv : LibBuiltin<"fenv.h"> {
+  let Spellings = ["fegetenv"];
+  let Prototype = "int(fenv_t*)";
+}
+
+def FeHoldExcept : LibBuiltin<"fenv.h"> {
+  let Spellings = ["feholdexcept"];
+  let Prototype = "int(fenv_t*)";
+}
+
+def FeSetEnv : LibBuiltin<"fenv.h"> {
+  let Spellings = ["fesetenv"];
+  let Prototype = "int(fenv_t const*)";
+}
+
+def FeUpdateEnv : LibBuiltin<"fenv.h"> {
+  let Spellings = ["feupdateenv"];
+  let Prototype = "int(fenv_t const*)";
+}
+
 def __Addressof : LangBuiltin<"CXX_LANG"> {
   let Spellings = ["__addressof"];
   let Attributes = [FunctionWithoutBuiltinPrefix, NoThrow, Const,
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 7f80880d83273..3796e42d542b1 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3845,10 +3845,16 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
     break;
 
   case Builtin::BIfeclearexcept:
+  case Builtin::BIfegetexceptflag:
   case Builtin::BIferaiseexcept:
+  case Builtin::BIfesetexceptflag:
   case Builtin::BIfetestexcept:
   case Builtin::BIfegetround:
   case Builtin::BIfesetround:
+  case Builtin::BIfegetenv:
+  case Builtin::BIfeholdexcept:
+  case Builtin::BIfesetenv:
+  case Builtin::BIfeupdateenv:
     if (TheCall->getFPFeaturesInEffect(getLangOpts()).getExceptionMode() ==
         LangOptions::FPE_Ignore) {
       Diag(TheCall->getBeginLoc(), diag::warn_fe_access_without_fenv_access)

>From 16496438408517fce0657142c26e00838cf166aa Mon Sep 17 00:00:00 2001
From: Marcos Ramirez Joos <[email protected]>
Date: Sun, 29 Mar 2026 15:29:25 +0200
Subject: [PATCH 5/5] Added additional regression tests for fenv access warning

---
 clang/test/Sema/fenv-access.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/clang/test/Sema/fenv-access.c b/clang/test/Sema/fenv-access.c
index 57d4debfa9c73..3a7b95af7ab4c 100644
--- a/clang/test/Sema/fenv-access.c
+++ b/clang/test/Sema/fenv-access.c
@@ -2,36 +2,67 @@
 // RUN: %clang_cc1 -verify -Wfenv-access -ffp-exception-behavior=maytrap 
-DNO_WARN %s
 // RUN: %clang_cc1 -verify -Wfenv-access -ffp-exception-behavior=strict 
-DNO_WARN %s
 
+typedef struct {} fenv_t;
+typedef unsigned short int fexcept_t;
+
 int feclearexcept(int excepts);
+int fegetexceptflag(fexcept_t *flagp, int excepts);
 int feraiseexcept(int excepts);
+int fesetexceptflag(const fexcept_t *flagp, int excepts);
 int fetestexcept(int excepts);
 int fegetround(void);
 int fesetround(int rounding_mode);
+int fegetenv(fenv_t *envp);
+int feholdexcept(fenv_t *envp);
+int fesetenv(const fenv_t *envp);
+int feupdateenv(const fenv_t *envp);
 
 #define FE_INVALID 1
 
+fexcept_t *flagp = 0;
+fenv_t *envp = 0;
+
 void test_fenv_access_off(void) {
 #ifdef NO_WARN
   // expected-no-diagnostics
   feclearexcept(FE_INVALID);
+  fegetexceptflag(flagp, FE_INVALID);
   feraiseexcept(FE_INVALID);
+  fesetexceptflag(flagp, FE_INVALID);
   fetestexcept(FE_INVALID);
   fegetround();
   fesetround(0);
+  fegetenv(envp);
+  feholdexcept(envp);
+  fesetenv(envp);
+  feupdateenv(envp);
 #else 
   feclearexcept(FE_INVALID); // expected-warning {{'feclearexcept' used 
without enabling floating-point exception behavior; use 'pragma STDC 
FENV_ACCESS ON' or compile with '-ffp-exception-behavior=maytrap'}}
+  fegetexceptflag(flagp, FE_INVALID); // expected-warning {{'fegetexceptflag' 
used without enabling floating-point exception behavior; use 'pragma STDC 
FENV_ACCESS ON' or compile with '-ffp-exception-behavior=maytrap'}}
   feraiseexcept(FE_INVALID); // expected-warning {{'feraiseexcept' used 
without enabling floating-point exception behavior; use 'pragma STDC 
FENV_ACCESS ON' or compile with '-ffp-exception-behavior=maytrap'}}
+  fesetexceptflag(flagp, FE_INVALID); // expected-warning {{'fesetexceptflag' 
used without enabling floating-point exception behavior; use 'pragma STDC 
FENV_ACCESS ON' or compile with '-ffp-exception-behavior=maytrap'}}
   fetestexcept(FE_INVALID); // expected-warning {{'fetestexcept' used without 
enabling floating-point exception behavior; use 'pragma STDC FENV_ACCESS ON' or 
compile with '-ffp-exception-behavior=maytrap'}}
   fegetround(); // expected-warning {{'fegetround' used without enabling 
floating-point exception behavior; use 'pragma STDC FENV_ACCESS ON' or compile 
with '-ffp-exception-behavior=maytrap'}}
   fesetround(0); // expected-warning {{'fesetround' used without enabling 
floating-point exception behavior; use 'pragma STDC FENV_ACCESS ON' or compile 
with '-ffp-exception-behavior=maytrap'}}
+  fegetenv(envp); // expected-warning {{'fegetenv' used without enabling 
floating-point exception behavior; use 'pragma STDC FENV_ACCESS ON' or compile 
with '-ffp-exception-behavior=maytrap'}}
+  feholdexcept(envp); // expected-warning {{'feholdexcept' used without 
enabling floating-point exception behavior; use 'pragma STDC FENV_ACCESS ON' or 
compile with '-ffp-exception-behavior=maytrap'}}
+  fesetenv(envp); // expected-warning {{'fesetenv' used without enabling 
floating-point exception behavior; use 'pragma STDC FENV_ACCESS ON' or compile 
with '-ffp-exception-behavior=maytrap'}}
+  feupdateenv(envp); // expected-warning {{'feupdateenv' used without enabling 
floating-point exception behavior; use 'pragma STDC FENV_ACCESS ON' or compile 
with '-ffp-exception-behavior=maytrap'}}
 #endif
 }
 
 void test_fenv_access_on(void) {
   #pragma STDC FENV_ACCESS ON
+  fesetround(0);
   feclearexcept(FE_INVALID);
+  fegetexceptflag(flagp, FE_INVALID);
   feraiseexcept(FE_INVALID);
+  fesetexceptflag(flagp, FE_INVALID);
   fetestexcept(FE_INVALID);
   fegetround();
   fesetround(0);
+  fegetenv(envp);
+  feholdexcept(envp);
+  fesetenv(envp);
+  feupdateenv(envp);
 }

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to