diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ee37b654aed..743854196a0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2009-07-29 Richard Guenther + + PR c++/40834 + * cp-gimplify.c (cp_genericize_r): Properly walk the BIND_EXPR + vars. + 2009-07-26 Simon Martin PR c++/40749 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 184ae9e3072..b4d36de44ca 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -810,7 +810,6 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) cp_walk_tree (&BIND_EXPR_BODY (stmt), cp_genericize_r, data, NULL); VEC_pop (tree, wtd->bind_expr_stack); - *walk_subtrees = 0; } else if (TREE_CODE (stmt) == USING_STMT) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2c64bb6e555..0e55fabebaf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-07-29 Richard Guenther + + PR c++/40834 + * g++.dg/torture/pr40834.C: New testcase. + 2009-07-29 Michael Matz PR middle-end/40830 diff --git a/gcc/testsuite/g++.dg/torture/pr40834.C b/gcc/testsuite/g++.dg/torture/pr40834.C new file mode 100644 index 00000000000..67d3028532a --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr40834.C @@ -0,0 +1,52 @@ +/* { dg-do run } */ + +extern "C" void abort (void); +class XalanDOMString +{ +public: + int y; +}; + +class XObject +{ +public: + const XalanDOMString& str() const { return x; } + XalanDOMString x; +}; + +class XObjectPtr +{ +public: + XObjectPtr(const XObjectPtr& theSource) + { + m_xobjectPtr = theSource.m_xobjectPtr; + } + const XObject* operator->() const + { + return m_xobjectPtr; + }; + XObjectPtr(XObject *p) { m_xobjectPtr = p; } + XObject* m_xobjectPtr; +}; + +class FunctionSubstringBefore +{ +public: + int execute( const XObjectPtr arg1) const + { + const XalanDOMString& theFirstString = arg1->str(); + return theFirstString.y; + } +}; + +int +main () +{ + XObject x; + XObjectPtr y (&x); + x.x.y = -1; + FunctionSubstringBefore z; + if (z.execute (y) != -1) + abort (); + return 0; +}