summaryrefslogtreecommitdiffstats
path: root/gcc/c-format.c
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-07 10:19:00 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-07 10:19:00 +0000
commit231bd014bbdc801d1b137f8989b0d0c2541fd0f7 (patch)
treedd4f142a645a4fabe170becf3c587e3d8176358c /gcc/c-format.c
parenta1fa05f04b8b8d1174e1e75aafe203366e0d4d93 (diff)
downloadppe42-gcc-231bd014bbdc801d1b137f8989b0d0c2541fd0f7.tar.gz
ppe42-gcc-231bd014bbdc801d1b137f8989b0d0c2541fd0f7.zip
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@87140 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-format.c')
-rw-r--r--gcc/c-format.c82
1 files changed, 33 insertions, 49 deletions
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;
OpenPOWER on IntegriCloud