This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/50252] [OOP] Error message on "call x%y" (x not declared) can be more informative
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 31 Aug 2011 19:31:10 +0000
- Subject: [Bug fortran/50252] [OOP] Error message on "call x%y" (x not declared) can be more informative
- Auto-submitted: auto-generated
- References: <bug-50252-4@http.gcc.gnu.org/bugzilla/>
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