public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/52325] New: unclear error: Unclassifiable statement
@ 2012-02-21 10:39 kloedej at knmi dot nl
  2012-02-21 11:09 ` [Bug fortran/52325] " burnus at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: kloedej at knmi dot nl @ 2012-02-21 10:39 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52325

             Bug #: 52325
           Summary: unclear error: Unclassifiable statement
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: kloedej@knmi.nl


The given example code generates this error:

   unclassifiable.F90:9.4:

       cc%a = 1
       1
   Error: Unclassifiable statement at (1)


while in fact it would be much more helpfull if the error would clearly state
that the symbol is not yet defined (as the commented out lines do):

   unclassifiable.F90:16.5:
       d=1
        1
   Error: Symbol 'd' at (1) has no IMPLICIT type

Especially in larger modules/programs having a clear error in case of this kind
of variable naming msitakes/typos could save a lot of debugging time for
gfortran users.

Example code:

module test_unclassifiable
  implicit none
  type test
     integer :: a
  end type test
contains
  subroutine test_sub1(c)
    type(test), intent(out) :: c
    cc%a = 1
  end subroutine test_sub1
!  subroutine test_sub2(c)
!    integer :: c
!    d=1
!  end subroutine test_sub2
end module test_unclassifiable


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/52325] unclear error: Unclassifiable statement
  2012-02-21 10:39 [Bug fortran/52325] New: unclear error: Unclassifiable statement kloedej at knmi dot nl
@ 2012-02-21 11:09 ` burnus at gcc dot gnu.org
  2012-02-21 16:43 ` burnus at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-21 11:09 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52325

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-21 11:05:11 UTC ---
Untested patch:

--- primary.c   (revision 184431)
+++ primary.c   (working copy)
@@ -1910,6 +1910,19 @@ gfc_match_varspec (gfc_expr *primary, int equiv_fl
       && gfc_get_default_type (sym->name, sym->ns)->type == BT_DERIVED)
     gfc_set_default_type (sym, 0, sym->ns);

+  if (sym->ts.type == BT_UNKNOWN && gfc_match_char ('%') == MATCH_YES)
+    {
+      gfc_error ("Symbol %s at %C has no IMPLICIT type", sym->name);
+      return MATCH_ERROR;
+    }
+  else if ((sym->ts.type != BT_DERIVED && sym->ts.type != BT_CLASS)
+          && gfc_match_char ('%') == MATCH_YES)
+    {
+      gfc_error ("Unexpected %% for nonderived type variable %s at %C",
+                sym->name);
+      return MATCH_ERROR;
+    }
+
   if ((sym->ts.type != BT_DERIVED && sym->ts.type != BT_CLASS)
       || gfc_match_char ('%') != MATCH_YES)
     goto check_substring;


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/52325] unclear error: Unclassifiable statement
  2012-02-21 10:39 [Bug fortran/52325] New: unclear error: Unclassifiable statement kloedej at knmi dot nl
  2012-02-21 11:09 ` [Bug fortran/52325] " burnus at gcc dot gnu.org
@ 2012-02-21 16:43 ` burnus at gcc dot gnu.org
  2012-02-22  6:52 ` Joost.VandeVondele at mat dot ethz.ch
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-21 16:43 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52325

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-21 15:58:23 UTC ---
Submitted patch (pending review):
  http://gcc.gnu.org/ml/fortran/2012-02/msg00089.html


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/52325] unclear error: Unclassifiable statement
  2012-02-21 10:39 [Bug fortran/52325] New: unclear error: Unclassifiable statement kloedej at knmi dot nl
  2012-02-21 11:09 ` [Bug fortran/52325] " burnus at gcc dot gnu.org
  2012-02-21 16:43 ` burnus at gcc dot gnu.org
@ 2012-02-22  6:52 ` Joost.VandeVondele at mat dot ethz.ch
  2012-02-22  7:05 ` Joost.VandeVondele at mat dot ethz.ch
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Joost.VandeVondele at mat dot ethz.ch @ 2012-02-22  6:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52325

--- Comment #3 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> 2012-02-22 06:49:41 UTC ---
(In reply to comment #2)
> Submitted patch (pending review):
>   http://gcc.gnu.org/ml/fortran/2012-02/msg00089.html

OK ;-)

this would be a significant improvement. 

I think it is independent, but a better choice for the error message could be
'Symbol %s at %C has an undefined type'. The type could be implicitly or
explicitly defined, that doesn't matter so much. For consistency, I believe
your proposed message is fine.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/52325] unclear error: Unclassifiable statement
  2012-02-21 10:39 [Bug fortran/52325] New: unclear error: Unclassifiable statement kloedej at knmi dot nl
                   ` (2 preceding siblings ...)
  2012-02-22  6:52 ` Joost.VandeVondele at mat dot ethz.ch
