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; 6+ 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] 6+ 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; 6+ 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] 6+ 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; 6+ 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] 6+ 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; 6+ 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] 6+ 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; 6+ 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] 6+ 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; 6+ 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] 6+ messages in thread

end of thread, other threads:[~2004-10-23 20:37 UTC | newest]

Thread overview: 6+ 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

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