re PR c++/20465 (error: no matching function for call)
authorNathan Sidwell <nathan@codesourcery.com>
Tue, 22 Mar 2005 09:30:22 +0000 (09:30 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 22 Mar 2005 09:30:22 +0000 (09:30 +0000)
cp:
PR c++/20465
PR c++/20381
* typeck.c (build_ptrmemfunc): Allow OFFSET_REF when processing a
template.
testsuite:
PR c++/20465
PR c++/20381
* g++.dg/template/ptrmem12.C: New.

From-SVN: r96862

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

index 1f79100a21d9adc218c961e97df4b30261239d9c..ddac9f88769843a432bcccee6983bec51375169e 100644 (file)
@@ -1,3 +1,10 @@
+2005-03-22  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/20465
+       PR c++/20381
+       * typeck.c (build_ptrmemfunc): Allow OFFSET_REF when processing a
+       template.
+
 2005-03-21  Paolo Carlini  <pcarlini@suse.de>
 
        PR c++/20461
index c2adb1c7fd469856d37702088f060698d92d060a..0ddf8f25e3ebc754f5283adb7000ded77498c765 100644 (file)
@@ -5683,7 +5683,10 @@ build_ptrmemfunc (tree type, tree pfn, int force, bool c_cast_p)
     return instantiate_type (type, pfn, tf_error | tf_warning);
 
   fn = TREE_OPERAND (pfn, 0);
-  gcc_assert (TREE_CODE (fn) == FUNCTION_DECL);
+  gcc_assert (TREE_CODE (fn) == FUNCTION_DECL
+             /* In a template, we will have preserved the
+                OFFSET_REF.  */
+             || (processing_template_decl && TREE_CODE (fn) == OFFSET_REF));
   return make_ptrmem_cst (to_type, fn);
 }
 
index 0a73ba3e4b73c7e220b69e2b334d4a4478be7744..e7222ef6e975d9e51748680af4f8adb76684d248 100644 (file)
@@ -1,3 +1,9 @@
+2005-03-22  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/20465
+       PR c++/20381
+       * g++.dg/template/ptrmem12.C: New.
+
 2005-03-22  Hans-Peter Nilsson  <hp@axis.com>
 
        PR rtl-optimization/20527
diff --git a/gcc/testsuite/g++.dg/template/ptrmem12.C b/gcc/testsuite/g++.dg/template/ptrmem12.C
new file mode 100644 (file)
index 0000000..717b869
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright (C) 2005 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 17 Mar 2005 <nathan@codesourcery.com>
+
+// PR 20465
+// Origin: Matthias Klose <doko@debian.org>
+//        Andrew Pinski <pinskia@gcc.gnu.org>
+
+template <class _Ret, class _Tp>
+void mem_fun_ref(_Ret (_Tp::*__f)());
+
+struct A {
+  double f();
+};
+
+void h ()
+{
+  mem_fun_ref(&A::f);
+}
+
+template <class T>
+void f()
+{
+  mem_fun_ref(&A::f);
+}
+
+void g()
+{
+  f<int>();
+}