OSDN Git Service

* call.c (build_over_call): Mark COMPOUND_EXPRs generated for
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 13 Aug 2001 21:07:22 +0000 (21:07 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 13 Aug 2001 21:07:22 +0000 (21:07 +0000)
empty class assignment as having side-effects to avoid
spurious warnings.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44868 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.old-deja/g++.other/empty2.C [new file with mode: 0644]

index b5f90a0..f49263b 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2001-08-13  Zack Weinberg  <zackw@panix.com>
 
        * Make-lang.in (cp/except.o): Add libfuncs.h to dependencies.
index 6278095..8203032 100644 (file)
@@ -4292,6 +4292,15 @@ build_over_call (cand, args, flags)
          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);
diff --git a/gcc/testsuite/g++.old-deja/g++.other/empty2.C b/gcc/testsuite/g++.old-deja/g++.other/empty2.C
new file mode 100644 (file)
index 0000000..92585b8
--- /dev/null
@@ -0,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.
+}