Bug 18738 - [3.4 Regression] typename not allowed with non-dependent qualified name
Summary: [3.4 Regression] typename not allowed with non-dependent qualified name
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 3.4.5
Assignee: Volker Reichelt
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: monitored, patch, rejects-valid
Depends on:
Blocks: 19253
  Show dependency treegraph
 
Reported: 2004-11-30 13:45 UTC by Mikael Kilpeläinen
Modified: 2005-09-06 15:27 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-09-04 18:20:25


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikael Kilpeläinen 2004-11-30 13:45:14 UTC
namespace foo {
    typedef int my_type;
}

template<typename T>
struct A {
    typename foo::my_type bar();
};


$ g++ typename.cpp
typename.cpp:8: error: 'my_type' in namespace 'foo' does not name a type

with

$ g++ -v
Reading specs from /usr/local/lib/gcc/i686-pc-linux-gnu/4.0.0/specs
Configured with: ../gcc/configure --enable-languages=c++,c --enable-
threads=posix
Thread model: posix
gcc version 4.0.0 20041130 (experimental)


The qualified name does not need to be dependent according to the std03 14.6/5.
This seems to be regression from the versions before new parser.


Mikael
Comment 1 Volker Reichelt 2004-12-01 16:30:02 UTC
Confirmed.
Comment 2 CVS Commits 2004-12-15 00:42:50 UTC
Subject: Bug 18738

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-12-15 00:42:36

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/g++.dg/parse: friend2.C 
	gcc/cp         : ChangeLog decl.c parser.c 
Added files:
	gcc/testsuite/g++.dg/template: typename8.C 

Log message:
	PR c++/18738
	* decl.c (make_typename_type): Do not handle namespace-scoped
	names here.
	(tag_name): Handle typename_type.
	(check_elaborated_type_specifier): Handle typenames.
	* parser.c (cp_parser_diagnose_invalid_type_name): Improve
	comment.
	(cp_parser_elaborated_type_specifier): Use
	cp_parser_diagnose_invalid_type_name.
	
	PR c++/18738
	* g++.dg/template/typename8.C: New test.
	* g++.dg/parse/friend2.C: Tweak error message.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4757&r2=1.4758
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/typename8.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/friend2.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4535&r2=1.4536
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1340&r2=1.1341
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.294&r2=1.295

Comment 3 Mark Mitchell 2004-12-15 00:45:34 UTC
Fixed in GCC 4.0.
Comment 4 Mark Mitchell 2004-12-15 01:50:56 UTC
Reopening, just for 3.4.
Comment 5 nefercheprure 2005-01-30 15:07:23 UTC
This issue also affects template parameters: see also: 14.1/2, 14.6/5

namespace N { typedef int my_typedef }
template < typename N::my_typedef > class X {};
X<3> variable;

Neither the other comments nor the proposed solution mentions this situation.
Could you please check this against the proposed solution? In any case the test
could be added.
Comment 6 Andrew Pinski 2005-01-30 15:10:44 UTC
(In reply to comment #5)
> This issue also affects template parameters: see also: 14.1/2, 14.6/5
> 
> namespace N { typedef int my_typedef }
> template < typename N::my_typedef > class X {};
> X<3> variable;
> 
> Neither the other comments nor the proposed solution mentions this situation.
> Could you please check this against the proposed solution? In any case the test
> could be added.

Yes the "proposed" (well it has been committed already on the mainline) works for this test.
Comment 7 Volker Reichelt 2005-09-06 10:41:12 UTC
Taking care of the backport to the 3.4 branch.
Comment 8 CVS Commits 2005-09-06 15:25:44 UTC
Subject: Bug 18738

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	reichelt@gcc.gnu.org	2005-09-06 15:25:13

Modified files:
	gcc/cp         : ChangeLog decl.c parser.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/g++.dg/parse: friend2.C 
Added files:
	gcc/testsuite/g++.dg/template: typename8.C 

Log message:
	Backport:
	
	2004-12-14  Mark Mitchell  <mark@codesourcery.com>
	PR c++/18738
	* decl.c (make_typename_type): Do not handle namespace-scoped
	names here.
	(tag_name): Handle typename_type.
	(check_elaborated_type_specifier): Handle typenames.
	* parser.c (cp_parser_diagnose_invalid_type_name): Do not call
	make_typename_type for namespace-scoped names here.
	(cp_parser_elaborated_type_specifier): Use
	cp_parser_diagnose_invalid_type_name.
	
	* g++.dg/template/typename8.C: New test.
	* g++.dg/parse/friend2.C: Tweak error message.

Patches:
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.239&r2=1.3892.2.240
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1174.2.39&r2=1.1174.2.40
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.61&r2=1.157.2.62
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.432&r2=1.3389.2.433
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/typename8.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.46.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/friend2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1&r2=1.1.28.1

Comment 9 Volker Reichelt 2005-09-06 15:27:03 UTC
Fixed also on the 3.4 branch.