From patchwork Mon Aug 29 09:24:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 811 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp1330983wro; Mon, 29 Aug 2022 02:26:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR6ld91cGjB98WveyM/MMBoUMxZDzF/NF/wuOYkRqSe4VoNus7ivfcUO8r3aQwExFI8DNlL1 X-Received: by 2002:a05:6402:4441:b0:43d:5bcf:afa0 with SMTP id o1-20020a056402444100b0043d5bcfafa0mr15518635edb.91.1661765187869; Mon, 29 Aug 2022 02:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661765187; cv=none; d=google.com; s=arc-20160816; b=BrHHKF9s7MxU6UYM5p/A2uepPJ4vqA4nNBWCRHF7qzo1O9OynbqqwOPwhzEiNCjSO3 N48xunIbbyG/AI+mFNWVJ8W5JJyGAFOIKt+iZopulSjd6QARJXNDzSA9TjY694hRlpj+ NfUrcSZ1/5buhnnL7ybggOGSeN59uSAxLHf6IY79C0aUglbCUOQ4K6ONnIwL/rm7Z31A ONYLVXcIIuGVOtkFdIxapfxmRigob0vHRdCqvS8/mhIGlBZv3u5b2AKQrSLAeMKYlYFz LYG73/bNNJ95A/alkvwurE8pTV/PemxDg7NDoQO8V8uIz5YGooGdBK53DY8RMGOdjWSq RaxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:to:from :content-language:user-agent:mime-version:date:message-id :ironport-sdr:dmarc-filter:delivered-to; bh=0InuvJS3vxHtrLVJzIOtlkQdGmPLpcHY+mdZR2N4aTo=; b=YLwtQ+9V5dBJJTQgOdCr7zR2P77rrDxw6cbnHyrGBKSJ67kYg7J1FGWr9K2JH4cyGf EiOrh1OH2bdXjOfXylTZn5cRb+ez4qAdssMEkkAUVmXRjQtOwdrPpP0BHcQdJ87XJdub uBv3ckmsRZEwqKhZVV0eM6H2JrEkYXxLNDT4A9+CqBSqTwEyzwImbEL7OOTujMZWCDj9 2Q8hrOK2Tr1Kn/AiIiYn/iEVhSsdHsD7XCNb9stDadp+xRJv+WqOfsmdFQHOQsO9eHe1 ZKgQaB1GJsJgb1ZbtubWZEzTyKp9hzSfSBIzlztXmTzemylm9ShFfqPc3UW0YaoNT1+w svVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id di22-20020a170906731600b007306ac0faa0si7073353ejc.615.2022.08.29.02.26.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 02:26:27 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8C1F83857B85 for ; Mon, 29 Aug 2022 09:25:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id E8CF13858D3C; Mon, 29 Aug 2022 09:25:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E8CF13858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.93,272,1654588800"; d="diff'?scan'208,217";a="82092318" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 29 Aug 2022 01:25:00 -0800 IronPort-SDR: CHFSMR+ydQzVgjNiJZs6+RbGmoQbF4JuqmrPN7brKXmaFsASkcSEzAMbDE53O5s/uSWYkSYRPR +IeVc132IOsAHvVHuziGbSmFuEv1MC+SmRr0J550JPCGqZIATtyKUFZncK7XGB7fMaz1RyHCNR D5T+SsKfU1B1HL9AMOaKZxb4zbrA9VQUfOkz2DKlDSaaUZXBDpK9nriCxAziTyb6JJiCI5g/uK BqFXos7YAt94uYVpsHhkWkqlFla+isg+W9Vu1J8/oTbcjMLulj4Yn3W1pfN/hdayOQEMThdh+b NSY= Message-ID: Date: Mon, 29 Aug 2022 11:24:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Content-Language: en-US From: Tobias Burnus To: gcc-patches , fortran , Jakub Jelinek Subject: [Patch] OpenMP: Document ompx warnings + add Fortran omx warning [PR106670] X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-15.mgc.mentorg.com (139.181.222.15) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE, 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-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742487093500293454?= X-GMAIL-MSGID: =?utf-8?q?1742487093500293454?= (Patch + RFC.) OpenMP 5.2 has 'ompx' and (for fixed source form Fortran) 'omx' as sentinel to provide a defined namespace for vendor extensions. The behavior when encountering an unknown directive with ompx/omp sentinel (or an unknown clause with ompx_ prefix) is implementation defined. For unknown clauses there will be always an error in GCC. For sentinels, GCC compiles the code and ignores the directive. From the user perspective, either silently ignoring the directive or showing a warning or showing an erroring is best - depending on the semantic of that vendor extension. As the semantic is not known, providing a means to warn makes most sense. For warning, we can either show a - specific message for ompx/omx - or a - generic message And we can either use some existing generic flag (unknown pragmas, attributes, suprising behavior etc.), depending on language and source language (C, C++, Fortran fixed/free)- or add & use a specific -W flag. The attached patch just documents the existing warning behavior, which is quite diverse + adds testcases for them. As fixed-form Fortran had no warning, a new warning with a specific message was added. (Cf. testcases in the patch for what's shown as message.) OK for mainline - or other ideas how to handle this topic best? Tobias ----------------- 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: Document ompx warnings + add Fortran omx warning [PR106670] omp/ompx sentinels are for vendor extensions; as they might be required for the correctness of the program, a warning should be printable. This patch documents in the OpenMP 5.2 table the existing warnings, including the new warning for for fixed source form Fortran. PR fortran/106670 gcc/fortran/ChangeLog: * scanner.cc (skip_fixed_omp_sentinel): Add -Wsurprising warning for 'omx' sentinels with -fopenmp. * invoke.texi (-Wsurprising): Document additional warning case. libgomp/ChangeLog: * libgomp.texi (OpenMP 5.2): Add comment to ompx/omx entry. gcc/testsuite/ChangeLog: * c-c++-common/gomp/ompx-1.c: New test. * c-c++-common/gomp/ompx-2.c: New test. * g++.dg/gomp/ompx-attrs-1.C: New test. * gfortran.dg/gomp/ompx-1.f90: New test. * gfortran.dg/gomp/omx-1.f: New test. * gfortran.dg/gomp/omx-2.f: New test. gcc/fortran/invoke.texi | 5 +++++ gcc/fortran/scanner.cc | 8 ++++++-- gcc/testsuite/c-c++-common/gomp/ompx-1.c | 4 ++++ gcc/testsuite/c-c++-common/gomp/ompx-2.c | 5 +++++ gcc/testsuite/g++.dg/gomp/ompx-attrs-1.C | 7 +++++++ gcc/testsuite/gfortran.dg/gomp/ompx-1.f90 | 2 ++ gcc/testsuite/gfortran.dg/gomp/omx-1.f | 7 +++++++ gcc/testsuite/gfortran.dg/gomp/omx-2.f | 9 +++++++++ libgomp/libgomp.texi | 8 +++++++- 9 files changed, 52 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index 4d1e0d6b513..58502d38ac8 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -1092,6 +1092,11 @@ The type of a function result is declared more than once with the same type. If @item A @code{CHARACTER} variable is declared with negative length. + +@item +With @option{-fopenmp}, for fixed-form source code, when an @code{omx} +vendor-extension sentinel is encountered. (The equivalent @code{ompx}, +used in free-form source code, is diagnosed by default.) @end itemize @item -Wtabs diff --git a/gcc/fortran/scanner.cc b/gcc/fortran/scanner.cc index 2dff2514700..fa1d9cba394 100644 --- a/gcc/fortran/scanner.cc +++ b/gcc/fortran/scanner.cc @@ -982,8 +982,9 @@ static bool skip_fixed_omp_sentinel (locus *start) { gfc_char_t c; - if (((c = next_char ()) == 'm' || c == 'M') - && ((c = next_char ()) == 'p' || c == 'P')) + if ((c = next_char ()) != 'm' && c != 'M') + return false; + if ((c = next_char ()) == 'p' || c == 'P') { c = next_char (); if (c != '\n' @@ -1005,6 +1006,9 @@ skip_fixed_omp_sentinel (locus *start) } } } + else if (UNLIKELY (c == 'x' || c == 'X')) + gfc_warning_now (OPT_Wsurprising, + "Ignoring '!$omx' vendor-extension sentinel at %C"); return false; } diff --git a/gcc/testsuite/c-c++-common/gomp/ompx-1.c b/gcc/testsuite/c-c++-common/gomp/ompx-1.c new file mode 100644 index 00000000000..9758d0f0cae --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/ompx-1.c @@ -0,0 +1,4 @@ +void f(void) +{ + #pragma ompx some_vendor_extension +} diff --git a/gcc/testsuite/c-c++-common/gomp/ompx-2.c b/gcc/testsuite/c-c++-common/gomp/ompx-2.c new file mode 100644 index 00000000000..4b66b0e2b1c --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/ompx-2.c @@ -0,0 +1,5 @@ +/* { dg-additional-options "-Wunknown-pragmas" } */ +void f(void) +{ + #pragma ompx some_vendor_extension /* { dg-warning "-:ignoring '#pragma ompx some_vendor_extension'" } */ +} diff --git a/gcc/testsuite/g++.dg/gomp/ompx-attrs-1.C b/gcc/testsuite/g++.dg/gomp/ompx-attrs-1.C new file mode 100644 index 00000000000..2e9fc0b591f --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/ompx-attrs-1.C @@ -0,0 +1,7 @@ +// { dg-do compile { target c++11 } } + +void +foo () +{ + [[ompx::directive(some_vendor_extension)]]; /* { dg-warning "attributes at the beginning of statement are ignored" } */ +} diff --git a/gcc/testsuite/gfortran.dg/gomp/ompx-1.f90 b/gcc/testsuite/gfortran.dg/gomp/ompx-1.f90 new file mode 100644 index 00000000000..e5dc6520fd4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/ompx-1.f90 @@ -0,0 +1,2 @@ +!$ompx foo ! { dg-warning "!.OMP at .1. starts a commented line as it neither is followed by a space nor is a continuation line" } +end diff --git a/gcc/testsuite/gfortran.dg/gomp/omx-1.f b/gcc/testsuite/gfortran.dg/gomp/omx-1.f new file mode 100644 index 00000000000..4febf8908bf --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/omx-1.f @@ -0,0 +1,7 @@ +!$omx foo +!$OMX foo +c$oMx foo +c$OMx foo +*$oMx foo +*$OMx foo + end diff --git a/gcc/testsuite/gfortran.dg/gomp/omx-2.f b/gcc/testsuite/gfortran.dg/gomp/omx-2.f new file mode 100644 index 00000000000..3c107d98367 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/omx-2.f @@ -0,0 +1,9 @@ +! { dg-additional-options "-Wsurprising" } + +!$omx foo ! { dg-warning "Ignoring '!.omx' vendor-extension sentinel" } +!$OMX foo ! { dg-warning "Ignoring '!.omx' vendor-extension sentinel" } +c$oMx foo ! { dg-warning "Ignoring '!.omx' vendor-extension sentinel" } +c$OMx foo ! { dg-warning "Ignoring '!.omx' vendor-extension sentinel" } +*$oMx foo ! { dg-warning "Ignoring '!.omx' vendor-extension sentinel" } +*$OMx foo ! { dg-warning "Ignoring '!.omx' vendor-extension sentinel" } + end diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi index 0f2998cf8f1..6298de8254c 100644 --- a/libgomp/libgomp.texi +++ b/libgomp/libgomp.texi @@ -359,7 +359,13 @@ to address of matching mapped list item per 5.1, Sect. 2.21.7.2 @tab N @tab @item @code{omp_in_explicit_task} routine and @emph{implicit-task-var} ICV @tab N @tab @item @code{omp}/@code{ompx}/@code{omx} sentinels and @code{omp_}/@code{ompx_} - namespaces @tab N/A @tab + namespaces @tab N/A + @tab warning for @code{omp/ompx} sentinels@footnote{@code{omp/ompx} + sentinels as C/C++ pragma and C++ attributes are warned for with + @code{-Wunknown-pragmas} (implied by @code{-Wall}) and @code{-Wattributes} + (by default), respectively; for Fortran free-source code, the there is a + warning by default and for fixed-source code with @code{-Wsurprising} + (enabled by @code{-Wall})} @item Clauses on @code{end} directive can be on directive @tab N @tab @item Deprecation of no-argument @code{destroy} clause on @code{depobj} @tab N @tab