* java-gimplify.c: Use gcc_assert and gcc_unreachable throughout.
* typeck.c: Likewise.
* verify-impl.c: Likewise.
* class.c: Likewise.
* decl.c: Likewise.
* jcf-parse.c: Likewise.
* constants.c: Likewise.
* check-init.c: Likewise.
* jcf-write.c: Likewise.
* verify-glue.c: Likewise.
* mangle.c: Likewise.
* expr.c: Likewise.
* lang.c: Likewise.
* boehm.c: Likewise.
From-SVN: r110541
+2006-02-03 Ben Elliston <bje@au.ibm.com>
+
+ * java-gimplify.c: Use gcc_assert and gcc_unreachable throughout.
+ * typeck.c: Likewise.
+ * verify-impl.c: Likewise.
+ * class.c: Likewise.
+ * decl.c: Likewise.
+ * jcf-parse.c: Likewise.
+ * constants.c: Likewise.
+ * check-init.c: Likewise.
+ * jcf-write.c: Likewise.
+ * verify-glue.c: Likewise.
+ * mangle.c: Likewise.
+ * expr.c: Likewise.
+ * lang.c: Likewise.
+ * boehm.c: Likewise.
+
2006-02-01 Jan Hubicka <jh@suse.cz>
* decl.c (end_java_method): Kill hack disabling unit-at-a-time.
/* If this reference slot appears to overlay a slot we think
we already covered, then we are doomed. */
- if (offset <= *last_view_index)
- abort ();
+ gcc_assert (offset > *last_view_index);
count = offset * BITS_PER_UNIT / POINTER_SIZE;
size_words = size_bytes * BITS_PER_UNIT / POINTER_SIZE;
DECLARE_BUFFERS(when_true, 2);
words when_false = when_true + num_current_words;
#ifdef ENABLE_JC1_CHECKING
- if (TREE_CODE (alt->block) != LOOP_EXPR)
- abort ();
+ gcc_assert (TREE_CODE (alt->block) == LOOP_EXPR);
#endif
check_bool_init (TREE_OPERAND (exp, 0), before, when_false, when_true);
done_alternative (when_true, alt);
else if (type == void_type_node)
prim_class_name = "java.lang.Void";
else
- abort ();
+ gcc_unreachable ();
prim_class = lookup_class (get_identifier (prim_class_name));
/* We wrap the class in a NOP_EXPR, because it is a
access_flags |= ACC_INVISIBLE;
return access_flags;
}
- abort ();
+ gcc_unreachable ();
}
static GTY (()) int alias_labelno = 0;
{
if (meth == method)
return i;
- if (meth == NULL_TREE)
- abort ();
+ gcc_assert (meth != NULL_TREE);
}
}
}
}
- if (ptr != buffer + length)
- abort ();
+ gcc_assert (ptr == buffer + length);
}
static GTY(()) tree tag_nodes[13];
tree decl_type = TREE_TYPE (decl);
tree tmp;
- if (debug_variable_p (decl))
- abort ();
+ gcc_assert (! debug_variable_p (decl));
for (tmp = TREE_VEC_ELT (decl_map, index);
tmp != NULL_TREE;
&& TREE_CODE (decl_type) == POINTER_TYPE)))
{
tree src = build1 (NOP_EXPR, tmp_type, decl);
- if (LOCAL_VAR_OUT_OF_SCOPE_P (tmp))
- abort ();
+ gcc_assert (! LOCAL_VAR_OUT_OF_SCOPE_P (tmp));
java_add_stmt (build2 (MODIFY_EXPR, tmp_type, tmp, src));
}
}
{
tree decl_type = TREE_TYPE (decl);
- if (LOCAL_VAR_OUT_OF_SCOPE_P (decl))
- abort ();
+ gcc_assert (! LOCAL_VAR_OUT_OF_SCOPE_P (decl));
/* Use the same decl for all integer types <= 32 bits. This is
necessary because sometimes a value is stored as (for example)
int index = DECL_LOCAL_SLOT_NUMBER (var_decl);
tree base_decl = TREE_VEC_ELT (base_decl_map, index);
- if (! base_decl)
- abort ();
-
+ gcc_assert (base_decl);
if (! want_lvalue)
base_decl = build1 (NOP_EXPR, decl_type, base_decl);
{
tree parm_name = NULL_TREE, parm_decl;
tree parm_type = TREE_VALUE (tem);
- if (i >= DECL_MAX_LOCALS (fndecl))
- abort ();
+ gcc_assert (i < DECL_MAX_LOCALS (fndecl));
parm_decl = build_decl (PARM_DECL, parm_name, parm_type);
DECL_CONTEXT (parm_decl) = fndecl;
void
register_exception_range (struct eh_range *range, int pc, int end_pc)
{
- if (current_binding_level->exception_range)
- abort ();
+ gcc_assert (! current_binding_level->exception_range);
current_binding_level->exception_range = range;
current_binding_level->end_pc = end_pc;
current_binding_level->start_pc = pc;
void
push_type (tree type)
{
- if (! push_type_0 (type))
- abort ();
+ gcc_assert (push_type_0 (type));
}
static void
{
tree type, val;
- if (stack_pointer == 0)
- abort ();
+ gcc_assert (stack_pointer != 0);
type = stack_type_map[stack_pointer - 1];
if (type == TYPE_SECOND)
{
count--;
- if (stack_pointer == 1 || count <= 0)
- abort ();
+ gcc_assert (stack_pointer != 1 && count > 0);
type = stack_type_map[stack_pointer - 2];
}
tree temp;
tree decl1, decl2;
- if (stack_pointer < 2
- || (type1 = stack_type_map[stack_pointer - 1]) == TYPE_UNKNOWN
- || (type2 = stack_type_map[stack_pointer - 2]) == TYPE_UNKNOWN
- || type1 == TYPE_SECOND || type2 == TYPE_SECOND
- || TYPE_IS_WIDE (type1) || TYPE_IS_WIDE (type2))
- /* Bad stack swap. */
- abort ();
+ /* Bad stack swap. */
+ gcc_assert (stack_pointer >= 2
+ && (type1 = stack_type_map[stack_pointer - 1]) != TYPE_UNKNOWN
+ && (type2 = stack_type_map[stack_pointer - 2]) != TYPE_UNKNOWN
+ && (type1 != TYPE_SECOND && type2 != TYPE_SECOND)
+ && (! TYPE_IS_WIDE (type1) && ! TYPE_IS_WIDE (type2)));
flush_quick_stack ();
decl1 = find_stack_slot (stack_pointer - 1, type1);
type = stack_type_map [src_index];
if (type == TYPE_SECOND)
{
- if (src_index <= low_index)
- /* Dup operation splits 64-bit number. */
- abort ();
+ /* Dup operation splits 64-bit number. */
+ gcc_assert (src_index > low_index);
stack_type_map[dst_index] = type;
src_index--; dst_index--;
type = stack_type_map[src_index];
- if (! TYPE_IS_WIDE (type))
- abort ();
+ gcc_assert (TYPE_IS_WIDE (type));
}
- else if (TYPE_IS_WIDE (type))
- abort ();
+ else
+ gcc_assert (! TYPE_IS_WIDE (type));
if (src_index != dst_index)
{
else if (type == long_type_node)
return 11;
else
- abort ();
+ gcc_unreachable ();
}
/* Build a call to _Jv_ThrowBadArrayIndex(), the
}
else
{
- if (! is_array_type_p (array_type_p))
- abort ();
+ gcc_assert (is_array_type_p (array_type_p));
/* Get the TYPE_DECL for ARRAY's element type. */
element_type
= TYPE_NAME (TREE_TYPE (TREE_TYPE (TREE_TYPE (array_type_p))));
}
- if (TREE_CODE (element_type) != TYPE_DECL
- || TREE_CODE (object_type) != TYPE_DECL)
- abort ();
+ gcc_assert (TREE_CODE (element_type) == TYPE_DECL
+ && TREE_CODE (object_type) == TYPE_DECL);
if (!flag_store_check)
return build1 (NOP_EXPR, array_type_p, array);
value = build_real (type, x);
}
else
- abort ();
+ gcc_unreachable ();
push_value (value);
}
}
}
- if (! call)
- abort ();
-
+ gcc_assert (call);
call = build3 (CALL_EXPR, type,
build_address_of (call),
tree_cons (NULL_TREE, arg1,
arg = convert (integer_type_node, arg);
return tree_cons (NULL_TREE, arg, tail);
}
- abort ();
+ gcc_unreachable ();
}
/* Attach to PTR (a block) the declaration found in ENTRY. */
if (flag_indirect_dispatch)
{
- if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
- abort ();
+ gcc_assert (! CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))));
otable_index
= build_int_cst (NULL_TREE, get_symbol_table_index
lookup_field (&dtable_type, class_ident), NULL_TREE);
interface = DECL_CONTEXT (method);
- if (! CLASS_INTERFACE (TYPE_NAME (interface)))
- abort ();
+ gcc_assert (CLASS_INTERFACE (TYPE_NAME (interface)));
layout_class_methods (interface);
if (flag_indirect_dispatch)
int from_class = ! CLASS_FROM_SOURCE_P (klass);
klass = build_class_ref (klass);
- if (! METHOD_NATIVE (method) || ! flag_jni)
- abort ();
+ gcc_assert (METHOD_NATIVE (method) && flag_jni);
DECL_ARTIFICIAL (method) = 1;
DECL_EXTERNAL (method) = 0;
if (res_var != NULL_TREE)
{
tree drt;
- if (! DECL_RESULT (method))
- abort ();
+ gcc_assert (DECL_RESULT (method));
/* Make sure we copy the result variable to the actual
result. We use the type of the DECL_RESULT because it
might be different from the return type of the function:
return node;
/* Not having a list of arguments here is an error. */
- if (TREE_CODE (arg) != TREE_LIST)
- abort ();
+ gcc_assert (TREE_CODE (arg) == TREE_LIST);
/* This reverses the evaluation order. This is a desired effect. */
for (cmp = NULL_TREE; arg; arg = TREE_CHAIN (arg))
case CONDITIONAL_EXPR:
case INSTANCEOF_EXPR:
case CLASS_LITERAL:
- abort ();
+ gcc_unreachable ();
default:
/* Java insists on strict left-to-right evaluation of expressions.
else
{
/* Shouldn't happen. */
- abort ();
+ gcc_unreachable ();
}
}
tree
parse_signature (JCF *jcf, int sig_index)
{
- if (sig_index <= 0 || sig_index >= JPOOL_SIZE (jcf)
- || JPOOL_TAG (jcf, sig_index) != CONSTANT_Utf8)
- abort ();
- else
- return parse_signature_string (JPOOL_UTF_DATA (jcf, sig_index),
- JPOOL_UTF_LENGTH (jcf, sig_index));
+ gcc_assert (sig_index > 0
+ && sig_index < JPOOL_SIZE (jcf)
+ && JPOOL_TAG (jcf, sig_index) == CONSTANT_Utf8);
+
+ return parse_signature_string (JPOOL_UTF_DATA (jcf, sig_index),
+ JPOOL_UTF_LENGTH (jcf, sig_index));
}
tree
get_name_constant (JCF *jcf, int index)
{
tree name = get_constant (jcf, index);
-
- if (TREE_CODE (name) != IDENTIFIER_NODE)
- abort ();
-
+ gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
return name;
}
static tree
give_name_to_class (JCF *jcf, int i)
{
- if (i <= 0 || i >= JPOOL_SIZE (jcf)
- || JPOOL_TAG (jcf, i) != CONSTANT_Class)
- abort ();
- else
+ gcc_assert (i > 0
+ && i < JPOOL_SIZE (jcf)
+ && JPOOL_TAG (jcf, i) == CONSTANT_Class);
+
{
tree package_name = NULL_TREE, tmp;
tree this_class;
get_class_constant (JCF *jcf, int i)
{
tree type;
- if (i <= 0 || i >= JPOOL_SIZE (jcf)
- || (JPOOL_TAG (jcf, i) & ~CONSTANT_ResolvedFlag) != CONSTANT_Class)
- abort ();
+ gcc_assert (i > 0
+ && i < JPOOL_SIZE (jcf)
+ && (JPOOL_TAG (jcf, i) & ~CONSTANT_ResolvedFlag) == CONSTANT_Class);
if (JPOOL_TAG (jcf, i) != CONSTANT_ResolvedClass)
{
CLASS_FROM_CURRENTLY_COMPILED_P (current_class) = 1;
- if (TYPE_DUMMY (class))
- {
- /* This is a dummy class, and now we're compiling it
- for real. */
- abort ();
- }
+ /* This is a dummy class, and now we're compiling it for
+ real. */
+ gcc_assert (! TYPE_DUMMY (class));
/* This is for a corner case where we have a superclass
but no superclass fields.
break;
default:
- abort ();
+ gcc_unreachable ();
}
}
}
/* Macro to call each time we pop I words from the JVM stack. */
#define NOTE_POP(I) \
- do { state->code_SP -= (I); if (state->code_SP < 0) abort(); } while (0)
+ do { state->code_SP -= (I); gcc_assert (state->code_SP >= 0); } while (0)
/* A chunk or segment of a .class file. */
static int
CHECK_PUT (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)
- abort ();
-
+ gcc_assert ((unsigned char *) ptr >= state->chunk->data
+ && (unsigned char *) ptr + i <= state->chunk->data + state->chunk->size);
return 0;
}
#else
static int
CHECK_OP (struct jcf_partial *state)
{
- if (state->bytecode.ptr > state->bytecode.limit)
- abort ();
-
+ gcc_assert (state->bytecode.ptr <= state->bytecode.limit);
return 0;
}
#else
info->end_label = end_label;
- if (info->decl != decl)
- abort ();
+ gcc_assert (info->decl == decl);
if (! really)
return;
ptr[0] = NULL;
if (wide)
{
- if (ptr[1] != (struct localvar_info *)(~0))
- abort ();
+ gcc_assert (ptr[1] == (struct localvar_info *) (~0));
ptr[1] = NULL;
}
}
flags |= ACC_STRICT;
}
else
- abort ();
+ gcc_unreachable ();
if (TREE_CODE (decl) == FUNCTION_DECL)
{
return find_string_constant (&state->cpool, value);
else
- abort ();
+ gcc_unreachable ();
}
/* Push 64-bit long constant on VM stack.
default:
break;
}
- abort ();
+ gcc_unreachable ();
}
static void
else if (offset == 2)
kind = size == 1 ? OPCODE_dup_x2 : OPCODE_dup2_x2;
else
- abort();
+ gcc_unreachable ();
OP1 (kind);
NOTE_PUSH (size);
}
generate_bytecode_conditional (TREE_OPERAND (exp, 2),
true_label, false_label,
true_branch_first, state);
- if (state->code_SP != save_SP_after)
- abort ();
+ gcc_assert (state->code_SP == save_SP_after);
}
break;
case TRUTH_NOT_EXPR:
{
case EQ_EXPR: op = OPCODE_if_acmpeq; break;
case NE_EXPR: op = OPCODE_if_acmpne; break;
- default: abort();
+ default:
+ gcc_unreachable ();
}
if (integer_zerop (exp1) || integer_zerop (exp0))
{
}
break;
}
- if (save_SP != state->code_SP)
- abort ();
+ gcc_assert (save_SP == state->code_SP);
}
/* Call pending cleanups i.e. those for surrounding TRY_FINALLY_EXPRs.
if (target == IGNORE_TARGET) ; /* do nothing */
else if (TREE_CODE (type) == POINTER_TYPE)
{
- if (! integer_zerop (exp))
- abort();
+ gcc_assert (integer_zerop (exp));
RESERVE(1);
OP1 (OPCODE_aconst_null);
NOTE_PUSH (1);
if (exp == NULL_TREE)
exp = build_java_empty_stmt ();
else if (TREE_CODE (exp) != MODIFY_EXPR)
- abort ();
+ gcc_unreachable ();
else
exp = TREE_OPERAND (exp, 1);
generate_bytecode_return (exp, state);
end_label->u.labeled_block = exp;
if (LABELED_BLOCK_BODY (exp))
generate_bytecode_insns (LABELED_BLOCK_BODY (exp), target, state);
- if (state->labeled_blocks != end_label)
- abort();
+ gcc_assert (state->labeled_blocks == end_label);
state->labeled_blocks = end_label->next;
define_jcf_label (end_label, state);
}
offset = 0;
}
else
- abort ();
+ gcc_unreachable ();
if (target != IGNORE_TARGET && post_op)
emit_dup (size, offset, state);
NOTE_PUSH (TYPE_IS_WIDE (TREE_TYPE (lhs)) ? 2 : 1);
}
else
- abort ();
+ gcc_unreachable ();
/* This function correctly handles the case where the LHS
of a binary expression is NULL_TREE. */
NOTE_POP (TYPE_IS_WIDE (TREE_TYPE (exp)) ? 4 : 3);
}
else
- abort ();
+ gcc_unreachable ();
break;
case PLUS_EXPR:
jopcode = OPCODE_iadd;
struct jcf_block *end_label; /* End of try clause. */
struct jcf_block *finished_label = gen_jcf_label (state);
tree clause = TREE_OPERAND (exp, 1);
- if (target != IGNORE_TARGET)
- abort ();
+ gcc_assert (target == IGNORE_TARGET);
generate_bytecode_insns (try_clause, IGNORE_TARGET, state);
end_label = get_jcf_label_here (state);
if (end_label == start_label)
if (CAN_COMPLETE_NORMALLY (finally))
{
- if (state->labeled_blocks != finally_label)
- abort();
+ gcc_assert (state->labeled_blocks == finally_label);
state->labeled_blocks = finally_label->next;
}
end_label = get_jcf_label_here (state);
tree op0 = TREE_OPERAND (exp, 0);
tree op1 = TREE_OPERAND (exp, 1);
tree x;
- if (TREE_SIDE_EFFECTS (op0) || TREE_SIDE_EFFECTS (op1))
- abort ();
+ gcc_assert (! TREE_SIDE_EFFECTS (op0) && ! TREE_SIDE_EFFECTS (op1));
x = build3 (COND_EXPR, TREE_TYPE (exp),
build2 (code, boolean_type_node, op0, op1),
op0, op1);
OP2 (index);
if (interface)
{
- if (nargs <= 0)
- abort ();
-
+ gcc_assert (nargs > 0);
OP1 (nargs);
OP1 (0);
}
*--new_ptr = - reloc->kind;
}
}
- if (new_ptr != chunk->data)
- abort ();
+ gcc_assert (new_ptr == chunk->data);
}
state->code_length = pc;
}
generate_bytecode_insns (body, IGNORE_TARGET, state);
if (CAN_COMPLETE_NORMALLY (body))
{
- if (TREE_CODE (TREE_TYPE (type)) != VOID_TYPE)
- abort();
+ gcc_assert (TREE_CODE (TREE_TYPE (type)) == VOID_TYPE);
RESERVE (1);
OP1 (OPCODE_return);
}
default:
if (cl_options[code].flags & CL_Java)
break;
- abort();
+ gcc_unreachable ();
}
return 1;
/* 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
break;
bad_type:
default:
- abort ();
+ gcc_unreachable ();
}
}
#define ADD_N() \
do { obstack_1grow (mangle_obstack, 'N'); nadded_p = 1; } while (0)
- if (TREE_CODE (type) != RECORD_TYPE)
- abort ();
+ gcc_assert (TREE_CODE (type) == RECORD_TYPE);
if (!TYPE_PACKAGE_LIST (type))
set_type_package_list (type);
/* This didn't work. We start by mangling the pointed-to type */
pointer_type = type;
type = TREE_TYPE (type);
- if (TREE_CODE (type) != RECORD_TYPE)
- abort ();
+ gcc_assert (TREE_CODE (type) == RECORD_TYPE);
obstack_1grow (mangle_obstack, 'P');
if (mangle_record_type (type, /* for_pointer = */ 1))
int match;
type = TREE_TYPE (p_type);
- if (!type)
- abort ();
+ gcc_assert (type);
elt_type = TYPE_ARRAY_ELEMENT (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)
- abort ();
+ gcc_assert (slot >= 0 && (slot + nslots - 1 < max_locals));
type_map[slot] = type;
while (--nslots > 0)
parse_signature_type (const unsigned char **ptr, const unsigned char *limit)
{
tree type;
-
- if (*ptr >= limit)
- abort ();
+ gcc_assert (*ptr < limit);
switch (**ptr)
{
const unsigned char *str = start;
for ( ; ; str++)
{
- if (str >= limit)
- abort ();
+ gcc_assert (str < limit);
if (*str == ';')
break;
}
break;
}
default:
- abort ();
+ gcc_unreachable ();
}
return promote_type (type);
}
break;
bad_type:
default:
- abort ();
+ gcc_unreachable ();
}
TYPE_SIGNATURE (type) = sig;
}
vfy_get_primitive_char (vfy_jclass klass)
{
tree sig;
- if (! vfy_is_primitive (klass))
- abort ();
+ gcc_assert (vfy_is_primitive (klass));
sig = build_java_signature (klass);
return (IDENTIFIER_POINTER (sig))[0];
}
vfy_get_component_type (vfy_jclass klass)
{
vfy_jclass k;
- if (! vfy_is_array (klass))
- abort ();
+ gcc_assert (vfy_is_array (klass));
k = TYPE_ARRAY_ELEMENT (klass);
if (TREE_CODE (k) == POINTER_TYPE)
k = TREE_TYPE (k);
return vfy_object_type ();
}
- abort ();
+ gcc_unreachable ();
}
static void
vfy_unsuitable_type ());
}
}
- if (slot != curr->stackdepth)
- abort ();
+ gcc_assert (slot == curr->stackdepth);
}
}