Hi Tobias, > This patch fixes a couple of issues, I run into when working on FINAL > subroutines. > > > a) PR54618: > > (i) For a nonallocatable CLASS(...),INTENT(OUT), gfortran is setting the the > _def_init; however, for OPTIONAL this has to be guarded by an is-present > check. > > (ii) For CLASS(...),ALLOCATABLE, INTENT(OUT), gfortran didn't deallocate the > dummy argument - nor did it reset the var->_vtab to the declared type. > > Note: (ii) for polymorphic arrays has still to be implemented, currently, > only scalars are handled. There are also some other issues related to > OPTIONAL with polymorphic arrays. (See PR.) > > b) When working on FINAL, I also run into the problem that attr.alloc_comp > is set, when there is a pointer component, which only in turn has > allocatable components. That lead to an ICE (segfault) with my FINAL patch. > > c) I also include three coverity patches: > (i) resolve.c: "nl->sym" is many times dereferenced (before and after that > check), thus it cannot be NULL. > (ii) simplify.c: There is an "if (extremum == NULL) ... continue;", hence, > one always loops at least once before one reaches that line; but then "last" > gets set. Thus, the code is unreachable. > (iii) trans-array.c: Here, class_expr is NULL_TREE if the condition is > false, but TREE_TYPE(NULL_TREE) won't work. Hence, an assert is better. > > I intent to do two commits: One for (a) and one for the rest. > > Build and regtested on x86-64-linux. > OK for the trunk?
yes, looks good to me. Thanks for the patch! Cheers, Janus