+2004-11-26 Andrew Pinski <pinskia@physics.uc.edu>
+
+ PR java/18305
+ * decl.c (end_java_method): Call
+ attach_init_test_initialization_flags on all the init_decls.
+ * parse.y (attach_init_test_initialization_flags): Move to ...
+ * expr.c (attach_init_test_initialization_flags): here and
+ support BIND_EXPR also.
+ * java-tree.h (attach_init_test_initialization_flags): Prototype.
+ * jcf-parse.c (parse_class_file): Don't disable class init
+ optimization.
+
2004-11-25 Joseph S. Myers <joseph@codesourcery.com>
* gjavah.c, jcf-dump.c, jv-scan.c, jvspec.c: Avoid ` as left quote
poplevel (1, 0, 1);
BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
+
+ if (DECL_SAVED_TREE (fndecl))
+ {
+ tree fbody, block_body;
+ /* Before we check initialization, attached all class initialization
+ variable to the block_body */
+ fbody = DECL_SAVED_TREE (fndecl);
+ block_body = BIND_EXPR_BODY (fbody);
+ htab_traverse (DECL_FUNCTION_INIT_TEST_TABLE (fndecl),
+ attach_init_test_initialization_flags, block_body);
+ }
flag_unit_at_a_time = 0;
finish_method (fndecl);
abort ();
}
+/* Attach to PTR (a block) the declaration found in ENTRY. */
+
+int
+attach_init_test_initialization_flags (void **entry, void *ptr)
+{
+ tree block = (tree)ptr;
+ struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry;
+
+ if (block != error_mark_node)
+ {
+ if (TREE_CODE (block) == BIND_EXPR)
+ {
+ tree body = BIND_EXPR_BODY (block);
+ TREE_CHAIN (ite->value) = BIND_EXPR_VARS (block);
+ BIND_EXPR_VARS (block) = ite->value;
+ body = build2 (COMPOUND_EXPR, void_type_node,
+ build1 (DECL_EXPR, void_type_node, ite->value), body);
+ BIND_EXPR_BODY (block) = body;
+ }
+ else
+ {
+ tree body = BLOCK_SUBBLOCKS (block);
+ TREE_CHAIN (ite->value) = BLOCK_EXPR_DECLS (block);
+ BLOCK_EXPR_DECLS (block) = ite->value;
+ body = build2 (COMPOUND_EXPR, void_type_node,
+ build1 (DECL_EXPR, void_type_node, ite->value), body);
+ BLOCK_SUBBLOCKS (block) = body;
+ }
+
+ }
+ return true;
+}
+
/* Build an expression to initialize the class CLAS.
if EXPR is non-NULL, returns an expression to first call the initializer
(if it is needed) and then calls EXPR. */
extern tree lookup_name (tree);
extern tree build_known_method_ref (tree, tree, tree, tree, tree);
extern tree build_class_init (tree, tree);
+extern int attach_init_test_initialization_flags (void **, void *);
extern tree build_invokevirtual (tree, tree);
extern tree build_invokeinterface (tree, tree);
extern tree build_jni_stub (tree);
file_start_location = input_location;
(*debug_hooks->start_source_file) (input_line, input_filename);
- /* Currently we always have to emit calls to _Jv_InitClass when
- compiling from class files. */
- always_initialize_class_p = 1;
-
gen_indirect_dispatch_tables (current_class);
java_mark_class_local (current_class);
static void create_new_parser_context (int);
static tree maybe_build_class_init_for_field (tree, tree);
-static int attach_init_test_initialization_flags (void **, void *);
static int emit_test_initialization (void **, void *);
static char *string_convert_int_cst (tree);
/* This section deals with the functions that are called when tables
recording class initialization information are traversed. */
-/* Attach to PTR (a block) the declaration found in ENTRY. */
-
-static int
-attach_init_test_initialization_flags (void **entry, void *ptr)
-{
- tree block = (tree)ptr;
- struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry;
-
- if (block != error_mark_node)
- {
- tree body = BLOCK_SUBBLOCKS (block);
- TREE_CHAIN (ite->value) = BLOCK_EXPR_DECLS (block);
- BLOCK_EXPR_DECLS (block) = ite->value;
- body = build2 (COMPOUND_EXPR, void_type_node,
- build1 (DECL_EXPR, void_type_node, ite->value), body);
- BLOCK_SUBBLOCKS (block) = body;
- }
- return true;
-}
-
/* This function is called for each class that is known definitely
initialized when a given static method was called. This function
augments a compound expression (INFO) storing all assignment to