OSDN Git Service

* java-tree.h (push_labeled_block, pop_labeled_block): Remove.
[pf3gnuchains/gcc-fork.git] / gcc / java / lang.c
index bcf4e45..693193d 100644 (file)
@@ -1,6 +1,6 @@
 /* Java(TM) language-specific utility routines.
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
-   Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+   2005, 2006, 2007 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -16,8 +16,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.
 
 Java and all Java-based marks are trademarks or registered trademarks
 of Sun Microsystems, Inc. in the United States and other countries.
@@ -39,7 +39,6 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #include "langhooks.h"
 #include "langhooks-def.h"
 #include "flags.h"
-#include "xref.h"
 #include "ggc.h"
 #include "diagnostic.h"
 #include "tree-inline.h"
@@ -61,7 +60,6 @@ static tree java_tree_inlining_walk_subtrees (tree *, int *, walk_tree_fn,
                                              void *, struct pointer_set_t *);
 static int merge_init_test_initialization (void * *, void *);
 static int inline_init_test_initialization (void * *, void *);
-static bool java_can_use_bit_fields_p (void);
 static bool java_dump_tree (void *, tree);
 static void dump_compound_expr (dump_info_p, tree);
 static bool java_decl_ok_for_sibcall (tree);
@@ -109,25 +107,23 @@ const char *const tree_code_name[] = {
 };
 #undef DEFTREECODE
 
+/* Table of machine-independent attributes.  */
+const struct attribute_spec java_attribute_table[] =
+{
+ { "nonnull",                0, -1, false, true, true,
+                             NULL },
+  { NULL,                     0, 0, false, false, false, NULL }
+};
+
 /* Used to avoid printing error messages with bogus function
    prototypes.  Starts out false.  */
 static bool inhibit_error_function_printing;
 
-int compiling_from_source;
-
 const char *resource_name;
 
-/* When nonzero, we emit xref strings. Values of the flag for xref
-   backends are defined in xref_flag_table, xref.c.  */
-
-int flag_emit_xref = 0;
-
 /* When nonzero, -Wall was turned on.  */
 int flag_wall = 0;
 
-/* The encoding of the source file.  */
-const char *current_encoding = NULL;
-
 /* When nonzero, report use of deprecated classes, methods, or fields.  */
 int flag_deprecated = 1;
 
@@ -175,27 +171,17 @@ struct language_function GTY(())
 #define LANG_HOOKS_PARSE_FILE java_parse_file
 #undef LANG_HOOKS_MARK_ADDRESSABLE
 #define LANG_HOOKS_MARK_ADDRESSABLE java_mark_addressable
-#undef LANG_HOOKS_TRUTHVALUE_CONVERSION
-#define LANG_HOOKS_TRUTHVALUE_CONVERSION java_truthvalue_conversion
 #undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
 #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL java_dup_lang_specific_decl
 #undef LANG_HOOKS_DECL_PRINTABLE_NAME
 #define LANG_HOOKS_DECL_PRINTABLE_NAME lang_printable_name
 #undef LANG_HOOKS_PRINT_ERROR_FUNCTION
 #define LANG_HOOKS_PRINT_ERROR_FUNCTION        java_print_error_function
-#undef LANG_HOOKS_CAN_USE_BIT_FIELDS_P
-#define LANG_HOOKS_CAN_USE_BIT_FIELDS_P java_can_use_bit_fields_p
 
 #undef LANG_HOOKS_TYPE_FOR_MODE
 #define LANG_HOOKS_TYPE_FOR_MODE java_type_for_mode
 #undef LANG_HOOKS_TYPE_FOR_SIZE
 #define LANG_HOOKS_TYPE_FOR_SIZE java_type_for_size
-#undef LANG_HOOKS_SIGNED_TYPE
-#define LANG_HOOKS_SIGNED_TYPE java_signed_type
-#undef LANG_HOOKS_UNSIGNED_TYPE
-#define LANG_HOOKS_UNSIGNED_TYPE java_unsigned_type
-#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
-#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE java_signed_or_unsigned_type
 
 #undef LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN
 #define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN java_dump_tree
