public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++
       [not found] <bug-16189-4@http.gcc.gnu.org/bugzilla/>
@ 2010-11-20 18:50 ` froydnj at gcc dot gnu.org
  2011-09-08 15:16 ` redi at gcc dot gnu.org
  2011-09-08 15:53 ` froydnj at gcc dot gnu.org
  2 siblings, 0 replies; 13+ messages in thread
From: froydnj at gcc dot gnu.org @ 2010-11-20 18:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Nathan Froyd <froydnj at gcc dot gnu.org> 2010-11-20 18:50:05 UTC ---
Author: froydnj
Date: Sat Nov 20 18:50:00 2010
New Revision: 166977

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=166977
Log:
gcc/c-family/
    PR c++/16189
    PR c++/36888
    PR c++/45331
    * c-common.h (keyword_begins_type_specifier): Declare.
    (keyword_is_storage_class_specifier): Declare.
    (keyword_is_type_qualifier): Declare.
    * c-common.c (keyword_begins_type_specifier): New function.
    (keyword_is_storage_class_specifier): New function.
    (keyword_is_type_qualifier): Declare.

gcc/cp/
    PR c++/16189
    PR c++/36888
    PR c++/45331
    * parser.c (cp_lexer_set_token_position): New function.
    (cp_lexer_previous_token_position): New function.
    (cp_lexer_previous_token): Call it.
    (cp_parser_class_specifier): Try to gracefully handle a missing
    semicolon.

gcc/testsuite/
    PR c++/16189
    PR c++/36888
    PR c++/45331
    * g++.dg/parse/semicolon3.C: New test.
    * g++.dg/debug/pr22514.C: Adjust.
    * g++.dg/init/error1.C: Adjust.
    * g++.dg/other/bitfield3.C: Adjust.
    * g++.dg/other/semicolon.C: Adjust.
    * g++.dg/parse/error14.C: Adjust.
    * g++.dg/parse/error5.C: Adjust.
    * g++.dg/parse/parameter-declaration-1.C: Adjust.
    * g++.dg/template/pr23510.C: Adjust.
    * g++.dg/template/pr39425.C: Adjust.
    * g++.old-deja/g++.robertl/eb125.C: Adjust.


Added:
    trunk/gcc/testsuite/g++.dg/parse/semicolon3.C
Modified:
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-common.c
    trunk/gcc/c-family/c-common.h
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/debug/pr22514.C
    trunk/gcc/testsuite/g++.dg/init/error1.C
    trunk/gcc/testsuite/g++.dg/other/bitfield3.C
    trunk/gcc/testsuite/g++.dg/other/semicolon.C
    trunk/gcc/testsuite/g++.dg/parse/error14.C
    trunk/gcc/testsuite/g++.dg/parse/error5.C
    trunk/gcc/testsuite/g++.dg/parse/parameter-declaration-1.C
    trunk/gcc/testsuite/g++.dg/template/pr23510.C
    trunk/gcc/testsuite/g++.dg/template/pr39425.C
    trunk/gcc/testsuite/g++.old-deja/g++.robertl/eb125.C


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

* [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++
       [not found] <bug-16189-4@http.gcc.gnu.org/bugzilla/>
  2010-11-20 18:50 ` [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++ froydnj at gcc dot gnu.org
@ 2011-09-08 15:16 ` redi at gcc dot gnu.org
  2011-09-08 15:53 ` froydnj at gcc dot gnu.org
  2 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu.org @ 2011-09-08 15:16 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |froydnj at gcc dot gnu.org

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-09-08 15:13:06 UTC ---
Nathan, should this PR have been closed following your patch?


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

* [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++
       [not found] <bug-16189-4@http.gcc.gnu.org/bugzilla/>
  2010-11-20 18:50 ` [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++ froydnj at gcc dot gnu.org
  2011-09-08 15:16 ` redi at gcc dot gnu.org
@ 2011-09-08 15:53 ` froydnj at gcc dot gnu.org
  2 siblings, 0 replies; 13+ messages in thread
From: froydnj at gcc dot gnu.org @ 2011-09-08 15:53 UTC (permalink / raw)
  To: gcc-bugs

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

Nathan Froyd <froydnj at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #12 from Nathan Froyd <froydnj at gcc dot gnu.org> 2011-09-08 15:51:11 UTC ---
Probably.  I think I didn't close it previously because I hadn't tested the
examples in comment 3.

But since those are perverse examples anyway, I'm going to go ahead and close
the bug.  If somebody doesn't like it, they can reopen, preferably with a
real-world example where the compiler doesn't do the preferred thing.


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

* [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++
       [not found] <bug-16189-6650@http.gcc.gnu.org/bugzilla/>
@ 2006-03-21 16:50 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-21 16:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pinskia at gcc dot gnu dot org  2006-03-21 16:50 -------
*** Bug 20665 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |igodard at pacbell dot net


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


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

* [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++
  2004-06-25  2:25 [Bug c++/16189] New: " bernie at develer dot com
                   ` (7 preceding siblings ...)
  2004-07-28  5:26 ` neil at gcc dot gnu dot org
@ 2004-07-31  0:24 ` giovannibajo at libero dot it
  8 siblings, 0 replies; 13+ messages in thread
From: giovannibajo at libero dot it @ 2004-07-31  0:24 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-07-31 00:24 -------
We have a RD parser, but when you already have a dozen of nested tentative 
lookups to disambiguate the C++ grammar, nothing is really easy, not even 
fixing this bug.

Notice that maybe there *is* an easy fix, I haven't looked yet.

-- 


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


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

* [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++
  2004-06-25  2:25 [Bug c++/16189] New: " bernie at develer dot com
                   ` (6 preceding siblings ...)
  2004-07-28  1:43 ` bernie at develer dot com
@ 2004-07-28  5:26 ` neil at gcc dot gnu dot org
  2004-07-31  0:24 ` giovannibajo at libero dot it
  8 siblings, 0 replies; 13+ messages in thread
From: neil at gcc dot gnu dot org @ 2004-07-28  5:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From neil at gcc dot gnu dot org  2004-07-28 05:26 -------
FWIW this is one of those things that's easy to do with an RD parser.

-- 


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


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

* [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++
  2004-06-25  2:25 [Bug c++/16189] New: " bernie at develer dot com
                   ` (5 preceding siblings ...)
  2004-07-27 23:00 ` jsm at polyomino dot org dot uk
@ 2004-07-28  1:43 ` bernie at develer dot com
  2004-07-28  5:26 ` neil at gcc dot gnu dot org
  2004-07-31  0:24 ` giovannibajo at libero dot it
  8 siblings, 0 replies; 13+ messages in thread
From: bernie at develer dot com @ 2004-07-28  1:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bernie at develer dot com  2004-07-28 01:43 -------
I don't know much about GCC frontends, but I've seen
cases where such ambiguity was being solved by a
speculative parsing trick.

If a mixed struct-declaration and defition statement
causes a syntax error, the parser could insert a
semicolon after the closing brace and try parsing the
resulting two statements again.

If the result is syntactically correct, the compiler
issues a friendly error pointing to the missing
semicolon after the declaration.


-- 


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


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

* [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++
  2004-06-25  2:25 [Bug c++/16189] New: " bernie at develer dot com
                   ` (4 preceding siblings ...)
  2004-07-27 22:47 ` schwab at suse dot de
@ 2004-07-27 23:00 ` jsm at polyomino dot org dot uk
  2004-07-28  1:43 ` bernie at develer dot com
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-07-27 23:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm at polyomino dot org dot uk  2004-07-27 23:00 -------
Subject: Re:  obfuscated error message for missing semicolon
 after declaration in C++

On Tue, 27 Jul 2004, schwab at suse dot de wrote:

> Note that the last one is obsolescent in C99.  Future standards will require 
> the storage class to appear first. 

The listed future directions bear little relation to what will actually be
removed.  Storage class specifiers not appearing first were already listed
as obsolescent in C90, while C99 removed implicit int which hadn't been
marked as obsolescent and ignored C90's indications about future use of
printf/scanf format characters (lowercase for future standard use,
uppercase for extensions) by adding both uppercase and lowercase
conversion specifiers.



-- 


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


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

* [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++
  2004-06-25  2:25 [Bug c++/16189] New: " bernie at develer dot com
                   ` (3 preceding siblings ...)
  2004-07-27 22:14 ` bangerth at dealii dot org
@ 2004-07-27 22:47 ` schwab at suse dot de
  2004-07-27 23:00 ` jsm at polyomino dot org dot uk
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: schwab at suse dot de @ 2004-07-27 22:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schwab at suse dot de  2004-07-27 22:47 -------
Note that the last one is obsolescent in C99.  Future standards will require 
the storage class to appear first. 

-- 


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


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

* [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++
  2004-06-25  2:25 [Bug c++/16189] New: " bernie at develer dot com
                   ` (2 preceding siblings ...)
  2004-07-27 21:25 ` jleatherwood at acm dot org
@ 2004-07-27 22:14 ` bangerth at dealii dot org
  2004-07-27 22:47 ` schwab at suse dot de
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: bangerth at dealii dot org @ 2004-07-27 22:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-07-27 22:14 -------
The reason why this is so hard to get right is that the compiler can't 
know what comes after the closing brace of the structure declaration. 
It can't assume that you just forgot a semicolon, since all the 
following lines are valid (including the last one, which is really ugly): 
-------------- 
struct S1 {} s1; 
struct S2 {} s2a, &s2b=s2a; 
struct S3 {} ***s3; 
struct S4 {} typedef s4; 
-------------- 
I guess you get the message what makes compiler writer's life hard. gcc's 
present message is actually not so far away from what one can really 
do in this case. 
 
W. 

-- 


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


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

* [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++
  2004-06-25  2:25 [Bug c++/16189] New: " bernie at develer dot com
  2004-06-25  2:26 ` [Bug c++/16189] " bernie at develer dot com
  2004-06-25  6:35 ` pinskia at gcc dot gnu dot org
@ 2004-07-27 21:25 ` jleatherwood at acm dot org
  2004-07-27 22:14 ` bangerth at dealii dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: jleatherwood at acm dot org @ 2004-07-27 21:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jleatherwood at acm dot org  2004-07-27 21:25 -------
(In reply to comment #0) 
> The misleading error message is also reported on 
> the *last* line of the *following* struct/class 
> declaration, which makes it hard for the user to 
> hunt for the source line containing the error. 
 
This behavior also observed in version 3.3.4 of gcc. 

-- 


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


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

* [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++
  2004-06-25  2:25 [Bug c++/16189] New: " bernie at develer dot com
  2004-06-25  2:26 ` [Bug c++/16189] " bernie at develer dot com
@ 2004-06-25  6:35 ` pinskia at gcc dot gnu dot org
  2004-07-27 21:25 ` jleatherwood at acm dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-25  6:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-25 06:33 -------
Confirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-06-25 06:33:45
               date|                            |


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


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

* [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++
  2004-06-25  2:25 [Bug c++/16189] New: " bernie at develer dot com
@ 2004-06-25  2:26 ` bernie at develer dot com
  2004-06-25  6:35 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: bernie at develer dot com @ 2004-06-25  2:26 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |giovannibajo at libero dot
                   |                            |it


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


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

end of thread, other threads:[~2011-09-08 15:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-16189-4@http.gcc.gnu.org/bugzilla/>
2010-11-20 18:50 ` [Bug c++/16189] obfuscated error message for missing semicolon after declaration in C++ froydnj at gcc dot gnu.org
2011-09-08 15:16 ` redi at gcc dot gnu.org
2011-09-08 15:53 ` froydnj at gcc dot gnu.org
     [not found] <bug-16189-6650@http.gcc.gnu.org/bugzilla/>
2006-03-21 16:50 ` pinskia at gcc dot gnu dot org
2004-06-25  2:25 [Bug c++/16189] New: " bernie at develer dot com
2004-06-25  2:26 ` [Bug c++/16189] " bernie at develer dot com
2004-06-25  6:35 ` pinskia at gcc dot gnu dot org
2004-07-27 21:25 ` jleatherwood at acm dot org
2004-07-27 22:14 ` bangerth at dealii dot org
2004-07-27 22:47 ` schwab at suse dot de
2004-07-27 23:00 ` jsm at polyomino dot org dot uk
2004-07-28  1:43 ` bernie at develer dot com
2004-07-28  5:26 ` neil at gcc dot gnu dot org
2004-07-31  0:24 ` giovannibajo at libero dot it

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