Output an error if the right hand value is a zero sized array or
does not have a symbol tree otherwise continue checking.
2020-07-14 Steven G. Kargl <kargl@gcc.gnu.org>
gcc/fortran/
PR fortran/95612
* expr.c (gfc_check_pointer_assigb): Output an error if
rvalue is a zero sized array or output an error if rvalue
doesn't have a symbol tree.
2020-07-14 Mark Eggleston <markeggleston@gcc.gnu.org>
gcc/testsuite/
PR fortran/95612
* gfortran.dg/pr95612.f90: New test.
gfc_symbol *sym;
bool target;
- gcc_assert (rvalue->symtree);
+ if (gfc_is_size_zero_array (rvalue))
+ {
+ gfc_error ("Zero-sized array detected at %L where an entity with "
+ "the TARGET attribute is expected", &rvalue->where);
+ return false;
+ }
+ else if (!rvalue->symtree)
+ {
+ gfc_error ("Pointer assignment target in initialization expression "
+ "does not have the TARGET attribute at %L",
+ &rvalue->where);
+ return false;
+ }
+
sym = rvalue->symtree->n.sym;
if (sym->ts.type == BT_CLASS && sym->attr.class_ok)
--- /dev/null
+! { dg-do compile }
+
+program p
+ integer, pointer :: y(:) => shape(1) ! { dg-error "Zero-sized array detected at .1. where an entity with the TARGET attribute is expected" }
+ integer, pointer :: z(:) => shape([1]) ! { dg-error "Pointer assignment target in initialization expression does not have the TARGET attribute at .1." }
+end
+