@ 2012-02-22  7:05 ` Joost.VandeVondele at mat dot ethz.ch
  2012-03-02 13:21 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Joost.VandeVondele at mat dot ethz.ch @ 2012-02-22  7:05 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52325

--- Comment #4 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> 2012-02-22 06:53:09 UTC ---
(In reply to comment #2)
> Submitted patch (pending review):
>   http://gcc.gnu.org/ml/fortran/2012-02/msg00089.html

and a nitpick... it should be 'non-derived type' instead on 'nonderived type'
(unless I got this with the hyphens wrong again).


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/52325] unclear error: Unclassifiable statement
  2012-02-21 10:39 [Bug fortran/52325] New: unclear error: Unclassifiable statement kloedej at knmi dot nl
                   ` (3 preceding siblings ...)
  2012-02-22  7:05 ` Joost.VandeVondele at mat dot ethz.ch
@ 2012-03-02 13:21 ` burnus at gcc dot gnu.org
  2012-03-02 13:37 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-03-02 13:21 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52325

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-03-02 13:21:00 UTC ---
Author: burnus
Date: Fri Mar  2 13:20:52 2012
New Revision: 184785

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=184785
Log:
2012-03-02  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52325
        * primary.c (gfc_match_varspec): Add diagnostic for % with
        nonderived types.

2012-03-02  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52325
        * gfortran.dg/derived_comp_array_ref_8.f90: New.
        * gfortran.dg/nullify_2.f90: Update dg-error.
        * gfortran.dg/nullify_4.f90: Ditto.
        * gfortran.dg/pointer_init_6.f90: Ditto.


Added:
    trunk/gcc/testsuite/gfortran.dg/derived_comp_array_ref_8.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/primary.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/nullify_2.f90
    trunk/gcc/testsuite/gfortran.dg/nullify_4.f90
    trunk/gcc/testsuite/gfortran.dg/pointer_init_6.f90


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/52325] unclear error: Unclassifiable statement
  2012-02-21 10:39 [Bug fortran/52325] New: unclear error: Unclassifiable statement kloedej at knmi dot nl
                   ` (4 preceding siblings ...)
  2012-03-02 13:21 ` burnus at gcc dot gnu.org
@ 2012-03-02 13:37 ` burnus at gcc dot gnu.org
  2012-03-02 13:51 ` kloedej at knmi dot nl
  2012-03-02 15:01 ` burnus at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-03-02 13:37 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52325

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-03-02 13:36:35 UTC ---
FIXED on the trunk (i.e. GCC 4.8).

It had bothered me already a couple of times - your PR report finally nudged me
to fix it.

Thanks for the bug report.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/52325] unclear error: Unclassifiable statement
  2012-02-21 10:39 [Bug fortran/52325] New: unclear error: Unclassifiable statement kloedej at knmi dot nl
                   ` (5 preceding siblings ...)
  2012-03-02 13:37 ` burnus at gcc dot gnu.org
@ 2012-03-02 13:51 ` kloedej at knmi dot nl
  2012-03-02 15:01 ` burnus at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: kloedej at knmi dot nl @ 2012-03-02 13:51 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52325

--- Comment #7 from Jos de Kloe <kloedej at knmi dot nl> 2012-03-02 13:50:59 UTC ---
Thanks for your (really) fast response and fix.
I'll keep my eye open for other details that might improve gfortran.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/52325] unclear error: Unclassifiable statement
  2012-02-21 10:39 [Bug fortran/52325] New: unclear error: Unclassifiable statement kloedej at knmi dot nl
                   ` (6 preceding siblings ...)
  2012-03-02 13:51 ` kloedej at knmi dot nl
@ 2012-03-02 15:01 ` burnus at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-03-02 15:01 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52325

--- Comment #8 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-03-02 14:59:05 UTC ---
Author: burnus
Date: Fri Mar  2 14:58:58 2012
New Revision: 184790

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=184790
Log:
2012-03-02  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52325
        * primary.c (gfc_match_varspec): Add missing ;.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/primary.c


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-03-02 15:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-21 10:39 [Bug fortran/52325] New: unclear error: Unclassifiable statement kloedej at knmi dot nl
2012-02-21 11:09 ` [Bug fortran/52325] " burnus at gcc dot gnu.org
2012-02-21 16:43 ` burnus at gcc dot gnu.org
2012-02-22  6:52 ` Joost.VandeVondele at mat dot ethz.ch
2012-02-22  7:05 ` Joost.VandeVondele at mat dot ethz.ch
2012-03-02 13:21 ` burnus at gcc dot gnu.org
2012-03-02 13:37 ` burnus at gcc dot gnu.org
2012-03-02 13:51 ` kloedej at knmi dot nl
2012-03-02 15:01 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).