Skip to content

Conversation

akuhlens
Copy link
Contributor

@akuhlens akuhlens commented Aug 12, 2025

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.

@akuhlens akuhlens changed the title [flang][semantics][NFC] add test for an already supported semantic check [flang][semantics][NFC] add test for an already supported semantic warning Aug 12, 2025
@akuhlens akuhlens marked this pull request as ready for review August 12, 2025 19:51
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Aug 12, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 12, 2025

@llvm/pr-subscribers-flang-semantics

Author: Andre Kuhlenschmidt (akuhlens)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/153263.diff

1 Files Affected:

  • (added) flang/test/Semantics/call45.f90 (+15)
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

@eugeneepshteyn
Copy link
Contributor

Well, this is no longer [NFC] change and it also needs better PR description :)

@akuhlens akuhlens requested a review from klausler August 14, 2025 16:30
@akuhlens akuhlens changed the title [flang][semantics][NFC] add test for an already supported semantic warning [flang][semantics] add portability warning and tests for copy-in/copy-out case Aug 14, 2025
@@ -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);
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@akuhlens akuhlens force-pushed the andre/volatile-copy-in branch from 47c3f32 to 42bab5b Compare August 27, 2025 15:59
@akuhlens akuhlens merged commit a8680be into llvm:main Aug 27, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants