public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran, OOP] PR 56266: ICE on invalid in gfc_match_varspec
@ 2013-04-12 23:38 Janus Weil
  2013-04-13 19:48 ` Mikael Morin
  0 siblings, 1 reply; 8+ messages in thread
From: Janus Weil @ 2013-04-12 23:38 UTC (permalink / raw)
  To: gfortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 900 bytes --]

Hi all,

here is a small patch which fixes an ICE-on-invalid problem by simply
turning a "gcc_assert" into a MATCH_ERROR. I am aware that the
resulting error message ("Unclassifiable statement") is not the most
helpful one, but I couldn't come up with something better.

The problem is that "c(i)" is wrongly identified as a function call,
which is the best thing one can do at parsing time. But giving an
error message based on this (wrong) assumption will not be any more
helpful, therefore I prefer the "Unclassifiable statement".

Unless someone has a better idea how to treat this, I will commit the
attached patch as obvious.

Cheers,
Janus


2013-04-12  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/56266
    * primary.c (gfc_match_varspec): Turn gcc_assert into MATCH_ERROR.


2013-04-12  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/56261
    * gfortran.dg/typebound_proc_28.f03: New.

[-- Attachment #2: pr56266.diff --]
[-- Type: application/octet-stream, Size: 814 bytes --]

Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c	(revision 197920)
+++ gcc/fortran/primary.c	(working copy)
@@ -1953,11 +1953,13 @@ gfc_match_varspec (gfc_expr *primary, int equiv_fl
 	    return MATCH_ERROR;
 
 	  gcc_assert (!tail || !tail->next);
-	  gcc_assert (primary->expr_type == EXPR_VARIABLE
-		      || (primary->expr_type == EXPR_STRUCTURE
-			  && primary->symtree && primary->symtree->n.sym
-			  && primary->symtree->n.sym->attr.flavor));
 
+	  if (!(primary->expr_type == EXPR_VARIABLE
+		|| (primary->expr_type == EXPR_STRUCTURE
+		    && primary->symtree && primary->symtree->n.sym
+		    && primary->symtree->n.sym->attr.flavor)))
+	    return MATCH_ERROR;
+
 	  if (tbp->n.tb->is_generic)
 	    tbp_sym = NULL;
 	  else

[-- Attachment #3: typebound_proc_28.f03 --]
[-- Type: application/octet-stream, Size: 504 bytes --]

! { dg-do compile }
!
! PR 56266: [OOP] ICE on invalid in gfc_match_varspec
!
! Contributed by Andrew Benson <abensonca@gmail.com>

module t

  implicit none

  type nc
   contains
     procedure :: encM => em
  end type nc

contains

  double precision function em(self)
    class(nc) :: self
    em=0.
  end function

  double precision function cem(c)
    type(nc) :: c
    cem=c(i)%encM()   ! { dg-error "Unclassifiable statement" }
  end function

end module

! { dg-final { cleanup-modules "t" } }

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

end of thread, other threads:[~2013-04-16 11:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-12 23:38 [Patch, Fortran, OOP] PR 56266: ICE on invalid in gfc_match_varspec Janus Weil
2013-04-13 19:48 ` Mikael Morin
2013-04-14  1:18   ` Janus Weil
2013-04-14  8:42     ` Mikael Morin
2013-04-15 22:49       ` Mikael Morin
2013-04-15 23:11         ` Janus Weil
2013-04-16 15:07           ` Janus Weil
2013-04-16 16:19             ` Tobias Burnus

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).