summaryrefslogtreecommitdiff
path: root/libc/test/src/fenv/enabled_exceptions_test.cpp
diff options
context:
space:
mode:
authorMichael Jones <michaelrj@google.com>2021-01-29 00:30:23 +0000
committerMichael Jones <michaelrj@google.com>2021-02-01 18:40:32 +0000
commitcb2e2d506814dc3c06449a87aec180b29f4351d7 (patch)
tree0da78a60b67b3e1c2258076f5466a4f119d8cf18 /libc/test/src/fenv/enabled_exceptions_test.cpp
parentc4d6f2707a1e6c4e9bd93480dd913121fef122b7 (diff)
[libc] Small adjustments to fenv tests
Some libcs define non-standard FE_* macros and include them in FE_ALL_EXCEPT. This change adjusts the fenv tests so that the non-standard FE_* macros do not interfere when compiled with fenv.h from another libc. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D95650
Diffstat (limited to 'libc/test/src/fenv/enabled_exceptions_test.cpp')
-rw-r--r--libc/test/src/fenv/enabled_exceptions_test.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/libc/test/src/fenv/enabled_exceptions_test.cpp b/libc/test/src/fenv/enabled_exceptions_test.cpp
index 81cd4947cc76..e9c2ae86b8c0 100644
--- a/libc/test/src/fenv/enabled_exceptions_test.cpp
+++ b/libc/test/src/fenv/enabled_exceptions_test.cpp
@@ -27,6 +27,12 @@ TEST(LlvmLibcExceptionStatusTest, RaiseAndCrash) {
int excepts[] = {FE_DIVBYZERO, FE_INVALID, FE_INEXACT, FE_OVERFLOW,
FE_UNDERFLOW};
+ // We '|' the individual exception flags instead of using FE_ALL_EXCEPT
+ // as it can include non-standard extensions. Note that we should be able
+ // to compile this file with headers from other libcs as well.
+ constexpr int allExcepts =
+ FE_DIVBYZERO | FE_INVALID | FE_INEXACT | FE_OVERFLOW | FE_UNDERFLOW;
+
for (int e : excepts) {
ASSERT_DEATH(
[=] {
@@ -36,7 +42,7 @@ TEST(LlvmLibcExceptionStatusTest, RaiseAndCrash) {
// Raising all exceptions except |e| should not call the
// SIGFPE handler. They should set the exception flag though,
// so we verify that.
- int others = FE_ALL_EXCEPT & ~e;
+ int others = allExcepts & ~e;
ASSERT_EQ(__llvm_libc::feraiseexcept(others), 0);
ASSERT_EQ(__llvm_libc::fetestexcept(others), others);