Skip to content

Commit 16c143d

Browse files
committed
Review comments
1 parent 489ace6 commit 16c143d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6530,15 +6530,18 @@ void OmpStructureChecker::CheckArraySection(
65306530
// not arrays.
65316531
bool isSubstring{false};
65326532
evaluate::ExpressionAnalyzer ea{context_};
6533-
MaybeExpr expr = ea.Analyze(arrayElement.base);
6534-
if (expr) {
6533+
if (MaybeExpr expr = ea.Analyze(arrayElement.base)) {
65356534
std::optional<evaluate::Shape> shape = evaluate::GetShape(expr);
65366535
// Not an array: rank 0
65376536
if (shape && shape->size() == 0) {
6538-
std::optional<evaluate::DynamicType> type = expr->GetType();
6539-
if (type) {
6537+
if (std::optional<evaluate::DynamicType> type = expr->GetType()) {
65406538
if (type->category() == evaluate::TypeCategory::Character) {
6539+
// Substrings are explicitly denied by the standard [6.0:163:9-11].
6540+
// This is supported as an extension. This restriction was added in
6541+
// OpenMP 5.2.
65416542
isSubstring = true;
6543+
context_.Say(GetContext().clauseSource,
6544+
"The use of substrings in OpenMP argument lists has been disallowed since OpenMP 5.2."_port_en_US);
65426545
} else {
65436546
llvm_unreachable("Array indexing on a variable that isn't an array");
65446547
}

flang/test/Semantics/OpenMP/depend-substring.f90

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,31 @@
44
! This is okay: selects the whole substring
55
subroutine substring_0(c)
66
character(:), pointer :: c
7+
!PORTABILITY: The use of substrings in OpenMP argument lists has been disallowed since OpenMP 5.2.
78
!$omp task depend(out:c(:))
89
!$omp end task
910
end
1011

1112
! This is okay: selects from the second character onwards
1213
subroutine substring_1(c)
1314
character(:), pointer :: c
15+
!PORTABILITY: The use of substrings in OpenMP argument lists has been disallowed since OpenMP 5.2.
1416
!$omp task depend(out:c(2:))
1517
!$omp end task
1618
end
1719

1820
! This is okay: selects the first 2 characters
1921
subroutine substring_2(c)
2022
character(:), pointer :: c
23+
!PORTABILITY: The use of substrings in OpenMP argument lists has been disallowed since OpenMP 5.2.
2124
!$omp task depend(out:c(:2))
2225
!$omp end task
2326
end
2427

2528
! Error
2629
subroutine substring_3(c)
2730
character(:), pointer :: c
31+
!PORTABILITY: The use of substrings in OpenMP argument lists has been disallowed since OpenMP 5.2.
2832
!ERROR: Substrings must be in the form parent-string(lb:ub)
2933
!$omp task depend(out:c(2))
3034
!$omp end task
@@ -47,7 +51,8 @@ subroutine substring_4(c)
4751
! This is not okay: substrings can't have a stride
4852
subroutine substring_5(c)
4953
character(:), pointer :: c
50-
! ERROR: Cannot specify a step for a substring
54+
!PORTABILITY: The use of substrings in OpenMP argument lists has been disallowed since OpenMP 5.2.
55+
!ERROR: Cannot specify a step for a substring
5156
!$omp task depend(out:c(1:20:5))
5257
!$omp end task
5358
end

0 commit comments

Comments
 (0)