+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>
PR fortran/91552
match m;
bool unknown;
bool inquiry;
+ bool intrinsic;
locus old_loc;
char sep;
if (m != MATCH_YES)
return MATCH_ERROR;
+ intrinsic = false;
if (primary->ts.type != BT_CLASS && primary->ts.type != BT_DERIVED)
{
inquiry = is_inquiry_ref (name, &tmp);
if (inquiry)
sym = NULL;
+
+ if (sep == '%' && primary->ts.type != BT_UNKNOWN)
+ intrinsic = true;
}
else
inquiry = false;
break;
}
- if (!inquiry)
+ if (!inquiry && !intrinsic)
component = gfc_find_component (sym, name, false, false, &tmp);
else
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;
/* Extend the reference chain determined by gfc_find_component or
case AR_UNKNOWN:
/* 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. */
break;
}
--- /dev/null
+! { 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
+