aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorKazu Hirata <kazu@codesourcery.com>2006-01-28 05:19:44 +0000
committerKazu Hirata <kazu@gcc.gnu.org>2006-01-28 05:19:44 +0000
commite6620e86376c650754216a2bf4601e76cf15e9c8 (patch)
tree4ddc98ebd807edb66fa95964e68d043ebfd32d12 /gcc/testsuite
parentdadd8a3feb939f977b30b02e781133b315b117d4 (diff)
downloadgcc-e6620e86376c650754216a2bf4601e76cf15e9c8.zip
gcc-e6620e86376c650754216a2bf4601e76cf15e9c8.tar.gz
gcc-e6620e86376c650754216a2bf4601e76cf15e9c8.tar.bz2
re PR c/19606 (wrong code for arith.expr: (((unsigned int)(signed int) a ) / 2LL) with signed char a=-4)
gcc/ PR c/19606. * c-typeck.c (build_binary_op): Perform implicit casts of operands before shortening them. gcc/testsuite/ PR c/19606. * gcc.c-torture/execute/pr19606.c: New. From-SVN: r110321
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr19606.c34
2 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 50cc323..2f2f8c6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-01-28 Kazu Hirata <kazu@codesourcery.com>
+
+ PR c/19606.
+ * gcc.c-torture/execute/pr19606.c: New.
+
2006-01-27 Carlos O'Donell <carlos@codesourcery.com>
* gcc.dg/pragma-re-4.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr19606.c b/gcc/testsuite/gcc.c-torture/execute/pr19606.c
new file mode 100644
index 0000000..d1e836f
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr19606.c
@@ -0,0 +1,34 @@
+/* PR c/19606
+ The C front end used to shorten the type of a division to a type
+ that does not preserve the semantics of the original computation.
+ Make sure that won't happen. */
+
+signed char a = -4;
+
+int
+foo (void)
+{
+ return ((unsigned int) (signed int) a) / 2LL;
+}
+
+int
+bar (void)
+{
+ return ((unsigned int) (signed int) a) % 5LL;
+}
+
+int
+main (void)
+{
+ int r;
+
+ r = foo ();
+ if (r != ((unsigned int) (signed int) (signed char) -4) / 2LL)
+ abort ();
+
+ r = bar ();
+ if (r != ((unsigned int) (signed int) (signed char) -4) % 5LL)
+ abort ();
+
+ exit (0);
+}