[Patch, fortran] PR20847 and PR20856

Paul Thomas paulthomas2@wanadoo.fr
Sat Oct 8 09:59:00 GMT 2005


:ADDPATCH fortran:

Sorry, this was submitted earlier under the wrong subject line; I have 
deleted that patch queue entry to stop things from getting any more 
screwed up.

This patch cures two cases where the SAVE attribute is not compliant 
with the standard - common variables and function results.  The two 
constraints have been added to symbol.c (check_conflict).

Bootstrapped and regtested on FC3/Athlon.  OK for mainline and 4.0?

Paul T

------------------------------------------------------------------------

2005-10-08  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/20847
	PR fortran/20856
	* symbol.c (check_conflict): Prevent common variables and
	function results from having the SAVE attribute,as required
	by the standard.

2005-10-08  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/20847
	gfortran.dg/save_common.f90: New test.

	PR fortran/20856
	gfortran.dg/save_result.f90: New test.


Index: gcc/gcc/fortran/symbol.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/symbol.c,v
retrieving revision 1.33
diff -c -p -r1.33 symbol.c
*** gcc/gcc/fortran/symbol.c	7 Sep 2005 21:08:22 -0000	1.33
--- gcc/gcc/fortran/symbol.c	26 Sep 2005 09:32:35 -0000
*************** check_conflict (symbol_attribute * attr,
*** 321,326 ****
--- 321,329 ----
    conf (in_common, dummy);
    conf (in_common, allocatable);
    conf (in_common, result);
+   conf (in_common, save);
+   conf (result, save);
+ 
    conf (dummy, result);
  
    conf (in_namelist, pointer);

--------------------save_common.f90--------------------------

! { dg-do compile }
! PR20847 - A common variable may not have the SAVE attribute.
! Contributed by Joost VandeVondele <jv244@cam.ac.uk>
INTEGER, SAVE :: X
COMMON /COM/ X ! { dg-error "conflicts with SAVE attribute" }
END


--------------------save_result.f90--------------------------

! { dg-do compile }
! PR20856 - A function result may not have SAVE attribute.
! Contributed by Joost VandeVondele <jv244@cam.ac.uk>
FUNCTION X() RESULT(Y)
REAL, SAVE :: Y ! { dg-error "RESULT attribute conflicts with SAVE" }
y = 1
END FUNCTION X
END








More information about the Fortran mailing list