re PR fortran/78500 (ICE in gfc_check_vardef_context, at fortran/expr.c:5289)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 24 Nov 2016 18:27:58 +0000 (18:27 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 24 Nov 2016 18:27:58 +0000 (18:27 +0000)
2016-11-24  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/78500
* expr.c (gfc_check_vardef_contextm): Fix NULL pointer dereference.
* interface.c (matching_typebound_op): Ditto.

2016-11-24  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/78500
* gfortran.dg/class_result_4.f90: New test.

From-SVN: r242846

gcc/fortran/ChangeLog
gcc/fortran/expr.c
gcc/fortran/interface.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/class_result_4.f90 [new file with mode: 0644]

index e468a4928814f8b0e77621ac04387c84f308d529..4c27f1b622e61bc8bfe729dffa26253c607b2d03 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-24  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/78500
+       * expr.c (gfc_check_vardef_contextm): Fix NULL pointer dereference.
+       * interface.c (matching_typebound_op): Ditto.
+
 2016-11-23  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/78297
index b028d81ba6d07f37d1398ae32ddbb744c678052e..60f6080877f408f62ab5f3c0f82e1e80e0c908b7 100644 (file)
@@ -5291,7 +5291,8 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj,
      component.  Note that (normal) assignment to procedure pointers is not
      possible.  */
   check_intentin = !own_scope;
-  ptr_component = (sym->ts.type == BT_CLASS && CLASS_DATA (sym))
+  ptr_component = (sym->ts.type == BT_CLASS && sym->ts.u.derived
+                  && CLASS_DATA (sym))
                  ? CLASS_DATA (sym)->attr.class_pointer : sym->attr.pointer;
   for (ref = e->ref; ref && check_intentin; ref = ref->next)
     {
index a0cb0bb9ce300b9fb8e5433bf21da08b2b65895e..4c8d67193ae38c99e44658a394d20f057bc8ec6c 100644 (file)
@@ -3885,7 +3885,7 @@ matching_typebound_op (gfc_expr** tb_base,
 
        if (base->expr->ts.type == BT_CLASS)
          {
-           if (CLASS_DATA (base->expr) == NULL
+           if (!base->expr->ts.u.derived || CLASS_DATA (base->expr) == NULL
                || !gfc_expr_attr (base->expr).class_ok)
              continue;
            derived = CLASS_DATA (base->expr)->ts.u.derived;
index 194e85fd49bb1af7620f1f969870f9b2199b598c..144cd3cbff07d6203d20d9749974fe9d13ccbc97 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-24  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/78500
+       * gfortran.dg/class_result_4.f90: New test.
+
 2016-11-24  James Greenhalgh  <james.greenhalgh@arm.com>
 
        * gcc.target/aarch64/_Float16_1.c: New.
diff --git a/gcc/testsuite/gfortran.dg/class_result_4.f90 b/gcc/testsuite/gfortran.dg/class_result_4.f90
new file mode 100644 (file)
index 0000000..4b22a3c
--- /dev/null
@@ -0,0 +1,6 @@
+! { dg-do compile }
+! PR fortran/78500
+class(t) function f() ! { dg-error "must be dummy, allocatable or pointer" }
+   f = 1              ! { dg-error "variable must not be polymorphic" }
+end
+