diff options
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 55 | ||||
-rw-r--r-- | gcc/java/check-init.c | 12 | ||||
-rw-r--r-- | gcc/java/class.c | 17 | ||||
-rw-r--r-- | gcc/java/constants.c | 7 | ||||
-rw-r--r-- | gcc/java/decl.c | 7 | ||||
-rw-r--r-- | gcc/java/expr.c | 54 | ||||
-rw-r--r-- | gcc/java/java-tree.h | 2 | ||||
-rw-r--r-- | gcc/java/jcf-parse.c | 58 | ||||
-rw-r--r-- | gcc/java/jcf-write.c | 69 | ||||
-rw-r--r-- | gcc/java/jv-scan.c | 14 | ||||
-rw-r--r-- | gcc/java/lex.c | 17 | ||||
-rw-r--r-- | gcc/java/mangle.c | 18 | ||||
-rw-r--r-- | gcc/java/parse.h | 4 | ||||
-rw-r--r-- | gcc/java/parse.y | 42 | ||||
-rw-r--r-- | gcc/java/typeck.c | 25 | ||||
-rw-r--r-- | gcc/java/verify.c | 10 |
16 files changed, 247 insertions, 164 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index faba27c..ad17577 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,58 @@ +Sun Feb 4 15:52:44 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * check-init.c (check_init): Call internal_error instead of fatal. + * expr.c (java_lang_expand_expr): Likewise. + * jcf-parse.c (get_constant): Likewise. + * mangle.c (java_mangle_decl): Likewise. + * parse.y (make_nested_class_name, java_complete_lhs): Likewise. + (operator_string): Likewise. + * check-init.c (check_init): Call abort instead of fatal. + * class.c (build_class_ref): Likewise. + * constants.c (write_constant_pool): Likewise. + * decl.c (start_java_method): Likewise. + * expr.c (push_type, java_stack_pop, java_stack_swap): Likewise. + (java_stack_dup, encode_newarray_type): Likewise. + (build_java_array_length_access): Likewise. + (build_java_check_indexed_type, expand_java_pushc): Likewise. + (build_java_soft_divmod, build_invokeinterface): Likewise. + * java-tree.h (INNER_CLASS_P): Likewise. + * jcf-parse.c (parse_signature, get_name_constant): Likewise. + (give_name_to_class, get_class_constant): Likewise. + * jcf-write.c (CHECK_PUT, CHECK_OP, get_access_flags): Likewise. + (find_constant_index, generate_bytecode_conditional): Likewise. + (generate_bytecode_insns, perform_relocations): Likewise. + * lex.c (java_unget_unicode, java_lex): Likewise. + * mangle.c (mangle_type, mangle_record_type): Likewise. + (mangle_pointer_type, mangle_array_type, init_mangling): Likewise. + (finish_mangling): Likewise. + * parse.h (MARK_FINAL_PARMS): Likewise. + * parse.y (pop_current_osb, unreachable_stmt_error): Likewise. + (obtain_incomplete_type, java_complete_class): Likewise. + (java_check_regular_methods, java_complete_expand_method): Likewise. + (cut_identifier_in_qualified, check_deprecation): Likewise. + (patch_invoke, find_applicable_accessible_methods_list): Likewise. + (java_complete_lhs, lookup_name_in_blocks): Likewise. + (check_final_variable_indirect_assignment, build_unaryop): Likewise. + * typeck.c (set_local_type, parse_signature_type): Likewise. + (parse_signature_string, build_java_signature): Likewise; + (set_java_signature): Likewise. + * verify.c (type_stack_dup, CHECK_PC_IN_RANGE): Likewise. + * class.c (add_method): Call fatal_error instead of fatal. + (build_static_field_ref): Likewise. + * expr.c (build_known_method_ref, expand_invoke): Likewise. + * jcf-parse.c (get_constant, jcf_parse): Likewise. + * lex.c (java_new_new_lexer): Likewise. + * jv-scan.c (main): Likewise. + (fatal_error): Renamed from fatal. + * jcf-parse.c (yyparse): Call fatal_io_error instead of + pfatal_with_name. + * jcf-parse.c (jcf_parse_source): Call fatal_io_error, not fatal. + (yyparse): Likewise. + * jcf-write.c (make_class_file_name, write_classfile): Likewise. + * lex.c (java_get_line_col): Likewise. + * jcf-parse.c (load_class): Make errors non-fatal. + * lex.c (byteswap_init, need_byteswap): Only #ifdef HAVE_ICONV. + 2001-02-01 Bryce McKinlay <bryce@albatross.co.nz> * jvgenmain.c (class_mangling_suffix): Remove unused string. diff --git a/gcc/java/check-init.c b/gcc/java/check-init.c index 7de0e18..9d89196 100644 --- a/gcc/java/check-init.c +++ b/gcc/java/check-init.c @@ -1,6 +1,5 @@ /* Code to test for "definitive assignment". - - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -464,7 +463,7 @@ check_init (exp, before) words when_false = tmp + num_current_words; #ifdef ENABLE_JC1_CHECKING if (TREE_CODE (alt->block) != LOOP_EXPR) - fatal ("internal error in check-init: EXIT_EXPR not in LOOP_EXPR"); + abort (); #endif check_bool_init (TREE_OPERAND (exp, 0), before, when_false, when_true); done_alternative (when_true, alt); @@ -535,7 +534,7 @@ check_init (exp, before) struct alternatives *alt = alternatives; #ifdef ENABLE_JC1_CHECKING if (TREE_CODE (alt->block) != CLEANUP_POINT_EXPR) - fatal ("internal error in check-init: WITH_CLEANUP_EXPR not in CLEANUP_POINT_EXPR"); + abort (); #endif check_init (TREE_OPERAND (exp, 0), before); UNION (alt->combined, alt->combined, before); @@ -728,8 +727,9 @@ check_init (exp, before) break; default: - fatal ("internal error in check-init: tree code not implemented: %s", - tree_code_name [(int) TREE_CODE (exp)]); + internal_error + ("internal error in check-init: tree code not implemented: %s", + tree_code_name [(int) TREE_CODE (exp)]); } } diff --git a/gcc/java/class.c b/gcc/java/class.c index b0b4719..615c075 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -1,5 +1,6 @@ /* Functions related to building classes and their related objects. - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 + Free Software Foundation, Inc. This file is part of GNU CC. @@ -692,9 +693,12 @@ add_method (this_class, access_flags, name, method_sig) { tree handle_class = CLASS_TO_HANDLE_TYPE (this_class); tree function_type, fndecl; - const unsigned char *sig = (const unsigned char*)IDENTIFIER_POINTER (method_sig); + const unsigned char *sig + = (const unsigned char *) IDENTIFIER_POINTER (method_sig); + if (sig[0] != '(') - fatal ("bad method signature"); + fatal_error ("bad method signature"); + function_type = get_type_from_signature (method_sig); fndecl = add_method_1 (handle_class, access_flags, name, function_type); set_java_signature (TREE_TYPE (fndecl), method_sig); @@ -928,7 +932,8 @@ build_class_ref (type) else if (type == void_type_node) prim_class_name = "java.lang.Void"; else - fatal ("internal error - bad type to build_class_ref"); + abort (); + prim_class = lookup_class (get_identifier (prim_class_name)); return build (COMPONENT_REF, NULL_TREE, prim_class, TYPE_identifier_node); @@ -1000,8 +1005,8 @@ build_static_field_ref (fdecl) if (fld == fdecl) break; if (fld == NULL_TREE) - fatal ("field '%s' not found in class", - IDENTIFIER_POINTER (DECL_NAME (fdecl))); + fatal_error ("field '%s' not found in class", + IDENTIFIER_POINTER (DECL_NAME (fdecl))); if (FIELD_STATIC (fld)) field_index++; } diff --git a/gcc/java/constants.c b/gcc/java/constants.c index ee7be0b..0dcd715 100644 --- a/gcc/java/constants.c +++ b/gcc/java/constants.c @@ -268,10 +268,10 @@ count_constant_pool_bytes (cpool) void write_constant_pool (cpool, buffer, length) CPool *cpool; - unsigned char* buffer; + unsigned char *buffer; int length; { - unsigned char* ptr = buffer; + unsigned char *ptr = buffer; int i = 1; jword *datap = &cpool->data[1]; PUT2 (cpool->count); @@ -311,8 +311,9 @@ write_constant_pool (cpool, buffer, length) break; } } + if (ptr != buffer + length) - fatal("internal error - incorrect constant pool"); + abort (); } CPool *outgoing_cpool; diff --git a/gcc/java/decl.c b/gcc/java/decl.c index a19d06d..f596059 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -1,6 +1,7 @@ /* Process declarations and variables for the GNU compiler for the Java(TM) language. - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 + Free Software Foundation, Inc. This file is part of GNU CC. @@ -1817,8 +1818,8 @@ start_java_method (fndecl) { tree parm_name = NULL_TREE, parm_decl; tree parm_type = TREE_VALUE (tem); - if (i >= DECL_MAX_LOCALS(fndecl)) - fatal ("function has more parameters than local slots"); + if (i >= DECL_MAX_LOCALS (fndecl)) + abort (); parm_decl = build_decl (PARM_DECL, parm_name, parm_type); DECL_CONTEXT (parm_decl) = fndecl; diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 16653ec..d74dfc0 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -1,5 +1,6 @@ /* Process expressions for the GNU compiler for the Java(TM) language. - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 + Free Software Foundation, Inc. This file is part of GNU CC. @@ -279,7 +280,7 @@ push_type (type) tree type; { if (! push_type_0 (type)) - fatal ("stack overflow"); + abort (); } static void @@ -497,14 +498,17 @@ java_stack_pop (count) while (count > 0) { tree type, val; + if (stack_pointer == 0) - fatal ("stack underflow"); + abort (); + type = stack_type_map[stack_pointer - 1]; if (type == TYPE_SECOND) { count--; if (stack_pointer == 1 || count <= 0) - fatal ("stack underflow"); + abort (); + type = stack_type_map[stack_pointer - 2]; } val = pop_value (type); @@ -526,7 +530,8 @@ java_stack_swap () || (type2 = stack_type_map[stack_pointer - 2]) == TYPE_UNKNOWN || type1 == TYPE_SECOND || type2 == TYPE_SECOND || TYPE_IS_WIDE (type1) || TYPE_IS_WIDE (type2)) - fatal ("bad stack swap"); + /* Bad stack swap. */ + abort (); flush_quick_stack (); decl1 = find_stack_slot (stack_pointer - 1, type1); @@ -562,15 +567,18 @@ java_stack_dup (size, offset) if (type == TYPE_SECOND) { if (src_index <= low_index) - fatal ("dup operation splits 64-bit number"); + /* Dup operation splits 64-bit number. */ + abort (); + stack_type_map[dst_index] = type; src_index--; dst_index--; type = stack_type_map[src_index]; if (! TYPE_IS_WIDE (type)) - fatal ("internal error - dup operation"); + abort (); } else if (TYPE_IS_WIDE (type)) - fatal ("internal error - dup operation"); + abort (); + if (src_index != dst_index) { tree src_decl = find_stack_slot (src_index, type); @@ -669,7 +677,7 @@ encode_newarray_type (type) else if (type == long_type_node) return 11; else - fatal ("Can't compute type code - patch_newarray"); + abort (); } /* Build a call to _Jv_ThrowBadArrayIndex(), the @@ -695,11 +703,14 @@ build_java_array_length_access (node) { tree type = TREE_TYPE (node); HOST_WIDE_INT length; + if (!is_array_type_p (type)) - fatal ("array length on a non-array reference"); + abort (); + length = java_array_type_length (type); if (length >= 0) return build_int_2 (length, 0); + return fold (build1 (INDIRECT_REF, int_type_node, fold (build (PLUS_EXPR, ptr_type_node, @@ -807,7 +818,7 @@ build_java_check_indexed_type (array_node, indexed_type) tree elt_type; if (!is_array_type_p (TREE_TYPE (array_node))) - fatal ("array indexing on a non-array reference"); + abort (); elt_type = (TYPE_ARRAY_ELEMENT (TREE_TYPE (TREE_TYPE (array_node)))); @@ -819,7 +830,7 @@ build_java_check_indexed_type (array_node, indexed_type) return boolean_type_node; if (indexed_type != elt_type ) - fatal ("type array element mismatch"); + abort (); else return indexed_type; } @@ -1041,7 +1052,8 @@ expand_java_pushc (ival, type) value = build_real (type, x); } else - fatal ("internal error in expand_java_pushc"); + abort (); + push_value (value); } @@ -1257,7 +1269,7 @@ build_java_soft_divmod (op, type, op1, op2) } if (! call) - fatal ("Internal compiler error in build_java_soft_divmod"); + abort (); call = build (CALL_EXPR, type, build_address_of (call), @@ -1733,8 +1745,8 @@ build_known_method_ref (method, method_type, self_type, method_signature, arg_li if (method == meth) break; if (meth == NULL_TREE) - fatal ("method '%s' not found in class", - IDENTIFIER_POINTER (DECL_NAME (method))); + fatal_error ("method '%s' not found in class", + IDENTIFIER_POINTER (DECL_NAME (method))); method_index++; } method_index *= int_size_in_bytes (method_type_node); @@ -1831,7 +1843,7 @@ build_invokeinterface (dtable, method) break; } if (meth == NULL_TREE) - fatal ("internal error in build_invokeinterface"); + abort (); } lookup_arg = tree_cons (NULL_TREE, dtable, @@ -1858,7 +1870,8 @@ expand_invoke (opcode, method_ref_index, nargs) tree method_name = COMPONENT_REF_NAME (¤t_jcf->cpool, method_ref_index); tree self_type = get_class_constant (current_jcf, COMPONENT_REF_CLASS_INDEX(¤t_jcf->cpool, method_ref_index)); - const char *self_name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (self_type))); + const char *self_name + = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (self_type))); tree call, func, method, arg_list, method_type; tree cond = NULL_TREE; @@ -1867,7 +1880,7 @@ expand_invoke (opcode, method_ref_index, nargs) load_class (self_type, 1); safe_layout_class (self_type); if (TREE_CODE (TYPE_SIZE (self_type)) == ERROR_MARK) - fatal ("failed to find class '%s'", self_name); + fatal_error ("failed to find class '%s'", self_name); } layout_class_methods (self_type); @@ -2501,8 +2514,7 @@ java_lang_expand_expr (exp, target, tmode, modifier) return const0_rtx; default: - fatal ("Can't expand '%s' tree - java_lang_expand_expr", - tree_code_name [TREE_CODE (exp)]); + internal_error ("Can't expand %s", tree_code_name [TREE_CODE (exp)]); } } diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index c390432..7aeab9a 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -1415,7 +1415,7 @@ extern tree *type_map; INNER_CLASS_DECL_P (NODE) : \ (TREE_CODE (NODE) == RECORD_TYPE ? \ INNER_CLASS_TYPE_P (NODE) : \ - (fatal ("INNER_CLASS_P: Wrong node type"), 0))) + (abort (), 0))) /* On a TYPE_DECL, hold the list of inner classes defined within the scope of TYPE_DECL. */ diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index 24eb0a3..7cc1de6 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -240,14 +240,12 @@ parse_signature (jcf, sig_index) JCF *jcf; int sig_index; { - if (sig_index <= 0 || sig_index >= JPOOL_SIZE(jcf) + if (sig_index <= 0 || sig_index >= JPOOL_SIZE (jcf) || JPOOL_TAG (jcf, sig_index) != CONSTANT_Utf8) - fatal ("invalid field/method signature"); + abort (); else - { - return parse_signature_string (JPOOL_UTF_DATA (jcf, sig_index), - JPOOL_UTF_LENGTH (jcf, sig_index)); - } + return parse_signature_string (JPOOL_UTF_DATA (jcf, sig_index), + JPOOL_UTF_LENGTH (jcf, sig_index)); } void @@ -364,7 +362,8 @@ get_constant (jcf, index) { int char_len = UT8_CHAR_LENGTH (*utf8); if (char_len < 0 || char_len > 3 || char_len > i) - fatal ("bad string constant"); + fatal_error ("bad string constant"); + utf8 += char_len; i -= char_len; str_len++; @@ -415,12 +414,12 @@ get_constant (jcf, index) default: goto bad; } - JPOOL_TAG(jcf, index) = tag | CONSTANT_ResolvedFlag; + JPOOL_TAG (jcf, index) = tag | CONSTANT_ResolvedFlag; jcf->cpool.data [index] = (jword) value; return value; bad: - fatal ("bad value constant type %d, index %d", - JPOOL_TAG( jcf, index ), index); + internal_error ("bad value constant type %d, index %d", + JPOOL_TAG (jcf, index), index); } tree @@ -429,8 +428,10 @@ get_name_constant (jcf, index) int index; { tree name = get_constant (jcf, index); + if (TREE_CODE (name) != IDENTIFIER_NODE) - fatal ("bad nameandtype index %d", index); + abort (); + return name; } @@ -479,9 +480,9 @@ give_name_to_class (jcf, i) JCF *jcf; int i; { - if (i <= 0 || i >= JPOOL_SIZE(jcf) + if (i <= 0 || i >= JPOOL_SIZE (jcf) || JPOOL_TAG (jcf, i) != CONSTANT_Class) - fatal ("bad class index %d", i); + abort (); else { tree this_class; @@ -507,9 +508,9 @@ tree get_class_constant (JCF *jcf , int i) { tree type; - if (i <= 0 || i >= JPOOL_SIZE(jcf) + if (i <= 0 || i >= JPOOL_SIZE (jcf) || (JPOOL_TAG (jcf, i) & ~CONSTANT_ResolvedFlag) != CONSTANT_Class) - fatal ("bad class index %d", i); + abort (); if (JPOOL_TAG (jcf, i) != CONSTANT_ResolvedClass) { @@ -517,6 +518,7 @@ get_class_constant (JCF *jcf , int i) /* verify_constant_pool confirmed that name_index is a CONSTANT_Utf8. */ const char *name = JPOOL_UTF_DATA (jcf, name_index); int nlength = JPOOL_UTF_LENGTH (jcf, name_index); + if (name[0] == '[') /* Handle array "classes". */ type = TREE_TYPE (parse_signature_string (name, nlength)); else @@ -614,7 +616,7 @@ load_class (class_or_name, verbose) name = DECL_NAME (TYPE_NAME (class_or_name)); if (read_class (name) == 0 && verbose) - fatal ("Cannot find file for class %s.", IDENTIFIER_POINTER (name)); + error ("Cannot find file for class %s.", IDENTIFIER_POINTER (name)); } /* Parse a source file when JCF refers to a source file. */ @@ -637,12 +639,10 @@ jcf_parse_source () if (!HAS_BEEN_ALREADY_PARSED_P (file)) { if (!(finput = fopen (input_filename, "r"))) - fatal ("input file `%s' just disappeared - jcf_parse_source", - input_filename); + fatal_io_error ("can't reopen %s", input_filename); parse_source_file (file, finput); if (fclose (finput)) - fatal ("can't close input file `%s' stream - jcf_parse_source", - input_filename); + fatal_io_error ("can't close %s", input_filename); } java_pop_parser_context (IS_A_COMMAND_LINE_FILENAME_P (file)); java_parser_context_restore_global (); @@ -658,13 +658,13 @@ jcf_parse (jcf) tree current; if (jcf_parse_preamble (jcf) != 0) - fatal ("Not a valid Java .class file.\n"); + fatal_error ("not a valid Java .class file"); code = jcf_parse_constant_pool (jcf); if (code != 0) - fatal ("error while parsing constant pool"); + fatal_error ("error while parsing constant pool"); code = verify_constant_pool (jcf); if (code > 0) - fatal ("error in constant pool entry #%d\n", code); + fatal_error ("error in constant pool entry #%d\n", code); jcf_parse_class (jcf); if (main_class == NULL_TREE) @@ -689,13 +689,13 @@ jcf_parse (jcf) code = jcf_parse_fields (jcf); if (code != 0) - fatal ("error while parsing fields"); + fatal_error ("error while parsing fields"); code = jcf_parse_methods (jcf); if (code != 0) - fatal ("error while parsing methods"); + fatal_error ("error while parsing methods"); code = jcf_parse_final_attributes (jcf); if (code != 0) - fatal ("error while parsing final attributes"); + fatal_error ("error while parsing final attributes"); /* The fields of class_type_node are already in correct order. */ if (current_class != class_type_node && current_class != object_type_node) @@ -954,14 +954,14 @@ yyparse () /* Close previous descriptor, if any */ if (main_jcf->read_state && fclose (main_jcf->read_state)) - fatal ("failed to close input file `%s' - yyparse", - (main_jcf->filename ? main_jcf->filename : "<unknown>")); + fatal_io_error ("can't close %s", + main_jcf->filename ? main_jcf->filename : "<unknown>"); /* Set jcf up and open a new file */ JCF_ZERO (main_jcf); main_jcf->read_state = fopen (IDENTIFIER_POINTER (name), "rb"); if (main_jcf->read_state == NULL) - pfatal_with_name (IDENTIFIER_POINTER (name)); + fatal_io_error ("can't open %s", IDENTIFIER_POINTER (name)); /* Set new input_filename and finput */ finput = main_jcf->read_state; diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c index 1106a75..5cb4fb3 100644 --- a/gcc/java/jcf-write.c +++ b/gcc/java/jcf-write.c @@ -1,5 +1,5 @@ /* Write out a Java(TM) class file. - Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This file is part of GNU CC. @@ -355,14 +355,15 @@ static void append_innerclasses_attribute_entry PARAMS ((struct jcf_partial *, t static int CHECK_PUT PARAMS ((void *, struct jcf_partial *, int)); static int -CHECK_PUT(ptr, state, i) +CHECK_PUT (ptr, state, i) void *ptr; struct jcf_partial *state; int i; { - if ((unsigned char *)ptr < state->chunk->data - || (unsigned char*)ptr + i > state->chunk->data + state->chunk->size) - fatal ("internal error - CHECK_PUT failed"); + if ((unsigned char *) ptr < state->chunk->data + || (unsigned char *) ptr + i > state->chunk->data + state->chunk->size) + abort (); + return 0; } #else @@ -411,16 +412,16 @@ alloc_chunk (last, data, size, work) static int CHECK_OP PARAMS ((struct jcf_partial *)); static int -CHECK_OP(struct jcf_partial *state) +CHECK_OP (state) + struct jcf_partial *state; { if (state->bytecode.ptr > state->bytecode.limit) - { - fatal("internal error - CHECK_OP failed"); - } + abort (); + return 0; } #else -#define CHECK_OP(STATE) ((void)0) +#define CHECK_OP(STATE) ((void) 0) #endif static unsigned char * @@ -687,7 +688,8 @@ get_access_flags (decl) flags |= ACC_PRIVATE; } else - fatal ("internal error - bad argument to get_access_flags"); + abort (); + if (TREE_CODE (decl) == FUNCTION_DECL) { if (METHOD_NATIVE (decl)) @@ -833,11 +835,10 @@ find_constant_index (value, state) } } else if (TREE_CODE (value) == STRING_CST) - { - return find_string_constant (&state->cpool, value); - } + return find_string_constant (&state->cpool, value); + else - fatal ("find_constant_index - bad type"); + abort (); } /* Push 64-bit long constant on VM stack. @@ -1176,12 +1177,12 @@ generate_bytecode_conditional (exp, true_label, false_label, true_label, false_label, true_branch_first, state); if (state->code_SP != save_SP_after) - fatal ("internal error non-matching SP"); + abort (); } break; case TRUTH_NOT_EXPR: - generate_bytecode_conditional (TREE_OPERAND (exp, 0), false_label, true_label, - ! true_branch_first, state); + generate_bytecode_conditional (TREE_OPERAND (exp, 0), false_label, + true_label, ! true_branch_first, state); break; case TRUTH_ANDIF_EXPR: { @@ -1345,7 +1346,7 @@ generate_bytecode_conditional (exp, true_label, false_label, break; } if (save_SP != state->code_SP) - fatal ("internal error - SP mismatch"); + abort (); } /* Call pending cleanups i.e. those for surrounding CLEANUP_POINT_EXPRs @@ -2062,12 +2063,12 @@ generate_bytecode_insns (exp, target, state) else if (TREE_CODE (exp) == ARRAY_REF) { jopcode = OPCODE_iastore + adjust_typed_op (TREE_TYPE (exp), 7); - RESERVE(1); + RESERVE (1); OP1 (jopcode); NOTE_POP (TYPE_IS_WIDE (TREE_TYPE (exp)) ? 4 : 3); } else - fatal ("internal error (bad lhs to MODIFY_EXPR)"); + abort (); break; case PLUS_EXPR: jopcode = OPCODE_iadd; @@ -2579,8 +2580,8 @@ generate_bytecode_insns (exp, target, state) { DECL_CONTEXT (f) = saved_context; if (nargs <= 0) - fatal ("Illegal number of arguments to invokeinterface, nargs=%d", - nargs); + abort (); + OP1 (nargs); OP1 (0); } @@ -2767,7 +2768,7 @@ perform_relocations (state) } } if (new_ptr != chunk->data) - fatal ("internal error - perform_relocations"); + abort (); } state->code_length = pc; } @@ -3288,16 +3289,11 @@ make_class_file_name (clas) if (s == NULL) break; *s = '\0'; - if (stat (r, &sb) == -1) - { + if (stat (r, &sb) == -1 /* Try to make it. */ - if (mkdir (r, 0755) == -1) - { - fatal ("failed to create directory `%s'", r); - free (r); - return NULL; - } - } + && mkdir (r, 0755) == -1) + fatal_io_error ("can't create directory %s", r); + *s = DIR_SEPARATOR; /* Skip consecutive separators. */ for (dname = s + 1; *dname && *dname == DIR_SEPARATOR; ++dname) @@ -3321,15 +3317,16 @@ write_classfile (clas) if (class_file_name != NULL) { - FILE* stream = fopen (class_file_name, "wb"); + FILE *stream = fopen (class_file_name, "wb"); if (stream == NULL) - fatal ("failed to open `%s' for writing", class_file_name); + fatal_io_error ("can't to open %s", class_file_name); + jcf_dependency_add_target (class_file_name); init_jcf_state (state, work); chunks = generate_classfile (clas, state); write_chunks (stream, chunks); if (fclose (stream)) - fatal ("failed to close after writing `%s'", class_file_name); + fatal_io_error ("can't close %s", class_file_name); free (class_file_name); } release_jcf_state (state); diff --git a/gcc/java/jv-scan.c b/gcc/java/jv-scan.c index bb0be61..d5b0d0a 100644 --- a/gcc/java/jv-scan.c +++ b/gcc/java/jv-scan.c @@ -1,5 +1,5 @@ /* Main for jv-scan - Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com) This file is part of GNU CC. @@ -36,7 +36,8 @@ Boston, MA 02111-1307, USA. */ #include <getopt.h> -void fatal PARAMS ((const char *s, ...)) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN; +extern void fatal_error PARAMS ((const char *s, ...)) + ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN; void warning PARAMS ((const char *s, ...)) ATTRIBUTE_PRINTF_1; void gcc_obstack_init PARAMS ((struct obstack *obstack)); void report PARAMS ((void)); @@ -178,10 +179,11 @@ DEFUN (main, (argc, argv), /* Check on bad usage */ if (flag_find_main + flag_dump_class + flag_complexity > 1) - fatal ("Only one of `--print-main', `--list-class', and `--complexity' allowed"); + fatal_error + ("Only one of `--print-main', `--list-class', and `--complexity' allowed"); if (output_file && !(out = fopen (output_file, "w"))) - fatal ("Can't open output file `%s'", output_file); + fatal_error ("Can't open output file `%s'", output_file); ft = ftell (out); @@ -217,7 +219,7 @@ DEFUN (main, (argc, argv), reset_report (); } else - fatal ("File not found `%s'", argv [i]); + fatal_error ("File not found `%s'", argv [i]); } /* Flush and close */ @@ -235,7 +237,7 @@ DEFUN (main, (argc, argv), functions */ void -fatal VPARAMS ((const char *s, ...)) +fatal_error VPARAMS ((const char *s, ...)) { #ifndef ANSI_PROTOTYPES const char *s; diff --git a/gcc/java/lex.c b/gcc/java/lex.c index fdfb0a7..06eb35d 100644 --- a/gcc/java/lex.c +++ b/gcc/java/lex.c @@ -67,6 +67,7 @@ static int utf8_cmp PARAMS ((const unsigned char *, int, const char *)); java_lexer *java_new_lexer PARAMS ((FILE *, const char *)); +#ifdef HAVE_ICONV /* This is nonzero if we have initialized `need_byteswap'. */ static int byteswap_init = 0; @@ -75,6 +76,7 @@ static int byteswap_init = 0; doing a conversion once at startup and seeing what happens. This flag holds the results of this determination. */ static int need_byteswap = 0; +#endif void java_init_lex (finput, encoding) @@ -161,7 +163,9 @@ static void java_unget_unicode () { if (!ctxp->c_line->current) - fatal ("can't unget unicode - java_unget_unicode"); + /* Can't unget unicode. */ + abort (); + ctxp->c_line->current--; ctxp->c_line->char_col -= JAVA_COLUMN_DELTA (0); } @@ -211,6 +215,7 @@ java_allocate_new_line () } /* Create a new lexer object. */ + java_lexer * java_new_lexer (finput, encoding) FILE *finput; @@ -277,8 +282,8 @@ java_new_lexer (finput, encoding) { /* If iconv failed, use the internal decoder if the default encoding was requested. This code is used on platforms where - iconv() exists but is insufficient for our needs. For - instance, on Solaris 2.5 iconv() cannot handle UTF-8 or UCS-2. */ + iconv exists but is insufficient for our needs. For + instance, on Solaris 2.5 iconv cannot handle UTF-8 or UCS-2. */ if (strcmp (encoding, DEFAULT_ENCODING)) enc_error = 1; #ifdef HAVE_ICONV @@ -288,7 +293,7 @@ java_new_lexer (finput, encoding) } if (enc_error) - fatal ("unknown encoding: `%s'", encoding); + fatal_error ("unknown encoding: `%s'", encoding); return lex; } @@ -956,7 +961,7 @@ java_lex (java_lval) ctxp->elc.prev_col = ctxp->elc.col; ctxp->elc.col = ctxp->c_line->char_col - JAVA_COLUMN_DELTA (-1); if (ctxp->elc.col < 0) - fatal ("ctxp->elc.col < 0 - java_lex"); + abort (); /* Numeric literals */ if (JAVA_ASCII_DIGIT (c) || (c == '.')) @@ -1712,7 +1717,7 @@ java_get_line_col (filename, line, col) char *base; if (!(fp = fopen (filename, "r"))) - fatal ("Can't open file - java_display_line_col"); + fatal_io_error ("can't open %s", filename); while (cline != line) { diff --git a/gcc/java/mangle.c b/gcc/java/mangle.c index e6ead9b5..1c83ac2 100644 --- a/gcc/java/mangle.c +++ b/gcc/java/mangle.c @@ -85,8 +85,7 @@ java_mangle_decl (obstack, decl) mangle_method_decl (decl); break; default: - fatal ("Can't mangle `%s\' -- java_mangle_decl", - tree_code_name [TREE_CODE (decl)]); + internal_error ("Can't mangle %s", tree_code_name [TREE_CODE (decl)]); } return finish_mangling (); } @@ -368,7 +367,7 @@ mangle_type (type) break; bad_type: default: - fatal ("internal error - trying to mangle unknown type"); + abort (); } } @@ -481,7 +480,7 @@ mangle_record_type (type, from_pointer) do { obstack_1grow (mangle_obstack, 'N'); nadded_p = 1; } while (0) if (TREE_CODE (type) != RECORD_TYPE) - fatal ("Non RECORD_TYPE argument -- mangle_record_type"); + abort (); if (!TYPE_PACKAGE_LIST (type)) set_type_package_list (type); @@ -534,7 +533,7 @@ mangle_pointer_type (type) pointer_type = type; type = TREE_TYPE (type); if (TREE_CODE (type) != RECORD_TYPE) - fatal ("Double indirection found -- mangle_pointer_type"); + abort (); obstack_1grow (mangle_obstack, 'P'); if (mangle_record_type (type, /* for_pointer = */ 1)) @@ -560,7 +559,8 @@ mangle_array_type (p_type) type = TREE_TYPE (p_type); if (!type) - fatal ("Non pointer array type -- mangle_array_type"); + abort (); + elt_type = TYPE_ARRAY_ELEMENT (type); /* We cache a bit of the Jarray <> mangle. */ @@ -736,7 +736,8 @@ init_mangling (obstack) if (!compression_table) compression_table = make_tree_vec (10); else - fatal ("Mangling already in progress -- init_mangling"); + /* Mangling already in progress. */ + abort (); /* Mangled name are to be suffixed */ obstack_grow (mangle_obstack, "_Z", 2); @@ -754,7 +755,8 @@ finish_mangling () tree result; if (!compression_table) - fatal ("Mangling already finished -- finish_mangling"); + /* Mangling already finished. */ + abort (); ggc_del_root (&compression_table); compression_table = NULL_TREE; diff --git a/gcc/java/parse.h b/gcc/java/parse.h index 15e9852..dc25907 100644 --- a/gcc/java/parse.h +++ b/gcc/java/parse.h @@ -1,5 +1,5 @@ /* Language parser definitions for the GNU compiler for the Java(TM) language. - Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com) This file is part of GNU CC. @@ -290,7 +290,7 @@ extern tree stabilize_reference PARAMS ((tree)); current = TREE_CHAIN (current), list = TREE_CHAIN (list)) \ ARG_FINAL_P (current) = ARG_FINAL_P (list); \ if (current != list) \ - fatal ("MARK_FINAL_PARMS"); \ + abort (); \ } /* Reset the ARG_FINAL_P that might have been set in method M args. */ diff --git a/gcc/java/parse.y b/gcc/java/parse.y index d566133..33c868c 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -2596,7 +2596,7 @@ pop_current_osb (ctxp) int to_return; if (ctxp->osb_depth < 0) - fatal ("osb stack underflow"); + abort (); to_return = CURRENT_OSB (ctxp); ctxp->osb_depth--; @@ -3167,7 +3167,7 @@ unreachable_stmt_error (node) parse_error_context (wfl_operator, "Unreachable statement"); } else - fatal ("Can't get valid statement - unreachable_stmt_error"); + abort (); } int @@ -3467,8 +3467,7 @@ make_nested_class_name (cpc_list) /* Why is NO_DOLLAR_IN_LABEL defined? */ #if 0 #ifdef NO_DOLLAR_IN_LABEL - fatal ("make_nested_class_name: Can't use '$' as a separator " - "for inner classes"); + internal_error ("Can't use '$' as a separator for inner classes"); #endif #endif obstack_1grow (&temporary_obstack, '$'); @@ -4985,7 +4984,7 @@ obtain_incomplete_type (type_name) else if (INCOMPLETE_TYPE_P (type_name)) name = TYPE_NAME (type_name); else - fatal ("invalid type name - obtain_incomplete_type"); + abort (); for (ptr = ctxp->incomplete_class; ptr; ptr = TREE_CHAIN (ptr)) if (TYPE_NAME (ptr) == name) @@ -5422,8 +5421,7 @@ java_complete_class () break; default: - fatal ("Can't handle patch code %d - java_complete_class", - JDEP_KIND (dep)); + abort (); } } } @@ -6180,7 +6178,7 @@ java_check_regular_methods (class_decl) java_check_abstract_method_definitions (class_decl); if (!saw_constructor) - fatal ("No constructor found"); + abort (); } /* Return a non zero value if the `throws' clause of METHOD (if any) @@ -7723,7 +7721,7 @@ java_complete_expand_method (mdecl) /* Pop the exceptions and sanity check */ POP_EXCEPTIONS(); if (currently_caught_type_list) - fatal ("Exception list non empty - java_complete_expand_method"); + abort (); if (flag_emit_xref) DECL_FUNCTION_THROWS (mdecl) = exception_copy; @@ -8736,7 +8734,9 @@ cut_identifier_in_qualified (wfl) if (!TREE_CHAIN (q)) { if (!previous) - fatal ("Operating on a non qualified qualified WFL - cut_identifier_in_qualified"); + /* Operating on a non qualified qualified WFL. */ + abort (); + TREE_CHAIN (previous) = NULL_TREE; return TREE_PURPOSE (q); } @@ -9580,7 +9580,7 @@ check_deprecation (wfl, decl) strcpy (the, "class"); break; default: - fatal ("unexpected DECL code - check_deprecation"); + abort (); } parse_warning_context (wfl, "The %s `%s' in class `%s' has been deprecated", @@ -10181,7 +10181,7 @@ patch_invoke (patch, method, args) break; default: - fatal ("internal error - unknown invocation_mode result"); + abort (); } /* Ensure self_type is initialized, (invokestatic). FIXME */ @@ -10426,7 +10426,7 @@ find_applicable_accessible_methods_list (lc, class, name, arglist) { lc = 1; if (!list) - fatal ("finit$ not found in class -- find_applicable_accessible_methods_list"); + abort (); } /* We must search all interfaces of this class */ @@ -11644,7 +11644,7 @@ java_complete_lhs (node) return field; } else - fatal ("unimplemented java_complete_tree for COMPONENT_REF"); + abort (); break; case THIS_EXPR: @@ -11691,8 +11691,7 @@ java_complete_lhs (node) if ((nn = patch_string (node))) node = nn; else - fatal ("No case for tree code `%s' - java_complete_tree\n", - tree_code_name [TREE_CODE (node)]); + internal_error ("No case for %s", tree_code_name [TREE_CODE (node)]); } return node; } @@ -11841,7 +11840,7 @@ lookup_name_in_blocks (name) /* Paranoid sanity check. To be removed */ if (TREE_CODE (b) != BLOCK) - fatal ("non block expr function body - lookup_name_in_blocks"); + abort (); for (current = BLOCK_EXPR_DECLS (b); current; current = TREE_CHAIN (current)) @@ -12136,7 +12135,7 @@ check_final_variable_indirect_assignment (stmt) if (TREE_CODE (decl) != FUNCTION_DECL) decl = TREE_OPERAND (TREE_OPERAND (decl, 0), 0); if (TREE_CODE (decl) != FUNCTION_DECL) - fatal ("Can't find FUNCTION_DECL in CALL_EXPR - check_final_variable_indirect_assignment"); + abort (); if (DECL_FUNCTION_ALL_FINAL_INITIALIZED (decl)) return 1; if (DECL_FINIT_P (decl) || DECL_CONTEXT (decl) != current_class) @@ -12861,8 +12860,8 @@ operator_string (node) case PREDECREMENT_EXPR: /* Fall through */ case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--"); default: - fatal ("unregistered operator %s - operator_string", - tree_code_name [TREE_CODE (node)]); + internal_error ("unregistered operator %s", + tree_code_name [TREE_CODE (node)]); } return NULL; #undef BUILD_OPERATOR_STRING @@ -13561,8 +13560,7 @@ build_unaryop (op_token, op_location, op1) case MINUS_TK: op = NEGATE_EXPR; break; case NEG_TK: op = TRUTH_NOT_EXPR; break; case NOT_TK: op = BIT_NOT_EXPR; break; - default: fatal ("Unknown token `%d' for unary operator - build_unaryop", - op_token); + default: abort (); } unaryop = build1 (op, NULL_TREE, op1); diff --git a/gcc/java/typeck.c b/gcc/java/typeck.c index 83be326..e20903d 100644 --- a/gcc/java/typeck.c +++ b/gcc/java/typeck.c @@ -1,5 +1,6 @@ /* Handle types for the GNU compiler for the Java(TM) language. - Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 + Free Software Foundation, Inc. This file is part of GNU CC. @@ -52,8 +53,10 @@ set_local_type (slot, type) { int max_locals = DECL_MAX_LOCALS(current_function_decl); int nslots = TYPE_IS_WIDE (type) ? 2 : 1; + if (slot < 0 || slot + nslots - 1 >= max_locals) - fatal ("invalid local variable index"); + abort (); + type_map[slot] = type; while (--nslots > 0) type_map[++slot] = void_type_node; @@ -498,9 +501,11 @@ parse_signature_type (ptr, limit) const unsigned char **ptr, *limit; { tree type; - if ((*ptr) >= limit) - fatal ("bad signature string"); - switch (*(*ptr)) + + if (*ptr >= limit) + abort (); + + switch (**ptr) { case 'B': (*ptr)++; return byte_type_node; case 'C': (*ptr)++; return char_type_node; @@ -523,7 +528,7 @@ parse_signature_type (ptr, limit) for ( ; ; str++) { if (str >= limit) - fatal ("bad signature string"); + abort (); if (*str == ';') break; } @@ -532,7 +537,7 @@ parse_signature_type (ptr, limit) break; } default: - fatal ("unrecognized signature string"); + abort (); } return promote_type (type); } @@ -560,7 +565,7 @@ parse_signature_string (sig_string, sig_length) argtype_list = tree_cons (NULL_TREE, argtype, argtype_list); } if (str++, str >= limit) - fatal ("bad signature string"); + abort (); result_type = parse_signature_type (&str, limit); argtype_list = chainon (nreverse (argtype_list), end_params_node); result_type = build_function_type (result_type, argtype_list); @@ -696,7 +701,7 @@ build_java_signature (type) break; bad_type: default: - fatal ("internal error - build_java_signature passed invalid type"); + abort (); } TYPE_SIGNATURE (type) = sig; } @@ -716,7 +721,7 @@ set_java_signature (type, sig) MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type); old_sig = TYPE_SIGNATURE (type); if (old_sig != NULL_TREE && old_sig != sig) - fatal ("internal error - set_java_signature"); + abort (); TYPE_SIGNATURE (type) = sig; #if 0 /* careful about METHOD_TYPE */ if (IDENTIFIER_SIGNATURE_TYPE (sig) == NULL_TREE && TREE_PERMANENT (type)) diff --git a/gcc/java/verify.c b/gcc/java/verify.c index f25fff1..5ac1d05 100644 --- a/gcc/java/verify.c +++ b/gcc/java/verify.c @@ -1,6 +1,6 @@ /* Handle verification of bytecoded methods for the GNU compiler for the Java(TM) language. - Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This file is part of GNU CC. @@ -304,9 +304,10 @@ type_stack_dup (size, offset) index++; type[index] = stack_type_map[stack_pointer - 2]; if (! TYPE_IS_WIDE (type[index])) - fatal ("internal error - dup operation"); + abort (); if (index == size || index == size + offset) - fatal ("dup operation splits 64-bit number"); + /* Dup operation splits 64-bit number. */ + abort (); } pop_type (type[index]); } @@ -393,8 +394,7 @@ pop_argument_types (arg_types) #ifdef __GNUC__ #define CHECK_PC_IN_RANGE(PC) ({if (PC < 0 || PC > length) goto bad_pc; (void)1;}) #else -#define CHECK_PC_IN_RANGE(PC) (PC < 0 || PC > length ? \ - (fatal("Bad byte codes.\n"), 0) : 1) +#define CHECK_PC_IN_RANGE(PC) (PC < 0 || PC > length ? (abort (), 0) : 1) #endif #define BCODE byte_ops |