OSDN Git Service

PR java/15543
[pf3gnuchains/gcc-fork.git] / gcc / java / typeck.c
index 5c38bb8..dcd201d 100644 (file)
@@ -83,22 +83,24 @@ convert_ieee_real_to_integer (tree type, tree expr)
   tree result;
   expr = save_expr (expr);
 
-  result = build3 (COND_EXPR, type,
-                  build2 (NE_EXPR, boolean_type_node, expr, expr),
-                  convert (type, integer_zero_node),
-                  convert_to_integer (type, expr));
-                 
-  result = build3 (COND_EXPR, type, 
-                  build2 (LE_EXPR, boolean_type_node, expr, 
-                          convert (TREE_TYPE (expr), TYPE_MIN_VALUE (type))),
-                  TYPE_MIN_VALUE (type),
-                  result);
-
-  result = build3 (COND_EXPR, type,
-                  build2 (GE_EXPR, boolean_type_node, expr, 
-                          convert (TREE_TYPE (expr), TYPE_MAX_VALUE (type))),  
-                  TYPE_MAX_VALUE (type),
-                  result);
+  result = fold (build3 (COND_EXPR, type,
+                        fold (build2 (NE_EXPR, boolean_type_node, expr, expr)),
+                        convert (type, integer_zero_node),
+                        convert_to_integer (type, expr)));
+  
+  result = fold (build3 (COND_EXPR, type, 
+                        fold (build2 (LE_EXPR, boolean_type_node, expr, 
+                                      convert (TREE_TYPE (expr), 
+                                               TYPE_MIN_VALUE (type)))),
+                        TYPE_MIN_VALUE (type),
+                        result));
+  
+  result = fold (build3 (COND_EXPR, type,
+                        fold (build2 (GE_EXPR, boolean_type_node, expr, 
+                                      convert (TREE_TYPE (expr), 
+                                               TYPE_MAX_VALUE (type)))),
+                        TYPE_MAX_VALUE (type),
+                        result));
 
   return result;
 }  
@@ -127,12 +129,13 @@ convert (tree type, tree expr)
     return error_mark_node;
   if (code == VOID_TYPE)
     return build1 (CONVERT_EXPR, type, expr);
-  if (code == BOOLEAN_TYPE)
-    return fold (convert_to_boolean (type, expr));
+  if (code == BOOLEAN_TYPE || code ==  CHAR_TYPE)
+    return fold_convert (type, expr);
   if (code == INTEGER_TYPE)
     {
-      if (! flag_unsafe_math_optimizations
-         && ! flag_emit_class_files
+      if ((really_constant_p (expr)
+          || (! flag_unsafe_math_optimizations
+              && ! flag_emit_class_files))
          && TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE
          && TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT)
        return fold (convert_ieee_real_to_integer (type, expr));
@@ -148,8 +151,6 @@ convert (tree type, tree expr)
     }    
   if (code == REAL_TYPE)
     return fold (convert_to_real (type, expr));
-  if (code == CHAR_TYPE)
-    return fold (convert_to_char (type, expr));
   if (code == POINTER_TYPE)
     return fold (convert_to_pointer (type, expr));
   error ("conversion to non-scalar type requested");
@@ -157,18 +158,6 @@ convert (tree type, tree expr)
 }
 
 
-tree
-convert_to_char (tree type, tree expr)
-{
-  return build1 (NOP_EXPR, type, expr);
-}
-
-tree
-convert_to_boolean (tree type, tree expr)
-{
-  return build1 (NOP_EXPR, type, expr);
-}
-
 /* Return a data type that has machine mode MODE.
    If the mode is an integer,
    then UNSIGNEDP selects between signed and unsigned types.  */
@@ -354,8 +343,7 @@ build_prim_array_type (tree element_type, HOST_WIDE_INT length)
 
   if (length != -1)
     {
-      tree max_index = build_int_2 (length - 1, (0 == length ? -1 : 0));
-      TREE_TYPE (max_index) = sizetype;
+      tree max_index = build_int_cst (sizetype, length - 1);
       index = build_index_type (max_index);
     }
   return build_array_type (element_type, index);
@@ -504,7 +492,7 @@ parse_signature_type (const unsigned char **ptr, const unsigned char *limit)
              break;
          }
        *ptr = str+1;
-       type = lookup_class (unmangle_classname (start, str - start));
+       type = lookup_class (unmangle_classname ((const char *) start, str - start));
        break;
       }
     default:
@@ -741,7 +729,7 @@ lookup_java_method (tree searched_class, tree method_name,
                    method_signature, build_java_signature);
 }
 
-/* Return true iff CLASS (or its ancestors) has a method METHOD_NAME.  */
+/* Return true iff CLASS (or its ancestors) has a method METHOD_NAME.  */
 int
 has_method (tree class, tree method_name)
 {