diff mbox

[Fortran,+,Testsuite] Fix coarray handling in modules

Message ID 54A86D6A.2030101@net-b.de
State New
Headers show

Commit Message

Tobias Burnus Jan. 3, 2015, 10:30 p.m. UTC
Dominique d'Humières wrote:
>  From a quick test, with the patch I still see the error with -m32

It helps if one actually adds the decl. The following (still untested) 
should help. I also marked the token as nonaliasing (it really should!) 
and added for proc pointers the tree-public optimization.

Tobias

Comments

Dominique d'Humières Jan. 3, 2015, 11:04 p.m. UTC | #1
Compilation with the new patch fails with

../../work/gcc/fortran/trans-decl.c: In function 'void gfc_build_qualified_array(tree, gfc_symbol*)':
../../work/gcc/fortran/trans-decl.c:855:25: error: 'cur_module' was not declared in this scope
    gfc_module_add_decl (cur_module, token);

Dominique

> Le 3 janv. 2015 à 23:30, Tobias Burnus <burnus@net-b.de> a écrit :
> 
> Dominique d'Humières wrote:
>> From a quick test, with the patch I still see the error with -m32
> 
> It helps if one actually adds the decl. The following (still untested) should help. I also marked the token as nonaliasing (it really should!) and added for proc pointers the tree-public optimization.
> 
> Tobias
> <foo.diff>
diff mbox

Patch

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 9ef6bfc..976db2b 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -830,15 +830,32 @@  gfc_build_qualified_array (tree decl, gfc_symbol * sym)
 			IDENTIFIER_POINTER (gfc_sym_mangled_identifier (sym))));
 	  token = build_decl (DECL_SOURCE_LOCATION (decl), VAR_DECL, token_name,
 			      token_type);
-	  TREE_PUBLIC (token) = 1;
+	  if (sym->attr.use_assoc)
+	    DECL_EXTERNAL (token) = 1;
+	  else
+	    TREE_STATIC (token) = 1;
+
+	  if (sym->attr.use_assoc || sym->attr.access != ACCESS_PRIVATE ||
+	      sym->attr.public_used)
+	    TREE_PUBLIC (token) = 1;
 	}
       else
-	token = gfc_create_var_np (token_type, "caf_token");
+	{
+	  token = gfc_create_var_np (token_type, "caf_token");
+	  TREE_STATIC (token) = 1;
+	}
 
       GFC_TYPE_ARRAY_CAF_TOKEN (type) = token;
       DECL_ARTIFICIAL (token) = 1;
-      TREE_STATIC (token) = 1;
-      gfc_add_decl_to_function (token);
+      DECL_NONALIASED (token) = 1;
+
+      if (sym->module && !sym->attr.use_assoc)
+	{
+	  DECL_CONTEXT (token) = sym->ns->proc_name->backend_decl;
+	  gfc_module_add_decl (cur_module, token);
+	}
+      else
+	gfc_add_decl_to_function (token);
     }
 
   for (dim = 0; dim < GFC_TYPE_ARRAY_RANK (type); dim++)
@@ -1664,7 +1681,9 @@  get_proc_pointer_decl (gfc_symbol *sym)
   else if (sym->module && sym->ns->proc_name->attr.flavor == FL_MODULE)
     {
       /* This is the declaration of a module variable.  */
-      TREE_PUBLIC (decl) = 1;
+      if (sym->ns->proc_name->attr.flavor == FL_MODULE
+	  && (sym->attr.access != ACCESS_PRIVATE || sym->attr.public_used))
+	TREE_PUBLIC (decl) = 1;
       TREE_STATIC (decl) = 1;
     }