This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
patch to fix PR 5879
- From: Adam Megacz <patches at lists dot megacz dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 08 Mar 2002 22:52:32 -0800
- Subject: patch to fix PR 5879
- Organization: Myself
This patch backs out a change made in December which causes a
regression. Please see the PR and
http://gcc.gnu.org/ml/java/2002-03/msg00072.html for more detail.
If there are no objections, I would like to apply it to the branch and
trunk.
- a
Index: semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.252
diff -u -r1.252 semantics.c
--- semantics.c 2002/02/22 17:42:19 1.252
+++ semantics.c 2002/03/06 20:01:37
@@ -2550,6 +2550,7 @@
genrtl_finish_function (fn)
tree fn;
{
+ tree no_return_label = NULL_TREE;
tree t;
#if 0
@@ -2578,10 +2579,59 @@
/* Clean house because we will need to reorder insns here. */
do_pending_stack_adjust ();
- /* If we have a named return value, we need to force a return so that
- the return register is USEd. */
- if (DECL_NAME (DECL_RESULT (fn)))
+ if (!dtor_label && !DECL_CONSTRUCTOR_P (fn)
+ && return_label != NULL_RTX
+ && ! DECL_NAME (DECL_RESULT (current_function_decl)))
+ no_return_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+
+ /* If this function is supposed to return a value, ensure that
+ we do not fall into the cleanups by mistake. The end of our
+ function will look like this:
+
+ user code (may have return stmt somewhere)
+ goto no_return_label
+ cleanup_label:
+ cleanups
+ goto return_label
+ no_return_label:
+ NOTE_INSN_FUNCTION_END
+ return_label:
+ things for return
+
+ If the user omits a return stmt in the USER CODE section, we
+ will have a control path which reaches NOTE_INSN_FUNCTION_END.
+ Otherwise, we won't. */
+ if (no_return_label)
+ {
+ DECL_CONTEXT (no_return_label) = fn;
+ DECL_INITIAL (no_return_label) = error_mark_node;
+ DECL_SOURCE_FILE (no_return_label) = input_filename;
+ DECL_SOURCE_LINE (no_return_label) = lineno;
+ expand_goto (no_return_label);
+ }
+
+ if (cleanup_label)
+ {
+ /* Remove the binding contour which is used to catch
+ cleanup-generated temporaries. */
+ expand_end_bindings (0, 0, 0);
+ poplevel (0, 0, 0);
+
+ /* Emit label at beginning of cleanup code for parameters. */
+ emit_label (cleanup_label);
+ }
+
+ /* Finish building code that will trigger warnings if users forget
+ to make their functions return values. */
+ if (return_label)
emit_jump (return_label);
+ if (no_return_label)
+ {
+ /* We don't need to call `expand_*_return' here because we don't
+ need any cleanups here--this path of code is only for error
+ checking purposes. */
+ expand_label (no_return_label);
+ }
/* We hard-wired immediate_size_expand to zero in start_function.
Expand_function_end will decrement this variable. So, we set the