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] | |
This is embarrassing - I forgot about derived type components *sigh*
Since the code->expr has been resolved, the expr character length is as available as it ever will be, if it is constant. Thus the patch uses that, rather than the symbol's.
I notice that substring references could be resolved but are not - see below.
I can do something about this at the weekend - if anybody wants to get this out of the door now, please do. Note that it is not regtested.
Paul
module linebufmod implicit none
type linebuf character(len=80), dimension(:), pointer :: data=>NULL() end type linebuf
type linebuf_short character(len=2), dimension(:), pointer :: data=>NULL() end type linebuf_short
contains
subroutine linebuf_add (buf, buf_short) type(linebuf), intent(inout) :: buf type(linebuf_short), intent(inout) :: buf_short character(4) :: chr
buf%data(1) = "blah" buf%data(1)(1:2) = "blah" ! misses this buf_short%data(1) = "blah" ! { dg-warning "will be truncated" } chr(1:2) = "blahblah" ! misses this too end subroutine linebuf_add
end module linebufmod
Index: gcc/fortran/resolve.c
===================================================================
*** gcc/fortran/resolve.c (revision 120520)
--- gcc/fortran/resolve.c (working copy)
*************** resolve_code (gfc_code * code, gfc_names
*** 5088,5097 ****
&& gfc_option.warn_character_truncation)
{
int llen = 0, rlen = 0;
! gfc_symbol *sym;
! sym = code->expr->symtree->n.sym;
! if (sym->ts.cl->length->expr_type == EXPR_CONSTANT)
! llen = mpz_get_si (sym->ts.cl->length->value.integer);
if (code->expr2->expr_type == EXPR_CONSTANT)
rlen = code->expr2->value.character.length;
--- 5088,5098 ----
&& gfc_option.warn_character_truncation)
{
int llen = 0, rlen = 0;
!
! if (code->expr->ts.cl != NULL
! && code->expr->ts.cl->length != NULL
! && code->expr->ts.cl->length->expr_type == EXPR_CONSTANT)
! llen = mpz_get_si (code->expr->ts.cl->length->value.integer);
if (code->expr2->expr_type == EXPR_CONSTANT)
rlen = code->expr2->value.character.length;
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |