Commit 49c4043
committed
[flang] Finalize allocatable components in expression results
An expression result is a "data entity" (F'2023 3.41), and thus
can be "finalizable" (3.71); however, they are not finalized
in general because there is no item in the list of events that trigger
finalization (7.5.6.3p2) that applies, apart from two relevant
exceptions. One of them we handle correctly (allocatable function
results) we handle correctly, the other we do not.
The second exception is the case of allocated allocatables which
may appear as subobjects in an expression result. They are
automatically deallocated (9.7.3.2p9), and deallocation is on that
list of finalization-triggering events (7.5.6.3p2).
So this patch makes sure to finalize any allocatable finalizable
subobject, unless the destruction is part of the left-hand side of
an intrinsic assignment -- in which case it will have already been
finalized (7.5.6.3p1) anyway.
Note: the "stop 171" case in the test
llvm-test-suite/Fortran/gfortran/regression/finalize_38.f90
will now fail, and a companion patch will disable that test when
this patch is merged.1 parent 2775c79 commit 49c4043
File tree
5 files changed
+49
-35
lines changed- flang-rt
- include/flang-rt/runtime
- lib/runtime
- flang/docs
5 files changed
+49
-35
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
301 | | - | |
| 301 | + | |
| 302 | + | |
302 | 303 | | |
303 | 304 | | |
| 305 | + | |
304 | 306 | | |
305 | 307 | | |
306 | 308 | | |
307 | 309 | | |
308 | 310 | | |
309 | 311 | | |
| 312 | + | |
310 | 313 | | |
311 | 314 | | |
312 | 315 | | |
| |||
479 | 482 | | |
480 | 483 | | |
481 | 484 | | |
482 | | - | |
| 485 | + | |
| 486 | + | |
483 | 487 | | |
484 | | - | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
485 | 491 | | |
486 | | - | |
| 492 | + | |
| 493 | + | |
487 | 494 | | |
488 | 495 | | |
489 | 496 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
376 | | - | |
| 376 | + | |
| 377 | + | |
377 | 378 | | |
378 | 379 | | |
379 | 380 | | |
| |||
683 | 684 | | |
684 | 685 | | |
685 | 686 | | |
686 | | - | |
687 | | - | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
688 | 690 | | |
689 | 691 | | |
690 | 692 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
147 | 151 | | |
148 | 152 | | |
149 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
399 | | - | |
400 | | - | |
| 399 | + | |
| 400 | + | |
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
406 | | - | |
| 406 | + | |
| 407 | + | |
407 | 408 | | |
408 | 409 | | |
409 | 410 | | |
410 | 411 | | |
411 | 412 | | |
412 | 413 | | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
417 | 421 | | |
418 | 422 | | |
419 | 423 | | |
| |||
440 | 444 | | |
441 | 445 | | |
442 | 446 | | |
443 | | - | |
444 | | - | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
445 | 454 | | |
446 | 455 | | |
447 | 456 | | |
| |||
465 | 474 | | |
466 | 475 | | |
467 | 476 | | |
468 | | - | |
469 | | - | |
| 477 | + | |
| 478 | + | |
470 | 479 | | |
471 | 480 | | |
472 | 481 | | |
| |||
481 | 490 | | |
482 | 491 | | |
483 | 492 | | |
484 | | - | |
485 | | - | |
| 493 | + | |
| 494 | + | |
486 | 495 | | |
487 | 496 | | |
488 | 497 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
817 | 817 | | |
818 | 818 | | |
819 | 819 | | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
824 | | - | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
834 | 826 | | |
835 | 827 | | |
836 | 828 | | |
| |||
0 commit comments