This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] PR fortran/84511 -- Fix C_LOC in a transfer statement
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 22 Feb 2018 12:01:36 -0800
- Subject: [PATCH] PR fortran/84511 -- Fix C_LOC in a transfer statement
- Authentication-results: sourceware.org; auth=none
- Reply-to: sgk at troutmask dot apl dot washington dot edu
All,
The attached patch handles C_LOC in a transfer statement
such as "print *, c_loc(xxx)". The bug report contains
two files that must be compiled separately to exhibit
the bug. I have no idea how to write a testcase for this
situation. If someone can write a testcase, I'm fine
with that. If someone can tell me how to write a testcase,
I'm fine with that, too.
Regression tested on x86_64-*-freebsd. OK to commit?
2018-02-22 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/84511
* trans-io.c (transfer_expr): Deal with C_LOC in transfer statement.
--
Steve
Index: trans-io.c
===================================================================
--- trans-io.c (revision 257695)
+++ trans-io.c (working copy)
@@ -2289,6 +2289,16 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree ad
ts->kind = gfc_index_integer_kind;
}
+ /* gfortran reaches here for "print *, c_loc(xxx)". */
+ if (ts->type == BT_VOID
+ && code->expr1 && code->expr1->ts.type == BT_VOID
+ && code->expr1->symtree
+ && strcmp (code->expr1->symtree->name, "c_loc") == 0)
+ {
+ ts->type = BT_INTEGER;
+ ts->kind = gfc_index_integer_kind;
+ }
+
kind = ts->kind;
function = NULL;
arg2 = NULL;