https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96325
Paul Thomas <pault at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pault at gcc dot gnu.org --- Comment #12 from Paul Thomas <pault at gcc dot gnu.org> --- (In reply to kargl from comment #10) > (In reply to jvdelisle from comment #9) > > I regression tested the patch in comment 8 and see these failures. > > > > FAIL: gfortran.dg/pr93423.f90 -O (test for excess errors) > > FAIL: gfortran.dg/typebound_call_31.f90 -O (test for errors, line 14) > > FAIL: gfortran.dg/typebound_call_31.f90 -O (test for excess errors) > > Thanks for testing. Does the patch that follows fix the regressions? > gfortran treats components and type bound procedures separately. I've > (hopefully) adapted the patch to whether foo is either. > > Index: gcc/fortran/primary.c > =================================================================== > --- gcc/fortran/primary.c (revision 280157) > +++ gcc/fortran/primary.c (working copy) > @@ -2240,6 +2240,18 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, > inquiry = is_inquiry_ref (name, &tmp); > if (inquiry) > sym = NULL; > + else > + { > + component = gfc_find_component (sym, name, false, false, &tmp); > + tbp = gfc_find_typebound_proc (sym, &t, name, false, > &gfc_current_locus); > + if (!component && !tbp) > + { > + gfc_error ("%qs at %C is neither a component nor a type " > + "bound procedure of the derived " > + "type %qs", name, sym->name); > + return MATCH_ERROR; > + } > + } > > if (sep == '%' && primary->ts.type != BT_UNKNOWN) > intrinsic = true; Hi Steve, Given your comment 6, I set too first thing this morning and located the bug by searching the ChangeLogs for candidates. That I was the culprit is galling to say the least of it. My version of the fix is: index d73898473df..6f032fbabfd 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -2327,10 +2327,12 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag, else component = NULL; - /* In some cases, returning MATCH_NO gives a better error message. Most - cases return "Unclassifiable statement at..." */ if (intrinsic && !inquiry) - return MATCH_NO; + { + gfc_error ("%qs at %C is not an inquiry reference to an " + "intrinsic type", name); + return MATCH_ERROR; + } else if (component == NULL && !inquiry) return MATCH_ERROR; Just a couple of nits concerning your patch: The false typebound call appears after the 'r1' components ref, which is not a derived type or class type. That is why the test for an inquiry reference is appropriate and is tested for in this block. Your error message comes up with t2 as being the type. I suggest: > + gfc_error ("%qs at %C is not an inquiry reference to an " > + "intrinsic type", name); or some such. Also, you have to get rid of the comment and the dead code that was modified in my patch. Thanks for the patch. OK for trunk when the error message is corrected and the comment plus dead code removed. Cheers Paul