[Patch, fortran] PR32156 - [4.3 Regression] ICE with characters

Paul Richard Thomas paul.richard.thomas@gmail.com
Fri Jun 8 08:33:00 GMT 2007


Andrew,

> The other thing (if you have some [quick] time) is add the testcases
> so we don't regress again in this area.

I wholeheartedly agree - it's an obvious gap in our testsuite armoury.

In fact, the problem is entirely with REAL, in the three PRs - I was
mistaken about CMPLX.  I think that CHAR is wrong too.

The attached fixes the prs but has not been regtested.  Like FX, I
have no time right now to do any more than this.

Lee, I thank that you have to sit with the standard and check off the
argument counts, one by one.  gfc_conv_intrinsic_conversion is nasty
because the optional  (KIND) argument is incorporated in resolution
and ignored in conversion.  Thus, fixing the number of args at one
caused the regression.  Doubtless there are other intrinsics that are
like this:)

Cheers

Paul
-------------- next part --------------
Index: gcc/fortran/trans-intrinsic.c
===================================================================
*** gcc/fortran/trans-intrinsic.c	(r?vision 125560)
--- gcc/fortran/trans-intrinsic.c	(copie de travail)
*************** static void
*** 250,274 ****
  gfc_conv_intrinsic_conversion (gfc_se * se, gfc_expr * expr)
  {
    tree type;
!   tree arg;
  
    /* Evaluate the argument.  */
    type = gfc_typenode_for_spec (&expr->ts);
    gcc_assert (expr->value.function.actual->expr);
!   gfc_conv_intrinsic_function_args (se, expr, &arg, 1);
  
    /* Conversion from complex to non-complex involves taking the real
       component of the value.  */
!   if (TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE
        && expr->ts.type != BT_COMPLEX)
      {
        tree artype;
  
!       artype = TREE_TYPE (TREE_TYPE (arg));
!       arg = build1 (REALPART_EXPR, artype, arg);
      }
  
!   se->expr = convert (type, arg);
  }
  
  /* This is needed because the gcc backend only implements
--- 250,276 ----
  gfc_conv_intrinsic_conversion (gfc_se * se, gfc_expr * expr)
  {
    tree type;
!   tree arg[2];
!   int num_args;
  
    /* Evaluate the argument.  */
    type = gfc_typenode_for_spec (&expr->ts);
    gcc_assert (expr->value.function.actual->expr);
!   num_args = expr->value.function.actual->next ? 2 : 1;
!   gfc_conv_intrinsic_function_args (se, expr, arg, num_args);
  
    /* Conversion from complex to non-complex involves taking the real
       component of the value.  */
!   if (TREE_CODE (TREE_TYPE (arg[0])) == COMPLEX_TYPE
        && expr->ts.type != BT_COMPLEX)
      {
        tree artype;
  
!       artype = TREE_TYPE (TREE_TYPE (arg[0]));
!       arg[0] = build1 (REALPART_EXPR, artype, arg[0]);
      }
  
!   se->expr = convert (type, arg[0]);
  }
  
  /* This is needed because the gcc backend only implements


More information about the Gcc-patches mailing list