diff mbox series

deprecations in OpenMP 5.0

Message ID 210ee81a-9581-680a-ccfa-781a85507dbb@redhat.com
State New
Headers show
Series deprecations in OpenMP 5.0 | expand

Commit Message

Ulrich Drepper Jan. 2, 2019, 4:58 p.m. UTC
Should we mark the symbols that are deprecated in OpenMP 5.0 as such in
the header?  Yes, this will break code that uses the symbols and -Werror
but this is the standard writers intend, right?  It's easy enough to
work around for the time being.

Aside from the header changes the files implementing the
omp_[gs]et_nested functions had to be changed.  I just use the pragma to
disable the warning temporarily instead of a more global option like
using -Wno-deprecated-declarations in the Makefile.

What do people think about this?


2019-01-02  Ulrich Drepper  <drepper@redhat.com>

       Newly deprecated symbols in OpenMP 5.0.
       * omp.h.in (__GOMP_DEPRECATED): Define.
       Make omp_lock_hint_* enum values, omp_lock_hint_t, omp_set_nested,
       and omp_get_nested with __GOMP_DEPRECATED.
       * fortran.c: Wrap uses of omp_set_nested and omp_get_nested with
       pragmas to ignore -Wdeprecated-declarations warnings.
       * icv.c: Likewise.

Comments

Jakub Jelinek Jan. 2, 2019, 5:21 p.m. UTC | #1
On Wed, Jan 02, 2019 at 05:58:07PM +0100, Ulrich Drepper wrote:
> Should we mark the symbols that are deprecated in OpenMP 5.0 as such in
> the header?  Yes, this will break code that uses the symbols and -Werror
> but this is the standard writers intend, right?  It's easy enough to
> work around for the time being.

As we aren't implementing OpenMP 5.0 fully yet and especially because
we aren't implementing the new nesting ICV semantics, we shouldn't do it now,
they are valid in OpenMP 4.5.

We can reconsider that for GCC 10 if all of OpenMP 5.0 is implemented by
then or at least that nesting semantics and we want people to move over.

	Jakub
Ulrich Drepper Jan. 2, 2019, 5:23 p.m. UTC | #2
On 1/2/19 6:21 PM, Jakub Jelinek wrote:
> As we aren't implementing OpenMP 5.0 fully yet and especially because
> we aren't implementing the new nesting ICV semantics, we shouldn't do it now,
> they are valid in OpenMP 4.5.

OK, that applies to omp_[gs]et_nested.

How about the lock symbols?  All the sync symbols are already defined as
aliases (or more correctly, the other way around).  The sooner people
change, the better, and at least those parts of OpenMP5 are "implemented".
Jakub Jelinek Jan. 2, 2019, 5:29 p.m. UTC | #3
On Wed, Jan 02, 2019 at 06:23:57PM +0100, Ulrich Drepper wrote:
> On 1/2/19 6:21 PM, Jakub Jelinek wrote:
> > As we aren't implementing OpenMP 5.0 fully yet and especially because
> > we aren't implementing the new nesting ICV semantics, we shouldn't do it now,
> > they are valid in OpenMP 4.5.
> 
> OK, that applies to omp_[gs]et_nested.
> 
> How about the lock symbols?  All the sync symbols are already defined as
> aliases (or more correctly, the other way around).  The sooner people
> change, the better, and at least those parts of OpenMP5 are "implemented".

We ignore the hints, so "implemented" is the right term ;).

I'd say there is no hurry for them either, I believe what is deprecated in
5.0 is going to be removed only (if at all) in 6.0, so like 5 years from
now, so waiting until we implement all of OpenMP 5.0 shouldn't hurt that
much.

	Jakub
Jakub Jelinek Jan. 2, 2019, 6:08 p.m. UTC | #4
On Wed, Jan 02, 2019 at 06:29:27PM +0100, Jakub Jelinek wrote:
> On Wed, Jan 02, 2019 at 06:23:57PM +0100, Ulrich Drepper wrote:
> > On 1/2/19 6:21 PM, Jakub Jelinek wrote:
> > > As we aren't implementing OpenMP 5.0 fully yet and especially because
> > > we aren't implementing the new nesting ICV semantics, we shouldn't do it now,
> > > they are valid in OpenMP 4.5.
> > 
> > OK, that applies to omp_[gs]et_nested.
> > 
> > How about the lock symbols?  All the sync symbols are already defined as
> > aliases (or more correctly, the other way around).  The sooner people
> > change, the better, and at least those parts of OpenMP5 are "implemented".
> 
> We ignore the hints, so "implemented" is the right term ;).
> 
> I'd say there is no hurry for them either, I believe what is deprecated in
> 5.0 is going to be removed only (if at all) in 6.0, so like 5 years from
> now, so waiting until we implement all of OpenMP 5.0 shouldn't hurt that
> much.

E.g. if somebody tries hard to write portable OpenMP code and has:
  omp_lock_t lock;
  #if __OPENMP__ >= 201811L
  omp_init_lock_with_hint (&lock, omp_sync_hint_contended);
  #elif __OPENMP__ >= 201511L
  omp_init_lock_with_hint (&lock, omp_lock_hint_contended);
  #else
  omp_init_lock (&lock);
  #endif
they would now get a warning even when they did the right thing.
So, deprecating those when we change __OPENMP__ macro is the right thing.

	Jakub
Kwok Cheung Yeung Oct. 28, 2020, 3:41 p.m. UTC | #5
Hello

I found this almost two-year old thread while looking for how the OpenMP 5.0 
deprecations were to be handled.

> E.g. if somebody tries hard to write portable OpenMP code and has:
>   omp_lock_t lock;
>   #if __OPENMP__ >= 201811L
>   omp_init_lock_with_hint (&lock, omp_sync_hint_contended);
>   #elif __OPENMP__ >= 201511L
>   omp_init_lock_with_hint (&lock, omp_lock_hint_contended);
>   #else
>   omp_init_lock (&lock);
>   #endif
> they would now get a warning even when they did the right thing.
> So, deprecating those when we change __OPENMP__ macro is the right thing.

What if we made the definition of __GOMP_DEPRECATED in the original patch 
conditional on the current value of __OPENMP__? i.e. Something like:

+#if defined(__GNUC__) && __OPENMP__ >= 201811L
+# define __GOMP_DEPRECATED __attribute__((__deprecated__))
+#else
+# define __GOMP_DEPRECATED
+#endif

In that case, __GOMP_DEPRECATED will not do anything until __OPENMP__ is updated 
to reflect OpenMP 5.0, but when it is, the functions will immediately be marked 
deprecated without any further work.

However, GFortran does not support the deprecated attribute, so how should it 
behave? My first thought would be to print out a warning message at runtime the 
first time a deprecated function is called (printing it out every time would 
probably be too annoying), and maybe add an environment variable that can be set 
to disable the warning. A similar runtime warning could also be printed if the 
OMP_NESTED environment variable is set. Again, printing these warnings could be 
surpressed until the value of __OPENMP__ is bumped up.

Kwok
Jakub Jelinek Oct. 28, 2020, 4:06 p.m. UTC | #6
On Wed, Oct 28, 2020 at 03:41:25PM +0000, Kwok Cheung Yeung wrote:
> I found this almost two-year old thread while looking for how the OpenMP 5.0
> deprecations were to be handled.
> 
> > E.g. if somebody tries hard to write portable OpenMP code and has:
> >   omp_lock_t lock;
> >   #if __OPENMP__ >= 201811L
> >   omp_init_lock_with_hint (&lock, omp_sync_hint_contended);
> >   #elif __OPENMP__ >= 201511L
> >   omp_init_lock_with_hint (&lock, omp_lock_hint_contended);
> >   #else
> >   omp_init_lock (&lock);
> >   #endif
> > they would now get a warning even when they did the right thing.
> > So, deprecating those when we change __OPENMP__ macro is the right thing.
> 
> What if we made the definition of __GOMP_DEPRECATED in the original patch
> conditional on the current value of __OPENMP__? i.e. Something like:
> 
> +#if defined(__GNUC__) && __OPENMP__ >= 201811L
> +# define __GOMP_DEPRECATED __attribute__((__deprecated__))
> +#else
> +# define __GOMP_DEPRECATED
> +#endif
> 
> In that case, __GOMP_DEPRECATED will not do anything until __OPENMP__ is
> updated to reflect OpenMP 5.0, but when it is, the functions will
> immediately be marked deprecated without any further work.

That could work, but the macro name would need to incorporate the exact
OpenMP version.
Because some APIs can be deprecated in OpenMP 5.0, others in 5.1 or in 5.2
(all to be removed in 6.0), others in 6.0/6.1 etc. to be removed in 7.0 etc.
> 
> However, GFortran does not support the deprecated attribute, so how should
> it behave? My first thought would be to print out a warning message at
> runtime the first time a deprecated function is called (printing it out
> every time would probably be too annoying), and maybe add an environment
> variable that can be set to disable the warning. A similar runtime warning
> could also be printed if the OMP_NESTED environment variable is set. Again,
> printing these warnings could be surpressed until the value of __OPENMP__ is
> bumped up.

I'm against such runtime diagnostics, that is perhaps good for some
sanitization, but not normal usage.  Perhaps better implement deprecated
attribute in gfortran?

	Jakub
Kwok Cheung Yeung Nov. 4, 2020, 2:23 p.m. UTC | #7
On 28/10/2020 4:06 pm, Jakub Jelinek wrote:
> On Wed, Oct 28, 2020 at 03:41:25PM +0000, Kwok Cheung Yeung wrote:
>> What if we made the definition of __GOMP_DEPRECATED in the original patch
>> conditional on the current value of __OPENMP__? i.e. Something like:
>>
>> +#if defined(__GNUC__) && __OPENMP__ >= 201811L
>> +# define __GOMP_DEPRECATED __attribute__((__deprecated__))
>> +#else
>> +# define __GOMP_DEPRECATED
>> +#endif
>>
>> In that case, __GOMP_DEPRECATED will not do anything until __OPENMP__ is
>> updated to reflect OpenMP 5.0, but when it is, the functions will
>> immediately be marked deprecated without any further work.
> 
> That could work, but the macro name would need to incorporate the exact
> OpenMP version.
> Because some APIs can be deprecated in OpenMP 5.0, others in 5.1 or in 5.2
> (all to be removed in 6.0), others in 6.0/6.1 etc. to be removed in 7.0 etc.

I've renamed __GOMP_DEPRECATED to __GOMP_DEPRECATED_5_0.

>>
>> However, GFortran does not support the deprecated attribute, so how should
>> it behave? My first thought would be to print out a warning message at
>> runtime the first time a deprecated function is called (printing it out
>> every time would probably be too annoying), and maybe add an environment
>> variable that can be set to disable the warning. A similar runtime warning
>> could also be printed if the OMP_NESTED environment variable is set. Again,
>> printing these warnings could be surpressed until the value of __OPENMP__ is
>> bumped up.
> 
> I'm against such runtime diagnostics, that is perhaps good for some
> sanitization, but not normal usage.  Perhaps better implement deprecated
> attribute in gfortran?
> 

I have used Tobias' recently added patch for Fortran deprecation support to mark 
omp_get_nested and omp_set_nested as deprecated. If the omp_lock_hint_* integer 
parameters are marked though, then the deprecation warnings will fire the moment 
omp_lib is used from a Fortran program, even if they are not referenced in the 
progam itself - a bug perhaps?

I have added '-cpp' (for preprocessor support) and '-fopenmp' (for the _OPENMP 
define) to the Makefile when compiling the omp_lib.f90.

Would a warning message be acceptable if OMP_NESTED is used? Obviously this 
cannot be done at compile-time.

Is this patch okay for trunk? We could add the deprecations for omp_lock_hint_* 
later when the deprecations for parameters are fixed. I have checked that it 
bootstraps on x86_64.

Kwok
From 6e8fc46bdcaf44da11d46968cccca488fdd990ae Mon Sep 17 00:00:00 2001
From: Kwok Cheung Yeung <kcy@codesourcery.com>
Date: Wed, 4 Nov 2020 03:59:44 -0800
Subject: [PATCH] openmp: Mark deprecated symbols in OpenMP 5.0

2020-11-04  Ulrich Drepper  <drepper@redhat.com>
	    Kwok Cheung Yeung  <kcy@codesourcery.com>

	libgomp/
	* Makefile.am (%.mod): Add -cpp and -fopenmp to compile flags.
	* Makefile.in: Regenerate.
	* fortran.c: Wrap uses of omp_set_nested and omp_get_nested with
	pragmas to ignore -Wdeprecated-declarations warnings.
	* icv.c: Likewise.
	* omp.h.in (__GOMP_DEPRECATED_5_0): Define.
	Mark omp_lock_hint_* enum values, omp_lock_hint_t, omp_set_nested,
	and omp_get_nested with __GOMP_DEPRECATED_5_0.
	* omp_lib.f90.in: Mark omp_get_nested and omp_set_nested as
	deprecated.
---
 libgomp/Makefile.am    |  2 +-
 libgomp/Makefile.in    |  2 +-
 libgomp/fortran.c      | 13 +++++++++++--
 libgomp/icv.c          | 10 ++++++++--
 libgomp/omp.h.in       | 22 ++++++++++++++--------
 libgomp/omp_lib.f90.in |  4 ++++
 6 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/libgomp/Makefile.am b/libgomp/Makefile.am
index 586c930..4cf1f58 100644
--- a/libgomp/Makefile.am
+++ b/libgomp/Makefile.am
@@ -92,7 +92,7 @@ openacc_kinds.mod: openacc.mod
 openacc.mod: openacc.lo
 	:
 %.mod: %.f90
-	$(FC) $(FCFLAGS) -fsyntax-only $<
+	$(FC) $(FCFLAGS) -cpp -fopenmp -fsyntax-only $<
 fortran.lo: libgomp_f.h
 fortran.o: libgomp_f.h
 env.lo: libgomp_f.h
diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
index 00d5e29..eb868b3 100644
--- a/libgomp/Makefile.in
+++ b/libgomp/Makefile.in
@@ -1382,7 +1382,7 @@ openacc_kinds.mod: openacc.mod
 openacc.mod: openacc.lo
 	:
 %.mod: %.f90
-	$(FC) $(FCFLAGS) -fsyntax-only $<
+	$(FC) $(FCFLAGS) -cpp -fopenmp -fsyntax-only $<
 fortran.lo: libgomp_f.h
 fortran.o: libgomp_f.h
 env.lo: libgomp_f.h
diff --git a/libgomp/fortran.c b/libgomp/fortran.c
index 029dec1..cd719f9 100644
--- a/libgomp/fortran.c
+++ b/libgomp/fortran.c
@@ -47,10 +47,13 @@ ialias_redirect (omp_test_lock)
 ialias_redirect (omp_test_nest_lock)
 # endif
 ialias_redirect (omp_set_dynamic)
-ialias_redirect (omp_set_nested)
-ialias_redirect (omp_set_num_threads)
 ialias_redirect (omp_get_dynamic)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ialias_redirect (omp_set_nested)
 ialias_redirect (omp_get_nested)
+#pragma GCC diagnostic pop
+ialias_redirect (omp_set_num_threads)
 ialias_redirect (omp_in_parallel)
 ialias_redirect (omp_get_max_threads)
 ialias_redirect (omp_get_num_procs)
@@ -281,6 +284,8 @@ omp_set_dynamic_8_ (const int64_t *set)
   omp_set_dynamic (!!*set);
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 void
 omp_set_nested_ (const int32_t *set)
 {
@@ -292,6 +297,7 @@ omp_set_nested_8_ (const int64_t *set)
 {
   omp_set_nested (!!*set);
 }
+#pragma GCC diagnostic pop
 
 void
 omp_set_num_threads_ (const int32_t *set)
@@ -311,11 +317,14 @@ omp_get_dynamic_ (void)
   return omp_get_dynamic ();
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 int32_t
 omp_get_nested_ (void)
 {
   return omp_get_nested ();
 }
+#pragma GCC diagnostic pop
 
 int32_t
 omp_in_parallel_ (void)
diff --git a/libgomp/icv.c b/libgomp/icv.c
index 4da6527..8df15e3 100644
--- a/libgomp/icv.c
+++ b/libgomp/icv.c
@@ -51,6 +51,8 @@ omp_get_dynamic (void)
   return icv->dyn_var;
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 void
 omp_set_nested (int val)
 {
@@ -64,6 +66,7 @@ omp_get_nested (void)
   struct gomp_task_icv *icv = gomp_icv (false);
   return icv->nest_var;
 }
+#pragma GCC diagnostic pop
 
 void
 omp_set_schedule (omp_sched_t kind, int chunk_size)
@@ -222,10 +225,13 @@ omp_get_default_allocator (void)
 }
 
 ialias (omp_set_dynamic)
-ialias (omp_set_nested)
-ialias (omp_set_num_threads)
 ialias (omp_get_dynamic)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ialias (omp_set_nested)
 ialias (omp_get_nested)
+#pragma GCC diagnostic pop
+ialias (omp_set_num_threads)
 ialias (omp_set_schedule)
 ialias (omp_get_schedule)
 ialias (omp_get_max_threads)
diff --git a/libgomp/omp.h.in b/libgomp/omp.h.in
index a9e6c44..f6accf2 100644
--- a/libgomp/omp.h.in
+++ b/libgomp/omp.h.in
@@ -26,6 +26,12 @@
 #ifndef _OMP_H
 #define _OMP_H 1
 
