aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2008-08-25 15:04:09 +0000
committerJakub Jelinek <jakub@redhat.com>2008-08-25 15:04:09 +0000
commit2f06e1a67e8386223e650683a55ce73d4ff0212a (patch)
treef1b02ae6b14256e8a51a0d1abb1fb752abd4ec66
parentf7f83f3eae191199ade4c1a83b39091ffad35f8b (diff)
svn merge -r139093:139094 svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_3-branchredhat/gcc-4_1-branch
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/redhat/gcc-4_1-branch@139561 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/fold-const.c4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20080813-1.c30
4 files changed, 43 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2d63bd5f307..e8c69a56fa9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2008-08-14 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/37103
+ * fold-const.c (fold_widened_comparison): Do not allow
+ sign changes that change the result even if shorter type
+ is wider than arg1_unw's type.
+
2008-06-05 Richard Sandiford <rdsandiford@googlemail.com>
* config/mips/mips.c (mips_emit_loadgp): Emit a blockage if
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 438820afecc..12a75ab943c 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6311,10 +6311,8 @@ fold_widened_comparison (enum tree_code code, tree type, tree arg0, tree arg1)
if ((code == EQ_EXPR || code == NE_EXPR
|| TYPE_UNSIGNED (TREE_TYPE (arg0)) == TYPE_UNSIGNED (shorter_type))
&& (TREE_TYPE (arg1_unw) == shorter_type
- || (TYPE_PRECISION (shorter_type)
- > TYPE_PRECISION (TREE_TYPE (arg1_unw)))
|| ((TYPE_PRECISION (shorter_type)
- == TYPE_PRECISION (TREE_TYPE (arg1_unw)))
+ >= TYPE_PRECISION (TREE_TYPE (arg1_unw)))
&& (TYPE_UNSIGNED (shorter_type)
== TYPE_UNSIGNED (TREE_TYPE (arg1_unw))))
|| (TREE_CODE (arg1_unw) == INTEGER_CST
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 54612cbdaff..a29d3db74e9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-08-14 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/37103
+ * gcc.c-torture/execute/20080813-1.c: New test.
+
2008-05-29 Eric Botcazou <ebotcazou@adacore.com>
* gcc.dg/nested-func-6.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20080813-1.c b/gcc/testsuite/gcc.c-torture/execute/20080813-1.c
new file mode 100644
index 00000000000..9ef6bc2e2c5
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20080813-1.c
@@ -0,0 +1,30 @@
+/* PR middle-end/37103 */
+
+extern void abort (void);
+
+void
+foo (unsigned short x)
+{
+ signed char y = -1;
+ if (x == y)
+ abort ();
+}
+
+void
+bar (unsigned short x)
+{
+ unsigned char y = -1;
+ if (x == y)
+ abort ();
+}
+
+int
+main (void)
+{
+ if (sizeof (int) == sizeof (short))
+ return 0;
+ foo (-1);
+ if (sizeof (short) > 1)
+ bar (-1);
+ return 0;
+}