public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/50556] New: cannot save namelist group name
@ 2011-09-28 10:08 zeccav at gmail dot com
  2011-10-28  5:22 ` [Bug fortran/50556] " kargl at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: zeccav at gmail dot com @ 2011-09-28 10:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50556

             Bug #: 50556
           Summary: cannot save namelist group name
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zeccav@gmail.com


! cannot save namelist group name 
      namelist /i/ ii
      save i
      end


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

* [Bug fortran/50556] cannot save namelist group name
  2011-09-28 10:08 [Bug fortran/50556] New: cannot save namelist group name zeccav at gmail dot com
@ 2011-10-28  5:22 ` kargl at gcc dot gnu.org
  2011-10-29 14:48 ` burnus at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu.org @ 2011-10-28  5:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50556

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org 2011-10-28 05:21:48 UTC ---
The patch at the end of this note will issue an error for the test code.
I, however, cannot find any text concerning namelist in the F2008 standard
that prohibits the code.  One might argue that a "SAVE namelist-group-name"
should mean that all namelist-group-objects associate this 
namelist-group-name gets the SAVE attribute.  If this interpretation
was correct, then one would expect that text in the Standard would 
make this clear.


laptop:kargl[231] gfc4x -c foo.f90
foo.f90:2.12:

      save i
            1
Error: Namelist group name at (1) cannot appear in a SAVE statement


Index: decl.c
===================================================================
--- decl.c      (revision 180567)
+++ decl.c      (working copy)
@@ -6831,6 +6831,14 @@ gfc_match_save (void)
          if (gfc_add_save (&sym->attr, SAVE_EXPLICIT, sym->name,
                            &gfc_current_locus) == FAILURE)
            return MATCH_ERROR;
+
+         if (sym->attr.flavor == FL_NAMELIST)
+           {
+             gfc_error ("Namelist group name at %C cannot appear in a "
+                        "SAVE statement");
+             return MATCH_ERROR;
+           }
+
          goto next_item;

        case MATCH_NO:
l


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

* [Bug fortran/50556] cannot save namelist group name
  2011-09-28 10:08 [Bug fortran/50556] New: cannot save namelist group name zeccav at gmail dot com
  2011-10-28  5:22 ` [Bug fortran/50556] " kargl at gcc dot gnu.org
@ 2011-10-29 14:48 ` burnus at gcc dot gnu.org
  2011-10-29 15:17 ` burnus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-10-29 14:48 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50556

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-10-29 14:47:52 UTC ---
> One might argue that a "SAVE namelist-group-name" should mean that all
> namelist-group-objects associate this namelist-group-name gets the SAVE
> attribute.  If this interpretation was correct, then one would expect that
> text in the Standard would make this clear.

Well, I see in the standard:

"C553   An entity with the SAVE attribute shall be a common block, variable, or
procedure pointer."

And I would argue that a namelist-group-name is neither a common block, a
variable nor a procedure pointer.

Thus, I believe that the code in comment 0 is invalid.

Regarding the patch in comment 1: I think it will not work if one swaps the
order of NAMELIST and SAVE.

Untested patch:

--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -441,6 +441,7 @@ check_conflict (symbol_attribute *attr, const char *name,
locus *where)
          case FL_LABEL:
          case FL_DERIVED:
          case FL_PARAMETER:
+         case FL_NAMELIST:
             a1 = gfc_code2string (flavors, attr->flavor);
             a2 = save;
            goto conflict;
@@ -449,7 +450,6 @@ check_conflict (symbol_attribute *attr, const char *name,
locus *where)
            /* Conflicts between SAVE and PROCEDURE will be checked at
               resolution stage, see "resolve_fl_procedure".  */
          case FL_VARIABLE:
-         case FL_NAMELIST:
          default:
            break;
        }


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

* [Bug fortran/50556] cannot save namelist group name
  2011-09-28 10:08 [Bug fortran/50556] New: cannot save namelist group name zeccav at gmail dot com
  2011-10-28  5:22 ` [Bug fortran/50556] " kargl at gcc dot gnu.org
  2011-10-29 14:48 ` burnus at gcc dot gnu.org
