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
Confirmed.
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
Fixed in GCC 4.0.
Reopening, just for 3.4.
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.
(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.
Taking care of the backport to the 3.4 branch.
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
Fixed also on the 3.4 branch.