aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/cp-gimplify.c5
-rw-r--r--gcc/testsuite/g++.dg/inherit/thunk5.C22
3 files changed, 32 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5d2cc80..dcd0d3f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2005-11-30 Jason Merrill <jason@redhat.com>
+
+ PR c++/21123
+ * cp-gimplify.c (cp_genericize_r): Don't dereference invisible reference
+ parms in a thunk.
+
2005-11-30 Ben Elliston <bje@au.ibm.com>
* typeck.c (build_x_unary_op): Correct spelling in error message.
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index a4d59f5..aa71746 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -596,7 +596,10 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
tree stmt = *stmt_p;
struct pointer_set_t *p_set = (struct pointer_set_t*) data;
- if (is_invisiref_parm (stmt))
+ if (is_invisiref_parm (stmt)
+ /* Don't dereference parms in a thunk, pass the references through. */
+ && !(DECL_THUNK_P (current_function_decl)
+ && TREE_CODE (stmt) == PARM_DECL))
{
*stmt_p = convert_from_reference (stmt);
*walk_subtrees = 0;
diff --git a/gcc/testsuite/g++.dg/inherit/thunk5.C b/gcc/testsuite/g++.dg/inherit/thunk5.C
new file mode 100644
index 0000000..05dba36
--- /dev/null
+++ b/gcc/testsuite/g++.dg/inherit/thunk5.C
@@ -0,0 +1,22 @@
+// PR c++/21123
+
+struct A
+{
+ A(const A &a);
+ const A& operator=(const A& a);
+};
+
+struct B
+{
+ virtual A f(A);
+};
+
+struct C : virtual B
+{
+ virtual A f(A);
+};
+
+A C::f(A a)
+{
+ return a;
+}