+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
break;
}
- if (gfc_error_flag_test () == 0)
+ if (!gfc_error_flag_test ())
gfc_error ("Syntax error in data declaration at %C");
m = MATCH_ERROR;
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;
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)
{
error_char ('\0');
- if (buffer_flag == 0)
+ if (!buffered_p)
{
warnings++;
if (warnings_are_errors)
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);
error_char ('\0');
- if (buffer_flag == 0)
+ if (!buffered_p)
{
if (warning && !warnings_are_errors)
warnings++;
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);
if (warnings_are_errors)
gfc_increment_error_count();
- buffer_flag = i;
+ buffered_p = buffered_p_saved;
}
/* Called from output_format -- during diagnostic message processing
error_char ('\0');
- if (buffer_flag == 0)
+ if (!buffered_p)
gfc_increment_error_count();
return;
error_char ('\0');
- if (buffer_flag == 0)
+ if (!buffered_p)
{
warnings++;
if (warnings_are_errors)
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);
gfc_increment_error_count();
- buffer_flag = i;
+ buffered_p = buffered_p_saved;
if (flag_fatal_errors)
exit (FATAL_EXIT_CODE);
/* Tests the state of error_flag. */
-int
+bool
gfc_error_flag_test (void)
{
return error_buffer.flag;
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);
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);
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;
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 ();
end_of_block:
gfc_clear_error ();
- gfc_buffer_error (0);
+ gfc_buffer_error (false);
gfc_current_locus = old_locus;
return ST_GET_FCN_CHARACTERISTICS;
if (c != ' ' && c != '0')
{
- gfc_buffer_error (0);
+ gfc_buffer_error (false);
gfc_error ("Bad continuation line at %C");
return ST_NONE;
}
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;
}
if (c != ' ' && c != '0')
{
- gfc_buffer_error (0);
+ gfc_buffer_error (false);
gfc_error ("Bad continuation line at %C");
return ST_NONE;
}
for (;;)
{
gfc_statement_label = NULL;
- gfc_buffer_error (1);
+ gfc_buffer_error (true);
if (gfc_at_eol ())
gfc_advance_line ();
break;
}
- gfc_buffer_error (0);
+ gfc_buffer_error (false);
if (st == ST_GET_FCN_CHARACTERISTICS && gfc_statement_label != NULL)
{
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)
{