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

Reply via email to