[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-patches
Subject: Re: [PATCH c/4.2] Fix PR c/27273
From: Dirk Mueller <dmuell () gmx ! net>
Date: 2006-05-19 7:41:22
Message-ID: 200605190941.23059.dmuell () gmx ! net
[Download RAW message or body]
On Thursday, 18. May 2006 02:19, Roger Sayle wrote:
> However, in the meantime, I believe the less intrusive patch is
> to check for CONSTANT_CLASS_P(expr) immediately before the test
> of TREE_CONSTANT_OVERFLOW.
Hmm. I didn't do that because it introduces a warning in the testcase that
hasn't been there before (with older gcc's), and I can't decide if that
should be a bug or a feature. Having thought more about it, I tend to believe
in a feature.
New patch, bootstrapped, regtested on i686-suse-linux. Ok?
:ADDPATCH c:
2006-05-19 Dirk Mueller <dmueller@suse.de>
PR c/27273
* c-common.c (convert_and_check): only track TREE_CONSTANT_OVERFLOW
for CONSTANT_CLASS_P expressions.
* gcc.dg/overflow-warn-5.c: New testcase.
--- gcc/c-common.c (revision 113851)
+++ gcc/c-common.c (working copy)
@@ -1083,7 +1083,8 @@ convert_and_check (tree type, tree expr)
/* Do not diagnose overflow in a constant expression merely
because a conversion overflowed. */
- TREE_CONSTANT_OVERFLOW (t) = TREE_CONSTANT_OVERFLOW (expr);
+ TREE_CONSTANT_OVERFLOW (t) = CONSTANT_CLASS_P (expr)
+ && TREE_CONSTANT_OVERFLOW (expr);
/* No warning for converting 0x80000000 to int. */
if (!(TYPE_UNSIGNED (type) < TYPE_UNSIGNED (TREE_TYPE (expr))
--- gcc/testsuite/gcc.dg/overflow-warn-5.c (revision 0)
+++ gcc/testsuite/gcc.dg/overflow-warn-5.c (revision 0)
@@ -0,0 +1,7 @@
+/* PR c/27273 */
+/* { dg-do compile } */
+/* { dg-options "-Woverflow" } */
+
+unsigned char rx_async(unsigned char p) {
+ return p & 512; /* { dg-warning "overflow in implicit constant
conversion" } */
+}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic