C++ PATCH: PR 14481
Mark Mitchell
mark@codesourcery.com
Wed Mar 17 04:35:00 GMT 2004
This patch fixes a spurious warning regression about an unused
right-hand operand to a comma-expression in code that has no
comma-expression.
Tested on i686-pc-linux-gnu, applied on the mainline and the 3.4
branch.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
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 Mark Mitchell <mark@codesourcery.com>
PR c++/14481
* g++.dg/warn/Wunused-7.C: New test.
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.322.2.7
diff -c -5 -p -r1.322.2.7 fold-const.c
*** fold-const.c 8 Mar 2004 20:34:37 -0000 1.322.2.7
--- fold-const.c 17 Mar 2004 03:46:03 -0000
*************** fold (tree expr)
*** 5668,5677 ****
--- 5668,5678 ----
if (t == orig_t)
t = copy_node (t);
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;
}
/* Convert (T)(x & c) into (T)x & (T)c, if c is an integer
Index: testsuite/g++.dg/warn/Wunused-7.C
===================================================================
RCS file: testsuite/g++.dg/warn/Wunused-7.C
diff -N testsuite/g++.dg/warn/Wunused-7.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/warn/Wunused-7.C 17 Mar 2004 03:46:04 -0000
***************
*** 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;
+ };
+
More information about the Gcc-patches
mailing list