PR c++/34206
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Dec 2007 22:25:20 +0000 (22:25 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Dec 2007 22:25:20 +0000 (22:25 +0000)
        * pt.c (tsubst_aggr_type): Do nothing if the type already doesn't
        use template parms.
        (dependent_type_p_r): Handle the domain of an array.

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

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

index a3bc0ab..c7f0fc4 100644 (file)
@@ -1,3 +1,10 @@
+2007-12-18  Jason Merrill  <jason@redhat.com>
+
+       PR c++/34206
+       * pt.c (tsubst_aggr_type): Do nothing if the type already doesn't 
+       use template parms.
+       (dependent_type_p_r): Handle the domain of an array.
+
 2007-12-18  Douglas Gregor  <doug.gregor@gmail.com>
             Jakub Jelinek  <jakub@redhat.com>
        
index 011ef2f..9f87778 100644 (file)
@@ -7638,7 +7638,7 @@ tsubst_aggr_type (tree t,
       /* Else fall through.  */
     case ENUMERAL_TYPE:
     case UNION_TYPE:
-      if (TYPE_TEMPLATE_INFO (t))
+      if (TYPE_TEMPLATE_INFO (t) && uses_template_parms (t))
        {
          tree argvec;
          tree context;
@@ -15455,13 +15455,18 @@ dependent_type_p_r (tree type)
   if (TREE_CODE (type) == ARRAY_TYPE)
     {
       if (TYPE_DOMAIN (type)
-         && ((value_dependent_expression_p
-              (TYPE_MAX_VALUE (TYPE_DOMAIN (type))))
-             || (type_dependent_expression_p
-                 (TYPE_MAX_VALUE (TYPE_DOMAIN (type))))))
+         && dependent_type_p (TYPE_DOMAIN (type)))
        return true;
       return dependent_type_p (TREE_TYPE (type));
     }
+  else if (TREE_CODE (type) == INTEGER_TYPE
+          && !TREE_CONSTANT (TYPE_MAX_VALUE (type)))
+    {
+      /* If this is the TYPE_DOMAIN of an array type, consider it
+        dependent.  */
+      return (value_dependent_expression_p (TYPE_MAX_VALUE (type))
+             || type_dependent_expression_p (TYPE_MAX_VALUE (type)));
+    }
 
   /* -- a template-id in which either the template name is a template
      parameter ...  */
diff --git a/gcc/testsuite/g++.dg/template/typedef8.C b/gcc/testsuite/g++.dg/template/typedef8.C
new file mode 100644 (file)
index 0000000..f132606
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/34206
+
+template<class _T1, class _T2> struct pair { };
+template <class T0, class T1> struct tuple {
+  template <class U1, class U2>
+  tuple& operator=(const pair<U1, U2>& k) { }
+};
+template<class T1, class T2> inline tuple<T1&, T2&> tie(T1& t1, T2& t2) { }
+
+template <class T> struct A
+{   
+  typedef T type;
+  pair<type, type> f();
+};
+
+void g(A<int> a)
+{
+  typedef A<int>::type type;
+  type begin1, end1;
+  tie(begin1, end1) = a.f();
+}