This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH Re: [ast-optimizer-branch]: Simplify STMT_EXPR's
>>>>> "Jason" == Jason Merrill <jason@redhat.com> writes:
>>>>> "Diego" == Diego Novillo <dnovillo@redhat.com> writes:
>> What I meant is that variable 'saved_stmts_are_full_exprs_p' is a
>> local variable inside simplify_stmt() that is set but never used
>> in that function.
> Yep, that'll be fixed in a future patch. It doesn't currently matter.
It still doesn't matter, but here's a patch to restore it properly. It
also avoids a situation whereby simplify_expr_wfl could wrap things which
were on the pre list already.
2002-06-20 Jason Merrill <jason@redhat.com>
* c-simplify.c (simplify_expr_wfl): Only wrap pre and post stuff
that came from our subexpression.
(simplify_stmt): Restore stmts_are_full_exprs_p.
*** c-simplify.c.~1~ Thu Jun 20 10:46:38 2002
--- c-simplify.c Thu Jun 20 12:43:37 2002
*************** simplify_stmt (stmt_p)
*** 214,220 ****
case COMPOUND_STMT:
simplify_stmt (&COMPOUND_BODY (stmt));
stmt_p = &TREE_CHAIN (stmt);
! continue;
case FOR_STMT:
simplify_for_stmt (stmt, &pre);
--- 214,220 ----
case COMPOUND_STMT:
simplify_stmt (&COMPOUND_BODY (stmt));
stmt_p = &TREE_CHAIN (stmt);
! goto cont;
case FOR_STMT:
simplify_for_stmt (stmt, &pre);
*************** simplify_stmt (stmt_p)
*** 263,274 ****
case BREAK_STMT:
case SCOPE_STMT:
stmt_p = &TREE_CHAIN (stmt);
! continue;
case FILE_STMT:
input_filename = FILE_STMT_FILENAME (stmt);
stmt_p = &TREE_CHAIN (stmt);
! continue;
default:
prep_stmt (stmt);
--- 257,268 ----
case BREAK_STMT:
case SCOPE_STMT:
stmt_p = &TREE_CHAIN (stmt);
! goto cont;
case FILE_STMT:
input_filename = FILE_STMT_FILENAME (stmt);
stmt_p = &TREE_CHAIN (stmt);
! goto cont;
default:
prep_stmt (stmt);
*************** simplify_stmt (stmt_p)
*** 331,336 ****
--- 325,335 ----
stmt_p = &TREE_CHAIN (stmt);
}
*stmt_p = next;
+
+ cont:
+ /* Restore saved state. */
+ current_stmt_tree ()->stmts_are_full_exprs_p
+ = saved_stmts_are_full_exprs_p;
}
}
*************** simplify_expr_wfl (expr_p, pre_p, post_p
*** 1830,1835 ****
--- 1886,1893 ----
const char *file;
tree fstmt = NULL_TREE;
int line, col;
+ tree pre = NULL_TREE;
+ tree post = NULL_TREE;
if (TREE_CODE (*expr_p) != EXPR_WITH_FILE_LOCATION)
abort ();
*************** simplify_expr_wfl (expr_p, pre_p, post_p
*** 1842,1875 ****
col = EXPR_WFL_COLNO (*expr_p);
! simplify_expr (&EXPR_WFL_NODE (*expr_p), pre_p, post_p, simple_test_f,
fb_rvalue);
! for (op = *pre_p; op; op = TREE_CHAIN (op))
{
if (!statement_code_p (TREE_CODE (TREE_VALUE (op))))
TREE_VALUE (op) = build_expr_wfl (TREE_VALUE (op), file, line, col);
else if (strcmp (file, input_filename) != 0)
{
fstmt = build_stmt (FILE_STMT, get_identifier (input_filename));
! *pre_p = tree_cons (NULL_TREE, fstmt, *pre_p);
}
}
! for (op = *post_p; op; op = TREE_CHAIN (op))
TREE_VALUE (op) = build_expr_wfl (TREE_VALUE (op), file, line, col);
- if (EXPR_WFL_NODE (*expr_p) == NULL_TREE)
- *expr_p = NULL_TREE;
-
lineno = line;
input_filename = file;
if (fstmt)
{
fstmt = build_stmt (FILE_STMT, get_identifier (input_filename));
! add_tree (fstmt, post_p);
}
}
/** Simplify a SAVE_EXPR node. EXPR_P points to the expression to
--- 1900,1933 ----
col = EXPR_WFL_COLNO (*expr_p);
! simplify_expr (&EXPR_WFL_NODE (*expr_p), &pre, &post, simple_test_f,
fb_rvalue);
! for (op = pre; op; op = TREE_CHAIN (op))
{
if (!statement_code_p (TREE_CODE (TREE_VALUE (op))))
TREE_VALUE (op) = build_expr_wfl (TREE_VALUE (op), file, line, col);
else if (strcmp (file, input_filename) != 0)
{
fstmt = build_stmt (FILE_STMT, get_identifier (input_filename));
! pre = tree_cons (NULL_TREE, fstmt, pre);
}
}
! for (op = post; op; op = TREE_CHAIN (op))
TREE_VALUE (op) = build_expr_wfl (TREE_VALUE (op), file, line, col);
lineno = line;
input_filename = file;
if (fstmt)
{
fstmt = build_stmt (FILE_STMT, get_identifier (input_filename));
! add_tree (fstmt, &post);
}
+
+ add_tree (pre, pre_p);
+ add_tree (post, post_p);
}
/** Simplify a SAVE_EXPR node. EXPR_P points to the expression to