http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50252
--- Comment #2 from janus at gcc dot gnu.org 2011-08-31 19:31:10 UTC --- Ok, here is one thing that could be easily done. Preliminary patch, not regtested. Does this sound like an improvement? Index: gcc/fortran/match.c =================================================================== --- gcc/fortran/match.c (revision 178293) +++ gcc/fortran/match.c (working copy) @@ -3639,15 +3639,24 @@ done: } -/* Match the call of a type-bound procedure, if CALL%var has already been - matched and var found to be a derived-type variable. */ +/* Match the call of a type-bound procedure, if 'CALL var' has already been + matched. */ static match match_typebound_call (gfc_symtree* varst) { gfc_expr* base; + gfc_symbol *sym; match m; + sym = varst->n.sym; + if (sym->ts.type != BT_DERIVED && sym->ts.type != BT_CLASS) + { + gfc_error ("Base object '%s' in type-bound procedure call at %C " + "is not of derived type", sym->name); + return MATCH_ERROR; + } + base = gfc_get_expr (); base->expr_type = EXPR_VARIABLE; base->symtree = varst; @@ -3718,7 +3727,7 @@ gfc_match_call (void) procedure call. */ if ((sym->attr.flavor != FL_PROCEDURE || gfc_is_function_return_value (sym, gfc_current_ns)) - && (sym->ts.type == BT_DERIVED || sym->ts.type == BT_CLASS)) + && gfc_peek_char() == '%') return match_typebound_call (st); /* If it does not seem to be callable (include functions so that the