From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id 99514385742A; Fri, 9 Sep 2022 09:37:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 99514385742A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662716275; bh=rud52+qdR/ye4yP8mUE+84TGzNom2OT1wSqr4/6Djcs=; h=From:To:Subject:Date:From; b=Q03i2VAyZMq+Qui84W4Z8D1+BCnQPfsM0kU191LE+Lec4laGsEuzGvZCGxSJbEeYE PBY+9+xdUIVHxCZ3XgP2Yoe6OnK6Bi3JDv8WWqXWjygseDt1baqNupmdyUYg2DwHOl 9uEFPINGrcOnQ90ByNHzntlZBEj9UD9CoglN2on4= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tobias Burnus To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-12] OpenMP: Document ompx warnings + add Fortran omx warning [PR106670] X-Act-Checkin: gcc X-Git-Author: Tobias Burnus X-Git-Refname: refs/heads/devel/omp/gcc-12 X-Git-Oldrev: 8b479946d9a32bcd47494c9cb6b121b83e185c40 X-Git-Newrev: fa7e73819ec1d6c62223fe2b36b0ce9da27d669b Message-Id: <20220909093755.99514385742A@sourceware.org> Date: Fri, 9 Sep 2022 09:37:55 +0000 (GMT) List-Id: https://gcc.gnu.org/g:fa7e73819ec1d6c62223fe2b36b0ce9da27d669b commit fa7e73819ec1d6c62223fe2b36b0ce9da27d669b Author: Tobias Burnus Date: Fri Sep 9 11:31:14 2022 +0200 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. (cherry picked from commit 264deecb16abcfc8ca8efe9b94b0ad55febd55cc) Diff: --- gcc/fortran/ChangeLog.omp | 10 ++++++++++ gcc/fortran/invoke.texi | 5 +++++ gcc/fortran/scanner.cc | 8 ++++++-- gcc/testsuite/ChangeLog.omp | 13 +++++++++++++ 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/ChangeLog.omp | 8 ++++++++ libgomp/libgomp.texi | 8 +++++++- 12 files changed, 83 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp index 6d0a243169b..8c89cd5bd43 100644 --- a/gcc/fortran/ChangeLog.omp +++ b/gcc/fortran/ChangeLog.omp @@ -1,3 +1,13 @@ +2022-09-09 Tobias Burnus + + Backport from mainline: + 2022-09-08 Tobias Burnus + + PR fortran/106670 + * scanner.cc (skip_fixed_omp_sentinel): Add -Wsurprising warning + for 'omx' sentinels with -fopenmp. + * invoke.texi (-Wsurprising): Document additional warning case. + 2022-09-06 Tobias Burnus Backport from mainline: diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index c0932f6cd70..d3261f0d061 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..7e5062a13c1 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 (__builtin_expect (c == 'x' || c == 'X', 0)) + gfc_warning_now (OPT_Wsurprising, + "Ignoring '!$omx' vendor-extension sentinel at %C"); return false; } diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index 5fccb81aed8..74b36e20c5a 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,16 @@ +2022-09-09 Tobias Burnus + + Backport from mainline: + 2022-09-08 Tobias Burnus + + PR fortran/106670 + * 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. + 2022-09-08 Tobias Burnus Backport from mainline: 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/ChangeLog.omp b/libgomp/ChangeLog.omp index 62fbddbf677..5779390952f 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,3 +1,11 @@ +2022-09-09 Tobias Burnus + + Backport from mainline: + 2022-09-08 Tobias Burnus + + PR fortran/106670 + * libgomp.texi (OpenMP 5.2): Add comment to ompx/omx entry. + 2022-09-09 Tobias Burnus Backport from mainline: diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi index 10bfb90abb0..0a0bf8aabf1 100644 --- a/libgomp/libgomp.texi +++ b/libgomp/libgomp.texi @@ -361,7 +361,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} + (enabled by default), respectively; for Fortran free-source code, there is + a warning enabled 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