[llvm-branch-commits] [flang] [flang][OpenMP] Move check for substring to semantic checks (PR #201384)
Krzysztof Parzyszek via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jun 4 09:47:34 PDT 2026
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/201384
>From 4c502a55db3be6537403737e99990f1f86f2851e Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Sun, 17 May 2026 07:18:36 -0500
Subject: [PATCH 1/2] [flang][OpenMP] Move check for substring to semantic
checks
Move it to CheckVarIsNotPartOfAnotherVar, which is also refactored a bit.
---
flang/include/flang/Semantics/openmp-utils.h | 3 ++
flang/lib/Semantics/check-omp-structure.cpp | 32 +++++++++++--------
flang/lib/Semantics/openmp-utils.cpp | 20 ++++++++++++
flang/lib/Semantics/resolve-directives.cpp | 8 -----
flang/test/Semantics/OpenMP/allocate03.f90 | 4 +--
flang/test/Semantics/OpenMP/allocators02.f90 | 2 +-
.../Semantics/OpenMP/declare-target01.f90 | 32 +++++++++----------
flang/test/Semantics/OpenMP/detach01.f90 | 4 +--
.../test/Semantics/OpenMP/firstprivate02.f90 | 4 +--
flang/test/Semantics/OpenMP/lastprivate03.f90 | 4 +--
.../OpenMP/linear-clause-array-section.f90 | 6 ++--
.../Semantics/OpenMP/parallel-private01.f90 | 2 +-
.../Semantics/OpenMP/parallel-private02.f90 | 2 +-
.../Semantics/OpenMP/parallel-private03.f90 | 2 +-
.../Semantics/OpenMP/parallel-private04.f90 | 2 +-
.../Semantics/OpenMP/parallel-sections01.f90 | 8 ++---
.../Semantics/OpenMP/parallel-shared01.f90 | 2 +-
.../Semantics/OpenMP/parallel-shared02.f90 | 2 +-
.../Semantics/OpenMP/parallel-shared03.f90 | 2 +-
.../Semantics/OpenMP/parallel-shared04.f90 | 2 +-
flang/test/Semantics/OpenMP/resolve01.f90 | 2 +-
.../test/Semantics/OpenMP/threadprivate01.f90 | 8 ++---
22 files changed, 86 insertions(+), 67 deletions(-)
diff --git a/flang/include/flang/Semantics/openmp-utils.h b/flang/include/flang/Semantics/openmp-utils.h
index 0b6bd40ad84c2..de6c4294e957d 100644
--- a/flang/include/flang/Semantics/openmp-utils.h
+++ b/flang/include/flang/Semantics/openmp-utils.h
@@ -109,6 +109,9 @@ bool IsLocatorListItem(
bool IsVariableListItem(
const parser::OmpObject &object, SemanticsContext *semaCtx);
+bool IsSubstring(const parser::OmpObject &object, SemanticsContext *semaCtx);
+bool IsArrayElement(const parser::OmpObject &object, SemanticsContext *semaCtx);
+
const Symbol *GetHostSymbol(const Symbol &sym);
bool IsMapEnteringType(parser::OmpMapType::Value type);
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 94187aff125ee..dfebf398801e7 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -4276,24 +4276,28 @@ void OmpStructureChecker::CheckVarIsNotPartOfAnotherVar(
void OmpStructureChecker::CheckVarIsNotPartOfAnotherVar(
const parser::CharBlock &source, const parser::OmpObject &object,
llvm::StringRef clause) {
- bool report{false};
- if (auto *symbol{GetObjectSymbol(object)}) {
+ if (const Symbol *symbol{GetObjectSymbol(object)}) {
if (IsTypeParamInquiry(*symbol)) {
return;
}
- report = IsStructureComponent(*symbol);
- }
+ llvm::StringRef kind{};
+ if (IsStructureComponent(*symbol)) {
+ kind = "A structure component";
+ } else if (IsSubstring(object, &context_)) {
+ kind = "A substrincg";
+ } else if (IsArrayElement(object, &context_)) {
+ kind = "An array element";
+ }
- if (report || parser::Unwrap<parser::ArrayElement>(object)) {
- if (clause.empty() &&
- llvm::omp::nonPartialVarSet.test(GetContext().directive)) {
- context_.Say(source,
- "A variable that is part of another variable (as an array or structure element) cannot appear on the %s directive"_err_en_US,
- ContextDirectiveAsFortran());
- } else {
- context_.Say(source,
- "A variable that is part of another variable (as an array or structure element) cannot appear in a %s clause"_err_en_US,
- clause.str());
+ if (!kind.empty()) {
+ if (clause.empty() &&
+ llvm::omp::nonPartialVarSet.test(GetContext().directive)) {
+ context_.Say(source, "%s cannot appear on the %s directive"_err_en_US,
+ kind.str(), ContextDirectiveAsFortran());
+ } else {
+ context_.Say(source, "%s cannot appear in a %s clause"_err_en_US,
+ kind.str(), clause.str());
+ }
}
}
}
diff --git a/flang/lib/Semantics/openmp-utils.cpp b/flang/lib/Semantics/openmp-utils.cpp
index d2f26b70c60ae..f1a50d30fd316 100644
--- a/flang/lib/Semantics/openmp-utils.cpp
+++ b/flang/lib/Semantics/openmp-utils.cpp
@@ -258,6 +258,26 @@ bool IsVariableListItem(
return false;
}
+bool IsSubstring(const parser::OmpObject &object, SemanticsContext *semaCtx) {
+ if (auto *desg{parser::Unwrap<parser::Designator>(object)}) {
+ evaluate::ExpressionAnalyzer ea(*semaCtx);
+ auto restorer{ea.GetContextualMessages().DiscardMessages()};
+ if (MaybeExpr expr{ea.Analyze(*desg)}) {
+ return ExtractSubstring(*expr).has_value();
+ }
+ }
+ return false;
+}
+
+bool IsArrayElement(
+ const parser::OmpObject &object, SemanticsContext *semaCtx) {
+ if (auto *sym{GetObjectSymbol(object, /*ultimate=*/true)}) {
+ return !IsTypeParamInquiry(*sym) &&
+ parser::Unwrap<parser::ArrayElement>(object);
+ }
+ return false;
+}
+
const Symbol *GetHostSymbol(const Symbol &sym) {
if (auto *details{sym.detailsIf<HostAssocDetails>()}) {
return &details->symbol();
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 2fa59adf7f3af..8bfb6687ea58f 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -2856,14 +2856,6 @@ void OmpAttributeVisitor::ResolveOmpDesignator(
const auto *name{parser::GetDesignatorNameIfDataRef(designator)};
if (!name) {
- // Array sections to be changed to substrings as needed
- if (AnalyzeExpr(context_, designator)) {
- if (std::holds_alternative<parser::Substring>(designator.u)) {
- context_.Say(designator.source,
- "Substrings are not allowed on OpenMP directives or clauses"_err_en_US);
- }
- }
- // other checks, more TBD
return;
}
diff --git a/flang/test/Semantics/OpenMP/allocate03.f90 b/flang/test/Semantics/OpenMP/allocate03.f90
index 3609f38eb6ee7..f2d48b5e7cbbe 100644
--- a/flang/test/Semantics/OpenMP/allocate03.f90
+++ b/flang/test/Semantics/OpenMP/allocate03.f90
@@ -15,11 +15,11 @@ subroutine allocate()
real, dimension (:,:), allocatable :: darray
integer :: a, b
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the ALLOCATE directive
+ !ERROR: A structure component cannot appear on the ALLOCATE directive
!$omp allocate(my_var%array)
continue
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the ALLOCATE directive
+ !ERROR: A structure component cannot appear on the ALLOCATE directive
!$omp allocate(darray, my_var%array) allocator(omp_default_mem_alloc)
allocate ( darray(a, b) )
diff --git a/flang/test/Semantics/OpenMP/allocators02.f90 b/flang/test/Semantics/OpenMP/allocators02.f90
index 8055d21c68095..ce6315556f493 100644
--- a/flang/test/Semantics/OpenMP/allocators02.f90
+++ b/flang/test/Semantics/OpenMP/allocators02.f90
@@ -15,7 +15,7 @@ subroutine allocate()
type(my_type) :: my_var
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the ALLOCATORS directive
+ !ERROR: A structure component cannot appear on the ALLOCATORS directive
!$omp allocators allocate(my_var%array)
allocate(my_var%array(10))
diff --git a/flang/test/Semantics/OpenMP/declare-target01.f90 b/flang/test/Semantics/OpenMP/declare-target01.f90
index ddd48c5a96820..e1c7cfaf092bb 100644
--- a/flang/test/Semantics/OpenMP/declare-target01.f90
+++ b/flang/test/Semantics/OpenMP/declare-target01.f90
@@ -22,10 +22,10 @@ module declare_target01
!$omp declare target (my_var)
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: A structure component cannot appear on the DECLARE TARGET directive
!$omp declare target (my_var%t_i)
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: A structure component cannot appear on the DECLARE TARGET directive
!$omp declare target (my_var%t_arr)
!ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
@@ -36,10 +36,10 @@ module declare_target01
!$omp declare target (arr)
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: An array element cannot appear on the DECLARE TARGET directive
!$omp declare target (arr(1))
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: An array element cannot appear on the DECLARE TARGET directive
!$omp declare target (arr(1:2))
!ERROR: A type parameter inquiry cannot appear on the DECLARE TARGET directive
@@ -61,18 +61,18 @@ module declare_target01
!$omp declare target enter (my_var) device_type(host)
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: A structure component cannot appear on the DECLARE TARGET directive
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (my_var%t_i)
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: A structure component cannot appear on the DECLARE TARGET directive
!$omp declare target enter (my_var%t_i)
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: A structure component cannot appear on the DECLARE TARGET directive
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (my_var%t_arr)
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: A structure component cannot appear on the DECLARE TARGET directive
!$omp declare target enter (my_var%t_arr)
!ERROR: Type parameter inquiry is not allowed as a list item on TO clause
@@ -99,18 +99,18 @@ module declare_target01
!$omp declare target enter (arr) device_type(nohost)
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: An array element cannot appear on the DECLARE TARGET directive
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (arr(1))
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: An array element cannot appear on the DECLARE TARGET directive
!$omp declare target enter (arr(1))
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: An array element cannot appear on the DECLARE TARGET directive
!WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. [-Wopenmp-usage]
!$omp declare target to (arr(1:2))
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: An array element cannot appear on the DECLARE TARGET directive
!$omp declare target enter (arr(1:2))
!ERROR: Type parameter inquiry is not allowed as a list item on TO clause
@@ -138,10 +138,10 @@ module declare_target01
!$omp declare target link (my_var2) device_type(any)
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: A structure component cannot appear on the DECLARE TARGET directive
!$omp declare target link (my_var2%t_i)
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: A structure component cannot appear on the DECLARE TARGET directive
!$omp declare target link (my_var2%t_arr)
!ERROR: Type parameter inquiry is not allowed as a list item on LINK clause
@@ -152,10 +152,10 @@ module declare_target01
!$omp declare target link (arr2)
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: An array element cannot appear on the DECLARE TARGET directive
!$omp declare target link (arr2(1))
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the DECLARE TARGET directive
+ !ERROR: An array element cannot appear on the DECLARE TARGET directive
!$omp declare target link (arr2(1:2))
!ERROR: Type parameter inquiry is not allowed as a list item on LINK clause
diff --git a/flang/test/Semantics/OpenMP/detach01.f90 b/flang/test/Semantics/OpenMP/detach01.f90
index 7729c85ea1128..f70f139b2de7d 100644
--- a/flang/test/Semantics/OpenMP/detach01.f90
+++ b/flang/test/Semantics/OpenMP/detach01.f90
@@ -46,12 +46,12 @@ program detach01
x = x + 1
!$omp end task
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a DETACH clause
+ !ERROR: An array element cannot appear in a DETACH clause
!$omp task detach(event_02(1))
x = x + 1
!$omp end task
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a DETACH clause
+ !ERROR: A structure component cannot appear in a DETACH clause
!$omp task detach(t_01%event)
x = x + 1
!$omp end task
diff --git a/flang/test/Semantics/OpenMP/firstprivate02.f90 b/flang/test/Semantics/OpenMP/firstprivate02.f90
index eb2597cb1cc40..61033b89f5513 100644
--- a/flang/test/Semantics/OpenMP/firstprivate02.f90
+++ b/flang/test/Semantics/OpenMP/firstprivate02.f90
@@ -8,12 +8,12 @@ subroutine omp_firstprivate(init)
end type my_type
type(my_type) :: my_var
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a FIRSTPRIVATE clause
+ !ERROR: An array element cannot appear in a FIRSTPRIVATE clause
!$omp parallel firstprivate(a(2))
a(2) = init
!$omp end parallel
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a FIRSTPRIVATE clause
+ !ERROR: A structure component cannot appear in a FIRSTPRIVATE clause
!$omp parallel firstprivate(my_var%val)
my_var%val = init
!$omp end parallel
diff --git a/flang/test/Semantics/OpenMP/lastprivate03.f90 b/flang/test/Semantics/OpenMP/lastprivate03.f90
index d7fe0c162f27c..348bcb747b0dd 100644
--- a/flang/test/Semantics/OpenMP/lastprivate03.f90
+++ b/flang/test/Semantics/OpenMP/lastprivate03.f90
@@ -8,14 +8,14 @@ subroutine omp_lastprivate(init)
end type my_type
type(my_type) :: my_var
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a LASTPRIVATE clause
+ !ERROR: An array element cannot appear in a LASTPRIVATE clause
!$omp do lastprivate(a(2))
do i=1, 10
a(2) = init
end do
!$omp end do
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a LASTPRIVATE clause
+ !ERROR: A structure component cannot appear in a LASTPRIVATE clause
!$omp do lastprivate(my_var%val)
do i=1, 10
my_var%val = init
diff --git a/flang/test/Semantics/OpenMP/linear-clause-array-section.f90 b/flang/test/Semantics/OpenMP/linear-clause-array-section.f90
index cdcf9df723334..0749ea44db659 100644
--- a/flang/test/Semantics/OpenMP/linear-clause-array-section.f90
+++ b/flang/test/Semantics/OpenMP/linear-clause-array-section.f90
@@ -8,7 +8,7 @@ subroutine test_array_section_in_linear()
integer, dimension(0:99, -99:10, 200) :: a, b, c
!$omp parallel
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a LINEAR clause
+ !ERROR: An array element cannot appear in a LINEAR clause
!$omp do linear(a(:,1,1))
do i = 0, 99
c(i, 1, 1) = a(i, 1, 1) + b(i, 1, 1)
@@ -23,7 +23,7 @@ subroutine test_array_element_in_linear()
integer :: arr(10)
!$omp parallel
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a LINEAR clause
+ !ERROR: An array element cannot appear in a LINEAR clause
!$omp do linear(arr(1))
do i = 1, 10
arr(i) = i
@@ -41,7 +41,7 @@ subroutine test_structure_component_in_linear()
type(my_type) :: obj
!$omp parallel
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a LINEAR clause
+ !ERROR: A structure component cannot appear in a LINEAR clause
!$omp do linear(obj%field)
do i = 1, 10
end do
diff --git a/flang/test/Semantics/OpenMP/parallel-private01.f90 b/flang/test/Semantics/OpenMP/parallel-private01.f90
index a3d332c95ed25..76bf581b82abf 100644
--- a/flang/test/Semantics/OpenMP/parallel-private01.f90
+++ b/flang/test/Semantics/OpenMP/parallel-private01.f90
@@ -10,7 +10,7 @@ program omp_parallel_private
type(my_type) :: my_var
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a PRIVATE clause
+ !ERROR: A structure component cannot appear in a PRIVATE clause
!$omp parallel private(my_var%array)
do i = 1, 10
c(i) = a(i) + b(i) + k
diff --git a/flang/test/Semantics/OpenMP/parallel-private02.f90 b/flang/test/Semantics/OpenMP/parallel-private02.f90
index 8cb72159d6ab5..655487dc1045d 100644
--- a/flang/test/Semantics/OpenMP/parallel-private02.f90
+++ b/flang/test/Semantics/OpenMP/parallel-private02.f90
@@ -10,7 +10,7 @@ program omp_parallel_private
array(i) = i
end do
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a PRIVATE clause
+ !ERROR: An array element cannot appear in a PRIVATE clause
!$omp parallel private(array(i))
do i = 1, 10
c(i) = a(i) + b(i) + k
diff --git a/flang/test/Semantics/OpenMP/parallel-private03.f90 b/flang/test/Semantics/OpenMP/parallel-private03.f90
index 24a096302e53d..2442281a0e211 100644
--- a/flang/test/Semantics/OpenMP/parallel-private03.f90
+++ b/flang/test/Semantics/OpenMP/parallel-private03.f90
@@ -17,7 +17,7 @@ program omp_parallel_private
arr(i) = 0.0
end do
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a PRIVATE clause
+ !ERROR: An array element cannot appear in a PRIVATE clause
!$omp parallel private(arr(i),intx)
do i = 1, 10
c(i) = a(i) + b(i) + k
diff --git a/flang/test/Semantics/OpenMP/parallel-private04.f90 b/flang/test/Semantics/OpenMP/parallel-private04.f90
index 67a669c9882a5..50e1d267e1ca9 100644
--- a/flang/test/Semantics/OpenMP/parallel-private04.f90
+++ b/flang/test/Semantics/OpenMP/parallel-private04.f90
@@ -17,7 +17,7 @@ program omp_parallel_private
arr(i) = 0.0
end do
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a PRIVATE clause
+ !ERROR: A structure component cannot appear in a PRIVATE clause
!$omp parallel private(arr,intx,my_var%array(1))
do i = 1, 10
c(i) = a(i) + b(i) + k
diff --git a/flang/test/Semantics/OpenMP/parallel-sections01.f90 b/flang/test/Semantics/OpenMP/parallel-sections01.f90
index 19448258af766..0e4facac9831a 100644
--- a/flang/test/Semantics/OpenMP/parallel-sections01.f90
+++ b/flang/test/Semantics/OpenMP/parallel-sections01.f90
@@ -17,10 +17,10 @@ program OmpConstructSections01
do i = 1, 10
array(i) = i
end do
-!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a SHARED clause
+!ERROR: An array element cannot appear in a SHARED clause
!$omp parallel sections shared(array(i))
!$omp end parallel sections
-!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a SHARED clause
+!ERROR: A structure component cannot appear in a SHARED clause
!$omp parallel sections shared(my_var%array)
!$omp end parallel sections
@@ -30,7 +30,7 @@ program OmpConstructSections01
if (NT) 20, 30, 40
!ERROR: invalid branch into an OpenMP structured block
goto 20
-!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a PRIVATE clause
+!ERROR: A structure component cannot appear in a PRIVATE clause
!$omp parallel sections private(my_var%array)
!$omp section
print *, "This is a single statement structured block"
@@ -55,7 +55,7 @@ program OmpConstructSections01
30 print *, "Error in opening file"
!$omp end parallel sections
10 print *, 'Jump from section'
-!ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a PRIVATE clause
+!ERROR: An array element cannot appear in a PRIVATE clause
!$omp parallel sections private(array(i))
!$omp section
40 print *, 'Error in opening file'
diff --git a/flang/test/Semantics/OpenMP/parallel-shared01.f90 b/flang/test/Semantics/OpenMP/parallel-shared01.f90
index 7abfe1f7b1637..253d0723e3e91 100644
--- a/flang/test/Semantics/OpenMP/parallel-shared01.f90
+++ b/flang/test/Semantics/OpenMP/parallel-shared01.f90
@@ -10,7 +10,7 @@ program omp_parallel_shared
type(my_type) :: my_var
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a SHARED clause
+ !ERROR: A structure component cannot appear in a SHARED clause
!$omp parallel shared(my_var%array)
do i = 1, 10
c(i) = a(i) + b(i) + k
diff --git a/flang/test/Semantics/OpenMP/parallel-shared02.f90 b/flang/test/Semantics/OpenMP/parallel-shared02.f90
index f59f5236dfd93..f82cd6e643ad2 100644
--- a/flang/test/Semantics/OpenMP/parallel-shared02.f90
+++ b/flang/test/Semantics/OpenMP/parallel-shared02.f90
@@ -10,7 +10,7 @@ program omp_parallel_shared
array(i) = i
end do
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a SHARED clause
+ !ERROR: An array element cannot appear in a SHARED clause
!$omp parallel shared(array(i))
do i = 1, 10
c(i) = a(i) + b(i) + k
diff --git a/flang/test/Semantics/OpenMP/parallel-shared03.f90 b/flang/test/Semantics/OpenMP/parallel-shared03.f90
index 3d9111c7aaf10..f334a6caabda4 100644
--- a/flang/test/Semantics/OpenMP/parallel-shared03.f90
+++ b/flang/test/Semantics/OpenMP/parallel-shared03.f90
@@ -17,7 +17,7 @@ program omp_parallel_shared
arr(i) = 0.0
end do
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a SHARED clause
+ !ERROR: An array element cannot appear in a SHARED clause
!$omp parallel shared(arr(i),intx)
do i = 1, 10
c(i) = a(i) + b(i) + k
diff --git a/flang/test/Semantics/OpenMP/parallel-shared04.f90 b/flang/test/Semantics/OpenMP/parallel-shared04.f90
index 06b7fcfa01d7a..552b4df928c63 100644
--- a/flang/test/Semantics/OpenMP/parallel-shared04.f90
+++ b/flang/test/Semantics/OpenMP/parallel-shared04.f90
@@ -17,7 +17,7 @@ program omp_parallel_shared
arr(i) = 0.0
end do
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear in a SHARED clause
+ !ERROR: A structure component cannot appear in a SHARED clause
!$omp parallel shared(arr,intx,my_var%array(1))
do i = 1, 10
c(i) = a(i) + b(i) + k
diff --git a/flang/test/Semantics/OpenMP/resolve01.f90 b/flang/test/Semantics/OpenMP/resolve01.f90
index 79b67885b8b9c..95e473d30cd91 100644
--- a/flang/test/Semantics/OpenMP/resolve01.f90
+++ b/flang/test/Semantics/OpenMP/resolve01.f90
@@ -8,7 +8,7 @@
b = "HIFROMPGI"
c = b(2:7)
- !ERROR: Substrings are not allowed on OpenMP directives or clauses
+ !ERROR: A substrincg cannot appear in a PRIVATE clause
!$omp parallel private(c(1:3))
a = c(1:1)
!$omp end parallel
diff --git a/flang/test/Semantics/OpenMP/threadprivate01.f90 b/flang/test/Semantics/OpenMP/threadprivate01.f90
index c2cf9ba99ab04..ebccaaa99d62a 100644
--- a/flang/test/Semantics/OpenMP/threadprivate01.f90
+++ b/flang/test/Semantics/OpenMP/threadprivate01.f90
@@ -22,10 +22,10 @@ module thread_private01
!$omp threadprivate(my_var)
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the THREADPRIVATE directive
+ !ERROR: A structure component cannot appear on the THREADPRIVATE directive
!$omp threadprivate(my_var%t_i)
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the THREADPRIVATE directive
+ !ERROR: A structure component cannot appear on the THREADPRIVATE directive
!$omp threadprivate(my_var%t_arr)
!ERROR: A type parameter inquiry cannot appear on the THREADPRIVATE directive
@@ -36,10 +36,10 @@ module thread_private01
!$omp threadprivate(arr)
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the THREADPRIVATE directive
+ !ERROR: An array element cannot appear on the THREADPRIVATE directive
!$omp threadprivate(arr(1))
- !ERROR: A variable that is part of another variable (as an array or structure element) cannot appear on the THREADPRIVATE directive
+ !ERROR: An array element cannot appear on the THREADPRIVATE directive
!$omp threadprivate(arr(1:2))
!ERROR: A type parameter inquiry cannot appear on the THREADPRIVATE directive
>From 16198c7c076589e54179b5a83067a1289e8776a6 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Thu, 4 Jun 2026 11:47:25 -0500
Subject: [PATCH 2/2] Apply suggestions from code review
Co-authored-by: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
---
flang/lib/Semantics/check-omp-structure.cpp | 2 +-
flang/test/Semantics/OpenMP/resolve01.f90 | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index dfebf398801e7..03f83184aa6ce 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -4284,7 +4284,7 @@ void OmpStructureChecker::CheckVarIsNotPartOfAnotherVar(
if (IsStructureComponent(*symbol)) {
kind = "A structure component";
} else if (IsSubstring(object, &context_)) {
- kind = "A substrincg";
+ kind = "A substring";
} else if (IsArrayElement(object, &context_)) {
kind = "An array element";
}
diff --git a/flang/test/Semantics/OpenMP/resolve01.f90 b/flang/test/Semantics/OpenMP/resolve01.f90
index 95e473d30cd91..fcccb8f6bd577 100644
--- a/flang/test/Semantics/OpenMP/resolve01.f90
+++ b/flang/test/Semantics/OpenMP/resolve01.f90
@@ -8,7 +8,7 @@
b = "HIFROMPGI"
c = b(2:7)
- !ERROR: A substrincg cannot appear in a PRIVATE clause
+ !ERROR: A substring cannot appear in a PRIVATE clause
!$omp parallel private(c(1:3))
a = c(1:1)
!$omp end parallel
More information about the llvm-branch-commits
mailing list