From 67bcc252247fa1d0e45258c2ce927b666e621321 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Thu, 16 Sep 2004 22:55:13 +0000 Subject: [PATCH] re PR c++/17501 (Confusion with member templates) PR c++/17501 * parser.c (cp_parser_nested_name_specifier): Do not resolve typename types if the user explicitly said "typename". PR c++/17501 * g++.dg/template/typename7.C: New test. From-SVN: r87616 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 4 +++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/typename7.C | 19 +++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/typename7.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2979b3d3a30..8d5e2d425cf 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-09-16 Mark Mitchell + + PR c++/17501 + * parser.c (cp_parser_nested_name_specifier): Do not resolve + typename types if the user explicitly said "typename". + 2004-09-16 Andrew MacLeod * error.c (dump_decl): Make sure there is lang_specific info before diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 05f447a6325..bfe749c8483 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -3497,7 +3497,9 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, look up names in "X::I" in order to determine that "Y" is a template. So, if we have a typename at this point, we make an effort to look through it. */ - if (is_declaration && parser->scope + if (is_declaration + && !typename_keyword_p + && parser->scope && TREE_CODE (parser->scope) == TYPENAME_TYPE) parser->scope = resolve_typename_type (parser->scope, /*only_current_p=*/false); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 88ebcdc0c52..7a5fed34795 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-09-16 Mark Mitchell + + PR c++/17501 + * g++.dg/template/typename7.C: New test. + 2004-09-16 Zdenek Dvorak * gcc.dg/tree-ssa/copy-headers.c: Update outcome. diff --git a/gcc/testsuite/g++.dg/template/typename7.C b/gcc/testsuite/g++.dg/template/typename7.C new file mode 100644 index 00000000000..d9c8f2609aa --- /dev/null +++ b/gcc/testsuite/g++.dg/template/typename7.C @@ -0,0 +1,19 @@ +// PR c++/17501 + +template struct A; + +template<> struct A<0> +{ + struct B + { + struct C + { + typedef int D; + }; + }; +}; + +template struct E +{ + typename A::B::C::D i; +}; -- 2.30.2