You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Automerge: [flang][semantic] update semantic checks for ansychronous and volatility attributes to use MayNeedCopy (#159477)
Ties the semantic checks for overwriting a asynchronous or volatile
value with a copy-out operation to the function
`evaluate::MayNeedCopy(..., /*forCopyOut=*/false)`. This should make the
checks more accurate and consistent with the lowering. The PR also adds
a default check that looks for the undesired behavior directly, in case
extension later modify what is possible.
A couple portability warnings are added where other compilers are over
restrictive.
Closesllvm/llvm-project#137369
```
$ build/bin/flang -c ~/work/llvm-test-suite/Fortran/gfortran/regression/volatile8.f90 -pedantic
/home/akuhlenschmi/work/llvm-test-suite/Fortran/gfortran/regression/volatile8.f90:21:16: warning: The array section 'a(1_8:5_8:2_8)' should not be associated with dummy argument 'dummy8=' with VOLATILE attribute, unless the dummy is assumed-shape or assumed-rank [-Wvolatile-or-asynchronous-temporary]
call sub8 (a(1:5:2)) ! { dg-error "Array-section actual argument" }
^^^^^^^^
/home/akuhlenschmi/work/llvm-test-suite/Fortran/gfortran/regression/volatile8.f90:37:16: portability: The actual argument 's9dummy' should not be associated with dummy argument 'dummy9=' with VOLATILE attribute, because a temporary copy is required during the call [-Wportability]
call sub9 (s9dummy) ! { dg-error "Assumed-shape actual argument" }
^^^^^^^
/home/akuhlenschmi/work/llvm-test-suite/Fortran/gfortran/regression/volatile8.f90:55:17: portability: The actual argument 'a' should not be associated with dummy argument 'dummy10=' with VOLATILE attribute, because a temporary copy is required during the call [-Wportability]
call sub10 (a) ! { dg-error "Pointer-array actual argument" }
^
```
"ASYNCHRONOUS or VOLATILE actual argument that is not simply contiguous may not be associated with a contiguous ASYNCHRONOUS or VOLATILE %s"_err_en_US,
786
795
dummyName);
796
+
volatileOrAsyncNeedsTempDiagnosticIssued = true;
787
797
}
788
798
}
789
-
// The vector subscript case is handled by the definability check above.
790
-
// The copy-in/copy-out cases are handled by the previous checks.
791
-
// Nag, GFortran, and NVFortran all error on this case, even though it is
"The actual argument '%s' with %s attribute should not be associated with %s with %s attribute, because a temporary copy is required during the call"_warn_en_US,
Copy file name to clipboardExpand all lines: flang/test/Semantics/call45.f90
+8-3Lines changed: 8 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -7,10 +7,11 @@ program call45
7
7
call sub(v([1,2,2,3,3,3,4,4,4,4]))
8
8
!PORTABILITY: The array section 'v(21_8:30_8:1_8)' should not be associated with dummy argument 'v=' with VOLATILE attribute, unless the dummy is assumed-shape or assumed-rank [-Wportability]
9
9
call sub(v(21:30))
10
-
!PORTABILITY: The array section 'v(21_8:40_8:2_8)' should not be associated with dummy argument 'v=' with VOLATILE attribute, unless the dummy is assumed-shape or assumed-rank [-Wportability]
10
+
!WARNING: The array section 'v(21_8:40_8:2_8)' should not be associated with dummy argument 'v=' with VOLATILE attribute, unless the dummy is assumed-shape or assumed-rank [-Wvolatile-or-asynchronous-temporary]
11
11
call sub(v(21:40:2))
12
12
call sub2(v(21:40:2))
13
13
call sub4(p)
14
+
call sub5(p)
14
15
print*, v
15
16
contains
16
17
subroutinesub(v)
@@ -23,7 +24,7 @@ subroutine sub1(v)
23
24
endsubroutine sub1
24
25
subroutinesub2(v)
25
26
integer:: v(:)
26
-
!TODO: This should either be an portability warning or copy-in-copy-out warning
27
+
!PORTABILITY: The actual argument 'v' should not be associated with dummy argument 'v=' with VOLATILE attribute, because a temporary copy is required during the call [-Wportability]
27
28
call sub(v)
28
29
call sub1(v)
29
30
endsubroutine sub2
@@ -33,9 +34,13 @@ subroutine sub3(v)
33
34
endsubroutine sub3
34
35
subroutinesub4(v)
35
36
integer, pointer:: v(:)
36
-
!TODO: This should either be a portability warning or copy-in-copy-out warning
37
+
!PORTABILITY: The actual argument 'v' should not be associated with dummy argument 'v=' with VOLATILE attribute, because a temporary copy is required during the call [-Wportability]
0 commit comments