Skip to content

Declare enum-valued arguments integer(c_int) in the bind(C) interfaces - #586

Merged
amontoison merged 1 commit into
developfrom
c_int_enums
Oct 9, 2026
Merged

amontoison merged 1 commit into
developfrom
c_int_enums

Conversation

@amontoison

@amontoison amontoison commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

integer(kind(<enumerator>)) is the same type as integer(c_int), because the enumerators of an enum, bind(c) have the kind of a C int. gfortran -Wall still reports every occurrence in a bind(C) interface as possibly not C interoperable (-Wc-binding-type), about 12,000 warnings over the modules. The bind(C) specifics now declare these arguments and results integer(c_int). The module procedures (_typed, _devptr, array overloads) keep the enum's name in their kind. Interfaces that no longer use an enum also drop their use hipfort_*_enums.

Nothing changes for callers: the types are identical, and integer(c_int) comes from standard ISO_C_BINDING, so every compiler supports it.

Regenerated with rocm-fortran 2bbcea6, including the symbol tests.

Warnings when compiling lib/hipfort (default, -DUSE_ASSUMED_RANK, -DUSE_ASSUMED_SHAPE, -DUSE_ASSUMED_SHAPE -DUSE_CUDA_NAMES):

before after
gfortran -Wall ~12,475 0
amdflang -pedantic 0 0

Full build with -DHIPFORT_EXTENDED_TESTS=ON (gfortran): 0 warnings. ctest on GPU: 1266/1269 pass. The 3 failures (hip_mem_advise f2003/f2008, hip_module_kernel) are the known WSL-only failures and also happen on develop.

@amontoison
amontoison requested a review from a team as a code owner October 9, 2026 03:08
Base automatically changed from more_typed_forms to develop October 9, 2026 03:14
integer(kind(<enumerator>)) is the same type as integer(c_int), but gfortran
-Wall reported every occurrence in a bind(C) interface as possibly not C
interoperable (-Wc-binding-type), about 12,000 warnings over the modules.
The module procedures keep the enum's name in their kind. Regenerated with
rocm-fortran 2bbcea6, symbol tests included.
@amontoison
amontoison merged commit 145d893 into develop Oct 9, 2026
2 of 3 checks passed
@amontoison
amontoison deleted the c_int_enums branch October 9, 2026 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant