"polymorphic [F2008: C4106]", &c->expr->where);
t = false;
}
+
+ /* F2018:C7114 The declared type of an ac-value shall not be abstract. */
+ if (c->expr->ts.type == BT_CLASS
+ && c->expr->ts.u.derived
+ && c->expr->ts.u.derived->attr.abstract
+ && CLASS_DATA (c->expr))
+ {
+ gfc_error ("Array constructor value %qs at %L is of the ABSTRACT "
+ "type %qs", c->expr->symtree->name, &c->expr->where,
+ CLASS_DATA (c->expr)->ts.u.derived->name);
+ t = false;
+ }
+
}
return t;
--- /dev/null
+! { dg-do compile }
+!
+! PR fortran/114308 - reject array constructor value of abstract type
+
+module my_module
+ implicit none
+ private
+
+ type, abstract, public :: a
+ end type
+
+ type, extends(a), public :: b
+ end type
+end
+
+program main
+ use my_module
+ implicit none
+ type(b) :: b_instance
+ class(a), allocatable :: a_array(:)
+ class(b), allocatable :: b_array(:)
+
+ a_array = [b_instance]
+ b_array = [b_instance]
+ a_array = [a_array] ! { dg-error "is of the ABSTRACT type" }
+ a_array = [a_array(1)] ! { dg-error "is of the ABSTRACT type" }
+ a_array = [a_array, b_instance] ! { dg-error "is of the ABSTRACT type" }
+ a_array = [b_instance, a_array] ! { dg-error "is of the ABSTRACT type" }
+ b_array = [b_array, a_array] ! { dg-error "is of the ABSTRACT type" }
+end program