[Patch] Fortran/OpenMP: Add memory routines existing for C/C++

Tobias Burnus tobias@codesourcery.com
Wed Aug 18 09:00:47 GMT 2021

The added routines existed before for C/C++ (being part of OpenMP 5.0)
but not for Fortran (new there since OpenMP 5.1) – as those are all bind(C),
it only affects 'omp_lib' and uses the C interface otherwise.

Note 1: OpenMP 5.1 added additional (target) memory routines for
C/C++ and Fortran; those are not included here.

---------------- Note 2 -----------------------
'omp_lib.h' is included in as declaration-construct in the
specification-part of a file (i.e. possibly after an implicit statement);
hence, it cannot contain a use-stmt.  Additionally, it needs to support
both free- and fixed-form source files.
While thought to be compatible with Fortran 77, nothing actually requires
that only Fortran 77 code is used and gfortran only supports -std=f95 or

Hence, (rightly!) assuming that only gfortran compiles that file,
Fortran 90 + 95 features can be used; the code already uses TYPE.

However, the the attached patch also BIND(C) + IMPORT, which are
Fortran 2003 features, effectively preventing the compilation with

My impression is that old code (Fortran IV, 66, 77, older 90/95) code
tends to use vendor extension (preventing the compilation with -std=f*)
and users do not care about setting -std=f* flags.
Or the code is old but still maintained. But in that case, new features
of Fortran 2003 (and later) intentionally and/or accidentally get used,
already preventing the compilation with -std=f95.

Thus, I think it is okay to use a Fortran 2003 feature.
---------------- End of Note 2 -----------------------

The testcases are those for C/C++ converted to Fortran.
Comments? OK?


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: omp-alloc-fortran.diff
Type: text/x-patch
Size: 19043 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210818/a290f4d6/attachment-0001.bin>

More information about the Gcc-patches mailing list