Commit 7e703f01 by Thomas Koenig

re PR fortran/88008 (ICE in check_typebound_baseobject, at fortran/resolve.c:6058)

2019-03-17  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/88008
	* gfortran.h (expr_t): Add EXPR_UNKNOWN.
	* expr.c (gfc_copy_expr): Add EXPR_UNKNOWN to switch statement.
	(gfc_simplify_expr): Likewise.
	* module.c (mio_expr): Likewise.
	* resovle.c (extract_compcall_passed_object): Issue error on
	unknown type.
	(check_typebound_baseobject): Issue error on wrong type.
	* trans-expr.c (gfc_apply_interface_mapping_to_expr): Add
	EXPR_UNKNOWN to switch statement.

2019-03-17  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/88008
	 * gfortran.dg/typebound_call_31.f90: New test.

From-SVN: r269750
parent af52cce0
2019-03-17 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/88008
* gfortran.h (expr_t): Add EXPR_UNKNOWN.
* expr.c (gfc_copy_expr): Add EXPR_UNKNOWN to switch statement.
(gfc_simplify_expr): Likewise.
* module.c (mio_expr): Likewise.
* resovle.c (extract_compcall_passed_object): Issue error on
unknown type.
(check_typebound_baseobject): Issue error on wrong type.
* trans-expr.c (gfc_apply_interface_mapping_to_expr): Add
EXPR_UNKNOWN to switch statement.
2019-03-16 Jakub Jelinek <jakub@redhat.com> 2019-03-16 Jakub Jelinek <jakub@redhat.com>
PR fortran/89724 PR fortran/89724
......
...@@ -390,6 +390,9 @@ gfc_copy_expr (gfc_expr *p) ...@@ -390,6 +390,9 @@ gfc_copy_expr (gfc_expr *p)
case EXPR_VARIABLE: case EXPR_VARIABLE:
case EXPR_NULL: case EXPR_NULL:
break; break;
case EXPR_UNKNOWN:
gcc_unreachable ();
} }
q->shape = gfc_copy_shape (p->shape, p->rank); q->shape = gfc_copy_shape (p->shape, p->rank);
...@@ -2206,6 +2209,9 @@ gfc_simplify_expr (gfc_expr *p, int type) ...@@ -2206,6 +2209,9 @@ gfc_simplify_expr (gfc_expr *p, int type)
case EXPR_COMPCALL: case EXPR_COMPCALL:
case EXPR_PPC: case EXPR_PPC:
break; break;
case EXPR_UNKNOWN:
gcc_unreachable ();
} }
return true; return true;
......
...@@ -142,7 +142,7 @@ enum gfc_source_form ...@@ -142,7 +142,7 @@ enum gfc_source_form
/* Expression node types. */ /* Expression node types. */
enum expr_t enum expr_t
{ EXPR_OP = 1, EXPR_FUNCTION, EXPR_CONSTANT, EXPR_VARIABLE, { EXPR_UNKNOWN = 0, EXPR_OP = 1, EXPR_FUNCTION, EXPR_CONSTANT, EXPR_VARIABLE,
EXPR_SUBSTRING, EXPR_STRUCTURE, EXPR_ARRAY, EXPR_NULL, EXPR_COMPCALL, EXPR_PPC EXPR_SUBSTRING, EXPR_STRUCTURE, EXPR_ARRAY, EXPR_NULL, EXPR_COMPCALL, EXPR_PPC
}; };
......
...@@ -3694,6 +3694,7 @@ mio_expr (gfc_expr **ep) ...@@ -3694,6 +3694,7 @@ mio_expr (gfc_expr **ep)
case EXPR_COMPCALL: case EXPR_COMPCALL:
case EXPR_PPC: case EXPR_PPC:
case EXPR_UNKNOWN:
gcc_unreachable (); gcc_unreachable ();
break; break;
} }
......
...@@ -5945,6 +5945,13 @@ extract_compcall_passed_object (gfc_expr* e) ...@@ -5945,6 +5945,13 @@ extract_compcall_passed_object (gfc_expr* e)
{ {
gfc_expr* po; gfc_expr* po;
if (e->expr_type == EXPR_UNKNOWN)
{
gfc_error ("Error in typebound call at %L",
&e->where);
return NULL;
}
gcc_assert (e->expr_type == EXPR_COMPCALL); gcc_assert (e->expr_type == EXPR_COMPCALL);
if (e->value.compcall.base_object) if (e->value.compcall.base_object)
...@@ -6090,7 +6097,11 @@ check_typebound_baseobject (gfc_expr* e) ...@@ -6090,7 +6097,11 @@ check_typebound_baseobject (gfc_expr* e)
if (!base) if (!base)
return false; return false;
gcc_assert (base->ts.type == BT_DERIVED || base->ts.type == BT_CLASS); if (base->ts.type != BT_DERIVED && base->ts.type != BT_CLASS)
{
gfc_error ("Error in typebound call at %L", &e->where);
goto cleanup;
}
if (base->ts.type == BT_CLASS && !gfc_expr_attr (base).class_ok) if (base->ts.type == BT_CLASS && !gfc_expr_attr (base).class_ok)
return false; return false;
......
...@@ -4536,6 +4536,7 @@ gfc_apply_interface_mapping_to_expr (gfc_interface_mapping * mapping, ...@@ -4536,6 +4536,7 @@ gfc_apply_interface_mapping_to_expr (gfc_interface_mapping * mapping,
case EXPR_COMPCALL: case EXPR_COMPCALL:
case EXPR_PPC: case EXPR_PPC:
case EXPR_UNKNOWN:
gcc_unreachable (); gcc_unreachable ();
break; break;
} }
......
2019-03-17 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/88008
* gfortran.dg/typebound_call_31.f90: New test.
2019-03-03-17 John David Anglin <danglin@gcc.gnu.org> 2019-03-03-17 John David Anglin <danglin@gcc.gnu.org>
* gcc.dg/compat/pr83487-1_x.c: Use -fno-common option on hppa*-*-hpux*. * gcc.dg/compat/pr83487-1_x.c: Use -fno-common option on hppa*-*-hpux*.
......
! { dg-do compile }
! PR 88008 - this use to ICE. Original test case by
! Gerhard Steinmetz.
module m
type t
integer, pointer :: z
contains
procedure :: g
end type
contains
subroutine g(x)
class(t) :: x
call x%z%g() ! { dg-error "Error in typebound call" }
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment