diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-05-11 09:42:50 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2018-05-11 09:42:50 +0200 |
commit | 1c9ee609dffac3f7d59ac9b8ca725d3cb9769b61 (patch) | |
tree | e7db792cd4f69d5d1a77de3bd61c59c065d8b2c7 /gcc | |
parent | 5a599c460e3846df80aaabd2b4629544337167ba (diff) | |
download | gcc-1c9ee609dffac3f7d59ac9b8ca725d3cb9769b61.zip gcc-1c9ee609dffac3f7d59ac9b8ca725d3cb9769b61.tar.gz gcc-1c9ee609dffac3f7d59ac9b8ca725d3cb9769b61.tar.bz2 |
re PR c/85696 (OpenMP with variably modified and default(none) won't compile)
PR c/85696
* c-omp.c (c_omp_predetermined_sharing): Return
OMP_CLAUSE_DEFAULT_SHARED for artificial vars with integral type.
* cp-tree.h (cxx_omp_predetermined_sharing_1): New prototype.
* cp-gimplify.c (cxx_omp_predetermined_sharing): New wrapper around
cxx_omp_predetermined_sharing_1. Rename old function to ...
(cxx_omp_predetermined_sharing_1): ... this.
* semantics.c (finish_omp_clauses): Use cxx_omp_predetermined_sharing_1
instead of cxx_omp_predetermined_sharing.
* c-c++-common/gomp/pr85696.c: New test.
From-SVN: r260156
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-family/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/c-omp.c | 8 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/cp-gimplify.c | 28 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/pr85696.c | 20 |
8 files changed, 78 insertions, 2 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index d2fba2f..c38d5ec 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2018-05-11 Jakub Jelinek <jakub@redhat.com> + + PR c/85696 + * c-omp.c (c_omp_predetermined_sharing): Return + OMP_CLAUSE_DEFAULT_SHARED for artificial vars with integral type. + 2018-05-11 Martin Liska <mliska@suse.cz> PR sanitizer/85556 diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index a076e3c..d8695f5 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -1611,5 +1611,13 @@ c_omp_predetermined_sharing (tree decl) if (TREE_READONLY (decl)) return OMP_CLAUSE_DEFAULT_SHARED; + /* Predetermine artificial variables holding integral values, those + are usually result of gimplify_one_sizepos or SAVE_EXPR + gimplification. */ + if (VAR_P (decl) + && DECL_ARTIFICIAL (decl) + && INTEGRAL_TYPE_P (TREE_TYPE (decl))) + return OMP_CLAUSE_DEFAULT_SHARED; + return OMP_CLAUSE_DEFAULT_UNSPECIFIED; } diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 920bed4..08cd81f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2018-05-11 Jakub Jelinek <jakub@redhat.com> + + PR c/85696 + * cp-tree.h (cxx_omp_predetermined_sharing_1): New prototype. + * cp-gimplify.c (cxx_omp_predetermined_sharing): New wrapper around + cxx_omp_predetermined_sharing_1. Rename old function to ... + (cxx_omp_predetermined_sharing_1): ... this. + * semantics.c (finish_omp_clauses): Use cxx_omp_predetermined_sharing_1 + instead of cxx_omp_predetermined_sharing. + 2018-05-10 Jason Merrill <jason@redhat.com> * decl.c (cp_finish_decl): Don't instantiate auto variable. diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 84882f8..317ba45 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -1957,7 +1957,7 @@ cxx_omp_const_qual_no_mutable (tree decl) /* True if OpenMP sharing attribute of DECL is predetermined. */ enum omp_clause_default_kind -cxx_omp_predetermined_sharing (tree decl) +cxx_omp_predetermined_sharing_1 (tree decl) { /* Static data members are predetermined shared. */ if (TREE_STATIC (decl)) @@ -1975,6 +1975,32 @@ cxx_omp_predetermined_sharing (tree decl) return OMP_CLAUSE_DEFAULT_UNSPECIFIED; } +/* Likewise, but also include the artificial vars. We don't want to + disallow the artificial vars being mentioned in explicit clauses, + as we use artificial vars e.g. for loop constructs with random + access iterators other than pointers, but during gimplification + we want to treat them as predetermined. */ + +enum omp_clause_default_kind +cxx_omp_predetermined_sharing (tree decl) +{ + enum omp_clause_default_kind ret = cxx_omp_predetermined_sharing_1 (decl); + if (ret != OMP_CLAUSE_DEFAULT_UNSPECIFIED) + return ret; + + /* Predetermine artificial variables holding integral values, those + are usually result of gimplify_one_sizepos or SAVE_EXPR + gimplification. */ + if (VAR_P (decl) + && DECL_ARTIFICIAL (decl) + && INTEGRAL_TYPE_P (TREE_TYPE (decl)) + && !(DECL_LANG_SPECIFIC (decl) + && DECL_OMP_PRIVATIZED_MEMBER (decl))) + return OMP_CLAUSE_DEFAULT_SHARED; + + return OMP_CLAUSE_DEFAULT_UNSPECIFIED; +} + /* Finalize an implicitly determined clause. */ void diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index a4e0099..353bc6a 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -7383,6 +7383,7 @@ extern int cp_gimplify_expr (tree *, gimple_seq *, gimple_seq *); extern void cp_genericize (tree); extern bool cxx_omp_const_qual_no_mutable (tree); +extern enum omp_clause_default_kind cxx_omp_predetermined_sharing_1 (tree); extern enum omp_clause_default_kind cxx_omp_predetermined_sharing (tree); extern tree cxx_omp_clause_default_ctor (tree, tree, tree); extern tree cxx_omp_clause_copy_ctor (tree, tree, tree); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 195286c..6557817 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -7297,7 +7297,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) if (VAR_P (t) && CP_DECL_THREAD_LOCAL_P (t)) share_name = "threadprivate"; - else switch (cxx_omp_predetermined_sharing (t)) + else switch (cxx_omp_predetermined_sharing_1 (t)) { case OMP_CLAUSE_DEFAULT_UNSPECIFIED: break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1591122..ca16f5c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-05-11 Jakub Jelinek <jakub@redhat.com> + + PR c/85696 + * c-c++-common/gomp/pr85696.c: New test. + 2018-05-11 Allan Sandfeld Jensen <allan.jensen@qt.io> Jakub Jelinek <jakub@redhat.com> diff --git a/gcc/testsuite/c-c++-common/gomp/pr85696.c b/gcc/testsuite/c-c++-common/gomp/pr85696.c new file mode 100644 index 0000000..798718b --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr85696.c @@ -0,0 +1,20 @@ +/* PR c/85696 */ + +#ifndef __cplusplus +void +foo (int n, int a[][n]) +{ + #pragma omp parallel shared(a) default(none) + #pragma omp master + a[23][0] = 42; +} +#endif + +void +bar (int n, void *p) +{ + int (*a)[n] = (int (*)[n]) p; + #pragma omp parallel shared(a) default(none) + #pragma omp master + a[23][0] = 42; +} |