I've backported several patches having to do with Fortran/C interoperability from mainline to the OG11 branch. See attached log for details.

-Sandra
commit d554155c07771935778f557e9ef649cc3624d1ce
Author: Sandra Loosemore <san...@codesourcery.com>
Date:   Wed Aug 11 19:24:17 2021 -0700

    Fortran: Fix c_float128 and c_float128_complex definitions.
    
    gfc_float128_type_node is only non-NULL on targets that support a
    128-bit type that is not long double.  Use float128_type_node instead
    when computing the value of the kind constants c_float128 and
    c_float128_complex from the ISO_C_BINDING intrinsic module; this also
    ensures it actually corresponds to __float128 (the IEEE encoding) and
    not some other 128-bit floating-point type.
    
    2021-08-11  Sandra Loosemore  <san...@codesourcery.com>
    
    gcc/fortran/
    	* iso-c-binding.def (c_float128, c_float128_complex): Check
    	float128_type_node instead of gfc_float128_type_node.
    	* trans-types.c (gfc_init_kinds, gfc_build_real_type):
    	Update comments re supported 128-bit floating-point types.
    
    (cherry picked from commit 58340a7cd3670024bafdbbc6ca63a9af841df98a)

commit 0a8af79817f5c633543d2aa32f4f0385af4cf22c
Author: Tobias Burnus <tob...@codesourcery.com>
Date:   Wed Aug 11 19:18:42 2021 -0700

    gfortran: Fix in-build-tree testing [PR101305, PR101660]
    
    ISO_Fortran_binding.h is written in the build dir - hence, a previous commit
    added it as include directory for in-build-tree testing.  However,
    it turned out that -I$specdir/libgfortran interferes with reading .mod files
    as they are then no longer regareded as intrinsic modules.  Solution: Create
    an extra include/ directory in the libgfortran build dir and copy
    ISO_Fortran_binding.h to that directory.  As -B$specdir/libgfortran already
    causes gfortran to read that include subdirectory, the -I flag is no longer
    needed.
    
    	PR libfortran/101305
    	PR fortran/101660
    	PR testsuite/101847
    
    libgfortran/ChangeLog:
    
    	* Makefile.am (ISO_Fortran_binding.h): Create include/ in the build dir
    	and copy the include file to it.
    	(clean-local): Add for removing the 'include' directory.
    	* Makefile.in: Regenerate.
    
    gcc/testsuite/ChangeLog:
    
    	* lib/gfortran.exp (gfortran_init): Remove -I$specpath/libgfortran
    	from the string used to set GFORTRAN_UNDER_TEST.
    
    (cherry picked from commit 2ba0376ac40447ce7ee09fcef00511c18db25dfa)

commit d2b1fbc8a159a465ce6114723301721808972a6e
Author: Tobias Burnus <tob...@codesourcery.com>
Date:   Mon Aug 9 12:35:23 2021 +0200

    testsuite/lib/gfortran.exp: Add -I for ISO*.h [PR101305, PR101660]
    
    This patch adds -I$specdir/libgfortran to GFORTRAN_UNDER_TEST, when
    set by proc gfortran_init. As the $specdir depends on the multilib
    setting, it has to be re-set for a different multilib; hence, we track
    whether a previous call to gfortran_init set that var or whether it
    was set differently.
    
    gcc/testsuite/
    	PR libfortran/101305
    	PR fortran/101660
    
    	* lib/gfortran.exp (gfortran_init): Add -I $specdir/libgfortran to
    	GFORTRAN_UNDER_TEST; update it when set by previous gfortran_init call.
    	* gfortran.dg/ISO_Fortran_binding_1.c: Use <...> not "..." for
    	ISO_Fortran_binding.h's #include.
    	* gfortran.dg/ISO_Fortran_binding_10.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_11.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_12.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_15.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_16.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_17.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_18.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_3.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_5.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_6.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_7.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_8.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_9.c: Likewise.
    	* gfortran.dg/PR94327.c: Likewise.
    	* gfortran.dg/PR94331.c: Likewise.
    	* gfortran.dg/bind_c_array_params_3_aux.c: Likewise.
    	* gfortran.dg/iso_fortran_binding_uint8_array_driver.c: Likewise.
    	* gfortran.dg/pr93524.c: Likewise.
    
    (cherry picked from commit 527a1cf32c27a3fbeaf6be7596241570d864cc4c)

