Bug 19499 - [3.4/4.0 regression] Bad diagnostic for namespace as template parameter
Summary: [3.4/4.0 regression] Bad diagnostic for namespace as template parameter
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 3.4.4
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, monitored
Depends on:
Blocks:
 
Reported: 2005-01-18 09:15 UTC by Volker Reichelt
Modified: 2005-02-01 10:49 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-01-18 14:30:57


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2005-01-18 09:15:26 UTC
The diagnostic for the following invalid code snippet could be improved:

=================================
template<typename> struct A {};

namespace N {}

A<N> a;
=================================

On mainline we now get:

bug5.cc:5: error: template argument 1 is invalid
bug5.cc:5: error: template argument 1 is invalid
bug5.cc:5: error: template argument 1 is invalid
bug5.cc:5: error: template argument 1 is invalid
bug5.cc:5: error: template argument 1 is invalid
bug5.cc:5: error: template argument 1 is invalid
bug5.cc:5: error: template argument 1 is invalid
bug5.cc:5: error: template argument 1 is invalid
bug5.cc:5: error: expected constructor, destructor, or type conversion before
'<' token

With 3.3.5 we get:

bug5.cc:5: error: use of namespace `N' as expression
bug5.cc:5: error: template argument 1 is invalid
bug5.cc:5: error: ISO C++ forbids declaration of `a' with no type

which is okay IMHO. With 3.4.3 we get

bug5.cc:5: error: template argument 1 is invalid
bug5.cc:5: error: invalid type in declaration before ';' token

which is less informative, but still okay.
With the current 3.4 branch we almost get the same mess as with mainline.
Comment 1 Volker Reichelt 2005-01-18 09:23:20 UTC
Alexandre, this was probably caused by your patch for PR18757:
http://gcc.gnu.org/ml/gcc-cvs/2004-12/msg00382.html
Comment 2 Drea Pinski 2005-01-18 14:30:57 UTC
Confirmed.
Comment 3 Mark Mitchell 2005-01-31 06:26:25 UTC
Alexandre, this patch was clearly incorrect.  The whole reason to create
CPP_TEMPLATE_ID tokens is to avoid re-parsing the same token sequence in the
case that an error occurred.  Please revert this patch ASAP.

Feel free to assign the original bug which your patch fixed to me.
Comment 4 GCC Commits 2005-02-01 05:56:37 UTC
Subject: Bug 19499

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	aoliva@gcc.gnu.org	2005-02-01 05:56:08

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog parser.c pt.c 
	gcc/testsuite/g++.dg/parse: typename7.C 

Log message:
	gcc/cp/ChangeLog:
	PR c++/18757
	PR c++/19366
	PR c++/19499
	* parser.c (cp_parser_template_id): Revert 2004-12-09's patch.
	Issue an error when creating the template id.
	* pt.c (fn_type_unification): Return early if the explicit
	template arg list is an error_mark_node.
	gcc/testsuite/ChangeLog:
	* g++.dg/parse/typename7.C: Adjust error messages.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4967&r2=1.4968
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4607&r2=1.4608
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.306&r2=1.307
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.970&r2=1.971
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/typename7.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 5 GCC Commits 2005-02-01 07:04:25 UTC
Subject: Bug 19499

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	aoliva@gcc.gnu.org	2005-02-01 07:04:01

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog parser.c pt.c 
	gcc/testsuite/g++.dg/parse: typename7.C 

Log message:
	gcc/cp/ChangeLog:
	PR c++/18757
	PR c++/19366
	PR c++/19499
	* parser.c (cp_parser_template_id): Revert 2004-12-09's patch.
	Issue an error when creating the template id.
	* pt.c (fn_type_unification): Return early if the explicit
	template arg list is an error_mark_node.
	gcc/testsuite/ChangeLog:
	* g++.dg/parse/typename7.C: Adjust error messages.

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.354&r2=1.3389.2.355
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.193&r2=1.3892.2.194
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.50&r2=1.157.2.51
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.49&r2=1.816.2.50
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/typename7.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1.10.1&r2=1.1.10.2

Comment 6 Giovanni Bajo 2005-02-01 10:49:52 UTC
Fixed in 3.4.4 and 4.0.0.