Commit 103c4f75 by Janus Weil

re PR fortran/68440 ([OOP] ICE on declaring class variable with wrong attribute)

2016-11-08  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/68440
	* expr.c (check_alloc_comp_init): Loosen an assert.
	* resolve.c (resolve_fl_parameter): Reject class parameters.

2016-11-08  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/68440
	* gfortran.dg/class_58.f90: New test.

From-SVN: r241979
parent fe7913f6
2016-11-08 Janus Weil <janus@gcc.gnu.org> 2016-11-08 Janus Weil <janus@gcc.gnu.org>
PR fortran/68440
* expr.c (check_alloc_comp_init): Loosen an assert.
* resolve.c (resolve_fl_parameter): Reject class parameters.
2016-11-08 Janus Weil <janus@gcc.gnu.org>
PR fortran/77596 PR fortran/77596
* expr.c (gfc_check_pointer_assign): Add special check for procedure- * expr.c (gfc_check_pointer_assign): Add special check for procedure-
pointer component with absent interface. pointer component with absent interface.
......
...@@ -2206,7 +2206,7 @@ check_alloc_comp_init (gfc_expr *e) ...@@ -2206,7 +2206,7 @@ check_alloc_comp_init (gfc_expr *e)
gfc_constructor *ctor; gfc_constructor *ctor;
gcc_assert (e->expr_type == EXPR_STRUCTURE); gcc_assert (e->expr_type == EXPR_STRUCTURE);
gcc_assert (e->ts.type == BT_DERIVED); gcc_assert (e->ts.type == BT_DERIVED || e->ts.type == BT_CLASS);
for (comp = e->ts.u.derived->components, for (comp = e->ts.u.derived->components,
ctor = gfc_constructor_first (e->value.constructor); ctor = gfc_constructor_first (e->value.constructor);
......
...@@ -14001,6 +14001,15 @@ resolve_fl_parameter (gfc_symbol *sym) ...@@ -14001,6 +14001,15 @@ resolve_fl_parameter (gfc_symbol *sym)
&sym->value->where); &sym->value->where);
return false; return false;
} }
/* F03:C509,C514. */
if (sym->ts.type == BT_CLASS)
{
gfc_error ("CLASS variable %qs at %L cannot have the PARAMETER attribute",
sym->name, &sym->declared_at);
return false;
}
return true; return true;
} }
......
2016-11-08 Janus Weil <janus@gcc.gnu.org>
PR fortran/68440
* gfortran.dg/class_58.f90: New test.
2016-11-08 Uros Bizjak <ubizjak@gmail.com> 2016-11-08 Uros Bizjak <ubizjak@gmail.com>
PR target/70799 PR target/70799
......
! { dg-do compile }
!
! PR 68440: [OOP] ICE on declaring class variable with wrong attribute
!
! Contributed by Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de>
subroutine s
type t
end type
class(t), parameter :: x = t() ! { dg-error "cannot have the PARAMETER attribute" }
class(t), parameter :: y = x ! { dg-error "cannot have the PARAMETER attribute" }
class(t) :: z = x ! { dg-error "must be dummy, allocatable or pointer" }
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