From patchwork Tue Nov 29 18:35:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Fortran] PR50815 - don't -fcheck=bounds of deferred-length strings Date: Tue, 29 Nov 2011 08:35:19 -0000 From: Tobias Burnus X-Patchwork-Id: 128313 Message-Id: <4ED525E7.8030001@net-b.de> To: gcc patches , gfortran gfortran had an ICE when trying to insert a check whether the character length between actual and dummy argument matches. This check is pointless for deferred-length character arguments - thus, no bounds check should be generated. Build and regtested on x86-64-linux. OK for the trunk? Tobias 2011-11-29 Tobias Burnus PR fortran/50815 * trans-decl.c (add_argument_checking): Skip bound checking for deferred-length strings. 2011-11-29 Tobias Burnus PR fortran/50815 * gfortran.dg/bounds_check_16.f90: New. diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 67bd3e2..1be079b 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -4695,8 +4717,10 @@ add_argument_checking (stmtblock_t *block, gfc_symbol *sym) if the actual argument is (part of) an array, but only if the dummy argument is an array. (See "Sequence association" in Section 12.4.1.4 for F95 and 12.4.1.5 for F2003.) */ - if (fsym->attr.pointer || fsym->attr.allocatable - || (fsym->as && fsym->as->type == AS_ASSUMED_SHAPE)) + if (fsym->ts.deferred) + continue; + else if (fsym->attr.pointer || fsym->attr.allocatable + || (fsym->as && fsym->as->type == AS_ASSUMED_SHAPE)) { comparison = NE_EXPR; message = _("Actual string length does not match the declared one" --- /dev/null 2011-11-29 07:50:43.475522632 +0100 +++ gcc/gcc/testsuite/gfortran.dg/bounds_check_16.f90 2011-11-29 17:04:37.000000000 +0100 @@ -0,0 +1,14 @@ +! { dg-do compile } +! { dg-options "-fcheck=bounds" } +! +! PR fortran/50815 +! +! Don't check the bounds of deferred-length strings. +! gfortran had an ICE before because it did. +! +SUBROUTINE TEST(VALUE) + IMPLICIT NONE + CHARACTER(LEN=:), ALLOCATABLE :: VALUE + CHARACTER(LEN=128) :: VAL + VALUE = VAL +END SUBROUTINE TEST