From:	CSBVAX::CSBVAX::MRGATE::"SMTP::UUNET.UU.NET::MCVAX!MONCAM!PAUL"  5-DEC-1988 20:17
To:	MRGATE::"ARISIA::EVERHART"
Subj:	extra extra warning #2


Received: from uunet.UU.NET by prep.ai.mit.edu; Mon, 5 Dec 88 17:44:27 EST
Received: from mcvax.UUCP by uunet.UU.NET (5.59/1.14) with UUCP 
	id AA05696; Mon, 5 Dec 88 17:52:02 EST
Received: by mcvax.cwi.nl via EUnet; Mon, 5 Dec 88 23:38:35 +0100 (MET)
Received: from acorn by kestrel.Ukc.AC.UK   with UUCP  id aa21269;
          5 Dec 88 21:05 GMT
Received: by acorn.co.uk (5.51/AM10)
	id AA18754; Mon, 5 Dec 88 20:38:59 GMT
Received: by marvin.moncam.uucp (3.2/SMI-3.2)
	id AA04953; Mon, 5 Dec 88 18:35:06 GMT
Date: Mon, 5 Dec 88 18:35:06 GMT
From: Paul Hudson <mcvax!moncam!paul@uunet.uu.net>
Message-Id: <8812051835.AA04953@marvin.moncam.uucp>
To: info-gcc@prep.ai.mit.edu
Subject: extra extra warning #2


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);
