This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] fix PR c++/20624 (really middle-end)


The problem here is that from the C++ front-end we get:
COND_EXPR < TRUTH_ANDIF <a, b>,
CLEANUP_POINT_EXPR <RETURN_EXPR xxx>,
CLEANUP_POINT_EXPR <RETURN_EXPR xxx> >
and block_may_fallthru does not look passed CLEANUP_POINT_EXPR so returns
we can fallthru which in term causes the eh lowering to think there are
two ways of exiting a finally block. Which causes use to have a switch
statement and a basic block which returns with no value so we get a warning.


There are two ways of fixing the problem here.  The easy way is to
teach block_may_fallthru of CLEAN_POINT_EXRP.  The way is to remove
statements after a return and gotos up till a label and then remove
unused compiler generated labels (which is already a FIXME/???? in
remove_useless_stmts_label.  This patch does the earlier one and fixes
the issue in the PR and actually saves one label/decl while compiling
PR8361.


I have a separate patch which implements the first part of the second way of fixing the issue which I will submit for 4.2. It actually saves us from creating two basic blocks while compile PR 8361.

OK for 4.0 and mainline? Bootstrapped and tested on powerpc-darwin with
no regressions.

Thanks,
Andrew Pinski

ChangeLog:
* gimple-low.c (block_may_fallthru): Handle CLEANUP_POINT_EXPR by looking
passed it.


testsuite/ChangeLog:
	* g++.dg/warn/Wreturn-3.C: New test


Attachment: t.diff.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]