diff options
| author | Mark Mitchell <mark@codesourcery.com> | 1999-09-25 18:10:04 +0000 |
|---|---|---|
| committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1999-09-25 18:10:04 +0000 |
| commit | efee38a99ac1639e29a1f08235756becdbeca01c (patch) | |
| tree | 29d37f53a0796acd0b38eaf7a9a35991a1aa4bf6 /gcc/cp/semantics.c | |
| parent | 5a657fc371aefb7648ad42cc9db9187032a80809 (diff) | |
| download | gcc-efee38a99ac1639e29a1f08235756becdbeca01c.zip gcc-efee38a99ac1639e29a1f08235756becdbeca01c.tar.gz gcc-efee38a99ac1639e29a1f08235756becdbeca01c.tar.bz2 | |
cp-tree.h (check_return_expr): New function.
* cp-tree.h (check_return_expr): New function.
* decl.c (finish_constructor_body): New function.
(pushdecl): Put global friend functions in namespace binding
level, not the class binding level.
(finish_destructor_body): Make sure the dtor_label is always
defined. Fix typo in comment.
(finish_function): Move generation of constructor-termination code
to semantic-analysis time. Move generation of implicit `main'
return value to semantic-analysis time.
* semantics.c (finish_return_stmt): Generate goto's to
ctor_label/dtor_label here. Use check_return_expr to do semantic
analysis on the returned expression.
* typeck.c (maybe_warn_about_returning_address_of_local): New
function split out from c_expand_return.
(check_return_expr): Likewise.
(c_expand_return): Just generate the RTL for the return.
From-SVN: r29663
Diffstat (limited to 'gcc/cp/semantics.c')
| -rw-r--r-- | gcc/cp/semantics.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index cd48570..ac7856b 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -371,6 +371,33 @@ void finish_return_stmt (expr) tree expr; { + if (doing_semantic_analysis_p () && !processing_template_decl) + expr = check_return_expr (expr); + + if (doing_semantic_analysis_p () && !processing_template_decl) + { + if (DECL_CONSTRUCTOR_P (current_function_decl) && ctor_label) + { + /* Even returns without a value in a constructor must return + `this'. We accomplish this by sending all returns in a + constructor to the CTOR_LABEL; finish_function emits code to + return a value there. When we finally generate the real + return statement, CTOR_LABEL is no longer set, and we fall + through into the normal return-processing code below. */ + finish_goto_stmt (ctor_label); + return; + } + else if (DECL_DESTRUCTOR_P (current_function_decl)) + { + /* Similarly, all destructors must run destructors for + base-classes before returning. So, all returns in a + destructor get sent to the DTOR_LABEL; finsh_function emits + code to return a value there. */ + finish_goto_stmt (dtor_label); + return; + } + } + if (building_stmt_tree ()) add_tree (build_min_nt (RETURN_STMT, expr)); else |