+#if defined(__GNUC__) && _OPENMP >= 201811
+# define __GOMP_DEPRECATED_5_0 __attribute__((__deprecated__))
+#else
+# define __GOMP_DEPRECATED_5_0
+#endif
+
 #ifndef _LIBGOMP_OMP_LOCK_DEFINED
 #define _LIBGOMP_OMP_LOCK_DEFINED 1
 /* These two structures get edited by the libgomp build process to 
@@ -66,18 +72,18 @@ typedef enum omp_proc_bind_t
 typedef enum omp_sync_hint_t
 {
   omp_sync_hint_none = 0,
-  omp_lock_hint_none = omp_sync_hint_none,
+  omp_lock_hint_none __GOMP_DEPRECATED_5_0 = omp_sync_hint_none,
   omp_sync_hint_uncontended = 1,
-  omp_lock_hint_uncontended = omp_sync_hint_uncontended,
+  omp_lock_hint_uncontended __GOMP_DEPRECATED_5_0 = omp_sync_hint_uncontended,
   omp_sync_hint_contended = 2,
-  omp_lock_hint_contended = omp_sync_hint_contended,
+  omp_lock_hint_contended __GOMP_DEPRECATED_5_0 = omp_sync_hint_contended,
   omp_sync_hint_nonspeculative = 4,
-  omp_lock_hint_nonspeculative = omp_sync_hint_nonspeculative,
+  omp_lock_hint_nonspeculative __GOMP_DEPRECATED_5_0 = omp_sync_hint_nonspeculative,
   omp_sync_hint_speculative = 8,
-  omp_lock_hint_speculative = omp_sync_hint_speculative
+  omp_lock_hint_speculative __GOMP_DEPRECATED_5_0 = omp_sync_hint_speculative
 } omp_sync_hint_t;
 
-typedef omp_sync_hint_t omp_lock_hint_t;
+typedef __GOMP_DEPRECATED_5_0 omp_sync_hint_t omp_lock_hint_t;
 
 typedef struct __attribute__((__aligned__ (sizeof (void *)))) omp_depend_t
 {
@@ -184,8 +190,8 @@ extern int omp_in_parallel (void) __GOMP_NOTHROW;
 extern void omp_set_dynamic (int) __GOMP_NOTHROW;
 extern int omp_get_dynamic (void) __GOMP_NOTHROW;
 
-extern void omp_set_nested (int) __GOMP_NOTHROW;
-extern int omp_get_nested (void) __GOMP_NOTHROW;
+extern void omp_set_nested (int) __GOMP_DEPRECATED_5_0 __GOMP_NOTHROW;
+extern int omp_get_nested (void) __GOMP_DEPRECATED_5_0 __GOMP_NOTHROW;
 
 extern void omp_init_lock (omp_lock_t *) __GOMP_NOTHROW;
 extern void omp_init_lock_with_hint (omp_lock_t *, omp_sync_hint_t)
diff --git a/libgomp/omp_lib.f90.in b/libgomp/omp_lib.f90.in
index 2fae57b..3b7f0cb 100644
--- a/libgomp/omp_lib.f90.in
+++ b/libgomp/omp_lib.f90.in
@@ -644,4 +644,8 @@
           end function
         end interface
 
+#if _OPENMP >= 201811
+!GCC$ ATTRIBUTES DEPRECATED :: omp_get_nested, omp_set_nested
+#endif
+
       end module omp_lib
Jakub Jelinek Nov. 4, 2020, 2:33 p.m. UTC | #8
On Wed, Nov 04, 2020 at 02:23:17PM +0000, Kwok Cheung Yeung wrote:
> I have used Tobias' recently added patch for Fortran deprecation support to
> mark omp_get_nested and omp_set_nested as deprecated. If the omp_lock_hint_*
> integer parameters are marked though, then the deprecation warnings will
> fire the moment omp_lib is used from a Fortran program, even if they are not
> referenced in the progam itself - a bug perhaps?
> 
> I have added '-cpp' (for preprocessor support) and '-fopenmp' (for the
> _OPENMP define) to the Makefile when compiling the omp_lib.f90.
> 
> Would a warning message be acceptable if OMP_NESTED is used? Obviously this
> cannot be done at compile-time.

I'd strongly prefer no runtime warnings.

> 2020-11-04  Ulrich Drepper  <drepper@redhat.com>
> 	    Kwok Cheung Yeung  <kcy@codesourcery.com>
> 
> 	libgomp/
> 	* Makefile.am (%.mod): Add -cpp and -fopenmp to compile flags.
> 	* Makefile.in: Regenerate.
> 	* fortran.c: Wrap uses of omp_set_nested and omp_get_nested with
> 	pragmas to ignore -Wdeprecated-declarations warnings.
> 	* icv.c: Likewise.
> 	* omp.h.in (__GOMP_DEPRECATED_5_0): Define.
> 	Mark omp_lock_hint_* enum values, omp_lock_hint_t, omp_set_nested,
> 	and omp_get_nested with __GOMP_DEPRECATED_5_0.
> 	* omp_lib.f90.in: Mark omp_get_nested and omp_set_nested as
> 	deprecated.

LGTM, except:

> +  omp_lock_hint_contended __GOMP_DEPRECATED_5_0 = omp_sync_hint_contended,
>    omp_sync_hint_nonspeculative = 4,
> -  omp_lock_hint_nonspeculative = omp_sync_hint_nonspeculative,
> +  omp_lock_hint_nonspeculative __GOMP_DEPRECATED_5_0 = omp_sync_hint_nonspeculative,

The above line is too long and needs wrapping.

But it would be nice to also add -Wno-deprecated to dg-additional-options of
tests that do use those.
Perhaps for testing replace the 201811 temporarily with 201511 and run make
check.

> --- a/libgomp/omp_lib.f90.in
> +++ b/libgomp/omp_lib.f90.in
> @@ -644,4 +644,8 @@
>            end function
>          end interface
>  
> +#if _OPENMP >= 201811
> +!GCC$ ATTRIBUTES DEPRECATED :: omp_get_nested, omp_set_nested
> +#endif
> +
>        end module omp_lib

Also, what about omp_lib.h?  Do you plan to change it only when we switch
_OPENMP macro?  I mean, we can't rely on preprocessing in that case...

	Jakub
Kwok Cheung Yeung Nov. 5, 2020, 6:18 p.m. UTC | #9
On 04/11/2020 2:33 pm, Jakub Jelinek wrote:
> LGTM, except:
> 
>> +  omp_lock_hint_contended __GOMP_DEPRECATED_5_0 = omp_sync_hint_contended,
>>     omp_sync_hint_nonspeculative = 4,
>> -  omp_lock_hint_nonspeculative = omp_sync_hint_nonspeculative,
>> +  omp_lock_hint_nonspeculative __GOMP_DEPRECATED_5_0 = omp_sync_hint_nonspeculative,
> 
> The above line is too long and needs wrapping.
> 

Fixed.

> But it would be nice to also add -Wno-deprecated to dg-additional-options of
> tests that do use those.
> Perhaps for testing replace the 201811 temporarily with 201511 and run make
> check.
> 

I have run the tests (with _OPENMP >= 201511) and added 
-Wno-deprecated-declarations option to the testcases that trigger the 
deprecation warning.

I also found a bug in the previous version of the patch - C++ doesn't like 
having an attribute come before the throw clause at the end of a function 
declaration. This is now fixed.

Bootstrapped on x86_64 with no offloading, and tested with nvptx offloading. Is 
this version okay for trunk?

>> --- a/libgomp/omp_lib.f90.in
>> +++ b/libgomp/omp_lib.f90.in
>> @@ -644,4 +644,8 @@
>>             end function
>>           end interface
>>   
>> +#if _OPENMP >= 201811
>> +!GCC$ ATTRIBUTES DEPRECATED :: omp_get_nested, omp_set_nested
>> +#endif
>> +
>>         end module omp_lib
> 
> Also, what about omp_lib.h?  Do you plan to change it only when we switch
> _OPENMP macro?  I mean, we can't rely on preprocessing in that case...
> 

Since we can't rely on having access to the preprocessor, I don't see what else 
we could do at the moment, except maybe extend the DEPRECATED attribute to take 
a condition (openmp_version >= 201811), and not print when false? Probably more 
trouble than it is worth, and it differs from the behaviour of the C attribute.

Kwok
commit a944f2ab445bb226f65239429d13efdf69a98e4b
Author: Kwok Cheung Yeung <kcy@codesourcery.com>
Date:   Thu Nov 5 10:11:23 2020 -0800

    openmp: Mark deprecated symbols in OpenMP 5.0
    
    2020-11-05  Ulrich Drepper  <drepper@redhat.com>
    	    Kwok Cheung Yeung  <kcy@codesourcery.com>
    
    	libgomp/
    	* Makefile.am (%.mod): Add -cpp and -fopenmp to compile flags.
    	* Makefile.in: Regenerate.
    	* fortran.c: Wrap uses of omp_set_nested and omp_get_nested with
    	pragmas to ignore -Wdeprecated-declarations warnings.
    	* icv.c: Likewise.
    	* omp.h.in (__GOMP_DEPRECATED_5_0): Define.
    	Mark omp_lock_hint_* enum values, omp_lock_hint_t, omp_set_nested,
    	and omp_get_nested with __GOMP_DEPRECATED_5_0.
    	* omp_lib.f90.in: Mark omp_get_nested and omp_set_nested as
    	deprecated.
    	* testsuite/libgomp.c++/affinity-1.C: Add -Wno-deprecated-declarations
    	to test options.
    	* testsuite/libgomp.c/affinity-1.c: Likewise.
    	* testsuite/libgomp.c/affinity-2.c: Likewise.
    	* testsuite/libgomp.c/appendix-a/a.15.1.c: Likewise.
    	* testsuite/libgomp.c/lib-1.c: Likewise.
    	* testsuite/libgomp.c/nested-1.c: Likewise.
    	* testsuite/libgomp.c/nested-2.c: Likewise.
    	* testsuite/libgomp.c/nested-3.c: Likewise.
    	* testsuite/libgomp.c/pr32362-1.c: Likewise.
    	* testsuite/libgomp.c/pr32362-2.c: Likewise.
    	* testsuite/libgomp.c/pr32362-3.c: Likewise.
    	* testsuite/libgomp.c/pr35549.c: Likewise.
    	* testsuite/libgomp.c/pr42942.c: Likewise.
    	* testsuite/libgomp.c/pr61200.c: Likewise.
    	* testsuite/libgomp.c/sort-1.c: Likewise.
    	* testsuite/libgomp.c/target-5.c: Likewise.
    	* testsuite/libgomp.c/target-6.c: Likewise.
    	* testsuite/libgomp.c/teams-1.c: Likewise.
    	* testsuite/libgomp.c/thread-limit-1.c: Likewise.
    	* testsuite/libgomp.c/thread-limit-2.c: Likewise.
    	* testsuite/libgomp.c/thread-limit-4.c: Likewise.
    	* testsuite/libgomp.fortran/affinity1.f90: Likewise.
    	* testsuite/libgomp.fortran/lib1.f90: Likewise.
    	* testsuite/libgomp.fortran/lib2.f: Likewise.
    	* testsuite/libgomp.fortran/nested1.f90: Likewise.
    	* testsuite/libgomp.fortran/teams1.f90: Likewise.

diff --git a/libgomp/Makefile.am b/libgomp/Makefile.am
index 586c930..4cf1f58 100644
--- a/libgomp/Makefile.am
+++ b/libgomp/Makefile.am
@@ -92,7 +92,7 @@ openacc_kinds.mod: openacc.mod
 openacc.mod: openacc.lo
 	:
 %.mod: %.f90
-	$(FC) $(FCFLAGS) -fsyntax-only $<
+	$(FC) $(FCFLAGS) -cpp -fopenmp -fsyntax-only $<
 fortran.lo: libgomp_f.h
 fortran.o: libgomp_f.h
 env.lo: libgomp_f.h
diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
index 00d5e29..eb868b3 100644
--- a/libgomp/Makefile.in
+++ b/libgomp/Makefile.in
@@ -1382,7 +1382,7 @@ openacc_kinds.mod: openacc.mod
 openacc.mod: openacc.lo
 	:
 %.mod: %.f90
-	$(FC) $(FCFLAGS) -fsyntax-only $<
+	$(FC) $(FCFLAGS) -cpp -fopenmp -fsyntax-only $<
 fortran.lo: libgomp_f.h
 fortran.o: libgomp_f.h
 env.lo: libgomp_f.h
diff --git a/libgomp/fortran.c b/libgomp/fortran.c
index 029dec1..cd719f9 100644
--- a/libgomp/fortran.c
+++ b/libgomp/fortran.c
@@ -47,10 +47,13 @@ ialias_redirect (omp_test_lock)
 ialias_redirect (omp_test_nest_lock)
 # endif
 ialias_redirect (omp_set_dynamic)
-ialias_redirect (omp_set_nested)
-ialias_redirect (omp_set_num_threads)
 ialias_redirect (omp_get_dynamic)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ialias_redirect (omp_set_nested)
 ialias_redirect (omp_get_nested)
+#pragma GCC diagnostic pop
+ialias_redirect (omp_set_num_threads)
 ialias_redirect (omp_in_parallel)
 ialias_redirect (omp_get_max_threads)
 ialias_redirect (omp_get_num_procs)
@@ -281,6 +284,8 @@ omp_set_dynamic_8_ (const int64_t *set)
   omp_set_dynamic (!!*set);
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 void
 omp_set_nested_ (const int32_t *set)
 {
@@ -292,6 +297,7 @@ omp_set_nested_8_ (const int64_t *set)
 {
   omp_set_nested (!!*set);
 }
+#pragma GCC diagnostic pop
 
 void
 omp_set_num_threads_ (const int32_t *set)
@@ -311,11 +317,14 @@ omp_get_dynamic_ (void)
   return omp_get_dynamic ();
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 int32_t
 omp_get_nested_ (void)
 {
   return omp_get_nested ();
 }
+#pragma GCC diagnostic pop
 
 int32_t
 omp_in_parallel_ (void)
diff --git a/libgomp/icv.c b/libgomp/icv.c
index 4da6527..8df15e3 100644
--- a/libgomp/icv.c
+++ b/libgomp/icv.c
@@ -51,6 +51,8 @@ omp_get_dynamic (void)
   return icv->dyn_var;
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 void
 omp_set_nested (int val)
 {
@@ -64,6 +66,7 @@ omp_get_nested (void)
   struct gomp_task_icv *icv = gomp_icv (false);
   return icv->nest_var;
 }
+#pragma GCC diagnostic pop
 
 void
 omp_set_schedule (omp_sched_t kind, int chunk_size)
@@ -222,10 +225,13 @@ omp_get_default_allocator (void)
 }
 
 ialias (omp_set_dynamic)
-ialias (omp_set_nested)
-ialias (omp_set_num_threads)
 ialias (omp_get_dynamic)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ialias (omp_set_nested)
 ialias (omp_get_nested)
+#pragma GCC diagnostic pop
+ialias (omp_set_num_threads)
 ialias (omp_set_schedule)
 ialias (omp_get_schedule)
 ialias (omp_get_max_threads)
diff --git a/libgomp/omp.h.in b/libgomp/omp.h.in
index a9e6c44..be7df6d 100644
--- a/libgomp/omp.h.in
+++ b/libgomp/omp.h.in
@@ -26,6 +26,12 @@
 #ifndef _OMP_H
 #define _OMP_H 1
 
+#if defined(__GNUC__) && _OPENMP >= 201811
+# define __GOMP_DEPRECATED_5_0 __attribute__((__deprecated__))
+#else
+# define __GOMP_DEPRECATED_5_0
+#endif
+
 #ifndef _LIBGOMP_OMP_LOCK_DEFINED
 #define _LIBGOMP_OMP_LOCK_DEFINED 1
 /* These two structures get edited by the libgomp build process to 
@@ -66,18 +72,19 @@ typedef enum omp_proc_bind_t
 typedef enum omp_sync_hint_t
 {
   omp_sync_hint_none = 0,
-  omp_lock_hint_none = omp_sync_hint_none,
+  omp_lock_hint_none __GOMP_DEPRECATED_5_0 = omp_sync_hint_none,
   omp_sync_hint_uncontended = 1,
-  omp_lock_hint_uncontended = omp_sync_hint_uncontended,
+  omp_lock_hint_uncontended __GOMP_DEPRECATED_5_0 = omp_sync_hint_uncontended,
   omp_sync_hint_contended = 2,
-  omp_lock_hint_contended = omp_sync_hint_contended,
+  omp_lock_hint_contended __GOMP_DEPRECATED_5_0 = omp_sync_hint_contended,
   omp_sync_hint_nonspeculative = 4,
-  omp_lock_hint_nonspeculative = omp_sync_hint_nonspeculative,
+  omp_lock_hint_nonspeculative __GOMP_DEPRECATED_5_0
+    = omp_sync_hint_nonspeculative,
   omp_sync_hint_speculative = 8,
-  omp_lock_hint_speculative = omp_sync_hint_speculative
+  omp_lock_hint_speculative __GOMP_DEPRECATED_5_0 = omp_sync_hint_speculative
 } omp_sync_hint_t;
 
-typedef omp_sync_hint_t omp_lock_hint_t;
+typedef __GOMP_DEPRECATED_5_0 omp_sync_hint_t omp_lock_hint_t;
 
 typedef struct __attribute__((__aligned__ (sizeof (void *)))) omp_depend_t
 {
@@ -184,8 +191,8 @@ extern int omp_in_parallel (void) __GOMP_NOTHROW;
 extern void omp_set_dynamic (int) __GOMP_NOTHROW;
 extern int omp_get_dynamic (void) __GOMP_NOTHROW;
 
-extern void omp_set_nested (int) __GOMP_NOTHROW;
-extern int omp_get_nested (void) __GOMP_NOTHROW;
+extern void omp_set_nested (int) __GOMP_NOTHROW __GOMP_DEPRECATED_5_0;
+extern int omp_get_nested (void) __GOMP_NOTHROW __GOMP_DEPRECATED_5_0;
 
 extern void omp_init_lock (omp_lock_t *) __GOMP_NOTHROW;
 extern void omp_init_lock_with_hint (omp_lock_t *, omp_sync_hint_t)
diff --git a/libgomp/omp_lib.f90.in b/libgomp/omp_lib.f90.in
index 2fae57b..3b7f0cb 100644
--- a/libgomp/omp_lib.f90.in
+++ b/libgomp/omp_lib.f90.in
@@ -644,4 +644,8 @@
           end function
         end interface
 
+#if _OPENMP >= 201811
+!GCC$ ATTRIBUTES DEPRECATED :: omp_get_nested, omp_set_nested
+#endif
+
       end module omp_lib
diff --git a/libgomp/testsuite/libgomp.c++/affinity-1.C b/libgomp/testsuite/libgomp.c++/affinity-1.C
index d20b392..eff2316 100644
--- a/libgomp/testsuite/libgomp.c++/affinity-1.C
+++ b/libgomp/testsuite/libgomp.c++/affinity-1.C
@@ -1,4 +1,5 @@
 // { dg-do run }
 // { dg-set-target-env-var OMP_PROC_BIND "true" }
+// { dg-additional-options "-Wno-deprecated-declarations" }
 
 #include "../libgomp.c/affinity-1.c"
diff --git a/libgomp/testsuite/libgomp.c/affinity-1.c b/libgomp/testsuite/libgomp.c/affinity-1.c
index aeb0f4d..4c9f9d1 100644
--- a/libgomp/testsuite/libgomp.c/affinity-1.c
+++ b/libgomp/testsuite/libgomp.c/affinity-1.c
@@ -17,7 +17,8 @@
 
 /* { dg-do run } */
 /* { dg-set-target-env-var OMP_PROC_BIND "false" } */
