This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: PR java/25676
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: 04 Feb 2006 16:28:34 -0700
- Subject: Patch: FYI: PR java/25676
- Reply-to: tromey at redhat dot com
I'm checking this in on the trunk.
This fixes PR 25676. We were incorrectly changing Math.min() into
MIN_EXPR (and likewise for max) for floating point types. This is
incorrect for java due to the special handling of -0.0 in Math.min.
Test case included.
Tom
2006-02-04 Tom Tromey <tromey@redhat.com>
PR java/25676:
* builtins.c (max_builtin): Skip floating point 'max'.
(min_builtin): Skip floating point 'min'.
(check_for_builtin): Never return NULL_TREE.
2006-02-04 Tom Tromey <tromey@redhat.com>
PR java/25676:
* testsuite/libjava.lang/pr25676.out: New file.
* testsuite/libjava.lang/pr25676.java: New file.
Index: gcc/java/builtins.c
===================================================================
--- gcc/java/builtins.c (revision 110597)
+++ gcc/java/builtins.c (working copy)
@@ -1,5 +1,5 @@
/* Built-in and inline functions for gcj
- Copyright (C) 2001, 2003, 2004, 2005
+ Copyright (C) 2001, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of GCC.
@@ -94,6 +94,9 @@
static tree
max_builtin (tree method_return_type, tree method_arguments)
{
+ /* MAX_EXPR does not handle -0.0 in the Java style. */
+ if (TREE_CODE (method_return_type) == REAL_TYPE)
+ return NULL_TREE;
return fold_build2 (MAX_EXPR, method_return_type,
TREE_VALUE (method_arguments),
TREE_VALUE (TREE_CHAIN (method_arguments)));
@@ -102,6 +105,9 @@
static tree
min_builtin (tree method_return_type, tree method_arguments)
{
+ /* MIN_EXPR does not handle -0.0 in the Java style. */
+ if (TREE_CODE (method_return_type) == REAL_TYPE)
+ return NULL_TREE;
return fold_build2 (MIN_EXPR, method_return_type,
TREE_VALUE (method_arguments),
TREE_VALUE (TREE_CHAIN (method_arguments)));
@@ -265,11 +271,15 @@
tree fn;
if (java_builtins[i].creator != NULL)
- return (*java_builtins[i].creator) (method_return_type,
- method_arguments);
+ {
+ tree result
+ = (*java_builtins[i].creator) (method_return_type,
+ method_arguments);
+ return result == NULL_TREE ? call : result;
+ }
fn = built_in_decls[java_builtins[i].builtin_code];
if (fn == NULL_TREE)
- return NULL_TREE;
+ return call;
return java_build_function_call_expr (fn, method_arguments);
}
}
Index: libjava/testsuite/libjava.lang/pr25676.java
===================================================================
--- libjava/testsuite/libjava.lang/pr25676.java (revision 0)
+++ libjava/testsuite/libjava.lang/pr25676.java (revision 0)
@@ -0,0 +1,12 @@
+public class pr25676
+{
+ public static double g(double a, double b)
+ {
+ return Math.min(a, b);
+ }
+ public static void main(String a[])
+ {
+ System.out.println (g(0.0, -0.0));
+ System.out.println (g(-0.0, 0.0));
+ }
+}
Index: libjava/testsuite/libjava.lang/pr25676.out
===================================================================
--- libjava/testsuite/libjava.lang/pr25676.out (revision 0)
+++ libjava/testsuite/libjava.lang/pr25676.out (revision 0)
@@ -0,0 +1,2 @@
+-0.0
+-0.0