This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
maybe_build_cleanup langhook
- From: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 25 Mar 2002 18:12:25 +0000
- Subject: maybe_build_cleanup langhook
Bootstrapped and regtested x86 Linux. OK?
I'd also appreciate a review of the 5 langhooks here:
http://gcc.gnu.org/ml/gcc-patches/2002-03/msg01032.html
Thanks,
Neil.
* c-decl.c (maybe_build_cleanup): Remove.
* expr.c (expand_expr): Use langhook.
* langhooks-def.h (lhd_return_null_tree,
LANG_HOOKS_MAYBE_BUILD_CLEANUP): New.
(LANGHOOKS_INITIALIZER): Update.
* langhooks.c (lhd_return_null_tree): New.
* langhooks.h (struct lang_hooks): New hook.
* tree-inline.c (initialize_inlined_parameters): Use langhook.
* tree.h (maybe_build_cleanup): Remove.
ada:
* misc.c (maybe_build_cleanup): Remove.
cp:
* cp-tree.h (cxx_maybe_build_cleanup): New.
* decl.c (destroy_local_var, hack_incomplete_structures): Update.
(maybe_build_cleanup): Rename cxx_maybe_build_cleanup.
* tree.c (build_target_expr): Update.
f:
* com.c (maybe_build_cleanup): Remove.
java:
* decl.c (maybe_build_cleanup): Remove.
============================================================
Index: gcc/c-decl.c
--- gcc/c-decl.c 2002/03/24 12:27:28 1.308
+++ gcc/c-decl.c 2002/03/25 07:54:14
@@ -3657,17 +3657,6 @@ finish_decl (decl, init, asmspec_tree)
get_pending_sizes ();
}
-/* If DECL has a cleanup, build and return that cleanup here.
- This is a callback called by expand_expr. */
-
-tree
-maybe_build_cleanup (decl)
- tree decl ATTRIBUTE_UNUSED;
-{
- /* There are no cleanups in C. */
- return NULL_TREE;
-}
-
/* Given a parsed parameter declaration,
decode it into a PARM_DECL and push that on the current binding level.
Also, for the sake of forward parm decls,
============================================================
Index: gcc/expr.c
--- gcc/expr.c 2002/03/22 18:13:45 1.435
+++ gcc/expr.c 2002/03/25 07:54:37
@@ -8365,7 +8365,8 @@ expand_expr (exp, target, tmode, modifie
built here. */
if (TREE_OPERAND (exp, 2) == 0)
- TREE_OPERAND (exp, 2) = maybe_build_cleanup (slot);
+ TREE_OPERAND (exp, 2)
+ = (*lang_hooks.maybe_build_cleanup) (slot);
cleanups = TREE_OPERAND (exp, 2);
}
}
============================================================
Index: gcc/langhooks-def.h
--- gcc/langhooks-def.h 2002/03/21 18:39:13 1.14
+++ gcc/langhooks-def.h 2002/03/25 07:54:38
@@ -42,6 +42,7 @@ extern void lhd_do_nothing_t PARAMS ((tr
extern int lhd_decode_option PARAMS ((int, char **));
extern HOST_WIDE_INT lhd_get_alias_set PARAMS ((tree));
extern tree lhd_return_tree PARAMS ((tree));
+extern tree lhd_return_null_tree PARAMS ((tree));
extern int lhd_safe_from_p PARAMS ((rtx, tree));
extern int lhd_staticp PARAMS ((tree));
extern void lhd_clear_binding_stack PARAMS ((void));
@@ -81,6 +82,7 @@ tree lhd_tree_inlining_convert_parm_for_
#define LANG_HOOKS_STATICP lhd_staticp
#define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL lhd_do_nothing_t
#define LANG_HOOKS_UNSAVE_EXPR_NOW lhd_unsave_expr_now
+#define LANG_HOOKS_MAYBE_BUILD_CLEANUP lhd_return_null_tree
#define LANG_HOOKS_HONOR_READONLY false
#define LANG_HOOKS_PRINT_STATISTICS lhd_do_nothing
#define LANG_HOOKS_PRINT_XNODE lhd_print_tree_nothing
@@ -175,6 +177,7 @@ int lhd_tree_dump_type_quals PARAMS ((
LANG_HOOKS_STATICP, \
LANG_HOOKS_DUP_LANG_SPECIFIC_DECL, \
LANG_HOOKS_UNSAVE_EXPR_NOW, \
+ LANG_HOOKS_MAYBE_BUILD_CLEANUP, \
LANG_HOOKS_HONOR_READONLY, \
LANG_HOOKS_PRINT_STATISTICS, \
LANG_HOOKS_PRINT_XNODE, \
============================================================
Index: gcc/langhooks.c
--- gcc/langhooks.c 2002/03/21 23:15:27 1.21
+++ gcc/langhooks.c 2002/03/25 07:54:38
@@ -56,6 +56,15 @@ lhd_return_tree (t)
return t;
}
+/* Do nothing (return NULL_TREE). */
+
+tree
+lhd_return_null_tree (t)
+ tree t ATTRIBUTE_UNUSED;
+{
+ return NULL_TREE;
+}
+
/* Do nothing; the default hook to decode an option. */
int
============================================================
Index: gcc/langhooks.h
--- gcc/langhooks.h 2002/03/21 18:39:13 1.21
+++ gcc/langhooks.h 2002/03/25 07:54:40
@@ -180,6 +180,10 @@ struct lang_hooks
things are cleared out. */
tree (*unsave_expr_now) PARAMS ((tree));
+ /* Called by expand_expr to build and return the cleanup-expression
+ for the passed TARGET_EXPR. Return NULL if there is none. */
+ tree (*maybe_build_cleanup) PARAMS ((tree));
+
/* Nonzero if TYPE_READONLY and TREE_READONLY should always be honored. */
bool honor_readonly;
============================================================
Index: gcc/tree-inline.c
--- gcc/tree-inline.c 2002/03/21 18:39:16 1.18
+++ gcc/tree-inline.c 2002/03/25 07:54:43
@@ -562,7 +562,7 @@ initialize_inlined_parameters (id, args,
}
/* See if we need to clean up the declaration. */
- cleanup = maybe_build_cleanup (var);
+ cleanup = (*lang_hooks.maybe_build_cleanup) (var);
if (cleanup)
{
tree cleanup_stmt;
============================================================
Index: gcc/tree.h
--- gcc/tree.h 2002/03/21 18:39:16 1.317
+++ gcc/tree.h 2002/03/25 07:54:52
@@ -2641,12 +2641,6 @@ extern tree unsigned_type PARAMS ((tree
extern tree signed_type PARAMS ((tree));
-/* This function must be defined in the language-specific files.
- expand_expr calls it to build the cleanup-expression for a TARGET_EXPR.
- This is defined in a language-specific file. */
-
-extern tree maybe_build_cleanup PARAMS ((tree));
-
/* Given an expression EXP that may be a COMPONENT_REF or an ARRAY_REF,
look for nested component-refs or array-refs at constant positions
and find the ultimate containing object, which is returned. */
============================================================
Index: gcc/ada/misc.c
--- gcc/ada/misc.c 2002/03/20 07:58:31 1.24
+++ gcc/ada/misc.c 2002/03/25 07:54:55
@@ -406,18 +406,6 @@ gnat_init_gcc_eh ()
#endif
}
-
-/* If DECL has a cleanup, build and return that cleanup here.
- This is a callback called by expand_expr. */
-
-tree
-maybe_build_cleanup (decl)
- tree decl ATTRIBUTE_UNUSED;
-{
- /* There are no cleanups in C. */
- return NULL_TREE;
-}
-
/* Hooks for print-tree.c: */
static void
============================================================
Index: gcc/cp/cp-tree.h
--- gcc/cp/cp-tree.h 2002/03/21 18:39:27 1.694
+++ gcc/cp/cp-tree.h 2002/03/25 07:55:08
@@ -4241,6 +4241,7 @@ extern void end_input PARAMS ((void))
/* in tree.c */
extern tree stabilize_expr PARAMS ((tree, tree *));
extern tree cxx_unsave_expr_now PARAMS ((tree));
+extern tree cxx_maybe_build_cleanup PARAMS ((tree));
extern void init_tree PARAMS ((void));
extern int pod_type_p PARAMS ((tree));
extern tree canonical_type_variant PARAMS ((tree));
============================================================
Index: gcc/cp/decl.c
--- gcc/cp/decl.c 2002/03/23 09:30:26 1.880
+++ gcc/cp/decl.c 2002/03/25 07:55:41
@@ -8034,7 +8034,7 @@ destroy_local_var (decl)
return;
/* Compute the cleanup. */
- cleanup = maybe_build_cleanup (decl);
+ cleanup = cxx_maybe_build_cleanup (decl);
/* Record the cleanup required for this declaration. */
if (DECL_SIZE (decl) && cleanup)
@@ -14451,7 +14451,7 @@ hack_incomplete_structures (type)
{
tree cleanup;
expand_decl (decl);
- cleanup = maybe_build_cleanup (decl);
+ cleanup = cxx_maybe_build_cleanup (decl);
expand_decl_init (decl);
if (! expand_decl_cleanup (decl, cleanup))
error ("parser lost in parsing declaration of `%D'",
@@ -14479,7 +14479,7 @@ hack_incomplete_structures (type)
here. */
tree
-maybe_build_cleanup (decl)
+cxx_maybe_build_cleanup (decl)
tree decl;
{
tree type = TREE_TYPE (decl);
============================================================
Index: gcc/cp/tree.c
--- gcc/cp/tree.c 2002/03/21 23:15:38 1.274
+++ gcc/cp/tree.c 2002/03/25 07:55:47
@@ -234,7 +234,7 @@ build_target_expr (decl, value)
tree t;
t = build (TARGET_EXPR, TREE_TYPE (decl), decl, value,
- maybe_build_cleanup (decl), NULL_TREE);
+ cxx_maybe_build_cleanup (decl), NULL_TREE);
/* We always set TREE_SIDE_EFFECTS so that expand_expr does not
ignore the TARGET_EXPR. If there really turn out to be no
side-effects, then the optimizer should be able to get rid of
============================================================
Index: gcc/f/com.c
--- gcc/f/com.c 2002/03/23 20:00:10 1.160
+++ gcc/f/com.c 2002/03/25 07:56:17
@@ -14381,17 +14381,6 @@ mark_addressable (exp)
}
}
-/* If DECL has a cleanup, build and return that cleanup here.
- This is a callback called by expand_expr. */
-
-tree
-maybe_build_cleanup (decl)
- tree decl UNUSED;
-{
- /* There are no cleanups in Fortran. */
- return NULL_TREE;
-}
-
/* Exit a binding level.
Pop the level off, and restore the state of the identifier-decl mappings
that were in effect when this level was entered.
============================================================
Index: gcc/java/decl.c
--- gcc/java/decl.c 2002/03/20 07:58:40 1.122
+++ gcc/java/decl.c 2002/03/25 07:56:21
@@ -1565,17 +1565,6 @@ java_dup_lang_specific_decl (node)
DECL_LANG_SPECIFIC (node) = x;
}
-/* If DECL has a cleanup, build and return that cleanup here.
- This is a callback called by expand_expr. */
-
-tree
-maybe_build_cleanup (decl)
- tree decl ATTRIBUTE_UNUSED;
-{
- /* There are no cleanups in Java (I think). */
- return NULL_TREE;
-}
-
void
give_name_to_locals (jcf)
JCF *jcf;