summaryrefslogtreecommitdiff
path: root/gcc/fortran/error.c
diff options
context:
space:
mode:
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-24 22:16:42 +0000
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-24 22:16:42 +0000
commit964f793c121e2d2bc68a29fcc1def75180f669b4 (patch)
treee81edd67a3b77dde68f383afc975aefbcbc1092d /gcc/fortran/error.c
parent5ef5d6bbdb6028b6724c8878119c7e16a24e0ab8 (diff)
The problem is that diagnostic_action_after_output tries to delete the active
pretty-printer which tries to delete its output_buffer, which is normally dynamically allocated via placement-new, but the output_buffer used by the error_buffer of Fortran is statically allocated. Being statically allocated simplifies a lot pushing/poping several instances of error_buffer. The solution is to reset the active output_buffer back to the default one before calling diagnostic_action_after_output. This is a bit ugly, because this function does use the output_buffer, however, at the point that Fortran calls it, both are in an equivalent state, thus there is no visible difference. gcc/testsuite/ChangeLog: 2015-06-24 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/66528 * gfortran.dg/maxerrors.f90: New test. gcc/fortran/ChangeLog: 2015-06-24 Manuel López-Ibáñez <manu@gcc.gnu.org> PR fortran/66528 * error.c (gfc_warning_check): Restore the default output_buffer before calling diagnostic_action_after_output. (gfc_error_check): Likewise. (gfc_diagnostics_init): Add comment. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224926 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/error.c')
-rw-r--r--gcc/fortran/error.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c
index 2512cfc36aa7..c7d8581f9708 100644
--- a/gcc/fortran/error.c
+++ b/gcc/fortran/error.c
@@ -1249,7 +1249,6 @@ gfc_clear_warning (void)
void
gfc_warning_check (void)
{
- /* This is for the new diagnostics machinery. */
if (! gfc_output_buffer_empty_p (pp_warning_buffer))
{
pretty_printer *pp = global_dc->printer;
@@ -1259,10 +1258,10 @@ gfc_warning_check (void)
warningcount += warningcount_buffered;
werrorcount += werrorcount_buffered;
gcc_assert (warningcount_buffered + werrorcount_buffered == 1);
+ pp->buffer = tmp_buffer;
diagnostic_action_after_output (global_dc,
warningcount_buffered
? DK_WARNING : DK_ERROR);
- pp->buffer = tmp_buffer;
}
}
@@ -1381,8 +1380,8 @@ gfc_error_check (void)
pp_really_flush (pp);
++errorcount;
gcc_assert (gfc_output_buffer_empty_p (pp_error_buffer));
- diagnostic_action_after_output (global_dc, DK_ERROR);
pp->buffer = tmp_buffer;
+ diagnostic_action_after_output (global_dc, DK_ERROR);
return true;
}
@@ -1472,6 +1471,8 @@ gfc_diagnostics_init (void)
global_dc->caret_chars[1] = '2';
pp_warning_buffer = new (XNEW (output_buffer)) output_buffer ();
pp_warning_buffer->flush_p = false;
+ /* pp_error_buffer is statically allocated. This simplifies memory
+ management when using gfc_push/pop_error. */
pp_error_buffer = &(error_buffer.buffer);
pp_error_buffer->flush_p = false;
}