This is an updated version of the earlier patch. The main addition is a second testcase that checks the errors emitted by the CFI API functions. It should be noted that there is some strangeness in the test for CFI_select_part errors. The order of the tests matters. If they are inverted from the order in the patch, the test fails for -O2 and greater. Testing with the order inverted outside of the test harness gave all manner of random errors and occasional success. I haven't understood what is going on. That said, deliberately triggering a sequence of deliberate errors like this is highly artificial since I suppose that they would normally individually lead to termination of execution. Bootstrapped and regtested on FC28/x86_64 - OK for trunk? Paul 2019-01-07 Paul Thomas * trans-array.c (gfc_conv_descriptor_attribute): New function. (gfc_get_dataptr_offset): Remove static function attribute. * trans-array.h : Add prototypes for above functions. * trans-decl.c : Add declarations for the library functions cfi_desc_to_gfc_desc and gfc_desc_to_cfi_desc. * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): New function. (gfc_conv_procedure_call): Call it for scalar and array actual arguments, when the formal arguments are bind_c with assumed shape or assumed rank. * trans.h : External declarations for gfor_fndecl_cfi_to_gfc and gfor_fndecl_gfc_to_cfi. 2019-01-07 Paul Thomas * gfortran.dg/ISO_Fortran_binding_1.f90 : New test. * gfortran.dg/ISO_Fortran_binding_1.c : Auxilliary file for test. * gfortran.dg/ISO_Fortran_binding_2.f90 : New test. * gfortran.dg/ISO_Fortran_binding_2.c : Auxilliary file for test. * gfortran.dg/ISO_Fortran_binding.h : Auxilliary file for test. * gfortran.dg/bind_c_array_params_2.f90 : Change search string for dump tree scan. 2019-01-07 Paul Thomas * ISO_Fortran_binding.h : New file. * Makefile.am : Include ISO_Fortran_binding.c in the list of files to compile. * Makefile.in : Regenerated. * gfortran.map : Add _gfortran_cfi_desc_to_gfc_desc, _gfortran_gfc_desc_to_cfi_desc and the CFI API functions. * runtime/ISO_Fortran_binding.c : New file containing the new functions added to the map.