From 366de0ce7d916d313aba839a2802cfbc70b991cf Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 7 Sep 2004 10:19:00 +0000 Subject: [PATCH] c-aux-info.c (gen_type): Use gcc_assert or gcc_unreachable. * c-aux-info.c (gen_type): Use gcc_assert or gcc_unreachable. * c-common.c (c_type_hash, c_common_nodes_and_builtins, c_expand_expr, boolean_increment, nonnull_check_p, check_function_arguments_recurse, fold_offsetof_1): Likewise. * c-cppbuiltin.c (define__GNUC__, builtin_define_stdint_macros, builtin_define_type_max): Likewise. * c-decl.c (bind, pop_scope, merge_decls, pushdecl_top_level, implicit_decl_warning, builtin_function, build_compound_literal, complete_array_type, grokdeclarator, get_parm_info, start_function, store_parm_decls_oldstyle, c_write_global_declarations): Likewise. * c-format.c (get_constant, decode_format_attr, maybe_read_dollar_number, get_flag_spec, check_format_arg, check_format_types, format_type_warning, find_char_info_specifier_index, init_dynamic_asm_fprintf_info, init_dynamic_diag_info, handle_format_attribute): Likewise. * c-gimplify.c (push_context, pop_context, finish_bc_block): * c-lex.c (c_lex_with_flags, lex_string): Likewise. * c-objc-common.c (c_tree_printer): Likewise. * c-pch.c (pch_init): Likewise. * c-pragma.c (maybe_apply_pragma_weak): Likewise. * c-pretty-print.c (pp_c_tree_decl_identifier): Likewise. * c-typeck.c (c_incomplete_type_error, composite_type, common_pointer_type, common_type, same_translation_unit_p, tagged_types_tu_compatible_p, finish_init, pop_init_level, set_designator, set_nonincremental_init_from_string, process_init_element, c_finish_if_stmt): Likewise. * caller-save.c (init_caller_save, save_call_clobbered_regs, insert_restore, insert_save, insert_one_insn): Likewise. * calls.c (emit_call_1, compute_argument_block_size, precompute_arguments, expand_call, emit_library_call_value_1, store_one_arg): Likewise. From-SVN: r87140 --- gcc/ChangeLog | 35 +++ gcc/c-aux-info.c | 2 +- gcc/c-common.c | 22 +- gcc/c-cppbuiltin.c | 17 +- gcc/c-decl.c | 693 +++++++++++++++++++++---------------------- gcc/c-format.c | 82 +++-- gcc/c-gimplify.c | 9 +- gcc/c-lex.c | 15 +- gcc/c-objc-common.c | 7 +- gcc/c-pch.c | 11 +- gcc/c-pragma.c | 2 +- gcc/c-pretty-print.c | 3 +- gcc/c-typeck.c | 85 +++--- gcc/caller-save.c | 45 +-- gcc/calls.c | 119 ++++---- 15 files changed, 553 insertions(+), 594 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4aeba215d02..bc6075e9540 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,38 @@ +2004-09-07 Nathan Sidwell + + * c-aux-info.c (gen_type): Use gcc_assert or gcc_unreachable. + * c-common.c (c_type_hash, c_common_nodes_and_builtins, + c_expand_expr, boolean_increment, nonnull_check_p, + check_function_arguments_recurse, fold_offsetof_1): Likewise. + * c-cppbuiltin.c (define__GNUC__, builtin_define_stdint_macros, + builtin_define_type_max): Likewise. + * c-decl.c (bind, pop_scope, merge_decls, pushdecl_top_level, + implicit_decl_warning, builtin_function, build_compound_literal, + complete_array_type, grokdeclarator, get_parm_info, + start_function, store_parm_decls_oldstyle, + c_write_global_declarations): Likewise. + * c-format.c (get_constant, decode_format_attr, + maybe_read_dollar_number, get_flag_spec, check_format_arg, + check_format_types, format_type_warning, + find_char_info_specifier_index, init_dynamic_asm_fprintf_info, + init_dynamic_diag_info, handle_format_attribute): Likewise. + * c-gimplify.c (push_context, pop_context, finish_bc_block): + * c-lex.c (c_lex_with_flags, lex_string): Likewise. + * c-objc-common.c (c_tree_printer): Likewise. + * c-pch.c (pch_init): Likewise. + * c-pragma.c (maybe_apply_pragma_weak): Likewise. + * c-pretty-print.c (pp_c_tree_decl_identifier): Likewise. + * c-typeck.c (c_incomplete_type_error, composite_type, + common_pointer_type, common_type, same_translation_unit_p, + tagged_types_tu_compatible_p, finish_init, pop_init_level, + set_designator, set_nonincremental_init_from_string, + process_init_element, c_finish_if_stmt): Likewise. + * caller-save.c (init_caller_save, save_call_clobbered_regs, + insert_restore, insert_save, insert_one_insn): Likewise. + * calls.c (emit_call_1, compute_argument_block_size, + precompute_arguments, expand_call, emit_library_call_value_1, + store_one_arg): Likewise. + 2004-09-07 Nathan Sidwell * configure.ac (enable-checking): Add release option. Reorganize diff --git a/gcc/c-aux-info.c b/gcc/c-aux-info.c index 8d457836c75..b42adce9a80 100644 --- a/gcc/c-aux-info.c +++ b/gcc/c-aux-info.c @@ -447,7 +447,7 @@ gen_type (const char *ret_val, tree t, formals_style style) break; default: - abort (); + gcc_unreachable (); } } if (TYPE_READONLY (t)) diff --git a/gcc/c-common.c b/gcc/c-common.c index e1fa8e497cd..b7aa389cbfa 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -2578,7 +2578,7 @@ c_type_hash (const void *p) t2 = TYPE_FIELDS (t); break; default: - abort (); + gcc_unreachable (); } for (; t2; t2 = TREE_CHAIN (t2)) i++; @@ -3188,8 +3188,8 @@ c_common_nodes_and_builtins (void) { \ tree decl; \ \ - if (strncmp (NAME, "__builtin_", strlen ("__builtin_")) != 0) \ - abort (); \ + gcc_assert (!strncmp (NAME, "__builtin_", \ + strlen ("__builtin_"))); \ \ if (!BOTH_P) \ decl = lang_hooks.builtin_function (NAME, builtin_types[TYPE], \ @@ -3830,7 +3830,7 @@ c_expand_expr (tree exp, rtx target, enum machine_mode tmode, } default: - abort (); + gcc_unreachable (); } } @@ -3878,7 +3878,7 @@ boolean_increment (enum tree_code code, tree arg) val = build2 (COMPOUND_EXPR, TREE_TYPE (arg), arg, val); break; default: - abort (); + gcc_unreachable (); } TREE_SIDE_EFFECTS (val) = 1; return val; @@ -5111,8 +5111,9 @@ nonnull_check_p (tree args, unsigned HOST_WIDE_INT param_num) for (; args; args = TREE_CHAIN (args)) { - if (! get_nonnull_operand (TREE_VALUE (args), &arg_num)) - abort (); + bool found = get_nonnull_operand (TREE_VALUE (args), &arg_num); + + gcc_assert (found); if (arg_num == param_num) return true; @@ -5356,9 +5357,8 @@ check_function_arguments_recurse (void (*callback) || TREE_CODE (format_num_expr) == NON_LVALUE_EXPR) format_num_expr = TREE_OPERAND (format_num_expr, 0); - if (TREE_CODE (format_num_expr) != INTEGER_CST - || TREE_INT_CST_HIGH (format_num_expr) != 0) - abort (); + gcc_assert (TREE_CODE (format_num_expr) == INTEGER_CST + && !TREE_INT_CST_HIGH (format_num_expr)); format_num = TREE_INT_CST_LOW (format_num_expr); @@ -5619,7 +5619,7 @@ fold_offsetof_1 (tree expr) break; default: - abort (); + gcc_unreachable (); } return size_binop (code, base, off); diff --git a/gcc/c-cppbuiltin.c b/gcc/c-cppbuiltin.c index f6a1805f0b8..c20e987e83a 100644 --- a/gcc/c-cppbuiltin.c +++ b/gcc/c-cppbuiltin.c @@ -261,8 +261,7 @@ define__GNUC__ (void) while (*v && ! ISDIGIT (*v)) v++; - if (!*v || (v > version_string && v[-1] != '-')) - abort (); + gcc_assert (*v && (v <= version_string || v[-1] == '-')); q = v; while (ISDIGIT (*v)) @@ -271,8 +270,8 @@ define__GNUC__ (void) if (c_dialect_cxx ()) builtin_define_with_value_n ("__GNUG__", q, v - q); - if (*v != '.' || !ISDIGIT (v[1])) - abort (); + gcc_assert (*v == '.' || ISDIGIT (v[1])); + q = ++v; while (ISDIGIT (*v)) v++; @@ -280,8 +279,7 @@ define__GNUC__ (void) if (*v == '.') { - if (!ISDIGIT (v[1])) - abort (); + gcc_assert (ISDIGIT (v[1])); q = ++v; while (ISDIGIT (*v)) v++; @@ -290,8 +288,7 @@ define__GNUC__ (void) else builtin_define_with_value_n ("__GNUC_PATCHLEVEL__", "0", 1); - if (*v && *v != ' ' && *v != '-') - abort (); + gcc_assert (!*v || *v == ' ' || *v == '-'); } /* Define macros used by . Currently only defines limits @@ -307,7 +304,7 @@ builtin_define_stdint_macros (void) else if (intmax_type_node == integer_type_node) intmax_long = 0; else - abort (); + gcc_unreachable (); builtin_define_type_max ("__INTMAX_MAX__", intmax_type_node, intmax_long); } @@ -617,7 +614,7 @@ builtin_define_type_max (const char *macro, tree type, int is_long) case 32: idx = 4; break; case 64: idx = 6; break; case 128: idx = 8; break; - default: abort (); + default: gcc_unreachable (); } value = values[idx + TYPE_UNSIGNED (type)]; diff --git a/gcc/c-decl.c b/gcc/c-decl.c index f5c74f35aa6..aad75640ca9 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -477,7 +477,7 @@ bind (tree name, tree decl, struct c_scope *scope, bool invisible, bool nested) case ERROR_MARK: here = &I_SYMBOL_BINDING (name); break; default: - abort (); + gcc_unreachable (); } /* Locate the appropriate place in the chain of shadowed decls @@ -731,10 +731,7 @@ pop_scope (void) /* Labels go in BLOCK_VARS. */ TREE_CHAIN (p) = BLOCK_VARS (block); BLOCK_VARS (block) = p; - -#ifdef ENABLE_CHECKING - if (I_LABEL_BINDING (b->id) != b) abort (); -#endif + gcc_assert (I_LABEL_BINDING (b->id) == b); I_LABEL_BINDING (b->id) = b->shadowed; break; @@ -747,9 +744,7 @@ pop_scope (void) appears in the bindings list with b->id NULL. */ if (b->id) { -#ifdef ENABLE_CHECKING - if (I_TAG_BINDING (b->id) != b) abort (); -#endif + gcc_assert (I_TAG_BINDING (b->id) == b); I_TAG_BINDING (b->id) = b->shadowed; } break; @@ -819,9 +814,7 @@ pop_scope (void) here with b->id NULL in this case. */ if (b->id) { -#ifdef ENABLE_CHECKING - if (I_SYMBOL_BINDING (b->id) != b) abort (); -#endif + gcc_assert (I_SYMBOL_BINDING (b->id) == b); I_SYMBOL_BINDING (b->id) = b->shadowed; if (b->shadowed && b->shadowed->type) TREE_TYPE (b->shadowed->decl) = b->shadowed->type; @@ -829,7 +822,7 @@ pop_scope (void) break; default: - abort (); + gcc_unreachable (); } } @@ -1527,7 +1520,7 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) for (here = ¤t_scope->bindings; *here; here = &(*here)->prev) if ((*here)->decl == olddecl) goto found; - abort (); + gcc_unreachable (); found: b = *here; @@ -2124,13 +2117,11 @@ pushdecl_top_level (tree x) tree name; bool nested = false; - if (TREE_CODE (x) != VAR_DECL) - abort (); + gcc_assert (TREE_CODE (x) == VAR_DECL); name = DECL_NAME (x); - if (I_SYMBOL_BINDING (name)) - abort (); + gcc_assert (!I_SYMBOL_BINDING (name)); if (TREE_PUBLIC (x)) { @@ -2152,7 +2143,7 @@ implicit_decl_warning (tree id, tree olddecl) case 0: return; case 1: diag = warning; break; case 2: diag = error; break; - default: abort (); + default: gcc_unreachable (); } diag (N_("implicit declaration of function '%E'"), id); @@ -2644,8 +2635,7 @@ builtin_function (const char *name, tree type, int function_code, SET_DECL_ASSEMBLER_NAME (decl, get_identifier (library_name)); /* Should never be called on a symbol with a preexisting meaning. */ - if (I_SYMBOL_BINDING (id)) - abort (); + gcc_assert (!I_SYMBOL_BINDING (id)); bind (id, decl, external_scope, /*invisible=*/true, /*nested=*/false); @@ -3439,8 +3429,8 @@ build_compound_literal (tree type, tree init) if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type)) { int failure = complete_array_type (type, DECL_INITIAL (decl), 1); - if (failure) - abort (); + + gcc_assert (!failure); } type = TREE_TYPE (decl); @@ -3529,8 +3519,8 @@ complete_array_type (tree type, tree initial_value, int do_default) if (maxindex) { TYPE_DOMAIN (type) = build_index_type (maxindex); - if (!TREE_TYPE (maxindex)) - abort (); + + gcc_assert (TREE_TYPE (maxindex)); } /* Lay out the type now that we can get the real answer. */ @@ -3737,7 +3727,7 @@ grokdeclarator (tree declarator, tree declspecs, break; default: - abort (); + gcc_unreachable (); } orig_name = name; if (name == 0) @@ -4211,333 +4201,341 @@ grokdeclarator (tree declarator, tree declspecs, array_parm_static = 0; } - if (TREE_CODE (declarator) == TREE_LIST) - { - /* We encode a declarator with embedded attributes using - a TREE_LIST. */ - tree attrs = TREE_PURPOSE (declarator); - tree inner_decl; - int attr_flags = 0; - declarator = TREE_VALUE (declarator); - inner_decl = declarator; - while (inner_decl != NULL_TREE - && TREE_CODE (inner_decl) == TREE_LIST) - inner_decl = TREE_VALUE (inner_decl); - if (inner_decl == NULL_TREE - || TREE_CODE (inner_decl) == IDENTIFIER_NODE) - attr_flags |= (int) ATTR_FLAG_DECL_NEXT; - else if (TREE_CODE (inner_decl) == CALL_EXPR) - attr_flags |= (int) ATTR_FLAG_FUNCTION_NEXT; - else if (TREE_CODE (inner_decl) == ARRAY_REF) - attr_flags |= (int) ATTR_FLAG_ARRAY_NEXT; - returned_attrs = decl_attributes (&type, - chainon (returned_attrs, attrs), - attr_flags); - } - else if (TREE_CODE (declarator) == ARRAY_REF) + switch (TREE_CODE (declarator)) { - tree itype = NULL_TREE; - tree size = TREE_OPERAND (declarator, 1); - /* The index is a signed object `sizetype' bits wide. */ - tree index_type = c_common_signed_type (sizetype); - - array_ptr_quals = TREE_TYPE (declarator); - array_parm_static = TREE_STATIC (declarator); - - declarator = TREE_OPERAND (declarator, 0); - - /* Check for some types that there cannot be arrays of. */ - - if (VOID_TYPE_P (type)) - { - error ("declaration of `%s' as array of voids", name); - type = error_mark_node; - } - - if (TREE_CODE (type) == FUNCTION_TYPE) - { - error ("declaration of `%s' as array of functions", name); + case TREE_LIST: + { + /* We encode a declarator with embedded attributes using a + TREE_LIST. */ + tree attrs = TREE_PURPOSE (declarator); + tree inner_decl; + int attr_flags = 0; + declarator = TREE_VALUE (declarator); + inner_decl = declarator; + while (inner_decl != NULL_TREE + && TREE_CODE (inner_decl) == TREE_LIST) + inner_decl = TREE_VALUE (inner_decl); + if (inner_decl == NULL_TREE + || TREE_CODE (inner_decl) == IDENTIFIER_NODE) + attr_flags |= (int) ATTR_FLAG_DECL_NEXT; + else if (TREE_CODE (inner_decl) == CALL_EXPR) + attr_flags |= (int) ATTR_FLAG_FUNCTION_NEXT; + else if (TREE_CODE (inner_decl) == ARRAY_REF) + attr_flags |= (int) ATTR_FLAG_ARRAY_NEXT; + returned_attrs = decl_attributes (&type, + chainon (returned_attrs, attrs), + attr_flags); + break; + } + case ARRAY_REF: + { + tree itype = NULL_TREE; + tree size = TREE_OPERAND (declarator, 1); + /* The index is a signed object `sizetype' bits wide. */ + tree index_type = c_common_signed_type (sizetype); + + array_ptr_quals = TREE_TYPE (declarator); + array_parm_static = TREE_STATIC (declarator); + + declarator = TREE_OPERAND (declarator, 0); + + /* Check for some types that there cannot be arrays of. */ + + if (VOID_TYPE_P (type)) + { + error ("declaration of `%s' as array of voids", name); + type = error_mark_node; + } + + if (TREE_CODE (type) == FUNCTION_TYPE) + { + error ("declaration of `%s' as array of functions", name); + type = error_mark_node; + } + + if (pedantic && !in_system_header && flexible_array_type_p (type)) + pedwarn ("invalid use of structure with flexible array member"); + + if (size == error_mark_node) type = error_mark_node; - } - - if (pedantic && !in_system_header && flexible_array_type_p (type)) - pedwarn ("invalid use of structure with flexible array member"); - - if (size == error_mark_node) - type = error_mark_node; - - if (type == error_mark_node) - continue; - - /* If size was specified, set ITYPE to a range-type for that size. - Otherwise, ITYPE remains null. finish_decl may figure it out - from an initial value. */ - - if (size) - { - /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */ - STRIP_TYPE_NOPS (size); - - if (! INTEGRAL_TYPE_P (TREE_TYPE (size))) - { - error ("size of array `%s' has non-integer type", name); - size = integer_one_node; - } - - if (pedantic && integer_zerop (size)) - pedwarn ("ISO C forbids zero-size array `%s'", name); - - if (TREE_CODE (size) == INTEGER_CST) - { - constant_expression_warning (size); - if (tree_int_cst_sgn (size) < 0) - { - error ("size of array `%s' is negative", name); - size = integer_one_node; - } - } - else - { - /* Make sure the array size remains visibly nonconstant - even if it is (eg) a const variable with known value. */ - size_varies = 1; - - if (!flag_isoc99 && pedantic) - { - if (TREE_CONSTANT (size)) - pedwarn ("ISO C90 forbids array `%s' whose size can't be evaluated", - name); - else - pedwarn ("ISO C90 forbids variable-size array `%s'", - name); - } - } - - if (integer_zerop (size)) - { - /* A zero-length array cannot be represented with an - unsigned index type, which is what we'll get with - build_index_type. Create an open-ended range instead. */ - itype = build_range_type (sizetype, size, NULL_TREE); - } - else - { - /* Compute the maximum valid index, that is, size - 1. - Do the calculation in index_type, so that if it is - a variable the computations will be done in the - proper mode. */ - itype = fold (build2 (MINUS_EXPR, index_type, - convert (index_type, size), - convert (index_type, size_one_node))); - - /* If that overflowed, the array is too big. - ??? While a size of INT_MAX+1 technically shouldn't - cause an overflow (because we subtract 1), the overflow - is recorded during the conversion to index_type, before - the subtraction. Handling this case seems like an - unnecessary complication. */ - if (TREE_OVERFLOW (itype)) - { - error ("size of array `%s' is too large", name); - type = error_mark_node; - continue; - } + + if (type == error_mark_node) + continue; - if (size_varies) - itype = variable_size (itype); - itype = build_index_type (itype); - } - } - else if (decl_context == FIELD) - { - if (pedantic && !flag_isoc99 && !in_system_header) - pedwarn ("ISO C90 does not support flexible array members"); + /* If size was specified, set ITYPE to a range-type for + that size. Otherwise, ITYPE remains null. finish_decl + may figure it out from an initial value. */ - /* ISO C99 Flexible array members are effectively identical - to GCC's zero-length array extension. */ - itype = build_range_type (sizetype, size_zero_node, NULL_TREE); - } + if (size) + { + /* Strip NON_LVALUE_EXPRs since we aren't using as an + lvalue. */ + STRIP_TYPE_NOPS (size); + + if (! INTEGRAL_TYPE_P (TREE_TYPE (size))) + { + error ("size of array `%s' has non-integer type", name); + size = integer_one_node; + } + + if (pedantic && integer_zerop (size)) + pedwarn ("ISO C forbids zero-size array `%s'", name); + + if (TREE_CODE (size) == INTEGER_CST) + { + constant_expression_warning (size); + if (tree_int_cst_sgn (size) < 0) + { + error ("size of array `%s' is negative", name); + size = integer_one_node; + } + } + else + { + /* Make sure the array size remains visibly + nonconstant even if it is (eg) a const variable + with known value. */ + size_varies = 1; + + if (!flag_isoc99 && pedantic) + { + if (TREE_CONSTANT (size)) + pedwarn ("ISO C90 forbids array `%s' whose size can't be evaluated", + name); + else + pedwarn ("ISO C90 forbids variable-size array `%s'", + name); + } + } - /* If pedantic, complain about arrays of incomplete types. */ + if (integer_zerop (size)) + { + /* A zero-length array cannot be represented with + an unsigned index type, which is what we'll + get with build_index_type. Create an + open-ended range instead. */ + itype = build_range_type (sizetype, size, NULL_TREE); + } + else + { + /* Compute the maximum valid index, that is, size + - 1. Do the calculation in index_type, so that + if it is a variable the computations will be + done in the proper mode. */ + itype = fold (build2 (MINUS_EXPR, index_type, + convert (index_type, size), + convert (index_type, + size_one_node))); + + /* If that overflowed, the array is too big. ??? + While a size of INT_MAX+1 technically shouldn't + cause an overflow (because we subtract 1), the + overflow is recorded during the conversion to + index_type, before the subtraction. Handling + this case seems like an unnecessary + complication. */ + if (TREE_OVERFLOW (itype)) + { + error ("size of array `%s' is too large", name); + type = error_mark_node; + continue; + } + + if (size_varies) + itype = variable_size (itype); + itype = build_index_type (itype); + } + } + else if (decl_context == FIELD) + { + if (pedantic && !flag_isoc99 && !in_system_header) + pedwarn ("ISO C90 does not support flexible array members"); - if (pedantic && !COMPLETE_TYPE_P (type)) - pedwarn ("array type has incomplete element type"); + /* ISO C99 Flexible array members are effectively + identical to GCC's zero-length array extension. */ + itype = build_range_type (sizetype, size_zero_node, NULL_TREE); + } - /* Build the array type itself, then merge any constancy or - volatility into the target type. We must do it in this order - to ensure that the TYPE_MAIN_VARIANT field of the array type - is set correctly. */ + /* If pedantic, complain about arrays of incomplete types. */ + if (pedantic && !COMPLETE_TYPE_P (type)) + pedwarn ("array type has incomplete element type"); - type = build_array_type (type, itype); - if (type_quals) - type = c_build_qualified_type (type, type_quals); + /* Build the array type itself, then merge any constancy + or volatility into the target type. We must do it in + this order to ensure that the TYPE_MAIN_VARIANT field + of the array type is set correctly. */ + type = build_array_type (type, itype); + if (type_quals) + type = c_build_qualified_type (type, type_quals); - if (size_varies) - C_TYPE_VARIABLE_SIZE (type) = 1; + if (size_varies) + C_TYPE_VARIABLE_SIZE (type) = 1; - /* The GCC extension for zero-length arrays differs from - ISO flexible array members in that sizeof yields zero. */ - if (size && integer_zerop (size)) - { + /* The GCC extension for zero-length arrays differs from + ISO flexible array members in that sizeof yields + zero. */ + if (size && integer_zerop (size)) + { + layout_type (type); + TYPE_SIZE (type) = bitsize_zero_node; + TYPE_SIZE_UNIT (type) = size_zero_node; + } + else if (declarator && TREE_CODE (declarator) == INDIRECT_REF) + /* We can never complete an array type which is the + target of a pointer, so go ahead and lay it out. */ layout_type (type); - TYPE_SIZE (type) = bitsize_zero_node; - TYPE_SIZE_UNIT (type) = size_zero_node; - } - else if (declarator && TREE_CODE (declarator) == INDIRECT_REF) - /* We can never complete an array type which is the target of a - pointer, so go ahead and lay it out. */ - layout_type (type); - - if (decl_context != PARM - && (array_ptr_quals != NULL_TREE || array_parm_static)) - { - error ("static or type qualifiers in non-parameter array declarator"); - array_ptr_quals = NULL_TREE; - array_parm_static = 0; - } - } - else if (TREE_CODE (declarator) == CALL_EXPR) - { - /* Say it's a definition only for the declarator closest to - the identifier, apart possibly from some attributes. */ - bool really_funcdef = false; - tree arg_types; - if (funcdef_flag) - { - tree t = TREE_OPERAND (declarator, 0); - while (TREE_CODE (t) == TREE_LIST) - t = TREE_VALUE (t); - really_funcdef = (TREE_CODE (t) == IDENTIFIER_NODE); - } - /* Declaring a function type. - Make sure we have a valid type for the function to return. */ - if (type == error_mark_node) - continue; - - size_varies = 0; + if (decl_context != PARM + && (array_ptr_quals != NULL_TREE || array_parm_static)) + { + error ("static or type qualifiers in non-parameter array declarator"); + array_ptr_quals = NULL_TREE; + array_parm_static = 0; + } + break; + } + case CALL_EXPR: + { + /* Say it's a definition only for the declarator closest + to the identifier, apart possibly from some + attributes. */ + bool really_funcdef = false; + tree arg_types; + if (funcdef_flag) + { + tree t = TREE_OPERAND (declarator, 0); + while (TREE_CODE (t) == TREE_LIST) + t = TREE_VALUE (t); + really_funcdef = (TREE_CODE (t) == IDENTIFIER_NODE); + } - /* Warn about some types functions can't return. */ + /* Declaring a function type. Make sure we have a valid + type for the function to return. */ + if (type == error_mark_node) + continue; + + size_varies = 0; - if (TREE_CODE (type) == FUNCTION_TYPE) - { - error ("`%s' declared as function returning a function", name); - type = integer_type_node; - } - if (TREE_CODE (type) == ARRAY_TYPE) - { - error ("`%s' declared as function returning an array", name); - type = integer_type_node; - } + /* Warn about some types functions can't return. */ + if (TREE_CODE (type) == FUNCTION_TYPE) + { + error ("`%s' declared as function returning a function", name); + type = integer_type_node; + } + if (TREE_CODE (type) == ARRAY_TYPE) + { + error ("`%s' declared as function returning an array", name); + type = integer_type_node; + } - /* Construct the function type and go to the next - inner layer of declarator. */ - arg_info = TREE_OPERAND (declarator, 1); - arg_types = grokparms (arg_info, really_funcdef); + /* Construct the function type and go to the next + inner layer of declarator. */ + arg_info = TREE_OPERAND (declarator, 1); + arg_types = grokparms (arg_info, really_funcdef); - /* Type qualifiers before the return type of the function - qualify the return type, not the function type. */ - if (type_quals) + /* Type qualifiers before the return type of the function + qualify the return type, not the function type. */ + if (type_quals) + { + /* Type qualifiers on a function return type are + normally permitted by the standard but have no + effect, so give a warning at -Wreturn-type. + Qualifiers on a void return type are banned on + function definitions in ISO C; GCC used to used + them for noreturn functions. */ + if (VOID_TYPE_P (type) && really_funcdef) + pedwarn ("function definition has qualified void return type"); + else if (warn_return_type) + warning ("type qualifiers ignored on function return type"); + + type = c_build_qualified_type (type, type_quals); + } + type_quals = TYPE_UNQUALIFIED; + + type = build_function_type (type, arg_types); + declarator = TREE_OPERAND (declarator, 0); + + /* Set the TYPE_CONTEXTs for each tagged type which is local to + the formal parameter list of this FUNCTION_TYPE to point to + the FUNCTION_TYPE node itself. */ { - /* Type qualifiers on a function return type are - normally permitted by the standard but have no - effect, so give a warning at -Wreturn-type. - Qualifiers on a void return type are banned on - function definitions in ISO C; GCC used to used them - for noreturn functions. */ - if (VOID_TYPE_P (type) && really_funcdef) - pedwarn ("function definition has qualified void return type"); - else if (warn_return_type) - warning ("type qualifiers ignored on function return type"); - - type = c_build_qualified_type (type, type_quals); + tree link; + + for (link = ARG_INFO_TAGS (arg_info); + link; + link = TREE_CHAIN (link)) + TYPE_CONTEXT (TREE_VALUE (link)) = type; } - type_quals = TYPE_UNQUALIFIED; - - type = build_function_type (type, arg_types); - declarator = TREE_OPERAND (declarator, 0); - - /* Set the TYPE_CONTEXTs for each tagged type which is local to - the formal parameter list of this FUNCTION_TYPE to point to - the FUNCTION_TYPE node itself. */ - + break; + } + case INDIRECT_REF: { - tree link; + /* Merge any constancy or volatility into the target type + for the pointer. */ - for (link = ARG_INFO_TAGS (arg_info); - link; - link = TREE_CHAIN (link)) - TYPE_CONTEXT (TREE_VALUE (link)) = type; + if (pedantic && TREE_CODE (type) == FUNCTION_TYPE + && type_quals) + pedwarn ("ISO C forbids qualified function types"); + if (type_quals) + type = c_build_qualified_type (type, type_quals); + type_quals = TYPE_UNQUALIFIED; + size_varies = 0; + + type = build_pointer_type (type); + + /* Process a list of type modifier keywords (such as const + or volatile) that were given inside the `*'. */ + if (TREE_TYPE (declarator)) + { + tree typemodlist; + int erred = 0; + + constp = 0; + volatilep = 0; + restrictp = 0; + for (typemodlist = TREE_TYPE (declarator); typemodlist; + typemodlist = TREE_CHAIN (typemodlist)) + { + tree qualifier = TREE_VALUE (typemodlist); + + if (C_IS_RESERVED_WORD (qualifier)) + { + if (C_RID_CODE (qualifier) == RID_CONST) + constp++; + else if (C_RID_CODE (qualifier) == RID_VOLATILE) + volatilep++; + else if (C_RID_CODE (qualifier) == RID_RESTRICT) + restrictp++; + else + erred++; + } + else + erred++; + } + + if (erred) + error ("invalid type modifier within pointer declarator"); + if (pedantic && !flag_isoc99) + { + if (constp > 1) + pedwarn ("duplicate `const'"); + if (volatilep > 1) + pedwarn ("duplicate `volatile'"); + if (restrictp > 1) + pedwarn ("duplicate `restrict'"); + } + + type_quals = ((constp ? TYPE_QUAL_CONST : 0) + | (restrictp ? TYPE_QUAL_RESTRICT : 0) + | (volatilep ? TYPE_QUAL_VOLATILE : 0)); + } + + declarator = TREE_OPERAND (declarator, 0); + break; } + default: + gcc_unreachable (); } - else if (TREE_CODE (declarator) == INDIRECT_REF) - { - /* Merge any constancy or volatility into the target type - for the pointer. */ - - if (pedantic && TREE_CODE (type) == FUNCTION_TYPE - && type_quals) - pedwarn ("ISO C forbids qualified function types"); - if (type_quals) - type = c_build_qualified_type (type, type_quals); - type_quals = TYPE_UNQUALIFIED; - size_varies = 0; - - type = build_pointer_type (type); - - /* Process a list of type modifier keywords - (such as const or volatile) that were given inside the `*'. */ - - if (TREE_TYPE (declarator)) - { - tree typemodlist; - int erred = 0; - - constp = 0; - volatilep = 0; - restrictp = 0; - for (typemodlist = TREE_TYPE (declarator); typemodlist; - typemodlist = TREE_CHAIN (typemodlist)) - { - tree qualifier = TREE_VALUE (typemodlist); - - if (C_IS_RESERVED_WORD (qualifier)) - { - if (C_RID_CODE (qualifier) == RID_CONST) - constp++; - else if (C_RID_CODE (qualifier) == RID_VOLATILE) - volatilep++; - else if (C_RID_CODE (qualifier) == RID_RESTRICT) - restrictp++; - else - erred++; - } - else - erred++; - } - - if (erred) - error ("invalid type modifier within pointer declarator"); - if (pedantic && !flag_isoc99) - { - if (constp > 1) - pedwarn ("duplicate `const'"); - if (volatilep > 1) - pedwarn ("duplicate `volatile'"); - if (restrictp > 1) - pedwarn ("duplicate `restrict'"); - } - - type_quals = ((constp ? TYPE_QUAL_CONST : 0) - | (restrictp ? TYPE_QUAL_RESTRICT : 0) - | (volatilep ? TYPE_QUAL_VOLATILE : 0)); - } - - declarator = TREE_OPERAND (declarator, 0); - } - else - abort (); - } /* Now TYPE has the actual type. */ @@ -4930,12 +4928,9 @@ grokdeclarator (tree declarator, tree declspecs, C_DECL_REGISTER (decl) = was_reg; } -#ifdef ENABLE_CHECKING /* This is the earliest point at which we might know the assembler name of a variable. Thus, if it's known before this, die horribly. */ - if (DECL_ASSEMBLER_NAME_SET_P (decl)) - abort (); -#endif + gcc_assert (!DECL_ASSEMBLER_NAME_SET_P (decl)); decl_attributes (&decl, returned_attrs, 0); @@ -5059,10 +5054,7 @@ get_parm_info (bool ellipsis) /* This function is only called if there was *something* on the parameter list. */ -#ifdef ENABLE_CHECKING - if (b == 0) - abort (); -#endif + gcc_assert (b); /* A parameter list consisting solely of 'void' indicates that the function takes no arguments. But if the 'void' is qualified @@ -5103,9 +5095,7 @@ get_parm_info (bool ellipsis) case PARM_DECL: if (b->id) { -#ifdef ENABLE_CHECKING - if (I_SYMBOL_BINDING (b->id) != b) abort (); -#endif + gcc_assert (I_SYMBOL_BINDING (b->id) == b); I_SYMBOL_BINDING (b->id) = b->shadowed; } @@ -5143,9 +5133,7 @@ get_parm_info (bool ellipsis) appears in the bindings list with b->id NULL. */ if (b->id) { -#ifdef ENABLE_CHECKING - if (I_TAG_BINDING (b->id) != b) abort (); -#endif + gcc_assert (I_TAG_BINDING (b->id) == b); I_TAG_BINDING (b->id) = b->shadowed; } @@ -5192,9 +5180,7 @@ get_parm_info (bool ellipsis) variable. Just throw it away. */ if (b->id) { -#ifdef ENABLE_CHECKING - if (I_SYMBOL_BINDING (b->id) != b) abort (); -#endif + gcc_assert (I_SYMBOL_BINDING (b->id) == b); I_SYMBOL_BINDING (b->id) = b->shadowed; } break; @@ -5204,7 +5190,7 @@ get_parm_info (bool ellipsis) case FUNCTION_DECL: case VAR_DECL: default: - abort (); + gcc_unreachable (); } b = free_binding_and_advance (b); @@ -6054,12 +6040,9 @@ start_function (tree declspecs, tree declarator, tree attributes) if (current_function_decl != 0) TREE_PUBLIC (decl1) = 0; -#ifdef ENABLE_CHECKING /* This is the earliest point at which we might know the assembler name of the function. Thus, if it's set before this, die horribly. */ - if (DECL_ASSEMBLER_NAME_SET_P (decl1)) - abort (); -#endif + gcc_assert (!DECL_ASSEMBLER_NAME_SET_P (decl1)); /* If #pragma weak was used, mark the decl weak now. */ if (current_scope == file_scope) @@ -6229,8 +6212,7 @@ store_parm_decls_oldstyle (tree fndecl, tree arg_info) seen already, since it is not used on PARM_DECL. */ #ifdef ENABLE_CHECKING for (b = current_scope->bindings; b; b = b->prev) - if (TREE_CODE (b->decl) == PARM_DECL && DECL_WEAK (b->decl)) - abort (); + gcc_assert (TREE_CODE (b->decl) != PARM_DECL || !DECL_WEAK (b->decl)); #endif if (warn_old_style_definition && !in_system_header) @@ -6991,8 +6973,7 @@ c_write_global_declarations (void) /* Close the external scope. */ ext_block = pop_scope (); external_scope = 0; - if (current_scope) - abort (); + gcc_assert (!current_scope); /* Process all file scopes in this compilation, and the external_scope, through wrapup_global_declarations and check_global_declarations. */ diff --git a/gcc/c-format.c b/gcc/c-format.c index 019b91a7339..9524746568e 100644 --- a/gcc/c-format.c +++ b/gcc/c-format.c @@ -151,7 +151,7 @@ check_format_string (tree argument, unsigned HOST_WIDE_INT format_num, and store its value. If validated_p is true, abort on errors. Returns true on success, false otherwise. */ static bool -get_constant(tree expr, unsigned HOST_WIDE_INT *value, int validated_p) +get_constant (tree expr, unsigned HOST_WIDE_INT *value, int validated_p) { while (TREE_CODE (expr) == NOP_EXPR || TREE_CODE (expr) == CONVERT_EXPR @@ -160,8 +160,7 @@ get_constant(tree expr, unsigned HOST_WIDE_INT *value, int validated_p) if (TREE_CODE (expr) != INTEGER_CST || TREE_INT_CST_HIGH (expr) != 0) { - if (validated_p) - abort (); + gcc_assert (!validated_p); return false; } @@ -187,8 +186,7 @@ decode_format_attr (tree args, function_format_info *info, int validated_p) if (TREE_CODE (format_type_id) != IDENTIFIER_NODE) { - if (validated_p) - abort (); + gcc_assert (!validated_p); error ("unrecognized format specifier"); return false; } @@ -200,8 +198,7 @@ decode_format_attr (tree args, function_format_info *info, int validated_p) if (info->format_type == format_type_error) { - if (validated_p) - abort (); + gcc_assert (!validated_p); warning ("%qs is an unrecognized format function type", p); return false; } @@ -221,8 +218,7 @@ decode_format_attr (tree args, function_format_info *info, int validated_p) if (info->first_arg_num != 0 && info->first_arg_num <= info->format_num) { - if (validated_p) - abort (); + gcc_assert (!validated_p); error ("format string arg follows the args to be formatted"); return false; } @@ -1004,11 +1000,8 @@ maybe_read_dollar_number (const char **format, for (i = 1; i < argnum && *param_ptr != 0; i++) *param_ptr = TREE_CHAIN (*param_ptr); - if (*param_ptr == 0) - { - /* This case shouldn't be caught here. */ - abort (); - } + /* This case shouldn't be caught here. */ + gcc_assert (*param_ptr); } else *param_ptr = 0; @@ -1096,10 +1089,8 @@ get_flag_spec (const format_flag_spec *spec, int flag, const char *predicates) else if (spec[i].predicate == 0) return &spec[i]; } - if (predicates == NULL) - abort (); - else - return NULL; + gcc_assert (predicates); + return NULL; } @@ -1299,8 +1290,8 @@ check_format_arg (void *ctx, tree format_tree, if (array_size != 0) { /* Variable length arrays can't be initialized. */ - if (TREE_CODE (array_size) != INTEGER_CST) - abort (); + gcc_assert (TREE_CODE (array_size) == INTEGER_CST); + if (host_integerp (array_size, 0)) { HOST_WIDE_INT array_size_value = TREE_INT_CST_LOW (array_size); @@ -2053,10 +2044,8 @@ check_format_types (format_wanted_type *types, const char *format_start, arg_num = types->arg_num; /* The following should not occur here. */ - if (wanted_type == 0) - abort (); - if (wanted_type == void_type_node && types->pointer_count == 0) - abort (); + gcc_assert (wanted_type); + gcc_assert (wanted_type != void_type_node || types->pointer_count); if (types->pointer_count == 0) wanted_type = lang_hooks.types.type_promotes_to (wanted_type); @@ -2253,17 +2242,14 @@ format_type_warning (const char *descr, const char *format_start, static unsigned int find_char_info_specifier_index (const format_char_info *fci, int c) { - unsigned int i = 0; - - while (fci->format_chars) - { - if (strchr (fci->format_chars, c)) - return i; - i++; fci++; - } + unsigned i; + + for (i = 0; fci->format_chars; i++, fci++) + if (strchr (fci->format_chars, c)) + return i; /* We shouldn't be looking for a non-existent specifier. */ - abort (); + gcc_unreachable (); } /* Given a format_length_info array FLI, and a character C, this @@ -2273,17 +2259,14 @@ find_char_info_specifier_index (const format_char_info *fci, int c) static unsigned int find_length_info_modifier_index (const format_length_info *fli, int c) { - unsigned int i = 0; - - while (fli->name) - { - if (strchr (fli->name, c)) - return i; - i++; fli++; - } + unsigned i; + + for (i = 0; fli->name; i++, fli++) + if (strchr (fli->name, c)) + return i; /* We shouldn't be looking for a non-existent modifier. */ - abort (); + gcc_unreachable (); } /* Determine the type of HOST_WIDE_INT in the code being compiled for @@ -2293,7 +2276,7 @@ static void init_dynamic_asm_fprintf_info (void) { static tree hwi; - + if (!hwi) { format_length_info *new_asm_fprintf_length_specs; @@ -2303,9 +2286,10 @@ init_dynamic_asm_fprintf_info (void) length modifier to work, one must have issued: "typedef HOST_WIDE_INT __gcc_host_wide_int__;" in one's source code prior to using that modifier. */ - if (!(hwi = maybe_get_identifier ("__gcc_host_wide_int__")) - || !(hwi = DECL_ORIGINAL_TYPE (identifier_global_value (hwi)))) - abort (); + hwi = maybe_get_identifier ("__gcc_host_wide_int__"); + gcc_assert (hwi); + hwi = DECL_ORIGINAL_TYPE (identifier_global_value (hwi)); + gcc_assert (hwi); /* Create a new (writable) copy of asm_fprintf_length_specs. */ new_asm_fprintf_length_specs = (format_length_info *) @@ -2320,7 +2304,7 @@ init_dynamic_asm_fprintf_info (void) else if (hwi == long_long_integer_type_node) new_asm_fprintf_length_specs[i].index = FMT_LEN_ll; else - abort (); + gcc_unreachable (); /* Assign the new data for use. */ dynamic_format_types[asm_fprintf_format_type].length_char_specs = @@ -2383,7 +2367,7 @@ init_dynamic_diag_info (void) else if (hwi == long_long_integer_type_node) diag_ls[i].index = FMT_LEN_ll; else - abort (); + gcc_unreachable (); } /* Handle the __gcc_diag__ format specifics. */ @@ -2551,7 +2535,7 @@ handle_format_attribute (tree *node, tree ARG_UNUSED (name), tree args, || info.format_type == gcc_cxxdiag_format_type) init_dynamic_diag_info(); else - abort(); + gcc_unreachable(); } return NULL_TREE; diff --git a/gcc/c-gimplify.c b/gcc/c-gimplify.c index 404ea71f0fc..d77d75c2f77 100644 --- a/gcc/c-gimplify.c +++ b/gcc/c-gimplify.c @@ -84,8 +84,7 @@ static struct c_gimplify_ctx static void push_context (void) { - if (ctxp) - abort (); + gcc_assert (!ctxp); ctxp = (struct c_gimplify_ctx *) xcalloc (1, sizeof (struct c_gimplify_ctx)); ctxp->bc_id[bc_continue] = get_identifier ("continue"); ctxp->bc_id[bc_break] = get_identifier ("break"); @@ -94,8 +93,7 @@ push_context (void) static void pop_context (void) { - if (!ctxp || ctxp->current_bc_label) - abort (); + gcc_assert (ctxp && !ctxp->current_bc_label); free (ctxp); ctxp = NULL; } @@ -275,8 +273,7 @@ begin_bc_block (enum bc_t bc) static tree finish_bc_block (tree label, tree body) { - if (label != ctxp->current_bc_label) - abort (); + gcc_assert (label == ctxp->current_bc_label); if (TREE_USED (label)) { diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 4b875618420..6334885f0a3 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -373,7 +373,7 @@ c_lex_with_flags (tree *value, unsigned char *cpp_flags) break; default: - abort (); + gcc_unreachable (); } } break; @@ -435,7 +435,7 @@ c_lex_with_flags (tree *value, unsigned char *cpp_flags) case CPP_HEADER_NAME: case CPP_COMMENT: case CPP_MACRO_ARG: - abort (); + gcc_unreachable (); default: *value = NULL_TREE; @@ -737,12 +737,11 @@ lex_string (const cpp_token *tok, tree *valp, bool objc_string) if (c_lex_string_translate == -1) { - if (!cpp_interpret_string_notranslate (parse_in, strs, count, - &istr, wide)) - /* Assume that, if we managed to translate the string - above, then the untranslated parsing will always - succeed. */ - abort (); + int xlated = cpp_interpret_string_notranslate (parse_in, strs, count, + &istr, wide); + /* Assume that, if we managed to translate the string above, + then the untranslated parsing will always succeed. */ + gcc_assert (xlated); if (TREE_STRING_LENGTH (value) != (int)istr.len || 0 != strncmp (TREE_STRING_POINTER (value), (char *)istr.text, diff --git a/gcc/c-objc-common.c b/gcc/c-objc-common.c index a4bb683ca93..9d05a6d97bf 100644 --- a/gcc/c-objc-common.c +++ b/gcc/c-objc-common.c @@ -213,10 +213,9 @@ c_tree_printer (pretty_printer *pp, text_info *text) break; case 'T': - if (TYPE_P (t)) - name = TYPE_NAME (t); - else - abort (); + gcc_assert (TYPE_P (t)); + name = TYPE_NAME (t); + if (name && TREE_CODE (name) == TYPE_DECL) { if (DECL_NAME (name)) diff --git a/gcc/c-pch.c b/gcc/c-pch.c index 21c3135b110..6352d37fb3d 100644 --- a/gcc/c-pch.c +++ b/gcc/c-pch.c @@ -129,10 +129,10 @@ pch_init (void) if (f == NULL) fatal_error ("can't create precompiled header %s: %m", pch_file); pch_outfile = f; - - if (strlen (host_machine) > 255 || strlen (target_machine) > 255 - || strlen (version_string) > 255) - abort (); + + gcc_assert (strlen (host_machine) < 256 + && strlen (target_machine) < 256 + && strlen (version_string) < 256); v.host_machine_length = strlen (host_machine); v.target_machine_length = strlen (target_machine); @@ -143,8 +143,7 @@ pch_init (void) for (i = 0; i < MATCH_SIZE; i++) { v.match[i] = *pch_matching[i].flag_var; - if (v.match[i] != *pch_matching[i].flag_var) - abort (); + gcc_assert (v.match[i] == *pch_matching[i].flag_var); } } v.pch_init = &pch_init; diff --git a/gcc/c-pragma.c b/gcc/c-pragma.c index cb518e03475..fe9f17ab569 100644 --- a/gcc/c-pragma.c +++ b/gcc/c-pragma.c @@ -279,7 +279,7 @@ maybe_apply_pragma_weak (tree decl) return; /* If it's not a function or a variable, it can't be weak. FIXME: what kinds of things are visible outside this file but - aren't functions or variables? Should this be an abort() instead? */ + aren't functions or variables? Should this be an assert instead? */ if (TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL) return; diff --git a/gcc/c-pretty-print.c b/gcc/c-pretty-print.c index 43bc1deaec5..7b741244bbf 100644 --- a/gcc/c-pretty-print.c +++ b/gcc/c-pretty-print.c @@ -2139,8 +2139,7 @@ pp_c_tree_decl_identifier (c_pretty_printer *pp, tree t) { const char *name; - if (!DECL_P (t)) - abort (); + gcc_assert (DECL_P (t)); if (DECL_NAME (t)) name = IDENTIFIER_POINTER (DECL_NAME (t)); diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 33c19da6d0a..c776c7874bf 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -157,7 +157,7 @@ c_incomplete_type_error (tree value, tree type) return; default: - abort (); + gcc_unreachable (); } if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) @@ -240,8 +240,7 @@ composite_type (tree t1, tree t2) if (code2 == ENUMERAL_TYPE && code1 == INTEGER_TYPE) return t2; - if (code1 != code2) - abort (); + gcc_assert (code1 == code2); switch (code1) { @@ -261,8 +260,7 @@ composite_type (tree t1, tree t2) tree elt = composite_type (TREE_TYPE (t1), TREE_TYPE (t2)); /* We should not have any type quals on arrays at all. */ - if (TYPE_QUALS (t1) || TYPE_QUALS (t2)) - abort (); + gcc_assert (!TYPE_QUALS (t1) && !TYPE_QUALS (t2)); /* Save space: see if the result is identical to one of the args. */ if (elt == TREE_TYPE (t1) && TYPE_DOMAIN (t1)) @@ -412,8 +410,8 @@ common_pointer_type (tree t1, tree t2) if (t2 == error_mark_node) return t1; - if (TREE_CODE (t1) != POINTER_TYPE || TREE_CODE (t2) != POINTER_TYPE) - abort (); + gcc_assert (TREE_CODE (t1) == POINTER_TYPE + && TREE_CODE (t2) == POINTER_TYPE); /* Merge the attributes. */ attributes = targetm.merge_type_attributes (t1, t2); @@ -470,13 +468,10 @@ common_type (tree t1, tree t2) code1 = TREE_CODE (t1); code2 = TREE_CODE (t2); - if (code1 != VECTOR_TYPE && code1 != COMPLEX_TYPE - && code1 != REAL_TYPE && code1 != INTEGER_TYPE) - abort (); - - if (code2 != VECTOR_TYPE && code2 != COMPLEX_TYPE - && code2 != REAL_TYPE && code2 != INTEGER_TYPE) - abort (); + gcc_assert (code1 == VECTOR_TYPE || code1 == COMPLEX_TYPE + || code1 == REAL_TYPE || code1 == INTEGER_TYPE); + gcc_assert (code2 == VECTOR_TYPE || code2 == COMPLEX_TYPE + || code2 == REAL_TYPE || code2 == INTEGER_TYPE); /* If one type is a vector type, return that type. (How the usual arithmetic conversions apply to the vector types extension is not @@ -744,7 +739,7 @@ same_translation_unit_p (tree t1, tree t2) case 'd': t1 = DECL_CONTEXT (t1); break; case 't': t1 = TYPE_CONTEXT (t1); break; case 'x': t1 = BLOCK_SUPERCONTEXT (t1); break; /* assume block */ - default: abort (); + default: gcc_unreachable (); } while (t2 && TREE_CODE (t2) != TRANSLATION_UNIT_DECL) @@ -753,7 +748,7 @@ same_translation_unit_p (tree t1, tree t2) case 'd': t2 = DECL_CONTEXT (t2); break; case 't': t2 = TYPE_CONTEXT (t2); break; case 'x': t2 = BLOCK_SUPERCONTEXT (t2); break; /* assume block */ - default: abort (); + default: gcc_unreachable (); } return t1 == t2; @@ -935,7 +930,7 @@ tagged_types_tu_compatible_p (tree t1, tree t2) } default: - abort (); + gcc_unreachable (); } } @@ -4371,8 +4366,7 @@ finish_init (void) free (q); } - if (constructor_range_stack) - abort (); + gcc_assert (!constructor_range_stack); /* Pop back to the data of the outer initializer (if any). */ free (spelling_base); @@ -4716,8 +4710,7 @@ pop_init_level (int implicit) while (constructor_stack->implicit) process_init_element (pop_init_level (1)); - if (constructor_range_stack) - abort (); + gcc_assert (!constructor_range_stack); } /* Now output all pending elements. */ @@ -4737,8 +4730,10 @@ pop_init_level (int implicit) already have pedwarned for empty brackets. */ if (integer_zerop (constructor_unfilled_index)) constructor_type = NULL_TREE; - else if (! TYPE_SIZE (constructor_type)) + else { + gcc_assert (!TYPE_SIZE (constructor_type)); + if (constructor_depth > 2) error_init ("initialization of flexible array member in a nested context"); else if (pedantic) @@ -4750,10 +4745,6 @@ pop_init_level (int implicit) if (TREE_CHAIN (constructor_fields) != NULL_TREE) constructor_type = NULL_TREE; } - else - /* Zero-length arrays are no longer special, so we should no longer - get here. */ - abort (); } /* Warn when some struct elements are implicitly initialized to zero. */ @@ -4869,14 +4860,14 @@ set_designator (int array) if (constructor_type == 0) return 1; - /* If there were errors in this designator list already, bail out silently. */ + /* If there were errors in this designator list already, bail out + silently. */ if (designator_errorneous) return 1; if (!designator_depth) { - if (constructor_range_stack) - abort (); + gcc_assert (!constructor_range_stack); /* Designator list starts at the level of closest explicit braces. */ @@ -4892,19 +4883,20 @@ set_designator (int array) return 1; } - if (TREE_CODE (constructor_type) == RECORD_TYPE - || TREE_CODE (constructor_type) == UNION_TYPE) + switch (TREE_CODE (constructor_type)) { + case RECORD_TYPE: + case UNION_TYPE: subtype = TREE_TYPE (constructor_fields); if (subtype != error_mark_node) subtype = TYPE_MAIN_VARIANT (subtype); - } - else if (TREE_CODE (constructor_type) == ARRAY_TYPE) - { + break; + case ARRAY_TYPE: subtype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type)); + break; + default: + gcc_unreachable (); } - else - abort (); subcode = TREE_CODE (subtype); if (array && subcode != ARRAY_TYPE) @@ -5324,18 +5316,17 @@ set_nonincremental_init_from_string (tree str) const char *p, *end; int byte, wchar_bytes, charwidth, bitpos; - if (TREE_CODE (constructor_type) != ARRAY_TYPE) - abort (); + gcc_assert (TREE_CODE (constructor_type) == ARRAY_TYPE); if (TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str))) == TYPE_PRECISION (char_type_node)) wchar_bytes = 1; - else if (TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str))) - == TYPE_PRECISION (wchar_type_node)) - wchar_bytes = TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT; else - abort (); - + { + gcc_assert (TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str))) + == TYPE_PRECISION (wchar_type_node)); + wchar_bytes = TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT; + } charwidth = TYPE_PRECISION (char_type_node); type = TREE_TYPE (constructor_type); p = TREE_STRING_POINTER (str); @@ -6077,16 +6068,14 @@ process_init_element (struct c_expr value) constructor_range_stack = 0; while (constructor_stack != range_stack->stack) { - if (!constructor_stack->implicit) - abort (); + gcc_assert (constructor_stack->implicit); process_init_element (pop_init_level (1)); } for (p = range_stack; !p->range_end || tree_int_cst_equal (p->index, p->range_end); p = p->prev) { - if (!constructor_stack->implicit) - abort (); + gcc_assert (constructor_stack->implicit); process_init_element (pop_init_level (1)); } @@ -6471,7 +6460,7 @@ c_finish_if_stmt (location_t if_locus, tree cond, tree then_block, inner_if = TREE_OPERAND (inner_if, 0); break; default: - abort (); + gcc_unreachable (); } found: diff --git a/gcc/caller-save.c b/gcc/caller-save.c index aa9b5845a41..53446f38ec3 100644 --- a/gcc/caller-save.c +++ b/gcc/caller-save.c @@ -160,8 +160,7 @@ init_caller_save (void) [(int) MODE_BASE_REG_CLASS (regno_save_mode [i][1])], i)) break; - if (i == FIRST_PSEUDO_REGISTER) - abort (); + gcc_assert (i < FIRST_PSEUDO_REGISTER); addr_reg = gen_rtx_REG (Pmode, i); @@ -381,8 +380,7 @@ save_call_clobbered_regs (void) next = chain->next; - if (chain->is_caller_save_insn) - abort (); + gcc_assert (!chain->is_caller_save_insn); if (INSN_P (insn)) { @@ -431,22 +429,17 @@ save_call_clobbered_regs (void) { int r = reg_renumber[regno]; int nregs; - - if (r >= 0) - { - enum machine_mode mode; - - nregs = hard_regno_nregs[r][PSEUDO_REGNO_MODE (regno)]; - mode = HARD_REGNO_CALLER_SAVE_MODE - (r, nregs, PSEUDO_REGNO_MODE (regno)); - if (GET_MODE_BITSIZE (mode) - > GET_MODE_BITSIZE (save_mode[r])) - save_mode[r] = mode; - while (nregs-- > 0) - SET_HARD_REG_BIT (hard_regs_to_save, r + nregs); - } - else - abort (); + enum machine_mode mode; + + gcc_assert (r >= 0); + nregs = hard_regno_nregs[r][PSEUDO_REGNO_MODE (regno)]; + mode = HARD_REGNO_CALLER_SAVE_MODE + (r, nregs, PSEUDO_REGNO_MODE (regno)); + if (GET_MODE_BITSIZE (mode) + > GET_MODE_BITSIZE (save_mode[r])) + save_mode[r] = mode; + while (nregs-- > 0) + SET_HARD_REG_BIT (hard_regs_to_save, r + nregs); }); /* Record all registers set in this call insn. These don't need @@ -650,9 +643,7 @@ insert_restore (struct insn_chain *chain, int before_p, int regno, or SET_SRC. Instead of doing so and causing a crash later, check for this common case and abort here instead. This will remove one step in debugging such problems. */ - - if (regno_save_mem[regno][1] == 0) - abort (); + gcc_assert (regno_save_mem[regno][1]); /* Get the pattern to emit and update our status. @@ -725,9 +716,7 @@ insert_save (struct insn_chain *chain, int before_p, int regno, or SET_SRC. Instead of doing so and causing a crash later, check for this common case and abort here instead. This will remove one step in debugging such problems. */ - - if (regno_save_mem[regno][1] == 0) - abort (); + gcc_assert (regno_save_mem[regno][1]); /* Get the pattern to emit and update our status. @@ -824,9 +813,7 @@ insert_one_insn (struct insn_chain *chain, int before_p, int code, rtx pat) rtx reg = XEXP (link, 0); int regno, i; - if (!REG_P (reg)) - abort (); - + gcc_assert (REG_P (reg)); regno = REGNO (reg); if (regno >= FIRST_PSEUDO_REGISTER) regno = reg_renumber[regno]; diff --git a/gcc/calls.c b/gcc/calls.c index e350a3fed14..eea4146e16b 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -349,7 +349,7 @@ emit_call_1 (rtx funexp, tree fntree, tree fndecl ATTRIBUTE_UNUSED, } else #endif - abort (); + gcc_unreachable (); /* Find the call we just emitted. */ call_insn = last_call_insn (); @@ -1158,8 +1158,7 @@ compute_argument_block_size (int reg_parm_stack_space, /* We don't handle this case yet. To handle it correctly we have to add the delta, round and subtract the delta. Currently no machine description requires this support. */ - if (stack_pointer_delta & (preferred_stack_boundary - 1)) - abort (); + gcc_assert (!(stack_pointer_delta & (preferred_stack_boundary - 1))); args_size->var = round_up (args_size->var, preferred_stack_boundary); } @@ -1225,8 +1224,7 @@ precompute_arguments (int flags, int num_actuals, struct arg_data *args) enum machine_mode mode; /* If this is an addressable type, we cannot pre-evaluate it. */ - if (TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value))) - abort (); + gcc_assert (!TREE_ADDRESSABLE (TREE_TYPE (args[i].tree_value))); args[i].initial_value = args[i].value = expand_expr (args[i].tree_value, NULL_RTX, VOIDmode, 0); @@ -1999,8 +1997,7 @@ expand_call (tree exp, rtx target, int ignore) /* Operand 0 is a pointer-to-function; get the type of the function. */ funtype = TREE_TYPE (addr); - if (! POINTER_TYPE_P (funtype)) - abort (); + gcc_assert (POINTER_TYPE_P (funtype)); funtype = TREE_TYPE (funtype); /* Munge the tree to split complex arguments into their imaginary @@ -2641,8 +2638,8 @@ expand_call (tree exp, rtx target, int ignore) now! */ /* Stack must be properly aligned now. */ - if (pass && stack_pointer_delta % preferred_unit_stack_boundary) - abort (); + gcc_assert (!pass + || !(stack_pointer_delta % preferred_unit_stack_boundary)); /* Generate the actual call instruction. */ emit_call_1 (funexp, exp, fndecl, funtype, unadjusted_args_size, @@ -2754,8 +2751,7 @@ expand_call (tree exp, rtx target, int ignore) { last = PREV_INSN (last); /* There was no CALL_INSN? */ - if (last == before_call) - abort (); + gcc_assert (last != before_call); } emit_barrier_after (last); @@ -2855,36 +2851,36 @@ expand_call (tree exp, rtx target, int ignore) if (targetm.calls.promote_function_return(funtype)) { - /* If we promoted this return value, make the proper SUBREG. TARGET - might be const0_rtx here, so be careful. */ - if (REG_P (target) - && TYPE_MODE (TREE_TYPE (exp)) != BLKmode - && GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp))) - { - tree type = TREE_TYPE (exp); - int unsignedp = TYPE_UNSIGNED (type); - int offset = 0; - - /* If we don't promote as expected, something is wrong. */ - if (GET_MODE (target) - != promote_mode (type, TYPE_MODE (type), &unsignedp, 1)) - abort (); - - if ((WORDS_BIG_ENDIAN || BYTES_BIG_ENDIAN) - && GET_MODE_SIZE (GET_MODE (target)) - > GET_MODE_SIZE (TYPE_MODE (type))) - { - offset = GET_MODE_SIZE (GET_MODE (target)) - - GET_MODE_SIZE (TYPE_MODE (type)); - if (! BYTES_BIG_ENDIAN) - offset = (offset / UNITS_PER_WORD) * UNITS_PER_WORD; - else if (! WORDS_BIG_ENDIAN) - offset %= UNITS_PER_WORD; - } - target = gen_rtx_SUBREG (TYPE_MODE (type), target, offset); - SUBREG_PROMOTED_VAR_P (target) = 1; - SUBREG_PROMOTED_UNSIGNED_SET (target, unsignedp); - } + /* If we promoted this return value, make the proper SUBREG. + TARGET might be const0_rtx here, so be careful. */ + if (REG_P (target) + && TYPE_MODE (TREE_TYPE (exp)) != BLKmode + && GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp))) + { + tree type = TREE_TYPE (exp); + int unsignedp = TYPE_UNSIGNED (type); + int offset = 0; + enum machine_mode pmode; + + pmode = promote_mode (type, TYPE_MODE (type), &unsignedp, 1); + /* If we don't promote as expected, something is wrong. */ + gcc_assert (GET_MODE (target) == pmode); + + if ((WORDS_BIG_ENDIAN || BYTES_BIG_ENDIAN) + && (GET_MODE_SIZE (GET_MODE (target)) + > GET_MODE_SIZE (TYPE_MODE (type)))) + { + offset = GET_MODE_SIZE (GET_MODE (target)) + - GET_MODE_SIZE (TYPE_MODE (type)); + if (! BYTES_BIG_ENDIAN) + offset = (offset / UNITS_PER_WORD) * UNITS_PER_WORD; + else if (! WORDS_BIG_ENDIAN) + offset %= UNITS_PER_WORD; + } + target = gen_rtx_SUBREG (TYPE_MODE (type), target, offset); + SUBREG_PROMOTED_VAR_P (target) = 1; + SUBREG_PROMOTED_UNSIGNED_SET (target, unsignedp); + } } /* If size of args is variable or this was a constructor call for a stack @@ -2971,10 +2967,9 @@ expand_call (tree exp, rtx target, int ignore) normal_call_insns = insns; /* Verify that we've deallocated all the stack we used. */ - if (! (flags & (ECF_NORETURN | ECF_LONGJMP)) - && old_stack_allocated != stack_pointer_delta - - pending_stack_adjust) - abort (); + gcc_assert ((flags & (ECF_NORETURN | ECF_LONGJMP)) + || (old_stack_allocated + == stack_pointer_delta - pending_stack_adjust)); } /* If something prevents making this a sibling call, @@ -3286,6 +3281,8 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, if (mem_value && struct_value == 0 && ! pcc_struct_value) { rtx addr = XEXP (mem_value, 0); + int partial; + nargs++; /* Make sure it is a reasonable operand for a move or push insn. */ @@ -3298,8 +3295,8 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, argvec[count].partial = 0; argvec[count].reg = FUNCTION_ARG (args_so_far, Pmode, NULL_TREE, 1); - if (FUNCTION_ARG_PARTIAL_NREGS (args_so_far, Pmode, NULL_TREE, 1)) - abort (); + partial = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, Pmode, NULL_TREE, 1); + gcc_assert (!partial); locate_and_pad_parm (Pmode, NULL_TREE, #ifdef STACK_PARMS_IN_REG_PARM_AREA @@ -3325,9 +3322,8 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, /* We cannot convert the arg value to the mode the library wants here; must do it earlier where we know the signedness of the arg. */ - if (mode == BLKmode - || (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode)) - abort (); + gcc_assert (mode != BLKmode + && (GET_MODE (val) == mode || GET_MODE (val) == VOIDmode)); /* Make sure it is a reasonable operand for a move or push insn. */ if (!REG_P (val) && !MEM_P (val) @@ -3397,8 +3393,7 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, argvec[count].partial, NULL_TREE, &args_size, &argvec[count].locate); - if (argvec[count].locate.size.var) - abort (); + gcc_assert (!argvec[count].locate.size.var); if (argvec[count].reg == 0 || argvec[count].partial != 0 || reg_parm_stack_space > 0) @@ -3662,8 +3657,8 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, ? hard_libcall_value (outmode) : NULL_RTX); /* Stack must be properly aligned now. */ - if (stack_pointer_delta & (PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT - 1)) - abort (); + gcc_assert (!(stack_pointer_delta + & (PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT - 1))); before_call = get_last_insn (); @@ -3698,8 +3693,7 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, { last = PREV_INSN (last); /* There was no CALL_INSN? */ - if (last == before_call) - abort (); + gcc_assert (last != before_call); } emit_barrier_after (last); @@ -3975,11 +3969,10 @@ store_one_arg (struct arg_data *arg, rtx argblock, int flags, partial = arg->partial; } - if (reg != 0 && partial == 0) - /* Being passed entirely in a register. We shouldn't be called in - this case. */ - abort (); - + /* Being passed entirely in a register. We shouldn't be called in + this case. */ + gcc_assert (reg == 0 || partial != 0); + /* If this arg needs special alignment, don't load the registers here. */ if (arg->n_aligned_regs != 0) @@ -4151,8 +4144,8 @@ store_one_arg (struct arg_data *arg, rtx argblock, int flags, i = INTVAL (XEXP (XEXP (x, 0), 1)); /* expand_call should ensure this. */ - if (arg->locate.offset.var || GET_CODE (size_rtx) != CONST_INT) - abort (); + gcc_assert (!arg->locate.offset.var + && GET_CODE (size_rtx) == CONST_INT); if (arg->locate.offset.constant > i) { -- 2.30.2