[libc-commits] [libc] ff38470 - [libc][NFC] Adjust enabled_exceptions_test wrt FE_INEXACT.

Siva Chandra Reddy via libc-commits libc-commits at lists.llvm.org
Tue Jul 20 22:51:40 PDT 2021


Author: Siva Chandra Reddy
Date: 2021-07-21T05:49:19Z
New Revision: ff384700f25d8637c044325c2c086382b4234646

URL: https://github.com/llvm/llvm-project/commit/ff384700f25d8637c044325c2c086382b4234646
DIFF: https://github.com/llvm/llvm-project/commit/ff384700f25d8637c044325c2c086382b4234646.diff

LOG: [libc][NFC] Adjust enabled_exceptions_test wrt FE_INEXACT.

Since exceptions like FE_DIVBYZERO can raise FE_INEXACT, we need to
ensure that we don't raise FE_DIVBYZERO (or others which can also raise
FE_INEXACT) when FE_INEXACT is enabled.

Added: 
    

Modified: 
    libc/test/src/fenv/enabled_exceptions_test.cpp

Removed: 
    


################################################################################
diff  --git a/libc/test/src/fenv/enabled_exceptions_test.cpp b/libc/test/src/fenv/enabled_exceptions_test.cpp
index a403f247d5709..980c2c0dffdd1 100644
--- a/libc/test/src/fenv/enabled_exceptions_test.cpp
+++ b/libc/test/src/fenv/enabled_exceptions_test.cpp
@@ -40,10 +40,14 @@ TEST(LlvmLibcExceptionStatusTest, RaiseAndCrash) {
     ASSERT_EQ(__llvm_libc::feclearexcept(FE_ALL_EXCEPT), 0);
     // Raising all exceptions except |e| should not call the
     // SIGFPE handler. They should set the exception flag though,
-    // so we verify that.
-    int others = allExcepts & ~e;
-    ASSERT_EQ(__llvm_libc::feraiseexcept(others), 0);
-    ASSERT_EQ(__llvm_libc::fetestexcept(others), others);
+    // so we verify that. Since other exceptions like FE_DIVBYZERO
+    // can raise FE_INEXACT as well, we don't verify the other
+    // exception flags when FE_INEXACT is enabled.
+    if (e != FE_INEXACT) {
+      int others = allExcepts & ~e;
+      ASSERT_EQ(__llvm_libc::feraiseexcept(others), 0);
+      ASSERT_EQ(__llvm_libc::fetestexcept(others), others);
+    }
 
     ASSERT_RAISES_FP_EXCEPT([=] { __llvm_libc::feraiseexcept(e); });
   }


        


More information about the libc-commits mailing list