public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26058]  New: C++ error recovery regression
@ 2006-02-01  2:13 sabre at nondot dot org
  2006-02-01  2:18 ` [Bug c++/26058] [3.4/4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: sabre at nondot dot org @ 2006-02-01  2:13 UTC (permalink / raw)
  To: gcc-bugs

GCC 3.3 emitted one "parse error before `{' token" error on this code, GCC 4
emits one error for *every* function defined after the error.  It would be nice
to only say "error: a function-definition is not allowed here before '{' token"
once, and perhaps pop up to global scope so that the rest of the file is parsed
in a sane way.

---
int t1() {
  { // unclosed brace
}
int t2() {}
int t3() {}
int t4() {}
int t5() {}
int t6() {}
int t7() {}
int t8() {}
--- 

-Chris


-- 
           Summary: C++ error recovery regression
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sabre at nondot dot org


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


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

* [Bug c++/26058] [3.4/4.0/4.1/4.2 Regression] C++ error recovery regression
  2006-02-01  2:13 [Bug c++/26058] New: C++ error recovery regression sabre at nondot dot org
@ 2006-02-01  2:18 ` pinskia at gcc dot gnu dot org
  2006-03-01  5:13 ` gdr at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-01  2:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-02-01 02:17 -------
Confirmed. 3.4.0 had even worse error messages:
t.cc:4: error: expected primary-expression before "int"
t.cc:4: error: expected `;' before "int"
t.cc:5: error: expected primary-expression before "int"
t.cc:5: error: expected `;' before "int"
t.cc:6: error: expected primary-expression before "int"
t.cc:6: error: expected `;' before "int"
t.cc:7: error: expected primary-expression before "int"
t.cc:7: error: expected `;' before "int"
t.cc:8: error: expected primary-expression before "int"
t.cc:8: error: expected `;' before "int"
t.cc:9: error: expected primary-expression before "int"
t.cc:9: error: expected `;' before "int"
t.cc:10: error: expected primary-expression before "int"
t.cc:10: error: expected `;' before "int"
t.cc:10: error: expected `}' at end of input


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2006-02-01 02:17:56
               date|                            |
            Summary|C++ error recovery          |[3.4/4.0/4.1/4.2 Regression]
                   |regression                  |C++ error recovery
                   |                            |regression
   Target Milestone|---                         |3.4.6
            Version|unknown                     |4.0.0


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


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

* [Bug c++/26058] [3.4/4.0/4.1/4.2 Regression] C++ error recovery regression
  2006-02-01  2:13 [Bug c++/26058] New: C++ error recovery regression sabre at nondot dot org
  2006-02-01  2:18 ` [Bug c++/26058] [3.4/4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
@ 2006-03-01  5:13 ` gdr at gcc dot gnu dot org
  2006-03-01  5:14 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: gdr at gcc dot gnu dot org @ 2006-03-01  5:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from gdr at gcc dot gnu dot org  2006-03-01 05:13 -------
Not release cirtical for 3.4.6


-- 

gdr at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.6                       |---


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


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

* [Bug c++/26058] [3.4/4.0/4.1/4.2 Regression] C++ error recovery regression
  2006-02-01  2:13 [Bug c++/26058] New: C++ error recovery regression sabre at nondot dot org
  2006-02-01  2:18 ` [Bug c++/26058] [3.4/4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
  2006-03-01  5:13 ` gdr at gcc dot gnu dot org
@ 2006-03-01  5:14 ` pinskia at gcc dot gnu dot org
  2006-03-11  3:20 ` mmitchel at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-01  5:14 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.3


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


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

* [Bug c++/26058] [3.4/4.0/4.1/4.2 Regression] C++ error recovery regression
  2006-02-01  2:13 [Bug c++/26058] New: C++ error recovery regression sabre at nondot dot org
                   ` (2 preceding siblings ...)
  2006-03-01  5:14 ` pinskia at gcc dot gnu dot org
@ 2006-03-11  3:20 ` mmitchel at gcc dot gnu dot org
  2006-05-31  4:54 ` [Bug c++/26058] [4.0/4.1/4.2 " mmitchel at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-03-11  3:20 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.3                       |4.0.4


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


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

* [Bug c++/26058] [4.0/4.1/4.2 Regression] C++ error recovery regression
  2006-02-01  2:13 [Bug c++/26058] New: C++ error recovery regression sabre at nondot dot org
                   ` (3 preceding siblings ...)
  2006-03-11  3:20 ` mmitchel at gcc dot gnu dot org
@ 2006-05-31  4:54 ` mmitchel at gcc dot gnu dot org
  2006-05-31 19:14 ` sabre at nondot dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-05-31  4:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from mmitchel at gcc dot gnu dot org  2006-05-31 04:54 -------
There is no way to win here.

The EDG front end skips the entire rest of the file:

==
"pr26058.cpp", line 4: error: expected a ";"
    int t2() {}
             ^

At end of source: warning: parsing restarts here after previous syntax error

At end of source: warning: missing return statement at end of non-void
          function "t1"

At end of source: error: expected a "}"
==

That's quieter, but it also means that it issues no error message about the
bogus use of "i" in:

  int t1() {
  { // unclosed brace                                                           
  }
  int t2() {}
  if (i) ;

It's not a good idea to pop back to the top level because function declarations
are perfectly legal in function scope; it's just not legal to have a
definition.

So, the realistic choices are the EDG approach of just skipping to the end of
the current block (which may be the end of the file), or the current behavior. 
I think the current behavior is better.

I've also marked this P5, so that if someone decides to reopen the bug it will
at least be clear that this is not a release-critical problem.


-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
           Priority|P3                          |P5
         Resolution|                            |INVALID


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


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

* [Bug c++/26058] [4.0/4.1/4.2 Regression] C++ error recovery regression
  2006-02-01  2:13 [Bug c++/26058] New: C++ error recovery regression sabre at nondot dot org
                   ` (4 preceding siblings ...)
  2006-05-31  4:54 ` [Bug c++/26058] [4.0/4.1/4.2 " mmitchel at gcc dot gnu dot org
@ 2006-05-31 19:14 ` sabre at nondot dot org
  2006-05-31 19:14 ` sabre at nondot dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: sabre at nondot dot org @ 2006-05-31 19:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from sabre at nondot dot org  2006-05-31 19:13 -------
I guess I don't follow your logic here.  I agree that the EDG approach is
inferior to the current GCC implementation, but the current GCC approach is
inferior to the old GCC implementation (thus it's a regression, if not a very
important one).  Why does EDG not doing well mean that GCC can't do well?

-Chris


-- 


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


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

* [Bug c++/26058] [4.0/4.1/4.2 Regression] C++ error recovery regression
  2006-02-01  2:13 [Bug c++/26058] New: C++ error recovery regression sabre at nondot dot org
                   ` (5 preceding siblings ...)
  2006-05-31 19:14 ` sabre at nondot dot org
@ 2006-05-31 19:14 ` sabre at nondot dot org
  2006-05-31 19:54 ` mmitchel at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: sabre at nondot dot org @ 2006-05-31 19:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from sabre at nondot dot org  2006-05-31 19:14 -------
... Adding mark so that he will hopefully see the previous comment.


-- 

sabre at nondot dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mmitchel at gcc dot gnu dot
                   |                            |org


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


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

* [Bug c++/26058] [4.0/4.1/4.2 Regression] C++ error recovery regression
  2006-02-01  2:13 [Bug c++/26058] New: C++ error recovery regression sabre at nondot dot org
                   ` (6 preceding siblings ...)
  2006-05-31 19:14 ` sabre at nondot dot org
@ 2006-05-31 19:54 ` mmitchel at gcc dot gnu dot org
  2006-05-31 22:17 ` sabre at nondot dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-05-31 19:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from mmitchel at gcc dot gnu dot org  2006-05-31 19:54 -------
GCC 3.3 isn't really a very good benchmark, since the parser there didn't
handle much of the language.  We'd have to figure out what it actually did for
recovery (how many tokens did it skip, where did it pick things back up), and
then decide if that was a workable strategy.

Fundamentally, though, you only have three options:

1. Skip until you see the end of the block (EDG behavior)

2. Pop to global scope.  Problem: if the user accidentally had a definition in
local scope, but intended the following stuff to be in the local scope, then
you get confused.

3. Stay in local scope (current GCC behavior).  Problem: if the user forgot the
closing brace (and so intended stuff to be in the global scope), then you get
confused.


-- 


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


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

* [Bug c++/26058] [4.0/4.1/4.2 Regression] C++ error recovery regression
  2006-02-01  2:13 [Bug c++/26058] New: C++ error recovery regression sabre at nondot dot org
                   ` (7 preceding siblings ...)
  2006-05-31 19:54 ` mmitchel at gcc dot gnu dot org
@ 2006-05-31 22:17 ` sabre at nondot dot org
  2006-05-31 22:56 ` mark at codesourcery dot com
  2006-05-31 23:00 ` sabre at nondot dot org
  10 siblings, 0 replies; 12+ messages in thread
From: sabre at nondot dot org @ 2006-05-31 22:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from sabre at nondot dot org  2006-05-31 22:17 -------
Ok, makes sense.  The strategy that made sense to me was "If I see a definition
for something that obviously has to be at global scope, but is defined inside
of a function, pop all the way out to global scope and continue, there must be
a missing }".  I have no idea how hard that is to implement though.  If you
think it's infeasible to implement or would confuse some other important case,
then I'm ok with RESOLVED INVALID.

-Chris


-- 


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


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

* [Bug c++/26058] [4.0/4.1/4.2 Regression] C++ error recovery regression
  2006-02-01  2:13 [Bug c++/26058] New: C++ error recovery regression sabre at nondot dot org
                   ` (8 preceding siblings ...)
  2006-05-31 22:17 ` sabre at nondot dot org
@ 2006-05-31 22:56 ` mark at codesourcery dot com
  2006-05-31 23:00 ` sabre at nondot dot org
  10 siblings, 0 replies; 12+ messages in thread
From: mark at codesourcery dot com @ 2006-05-31 22:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from mark at codesourcery dot com  2006-05-31 22:56 -------
Subject: Re:  [4.0/4.1/4.2 Regression] C++ error recovery regression

sabre at nondot dot org wrote:
> ------- Comment #7 from sabre at nondot dot org  2006-05-31 22:17 -------
> Ok, makes sense.  The strategy that made sense to me was "If I see a definition
> for something that obviously has to be at global scope, but is defined inside
> of a function, pop all the way out to global scope and continue, there must be
> a missing }". 

One could attempt that -- but it would be hard.  It would also fall
afoul of code like this:

  void f() {
    void g() {} // Must be at global scope, but I didn't know that.
    g();
  }

which is likely to be another common error mode, since:

  void f() {
    void g();
    g();
  }

is valid.


-- 


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


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

* [Bug c++/26058] [4.0/4.1/4.2 Regression] C++ error recovery regression
  2006-02-01  2:13 [Bug c++/26058] New: C++ error recovery regression sabre at nondot dot org
                   ` (9 preceding siblings ...)
  2006-05-31 22:56 ` mark at codesourcery dot com
@ 2006-05-31 23:00 ` sabre at nondot dot org
  10 siblings, 0 replies; 12+ messages in thread
From: sabre at nondot dot org @ 2006-05-31 23:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from sabre at nondot dot org  2006-05-31 23:00 -------
Right, clearly issuing good diagnostics is a matter of balancing cases against
each other.  While I agree that this is valid:

 void f() {
    void g();
    g();
  }

I don't see it used very often, particularly not in C++ code (I'm accustomed to
seeing it in pre-ansi C code most of the time).  I personally think that
forgetting (or losing track of) the brace occurs more often than the erroneous
version of this, but if you disagree, that's fine and I'll stop bugging you!

-Chris


-- 


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


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

end of thread, other threads:[~2006-05-31 23:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-01  2:13 [Bug c++/26058] New: C++ error recovery regression sabre at nondot dot org
2006-02-01  2:18 ` [Bug c++/26058] [3.4/4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
2006-03-01  5:13 ` gdr at gcc dot gnu dot org
2006-03-01  5:14 ` pinskia at gcc dot gnu dot org
2006-03-11  3:20 ` mmitchel at gcc dot gnu dot org
2006-05-31  4:54 ` [Bug c++/26058] [4.0/4.1/4.2 " mmitchel at gcc dot gnu dot org
2006-05-31 19:14 ` sabre at nondot dot org
2006-05-31 19:14 ` sabre at nondot dot org
2006-05-31 19:54 ` mmitchel at gcc dot gnu dot org
2006-05-31 22:17 ` sabre at nondot dot org
2006-05-31 22:56 ` mark at codesourcery dot com
2006-05-31 23:00 ` sabre at nondot 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).