]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/fortran/interface.cc
Fortran: Fix incompatible types between INTEGER(8) and TYPE(c_ptr)
authorPaul-Antoine Arras <pa@codesourcery.com>
Fri, 20 Oct 2023 10:42:49 +0000 (12:42 +0200)
committerPaul-Antoine Arras <pa@codesourcery.com>
Thu, 26 Oct 2023 13:12:37 +0000 (15:12 +0200)
commit8d2130a4e5ce369f5884c8522934dc027db6e9d8
tree799e2df49d40b047c9275c2f30452476781b039e
parenta4ca8691333344cecc595d1af8b21e51f588e2f2
Fortran: Fix incompatible types between INTEGER(8) and TYPE(c_ptr)

In the context of an OpenMP declare variant directive, arguments of type C_PTR
are sometimes recognised as C_PTR in the base function and as INTEGER(8) in the
variant - or the other way around, depending on the parsing order.
This patch prevents such situation from turning into a compile error.

2023-10-20  Paul-Antoine Arras  <pa@codesourcery.com>
    Tobias Burnus  <tobias@codesourcery.com>

gcc/fortran/ChangeLog:

* interface.cc (gfc_compare_types): Return true if one type is C_PTR
and the other is a compatible INTEGER(8).
* misc.cc (gfc_typename): Handle the case where an INTEGER(8) actually
holds a TYPE(C_PTR).

gcc/testsuite/ChangeLog:

* gfortran.dg/c_ptr_tests_20.f90: New test, checking that INTEGER(8)
and TYPE(C_PTR) are recognised as compatible.
* gfortran.dg/c_ptr_tests_21.f90: New test, exercising the error
detection for C_FUNPTR.
gcc/fortran/interface.cc
gcc/fortran/misc.cc
gcc/testsuite/gfortran.dg/c_ptr_tests_20.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/c_ptr_tests_21.f90 [new file with mode: 0644]