Commit d06f8b75 by Marek Polacek Committed by Marek Polacek

re PR c/64637 (Incorrect location for -Wunused-value warnings in for-loop)

	PR c/64637
	* c-typeck.c (c_process_expr_stmt): Use location of the expression if
	available.

	* gcc.dg/pr64637.c: New test.

From-SVN: r231700
parent bc325637
2015-12-16 Marek Polacek <polacek@redhat.com>
PR c/64637
* c-typeck.c (c_process_expr_stmt): Use location of the expression if
available.
2015-12-15 Marek Polacek <polacek@redhat.com> 2015-12-15 Marek Polacek <polacek@redhat.com>
PR c/68907 PR c/68907
......
...@@ -10131,7 +10131,7 @@ c_process_expr_stmt (location_t loc, tree expr) ...@@ -10131,7 +10131,7 @@ c_process_expr_stmt (location_t loc, tree expr)
out which is the result. */ out which is the result. */
if (!STATEMENT_LIST_STMT_EXPR (cur_stmt_list) if (!STATEMENT_LIST_STMT_EXPR (cur_stmt_list)
&& warn_unused_value) && warn_unused_value)
emit_side_effect_warnings (loc, expr); emit_side_effect_warnings (EXPR_LOC_OR_LOC (expr, loc), expr);
exprv = expr; exprv = expr;
while (TREE_CODE (exprv) == COMPOUND_EXPR) while (TREE_CODE (exprv) == COMPOUND_EXPR)
......
2015-12-16 Marek Polacek <polacek@redhat.com>
PR c/64637
* gcc.dg/pr64637.c: New test.
2015-12-16 Nathan Sidwell <nathan@acm.org> 2015-12-16 Nathan Sidwell <nathan@acm.org>
* gcc.dg/sibcall-9.c: Xfail for nvptx. * gcc.dg/sibcall-9.c: Xfail for nvptx.
......
/* PR c/64637 */
/* { dg-do compile } */
/* { dg-options "-Wunused" } */
void g ();
void
f (int b)
{
for (int i = 0; i < b; i + b) /* { dg-warning "28:statement with no effect" } */
g ();
// PARM_DECLs still don't have a location, don't expect an exact location.
for (int i = 0; i < b; b) /* { dg-warning "statement with no effect" } */
g ();
for (int i = 0; i < b; !i) /* { dg-warning "26:statement with no effect" } */
g ();
for (!b;;) /* { dg-warning "8:statement with no effect" } */
g ();
for (;; b * 2) /* { dg-warning "13:statement with no effect" } */
g ();
({
b / 5; /* { dg-warning "8:statement with no effect" } */
b ^ 5;
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment