I patched this in on top of all the other patches.  It passes what Jim has
called the "Bob CI/CD pipeline".

Jim is finalizing his changes.

> -----Original Message-----
> From: Richard Biener <rguent...@suse.de>
> Sent: Tuesday, March 25, 2025 05:51
> To: gcc-patches@gcc.gnu.org
> Cc: rdub...@symas.com; Jakub Jelinek <ja...@redhat.com>
> Subject: [PATCH][COBOL][RFC] Remove strtof128 based diagnostics
> 
> The following removes uses of strtof128 which are all in some way
> verifying something parses as _Float128 but which lexing should
> have guarnateed.
> 
> Tested on x86_64-unknown-linux-gnu.
> 
> Richard.
> 
> gcc/cobol/
>       * parse.y (intrinsic): Remove checking that
$r1->field->data.initial
>       parses as _Float128.
>       (numstr2i): Remove checking that all of the string is consumed
>       by the converted from number.
>       * symbols.h (strtof128): Remove.
>       (cbl_field_data_t::valify): Remove checking that all of the
>       string is consumed by the number conversion.
> ---
>  gcc/cobol/parse.y   | 21 +++++----------------
>  gcc/cobol/symbols.h | 20 --------------------
>  2 files changed, 5 insertions(+), 36 deletions(-)
> 
> diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y
> index 390e115f37e..5fa472a3645 100644
> --- a/gcc/cobol/parse.y
> +++ b/gcc/cobol/parse.y
> @@ -10326,16 +10326,7 @@ intrinsic:      function_udf
>                    }
>                    if( $1 == NUMVAL_F ) {
>                      if( is_literal($r1->field) ) {
> -                      _Float128 output __attribute__ ((__unused__));
> -                      auto input = $r1->field->data.initial;
> -                      auto local = xstrdup(input), pend = local;
> -                      std::replace(local, local + strlen(local), ',',
> '.');
> -                      std::remove_if(local, local + strlen(local),
> isspace);
> -                      output = strtof128(local, &pend);
> -                      // bad if strtof128 could not convert input
> -                      if( *pend != '\0' ) {
> -                        error_msg(@r1, "'%s' is not a numeric string",
> input);
> -                      }
> +                   // we assume $r1->field->data.initial parses as
float
>                      }
>                    }
>                    if( ! intrinsic_call_1($$, $1, $r1, @r1)) YYERROR;
> @@ -12065,20 +12056,18 @@ static REAL_VALUE_TYPE
>  numstr2i( const char input[], radix_t radix ) {
>    REAL_VALUE_TYPE output;
>    size_t integer = 0;
> -  int erc=0, n=0;
> +  int erc=0;
> 
>    switch( radix ) {
>    case decimal_e: { // Use decimal point for comma, just in case.
> -      auto local = xstrdup(input), pend = local;
> +      auto local = xstrdup(input);
>        if( !local ) { erc = -1; break; }
>        std::replace(local, local + strlen(local), ',', '.');
>        real_from_string3 (&output, local, TYPE_MODE
(float128_type_node));
> -      strtof128(local, &pend);
> -      n = pend - local;
>      }
>      break;
>    case hexadecimal_e:
> -    erc = sscanf(input, "%zx%n", &integer, &n);
> +    erc = sscanf(input, "%zx", &integer);
>      real_from_integer (&output, VOIDmode, integer, UNSIGNED);
>      break;
>    case boolean_e:
> @@ -12101,7 +12090,7 @@ numstr2i( const char input[], radix_t radix ) {
>      real_from_integer (&output, VOIDmode, integer, UNSIGNED);
>      return output;
>    }
> -  if( erc == -1 || n < int(strlen(input)) ) {
> +  if( erc == -1 ) {
>      yywarn("'%s' was accepted as %lld", input, output);
>    }
>    return output;
> diff --git a/gcc/cobol/symbols.h b/gcc/cobol/symbols.h
> index 72bb188ec5b..35e4d816233 100644
> --- a/gcc/cobol/symbols.h
> +++ b/gcc/cobol/symbols.h
> @@ -48,17 +48,6 @@
> 
>  #define PICTURE_MAX 64
> 
> -#if ! (__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT))
> -static_assert( sizeof(output) == sizeof(long double), "long doubles?"
);
> -
> -// ???  This is still used for verificataion that __nptr parses as
> -// float number via setting *__endptr.
> -static inline _Float128
> -strtof128 (const char *__restrict __nptr, char **__restrict __endptr) {
> -  return strtold(nptr, endptr);
> -}
> -#endif
> -
>  extern const char *numed_message;
> 
>  enum cbl_dialect_t {
> @@ -352,15 +341,6 @@ struct cbl_field_data_t {
>        std::replace(input.begin(), input.end(), ',', '.');
>      }
> 
> -    char *pend = NULL;
> -
> -    strtof128(input.c_str(), &pend);
> -
> -    if( pend != input.c_str() + len ) {
> -      dbgmsg("%s: error: could not interpret '%s' of '%s' as a number",
> -             __func__, pend, initial);
> -    }
> -
>      REAL_VALUE_TYPE r;
>      real_from_string (&r, input.c_str());
>      r = real_value_truncate (TYPE_MODE (float128_type_node), r);
> --
> 2.43.0

Reply via email to