This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
New test: Float_2.java
- From: Andrew Haley <aph at redhat dot com>
- To: "Rafael EspÃndola" <rafael dot espindola at gmail dot com>
- Cc: "GCC Mailing List" <gcc at gcc dot gnu dot org>
- Date: Mon, 3 Apr 2006 11:08:25 +0100
- Subject: New test: Float_2.java
- References: <564d96fb0603311720s7f55c880if5c93fe62bc95756@mail.gmail.com>
Rafael Espíndola writes:
> The attached patch removes the convert callback by
> 1) copying the c implementation of convert to convert2
> 2) changing all calls to convert in gcj and gfortran into calls to convert2
> 3) adding a lang prefix to the remaining implementations (cxx_, c_, gnat_)
> 4) renaming all convert calls in a front end to the corresponding implementation
> 5) coping convert_and_check and constant_fits_type_p into the c++
> front end so that it doesn't try to use convert2
> 6) renaming all the remaining calls to convert into convert2
> 7) removing the treelang, java and fortran implementation of convert
>
> This patch was bootstraped and regtested on a x86 without any regressions!
>
> I found a bit strange that there were no java regression since
> convert_ieee_real_to_integer is no longer used. Is a testcase missing?
There's one in mauve. I added this to the libgcj testsuite.
The libgcj testsuite isn't a complete test of the Java language, and I
don't think gcc developers would thank us if we made it one!
Andrew.
2006-04-03 Andrew Haley <aph@redhat.com>
* testsuite/libjava.lang/Float_2.java: New file.
Index: testsuite/libjava.lang/Float_2.java
===================================================================
--- testsuite/libjava.lang/Float_2.java (revision 0)
+++ testsuite/libjava.lang/Float_2.java (revision 0)
@@ -0,0 +1,138 @@
+// Test floating-point to integer conversion. We do this twice, once
+// with literal conversions that can be optimized away and once using
+// a static field that can't.
+
+public class Float_2
+{
+ public static double zero = 0.0;
+
+ public static void main (String argv[])
+ {
+ {
+ int itest = (int)(float)(0.0/0.0);
+ if (itest != 0)
+ System.err.println ("literal inf error 1: " + itest);
+ }
+ {
+ int itest = (int)(0.0/0.0);
+ if (itest != 0)
+ System.err.println ("literal inf error 2" + itest);
+ }
+ {
+ long ltest = (long)(0.0/0.0);
+ if (ltest != 0)
+ System.err.println ("literal inf error 3" + ltest);
+ }
+ {
+ long ltest = (long)(float)(0.0/0.0);
+ if (ltest != 0)
+ System.err.println ("literal inf error 4" + ltest);
+ }
+
+ {
+ int itest = (int)(float)(1.0/0.0);
+ if (itest != Integer.MAX_VALUE)
+ System.err.println ("literal max error 1: " + itest);
+ }
+ {
+ int itest = (int)(1.0/0.0);
+ if (itest != Integer.MAX_VALUE)
+ System.err.println ("literal max error 2" + itest);
+ }
+ {
+ long ltest = (long)(1.0/0.0);
+ if (ltest != Long.MAX_VALUE)
+ System.err.println ("literal max error 3" + ltest);
+ }
+ {
+ long ltest = (long)(float)(1.0/0.0);
+ if (ltest != Long.MAX_VALUE)
+ System.err.println ("literal max error 4" + ltest);
+ }
+
+ {
+ int itest = (int)(float)(-1.0/0.0);
+ if (itest != Integer.MIN_VALUE)
+ System.err.println ("literal min error 1: " + itest);
+ }
+ {
+ int itest = (int)(-1.0/0.0);
+ if (itest != Integer.MIN_VALUE)
+ System.err.println ("literal min error 2" + itest);
+ }
+ {
+ long ltest = (long)(-1.0/0.0);
+ if (ltest != Long.MIN_VALUE)
+ System.err.println ("literal min error 3" + ltest);
+ }
+ {
+ long ltest = (long)(float)(-1.0/0.0);
+ if (ltest != Long.MIN_VALUE)
+ System.err.println ("literal min error 4" + ltest);
+ }
+
+ {
+ int itest = (int)(float)(zero/zero);
+ if (itest != 0)
+ System.err.println ("calc inf error 1: " + itest);
+ }
+ {
+ int itest = (int)(zero/zero);
+ if (itest != 0)
+ System.err.println ("calc inf error 2" + itest);
+ }
+ {
+ long ltest = (long)(zero/zero);
+ if (ltest != 0)
+ System.err.println ("calc inf error 3" + ltest);
+ }
+ {
+ long ltest = (long)(float)(zero/zero);
+ if (ltest != 0)
+ System.err.println ("calc inf error 4" + ltest);
+ }
+
+ {
+ int itest = (int)(float)(1.0/zero);
+ if (itest != Integer.MAX_VALUE)
+ System.err.println ("calc max error 1: " + itest);
+ }
+ {
+ int itest = (int)(1.0/zero);
+ if (itest != Integer.MAX_VALUE)
+ System.err.println ("calc max error 2" + itest);
+ }
+ {
+ long ltest = (long)(1.0/zero);
+ if (ltest != Long.MAX_VALUE)
+ System.err.println ("calc max error 3" + ltest);
+ }
+ {
+ long ltest = (long)(float)(1.0/zero);
+ if (ltest != Long.MAX_VALUE)
+ System.err.println ("calc max error 4" + ltest);
+ }
+
+ {
+ int itest = (int)(float)(-1.0/zero);
+ if (itest != Integer.MIN_VALUE)
+ System.err.println ("calc min error 1: " + itest);
+ }
+ {
+ int itest = (int)(-1.0/zero);
+ if (itest != Integer.MIN_VALUE)
+ System.err.println ("calc min error 2" + itest);
+ }
+ {
+ long ltest = (long)(-1.0/zero);
+ if (ltest != Long.MIN_VALUE)
+ System.err.println ("calc min error 3" + ltest);
+ }
+ {
+ long ltest = (long)(float)(-1.0/zero);
+ if (ltest != Long.MIN_VALUE)
+ System.err.println ("calc min error 4" + ltest);
+ }
+
+ }
+}