This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[3.4 PATCH] Fix PR middle-end/17827
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 6 Dec 2004 17:37:53 +0100
- Subject: [3.4 PATCH] Fix PR middle-end/17827
Hi,
This is a fallout of the fix for PR c/10175, a regression present on the 3.4
branch. In corner cases like:
void foo()
{
if (false)
if (int i=0)
int j=i;
}
the compiler doesn't expand the condition (int i =0) anymore, so i is never
allocated as a local variable and the compiler ICEs in make_decl_rtl.
The proposed fix is to expand the condition if it contains a declaration; it
turns out that this is exactly the purpose of expand_cond. This appears to
work, but I'm not very comfortable with the patch.
Bootstrapped/regtested on amd64-mandrake-linux-gnu.
2004-12-05 Eric Botcazou <ebotcazou@libertysurf.fr>
Fix PR middle-end/17827
* c-semantics.c (expand_unreachable_if_stmt): Invoke
expand_cond on the condition.
2004-12-05 Volker Reichelt <reichelt@gcc.gnu.org>
* g++dg/other/unreachable-1.C
--
Eric Botcazou
Index: c-semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-semantics.c,v
retrieving revision 1.74.4.3
diff -u -p -r1.74.4.3 c-semantics.c
--- c-semantics.c 24 Aug 2004 04:02:34 -0000 1.74.4.3
+++ c-semantics.c 5 Dec 2004 10:22:50 -0000
@@ -937,6 +937,9 @@ expand_unreachable_if_stmt (tree t)
return true;
}
+ /* Account for declarations as conditions. */
+ expand_cond (IF_COND (t));
+
if (THEN_CLAUSE (t) && ELSE_CLAUSE (t))
{
n = expand_unreachable_stmt (THEN_CLAUSE (t), 0);
// PR middle-end/17827
// Origin: André Woebbeking <Woebbeking@web.de>
// Testcase by Volker Reichelt <reichelt@gcc.gnu.org>
// { dg-do compile }
void foo()
{
if (false)
if (int i=0)
int j=i;
}