diff mbox

[Fortran] PR50815 - don't -fcheck=bounds of deferred-length strings

Message ID 4ED525E7.8030001@net-b.de
State New
Headers show

Commit Message

Tobias Burnus Nov. 29, 2011, 6:35 p.m. UTC
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

Comments

Tobias Burnus Dec. 7, 2011, 1:53 p.m. UTC | #1
** PING **

On 11/29/2011 07:35 PM, Tobias Burnus wrote:
> 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
Mikael Morin Dec. 7, 2011, 8:36 p.m. UTC | #2
On Wednesday 07 December 2011 14:53:20 Tobias Burnus wrote:
> ** PING **
> 
> On 11/29/2011 07:35 PM, Tobias Burnus wrote:
> > 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?
> > 
OK, though I would have merged the skip for deferred lengths into the toplevel 
if condition (either is fine anyway).

Mikael
diff mbox

Patch

2011-11-29  Tobias Burnus  <burnus@net-b.de>

	PR fortran/50815
	* trans-decl.c (add_argument_checking): Skip bound checking
	for deferred-length strings.

2011-11-29  Tobias Burnus  <burnus@net-b.de>

	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