public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/56520] New: Syntax error causes misleading message: "Invalid character in name"
@ 2013-03-04 13:44 arjen.markus at deltares dot nl
  2014-01-07 10:10 ` [Bug fortran/56520] " dominiq at lps dot ens.fr
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: arjen.markus at deltares dot nl @ 2013-03-04 13:44 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56520

             Bug #: 56520
           Summary: Syntax error causes misleading message: "Invalid
                    character in name"
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: arjen.markus@deltares.nl


An extra parenthesis at the end of a statement leads to the error message:
   Invalid character in name at (1)

The message has nothing to do with the actual error.

Here is a small program to reproduce it:

! misleading.f90 --
!     Syntax error is reported with a misleading message
!
program misleading
    implicit none

    real :: a, b, c

    a = 1.0
    b = 1.0

    c = exp(-a*b) )
end program misleading


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/56520] Syntax error causes misleading message: "Invalid character in name"
  2013-03-04 13:44 [Bug fortran/56520] New: Syntax error causes misleading message: "Invalid character in name" arjen.markus at deltares dot nl
@ 2014-01-07 10:10 ` dominiq at lps dot ens.fr
  2015-07-01  9:56 ` dominiq at lps dot ens.fr
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-01-07 10:10 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56520

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 #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Still present at r206385.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/56520] Syntax error causes misleading message: "Invalid character in name"
  2013-03-04 13:44 [Bug fortran/56520] New: Syntax error causes misleading message: "Invalid character in name" arjen.markus at deltares dot nl
  2014-01-07 10:10 ` [Bug fortran/56520] " dominiq at lps dot ens.fr
@ 2015-07-01  9:56 ` dominiq at lps dot ens.fr
  2015-07-01 17:54 ` kargl at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-07-01  9:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56520

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |casey.webster at gmail dot com

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
*** Bug 66710 has been marked as a duplicate of this bug. ***


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/56520] Syntax error causes misleading message: "Invalid character in name"
  2013-03-04 13:44 [Bug fortran/56520] New: Syntax error causes misleading message: "Invalid character in name" arjen.markus at deltares dot nl
  2014-01-07 10:10 ` [Bug fortran/56520] " dominiq at lps dot ens.fr
  2015-07-01  9:56 ` dominiq at lps dot ens.fr
@ 2015-07-01 17:54 ` kargl at gcc dot gnu.org
  2015-07-01 17:55 ` kargl at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-01 17:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56520

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |kargl at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |kargl at gcc dot gnu.org
           Severity|normal                      |enhancement


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/56520] Syntax error causes misleading message: "Invalid character in name"
  2013-03-04 13:44 [Bug fortran/56520] New: Syntax error causes misleading message: "Invalid character in name" arjen.markus at deltares dot nl
                   ` (2 preceding siblings ...)
  2015-07-01 17:54 ` kargl at gcc dot gnu.org
@ 2015-07-01 17:55 ` kargl at gcc dot gnu.org
  2015-07-02 17:29 ` kargl at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-01 17:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56520

--- Comment #3 from kargl at gcc dot gnu.org ---
Patch submitted for review

https://gcc.gnu.org/ml/gcc-patches/2015-07/msg00071.html


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/56520] Syntax error causes misleading message: "Invalid character in name"
  2013-03-04 13:44 [Bug fortran/56520] New: Syntax error causes misleading message: "Invalid character in name" arjen.markus at deltares dot nl
                   ` (3 preceding siblings ...)
  2015-07-01 17:55 ` kargl at gcc dot gnu.org
@ 2015-07-02 17:29 ` kargl at gcc dot gnu.org
  2015-07-07 17:23 ` casey.webster at gmail dot com
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-02 17:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56520

--- Comment #4 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Thu Jul  2 17:29:04 2015
New Revision: 225349

URL: https://gcc.gnu.org/viewcvs?rev=225349&root=gcc&view=rev
Log:
2015-07-02  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/56520
        * match.c (gfc_match_name): Special case unary minus and plus.

