[flang-commits] [flang] Adding warning for Master as it is deprecated in 5.2 (PR #98955)
Anchu Rajendran S via flang-commits
flang-commits at lists.llvm.org
Mon Jul 22 08:06:56 PDT 2024
https://github.com/anchuraj updated https://github.com/llvm/llvm-project/pull/98955
>From 65ab1a08c40a30c42853066ded1618f8c85954be Mon Sep 17 00:00:00 2001
From: Anchu Rajendran <asudhaku at amd.com>
Date: Mon, 15 Jul 2024 15:25:20 -0500
Subject: [PATCH 1/3] Adding warning for Master as it is deprecated in 5.2
---
flang/lib/Semantics/resolve-directives.cpp | 18 +++++++++++++-----
.../Semantics/OpenMP/clause-validity01.f90 | 2 ++
flang/test/Semantics/OpenMP/flush02.f90 | 1 +
flang/test/Semantics/OpenMP/nested-barrier.f90 | 2 ++
flang/test/Semantics/OpenMP/nested-master.f90 | 12 ++++++++++++
flang/test/Semantics/OpenMP/nested-teams.f90 | 1 +
flang/test/Semantics/OpenMP/ordered-simd.f90 | 4 ++++
7 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 16658d50c151c..bb0227e648b2e 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -734,6 +734,8 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
void AddOmpRequiresToScope(Scope &, WithOmpDeclarative::RequiresFlags,
std::optional<common::OmpAtomicDefaultMemOrderType>);
+ void IssueNonConformanceWarning(
+ llvm::omp::Directive D, parser::CharBlock source);
};
template <typename T>
@@ -1524,6 +1526,8 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPBlockConstruct &x) {
// TODO others
break;
}
+ if (beginDir.v == llvm::omp::Directive::OMPD_master)
+ IssueNonConformanceWarning(beginDir.v, beginDir.source);
ClearDataSharingAttributeObjects();
ClearPrivateDataSharingAttributeObjects();
ClearAllocateNames();
@@ -1634,11 +1638,7 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPLoopConstruct &x) {
break;
}
if (beginDir.v == llvm::omp::Directive::OMPD_target_loop)
- if (context_.ShouldWarn(common::UsageWarning::OpenMPUsage)) {
- context_.Say(beginDir.source,
- "Usage of directive %s is non-confirming to OpenMP standard"_warn_en_US,
- llvm::omp::getOpenMPDirectiveName(beginDir.v).str());
- }
+ IssueNonConformanceWarning(beginDir.v, beginDir.source);
ClearDataSharingAttributeObjects();
SetContextAssociatedLoopLevel(GetAssociatedLoopLevelFromClauses(clauseList));
@@ -2758,4 +2758,12 @@ void OmpAttributeVisitor::AddOmpRequiresToScope(Scope &scope,
} while (!scopeIter->IsGlobal());
}
+void OmpAttributeVisitor::IssueNonConformanceWarning(
+ llvm::omp::Directive D, parser::CharBlock source) {
+ if (context_.ShouldWarn(common::UsageWarning::OpenMPUsage)) {
+ context_.Say(source,
+ "Usage of directive %s is non-confirming to OpenMP standard"_warn_en_US,
+ llvm::omp::getOpenMPDirectiveName(D).str());
+ }
+}
} // namespace Fortran::semantics
diff --git a/flang/test/Semantics/OpenMP/clause-validity01.f90 b/flang/test/Semantics/OpenMP/clause-validity01.f90
index 22ac57065ffec..b683112685931 100644
--- a/flang/test/Semantics/OpenMP/clause-validity01.f90
+++ b/flang/test/Semantics/OpenMP/clause-validity01.f90
@@ -469,12 +469,14 @@
! 2.13.1 master
!$omp parallel
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!$omp master
a=3.14
!$omp end master
!$omp end parallel
!$omp parallel
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!ERROR: NUM_THREADS clause is not allowed on the MASTER directive
!$omp master num_threads(4)
a=3.14
diff --git a/flang/test/Semantics/OpenMP/flush02.f90 b/flang/test/Semantics/OpenMP/flush02.f90
index 18a0d0356bbd7..3e4d13212c477 100644
--- a/flang/test/Semantics/OpenMP/flush02.f90
+++ b/flang/test/Semantics/OpenMP/flush02.f90
@@ -80,6 +80,7 @@
!$omp parallel num_threads(4)
array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/)
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!$omp master
!$omp flush (array)
!$omp end master
diff --git a/flang/test/Semantics/OpenMP/nested-barrier.f90 b/flang/test/Semantics/OpenMP/nested-barrier.f90
index cad31d7985607..788c06a86d8e9 100644
--- a/flang/test/Semantics/OpenMP/nested-barrier.f90
+++ b/flang/test/Semantics/OpenMP/nested-barrier.f90
@@ -75,6 +75,7 @@ program omp_nest_barrier
end do
!$omp end critical
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!$omp master
do i = 1, 10
k = k + 1
@@ -107,6 +108,7 @@ program omp_nest_barrier
end do
!$omp end ordered
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!$omp master
do i = 1, 10
!ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
diff --git a/flang/test/Semantics/OpenMP/nested-master.f90 b/flang/test/Semantics/OpenMP/nested-master.f90
index ef7d2cef6f88a..279eab0b9077a 100644
--- a/flang/test/Semantics/OpenMP/nested-master.f90
+++ b/flang/test/Semantics/OpenMP/nested-master.f90
@@ -9,6 +9,7 @@ program omp_nest_master
!$omp do
do i = 1, 10
k = k + 1
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -16,6 +17,7 @@ program omp_nest_master
end do
!$omp sections
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
do i = 1, 10
@@ -25,6 +27,7 @@ program omp_nest_master
!$omp end sections
!$omp single
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
do i = 1, 10
@@ -38,6 +41,7 @@ program omp_nest_master
!$omp task
do i = 1, 10
k = k + 1
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -48,6 +52,7 @@ program omp_nest_master
!$omp taskloop
do i = 1, 10
k = k + 1
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -58,6 +63,7 @@ program omp_nest_master
!$omp target parallel do simd
do i = 1, 10
k = k + 1
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!ERROR: The only OpenMP constructs that can be encountered during execution of a 'SIMD' region are the `ATOMIC` construct, the `LOOP` construct, the `SIMD` construct and the `ORDERED` construct with the `SIMD` clause.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
@@ -69,6 +75,7 @@ program omp_nest_master
!$omp critical
do i = 1, 10
k = k + 1
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!$omp master
j = j -1
!$omp end master
@@ -78,6 +85,7 @@ program omp_nest_master
!$omp ordered
do i = 1, 10
k = k + 1
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!$omp master
j = j -1
!$omp end master
@@ -91,6 +99,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!$omp master
j = j -1
!$omp end master
@@ -107,6 +116,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!$omp master
j = j -1
!$omp end master
@@ -123,6 +133,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -140,6 +151,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
diff --git a/flang/test/Semantics/OpenMP/nested-teams.f90 b/flang/test/Semantics/OpenMP/nested-teams.f90
index 80c59e07fbaa6..9fef6d411ce41 100644
--- a/flang/test/Semantics/OpenMP/nested-teams.f90
+++ b/flang/test/Semantics/OpenMP/nested-teams.f90
@@ -42,6 +42,7 @@ program main
!$omp end teams
end do
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!$omp master
!ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
!$omp teams
diff --git a/flang/test/Semantics/OpenMP/ordered-simd.f90 b/flang/test/Semantics/OpenMP/ordered-simd.f90
index c33ec745f2dda..b0fe9900a1f23 100644
--- a/flang/test/Semantics/OpenMP/ordered-simd.f90
+++ b/flang/test/Semantics/OpenMP/ordered-simd.f90
@@ -95,6 +95,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP CRITICAL
C = C - A * B
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!$OMP MASTER
DO I = 1,N
!ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region.
@@ -107,6 +108,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP ORDERED
C = C - A * B
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!$OMP MASTER
DO I = 1,N
!ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region.
@@ -119,6 +121,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP TASK
C = C - A * B
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$OMP MASTER
DO I = 1,N
@@ -133,6 +136,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP TASKLOOP
DO J= 1,N
C = C - A * B
+ !WARNING: Usage of directive master is non-confirming to OpenMP standard
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$OMP MASTER
DO I = 1,N
>From 05d833bc0e13aac2ec2ef921f30a1e2bd3591758 Mon Sep 17 00:00:00 2001
From: Anchu Rajendran <asudhaku at amd.com>
Date: Tue, 16 Jul 2024 13:13:10 -0500
Subject: [PATCH 2/3] R2: Adding detailed warning message for masked
---
flang/lib/Semantics/resolve-directives.cpp | 16 ++++++++++---
.../Semantics/OpenMP/clause-validity01.f90 | 4 ++--
flang/test/Semantics/OpenMP/flush02.f90 | 2 +-
.../test/Semantics/OpenMP/nested-barrier.f90 | 4 ++--
flang/test/Semantics/OpenMP/nested-master.f90 | 24 +++++++++----------
flang/test/Semantics/OpenMP/nested-teams.f90 | 2 +-
flang/test/Semantics/OpenMP/ordered-simd.f90 | 8 +++----
7 files changed, 35 insertions(+), 25 deletions(-)
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index bb0227e648b2e..573a23524f480 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -2760,10 +2760,20 @@ void OmpAttributeVisitor::AddOmpRequiresToScope(Scope &scope,
void OmpAttributeVisitor::IssueNonConformanceWarning(
llvm::omp::Directive D, parser::CharBlock source) {
+ std::string warnStr = "";
+ std::string dirName = llvm::omp::getOpenMPDirectiveName(D).str();
+ switch (D) {
+ case llvm::omp::OMPD_master:
+ warnStr = "OpenMP directive " + dirName +
+ " has been deprecated, please use masked instead.";
+ break;
+ case llvm::omp::OMPD_target_loop:
+ default:
+ warnStr = "Usage of directive " + dirName +
+ "is non-confirming to OpenMP standard.";
+ }
if (context_.ShouldWarn(common::UsageWarning::OpenMPUsage)) {
- context_.Say(source,
- "Usage of directive %s is non-confirming to OpenMP standard"_warn_en_US,
- llvm::omp::getOpenMPDirectiveName(D).str());
+ context_.Say(source, "%s"_warn_en_US, warnStr);
}
}
} // namespace Fortran::semantics
diff --git a/flang/test/Semantics/OpenMP/clause-validity01.f90 b/flang/test/Semantics/OpenMP/clause-validity01.f90
index b683112685931..be1ecb1e8de9e 100644
--- a/flang/test/Semantics/OpenMP/clause-validity01.f90
+++ b/flang/test/Semantics/OpenMP/clause-validity01.f90
@@ -469,14 +469,14 @@
! 2.13.1 master
!$omp parallel
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!$omp master
a=3.14
!$omp end master
!$omp end parallel
!$omp parallel
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!ERROR: NUM_THREADS clause is not allowed on the MASTER directive
!$omp master num_threads(4)
a=3.14
diff --git a/flang/test/Semantics/OpenMP/flush02.f90 b/flang/test/Semantics/OpenMP/flush02.f90
index 3e4d13212c477..193b57773f9e0 100644
--- a/flang/test/Semantics/OpenMP/flush02.f90
+++ b/flang/test/Semantics/OpenMP/flush02.f90
@@ -80,7 +80,7 @@
!$omp parallel num_threads(4)
array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/)
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!$omp master
!$omp flush (array)
!$omp end master
diff --git a/flang/test/Semantics/OpenMP/nested-barrier.f90 b/flang/test/Semantics/OpenMP/nested-barrier.f90
index 788c06a86d8e9..f72b4b8c51ad3 100644
--- a/flang/test/Semantics/OpenMP/nested-barrier.f90
+++ b/flang/test/Semantics/OpenMP/nested-barrier.f90
@@ -75,7 +75,7 @@ program omp_nest_barrier
end do
!$omp end critical
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!$omp master
do i = 1, 10
k = k + 1
@@ -108,7 +108,7 @@ program omp_nest_barrier
end do
!$omp end ordered
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!$omp master
do i = 1, 10
!ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
diff --git a/flang/test/Semantics/OpenMP/nested-master.f90 b/flang/test/Semantics/OpenMP/nested-master.f90
index 279eab0b9077a..64df1d93f9b77 100644
--- a/flang/test/Semantics/OpenMP/nested-master.f90
+++ b/flang/test/Semantics/OpenMP/nested-master.f90
@@ -9,7 +9,7 @@ program omp_nest_master
!$omp do
do i = 1, 10
k = k + 1
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -17,7 +17,7 @@ program omp_nest_master
end do
!$omp sections
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
do i = 1, 10
@@ -27,7 +27,7 @@ program omp_nest_master
!$omp end sections
!$omp single
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
do i = 1, 10
@@ -41,7 +41,7 @@ program omp_nest_master
!$omp task
do i = 1, 10
k = k + 1
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -52,7 +52,7 @@ program omp_nest_master
!$omp taskloop
do i = 1, 10
k = k + 1
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -63,7 +63,7 @@ program omp_nest_master
!$omp target parallel do simd
do i = 1, 10
k = k + 1
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!ERROR: The only OpenMP constructs that can be encountered during execution of a 'SIMD' region are the `ATOMIC` construct, the `LOOP` construct, the `SIMD` construct and the `ORDERED` construct with the `SIMD` clause.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
@@ -75,7 +75,7 @@ program omp_nest_master
!$omp critical
do i = 1, 10
k = k + 1
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!$omp master
j = j -1
!$omp end master
@@ -85,7 +85,7 @@ program omp_nest_master
!$omp ordered
do i = 1, 10
k = k + 1
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!$omp master
j = j -1
!$omp end master
@@ -99,7 +99,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!$omp master
j = j -1
!$omp end master
@@ -116,7 +116,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!$omp master
j = j -1
!$omp end master
@@ -133,7 +133,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -151,7 +151,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
diff --git a/flang/test/Semantics/OpenMP/nested-teams.f90 b/flang/test/Semantics/OpenMP/nested-teams.f90
index 9fef6d411ce41..ee89c6509702f 100644
--- a/flang/test/Semantics/OpenMP/nested-teams.f90
+++ b/flang/test/Semantics/OpenMP/nested-teams.f90
@@ -42,7 +42,7 @@ program main
!$omp end teams
end do
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!$omp master
!ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
!$omp teams
diff --git a/flang/test/Semantics/OpenMP/ordered-simd.f90 b/flang/test/Semantics/OpenMP/ordered-simd.f90
index b0fe9900a1f23..76689af9da06d 100644
--- a/flang/test/Semantics/OpenMP/ordered-simd.f90
+++ b/flang/test/Semantics/OpenMP/ordered-simd.f90
@@ -95,7 +95,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP CRITICAL
C = C - A * B
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!$OMP MASTER
DO I = 1,N
!ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region.
@@ -108,7 +108,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP ORDERED
C = C - A * B
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!$OMP MASTER
DO I = 1,N
!ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region.
@@ -121,7 +121,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP TASK
C = C - A * B
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$OMP MASTER
DO I = 1,N
@@ -136,7 +136,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP TASKLOOP
DO J= 1,N
C = C - A * B
- !WARNING: Usage of directive master is non-confirming to OpenMP standard
+ !WARNING: OpenMP directive master has been deprecated, please use masked instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$OMP MASTER
DO I = 1,N
>From 635bc4312a05f399c9efedf6ade7f6398c9f8780 Mon Sep 17 00:00:00 2001
From: Anchu Rajendran <asudhaku at amd.com>
Date: Mon, 22 Jul 2024 10:06:35 -0500
Subject: [PATCH 3/3] R3: Changing warning messages
---
flang/lib/Semantics/resolve-directives.cpp | 7 +++---
.../Semantics/OpenMP/clause-validity01.f90 | 4 ++--
flang/test/Semantics/OpenMP/flush02.f90 | 2 +-
.../test/Semantics/OpenMP/nested-barrier.f90 | 4 ++--
flang/test/Semantics/OpenMP/nested-master.f90 | 24 +++++++++----------
flang/test/Semantics/OpenMP/nested-teams.f90 | 2 +-
flang/test/Semantics/OpenMP/ordered-simd.f90 | 8 +++----
7 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 573a23524f480..fb32ce6837fbf 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -2764,13 +2764,12 @@ void OmpAttributeVisitor::IssueNonConformanceWarning(
std::string dirName = llvm::omp::getOpenMPDirectiveName(D).str();
switch (D) {
case llvm::omp::OMPD_master:
- warnStr = "OpenMP directive " + dirName +
- " has been deprecated, please use masked instead.";
+ warnStr = "OpenMP directive '" + dirName +
+ "' has been deprecated, please use 'masked' instead.";
break;
case llvm::omp::OMPD_target_loop:
default:
- warnStr = "Usage of directive " + dirName +
- "is non-confirming to OpenMP standard.";
+ warnStr = "OpenMP directive '" + dirName + "' has been deprecated.";
}
if (context_.ShouldWarn(common::UsageWarning::OpenMPUsage)) {
context_.Say(source, "%s"_warn_en_US, warnStr);
diff --git a/flang/test/Semantics/OpenMP/clause-validity01.f90 b/flang/test/Semantics/OpenMP/clause-validity01.f90
index be1ecb1e8de9e..94132f04e7cf0 100644
--- a/flang/test/Semantics/OpenMP/clause-validity01.f90
+++ b/flang/test/Semantics/OpenMP/clause-validity01.f90
@@ -469,14 +469,14 @@
! 2.13.1 master
!$omp parallel
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!$omp master
a=3.14
!$omp end master
!$omp end parallel
!$omp parallel
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!ERROR: NUM_THREADS clause is not allowed on the MASTER directive
!$omp master num_threads(4)
a=3.14
diff --git a/flang/test/Semantics/OpenMP/flush02.f90 b/flang/test/Semantics/OpenMP/flush02.f90
index 193b57773f9e0..d12c76bad0334 100644
--- a/flang/test/Semantics/OpenMP/flush02.f90
+++ b/flang/test/Semantics/OpenMP/flush02.f90
@@ -80,7 +80,7 @@
!$omp parallel num_threads(4)
array = (/1, 2, 3, 4, 5, 6, 7, 8, 9, 10/)
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!$omp master
!$omp flush (array)
!$omp end master
diff --git a/flang/test/Semantics/OpenMP/nested-barrier.f90 b/flang/test/Semantics/OpenMP/nested-barrier.f90
index f72b4b8c51ad3..aae283229e330 100644
--- a/flang/test/Semantics/OpenMP/nested-barrier.f90
+++ b/flang/test/Semantics/OpenMP/nested-barrier.f90
@@ -75,7 +75,7 @@ program omp_nest_barrier
end do
!$omp end critical
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!$omp master
do i = 1, 10
k = k + 1
@@ -108,7 +108,7 @@ program omp_nest_barrier
end do
!$omp end ordered
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!$omp master
do i = 1, 10
!ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
diff --git a/flang/test/Semantics/OpenMP/nested-master.f90 b/flang/test/Semantics/OpenMP/nested-master.f90
index 64df1d93f9b77..069de67cafae2 100644
--- a/flang/test/Semantics/OpenMP/nested-master.f90
+++ b/flang/test/Semantics/OpenMP/nested-master.f90
@@ -9,7 +9,7 @@ program omp_nest_master
!$omp do
do i = 1, 10
k = k + 1
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -17,7 +17,7 @@ program omp_nest_master
end do
!$omp sections
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
do i = 1, 10
@@ -27,7 +27,7 @@ program omp_nest_master
!$omp end sections
!$omp single
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
do i = 1, 10
@@ -41,7 +41,7 @@ program omp_nest_master
!$omp task
do i = 1, 10
k = k + 1
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -52,7 +52,7 @@ program omp_nest_master
!$omp taskloop
do i = 1, 10
k = k + 1
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -63,7 +63,7 @@ program omp_nest_master
!$omp target parallel do simd
do i = 1, 10
k = k + 1
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!ERROR: The only OpenMP constructs that can be encountered during execution of a 'SIMD' region are the `ATOMIC` construct, the `LOOP` construct, the `SIMD` construct and the `ORDERED` construct with the `SIMD` clause.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
@@ -75,7 +75,7 @@ program omp_nest_master
!$omp critical
do i = 1, 10
k = k + 1
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!$omp master
j = j -1
!$omp end master
@@ -85,7 +85,7 @@ program omp_nest_master
!$omp ordered
do i = 1, 10
k = k + 1
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!$omp master
j = j -1
!$omp end master
@@ -99,7 +99,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!$omp master
j = j -1
!$omp end master
@@ -116,7 +116,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!$omp master
j = j -1
!$omp end master
@@ -133,7 +133,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
@@ -151,7 +151,7 @@ program omp_nest_master
!$omp distribute
do k =1, 10
print *, "hello"
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$omp master
j = j -1
diff --git a/flang/test/Semantics/OpenMP/nested-teams.f90 b/flang/test/Semantics/OpenMP/nested-teams.f90
index ee89c6509702f..f3b96b0ab4390 100644
--- a/flang/test/Semantics/OpenMP/nested-teams.f90
+++ b/flang/test/Semantics/OpenMP/nested-teams.f90
@@ -42,7 +42,7 @@ program main
!$omp end teams
end do
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!$omp master
!ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
!$omp teams
diff --git a/flang/test/Semantics/OpenMP/ordered-simd.f90 b/flang/test/Semantics/OpenMP/ordered-simd.f90
index 76689af9da06d..ed52b75949100 100644
--- a/flang/test/Semantics/OpenMP/ordered-simd.f90
+++ b/flang/test/Semantics/OpenMP/ordered-simd.f90
@@ -95,7 +95,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP CRITICAL
C = C - A * B
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!$OMP MASTER
DO I = 1,N
!ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region.
@@ -108,7 +108,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP ORDERED
C = C - A * B
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!$OMP MASTER
DO I = 1,N
!ERROR: `ORDERED` region may not be closely nested inside of `CRITICAL`, `ORDERED`, explicit `TASK` or `TASKLOOP` region.
@@ -121,7 +121,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP TASK
C = C - A * B
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$OMP MASTER
DO I = 1,N
@@ -136,7 +136,7 @@ SUBROUTINE ORDERED_BAD(N)
!$OMP TASKLOOP
DO J= 1,N
C = C - A * B
- !WARNING: OpenMP directive master has been deprecated, please use masked instead.
+ !WARNING: OpenMP directive 'master' has been deprecated, please use 'masked' instead.
!ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
!$OMP MASTER
DO I = 1,N
More information about the flang-commits
mailing list