From 44d10c10029bc5bec8fb352c6270b07f0d4d82e8 Mon Sep 17 00:00:00 2001 From: Paul Brook Date: Wed, 4 Aug 2004 15:33:51 +0000 Subject: target-def.h (TARGET_CXX_CDTOR_RETURNS_THIS): Define. gcc/ * target-def.h (TARGET_CXX_CDTOR_RETURNS_THIS): Define. (TARGET_CXX): Use it. * target.h (struct gcc_target): Add cdtor_returns_this. * config/arm/arm.c (arm_cxx_cdtor_returns_this): New function. (TARGET_CXX_CDTOR_RETURNS_THIS): Define. * doc/tm.texi: Document TARGET_CXX_CDTOR_RETURNS_THIS. gcc/cp/ * Make-lang.in (cp/semantics.o, cp/optimize.o): Depend on TARGET_H. * cp-tree.h (struct language_function): Rename x_dtor_label to x_cdtor_label. (dtor_label): Rename ... (cdtor_label): ... to this. * decl.c (begin_constructor_body): Remove. (check_special_function_return_type): Maybe change the return type. (grokdeclarator): Pass the class type. (start_preparsed_function): Constructors may need a return label. (finish_constructor_body, finish_destructor_body): Set the return value. (begin_function_body): Don't call begin_constructor_body. (finish_function): Don't warn for constructors or destructors. (implicitly_declare_fn): Maybe change the return type. * optimize.c: Include target.h. (maybe_clone_body): Remap the function result. * semantics.c: Include target.h. (finish_return_stmt): Maybe jump to return label for constructors. From-SVN: r85561 --- gcc/cp/semantics.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 606fe5f..cf61c22 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -45,6 +45,7 @@ #include "cgraph.h" #include "tree-iterator.h" #include "vec.h" +#include "target.h" /* There routines provide a modular interface to perform many parsing operations. They may therefore be used during actual parsing, or @@ -703,13 +704,15 @@ finish_return_stmt (tree expr) expr = check_return_expr (expr); if (!processing_template_decl) { - if (DECL_DESTRUCTOR_P (current_function_decl)) + if (DECL_DESTRUCTOR_P (current_function_decl) + || (DECL_CONSTRUCTOR_P (current_function_decl) + && targetm.cxx.cdtor_returns_this ())) { /* Similarly, all destructors must run destructors for base-classes before returning. So, all returns in a destructor get sent to the DTOR_LABEL; finish_function emits code to return a value there. */ - return finish_goto_stmt (dtor_label); + return finish_goto_stmt (cdtor_label); } } -- cgit v1.1