2015-07-02  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/56520
        * gfortran.dg/pr56520.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr56520.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/match.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/56520] Syntax error causes misleading message: "Invalid character in name"
  2013-03-04 13:44 [Bug fortran/56520] New: Syntax error causes misleading message: "Invalid character in name" arjen.markus at deltares dot nl
                   ` (4 preceding siblings ...)
  2015-07-02 17:29 ` kargl at gcc dot gnu.org
@ 2015-07-07 17:23 ` casey.webster at gmail dot com
  2015-07-07 18:30 ` sgk at troutmask dot apl.washington.edu
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: casey.webster at gmail dot com @ 2015-07-07 17:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56520

--- Comment #5 from Casey Webster <casey.webster at gmail dot com> ---
This patch changes the error given for the testcase in this bug, but not the
one in my bug marked as a duplicate of this one (pr66710).  From that bug, the
invalid character error is still emitted:

   b = A(:,iter))
          1
Error: Invalid character in name at (1)

This was confirmed with gcc built this morning (gcc version 6.0.0 20150707)


Also, while I'll agree that "Unclassifiable statement" is better than "Invalid
character in name", it would be nicer to see "Unbalanced parenthesis".


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/56520] Syntax error causes misleading message: "Invalid character in name"
  2013-03-04 13:44 [Bug fortran/56520] New: Syntax error causes misleading message: "Invalid character in name" arjen.markus at deltares dot nl
                   ` (5 preceding siblings ...)
  2015-07-07 17:23 ` casey.webster at gmail dot com
@ 2015-07-07 18:30 ` sgk at troutmask dot apl.washington.edu
  2015-07-07 19:10 ` casey.webster at gmail dot com
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-07-07 18:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56520

--- Comment #6 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Jul 07, 2015 at 05:23:17PM +0000, casey.webster at gmail dot com wrote:
> 
> Also, while I'll agree that "Unclassifiable statement" is better
> than "Invalid character in name", it would be nicer to see
> "Unbalanced parenthesis".
> 

I'm sorry that gfortran does not meet your needs.  But, given
how gfortran's matchers work, I doubt that anyone will produce
a patch to do what you want.  I could be wrong.  Maybe someone
will take up the challenge.

The patch I developed and committed specifically addresses a
problem where the error message and the locus to which it
pointed are simply wrong.  In 'c = exp(+a))', the old error
message pointed to '+', which is a valid token in a valid
expression.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/56520] Syntax error causes misleading message: "Invalid character in name"
  2013-03-04 13:44 [Bug fortran/56520] New: Syntax error causes misleading message: "Invalid character in name" arjen.markus at deltares dot nl
                   ` (6 preceding siblings ...)
  2015-07-07 18:30 ` sgk at troutmask dot apl.washington.edu
@ 2015-07-07 19:10 ` casey.webster at gmail dot com
  2015-07-07 19:33 ` sgk at troutmask dot apl.washington.edu
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: casey.webster at gmail dot com @ 2015-07-07 19:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56520

--- Comment #7 from Casey Webster <casey.webster at gmail dot com> ---
(In reply to Steve Kargl from comment #6)
> On Tue, Jul 07, 2015 at 05:23:17PM +0000, casey.webster at gmail dot com
> wrote:
> > 
> > Also, while I'll agree that "Unclassifiable statement" is better
> > than "Invalid character in name", it would be nicer to see
> > "Unbalanced parenthesis".
> > 
> 
> I'm sorry that gfortran does not meet your needs.  But, given
> how gfortran's matchers work, I doubt that anyone will produce
> a patch to do what you want.  I could be wrong.  Maybe someone
> will take up the challenge.
> 
> The patch I developed and committed specifically addresses a
> problem where the error message and the locus to which it
> pointed are simply wrong.  In 'c = exp(+a))', the old error
> message pointed to '+', which is a valid token in a valid
> expression.

Understood.  In this case would it be proper to request the other bug I filed
be un-marked as a duplicate of this one so this one can be resolved and the
other can still be fodder for someone with enough spare time and desire to look
into it?  Thanks for your patch btw, I only complained here since my bug was
duped to this one.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/56520] Syntax error causes misleading message: "Invalid character in name"
  2013-03-04 13:44 [Bug fortran/56520] New: Syntax error causes misleading message: "Invalid character in name" arjen.markus at deltares dot nl
                   ` (7 preceding siblings ...)
  2015-07-07 19:10 ` casey.webster at gmail dot com
