[patch, fortran] Make ABI ready for BACK argument of MINLOC and MAXLOC

Janne Blomqvist blomqvist.janne@gmail.com
Tue Jan 9 08:27:00 GMT 2018


On Mon, Jan 8, 2018 at 11:48 PM, Thomas Koenig <tkoenig@netcologne.de> wrote:
> Hi Janne,
>
>> If I understand it correctly, in the library the back argument is
>> always a LOGICAL(kind=4). But in the frontend, the back argument is
>> coerced to gfc_default_logical_kind. So this doesn't work if one uses
>> the -fdefault-integer-8 option, because then gfc_default_logical_kind
>> will be 8.
>>
>> I suggest you create a constant "gfc_logical4_kind" and use that in
>> the frontend.
>
>
> Implemented in the version below. (I discussed briefly with myself
> if it would make sense to create a global variable to hold the value
> of 4, then decided against that, hence the macro). I also added
> a new test case with -fdefault-integer-8.

Thanks, good enough for me.

> OK for trunk?

In iresolve.c your patch adds code like

+  if (back->ts.kind != gfc_logical_4_kind)
+    {
+      gfc_typespec ts;
+      gfc_clear_ts (&ts);
+      ts.type = BT_LOGICAL;
+      ts.kind = gfc_default_logical_kind;
+      gfc_convert_type_warn (back, &ts, 2, 0);
+    }

in two places. Presumably the ts.kind assignment should be
gfc_logical_4_kind, no?

Secondly, since the back argument is always present (you always set it
to .false., as there is no need in the library to distinguish between
a non-present and a .false. argument in this case), I think it would
make more sense to pass it by value than a pointer to it. Sorry for
missing this the first time around.


-- 
Janne Blomqvist



More information about the Gcc-patches mailing list