commit 5084c7d199d149cb58a3c41aae4ed9e97ef9ad31
Author: Sandra Loosemore <san...@codesourcery.com>
Date:   Wed Aug 11 18:57:34 2021 -0700

    Bind(c): Improve error checking in CFI_* functions
    
    This patch adds additional run-time checking for invalid arguments to
    CFI_establish and CFI_setpointer.  It also changes existing messages
    throughout the CFI_* functions to use PRIiPTR to format CFI_index_t
    values instead of casting them to int and using %d (which may not work
    on targets where int is a smaller type), simplifies wording of some
    messages, and fixes issues with capitalization, typos, and the like.
    Additionally some coding standards problems such as >80 character lines
    are addressed.
    
    2021-07-24  Sandra Loosemore  <san...@codesourcery.com>
    
    	PR libfortran/101317
    
    libgfortran/
    	* runtime/ISO_Fortran_binding.c: Include <inttypes.h>.
    	(CFI_address): Tidy error messages and comments.
    	(CFI_allocate): Likewise.
    	(CFI_deallocate): Likewise.
    	(CFI_establish): Likewise.  Add new checks for validity of
    	elem_len when it's used, plus type argument and extents.
    	(CFI_is_contiguous): Tidy error messages and comments.
    	(CFI_section): Likewise.  Refactor some repetitive code to
    	make it more understandable.
    	(CFI_select_part): Likewise.
    	(CFI_setpointer): Likewise.  Check that source is not an
    	unallocated allocatable array or an assumed-size array.
    
    gcc/testsuite/
    	* gfortran.dg/ISO_Fortran_binding_17.f90: Fix typo in error
    	message patterns.
    
    (cherry picked from commit e78480ad0983cf75813af5e02d68cdad09e441e9)

commit 5fb197bb665363eb556690fb2d3106c2d0caff69
Author: Sandra Loosemore <san...@codesourcery.com>
Date:   Wed Aug 11 18:54:24 2021 -0700

    Bind(c): Fix bugs in CFI_section
    
    CFI_section was incorrectly adjusting the base pointer for the result
    array twice in different ways.  It was also overwriting the array
    dimension info in the result descriptor before computing the base
    address offset from the source descriptor, which caused problems if
    the two descriptors are the same.  This patch fixes both problems and
    makes the code simpler, too.
    
    A consequence of this patch is that the result array is now 0-based in
    all dimensions instead of starting at the numbering to match the first
    element of the source array.  The Fortran standard only specifies the
    shape of the result array, not its lower bounds, so this is permitted
    and probably less confusing for users as well as implementors.
    
    2021-07-17  Sandra Loosemore  <san...@codesourcery.com>
    
    	PR libfortran/101310
    
    libgfortran/
    	* runtime/ISO_Fortran_binding.c (CFI_section): Fix the base
    	address computation and simplify the code.
    
    gcc/testsuite/
    	* gfortran.dg/ISO_Fortran_binding_1.c (section_c): Remove
    	incorrect assertions.
    
    (cherry picked from commit b4a9bc7856ee1d3ff98b04402334a362540af2cf)

commit 9066930df2310a09aed84e6ddb33af570aefc6a4
Author: Sandra Loosemore <san...@codesourcery.com>
Date:   Wed Aug 11 18:46:24 2021 -0700

    Fix ISO_Fortran_binding.h paths in gfortran testsuite
    
    ISO_Fortran_binding.h is now generated in the libgfortran build
    directory where it is on the default include path.  Adjust includes in
    the gfortran testsuite not to include an explicit path pointing at the
    source directory.
    
    2021-07-27  Sandra Loosemore  <san...@codesourcery.com>
    
    gcc/testsuite/
    	PR libfortran/101305
    	* gfortran.dg/ISO_Fortran_binding_1.c: Adjust include path.
    	* gfortran.dg/ISO_Fortran_binding_10.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_11.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_12.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_15.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_16.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_17.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_18.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_3.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_5.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_6.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_7.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_8.c: Likewise.
    	* gfortran.dg/ISO_Fortran_binding_9.c: Likewise.
    	* gfortran.dg/PR94327.c: Likewise.
    	* gfortran.dg/PR94331.c: Likewise.
    	* gfortran.dg/bind_c_array_params_3_aux.c: Likewise.
    	* gfortran.dg/iso_fortran_binding_uint8_array_driver.c: Likewise.
    	* gfortran.dg/pr93524.c: Likewise.
    
    (cherry picked from commit a3b350f1799a1c0f9e2ece5b817a537fe42f0d2d)

