public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/34269]  New: [4.3 regression] Incomplete __decltype expressions accepted
@ 2007-11-28 21:06 reichelt at gcc dot gnu dot org
  2007-11-28 21:06 ` [Bug c++/34269] " reichelt at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2007-11-28 21:06 UTC (permalink / raw)
  To: gcc-bugs

The following invalid code snippets are wrongly accepted on mainline:

=============================
void foo() { __decltype; }
=============================

=============================
void foo() { __decltype(; }
=============================


-- 
           Summary: [4.3 regression] Incomplete __decltype expressions
                    accepted
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid, monitored
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org


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


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

* [Bug c++/34269] [4.3 regression] Incomplete __decltype expressions accepted
  2007-11-28 21:06 [Bug c++/34269] New: [4.3 regression] Incomplete __decltype expressions accepted reichelt at gcc dot gnu dot org
@ 2007-11-28 21:06 ` reichelt at gcc dot gnu dot org
  2007-11-28 22:28 ` jakub at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2007-11-28 21:06 UTC (permalink / raw)
  To: gcc-bugs



-- 

reichelt at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.3.0


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


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

* [Bug c++/34269] [4.3 regression] Incomplete __decltype expressions accepted
  2007-11-28 21:06 [Bug c++/34269] New: [4.3 regression] Incomplete __decltype expressions accepted reichelt at gcc dot gnu dot org
  2007-11-28 21:06 ` [Bug c++/34269] " reichelt at gcc dot gnu dot org
@ 2007-11-28 22:28 ` jakub at gcc dot gnu dot org
  2007-12-08 20:47 ` [Bug c++/34269] [4.1/4.2/4.3 regression] Incomplete __decltype/__typeof " pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-11-28 22:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jakub at gcc dot gnu dot org  2007-11-28 22:27 -------
And the same with __typeof__ instead of __decltype.  Since 3.4.
Why is this considered an regression?


-- 


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


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

* [Bug c++/34269] [4.1/4.2/4.3 regression] Incomplete __decltype/__typeof expressions accepted
  2007-11-28 21:06 [Bug c++/34269] New: [4.3 regression] Incomplete __decltype expressions accepted reichelt at gcc dot gnu dot org
  2007-11-28 21:06 ` [Bug c++/34269] " reichelt at gcc dot gnu dot org
  2007-11-28 22:28 ` jakub at gcc dot gnu dot org
@ 2007-12-08 20:47 ` pinskia at gcc dot gnu dot org
  2007-12-12 20:57 ` mmitchel at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-12-08 20:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2007-12-08 20:47 -------
(In reply to comment #1)
> And the same with __typeof__ instead of __decltype.  Since 3.4.
> Why is this considered an regression?

Well 3.3 rejected the incomplete __typeof__ so this is a regression for that.

Confirmed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
      Known to fail|                            |3.4.0 4.0.4 4.1.0 4.2.0
                   |                            |4.3.0
      Known to work|                            |3.3.3
   Last reconfirmed|0000-00-00 00:00:00         |2007-12-08 20:47:13
               date|                            |
            Summary|[4.3 regression] Incomplete |[4.1/4.2/4.3 regression]
                   |__decltype expressions      |Incomplete
                   |accepted                    |__decltype/__typeof
                   |                            |expressions accepted
   Target Milestone|4.3.0                       |4.1.3


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


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

* [Bug c++/34269] [4.1/4.2/4.3 regression] Incomplete __decltype/__typeof expressions accepted
  2007-11-28 21:06 [Bug c++/34269] New: [4.3 regression] Incomplete __decltype expressions accepted reichelt at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-12-08 20:47 ` [Bug c++/34269] [4.1/4.2/4.3 regression] Incomplete __decltype/__typeof " pinskia at gcc dot gnu dot org
@ 2007-12-12 20:57 ` mmitchel at gcc dot gnu dot org
  2008-07-04 22:21 ` [Bug c++/34269] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-12-12 20:57 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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


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

* [Bug c++/34269] [4.2/4.3/4.4 regression] Incomplete __decltype/__typeof expressions accepted
  2007-11-28 21:06 [Bug c++/34269] New: [4.3 regression] Incomplete __decltype expressions accepted reichelt at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-12-12 20:57 ` mmitchel at gcc dot gnu dot org
@ 2008-07-04 22:21 ` jsm28 at gcc dot gnu dot org
  2008-11-11 15:43 ` jakub at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 22:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jsm28 at gcc dot gnu dot org  2008-07-04 22:21 -------
Closing 4.1 branch.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.1/4.2/4.3/4.4 regression]|[4.2/4.3/4.4 regression]
                   |Incomplete                  |Incomplete
                   |__decltype/__typeof         |__decltype/__typeof
                   |expressions accepted        |expressions accepted
   Target Milestone|4.1.3                       |4.2.5


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


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

