diff mbox

fortran/44797 -- inquire's exist shall be default logical

Message ID 20100704060614.GA45076@troutmask.apl.washington.edu
State New
Headers show

Commit Message

Steve Kargl July 4, 2010, 6:06 a.m. UTC
The standard requires a default logical for the EXIST
tag in an inquire statement.  gfortran has an extension
to accept any logical kind.  However, if -std=f95 or
-std=f2003 is given gfortran does not issue an error.
This patch fixes that shortcoming.

OK for trunk?
 
2010-07-03  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/44797
	* fortran/io.c (resolve_tag): Check EXIST is a default logical.

Comments

Tobias Burnus July 4, 2010, 7:21 a.m. UTC | #1
Steve Kargl wrote:
> The standard requires a default logical for the EXIST
> tag in an inquire statement.  gfortran has an extension
> to accept any logical kind.  However, if -std=f95 or
> -std=f2003 is given gfortran does not issue an error.
> This patch fixes that shortcoming.
>
> OK for trunk?
>   

OK if you change GFC_STD_GNU into GFC_STD_F2008. While F95 has

R924 inquire-spec ... or EXIST = scalar-default-logical-variable

and F2003 has

R930 inquire-spec ... EXIST = scalar-default-logical-variable

F2008 FDIS allows it:

R931 inquire-spec ... EXIST = scalar-logical-variable

Tobias

> 2010-07-03  Steven G. Kargl  <kargl@gcc.gnu.org>
>
> 	PR fortran/44797
> 	* fortran/io.c (resolve_tag): Check EXIST is a default logical
Tobias Burnus July 4, 2010, 8:09 a.m. UTC | #2
Am 04.07.2010 09:21, schrieb Tobias Burnus:
> Steve Kargl wrote:
>> The standard requires a default logical for the EXIST
>> tag in an inquire statement.  gfortran has an extension
>> to accept any logical kind.  However, if -std=f95 or
>> -std=f2003 is given gfortran does not issue an error.
>> This patch fixes that shortcoming.
>>
>> OK for trunk?
>>   
> 
> OK if you change GFC_STD_GNU into GFC_STD_F2008. While F95 has

For completeness, I have checked the other I/O statements and the change
applies to all (F2003->F2008).


+      if (gfc_notify_std (GFC_STD_GNU, "default LOGICAL required "
+			  "in %s tag at %L", tag->name, &e->where)

I would like to see in the message that it is allowed with F2008, e.g.
"Fortran 2008: Nondefault LOGICAL in %s tag at %L".

Tobias
Steve Kargl July 5, 2010, 8:15 p.m. UTC | #3
On Sun, Jul 04, 2010 at 10:09:37AM +0200, Tobias Burnus wrote:
> Am 04.07.2010 09:21, schrieb Tobias Burnus:
> > Steve Kargl wrote:
> >> The standard requires a default logical for the EXIST
> >> tag in an inquire statement.  gfortran has an extension
> >> to accept any logical kind.  However, if -std=f95 or
> >> -std=f2003 is given gfortran does not issue an error.
> >> This patch fixes that shortcoming.
> >>
> >> OK for trunk?
> >>   
> > 
> > OK if you change GFC_STD_GNU into GFC_STD_F2008. While F95 has
> 
> For completeness, I have checked the other I/O statements and the change
> applies to all (F2003->F2008).
> 
> 
> +      if (gfc_notify_std (GFC_STD_GNU, "default LOGICAL required "
> +			  "in %s tag at %L", tag->name, &e->where)
> 
> I would like to see in the message that it is allowed with F2008, e.g.
> "Fortran 2008: Nondefault LOGICAL in %s tag at %L".
> 

Committed with your suggested changes as

Sending        ChangeLog
Sending        io.c
Transmitting file data ..
Committed revision 161852.
diff mbox

Patch

Index: io.c
===================================================================
--- io.c	(revision 161480)
+++ io.c	(working copy)
@@ -1497,6 +1497,14 @@  resolve_tag (const io_tag *tag, gfc_expr
 	return FAILURE;
     }
 
+  if (tag == &tag_exist && e->ts.kind != gfc_default_logical_kind)
+    {
+      if (gfc_notify_std (GFC_STD_GNU, "default LOGICAL required "
+			  "in %s tag at %L", tag->name, &e->where)
+	  == FAILURE)
+	return FAILURE;
+    }
+
   if (tag == &tag_convert)
     {
       if (gfc_notify_std (GFC_STD_GNU, "Extension: CONVERT tag at %L",