OSDN Git Service

gcc/testsuite/
[pf3gnuchains/gcc-fork.git] / gcc / fortran / trans-common.c
index a8e1126..8c30309 100644 (file)
@@ -1,5 +1,5 @@
 /* Common block and equivalence list handling
-   Copyright (C) 2000, 2003, 2004, 2005, 2006, 2007
+   Copyright (C) 2000, 2003, 2004, 2005, 2006, 2007, 2008
    Free Software Foundation, Inc.
    Contributed by Canqun Yang <canqun@nudt.edu.cn>
 
@@ -321,10 +321,10 @@ build_field (segment_info *h, tree union_type, record_layout_info rli)
   /* If this field is volatile, mark it.  */
   if (h->sym->attr.volatile_)
     {
-      tree new;
+      tree new_type;
       TREE_THIS_VOLATILE (field) = 1;
-      new = build_qualified_type (TREE_TYPE (field), TYPE_QUAL_VOLATILE);
-      TREE_TYPE (field) = new;
+      new_type = build_qualified_type (TREE_TYPE (field), TYPE_QUAL_VOLATILE);
+      TREE_TYPE (field) = new_type;
     }
 
   h->field = field;
@@ -547,7 +547,6 @@ get_init_field (segment_info *head, tree union_type, tree *field_init,
 
   init = build_constructor (TREE_TYPE (field), v);
   TREE_CONSTANT (init) = 1;
-  TREE_INVARIANT (init) = 1;
 
   *field_init = init;
 
@@ -657,7 +656,6 @@ create_common (gfc_common_head *com, segment_info *head, bool saw_equiv)
       gcc_assert (!VEC_empty (constructor_elt, v));
       ctor = build_constructor (union_type, v);
       TREE_CONSTANT (ctor) = 1;
-      TREE_INVARIANT (ctor) = 1;
       TREE_STATIC (ctor) = 1;
       DECL_INITIAL (decl) = ctor;
 
@@ -686,15 +684,19 @@ create_common (gfc_common_head *com, segment_info *head, bool saw_equiv)
        TREE_ADDRESSABLE (var_decl) = 1;
       /* This is a fake variable just for debugging purposes.  */
       TREE_ASM_WRITTEN (var_decl) = 1;
-
-      if (com)
+      
+      /* To preserve identifier names in COMMON, chain to procedure
+         scope unless at top level in a module definition.  */
+      if (com
+          && s->sym->ns->proc_name
+          && s->sym->ns->proc_name->attr.flavor == FL_MODULE)
        var_decl = pushdecl_top_level (var_decl);
       else
        gfc_add_decl_to_function (var_decl);
 
       SET_DECL_VALUE_EXPR (var_decl,
-                          build3 (COMPONENT_REF, TREE_TYPE (s->field),
-                                  decl, s->field, NULL_TREE));
+                          fold_build3 (COMPONENT_REF, TREE_TYPE (s->field),
+                                       decl, s->field, NULL_TREE));
       DECL_HAS_VALUE_EXPR_P (var_decl) = 1;
       GFC_DECL_COMMON_OR_EQUIV (var_decl) = 1;
 
@@ -953,7 +955,7 @@ find_equivalence (segment_info *n)
    segment list multiple times to include indirect equivalences.  Since
    a new segment_info can inserted at the beginning of the segment list,
    depending on its offset, we have to force a final pass through the
-   loop by demanding that completion sees a pass with no matches; ie.
+   loop by demanding that completion sees a pass with no matches; i.e.,
    all symbols with equiv_built set and no new equivalences found.  */
 
 static void