Bug 38444 - Poor recovery from error
Summary: Poor recovery from error
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, error-recovery
Depends on:
Blocks:
 
Reported: 2008-12-08 14:28 UTC by Joost VandeVondele
Modified: 2016-03-11 16:20 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-03-29 08:30:49


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joost VandeVondele 2008-12-08 14:28:52 UTC
IMPLICIT NONE
INTEGER :: a,b,c,d,e,f,g,h,a
a=0 ; b=0 ; c=0 ; d=0 ; e=0 ; f=0 ; g=0 ; h=0
END

this typo leads to 9 error messages.
Comment 1 kargls 2008-12-08 18:24:13 UTC
Yeah, this has always bothered me.  I typically use -fmax-errors=1 when
developing new code because of the run-on errors for simple mistakes.
This fixes the excessive errors in this case.

Index: symbol.c
===================================================================
--- symbol.c    (revision 142481)
+++ symbol.c    (working copy)
@@ -1559,7 +1559,8 @@ gfc_add_type (gfc_symbol *sym, gfc_types
          || gfc_notification_std (GFC_STD_GNU) == ERROR
          || pedantic)
        {
-         gfc_error (msg, sym->name, where, gfc_basic_typename (sym->ts.type));
+         gfc_fatal_error (msg, sym->name, where,
+                          gfc_basic_typename (sym->ts.type));
          return FAILURE;
        }
       if (gfc_notify_std (GFC_STD_GNU, msg, sym->name, where,
Comment 2 Joost VandeVondele 2008-12-08 18:39:58 UTC
(In reply to comment #1)
> -         gfc_error (msg, sym->name, where, gfc_basic_typename (sym->ts.type));
> +         gfc_fatal_error (msg, sym->name, where,
> +                          gfc_basic_typename (sym->ts.type));

That produces too few error messages. I.e. 

IMPLICIT NONE
INTEGER :: a,b,c,d,e,f,g,h,a
a=0 ; b=0 ; c=0 ; d=0 ; e=0 ; f=0 ; g=0 ; h=0; i=0
END

should produce (like NAG f95, ifort) two errors only.
Comment 3 kargls 2008-12-08 19:31:46 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > -         gfc_error (msg, sym->name, where, gfc_basic_typename (sym->ts.type));
> > +         gfc_fatal_error (msg, sym->name, where,
> > +                          gfc_basic_typename (sym->ts.type));
> 
> That produces too few error messages. I.e. 
> 
> IMPLICIT NONE
> INTEGER :: a,b,c,d,e,f,g,h,a
> a=0 ; b=0 ; c=0 ; d=0 ; e=0 ; f=0 ; g=0 ; h=0; i=0
> END
> 
> should produce (like NAG f95, ifort) two errors only.
> 

Unfortunately, the first error causes the entire line to
be rejected.  Thus, all your variables are implicitly typed
when gfortran tries to continue with processing the file.
AFAIK, gfortran cannot accept a partially correct specification
statement.

If you fix the fatal error, you'll then see the second error.
So, you can view my patch as an all-or-nothing solution.


Comment 4 Dominique d'Humieres 2015-12-06 10:51:42 UTC
No activity for seven years. How many decades this PR will remain opened before being closed as WONTFIX?
Comment 5 Dominique d'Humieres 2016-03-11 16:20:26 UTC
> No activity for seven years. How many decades this PR will remain
> opened before being closed as WONTFIX?

No feedback, closing as WONTFIX.