aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJim Wilson <wilson@gcc.gnu.org>1993-11-20 13:51:04 -0800
committerJim Wilson <wilson@gcc.gnu.org>1993-11-20 13:51:04 -0800
commit55cd1c090ce849ebe7110c7361d5679e54da5b5e (patch)
treeb0674b7bb5749d5d6802f9f9a9f85ef44e382865 /gcc
parent25f514cb80063e4667de72ef39a7736213451d8f (diff)
downloadgcc-55cd1c090ce849ebe7110c7361d5679e54da5b5e.zip
gcc-55cd1c090ce849ebe7110c7361d5679e54da5b5e.tar.gz
gcc-55cd1c090ce849ebe7110c7361d5679e54da5b5e.tar.bz2
(warn_if_unused_value): Handle arbitrary number of casts
before a modify. From-SVN: r6124
Diffstat (limited to 'gcc')
-rw-r--r--gcc/stmt.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 928e6cb..9795d8f 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -1709,15 +1709,19 @@ warn_if_unused_value (exp)
if (TREE_NO_UNUSED_WARNING (exp))
return 0;
/* Assignment to a cast usually results in a cast of a modify.
- Don't complain about that. */
- if (TREE_CODE (TREE_OPERAND (exp, 0)) == MODIFY_EXPR)
- return 0;
- /* Sometimes it results in a cast of a cast of a modify.
- Don't complain about that. */
- if ((TREE_CODE (TREE_OPERAND (exp, 0)) == CONVERT_EXPR
- || TREE_CODE (TREE_OPERAND (exp, 0)) == NOP_EXPR)
- && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == MODIFY_EXPR)
- return 0;
+ Don't complain about that. There can be an arbitrary number of
+ casts before the modify, so we must loop until we find the first
+ non-cast expression and then test to see if that is a modify. */
+ {
+ tree tem = TREE_OPERAND (exp, 0);
+
+ while (TREE_CODE (tem) == CONVERT_EXPR || TREE_CODE (tem) == NOP_EXPR)
+ tem = TREE_OPERAND (tem, 0);
+
+ if (TREE_CODE (tem) == MODIFY_EXPR)
+ return 0;
+ }
+ /* ... fall through ... */
default:
/* Referencing a volatile value is a side effect, so don't warn. */