-/* { dg-additional-options "-DINTERPOSE_GETAFFINITY -DDO_FORK -ldl" { target *-*-linux* } } */
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
+/* { dg-additional-options "-DINTERPOSE_GETAFFINITY -DDO_FORK -ldl -Wno-deprecated-declarations" { target *-*-linux* } } */
 
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
diff --git a/libgomp/testsuite/libgomp.c/affinity-2.c b/libgomp/testsuite/libgomp.c/affinity-2.c
index f821657..8e5bb56 100644
--- a/libgomp/testsuite/libgomp.c/affinity-2.c
+++ b/libgomp/testsuite/libgomp.c/affinity-2.c
@@ -2,6 +2,7 @@
 /* { dg-set-target-env-var OMP_PROC_BIND "spread,close" } */
 /* { dg-set-target-env-var OMP_PLACES "{6,7}:4:-2,!{2,3}" } */
 /* { dg-set-target-env-var OMP_NUM_THREADS "2" } */
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
 
 #include <omp.h>
 #include <stdlib.h>
diff --git a/libgomp/testsuite/libgomp.c/appendix-a/a.15.1.c b/libgomp/testsuite/libgomp.c/appendix-a/a.15.1.c
index c167dab..469da6a 100644
--- a/libgomp/testsuite/libgomp.c/appendix-a/a.15.1.c
+++ b/libgomp/testsuite/libgomp.c/appendix-a/a.15.1.c
@@ -1,4 +1,5 @@
 /* { dg-do run } */
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
 
 #include <omp.h>
 #include <stdio.h>
