This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/65430] Missing -Wsequence-point warning with COMPOUND_EXPRs
- From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 15 May 2017 15:50:16 +0000
- Subject: [Bug c/65430] Missing -Wsequence-point warning with COMPOUND_EXPRs
- Auto-submitted: auto-generated
- References: <bug-65430-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65430
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This ought to fix both problems:
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -10443,6 +10443,7 @@ tree
c_process_expr_stmt (location_t loc, tree expr)
{
tree exprv;
+ tree orig_expr = expr;
if (!expr)
return NULL_TREE;
@@ -10450,7 +10451,7 @@ c_process_expr_stmt (location_t loc, tree expr)
expr = c_fully_fold (expr, false, NULL);
if (warn_sequence_point)
- verify_sequence_points (expr);
+ verify_sequence_points (orig_expr);
if (TREE_TYPE (expr) != error_mark_node
&& !COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (expr))
@@ -10462,7 +10463,7 @@ c_process_expr_stmt (location_t loc, tree expr)
out which is the result. */
if (!STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
&& warn_unused_value)
- emit_side_effect_warnings (EXPR_LOC_OR_LOC (expr, loc), expr);
+ emit_side_effect_warnings (EXPR_LOC_OR_LOC (orig_expr, loc), orig_expr);
exprv = expr;
while (TREE_CODE (exprv) == COMPOUND_EXPR)