Fortran: Fix deprecate warning with parameter
Commit Message
Played around with the warning in the 'omp_lib' module (needs tweaking
as for the current version, no warning is done). Turned out that already
use omp_lib
outputs a warning even when not used.
That's fixed by the attached patch - even if the location is not perfect.
OK for GCC 12 + GCC 11 backport?
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
Comments
Hi Tobias,
Am 05.10.21 um 20:03 schrieb Tobias Burnus:
> Played around with the warning in the 'omp_lib' module (needs tweaking
> as for the current version, no warning is done). Turned out that already
> use omp_lib
> outputs a warning even when not used.
that must have been a non-trivial example; I didn't see that on my
installation.
> That's fixed by the attached patch - even if the location is not perfect.
That is certainly an improvement for the testcase.
IIUC the warning is for GCC$ ATTRIBUTES DEPRECATED, so could you mention
that in the commit message.
> OK for GCC 12 + GCC 11 backport?
OK for both.
Thanks for the patch!
Harald
> 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
Hi Harald,
On 05.10.21 21:10, Harald Anlauf wrote:
> Am 05.10.21 um 20:03 schrieb Tobias Burnus:
>> Played around with the warning in the 'omp_lib' module (needs tweaking
>> as for the current version, no warning is done). Turned out that already
>> use omp_lib
>> outputs a warning even when not used.
>
> that must have been a non-trivial example; I didn't see that on my
> installation.
The example is trivial – but as written, you need to tweak the module.
libgomp/omp_lib.f90.in has:
...
#if _OPENMP >= 202011
!GCC$ ATTRIBUTES DEPRECATED :: omp_proc_bind_master
#endif
That file is compiled with '-fopenmp -cpp' and _OPENMP is set to
201511 (= OpenMP 4.5) but the parameter is only deprecated in
OpenMP 5.1 (202011). Thus, you only see this warning (with -Wall)
when either the OpenMP version is bumped - or as I did it:
when commenting the version checks.
Tobias
PS: I will commit the patch tomorrow. Thanks for the review.
-----------------
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
Fortran: Fix deprecate warning with parameter
gcc/fortran/ChangeLog:
* resolve.c (resolve_values): Only show
deprecated warning if attr.referenced.
gcc/testsuite/ChangeLog:
* gfortran.dg/attr_deprecated-2.f90: New test.
@@ -12351,7 +12351,7 @@ resolve_values (gfc_symbol *sym)
if (sym->value == NULL)
return;
- if (sym->attr.ext_attr & (1 << EXT_ATTR_DEPRECATED))
+ if (sym->attr.ext_attr & (1 << EXT_ATTR_DEPRECATED) && sym->attr.referenced)
gfc_warning (OPT_Wdeprecated_declarations,
"Using parameter %qs declared at %L is deprecated",
sym->name, &sym->declared_at);
new file mode 100644
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! { dg-additional-options "-Wall" }
+!
+! Ensure that only those parameters are warned for which are actually used
+!
+module m
+ implicit none
+ integer, parameter :: parm = 4 ! unused
+ integer, parameter :: parm2 = 4 ! used in the main program
+ integer, parameter :: parm3 = 4 ! used in "f()" - { dg-warning "Using parameter 'parm3' declared at .1. is deprecated" }
+ integer, save :: var, var2
+!GCC$ ATTRIBUTES DEPRECATED :: parm, parm2, parm3, var, var2
+contains
+ subroutine f()
+ print *, parm3 ! warning shown above
+ end
+end module m
+
+use m ! { dg-warning "Using parameter 'parm2' declared at .1. is deprecated" }
+implicit none
+print *, var2, parm2 ! { dg-warning "Using variable 'var2' at .1. is deprecated" }
+end