From 0f447a6e33db466cb8b04fc3583ed76626ca8f3b Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Sat, 6 Dec 2014 17:33:11 +0100 Subject: [PATCH] error.c (gfc_buffer_error, [...]): Use bool not MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2014-12-06 Tobias Burnus Manuel López-Ibáñez * error.c (gfc_buffer_error, gfc_error_flag_test): Use bool not * int. (buffer_flag): Remove static variable. (buffered_p): Add static variable. (gfc_error_init_1): Call gfc_buffer_error. (gfc_warning_1, gfc_warning, gfc_warning_now_1, gfc_error, gfc_error_now_1): Update for static variable change. * gfortran.h (gfc_buffer_error, gfc_error_flag_test): Update prototype. * parse.c (use_modules, decode_specification_statement, next_fixed, next_statement, match_deferred_characteristics): Update calls. * decl.c (gfc_match_data_decl): Ditto. * match.c (gfc_match_name): Ditto. Co-Authored-By: Manuel López-Ibáñez From-SVN: r218449 --- gcc/fortran/ChangeLog | 17 ++++++++++++++++ gcc/fortran/decl.c | 2 +- gcc/fortran/error.c | 44 +++++++++++++++++++++++------------------- gcc/fortran/gfortran.h | 4 ++-- gcc/fortran/match.c | 2 +- gcc/fortran/parse.c | 20 +++++++++---------- 6 files changed, 55 insertions(+), 34 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6662284cc85..137303cfc0d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,20 @@ +2014-12-06 Tobias Burnus + Manuel López-Ibáñez + + * error.c (gfc_buffer_error, gfc_error_flag_test): Use bool not int. + (buffer_flag): Remove static variable. + (buffered_p): Add static variable. + (gfc_error_init_1): Call gfc_buffer_error. + (gfc_warning_1, gfc_warning, gfc_warning_now_1, gfc_error, + gfc_error_now_1): Update for static variable change. + * gfortran.h (gfc_buffer_error, gfc_error_flag_test): Update + prototype. + * parse.c (use_modules, decode_specification_statement, + next_fixed, next_statement, match_deferred_characteristics): + Update calls. + * decl.c (gfc_match_data_decl): Ditto. + * match.c (gfc_match_name): Ditto. + 2014-12-05 Andre Vehreschild PR fortran/60414 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index f374b9a245c..6e55bbf0a93 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -4397,7 +4397,7 @@ ok: break; } - if (gfc_error_flag_test () == 0) + if (!gfc_error_flag_test ()) gfc_error ("Syntax error in data declaration at %C"); m = MATCH_ERROR; diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c index 333ad006a15..db4bcf38729 100644 --- a/gcc/fortran/error.c +++ b/gcc/fortran/error.c @@ -46,10 +46,15 @@ static int suppress_errors = 0; static bool warnings_not_errors = false; -static int terminal_width, buffer_flag, errors, warnings; +static int terminal_width, errors, warnings; static gfc_error_buf error_buffer, warning_buffer, *cur_error_buffer; +/* True if the error/warnings should be buffered. */ +static bool buffered_p; + +/* These are always buffered buffers (.flush_p == false) to be used by + the pretty-printer. */ static output_buffer pp_warning_buffer; static int warningcount_buffered, werrorcount_buffered; @@ -116,27 +121,27 @@ gfc_error_init_1 (void) terminal_width = get_terminal_width (); errors = 0; warnings = 0; - buffer_flag = 0; + gfc_buffer_error (false); } /* Set the flag for buffering errors or not. */ void -gfc_buffer_error (int flag) +gfc_buffer_error (bool flag) { - buffer_flag = flag; + buffered_p = flag; pp_warning_buffer.flush_p = !flag; } /* Add a single character to the error buffer or output depending on - buffer_flag. */ + buffered_p. */ static void error_char (char c) { - if (buffer_flag) + if (buffered_p) { if (cur_error_buffer->index >= cur_error_buffer->allocated) { @@ -844,7 +849,7 @@ gfc_warning_1 (const char *gmsgid, ...) error_char ('\0'); - if (buffer_flag == 0) + if (!buffered_p) { warnings++; if (warnings_are_errors) @@ -869,7 +874,6 @@ gfc_warning (int opt, const char *gmsgid, va_list ap) bool fatal_errors = global_dc->fatal_errors; pretty_printer *pp = global_dc->printer; output_buffer *tmp_buffer = pp->buffer; - bool buffered_p = !pp_warning_buffer.flush_p; gfc_clear_pp_buffer (&pp_warning_buffer); @@ -1021,7 +1025,7 @@ gfc_notify_std (int std, const char *gmsgid, ...) error_char ('\0'); - if (buffer_flag == 0) + if (!buffered_p) { if (warning && !warnings_are_errors) warnings++; @@ -1042,13 +1046,13 @@ void gfc_warning_now_1 (const char *gmsgid, ...) { va_list argp; - int i; + bool buffered_p_saved; if (inhibit_warnings) return; - i = buffer_flag; - buffer_flag = 0; + buffered_p_saved = buffered_p; + buffered_p = false; warnings++; va_start (argp, gmsgid); @@ -1060,7 +1064,7 @@ gfc_warning_now_1 (const char *gmsgid, ...) if (warnings_are_errors) gfc_increment_error_count(); - buffer_flag = i; + buffered_p = buffered_p_saved; } /* Called from output_format -- during diagnostic message processing @@ -1336,7 +1340,7 @@ gfc_error (const char *gmsgid, ...) error_char ('\0'); - if (buffer_flag == 0) + if (!buffered_p) gfc_increment_error_count(); return; @@ -1356,7 +1360,7 @@ warning: error_char ('\0'); - if (buffer_flag == 0) + if (!buffered_p) { warnings++; if (warnings_are_errors) @@ -1373,14 +1377,14 @@ void gfc_error_now_1 (const char *gmsgid, ...) { va_list argp; - int i; + bool buffered_p_saved; error_buffer.flag = 1; error_buffer.index = 0; cur_error_buffer = &error_buffer; - i = buffer_flag; - buffer_flag = 0; + buffered_p_saved = buffered_p; + buffered_p = false; va_start (argp, gmsgid); error_print (_("Error:"), _(gmsgid), argp); @@ -1390,7 +1394,7 @@ gfc_error_now_1 (const char *gmsgid, ...) gfc_increment_error_count(); - buffer_flag = i; + buffered_p = buffered_p_saved; if (flag_fatal_errors) exit (FATAL_EXIT_CODE); @@ -1426,7 +1430,7 @@ gfc_clear_error (void) /* Tests the state of error_flag. */ -int +bool gfc_error_flag_test (void) { return error_buffer.flag; diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 0baf041641e..02e78f79e83 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -2668,7 +2668,7 @@ typedef struct gfc_error_buf void gfc_error_init_1 (void); void gfc_diagnostics_init (void); void gfc_diagnostics_finish (void); -void gfc_buffer_error (int); +void gfc_buffer_error (bool); const char *gfc_print_wide_char (gfc_char_t); @@ -2689,7 +2689,7 @@ void gfc_fatal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1, void gfc_internal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2); void gfc_clear_error (void); int gfc_error_check (void); -int gfc_error_flag_test (void); +bool gfc_error_flag_test (void); notification gfc_notification_std (int); bool gfc_notify_std (int, const char *, ...) ATTRIBUTE_GCC_GFC(2,3); diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index bf3cd80689a..06f1e94dfee 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -532,7 +532,7 @@ gfc_match_name (char *buffer) c = gfc_next_ascii_char (); if (!(ISALPHA (c) || (c == '_' && gfc_option.flag_allow_leading_underscore))) { - if (gfc_error_flag_test () == 0 && c != '(') + if (!gfc_error_flag_test () && c != '(') gfc_error ("Invalid character in name at %C"); gfc_current_locus = old_loc; return MATCH_NO; diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 540424f88bd..1023037dfe1 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -110,9 +110,9 @@ use_modules (void) gfc_error_buf old_error; gfc_push_error (&old_error); - gfc_buffer_error (0); + gfc_buffer_error (false); gfc_use_modules (); - gfc_buffer_error (1); + gfc_buffer_error (true); gfc_pop_error (&old_error); gfc_commit_symbols (); gfc_warning_check (); @@ -279,7 +279,7 @@ decode_specification_statement (void) end_of_block: gfc_clear_error (); - gfc_buffer_error (0); + gfc_buffer_error (false); gfc_current_locus = old_locus; return ST_GET_FCN_CHARACTERISTICS; @@ -994,7 +994,7 @@ next_fixed (void) if (c != ' ' && c != '0') { - gfc_buffer_error (0); + gfc_buffer_error (false); gfc_error ("Bad continuation line at %C"); return ST_NONE; } @@ -1008,7 +1008,7 @@ next_fixed (void) here so don't bother checking for them. */ default: - gfc_buffer_error (0); + gfc_buffer_error (false); gfc_error ("Non-numeric character in statement label at %C"); return ST_NONE; } @@ -1035,7 +1035,7 @@ next_fixed (void) if (c != ' ' && c != '0') { - gfc_buffer_error (0); + gfc_buffer_error (false); gfc_error ("Bad continuation line at %C"); return ST_NONE; } @@ -1100,7 +1100,7 @@ next_statement (void) for (;;) { gfc_statement_label = NULL; - gfc_buffer_error (1); + gfc_buffer_error (true); if (gfc_at_eol ()) gfc_advance_line (); @@ -1124,7 +1124,7 @@ next_statement (void) break; } - gfc_buffer_error (0); + gfc_buffer_error (false); if (st == ST_GET_FCN_CHARACTERISTICS && gfc_statement_label != NULL) { @@ -2815,9 +2815,9 @@ match_deferred_characteristics (gfc_typespec * ts) gfc_current_locus = gfc_current_block ()->declared_at; gfc_clear_error (); - gfc_buffer_error (1); + gfc_buffer_error (true); m = gfc_match_prefix (ts); - gfc_buffer_error (0); + gfc_buffer_error (false); if (ts->type == BT_DERIVED) { -- 2.30.2