@ 2011-10-29 15:17 ` burnus at gcc dot gnu.org
  2011-10-29 16:50 ` sgk at troutmask dot apl.washington.edu
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-10-29 15:17 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50556

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-10-29 15:17:19 UTC ---
(In reply to comment #2)
> Well, I see in the standard:
[Fortran 2008]
> "C553   An entity with the SAVE attribute shall be a common block, variable, or
> procedure pointer."
> 
> And I would argue that a namelist-group-name is neither a common block, a
> variable nor a procedure pointer.

See also
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/07da50d1aaf3870d
- there, the argument seems to be the same, though the reference is R544.

 * * *

>From c.l.f:
> Unfortunately, I also found that gfortran has interpreted something like
>      namelist /cmd/ i, j, k
>      save cmd
> to mean
>     namelist /cmd/ i, j, k
>     save i, j, k

The question is whether one needs to allow it.

g95 and gfortran allow the code
ifort, NAG f95, g77 (!), pathf95/openf95/crayftn reject it.
PGI warns "Symbol, i, appears illegally in a SAVE statement"

Thus, I wouldn't mind breaking the backward compatibility.


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

* [Bug fortran/50556] cannot save namelist group name
  2011-09-28 10:08 [Bug fortran/50556] New: cannot save namelist group name zeccav at gmail dot com
                   ` (2 preceding siblings ...)
  2011-10-29 15:17 ` burnus at gcc dot gnu.org
@ 2011-10-29 16:50 ` sgk at troutmask dot apl.washington.edu
  2011-10-29 16:51 ` sgk at troutmask dot apl.washington.edu
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2011-10-29 16:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50556

--- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> 2011-10-29 16:49:38 UTC ---
On Sat, Oct 29, 2011 at 02:47:52PM +0000, burnus at gcc dot gnu.org wrote:
> > One might argue that a "SAVE namelist-group-name" should mean that all
> > namelist-group-objects associate this namelist-group-name gets the SAVE
> > attribute.  If this interpretation was correct, then one would expect that
> > text in the Standard would make this clear.
> 
> Well, I see in the standard:
> 
> "C553   An entity with the SAVE attribute shall be a common block,
>         variable, or procedure pointer."
> 
> And I would argue that a namelist-group-name is neither a common block, a
> variable nor a procedure pointer.

Well, spotted.  I was scanning the standards for 'namelist-group',
so missed C553.

> Thus, I believe that the code in comment 0 is invalid.
> 
> Regarding the patch in comment 1: I think it will not work if one swaps the
> order of NAMELIST and SAVE.

Confirmed.

> Untested patch:
> 
> --- a/gcc/fortran/symbol.c
> +++ b/gcc/fortran/symbol.c
> @@ -441,6 +441,7 @@ check_conflict (symbol_attribute *attr, const char *name,
> locus *where)
>           case FL_LABEL:
>           case FL_DERIVED:
>           case FL_PARAMETER:
> +         case FL_NAMELIST:
>              a1 = gfc_code2string (flavors, attr->flavor);
>              a2 = save;
>             goto conflict;
> @@ -449,7 +450,6 @@ check_conflict (symbol_attribute *attr, const char *name,
> locus *where)
>             /* Conflicts between SAVE and PROCEDURE will be checked at
>                resolution stage, see "resolve_fl_procedure".  */
>           case FL_VARIABLE:
> -         case FL_NAMELIST:
>           default:
>             break;
>         }

I tested the above.  It catches both examples of invalid code
(namelist before save and save before namelist).  However, the
error message is a bit strange:

ab.f90:2.12:

      save i
            1
Error: NAMELIST attribute conflicts with SAVE attribute in 'i' at (1)

NAMELIST is not an attribute.  With the attached patch, I get

laptop:kargl[239] gfc4x -c namelist_74.f90
namelist_74.f90:5.15:

   namelist /i/ ii    ! { dg-error "cannot have a SAVE attribute" }
               1
Error: Namelist group name at (1) cannot have a SAVE attribute
namelist_74.f90:9.9:

   save i             ! { dg-error "cannot have a SAVE attribute" }
         1
Error: Namelist group name at (1) cannot have a SAVE attribute


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

* [Bug fortran/50556] cannot save namelist group name
  2011-09-28 10:08 [Bug fortran/50556] New: cannot save namelist group name zeccav at gmail dot com
                   ` (3 preceding siblings ...)
  2011-10-29 16:50 ` sgk at troutmask dot apl.washington.edu
@ 2011-10-29 16:51 ` sgk at troutmask dot apl.washington.edu
  2012-01-21 18:01 ` kargl at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2011-10-29 16:51 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50556

