2018-02-23  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/83148
	* trans-const.c : Clean up some whitespace issues.
	* trans-expr.c (gfc_conv_initializer): If an iso_c_binding
	derived type has a kind value of zero, set it to the default
	integer kind.

2018-02-23  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/83148
	* gfortran.dg/class_68.f90: New test.



git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257930 138bc75d-0d04-0410-961f-82ee72b054a4
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 3b56c37..c26c67f 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,11 @@
+2018-02-23  Paul Thomas  <pault@gcc.gnu.org>
+
+	PR fortran/83148
+	* trans-const.c : Clean up some whitespace issues.
+	* trans-expr.c (gfc_conv_initializer): If an iso_c_binding
+	derived type has a kind value of zero, set it to the default
+	integer kind.
+
 2018-02-23  Janne Blomqvist  <jb@gcc.gnu.org>
 
 	PR fortran/84519
diff --git a/gcc/fortran/trans-const.c b/gcc/fortran/trans-const.c
index 07950dc..6b4e0de43 100644
--- a/gcc/fortran/trans-const.c
+++ b/gcc/fortran/trans-const.c
@@ -133,7 +133,7 @@
 
 
 /* Return a string constant with the given length.  Used for static
-   initializers.  The constant will be padded or truncated to match 
+   initializers.  The constant will be padded or truncated to match
    length.  */
 
 tree
@@ -303,7 +303,7 @@
 
   /* If it is has a prescribed memory representation, we build a string
      constant and VIEW_CONVERT to its type.  */
- 
+
   switch (expr->ts.type)
     {
     case BT_INTEGER:
@@ -389,12 +389,12 @@
   if (expr->ts.type == BT_DERIVED && expr->ts.u.derived
       && expr->ts.u.derived->attr.is_iso_c)
     {
-      if (expr->symtree->n.sym->intmod_sym_id == ISOCBINDING_NULL_PTR 
-          || expr->symtree->n.sym->intmod_sym_id == ISOCBINDING_NULL_FUNPTR)
-        {
-          /* Create a new EXPR_CONSTANT expression for our local uses.  */
-          expr = gfc_get_int_expr (gfc_default_integer_kind, NULL, 0);
-        }
+      if (expr->symtree->n.sym->intmod_sym_id == ISOCBINDING_NULL_PTR
+	  || expr->symtree->n.sym->intmod_sym_id == ISOCBINDING_NULL_FUNPTR)
+	{
+	  /* Create a new EXPR_CONSTANT expression for our local uses.  */
+	  expr = gfc_get_int_expr (gfc_default_integer_kind, NULL, 0);
+	}
     }
 
   if (expr->expr_type != EXPR_CONSTANT)
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 04e06ef..a93257c 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -6868,6 +6868,8 @@
 
       /* 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;
 
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 62b65bf..fca98dd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-23  Paul Thomas  <pault@gcc.gnu.org>
+
+	PR fortran/83148
+	* gfortran.dg/class_68.f90: New test.
+
 2018-02-22  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
 	PR fortran/59781
diff --git a/gcc/testsuite/gfortran.dg/class_68.f90 b/gcc/testsuite/gfortran.dg/class_68.f90
new file mode 100644
index 0000000..fce30ea
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/class_68.f90
@@ -0,0 +1,25 @@
+! { dg-do compile }
+!
+! Test the fix for PR83148.
+!
+! Contributed by Neil Carlson  <neil.n.carlson@gmail.com>
+!
+module fhypre
+  use iso_c_binding, only: c_ptr, c_null_ptr
+  use iso_c_binding, only: hypre_obj => c_ptr, hypre_null_obj => c_null_ptr
+  private
+  public :: hypre_obj, hypre_null_obj
+end module
+
+module hypre_hybrid_type
+  use fhypre
+  type hypre_hybrid
+    type(hypre_obj) :: solver = hypre_null_obj
+  end type hypre_hybrid
+end module
+
+  use hypre_hybrid_type
+  class(hypre_hybrid), allocatable :: x
+  allocate (x)
+end
+