diff options
author | Mark Mitchell <mark@codesourcery.com> | 2004-03-17 04:33:28 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2004-03-17 04:33:28 +0000 |
commit | 88020bd8ea3599aacf21218df9f8f7dbb8e15cff (patch) | |
tree | db986d888c5c1503a9a42244b70a049fbedc32d0 /gcc | |
parent | bf3864fe15178a34c0445b0b834dada0fe3aeded (diff) | |
download | gcc-88020bd8ea3599aacf21218df9f8f7dbb8e15cff.zip gcc-88020bd8ea3599aacf21218df9f8f7dbb8e15cff.tar.gz gcc-88020bd8ea3599aacf21218df9f8f7dbb8e15cff.tar.bz2 |
re PR c++/14481 (strange warning when assigning to bitfield)
PR c++/14481
* fold-const.c (fold): Set TREE_NO_UNUSED_WARNING on implicitly
generated COMPOUND_EXPRs.
PR c++/14481
* g++.dg/warn/Wunused-7.C: New test.
From-SVN: r79570
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fold-const.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wunused-7.C | 12 |
4 files changed, 30 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9ecf969..894d105 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-03-16 Mark Mitchell <mark@codesourcery.com> + + PR c++/14481 + * fold-const.c (fold): Set TREE_NO_UNUSED_WARNING on implicitly + generated COMPOUND_EXPRs. + 2004-03-16 Ralf Corsepius <corsepiu@faw.uni-ulm.de> * config/h8300/t-rtems (h8300-*-rtems*): New. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 5e899fd..4168339 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1392,7 +1392,7 @@ int_const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc) && ((hi == 0 && (HOST_WIDE_INT) low >= 0) || (hi == -1 && (HOST_WIDE_INT) low < 0)) && overflow == 0 && ! TREE_OVERFLOW (arg1) && ! TREE_OVERFLOW (arg2)) - return size_int_type_wide (low, type); + return size_int_type (low, type); else { t = build_int_2 (low, hi); @@ -1598,7 +1598,7 @@ size_htab_eq (const void *x, const void *y) tree size_int_wide (HOST_WIDE_INT number, enum size_type_kind kind) { - return size_int_type_wide (number, sizetype_tab[(int) kind]); + return size_int_type (number, sizetype_tab[(int) kind]); } /* Likewise, but the desired type is specified explicitly. */ @@ -1608,7 +1608,7 @@ static GTY ((if_marked ("ggc_marked_p"), param_is (union tree_node))) htab_t size_htab; tree -size_int_type_wide (HOST_WIDE_INT number, tree type) +size_int_type_wide (HOST_WIDE_INT high, HOST_WIDE_INT low, tree type) { void **slot; @@ -1621,8 +1621,8 @@ size_int_type_wide (HOST_WIDE_INT number, tree type) /* Adjust NEW_CONST to be the constant we want. If it's already in the hash table, we return the value from the hash table. Otherwise, we place that in the hash table and make a new node for the next time. */ - TREE_INT_CST_LOW (new_const) = number; - TREE_INT_CST_HIGH (new_const) = number < 0 ? -1 : 0; + TREE_INT_CST_LOW (new_const) = low; + TREE_INT_CST_HIGH (new_const) = high; TREE_TYPE (new_const) = type; TREE_OVERFLOW (new_const) = TREE_CONSTANT_OVERFLOW (new_const) = force_fit_type (new_const, 0); @@ -1745,7 +1745,7 @@ fold_convert_const (enum tree_code code, tree type, tree arg1) if (TREE_CODE (type) == INTEGER_TYPE && TYPE_IS_SIZETYPE (type) && !TREE_CONSTANT_OVERFLOW (arg1) && compare_tree_int (arg1, 10000) < 0) - return size_int_type_wide (TREE_INT_CST_LOW (arg1), type); + return size_int_type (TREE_INT_CST_LOW (arg1), type); /* Given an integer constant, make new constant with new type, appropriately sign-extended or truncated. */ @@ -5749,6 +5749,7 @@ fold (tree expr) TREE_OPERAND (t, 0) = TREE_OPERAND (prev, 1); /* First do the assignment, then return converted constant. */ t = build (COMPOUND_EXPR, TREE_TYPE (t), prev, fold (t)); + TREE_NO_UNUSED_WARNING (t) = 1; TREE_USED (t) = 1; return t; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e5df14e..029201b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-03-16 Mark Mitchell <mark@codesourcery.com> + + PR c++/14481 + * g++.dg/warn/Wunused-7.C: New test. + 2004-03-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * gcc.dg/torture/builtin-integral-1.c: New test. diff --git a/gcc/testsuite/g++.dg/warn/Wunused-7.C b/gcc/testsuite/g++.dg/warn/Wunused-7.C new file mode 100644 index 0000000..4281bc8 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-7.C @@ -0,0 +1,12 @@ +// PR c++/14481 +// { dg-options "-Wunused" } + +void func() +{ + struct mybitfields { + unsigned int s_field:8; + }; + struct mybitfields s; + s.s_field = 255; +}; + |