re PR c++/17501 (Confusion with member templates)
authorMark Mitchell <mark@codesourcery.com>
Thu, 16 Sep 2004 22:55:13 +0000 (22:55 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 16 Sep 2004 22:55:13 +0000 (22:55 +0000)
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
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/typename7.C [new file with mode: 0644]

index 2979b3d3a302862952e4f19e7308fb68da207c62..8d5e2d425cfa65102427b705cfa04677fe3d3d43 100644 (file)
@@ -1,3 +1,9 @@
+2004-09-16  Mark Mitchell  <mark@codesourcery.com>
+
+       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  <amacleod@redhat.com>
 
        * error.c (dump_decl): Make sure there is lang_specific info before 
index 05f447a6325bced67a5a9c22fead75598d478488..bfe749c8483a3206d8edb6219871768f5686eb70 100644 (file)
@@ -3497,7 +3497,9 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser,
         look up names in "X<T>::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);
index 88ebcdc0c5248c7167615709a153c683922f2dba..7a5fed34795c1fd6243e6576d1abdde51e9a3d23 100644 (file)
@@ -1,3 +1,8 @@
+2004-09-16  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/17501
+       * g++.dg/template/typename7.C: New test.
+
 2004-09-16  Zdenek Dvorak  <rakdver@atrey.karlin.mff.cuni.cz>
 
        * 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 (file)
index 0000000..d9c8f26
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/17501
+
+template<int> struct A;
+
+template<> struct A<0>
+{
+    struct B
+    {
+        struct C
+        {
+         typedef int D;
+        };
+    };
+};
+
+template<int I> struct E
+{
+  typename A<I>::B::C::D i;
+};