PR java/21540, PR java/13788:
gcc/java/: PR java/21540, PR java/13788: * parse.y (java_complete_lhs) <CASE_EXPR>: Use fold_constant_for_init. (patch_binop): Added 'folding' argument. Updated all callers. (patch_unaryop) <NOP_EXPR>: New case. (fold_constant_for_init) <NOP_EXPR>: Likewise. (fold_constant_for_init) <COND_EXPR>: Fix sense of test. libjava/: PR java/21540, PR java/13788: * testsuite/libjava.compile/pr21540.java: New file. * testsuite/libjava.compile/pr13788.java: New file. * testsuite/libjava.jacks/jacks.xfail: Updated. From-SVN: r101358
This commit is contained in:
parent
d994b336c8
commit
4ebe7d9317
6 changed files with 64 additions and 33 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
2005-06-27 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
PR java/21540, PR java/13788:
|
||||||
|
* parse.y (java_complete_lhs) <CASE_EXPR>: Use
|
||||||
|
fold_constant_for_init.
|
||||||
|
(patch_binop): Added 'folding' argument. Updated all callers.
|
||||||
|
(patch_unaryop) <NOP_EXPR>: New case.
|
||||||
|
(fold_constant_for_init) <NOP_EXPR>: Likewise.
|
||||||
|
(fold_constant_for_init) <COND_EXPR>: Fix sense of test.
|
||||||
|
|
||||||
2005-06-25 Jan Hubicka <jh@suse.cz>
|
2005-06-25 Jan Hubicka <jh@suse.cz>
|
||||||
|
|
||||||
* builtins.c (define_builtin): Accept new flags parameter.
|
* builtins.c (define_builtin): Accept new flags parameter.
|
||||||
|
|
|
@ -161,7 +161,7 @@ static tree build_new_invocation (tree, tree);
|
||||||
static tree build_assignment (int, int, tree, tree);
|
static tree build_assignment (int, int, tree, tree);
|
||||||
static tree build_binop (enum tree_code, int, tree, tree);
|
static tree build_binop (enum tree_code, int, tree, tree);
|
||||||
static tree patch_assignment (tree, tree);
|
static tree patch_assignment (tree, tree);
|
||||||
static tree patch_binop (tree, tree, tree);
|
static tree patch_binop (tree, tree, tree, int);
|
||||||
static tree build_unaryop (int, int, tree);
|
static tree build_unaryop (int, int, tree);
|
||||||
static tree build_incdec (int, int, tree, int);
|
static tree build_incdec (int, int, tree, int);
|
||||||
static tree patch_unaryop (tree, tree);
|
static tree patch_unaryop (tree, tree);
|
||||||
|
@ -11791,8 +11791,13 @@ java_complete_lhs (tree node)
|
||||||
|
|
||||||
/* First, the case expression must be constant. Values of final
|
/* First, the case expression must be constant. Values of final
|
||||||
fields are accepted. */
|
fields are accepted. */
|
||||||
|
nn = fold_constant_for_init (cn, NULL_TREE);
|
||||||
|
if (nn != NULL_TREE)
|
||||||
|
cn = nn;
|
||||||
|
|
||||||
cn = fold (cn);
|
cn = fold (cn);
|
||||||
if ((TREE_CODE (cn) == COMPOUND_EXPR || TREE_CODE (cn) == COMPONENT_REF)
|
if ((TREE_CODE (cn) == COMPOUND_EXPR
|
||||||
|
|| TREE_CODE (cn) == COMPONENT_REF)
|
||||||
&& JDECL_P (TREE_OPERAND (cn, 1))
|
&& JDECL_P (TREE_OPERAND (cn, 1))
|
||||||
&& FIELD_FINAL (TREE_OPERAND (cn, 1))
|
&& FIELD_FINAL (TREE_OPERAND (cn, 1))
|
||||||
&& DECL_INITIAL (TREE_OPERAND (cn, 1)))
|
&& DECL_INITIAL (TREE_OPERAND (cn, 1)))
|
||||||
|
@ -12303,12 +12308,12 @@ java_complete_lhs (tree node)
|
||||||
|
|
||||||
TREE_OPERAND (node, 1) = nn;
|
TREE_OPERAND (node, 1) = nn;
|
||||||
}
|
}
|
||||||
return patch_binop (node, wfl_op1, wfl_op2);
|
return patch_binop (node, wfl_op1, wfl_op2, 0);
|
||||||
|
|
||||||
case INSTANCEOF_EXPR:
|
case INSTANCEOF_EXPR:
|
||||||
wfl_op1 = TREE_OPERAND (node, 0);
|
wfl_op1 = TREE_OPERAND (node, 0);
|
||||||
COMPLETE_CHECK_OP_0 (node);
|
COMPLETE_CHECK_OP_0 (node);
|
||||||
return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1));
|
return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1), 0);
|
||||||
|
|
||||||
case UNARY_PLUS_EXPR:
|
case UNARY_PLUS_EXPR:
|
||||||
case NEGATE_EXPR:
|
case NEGATE_EXPR:
|
||||||
|
@ -13442,7 +13447,7 @@ java_refold (tree t)
|
||||||
of remaining nodes and detects more errors in certain cases. */
|
of remaining nodes and detects more errors in certain cases. */
|
||||||
|
|
||||||
static tree
|
static tree
|
||||||
patch_binop (tree node, tree wfl_op1, tree wfl_op2)
|
patch_binop (tree node, tree wfl_op1, tree wfl_op2, int folding)
|
||||||
{
|
{
|
||||||
tree op1 = TREE_OPERAND (node, 0);
|
tree op1 = TREE_OPERAND (node, 0);
|
||||||
tree op2 = TREE_OPERAND (node, 1);
|
tree op2 = TREE_OPERAND (node, 1);
|
||||||
|
@ -13624,16 +13629,14 @@ patch_binop (tree node, tree wfl_op1, tree wfl_op2)
|
||||||
build_int_cst (NULL_TREE, 0x3f)));
|
build_int_cst (NULL_TREE, 0x3f)));
|
||||||
|
|
||||||
/* The >>> operator is a >> operating on unsigned quantities */
|
/* The >>> operator is a >> operating on unsigned quantities */
|
||||||
if (code == URSHIFT_EXPR && ! flag_emit_class_files)
|
if (code == URSHIFT_EXPR && (folding || ! flag_emit_class_files))
|
||||||
{
|
{
|
||||||
tree to_return;
|
tree to_return;
|
||||||
tree utype = java_unsigned_type (prom_type);
|
tree utype = java_unsigned_type (prom_type);
|
||||||
op1 = convert (utype, op1);
|
op1 = convert (utype, op1);
|
||||||
TREE_SET_CODE (node, RSHIFT_EXPR);
|
|
||||||
TREE_OPERAND (node, 0) = op1;
|
to_return = fold_build2 (RSHIFT_EXPR, utype, op1, op2);
|
||||||
TREE_OPERAND (node, 1) = op2;
|
to_return = convert (prom_type, to_return);
|
||||||
TREE_TYPE (node) = utype;
|
|
||||||
to_return = convert (prom_type, node);
|
|
||||||
/* Copy the original value of the COMPOUND_ASSIGN_P flag */
|
/* Copy the original value of the COMPOUND_ASSIGN_P flag */
|
||||||
COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
|
COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
|
||||||
TREE_SIDE_EFFECTS (to_return)
|
TREE_SIDE_EFFECTS (to_return)
|
||||||
|
@ -14413,6 +14416,12 @@ patch_unaryop (tree node, tree wfl_op)
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case NOP_EXPR:
|
||||||
|
/* This can only happen when the type is already known. */
|
||||||
|
gcc_assert (TREE_TYPE (node) != NULL_TREE);
|
||||||
|
prom_type = TREE_TYPE (node);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error_found)
|
if (error_found)
|
||||||
|
@ -16214,13 +16223,14 @@ fold_constant_for_init (tree node, tree context)
|
||||||
if (val == NULL_TREE || ! TREE_CONSTANT (val))
|
if (val == NULL_TREE || ! TREE_CONSTANT (val))
|
||||||
return NULL_TREE;
|
return NULL_TREE;
|
||||||
TREE_OPERAND (node, 1) = val;
|
TREE_OPERAND (node, 1) = val;
|
||||||
return patch_binop (node, op0, op1);
|
return patch_binop (node, op0, op1, 1);
|
||||||
|
|
||||||
case UNARY_PLUS_EXPR:
|
case UNARY_PLUS_EXPR:
|
||||||
case NEGATE_EXPR:
|
case NEGATE_EXPR:
|
||||||
case TRUTH_NOT_EXPR:
|
case TRUTH_NOT_EXPR:
|
||||||
case BIT_NOT_EXPR:
|
case BIT_NOT_EXPR:
|
||||||
case CONVERT_EXPR:
|
case CONVERT_EXPR:
|
||||||
|
case NOP_EXPR:
|
||||||
op0 = TREE_OPERAND (node, 0);
|
op0 = TREE_OPERAND (node, 0);
|
||||||
val = fold_constant_for_init (op0, context);
|
val = fold_constant_for_init (op0, context);
|
||||||
if (val == NULL_TREE || ! TREE_CONSTANT (val))
|
if (val == NULL_TREE || ! TREE_CONSTANT (val))
|
||||||
|
@ -16246,8 +16256,8 @@ fold_constant_for_init (tree node, tree context)
|
||||||
if (val == NULL_TREE || ! TREE_CONSTANT (val))
|
if (val == NULL_TREE || ! TREE_CONSTANT (val))
|
||||||
return NULL_TREE;
|
return NULL_TREE;
|
||||||
TREE_OPERAND (node, 2) = val;
|
TREE_OPERAND (node, 2) = val;
|
||||||
return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1)
|
return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 2)
|
||||||
: TREE_OPERAND (node, 2);
|
: TREE_OPERAND (node, 1);
|
||||||
|
|
||||||
case VAR_DECL:
|
case VAR_DECL:
|
||||||
case FIELD_DECL:
|
case FIELD_DECL:
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
2005-06-27 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
PR java/21540, PR java/13788:
|
||||||
|
* testsuite/libjava.compile/pr21540.java: New file.
|
||||||
|
* testsuite/libjava.compile/pr13788.java: New file.
|
||||||
|
* testsuite/libjava.jacks/jacks.xfail: Updated.
|
||||||
|
|
||||||
2005-06-26 Andreas Tobler <a.tobler@schweiz.ch>
|
2005-06-26 Andreas Tobler <a.tobler@schweiz.ch>
|
||||||
|
|
||||||
* testsuite/libjava.mauve/xfails: Updated to reflect current state
|
* testsuite/libjava.mauve/xfails: Updated to reflect current state
|
||||||
|
|
8
libjava/testsuite/libjava.compile/pr13788.java
Normal file
8
libjava/testsuite/libjava.compile/pr13788.java
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
class pr13788 {
|
||||||
|
private static final int DUMMY1 = 1 >>> 1;
|
||||||
|
|
||||||
|
public static void main(String [] args) {
|
||||||
|
System.out.println(DUMMY1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
15
libjava/testsuite/libjava.compile/pr21540.java
Normal file
15
libjava/testsuite/libjava.compile/pr21540.java
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
public class pr21540
|
||||||
|
{
|
||||||
|
public static final long xxx = 555;
|
||||||
|
|
||||||
|
public boolean fn (int v)
|
||||||
|
{
|
||||||
|
switch (v)
|
||||||
|
{
|
||||||
|
case ((int) xxx >>> 32):
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -274,9 +274,7 @@
|
||||||
15.28-null-1
|
15.28-null-1
|
||||||
15.28-null-3
|
15.28-null-3
|
||||||
15.28-primitive-15
|
15.28-primitive-15
|
||||||
15.28-primitive-16
|
|
||||||
15.28-primitive-17
|
15.28-primitive-17
|
||||||
15.28-primitive-9
|
|
||||||
15.28-qualified-name-10
|
15.28-qualified-name-10
|
||||||
15.28-qualified-name-5
|
15.28-qualified-name-5
|
||||||
15.28-qualified-name-6
|
15.28-qualified-name-6
|
||||||
|
@ -294,7 +292,6 @@
|
||||||
15.28-simple-namestr-4
|
15.28-simple-namestr-4
|
||||||
15.28-string-11
|
15.28-string-11
|
||||||
15.28-string-15
|
15.28-string-15
|
||||||
15.28-string-16
|
|
||||||
15.28-string-17
|
15.28-string-17
|
||||||
15.28-string-18
|
15.28-string-18
|
||||||
15.28-string-2
|
15.28-string-2
|
||||||
|
@ -456,27 +453,11 @@
|
||||||
5.1.2-btf-1
|
5.1.2-btf-1
|
||||||
5.1.2-btf-3
|
5.1.2-btf-3
|
||||||
5.1.2-btf-5
|
5.1.2-btf-5
|
||||||
5.1.2-bti-1
|
|
||||||
5.1.2-bti-3
|
|
||||||
5.1.2-bti-5
|
|
||||||
5.1.2-btl-1
|
|
||||||
5.1.2-btl-3
|
|
||||||
5.1.2-btl-5
|
|
||||||
5.1.2-bts-1
|
|
||||||
5.1.2-bts-2
|
|
||||||
5.1.2-bts-3
|
|
||||||
5.1.2-bts-4
|
|
||||||
5.1.2-bts-5
|
|
||||||
5.1.2-std-3
|
5.1.2-std-3
|
||||||
5.1.2-std-5
|
5.1.2-std-5
|
||||||
5.1.2-stf-1
|
5.1.2-stf-1
|
||||||
5.1.2-stf-3
|
5.1.2-stf-3
|
||||||
5.1.2-stf-5
|
5.1.2-stf-5
|
||||||
5.1.2-sti-1
|
|
||||||
5.1.2-sti-5
|
|
||||||
5.1.2-stl-1
|
|
||||||
5.1.2-stl-3
|
|
||||||
5.1.2-stl-5
|
|
||||||
6.3-1
|
6.3-1
|
||||||
6.5.1-type-15
|
6.5.1-type-15
|
||||||
6.5.1-type-16
|
6.5.1-type-16
|
||||||
|
|
Loading…
Add table
Reference in a new issue