aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2007-07-18 20:22:32 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2007-07-18 20:22:32 +0000
commitdadda6caba15b21a03e9522ca5cce41e2c2d270b (patch)
treecbf2a3e15dd08f11a41d46289515a304aec79ed0 /gcc
parent2a48b790b26895fd7fb56c9ce1d64f083dd278bb (diff)
downloadgcc-dadda6caba15b21a03e9522ca5cce41e2c2d270b.zip
gcc-dadda6caba15b21a03e9522ca5cce41e2c2d270b.tar.gz
gcc-dadda6caba15b21a03e9522ca5cce41e2c2d270b.tar.bz2
re PR target/32641 (C99 fpclassify, isinf, isfinite, isnormal may raise FP exceptions)
fixincludes: PR target/32641 * inclhack.def (solaris_math_4, solaris_math_5, solaris_math_6, solaris_math_7): Constify and make FP exception-safe. * tests/base/iso/math_c99.h: Update. * fixincl.x: Regenerate. gcc/testsuite: * gcc.dg/c99-math-double-1.c: Mark test variables as volatile. Test negative numbers also. * gcc.dg/c99-math-float-1.c: Likewise. * gcc.dg/c99-math-long-double-1.c: Likewise. * gcc.dg/c99-math.h: Check for FP exceptions. Update for negative test inputs. From-SVN: r126730
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/gcc.dg/c99-math-double-1.c17
-rw-r--r--gcc/testsuite/gcc.dg/c99-math-float-1.c17
-rw-r--r--gcc/testsuite/gcc.dg/c99-math-long-double-1.c17
-rw-r--r--gcc/testsuite/gcc.dg/c99-math.h138
5 files changed, 163 insertions, 35 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 72564be..1cac088 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2007-07-18 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * gcc.dg/c99-math-double-1.c: Mark test variables as volatile.
+ Test negative numbers also.
+ * gcc.dg/c99-math-float-1.c: Likewise.
+ * gcc.dg/c99-math-long-double-1.c: Likewise.
+ * gcc.dg/c99-math.h: Check for FP exceptions. Update for negative
+ test inputs.
+
2007-07-18 Bob Wilson <bob.wilson@acm.org>
* lib/target-supports.exp (check_effective_target_sync_int_long):
diff --git a/gcc/testsuite/gcc.dg/c99-math-double-1.c b/gcc/testsuite/gcc.dg/c99-math-double-1.c
index ef11d1b..6441a59 100644
--- a/gcc/testsuite/gcc.dg/c99-math-double-1.c
+++ b/gcc/testsuite/gcc.dg/c99-math-double-1.c
@@ -6,14 +6,17 @@
int main(void)
{
- double nan = NAN;
- double inf = INFINITY;
- double huge = HUGE_VAL;
- double norm = __DBL_MIN__;
- double sub = __DBL_MIN__ / 2;
- double zero = 0.0;
+ volatile double nan = NAN;
+ volatile double inf = INFINITY;
+ volatile double huge = HUGE_VAL;
+ volatile double norm1 = __DBL_MIN__;
+ volatile double norm2 = 1;
+ volatile double norm3 = __DBL_MAX__;
+ volatile double sub = __DBL_MIN__ / 2;
+ volatile double zero = 0.0;
- C99_MATH_TESTS (nan, inf, huge, norm, sub, zero)
+ C99_MATH_TESTS (nan, inf, huge, norm1, norm2, norm3, sub, zero, /*neg=*/0)
+ C99_MATH_TESTS (-nan, -inf, -huge, -norm1, -norm2, -norm3, -sub, -zero, /*neg=*/1)
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/c99-math-float-1.c b/gcc/testsuite/gcc.dg/c99-math-float-1.c
index f377c1a..36a7396 100644
--- a/gcc/testsuite/gcc.dg/c99-math-float-1.c
+++ b/gcc/testsuite/gcc.dg/c99-math-float-1.c
@@ -6,14 +6,17 @@
int main(void)
{
- float nan = NAN;
- float inf = INFINITY;
- float huge = HUGE_VALF;
- float norm = __FLT_MIN__;
- float sub = __FLT_MIN__ / 2;
- float zero = 0.0f;
+ volatile float nan = NAN;
+ volatile float inf = INFINITY;
+ volatile float huge = HUGE_VALF;
+ volatile float norm1 = __FLT_MIN__;
+ volatile float norm2 = 1;
+ volatile float norm3 = __FLT_MAX__;
+ volatile float sub = __FLT_MIN__ / 2;
+ volatile float zero = 0.0f;
- C99_MATH_TESTS (nan, inf, huge, norm, sub, zero)
+ C99_MATH_TESTS (nan, inf, huge, norm1, norm2, norm3, sub, zero, /*neg=*/0)
+ C99_MATH_TESTS (-nan, -inf, -huge, -norm1, -norm2, -norm3, -sub, -zero, /*neg=*/1)
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/c99-math-long-double-1.c b/gcc/testsuite/gcc.dg/c99-math-long-double-1.c
index 5f1cd30..d8146c2 100644
--- a/gcc/testsuite/gcc.dg/c99-math-long-double-1.c
+++ b/gcc/testsuite/gcc.dg/c99-math-long-double-1.c
@@ -6,14 +6,17 @@
int main(void)
{
- long double nan = NAN;
- long double inf = INFINITY;
- long double huge = HUGE_VALL;
- long double norm = __LDBL_MIN__;
- long double sub = __LDBL_MIN__ / 2;
- long double zero = 0.0l;
+ volatile long double nan = NAN;
+ volatile long double inf = INFINITY;
+ volatile long double huge = HUGE_VALL;
+ volatile long double norm1 = __LDBL_MIN__;
+ volatile long double norm2 = 1;
+ volatile long double norm3 = __LDBL_MAX__;
+ volatile long double sub = __LDBL_MIN__ / 2;
+ volatile long double zero = 0.0l;
- C99_MATH_TESTS (nan, inf, huge, norm, sub, zero)
+ C99_MATH_TESTS (nan, inf, huge, norm1, norm2, norm3, sub, zero, /*neg=*/0)
+ C99_MATH_TESTS (-nan, -inf, -huge, -norm1, -norm2, -norm3, -sub, -zero, /*neg=*/1)
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/c99-math.h b/gcc/testsuite/gcc.dg/c99-math.h
index aff81b3..81f2e6d 100644
--- a/gcc/testsuite/gcc.dg/c99-math.h
+++ b/gcc/testsuite/gcc.dg/c99-math.h
@@ -1,9 +1,14 @@
#include <math.h>
+#include <fenv.h>
extern void abort(void);
-#define C99_MATH_TESTS(nan, inf, huge, norm, sub, zero) \
+#define C99_MATH_TESTS(nan, inf, huge, norm1, norm2, norm3, sub, zero, neg) \
{ \
+ if (feclearexcept (FE_ALL_EXCEPT) != 0) \
+ abort(); \
+ \
+ \
if (fpclassify (nan) != FP_NAN) \
abort (); \
\
@@ -13,7 +18,13 @@ extern void abort(void);
if (fpclassify (huge) != FP_INFINITE) \
abort (); \
\
- if (fpclassify (norm) != FP_NORMAL) \
+ if (fpclassify (norm1) != FP_NORMAL) \
+ abort (); \
+ \
+ if (fpclassify (norm2) != FP_NORMAL) \
+ abort (); \
+ \
+ if (fpclassify (norm3) != FP_NORMAL) \
abort (); \
\
if (fpclassify (sub) != FP_SUBNORMAL) \
@@ -32,7 +43,13 @@ extern void abort(void);
if (isnan (huge)) \
abort (); \
\
- if (isnan (norm)) \
+ if (isnan (norm1)) \
+ abort (); \
+ \
+ if (isnan (norm2)) \
+ abort (); \
+ \
+ if (isnan (norm3)) \
abort (); \
\
if (isnan (sub)) \
@@ -51,7 +68,13 @@ extern void abort(void);
if (!isinf (huge)) \
abort (); \
\
- if (isinf (norm)) \
+ if (isinf (norm1)) \
+ abort (); \
+ \
+ if (isinf (norm2)) \
+ abort (); \
+ \
+ if (isinf (norm3)) \
abort (); \
\
if (isinf (sub)) \
@@ -70,7 +93,13 @@ extern void abort(void);
if (isfinite (huge)) \
abort (); \
\
- if (!isfinite (norm)) \
+ if (!isfinite (norm1)) \
+ abort (); \
+ \
+ if (!isfinite (norm2)) \
+ abort (); \
+ \
+ if (!isfinite (norm3)) \
abort (); \
\
if (!isfinite (sub)) \
@@ -89,7 +118,13 @@ extern void abort(void);
if (isnormal (huge)) \
abort (); \
\
- if (!isnormal (norm)) \
+ if (!isnormal (norm1)) \
+ abort (); \
+ \
+ if (!isnormal (norm2)) \
+ abort (); \
+ \
+ if (!isnormal (norm3)) \
abort (); \
\
if (isnormal (sub)) \
@@ -99,28 +134,103 @@ extern void abort(void);
abort (); \
\
\
- if (signbit (norm)) \
+ if (!!signbit (nan) != neg) \
abort (); \
\
- if (!signbit (-(norm))) \
+ if (!!signbit (inf) != neg) \
abort (); \
\
+ if (!!signbit (huge) != neg) \
+ abort (); \
\
- if (!isgreater ((inf), (norm))) \
+ if (!!signbit (norm1) != neg) \
abort (); \
\
- if (!isgreaterequal ((inf), (huge))) \
+ if (!!signbit (norm2) != neg) \
abort (); \
\
- if (!isless ((norm), (inf))) \
+ if (!!signbit (norm3) != neg) \
abort (); \
\
- if (!islessequal ((huge), (inf))) \
+ if (!!signbit (sub) != neg) \
abort (); \
\
- if (!islessgreater ((inf), (norm))) \
+ if (!!signbit (zero) != neg) \
abort (); \
\
- if (!isunordered ((nan), (norm))) \
+ \
+ if (neg) \
+ { \
+ if (!isless ((inf), (norm1))) \
+ abort (); \
+ \
+ if (!isless ((inf), (norm2))) \
+ abort (); \
+ \
+ if (!isless ((inf), (norm3))) \
+ abort (); \
+ \
+ if (!islessequal ((inf), (huge))) \
+ abort (); \
+ \
+ if (!isgreater ((norm1), (inf))) \
+ abort (); \
+ \
+ if (!isgreater ((norm2), (inf))) \
+ abort (); \
+ \
+ if (!isgreater ((norm3), (inf))) \
+ abort (); \
+ \
+ if (!isgreaterequal ((huge), (inf))) \
+ abort (); \
+ } \
+ else \
+ { \
+ if (!isgreater ((inf), (norm1))) \
+ abort (); \
+ \
+ if (!isgreater ((inf), (norm2))) \
+ abort (); \
+ \
+ if (!isgreater ((inf), (norm3))) \
+ abort (); \
+ \
+ if (!isgreaterequal ((inf), (huge))) \
+ abort (); \
+ \
+ if (!isless ((norm1), (inf))) \
+ abort (); \
+ \
+ if (!isless ((norm2), (inf))) \
+ abort (); \
+ \
+ if (!isless ((norm3), (inf))) \
+ abort (); \
+ \
+ if (!islessequal ((huge), (inf))) \
+ abort (); \
+ } \
+ \
+ if (!islessgreater ((inf), (norm1))) \
abort (); \
+ \
+ if (!islessgreater ((inf), (norm2))) \
+ abort (); \
+ \
+ if (!islessgreater ((inf), (norm3))) \
+ abort (); \
+ \
+ if (!isunordered ((nan), (norm1))) \
+ abort (); \
+ \
+ if (!isunordered ((nan), (norm2))) \
+ abort (); \
+ \
+ if (!isunordered ((nan), (norm3))) \
+ abort (); \
+ \
+ \
+ if (fetestexcept (FE_ALL_EXCEPT) != 0) \
+ abort(); \
}