[Patch-fortran] PR91589 - [9/10 Regression] ICE in gfc_conv_component_ref, at fortran/trans-expr.c:2447

Message ID CAGkQGi+xg51nNo6msi4=zjZ_OxrpOZcd9ZCxX_ar6cKUcyPBdg@mail.gmail.com
State New
Headers show
Series
  • [Patch-fortran] PR91589 - [9/10 Regression] ICE in gfc_conv_component_ref, at fortran/trans-expr.c:2447
Related show

Commit Message

Paul Richard Thomas Sept. 1, 2019, 6 p.m.
This was caused by my inquiry ref patch.

I will commit to both branches tomorrow night unless there is an objection.

Bootstraps and regtests on FC29/x86_64.

Paul

2019-09-02  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/91589
    * primary.c (gfc_match_varspec): Return MATCH_NO on an apparent
    component ref, when the primary type is not derived, class or
    unknown.

2019-09-02  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/91589
    * gfortran.dg/pr91589.f90 : New test.

Patch

Index: gcc/fortran/primary.c
===================================================================
*** gcc/fortran/primary.c	(revision 275268)
--- gcc/fortran/primary.c	(working copy)
*************** gfc_match_varspec (gfc_expr *primary, in
*** 2237,2242 ****
--- 2237,2244 ----
  	  inquiry = is_inquiry_ref (name, &tmp);
  	  if (inquiry)
  	    sym = NULL;
+ 	  else if (primary->ts.type != BT_UNKNOWN)
+ 	    return MATCH_NO;
  	}
        else
  	inquiry = false;
*************** gfc_variable_attr (gfc_expr *expr, gfc_t
*** 2598,2604 ****
  
  	  case AR_UNKNOWN:
  	    /* For standard conforming code, AR_UNKNOWN should not happen.
! 	       For nonconforming code, gfortran can end up here.  Treat it 
  	       as a no-op.  */
  	    break;
  	  }
--- 2600,2606 ----
  
  	  case AR_UNKNOWN:
  	    /* For standard conforming code, AR_UNKNOWN should not happen.
! 	       For nonconforming code, gfortran can end up here.  Treat it
  	       as a no-op.  */
  	    break;
  	  }
Index: gcc/testsuite/gfortran.dg/pr91589.f90
===================================================================
*** gcc/testsuite/gfortran.dg/pr91589.f90	(nonexistent)
--- gcc/testsuite/gfortran.dg/pr91589.f90	(working copy)
***************
*** 0 ****
--- 1,14 ----
+ ! { dg-do compile }
+ !
+ ! Check the fix for PR91589, in which the invalid expression caused an ICE.
+ !
+ ! Contributed by Gerhardt Steinmetz  <gscfq@t-online.de>
+ !
+ program p
+    type t
+       integer :: a
+    end type
+    type(t) :: x = t(1)
+    call sub (x%a%a)   ! { dg-error "Syntax error in argument list" }
+ end
+