Patchwork [committed] PR Fortran/50556

login
register
mail settings
Submitter Steve Kargl
Date Jan. 21, 2012, 5:40 p.m.
Message ID <20120121174040.GA44925@troutmask.apl.washington.edu>
Download mbox | patch
Permalink /patch/137198/
State New
Headers show

Comments

Steve Kargl - Jan. 21, 2012, 5:40 p.m.
I've committed the following patch after successful
build and regression testing and Tobias' approval 
in private email.

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

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.

Patch

Index: fortran/symbol.c
===================================================================
--- fortran/symbol.c	(revision 180650)
+++ fortran/symbol.c	(working copy)
@@ -444,12 +444,15 @@  check_conflict (symbol_attribute *attr, 
             a1 = gfc_code2string (flavors, attr->flavor);
             a2 = save;
 	    goto conflict;
-
+	  case FL_NAMELIST:
+	    gfc_error ("Namelist group name at %L cannot have the "
+		       "SAVE attribute", where);
+	    return FAILURE; 
+	    break;
 	  case FL_PROCEDURE:
 	    /* Conflicts between SAVE and PROCEDURE will be checked at
 	       resolution stage, see "resolve_fl_procedure".  */
 	  case FL_VARIABLE:
-	  case FL_NAMELIST:
 	  default:
 	    break;
 	}
Index: testsuite/gfortran.dg/namelist_59.f90
===================================================================
--- testsuite/gfortran.dg/namelist_59.f90	(revision 180650)
+++ testsuite/gfortran.dg/namelist_59.f90	(working copy)
@@ -16,7 +16,6 @@  subroutine process(string)
  integer :: i=1,j=2,k=3
  integer ios
  namelist /cmd/ i,j,k
- save cmd
  lines(1)='&cmd'
  lines(2)=string
  lines(3)='/'
Index: testsuite/gfortran.dg/namelist_74.f90
===================================================================
--- testsuite/gfortran.dg/namelist_74.f90	(revision 0)
+++ testsuite/gfortran.dg/namelist_74.f90	(revision 0)
@@ -0,0 +1,10 @@ 
+! { dg-do compile }
+! PR fortran/50556
+subroutine foo
+   save i
+   namelist /i/ ii    ! { dg-error "cannot have a SAVE attribute" }
+end subroutine foo
+subroutine bar
+   namelist /i/ ii
+   save i             ! { dg-error "cannot have a SAVE attribute" }
+end subroutine bar