diff --git a/libgomp/testsuite/libgomp.c/lib-1.c b/libgomp/testsuite/libgomp.c/lib-1.c
index 086036d..fc6f746 100644
--- a/libgomp/testsuite/libgomp.c/lib-1.c
+++ b/libgomp/testsuite/libgomp.c/lib-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
+
 #include <stdlib.h>
 #include <omp.h>
 
diff --git a/libgomp/testsuite/libgomp.c/nested-1.c b/libgomp/testsuite/libgomp.c/nested-1.c
index d3cfb01..925f5c5 100644
--- a/libgomp/testsuite/libgomp.c/nested-1.c
+++ b/libgomp/testsuite/libgomp.c/nested-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
+
 #include <omp.h>
 #include <stdlib.h>
 
diff --git a/libgomp/testsuite/libgomp.c/nested-2.c b/libgomp/testsuite/libgomp.c/nested-2.c
index f52b074..ab113f1 100644
--- a/libgomp/testsuite/libgomp.c/nested-2.c
+++ b/libgomp/testsuite/libgomp.c/nested-2.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
+
 #include <omp.h>
 #include <stdlib.h>
 
diff --git a/libgomp/testsuite/libgomp.c/nested-3.c b/libgomp/testsuite/libgomp.c/nested-3.c
index 6186006..625ca88 100644
--- a/libgomp/testsuite/libgomp.c/nested-3.c
+++ b/libgomp/testsuite/libgomp.c/nested-3.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
+
 #include <omp.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/libgomp/testsuite/libgomp.c/pr32362-1.c b/libgomp/testsuite/libgomp.c/pr32362-1.c
index 55807e3..33890df 100644
--- a/libgomp/testsuite/libgomp.c/pr32362-1.c
+++ b/libgomp/testsuite/libgomp.c/pr32362-1.c
@@ -1,5 +1,6 @@
 /* PR middle-end/32362 */
 /* { dg-do run } */
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
 
 #include <omp.h>
 #include <stdlib.h>
diff --git a/libgomp/testsuite/libgomp.c/pr32362-2.c b/libgomp/testsuite/libgomp.c/pr32362-2.c
index d4ce091..445ccbf 100644
--- a/libgomp/testsuite/libgomp.c/pr32362-2.c
+++ b/libgomp/testsuite/libgomp.c/pr32362-2.c
@@ -1,5 +1,6 @@
 /* PR middle-end/32362 */
 /* { dg-do run } */
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
 
 #include <omp.h>
 #include <stdlib.h>
diff --git a/libgomp/testsuite/libgomp.c/pr32362-3.c b/libgomp/testsuite/libgomp.c/pr32362-3.c
index 11a0a0a..1d0b19c 100644
--- a/libgomp/testsuite/libgomp.c/pr32362-3.c
+++ b/libgomp/testsuite/libgomp.c/pr32362-3.c
@@ -1,5 +1,6 @@
 /* PR middle-end/32362 */
 /* { dg-do run } */
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
 
 #include <omp.h>
 #include <stdlib.h>
