aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2023-11-24 15:31:08 +0100
committerTobias Burnus <tobias@codesourcery.com>2023-11-24 15:31:08 +0100
commit449b6b817ed76173e6475debd02b195ea9dab0a0 (patch)
treefb600916fe66e127887ae99bcfb4cc34bd868bd5 /gcc/cp
parent439779bacee869643c93a4710a29f89ad031ee4a (diff)
downloadgcc-449b6b817ed76173e6475debd02b195ea9dab0a0.zip
gcc-449b6b817ed76173e6475debd02b195ea9dab0a0.tar.gz
gcc-449b6b817ed76173e6475debd02b195ea9dab0a0.tar.bz2
OpenMP: Add -Wopenmp and use it
The new warning has two purposes: First, it makes clearer to the user that it is about OpenMP and, secondly and more importantly, it permits to use -Wno-openmp. The newly added -Wopenmp is enabled by default and replaces the '0' (always warning) in several OpenMP-related warning calls. For code shared with OpenACC, it only uses OPT_Wopenmp for 'flag_openmp | flag_openmp_simd'. gcc/c-family/ChangeLog: * c.opt (Wopenmp): Add, enable by default. gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_clause_num_threads, c_parser_omp_clause_num_tasks, c_parser_omp_clause_grainsize, c_parser_omp_clause_priority, c_parser_omp_clause_schedule, c_parser_omp_clause_num_teams, c_parser_omp_clause_thread_limit, c_parser_omp_clause_dist_schedule, c_parser_omp_depobj, c_parser_omp_scan_loop_body, c_parser_omp_assumption_clauses): Add OPT_Wopenmp to warning_at. gcc/cp/ChangeLog: * parser.cc (cp_parser_omp_clause_dist_schedule, cp_parser_omp_scan_loop_body, cp_parser_omp_assumption_clauses, cp_parser_omp_depobj): Add OPT_Wopenmp to warning_at. * semantics.cc (finish_omp_clauses): Likewise. gcc/ChangeLog: * doc/invoke.texi (-Wopenmp): Add. * gimplify.cc (gimplify_omp_for): Add OPT_Wopenmp to warning_at. * omp-expand.cc (expand_omp_ordered_sink): Likewise. * omp-general.cc (omp_check_context_selector): Likewise. * omp-low.cc (scan_omp_for, check_omp_nesting_restrictions, lower_omp_ordered_clauses): Likewise. * omp-simd-clone.cc (simd_clone_clauses_extract): Likewise. gcc/fortran/ChangeLog: * lang.opt (Wopenmp): Add, enabled by dafault and documented in C. * openmp.cc (gfc_match_omp_declare_target, resolve_positive_int_expr, resolve_nonnegative_int_expr, resolve_omp_clauses, gfc_resolve_omp_do_blocks): Use OPT_Wopenmp with gfc_warning{,_now}.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/parser.cc16
-rw-r--r--gcc/cp/semantics.cc18
2 files changed, 19 insertions, 15 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index e4e2fea..2464d1a 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -41161,7 +41161,7 @@ cp_parser_omp_clause_dist_schedule (cp_parser *parser, tree list,
/* check_no_duplicate_clause (list, OMP_CLAUSE_DIST_SCHEDULE,
"dist_schedule", location); */
if (omp_find_clause (list, OMP_CLAUSE_DIST_SCHEDULE))
- warning_at (location, 0, "too many %qs clauses", "dist_schedule");
+ warning_at (location, OPT_Wopenmp, "too many %qs clauses", "dist_schedule");
OMP_CLAUSE_CHAIN (c) = list;
return c;
@@ -43233,7 +43233,7 @@ cp_parser_omp_depobj (cp_parser *parser, cp_token *pragma_tok)
&& destobj != error_mark_node
&& !operand_equal_p (destobj, depobj, OEP_MATCH_SIDE_EFFECTS
| OEP_LEXICOGRAPHIC))
- warning_at (EXPR_LOC_OR_LOC (destobj, c_loc), 0,
+ warning_at (EXPR_LOC_OR_LOC (destobj, c_loc), OPT_Wopenmp,
"the %<destroy%> expression %qE should be the same "
"as the %<depobj%> argument %qE", destobj, depobj);
if (!c_parens.require_close (parser))
@@ -44106,8 +44106,9 @@ cp_parser_omp_scan_loop_body (cp_parser *parser)
substmt = cp_parser_omp_structured_block_sequence (parser, PRAGMA_OMP_SCAN);
else
{
- warning_at (tok->location, 0, "%<#pragma omp scan%> with zero preceding "
- "executable statements");
+ warning_at (tok->location, OPT_Wopenmp,
+ "%<#pragma omp scan%> with zero preceding executable "
+ "statements");
substmt = build_empty_stmt (tok->location);
}
substmt = build2 (OMP_SCAN, void_type_node, substmt, NULL_TREE);
@@ -44153,8 +44154,9 @@ cp_parser_omp_scan_loop_body (cp_parser *parser)
else
{
if (found_scan)
- warning_at (tok->location, 0, "%<#pragma omp scan%> with zero "
- "succeeding executable statements");
+ warning_at (tok->location, OPT_Wopenmp,
+ "%<#pragma omp scan%> with zero succeeding executable "
+ "statements");
substmt = build_empty_stmt (tok->location);
}
substmt = build2_loc (tok->location, OMP_SCAN, void_type_node, substmt,
@@ -47851,7 +47853,7 @@ cp_parser_omp_assumption_clauses (cp_parser *parser, cp_token *pragma_tok,
}
else if (startswith (p, "ext_"))
{
- warning_at (cloc, 0, "unknown assumption clause %qs", p);
+ warning_at (cloc, OPT_Wopenmp, "unknown assumption clause %qs", p);
cp_lexer_consume_token (parser->lexer);
if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN))
for (size_t n = cp_parser_skip_balanced_tokens (parser, 1) - 1;
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index f0a8372..3bf5864 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -7561,7 +7561,9 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
"positive");
break;
default:
- warning_at (OMP_CLAUSE_LOCATION (c), 0,
+ warning_at (OMP_CLAUSE_LOCATION (c),
+ (flag_openmp || flag_openmp_simd)
+ ? OPT_Wopenmp : 0,
"%qs value must be positive",
omp_clause_code_name
[OMP_CLAUSE_CODE (c)]);
@@ -7596,7 +7598,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (TREE_CODE (t) == INTEGER_CST
&& tree_int_cst_sgn (t) != 1)
{
- warning_at (OMP_CLAUSE_LOCATION (c), 0,
+ warning_at (OMP_CLAUSE_LOCATION (c), OPT_Wopenmp,
"%qs value must be positive",
omp_clause_code_name
[OMP_CLAUSE_CODE (c)]);
@@ -7610,7 +7612,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
&& TREE_CODE (upper) == INTEGER_CST
&& tree_int_cst_lt (upper, t))
{
- warning_at (OMP_CLAUSE_LOCATION (c), 0,
+ warning_at (OMP_CLAUSE_LOCATION (c), OPT_Wopenmp,
"%<num_teams%> lower bound %qE bigger "
"than upper bound %qE", t, upper);
t = NULL_TREE;
@@ -7643,7 +7645,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (TREE_CODE (t) == INTEGER_CST
&& tree_int_cst_sgn (t) != 1)
{
- warning_at (OMP_CLAUSE_LOCATION (c), 0,
+ warning_at (OMP_CLAUSE_LOCATION (c), OPT_Wopenmp,
"chunk size value must be positive");
t = integer_one_node;
}
@@ -7739,7 +7741,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (TREE_CODE (t) == INTEGER_CST
&& tree_int_cst_sgn (t) != 1)
{
- warning_at (OMP_CLAUSE_LOCATION (c), 0,
+ warning_at (OMP_CLAUSE_LOCATION (c), OPT_Wopenmp,
"%<thread_limit%> value must be positive");
t = integer_one_node;
}
@@ -7935,7 +7937,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
}
else if (bitmap_bit_p (&aligned_head, DECL_UID (t)))
{
- warning_at (OMP_CLAUSE_LOCATION (c), 0,
+ warning_at (OMP_CLAUSE_LOCATION (c), OPT_Wopenmp,
"%qD appears more than once in %<allocate%> clauses",
t);
remove = true;
@@ -8707,7 +8709,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (TREE_CODE (t) == INTEGER_CST
&& tree_int_cst_sgn (t) != 1)
{
- warning_at (OMP_CLAUSE_LOCATION (c), 0,
+ warning_at (OMP_CLAUSE_LOCATION (c), OPT_Wopenmp,
"%<grainsize%> value must be positive");
t = integer_one_node;
}
@@ -8737,7 +8739,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
if (TREE_CODE (t) == INTEGER_CST
&& tree_int_cst_sgn (t) == -1)
{
- warning_at (OMP_CLAUSE_LOCATION (c), 0,
+ warning_at (OMP_CLAUSE_LOCATION (c), OPT_Wopenmp,
"%<priority%> value must be non-negative");
t = integer_one_node;
}