diff options
author | Mark Mitchell <mark@codesourcery.com> | 2004-12-22 18:00:39 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2004-12-22 18:00:39 +0000 |
commit | dfb5c52315ecc5b6ebabf2d7cb3d3d69f35a378b (patch) | |
tree | 92d85ea737af3ab701ec3aa12c9d0ae5763ee5c1 /gcc/cp/cvt.c | |
parent | 606145e4e0e54d412059033a6261c53bf11d7b6d (diff) | |
download | gcc-dfb5c52315ecc5b6ebabf2d7cb3d3d69f35a378b.zip gcc-dfb5c52315ecc5b6ebabf2d7cb3d3d69f35a378b.tar.gz gcc-dfb5c52315ecc5b6ebabf2d7cb3d3d69f35a378b.tar.bz2 |
re PR c++/18464 (error message about "non-lvalue in unary '&'" when using ?: operator)
PR c++/18464
* call.c (build_this): In templates, do not bother with
build_unary_op.
* typeck.c (unary_complex_lvalue): In a template, always refuse
simplifications.
PR c++/18492
* cp-gimplify.c (cp_genericize): Relax assertion.
PR c++/11224
* cvt.c (convert_to_void): Warn about unused values.
PR c++/18257
* rtti.c (emit_support_tinfos): On systems without weak symbols,
emit the runtime library type-info objects as non-COMDAT.
PR c++/18464
* g++.dg/template/cond5.C: New test.
PR c++/18492
* g++.dg/inherit/thunk3.C: New test.
PR c++/11224
* g++.dg/warn/Wunused-9.C: New test.
From-SVN: r92491
Diffstat (limited to 'gcc/cp/cvt.c')
-rw-r--r-- | gcc/cp/cvt.c | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 2d73ab8..64db100 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -909,9 +909,43 @@ convert_to_void (tree expr, const char *implicit) if (expr != error_mark_node && !VOID_TYPE_P (TREE_TYPE (expr))) { - if (implicit && warn_unused_value - && !TREE_SIDE_EFFECTS (expr) && !TREE_NO_WARNING (expr)) - warning ("%s has no effect", implicit); + if (implicit && warn_unused_value && !TREE_NO_WARNING (expr)) + { + /* The middle end does not warn about expressions that have + been explicitly cast to void, so we must do so here. */ + if (!TREE_SIDE_EFFECTS (expr)) + warning ("%s has no effect", implicit); + else + { + tree e; + enum tree_code code; + enum tree_code_class class; + + e = expr; + /* We might like to warn about (say) "(int) f()", as the + cast has no effect, but the compiler itself will + generate implicit conversions under some + circmstances. (For example a block copy will be + turned into a call to "__builtin_memcpy", with a + conversion of the return value to an appropriate + type.) So, to avoid false positives, we strip + conversions. */ + STRIP_NOPS (e); + + code = TREE_CODE (e); + class = TREE_CODE_CLASS (code); + if (class == tcc_comparison + || class == tcc_unary + || (class == tcc_binary + && !(code == MODIFY_EXPR + || code == INIT_EXPR + || code == PREDECREMENT_EXPR + || code == PREINCREMENT_EXPR + || code == POSTDECREMENT_EXPR + || code == POSTINCREMENT_EXPR))) + warning ("value computed is not used"); + } + } expr = build1 (CONVERT_EXPR, void_type_node, expr); } return expr; |