diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index fb7ae5d145c..19fd506f809 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,21 @@ +2007-01-12 Tom Tromey + + * jcf-dump.c (main): Updated call to find_class. + * lang.c (java_init): Removed dead code. + * jcf-parse.c (read_class): Don't use java_source field. Removed + dead code. + (parse_zip_file_entries): Don't use java_source field. + (process_zip_dir): Likewise. + (jcf_parse): Removed dead code. + (java_parse_file): Likewise. + (read_class): Updated call to find_class. + * jcf-io.c (find_class): Don't use java_source field. Removed + 'source_ok' argument, .java logic. + * jcf.h (JCF) : Removed field. + (JCF_ZERO): Updated. (find_class): Updated. + * decl.c: Removed dead code. + * class.c: Removed dead code. + 2007-01-11 Tom Tromey * typeck.c (convert): Don't use flag_emit_class_files. diff --git a/gcc/java/class.c b/gcc/java/class.c index a22a9368bb2..a2a70a7ab16 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -669,19 +669,6 @@ add_interface (tree this_class, tree interface_class) BINFO_BASE_APPEND (TYPE_BINFO (this_class), interface_binfo); } -#if 0 -/* Return the address of a pointer to the first FUNCTION_DECL - in the list (*LIST) whose DECL_NAME is NAME. */ - -static tree * -find_named_method (tree *list, tree name) -{ - while (*list && DECL_NAME (*list) != name) - list = &TREE_CHAIN (*list); - return list; -} -#endif - static tree build_java_method_type (tree fntype, tree this_class, int access_flags) { @@ -842,24 +829,6 @@ set_constant_value (tree field, tree constant) } } -/* Count the number of Unicode chars encoded in a given Ut8 string. */ - -#if 0 -int -strLengthUtf8 (char *str, int len) -{ - register unsigned char* ptr = (unsigned char*) str; - register unsigned char *limit = ptr + len; - int str_length = 0; - for (; ptr < limit; str_length++) { - if (UTF8_GET (ptr, limit) < 0) - return -1; - } - return str_length; -} -#endif - - /* Calculate a hash value for a string encoded in Utf8 format. * This returns the same hash value as specified for java.lang.String.hashCode. */ @@ -2297,36 +2266,7 @@ maybe_layout_super_class (tree super_class, tree this_class ATTRIBUTE_UNUSED) if (TREE_TYPE (super_class) != NULL_TREE) super_class = TREE_TYPE (super_class); else - { -#if 0 - /* do_resolve_class expects an EXPR_WITH_FILE_LOCATION, so - we give it one. */ - tree this_wrap = NULL_TREE; - - /* Set the correct context for class resolution. */ - current_class = this_class; - - if (this_class) - { - tree this_decl = TYPE_NAME (this_class); -#ifdef USE_MAPPED_LOCATION - this_wrap = build_expr_wfl (this_class, - DECL_SOURCE_LOCATION (this_decl)); -#else - this_wrap = build_expr_wfl (this_class, - DECL_SOURCE_FILE (this_decl), - DECL_SOURCE_LINE (this_decl), 0); -#endif - } - super_class - = do_resolve_class (DECL_CONTEXT (TYPE_NAME (this_class)), - this_class, super_class, NULL_TREE, this_wrap); - if (!super_class) - return NULL_TREE; /* FIXME, NULL_TREE not checked by caller. */ - super_class = TREE_TYPE (super_class); -#endif - gcc_unreachable (); - } + gcc_unreachable (); } if (!TYPE_SIZE (super_class)) safe_layout_class (super_class); diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 346060999f5..fcf63539092 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -1,6 +1,6 @@ /* Process declarations and variables for the GNU compiler for the Java(TM) language. - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2005, 2006, 2007 Free Software Foundation, Inc. This file is part of GCC. @@ -427,18 +427,6 @@ static const struct binding_level clear_binding_level 0, /* binding_depth */ }; -#if 0 -/* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function - that have names. Here so we can clear out their names' definitions - at the end of the function. */ - -static tree named_labels; - -/* A list of LABEL_DECLs from outer contexts that are currently shadowed. */ - -static tree shadowed_labels; -#endif - tree java_global_trees[JTI_MAX]; /* Build (and pushdecl) a "promoted type" for all standard @@ -625,14 +613,6 @@ java_init_decl_processing (void) null_pointer_node = build_int_cst (ptr_type_node, 0); -#if 0 - /* Make a type to be the domain of a few array types - whose domains don't really matter. - 200 is small enough that it always fits in size_t - and large enough that it can hold most function names for the - initializations of __FUNCTION__ and __PRETTY_FUNCTION__. */ - short_array_type_node = build_prim_array_type (short_type_node, 200); -#endif char_type_node = make_node (INTEGER_TYPE); TYPE_STRING_FLAG (char_type_node) = 1; TYPE_PRECISION (char_type_node) = 16; @@ -859,9 +839,6 @@ java_init_decl_processing (void) field_info_union_node = make_node (UNION_TYPE); PUSH_FIELD (field_info_union_node, field, "boffset", int_type_node); PUSH_FIELD (field_info_union_node, field, "addr", ptr_type_node); -#if 0 - PUSH_FIELD (field_info_union_node, field, "idx", unsigned_short_type_node); -#endif layout_type (field_info_union_node); PUSH_FIELD (field_type_node, field, "name", utf8const_ptr_type); @@ -1106,9 +1083,6 @@ java_init_decl_processing (void) initialize_builtins (); soft_fmod_node = built_in_decls[BUILT_IN_FMOD]; -#if 0 - soft_fmodf_node = built_in_decls[BUILT_IN_FMODF]; -#endif parse_version (); } @@ -1240,55 +1214,6 @@ pushdecl (tree x) tree oldlocal = IDENTIFIER_LOCAL_VALUE (name); IDENTIFIER_LOCAL_VALUE (name) = x; -#if 0 - /* Warn if shadowing an argument at the top level of the body. */ - if (oldlocal != 0 && !DECL_EXTERNAL (x) - /* This warning doesn't apply to the parms of a nested fcn. */ - && ! current_binding_level->parm_flag - /* Check that this is one level down from the parms. */ - && current_binding_level->level_chain->parm_flag - /* Check that the decl being shadowed - comes from the parm level, one level up. */ - && chain_member (oldlocal, current_binding_level->level_chain->names)) - { - if (TREE_CODE (oldlocal) == PARM_DECL) - pedwarn ("declaration of %qs shadows a parameter", - IDENTIFIER_POINTER (name)); - else - pedwarn ("declaration of %qs shadows a symbol from the parameter list", - IDENTIFIER_POINTER (name)); - } - - /* Maybe warn if shadowing something else. */ - else if (warn_shadow && !DECL_EXTERNAL (x) - /* No shadow warnings for internally generated vars. */ - && DECL_SOURCE_LINE (x) != 0 - /* No shadow warnings for vars made for inlining. */ - && ! DECL_FROM_INLINE (x)) - { - const char *warnstring = 0; - - if (TREE_CODE (x) == PARM_DECL - && current_binding_level->level_chain->parm_flag) - /* Don't warn about the parm names in function declarator - within a function declarator. - It would be nice to avoid warning in any function - declarator in a declaration, as opposed to a definition, - but there is no way to tell it's not a definition. */ - ; - else if (oldlocal != 0 && TREE_CODE (oldlocal) == PARM_DECL) - warnstring = "declaration of %qs shadows a parameter"; - else if (oldlocal != 0) - warnstring = "declaration of %qs shadows previous local"; - else if (IDENTIFIER_GLOBAL_VALUE (name) != 0 - && IDENTIFIER_GLOBAL_VALUE (name) != error_mark_node) - warnstring = "declaration of %qs shadows global declaration"; - - if (warnstring) - warning (0, warnstring, IDENTIFIER_POINTER (name)); - } -#endif - /* If storing a local value, there may already be one (inherited). If so, record it for restoration when this binding level ends. */ if (oldlocal != 0) @@ -1371,14 +1296,6 @@ pushlevel (int unused ATTRIBUTE_UNUSED) { struct binding_level *newlevel = NULL_BINDING_LEVEL; -#if 0 - /* If this is the top level of a function, - just make sure that NAMED_LABELS is 0. */ - - if (current_binding_level == global_binding_level) - named_labels = 0; -#endif - /* Reuse or create a struct for this binding level. */ if (free_binding_level) @@ -1444,14 +1361,6 @@ poplevel (int keep, int reverse, int functionbody) else fprintf (stderr, "pop %s level %p pc %d\n", (is_class_level) ? "class" : "block", current_binding_level, current_pc); -#if 0 - if (is_class_level != (current_binding_level == class_binding_level)) - { - indent (); - fprintf (stderr, "XXX is_class_level != (current_binding_level == class_binding_level)\n"); - } - is_class_level = 0; -#endif #endif /* defined(DEBUG_JAVA_BINDING_LEVELS) */ /* Get the decls in the order they were written. @@ -1571,32 +1480,6 @@ poplevel (int keep, int reverse, int functionbody) found in the FUNCTION_DECL instead. */ BLOCK_VARS (block) = 0; - - /* Clear out the definitions of all label names, - since their scopes end here, - and add them to BLOCK_VARS. */ - -#if 0 - for (link = named_labels; link; link = TREE_CHAIN (link)) - { - tree label = TREE_VALUE (link); - - if (DECL_INITIAL (label) == 0) - { - error ("label %q+D used but not defined", label); - /* Avoid crashing later. */ - define_label (input_location, DECL_NAME (label)); - } - else if (warn_unused[UNUSED_LABEL] && !TREE_USED (label)) - warning (0, "label %q+D defined but not used", label); - IDENTIFIER_LABEL_VALUE (DECL_NAME (label)) = 0; - - /* Put the labels into the "variables" of the - top-level block, so debugger can see them. */ - TREE_CHAIN (label) = BLOCK_VARS (block); - BLOCK_VARS (block) = label; - } -#endif } /* Pop the current level, and free the structure for reuse. */ @@ -1811,14 +1694,6 @@ give_name_to_locals (JCF *jcf) MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl); DECL_LOCAL_SLOT_NUMBER (decl) = slot; DECL_LOCAL_START_PC (decl) = start_pc; -#if 0 - /* FIXME: The range used internally for exceptions and local - variable ranges, is a half-open interval: - start_pc <= pc < end_pc. However, the range used in the - Java VM spec is inclusive at both ends: - start_pc <= pc <= end_pc. */ - end_pc++; -#endif DECL_LOCAL_END_PC (decl) = end_pc; /* Now insert the new decl in the proper place in diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 662ef833567..85d732c9484 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -74,10 +74,6 @@ static void expand_cond (enum tree_code, tree, int); static void expand_java_goto (int); static tree expand_java_switch (tree, int); static void expand_java_add_case (tree, int, int); -#if 0 -static void expand_java_call (int, int); -static void expand_java_ret (tree); -#endif static tree pop_arguments (tree); static void expand_invoke (int, int, int); static void expand_java_field_op (int, int, int); diff --git a/gcc/java/jcf-dump.c b/gcc/java/jcf-dump.c index 66c2515c3d5..0dfa4c20792 100644 --- a/gcc/java/jcf-dump.c +++ b/gcc/java/jcf-dump.c @@ -2,7 +2,7 @@ Functionally similar to Sun's javap. Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006 Free Software Foundation, Inc. + 2006, 2007 Free Software Foundation, Inc. This file is part of GCC. @@ -1290,7 +1290,7 @@ main (int argc, char** argv) for (argi = optind; argi < argc; argi++) { char *arg = argv[argi]; - const char *class_filename = find_class (arg, strlen (arg), jcf, 0); + const char *class_filename = find_class (arg, strlen (arg), jcf); if (class_filename == NULL) class_filename = find_classfile (arg, jcf, NULL); if (class_filename == NULL) diff --git a/gcc/java/jcf-io.c b/gcc/java/jcf-io.c index 426b2532b12..27b910395d2 100644 --- a/gcc/java/jcf-io.c +++ b/gcc/java/jcf-io.c @@ -1,6 +1,6 @@ /* Utility routines for finding and reading Java(TM) .class files. - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, + 2006, 2007 Free Software Foundation, Inc. This file is part of GCC. @@ -437,22 +437,17 @@ static htab_t memoized_class_lookups; file. */ const char * -find_class (const char *classname, int classname_length, JCF *jcf, - int source_ok) +find_class (const char *classname, int classname_length, JCF *jcf) { int fd; - int i, k, java = -1, class = -1; - struct stat java_buf, class_buf; + int i, k, class = -1; + struct stat class_buf; char *dep_file; void *entry; - char *java_buffer; int buflen; char *buffer; hashval_t hash; - /* FIXME: ecj hack. */ - source_ok = 0; - /* Create the hash table, if it does not already exist. */ if (!memoized_class_lookups) memoized_class_lookups = htab_create (37, @@ -472,10 +467,6 @@ find_class (const char *classname, int classname_length, JCF *jcf, buffer = ALLOC (buflen); memset (buffer, 0, buflen); - java_buffer = alloca (buflen); - - jcf->java_source = 0; - for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry)) { const char *path_name = jcf_path_name (entry); @@ -524,39 +515,9 @@ find_class (const char *classname, int classname_length, JCF *jcf, } class = caching_stat(buffer, &class_buf); } - - if (source_ok) - { - /* Compute name of .java file. */ - int l, m; - strcpy (java_buffer, path_name); - l = strlen (java_buffer); - for (m = 0; m < classname_length; ++m) - java_buffer[m + l] = (classname[m] == '.' - ? DIR_SEPARATOR : classname[m]); - strcpy (java_buffer + m + l, ".java"); - java = caching_stat (java_buffer, &java_buf); - if (java == 0) - break; - } } - /* We preferably pick a class file if we have a chance. If the source - file is newer than the class file, we issue a warning and parse the - source file instead. - There should be a flag to allow people have the class file picked - up no matter what. FIXME. */ - if (! java && ! class && java_buf.st_mtime > class_buf.st_mtime) - { - if (flag_newer) - warning (0, "source file for class %qs is newer than its matching class file. Source file %qs used instead", classname, java_buffer); - class = -1; - } - - if (! java) - dep_file = java_buffer; - else - dep_file = buffer; + dep_file = buffer; if (!class) { SOURCE_FRONTEND_DEBUG ((stderr, "[Class selected: %s]\n", @@ -567,21 +528,6 @@ find_class (const char *classname, int classname_length, JCF *jcf, if (fd >= 0) goto found; } - /* Give .java a try, if necessary */ - if (!java) - { - strcpy (buffer, java_buffer); - SOURCE_FRONTEND_DEBUG ((stderr, "[Source selected: %s]\n", - classname+classname_length- - (classname_length <= 30 ? - classname_length : 30))); - fd = JCF_OPEN_EXACT_CASE (buffer, O_RDONLY); - if (fd >= 0) - { - jcf->java_source = 1; - goto found; - } - } free (buffer); @@ -592,15 +538,7 @@ find_class (const char *classname, int classname_length, JCF *jcf, return NULL; found: - if (jcf->java_source) - { - JCF_ZERO (jcf); /* JCF_FINISH relies on this */ - jcf->java_source = 1; - jcf->filename = xstrdup (buffer); - close (fd); /* We use STDIO for source file */ - } - else - buffer = (char *) open_class (buffer, jcf, fd, dep_file); + buffer = (char *) open_class (buffer, jcf, fd, dep_file); jcf->classname = xstrdup (classname); return buffer; } diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index 947f76d618c..10e13aea792 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -1295,7 +1295,7 @@ read_class (tree name) path_name = find_class (IDENTIFIER_POINTER (name), IDENTIFIER_LENGTH (name), - &this_jcf, 1); + &this_jcf); if (path_name == 0) return 0; else @@ -1304,72 +1304,21 @@ read_class (tree name) current_jcf = jcf; - if (current_jcf->java_source) + if (class == NULL_TREE || ! CLASS_PARSED_P (class)) { - gcc_unreachable (); -#if 0 - const char *filename = current_jcf->filename; - char *real_path; - tree given_file, real_file; - FILE *finput; - int generate; - - java_parser_context_save_global (); - java_push_parser_context (); - - given_file = get_identifier (filename); - filename = IDENTIFIER_POINTER (given_file); - real_path = lrealpath (filename); - real_file = get_identifier (real_path); - free (real_path); - - generate = IS_A_COMMAND_LINE_FILENAME_P (given_file); - output_class = current_class = NULL_TREE; - current_function_decl = NULL_TREE; - - if (! HAS_BEEN_ALREADY_PARSED_P (real_file)) - { - if (! (finput = fopen (filename, "r"))) - fatal_error ("can't reopen %s: %m", filename); - - parse_source_file_1 (real_file, filename, finput); - parse_source_file_2 (); - parse_source_file_3 (); - - if (fclose (finput)) - fatal_error ("can't close %s: %m", input_filename); -#ifdef USE_MAPPED_LOCATION - linemap_add (&line_table, LC_LEAVE, false, NULL, 0); -#endif - } - JCF_FINISH (current_jcf); - java_pop_parser_context (generate); - java_parser_context_restore_global (); -#endif - } - else - { - if (class == NULL_TREE || ! CLASS_PARSED_P (class)) - { -/* java_parser_context_save_global (); */ -/* java_push_parser_context (); */ - output_class = current_class = class; -/* ctxp->save_location = input_location; */ - if (JCF_SEEN_IN_ZIP (current_jcf)) - read_zip_member(current_jcf, - current_jcf->zipd, current_jcf->zipd->zipf); - jcf_parse (current_jcf); - /* Parsing might change the class, in which case we have to - put it back where we found it. */ - if (current_class != class && icv != NULL_TREE) - TREE_TYPE (icv) = current_class; - class = current_class; -/* java_pop_parser_context (0); */ -/* java_parser_context_restore_global (); */ - } - layout_class (class); - load_inner_classes (class); + output_class = current_class = class; + if (JCF_SEEN_IN_ZIP (current_jcf)) + read_zip_member(current_jcf, + current_jcf->zipd, current_jcf->zipd->zipf); + jcf_parse (current_jcf); + /* Parsing might change the class, in which case we have to + put it back where we found it. */ + if (current_class != class && icv != NULL_TREE) + TREE_TYPE (icv) = current_class; + class = current_class; } + layout_class (class); + load_inner_classes (class); output_class = save_output_class; current_class = save_current_class; @@ -1557,18 +1506,7 @@ jcf_parse (JCF* jcf) TYPE_FIELDS (current_class) = nreverse (TYPE_FIELDS (current_class)); if (current_class == object_type_node) - { - layout_class_methods (object_type_node); - /* If we don't have the right archive, emit a verbose warning. - If we're generating bytecode, emit the warning only if - -fforce-classes-archive-check was specified. */ -#if 0 - /* ECJ HACK: ignore this. */ - if (!jcf->right_zip - && (!flag_emit_class_files || flag_force_classes_archive_check)) - fatal_error ("the % that was found in %qs didn't have the special zero-length % attribute. This generally means that your classpath is incorrectly set. Use % to see the info page describing how to set the classpath", jcf->filename); -#endif - } + layout_class_methods (object_type_node); else all_class_list = tree_cons (NULL_TREE, TYPE_NAME (current_class), all_class_list ); @@ -2048,13 +1986,6 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED) bitmap_obstack_release (&bit_obstack); -/* java_expand_classes (); */ -/* if (java_report_errors () || flag_syntax_only) */ -/* return; */ - - /* Expand all classes compiled from source. */ -/* java_finish_classes (); */ - finish: /* Arrange for any necessary initialization to happen. */ java_emit_static_constructor (); @@ -2196,7 +2127,6 @@ parse_zip_file_entries (void) JCF_ZERO (jcf); jcf->read_state = finput; jcf->filbuf = jcf_filbuf_from_stdio; - jcf->java_source = 0; jcf->classname = NULL; jcf->filename = file_name; jcf->zipd = zdir; @@ -2270,7 +2200,6 @@ process_zip_dir (FILE *finput) jcf->read_state = finput; jcf->filbuf = jcf_filbuf_from_stdio; - jcf->java_source = 0; jcf->classname = class_name; jcf->filename = file_name; jcf->zipd = zdir; diff --git a/gcc/java/jcf.h b/gcc/java/jcf.h index 866dc4164ea..5a19b2f7b63 100644 --- a/gcc/java/jcf.h +++ b/gcc/java/jcf.h @@ -1,6 +1,6 @@ /* Utility macros to read Java(TM) .class files and byte codes. - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006 - Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, + 2006, 2007 Free Software Foundation, Inc. This file is part of GCC. @@ -106,7 +106,6 @@ typedef struct JCF GTY(()) { unsigned char * GTY ((skip)) buffer_end; unsigned char * GTY ((skip)) read_ptr; unsigned char * GTY ((skip)) read_end; - unsigned int java_source : 1; unsigned int right_zip : 1; unsigned int finished : 1; jcf_filbuf_t filbuf; @@ -178,7 +177,7 @@ typedef struct JCF GTY(()) { #define JCF_ZERO(JCF) \ ((JCF)->buffer = (JCF)->buffer_end = (JCF)->read_ptr = (JCF)->read_end = 0,\ (JCF)->read_state = 0, (JCF)->filename = (JCF)->classname = 0, \ - CPOOL_INIT(&(JCF)->cpool), (JCF)->java_source = 0, (JCF)->zipd = 0, \ + CPOOL_INIT(&(JCF)->cpool), (JCF)->zipd = 0, \ (JCF)->finished = 0) /* Given that PTR points to a 2-byte unsigned integer in network @@ -260,7 +259,7 @@ enum cpool_tag #define DEFAULT_CLASS_PATH "." -extern const char *find_class (const char *, int, JCF*, int); +extern const char *find_class (const char *, int, JCF *); extern const char *find_classfile (char *, JCF*, const char *); extern int jcf_filbuf_from_stdio (JCF *jcf, int count); extern int jcf_unexpected_eof (JCF*, int) ATTRIBUTE_NORETURN; diff --git a/gcc/java/lang.c b/gcc/java/lang.c index 431efe1fa0e..e5d2543450a 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -353,11 +353,6 @@ 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)