public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules
@ 2015-01-03 10:22 Dominique Dhumieres
  2015-01-03 20:50 ` Tobias Burnus
  0 siblings, 1 reply; 14+ messages in thread
From: Dominique Dhumieres @ 2015-01-03 10:22 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches, fxcoudert, burnus

Happy New Year to all.

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

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 -m32
/var/folders/8q/sh_swgz96r7f5vnn08f7fxr00000gn/T//ccPcznrm.s:18:non-relocatable subtraction expression, "__F.caf_token__global_coarrays_MOD_b" minus "L1$pb"
/var/folders/8q/sh_swgz96r7f5vnn08f7fxr00000gn/T//ccPcznrm.s:18:symbol: "__F.caf_token__global_coarrays_MOD_b" can't be undefined in a subtraction expression

Dominique

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules
  2015-01-03 10:22 [Patch, Fortran + Testsuite] Fix coarray handling in modules Dominique Dhumieres
@ 2015-01-03 20:50 ` Tobias Burnus
  2015-01-03 21:48   ` Dominique d'Humières
  0 siblings, 1 reply; 14+ messages in thread
From: Tobias Burnus @ 2015-01-03 20:50 UTC (permalink / raw)
  To: Dominique Dhumieres, fortran; +Cc: gcc-patches, fxcoudert

[-- Attachment #1: Type: text/plain, Size: 729 bytes --]

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

[-- Attachment #2: foo.diff --]
[-- Type: text/x-patch, Size: 991 bytes --]

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules
  2015-01-03 20:50 ` Tobias Burnus
@ 2015-01-03 21:48   ` Dominique d'Humières
  2015-01-03 22:30     ` Tobias Burnus
  0 siblings, 1 reply; 14+ messages in thread
From: Dominique d'Humières @ 2015-01-03 21:48 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: fortran, gcc-patches, fxcoudert

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>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules
  2015-01-03 21:48   ` Dominique d'Humières
@ 2015-01-03 22:30     ` Tobias Burnus
  2015-01-03 23:04       ` Dominique d'Humières
  0 siblings, 1 reply; 14+ messages in thread
From: Tobias Burnus @ 2015-01-03 22:30 UTC (permalink / raw)
  To: Dominique d'Humières; +Cc: fortran, gcc-patches, fxcoudert

[-- Attachment #1: Type: text/plain, Size: 310 bytes --]

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

[-- Attachment #2: foo.diff --]
[-- Type: text/x-patch, Size: 1722 bytes --]

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules
  2015-01-03 22:30     ` Tobias Burnus
@ 2015-01-03 23:04       ` Dominique d'Humières
  2015-01-04 18:58         ` [Patch, Fortran] Fix previous patch (was: Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules) Tobias Burnus
  0 siblings, 1 reply; 14+ messages in thread
From: Dominique d'Humières @ 2015-01-03 23:04 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: fortran, gcc-patches, fxcoudert

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>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Patch, Fortran] Fix previous patch (was: Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules)
  2015-01-03 23:04       ` Dominique d'Humières
@ 2015-01-04 18:58         ` Tobias Burnus
  2015-01-04 21:28           ` Dominique d'Humières
  2015-01-07 21:37           ` [Patch, Fortran] Fix previous patch Tobias Burnus
  0 siblings, 2 replies; 14+ messages in thread
From: Tobias Burnus @ 2015-01-04 18:58 UTC (permalink / raw)
  To: Dominique d'Humières; +Cc: fortran, gcc-patches, fxcoudert

[-- Attachment #1: Type: text/plain, Size: 1319 bytes --]

Attached is a regtested patch, which fixes the issue. Additionally, the 
variable visibility (TREE_PUBLIC) is now depending on the private 
attribute (copied from the module var generation) and I mark the tree as 
DECL_NONALIASED. The former I also did for proc-pointers, which is an 
unrelated patch.

Build and regtested on x86-64-gnu-linux.
OK for the trunk?


Dominique d'Humières wrote:
> 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);

Which shows that w/o compiling and testing, one (usually) cannot write 
patches. Solution is to move the declaration up in the file. However, it 
turned out that that's not sufficient: the pushdecl is required.

Tobias

>> 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>
>


[-- Attachment #2: caf.diff --]
[-- Type: text/x-patch, Size: 4482 bytes --]

2015-01-02  Tobias Burnus  <burnus@net-b.de>

        * trans-decl.c (gfc_build_qualified_array): Fix coarray tokens
        for module coarrays with -fcoarray=lib.
	(get_proc_pointer_decl): As module variable, make only public
	when not marked as private.

	* gfortran.dg/coarray/codimension_2b.f90: New file.
	* gfortran.dg/coarray/codimension_2.f90: Add it to dg-extra-sources.
	* gfortran.dg/coarray/codimension_2.f90: Call its subroutine.

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 9ef6bfc..dfc0f23 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -87,6 +87,8 @@ static gfc_namespace *module_namespace;
 /* The currently processed procedure symbol.  */
 static gfc_symbol* current_procedure_symbol = NULL;
 
+/* The currently processed module.  */
+static struct module_htab_entry *cur_module;
 
 /* With -fcoarray=lib: For generating the registering call
    of static coarrays.  */
@@ -830,15 +832,33 @@ 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)
+	{
+	  pushdecl (token);
+	  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 +1684,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;
     }
 