diff --git a/libgomp/testsuite/libgomp.c/pr35549.c b/libgomp/testsuite/libgomp.c/pr35549.c
index 269a0c2..a492c56 100644
--- a/libgomp/testsuite/libgomp.c/pr35549.c
+++ b/libgomp/testsuite/libgomp.c/pr35549.c
@@ -1,5 +1,6 @@
 /* PR middle-end/35549 */
 /* { dg-do run } */
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
 
 #include <omp.h>
 #include <stdlib.h>
diff --git a/libgomp/testsuite/libgomp.c/pr42942.c b/libgomp/testsuite/libgomp.c/pr42942.c
index 5d57852..260dd90 100644
--- a/libgomp/testsuite/libgomp.c/pr42942.c
+++ b/libgomp/testsuite/libgomp.c/pr42942.c
@@ -1,5 +1,6 @@
 /* PR libgomp/42942 */
 /* { dg-do run } */
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
 
 #include <omp.h>
 #include <stdlib.h>
diff --git a/libgomp/testsuite/libgomp.c/pr61200.c b/libgomp/testsuite/libgomp.c/pr61200.c
index ba3ed37..c98c10a 100644
--- a/libgomp/testsuite/libgomp.c/pr61200.c
+++ b/libgomp/testsuite/libgomp.c/pr61200.c
@@ -1,5 +1,6 @@
 /* PR libgomp/61200 */
 /* { dg-do run } */
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
 
 #include <omp.h>
 #include <stdlib.h>
diff --git a/libgomp/testsuite/libgomp.c/sort-1.c b/libgomp/testsuite/libgomp.c/sort-1.c
index f706fa2..bcabea5 100644
--- a/libgomp/testsuite/libgomp.c/sort-1.c
+++ b/libgomp/testsuite/libgomp.c/sort-1.c
@@ -15,6 +15,8 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
+
 #include <limits.h>
 #include <omp.h>
 #include <stdbool.h>
diff --git a/libgomp/testsuite/libgomp.c/target-5.c b/libgomp/testsuite/libgomp.c/target-5.c
index 4367443..21a69ea 100644
--- a/libgomp/testsuite/libgomp.c/target-5.c
+++ b/libgomp/testsuite/libgomp.c/target-5.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
+
 #include <omp.h>
 #include <stdlib.h>
 
diff --git a/libgomp/testsuite/libgomp.c/target-6.c b/libgomp/testsuite/libgomp.c/target-6.c
index ea35aa4..8ffcb5b 100644
--- a/libgomp/testsuite/libgomp.c/target-6.c
+++ b/libgomp/testsuite/libgomp.c/target-6.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
+
 #include <omp.h>
 #include <stdlib.h>
 
diff --git a/libgomp/testsuite/libgomp.c/teams-1.c b/libgomp/testsuite/libgomp.c/teams-1.c
index c5df837..977e5fc 100644
--- a/libgomp/testsuite/libgomp.c/teams-1.c
+++ b/libgomp/testsuite/libgomp.c/teams-1.c
@@ -1,3 +1,5 @@
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
+
 #include <omp.h>
 #include <stdlib.h>
 
diff --git a/libgomp/testsuite/libgomp.c/thread-limit-1.c b/libgomp/testsuite/libgomp.c/thread-limit-1.c
index 1d9794a..c8f76f9 100644
--- a/libgomp/testsuite/libgomp.c/thread-limit-1.c
+++ b/libgomp/testsuite/libgomp.c/thread-limit-1.c
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-set-target-env-var OMP_THREAD_LIMIT "6" } */
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
 
 #include <stdlib.h>
 #include <unistd.h>
diff --git a/libgomp/testsuite/libgomp.c/thread-limit-2.c b/libgomp/testsuite/libgomp.c/thread-limit-2.c
index dc247a7..2cff1fd 100644
--- a/libgomp/testsuite/libgomp.c/thread-limit-2.c
+++ b/libgomp/testsuite/libgomp.c/thread-limit-2.c
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-set-target-env-var OMP_THREAD_LIMIT "9" } */
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
 
 #include <stdlib.h>
 #include <unistd.h>
diff --git a/libgomp/testsuite/libgomp.c/thread-limit-4.c b/libgomp/testsuite/libgomp.c/thread-limit-4.c
index 5642e6a..351423c 100644
--- a/libgomp/testsuite/libgomp.c/thread-limit-4.c
+++ b/libgomp/testsuite/libgomp.c/thread-limit-4.c
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-set-target-env-var OMP_THREAD_LIMIT "9" } */
+/* { dg-additional-options "-Wno-deprecated-declarations" } */
 
 #include <stdlib.h>
 #include <unistd.h>
diff --git a/libgomp/testsuite/libgomp.fortran/affinity1.f90 b/libgomp/testsuite/libgomp.fortran/affinity1.f90
index 26b5185..ea84b83 100644
--- a/libgomp/testsuite/libgomp.fortran/affinity1.f90
+++ b/libgomp/testsuite/libgomp.fortran/affinity1.f90
@@ -3,6 +3,7 @@
 ! { dg-set-target-env-var OMP_PROC_BIND "spread,close" }
 ! { dg-set-target-env-var OMP_PLACES "{6,7}:4:-2,!{2,3}" }
 ! { dg-set-target-env-var OMP_NUM_THREADS "2" }
+! { dg-additional-options "-Wno-deprecated-declarations" }
 
   use omp_lib
   integer :: num, i, nump
diff --git a/libgomp/testsuite/libgomp.fortran/lib1.f90 b/libgomp/testsuite/libgomp.fortran/lib1.f90
index 4e7f9b2..c99eb7b 100644
--- a/libgomp/testsuite/libgomp.fortran/lib1.f90
+++ b/libgomp/testsuite/libgomp.fortran/lib1.f90
@@ -1,4 +1,5 @@
 ! { dg-do run }
+! { dg-additional-options "-Wno-deprecated-declarations" }
 
   use omp_lib
 
diff --git a/libgomp/testsuite/libgomp.fortran/lib2.f b/libgomp/testsuite/libgomp.fortran/lib2.f
index 91b56c0..a25611b 100644
--- a/libgomp/testsuite/libgomp.fortran/lib2.f
+++ b/libgomp/testsuite/libgomp.fortran/lib2.f
@@ -1,4 +1,5 @@
 C { dg-do run }
+C { dg-additional-options "-Wno-deprecated-declarations" }
 
       USE OMP_LIB
 
diff --git a/libgomp/testsuite/libgomp.fortran/nested1.f90 b/libgomp/testsuite/libgomp.fortran/nested1.f90
index f521b7b..bb3d0ed 100644
--- a/libgomp/testsuite/libgomp.fortran/nested1.f90
+++ b/libgomp/testsuite/libgomp.fortran/nested1.f90
@@ -1,4 +1,6 @@
 ! { dg-do run }
+! { dg-additional-options "-Wno-deprecated-declarations" }
+
 program nested1
   use omp_lib
   integer :: e1, e2, e3, e
diff --git a/libgomp/testsuite/libgomp.fortran/teams1.f90 b/libgomp/testsuite/libgomp.fortran/teams1.f90
index 4f14607..0077a70 100644
--- a/libgomp/testsuite/libgomp.fortran/teams1.f90
+++ b/libgomp/testsuite/libgomp.fortran/teams1.f90
@@ -1,3 +1,5 @@
+! { dg-additional-options "-Wno-deprecated-declarations" }
+
 program teams1
   use omp_lib
 !$omp teams thread_limit (2)
Jakub Jelinek Nov. 5, 2020, 6:19 p.m. UTC | #10
On Thu, Nov 05, 2020 at 06:18:11PM +0000, Kwok Cheung Yeung wrote:
> I have run the tests (with _OPENMP >= 201511) and added
> -Wno-deprecated-declarations option to the testcases that trigger the
> deprecation warning.
> 
> I also found a bug in the previous version of the patch - C++ doesn't like
> having an attribute come before the throw clause at the end of a function
> declaration. This is now fixed.
> 
> Bootstrapped on x86_64 with no offloading, and tested with nvptx offloading.
> Is this version okay for trunk?

Ok, thanks.

	Jakub
diff mbox series

Patch

diff --git a/libgomp/fortran.c b/libgomp/fortran.c
index 4d544be1c99..24d361157f0 100644
--- a/libgomp/fortran.c
+++ b/libgomp/fortran.c
@@ -47,10 +47,13 @@  ialias_redirect (omp_test_lock)
 ialias_redirect (omp_test_nest_lock)
 # endif
 ialias_redirect (omp_set_dynamic)
-ialias_redirect (omp_set_nested)
-ialias_redirect (omp_set_num_threads)
 ialias_redirect (omp_get_dynamic)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ialias_redirect (omp_set_nested)
 ialias_redirect (omp_get_nested)
+#pragma GCC diagnostic pop
+ialias_redirect (omp_set_num_threads)
 ialias_redirect (omp_in_parallel)
 ialias_redirect (omp_get_max_threads)
 ialias_redirect (omp_get_num_procs)
@@ -276,6 +279,8 @@  omp_set_dynamic_8_ (const int64_t *set)
   omp_set_dynamic (!!*set);
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 void
 omp_set_nested_ (const int32_t *set)
 {
@@ -287,6 +292,7 @@  omp_set_nested_8_ (const int64_t *set)
 {
   omp_set_nested (!!*set);
 }
+#pragma GCC diagnostic pop
 
 void
 omp_set_num_threads_ (const int32_t *set)
@@ -306,11 +312,14 @@  omp_get_dynamic_ (void)
   return omp_get_dynamic ();
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 int32_t
 omp_get_nested_ (void)
 {
   return omp_get_nested ();
 }
+#pragma GCC diagnostic pop
 
 int32_t
 omp_in_parallel_ (void)
diff --git a/libgomp/icv.c b/libgomp/icv.c
index 095d57a93b1..af0f4c0596e 100644
--- a/libgomp/icv.c
+++ b/libgomp/icv.c
@@ -51,6 +51,8 @@  omp_get_dynamic (void)
   return icv->dyn_var;
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 void
 omp_set_nested (int val)
 {
@@ -64,6 +66,7 @@  omp_get_nested (void)
   struct gomp_task_icv *icv = gomp_icv (false);
   return icv->nest_var;
 }
+#pragma GCC diagnostic pop
 
 void
 omp_set_schedule (omp_sched_t kind, int chunk_size)
@@ -198,10 +201,13 @@  omp_get_partition_place_nums (int *place_nums)
 }
 
 ialias (omp_set_dynamic)
-ialias (omp_set_nested)
-ialias (omp_set_num_threads)
 ialias (omp_get_dynamic)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ialias (omp_set_nested)
 ialias (omp_get_nested)
+#pragma GCC diagnostic pop
+ialias (omp_set_num_threads)
 ialias (omp_set_schedule)
 ialias (omp_get_schedule)
 ialias (omp_get_max_threads)
diff --git a/libgomp/omp.h.in b/libgomp/omp.h.in
index d7ac71400ad..060ee374829 100644
--- a/libgomp/omp.h.in
+++ b/libgomp/omp.h.in
@@ -26,6 +26,13 @@ 
 #ifndef _OMP_H
 #define _OMP_H 1
 
+
+#ifdef __GNUC__
+# define __GOMP_DEPRECATED __attribute__((__deprecated__))
+#else
+# define __GOMP_DEPRECATED
+#endif
+
 #ifndef _LIBGOMP_OMP_LOCK_DEFINED
 #define _LIBGOMP_OMP_LOCK_DEFINED 1
 /* These two structures get edited by the libgomp build process to 
@@ -66,18 +73,18 @@  typedef enum omp_proc_bind_t
 typedef enum omp_sync_hint_t
 {
   omp_sync_hint_none = 0,
-  omp_lock_hint_none = omp_sync_hint_none,
+  omp_lock_hint_none __GOMP_DEPRECATED = omp_sync_hint_none,
   omp_sync_hint_uncontended = 1,
-  omp_lock_hint_uncontended = omp_sync_hint_uncontended,
+  omp_lock_hint_uncontended __GOMP_DEPRECATED = omp_sync_hint_uncontended,
   omp_sync_hint_contended = 2,
-  omp_lock_hint_contended = omp_sync_hint_contended,
+  omp_lock_hint_contended __GOMP_DEPRECATED = omp_sync_hint_contended,
   omp_sync_hint_nonspeculative = 4,
-  omp_lock_hint_nonspeculative = omp_sync_hint_nonspeculative,
+  omp_lock_hint_nonspeculative __GOMP_DEPRECATED = omp_sync_hint_nonspeculative,
   omp_sync_hint_speculative = 8,
-  omp_lock_hint_speculative = omp_sync_hint_speculative
+  omp_lock_hint_speculative __GOMP_DEPRECATED = omp_sync_hint_speculative
 } omp_sync_hint_t;
 
-typedef omp_sync_hint_t omp_lock_hint_t;
+typedef __GOMP_DEPRECATED omp_sync_hint_t omp_lock_hint_t;
 
 typedef struct __attribute__((__aligned__ (sizeof (void *)))) omp_depend_t
 {
@@ -108,8 +115,8 @@  extern int omp_in_parallel (void) __GOMP_NOTHROW;
 extern void omp_set_dynamic (int) __GOMP_NOTHROW;
 extern int omp_get_dynamic (void) __GOMP_NOTHROW;
 
-extern void omp_set_nested (int) __GOMP_NOTHROW;
-extern int omp_get_nested (void) __GOMP_NOTHROW;
+extern void omp_set_nested (int) __GOMP_DEPRECATED __GOMP_NOTHROW;
+extern int omp_get_nested (void) __GOMP_DEPRECATED __GOMP_NOTHROW;
 
 extern void omp_init_lock (omp_lock_t *) __GOMP_NOTHROW;
 extern void omp_init_lock_with_hint (omp_lock_t *, omp_sync_hint_t)