OSDN Git Service

PR middle-end/40500
[pf3gnuchains/gcc-fork.git] / gcc / fortran / trans-decl.c
index ceabbbe..4e72a23 100644 (file)
@@ -578,6 +578,11 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym)
   if (sym->attr.threadprivate
       && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
     DECL_TLS_MODEL (decl) = decl_default_tls_model (decl);
+
+  if (!sym->attr.target
+      && !sym->attr.pointer
+      && !sym->attr.proc_pointer)
+    DECL_RESTRICTED_P (decl) = 1;
 }
 
 
@@ -840,7 +845,8 @@ gfc_build_dummy_array_decl (gfc_symbol * sym, tree dummy)
        }
 
       type = gfc_typenode_for_spec (&sym->ts);
-      type = gfc_get_nodesc_array_type (type, sym->as, packed);
+      type = gfc_get_nodesc_array_type (type, sym->as, packed,
+                                       !sym->attr.target);
     }
   else
     {
@@ -1796,16 +1802,7 @@ create_function_arglist (gfc_symbol * sym)
              /* This can happen if the same type is used for multiple
                 arguments. We need to copy cl as otherwise
                 cl->passed_length gets overwritten.  */
-             gfc_charlen *cl, *cl2;
-             cl = f->sym->ts.u.cl;
-             f->sym->ts.u.cl = gfc_get_charlen();
-             f->sym->ts.u.cl->length = cl->length;
-             f->sym->ts.u.cl->backend_decl = cl->backend_decl;
-             f->sym->ts.u.cl->length_from_typespec = cl->length_from_typespec;
-             f->sym->ts.u.cl->resolved = cl->resolved;
-             cl2 = f->sym->ts.u.cl->next;
-             f->sym->ts.u.cl->next = cl;
-              cl->next = cl2;
+             f->sym->ts.u.cl = gfc_new_charlen (f->sym->ns, f->sym->ts.u.cl);
             }
          f->sym->ts.u.cl->passed_length = length;
 
@@ -3435,7 +3432,13 @@ gfc_trans_use_stmts (gfc_namespace * ns)
              st = gfc_find_symtree (ns->sym_root,
                                     rent->local_name[0]
                                     ? rent->local_name : rent->use_name);
-             gcc_assert (st && st->n.sym->attr.use_assoc);
+             gcc_assert (st);
+
+             /* Sometimes, generic interfaces wind up being over-ruled by a
+                local symbol (see PR41062).  */
+             if (!st->n.sym->attr.use_assoc)
+               continue;
+
              if (st->n.sym->backend_decl
                  && DECL_P (st->n.sym->backend_decl)
                  && st->n.sym->module