From 8399a0cc2d64b1480c8dcc82af710c21ad1678b3 Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Fri, 18 Jun 2010 00:15:30 +0200 Subject: [PATCH] re PR fortran/44558 ([OOP] ICE on invalid code: called TBP subroutine as TBP function) 2010-06-17 Janus Weil PR fortran/44558 * resolve.c (resolve_typebound_function,resolve_typebound_subroutine): Return directly in case of an error. 2010-06-17 Janus Weil PR fortran/44558 * gfortran.dg/typebound_call_15.f03: New. From-SVN: r160948 --- gcc/fortran/ChangeLog | 6 +++++ gcc/fortran/resolve.c | 6 +++-- gcc/testsuite/ChangeLog | 5 ++++ .../gfortran.dg/typebound_call_15.f03 | 25 +++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/typebound_call_15.f03 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index a3b35270ba4..11bda1fc4b9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2010-06-17 Janus Weil + + PR fortran/44558 + * resolve.c (resolve_typebound_function,resolve_typebound_subroutine): + Return directly in case of an error. + 2010-06-16 Janus Weil PR fortran/44549 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 7e6b75aebe1..52920f4e6cc 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -5498,7 +5498,8 @@ resolve_typebound_function (gfc_expr* e) /* Treat the call as if it is a typebound procedure, in order to roll out the correct name for the specific function. */ - resolve_compcall (e, &name); + if (resolve_compcall (e, &name) == FAILURE) + return FAILURE; ts = e->ts; /* Then convert the expression to a procedure pointer component call. */ @@ -5571,7 +5572,8 @@ resolve_typebound_subroutine (gfc_code *code) if (code->expr1->value.compcall.tbp->is_generic) genname = code->expr1->value.compcall.name; - resolve_typebound_call (code, &name); + if (resolve_typebound_call (code, &name) == FAILURE) + return FAILURE; ts = code->expr1->ts; /* Then convert the expression to a procedure pointer component call. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 65fbf68bfa9..7676e43a9f5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-06-17 Janus Weil + + PR fortran/44558 + * gfortran.dg/typebound_call_15.f03: New. + 2010-06-17 Manuel López-Ibáñez PR c++/44486 diff --git a/gcc/testsuite/gfortran.dg/typebound_call_15.f03 b/gcc/testsuite/gfortran.dg/typebound_call_15.f03 new file mode 100644 index 00000000000..ac6a668cc46 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/typebound_call_15.f03 @@ -0,0 +1,25 @@ +! { dg-do compile } +! +! PR 44558: [OOP] ICE on invalid code: called TBP subroutine as TBP function +! +! Contributed by Hans-Werner Boschmann + +module ice5 + type::a_type + contains + procedure::a_subroutine_1 + procedure::a_subroutine_2 + end type a_type +contains + real function a_subroutine_1(this) + class(a_type)::this + real::res + res=this%a_subroutine_2() ! { dg-error "should be a FUNCTION" } + end function + subroutine a_subroutine_2(this) + class(a_type)::this + call this%a_subroutine_1() ! { dg-error "should be a SUBROUTINE" } + end subroutine +end module ice5 + +! { dg-final { cleanup-modules "ice5" } } -- 2.30.2