]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport:
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Wed, 1 Feb 2006 11:57:42 +0000 (11:57 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Wed, 1 Feb 2006 11:57:42 +0000 (11:57 +0000)
2005-12-22  Mark Mitchell  <mark@codesourcery.com>

PR c++/25369
* pt.c (tsubst_copy): Call mark_used on the member referenced by an
OFFSET_REF.
* decl2.c (mark_used): Accept BASELINKs.

* g++.dg/template/ptrmem16.C: New test.

From-SVN: r110473

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

index 5ea2f7ddfda8e93bf4717bd3c3af2db416517781..da47e4854b19264d1ac68a4c5e3ccead833b340f 100644 (file)
@@ -1,3 +1,13 @@
+2006-02-01  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       Backport:
+       2005-12-22  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/25369
+       * pt.c (tsubst_copy): Call mark_used on the member referenced by an
+       OFFSET_REF.
+       * decl2.c (mark_used): Accept BASELINKs.
+
 2006-02-01  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        Backport:
index 55d68a2e6016bec3139ddfb9059019bf0c80c4b7..abd86f7abecc5552c6f71d7b7a9ee389c440b205 100644 (file)
@@ -2967,6 +2967,18 @@ check_default_args (tree x)
 void
 mark_used (tree decl)
 {
+  /* If DECL is a BASELINK for a single function, then treat it just
+     like the DECL for the function.  Otherwise, if the BASELINK is
+     for an overloaded function, we don't know which function was
+     actually used until after overload resolution.  */
+  if (TREE_CODE (decl) == BASELINK)
+    {
+      decl = BASELINK_FUNCTIONS (decl);
+      if (really_overloaded_fn (decl))
+       return;
+      decl = OVL_CURRENT (decl);
+    }
+
   TREE_USED (decl) = 1;
   if (processing_template_decl || skip_evaluation)
     return;
index aca2dcd5361846d31cbe1226d46b65621203eb47..0ae2d23e70f8f570ba0c67e693321c477dc73779 100644 (file)
@@ -7807,6 +7807,10 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
                                          in_decl),
                             tsubst (TREE_TYPE (t), args, complain, in_decl));
 
+    case OFFSET_REF:
+      mark_used (TREE_OPERAND (t, 1));
+      return t;
+
     default:
       return t;
     }
index 4cad37618e17699800acf63afa0348aaeb56d5f8..6040ed2d972f3df809329e7386d44394ca3c00e1 100644 (file)
@@ -1,3 +1,11 @@
+2006-02-01  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       Backport:
+       2005-12-22  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/25369
+       * g++.dg/template/ptrmem16.C: New test.
+
 2006-02-01  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        Backport:
diff --git a/gcc/testsuite/g++.dg/template/ptrmem16.C b/gcc/testsuite/g++.dg/template/ptrmem16.C
new file mode 100644 (file)
index 0000000..caf5dd0
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c++/25369
+// { dg-do link }
+
+template <typename> struct A 
+{
+  void foo() {}
+};
+
+void bar(void (A<int>::*)()) {}
+
+template <int> void baz()
+{
+  bar(&A<int>::foo);
+}
+
+int main()
+{
+  baz<0>();
+  return 0;
+}
+
+