aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorKewen Lin <linkw@linux.ibm.com>2024-06-05 04:22:25 -0500
committerKewen Lin <linkw@linux.ibm.com>2024-06-05 04:22:25 -0500
commit37a4800939bd90400e03a8fa561d2a0df394bced (patch)
tree8ef1d5e1c2f1b0ebd5c3a5dbd1cb15190c4f745b /gcc/fortran
parentb36461f126148b027e7541aaf356d5322a0fbc08 (diff)
downloadgcc-37a4800939bd90400e03a8fa561d2a0df394bced.zip
gcc-37a4800939bd90400e03a8fa561d2a0df394bced.tar.gz
gcc-37a4800939bd90400e03a8fa561d2a0df394bced.tar.bz2
fortran: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
Joseph pointed out "floating types should have their mode, not a poorly defined precision value" in the discussion[1], as he and Richi suggested, the existing macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE will be replaced with a hook mode_for_floating_type. To be prepared for that, this patch is to replace use of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE in fortran with TYPE_PRECISION of {float,{,long_}double}_type_node. [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html gcc/fortran/ChangeLog: * trans-intrinsic.cc (build_round_expr): Use TYPE_PRECISION of long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE. * trans-types.cc (gfc_build_real_type): Use TYPE_PRECISION of {float,double,long_double}_type_node to replace {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/trans-intrinsic.cc3
-rw-r--r--gcc/fortran/trans-types.cc10
2 files changed, 8 insertions, 5 deletions
diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index 912c100..9683970 100644
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -395,7 +395,8 @@ build_round_expr (tree arg, tree restype)
don't have an appropriate function that converts directly to the integer
type (such as kind == 16), just use ROUND, and then convert the result to
an integer. We might also need to convert the result afterwards. */
- if (resprec <= INT_TYPE_SIZE && argprec <= LONG_DOUBLE_TYPE_SIZE)
+ if (resprec <= INT_TYPE_SIZE
+ && argprec <= TYPE_PRECISION (long_double_type_node))
fn = builtin_decl_for_precision (BUILT_IN_IROUND, argprec);
else if (resprec <= LONG_TYPE_SIZE)
fn = builtin_decl_for_precision (BUILT_IN_LROUND, argprec);
diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index 8466c59..0ef6772 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -873,13 +873,15 @@ gfc_build_real_type (gfc_real_info *info)
int mode_precision = info->mode_precision;
tree new_type;
- if (mode_precision == FLOAT_TYPE_SIZE)
+ if (mode_precision == TYPE_PRECISION (float_type_node))
info->c_float = 1;
- if (mode_precision == DOUBLE_TYPE_SIZE)
+ if (mode_precision == TYPE_PRECISION (double_type_node))
info->c_double = 1;
- if (mode_precision == LONG_DOUBLE_TYPE_SIZE && !info->c_float128)
+ if (mode_precision == TYPE_PRECISION (long_double_type_node)
+ && !info->c_float128)
info->c_long_double = 1;
- if (mode_precision != LONG_DOUBLE_TYPE_SIZE && mode_precision == 128)
+ if (mode_precision != TYPE_PRECISION (long_double_type_node)
+ && mode_precision == 128)
{
/* TODO: see PR101835. */
info->c_float128 = 1;