diff mbox

[committed] PR fortran/68108 -- Check for valid array ref.

Message ID 20151027164738.GA16960@troutmask.apl.washington.edu
State New
Headers show

Commit Message

Steve Kargl Oct. 27, 2015, 4:47 p.m. UTC
I've committed the attached patch after testing on
x86_64-*-freebsd.  A regression was introduced by 
my fix for PR fortran/67805, which failed to check
for a valid array ref.  Note, Mikael approved the 
patch in the PR audit trail.

2015-10-27  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68108
	* decl.c (char_len_param_value): Check for REF_ARRAY.
 
2015-10-27  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68108
	* gfortran.dg/pr67805_2.f90: New test.
diff mbox

Patch

Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(revision 229445)
+++ gcc/fortran/decl.c	(working copy)
@@ -748,13 +748,15 @@  char_len_param_value (gfc_expr **expr, b
 
       /* This catches the invalid code "[character(m(2:3)) :: 'x', 'y']",
 	 which causes an ICE if gfc_reduce_init_expr() is called.  */
-      if (e->ref && e->ref->u.ar.type == AR_UNKNOWN
+      if (e->ref && e->ref->type == REF_ARRAY
+	  && e->ref->u.ar.type == AR_UNKNOWN
 	  && e->ref->u.ar.dimen_type[0] == DIMEN_RANGE)
 	goto syntax;
 
       gfc_reduce_init_expr (e);
 
-      if ((e->ref && e->ref->u.ar.type != AR_ELEMENT) 
+      if ((e->ref && e->ref->type == REF_ARRAY
+	   && e->ref->u.ar.type != AR_ELEMENT) 
 	  || (!e->ref && e->expr_type == EXPR_ARRAY))
 	{
 	  gfc_free_expr (e);
Index: gcc/testsuite/gfortran.dg/pr67805_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr67805_2.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/pr67805_2.f90	(working copy)
@@ -0,0 +1,22 @@ 
+! { dg-do compile }
+! PR fortran/68108
+! Code contributed by Juergen Reuter (juergen.reuter at desy dot de)
+! Test fix for regression caused by PR fortran/67805.
+module lexers
+  implicit none
+  type :: template_t
+     character(256) :: charset1
+     integer :: len1
+  end type template_t
+
+contains
+
+  subroutine match_quoted (tt, s, n)
+    type(template_t), intent(in) :: tt
+    character(*), intent(in) :: s
+    integer, intent(out) :: n
+    character(tt%len1) :: ch1
+    ch1 = tt%charset1
+  end subroutine match_quoted
+
+end module lexers