From: Harald Anlauf Date: Fri, 22 Feb 2019 20:35:38 +0000 (+0000) Subject: re PR fortran/83057 (OPEN without a filename and without STATUS='SCRATCH' could produ... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=56bf85c1a747ae517abb861dddaf64c4927e8139;p=gcc.git re PR fortran/83057 (OPEN without a filename and without STATUS='SCRATCH' could produce a warning) 2019-02-22 Harald Anlauf PR fortran/83057 * io.c (gfc_match_open): Fix logic in checks of OPEN statement when NEWUNIT= is specified. PR fortran/83057 * gfortran.dg/newunit_6.f90: New test. From-SVN: r269134 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 970d1628ae8..4de649e2550 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-02-22 Harald Anlauf + + PR fortran/83057 + * io.c (gfc_match_open): Fix logic in checks of OPEN statement + when NEWUNIT= is specified. + 2019-02-22 Steven G. Kargl PR fortran/89431 diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 95b30132203..9828897852a 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -2504,16 +2504,15 @@ gfc_match_open (void) goto cleanup; } - if (!open->file && open->status) - { - if (open->status->expr_type == EXPR_CONSTANT + if (!open->file && + (!open->status || + (open->status->expr_type == EXPR_CONSTANT && gfc_wide_strncasecmp (open->status->value.character.string, - "scratch", 7) != 0) - { + "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/ChangeLog b/gcc/testsuite/ChangeLog index 9fae9ffa169..dd0437780c8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-02-22 Harald Anlauf + + PR fortran/83057 + * gfortran.dg/newunit_6.f90: New test. + 2019-02-22 Marek Polacek PR c++/89420 - ICE with CAST_EXPR in explicit-specifier. diff --git a/gcc/testsuite/gfortran.dg/newunit_6.f90 b/gcc/testsuite/gfortran.dg/newunit_6.f90 new file mode 100644 index 00000000000..849c7926cc4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/newunit_6.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! +! PR fortran/83057 - OPEN without a filename and without STATUS='SCRATCH' +! could produce a warning + + open(newunit=iun,file="file") ! this is ok + open(newunit=jun,status="scratch") ! this too + open(newunit=lun) ! { dg-error "NEWUNIT specifier must have" } +end