re GNATS gcj/82 (code generation for jvm IRETURN fails on boolean/byte/short methods...
authorPekka Nikander <pekka.nikander@hut.fi>
Fri, 18 Feb 2000 18:17:37 +0000 (20:17 +0200)
committerAlexandre Petit-Bianco <apbianco@gcc.gnu.org>
Fri, 18 Feb 2000 18:17:37 +0000 (10:17 -0800)
Wed Nov 03 02:16:00 PST 1999  Pekka Nikander  <pekka.nikander@hut.fi>

* decl.c (INT_TYPE_SIZE): Define if necessary.
(expand_java_return): Handle the case of a native integer smaller
  than a JVM integer.

(Fix to the Java PR #82:
  http://sourceware.cygnus.com/ml/java-prs/1999-q4/msg00078.html)

From-SVN: r32051

gcc/java/ChangeLog
gcc/java/expr.c

index 73f2054968b537533ef6d4222e7327040b675ae7..e3b199277581b3f9be42989edda3ff2d43410fcb 100644 (file)
@@ -1,3 +1,9 @@
+Wed Nov 03 02:16:00 PST 1999  Pekka Nikander  <pekka.nikander@hut.fi>
+
+       * decl.c (INT_TYPE_SIZE): Define if necessary.
+       (expand_java_return): Handle the case of a native integer smaller
+       than a JVM integer.
+
 2000-02-18  Martin von Loewis  <loewis@informatik.hu-berlin.de>
 
        * gjavah.c (help): Use GCCBUGURL.
index 3c1c0ffbd3ddabcc089ae60d4767035bcb1646d6..f25b1940a91fb7a993e7011915eb39085b221054 100644 (file)
@@ -981,6 +981,10 @@ expand_java_pushc (ival, type)
   push_value (value);
 }
 
+#ifndef INT_TYPE_SIZE
+#define INT_TYPE_SIZE BITS_PER_WORD
+#endif
+
 static void
 expand_java_return (type)
      tree type;
@@ -992,6 +996,16 @@ expand_java_return (type)
       tree retval = pop_value (type);
       tree res = DECL_RESULT (current_function_decl);
       retval = build (MODIFY_EXPR, TREE_TYPE (res), res, retval);
+
+      /* Handle the situation where the native integer type is smaller
+        than the JVM integer. It can happen for many cross compilers.
+        The whole if expression just goes away if INT_TYPE_SIZE < 32
+        is false. */
+      if (INT_TYPE_SIZE < 32
+         && (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (res)))
+             < GET_MODE_SIZE (TYPE_MODE (type))))
+       retval = build1(NOP_EXPR, TREE_TYPE(res), retval);
+      
       TREE_SIDE_EFFECTS (retval) = 1;
       expand_return (retval);
     }