-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[flang][semantics] add portability warning and tests for copy-in/copy-out case #153263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-flang-semantics Author: Andre Kuhlenschmidt (akuhlens) ChangesFull diff: https://github.com/llvm/llvm-project/pull/153263.diff 1 Files Affected:
diff --git a/flang/test/Semantics/call45.f90 b/flang/test/Semantics/call45.f90
new file mode 100644
index 0000000000000..aca0767e0ead2
--- /dev/null
+++ b/flang/test/Semantics/call45.f90
@@ -0,0 +1,15 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic -Werror
+program call45
+ integer :: v(100) = [(i, i=1, 100)]
+ !ERROR: Actual argument associated with VOLATILE dummy argument 'v=' is not definable [-Wundefinable-asynchronous-or-volatile-actual]
+ !BECAUSE: Variable 'v([INTEGER(8)::1_8,2_8,2_8,3_8,3_8,3_8,4_8,4_8,4_8,4_8])' has a vector subscript
+ call sub(v([1,2,2,3,3,3,4,4,4,4]))
+ !OK: Some compilers don't allow this, but there doesn't seem to be a good reason to disallow it.
+ call sub(v(21:30))
+ print *, v
+contains
+ subroutine sub(v)
+ integer, volatile :: v(10)
+ v = 0
+ end subroutine sub
+end program call45
|
Well, this is no longer |
@@ -1203,6 +1203,10 @@ bool HasVectorSubscript(const Expr<SomeType> &expr) { | |||
return HasVectorSubscriptHelper{}(expr); | |||
} | |||
|
|||
bool IsArraySection(const Expr<SomeType> &expr) { | |||
return expr.Rank() > 0 && IsVariable(expr) && !UnwrapWholeSymbolDataRef(expr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this predicate would be true if the expr were a whole symbol data ref to a non-CONTIGUOUS
assumed-shape dummy array or non-CONTIGUOUS
pointer, and while those are not "sections" strictly speaking, they are going to get copied in/out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a suggestion to change the name or use something like looking for a triplet instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither. You want to emit a warning when a volatile actual argument is going to be passed via a temporary buffer, yes? Then the case I mentioned will be a false negative, I think.
47c3f32
to
42bab5b
Compare
This PR adds some tests and a portability warning around volatility/async, copy-in/copy-out, and definability. It was a NFC until we decided to add the portability warning.