OSDN Git Service

2010-07-10 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 10 Jul 2010 14:57:25 +0000 (14:57 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 10 Jul 2010 14:57:25 +0000 (14:57 +0000)
PR fortran/44773
* trans-expr.c (arrayfunc_assign_needs_temporary): No temporary
if the lhs has never been host associated, as well as not being
use associated, a pointer or a target.
* resolve.c (resolve_variable): Mark variables that are host
associated.
* gfortran.h: Add the host_assoc bit to the symbol_attribute
structure.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162038 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/gfortran.h
gcc/fortran/resolve.c
gcc/fortran/trans-expr.c

index f43a33b..e4837b4 100644 (file)
@@ -1,3 +1,14 @@
+2010-07-10  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/44773
+       * trans-expr.c (arrayfunc_assign_needs_temporary): No temporary
+       if the lhs has never been host associated, as well as not being
+       use associated, a pointer or a target.
+       * resolve.c (resolve_variable): Mark variables that are host
+       associated.
+       * gfortran.h: Add the host_assoc bit to the symbol_attribute
+       structure.
+
 2010-07-09  Janus Weil  <janus@gcc.gnu.org>
 
        * intrinsic.texi: Add documentation for SAME_TYPE_AS, EXTENDS_TYPE_OF,
index 3797926..6086480 100644 (file)
@@ -682,7 +682,8 @@ typedef struct
     use_assoc:1,               /* Symbol has been use-associated.  */
     use_only:1,                        /* Symbol has been use-associated, with ONLY.  */
     use_rename:1,              /* Symbol has been use-associated and renamed.  */
-    imported:1;                        /* Symbol has been associated by IMPORT.  */
+    imported:1,                        /* Symbol has been associated by IMPORT.  */
+    host_assoc:1;              /* Symbol has been host associated.  */ 
 
   unsigned in_namelist:1, in_common:1, in_equivalence:1;
   unsigned function:1, subroutine:1, procedure:1;
index a8ed544..98d1e07 100644 (file)
@@ -4772,6 +4772,15 @@ resolve_variable (gfc_expr *e)
        sym->entry_id = current_entry_id + 1;
     }
 
+  /* If a symbol has been host_associated mark it.  This is used latter,
+     to identify if aliasing is possible via host association.  */
+  if (sym->attr.flavor == FL_VARIABLE
+       && gfc_current_ns->parent
+       && (gfc_current_ns->parent == sym->ns
+             || (gfc_current_ns->parent->parent
+                   && gfc_current_ns->parent->parent == sym->ns)))
+    sym->attr.host_assoc = 1;
+
 resolve_procedure:
   if (t == SUCCESS && resolve_procedure_expression (e) == FAILURE)
     t = FAILURE;
index ea8b892..5f2eda2 100644 (file)
@@ -4978,6 +4978,11 @@ arrayfunc_assign_needs_temporary (gfc_expr * expr1, gfc_expr * expr2)
       if (!expr2->value.function.esym->attr.contained)
        return false;
 
+      /* A temporary is not needed if the lhs has never been host
+        associated and the procedure is contained.  */
+      else if (!sym->attr.host_assoc)
+       return false;
+
       /* A temporary is not needed if the variable is local and not
         a pointer, a target or a result.  */
       if (sym->ns->parent