]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fold-const.c (fold_widened_comparison): Do not allow sign-changes that change the...
authorRichard Guenther <rguenther@suse.de>
Tue, 8 Apr 2008 22:11:09 +0000 (22:11 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 8 Apr 2008 22:11:09 +0000 (22:11 +0000)
2008-04-08  Richard Guenther  <rguenther@suse.de>

* fold-const.c (fold_widened_comparison): Do not allow
sign-changes that change the result.

* gcc.c-torture/execute/20080408-1.c: New testcase.

From-SVN: r134113

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20080408-1.c [new file with mode: 0644]

index 9c9783256b06665c7dd2636ed4c19e48ea044639..f05e325860a8c602939110362d8b4f7750d72766 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-08  Richard Guenther  <rguenther@suse.de>
+
+       * fold-const.c (fold_widened_comparison): Do not allow
+       sign-changes that change the result.
+
 2008-03-25  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline:
index bac759ec053be9f780b6887a29711871c496e3ab..c394e5509e2f632d1801c252edbee1bea71beb4a 100644 (file)
@@ -6308,7 +6308,11 @@ fold_widened_comparison (enum tree_code code, tree type, tree arg0, tree arg1)
        || 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 (TREE_TYPE (arg1_unw)))
+         || ((TYPE_PRECISION (shorter_type)
+              == TYPE_PRECISION (TREE_TYPE (arg1_unw)))
+             && (TYPE_UNSIGNED (shorter_type)
+                 == TYPE_UNSIGNED (TREE_TYPE (arg1_unw))))
          || (TREE_CODE (arg1_unw) == INTEGER_CST
              && (TREE_CODE (shorter_type) == INTEGER_TYPE
                  || TREE_CODE (shorter_type) == BOOLEAN_TYPE)
index 4a6e9eb921880d066b4121ab794b4908744e8746..900ff9583f2548f4d172f60b389b683e2aab9366 100644 (file)
@@ -1,3 +1,7 @@
+2008-04-08  Richard Guenther  <rguenther@suse.de>
+
+       * gcc.c-torture/execute/20080408-1.c: New testcase.
+
 2008-03-25  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline:
diff --git a/gcc/testsuite/gcc.c-torture/execute/20080408-1.c b/gcc/testsuite/gcc.c-torture/execute/20080408-1.c
new file mode 100644 (file)
index 0000000..9e1ff63
--- /dev/null
@@ -0,0 +1,11 @@
+extern void abort (void);
+int main ()
+{
+  short ssi = 126;
+  unsigned short usi = 65280;
+  int fail = !(ssi < usi);
+  if (fail)
+    abort ();
+  return 0;
+}
+