This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules


Dominique Dhumieres wrote:
The test gfortran.dg/coarray/codimension_2.f90 fails on x86_64-apple-darwin14 with -m32
(see https://gcc.gnu.org/ml/gcc-testresults/2015-01/msg00185.html). The error is
[...]

Yes, there seems to be something wrong. The module has:

                 U _F.caf_token__global_coarrays_MOD_b
0000000000000000 B __global_coarrays_MOD_b

where the token should not be "U"ndefined but "B". On the other hand, the USEr of the module has:

0000000000000000 B _F.caf_token__global_coarrays_MOD_b
                 U __global_coarrays_MOD_b

but it should have a "U" – with two users one even would get: "multiple definition of `_F.caf_token__global_coarrays_MOD_b'".


Untested patch attached.

Tobias
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 9ef6bfc..84a8a6e 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -830,14 +830,23 @@ 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);
     }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]