public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/50252] New: Error message on "call x%y" (x not declared) can be more informative
@ 2011-08-31 14:37 arjen.markus895 at gmail dot com
2011-08-31 19:49 ` [Bug fortran/50252] [OOP] " janus at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: arjen.markus895 at gmail dot com @ 2011-08-31 14:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50252
Bug #: 50252
Summary: Error message on "call x%y" (x not declared) can be
more informative
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: arjen.markus895@gmail.com
If you forget to declare a variable with type-bound procedures, say x,
and call one of the intended procedures anyway, the message is simply
that there was a syntax error.
The program:
program test123
call bb%print
end program test123
results in the following error message:
xx.f90:3.11:
call x%print
1
Error: Syntax error in CALL statement at (1)
This message could be made clearer by pointing out that a variable
may not be declared - if the statement contains a %:
Error: Syntax error in CALL statement at (1). Possibly a variable has not been
declared.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/50252] [OOP] Error message on "call x%y" (x not declared) can be more informative
2011-08-31 14:37 [Bug fortran/50252] New: Error message on "call x%y" (x not declared) can be more informative arjen.markus895 at gmail dot com
@ 2011-08-31 19:49 ` janus at gcc dot gnu.org
2011-08-31 19:59 ` janus at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2011-08-31 19:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50252
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |janus at gcc dot gnu.org
Summary|Error message on "call x%y" |[OOP] Error message on
|(x not declared) can be |"call x%y" (x not declared)
|more informative |can be more informative
--- Comment #1 from janus at gcc dot gnu.org 2011-08-31 19:03:39 UTC ---
The parsing of call statements happens in gfc_match_call (match.c), so any
improvement of the error message will most likely have to happen there.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/50252] [OOP] Error message on "call x%y" (x not declared) can be more informative
2011-08-31 14:37 [Bug fortran/50252] New: Error message on "call x%y" (x not declared) can be more informative arjen.markus895 at gmail dot com
2011-08-31 19:49 ` [Bug fortran/50252] [OOP] " janus at gcc dot gnu.org
@ 2011-08-31 19:59 ` janus at gcc dot gnu.org
2011-09-01 7:18 ` arjen.markus895 at gmail dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2011-08-31 19:59 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/50252] [OOP] Error message on "call x%y" (x not declared) can be more informative
2011-08-31 14:37 [Bug fortran/50252] New: Error message on "call x%y" (x not declared) can be more informative arjen.markus895 at gmail dot com
2011-08-31 19:49 ` [Bug fortran/50252] [OOP] " janus at gcc dot gnu.org
2011-08-31 19:59 ` janus at gcc dot gnu.org
@ 2011-09-01 7:18 ` arjen.markus895 at gmail dot com
2011-09-01 11:28 ` janus at gcc dot gnu.org
2014-01-07 8:15 ` dominiq at lps dot ens.fr
4 siblings, 0 replies; 6+ messages in thread
From: arjen.markus895 at gmail dot com @ 2011-09-01 7:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50252
--- Comment #3 from Arjen Markus <arjen.markus895 at gmail dot com> 2011-09-01 07:18:30 UTC ---
Hi Janus,
that seems quite to the point and it is much more straightforward than
my (minimal)
adjustment. Thanks.
The reason I brought this is that is a fairly recent addition and I
got puzzled by the
complaint that it was a syntax error.
Regards,
Arjen
2011/8/31 janus at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>:
> 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
>
> --
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You reported the bug.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/50252] [OOP] Error message on "call x%y" (x not declared) can be more informative
2011-08-31 14:37 [Bug fortran/50252] New: Error message on "call x%y" (x not declared) can be more informative arjen.markus895 at gmail dot com
` (2 preceding siblings ...)
2011-09-01 7:18 ` arjen.markus895 at gmail dot com
@ 2011-09-01 11:28 ` janus at gcc dot gnu.org
2014-01-07 8:15 ` dominiq at lps dot ens.fr
4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2011-09-01 11:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50252
--- Comment #4 from janus at gcc dot gnu.org 2011-09-01 11:28:35 UTC ---
Unfortunately the patch in comment #2 did not survive the regression test. It
fails at least on:
FAIL: gfortran.dg/dynamic_dispatch_10.f03 -O0 (test for excess errors)
FAIL: gfortran.dg/coarray_14.f90 -O (test for errors, line 39)
FAIL: gfortran.dg/coarray_8.f90 -O (test for errors, line 36)
FAIL: gfortran.dg/proc_ptr_comp_pass_6.f90 -O (test for excess errors)
FAIL: gfortran.dg/typebound_call_12.f03 -O (test for excess errors)
FAIL: gfortran.dg/typebound_call_14.f03 -O (test for excess errors)
FAIL: gfortran.dg/typebound_call_4.f03 -O (test for errors, line 41)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/50252] [OOP] Error message on "call x%y" (x not declared) can be more informative
2011-08-31 14:37 [Bug fortran/50252] New: Error message on "call x%y" (x not declared) can be more informative arjen.markus895 at gmail dot com
` (3 preceding siblings ...)
2011-09-01 11:28 ` janus at gcc dot gnu.org
@ 2014-01-07 8:15 ` dominiq at lps dot ens.fr
4 siblings, 0 replies; 6+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-01-07 8:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50252
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-01-07
Ever confirmed|0 |1
--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Still present at r206382.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-01-07 8:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-31 14:37 [Bug fortran/50252] New: Error message on "call x%y" (x not declared) can be more informative arjen.markus895 at gmail dot com
2011-08-31 19:49 ` [Bug fortran/50252] [OOP] " janus at gcc dot gnu.org
2011-08-31 19:59 ` janus at gcc dot gnu.org
2011-09-01 7:18 ` arjen.markus895 at gmail dot com
2011-09-01 11:28 ` janus at gcc dot gnu.org
2014-01-07 8:15 ` dominiq at lps dot ens.fr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).