-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[flang][OpenMP] Detect complex part designators in atomic variables #166612
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
Complex part designators do not have their own symbols. A symbol obtained for the expression `x%re` will be the symbol for `x`, and in this case x is allowed to be allocatable. Fixes #166278.
|
@llvm/pr-subscribers-flang-openmp @llvm/pr-subscribers-flang-semantics Author: Krzysztof Parzyszek (kparzysz) ChangesComplex part designators do not have their own symbols. A symbol obtained for the expression Fixes #166278. Full diff: https://github.com/llvm/llvm-project/pull/166612.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/check-omp-atomic.cpp b/flang/lib/Semantics/check-omp-atomic.cpp
index 2707921ca1dfa..ec03e6fe2d920 100644
--- a/flang/lib/Semantics/check-omp-atomic.cpp
+++ b/flang/lib/Semantics/check-omp-atomic.cpp
@@ -590,9 +590,11 @@ void OmpStructureChecker::CheckAtomicVariable(
CheckAtomicType(syms.back(), source, atom.AsFortran(), checkTypeOnPointer);
- if (IsAllocatable(syms.back()) && !IsArrayElement(atom)) {
- context_.Say(source, "Atomic variable %s cannot be ALLOCATABLE"_err_en_US,
- atom.AsFortran());
+ if (!IsArrayElement(atom) && !ExtractComplexPart(atom)) {
+ if (IsAllocatable(syms.back())) {
+ context_.Say(source, "Atomic variable %s cannot be ALLOCATABLE"_err_en_US,
+ atom.AsFortran());
+ }
}
}
diff --git a/flang/test/Lower/OpenMP/atomic-update-capture-complex-part.f90 b/flang/test/Lower/OpenMP/atomic-update-capture-complex-part.f90
new file mode 100644
index 0000000000000..ee15b8805a69b
--- /dev/null
+++ b/flang/test/Lower/OpenMP/atomic-update-capture-complex-part.f90
@@ -0,0 +1,17 @@
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=60 %s -o - | FileCheck %s
+
+! Check that this compiles successfully.
+
+!CHECK: omp.atomic.capture
+!CHECK: omp.atomic.read
+!CHECK: omp.atomic.update
+subroutine f00
+ implicit none
+ real :: c
+ complex, allocatable :: x
+ !$omp atomic update capture
+ c = x%re
+ x%re = x%re + 1.0
+ !$omp end atomic
+end
+
|
|
@llvm/pr-subscribers-flang-fir-hlfir Author: Krzysztof Parzyszek (kparzysz) ChangesComplex part designators do not have their own symbols. A symbol obtained for the expression Fixes #166278. Full diff: https://github.com/llvm/llvm-project/pull/166612.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/check-omp-atomic.cpp b/flang/lib/Semantics/check-omp-atomic.cpp
index 2707921ca1dfa..ec03e6fe2d920 100644
--- a/flang/lib/Semantics/check-omp-atomic.cpp
+++ b/flang/lib/Semantics/check-omp-atomic.cpp
@@ -590,9 +590,11 @@ void OmpStructureChecker::CheckAtomicVariable(
CheckAtomicType(syms.back(), source, atom.AsFortran(), checkTypeOnPointer);
- if (IsAllocatable(syms.back()) && !IsArrayElement(atom)) {
- context_.Say(source, "Atomic variable %s cannot be ALLOCATABLE"_err_en_US,
- atom.AsFortran());
+ if (!IsArrayElement(atom) && !ExtractComplexPart(atom)) {
+ if (IsAllocatable(syms.back())) {
+ context_.Say(source, "Atomic variable %s cannot be ALLOCATABLE"_err_en_US,
+ atom.AsFortran());
+ }
}
}
diff --git a/flang/test/Lower/OpenMP/atomic-update-capture-complex-part.f90 b/flang/test/Lower/OpenMP/atomic-update-capture-complex-part.f90
new file mode 100644
index 0000000000000..ee15b8805a69b
--- /dev/null
+++ b/flang/test/Lower/OpenMP/atomic-update-capture-complex-part.f90
@@ -0,0 +1,17 @@
+!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=60 %s -o - | FileCheck %s
+
+! Check that this compiles successfully.
+
+!CHECK: omp.atomic.capture
+!CHECK: omp.atomic.read
+!CHECK: omp.atomic.update
+subroutine f00
+ implicit none
+ real :: c
+ complex, allocatable :: x
+ !$omp atomic update capture
+ c = x%re
+ x%re = x%re + 1.0
+ !$omp end atomic
+end
+
|
tblah
left a comment
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.
Thanks!
Complex part designators do not have their own symbols. A symbol obtained for the expression
x%rewill be the symbol forx, and in this case x is allowed to be allocatable.Fixes #166278.