https://gcc.gnu.org/g:37a4800939bd90400e03a8fa561d2a0df394bced

commit r15-1033-g37a4800939bd90400e03a8fa561d2a0df394bced
Author: Kewen Lin <li...@linux.ibm.com>
Date:   Wed Jun 5 04:22:25 2024 -0500

    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.

Diff:
---
 gcc/fortran/trans-intrinsic.cc |  3 ++-
 gcc/fortran/trans-types.cc     | 10 ++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index 912c1000e18..96839705112 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 8466c595e06..0ef67723fcd 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;

Reply via email to