From patchwork Fri Nov 24 13:51:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1868163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4ScGcb5mRBz1ySk for ; Sat, 25 Nov 2023 00:51:59 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 95BBC385C6D9 for ; Fri, 24 Nov 2023 13:51:52 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 516CB3858D32; Fri, 24 Nov 2023 13:51:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 516CB3858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 516CB3858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=68.232.137.180 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700833901; cv=none; b=t9DyAVaqH+jmiYtrD9rKO+Xjd7FwQsq3fGU+SysFUhkxShPP/ZwnhPyeW+PZo+xwDqe4KorwX+dLgeBf9cwVKkqsNH+0MLey5IjUGcQJ6Oro9MxodIkWt18UdDqYRH75LidsLYTEbaYgob4aGmz9fRE1++uhibgghzC1fgng9HE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700833901; c=relaxed/simple; bh=Idjd1jhpRqhN14vT/51gURW1VW67s6/NZpj7jXb9z9c=; h=Message-ID:Date:MIME-Version:To:From:Subject; b=lhF308FBwwrAFY+QVm1CREK70oGAmUcpi/Toj2gwUMrtsxCu2BZ5yArEAl34Qon/IPOhtxZheYVvp1ATH5jc95/ttLUDpF0i1SBx7xALbvLJbI951rPcqz1tcaXi+1sqvg49BQdYCY6k2V2IbiQPa3tBapRe46CcetuWnT19krw= ARC-Authentication-Results: i=1; server2.sourceware.org X-CSE-ConnectionGUID: wM2o1yxQSi+6l/JV3dc3BQ== X-CSE-MsgGUID: l09OWRQnTtGFqPgYH8yBYg== X-IronPort-AV: E=Sophos;i="6.04,224,1695715200"; d="diff'?scan'208";a="23619168" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 24 Nov 2023 05:51:34 -0800 IronPort-SDR: 9IozE919hwmTzHYRKII5EpHgxCgCqi4L1t0AKjjbJ2FZFQ1MQ7r4UY859xzIRTHOtwcsLv+kxQ +RosgDCMCoDJ1HTGUJAJAUOCGwOXTnywJe6gHeCoyla4i9LESVofETQhme5vr+rrKGgvazLEMn QC4C1yI6f+DeJkUbp+3Gk+qfXqoWEdKTYMFDjMZZ/tAuBSC9Mc46TnDzLdu4TpAeh7hNG6fK+e qusoRGKTZ4liiSrE9oBh8K1XuRcHRnf8OYoiYHHWJDmfUfY42aTkbYdRnArZXUkDkZ9RsvhUsv +EA= Message-ID: <958dc0d6-7b1f-4a03-b7d4-1e13b47a545b@codesourcery.com> Date: Fri, 24 Nov 2023 14:51:28 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches , fortran , Jakub Jelinek From: Tobias Burnus Subject: [patch] OpenMP: Add -Wopenmp and use it X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-14.mgc.mentorg.com (139.181.222.14) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Following the general trend to add a "[-W...]" to the warning messages for both better grouping of the warnings and - more importantly - for providing a means to silence such a warning (or to -Werror= them explicitly), this patch replaces several '0' by OPT_Wopenmp. Comments or remarks before I commit it? Tobias PS: This does not cover all OpenMP warnings: Besides those '0' that I have missed, there are also some warnings which use a different -W... - I have not checked whether their current -W... value or -Wopenmp makes more sense for them. ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 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_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): 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}. gcc/c-family/c.opt | 4 ++++ gcc/c/c-parser.cc | 38 +++++++++++++++++++++++--------------- gcc/cp/parser.cc | 14 ++++++++------ gcc/cp/semantics.cc | 18 ++++++++++-------- gcc/doc/invoke.texi | 7 ++++++- gcc/fortran/lang.opt | 4 ++++ gcc/fortran/openmp.cc | 32 +++++++++++++++++++------------- gcc/gimplify.cc | 4 ++-- gcc/omp-expand.cc | 11 ++++++----- gcc/omp-general.cc | 4 ++-- gcc/omp-low.cc | 29 +++++++++++++++-------------- gcc/omp-simd-clone.cc | 8 ++++---- 12 files changed, 103 insertions(+), 70 deletions(-) diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 3848f378de1..c3d45a6ed96 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -1175,6 +1175,10 @@ Wopenacc-parallelism C C++ Var(warn_openacc_parallelism) Warning Warn about potentially suboptimal choices related to OpenACC parallelism. +Wopenmp +C ObjC C++ ObjC++ Warning Var(warn_openmp) Init(1) +Warn about suspicious OpenMP code + Wopenmp-simd C C++ Var(warn_openmp_simd) Warning LangEnabledBy(C C++,Wall) Warn if a simd directive is overridden by the vectorizer cost model. diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 371dd29557b..f493d764627 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -16071,7 +16071,7 @@ c_parser_omp_clause_num_threads (c_parser *parser, tree list) protected_set_expr_location (c, expr_loc); if (c == boolean_true_node) { - warning_at (expr_loc, 0, + warning_at (expr_loc, OPT_Wopenmp, "% value must be positive"); t = integer_one_node; } @@ -16132,7 +16132,8 @@ c_parser_omp_clause_num_tasks (c_parser *parser, tree list) SET_EXPR_LOCATION (c, expr_loc); if (c == boolean_true_node) { - warning_at (expr_loc, 0, "% value must be positive"); + warning_at (expr_loc, OPT_Wopenmp, + "% value must be positive"); t = integer_one_node; } @@ -16193,7 +16194,8 @@ c_parser_omp_clause_grainsize (c_parser *parser, tree list) SET_EXPR_LOCATION (c, expr_loc); if (c == boolean_true_node) { - warning_at (expr_loc, 0, "% value must be positive"); + warning_at (expr_loc, OPT_Wopenmp, + "% value must be positive"); t = integer_one_node; } @@ -16241,7 +16243,8 @@ c_parser_omp_clause_priority (c_parser *parser, tree list) SET_EXPR_LOCATION (c, expr_loc); if (c == boolean_true_node) { - warning_at (expr_loc, 0, "% value must be non-negative"); + warning_at (expr_loc, OPT_Wopenmp, + "% value must be non-negative"); t = integer_one_node; } @@ -17383,7 +17386,7 @@ c_parser_omp_clause_schedule (c_parser *parser, tree list) protected_set_expr_location (s, loc); if (s == boolean_true_node) { - warning_at (loc, 0, + warning_at (loc, OPT_Wopenmp, "chunk size value must be positive"); t = integer_one_node; } @@ -17545,7 +17548,8 @@ c_parser_omp_clause_num_teams (c_parser *parser, tree list) protected_set_expr_location (c, upper_loc); if (c == boolean_true_node) { - warning_at (upper_loc, 0, "% value must be positive"); + warning_at (upper_loc, OPT_Wopenmp, + "% value must be positive"); upper = integer_one_node; } if (lower) @@ -17555,15 +17559,17 @@ c_parser_omp_clause_num_teams (c_parser *parser, tree list) protected_set_expr_location (c, lower_loc); if (c == boolean_true_node) { - warning_at (lower_loc, 0, "% value must be positive"); + warning_at (lower_loc, OPT_Wopenmp, + "% value must be positive"); lower = NULL_TREE; } else if (TREE_CODE (lower) == INTEGER_CST && TREE_CODE (upper) == INTEGER_CST && tree_int_cst_lt (upper, lower)) { - warning_at (lower_loc, 0, "% lower bound %qE bigger " - "than upper bound %qE", lower, upper); + warning_at (lower_loc, OPT_Wopenmp, + "% lower bound %qE bigger than upper " + "bound %qE", lower, upper); lower = NULL_TREE; } } @@ -17610,7 +17616,8 @@ c_parser_omp_clause_thread_limit (c_parser *parser, tree list) protected_set_expr_location (c, expr_loc); if (c == boolean_true_node) { - warning_at (expr_loc, 0, "% value must be positive"); + warning_at (expr_loc, OPT_Wopenmp, + "% value must be positive"); t = integer_one_node; } @@ -18840,7 +18847,7 @@ c_parser_omp_clause_dist_schedule (c_parser *parser, tree list) /* check_no_duplicate_clause (list, OMP_CLAUSE_DIST_SCHEDULE, "dist_schedule"); */ if (omp_find_clause (list, OMP_CLAUSE_DIST_SCHEDULE)) - warning_at (loc, 0, "too many %qs clauses", "dist_schedule"); + warning_at (loc, OPT_Wopenmp, "too many %qs clauses", "dist_schedule"); if (t == error_mark_node) return list; @@ -21893,7 +21900,7 @@ c_parser_omp_scan_loop_body (c_parser *parser, bool open_brace_parsed) substmt = c_parser_omp_structured_block_sequence (parser, PRAGMA_OMP_SCAN); else { - warning_at (c_parser_peek_token (parser)->location, 0, + warning_at (c_parser_peek_token (parser)->location, OPT_Wopenmp, "%<#pragma omp scan%> with zero preceding executable " "statements"); substmt = build_empty_stmt (loc); @@ -21941,8 +21948,9 @@ c_parser_omp_scan_loop_body (c_parser *parser, bool open_brace_parsed) else { if (found_scan) - warning_at (loc, 0, "%<#pragma omp scan%> with zero succeeding " - "executable statements"); + warning_at (loc, OPT_Wopenmp, + "%<#pragma omp scan%> with zero succeeding executable " + "statements"); substmt = build_empty_stmt (loc); } substmt = build2 (OMP_SCAN, void_type_node, substmt, clauses); @@ -26248,7 +26256,7 @@ c_parser_omp_assumption_clauses (c_parser *parser, bool is_assume) } else if (startswith (p, "ext_")) { - warning_at (cloc, 0, "unknown assumption clause %qs", p); + warning_at (cloc, OPT_Wopenmp, "unknown assumption clause %qs", p); c_parser_consume_token (parser); if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)) { diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index f6d088bc73f..052560331ef 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; @@ -44083,8 +44083,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); @@ -44130,8 +44131,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, @@ -47828,7 +47830,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 f0a8372683d..3bf586453dc 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, "% 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, "% 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 % 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, "% 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, "% value must be non-negative"); t = integer_one_node; } diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 7801f80ff3c..23e2b7415b1 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -383,7 +383,7 @@ Objective-C and Objective-C++ Dialects}. -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} -Wnull-dereference -Wno-odr -Wopenacc-parallelism --Wopenmp-simd +-Wopenmp -Wopenmp-simd -Wno-overflow -Woverlength-strings -Wno-override-init-side-effects -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded -Wparentheses -Wno-pedantic-ms-format @@ -9957,6 +9957,11 @@ Enabled by default. @item -Wopenacc-parallelism Warn about potentially suboptimal choices related to OpenACC parallelism. +@opindex Wopenmp +@opindex Wno-openmp +@item -Wno-openmp +Warn about suspicious OpenMP code. + @opindex Wopenmp-simd @opindex Wno-openmp-simd @item -Wopenmp-simd diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt index 08c75394aa0..adcfc280b5a 100644 --- a/gcc/fortran/lang.opt +++ b/gcc/fortran/lang.opt @@ -289,6 +289,10 @@ Wopenacc-parallelism Fortran ; Documented in C +Wopenmp +Fortran +; Documented in C + Wopenmp-simd Fortran ; Documented in C diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 2e2e23d567b..c71014908a2 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see #include "config.h" #include "system.h" #include "coretypes.h" +#include "options.h" #include "gfortran.h" #include "arith.h" #include "match.h" @@ -5553,8 +5554,9 @@ gfc_match_omp_declare_target (void) && !c->lists[OMP_LIST_ENTER] && !c->lists[OMP_LIST_TO] && !c->lists[OMP_LIST_LINK]) - gfc_warning_now (0, "OMP DECLARE TARGET directive at %L with only " - "DEVICE_TYPE clause is ignored", &old_loc); + gfc_warning_now (OPT_Wopenmp, + "OMP DECLARE TARGET directive at %L with only " + "DEVICE_TYPE clause is ignored", &old_loc); gfc_buffer_error (true); @@ -7020,7 +7022,8 @@ resolve_positive_int_expr (gfc_expr *expr, const char *clause) if (expr->expr_type == EXPR_CONSTANT && expr->ts.type == BT_INTEGER && mpz_sgn (expr->value.integer) <= 0) - gfc_warning (0, "INTEGER expression of %s clause at %L must be positive", + gfc_warning ((flag_openmp || flag_openmp_simd) ? OPT_Wopenmp : 0, + "INTEGER expression of %s clause at %L must be positive", clause, &expr->where); } @@ -7031,8 +7034,9 @@ resolve_nonnegative_int_expr (gfc_expr *expr, const char *clause) if (expr->expr_type == EXPR_CONSTANT && expr->ts.type == BT_INTEGER && mpz_sgn (expr->value.integer) < 0) - gfc_warning (0, "INTEGER expression of %s clause at %L must be " - "non-negative", clause, &expr->where); + gfc_warning ((flag_openmp || flag_openmp_simd) ? OPT_Wopenmp : 0, + "INTEGER expression of %s clause at %L must be non-negative", + clause, &expr->where); } /* Emits error when symbol is pointer, cray pointer or cray pointee @@ -7595,8 +7599,8 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, else if (expr->expr_type == EXPR_CONSTANT && expr->ts.type == BT_INTEGER && mpz_sgn (expr->value.integer) <= 0) - gfc_warning (0, "INTEGER expression of SCHEDULE clause's chunk_size " - "at %L must be positive", &expr->where); + gfc_warning (OPT_Wopenmp, "INTEGER expression of SCHEDULE clause's " + "chunk_size at %L must be positive", &expr->where); } if (omp_clauses->sched_kind != OMP_SCHED_NONE && omp_clauses->sched_nonmonotonic) @@ -7906,8 +7910,8 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, } if (n->sym->mark == 1) { - gfc_warning (0, "%qs appears more than once in % " - "at %L" , n->sym->name, &n->where); + gfc_warning (OPT_Wopenmp, "%qs appears more than once in " + "% at %L" , n->sym->name, &n->where); /* We have already seen this variable so it is a duplicate. Remove it. */ if (prev != NULL && prev->next == n) @@ -8905,8 +8909,8 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, && omp_clauses->num_teams_upper->expr_type == EXPR_CONSTANT && mpz_cmp (omp_clauses->num_teams_lower->value.integer, omp_clauses->num_teams_upper->value.integer) > 0) - gfc_warning (0, "NUM_TEAMS lower bound at %L larger than upper bound at %L", - &omp_clauses->num_teams_lower->where, + gfc_warning (OPT_Wopenmp, "NUM_TEAMS lower bound at %L larger than upper " + "bound at %L", &omp_clauses->num_teams_lower->where, &omp_clauses->num_teams_upper->where); if (omp_clauses->device) resolve_scalar_int_expr (omp_clauses->device, "DEVICE"); @@ -9743,13 +9747,15 @@ gfc_resolve_omp_do_blocks (gfc_code *code, gfc_namespace *ns) else { if (block->op == EXEC_OMP_SCAN) - gfc_warning (0, "!$OMP SCAN at %L with zero executable " + gfc_warning (OPT_Wopenmp, + "!$OMP SCAN at %L with zero executable " "statements in preceding structured block " "sequence", &block->loc); if ((block->op == EXEC_OMP_SCAN && !block->next) || (block->next && block->next->op == EXEC_OMP_SCAN && !block->next->next)) - gfc_warning (0, "!$OMP SCAN at %L with zero executable " + gfc_warning (OPT_Wopenmp, + "!$OMP SCAN at %L with zero executable " "statements in succeeding structured block " "sequence", block->op == EXEC_OMP_SCAN ? &block->loc : &block->next->loc); diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index d52d71b9b6b..02f85e7109b 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -14382,7 +14382,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) OMP_CLAUSE_LASTPRIVATE)) if (OMP_CLAUSE_DECL (c3) == decl) { - warning_at (OMP_CLAUSE_LOCATION (c3), 0, + warning_at (OMP_CLAUSE_LOCATION (c3), OPT_Wopenmp, "conditional % on loop " "iterator %qD ignored", decl); OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c3) = 0; @@ -14490,7 +14490,7 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) OMP_CLAUSE_LASTPRIVATE)) if (OMP_CLAUSE_DECL (c3) == decl) { - warning_at (OMP_CLAUSE_LOCATION (c3), 0, + warning_at (OMP_CLAUSE_LOCATION (c3), OPT_Wopenmp, "conditional % on loop " "iterator %qD ignored", decl); OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c3) = 0; diff --git a/gcc/omp-expand.cc b/gcc/omp-expand.cc index 5c6a7f2e381..8281ec67e00 100644 --- a/gcc/omp-expand.cc +++ b/gcc/omp-expand.cc @@ -3416,8 +3416,9 @@ expand_omp_ordered_sink (gimple_stmt_iterator *gsi, struct omp_for_data *fd, forward = tree_int_cst_sgn (step) != -1; } if (forward ^ OMP_CLAUSE_DOACROSS_SINK_NEGATIVE (deps)) - warning_at (loc, 0, "%qs clause with % modifier " - "waiting for lexically later iteration", + warning_at (loc, OPT_Wopenmp, + "%qs clause with % modifier " + "waiting for lexically later iteration", OMP_CLAUSE_DOACROSS_DEPEND (c) ? "depend" : "doacross"); break; @@ -3555,9 +3556,9 @@ expand_omp_ordered_sink (gimple_stmt_iterator *gsi, struct omp_for_data *fd, build_int_cst (itype, 0)); if (integer_zerop (t) && !warned_step) { - warning_at (loc, 0, "%qs clause with % modifier " - "refers to iteration never in the iteration " - "space", + warning_at (loc, OPT_Wopenmp, + "%qs clause with % modifier refers to " + "iteration never in the iteration space", OMP_CLAUSE_DOACROSS_DEPEND (c) ? "depend" : "doacross"); warned_step = true; diff --git a/gcc/omp-general.cc b/gcc/omp-general.cc index b88d5930aab..8241574651d 100644 --- a/gcc/omp-general.cc +++ b/gcc/omp-general.cc @@ -1201,12 +1201,12 @@ omp_check_context_selector (location_t loc, tree ctx) return error_mark_node; } else if (TREE_PURPOSE (t2)) - warning_at (loc, 0, + warning_at (loc, OPT_Wopenmp, "unknown property %qs of %qs selector", IDENTIFIER_POINTER (TREE_PURPOSE (t2)), props[i].selector); else - warning_at (loc, 0, + warning_at (loc, OPT_Wopenmp, "unknown property %qE of %qs selector", TREE_VALUE (t2), props[i].selector); break; diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc index 161bcfeec05..dd802ca37a6 100644 --- a/gcc/omp-low.cc +++ b/gcc/omp-low.cc @@ -2844,12 +2844,13 @@ scan_omp_for (gomp_for *stmt, omp_context *outer_ctx) tree_code outer_op = OMP_CLAUSE_REDUCTION_CODE (outer_clause); if (outer_var == local_var && outer_op != local_op) { - warning_at (OMP_CLAUSE_LOCATION (local_clause), 0, - "conflicting reduction operations for %qE", - local_var); - inform (OMP_CLAUSE_LOCATION (outer_clause), - "location of the previous reduction for %qE", - outer_var); + if (warning_at (OMP_CLAUSE_LOCATION (local_clause), + OPT_Wopenmp, "conflicting reduction " + "operations for %qE", + local_var)) + inform (OMP_CLAUSE_LOCATION (outer_clause), + "location of the previous reduction for %qE", + outer_var); } if (outer_var == local_var) { @@ -2880,7 +2881,7 @@ scan_omp_for (gomp_for *stmt, omp_context *outer_ctx) } } if (!found) - warning_at (gimple_location (curr_loop->stmt), 0, + warning_at (gimple_location (curr_loop->stmt), OPT_Wopenmp, "nested loop in reduction needs " "reduction clause for %qE", local_var); @@ -3427,12 +3428,12 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx) ctx->cancellable = true; if (omp_find_clause (gimple_omp_for_clauses (ctx->stmt), OMP_CLAUSE_NOWAIT)) - warning_at (gimple_location (stmt), 0, + warning_at (gimple_location (stmt), OPT_Wopenmp, "% inside " "% for construct"); if (omp_find_clause (gimple_omp_for_clauses (ctx->stmt), OMP_CLAUSE_ORDERED)) - warning_at (gimple_location (stmt), 0, + warning_at (gimple_location (stmt), OPT_Wopenmp, "% inside " "% for construct"); } @@ -3452,7 +3453,7 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx) if (omp_find_clause (gimple_omp_sections_clauses (ctx->stmt), OMP_CLAUSE_NOWAIT)) - warning_at (gimple_location (stmt), 0, + warning_at (gimple_location (stmt), OPT_Wopenmp, "% inside " "% sections construct"); } @@ -3465,7 +3466,7 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx) if (omp_find_clause (gimple_omp_sections_clauses (ctx->outer->stmt), OMP_CLAUSE_NOWAIT)) - warning_at (gimple_location (stmt), 0, + warning_at (gimple_location (stmt), OPT_Wopenmp, "% inside " "% sections construct"); } @@ -3928,7 +3929,7 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx) if (c && OMP_CLAUSE_DEVICE_ANCESTOR (c)) break; } - warning_at (gimple_location (stmt), 0, + warning_at (gimple_location (stmt), OPT_Wopenmp, "%qs construct inside of %qs region", stmt_name, ctx_stmt_name); } @@ -9783,8 +9784,8 @@ lower_omp_ordered_clauses (gimple_stmt_iterator *gsi_p, gomp_ordered *ord_stmt, wi::abs (wi::to_wide (fd.loops[i].step)), UNSIGNED)) { - warning_at (OMP_CLAUSE_LOCATION (c), 0, - "ignoring sink clause with offset that is not " + warning_at (OMP_CLAUSE_LOCATION (c), OPT_Wopenmp, + "ignoring % clause with offset that is not " "a multiple of the loop step"); remove = true; goto next_ordered_clause; diff --git a/gcc/omp-simd-clone.cc b/gcc/omp-simd-clone.cc index 57b0793e1ad..3fbe4281252 100644 --- a/gcc/omp-simd-clone.cc +++ b/gcc/omp-simd-clone.cc @@ -387,13 +387,13 @@ simd_clone_clauses_extract (struct cgraph_node *node, tree clauses, step = fold_convert (ssizetype, step); if (!tree_fits_shwi_p (step)) { - warning_at (OMP_CLAUSE_LOCATION (t), 0, + warning_at (OMP_CLAUSE_LOCATION (t), OPT_Wopenmp, "ignoring large linear step"); return NULL; } else if (integer_zerop (step)) { - warning_at (OMP_CLAUSE_LOCATION (t), 0, + warning_at (OMP_CLAUSE_LOCATION (t), OPT_Wopenmp, "ignoring zero linear step"); return NULL; } @@ -455,7 +455,7 @@ simd_clone_clauses_extract (struct cgraph_node *node, tree clauses, out: if (TYPE_ATOMIC (TREE_TYPE (TREE_TYPE (node->decl)))) { - warning_at (DECL_SOURCE_LOCATION (node->decl), 0, + warning_at (DECL_SOURCE_LOCATION (node->decl), OPT_Wopenmp, "ignoring %<#pragma omp declare simd%> on function " "with %<_Atomic%> qualified return type"); return NULL; @@ -465,7 +465,7 @@ simd_clone_clauses_extract (struct cgraph_node *node, tree clauses, if (TYPE_ATOMIC (args[argno]) && clone_info->args[argno].arg_type != SIMD_CLONE_ARG_TYPE_UNIFORM) { - warning_at (DECL_SOURCE_LOCATION (node->decl), 0, + warning_at (DECL_SOURCE_LOCATION (node->decl), OPT_Wopenmp, "ignoring %<#pragma omp declare simd%> on function " "with %<_Atomic%> qualified non-% argument"); args.release ();