This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

C++ PATCH: PR3989



This patch fixes PR3989, a regression relative to GCC 3.0 in 
GCC 3.0.1.

Tested on i686-pc-linux-gnu, applied on the mainline and on the 
branch.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2001-08-13  Mark Mitchell  <mark@codesourcery.com>

	* call.c (build_over_call): Mark COMPOUND_EXPRs generated for
	empty class assignment as having side-effects to avoid
	spurious warnings.

Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.255.2.16
diff -c -p -r1.255.2.16 call.c
*** call.c	2001/08/07 13:06:42	1.255.2.16
--- call.c	2001/08/13 20:49:06
*************** build_over_call (cand, args, flags)
*** 4278,4283 ****
--- 4278,4292 ----
  	  TREE_USED (arg) = 1;
  
  	  val = build (COMPOUND_EXPR, DECL_CONTEXT (fn), arg, to);
+ 	  /* Even though the assignment may not actually result in any
+ 	     code being generated, we do not want to warn about the
+ 	     assignment having no effect.  That would be confusing to
+ 	     users who may be performing the assignment as part of a
+ 	     generic algorithm, for example.
+ 	     
+ 	     Ideally, the notions of having side-effects and of being
+ 	     useless would be orthogonal.  */
+ 	  TREE_SIDE_EFFECTS (val) = 1;
  	}
        else
  	val = build (MODIFY_EXPR, TREE_TYPE (to), to, arg);
Index: testsuite/g++.old-deja/g++.other/empty2.C
===================================================================
RCS file: empty2.C
diff -N empty2.C
*** /dev/null	Tue May  5 13:32:27 1998
--- empty2.C	Mon Aug 13 13:49:07 2001
***************
*** 0 ****
--- 1,10 ----
+ // Build don't link:
+ // Origin: Mark Mitchell <mark@codesourcery.com>
+ 
+ struct E {};
+ 
+ void f () {
+   E e1, e2;
+   e1 = e2; // We should not warn about this statement, even though no
+            // code is generated for it.
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]