From: Mark Mitchell Date: Mon, 13 Aug 2001 21:07:22 +0000 (+0000) Subject: call.c (build_over_call): Mark COMPOUND_EXPRs generated for empty class assignment... X-Git-Tag: prereleases/libstdc++-3.0.95~2672 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63d6f87a6d1eae6411542567d6834c27c4509f40;p=thirdparty%2Fgcc.git call.c (build_over_call): Mark COMPOUND_EXPRs generated for empty class assignment as having side-effects... * call.c (build_over_call): Mark COMPOUND_EXPRs generated for empty class assignment as having side-effects to avoid spurious warnings. From-SVN: r44868 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b5f90a07ec7e..f49263b28130 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2001-08-13 Mark Mitchell + + * 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 * Make-lang.in (cp/except.o): Add libfuncs.h to dependencies. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 6278095b8348..8203032fc8ad 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -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 index 000000000000..92585b8b03f2 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/empty2.C @@ -0,0 +1,10 @@ +// Build don't link: +// Origin: Mark Mitchell + +struct E {}; + +void f () { + E e1, e2; + e1 = e2; // We should not warn about this statement, even though no + // code is generated for it. +}