diff options
author | Jakub Jelinek <jakub@redhat.com> | 2010-05-06 08:52:30 +0200 |
---|---|---|
committer | Dodji Seketeli <dodji@gcc.gnu.org> | 2010-05-06 08:52:30 +0200 |
commit | 03a904b5a683713f848ef028aef63e0cfd16c4eb (patch) | |
tree | 98529df86d4f96b7809a5e235901996abf394d3f /gcc/cp/rtti.c | |
parent | 7d8930a046c5d5c80f990eef73c278b4c124b6f4 (diff) | |
download | gcc-03a904b5a683713f848ef028aef63e0cfd16c4eb.zip gcc-03a904b5a683713f848ef028aef63e0cfd16c4eb.tar.gz gcc-03a904b5a683713f848ef028aef63e0cfd16c4eb.tar.bz2 |
C++ support for -Wunused-but-set-variable
gcc/cp/ChangeLog:
PR 18624
* cp-tree.h (mark_exp_read, mark_rvalue_use, mark_lvalue_use,
mark_type_use): Declare ...
* expr.c (mark_exp_read, mark_rvalue_use, mark_lvalue_use,
mark_type_use): ... new fns.
* typeck.c (cxx_sizeof_expr, cxx_alignof_expr): Call mark_type_use.
(perform_integral_promotions): Call mark_rvalue_use.
(cp_build_unary_op): Call mark_lvalue_use.
(decay_conversion): Update comment. Call mark_lvalue.
* decl.c (unused_but_set_errorcount): New variable.
(poplevel): Issue -Wunused-but-set-variable diagnostics.
(duplicate_decls): Merge DECL_READ_P flags.
(start_cleanup_fn): Set DECL_READ_P flag.
(finish_function): Issue -Wunused-but-set-parameter diagnostics.
* tree.c (rvalue): Call mark_rvalue_use.
* pt.c (convert_nontype_argument): Likewise.
* semantics.c (finish_typeof, finish_decltype_type): Call
mark_type_use.
(finish_asm_stmt): Call mark_lvalue_use.
(finish_expr_stmt): Call mark_exp_read.
* call.c (convert_like_real) <ck_identity, ck_user>: Call
mark_rvalue_use.
(build_x_va_arg): Call mark_lvalue_use.
(build_over_call): Call mark_type_use.
* init.c (build_new, build_delete): Call mark_value_use.
* rtti.c (build_typeid): Call mark_lvalue_use or mark_type_use.
(build_dynamic_cast_1): call mark_lvalue_use or mark_rvalue_use.
gcc/testsuite/ChangeLog:
PR 18624
* g++.dg/warn/Wunused-7.C: Add dg-warning.
* g++.dg/template/sfinae16.C: Likewise.
* gcc.dg/Wunused-var-1.c: Moved to...
* c-c++-common/Wunused-var-1.c: ...here. New test.
* gcc.dg/Wunused-var-2.c: Moved to...
* c-c++-common/Wunused-var-2.c: ...here. New test.
* gcc.dg/Wunused-var-3.c: Moved to...
* c-c++-common/Wunused-var-3.c: ...here. New test.
* gcc.dg/Wunused-var-4.c: Moved to...
* gcc.dg/Wunused-var-1.c: ... here.
* gcc.dg/Wunused-var-5.c: Moved to...
* c-c++-common/Wunused-var-4.c: ...here. New test.
* gcc.dg/Wunused-var-7.c: Moved to...
* c-c++-common/Wunused-var-5.c: ...here. New test.
* gcc.dg/Wunused-var-6.c: Moved to...
* gcc.dg/Wunused-var-2.c: ... here.
* c-c++-common/Wunused-var-1.c: New test.
* c-c++-common/Wunused-var-2.c: New test.
* c-c++-common/Wunused-var-3.c: New test.
* c-c++-common/Wunused-var-4.c: New test.
* c-c++-common/Wunused-var-5.c: New test.
* g++.dg/warn/Wunused-var-1.C: New test.
* g++.dg/warn/Wunused-var-2.C: New test.
* g++.dg/warn/Wunused-var-3.C: New test.
* g++.dg/warn/Wunused-var-4.C: New test.
* g++.dg/warn/Wunused-var-5.C: New test.
* g++.dg/warn/Wunused-var-6.C: New test.
* g++.dg/warn/Wunused-var-7.C: New test.
* g++.dg/warn/Wunused-var-8.C: New test.
* g++.dg/warn/Wunused-parm-1.C: New test.
* g++.dg/warn/Wunused-parm-2.C: New test.
* g++.dg/warn/Wunused-parm-3.C: New test.
Co-Authored-By: Dodji Seketeli <dodji@redhat.com>
From-SVN: r159096
Diffstat (limited to 'gcc/cp/rtti.c')
-rw-r--r-- | gcc/cp/rtti.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 0f7225f..6f40653 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -318,7 +318,7 @@ typeid_ok_p (void) tree build_typeid (tree exp) { - tree cond = NULL_TREE; + tree cond = NULL_TREE, initial_expr = exp; int nonnull = 0; if (exp == error_mark_node || !typeid_ok_p ()) @@ -333,6 +333,9 @@ build_typeid (tree exp) && ! resolves_to_fixed_type_p (exp, &nonnull) && ! nonnull) { + /* So we need to look into the vtable of the type of exp. + This is an lvalue use of expr then. */ + exp = mark_lvalue_use (exp); exp = stabilize_reference (exp); cond = cp_convert (boolean_type_node, TREE_OPERAND (exp, 0)); } @@ -348,6 +351,8 @@ build_typeid (tree exp) exp = build3 (COND_EXPR, TREE_TYPE (exp), cond, exp, bad); } + else + mark_type_use (initial_expr); return exp; } @@ -546,6 +551,8 @@ build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain) /* If T is a pointer type, v shall be an rvalue of a pointer to complete class type, and the result is an rvalue of type T. */ + expr = mark_rvalue_use (expr); + if (TREE_CODE (exprtype) != POINTER_TYPE) { errstr = _("source is not a pointer"); @@ -564,6 +571,8 @@ build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain) } else { + expr = mark_lvalue_use (expr); + exprtype = build_reference_type (exprtype); /* T is a reference type, v shall be an lvalue of a complete class |