diff options
author | Jakub Jelinek <jakub@redhat.com> | 2010-07-02 22:22:32 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2010-07-02 22:22:32 +0200 |
commit | 416f380b0de93075cdf0e968ad76f1c102db5dd7 (patch) | |
tree | 94ec85f85c58f86f21bfcc5897fdfbbd27949fbf /gcc | |
parent | 2dc8bd762e1b69c34ce88b5b4d3672f008d856b8 (diff) | |
download | gcc-416f380b0de93075cdf0e968ad76f1c102db5dd7.zip gcc-416f380b0de93075cdf0e968ad76f1c102db5dd7.tar.gz gcc-416f380b0de93075cdf0e968ad76f1c102db5dd7.tar.bz2 |
re PR c++/44780 (Bogus set-but-not-used variable warning)
PR c++/44780
* typeck.c (convert_for_assignment): When converting a convertible
vector type or objc++ types, call mark_rvalue_use.
* typeck2.c (build_m_component_ref): Use return values from
mark_rvalue_use or mark_lvalue_use.
* class.c (build_base_path): Likewise.
* call.c (build_conditional_expr): Likewise.
* c-c++-common/Wunused-var-12.c: New test.
From-SVN: r161742
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/call.c | 4 | ||||
-rw-r--r-- | gcc/cp/class.c | 2 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 10 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/Wunused-var-12.c | 25 |
7 files changed, 53 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3b2764d..33aee8a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2010-07-02 Jakub Jelinek <jakub@redhat.com> + + PR c++/44780 + * typeck.c (convert_for_assignment): When converting a convertible + vector type or objc++ types, call mark_rvalue_use. + * typeck2.c (build_m_component_ref): Use return values from + mark_rvalue_use or mark_lvalue_use. + * class.c (build_base_path): Likewise. + * call.c (build_conditional_expr): Likewise. + 2010-07-02 Paolo Carlini <paolo.carlini@oracle.com> PR c++/44039 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index d03ecb1..c4f3e95 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3861,8 +3861,8 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3, && same_type_p (arg2_type, arg3_type)) { result_type = arg2_type; - mark_lvalue_use (arg2); - mark_lvalue_use (arg3); + arg2 = mark_lvalue_use (arg2); + arg3 = mark_lvalue_use (arg3); goto valid_operands; } diff --git a/gcc/cp/class.c b/gcc/cp/class.c index a2ed863..3c4830e 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -284,7 +284,7 @@ build_base_path (enum tree_code code, /* This must happen before the call to save_expr. */ expr = cp_build_unary_op (ADDR_EXPR, expr, 0, tf_warning_or_error); else - mark_rvalue_use (expr); + expr = mark_rvalue_use (expr); offset = BINFO_OFFSET (binfo); fixed_type_p = resolves_to_fixed_type_p (expr, &nonnull); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 20345b55..ec0b06d 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -7211,7 +7211,10 @@ convert_for_assignment (tree type, tree rhs, if (TREE_CODE (type) == VECTOR_TYPE && coder == VECTOR_TYPE && vector_types_convertible_p (type, rhstype, true)) - return convert (type, rhs); + { + rhs = mark_rvalue_use (rhs); + return convert (type, rhs); + } if (rhs == error_mark_node || rhstype == error_mark_node) return error_mark_node; @@ -7255,7 +7258,10 @@ convert_for_assignment (tree type, tree rhs, } if (objc_compare_types (type, rhstype, parmno, rname)) - return convert (type, rhs); + { + rhs = mark_rvalue_use (rhs); + return convert (type, rhs); + } } /* [expr.ass] diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index f62bbb5..bdc14c7 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1478,8 +1478,8 @@ build_m_component_ref (tree datum, tree component) if (error_operand_p (datum) || error_operand_p (component)) return error_mark_node; - mark_lvalue_use (datum); - mark_rvalue_use (component); + datum = mark_lvalue_use (datum); + component = mark_rvalue_use (component); ptrmem_type = TREE_TYPE (component); if (!TYPE_PTR_TO_MEMBER_P (ptrmem_type)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 33a1cae..09e56fb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-07-02 Jakub Jelinek <jakub@redhat.com> + + PR c++/44780 + * c-c++-common/Wunused-var-12.c: New test. + 2010-07-02 Bernd Schmidt <bernds@codesourcery.com> PR target/42835 diff --git a/gcc/testsuite/c-c++-common/Wunused-var-12.c b/gcc/testsuite/c-c++-common/Wunused-var-12.c new file mode 100644 index 0000000..312680a --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wunused-var-12.c @@ -0,0 +1,25 @@ +/* PR c++/44780 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +typedef double vec __attribute__ ((__vector_size__ (16))); +vec c, d; + +void +foo (void) +{ + vec a; + vec b; + a = c; + b = a; + d = b; +} + +void +bar (void) +{ + vec a; + vec b; /* { dg-warning "set but not used" } */ + a = c; + b = a; +} |