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
[parent not found: <bug-15787-6594@http.gcc.gnu.org/bugzilla/>]

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