Bug 18140 - [3.4/4.0 regression] C++ parser bug when using >> in templates
Summary: [3.4/4.0 regression] C++ parser bug when using >> in templates
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.1
: P2 normal
Target Milestone: 3.4.3
Assignee: Mark Mitchell
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2004-10-25 09:42 UTC by Markus F.X.J. Oberhumer
Modified: 2004-10-28 05:28 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.4
Known to fail: 3.4.3 4.0.0
Last reconfirmed: 2004-10-25 11:45:05


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus F.X.J. Oberhumer 2004-10-25 09:42:51 UTC
gcc incorrectly rejects the following template code - seems to be a bug in the
new (gcc 3.4) C++ parser.

> g++-4.0 -Wall -W x.cpp
x.cpp:6: error: spurious '>>', use '>' to terminate a template argument list
x.cpp:6: error: expected primary-expression before "S"
x.cpp:6: error: expected %<;%> before "S"


template <int N> struct IntHolder {
    static const int value = N;
};

template <int N, int S> struct ShrIntHolder {
    static const int value = IntHolder< N>>S >::value;
};
Comment 1 Wolfgang Bangerth 2004-10-25 11:31:25 UTC
Confirmed, a regression in 3.4 and mainline. 
W. 
Comment 2 Andrew Pinski 2004-10-25 11:45:03 UTC
Looks like caused by the new parser
: Search converges between 2003-12-18-trunk (#431) and 2003-12-24-trunk (#432).
Comment 3 CVS Commits 2004-10-28 05:17:21 UTC
Subject: Bug 18140

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-10-28 05:17:15

Modified files:
	gcc/cp         : ChangeLog parser.c call.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/g++.dg/template: error10.C 
Added files:
	gcc/testsuite/g++.dg/template: shift1.C 
	gcc/testsuite/g++.dg/init: ref12.C 

Log message:
	PR c++/17435
	* call.c (convert_like_real): Fix formatting.
	(initialize_reference): When binding a temporary to a base class,
	ensure that the nominal copy made is to the derived class, not the
	base class.
	
	PR c++/18140
	* parser.c (cp_parser_next_token_ends_template_argument_p): Do not
	include ">>".
	
	PR c++/17435
	* g++.dg/init/ref12.C: New test.
	
	PR c++/18140
	* g++.dg/template/shift1.C: New test.
	* g++.dg/template/error10.C: Adjust error markers.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4458&r2=1.4459
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.272&r2=1.273
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.516&r2=1.517
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4508&r2=1.4509
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/shift1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error10.C.diff?cvsroot=gcc&r1=1.2&r2=1.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/ref12.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 5 Mark Mitchell 2004-10-28 05:28:45 UTC
Fixed in GCC 3.4.3.