@@ -218,6 +204,12 @@ struct language_function GTY(())
 #undef LANG_HOOKS_CLEAR_BINDING_STACK
 #define LANG_HOOKS_CLEAR_BINDING_STACK java_clear_binding_stack
 
+#undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
+#define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME java_mangle_decl
+
+#undef LANG_HOOKS_ATTRIBUTE_TABLE
+#define LANG_HOOKS_ATTRIBUTE_TABLE java_attribute_table
+
 /* Each front end provides its own.  */
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
@@ -272,8 +264,6 @@ java_handle_option (size_t scode, const char *arg, int value)
 
     case OPT_Wall:
       flag_wall = value;
-      flag_redundant = value;
-      flag_extraneous_semicolon = value;
       /* When -Wall given, enable -Wunused.  We do this because the C
         compiler does it, and people expect it.  */
       set_Wunused (value);
@@ -307,6 +297,7 @@ java_handle_option (size_t scode, const char *arg, int value)
       jcf_path_bootclasspath_arg (arg);
       break;
 
+    case OPT_faux_classpath:
     case OPT_fclasspath_:
     case OPT_fCLASSPATH_:
       jcf_path_classpath_arg (arg);
@@ -322,7 +313,7 @@ java_handle_option (size_t scode, const char *arg, int value)
       break;
 
     case OPT_fencoding_:
-      current_encoding = arg;
+      /* Nothing.  */
       break;
 
     case OPT_fextdirs_:
@@ -330,17 +321,21 @@ java_handle_option (size_t scode, const char *arg, int value)
       break;
 
     case OPT_foutput_class_dir_:
-      jcf_write_base_directory = arg;
+      /* FIXME: remove; this is handled by ecj1 now.  */
       break;
 
     case OPT_version:
       v_flag = 1;
       break;
       
+    case OPT_fsource_filename_:
+      java_read_sourcefilenames (arg);
+      break;
+      
     default:
       if (cl_options[code].flags & CL_Java)
        break;
-      abort();
+      gcc_unreachable ();
     }
 
   return 1;
@@ -352,22 +347,13 @@ FILE *finput;
 static bool
 java_init (void)
 {
-#if 0
-  extern int flag_minimal_debug;
-  flag_minimal_debug = 0;
-#endif
-
   /* FIXME: Indirect dispatch isn't yet compatible with static class
      init optimization.  */
   if (flag_indirect_dispatch)
     always_initialize_class_p = true;
 
-  /* Force minimum function alignment if g++ uses the least significant
-     bit of function pointers to store the virtual bit. This is required
-     to keep vtables compatible.  */
-  if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn
-      && force_align_functions_log < 1)
-    force_align_functions_log = 1;
+  if (!flag_indirect_dispatch)
+    flag_indirect_classes = false;
 
   jcf_path_seal (v_flag);
 
