paul@UUNET.UU.NET (Paul Hudson) (12/06/88)
The following diffs cause gcc to give a warning if an expression statement
has no effect. This catches (among others) the reverse finger trouble to
my previous change, typing == where I meant =.
It only objects if the whole expression has no side-effect - it might
be argued that
f() + 1;
should be pointed out. I have a feeling that this would happen too often
as a result of macros returing a value which is ignored, but where the whole
expression has a side-effect. It could be added to expand_expr
if (ignore && !TREE_VOLATILE(exp) && extra_warnings)
warning("....");
should do it.
Paul Hudson
Snail mail: Monotype ADG Email: ...!ukc!acorn!moncam!paul
Science Park, paul@moncam.co.uk
Milton Road, "Sun Microsysytems:
Cambridge, The Company is Arrogant (TM)"
CB4 4FQ
*** stmt.c.orig Mon Dec 5 18:16:09 1988
--- stmt.c Mon Dec 5 18:17:38 1988
***************
*** 758,763 ****
--- 758,765 ----
expand_expr_stmt (exp)
tree exp;
{
+ if (expr_stmts_for_value == 0 && !TREE_VOLATILE(exp) && extra_warnings)
+ warning("statement with no effect");
last_expr_type = TREE_TYPE (exp);
last_expr_value = expand_expr (exp, expr_stmts_for_value ? 0 : const0_rtx,
VOIDmode, 0);