diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2020-06-03 12:28:25 +0200 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2020-06-03 12:30:04 +0200 |
commit | 93535a2b40367e6f68433295b37dc52c0e9c2c55 (patch) | |
tree | 3fd7c1567794717f5f0e8b88717e9106ab8748dd /gcc/fortran | |
parent | dda71670514e88dcd9b913c44c0ee64d8c3d6da9 (diff) | |
download | gcc-93535a2b40367e6f68433295b37dc52c0e9c2c55.zip gcc-93535a2b40367e6f68433295b37dc52c0e9c2c55.tar.gz gcc-93535a2b40367e6f68433295b37dc52c0e9c2c55.tar.bz2 |
[OpenMP] Fix mapping of artificial variables (PR94874)
gcc/c-family/ChangeLog:
* c-common.h (c_omp_predetermined_mapping): Declare.
* c-omp.c (c_omp_predetermined_mapping): New.
gcc/c/ChangeLog:
* c-objc-common.h (LANG_HOOKS_OMP_PREDETERMINED_MAPPING): Redefine.
gcc/cp/ChangeLog:
* cp-gimplify.c (cxx_omp_predetermined_mapping): New.
* cp-objcp-common.h (LANG_HOOKS_OMP_PREDETERMINED_MAPPING): Redfine.
* cp-tree.h (cxx_omp_predetermined_mapping): Declare.
gcc/fortran/ChangeLog:
* f95-lang.c (LANG_HOOKS_OMP_PREDETERMINED_MAPPING): Redefine.
* trans-openmp.c (gfc_omp_predetermined_mapping): New.
* trans.h (gfc_omp_predetermined_mapping): Declare.
gcc/ChangeLog:
* gimplify.c (omp_notice_variable): Use new hook.
* langhooks-def.h (lhd_omp_predetermined_mapping): Declare.
(LANG_HOOKS_OMP_PREDETERMINED_MAPPING): Define
(LANG_HOOKS_DECLS): Add it.
* langhooks.c (lhd_omp_predetermined_sharing): Remove bogus unused attr.
(lhd_omp_predetermined_mapping): New.
* langhooks.h (struct lang_hooks_for_decls): Add new hook.
gcc/testsuite/ChangeLog
2020-06-03 Thomas Schwinge <thomas@codesourcery.com>
Tobias Burnus <tobias@codesourcery.com>
PR middle-end/94874
* c-c++-common/gomp/pr94874.c: New.
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/f95-lang.c | 2 | ||||
-rw-r--r-- | gcc/fortran/trans-openmp.c | 25 | ||||
-rw-r--r-- | gcc/fortran/trans.h | 1 |
3 files changed, 27 insertions, 1 deletions
diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c index 44ebe3e..da8c35f 100644 --- a/gcc/fortran/f95-lang.c +++ b/gcc/fortran/f95-lang.c @@ -118,6 +118,7 @@ static const struct attribute_spec gfc_attribute_table[] = #undef LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT #undef LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE #undef LANG_HOOKS_OMP_PREDETERMINED_SHARING +#undef LANG_HOOKS_OMP_PREDETERMINED_MAPPING #undef LANG_HOOKS_OMP_REPORT_DECL #undef LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR #undef LANG_HOOKS_OMP_CLAUSE_COPY_CTOR @@ -153,6 +154,7 @@ static const struct attribute_spec gfc_attribute_table[] = #define LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT gfc_omp_check_optional_argument #define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE gfc_omp_privatize_by_reference #define LANG_HOOKS_OMP_PREDETERMINED_SHARING gfc_omp_predetermined_sharing +#define LANG_HOOKS_OMP_PREDETERMINED_MAPPING gfc_omp_predetermined_mapping #define LANG_HOOKS_OMP_REPORT_DECL gfc_omp_report_decl #define LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR gfc_omp_clause_default_ctor #define LANG_HOOKS_OMP_CLAUSE_COPY_CTOR gfc_omp_clause_copy_ctor diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index e27ce41..7e2f625 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -207,7 +207,8 @@ gfc_omp_privatize_by_reference (const_tree decl) return false; } -/* True if OpenMP sharing attribute of DECL is predetermined. */ +/* OMP_CLAUSE_DEFAULT_UNSPECIFIED unless OpenMP sharing attribute + of DECL is predetermined. */ enum omp_clause_default_kind gfc_omp_predetermined_sharing (tree decl) @@ -278,6 +279,28 @@ gfc_omp_predetermined_sharing (tree decl) return OMP_CLAUSE_DEFAULT_UNSPECIFIED; } + +/* OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED unless OpenMP mapping attribute + of DECL is predetermined. */ + +enum omp_clause_defaultmap_kind +gfc_omp_predetermined_mapping (tree decl) +{ + if (DECL_ARTIFICIAL (decl) + && ! GFC_DECL_RESULT (decl) + && ! (DECL_LANG_SPECIFIC (decl) + && GFC_DECL_SAVED_DESCRIPTOR (decl))) + return OMP_CLAUSE_DEFAULTMAP_TO; + + /* These are either array or derived parameters, or vtables. */ + if (VAR_P (decl) && TREE_READONLY (decl) + && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) + return OMP_CLAUSE_DEFAULTMAP_TO; + + return OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED; +} + + /* Return decl that should be used when reporting DEFAULT(NONE) diagnostics. */ diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h index bd96cdf..e126fe9 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h @@ -803,6 +803,7 @@ tree gfc_omp_check_optional_argument (tree, bool); tree gfc_omp_array_data (tree, bool); bool gfc_omp_privatize_by_reference (const_tree); enum omp_clause_default_kind gfc_omp_predetermined_sharing (tree); +enum omp_clause_defaultmap_kind gfc_omp_predetermined_mapping (tree); tree gfc_omp_report_decl (tree); tree gfc_omp_clause_default_ctor (tree, tree, tree); tree gfc_omp_clause_copy_ctor (tree, tree, tree); |