Skip to content

Commit c1eeb95

Browse files
committed
check CFI_CDESC_T
1 parent 33b5882 commit c1eeb95

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

cmake/compilers.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ endif()
6565
if(HAVE_ISO_FORTRAN_BINDING_H)
6666
check_symbol_exists(CFI_is_contiguous "ISO_Fortran_binding.h" HAVE_CFI_IS_CONTIGUOUS)
6767
check_symbol_exists(CFI_setpointer "ISO_Fortran_binding.h" HAVE_CFI_SETPOINTER)
68+
69+
# some compilers allow using CFI_CDESC_T as a pointer but are missing the properties of it.
70+
check_source_compiles(C "#include <ISO_Fortran_binding.h>
71+
int main(void){
72+
CFI_CDESC_T(1) t;
73+
char* s = (char*) t.base_addr;
74+
return 0;
75+
}"
76+
HAVE_CFI_CDESC
77+
)
6878
endif()
6979

7080
endfunction()

test/iso_fortran_binding/CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ if(HAVE_C_CHAR_PTR)
3535
add_executable(cfi_establish_string c_string.f90 c_string.c)
3636
add_test(NAME CFI_establish_string COMMAND cfi_establish_string)
3737

38-
add_executable(string_array string_array.cpp string_array.f90)
39-
set_property(TARGET string_array PROPERTY LINKER_LANGUAGE CXX)
40-
target_compile_options(string_array PRIVATE "$<$<COMPILE_LANG_AND_ID:Fortran,GNU>:-Wno-uninitialized>")
38+
if(HAVE_CFI_CDESC)
39+
add_executable(string_array string_array.cpp string_array.f90)
40+
set_property(TARGET string_array PROPERTY LINKER_LANGUAGE CXX)
41+
target_compile_options(string_array PRIVATE "$<$<COMPILE_LANG_AND_ID:Fortran,GNU>:-Wno-uninitialized>")
42+
43+
add_test(NAME string_array COMMAND string_array)
44+
set_property(TEST string_array PROPERTY PASS_REGULAR_EXPRESSION "red[ \n]+green[ \n]+blue")
45+
endif()
4146

42-
add_test(NAME string_array COMMAND string_array)
43-
set_property(TEST string_array PROPERTY PASS_REGULAR_EXPRESSION
44-
"red[ \n]+green[ \n]+blue")
4547
endif()
4648

4749

0 commit comments

Comments
 (0)