aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trigd_fe.inc
diff options
context:
space:
mode:
authorFritz Reese <foreese@gcc.gnu.org>2020-04-22 11:45:22 -0400
committerFritz Reese <foreese@gcc.gnu.org>2020-04-23 10:11:01 -0400
commite8eecc2a919033ad4224756a8759d8e94c0e4bc2 (patch)
tree6548c11c6df9c8fa08f6d2eb1311df9fbd30f648 /gcc/fortran/trigd_fe.inc
parent966de09be91c639d66d252c9ae6ab8da5ebfca18 (diff)
downloadgcc-e8eecc2a919033ad4224756a8759d8e94c0e4bc2.zip
gcc-e8eecc2a919033ad4224756a8759d8e94c0e4bc2.tar.gz
gcc-e8eecc2a919033ad4224756a8759d8e94c0e4bc2.tar.bz2
Protect the trigd functions in libgfortran from unavailable math functions.
libgfortran/ChangeLog: 2020-04-22 Fritz Reese <foreese@gcc.gnu.org> PR libfortran/94694 PR libfortran/94586 * intrinsics/trigd.c, intrinsics/trigd_lib.inc, intrinsics/trigd.inc: Guard against unavailable math functions. Use suffixes from kinds.h based on the REAL kind. gcc/fortran/ChangeLog: 2020-04-22 Fritz Reese <foreese@gcc.gnu.org> * trigd_fe.inc: Use mpfr to compute cosd(30) rather than a host- precision floating point literal based on an invalid macro.
Diffstat (limited to 'gcc/fortran/trigd_fe.inc')
-rw-r--r--gcc/fortran/trigd_fe.inc17
1 files changed, 10 insertions, 7 deletions
diff --git a/gcc/fortran/trigd_fe.inc b/gcc/fortran/trigd_fe.inc
index 78ca441..f94c367 100644
--- a/gcc/fortran/trigd_fe.inc
+++ b/gcc/fortran/trigd_fe.inc
@@ -29,17 +29,20 @@ along with GCC; see the file COPYING3. If not see
#define ISFINITE(x) mpfr_number_p(x)
#define D2R(x) deg2rad(x)
+#define ENABLE_SIND
+#define ENABLE_COSD
+#define ENABLE_TAND
+
#define SIND simplify_sind
#define COSD simplify_cosd
#define TAND simplify_tand
-#ifdef HAVE_GFC_REAL_16
-#define COSD30 8.66025403784438646763723170752936183e-01Q
-#else
-#define COSD30 8.66025403784438646763723170752936183e-01L
-#endif
-
-#define SET_COSD30(x) mpfr_set_ld((x), COSD30, GFC_RND_MODE)
+/* cosd(30) === sqrt(3) / 2. */
+#define SET_COSD30(x) do { \
+ mpfr_set_ui (x, 3, GFC_RND_MODE); \
+ mpfr_sqrt (x, x, GFC_RND_MODE); \
+ mpfr_div_ui (x, x, 2, GFC_RND_MODE); \
+ } while (0)
static RETTYPE SIND (FTYPE);
static RETTYPE COSD (FTYPE);