This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, Fortran] PR57895 - avoid segfault and improve diagnostic
- From: Mikael Morin <mikael dot morin at sfr dot fr>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: gcc patches <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Wed, 17 Jul 2013 14:04:20 +0200
- Subject: Re: [Patch, Fortran] PR57895 - avoid segfault and improve diagnostic
- References: <51E67390 dot 6030904 at net-b dot de>
Le 17/07/2013 12:36, Tobias Burnus a écrit :
> Without this patch, GCC 4.3 and later segfault. As Mikael wrote:
> "gfc_restore_last_undo_checkpoint seems to take care of the cleanup, so
> we don't need to do it in gfc_match_common."
>
> Additionally, this patch ensures that the error message about the "$"
> gets printed - without the change, it doesn't.
Well, once the segfault is fixed, it does get printed here. On the other
hand...
> Initially I had
> gfc_error_now instead of gfc_fatal_error. However, that gave tons of
> nonhelpful errors for the original test case - and for the test case in
> this patch, it prints the same message around twenty times. Hence,
> gfc_fatal_error is much more reasonable - even if the test case then no
> longer checks for the double free.
... avoiding the many duplicate errors is indeed more reasonable.
May I suggest adjusting the error locus one character back by the way:
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -556,8 +556,8 @@ gfc_match_name (char *buffer)
if (c == '$' && !gfc_option.flag_dollar_ok)
{
- gfc_fatal_error ("Invalid character '$' at %C. Use -fdollar-ok to
allow "
- "it as an extension");
+ gfc_fatal_error ("Invalid character '$' at %L. Use -fdollar-ok to
allow "
+ "it as an extension", &old_loc);
return MATCH_ERROR;
}
The patch is OK in any case. Thanks.
Mikael