aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2002-02-17 21:47:52 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2002-02-17 21:47:52 +0100
commitf6f8ada39ab16554f222bdc0a84a44689a44cc36 (patch)
treee63131501800d2d5c6229c295178c7ab46ee91c7 /gcc
parente16b32fc251052029bcccd99f6e90a52028b3af6 (diff)
downloadgcc-f6f8ada39ab16554f222bdc0a84a44689a44cc36.zip
gcc-f6f8ada39ab16554f222bdc0a84a44689a44cc36.tar.gz
gcc-f6f8ada39ab16554f222bdc0a84a44689a44cc36.tar.bz2
re PR c/3444 (Test fails (cast))
PR c/3444: * c-typeck.c (build_binary_op) [BIT_XOR_EXPR]: Remove explicit shortening. * typeck.c (build_binary_op) [BIT_XOR_EXPR]: Remove explicit shortening. * gcc.c-torture/execute/20020216-1.c: New test. From-SVN: r49825
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/c-typeck.c23
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/typeck.c25
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20020216-1.c24
6 files changed, 39 insertions, 48 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0e5ed7a..700f7a4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2002-02-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/3444:
+ * c-typeck.c (build_binary_op) [BIT_XOR_EXPR]: Remove explicit
+ shortening.
+
2002-02-17 Philipp Thomas <pthomas@suse.de>
* config/cris/cris.h: Undefine STARTFILE_SPEC and
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 3e00e04..dd8abdd 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -2060,29 +2060,6 @@ build_binary_op (code, orig_op0, orig_op1, convert_p)
case BIT_XOR_EXPR:
if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
shorten = -1;
- /* If one operand is a constant, and the other is a short type
- that has been converted to an int,
- really do the work in the short type and then convert the
- result to int. If we are lucky, the constant will be 0 or 1
- in the short type, making the entire operation go away. */
- if (TREE_CODE (op0) == INTEGER_CST
- && TREE_CODE (op1) == NOP_EXPR
- && TYPE_PRECISION (type1) > TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op1, 0)))
- && TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op1, 0))))
- {
- final_type = result_type;
- op1 = TREE_OPERAND (op1, 0);
- result_type = TREE_TYPE (op1);
- }
- if (TREE_CODE (op1) == INTEGER_CST
- && TREE_CODE (op0) == NOP_EXPR
- && TYPE_PRECISION (type0) > TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0, 0)))
- && TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op0, 0))))
- {
- final_type = result_type;
- op0 = TREE_OPERAND (op0, 0);
- result_type = TREE_TYPE (op0);
- }
break;
case TRUNC_MOD_EXPR:
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b8f7628..872ad4f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2002-02-17 Jakub Jelinek <jakub@redhat.com>
+
+ * typeck.c (build_binary_op) [BIT_XOR_EXPR]: Remove explicit
+ shortening.
+
2002-02-15 Nathan Sidwell <nathan@codesourcery.com>
* decl.c (grokdeclarator): Set typedef_decl for all TYPE_DECLs,
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 4d0cf78..62d17a8 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -3514,31 +3514,6 @@ build_binary_op (code, orig_op0, orig_op1, convert_p)
case BIT_XOR_EXPR:
if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
shorten = -1;
- /* If one operand is a constant, and the other is a short type
- that has been converted to an int,
- really do the work in the short type and then convert the
- result to int. If we are lucky, the constant will be 0 or 1
- in the short type, making the entire operation go away. */
- if (TREE_CODE (op0) == INTEGER_CST
- && TREE_CODE (op1) == NOP_EXPR
- && (TYPE_PRECISION (type1)
- > TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op1, 0))))
- && TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op1, 0))))
- {
- final_type = result_type;
- op1 = TREE_OPERAND (op1, 0);
- result_type = TREE_TYPE (op1);
- }
- if (TREE_CODE (op1) == INTEGER_CST
- && TREE_CODE (op0) == NOP_EXPR
- && (TYPE_PRECISION (type0)
- > TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0, 0))))
- && TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op0, 0))))
- {
- final_type = result_type;
- op0 = TREE_OPERAND (op0, 0);
- result_type = TREE_TYPE (op0);
- }
break;
case TRUNC_MOD_EXPR:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 48bc0e1..1e1538d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2002-02-17 Jakub Jelinek <jakub@redhat.com>
+
+ * gcc.c-torture/execute/20020216-1.c: New test.
+
2002-02-16 Neil Booth <neil@daikokuya.demon.co.uk>
* gcc.dg/decl-1.c: Update, new test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20020216-1.c b/gcc/testsuite/gcc.c-torture/execute/20020216-1.c
new file mode 100644
index 0000000..bf62de5
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20020216-1.c
@@ -0,0 +1,24 @@
+/* PR c/3444
+ This used to fail because bitwise xor was improperly computed in char type
+ and sign extended to int type. */
+
+extern void abort ();
+extern void exit (int);
+
+signed char c = (signed char) 0xffffffff;
+
+int foo (void)
+{
+ return (unsigned short) c ^ (signed char) 0x99999999;
+}
+
+int main (void)
+{
+ if ((unsigned char) -1 != 0xff
+ || sizeof (short) != 2
+ || sizeof (int) != 4)
+ exit (0);
+ if (foo () != (int) 0xffff0066)
+ abort ();
+ exit (0);
+}