User account creation filtered due to spam.

Bug 16162 - [3.4 regression] Rejects valid member-template-definition
Summary: [3.4 regression] Rejects valid member-template-definition
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.1
: P2 critical
Target Milestone: 3.4.3
Assignee: Not yet assigned to anyone
URL:
Keywords: monitored, rejects-valid
Depends on:
Blocks:
 
Reported: 2004-06-23 16:59 UTC by Wolfgang Bangerth
Modified: 2004-09-14 16:17 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.4 4.0.0
Known to fail: 3.4.0
Last reconfirmed: 2004-06-25 09:46:15


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Bangerth 2004-06-23 16:59:58 UTC
Here's a particularly bad regression on the 3.4 branch, since there does 
not seem to be a way to work around the problem. This code should be 
valid: 
-------------------- 
template <int N> struct O { 
    struct I { 
        template <typename T> struct II { 
            void f(); 
        }; 
    }; 
}; 
 
template <int N> 
template <typename T> 
void O<N>::I::II<T>::f () {} 
-------------------- 
 
However, 3.4 branch and mainline reject the code: 
 
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc 
x.cc:15: error: non-template `II' used as template 
x.cc:15: error: (use `typename O<N>::I::template II' to indicate that it is a 
template) 
x.cc:15: error: expected init-declarator at end of input 
x.cc:15: error: expected `;' at end of input 
 
No fun :-(( 
 
W.
Comment 1 Volker Reichelt 2004-06-25 09:46:15 UTC
Confirmed.
Comment 2 Wolfgang Bangerth 2004-06-29 14:57:28 UTC
This may or may not be related to PR 16270 which has similar code but 
ICEs the compiler, instead of just rejecting the code. 
 
W. 
Comment 3 Wolfgang Bangerth 2004-06-29 15:26:26 UTC
PR 16270 has been fixed, but the code in this PR is still rejected. In 
other words: they are not related. 
 
W. 
Comment 4 Mark Mitchell 2004-08-29 18:43:08 UTC
Postponed until GCC 3.4.3.
Comment 5 CVS Commits 2004-09-14 05:44:56 UTC
Subject: Bug 16162

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-09-14 05:44:44

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog parser.c 
Added files:
	gcc/testsuite/g++.dg/template: decl2.C 

Log message:
	PR c++/16162
	* parser.c (cp_parser_id_expression): Correct value for
	is_declarator.
	(cp_parser_nested_name_specifier_opt): Look through typenames as
	necessary.
	(cp_parser_template_name): Honor check_dependency_p.
	
	PR c++/16162
	* g++.dg/template/decl2.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4282&r2=1.4283
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/decl2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4349&r2=1.4350
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.246&r2=1.247

Comment 6 Mark Mitchell 2004-09-14 05:47:43 UTC
Fixed in GCC 4.0.  

I am still looking at applying this to 3.4.3, so I have not marked the PR as
fixed, yet.
Comment 7 Wolfgang Bangerth 2004-09-14 12:34:47 UTC
Mark, since there is no workaround for this problem, I would strongly support a backport 
to the 3.4 branch! 
 
Thanks 
 W. 
Comment 8 CVS Commits 2004-09-14 16:13:41 UTC
Subject: Bug 16162

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-09-14 16:13:27

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog parser.c 
	gcc/testsuite/g++.dg/template: nested3.C 
Added files:
	gcc/testsuite/g++.dg/template: decl2.C 

Log message:
	PR c++/16162
	* parser.c (cp_parser_id_expression): Correct value for
	is_declarator.
	(cp_parser_nested_name_specifier_opt): Look through typenames as
	necessary.
	(cp_parser_template_name): Honor check_dependency_p.
	
	PR c++/16162
	* g++.dg/template/decl2.C: New test.
	* g++.dg/template/nested3.C: Expect inferior diagnostics.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.267&r2=1.3389.2.268
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.156&r2=1.3892.2.157
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.157.2.38&r2=1.157.2.39
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/decl2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/nested3.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2&r2=1.2.4.1

Comment 9 Mark Mitchell 2004-09-14 16:17:37 UTC
Fixed in GCC 3.4.3.