public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15787] New: Poor error message
@ 2004-06-02 21:31 igodard at pacbell dot net
  2004-06-02 21:32 ` [Bug c++/15787] " igodard at pacbell dot net
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: igodard at pacbell dot net @ 2004-06-02 21:31 UTC (permalink / raw)
  To: gcc-bugs

The actual problem in the test case is a missing "}", which fact appears nowhere in the message. The message talks about a "primary-expression", which is technically correct but reflects a compiler- and formal syntax-centric view. A user will in general neither know nor care what a primary-expression is; he wants to know what's wrong in terms of his code. The education, experience and knowledge of compiler users is *not* the same as of compiler writers :-)

The great bulk of syntactic arrors are bracket errors or missing semis. Now that you have a recursive descent parser, it is trivial to have the compiler suggest a plausible fix for these. For example, have the compiler keep a side stack of brackets entered and not exited. If you get a closer that matches the *second* item on the stack then your message offers the closers of the *top* item on the stack as suggestions. 

In the case of this code, the top item is "{" and the second is "if". When the parse error happens the cursor is on "else", which matches the "if". So you produce a message "expected primary-expression before 'else'; possibly a missing '}'?". This same stack can be used for repair.

Ivan

-- 
           Summary: Poor error message
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/15787] Poor error message
  2004-06-02 21:31 [Bug c++/15787] New: Poor error message igodard at pacbell dot net
@ 2004-06-02 21:32 ` igodard at pacbell dot net
  2004-06-02 21:33 ` igodard at pacbell dot net
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: igodard at pacbell dot net @ 2004-06-02 21:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-06-02 21:32 -------
Created an attachment (id=6453)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6453&action=view)
Compiler output (-v -save-temps)


-- 


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


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

* [Bug c++/15787] Poor error message
  2004-06-02 21:31 [Bug c++/15787] New: Poor error message igodard at pacbell dot net
  2004-06-02 21:32 ` [Bug c++/15787] " igodard at pacbell dot net
@ 2004-06-02 21:33 ` igodard at pacbell dot net
  2004-06-02 21:37 ` igodard at pacbell dot net
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: igodard at pacbell dot net @ 2004-06-02 21:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-06-02 21:33 -------
Created an attachment (id=6454)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6454&action=view)
Source code (-save-temps)


-- 


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


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

* [Bug c++/15787] Poor error message
  2004-06-02 21:31 [Bug c++/15787] New: Poor error message igodard at pacbell dot net
  2004-06-02 21:32 ` [Bug c++/15787] " igodard at pacbell dot net
  2004-06-02 21:33 ` igodard at pacbell dot net
@ 2004-06-02 21:37 ` igodard at pacbell dot net
  2004-06-03  1:32 ` pinskia at gcc dot gnu dot org
  2004-10-23 20:37 ` [Bug c++/15787] Poor error message with if and blocks pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 10+ messages in thread
From: igodard at pacbell dot net @ 2004-06-02 21:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From igodard at pacbell dot net  2004-06-02 21:37 -------
p.s. Also put the line number of the opener in the info on that side stack. Then you can say "expected...; possibly a missing '}' matching the '{' on line 17?".

You wouldn't really need this in Algol68 or other languages with distinct opener/closer pairs, but in C with the heavy overload of "{}" and "()" it would be real helpful. And you *are* trying to be helpful, aren't you? :-)

Ivan

-- 


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


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

* [Bug c++/15787] Poor error message
  2004-06-02 21:31 [Bug c++/15787] New: Poor error message igodard at pacbell dot net
                   ` (2 preceding siblings ...)
  2004-06-02 21:37 ` igodard at pacbell dot net
@ 2004-06-03  1:32 ` pinskia at gcc dot gnu dot org
  2004-10-23 20:37 ` [Bug c++/15787] Poor error message with if and blocks pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-03  1:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-03 01:32 -------
Confirmed, here is much smaller example:
int f()
{
  if (1)
  {
   return 1;
  else
  {
  }
}

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2004-06-03 01:32:18
               date|                            |


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


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

* [Bug c++/15787] Poor error message with if and blocks
  2004-06-02 21:31 [Bug c++/15787] New: Poor error message igodard at pacbell dot net
                   ` (3 preceding siblings ...)
  2004-06-03  1:32 ` pinskia at gcc dot gnu dot org
@ 2004-10-23 20:37 ` pinskia at gcc dot gnu dot org
  4 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-23 20:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-23 20:37 -------
