From: Tobias Burnus Date: Thu, 8 Jan 2015 18:09:25 +0000 (+0100) Subject: trans-decl.c (gfc_build_qualified_array): Fix coarray tokens for module coarrays... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=de1184c0def2fe0bafc8dd4988f7b80df7a96147;p=gcc.git trans-decl.c (gfc_build_qualified_array): Fix coarray tokens for module coarrays with -fcoarray=lib. 2015-01-08 Tobias Burnus * 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. From-SVN: r219354 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 952d96f4f85..3f10004979c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2015-01-08 Tobias Burnus + + * 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. + 2015-01-05 Thomas Koenig PR fortran/47674 diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index e409310a7dd..43441fe2d71 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/ChangeLog b/gcc/testsuite/ChangeLog index e2112fff3ea..5812067bc76 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-01-08 Tobias Burnus + + * 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. + 2015-01-08 Paolo Carlini PR c++/59004 diff --git a/gcc/testsuite/gfortran.dg/coarray/codimension_2.f90 b/gcc/testsuite/gfortran.dg/coarray/codimension_2.f90 index b211f9b2448..45d3374e606 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 8eb472c6358..3dec4aa9f26 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 00000000000..c30d051a701 --- /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