+2016-02-27 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+ Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/69110
+ * io.c (gfc_match_open): Check that open status is an expression
+ constant before comparing string to 'scratch' with NEWUNIT.
+
2016-02-27 Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>
* trans.c (gfc_allocate_allocatable): size conversion
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)
+2016-02-27 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR fortran/69110
+ * gfortran.dg/newunit_4.f90: New test.
+
2016-02-27 Jakub Jelinek <jakub@redhat.com>
PR target/69613
--- /dev/null
+! { 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