This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR 13251


Hi,

This snippet currently fails to compile:

-------------------------
type :: tmp
  character(32) :: bar
end type

type (tmp) :: foo
character(3) :: t

foo%bar(1:10) = "abcdefghij"
t = foo%bar(3:5)
if (t /= "cde") call abort
end
-------------------------

I believe the problem was that we were trying to get the type kind of a 
substring of a character component of a derived type from the derived type 
itself.  This obviously makes no sense, since derived types in F95 do not 
have a kind (and in F2k its kind is not a scalar).

The attached patch should fix it.  We already propagate the kind to the 
outermost expression tree, so just take it from there instead of from a 
symbol.

The patch does not cause new failures:

                === gfortran Summary ===

# of expected passes            24

Still, I haven't touched gfortran in a while, so just to be sure: Paul, does 
this make sense?

Gr.
Steven

2003-12-05  Steven Bosscher  <stevenb@suse.de>

	PR fortran/13251
	* trans-expr.c (gfc_conv_variable): Take the type kind of a substring
	reference from the expression.

Index: trans-expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/Attic/trans-expr.c,v
retrieving revision 1.1.2.14
diff -c -3 -p -r1.1.2.14 trans-expr.c
*** trans-expr.c	5 Dec 2003 09:16:09 -0000	1.1.2.14
--- trans-expr.c	5 Dec 2003 11:56:46 -0000
*************** gfc_conv_variable (gfc_se * se, gfc_expr
*** 331,337 ****
  	  break;
  
  	case REF_SUBSTRING:
! 	  gfc_conv_substring (se, ref, sym->ts.kind);
  	  break;
  
  	default:
--- 331,337 ----
  	  break;
  
  	case REF_SUBSTRING:
! 	  gfc_conv_substring (se, ref, expr->ts.kind);
  	  break;
  
  	default:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]