* [Bug c++/34269] [4.2/4.3/4.4 regression] Incomplete __decltype/__typeof expressions accepted
  2007-11-28 21:06 [Bug c++/34269] New: [4.3 regression] Incomplete __decltype expressions accepted reichelt at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2008-07-04 22:21 ` [Bug c++/34269] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
@ 2008-11-11 15:43 ` jakub at gcc dot gnu dot org
  2008-11-11 17:47 ` jason at redhat dot com
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-11-11 15:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2008-11-11 15:42 -------
The joys (well, lack thereof) of tentative parsing.  No errors are reported
because cp_parser_decl_specifier_seq (and its caller
cp_parser_simple_declaration) is called during tentative parsing. 
cp_parser_decl_specifier_seq returns error_mark_node type, but any_specifiers_p
is set, so cp_parser_simple_declaration calls:
8172  /* If we have seen at least one decl-specifier, and the next token
8173     is not a parenthesis, then we must be looking at a declaration.
8174     (After "int (" we might be looking at a functional cast.)  */
8175  if (decl_specifiers.any_specifiers_p
8176      && cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_PAREN)
8177      && cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE))
8178    cp_parser_commit_to_tentative_parse (parser);
Type being error_mark_node generally means that routines assume that error
has been reported already, so nothing is diagnosed afterwards.

Mark, how should this be fixed up?  If cp_parser_decltype (and
cp_parser_simple_type_specifier) knew one of the callers is going to call
cp_parser_commit_to_tentative_parse, it could
cp_parser_commit_to_tentative_parse
first and let all the errors be reported right away.  But I doubt it can.
Another possibility would be add support for queing error messages during
tentative parsing and at cp_parser_commit_to_tentative_parse emit them.


-- 

jakub at gcc dot gnu dot org changed:

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


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


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

* [Bug c++/34269] [4.2/4.3/4.4 regression] Incomplete __decltype/__typeof expressions accepted
  2007-11-28 21:06 [Bug c++/34269] New: [4.3 regression] Incomplete __decltype expressions accepted reichelt at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2008-11-11 15:43 ` jakub at gcc dot gnu dot org
@ 2008-11-11 17:47 ` jason at redhat dot com
  2008-11-11 20:11 ` mark at codesourcery dot com
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jason at redhat dot com @ 2008-11-11 17:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jason at redhat dot com  2008-11-11 17:45 -------
Subject: Re:  [4.2/4.3/4.4 regression] Incomplete __decltype/__typeof
 expressions accepted

jakub at gcc dot gnu dot org wrote:
> Another possibility would be add support for queing error messages during
> tentative parsing and at cp_parser_commit_to_tentative_parse emit them.

This seems right to me.  It's even what the comment at the top of the 
file says we do:

      Then, while we attempt to parse the construct, the parser queues 
up
      error messages, rather than issuing them immediately, and saves 
the
      tokens it consumes.  If the construct is parsed successfully, the 

      parser "commits", i.e., it issues any queued error messages and 

      the tokens that were being preserved are permanently discarded.

The simulate_error business only works for parse errors that indicate 
that this line of parsing won't work; it doesn't work for code that 
parses fine, but violates semantic rules and therefore needs an error.

Jason


-- 


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


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

* [Bug c++/34269] [4.2/4.3/4.4 regression] Incomplete __decltype/__typeof expressions accepted
  2007-11-28 21:06 [Bug c++/34269] New: [4.3 regression] Incomplete __decltype expressions accepted reichelt at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2008-11-11 17:47 ` jason at redhat dot com
@ 2008-11-11 20:11 ` mark at codesourcery dot com
  2008-11-12 17:36 ` jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: mark at codesourcery dot com @ 2008-11-11 20:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from mark at codesourcery dot com  2008-11-11 20:09 -------
Subject: Re:  [4.2/4.3/4.4 regression] Incomplete __decltype/__typeof
 expressions accepted

jason at redhat dot com wrote:

> This seems right to me.  It's even what the comment at the top of the 
> file says we do:
> 
>       Then, while we attempt to parse the construct, the parser queues 
> up
>       error messages, rather than issuing them immediately, and saves 
> the
>       tokens it consumes.  If the construct is parsed successfully, the 
> 
>       parser "commits", i.e., it issues any queued error messages and 
> 
>       the tokens that were being preserved are permanently discarded.
> 
> The simulate_error business only works for parse errors that indicate 
> that this line of parsing won't work; it doesn't work for code that 
> parses fine, but violates semantic rules and therefore needs an error.

I forgot that comment was still there.  I think it's a lie, reflecting
an earlier implementation state.  I found queuing up the messages to be
really difficult.

For a syntactically broken construct, we can just issue the error and
commit to the tentative parse at that point.  I believe we do that in
some other places.  It doesn't matter what top-level construct
(declaration or expression-statement) we might be looking at; something
like "__decltype( ;" is always invalid.  Once you see "decltype (" , if
the parsing of the operand to decltype fails, we can commit to the
current tentative parse, issue the error, and move on.

However, I think the core bug here may be that the code you mention in
cp_parser_simple_declaration doesn't check to see if the parse has
already failed.  Committing to the tentative parse is reasonable in that
situation if the parsing has succeeded thus far -- but if we've actually
hit a *parse* error, rather than a *semantic* error, we could safely
give up.

That will result in trying to parse the decltype again (now as an
expression statement), and we'll get an error that time.


-- 


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


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

* [Bug c++/34269] [4.2/4.3/4.4 regression] Incomplete __decltype/__typeof expressions accepted
  2007-11-28 21:06 [Bug c++/34269] New: [4.3 regression] Incomplete __decltype expressions accepted reichelt at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2008-11-11 20:11 ` mark at codesourcery dot com
