OSDN Git Service

PR c++/10939
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 20 Jun 2003 05:52:43 +0000 (05:52 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 20 Jun 2003 05:52:43 +0000 (05:52 +0000)
* pt.c (tsubst_decl): Do not try to substitute into non-dependent
functions.
(value_dependent_expression_p): Correct logic for FUNCTION_DECLs.

PR c++/10939
* g++.dg/template/func1.C: New test.

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

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

index ba7bc03..32532d8 100644 (file)
@@ -1,5 +1,10 @@
 2003-06-19  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/10939
+       * pt.c (tsubst_decl): Do not try to substitute into non-dependent
+       functions.
+       (value_dependent_expression_p): Correct logic for FUNCTION_DECLs.
+
        PR c++/9649
        * cp-tree.h (pushdecl_class_level): Change prototype.
        (push_class_level_binding): Likewise.
index b5ac7b2..1a43d02 100644 (file)
@@ -5909,6 +5909,17 @@ tsubst_decl (tree t, tree args, tree type, tsubst_flags_t complain)
        if (TREE_CODE (DECL_TI_TEMPLATE (t)) == TEMPLATE_DECL)
          {
            tree spec;
+           bool dependent_p;
+
+           /* If T is not dependent, just return it.  We have to
+              increment PROCESSING_TEMPLATE_DECL because
+              value_dependent_expression_p assumes that nothing is
+              dependent when PROCESSING_TEMPLATE_DECL is zero.  */
+           ++processing_template_decl;
+           dependent_p = value_dependent_expression_p (t);
+           --processing_template_decl;
+           if (!dependent_p)
+             return t;
 
            /* Calculate the most general template of which R is a
               specialization, and the complete set of arguments used to
@@ -11368,8 +11379,8 @@ value_dependent_expression_p (tree expression)
 
   /* A name declared with a dependent type.  */
   if (TREE_CODE (expression) == LOOKUP_EXPR
-      || (DECL_P (expression)
-         && dependent_type_p (TREE_TYPE (expression))))
+      || (DECL_P (expression) 
+         && type_dependent_expression_p (expression)))
     return true;
   /* A non-type template parameter.  */
   if ((TREE_CODE (expression) == CONST_DECL
index 2b4942c..1e4cafa 100644 (file)
@@ -1,5 +1,8 @@
 2003-06-19  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/10939
+       * g++.dg/template/func1.C: New test.
+
        PR c++/9649
        * g++.dg/template/static4.C: New test.
        * g++.old-deja/g++.other/anon7.C: Remove spurious error messages.
diff --git a/gcc/testsuite/g++.dg/template/func1.C b/gcc/testsuite/g++.dg/template/func1.C
new file mode 100644 (file)
index 0000000..0d16770
--- /dev/null
@@ -0,0 +1,13 @@
+template <typename T1,typename T2>
+inline void f(const T1&,const T2&) { }
+
+template <typename T1,typename T2,void F(const T1&,const T2&)>
+struct A {
+    template <typename T> void g(T& i) { }
+};
+
+int main() {
+    int i;
+    A<int,int,f> a;
+    a.g(i);
+}