aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/c-omp.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-09-27 22:14:24 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2019-09-27 22:14:24 +0200
commit59bc434a3327ce58f7afcd1e9209eeb2da714960 (patch)
treec3c66425e42402e1f978eae510ebd6cb4a617da7 /gcc/c-family/c-omp.c
parent00798c58439037e3de959c3a003d6f4251eb93c6 (diff)
downloadgcc-59bc434a3327ce58f7afcd1e9209eeb2da714960.zip
gcc-59bc434a3327ce58f7afcd1e9209eeb2da714960.tar.gz
gcc-59bc434a3327ce58f7afcd1e9209eeb2da714960.tar.bz2
re PR c++/88203 (assert does not compile with OpenMP's pragma omp parallel for default(none))
PR c++/88203 c-family/ * c-common.h (c_omp_predefined_variable): Declare. * c-omp.c (c_omp_predefined_variable): New function. (c_omp_predetermined_sharing): Return OMP_CLAUSE_DEFAULT_SHARED for predefined variables. c/ * c-parser.c (c_parser_predefined_identifier): New function. (c_parser_postfix_expression): Use it. (c_parser_omp_variable_list): Parse predefined identifiers. * c-typeck.c (c_finish_omp_clauses): Allow predefined variables in shared and firstprivate clauses, even when they are predetermined shared. cp/ * parser.c (cp_parser_omp_var_list_no_open): Parse predefined variables. * semantics.c (finish_omp_clauses): Allow predefined variables in shared and firstprivate clauses, even when they are predetermined shared. * cp-gimplify.c (cxx_omp_predetermined_sharing_1): Return OMP_CLAUSE_DEFAULT_SHARED for predefined variables. testsuite/ * c-c++-common/gomp/pr88203-1.c: New test. * c-c++-common/gomp/pr88203-2.c: New test. * c-c++-common/gomp/pr88203-3.c: New test. From-SVN: r276212
Diffstat (limited to 'gcc/c-family/c-omp.c')
-rw-r--r--gcc/c-family/c-omp.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c
index 10f7c4e..0048289 100644
--- a/gcc/c-family/c-omp.c
+++ b/gcc/c-family/c-omp.c
@@ -2083,6 +2083,25 @@ c_omp_declare_simd_clauses_to_decls (tree fndecl, tree clauses)
}
}
+/* Return true for __func__ and similar function-local predefined
+ variables (which are in OpenMP predetermined shared, allowed in
+ shared/firstprivate clauses). */
+
+bool
+c_omp_predefined_variable (tree decl)
+{
+ if (VAR_P (decl)
+ && DECL_ARTIFICIAL (decl)
+ && TREE_READONLY (decl)
+ && TREE_STATIC (decl)
+ && DECL_NAME (decl)
+ && (DECL_NAME (decl) == ridpointers[RID_C99_FUNCTION_NAME]
+ || DECL_NAME (decl) == ridpointers[RID_FUNCTION_NAME]
+ || DECL_NAME (decl) == ridpointers[RID_PRETTY_FUNCTION_NAME]))
+ return true;
+ return false;
+}
+
/* True if OpenMP sharing attribute of DECL is predetermined. */
enum omp_clause_default_kind
@@ -2096,5 +2115,8 @@ c_omp_predetermined_sharing (tree decl)
&& INTEGRAL_TYPE_P (TREE_TYPE (decl)))
return OMP_CLAUSE_DEFAULT_SHARED;
+ if (c_omp_predefined_variable (decl))
+ return OMP_CLAUSE_DEFAULT_SHARED;
+
return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
}