aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCesar Philippidis <cesar@codesourcery.com>2016-05-09 20:34:06 +0000
committerCesar Philippidis <cesar@codesourcery.com>2016-05-09 20:34:06 +0000
commit43021bfbb5b5f12a582d792cabb9289cf12b9679 (patch)
treed35d187f044018672738924371f73240c9075c00
parent3b15d4c8233a3a79afcec3addea7ac4b50c746f3 (diff)
Backport trunk r235780:
2016-05-02 Cesar Philippidis <cesar@codesourcery.com> gcc/c-family/ * c-common.h (enum c_omp_region_type): Define. gcc/c/ * c-parser.c (c_parser_oacc_all_clauses): Update call to c_finish_omp_clauses. (c_parser_omp_all_clauses): Likewise. (c_parser_oacc_cache): Likewise. (c_parser_oacc_loop): Likewise. (omp_split_clauses): Likewise. (c_parser_omp_declare_target): Likewise. (c_parser_cilk_all_clauses): Likewise. (c_parser_cilk_for): Likewise. * c-typeck.c (c_finish_omp_clauses): Replace bool arguments is_omp, declare_simd, and is_cilk with enum c_omp_region_type ort. gcc/cp/ * cp-tree.h (finish_omp_clauses): Update prototype. * parser.c (cp_parser_oacc_all_clauses): Update call to finish_omp_clauses. (cp_parser_omp_all_clauses): Likewise. (cp_parser_omp_for_loop): Likewise. (cp_omp_split_clauses): Likewise. (cp_parser_oacc_cache): Likewise. (cp_parser_oacc_loop): Likewise. (cp_parser_omp_declare_target): (cp_parser_cilk_simd_all_clauses): Likewise. (cp_parser_cilk_for): Likewise. * pt.c (tsubst_omp_clauses): Replace allow_fields and declare_simd arguments with enum c_omp_region_type ort. (tsubst_omp_clauses): Update calls to finish_omp_clauses. (tsubst_omp_attribute): Update calls to tsubst_omp_clauses. (tsubst_omp_for_iterator): Update calls to finish_omp_clauses. (tsubst_expr): Update calls to tsubst_omp_clauses. * semantics.c (finish_omp_clauses): Replace bool arguments allow_fields, declare_simd, and is_cilk with bitmask ort. (finish_omp_for): Update call to finish_omp_clauses. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@236048 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/c-family/ChangeLog.gomp7
-rw-r--r--gcc/c-family/c-common.h9
-rw-r--r--gcc/c/ChangeLog.gomp17
-rw-r--r--gcc/c/c-parser.c22
-rw-r--r--gcc/c/c-tree.h2
-rw-r--r--gcc/c/c-typeck.c37
-rw-r--r--gcc/cp/ChangeLog.gomp26
-rw-r--r--gcc/cp/cp-tree.h3
-rw-r--r--gcc/cp/parser.c22
-rw-r--r--gcc/cp/pt.c66
-rw-r--r--gcc/cp/semantics.c51
11 files changed, 162 insertions, 100 deletions
diff --git a/gcc/c-family/ChangeLog.gomp b/gcc/c-family/ChangeLog.gomp
index 4bb8950bf36..666964cee19 100644
--- a/gcc/c-family/ChangeLog.gomp
+++ b/gcc/c-family/ChangeLog.gomp
@@ -1,5 +1,12 @@
2016-05-09 Cesar Philippidis <cesar@codesourcery.com>
+ Backport from trunk r235780:
+ 2016-05-02 Cesar Philippidis <cesar@codesourcery.com>
+
+ * c-common.h (enum c_omp_region_type): Define.
+
+2016-05-09 Cesar Philippidis <cesar@codesourcery.com>
+
Backport trunk r235290:
2016-04-20 Ilya Verbin <ilya.verbin@intel.com>
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 59da6c81289..ef3493e113a 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -1259,6 +1259,15 @@ enum c_omp_clause_split
C_OMP_CLAUSE_SPLIT_TASKLOOP = C_OMP_CLAUSE_SPLIT_FOR
};
+enum c_omp_region_type
+{
+ C_ORT_OMP = 1 << 0,
+ C_ORT_CILK = 1 << 1,
+ C_ORT_ACC = 1 << 2,
+ C_ORT_DECLARE_SIMD = 1 << 3,
+ C_ORT_OMP_DECLARE_SIMD = C_ORT_OMP | C_ORT_DECLARE_SIMD,
+};
+
extern tree c_finish_omp_master (location_t, tree);
extern tree c_finish_omp_taskgroup (location_t, tree);
extern tree c_finish_omp_critical (location_t, tree, tree, tree);
diff --git a/gcc/c/ChangeLog.gomp b/gcc/c/ChangeLog.gomp
index 3714e02b5a9..5fa34a00742 100644
--- a/gcc/c/ChangeLog.gomp
+++ b/gcc/c/ChangeLog.gomp
@@ -1,5 +1,22 @@
2016-05-09 Cesar Philippidis <cesar@codesourcery.com>
+ Backport trunk r235780:
+ 2016-05-02 Cesar Philippidis <cesar@codesourcery.com>
+
+ * c-parser.c (c_parser_oacc_all_clauses): Update call to
+ c_finish_omp_clauses.
+ (c_parser_omp_all_clauses): Likewise.
+ (c_parser_oacc_cache): Likewise.
+ (c_parser_oacc_loop): Likewise.
+ (omp_split_clauses): Likewise.
+ (c_parser_omp_declare_target): Likewise.
+ (c_parser_cilk_all_clauses): Likewise.
+ (c_parser_cilk_for): Likewise.
+ * c-typeck.c (c_finish_omp_clauses): Replace bool arguments
+ is_omp, declare_simd, and is_cilk with enum c_omp_region_type ort.
+
+2016-05-09 Cesar Philippidis <cesar@codesourcery.com>
+
Backport trunk r235290:
2016-04-20 Ilya Verbin <ilya.verbin@intel.com>
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 7667715e177..48fa26ac4f1 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -13367,7 +13367,7 @@ c_parser_oacc_all_clauses (c_parser *parser, omp_clause_mask mask,
c_parser_skip_to_pragma_eol (parser);
if (finish_p)
- return c_finish_omp_clauses (clauses, true, false);
+ return c_finish_omp_clauses (clauses, C_ORT_ACC);
return clauses;
}
@@ -13652,8 +13652,8 @@ c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask,
if (finish_p)
{
if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_UNIFORM)) != 0)
- return c_finish_omp_clauses (clauses, false, true, true);
- return c_finish_omp_clauses (clauses, false, true);
+ return c_finish_omp_clauses (clauses, C_ORT_OMP_DECLARE_SIMD);
+ return c_finish_omp_clauses (clauses, C_ORT_OMP);
}
return clauses;
@@ -13685,7 +13685,7 @@ c_parser_oacc_cache (location_t loc, c_parser *parser)
tree stmt, clauses;
clauses = c_parser_omp_var_list_parens (parser, OMP_CLAUSE__CACHE_, NULL);
- clauses = c_finish_omp_clauses (clauses, true, false);
+ clauses = c_finish_omp_clauses (clauses, C_ORT_ACC);
c_parser_skip_to_pragma_eol (parser);
@@ -14022,9 +14022,9 @@ c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name,
{
clauses = c_oacc_split_loop_clauses (clauses, cclauses);
if (*cclauses)
- *cclauses = c_finish_omp_clauses (*cclauses, true, false);
+ *cclauses = c_finish_omp_clauses (*cclauses, C_ORT_ACC);
if (clauses)
- clauses = c_finish_omp_clauses (clauses, true, false);
+ clauses = c_finish_omp_clauses (clauses, C_ORT_ACC);
}
tree block = c_begin_compound_stmt (true);
@@ -15228,7 +15228,7 @@ omp_split_clauses (location_t loc, enum tree_code code,
c_omp_split_clauses (loc, code, mask, clauses, cclauses);
for (i = 0; i < C_OMP_CLAUSE_SPLIT_COUNT; i++)
if (cclauses[i])
- cclauses[i] = c_finish_omp_clauses (cclauses[i], false, true);
+ cclauses[i] = c_finish_omp_clauses (cclauses[i], C_ORT_OMP);
}
/* OpenMP 4.0:
@@ -16759,7 +16759,7 @@ c_parser_omp_declare_target (c_parser *parser)
{
clauses = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_TO_DECLARE,
clauses);
- clauses = c_finish_omp_clauses (clauses, false, true);
+ clauses = c_finish_omp_clauses (clauses, C_ORT_OMP);
c_parser_skip_to_pragma_eol (parser);
}
else
@@ -17728,7 +17728,7 @@ c_parser_cilk_all_clauses (c_parser *parser)
saw_error:
c_parser_skip_to_pragma_eol (parser);
- return c_finish_omp_clauses (clauses, false, false, false, true);
+ return c_finish_omp_clauses (clauses, C_ORT_CILK);
}
/* This function helps parse the grainsize pragma for a _Cilk_for statement.
@@ -17810,7 +17810,7 @@ c_parser_cilk_for (c_parser *parser, tree grain, bool *if_p)
tree clauses = build_omp_clause (EXPR_LOCATION (grain), OMP_CLAUSE_SCHEDULE);
OMP_CLAUSE_SCHEDULE_KIND (clauses) = OMP_CLAUSE_SCHEDULE_CILKFOR;
OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clauses) = grain;
- clauses = c_finish_omp_clauses (clauses, false, false);
+ clauses = c_finish_omp_clauses (clauses, C_ORT_CILK);
tree block = c_begin_compound_stmt (true);
tree sb = push_stmt_list ();
@@ -17876,7 +17876,7 @@ c_parser_cilk_for (c_parser *parser, tree grain, bool *if_p)
OMP_CLAUSE_OPERAND (c, 0)
= cilk_for_number_of_iterations (omp_for);
OMP_CLAUSE_CHAIN (c) = clauses;
- OMP_PARALLEL_CLAUSES (omp_par) = c_finish_omp_clauses (c, false, true);
+ OMP_PARALLEL_CLAUSES (omp_par) = c_finish_omp_clauses (c, C_ORT_CILK);
add_stmt (omp_par);
}
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h
index 1703162e83c..07d0f656094 100644
--- a/gcc/c/c-tree.h
+++ b/gcc/c/c-tree.h
@@ -661,7 +661,7 @@ extern tree c_begin_omp_task (void);
extern tree c_finish_omp_task (location_t, tree, tree);
extern void c_finish_omp_cancel (location_t, tree);
extern void c_finish_omp_cancellation_point (location_t, tree);
-extern tree c_finish_omp_clauses (tree, bool, bool, bool = false, bool = false);
+extern tree c_finish_omp_clauses (tree, enum c_omp_region_type);
extern tree c_build_va_arg (location_t, tree, location_t, tree);
extern tree c_finish_transaction (location_t, tree, int);
extern bool c_tree_equal (tree, tree);
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 067ce824ecd..7fc06065db1 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -12496,8 +12496,7 @@ c_find_omp_placeholder_r (tree *tp, int *, void *data)
Remove any elements from the list that are invalid. */
tree
-c_finish_omp_clauses (tree clauses, bool is_oacc, bool is_omp,
- bool declare_simd, bool is_cilk)
+c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
{
bitmap_head generic_head, firstprivate_head, lastprivate_head;
bitmap_head aligned_head, map_head, map_field_head;
@@ -12539,18 +12538,18 @@ c_finish_omp_clauses (tree clauses, bool is_oacc, bool is_omp,
need_complete = true;
oacc_data = true;
need_implicitly_determined = true;
- if (is_oacc)
+ if (ort == C_ORT_ACC)
goto check_dup_oacc;
else
goto check_dup_generic;
case OMP_CLAUSE_REDUCTION:
- need_implicitly_determined = !is_oacc;
+ need_implicitly_determined = ort != C_ORT_ACC;
reduction = true;
t = OMP_CLAUSE_DECL (c);
if (TREE_CODE (t) == TREE_LIST)
{
- if (handle_omp_array_sections (c, is_omp))
+ if (handle_omp_array_sections (c, ort & C_ORT_OMP))
{
remove = true;
break;
@@ -12752,7 +12751,7 @@ c_finish_omp_clauses (tree clauses, bool is_oacc, bool is_omp,
if (TREE_CODE (t) == ADDR_EXPR)
t = TREE_OPERAND (t, 0);
}
- if (is_oacc)
+ if (ort == C_ORT_ACC)
goto check_dup_oacc_t;
else
goto check_dup_generic_t;
@@ -12781,10 +12780,10 @@ c_finish_omp_clauses (tree clauses, bool is_oacc, bool is_omp,
goto check_dup_generic;
case OMP_CLAUSE_LINEAR:
- if (!declare_simd)
+ if (ort != C_ORT_OMP_DECLARE_SIMD)
need_implicitly_determined = true;
t = OMP_CLAUSE_DECL (c);
- if (!declare_simd
+ if (ort != C_ORT_OMP_DECLARE_SIMD
&& OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT)
{
error_at (OMP_CLAUSE_LOCATION (c),
@@ -12792,7 +12791,7 @@ c_finish_omp_clauses (tree clauses, bool is_oacc, bool is_omp,
"clause on %<simd%> or %<for%> constructs");
OMP_CLAUSE_LINEAR_KIND (c) = OMP_CLAUSE_LINEAR_DEFAULT;
}
- if (is_cilk)
+ if (ort & C_ORT_CILK)
{
if (!INTEGRAL_TYPE_P (TREE_TYPE (t))
&& !SCALAR_FLOAT_TYPE_P (TREE_TYPE (t))
@@ -12818,7 +12817,7 @@ c_finish_omp_clauses (tree clauses, bool is_oacc, bool is_omp,
break;
}
}
- if (declare_simd)
+ if (ort == C_ORT_OMP_DECLARE_SIMD)
{
tree s = OMP_CLAUSE_LINEAR_STEP (c);
if (TREE_CODE (s) == PARM_DECL)
@@ -12908,7 +12907,8 @@ c_finish_omp_clauses (tree clauses, bool is_oacc, bool is_omp,
}
else if (reduction)
{
- if (is_oacc && bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
+ if (ort == C_ORT_ACC
+ && bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
{
error_at (OMP_CLAUSE_LOCATION (c),
"%qE appears in multiple reduction clauses", t);
@@ -12940,7 +12940,7 @@ c_finish_omp_clauses (tree clauses, bool is_oacc, bool is_omp,
"%qE is not a variable in clause %<firstprivate%>", t);
remove = true;
}
- else if (is_oacc)
+ else if (ort == C_ORT_ACC)
{
if (bitmap_bit_p (&oacc_data_head, DECL_UID (t)))
{
@@ -13056,7 +13056,7 @@ c_finish_omp_clauses (tree clauses, bool is_oacc, bool is_omp,
}
if (TREE_CODE (t) == TREE_LIST)
{
- if (handle_omp_array_sections (c, is_omp))
+ if (handle_omp_array_sections (c, ort & C_ORT_OMP))
remove = true;
break;
}
@@ -13079,7 +13079,7 @@ c_finish_omp_clauses (tree clauses, bool is_oacc, bool is_omp,
t = OMP_CLAUSE_DECL (c);
if (TREE_CODE (t) == TREE_LIST)
{
- if (handle_omp_array_sections (c, is_omp))
+ if (handle_omp_array_sections (c, ort & C_ORT_OMP))
remove = true;
else
{
@@ -13126,7 +13126,7 @@ c_finish_omp_clauses (tree clauses, bool is_oacc, bool is_omp,
break;
}
if (TREE_CODE (t) == COMPONENT_REF
- && is_omp
+ && (ort & C_ORT_OMP)
&& OMP_CLAUSE_CODE (c) != OMP_CLAUSE__CACHE_)
{
if (DECL_BIT_FIELD (TREE_OPERAND (t, 1)))
@@ -13213,7 +13213,7 @@ c_finish_omp_clauses (tree clauses, bool is_oacc, bool is_omp,
else
bitmap_set_bit (&generic_head, DECL_UID (t));
}
- else if ((is_oacc && bitmap_bit_p (&oacc_data_head, DECL_UID (t)))
+ else if ((ort == C_ORT_ACC && bitmap_bit_p (&oacc_data_head, DECL_UID (t)))
|| bitmap_bit_p (&map_head, DECL_UID (t)))
{
if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
@@ -13222,7 +13222,7 @@ c_finish_omp_clauses (tree clauses, bool is_oacc, bool is_omp,
error ("%qD appears more than once in map clauses", t);
remove = true;
}
- else if (is_oacc)
+ else if (ort == C_ORT_ACC)
bitmap_set_bit (&oacc_data_head, DECL_UID (t));
else if (bitmap_bit_p (&generic_head, DECL_UID (t))
|| bitmap_bit_p (&firstprivate_head, DECL_UID (t)))
@@ -13372,8 +13372,7 @@ c_finish_omp_clauses (tree clauses, bool is_oacc, bool is_omp,
case OMP_CLAUSE_DEVICE_TYPE:
OMP_CLAUSE_DEVICE_TYPE_CLAUSES (c)
- = c_finish_omp_clauses (OMP_CLAUSE_DEVICE_TYPE_CLAUSES (c),
- is_oacc, is_omp);
+ = c_finish_omp_clauses (OMP_CLAUSE_DEVICE_TYPE_CLAUSES (c), ort);
pc = &OMP_CLAUSE_CHAIN (c);
continue;
diff --git a/gcc/cp/ChangeLog.gomp b/gcc/cp/ChangeLog.gomp
index fd9b1123063..5c62159de93 100644
--- a/gcc/cp/ChangeLog.gomp
+++ b/gcc/cp/ChangeLog.gomp
@@ -1,5 +1,31 @@
2016-05-09 Cesar Philippidis <cesar@codesourcery.com>
+ Backport from trunk r235780:
+ 2016-05-02 Cesar Philippidis <cesar@codesourcery.com>
+
+ * cp-tree.h (finish_omp_clauses): Update prototype.
+ * parser.c (cp_parser_oacc_all_clauses): Update call to
+ finish_omp_clauses.
+ (cp_parser_omp_all_clauses): Likewise.
+ (cp_parser_omp_for_loop): Likewise.
+ (cp_omp_split_clauses): Likewise.
+ (cp_parser_oacc_cache): Likewise.
+ (cp_parser_oacc_loop): Likewise.
+ (cp_parser_omp_declare_target):
+ (cp_parser_cilk_simd_all_clauses): Likewise.
+ (cp_parser_cilk_for): Likewise.
+ * pt.c (tsubst_omp_clauses): Replace allow_fields and declare_simd
+ arguments with enum c_omp_region_type ort.
+ (tsubst_omp_clauses): Update calls to finish_omp_clauses.
+ (tsubst_omp_attribute): Update calls to tsubst_omp_clauses.
+ (tsubst_omp_for_iterator): Update calls to finish_omp_clauses.
+ (tsubst_expr): Update calls to tsubst_omp_clauses.
+ * semantics.c (finish_omp_clauses): Replace bool arguments
+ allow_fields, declare_simd, and is_cilk with bitmask ort.
+ (finish_omp_for): Update call to finish_omp_clauses.
+
+2016-05-09 Cesar Philippidis <cesar@codesourcery.com>
+
Backport trunk r235290:
2016-04-20 Ilya Verbin <ilya.verbin@intel.com>
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 7850571f25a..e40ec2081c2 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6397,8 +6397,7 @@ extern tree omp_reduction_id (enum tree_code, tree, tree);
extern tree cp_remove_omp_priv_cleanup_stmt (tree *, int *, void *);
extern void cp_check_omp_declare_reduction (tree);
extern void finish_omp_declare_simd_methods (tree);
-extern tree finish_omp_clauses (tree, bool, bool, bool = false,
- bool = false);
+extern tree finish_omp_clauses (tree, enum c_omp_region_type);
extern tree push_omp_privatization_clauses (bool);
extern void pop_omp_privatization_clauses (tree);
extern void save_omp_privatization_clauses (vec<tree> &);
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index a2861a58972..f4b26037be3 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -32432,7 +32432,7 @@ cp_parser_oacc_all_clauses (cp_parser *parser, omp_clause_mask mask,
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
if (finish_p)
- return finish_omp_clauses (clauses, true, true);
+ return finish_omp_clauses (clauses, C_ORT_ACC);
return clauses;
}
@@ -32751,9 +32751,9 @@ cp_parser_omp_all_clauses (cp_parser *parser, omp_clause_mask mask,
if (finish_p)
{
if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_UNIFORM)) != 0)
- return finish_omp_clauses (clauses, false, false, true);
+ return finish_omp_clauses (clauses, C_ORT_OMP_DECLARE_SIMD);
else
- return finish_omp_clauses (clauses, false, true);
+ return finish_omp_clauses (clauses, C_ORT_OMP);
}
return clauses;
}
@@ -33828,7 +33828,7 @@ cp_parser_omp_for_loop (cp_parser *parser, enum tree_code code, tree clauses,
else
c = build_omp_clause (loc, OMP_CLAUSE_LASTPRIVATE);
OMP_CLAUSE_DECL (c) = add_private_clause;
- c = finish_omp_clauses (c, false, true);
+ c = finish_omp_clauses (c, C_ORT_OMP);
if (c)
{
OMP_CLAUSE_CHAIN (c) = clauses;
@@ -33980,7 +33980,7 @@ cp_omp_split_clauses (location_t loc, enum tree_code code,
c_omp_split_clauses (loc, code, mask, clauses, cclauses);
for (i = 0; i < C_OMP_CLAUSE_SPLIT_COUNT; i++)
if (cclauses[i])
- cclauses[i] = finish_omp_clauses (cclauses[i], false, true);
+ cclauses[i] = finish_omp_clauses (cclauses[i], C_ORT_OMP);
}
/* OpenMP 4.0:
@@ -35263,7 +35263,7 @@ cp_parser_oacc_cache (cp_parser *parser, cp_token *pragma_tok)
tree stmt, clauses;
clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE__CACHE_, NULL_TREE);
- clauses = finish_omp_clauses (clauses, true, true);
+ clauses = finish_omp_clauses (clauses, C_ORT_ACC);
cp_parser_require_pragma_eol (parser, cp_lexer_peek_token (parser->lexer));
@@ -35591,9 +35591,9 @@ cp_parser_oacc_loop (cp_parser *parser, cp_token *pragma_tok, char *p_name,
{
clauses = c_oacc_split_loop_clauses (clauses, cclauses);
if (*cclauses)
- *cclauses = finish_omp_clauses (*cclauses, true, true);
+ *cclauses = finish_omp_clauses (*cclauses, C_ORT_ACC);
if (clauses)
- clauses = finish_omp_clauses (clauses, true, true);
+ clauses = finish_omp_clauses (clauses, C_ORT_ACC);
}
tree block = begin_omp_structured_block ();
@@ -35979,7 +35979,7 @@ cp_parser_omp_declare_target (cp_parser *parser, cp_token *pragma_tok)
{
clauses = cp_parser_omp_var_list (parser, OMP_CLAUSE_TO_DECLARE,
clauses);
- clauses = finish_omp_clauses (clauses, false, true);
+ clauses = finish_omp_clauses (clauses, C_ORT_OMP);
cp_parser_require_pragma_eol (parser, pragma_tok);
}
else
@@ -37997,7 +37997,7 @@ cp_parser_cilk_simd_all_clauses (cp_parser *parser, cp_token *pragma_token)
if (clauses == error_mark_node)
return error_mark_node;
else
- return finish_omp_clauses (clauses, false, false, false, true);
+ return finish_omp_clauses (clauses, C_ORT_CILK);
}
/* Main entry-point for parsing Cilk Plus <#pragma simd> for loops. */
@@ -38042,7 +38042,7 @@ cp_parser_cilk_for (cp_parser *parser, tree grain, bool *if_p)
tree clauses = build_omp_clause (EXPR_LOCATION (grain), OMP_CLAUSE_SCHEDULE);
OMP_CLAUSE_SCHEDULE_KIND (clauses) = OMP_CLAUSE_SCHEDULE_CILKFOR;
OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clauses) = grain;
- clauses = finish_omp_clauses (clauses, false, false);
+ clauses = finish_omp_clauses (clauses, C_ORT_CILK);
tree ret = cp_parser_omp_for_loop (parser, CILK_FOR, clauses, NULL, if_p);
if (ret)
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index e0b08c5c4bc..fbdfb971af9 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -9561,7 +9561,8 @@ can_complete_type_without_circularity (tree type)
return 1;
}
-static tree tsubst_omp_clauses (tree, bool, bool, tree, tsubst_flags_t, tree);
+static tree tsubst_omp_clauses (tree, enum c_omp_region_type, tree,
+ tsubst_flags_t, tree);
/* Instantiate a single dependent attribute T (a TREE_LIST), and return either
T or a new TREE_LIST, possibly a chain in the case of a pack expansion. */
@@ -9580,10 +9581,10 @@ tsubst_attribute (tree t, tree *decl_p, tree args,
get_attribute_name (t)))
{
tree clauses = TREE_VALUE (val);
- clauses = tsubst_omp_clauses (clauses, true, false, args,
+ clauses = tsubst_omp_clauses (clauses, C_ORT_OMP_DECLARE_SIMD, args,
complain, in_decl);
c_omp_declare_simd_clauses_to_decls (*decl_p, clauses);
- clauses = finish_omp_clauses (clauses, false, false, true);
+ clauses = finish_omp_clauses (clauses, C_ORT_OMP_DECLARE_SIMD);
tree parms = DECL_ARGUMENTS (*decl_p);
clauses
= c_omp_declare_simd_clauses_to_numbers (parms, clauses);
@@ -14531,7 +14532,7 @@ tsubst_omp_clause_decl (tree decl, tree args, tsubst_flags_t complain,
/* Like tsubst_copy, but specifically for OpenMP clauses. */
static tree
-tsubst_omp_clauses (tree clauses, bool declare_simd, bool allow_fields,
+tsubst_omp_clauses (tree clauses, enum c_omp_region_type ort,
tree args, tsubst_flags_t complain, tree in_decl)
{
tree new_clauses = NULL_TREE, nc, oc;
@@ -14684,7 +14685,7 @@ tsubst_omp_clauses (tree clauses, bool declare_simd, bool allow_fields,
default:
gcc_unreachable ();
}
- if (allow_fields)
+ if ((ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP)
switch (OMP_CLAUSE_CODE (nc))
{
case OMP_CLAUSE_SHARED:
@@ -14746,11 +14747,9 @@ tsubst_omp_clauses (tree clauses, bool declare_simd, bool allow_fields,
}
new_clauses = nreverse (new_clauses);
- if (!declare_simd)
+ if (ort != C_ORT_OMP_DECLARE_SIMD)
{
- new_clauses = finish_omp_clauses (new_clauses,
- /* TODO is_oacc */ !allow_fields,
- allow_fields);
+ new_clauses = finish_omp_clauses (new_clauses, ort);
if (linear_no_step)
for (nc = new_clauses; nc; nc = OMP_CLAUSE_CHAIN (nc))
if (nc == linear_no_step)
@@ -14971,7 +14970,7 @@ tsubst_omp_for_iterator (tree t, int i, tree declv, tree orig_declv,
{
tree c = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE);
OMP_CLAUSE_DECL (c) = decl;
- c = finish_omp_clauses (c, false, true);
+ c = finish_omp_clauses (c, C_ORT_OMP);
if (c)
{
OMP_CLAUSE_CHAIN (c) = *clauses;
@@ -15454,7 +15453,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
case OACC_KERNELS:
case OACC_PARALLEL:
- tmp = tsubst_omp_clauses (OMP_CLAUSES (t), false, false, args, complain,
+ tmp = tsubst_omp_clauses (OMP_CLAUSES (t), C_ORT_ACC, args, complain,
in_decl);
stmt = begin_omp_parallel ();
RECUR (OMP_BODY (t));
@@ -15463,8 +15462,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
case OMP_PARALLEL:
r = push_omp_privatization_clauses (OMP_PARALLEL_COMBINED (t));
- tmp = tsubst_omp_clauses (OMP_PARALLEL_CLAUSES (t), false, true,
- args, complain, in_decl);
+ tmp = tsubst_omp_clauses (OMP_PARALLEL_CLAUSES (t), C_ORT_OMP, args,
+ complain, in_decl);
if (OMP_PARALLEL_COMBINED (t))
omp_parallel_combined_clauses = &tmp;
stmt = begin_omp_parallel ();
@@ -15477,8 +15476,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
case OMP_TASK:
r = push_omp_privatization_clauses (false);
- tmp = tsubst_omp_clauses (OMP_TASK_CLAUSES (t), false, true,
- args, complain, in_decl);
+ tmp = tsubst_omp_clauses (OMP_TASK_CLAUSES (t), C_ORT_OMP, args,
+ complain, in_decl);
stmt = begin_omp_task ();
RECUR (OMP_TASK_BODY (t));
finish_omp_task (tmp, stmt);
@@ -15497,12 +15496,17 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
tree declv = NULL_TREE, initv = NULL_TREE, condv = NULL_TREE;
tree orig_declv = NULL_TREE;
tree incrv = NULL_TREE;
+ enum c_omp_region_type ort = C_ORT_OMP;
int i;
+ if (TREE_CODE (t) == CILK_SIMD || TREE_CODE (t) == CILK_FOR)
+ ort = C_ORT_CILK;
+ else if (TREE_CODE (t) == OACC_LOOP)
+ ort = C_ORT_ACC;
+
r = push_omp_privatization_clauses (OMP_FOR_INIT (t) == NULL_TREE);
- clauses = tsubst_omp_clauses (OMP_FOR_CLAUSES (t), false,
- TREE_CODE (t) != OACC_LOOP,
- args, complain, in_decl);
+ clauses = tsubst_omp_clauses (OMP_FOR_CLAUSES (t), ort, args, complain,
+ in_decl);
if (OMP_FOR_INIT (t) != NULL_TREE)
{
declv = make_tree_vec (TREE_VEC_LENGTH (OMP_FOR_INIT (t)));
@@ -15558,8 +15562,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
case OMP_CRITICAL:
r = push_omp_privatization_clauses (TREE_CODE (t) == OMP_TEAMS
&& OMP_TEAMS_COMBINED (t));
- tmp = tsubst_omp_clauses (OMP_CLAUSES (t), false, true,
- args, complain, in_decl);
+ tmp = tsubst_omp_clauses (OMP_CLAUSES (t), C_ORT_OMP, args, complain,
+ in_decl);
stmt = push_stmt_list ();
RECUR (OMP_BODY (t));
stmt = pop_stmt_list (stmt);
@@ -15574,9 +15578,9 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
case OACC_DATA:
case OMP_TARGET_DATA:
case OMP_TARGET:
- tmp = tsubst_omp_clauses (OMP_CLAUSES (t), false,
- TREE_CODE (t) != OACC_DATA,
- args, complain, in_decl);
+ tmp = tsubst_omp_clauses (OMP_CLAUSES (t), (TREE_CODE (t) == OACC_DATA)
+ ? C_ORT_ACC : C_ORT_OMP, args, complain,
+ in_decl);
keep_next_level (true);
stmt = begin_omp_structured_block ();
@@ -15621,8 +15625,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
case OACC_DECLARE:
t = copy_node (t);
- tmp = tsubst_omp_clauses (OACC_DECLARE_CLAUSES (t), false, false,
- args, complain, in_decl);
+ tmp = tsubst_omp_clauses (OACC_DECLARE_CLAUSES (t), C_ORT_ACC, args,
+ complain, in_decl);
OACC_DECLARE_CLAUSES (t) = tmp;
add_stmt (t);
break;
@@ -15630,8 +15634,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
case OMP_TARGET_UPDATE:
case OMP_TARGET_ENTER_DATA:
case OMP_TARGET_EXIT_DATA:
- tmp = tsubst_omp_clauses (OMP_STANDALONE_CLAUSES (t), false, true,
- args, complain, in_decl);
+ tmp = tsubst_omp_clauses (OMP_STANDALONE_CLAUSES (t), C_ORT_OMP, args,
+ complain, in_decl);
t = copy_node (t);
OMP_STANDALONE_CLAUSES (t) = tmp;
add_stmt (t);
@@ -15640,16 +15644,16 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
case OACC_ENTER_DATA:
case OACC_EXIT_DATA:
case OACC_UPDATE:
- tmp = tsubst_omp_clauses (OMP_STANDALONE_CLAUSES (t), false, false,
- args, complain, in_decl);
+ tmp = tsubst_omp_clauses (OMP_STANDALONE_CLAUSES (t), C_ORT_ACC, args,
+ complain, in_decl);
t = copy_node (t);
OMP_STANDALONE_CLAUSES (t) = tmp;
add_stmt (t);
break;
case OMP_ORDERED:
- tmp = tsubst_omp_clauses (OMP_ORDERED_CLAUSES (t), false, true,
- args, complain, in_decl);
+ tmp = tsubst_omp_clauses (OMP_ORDERED_CLAUSES (t), C_ORT_OMP, args,
+ complain, in_decl);
stmt = push_stmt_list ();
RECUR (OMP_BODY (t));
stmt = pop_stmt_list (stmt);
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 588e616a9cf..765e08bfebd 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -5783,8 +5783,7 @@ cp_finish_omp_clause_depend_sink (tree sink_clause)
Remove any elements from the list that are invalid. */
tree
-finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_simd,
- bool is_cilk)
+finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
{
bitmap_head generic_head, firstprivate_head, lastprivate_head;
bitmap_head aligned_head, map_head, map_field_head;
@@ -5794,6 +5793,8 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
bool branch_seen = false;
bool copyprivate_seen = false;
bool ordered_seen = false;
+ bool allow_fields = (ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP
+ || ort == C_ORT_ACC;
bitmap_obstack_initialize (NULL);
bitmap_initialize (&generic_head, &bitmap_default_obstack);
@@ -5818,7 +5819,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
field_ok = allow_fields;
goto check_dup_generic;
case OMP_CLAUSE_PRIVATE:
- if (is_oacc)
+ if (ort == C_ORT_ACC)
{
oacc_data = true;
goto check_dup_oacc;
@@ -5829,14 +5830,14 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
goto check_dup_generic;
}
case OMP_CLAUSE_REDUCTION:
- if (is_oacc)
+ if (ort == C_ORT_ACC)
reduction = true;
else
field_ok = allow_fields;
t = OMP_CLAUSE_DECL (c);
if (TREE_CODE (t) == TREE_LIST)
{
- if (handle_omp_array_sections (c, allow_fields && !is_oacc))
+ if (handle_omp_array_sections (c, allow_fields && ort != C_ORT_ACC))
{
remove = true;
break;
@@ -5859,12 +5860,12 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
tree n = omp_clause_decl_field (t);
if (n)
t = n;
- if (is_oacc)
+ if (ort == C_ORT_ACC)
goto check_dup_oacc_t;
else
goto check_dup_generic_t;
}
- if (is_oacc)
+ if (ort == C_ORT_ACC)
goto check_dup_oacc;
else
goto check_dup_generic;
@@ -5877,7 +5878,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
case OMP_CLAUSE_LINEAR:
field_ok = allow_fields;
t = OMP_CLAUSE_DECL (c);
- if (!declare_simd
+ if (ort != C_ORT_OMP_DECLARE_SIMD
&& OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT)
{
error_at (OMP_CLAUSE_LOCATION (c),
@@ -5902,7 +5903,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
}
if (TREE_CODE (type) == REFERENCE_TYPE)
type = TREE_TYPE (type);
- if (is_cilk)
+ if (ort == C_ORT_CILK)
{
if (!INTEGRAL_TYPE_P (type)
&& !SCALAR_FLOAT_TYPE_P (type)
@@ -5937,7 +5938,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
}
else if (!type_dependent_expression_p (t)
&& !INTEGRAL_TYPE_P (TREE_TYPE (t))
- && (!declare_simd
+ && (ort != C_ORT_OMP_DECLARE_SIMD
|| TREE_CODE (t) != PARM_DECL
|| TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE
|| !INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (t)))))
@@ -5949,7 +5950,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
else
{
t = mark_rvalue_use (t);
- if (declare_simd && TREE_CODE (t) == PARM_DECL)
+ if (ort == C_ORT_OMP_DECLARE_SIMD && TREE_CODE (t) == PARM_DECL)
{
OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c) = 1;
goto check_dup_generic;
@@ -5958,7 +5959,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
&& (VAR_P (OMP_CLAUSE_DECL (c))
|| TREE_CODE (OMP_CLAUSE_DECL (c)) == PARM_DECL))
{
- if (declare_simd)
+ if (ort == C_ORT_OMP_DECLARE_SIMD)
{
t = maybe_constant_value (t);
if (TREE_CODE (t) != INTEGER_CST)
@@ -5993,7 +5994,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
else if (TREE_CODE (type) == POINTER_TYPE
/* Can't multiply the step yet if *this
is still incomplete type. */
- && (!declare_simd
+ && (ort != C_ORT_OMP_DECLARE_SIMD
|| TREE_CODE (OMP_CLAUSE_DECL (c)) != PARM_DECL
|| !DECL_ARTIFICIAL (OMP_CLAUSE_DECL (c))
|| DECL_NAME (OMP_CLAUSE_DECL (c))
@@ -6030,7 +6031,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
t = OMP_CLAUSE_DECL (c);
check_dup_generic_t:
if (t == current_class_ptr
- && (!declare_simd
+ && (ort != C_ORT_OMP_DECLARE_SIMD
|| (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_LINEAR
&& OMP_CLAUSE_CODE (c) != OMP_CLAUSE_UNIFORM)))
{
@@ -6109,7 +6110,8 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
}
else if (reduction)
{
- if (is_oacc && bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
+ if (ort == C_ORT_ACC
+ && bitmap_bit_p (&oacc_reduction_head, DECL_UID (t)))
{
error_at (OMP_CLAUSE_LOCATION (c),
"%qE appears in multiple reduction clauses", t);
@@ -6138,7 +6140,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
omp_note_field_privatization (t, OMP_CLAUSE_DECL (c));
else
t = OMP_CLAUSE_DECL (c);
- if (!is_oacc
+ if (ort != C_ORT_ACC
&& t == current_class_ptr)
{
error ("%<this%> allowed in OpenMP only in %<declare simd%>"
@@ -6529,7 +6531,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
case OMP_CLAUSE_ALIGNED:
t = OMP_CLAUSE_DECL (c);
- if (t == current_class_ptr && !declare_simd)
+ if (t == current_class_ptr && ort != C_ORT_OMP_DECLARE_SIMD)
{
error ("%<this%> allowed in OpenMP only in %<declare simd%>"
" clauses");
@@ -6612,7 +6614,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
}
if (TREE_CODE (t) == TREE_LIST)
{
- if (handle_omp_array_sections (c, allow_fields && !is_oacc))
+ if (handle_omp_array_sections (c, allow_fields && ort != C_ORT_ACC))
remove = true;
break;
}
@@ -6646,7 +6648,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
t = OMP_CLAUSE_DECL (c);
if (TREE_CODE (t) == TREE_LIST)
{
- if (handle_omp_array_sections (c, allow_fields && !is_oacc))
+ if (handle_omp_array_sections (c, allow_fields && ort != C_ORT_ACC))
remove = true;
else
{
@@ -6701,7 +6703,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
OMP_CLAUSE_DECL (c) = t;
}
if (TREE_CODE (t) == COMPONENT_REF
- && allow_fields
+ && (ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP
&& OMP_CLAUSE_CODE (c) != OMP_CLAUSE__CACHE_)
{
if (type_dependent_expression_p (t))
@@ -6762,7 +6764,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
remove = true;
}
- else if (!is_oacc
+ else if (ort != C_ORT_ACC
&& t == current_class_ptr)
{
error ("%<this%> allowed in OpenMP only in %<declare simd%>"
@@ -7117,8 +7119,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
case OMP_CLAUSE_DEVICE_TYPE:
OMP_CLAUSE_DEVICE_TYPE_CLAUSES (c)
- = finish_omp_clauses (OMP_CLAUSE_DEVICE_TYPE_CLAUSES (c), is_oacc,
- false);
+ = finish_omp_clauses (OMP_CLAUSE_DEVICE_TYPE_CLAUSES (c), ort);
pc = &OMP_CLAUSE_CHAIN (c);
continue;
@@ -7185,7 +7186,7 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields, bool declare_
need_implicitly_determined = true;
break;
case OMP_CLAUSE_LINEAR:
- if (!declare_simd)
+ if (ort != C_ORT_OMP_DECLARE_SIMD)
need_implicitly_determined = true;
else if (OMP_CLAUSE_LINEAR_VARIABLE_STRIDE (c)
&& !bitmap_bit_p (&map_head,
@@ -8415,7 +8416,7 @@ finish_omp_for (location_t locus, enum tree_code code, tree declv,
OMP_CLAUSE_OPERAND (c, 0)
= cilk_for_number_of_iterations (omp_for);
OMP_CLAUSE_CHAIN (c) = clauses;
- OMP_PARALLEL_CLAUSES (omp_par) = finish_omp_clauses (c, false, false);
+ OMP_PARALLEL_CLAUSES (omp_par) = finish_omp_clauses (c, C_ORT_CILK);
add_stmt (omp_par);
return omp_par;
}