public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/28858]  New: [4.0/4.1/4.2 regression] Algorithm to find the end of a template parameter list is flawed
@ 2006-08-26 20:55 reichelt at gcc dot gnu dot org
  2006-08-26 22:46 ` [Bug c++/28858] " patchapp at dberlin dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2006-08-26 20:55 UTC (permalink / raw)
  To: gcc-bugs

If an error occurs in a template parameter list, the frontend
sometimes calls cp_parser_skip_until_found to find the ">" that
marks the end of the list. The algorithm used there has some flaws,
though:

1) It doesn't keep track of the nesting levels of "< ... >".
   This results in bogus error messages when templates are used as default
   parameters or when template template parameters are involved, e.g.:

     template<TEMPLATE<int> class> struct A {};

   yields:

     bug.cc:1: error: 'TEMPLATE' has not been declared
     bug.cc:1: error: expected `>' before '<' token
     bug.cc:1: error: expected identifier before '>' token
     bug.cc:1: error: expected unqualified-id before '>' token

2) It doesn't stop at ";", or "{", or "}".
   (These tokens probably indicate the end of a declaration or the start of
   a function/struct body which is not part of a template parameter list.)
   Because of this large parts of the source might be skipped,
   if one forgets the closing ">", again resulting in bogus errors, e.g.:

     template<int N struct A;
     bool i = 1 > 0;
     int j = i;

   yields:

     bug.cc:1: error: expected `>' before 'struct'
     bug.cc:2: error: expected unqualified-id before numeric constant
     bug.cc:3: error: 'i' was not declared in this scope

Posting a patch soon.


-- 
           Summary: [4.0/4.1/4.2 regression] Algorithm to find the end of a
                    template parameter list is flawed
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: error-recovery, diagnostic
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: reichelt at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org


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


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

* [Bug c++/28858] [4.0/4.1/4.2 regression] Algorithm to find the end of a template parameter list is flawed
  2006-08-26 20:55 [Bug c++/28858] New: [4.0/4.1/4.2 regression] Algorithm to find the end of a template parameter list is flawed reichelt at gcc dot gnu dot org
@ 2006-08-26 22:46 ` patchapp at dberlin dot org
  2006-08-28 23:21 ` reichelt at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: patchapp at dberlin dot org @ 2006-08-26 22:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from patchapp at dberlin dot org  2006-08-26 22:46 -------
Subject: Bug number PR c++/28858

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2006-08/msg01013.html


-- 


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


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

* [Bug c++/28858] [4.0/4.1/4.2 regression] Algorithm to find the end of a template parameter list is flawed
  2006-08-26 20:55 [Bug c++/28858] New: [4.0/4.1/4.2 regression] Algorithm to find the end of a template parameter list is flawed reichelt at gcc dot gnu dot org
  2006-08-26 22:46 ` [Bug c++/28858] " patchapp at dberlin dot org
@ 2006-08-28 23:21 ` reichelt at gcc dot gnu dot org
  2006-09-01 22:05 ` mmitchel at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2006-08-28 23:21 UTC (permalink / raw)
  To: gcc-bugs



-- 

reichelt at gcc dot gnu dot org changed:

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


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


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

* [Bug c++/28858] [4.0/4.1/4.2 regression] Algorithm to find the end of a template parameter list is flawed
  2006-08-26 20:55 [Bug c++/28858] New: [4.0/4.1/4.2 regression] Algorithm to find the end of a template parameter list is flawed reichelt at gcc dot gnu dot org
  2006-08-26 22:46 ` [Bug c++/28858] " patchapp at dberlin dot org
  2006-08-28 23:21 ` reichelt at gcc dot gnu dot org
@ 2006-09-01 22:05 ` mmitchel at gcc dot gnu dot org
  2006-09-08 22:57 ` reichelt at gcc dot gnu dot org
  2006-09-08 23:28 ` reichelt at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-09-01 22:05 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4


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


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

* [Bug c++/28858] [4.0/4.1/4.2 regression] Algorithm to find the end of a template parameter list is flawed
  2006-08-26 20:55 [Bug c++/28858] New: [4.0/4.1/4.2 regression] Algorithm to find the end of a template parameter list is flawed reichelt at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-09-01 22:05 ` mmitchel at gcc dot gnu dot org
@ 2006-09-08 22:57 ` reichelt at gcc dot gnu dot org
  2006-09-08 23:28 ` reichelt at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2006-09-08 22:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from reichelt at gcc dot gnu dot org  2006-09-08 22:56 -------
Subject: Bug 28858

Author: reichelt
Date: Fri Sep  8 22:56:44 2006
New Revision: 116788

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116788
Log:
        PR c++/28858
        * parser.c (cp_parser_skip_until_found): Rename to
        cp_parser_skip_to_end_of_template_parameter_list.  Remove last two
        parameters.  Track levels of '< ... >'.  Stop at '{', '}', or ';'.
        Reorganize.  Adjust comment.
        (cp_parser_template_declaration_after_export): Adjust call.
        (cp_parser_enclosed_template_argument_list): Likewise.

        * g++.dg/parse/template20.C: New test.
        * g++.dg/template/operator8.C: Remove obsolete part.
        * g++.dg/parse/def-tmpl-arg1.C: Adjust error-markers.
        * g++.old-deja/g++.pt/crash65.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/parse/template20.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/parse/def-tmpl-arg1.C
    trunk/gcc/testsuite/g++.dg/template/operator8.C
    trunk/gcc/testsuite/g++.old-deja/g++.pt/crash65.C


-- 


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


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

* [Bug c++/28858] [4.0/4.1/4.2 regression] Algorithm to find the end of a template parameter list is flawed
  2006-08-26 20:55 [Bug c++/28858] New: [4.0/4.1/4.2 regression] Algorithm to find the end of a template parameter list is flawed reichelt at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-09-08 22:57 ` reichelt at gcc dot gnu dot org
@ 2006-09-08 23:28 ` reichelt at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2006-09-08 23:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from reichelt at gcc dot gnu dot org  2006-09-08 23:28 -------
Fixed on mainline.
Won't backport to 4.1 and 4.0 branch.


-- 

reichelt at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|4.0.4                       |4.2.0


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


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

end of thread, other threads:[~2006-09-08 23:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-26 20:55 [Bug c++/28858] New: [4.0/4.1/4.2 regression] Algorithm to find the end of a template parameter list is flawed reichelt at gcc dot gnu dot org
2006-08-26 22:46 ` [Bug c++/28858] " patchapp at dberlin dot org
2006-08-28 23:21 ` reichelt at gcc dot gnu dot org
2006-09-01 22:05 ` mmitchel at gcc dot gnu dot org
2006-09-08 22:57 ` reichelt at gcc dot gnu dot org
2006-09-08 23:28 ` reichelt 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).