diff options
author | Jakub Jelinek <jakub@redhat.com> | 2010-05-11 20:12:28 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2010-05-11 20:12:28 +0200 |
commit | 056928b248b7e3f879c2b3ac4be935e67ad3a09a (patch) | |
tree | 89061f89197477311627b0ab6424fa6ee67aaf52 /gcc/c-parser.c | |
parent | edf86ec148f98f12a16ba9b2a26b0b66b6078c50 (diff) | |
download | gcc-056928b248b7e3f879c2b3ac4be935e67ad3a09a.zip gcc-056928b248b7e3f879c2b3ac4be935e67ad3a09a.tar.gz gcc-056928b248b7e3f879c2b3ac4be935e67ad3a09a.tar.bz2 |
re PR c++/44062 ((void)var; doesn't prevent 'set but not used' warning)
PR c++/44062
* c-parser.c (c_parser_expression): Mark LHS of a comma
expression as read if it is a decl, handled component or
COMPOUND_EXPR with that on the RHS.
* c-typeck.c (c_process_expr_stmt): Mark RHS of COMPOUND_EXPR
if it is a decl or handled component.
* semantics.c (finish_expr_stmt): Don't call mark_exp_read here...
* cvt.c (convert_to_void): ... but here. If expr is a COMPOUND_EXPR,
look at its second operand.
* c-c++-common/Wunused-var-7.c: New test.
* g++.dg/warn/Wunused-var-9.C: New test.
From-SVN: r159286
Diffstat (limited to 'gcc/c-parser.c')
-rw-r--r-- | gcc/c-parser.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/c-parser.c b/gcc/c-parser.c index e5440d4..a0f1bea 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -6028,10 +6028,16 @@ c_parser_expression (c_parser *parser) while (c_parser_next_token_is (parser, CPP_COMMA)) { struct c_expr next; + tree lhsval; location_t loc = c_parser_peek_token (parser)->location; location_t expr_loc; c_parser_consume_token (parser); expr_loc = c_parser_peek_token (parser)->location; + lhsval = expr.value; + while (TREE_CODE (lhsval) == COMPOUND_EXPR) + lhsval = TREE_OPERAND (lhsval, 1); + if (DECL_P (lhsval) || handled_component_p (lhsval)) + mark_exp_read (lhsval); next = c_parser_expr_no_commas (parser, NULL); next = default_function_array_conversion (expr_loc, next); expr.value = build_compound_expr (loc, expr.value, next.value); |