Commit f79be3a7 by Paul Thomas

re PR fortran/91589 (ICE in gfc_conv_component_ref, at fortran/trans-expr.c:2447)

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 intrinsic.

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

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

From-SVN: r275324
parent be0fb548
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 intrinsic.
2019-09-02 Steven G. Kargl <kargl@gc.gnu.org> 2019-09-02 Steven G. Kargl <kargl@gc.gnu.org>
PR fortran/91552 PR fortran/91552
......
...@@ -2028,6 +2028,7 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag, ...@@ -2028,6 +2028,7 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag,
match m; match m;
bool unknown; bool unknown;
bool inquiry; bool inquiry;
bool intrinsic;
locus old_loc; locus old_loc;
char sep; char sep;
...@@ -2232,11 +2233,15 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag, ...@@ -2232,11 +2233,15 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag,
if (m != MATCH_YES) if (m != MATCH_YES)
return MATCH_ERROR; return MATCH_ERROR;
intrinsic = false;
if (primary->ts.type != BT_CLASS && primary->ts.type != BT_DERIVED) if (primary->ts.type != BT_CLASS && primary->ts.type != BT_DERIVED)
{ {
inquiry = is_inquiry_ref (name, &tmp); inquiry = is_inquiry_ref (name, &tmp);
if (inquiry) if (inquiry)
sym = NULL; sym = NULL;
if (sep == '%' && primary->ts.type != BT_UNKNOWN)
intrinsic = true;
} }
else else
inquiry = false; inquiry = false;
...@@ -2296,12 +2301,16 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag, ...@@ -2296,12 +2301,16 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag,
break; break;
} }
if (!inquiry) if (!inquiry && !intrinsic)
component = gfc_find_component (sym, name, false, false, &tmp); component = gfc_find_component (sym, name, false, false, &tmp);
else else
component = NULL; component = NULL;
if (component == NULL && !inquiry) /* In some cases, returning MATCH_NO gives a better error message. Most
cases return "Unclassifiable statement at..." */
if (intrinsic && !inquiry)
return MATCH_NO;
else if (component == NULL && !inquiry)
return MATCH_ERROR; return MATCH_ERROR;
/* Extend the reference chain determined by gfc_find_component or /* Extend the reference chain determined by gfc_find_component or
...@@ -2598,7 +2607,7 @@ gfc_variable_attr (gfc_expr *expr, gfc_typespec *ts) ...@@ -2598,7 +2607,7 @@ gfc_variable_attr (gfc_expr *expr, gfc_typespec *ts)
case AR_UNKNOWN: case AR_UNKNOWN:
/* For standard conforming code, AR_UNKNOWN should not happen. /* For standard conforming code, AR_UNKNOWN should not happen.
For nonconforming code, gfortran can end up here. Treat it For nonconforming code, gfortran can end up here. Treat it
as a no-op. */ as a no-op. */
break; break;
} }
......
2019-09-02 Paul Thomas <pault@gcc.gnu.org>
PR fortran/91589
* gfortran.dg/pr91589.f90 : New test.
2019-09-02 Steven G. Kargl <kargl@gc.gnu.org> 2019-09-02 Steven G. Kargl <kargl@gc.gnu.org>
PR fortran/91552 PR fortran/91552
......
! { dg-do compile }
!
! Check the fix for PR91589, in which the invalid expression caused an ICE.
! Other statements using this invalid expression cause "Unclassifiable statement at..."
!
! 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment