Commit 4ceda204 by Janus Weil

re PR fortran/43207 ([OOP] invalid (pointer) assignment to and from abstract…

re PR fortran/43207 ([OOP] invalid (pointer) assignment to and from abstract non-polymorphic expressions)

2016-12-03  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/43207
	* primary.c (gfc_match_varspec): Reject nonpolymorphic references to
	abstract types.

2016-12-03  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/43207
	* gfortran.dg/abstract_type_9.f90: New test case.

From-SVN: r243224
parent 20fee4a9
2016-12-03 Janus Weil <janus@gcc.gnu.org>
PR fortran/43207
* primary.c (gfc_match_varspec): Reject nonpolymorphic references to
abstract types.
2016-12-03 Janus Weil <janus@gcc.gnu.org>
PR fortran/42188
* primary.c (gfc_match_rvalue): Add a new check that gives better error
messages.
......
......@@ -2222,7 +2222,15 @@ check_substring:
}
}
/* F2008, C727. */
/* F08:C611. */
if (primary->ts.type == BT_DERIVED && primary->ref
&& primary->ts.u.derived && primary->ts.u.derived->attr.abstract)
{
gfc_error ("Nonpolymorphic reference to abstract type at %C");
return MATCH_ERROR;
}
/* F08:C727. */
if (primary->expr_type == EXPR_PPC && gfc_is_coindexed (primary))
{
gfc_error ("Coindexed procedure-pointer component at %C");
......
2016-12-03 Janus Weil <janus@gcc.gnu.org>
PR fortran/43207
* gfortran.dg/abstract_type_9.f90: New test case.
2016-12-03 Janus Weil <janus@gcc.gnu.org>
PR fortran/42188
* gfortran.dg/derived_result_2.f90.f90: New test case.
......
! { dg-do compile }
!
! PR 43207: [OOP] invalid (pointer) assignment to and from abstract non-polymorphic expressions
!
! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
implicit none
type, abstract :: parent
integer :: i
end type
type, extends(parent) :: child
class(parent), pointer :: comp
end type
type(child), target :: c1
class(child), allocatable :: c2
class(parent), pointer :: cp
c1%parent = c1%parent ! { dg-error "Nonpolymorphic reference to abstract type" }
c2%parent = c1%parent ! { dg-error "Nonpolymorphic reference to abstract type" }
cp => c1%comp
cp => c1%parent ! { dg-error "Nonpolymorphic reference to abstract type" }
call sub(c1%comp)
call sub(c1%parent) ! { dg-error "Nonpolymorphic reference to abstract type" }
contains
subroutine sub(arg)
class(parent) :: arg
end subroutine
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