@@ -4326,8 +4348,6 @@ gfc_module_add_decl (struct module_htab_entry *entry, tree decl)
     *slot = decl;
 }
 
-static struct module_htab_entry *cur_module;
-
 
 /* Generate debugging symbols for namelists. This function must come after
    generate_local_decl to ensure that the variables in the namelist are
diff --git a/gcc/testsuite/gfortran.dg/coarray/codimension_2.f90 b/gcc/testsuite/gfortran.dg/coarray/codimension_2.f90
index b211f9b..45d3374 100644
--- a/gcc/testsuite/gfortran.dg/coarray/codimension_2.f90
+++ b/gcc/testsuite/gfortran.dg/coarray/codimension_2.f90
@@ -1,5 +1,5 @@
 ! { dg-do link }
-! { dg-additional-sources codimension_2a.f90 }
+! { dg-additional-sources "codimension_2a.f90 codimension_2b.f90" }
 !
 ! To be used with codimension_2a.f90
 ! Check that the coarray declared in the module is accessible
diff --git a/gcc/testsuite/gfortran.dg/coarray/codimension_2a.f90 b/gcc/testsuite/gfortran.dg/coarray/codimension_2a.f90
index 8eb472c..3dec4aa 100644
--- a/gcc/testsuite/gfortran.dg/coarray/codimension_2a.f90
+++ b/gcc/testsuite/gfortran.dg/coarray/codimension_2a.f90
@@ -11,6 +11,7 @@
 program testmod
   use global_coarrays
   implicit none
+  external ttest
   
   integer :: me
 
@@ -21,6 +22,8 @@ program testmod
   if(me==1) then
      b(:) = b(:)[2]
      write(*,*) b
+  elseif (me == 3) then
+     call ttest()
   end if
 
 end program testmod
diff --git a/gcc/testsuite/gfortran.dg/coarray/codimension_2b.f90 b/gcc/testsuite/gfortran.dg/coarray/codimension_2b.f90
new file mode 100644
index 0000000..c30d051
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray/codimension_2b.f90
@@ -0,0 +1,13 @@
+! { dg-do compile { target { ! *-*-* } } }
+! SKIP THIS FILE
+!
+! Used by codimension_2.f90
+!
+! Additional file to check that using the module doesn't generate
+! a token symbol. (The module is also used by codimension_2.f90.)
+!
+subroutine ttest
+  use global_coarrays
+  implicit none
+  b(:) = b(:)[2]
+end

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Patch, Fortran] Fix previous patch (was: Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules)
  2015-01-04 18:58         ` [Patch, Fortran] Fix previous patch (was: Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules) Tobias Burnus
@ 2015-01-04 21:28           ` Dominique d'Humières
  2015-01-07 21:37           ` [Patch, Fortran] Fix previous patch Tobias Burnus
  1 sibling, 0 replies; 14+ messages in thread
From: Dominique d'Humières @ 2015-01-04 21:28 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: fortran, gcc-patches, fxcoudert

Dear Tobias,

I have done a clean bootstrap with your patch and run

make -k check-gfortran RUNTESTFLAGS="caf.exp --target_board=unix'{-m32,-m64}’" 

without regression.

Thanks,

Dominique

> Le 4 janv. 2015 à 19:57, Tobias Burnus <burnus@net-b.de> a écrit :
> 
> Attached is a regtested patch, which fixes the issue. Additionally, the variable visibility (TREE_PUBLIC) is now depending on the private attribute (copied from the module var generation) and I mark the tree as DECL_NONALIASED. The former I also did for proc-pointers, which is an unrelated patch.
> 
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Patch, Fortran] Fix previous patch
  2015-01-04 18:58         ` [Patch, Fortran] Fix previous patch (was: Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules) Tobias Burnus
  2015-01-04 21:28           ` Dominique d'Humières
@ 2015-01-07 21:37           ` Tobias Burnus
       [not found]             ` <CAGkQGi+MJhuQCGyvVE-Qw9qZ6AcXBN1b62+Ky=adJO7iEKAxDA@mail.gmail.com>
  1 sibling, 1 reply; 14+ messages in thread
From: Tobias Burnus @ 2015-01-07 21:37 UTC (permalink / raw)
  To: Dominique d'Humières; +Cc: fortran, gcc-patches, fxcoudert

Early PING: https://gcc.gnu.org/ml/gcc-patches/2015-01/msg00090.html

Tobias Burnus wrote:
> Attached is a regtested patch, which fixes the issue. Additionally, 
> the variable visibility (TREE_PUBLIC) is now depending on the private 
> attribute (copied from the module var generation) and I mark the tree 
> as DECL_NONALIASED. The former I also did for proc-pointers, which is 
> an unrelated patch.
>
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?
>
>
> Dominique d'Humières wrote:
>> 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);
>
> Which shows that w/o compiling and testing, one (usually) cannot write 
> patches. Solution is to move the declaration up in the file. However, 
> it turned out that that's not sufficient: the pushdecl is required.
>
> Tobias
>
>>> 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>
>>
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Patch, Fortran] Fix previous patch
       [not found]             ` <CAGkQGi+MJhuQCGyvVE-Qw9qZ6AcXBN1b62+Ky=adJO7iEKAxDA@mail.gmail.com>
@ 2015-01-08 18:10               ` Tobias Burnus
  0 siblings, 0 replies; 14+ messages in thread
From: Tobias Burnus @ 2015-01-08 18:10 UTC (permalink / raw)
  To: Paul Richard Thomas
  Cc: Dominique d'Humières, fortran, gcc-patches, FX Coudert

Paul Richard Thomas wrote:
> It looks to me as if you had to do a fair amount of detective work 
> there! The patch is OK for trunk.

Thanks for the review - which didn't make it to mailing list for some 
reasons (text+HTML email?).

Committed as Rev. 219354

Tobias

> Thanks for your efforts
>
> Paul
>
> On 7 January 2015 at 22:37, Tobias Burnus <burnus@net-b.de 
> <mailto:burnus@net-b.de>> wrote:
>
>     Early PING: https://gcc.gnu.org/ml/gcc-patches/2015-01/msg00090.html
>
>     Tobias Burnus wrote:
>
>         Attached is a regtested patch, which fixes the issue.
>         Additionally, the variable visibility (TREE_PUBLIC) is now
>         depending on the private attribute (copied from the module var
>         generation) and I mark the tree as DECL_NONALIASED. The former
>         I also did for proc-pointers, which is an unrelated patch.
>
>         Build and regtested on x86-64-gnu-linux.
>         OK for the trunk?
>
>
>         Dominique d'Humières wrote:
>
>             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);
>
>
>         Which shows that w/o compiling and testing, one (usually)
>         cannot write patches. Solution is to move the declaration up
>         in the file. However, it turned out that that's not
>         sufficient: the pushdecl is required.
>
>         Tobias
>
>                 Le 3 janv. 2015 à 23:30, Tobias Burnus
>                 <burnus@net-b.de <mailto: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>
>
>
>
>
>
>
>
> -- 
> Outside of a dog, a book is a man's best friend. Inside of a dog it's 
> too dark to read.
>
> Groucho Marx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules
  2019-02-28 17:19 ` Thomas Schwinge
@ 2019-03-21 19:34   ` Thomas Schwinge
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas Schwinge @ 2019-03-21 19:34 UTC (permalink / raw)
  To: gcc-patches, fortran; +Cc: Jakub Jelinek, Tobias Burnus, FX, Mike Stump

[-- Attachment #1: Type: text/plain, Size: 3773 bytes --]

Hi!

On Thu, 28 Feb 2019 18:02:32 +0100, Thomas Schwinge <thomas@codesourcery.com> wrote:
> On Fri, 02 Jan 2015 12:28:10 +0100, Tobias Burnus <burnus@net-b.de> wrote:
> > [...]
> > 
> > I additionally propagated the dg-compile-aux-modules support to caf.dg 
> 
> That got committed in r219143:
> 
> > --- a/gcc/testsuite/gfortran.dg/coarray/caf.exp
> > +++ b/gcc/testsuite/gfortran.dg/coarray/caf.exp
> > @@ -43,6 +43,21 @@ global DG_TORTURE_OPTIONS torture_with_loops
> >  torture-init
> >  set-torture-options $DG_TORTURE_OPTIONS
> >  
> > +global gfortran_test_path
> > +global gfortran_aux_module_flags
> > +set gfortran_test_path $srcdir/$subdir
> > +set gfortran_aux_module_flags $DEFAULT_FFLAGS
> > +proc dg-compile-aux-modules { args } {
> > +    global gfortran_test_path
> > +    global gfortran_aux_module_flags
> > +    if { [llength $args] != 2 } {
> > +	error "dg-set-target-env-var: needs one argument"
> > +	return
> > +    }
> > +    dg-test $gfortran_test_path/[lindex $args 1] "" $gfortran_aux_module_flags
> > +    # cleanup-modules isn't intentionally invoked here.
> > +}
> 
> I just noticed that this copy is missing Jakub's r215293 changes that he
> had applied a few months *earlier* to the master copy of
> 'dg-compile-aux-modules', in 'gcc/testsuite/gfortran.dg/dg.exp', see
> attached, and/or
> <http://mid.mail-archive.com/20140916093700.GW17454@tucnak.redhat.com>.
> I can't easily test it with the affected DejaGnu version 1.4.4 (which is
> still the minimum version required now), but it tests fine with DejaGnu
> 1.5, and seems straight-forward, so I propose I commit "as obvious" these
> changes to the 'gcc/testsuite/gfortran.dg/coarray/caf.exp' copy, too?
> (It's exactly these changes missing to make the two copies identical.)

For testing GCC with a custom DejaGnu installation, you apparently just
have to put its installation directory into 'PATH'.

Testing with DejaGnu 1.4.4 (specifically, the 'dejagnu-1.4.4-release' Git
tag), one runs into:

    cannot trap SIGSEGV
        while executing
    "trap "send_error \"got a \[trap -name\] signal, $str \\n\"; log_and_exit;" $signal"
        ("foreach" body line 4)
        invoked from within
    "foreach sig "{SIGTERM {terminated}}  {SIGINT  {interrupted by user}}  {SIGQUIT {interrupted by user}}  {SIGSEGV {segmentation violation}}" {
            set sign..."
        invoked from within
    "if ![exp_debug] {
        foreach sig "{SIGTERM {terminated}} \
                 {SIGINT  {interrupted by user}} \
                 {SIGQUIT {interrupted by user}..."
        (file "[...]/share/dejagnu/runtest.exp" line 1503)

This is an incompatibility with "recent" versions of 'expect'; see
<https://bugs.debian.org/301557>, for example, and this is resolved by
DejaGnu commit 504776814fa56295c4cff40d78a1be446f851a7c.


With that resolved, no problems found -- that is, confirming that 15
years old DejaGnu version 1.4.4 still works fine for GCC testing (in my
configuration).


I convinced myself that my proposed changes are the right thing to do,
and committed "[testsuite, Fortran] Apply DejaGnu 1.4.4 work-around also
to 'gfortran.dg/coarray/caf.exp:dg-compile-aux-modules'" to trunk in
r269848, to gcc-8-branch in r269849, and to gcc-7-branch in r269850, see
attached.


> The other copy, created later, in
> 'gcc/testsuite/gcc.target/powerpc/ppc-fortran/ppc-fortran.exp' already
> does exactly match the master copy.
> 
> 
> And then, of course, we really should unify all 'dg-compile-aux-modules'
> copies into one shared file.  (But it's not completely straight-forward,
> because of the handling of 'gfortran_test_path', and
> 'gfortran_aux_module_flags'.)


Grüße
 Thomas



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-testsuite-Fortran-Apply-DejaGnu-1.4.4-work-aro.trunk.patch --]
[-- Type: text/x-diff, Size: 2214 bytes --]

From e78648a61e4e5fc60d400c2d2c89254aee4c0715 Mon Sep 17 00:00:00 2001
From: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 21 Mar 2019 19:16:29 +0000
Subject: [PATCH] [testsuite, Fortran] Apply DejaGnu 1.4.4 work-around also to
 'gfortran.dg/coarray/caf.exp:dg-compile-aux-modules'

See trunk r215293.  This unifies all 'dg-compile-aux-modules' instances.

	gcc/testsuite/
	PR fortran/56408
	* gfortran.dg/coarray/caf.exp (dg-compile-aux-modules): Workaround
	missing nexted dg-test call support in dejaGNU 1.4.4.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@269848 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/testsuite/ChangeLog                   |  4 ++++
 gcc/testsuite/gfortran.dg/coarray/caf.exp | 12 +++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 914ba7237033..40446965212e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
 2019-03-21  Thomas Schwinge  <thomas@codesourcery.com>
 
+	PR fortran/56408
+	* gfortran.dg/coarray/caf.exp (dg-compile-aux-modules): Workaround
+	missing nexted dg-test call support in dejaGNU 1.4.4.
+
 	PR fortran/29383
 	* gfortran.dg/ieee/ieee.exp (DEFAULT_FFLAGS): Set the same as in
 	other '*.exp' files.
diff --git a/gcc/testsuite/gfortran.dg/coarray/caf.exp b/gcc/testsuite/gfortran.dg/coarray/caf.exp
index 4c6dba1dc22b..e3204c34779b 100644
--- a/gcc/testsuite/gfortran.dg/coarray/caf.exp
+++ b/gcc/testsuite/gfortran.dg/coarray/caf.exp
@@ -54,8 +54,18 @@ proc dg-compile-aux-modules { args } {
 	error "dg-set-target-env-var: needs one argument"
 	return
     }
+
+    set level [info level]
+    if { [info procs dg-save-unknown] != [list] } {
+	rename dg-save-unknown dg-save-unknown-level-$level
+    }
+
     dg-test $gfortran_test_path/[lindex $args 1] "" $gfortran_aux_module_flags
-    # cleanup-modules isn't intentionally invoked here.
+    # cleanup-modules is intentionally not invoked here.
+
+    if { [info procs dg-save-unknown-level-$level] != [list] } {
+	rename dg-save-unknown-level-$level dg-save-unknown
+    }
 }
 
 # Add -latomic only where supported.  Assume built-in support elsewhere.
-- 
2.17.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-testsuite-Fortran-Apply-DejaGnu-1.4.4-w.gcc-8-branch.patch --]
[-- Type: text/x-diff, Size: 2245 bytes --]

From f0c23d90fc45bbfc1cf3cab52ddd3631b3a9be13 Mon Sep 17 00:00:00 2001
From: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 21 Mar 2019 19:16:54 +0000
Subject: [PATCH] [testsuite, Fortran] Apply DejaGnu 1.4.4 work-around also to
 'gfortran.dg/coarray/caf.exp:dg-compile-aux-modules'

See trunk r215293.  This unifies all 'dg-compile-aux-modules' instances.

	gcc/testsuite/
	PR fortran/56408
	* gfortran.dg/coarray/caf.exp (dg-compile-aux-modules): Workaround
	missing nexted dg-test call support in dejaGNU 1.4.4.

trunk r269848

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@269849 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/testsuite/ChangeLog                   |  4 ++++
 gcc/testsuite/gfortran.dg/coarray/caf.exp | 12 +++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9aa82da9a4aa..38982cf82f4b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
 2019-03-21  Thomas Schwinge  <thomas@codesourcery.com>
 
+	PR fortran/56408
+	* gfortran.dg/coarray/caf.exp (dg-compile-aux-modules): Workaround
+	missing nexted dg-test call support in dejaGNU 1.4.4.
+
 	PR fortran/29383
 	* gfortran.dg/ieee/ieee.exp (DEFAULT_FFLAGS): Set the same as in
 	other '*.exp' files.
diff --git a/gcc/testsuite/gfortran.dg/coarray/caf.exp b/gcc/testsuite/gfortran.dg/coarray/caf.exp
index d1a7a56970fc..f7f57f4477f1 100644
--- a/gcc/testsuite/gfortran.dg/coarray/caf.exp
+++ b/gcc/testsuite/gfortran.dg/coarray/caf.exp
@@ -54,8 +54,18 @@ proc dg-compile-aux-modules { args } {
 	error "dg-set-target-env-var: needs one argument"
 	return
     }
+
+    set level [info level]
+    if { [info procs dg-save-unknown] != [list] } {
+	rename dg-save-unknown dg-save-unknown-level-$level
+    }
+
     dg-test $gfortran_test_path/[lindex $args 1] "" $gfortran_aux_module_flags
-    # cleanup-modules isn't intentionally invoked here.
+    # cleanup-modules is intentionally not invoked here.
+
+    if { [info procs dg-save-unknown-level-$level] != [list] } {
+	rename dg-save-unknown-level-$level dg-save-unknown
+    }
 }
 
 # Add -latomic only where supported.  Assume built-in support elsewhere.
-- 
2.17.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0001-testsuite-Fortran-Apply-DejaGnu-1.4.4-w.gcc-7-branch.patch --]
[-- Type: text/x-diff, Size: 2245 bytes --]

From a6d1bc4242db77bd89a521e2a5260e6318c9c6ec Mon Sep 17 00:00:00 2001
From: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 21 Mar 2019 19:17:12 +0000
Subject: [PATCH] [testsuite, Fortran] Apply DejaGnu 1.4.4 work-around also to
 'gfortran.dg/coarray/caf.exp:dg-compile-aux-modules'

See trunk r215293.  This unifies all 'dg-compile-aux-modules' instances.

	gcc/testsuite/
	PR fortran/56408
	* gfortran.dg/coarray/caf.exp (dg-compile-aux-modules): Workaround
	missing nexted dg-test call support in dejaGNU 1.4.4.

trunk r269848

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@269850 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/testsuite/ChangeLog                   |  4 ++++
 gcc/testsuite/gfortran.dg/coarray/caf.exp | 12 +++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ca849083d7f4..5e6c1971413f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
 2019-03-21  Thomas Schwinge  <thomas@codesourcery.com>
 
+	PR fortran/56408
+	* gfortran.dg/coarray/caf.exp (dg-compile-aux-modules): Workaround
+	missing nexted dg-test call support in dejaGNU 1.4.4.
+
 	PR fortran/29383
 	* gfortran.dg/ieee/ieee.exp (DEFAULT_FFLAGS): Set the same as in
 	other '*.exp' files.
diff --git a/gcc/testsuite/gfortran.dg/coarray/caf.exp b/gcc/testsuite/gfortran.dg/coarray/caf.exp
index edac7dc981f0..be5cf27935e6 100644
--- a/gcc/testsuite/gfortran.dg/coarray/caf.exp
+++ b/gcc/testsuite/gfortran.dg/coarray/caf.exp
@@ -54,8 +54,18 @@ proc dg-compile-aux-modules { args } {
 	error "dg-set-target-env-var: needs one argument"
 	return
     }
+
+    set level [info level]
+    if { [info procs dg-save-unknown] != [list] } {
+	rename dg-save-unknown dg-save-unknown-level-$level
+    }
+
     dg-test $gfortran_test_path/[lindex $args 1] "" $gfortran_aux_module_flags
-    # cleanup-modules isn't intentionally invoked here.
+    # cleanup-modules is intentionally not invoked here.
+
+    if { [info procs dg-save-unknown-level-$level] != [list] } {
+	rename dg-save-unknown-level-$level dg-save-unknown
+    }
 }
 
 # Add -latomic only where supported.  Assume built-in support elsewhere.
-- 
2.17.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules
  2015-01-02 11:28 [Patch, Fortran + Testsuite] Fix coarray handling in modules Tobias Burnus
  2015-01-02 13:14 ` FX
  2015-01-02 20:47 ` Mike Stump
@ 2019-02-28 17:19 ` Thomas Schwinge
  2019-03-21 19:34   ` Thomas Schwinge
  2 siblings, 1 reply; 14+ messages in thread
From: Thomas Schwinge @ 2019-02-28 17:19 UTC (permalink / raw)
  To: Jakub Jelinek, Tobias Burnus, gcc-patches, gfortran, FX, Mike Stump


[-- Attachment #1.1: Type: text/plain, Size: 2055 bytes --]

Hi!

On Fri, 02 Jan 2015 12:28:10 +0100, Tobias Burnus <burnus@net-b.de> wrote:
> [...]
> 
> I additionally propagated the dg-compile-aux-modules support to caf.dg 

That got committed in r219143:

> --- a/gcc/testsuite/gfortran.dg/coarray/caf.exp
> +++ b/gcc/testsuite/gfortran.dg/coarray/caf.exp
> @@ -43,6 +43,21 @@ global DG_TORTURE_OPTIONS torture_with_loops
>  torture-init
>  set-torture-options $DG_TORTURE_OPTIONS
>  
> +global gfortran_test_path
> +global gfortran_aux_module_flags
> +set gfortran_test_path $srcdir/$subdir
> +set gfortran_aux_module_flags $DEFAULT_FFLAGS
> +proc dg-compile-aux-modules { args } {
> +    global gfortran_test_path
> +    global gfortran_aux_module_flags
> +    if { [llength $args] != 2 } {
> +	error "dg-set-target-env-var: needs one argument"
> +	return
> +    }
> +    dg-test $gfortran_test_path/[lindex $args 1] "" $gfortran_aux_module_flags
> +    # cleanup-modules isn't intentionally invoked here.
> +}

I just noticed that this copy is missing Jakub's r215293 changes that he
had applied a few months *earlier* to the master copy of
'dg-compile-aux-modules', in 'gcc/testsuite/gfortran.dg/dg.exp', see
attached, and/or
<http://mid.mail-archive.com/20140916093700.GW17454@tucnak.redhat.com>.
I can't easily test it with the affected DejaGnu version 1.4.4 (which is
still the minimum version required now), but it tests fine with DejaGnu
1.5, and seems straight-forward, so I propose I commit "as obvious" these
changes to the 'gcc/testsuite/gfortran.dg/coarray/caf.exp' copy, too?
(It's exactly these changes missing to make the two copies identical.)


The other copy, created later, in
'gcc/testsuite/gcc.target/powerpc/ppc-fortran/ppc-fortran.exp' already
does exactly match the master copy.


And then, of course, we really should unify all 'dg-compile-aux-modules'
copies into one shared file.  (But it's not completely straight-forward,
because of the handling of 'gfortran_test_path', and
'gfortran_aux_module_flags'.)


Grüße
 Thomas



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-PR-fortran-56408.patch --]
[-- Type: text/x-diff, Size: 1892 bytes --]

From 6278a9a2afb7d4d730c585f93d2bd435ed63f963 Mon Sep 17 00:00:00 2001
From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 16 Sep 2014 09:35:00 +0000
Subject: [PATCH] 	PR fortran/56408 	* gfortran.dg/dg.exp
 (dg-compile-aux-modules): Workaround 	missing nexted dg-test call support in
 dejaGNU 1.4.4.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@215293 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/testsuite/ChangeLog          |  6 ++++++
 gcc/testsuite/gfortran.dg/dg.exp | 12 +++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fdb706a8d8dd..4d3c96beee2c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2014-09-16  Jakub Jelinek  <jakub@redhat.com>
+
+	PR fortran/56408
+	* gfortran.dg/dg.exp (dg-compile-aux-modules): Workaround
+	missing nexted dg-test call support in dejaGNU 1.4.4.
+
 2014-09-15  Andi Kleen  <ak@linux.intel.com>
 
 	* gcc.dg/pg-override.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/dg.exp b/gcc/testsuite/gfortran.dg/dg.exp
index e8c39231db00..6bd69e6c88d0 100644
--- a/gcc/testsuite/gfortran.dg/dg.exp
+++ b/gcc/testsuite/gfortran.dg/dg.exp
@@ -39,8 +39,18 @@ proc dg-compile-aux-modules { args } {
 	error "dg-set-target-env-var: needs one argument"
 	return
     }
+
+    set level [info level]
+    if { [info procs dg-save-unknown] != [list] } {
+	rename dg-save-unknown dg-save-unknown-level-$level
+    }
+
     dg-test $gfortran_test_path/[lindex $args 1] "" $gfortran_aux_module_flags
-    # cleanup-modules isn't intentionally invoked here.
+    # cleanup-modules is intentionally not invoked here.
+
+    if { [info procs dg-save-unknown-level-$level] != [list] } {
+	rename dg-save-unknown-level-$level dg-save-unknown
+    }
 }
 
 # Main loop.
-- 
2.17.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 658 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules
  2015-01-02 11:28 [Patch, Fortran + Testsuite] Fix coarray handling in modules Tobias Burnus
  2015-01-02 13:14 ` FX
@ 2015-01-02 20:47 ` Mike Stump
  2019-02-28 17:19 ` Thomas Schwinge
  2 siblings, 0 replies; 14+ messages in thread
From: Mike Stump @ 2015-01-02 20:47 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc-patches, gfortran, Alessandro Fanfarillo

On Jan 2, 2015, at 3:28 AM, Tobias Burnus <burnus@net-b.de> wrote:
> As found by Alessandro: Statically allocated coarrays in declared in the specification part of a module didn't work (link-time failure). The reason was that the associated coarray token was wrongly mangled and not a public tree.
> 
> I additionally propagated the dg-compile-aux-modules support to caf.dg (currently unused).

> OK for the trunk?

So, I usually let the fortran people review and comment on things like this.  They do a great job and seems pretty straight forward.

I looked at it and didn’t see anything that was objectionable to me.  Seems usual and customary.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules
  2015-01-02 11:28 [Patch, Fortran + Testsuite] Fix coarray handling in modules Tobias Burnus
@ 2015-01-02 13:14 ` FX
  2015-01-02 20:47 ` Mike Stump
  2019-02-28 17:19 ` Thomas Schwinge
  2 siblings, 0 replies; 14+ messages in thread
From: FX @ 2015-01-02 13:14 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc-patches, gfortran, Alessandro Fanfarillo, Mike Stump

> As found by Alessandro: Statically allocated coarrays in declared in the specification part of a module didn't work (link-time failure). The reason was that the associated coarray token was wrongly mangled and not a public tree.
> 
> I additionally propagated the dg-compile-aux-modules support to caf.dg (currently unused).

OK. It’s probably best to commit the two parts as separate commits, though.

FX

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Patch, Fortran + Testsuite] Fix coarray handling in modules
@ 2015-01-02 11:28 Tobias Burnus
  2015-01-02 13:14 ` FX
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Tobias Burnus @ 2015-01-02 11:28 UTC (permalink / raw)
  To: gcc-patches, gfortran, Alessandro Fanfarillo, Mike Stump

[-- Attachment #1: Type: text/plain, Size: 388 bytes --]

As found by Alessandro: Statically allocated coarrays in declared in the 
specification part of a module didn't work (link-time failure). The 
reason was that the associated coarray token was wrongly mangled and not 
a public tree.

I additionally propagated the dg-compile-aux-modules support to caf.dg 
(currently unused).

That's fixed by the attached patch.
OK for the trunk?

Tobias

[-- Attachment #2: caf.diff --]
[-- Type: text/x-patch, Size: 6689 bytes --]

2015-01-02  Tobias Burnus  <burnus@net-b.de>

	* trans-decl.c (gfc_build_qualified_array): Fix coarray tokens
	for module coarrays with -fcoarray=lib.

2015-01-02  Tobias Burnus  <burnus@net-b.de>

	* gfortran.dg/coarray/caf.exp (dg-compile-aux-modules): Add.
	* gfortran.dg/coarray/codimension_2.f90: New.
	* gfortran.dg/coarray/codimension_2a.f90: New.
	* gfortran.dg/coarray_35.f90: New.
	* gfortran.dg/coarray_35a.f90: New.

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 75b84f1..9ef6bfc 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -819,10 +819,22 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
       && GFC_TYPE_ARRAY_CAF_TOKEN (type) == NULL_TREE)
     {
       tree token;
+      tree token_type = build_qualified_type (pvoid_type_node,
+					      TYPE_QUAL_RESTRICT);
+
+      if (sym->module && (sym->attr.use_assoc
+			  || sym->ns->proc_name->attr.flavor == FL_MODULE))
+	{
+	  tree token_name
+		= get_identifier (gfc_get_string (GFC_PREFIX ("caf_token%s"),
+			IDENTIFIER_POINTER (gfc_sym_mangled_identifier (sym))));
+	  token = build_decl (DECL_SOURCE_LOCATION (decl), VAR_DECL, token_name,
+			      token_type);
+	  TREE_PUBLIC (token) = 1;
+	}
+      else
+	token = gfc_create_var_np (token_type, "caf_token");
 
-      token = gfc_create_var_np (build_qualified_type (pvoid_type_node,
-						       TYPE_QUAL_RESTRICT),
-				 "caf_token");
       GFC_TYPE_ARRAY_CAF_TOKEN (type) = token;
       DECL_ARTIFICIAL (token) = 1;
       TREE_STATIC (token) = 1;
diff --git a/gcc/testsuite/gfortran.dg/coarray/caf.exp b/gcc/testsuite/gfortran.dg/coarray/caf.exp
index 011b5c9..e4e3798 100644
--- a/gcc/testsuite/gfortran.dg/coarray/caf.exp
+++ b/gcc/testsuite/gfortran.dg/coarray/caf.exp
@@ -43,6 +43,21 @@ global DG_TORTURE_OPTIONS torture_with_loops
 torture-init
 set-torture-options $DG_TORTURE_OPTIONS
 
+global gfortran_test_path
+global gfortran_aux_module_flags
+set gfortran_test_path $srcdir/$subdir
+set gfortran_aux_module_flags $DEFAULT_FFLAGS
+proc dg-compile-aux-modules { args } {
+    global gfortran_test_path
+    global gfortran_aux_module_flags
+    if { [llength $args] != 2 } {
+	error "dg-set-target-env-var: needs one argument"
+	return
+    }
+    dg-test $gfortran_test_path/[lindex $args 1] "" $gfortran_aux_module_flags
+    # cleanup-modules isn't intentionally invoked here.
+}
+
 # Main loop.
 foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ]] {
     # If we're only testing specific files and this isn't one of them, skip it.
@@ -65,12 +80,14 @@ foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ]]
 
     foreach flags $option_list {
 	verbose "Testing $nshort (single), $flags" 1
+        set gfortran_aux_module_flags "-fcoarray=single $flags"
 	dg-test $test "-fcoarray=single $flags" "" 
 	cleanup-modules ""
     }
 
     foreach flags $option_list {
 	verbose "Testing $nshort (libcaf_single), $flags" 1
+        set gfortran_aux_module_flags "-fcoarray=lib $flags -lcaf_single"
 	dg-test $test "-fcoarray=lib $flags -lcaf_single" ""
 	cleanup-modules ""
     }
diff --git a/gcc/testsuite/gfortran.dg/coarray/codimension_2.f90 b/gcc/testsuite/gfortran.dg/coarray/codimension_2.f90
new file mode 100644
index 0000000..b211f9b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray/codimension_2.f90
@@ -0,0 +1,14 @@
+! { dg-do link }
+! { dg-additional-sources codimension_2a.f90 }
+!
+! To be used with codimension_2a.f90
+! Check that the coarray declared in the module is accessible
+! by doing a link test
+!
+! Contributed by Alessandro Fanfarillo.
+!
+module global_coarrays
+  implicit none
+  integer,parameter :: n=10
+  integer :: b(10)[*]
+end module global_coarrays
diff --git a/gcc/testsuite/gfortran.dg/coarray/codimension_2a.f90 b/gcc/testsuite/gfortran.dg/coarray/codimension_2a.f90
new file mode 100644
index 0000000..8eb472c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray/codimension_2a.f90
@@ -0,0 +1,26 @@
+! { dg-do compile { target { ! *-*-* } } }
+! SKIP THIS FILE
+!
+! Used by codimension_2.f90
+!
+! Check that the coarray declared in the module is accessible
+! by doing a link test
+!
+! Contributed by Alessandro Fanfarillo.
+!
+program testmod
+  use global_coarrays
+  implicit none
+  
+  integer :: me
+
+  me = this_image()
+
+  b = me
+
+  if(me==1) then
+     b(:) = b(:)[2]
+     write(*,*) b
+  end if
+
+end program testmod
diff --git a/gcc/testsuite/gfortran.dg/coarray/collectives_4.f90 b/gcc/testsuite/gfortran.dg/coarray/collectives_4.f90
new file mode 100644
index 0000000..6e7be46
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray/collectives_4.f90
@@ -0,0 +1,24 @@
+! { dg-do run }
+!
+! CO_REDUCE
+!
+implicit none (type, external)
+intrinsic :: co_reduce
+integer :: stat
+integer :: i4, i4_2, i
+
+i4 = 21 * this_image()
+i4_2 = 21
+do i = 2, num_images()
+  i4_2 = i4_2 * 21 * i
+end do
+call co_reduce(i4, op_i4, stat=stat)
+if (stat /= 0) call abort()
+if (i4_2 /= i4) call abort()
+
+contains
+  pure integer function op_i4(a,b)
+    integer, value :: a, b
+    op_i4 = a * b
+  end function op_i4
+end
diff --git a/gcc/testsuite/gfortran.dg/coarray_35.f90 b/gcc/testsuite/gfortran.dg/coarray_35.f90
new file mode 100644
index 0000000..e65f8fe
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_35.f90
@@ -0,0 +1,17 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib" }
+!
+! To be used with coarray_35a.f90
+! Check that the coarray declared in the module is accessible
+! by checking the assembler name
+!
+! Contributed by Alessandro Fanfarillo.
+!
+module global_coarrays
+  implicit none
+  integer,parameter :: n=10
+  integer :: b(10)[*]
+end module global_coarrays
+
+! Check for the symbol of the coarray token (w/o system-dependend prefix)
+! { dg-final { scan-assembler "caf_token__global_coarrays_MOD_b" } }
diff --git a/gcc/testsuite/gfortran.dg/coarray_35a.f90 b/gcc/testsuite/gfortran.dg/coarray_35a.f90
new file mode 100644
index 0000000..eeeb289
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_35a.f90
@@ -0,0 +1,28 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib" }
+! { dg-compile-aux-modules "coarray_35.f90" }
+!
+! Check that the coarray declared in the module is accessible
+! by checking the assembler name
+!
+! Contributed by Alessandro Fanfarillo.
+!
+program testmod
+  use global_coarrays
+  implicit none
+  
+  integer :: me
+
+  me = this_image()
+
+  b = me
+
+  if(me==1) then
+     b(:) = b(:)[2]
+     write(*,*) b
+  end if
+
+end program testmod
+
+! Check for the symbol of the coarray token (w/o system-dependend prefix)
+! { dg-final { scan-assembler "caf_token__global_coarrays_MOD_b" } }

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-03-21 19:27 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-03 10:22 [Patch, Fortran + Testsuite] Fix coarray handling in modules Dominique Dhumieres
2015-01-03 20:50 ` Tobias Burnus
2015-01-03 21:48   ` Dominique d'Humières
2015-01-03 22:30     ` Tobias Burnus
2015-01-03 23:04       ` Dominique d'Humières
2015-01-04 18:58         ` [Patch, Fortran] Fix previous patch (was: Re: [Patch, Fortran + Testsuite] Fix coarray handling in modules) Tobias Burnus
2015-01-04 21:28           ` Dominique d'Humières
2015-01-07 21:37           ` [Patch, Fortran] Fix previous patch Tobias Burnus
     [not found]             ` <CAGkQGi+MJhuQCGyvVE-Qw9qZ6AcXBN1b62+Ky=adJO7iEKAxDA@mail.gmail.com>
2015-01-08 18:10               ` Tobias Burnus
  -- strict thread matches above, loose matches on Subject: below --
2015-01-02 11:28 [Patch, Fortran + Testsuite] Fix coarray handling in modules Tobias Burnus
2015-01-02 13:14 ` FX
2015-01-02 20:47 ` Mike Stump
2019-02-28 17:19 ` Thomas Schwinge
2019-03-21 19:34   ` Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).