Output from C2F

Paul Richard Thomas paul.richard.thomas@gmail.com
Sat Dec 9 12:38:00 GMT 2017


Hi Fritz,

I was triggered by a thread on clf to get c2f to compile and run with
gfortran, rather than CVF. It was a more or less straightforward
operation, largely due to your efforts to implement -fdec, and the
replacement of some dflib calls to runqq(...) and commitqq(...) with
system(...) and flush(...).

It now produces output from the supplied debug.c but the resulting
debug.f90 does not compile completely with gfortran. Notable among the
failures are:

union test
          {
            int x;
            char y;
          };
union test a;

translating to:
  TYPE :: TEST
  UNION
  MAP
    INTEGER :: x
  END MAP
  MAP
    CHARACTER :: y
  END MAP
  END UNION
  END TYPE
  TYPE (TEST) :: a

and
typedef struct
             {
              int a;
              float b;
              union
              {
               int c;
               float d;
              } u1;
              struct
              {
               int e;
               float f;
              } s1;
              double z;
             } Bigtype;

translating to:
  TYPE :: U1_U
  UNION
  MAP
    INTEGER :: c
  END MAP
  MAP
    REAL(4) :: d
  END MAP
  END UNION
  END TYPE
  TYPE :: S1_T
    INTEGER :: e
    REAL(4) :: f
  END TYPE
  TYPE :: BIGTYPE_T
    INTEGER :: a
    REAL(4) :: b
    TYPE (U1_U) :: u1
    TYPE (S1_T) :: s1
    REAL(8) :: z
  END TYPE

I presume that these must have compiled OK on CVF and I was wondering
why you didn't implement derived types hosting union/map? Obviously, I
could modify c2f to produce structures rather than derived types but
the backward compatability of gfortran with -fdec would be enganced if
the above versions were allowed.

Cheers

Paul

PS: Other snafus are:
(i) Cray pointers clashing with a later declaration of their type;
(ii) Error: CRAY POINTEE attribute conflicts with TARGET attribute at (1);
(iii) Warning: Cray pointer at (1) has 4 bytes of precision; memory
addresses require 8 bytes;
(iv) Passing integer(4) to integer(2);
(v) Some out of bounds array references;
(vi) Operands of comparison operator ‘>’ at (1) are LOGICAL(4)/INTEGER(4);
(vii) Error: Assumed size array at (1) must be a dummy argument; and
(viii) Some missing explicit interfaces, generated by the need to use
-fno-whole-file to overcome some deliberate interface mismatches
(character, dimension(len) => character(len) mostly).

All in all though, it is not too bad for the conversion of 2022 lines
of C into 3373 lines of fortran, including a lot of c2f supplied
comment lines. The porblems could be fixed by hand but, having
started, I intend to complete the job



More information about the Fortran mailing list