This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] PR c++/25369: backport to 3.4 branch
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Date: Tue, 31 Jan 2006 21:20:17 +0100 (CET)
- Subject: [patch] PR c++/25369: backport to 3.4 branch
The following patch is a straightforward backport of Mark's patch
http://gcc.gnu.org/ml/gcc-patches/2005-12/msg01748.html
for PR c++/25369 (link-failure because an inline-function is not
marked as used, a regression from gcc 3.4.4) to the 3.4 branch.
Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for the 3.4 branch?
Regards,
Volker
:ADDPATCH C++:
2006-01-31 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.
===================================================================
--- gcc/gcc/cp/pt.c (revision 110426)
+++ gcc/gcc/cp/pt.c (working copy)
@@ -7807,6 +7807,10 @@
in_decl),
tsubst (TREE_TYPE (t), args, complain, in_decl));
+ case OFFSET_REF:
+ mark_used (TREE_OPERAND (t, 1));
+ return t;
+
default:
return t;
}
===================================================================
--- gcc/gcc/cp/decl2.c (revision 110426)
+++ gcc/gcc/cp/decl2.c (working copy)
@@ -2967,6 +2967,18 @@
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;
===================================================================
2006-01-31 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.
===================================================================
--- gcc/gcc/testsuite/g++.dg/template/ptrmem16.C 2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/g++.dg/template/ptrmem16.C 2006-01-31 15:48:45 +0100
@@ -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;
+}
+
+
===================================================================