mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 03:16:37 +00:00

f18 current emits an error when an assignment is made to an array section with a vector subscript, and the array is finalized with a non-elemental final subroutine. Some other compilers emit this error because (I think) they want variables to only be finalized in place, not by a subroutine call involving copy-in & copy-out of the finalized elements. Since many other Fortran compilers can handle this case, and there's nothing in the standards to preclude it, let's downgrade this error message to a portability warning. This patch got complicated because the API for the WhyNotDefinable() utility routine was such that it would return a message only in error cases, and there was no provision for returning non-fatal messages. It now returns either nothing, a fatal message, or a non-fatal warning message, and all of its call sites have been modified to cope.
28 lines
709 B
Fortran
28 lines
709 B
Fortran
! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic -Werror
|
|
! PDT sensitivity of FINAL subroutines
|
|
module m
|
|
type :: pdt(k)
|
|
integer, kind :: k
|
|
contains
|
|
final :: finalArr, finalElem
|
|
end type
|
|
contains
|
|
subroutine finalArr(x)
|
|
type(pdt(1)), intent(in out) :: x(:)
|
|
end
|
|
elemental subroutine finalElem(x)
|
|
type(pdt(3)), intent(in out) :: x
|
|
end
|
|
end
|
|
|
|
program test
|
|
use m
|
|
type(pdt(1)) x1(1)
|
|
type(pdt(2)) x2(1)
|
|
type(pdt(3)) x3(1)
|
|
!PORTABILITY: Variable 'x1([INTEGER(8)::1_8])' has a vector subscript and will be finalized by non-elemental subroutine 'finalarr'
|
|
x1([1]) = pdt(1)()
|
|
x2([1]) = pdt(2)() ! ok, doesn't match either
|
|
x3([1]) = pdt(3)() ! ok, calls finalElem
|
|
end
|