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
This commit is contained in:
parent
7db1993723
commit
63d6f87a6d
3 changed files with 25 additions and 0 deletions
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
10
gcc/testsuite/g++.old-deja/g++.other/empty2.C
Normal file
10
gcc/testsuite/g++.old-deja/g++.other/empty2.C
Normal file
|
@ -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.
|
||||
}
|
Loading…
Add table
Reference in a new issue