@ 2008-11-12 17:36 ` jakub at gcc dot gnu dot org
  2008-11-12 19:23 ` [Bug c++/34269] [4.2/4.3 " jakub at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-11-12 17:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jakub at gcc dot gnu dot org  2008-11-12 17:35 -------
Subject: Bug 34269

Author: jakub
Date: Wed Nov 12 17:33:48 2008
New Revision: 141793

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141793
Log:
        PR c++/34269
        * parser.c (cp_parser_simple_declaration): Don't commit
        to tentative parse if parse errors were seen.

        * g++.dg/cpp0x/decltype13.C: New test.
        * g++.dg/cpp0x/decltype-33837.C: Adjust dg-error pattern.
        * g++.dg/cpp0x/pr33839.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/decltype13.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/decltype-33837.C
    trunk/gcc/testsuite/g++.dg/cpp0x/pr33839.C


-- 


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


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

* [Bug c++/34269] [4.2/4.3 regression] Incomplete __decltype/__typeof expressions accepted
  2007-11-28 21:06 [Bug c++/34269] New: [4.3 regression] Incomplete __decltype expressions accepted reichelt at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2008-11-12 17:36 ` jakub at gcc dot gnu dot org
@ 2008-11-12 19:23 ` jakub at gcc dot gnu dot org
  2009-03-31 20:14 ` [Bug c++/34269] [4.3 " jsm28 at gcc dot gnu dot org
  2009-06-04 11:34 ` rguenth at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-11-12 19:23 UTC (permalink / raw)
  To: gcc-bugs



-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
      Known to work|3.3.3                       |3.3.3 4.4.0
   Last reconfirmed|2007-12-08 20:47:13         |2008-11-12 19:22:27
               date|                            |
            Summary|[4.2/4.3/4.4 regression]    |[4.2/4.3 regression]
                   |Incomplete                  |Incomplete
                   |__decltype/__typeof         |__decltype/__typeof
                   |expressions accepted        |expressions accepted


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


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

* [Bug c++/34269] [4.3 regression] Incomplete __decltype/__typeof expressions accepted
  2007-11-28 21:06 [Bug c++/34269] New: [4.3 regression] Incomplete __decltype expressions accepted reichelt at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2008-11-12 19:23 ` [Bug c++/34269] [4.2/4.3 " jakub at gcc dot gnu dot org
@ 2009-03-31 20:14 ` jsm28 at gcc dot gnu dot org
  2009-06-04 11:34 ` rguenth at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-31 20:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jsm28 at gcc dot gnu dot org  2009-03-31 20:14 -------
Closing 4.2 branch.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.2/4.3 regression]        |[4.3 regression] Incomplete
                   |Incomplete                  |__decltype/__typeof
                   |__decltype/__typeof         |expressions accepted
                   |expressions accepted        |
   Target Milestone|4.2.5                       |4.3.4


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


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

* [Bug c++/34269] [4.3 regression] Incomplete __decltype/__typeof expressions accepted
  2007-11-28 21:06 [Bug c++/34269] New: [4.3 regression] Incomplete __decltype expressions accepted reichelt at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2009-03-31 20:14 ` [Bug c++/34269] [4.3 " jsm28 at gcc dot gnu dot org
@ 2009-06-04 11:34 ` rguenth at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-06-04 11:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from rguenth at gcc dot gnu dot org  2009-06-04 11:34 -------
Not worth fixing on the 4.3 branch.  Fixed for 4.4.0.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|4.3.4                       |4.4.0


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


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

end of thread, other threads:[~2009-06-04 11:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-28 21:06 [Bug c++/34269] New: [4.3 regression] Incomplete __decltype expressions accepted reichelt at gcc dot gnu dot org
2007-11-28 21:06 ` [Bug c++/34269] " reichelt at gcc dot gnu dot org
2007-11-28 22:28 ` jakub at gcc dot gnu dot org
2007-12-08 20:47 ` [Bug c++/34269] [4.1/4.2/4.3 regression] Incomplete __decltype/__typeof " pinskia at gcc dot gnu dot org
2007-12-12 20:57 ` mmitchel at gcc dot gnu dot org
2008-07-04 22:21 ` [Bug c++/34269] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
2008-11-11 15:43 ` jakub at gcc dot gnu dot org
2008-11-11 17:47 ` jason at redhat dot com
2008-11-11 20:11 ` mark at codesourcery dot com
2008-11-12 17:36 ` jakub at gcc dot gnu dot org
2008-11-12 19:23 ` [Bug c++/34269] [4.2/4.3 " jakub at gcc dot gnu dot org
2009-03-31 20:14 ` [Bug c++/34269] [4.3 " jsm28 at gcc dot gnu dot org
2009-06-04 11:34 ` rguenth 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).