mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-24 06:49:02 +08:00
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
This commit is contained in:
parent
e16b32fc25
commit
f6f8ada39a
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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,
|
||||
|
@ -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:
|
||||
|
@ -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.
|
||||
|
24
gcc/testsuite/gcc.c-torture/execute/20020216-1.c
Normal file
24
gcc/testsuite/gcc.c-torture/execute/20020216-1.c
Normal file
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user