commit 2942b4f3fb8fc574ef0d4ee868c9057d7e9bab47
Author: Sandra Loosemore <san...@codesourcery.com>
Date:   Wed Aug 11 18:41:44 2021 -0700

    Bind(C): Correct sizes of some types in CFI_establish
    
    CFI_establish was failing to set the default elem_len correctly for
    CFI_type_cptr, CFI_type_cfunptr, CFI_type_long_double, and
    CFI_type_long_double_Complex.
    
    2021-07-13  Sandra Loosemore  <san...@codesourcery.com>
    
    libgfortran/
    	PR libfortran/101305
    	* runtime/ISO_Fortran_binding.c (CFI_establish): Special-case
    	CFI_type_cptr and CFI_type_cfunptr.  Correct size of long double
    	on targets where it has kind 10.
    
    (cherry picked from commit c4dc9f590181321c36d3f3ef72c50b3c47bbfe7c)

commit 2446af41a53f0283360d523cb8b3554b4e36ade6
Author: Sandra Loosemore <san...@codesourcery.com>
Date:   Wed Aug 11 18:33:52 2021 -0700

    Bind(C): Fix type encodings in ISO_Fortran_binding.h
    
    ISO_Fortran_binding.h had many incorrect hardwired kind encodings in
    the definitions of the CFI_type_* macros.  Additionally, not all
    targets support all the defined type encodings, and the Fortran
    standard requires those macros to have a negative value.
    
    This patch changes ISO_Fortran_binding.h to use sizeof instead of
    hard-coded sizes, and assembles it from fragments that reflect the
    set of types supported by the target.
    
    2021-07-22  Sandra Loosemore  <san...@codesourcery.com>
    	    Tobias Burnus  <tob...@codesourcery.com>
    
    libgfortran/
    	PR libfortran/101305
    	* ISO_Fortran_binding.h: Fix hard-coded sizes and split into...
    	* ISO_Fortran_binding-1-tmpl.h: New file.
    	* ISO_Fortran_binding-2-tmpl.h: New file.
    	* ISO_Fortran_binding-3-tmpl.h: New file.
    	* Makefile.am: Add rule for generating ISO_Fortran_binding.h.
    	Adjust pathnames to that file.
    	* Makefile.in: Regenerated.
    	* mk-kinds-h.sh: New file.
    	* runtime/ISO_Fortran_binding.c: Fix include path.
    
    (cherry picked from commit fef67987cf502fe322e92ddce22eea7ac46b4d75)

commit 4ec35530502cdbf18f3ff13202c4f63b64395f42
Author: Paul Thomas <pa...@gcc.gnu.org>
Date:   Wed Aug 11 17:54:14 2021 -0700

    Fortran: Assumed and explicit size class arrays [PR46691/99819].
    
    2021-05-06  Paul Thomas  <pa...@gcc.gnu.org>
    
    gcc/fortran/ChangeLog
    
    	PR fortran/46691
    	PR fortran/99819
    	* class.c (gfc_build_class_symbol): Remove the error that
    	disables assumed size class arrays. Class array types that are
    	not deferred shape or assumed rank are given a unique name and
    	placed in the procedure namespace.
    	* trans-array.c (gfc_trans_g77_array): Obtain the data pointer
    	for class arrays.
    	(gfc_trans_dummy_array_bias): Suppress the runtime error for
    	extent violations in explicit shape class arrays because it
    	always fails.
    	* trans-expr.c (gfc_conv_procedure_call): Handle assumed size
    	class actual arguments passed to non-descriptor formal args by
    	using the data pointer, stored as the symbol's backend decl.
    
    gcc/testsuite/ChangeLog
    
    	PR fortran/46691
    	PR fortran/99819
    	* gfortran.dg/class_dummy_6.f90: New test.
    	* gfortran.dg/class_dummy_7.f90: New test.
    
    (cherry picked from commit a2c593009fef1564dbef2237ee71e9fd08f5361e)

Reply via email to