public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PR fortran/83057, patch] - OPEN without a filename and without STATUS='SCRATCH' could produce a warning
@ 2019-02-20 22:46 Harald Anlauf
  2019-02-22  7:27 ` Jerry DeLisle
  0 siblings, 1 reply; 3+ messages in thread
From: Harald Anlauf @ 2019-02-20 22:46 UTC (permalink / raw)
  To: gfortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 504 bytes --]

There was a rather obvious bug in the logic for checking the arguments
to the OPEN statement when NEWUNIT= was specified, which prohibited
the generation of the appropriate error message.

Regtested successfully.

OK for trunk?

Thanks,
Harald

2019-02-20  Harald Anlauf  <anlauf@gmx.de>

	PR fortran/83057
	* io.c (gfc_match_open): Fix logic in checks of OPEN statement
	when NEWUNIT= is specified.

2019-02-20  Harald Anlauf  <anlauf@gmx.de>

	PR fortran/83057
	* gfortran.dg/newunit_6.f90: New test.


[-- Attachment #2: patch-pr83057 --]
[-- Type: text/plain, Size: 709 bytes --]

Index: gcc/fortran/io.c
===================================================================
--- gcc/fortran/io.c	(revision 269028)
+++ gcc/fortran/io.c	(working copy)
@@ -2504,16 +2504,15 @@
 	  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)

[-- Attachment #3: patch-pr83057-testcase --]
[-- Type: text/plain, Size: 584 bytes --]

Index: gcc/testsuite/gfortran.dg/newunit_6.f90
===================================================================
--- gcc/testsuite/gfortran.dg/newunit_6.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/newunit_6.f90	(working copy)
@@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PR fortran/83057, patch] - OPEN without a filename and without STATUS='SCRATCH' could produce a warning
  2019-02-20 22:46 [PR fortran/83057, patch] - OPEN without a filename and without STATUS='SCRATCH' could produce a warning Harald Anlauf
@ 2019-02-22  7:27 ` Jerry DeLisle
  2019-02-22 21:26   ` Harald Anlauf
  0 siblings, 1 reply; 3+ messages in thread
From: Jerry DeLisle @ 2019-02-22  7:27 UTC (permalink / raw)
  To: Harald Anlauf, gfortran, gcc-patches

On 2/20/19 2:34 PM, Harald Anlauf wrote:
> There was a rather obvious bug in the logic for checking the arguments
> to the OPEN statement when NEWUNIT= was specified, which prohibited
> the generation of the appropriate error message.
> 
> Regtested successfully.
> 
> OK for trunk?

Yes and thanks for patch.

Jerry

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PR fortran/83057, patch] - OPEN without a filename and without STATUS='SCRATCH' could produce a warning
  2019-02-22  7:27 ` Jerry DeLisle
@ 2019-02-22 21:26   ` Harald Anlauf
  0 siblings, 0 replies; 3+ messages in thread
From: Harald Anlauf @ 2019-02-22 21:26 UTC (permalink / raw)
  To: Jerry DeLisle; +Cc: gfortran, gcc-patches

Committed to trunk as rev. 269134.

Thanks for the review!

Harald

On 02/22/19 06:28, Jerry DeLisle wrote:
> On 2/20/19 2:34 PM, Harald Anlauf wrote:
>> There was a rather obvious bug in the logic for checking the arguments
>> to the OPEN statement when NEWUNIT= was specified, which prohibited
>> the generation of the appropriate error message.
>>
>> Regtested successfully.
>>
>> OK for trunk?
> 
> Yes and thanks for patch.
> 
> Jerry
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-22 20:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-20 22:46 [PR fortran/83057, patch] - OPEN without a filename and without STATUS='SCRATCH' could produce a warning Harald Anlauf
2019-02-22  7:27 ` Jerry DeLisle
2019-02-22 21:26   ` Harald Anlauf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).