This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[4.0 committed] PR c/23165
- From: ja2morri at csclub dot uwaterloo dot ca (James A. Morrison)
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 06 Sep 2005 02:09:52 -0400
- Subject: [4.0 committed] PR c/23165
Hi,
This is another 4.0 regression that has had a fix on mainline for a while
now. The only change from the mainline patch is that warning("..."...) is used
instead of warning(0, ...). Bootstrapped and regtested on ia64-linux with
no new regressions.
--
Thanks,
Jim
http://www.csclub.uwaterloo.ca/~ja2morri/
http://phython.blogspot.com
http://open.nit.ca/wiki/?page=jim
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ChangeLog,v
retrieving revision 2.7592.2.411
diff -u -p -r2.7592.2.411 ChangeLog
--- ChangeLog 6 Sep 2005 05:36:03 -0000 2.7592.2.411
+++ ChangeLog 6 Sep 2005 05:48:41 -0000
@@ -1,5 +1,12 @@
2005-09-05 James A. Morrison <phython@gcc.gnu.org>
+ PR c/23161
+ PR c/23165
+ * c-typeck.c (c_finish_if_stmt): Look into STATEMENT_LISTs to see
+ if the if is really empty.
+
+2005-09-05 James A. Morrison <phython@gcc.gnu.org>
+
PR c++/23225
* tree.c (build_pointer_type_for_mode): Robustify.
Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.419.2.11
diff -u -p -r1.419.2.11 c-typeck.c
--- c-typeck.c 1 Aug 2005 01:34:09 -0000 1.419.2.11
+++ c-typeck.c 6 Sep 2005 05:48:45 -0000
@@ -6852,20 +6852,31 @@ c_finish_if_stmt (location_t if_locus, t
/* Diagnose ";" via the special empty statement node that we create. */
if (extra_warnings)
{
- if (TREE_CODE (then_block) == NOP_EXPR && !TREE_TYPE (then_block))
+ tree *inner_then = &then_block, *inner_else = &else_block;
+
+ if (TREE_CODE (*inner_then) == STATEMENT_LIST
+ && STATEMENT_LIST_TAIL (*inner_then))
+ inner_then = &STATEMENT_LIST_TAIL (*inner_then)->stmt;
+ if (*inner_else && TREE_CODE (*inner_else) == STATEMENT_LIST
+ && STATEMENT_LIST_TAIL (*inner_else))
+ inner_else = &STATEMENT_LIST_TAIL (*inner_else)->stmt;
+
+ if (TREE_CODE (*inner_then) == NOP_EXPR && !TREE_TYPE (*inner_then))
{
- if (!else_block)
+ if (!*inner_else)
warning ("%Hempty body in an if-statement",
- EXPR_LOCUS (then_block));
- then_block = alloc_stmt_list ();
+ EXPR_LOCUS (*inner_then));
+
+ *inner_then = alloc_stmt_list ();
}
- if (else_block
- && TREE_CODE (else_block) == NOP_EXPR
- && !TREE_TYPE (else_block))
+ if (*inner_else
+ && TREE_CODE (*inner_else) == NOP_EXPR
+ && !TREE_TYPE (*inner_else))
{
warning ("%Hempty body in an else-statement",
- EXPR_LOCUS (else_block));
- else_block = alloc_stmt_list ();
+ EXPR_LOCUS (*inner_else));
+
+ *inner_else = alloc_stmt_list ();
}
}
Index: testsuite/ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/ChangeLog,v
retrieving revision 1.5084.2.379
diff -u -p -r1.5084.2.379 ChangeLog
--- testsuite/ChangeLog 6 Sep 2005 05:36:47 -0000 1.5084.2.379
+++ testsuite/ChangeLog 6 Sep 2005 05:49:00 -0000
@@ -1,5 +1,11 @@
2005-09-05 James A. Morrison <phython@gcc.gnu.org>
+ PR c/23161
+ PR c/23165
+ * gcc.dg/pr23165.c: New test.
+
+2005-09-05 James A. Morrison <phython@gcc.gnu.org>
+
PR c++/23225
* g++.dg/parse/crash27.C: New test.