*** Bug 15788 has been marked as a duplicate of this bug. ***

-- 


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


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

* [Bug c++/15787] Poor error message with if and blocks
       [not found] <bug-15787-6594@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2007-03-03 15:32 ` manu at gcc dot gnu dot org
@ 2007-03-03 15:51 ` manu at gcc dot gnu dot org
  3 siblings, 0 replies; 10+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-03-03 15:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from manu at gcc dot gnu dot org  2007-03-03 15:51 -------
Fixed in 4.3.0


-- 

manu at gcc dot gnu dot org changed:

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


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


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

* [Bug c++/15787] Poor error message with if and blocks
       [not found] <bug-15787-6594@http.gcc.gnu.org/bugzilla/>
  2007-01-27 13:40 ` patchapp at dberlin dot org
  2007-01-30 22:10 ` patchapp at dberlin dot org
@ 2007-03-03 15:32 ` manu at gcc dot gnu dot org
  2007-03-03 15:51 ` manu at gcc dot gnu dot org
  3 siblings, 0 replies; 10+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-03-03 15:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from manu at gcc dot gnu dot org  2007-03-03 15:32 -------
Subject: Bug 15787

Author: manu
Date: Sat Mar  3 15:32:13 2007
New Revision: 122505

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122505
Log:
2007-03-03  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

        PR c++/15787
        * parser.c (struct cp_parser): New IN_IF_STMT.
        (cp_parser_statement_seq_opt): Handle an unexpected 'else',
        returning if parsing the body of an 'if' statement or issuing an
        error and continuing.
        (cp_parser_selection_statement): Set IN_IF_STMT bit when parsing
        body of 'if'.
        (cp_parser_jump_statement): Mask new IN_IF_STMT bit.

testsuite/
        * g++.dg/parse/else.C: New.
        * g++.dg/parse/else-2.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/parse/else-2.C
    trunk/gcc/testsuite/g++.dg/parse/else.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/15787] Poor error message with if and blocks
       [not found] <bug-15787-6594@http.gcc.gnu.org/bugzilla/>
  2007-01-27 13:40 ` patchapp at dberlin dot org
@ 2007-01-30 22:10 ` patchapp at dberlin dot org
  2007-03-03 15:32 ` manu at gcc dot gnu dot org
  2007-03-03 15:51 ` manu at gcc dot gnu dot org
  3 siblings, 0 replies; 10+ messages in thread
From: patchapp at dberlin dot org @ 2007-01-30 22:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from patchapp at dberlin dot org  2007-01-30 22:10 -------
Subject: Bug number PR 15787

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-01/msg02533.html


-- 


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


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

* [Bug c++/15787] Poor error message with if and blocks
       [not found] <bug-15787-6594@http.gcc.gnu.org/bugzilla/>
@ 2007-01-27 13:40 ` patchapp at dberlin dot org
  2007-01-30 22:10 ` patchapp at dberlin dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: patchapp at dberlin dot org @ 2007-01-27 13:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from patchapp at dberlin dot org  2007-01-27 13:40 -------
Subject: Bug number PR 15787

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-01/msg02238.html


-- 


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


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

end of thread, other threads:[~2007-03-03 15:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-02 21:31 [Bug c++/15787] New: Poor error message igodard at pacbell dot net
2004-06-02 21:32 ` [Bug c++/15787] " igodard at pacbell dot net
2004-06-02 21:33 ` igodard at pacbell dot net
2004-06-02 21:37 ` igodard at pacbell dot net
2004-06-03  1:32 ` pinskia at gcc dot gnu dot org
2004-10-23 20:37 ` [Bug c++/15787] Poor error message with if and blocks pinskia at gcc dot gnu dot org
     [not found] <bug-15787-6594@http.gcc.gnu.org/bugzilla/>
2007-01-27 13:40 ` patchapp at dberlin dot org
2007-01-30 22:10 ` patchapp at dberlin dot org
2007-03-03 15:32 ` manu at gcc dot gnu dot org
2007-03-03 15:51 ` manu at gcc dot gnu dot 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).