Permalink
Browse files

Fix issue with type-bound function with pointer return value

newargs_for_entry() generates descriptor arguments for
subprograms. Re-use (or preserve) a previously created
descriptor for a function result. That's because the
function could be used with a type bound procedure
where the compiler relies on the previously created
descriptor to get the order of the passed object's
type descriptor correct. Otherwise, the function
result will probably not have a previously created
descriptor. Code existed that covered this case
for derived type results but not simple variable
results. To fully cover this case, add a call to
needs_descriptor() as part of the check in the call
to set_preserve_descriptor().
  • Loading branch information...
gklimowicz committed Dec 18, 2018
1 parent 72e5222 commit 76894366d6435780a7d1a1ae76382bb40c651ded
Showing with 2 additions and 6 deletions.
  1. +2 −6 tools/flang1/flang1exe/dpm_out.c
@@ -2625,14 +2625,10 @@ newargs_for_entry(int this_entry)
} else {
newdsc = NEWDSCG(arg);
if (newdsc == 0) {
/* Subtlety: The commented-out ALLOCDESCG(arg) test is what
* seems to break pointer-valued functions in Whizard 2.3.1,
* since their results (which are converted into new first
* arguments) don't have the mystery ALLOCDESC flag set on them.
*/
set_preserve_descriptor(CLASSG(arg) || is_procedure_ptr(arg) ||
(sem.which_pass && IS_PROC_DUMMYG(arg)) ||
(ALLOCDESCG(arg) && RESULTG(arg)));
((ALLOCDESCG(arg) || needs_descriptor(arg)) &&
RESULTG(arg)));

newdsc = sym_get_arg_sec(arg);
set_preserve_descriptor(0);

0 comments on commit 7689436

Please sign in to comment.