re PR fortran/88611 (ICE in eliminate_stmt, at tree-ssa-sccvn.c:5011)
authorRichard Biener <rguenther@suse.de>
Tue, 8 Jan 2019 10:46:04 +0000 (10:46 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 8 Jan 2019 10:46:04 +0000 (10:46 +0000)
2019-01-08  Richard Biener  <rguenther@suse.de>

PR fortran/88611
* trans-expr.c (gfc_conv_initializer): For ISOCBINDING_NULL_*
directly build the expected GENERIC tree.

* gfortran.dg/pr88611.f90: New testcase.

From-SVN: r267721

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr88611.f90 [new file with mode: 0644]

index ba95a26e6aef18c9f7420cf0c6bbf9e713c11e5f..73d47da983267a1f95d81cb25242cbb37fc67d0f 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-08  Richard Biener  <rguenther@suse.de>
+
+       PR fortran/88611
+       * trans-expr.c (gfc_conv_initializer): For ISOCBINDING_NULL_*
+       directly build the expected GENERIC tree.
+
 2019-01-07  Thomas Koenig  <tkoenig@gcc.gnu.org>
        Harald Anlauf <anlauf@gmx.de>
        Tobias Burnus <burnus@gcc.gnu.org>
index 27eb2d2ee3800ed6fd47aea59eb4cd8e36eea0f4..c45752e516a14c0cd49fbb90834ec92bd1d3e61f 100644 (file)
@@ -7086,19 +7086,12 @@ gfc_conv_initializer (gfc_expr * expr, gfc_typespec * ts, tree type,
   if (expr != NULL && expr->ts.type == BT_DERIVED
       && expr->ts.is_iso_c && expr->ts.u.derived)
     {
-      gfc_symbol *derived = expr->ts.u.derived;
-
-      /* The derived symbol has already been converted to a (void *).  Use
-        its kind.  */
-      if (derived->ts.kind == 0)
-       derived->ts.kind = gfc_default_integer_kind;
-      expr = gfc_get_int_expr (derived->ts.kind, NULL, 0);
-      expr->ts.f90_type = derived->ts.f90_type;
-
-      gfc_init_se (&se, NULL);
-      gfc_conv_constant (&se, expr);
-      gcc_assert (TREE_CODE (se.expr) != CONSTRUCTOR);
-      return se.expr;
+      if (TREE_CODE (type) == ARRAY_TYPE)
+       return build_constructor (type, NULL);
+      else if (POINTER_TYPE_P (type))
+       return build_int_cst (type, 0);
+      else
+       gcc_unreachable ();
     }
 
   if (array && !procptr)
index 14a59446eb3f2d12c07b32425f07caf03f6fbb91..ff3e09dd9ad7f20527566787e49db24b2073ea04 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-08  Richard Biener  <rguenther@suse.de>
+
+       PR fortran/88611
+       * trans-expr.c (gfc_conv_initializer): For ISOCBINDING_NULL_*
+       directly build the expected GENERIC tree.
+
 2019-01-08  Sam Tebbs  <sam.tebbs@arm.com>
 
        * gcc.target/aarch64/(return_address_sign_1.c,
diff --git a/gcc/testsuite/gfortran.dg/pr88611.f90 b/gcc/testsuite/gfortran.dg/pr88611.f90
new file mode 100644 (file)
index 0000000..9847bc3
--- /dev/null
@@ -0,0 +1,14 @@
+! { dg-do run }
+! { dg-options "-fdefault-integer-8 -fno-tree-forwprop -O3 -fno-tree-ccp" }
+! PR 82869
+! A temp variable of type logical was incorrectly transferred
+! to the I/O library as a logical type of a different kind.
+program pr82869_8
+  use, intrinsic :: iso_c_binding
+  type(c_ptr) :: p = c_null_ptr
+  character(len=4) :: s
+  write (s, *) c_associated(p), c_associated(c_null_ptr)
+  if (s /= ' F F') then
+     STOP 1
+  end if
+end program pr82869_8