[Flang][OpenMP]add semantic check for linear clause with statement function variables#199743
Open
blazie2004 wants to merge 1 commit into
Open
[Flang][OpenMP]add semantic check for linear clause with statement function variables#199743blazie2004 wants to merge 1 commit into
blazie2004 wants to merge 1 commit into
Conversation
|
@llvm/pr-subscribers-flang-openmp Author: jay0x (blazie2004) ChangesDescription
Fixes : 199660 Reproducerwhen compiled with : Observed Behavior
Expected Behavior Full diff: https://github.com/llvm/llvm-project/pull/199743.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index b97f7ce58a1c0..fa84c35424108 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1064,7 +1064,8 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
Symbol::Flag::OmpIsDevicePtr, Symbol::Flag::OmpHasDeviceAddr};
Symbol::Flags privateDataSharingAttributeFlags{Symbol::Flag::OmpPrivate,
- Symbol::Flag::OmpFirstPrivate, Symbol::Flag::OmpLastPrivate};
+ Symbol::Flag::OmpFirstPrivate, Symbol::Flag::OmpLastPrivate,
+ Symbol::Flag::OmpLinear};
Symbol::Flags ompFlagsRequireNewSymbol{Symbol::Flag::OmpPrivate,
Symbol::Flag::OmpLinear, Symbol::Flag::OmpFirstPrivate,
@@ -3263,6 +3264,8 @@ void OmpAttributeVisitor::CheckObjectIsPrivatizable(
clauseName = "FIRSTPRIVATE";
} else if (ompFlag == Symbol::Flag::OmpLastPrivate) {
clauseName = "LASTPRIVATE";
+ } else if (ompFlag == Symbol::Flag::OmpLinear) {
+ clauseName = "LINEAR";
}
if (SymbolOrEquivalentIsInNamelist(symbol)) {
diff --git a/flang/test/Semantics/OpenMP/private03.f90 b/flang/test/Semantics/OpenMP/private03.f90
index 61f790fbb38b2..e921d8a58fdba 100644
--- a/flang/test/Semantics/OpenMP/private03.f90
+++ b/flang/test/Semantics/OpenMP/private03.f90
@@ -1,7 +1,7 @@
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
! OpenMP Version 4.5
! Variables that appear in expressions for statement function definitions
-! may not appear in private, firstprivate or lastprivate clauses.
+! may not appear in private, firstprivate, lastprivate or linear clauses.
subroutine stmt_function(temp)
@@ -34,6 +34,14 @@ subroutine stmt_function(temp)
end do
!$omp end parallel do
+ !ERROR: Variable 'p' in statement function expression cannot be in a LINEAR clause
+ !$omp parallel do simd linear(p)
+ do i = 1, 10
+ t(i) = v(temp) + i
+ p = p + 1
+ end do
+ !$omp end parallel do simd
+
print *, t
end subroutine stmt_function
|
|
@llvm/pr-subscribers-flang-semantics Author: jay0x (blazie2004) ChangesDescription
Fixes : 199660 Reproducerwhen compiled with : Observed Behavior
Expected Behavior Full diff: https://github.com/llvm/llvm-project/pull/199743.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index b97f7ce58a1c0..fa84c35424108 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1064,7 +1064,8 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
Symbol::Flag::OmpIsDevicePtr, Symbol::Flag::OmpHasDeviceAddr};
Symbol::Flags privateDataSharingAttributeFlags{Symbol::Flag::OmpPrivate,
- Symbol::Flag::OmpFirstPrivate, Symbol::Flag::OmpLastPrivate};
+ Symbol::Flag::OmpFirstPrivate, Symbol::Flag::OmpLastPrivate,
+ Symbol::Flag::OmpLinear};
Symbol::Flags ompFlagsRequireNewSymbol{Symbol::Flag::OmpPrivate,
Symbol::Flag::OmpLinear, Symbol::Flag::OmpFirstPrivate,
@@ -3263,6 +3264,8 @@ void OmpAttributeVisitor::CheckObjectIsPrivatizable(
clauseName = "FIRSTPRIVATE";
} else if (ompFlag == Symbol::Flag::OmpLastPrivate) {
clauseName = "LASTPRIVATE";
+ } else if (ompFlag == Symbol::Flag::OmpLinear) {
+ clauseName = "LINEAR";
}
if (SymbolOrEquivalentIsInNamelist(symbol)) {
diff --git a/flang/test/Semantics/OpenMP/private03.f90 b/flang/test/Semantics/OpenMP/private03.f90
index 61f790fbb38b2..e921d8a58fdba 100644
--- a/flang/test/Semantics/OpenMP/private03.f90
+++ b/flang/test/Semantics/OpenMP/private03.f90
@@ -1,7 +1,7 @@
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
! OpenMP Version 4.5
! Variables that appear in expressions for statement function definitions
-! may not appear in private, firstprivate or lastprivate clauses.
+! may not appear in private, firstprivate, lastprivate or linear clauses.
subroutine stmt_function(temp)
@@ -34,6 +34,14 @@ subroutine stmt_function(temp)
end do
!$omp end parallel do
+ !ERROR: Variable 'p' in statement function expression cannot be in a LINEAR clause
+ !$omp parallel do simd linear(p)
+ do i = 1, 10
+ t(i) = v(temp) + i
+ p = p + 1
+ end do
+ !$omp end parallel do simd
+
print *, t
end subroutine stmt_function
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes : 199660
Reproducer
when compiled with :
-fopenmp -fopenmp-version=45 -cObserved Behavior
No diagnostic emittedExpected Behavior