Skip to content

Commit 7689436

Browse files
committed
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().
1 parent 72e5222 commit 7689436

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

tools/flang1/flang1exe/dpm_out.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,14 +2625,10 @@ newargs_for_entry(int this_entry)
26252625
} else {
26262626
newdsc = NEWDSCG(arg);
26272627
if (newdsc == 0) {
2628-
/* Subtlety: The commented-out ALLOCDESCG(arg) test is what
2629-
* seems to break pointer-valued functions in Whizard 2.3.1,
2630-
* since their results (which are converted into new first
2631-
* arguments) don't have the mystery ALLOCDESC flag set on them.
2632-
*/
26332628
set_preserve_descriptor(CLASSG(arg) || is_procedure_ptr(arg) ||
26342629
(sem.which_pass && IS_PROC_DUMMYG(arg)) ||
2635-
(ALLOCDESCG(arg) && RESULTG(arg)));
2630+
((ALLOCDESCG(arg) || needs_descriptor(arg)) &&
2631+
RESULTG(arg)));
26362632

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

0 commit comments

Comments
 (0)