re PR fortran/84511 (Internal compiler error from directly printing return of C_LOC)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 23 Feb 2018 18:59:38 +0000 (18:59 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 23 Feb 2018 18:59:38 +0000 (18:59 +0000)
2018-02-23  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/84511
* trans-io.c (transfer_expr): Deal with C_LOC in transfer statement.

From-SVN: r257943

gcc/fortran/ChangeLog
gcc/fortran/trans-io.c

index da2c445ec15d8070ce5b3453a827d767bd686dc9..fa1a00b70501db9ee325b6b1b7607f0c566474c3 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-23  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/84511
+       * trans-io.c (transfer_expr): Deal with C_LOC in transfer statement.
+
 2018-02-23  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/84346
index 36adb0344756b3acac1af0c6e5210674db56a045..9058712c69558da71f2aa3925097101bf1c4ff67 100644 (file)
@@ -2289,6 +2289,16 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr,
       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;