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
This commit is contained in:
Tobias Burnus 2014-12-06 17:33:11 +01:00 committed by Tobias Burnus
parent b8a82c9dc6
commit 0f447a6e33
6 changed files with 55 additions and 34 deletions

View File

@ -1,3 +1,20 @@
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>
PR fortran/60414

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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)
{