diff mbox

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

Message ID 54A855FB.3050207@net-b.de
State New
Headers show

Commit Message

Tobias Burnus Jan. 3, 2015, 8:50 p.m. UTC
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

Comments

Dominique d'Humières Jan. 3, 2015, 9:48 p.m. UTC | #1
From a quick test, with the patch I still see the error with -m32

/var/folders/8q/sh_swgz96r7f5vnn08f7fxr00000gn/T//cc8Yz3Jr.s:18:non-relocatable subtraction expression, "__F.caf_token__global_coarrays_MOD_b" minus "L1$pb"
/var/folders/8q/sh_swgz96r7f5vnn08f7fxr00000gn/T//cc8Yz3Jr.s:18:symbol: "__F.caf_token__global_coarrays_MOD_b" can't be undefined in a subtraction expression

but also the test fails at link time with -m64

[Book15] f90/bug% gfc /opt/gcc/work/gcc/testsuite/gfortran.dg/coarray/codimension_2.f90 /opt/gcc/work/gcc/testsuite/gfortran.dg/coarray/codimension_2a.f90 -fcoarray=lib -O2 -lcaf_single
Undefined symbols for architecture x86_64:
  "__F.caf_token__global_coarrays_MOD_b", referenced from:
      __caf_init.0 in ccljvUii.o
      _MAIN__ in ccmqTPwK.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

Dominique

> Le 3 janv. 2015 à 21:50, Tobias Burnus <burnus@net-b.de> a écrit :
> 
> 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
> <foo.diff>
diff mbox

Patch

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);
     }