Looks fine, including the factor of 2 distinction between Kind and Star for Complex types. I don't have any opinion on how complete this is, someone who uses Fortran more extensively will know whether other interface types might be useful.
Ed On Mar 19, 2013, at 5:51 PM, Arnaud Charlet wrote: >> I would like if some of the Ada/GNAT experts could have a look - as >> this is really my first look at Ada code. > > Patch looks reasonable to me at first sight, but I'm not a Fortran specialist. > > Ed, Robert, could you have a look? > >> 2013-03-19 Tobias Burnus <bur...@net-b.de> >> >> * i-fortra.ads: Update comment, add Ada 2012's optional >> Star and Kind data types for enhanced interoperability. >> >> diff --git a/gcc/ada/i-fortra.ads b/gcc/ada/i-fortra.ads >> index 992eb28..270c819 100644 >> --- a/gcc/ada/i-fortra.ads >> +++ b/gcc/ada/i-fortra.ads >> @@ -26,11 +26,11 @@ package Interfaces.Fortran is >> type Logical is new Boolean; >> for Logical'Size use Integer'Size; >> pragma Convention (Fortran, Logical); >> - -- As required by Fortran standard, stand alone logical allocates same >> - -- space as integer (but what about the array case???). The convention >> - -- is important, since in Fortran, Booleans have zero/non-zero semantics >> - -- for False/True, and the pragma Convention (Fortran) activates the >> - -- special handling required in this case. >> + -- As required by Fortran standard, logical allocates same space as >> + -- an integer. The convention is important, since in Fortran, Booleans >> + -- are implemented with zero/non-zero semantics for False/True, and the >> + -- pragma Convention (Fortran) activates the special handling required >> + -- in this case. >> >> package Single_Precision_Complex_Types is >> new Ada.Numerics.Generic_Complex_Types (Real); >> @@ -50,6 +50,53 @@ package Interfaces.Fortran is >> >> type Fortran_Character is array (Positive range <>) of >> Character_Set; >> >> + -- Additional declarations as permitted by Ada 2012, p.608, paragraph >> 21. >> + -- Interoperability with Fortran 77's vendor extension using star >> + -- notation and Fortran 90's intrinsic types with kind=n parameter. >> + -- The following assumes that `n' matches the byte size, which >> + -- most Fortran compiler, including GCC's follow. >> + >> + type Integer_Star_1 is new Integer_8; >> + type Integer_Kind_1 is new Integer_8; >> + type Integer_Star_2 is new Integer_16; >> + type Integer_Kind_2 is new Integer_16; >> + type Integer_Star_4 is new Integer_32; >> + type Integer_Kind_4 is new Integer_32; >> + type Integer_Star_8 is new Integer_64; >> + type Integer_Kind_8 is new Integer_64; >> + >> + type Logical_Star_1 is new Boolean; >> + type Logical_Star_2 is new Boolean; >> + type Logical_Star_4 is new Boolean; >> + type Logical_Star_8 is new Boolean; >> + for Logical_Star_1'Size use Integer_8'Size; >> + for Logical_Star_2'Size use Integer_16'Size; >> + for Logical_Star_4'Size use Integer_32'Size; >> + for Logical_Star_8'Size use Integer_64'Size; >> + pragma Convention (Fortran, Logical_Star_1); >> + pragma Convention (Fortran, Logical_Star_2); >> + pragma Convention (Fortran, Logical_Star_4); >> + pragma Convention (Fortran, Logical_Star_8); >> + >> + type Logical_Kind_1 is new Logical_Star_1; >> + type Logical_Kind_2 is new Logical_Star_2; >> + type Logical_Kind_4 is new Logical_Star_4; >> + type Logical_Kind_8 is new Logical_Star_8; >> + >> + type Real_Star_4 is new Float; >> + type Real_Kind_4 is new Float; >> + type Real_Star_8 is new Long_Float; >> + type Real_Kind_8 is new Long_Float; >> + >> + -- In the kind syntax, n is the same as the associated real kind. >> + -- In the star syntax, n is twice as large (real+imaginary size) >> + type Complex_Star_8 is new Complex; >> + type Complex_Kind_4 is new Complex; >> + type Complex_Star_16 is new Double_Complex; >> + type Complex_Kind_8 is new Double_Complex; >> + >> + type Character_Kind_n is new Fortran_Character; >> + >> function To_Fortran (Item : Character) return Character_Set; >> function To_Ada (Item : Character_Set) return Character;