diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2019-12-05 15:18:39 +0000 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2019-12-05 16:18:39 +0100 |
commit | c3cb71ef35522f46afa6f11ee376cdcb73b893e8 (patch) | |
tree | 00586bccd3b51836b13802be9977e0024a9a7476 /gcc/fortran/trans-openmp.c | |
parent | 705f02b0ca8e625c4f513a66efe28b403c796c22 (diff) | |
download | gcc-c3cb71ef35522f46afa6f11ee376cdcb73b893e8.zip gcc-c3cb71ef35522f46afa6f11ee376cdcb73b893e8.tar.gz gcc-c3cb71ef35522f46afa6f11ee376cdcb73b893e8.tar.bz2 |
OpenMP] Fix use_device_… with absent optional arg
gcc/fortran/
* trans-openmp.c (gfc_omp_is_optional_argument,
gfc_omp_check_optional_argument): Handle type(c_ptr),value which uses a
hidden argument for the is-present check.
gcc/
* omp-low.c (lower_omp_target): For use_device_ptr/use_derice_addr
and Fortran's optional arguments, unconditionally add the is-present
condition before the libgomp call.
libgomp/
* testsuite/libgomp.fortran/use_device_ptr-optional-2.f90: Add
'type(c_ptr), value' test case. Conditionally map the per-value
passed arguments.
From-SVN: r279004
Diffstat (limited to 'gcc/fortran/trans-openmp.c')
-rw-r--r-- | gcc/fortran/trans-openmp.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 3a4f962..2f9456d 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -60,7 +60,8 @@ gfc_omp_is_allocatable_or_ptr (const_tree decl) /* True if the argument is an optional argument; except that false is also returned for arguments with the value attribute (nonpointers) and for - assumed-shape variables (decl is a local variable containing arg->data). */ + assumed-shape variables (decl is a local variable containing arg->data). + Note that pvoid_type_node is for 'type(c_ptr), value. */ static bool gfc_omp_is_optional_argument (const_tree decl) @@ -68,6 +69,7 @@ gfc_omp_is_optional_argument (const_tree decl) return (TREE_CODE (decl) == PARM_DECL && DECL_LANG_SPECIFIC (decl) && TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE + && !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl))) && GFC_DECL_OPTIONAL_ARGUMENT (decl)); } @@ -99,9 +101,12 @@ gfc_omp_check_optional_argument (tree decl, bool for_present_check) || !GFC_DECL_OPTIONAL_ARGUMENT (decl)) return NULL_TREE; - /* For VALUE, the scalar variable is passed as is but a hidden argument - denotes the value. Cf. trans-expr.c. */ - if (TREE_CODE (TREE_TYPE (decl)) != POINTER_TYPE) + /* Scalars with VALUE attribute which are passed by value use a hidden + argument to denote the present status. They are passed as nonpointer type + with one exception: 'type(c_ptr), value' as 'void*'. */ + /* Cf. trans-expr.c's gfc_conv_expr_present. */ + if (TREE_CODE (TREE_TYPE (decl)) != POINTER_TYPE + || VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl)))) { char name[GFC_MAX_SYMBOL_LEN + 2]; tree tree_name; |