diff options
author | Tobias Burnus <burnus@net-b.de> | 2015-04-10 14:03:35 +0200 |
---|---|---|
committer | Mikael Morin <mikael@gcc.gnu.org> | 2015-04-10 12:03:35 +0000 |
commit | 9f3880d1ecf46a2a1a5bd27a8d2bc4104a9bdd74 (patch) | |
tree | 4b0b922eb75c016e5b0c6256c024a7e35a063e14 /gcc/fortran/trans.c | |
parent | 44c57c2f9049c9fa53817b71110cf0cee00675b6 (diff) | |
download | gcc-9f3880d1ecf46a2a1a5bd27a8d2bc4104a9bdd74.zip gcc-9f3880d1ecf46a2a1a5bd27a8d2bc4104a9bdd74.tar.gz gcc-9f3880d1ecf46a2a1a5bd27a8d2bc4104a9bdd74.tar.bz2 |
trans-stmt.c (gfc_trans_lock_unlock): Implement -fcoarray=lib version; reject not-yet-implemented variants.
2015-04-10 Tobias Burnus <burnus@net-b.de>
gcc/fortran/
* trans-stmt.c (gfc_trans_lock_unlock): Implement -fcoarray=lib
version; reject not-yet-implemented variants.
* trans-types.c (gfc_get_derived_type): For lock_type with
-fcoarray=lib, use a void pointer as type.
* trans.c (gfc_allocate_using_lib, gfc_allocate_allocatable):
Handle lock_type with -fcoarray=lib.
gcc/testsuite/
* gfortran.dg/coarray_lock_6.f90: New.
* gfortran.dg/coarray_lock_7.f90: New.
* gfortran.dg/coarray/lock_2.f90: New.
From-SVN: r221973
Diffstat (limited to 'gcc/fortran/trans.c')
-rw-r--r-- | gcc/fortran/trans.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index b7ec0e5..549e921 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -700,7 +700,8 @@ gfc_allocate_using_malloc (stmtblock_t * block, tree pointer, } */ static void gfc_allocate_using_lib (stmtblock_t * block, tree pointer, tree size, - tree token, tree status, tree errmsg, tree errlen) + tree token, tree status, tree errmsg, tree errlen, + bool lock_var) { tree tmp, pstat; @@ -730,7 +731,8 @@ gfc_allocate_using_lib (stmtblock_t * block, tree pointer, tree size, MAX_EXPR, size_type_node, size, build_int_cst (size_type_node, 1)), build_int_cst (integer_type_node, - GFC_CAF_COARRAY_ALLOC), + lock_var ? GFC_CAF_LOCK_ALLOC + : GFC_CAF_COARRAY_ALLOC), token, pstat, errmsg, errlen); tmp = fold_build2_loc (input_location, MODIFY_EXPR, @@ -787,9 +789,22 @@ gfc_allocate_allocatable (stmtblock_t * block, tree mem, tree size, tree token, && gfc_expr_attr (expr).codimension) { tree cond; + bool lock_var = expr->ts.type == BT_DERIVED + && expr->ts.u.derived->from_intmod + == INTMOD_ISO_FORTRAN_ENV + && expr->ts.u.derived->intmod_sym_id + == ISOFORTRAN_LOCK_TYPE; + /* In the front end, we represent the lock variable as pointer. However, + the FE only passes the pointer around and leaves the actual + representation to the library. Hence, we have to convert back to the + number of elements. */ + if (lock_var) + size = fold_build2_loc (input_location, TRUNC_DIV_EXPR, size_type_node, + size, TYPE_SIZE_UNIT (ptr_type_node)); gfc_allocate_using_lib (&alloc_block, mem, size, token, status, - errmsg, errlen); + errmsg, errlen, lock_var); + if (status != NULL_TREE) { TREE_USED (label_finish) = 1; |