From 5a47fc2f955ddee6b4a061f51a75aad555dcc4ab Mon Sep 17 00:00:00 2001
From: Daniel Franke <franke.daniel@gmail.com>
Date: Sat, 3 Jan 2009 18:20:11 -0500
Subject: [PATCH] symbol.c (save_symbol): Don't SAVE function results.

gcc/fortran:
2009-01-03  Daniel Franke  <franke.daniel@gmail.com>

	* symbol.c (save_symbol): Don't SAVE function results.

gcc/testsuite:
2009-01-03  Daniel Franke  <franke.daniel@gmail.com>

	* gfortran.dg/func_result_4.f90: New.

From-SVN: r143039
---
 gcc/fortran/ChangeLog                       |  4 ++++
 gcc/fortran/symbol.c                        |  1 +
 gcc/testsuite/ChangeLog                     |  4 ++++
 gcc/testsuite/gfortran.dg/func_result_4.f90 | 10 ++++++++++
 4 files changed, 19 insertions(+)
 create mode 100644 gcc/testsuite/gfortran.dg/func_result_4.f90

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 738209bb992b..28fa3685ae87 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,7 @@
+2009-01-03  Daniel Franke  <franke.daniel@gmail.com>
+
+	* symbol.c (save_symbol): Don't SAVE function results.
+
 2009-01-03  Paul Thomas  <pault@gcc.gnu.org>
 
 	PR fortran/38594
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index 7c79ef80afa8..b74318c51f36 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -3197,6 +3197,7 @@ save_symbol (gfc_symbol *sym)
 
   if (sym->attr.in_common
       || sym->attr.dummy
+      || sym->attr.result
       || sym->attr.flavor != FL_VARIABLE)
     return;
   /* Automatic objects are not saved.  */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fe53d67cfe8b..7e2416303a44 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2009-01-03  Daniel Franke  <franke.daniel@gmail.com>
+
+	* gfortran.dg/func_result_4.f90: New.
+
 2009-01-03  Paul Thomas  <pault@gcc.gnu.org>
 
 	PR fortran/38594
diff --git a/gcc/testsuite/gfortran.dg/func_result_4.f90 b/gcc/testsuite/gfortran.dg/func_result_4.f90
new file mode 100644
index 000000000000..81f02a57ca28
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/func_result_4.f90
@@ -0,0 +1,10 @@
+! { dg-do "compile" }
+! { dg-options "-c" }
+!
+! Do not apply the SAVE attribute to function results.
+!
+FUNCTION f() RESULT (g)
+  INTEGER :: g
+  SAVE
+  g = 42
+END FUNCTION
-- 
GitLab