@@ -406,7 +392,7 @@ put_decl_string (const char *str, int len)
       if (decl_buf == NULL)
        {
          decl_buflen = len + 100;
-         decl_buf = xmalloc (decl_buflen);
+         decl_buf = XNEWVEC (char, decl_buflen);
        }
       else
        {
@@ -579,19 +565,15 @@ java_init_options (unsigned int argc ATTRIBUTE_UNUSED,
   /* Java requires left-to-right evaluation of subexpressions.  */
   flag_evaluation_order = 1;
 
+  /* Unit at a time is disabled for Java because it is considered
+     too expensive.  */
+  no_unit_at_a_time_default = 1;
+
   jcf_path_init ();
 
   return CL_Java;
 }
 
-static bool
-java_can_use_bit_fields_p (void)
-{
-  /* The bit-field optimizations cause problems when generating class
-     files.  */
-  return flag_emit_class_files ? false : true;
-}
-
 /* Post-switch processing.  */
 static bool
 java_post_options (const char **pfilename)
@@ -609,6 +591,15 @@ java_post_options (const char **pfilename)
   if (! flag_indirect_dispatch)
     flag_verify_invocations = true;
 
+  if (flag_reduced_reflection)
+    {
+      if (flag_indirect_dispatch)
+        error ("-findirect-dispatch is incompatible "
+               "with -freduced-reflection");
+      if (flag_jni)
+        error ("-fjni is incompatible with -freduced-reflection");
+    }
+
   /* Open input file.  */
 
   if (filename == 0 || !strcmp (filename, "-"))
@@ -636,7 +627,7 @@ java_post_options (const char **pfilename)
                error ("couldn't determine target name for dependency tracking");
              else
                {
-                 char *buf = xmalloc (dot - filename +
+                 char *buf = XNEWVEC (char, dot - filename +
                                       3 + sizeof (TARGET_OBJECT_SUFFIX));
                  strncpy (buf, filename, dot - filename);
 
@@ -646,8 +637,6 @@ java_post_options (const char **pfilename)
                     target name here.  */
                  if ((dependency_tracking & DEPEND_TARGET_SET))
                    ; /* Nothing.  */
-                 else if (flag_emit_class_files)
-                   jcf_dependency_set_target (NULL);
                  else
                    {
                      strcpy (buf + (dot - filename), TARGET_OBJECT_SUFFIX);
@@ -732,10 +721,6 @@ java_tree_inlining_walk_subtrees (tree *tp ATTRIBUTE_UNUSED,
       WALK_SUBTREE (BLOCK_EXPR_BODY (t));
       return NULL_TREE;
 
-    case EXIT_BLOCK_EXPR:
-      *subtrees = 0;
-      return NULL_TREE;
-
     default:
       return NULL_TREE;
     }
@@ -782,8 +767,7 @@ merge_init_test_initialization (void **entry, void *x)
   /* See if we have remapped this declaration.  If we haven't there's
      a bug in the inliner.  */
   n = splay_tree_lookup (decl_map, (splay_tree_key) ite->value);
-  if (! n)
-    abort ();
+  gcc_assert (n);
 
   /* Create a new entry for the class and its remapped boolean
      variable.  If we already have a mapping for this class we've
@@ -800,7 +784,7 @@ merge_init_test_initialization (void **entry, void *x)
   does this by setting the DECL_INITIAL of the init_test_decl for that
   class, and no initializations are emitted for that class.
 
-  However, what if the method that is suppoed to do the initialization
+  However, what if the method that is supposed to do the initialization
   is itself inlined in the caller?  When expanding the called method
   we'll assume that the class initialization has already been done,
   because the DECL_INITIAL of the init_test_decl is set.
@@ -875,13 +859,6 @@ dump_compound_expr (dump_info_p di, tree t)
          dump_compound_expr (di, TREE_OPERAND (t, i));
          break;
 
-       case EXPR_WITH_FILE_LOCATION:
-           {
-             tree wfl_node = EXPR_WFL_NODE (TREE_OPERAND (t, i));
-             dump_child ("expr", wfl_node);
-             break;
-           }
-
        default:
          dump_child ("expr", TREE_OPERAND (t, i));
        }
@@ -925,15 +902,6 @@ java_dump_tree (void *dump_info, tree t)
       dump_child ("label", TREE_OPERAND (t, 0));
       return true;
 
-    case LABELED_BLOCK_EXPR:
-      dump_child ("label", LABELED_BLOCK_LABEL (t));
-      dump_child ("block", LABELED_BLOCK_BODY (t));
-      return true;
-
-    case EXIT_BLOCK_EXPR:
-      dump_child ("block", EXIT_BLOCK_LABELED_BLOCK (t));
-      return true;
-
     case BLOCK:
       if (BLOCK_EXPR_BODY (t))
        {
@@ -973,7 +941,8 @@ java_dump_tree (void *dump_info, tree t)
 static bool
 java_decl_ok_for_sibcall (tree decl)
 {
-  return decl != NULL && DECL_CONTEXT (decl) == output_class;
+  return (decl != NULL && DECL_CONTEXT (decl) == output_class
+         && DECL_INLINE (decl));
 }
 
 /* Given a call_expr, try to figure out what its target might be.  In
@@ -994,7 +963,7 @@ java_get_callee_fndecl (tree call_expr)
 
   if (TREE_CODE (call_expr) != CALL_EXPR)
     return NULL;
-  method = TREE_OPERAND (call_expr, 0);
+  method = CALL_EXPR_FN (call_expr);
   STRIP_NOPS (method);
   if (TREE_CODE (method) != ARRAY_REF)
     return NULL;