Patchwork [Fortran] PR57895 - avoid segfault and improve diagnostic

login
register
mail settings
Submitter Mikael Morin
Date July 17, 2013, 12:04 p.m.
Message ID <51E68844.9090202@sfr.fr>
Download mbox | patch
Permalink /patch/259690/
State New
Headers show

Comments

Mikael Morin - July 17, 2013, 12:04 p.m.
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:

     }

The patch is OK in any case. Thanks.

Mikael

Patch

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