]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
OpenMP: Document ompx warnings + add Fortran omx warning [PR106670]
authorTobias Burnus <tobias@codesourcery.com>
Thu, 8 Sep 2022 19:03:21 +0000 (21:03 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Thu, 8 Sep 2022 19:03:21 +0000 (21:03 +0200)
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
gcc/fortran/scanner.cc
gcc/testsuite/c-c++-common/gomp/ompx-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/ompx-2.c [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/ompx-attrs-1.C [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/ompx-1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/omx-1.f [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/omx-2.f [new file with mode: 0644]
libgomp/libgomp.texi

index 4d1e0d6b513640f41d72644f55c306dd484901ac..58502d38ac8772e2467b75e42bdf723c74589c06 100644 (file)
@@ -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
index 2dff2514700b374524258fbeb659893e551a5ecc..fa1d9cba39472d0238f4a643f97a9ce82d08a747 100644 (file)
@@ -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 (file)
index 0000000..9758d0f
--- /dev/null
@@ -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 (file)
index 0000000..4b66b0e
--- /dev/null
@@ -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 (file)
index 0000000..2e9fc0b
--- /dev/null
@@ -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 (file)
index 0000000..e5dc652
--- /dev/null
@@ -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 (file)
index 0000000..4febf89
--- /dev/null
@@ -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 (file)
index 0000000..3c107d9
--- /dev/null
@@ -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
index 8847f3ee59f8ff560ae1e4bf70cb2a17e8148a67..3dc467aade022b0f525a1d60d353aeef920d144b 100644 (file)
@@ -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