--- Comment #5 from Steve Kargl <sgk at troutmask dot apl.washington.edu> 2011-10-29 16:51:10 UTC ---
On Sat, Oct 29, 2011 at 03:17:19PM +0000, burnus at gcc dot gnu.org wrote:
> >From c.l.f:
> > Unfortunately, I also found that gfortran has interpreted something like
> >      namelist /cmd/ i, j, k
> >      save cmd
> > to mean
> >     namelist /cmd/ i, j, k
> >     save i, j, k
> 
> The question is whether one needs to allow it.
> 
> g95 and gfortran allow the code
> ifort, NAG f95, g77 (!), pathf95/openf95/crayftn reject it.
> PGI warns "Symbol, i, appears illegally in a SAVE statement"
> 
> Thus, I wouldn't mind breaking the backward compatibility.

I vote that gfortran should follow the majority and simply
issue an error.


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

* [Bug fortran/50556] cannot save namelist group name
  2011-09-28 10:08 [Bug fortran/50556] New: cannot save namelist group name zeccav at gmail dot com
                   ` (4 preceding siblings ...)
  2011-10-29 16:51 ` sgk at troutmask dot apl.washington.edu
@ 2012-01-21 18:01 ` kargl at gcc dot gnu.org
  2012-01-21 18:08 ` kargl at gcc dot gnu.org
  2012-01-23 19:16 ` kargl at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu.org @ 2012-01-21 18:01 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50556

--- Comment #6 from kargl at gcc dot gnu.org 2012-01-21 17:32:15 UTC ---
Author: kargl
Date: Sat Jan 21 17:32:12 2012
New Revision: 183370

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183370
Log:
2012-01-21  Tobias Burnus  <burnus@net-b.de>
        Steven G. Kargl  <kargl@gcc.gnu.org>

    PR fortran/50556
    * symbol.c (check_conflict): namelist-group-name cannot have the SAVE
    attribure.

2012-01-21  Steven G. Kargl  <kargl@gcc.gnu.org>

    PR fortran/50556
    * gfortran.dg/namelist_74.f90: New test.
    * gfortran.dg/namelist_59.f90: Remove SAVE attribute.

Added:
    trunk/gcc/testsuite/gfortran.dg/namelist_74.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/symbol.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/namelist_59.f90


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

* [Bug fortran/50556] cannot save namelist group name
  2011-09-28 10:08 [Bug fortran/50556] New: cannot save namelist group name zeccav at gmail dot com
                   ` (5 preceding siblings ...)
  2012-01-21 18:01 ` kargl at gcc dot gnu.org
@ 2012-01-21 18:08 ` kargl at gcc dot gnu.org
  2012-01-23 19:16 ` kargl at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu.org @ 2012-01-21 18:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50556

--- Comment #7 from kargl at gcc dot gnu.org 2012-01-21 17:37:40 UTC ---
Fixed on trunk.  Thanks for the bug reports.


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

* [Bug fortran/50556] cannot save namelist group name
  2011-09-28 10:08 [Bug fortran/50556] New: cannot save namelist group name zeccav at gmail dot com
                   ` (6 preceding siblings ...)
  2012-01-21 18:08 ` kargl at gcc dot gnu.org
@ 2012-01-23 19:16 ` kargl at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu.org @ 2012-01-23 19:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50556

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED

--- Comment #8 from kargl at gcc dot gnu.org 2012-01-23 18:48:44 UTC ---
Seems I forgot to close this one after committing the fix.
Close now.


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

end of thread, other threads:[~2012-01-23 18:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-28 10:08 [Bug fortran/50556] New: cannot save namelist group name zeccav at gmail dot com
2011-10-28  5:22 ` [Bug fortran/50556] " kargl at gcc dot gnu.org
2011-10-29 14:48 ` burnus at gcc dot gnu.org
2011-10-29 15:17 ` burnus at gcc dot gnu.org
2011-10-29 16:50 ` sgk at troutmask dot apl.washington.edu
2011-10-29 16:51 ` sgk at troutmask dot apl.washington.edu
2012-01-21 18:01 ` kargl at gcc dot gnu.org
2012-01-21 18:08 ` kargl at gcc dot gnu.org
2012-01-23 19:16 ` kargl at gcc dot gnu.org

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).