Message ID | 56CE50D7.50903@charter.net |
---|---|
State | New |
Headers | show |
Hi Jerry and Steve,
> OK for trunk.
OK.
Regards
Thomas
On 25-02-16 01:54, Jerry DeLisle wrote: > This patch from Steve on c.l.f > > Fixes the segfault from attempting a string compare where there is no string yet. > > Regression tested on x86-64. New test case. > > OK for trunk. > > Regards, > > Jerry > > 2016-02-24 Jerry DeLisle <jvdelisle@gcc.gnu.org> > Steven G. Kargl <kargl@gcc.gnu.org> > > PR fortran/69110 I suppose you mean 69910? Thanks, - Tom
On 02/27/2016 01:12 PM, Tom de Vries wrote: > On 25-02-16 01:54, Jerry DeLisle wrote: >> This patch from Steve on c.l.f >> >> Fixes the segfault from attempting a string compare where there is no string yet. >> >> Regression tested on x86-64. New test case. >> >> OK for trunk. >> >> Regards, >> >> Jerry >> >> 2016-02-24 Jerry DeLisle <jvdelisle@gcc.gnu.org> >> Steven G. Kargl <kargl@gcc.gnu.org> >> >> PR fortran/69110 > > I suppose you mean 69910? > > Thanks, > - Tom > > Yes, sorry about that. Will fix Jerry
diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index fddd36b..da0e1c5 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -1890,13 +1890,16 @@ gfc_match_open (void) goto cleanup; } - if (!(open->file || (open->status - && gfc_wide_strncasecmp (open->status->value.character.string, - "scratch", 7) == 0))) - { - gfc_error ("NEWUNIT specifier must have FILE= " - "or STATUS='scratch' at %C"); - goto cleanup; + if (!open->file && open->status) + { + if (open->status->expr_type == EXPR_CONSTANT + && gfc_wide_strncasecmp (open->status->value.character.string, + "scratch", 7) != 0) + { + gfc_error ("NEWUNIT specifier must have FILE= " + "or STATUS='scratch' at %C"); + goto cleanup; + } } } else if (!open->unit) diff --git a/gcc/testsuite/gfortran.dg/newunit_4.f90 b/gcc/testsuite/gfortran.dg/newunit_4.f90 new file mode 100644 index 0000000..4d7d738 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/newunit_4.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR69110 ICE with NEWUNIT +subroutine open_file_safe(fname, fstatus, faction, fposition, funit) + character(*), intent(in) :: fname, fstatus, faction, fposition + integer, intent(out) :: funit + open(newunit=funit, status=fstatus) +end subroutine open_file_safe