diff mbox series

[fortran] Fix PR 87673, rejects-valid

Message ID daeec535-92a3-edc4-8bf8-157509115202@netcologne.de
State New
Headers show
Series [fortran] Fix PR 87673, rejects-valid | expand

Commit Message

Thomas Koenig March 10, 2019, 8:04 p.m. UTC
Hello world,

the attached patch fixes a 7/8/9 regression by removing
the call to gfc_resovle_expr during matching.  It turned
out that gfc_resolve_expr depends on some conditions
that are not yet met during the matching phase.

Fortunately, the bug that this originally fixed (PR 82049)
has been fixed another way on trunk, so that just removing
this part works.  For backporting, it would be necessary to
check if the fix(es) would need to be backported if they haven't
been already - probably one or several of Harald's patches.

So, OK for trunk? OK for backporting?

Regards

	Thomas

2019-03-10  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/87673
         * match.c (gfc_match_type_spec): Remove call to
         gfc_resolve_expr for character length.

2019-03-10  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/87673
         * gfortran.dg/charlen_17.f90: New patch.

Comments

Steve Kargl March 10, 2019, 8:15 p.m. UTC | #1
On Sun, Mar 10, 2019 at 09:04:18PM +0100, Thomas Koenig wrote:

> ! { dg-do compile }
> ! PR 87673 - used to cause errors about non-pure functions.
> !  A fragment from Richard Townsend's iso_varying_string, as modified by
> ! Ian Harvey to include F2003 language capabilities. For copyright notices
> ! see source at http://www.megms.com.au/download/aniso_varying_string.f90

Copyright notice?

If it isn't some version of gpl or lgpl, then you might need
to either get approval from FSF, get Richard Townshend to 
put the code that demonstrate the code under a gpl compatible
copyright, or rewrite the example that demonstrates the bug.

BTW, I think Ian's bug report is actually a duplicate of
another PR, but don't recall which one.
Thomas Koenig March 10, 2019, 9:12 p.m. UTC | #2
Am 10.03.19 um 21:15 schrieb Steve Kargl:
> On Sun, Mar 10, 2019 at 09:04:18PM +0100, Thomas Koenig wrote:
> 
>> ! { dg-do compile }
>> ! PR 87673 - used to cause errors about non-pure functions.
>> !  A fragment from Richard Townsend's iso_varying_string, as modified by
>> ! Ian Harvey to include F2003 language capabilities. For copyright notices
>> ! see source at http://www.megms.com.au/download/aniso_varying_string.f90
> 
> Copyright notice?

This is what I copied from the PR.

> If it isn't some version of gpl or lgpl, then you might need
> to either get approval from FSF, get Richard Townshend to
> put the code that demonstrate the code under a gpl compatible
> copyright, or rewrite the example that demonstrates the bug.

You're probably right, I will fix this.  Ugh...

> BTW, I think Ian's bug report is actually a duplicate of
> another PR, but don't recall which one.

It was marked as a duplicate of PR 87734, but I unmarked it
because PR 87734 is fixed on trunk and this one is not :-)

Regards

	Thomas
Thomas Koenig March 10, 2019, 9:36 p.m. UTC | #3
Am 10.03.19 um 22:12 schrieb Thomas Koenig:

> You're probably right, I will fix this.  Ugh...

OK, so here is the updated test case, without the copyright stuff.

OK for trunk now? :-)

Regards

	Thomas
! { dg-do compile }
! PR 87673 - used to cause errors about non-pure functions.

module x
  implicit none
contains
  pure function foo() result(res)
    character(len=:), allocatable :: res
    allocate (character(bar()) :: res)
  end function foo
  pure integer function bar()
    bar = 1
  end function bar
end module x
Steve Kargl March 11, 2019, 10:35 p.m. UTC | #4
On Sun, Mar 10, 2019 at 10:36:48PM +0100, Thomas Koenig wrote:
> Am 10.03.19 um 22:12 schrieb Thomas Koenig:
> 
> > You're probably right, I will fix this.  Ugh...
> 
> OK, so here is the updated test case, without the copyright stuff.
> 
> OK for trunk now? :-)
> 

Yes.  Thanks for patch.
diff mbox series

Patch

Index: match.c
===================================================================
--- match.c	(Revision 269552)
+++ match.c	(Arbeitskopie)
@@ -2122,8 +2122,6 @@  gfc_match_type_spec (gfc_typespec *ts)
       ts->type = BT_CHARACTER;
 
       m = gfc_match_char_spec (ts);
-      if (ts->u.cl && ts->u.cl->length)
-	gfc_resolve_expr (ts->u.cl->length);
 
       if (m == MATCH_NO)
 	m = MATCH_YES;