This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PPC ICE


On Wed, Aug 19, 2009 at 07:39:52AM -0700, Steve Kargl wrote:
> On Wed, Aug 19, 2009 at 10:30:41AM +0200, Janus Weil wrote:
> > 
> > >> > troutmask:sgk[206] gfc4x -c -std=f95 r.f90
> > >> > r.f90:4.38:
> > >> >
> > >> > ? ? procedure (), pointer, nopass :: f
> > >> > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1
> > >> > Error: Fortran 2003: Procedure pointer at (1)
> > >> > f951: internal compiler error: Segmentation fault: 11
> > 
> > thanks for reporting this.
> > 
> > 
> > > The ICE goes away with the following patch.
> > >
> > > 2009-08-18 ?Steven G. Kargl ?<kargl@gcc.gnu.org>
> > >
> > > ? ? ? ?* resolve.c (resolve_fl_derived): ?Don't dereference a NULL pointer.
> > >
> > > Index: resolve.c
> > > ===================================================================
> > > --- resolve.c ? (revision 150866)
> > > +++ resolve.c ? (working copy)
> > > @@ -9494,7 +9494,8 @@ resolve_fl_derived (gfc_symbol *sym)
> > > ? ? ? ?}
> > >
> > > ? ? ? /* Procedure pointer components: Check PASS arg. ?*/
> > > - ? ? ?if (c->attr.proc_pointer && !c->tb->nopass && c->tb->pass_arg_num == 0)
> > > + ? ? ?if (c->attr.proc_pointer
> > > + ? ? ? ? && (c->tb && !c->tb->nopass && c->tb->pass_arg_num == 0))
> > > ? ? ? ?{
> > > ? ? ? ? ?gfc_symbol* me_arg;
> > 
> > 
> > In principle the patch is ok. An alternative solution would be to
> > check for -std=... earlier (before the PPC is even added to the
> > derived type, so that we don't have to resolve it later on). I'd
> > propose the following:
> > 
> > Index: decl.c
> > ===================================================================
> > --- decl.c	(revision 150888)
> > +++ decl.c	(working copy)
> > @@ -4448,6 +4448,10 @@ match_ppc_decl (void)
> >        return MATCH_ERROR;
> >      }
> > 
> > +  if (gfc_notify_std (GFC_STD_F2003, "Fortran 2003: Procedure pointer
> > component"
> > +		      " at %C") == FAILURE)
> > +    return MATCH_ERROR;
> > +
> >    /* Match PPC names.  */
> >    ts = current_ts;
> >    for(num=1;;num++)
> > 
> > We do have such a check already (for all procedure pointers), but it
> > comes too late in the case at hand.
> > 
> > Steve, please feel free to commit whatever version you like best
> > (together with the dejagnuified test case).
> > 
> 
> I'll use your patch, degagnu the testcase, and commit on Saturday.
> Thanks.

Fixed with

2009-08-22  Steven G. Kargl  <kargl@gcc.gnu.org>

	* gfortran.dg/proc_ptr_24.f90: New test.

2009-08-22  Steven G. Kargl  <kargl@gcc.gnu.org>

	* fortran/decl.c: Disallow procedure pointers with -std=f95.


Index: gcc/testsuite/gfortran.dg/proc_ptr_24.f90
===================================================================
--- gcc/testsuite/gfortran.dg/proc_ptr_24.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/proc_ptr_24.f90	(revision 0)
@@ -0,0 +1,21 @@
+! { dg-do compile }
+! { dg-options -std=f95 }
+!
+! Code was posted to comp.lang.fortran by Richard Maine.
+! http://groups.google.com/group/comp.lang.fortran/browse_frm/thread/fff9b3426211c018#
+!
+module m
+  type :: foo
+    real, pointer :: array(:)
+    procedure (), pointer, nopass :: f ! { dg-error "Procedure pointer component" }
+  end type
+contains
+    elemental subroutine fooAssgn (a1, a2)
+        type(foo), intent(out) :: a1
+        type(foo), intent(in) :: a2
+        allocate (a1%array(size(a2%array)))
+
+        a1%array = a2%array
+        a1%f => a2%f         ! { dg-error "not a member of the" }
+    end subroutine
+end module m
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(revision 151023)
+++ gcc/fortran/decl.c	(working copy)
@@ -4449,6 +4449,10 @@ match_ppc_decl (void)
       return MATCH_ERROR;
     }
 
+  if (gfc_notify_std (GFC_STD_F2003, "Fortran 2003: Procedure pointer "
+                     "component at %C") == FAILURE)
+    return MATCH_ERROR;
+
   /* Match PPC names.  */
   ts = current_ts;
   for(num=1;;num++)
-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]