[WIP, Fortran] TS 29113 testsuite

2021-06-30 Thread Sandra Loosemore
For the past several months I've been working on developing a set of 
tests for the Fortran/C interoperability features added to Fortran via 
TS 29113, "Further Interoperability of Fortran with C":


https://wg5-fortran.org/N1901-N1950/N1942.pdf

The goal here is to exercise gfortran's implementation in a more 
systematic and complete way, including conformance with error detection 
requirements and the like as well as making sure correct programs run 
correctly.


I'm posting this as work-in-progress at this time because, well, there 
are a lot of bugs in the implementation causing lots of the tests to 
fail.  :-(  I know maintainers don't like patches that deliberately add 
FAILs to the test results and the normal practice seems to be to XFAIL 
known bugs with references to a PR.  Some of the bugs already have PRs 
open, but others don't.  What I plan to work on next is filing or 
updating the PRs with reference to the testcases that demonstrate the 
bugs, add the XFAILs, and then resubmit the patch for approval.  A few 
of these tests also still have some excessively verbose debugging output 
enabled which I'll also try to clean up before resubmitting.


I have a trivial patch for one set of failures (incorrect initialization 
of version fields) that I'll be posting shortly.  A couple of José's 
recent not-yet-committed patches also fix some of the bugs I've run 
into; I will note those in the corresponding PRs as I work through the list.


-Sandra






ts29113-testsuite-wip.patch.gz
Description: application/gzip


[PATCH, Fortran] set version field in CFI_cdesc_t to CFI_VERSION

2021-06-30 Thread Sandra Loosemore
This patch fixes the failures in interoperability/fc-descriptor-8.f90 in 
my just-posted TS 29113 testsuite:


https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574115.html

The problem here is that the routines that copy between GFC and CFI 
descriptors think they both use the same version number conventions, but 
the GFC descriptors' version is zero-initialized elsewhere and 
CFI_VERSION is defined to be 1.  It seems incorrect to expect the 
internal and external descriptor ABIs to be in lock step together anyway.


OK to check in?

-Sandra
commit b0edc2d3287d6ed52a43010b92c4158c6208ef11
Author: Sandra Loosemore 
Date:   Wed Jun 30 19:28:22 2021 -0700

Fortran: set version field in CFI_cdesc_t to CFI_VERSION

When converting a GFC descriptor to a CFI descriptor, it was
incorrectly copying the version number from the former to the latter.
It should be using the value of CFI_VERSION instead (currently 1).
Going the other direction, the GFC version field is initialized to
zero elsewhere, so do that here too.

2021-06-30  Tobias Burnus  
	Sandra Loosemore  

	libgfortran/
	* runtime/ISO_Fortran_binding.c (cfi_desc_to_gfc_desc):
	Initialize version field to 0.
	(gfc_desc_to_cfi_desc): Initialize version field to CFI_VERSION.

diff --git a/libgfortran/runtime/ISO_Fortran_binding.c b/libgfortran/runtime/ISO_Fortran_binding.c
index 0978832..73fb4c4 100644
--- a/libgfortran/runtime/ISO_Fortran_binding.c
+++ b/libgfortran/runtime/ISO_Fortran_binding.c
@@ -60,7 +60,7 @@ cfi_desc_to_gfc_desc (gfc_array_void *d, CFI_cdesc_t **s_ptr)
   else
 GFC_DESCRIPTOR_SIZE (d) = s->elem_len;
 
-  d->dtype.version = s->version;
+  d->dtype.version = 0;
   GFC_DESCRIPTOR_RANK (d) = (signed char)s->rank;
 
   d->dtype.attribute = (signed short)s->attribute;
@@ -104,7 +104,7 @@ gfc_desc_to_cfi_desc (CFI_cdesc_t **d_ptr, const gfc_array_void *s)
 
   d->base_addr = GFC_DESCRIPTOR_DATA (s);
   d->elem_len = GFC_DESCRIPTOR_SIZE (s);
-  d->version = s->dtype.version;
+  d->version = CFI_VERSION;
   d->rank = (CFI_rank_t)GFC_DESCRIPTOR_RANK (s);
   d->attribute = (CFI_attribute_t)s->dtype.attribute;