@ 2015-07-07 19:33 ` sgk at troutmask dot apl.washington.edu
  2015-07-08  2:21 ` casey.webster at gmail dot com
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-07-07 19:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56520

--- Comment #8 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Jul 07, 2015 at 07:10:48PM +0000, casey.webster at gmail dot com wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56520
> 
> --- Comment #7 from Casey Webster <casey.webster at gmail dot com> ---
> (In reply to Steve Kargl from comment #6)
> > On Tue, Jul 07, 2015 at 05:23:17PM +0000, casey.webster at gmail dot com
> > wrote:
> > > 
> > > Also, while I'll agree that "Unclassifiable statement" is better
> > > than "Invalid character in name", it would be nicer to see
> > > "Unbalanced parenthesis".
> > > 
> > 
> > I'm sorry that gfortran does not meet your needs.  But, given
> > how gfortran's matchers work, I doubt that anyone will produce
> > a patch to do what you want.  I could be wrong.  Maybe someone
> > will take up the challenge.
> > 
> > The patch I developed and committed specifically addresses a
> > problem where the error message and the locus to which it
> > pointed are simply wrong.  In 'c = exp(+a))', the old error
> > message pointed to '+', which is a valid token in a valid
> > expression.
> 
> Understood.  In this case would it be proper to request the other bug I filed
> be un-marked as a duplicate of this one so this one can be resolved and the
> other can still be fodder for someone with enough spare time and desire to look
> into it?  Thanks for your patch btw, I only complained here since my bug was
> duped to this one.
> 

Sure, you could re-open the bug, but I doubt any of the current
gfortran contributors will ever attempt to 'fix' the issue.  The
problem lies in how gfortran matches statements.  It attempts to
match a valid statement.  If it fails, gfortran will queue an
error message, back-up to what it considers a known good state,
and then call another matcher.  gfortran repeats this process 
for a collection of matchers.  Consider an implied do-loop
in a print statement:

  print *, (x(i), i = 1, 2)

gfortran will first attempt to match a complex constant of the
form (x, y).  This fails and an error is queued.  Then a matcher
for implied-do is run.  It successes and clears the error queue.

Now, your problem is all matchers fail and the first error
(or last because I can't remember) is printed.  Sometimes those
error messages are a little muddled.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/56520] Syntax error causes misleading message: "Invalid character in name"
  2013-03-04 13:44 [Bug fortran/56520] New: Syntax error causes misleading message: "Invalid character in name" arjen.markus at deltares dot nl
                   ` (8 preceding siblings ...)
  2015-07-07 19:33 ` sgk at troutmask dot apl.washington.edu
@ 2015-07-08  2:21 ` casey.webster at gmail dot com
  2015-07-16 18:45 ` kargl at gcc dot gnu.org
  2015-07-16 19:05 ` kargl at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: casey.webster at gmail dot com @ 2015-07-08  2:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56520

--- Comment #9 from Casey Webster <casey.webster at gmail dot com> ---
(In reply to Steve Kargl from comment #8)
> On Tue, Jul 07, 2015 at 07:10:48PM +0000, casey.webster at gmail dot com
> wrote:
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56520
> > 
> > --- Comment #7 from Casey Webster <casey.webster at gmail dot com> ---
> > (In reply to Steve Kargl from comment #6)
> > > On Tue, Jul 07, 2015 at 05:23:17PM +0000, casey.webster at gmail dot com
> > > wrote:
> > > > 
> > > > Also, while I'll agree that "Unclassifiable statement" is better
> > > > than "Invalid character in name", it would be nicer to see
> > > > "Unbalanced parenthesis".
> > > > 
> > > 
> > > I'm sorry that gfortran does not meet your needs.  But, given
> > > how gfortran's matchers work, I doubt that anyone will produce
> > > a patch to do what you want.  I could be wrong.  Maybe someone
> > > will take up the challenge.
> > > 
> > > The patch I developed and committed specifically addresses a
> > > problem where the error message and the locus to which it
> > > pointed are simply wrong.  In 'c = exp(+a))', the old error
> > > message pointed to '+', which is a valid token in a valid
> > > expression.
> > 
> > Understood.  In this case would it be proper to request the other bug I filed
> > be un-marked as a duplicate of this one so this one can be resolved and the
> > other can still be fodder for someone with enough spare time and desire to look
> > into it?  Thanks for your patch btw, I only complained here since my bug was
> > duped to this one.
> > 
> 
> Sure, you could re-open the bug, but I doubt any of the current
> gfortran contributors will ever attempt to 'fix' the issue.  The
> problem lies in how gfortran matches statements.  It attempts to
> match a valid statement.  If it fails, gfortran will queue an
> error message, back-up to what it considers a known good state,
> and then call another matcher.  gfortran repeats this process 
> for a collection of matchers.  Consider an implied do-loop
> in a print statement:
> 
>   print *, (x(i), i = 1, 2)
> 
> gfortran will first attempt to match a complex constant of the
> form (x, y).  This fails and an error is queued.  Then a matcher
> for implied-do is run.  It successes and clears the error queue.
> 
> Now, your problem is all matchers fail and the first error
> (or last because I can't remember) is printed.  Sometimes those
> error messages are a little muddled.

Thanks for the information.  I'm looking into this and I see there is already a
matcher written for balanced parens:

gcc/gfortran/match.c:124  match_parens (void)

which is only called from gfc_match_if() and gfc_match_do() in match.c and from
match_attr_spec() in decl.c.  When I get some free time I'll familiarize myself
better with the matchers and decoding in parse.c and if I come up with
something I'll reopen the duped bug and propose a patch.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/56520] Syntax error causes misleading message: "Invalid character in name"
  2013-03-04 13:44 [Bug fortran/56520] New: Syntax error causes misleading message: "Invalid character in name" arjen.markus at deltares dot nl
                   ` (9 preceding siblings ...)
  2015-07-08  2:21 ` casey.webster at gmail dot com
@ 2015-07-16 18:45 ` kargl at gcc dot gnu.org
  2015-07-16 19:05 ` kargl at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-16 18:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56520

--- Comment #10 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Thu Jul 16 18:44:56 2015
New Revision: 225900

URL: https://gcc.gnu.org/viewcvs?rev=225900&root=gcc&view=rev
Log:
2015-07-16  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/56520
        * match.c (gfc_match_name): Special case unary minus and plus.

2015-07-16  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/56520
        * gfortran.dg/pr56520.f90: New test.

Added:
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/pr56520.f90
Modified:
    branches/gcc-5-branch/gcc/fortran/ChangeLog
    branches/gcc-5-branch/gcc/fortran/match.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/56520] Syntax error causes misleading message: "Invalid character in name"
  2013-03-04 13:44 [Bug fortran/56520] New: Syntax error causes misleading message: "Invalid character in name" arjen.markus at deltares dot nl
                   ` (10 preceding siblings ...)
  2015-07-16 18:45 ` kargl at gcc dot gnu.org
@ 2015-07-16 19:05 ` kargl at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-16 19:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56520

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |5.3

--- Comment #11 from kargl at gcc dot gnu.org ---
Fixed on trunk and 5-branch.  Thanks for the bug report.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-07-16 19:05 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-04 13:44 [Bug fortran/56520] New: Syntax error causes misleading message: "Invalid character in name" arjen.markus at deltares dot nl
2014-01-07 10:10 ` [Bug fortran/56520] " dominiq at lps dot ens.fr
2015-07-01  9:56 ` dominiq at lps dot ens.fr
2015-07-01 17:54 ` kargl at gcc dot gnu.org
2015-07-01 17:55 ` kargl at gcc dot gnu.org
2015-07-02 17:29 ` kargl at gcc dot gnu.org
2015-07-07 17:23 ` casey.webster at gmail dot com
2015-07-07 18:30 ` sgk at troutmask dot apl.washington.edu
2015-07-07 19:10 ` casey.webster at gmail dot com
2015-07-07 19:33 ` sgk at troutmask dot apl.washington.edu
2015-07-08  2:21 ` casey.webster at gmail dot com
2015-07-16 18:45 ` kargl at gcc dot gnu.org
2015-07-16 19:05 ` kargl at gcc dot gnu.org

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).