diff options
author | David Malcolm <dmalcolm@redhat.com> | 2016-05-10 18:28:10 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2016-05-10 18:28:10 +0000 |
commit | 601070fce9761f7665d5916c786fe065f3165c00 (patch) | |
tree | 4536dc681253ddda5e2965d30e5b73bfb1e4008a /gcc/read-rtl.c | |
parent | 3126957087d5ce8dc7e7c5f38118769732c335bc (diff) | |
download | gcc-601070fce9761f7665d5916c786fe065f3165c00.zip gcc-601070fce9761f7665d5916c786fe065f3165c00.tar.gz gcc-601070fce9761f7665d5916c786fe065f3165c00.tar.bz2 |
Simplify read-md.c and read-rtl.c using require_char_ws
read-md.c and read-rtl.c repeatedly use this pattern:
c = read_skip_spaces ();
if (c != ')')
fatal_expected_char (')', c);
Simplify them by introduce a helper function to do this.
gcc/ChangeLog:
* read-md.c (require_char_ws): New function.
(read_string): Simplify using require_char_ws.
(handle_constants): Likewise.
(handle_enum): Likewise.
(handle_file): Likewise.
* read-md.h (require_char_ws): New declaration.
* read-rtl.c (read_conditions): Simplify using require_char_ws.
(read_mapping): Likewise.
(read_rtx_code): Likewise.
(read_nested_rtx): Likewise.
From-SVN: r236101
Diffstat (limited to 'gcc/read-rtl.c')
-rw-r--r-- | gcc/read-rtl.c | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/gcc/read-rtl.c b/gcc/read-rtl.c index 79f42bf..dc3a336 100644 --- a/gcc/read-rtl.c +++ b/gcc/read-rtl.c @@ -742,9 +742,7 @@ read_conditions (void) { int c; - c = read_skip_spaces (); - if (c != '[') - fatal_expected_char ('[', c); + require_char_ws ('['); while ( (c = read_skip_spaces ()) != ']') { @@ -759,14 +757,10 @@ read_conditions (void) validate_const_int (name.string); value = atoi (name.string); - c = read_skip_spaces (); - if (c != '"') - fatal_expected_char ('"', c); + require_char_ws ('"'); expr = read_quoted_string (); - c = read_skip_spaces (); - if (c != ')') - fatal_expected_char (')', c); + require_char_ws (')'); add_c_test (expr, value); } @@ -890,9 +884,7 @@ read_mapping (struct iterator_group *group, htab_t table) read_name (&name); m = add_mapping (group, table, name.string); - c = read_skip_spaces (); - if (c != '[') - fatal_expected_char ('[', c); + require_char_ws ('['); /* Read each value. */ end_ptr = &m->values; @@ -912,9 +904,7 @@ read_mapping (struct iterator_group *group, htab_t table) /* A "(name string)" pair. */ read_name (&name); string = read_string (false); - c = read_skip_spaces (); - if (c != ')') - fatal_expected_char (')', c); + require_char_ws (')'); } number = group->find_builtin (name.string); end_ptr = add_map_value (end_ptr, number, string); @@ -1181,9 +1171,7 @@ read_rtx_code (const char *code_name) int list_counter = 0; rtvec return_vec = NULL_RTVEC; - c = read_skip_spaces (); - if (c != '[') - fatal_expected_char ('[', c); + require_char_ws ('['); /* Add expressions to a list, while keeping a count. */ obstack_init (&vector_stack); @@ -1398,12 +1386,9 @@ static rtx read_nested_rtx (void) { struct md_name name; - int c; rtx return_rtx; - c = read_skip_spaces (); - if (c != '(') - fatal_expected_char ('(', c); + require_char_ws ('('); read_name (&name); if (strcmp (name.string, "nil") == 0) @@ -1411,9 +1396,7 @@ read_nested_rtx (void) else return_rtx = read_rtx_code (name.string); - c = read_skip_spaces (); - if (c != ')') - fatal_expected_char (')', c); + require_char_ws (')'); return return_rtx; } |