On Tue, Jan 21, 2014 at 11:54:03PM +0100, Marek Polacek wrote: > On Tue, Jan 21, 2014 at 11:34:42PM +0100, Jakub Jelinek wrote: > > On Tue, Jan 21, 2014 at 11:30:58PM +0100, Marek Polacek wrote: > > > I made another small change: in the second hunk, in > > > emit_side_effect_warnings, I got rid of the while, since it seems to > > > me we never get COMPOUND_EXPR in TREE_OPERAND (r, 1). > > > > For bar (), 1, 2, 3, 4, 5, 6, 7, 8; sure, but what about > > (1, (2, (3, (4, (5, (6, (bar (), 7))))))); ? > > For that `expr' that emit_side_effect_warnings gets is: > <compound_expr 0x7ffe2724b848 > type <integer_type 0x7ffe27144690 int public SI > size <integer_cst 0x7ffe271463c0 constant 32> > unit size <integer_cst 0x7ffe271463e0 constant 4> > align 32 symtab 0 alias set -1 canonical type 0x7ffe27144690 > precision 32 min <integer_cst 0x7ffe27146360 -2147483648> max <integer_cst > 0x7ffe27146380 2147483647> > pointer_to_this <pointer_type 0x7ffe27150738>> > side-effects > arg 0 <call_expr 0x7ffe2726a840 type <integer_type 0x7ffe27144690 int> > side-effects > fn <addr_expr 0x7ffe2725a720 type <pointer_type 0x7ffe2726e0a8> > constant arg 0 <function_decl 0x7ffe27250600 bar> > uu.c:19:32> > uu.c:19:32> > arg 1 <integer_cst 0x7ffe2725a760 type <integer_type 0x7ffe27144690 int> > constant 7> > uu.c:19:5> > so we should be fine even in that case.
And for (bar (), (bar (), (bar (), (bar (), (bar (), (bar (), (bar (), 7))))))); ? On the other side, there is warn_if_unused_value, which specifically has: /* Let people do `(foo (), 0)' without a warning. */ if (TREE_CONSTANT (TREE_OPERAND (exp, 1))) return false; so perhaps it is intentional that we don't warn about this? That stuff dates all the way back to r759. Though I wonder why it would be desirable to warn about this for C++ and not for C. Jakub