This is the mail archive of the gcc-bugs@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]

[Bug c/65430] Missing -Wsequence-point warning with COMPOUND_EXPRs


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)

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