Skip to content

Commit

Permalink
Fix issue with type-bound function with pointer return value
Browse files Browse the repository at this point in the history
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 7689436
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions tools/flang1/flang1exe/dpm_out.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7689436

Please sign in to comment.