aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2014-07-09 17:14:11 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2014-07-09 17:14:11 +0000
commit63dfbb95054c0ee31a1e8647316e1ef7015875a5 (patch)
tree1ff9d46ac3b6ed25a449b7d7eb8d7f13bd233a4b
parentbde56a1d4d63bf8beee7b66ebfde95225ddc17e2 (diff)
downloadgcc-63dfbb95054c0ee31a1e8647316e1ef7015875a5.zip
gcc-63dfbb95054c0ee31a1e8647316e1ef7015875a5.tar.gz
gcc-63dfbb95054c0ee31a1e8647316e1ef7015875a5.tar.bz2
re PR c/61741 (wrong code with -fno-strict-overflow)
2014-07-09 Richard Biener <rguenther@suse.de> PR c-family/61741 * c-gimplify.c (c_gimplify_expr): Gimplify self-modify expressions using unsigned arithmetic if overflow does not wrap instead of if overflow is undefined. * c-c++-common/torture/pr61741.c: New testcase. From-SVN: r212400
-rw-r--r--gcc/c-family/ChangeLog7
-rw-r--r--gcc/c-family/c-gimplify.c4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/c-c++-common/torture/pr61741.c22
4 files changed, 35 insertions, 3 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 5bd9c1e..2445597 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,10 @@
+2014-07-09 Richard Biener <rguenther@suse.de>
+
+ PR c-family/61741
+ * c-gimplify.c (c_gimplify_expr): Gimplify self-modify expressions
+ using unsigned arithmetic if overflow does not wrap instead of
+ if overflow is undefined.
+
2014-07-06 Marek Polacek <polacek@redhat.com>
PR c/6940
diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c
index 16bffd2..8fbff603 100644
--- a/gcc/c-family/c-gimplify.c
+++ b/gcc/c-family/c-gimplify.c
@@ -240,9 +240,7 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED,
tree type = TREE_TYPE (TREE_OPERAND (*expr_p, 0));
if (INTEGRAL_TYPE_P (type) && c_promoting_integer_type_p (type))
{
- if (TYPE_OVERFLOW_UNDEFINED (type)
- || ((flag_sanitize & SANITIZE_SI_OVERFLOW)
- && !TYPE_OVERFLOW_WRAPS (type)))
+ if (!TYPE_OVERFLOW_WRAPS (type))
type = unsigned_type_for (type);
return gimplify_self_mod_expr (expr_p, pre_p, post_p, 1, type);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 77cddaf..b2e6a01 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-07-09 Richard Biener <rguenther@suse.de>
+
+ PR c-family/61741
+ * c-c++-common/torture/pr61741.c: New testcase.
+
2014-07-09 Pat Haugen <pthaugen@us.ibm.com>
* lib/target-supports.exp
diff --git a/gcc/testsuite/c-c++-common/torture/pr61741.c b/gcc/testsuite/c-c++-common/torture/pr61741.c
new file mode 100644
index 0000000..b5f9b93
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/torture/pr61741.c
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+
+int a = 1, b;
+
+void
+foo (void)
+{
+ char c = 0;
+ for (; a; a--)
+ for (; c >= 0; c++);
+ if (!c)
+ b = 1;
+}
+
+int
+main ()
+{
+ foo ();
+ if (b != 0)
+ __builtin_abort ();
+ return 0;
+}