Skip to content

Commit 39598ff

Browse files
committed
add testcases, don't consider type param inquiry as subobject
1 parent 7ff4152 commit 39598ff

File tree

3 files changed

+54
-6
lines changed

3 files changed

+54
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3044,7 +3044,7 @@ void OmpStructureChecker::CheckReductionObjects(
30443044
if (!std::holds_alternative<parser::Name>(base.u)) {
30453045
auto source{GetObjectSource(object)};
30463046
context_.Say(source ? *source : GetContext().clauseSource,
3047-
"The base expression of an array element in %s clause must be an identifier"_err_en_US,
3047+
"The base expression of an array element or section in %s clause must be an identifier"_err_en_US,
30483048
parser::ToUpperCaseLetters(getClauseName(clauseId).str()));
30493049
}
30503050
}
@@ -4013,11 +4013,13 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Copyin &x) {
40134013
void OmpStructureChecker::CheckStructureComponent(
40144014
const parser::OmpObjectList &objects, llvm::omp::Clause clauseId) {
40154015
auto CheckComponent{[&](const parser::Designator &designator) {
4016-
if (auto *desg{std::get_if<parser::DataRef>(&designator.u)}) {
4017-
if (auto *comp{parser::Unwrap<parser::StructureComponent>(*desg)}) {
4018-
context_.Say(comp->component.source,
4019-
"A variable that is part of another variable cannot appear on the %s clause"_err_en_US,
4020-
parser::ToUpperCaseLetters(getClauseName(clauseId).str()));
4016+
if (auto *dataRef{std::get_if<parser::DataRef>(&designator.u)}) {
4017+
if (!IsDataRefTypeParamInquiry(dataRef)) {
4018+
if (auto *comp{parser::Unwrap<parser::StructureComponent>(*dataRef)}) {
4019+
context_.Say(comp->component.source,
4020+
"A variable that is part of another variable cannot appear on the %s clause"_err_en_US,
4021+
parser::ToUpperCaseLetters(getClauseName(clauseId).str()));
4022+
}
40214023
}
40224024
}
40234025
}};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
!RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp -fopenmp-version=50
2+
3+
!Ref: [5.0:297:28-29]
4+
! If a list item is an array section or an array element, its base expression
5+
! must be a base language identifier.
6+
7+
module m
8+
type t
9+
integer :: a(10)
10+
end type
11+
12+
contains
13+
14+
subroutine f00
15+
type(t) :: x
16+
!ERROR: The base expression of an array element or section in REDUCTION clause must be an identifier
17+
!$omp do reduction (+ : x%a(2))
18+
do i = 1, 10
19+
end do
20+
!$omp end do
21+
end subroutine
22+
23+
subroutine f01
24+
type(t) :: x
25+
!ERROR: The base expression of an array element or section in REDUCTION clause must be an identifier
26+
!$omp do reduction (+ : x%a(1:10))
27+
do i = 1, 10
28+
end do
29+
!$omp end do
30+
end subroutine
31+
end
32+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
!RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp -fopenmp-version=50
2+
3+
!Ref: [5.0:298:19]
4+
! A type parameter inquiry cannot appear in a reduction clause.
5+
6+
subroutine f00
7+
integer :: x
8+
!ERROR: Type parameter inquiry is not permitted in REDUCTION clause
9+
!$omp do reduction (+ : x%kind)
10+
do i = 1, 10
11+
end do
12+
!$omp end do
13+
end subroutine
14+

0 commit comments

Comments
 (0)