OSDN Git Service

PR c++/17132
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 28 Oct 2004 20:53:04 +0000 (20:53 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 28 Oct 2004 20:53:04 +0000 (20:53 +0000)
* pt.c (instantiate_class_template): Increment
processing_template_decl when substituting into a member class
template.

PR c++/17132
* g++.dg/template/memclass3.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@89778 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/memclass3.C [new file with mode: 0644]

index ee2ae82..2edaa40 100644 (file)
@@ -1,3 +1,10 @@
+2004-10-28  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/17132
+       * pt.c (instantiate_class_template): Increment
+       processing_template_decl when substituting into a member class
+       template.
+
 2004-10-27  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/17435
index 99f4e7b..eb44e64 100644 (file)
@@ -5621,14 +5621,28 @@ instantiate_class_template (tree type)
              tree tag = t;
              tree name = TYPE_IDENTIFIER (tag);
              tree newtag;
-
+             bool class_template_p;
+
+             class_template_p = (TREE_CODE (tag) != ENUMERAL_TYPE
+                                 && TYPE_LANG_SPECIFIC (tag)
+                                 && CLASSTYPE_IS_TEMPLATE (tag));
+             /* If the member is a class template, then -- even after
+                substituition -- there may be dependent types in the
+                template argument list for the class.  We increment
+                PROCESSING_TEMPLATE_DECL so that dependent_type_p, as
+                that function will assume that no types are dependent
+                when outside of a template.  */
+             if (class_template_p)
+               ++processing_template_decl;
              newtag = tsubst (tag, args, tf_error, NULL_TREE);
+             if (class_template_p)
+               --processing_template_decl;
              if (newtag == error_mark_node)
                continue;
 
              if (TREE_CODE (newtag) != ENUMERAL_TYPE)
                {
-                 if (TYPE_LANG_SPECIFIC (tag) && CLASSTYPE_IS_TEMPLATE (tag))
+                 if (class_template_p)
                    /* Unfortunately, lookup_template_class sets
                       CLASSTYPE_IMPLICIT_INSTANTIATION for a partial
                       instantiation (i.e., for the type of a member
index 7b1378a..556d330 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-28  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/17132
+       * g++.dg/template/memclass3.C: New test.
+
 2004-10-28  Adam Nemet  <anemet@lnxw.com>
 
        PR middle-end/18160  
diff --git a/gcc/testsuite/g++.dg/template/memclass3.C b/gcc/testsuite/g++.dg/template/memclass3.C
new file mode 100644 (file)
index 0000000..8230b94
--- /dev/null
@@ -0,0 +1,39 @@
+// PR c++/17132
+
+template <typename T>
+struct has_deref
+{
+    struct impl
+    {
+        template <
+            typename Type,
+            typename Type::reference (Type::*Func)(void) const>
+        struct func_tag;
+
+        template <typename Type>
+        static char (& test(
+            Type *,
+            func_tag<Type, &Type::operator*> * = 0
+        ))[2];
+        static char test(void *);
+    };
+
+    static const bool value = (sizeof(impl::test((T *) 0)) == 2);
+};
+
+template <typename T>
+struct container
+{
+    struct iterator
+    {
+        typedef T & reference;
+        reference operator*() const;
+    };
+};
+
+int main()
+{
+    typedef container<int>::iterator iter;
+    int result = has_deref<iter>::value;
+    return result;
+}