diff options
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/optimize.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/inline11.C | 33 |
3 files changed, 44 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f1ea463d2f0..17000bd4a58 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2000-06-12 Mark Mitchell <mark@codesourcery.com> + + * optimize.c (expand_call_inline): Don't recurse into the code + used to initialize the parameters more than once. + 2000-06-11 Mark Mitchell <mark@codesourcery.com> * mangle.c (NESTED_TEMPLATE_MATCH): Fix typo in comment. diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index fa8d9e821a0..b803627ed68 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -612,6 +612,7 @@ expand_call_inline (tp, walk_subtrees, data) tree scope_stmt; tree use_stmt; tree arg_inits; + tree *inlined_body; splay_tree st; /* See what we've got. */ @@ -724,8 +725,10 @@ expand_call_inline (tp, walk_subtrees, data) /* After we've initialized the parameters, we insert the body of the function itself. */ - STMT_EXPR_STMT (expr) - = chainon (STMT_EXPR_STMT (expr), copy_body (id)); + inlined_body = &STMT_EXPR_STMT (expr); + while (*inlined_body) + inlined_body = &TREE_CHAIN (*inlined_body); + *inlined_body = copy_body (id); /* Close the block for the parameters. */ scope_stmt = build_min_nt (SCOPE_STMT, DECL_INITIAL (fn)); @@ -771,7 +774,7 @@ expand_call_inline (tp, walk_subtrees, data) TREE_USED (*tp) = 1; /* Recurse into the body of the just inlined function. */ - expand_calls_inline (tp, id); + expand_calls_inline (inlined_body, id); VARRAY_POP (id->fns); /* Don't walk into subtrees. We've already handled them above. */ diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline11.C b/gcc/testsuite/g++.old-deja/g++.other/inline11.C new file mode 100644 index 00000000000..9556fc3b172 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline11.C @@ -0,0 +1,33 @@ +// Origin: Jakub Jelinek <jakub@redhat.com> +// Special g++ Options: -O2 + +class baz +{ +public: + baz& operator += (const baz&); +}; + +inline baz& baz::operator += (const baz& r) +{ + return *this; +} + +inline baz operator + (int x, const baz& y) +{ + return y; +} + +static inline baz bar (int alpha); +static inline baz foo (int alpha) +{ + baz tmp = alpha + foo (alpha); + tmp += alpha + bar (alpha); + return tmp; +} + +static inline baz bar (int alpha) +{ + baz tmp = alpha + bar (alpha); + tmp += alpha + foo (alpha); + return tmp; +} |