Commit 0f447a6e by Tobias Burnus Committed by Tobias Burnus

error.c (gfc_buffer_error, [...]): Use bool not

2014-12-06  Tobias Burnus  <burnus@net-b.de>
            Manuel López-Ibáñez  <manu@gcc.gnu.org>

        * 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 <manu@gcc.gnu.org>

From-SVN: r218449
parent b8a82c9d
2014-12-06 Tobias Burnus <burnus@net-b.de>
Manuel López-Ibáñez <manu@gcc.gnu.org>
* 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 <vehre@gmx.de> 2014-12-05 Andre Vehreschild <vehre@gmx.de>
PR fortran/60414 PR fortran/60414
......
...@@ -4397,7 +4397,7 @@ ok: ...@@ -4397,7 +4397,7 @@ ok:
break; break;
} }
if (gfc_error_flag_test () == 0) if (!gfc_error_flag_test ())
gfc_error ("Syntax error in data declaration at %C"); gfc_error ("Syntax error in data declaration at %C");
m = MATCH_ERROR; m = MATCH_ERROR;
......
...@@ -46,10 +46,15 @@ static int suppress_errors = 0; ...@@ -46,10 +46,15 @@ static int suppress_errors = 0;
static bool warnings_not_errors = false; 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; 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 output_buffer pp_warning_buffer;
static int warningcount_buffered, werrorcount_buffered; static int warningcount_buffered, werrorcount_buffered;
...@@ -116,27 +121,27 @@ gfc_error_init_1 (void) ...@@ -116,27 +121,27 @@ gfc_error_init_1 (void)
terminal_width = get_terminal_width (); terminal_width = get_terminal_width ();
errors = 0; errors = 0;
warnings = 0; warnings = 0;
buffer_flag = 0; gfc_buffer_error (false);
} }
/* Set the flag for buffering errors or not. */ /* Set the flag for buffering errors or not. */
void void
gfc_buffer_error (int flag) gfc_buffer_error (bool flag)
{ {
buffer_flag = flag; buffered_p = flag;
pp_warning_buffer.flush_p = !flag; pp_warning_buffer.flush_p = !flag;
} }
/* Add a single character to the error buffer or output depending on /* Add a single character to the error buffer or output depending on
buffer_flag. */ buffered_p. */
static void static void
error_char (char c) error_char (char c)
{ {
if (buffer_flag) if (buffered_p)
{ {
if (cur_error_buffer->index >= cur_error_buffer->allocated) if (cur_error_buffer->index >= cur_error_buffer->allocated)
{ {
...@@ -844,7 +849,7 @@ gfc_warning_1 (const char *gmsgid, ...) ...@@ -844,7 +849,7 @@ gfc_warning_1 (const char *gmsgid, ...)
error_char ('\0'); error_char ('\0');
if (buffer_flag == 0) if (!buffered_p)
{ {
warnings++; warnings++;
if (warnings_are_errors) if (warnings_are_errors)
...@@ -869,7 +874,6 @@ gfc_warning (int opt, const char *gmsgid, va_list ap) ...@@ -869,7 +874,6 @@ gfc_warning (int opt, const char *gmsgid, va_list ap)
bool fatal_errors = global_dc->fatal_errors; bool fatal_errors = global_dc->fatal_errors;
pretty_printer *pp = global_dc->printer; pretty_printer *pp = global_dc->printer;
output_buffer *tmp_buffer = pp->buffer; output_buffer *tmp_buffer = pp->buffer;
bool buffered_p = !pp_warning_buffer.flush_p;
gfc_clear_pp_buffer (&pp_warning_buffer); gfc_clear_pp_buffer (&pp_warning_buffer);
...@@ -1021,7 +1025,7 @@ gfc_notify_std (int std, const char *gmsgid, ...) ...@@ -1021,7 +1025,7 @@ gfc_notify_std (int std, const char *gmsgid, ...)
error_char ('\0'); error_char ('\0');
if (buffer_flag == 0) if (!buffered_p)
{ {
if (warning && !warnings_are_errors) if (warning && !warnings_are_errors)
warnings++; warnings++;
...@@ -1042,13 +1046,13 @@ void ...@@ -1042,13 +1046,13 @@ void
gfc_warning_now_1 (const char *gmsgid, ...) gfc_warning_now_1 (const char *gmsgid, ...)
{ {
va_list argp; va_list argp;
int i; bool buffered_p_saved;
if (inhibit_warnings) if (inhibit_warnings)
return; return;
i = buffer_flag; buffered_p_saved = buffered_p;
buffer_flag = 0; buffered_p = false;
warnings++; warnings++;
va_start (argp, gmsgid); va_start (argp, gmsgid);
...@@ -1060,7 +1064,7 @@ gfc_warning_now_1 (const char *gmsgid, ...) ...@@ -1060,7 +1064,7 @@ gfc_warning_now_1 (const char *gmsgid, ...)
if (warnings_are_errors) if (warnings_are_errors)
gfc_increment_error_count(); gfc_increment_error_count();
buffer_flag = i; buffered_p = buffered_p_saved;
} }
/* Called from output_format -- during diagnostic message processing /* Called from output_format -- during diagnostic message processing
...@@ -1336,7 +1340,7 @@ gfc_error (const char *gmsgid, ...) ...@@ -1336,7 +1340,7 @@ gfc_error (const char *gmsgid, ...)
error_char ('\0'); error_char ('\0');
if (buffer_flag == 0) if (!buffered_p)
gfc_increment_error_count(); gfc_increment_error_count();
return; return;
...@@ -1356,7 +1360,7 @@ warning: ...@@ -1356,7 +1360,7 @@ warning:
error_char ('\0'); error_char ('\0');
if (buffer_flag == 0) if (!buffered_p)
{ {
warnings++; warnings++;
if (warnings_are_errors) if (warnings_are_errors)
...@@ -1373,14 +1377,14 @@ void ...@@ -1373,14 +1377,14 @@ void
gfc_error_now_1 (const char *gmsgid, ...) gfc_error_now_1 (const char *gmsgid, ...)
{ {
va_list argp; va_list argp;
int i; bool buffered_p_saved;
error_buffer.flag = 1; error_buffer.flag = 1;
error_buffer.index = 0; error_buffer.index = 0;
cur_error_buffer = &error_buffer; cur_error_buffer = &error_buffer;
i = buffer_flag; buffered_p_saved = buffered_p;
buffer_flag = 0; buffered_p = false;
va_start (argp, gmsgid); va_start (argp, gmsgid);
error_print (_("Error:"), _(gmsgid), argp); error_print (_("Error:"), _(gmsgid), argp);
...@@ -1390,7 +1394,7 @@ gfc_error_now_1 (const char *gmsgid, ...) ...@@ -1390,7 +1394,7 @@ gfc_error_now_1 (const char *gmsgid, ...)
gfc_increment_error_count(); gfc_increment_error_count();
buffer_flag = i; buffered_p = buffered_p_saved;
if (flag_fatal_errors) if (flag_fatal_errors)
exit (FATAL_EXIT_CODE); exit (FATAL_EXIT_CODE);
...@@ -1426,7 +1430,7 @@ gfc_clear_error (void) ...@@ -1426,7 +1430,7 @@ gfc_clear_error (void)
/* Tests the state of error_flag. */ /* Tests the state of error_flag. */
int bool
gfc_error_flag_test (void) gfc_error_flag_test (void)
{ {
return error_buffer.flag; return error_buffer.flag;
......
...@@ -2668,7 +2668,7 @@ typedef struct gfc_error_buf ...@@ -2668,7 +2668,7 @@ typedef struct gfc_error_buf
void gfc_error_init_1 (void); void gfc_error_init_1 (void);
void gfc_diagnostics_init (void); void gfc_diagnostics_init (void);
void gfc_diagnostics_finish (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); 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, ...@@ -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_internal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2);
void gfc_clear_error (void); void gfc_clear_error (void);
int gfc_error_check (void); int gfc_error_check (void);
int gfc_error_flag_test (void); bool gfc_error_flag_test (void);
notification gfc_notification_std (int); notification gfc_notification_std (int);
bool gfc_notify_std (int, const char *, ...) ATTRIBUTE_GCC_GFC(2,3); bool gfc_notify_std (int, const char *, ...) ATTRIBUTE_GCC_GFC(2,3);
......
...@@ -532,7 +532,7 @@ gfc_match_name (char *buffer) ...@@ -532,7 +532,7 @@ gfc_match_name (char *buffer)
c = gfc_next_ascii_char (); c = gfc_next_ascii_char ();
if (!(ISALPHA (c) || (c == '_' && gfc_option.flag_allow_leading_underscore))) 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_error ("Invalid character in name at %C");
gfc_current_locus = old_loc; gfc_current_locus = old_loc;
return MATCH_NO; return MATCH_NO;
......
...@@ -110,9 +110,9 @@ use_modules (void) ...@@ -110,9 +110,9 @@ use_modules (void)
gfc_error_buf old_error; gfc_error_buf old_error;
gfc_push_error (&old_error); gfc_push_error (&old_error);
gfc_buffer_error (0); gfc_buffer_error (false);
gfc_use_modules (); gfc_use_modules ();
gfc_buffer_error (1); gfc_buffer_error (true);
gfc_pop_error (&old_error); gfc_pop_error (&old_error);
gfc_commit_symbols (); gfc_commit_symbols ();
gfc_warning_check (); gfc_warning_check ();
...@@ -279,7 +279,7 @@ decode_specification_statement (void) ...@@ -279,7 +279,7 @@ decode_specification_statement (void)
end_of_block: end_of_block:
gfc_clear_error (); gfc_clear_error ();
gfc_buffer_error (0); gfc_buffer_error (false);
gfc_current_locus = old_locus; gfc_current_locus = old_locus;
return ST_GET_FCN_CHARACTERISTICS; return ST_GET_FCN_CHARACTERISTICS;
...@@ -994,7 +994,7 @@ next_fixed (void) ...@@ -994,7 +994,7 @@ next_fixed (void)
if (c != ' ' && c != '0') if (c != ' ' && c != '0')
{ {
gfc_buffer_error (0); gfc_buffer_error (false);
gfc_error ("Bad continuation line at %C"); gfc_error ("Bad continuation line at %C");
return ST_NONE; return ST_NONE;
} }
...@@ -1008,7 +1008,7 @@ next_fixed (void) ...@@ -1008,7 +1008,7 @@ next_fixed (void)
here so don't bother checking for them. */ here so don't bother checking for them. */
default: default:
gfc_buffer_error (0); gfc_buffer_error (false);
gfc_error ("Non-numeric character in statement label at %C"); gfc_error ("Non-numeric character in statement label at %C");
return ST_NONE; return ST_NONE;
} }
...@@ -1035,7 +1035,7 @@ next_fixed (void) ...@@ -1035,7 +1035,7 @@ next_fixed (void)
if (c != ' ' && c != '0') if (c != ' ' && c != '0')
{ {
gfc_buffer_error (0); gfc_buffer_error (false);
gfc_error ("Bad continuation line at %C"); gfc_error ("Bad continuation line at %C");
return ST_NONE; return ST_NONE;
} }
...@@ -1100,7 +1100,7 @@ next_statement (void) ...@@ -1100,7 +1100,7 @@ next_statement (void)
for (;;) for (;;)
{ {
gfc_statement_label = NULL; gfc_statement_label = NULL;
gfc_buffer_error (1); gfc_buffer_error (true);
if (gfc_at_eol ()) if (gfc_at_eol ())
gfc_advance_line (); gfc_advance_line ();
...@@ -1124,7 +1124,7 @@ next_statement (void) ...@@ -1124,7 +1124,7 @@ next_statement (void)
break; break;
} }
gfc_buffer_error (0); gfc_buffer_error (false);
if (st == ST_GET_FCN_CHARACTERISTICS && gfc_statement_label != NULL) if (st == ST_GET_FCN_CHARACTERISTICS && gfc_statement_label != NULL)
{ {
...@@ -2815,9 +2815,9 @@ match_deferred_characteristics (gfc_typespec * ts) ...@@ -2815,9 +2815,9 @@ match_deferred_characteristics (gfc_typespec * ts)
gfc_current_locus = gfc_current_block ()->declared_at; gfc_current_locus = gfc_current_block ()->declared_at;
gfc_clear_error (); gfc_clear_error ();
gfc_buffer_error (1); gfc_buffer_error (true);
m = gfc_match_prefix (ts); m = gfc_match_prefix (ts);
gfc_buffer_error (0); gfc_buffer_error (false);
if (ts->type == BT_DERIVED) if (ts->type == BT_DERIVED)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment