Skip to content

Commit c7a4785

Browse files
committed
Revert "[flang][OpenMP] Analyze objects in OmpObjectList on clauses (llvm#155424)"
This reverts commit 6308531. This breaks gfortran test suite: ``` error: Semantic errors in gfortran/regression/gomp/pr80918.f90 gfortran/regression/gomp/pr80918.f90:6:27: error: Whole assumed-size array 'a' may not appear here without subscripts !$omp task depend(inout:a) ^ gfortran/regression/gomp/pr80918.f90:5:14: Declaration of 'a' integer :: a(*) ^ ``` The error appears to be legitimate.
1 parent 445060f commit c7a4785

File tree

7 files changed

+7
-77
lines changed

7 files changed

+7
-77
lines changed

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

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -268,43 +268,6 @@ bool OmpStructureChecker::CheckAllowedClause(llvmOmpClause clause) {
268268
return CheckAllowed(clause);
269269
}
270270

271-
void OmpStructureChecker::AnalyzeObject(
272-
const parser::OmpObject &object, bool allowAssumedSizeArrays) {
273-
if (std::holds_alternative<parser::Name>(object.u)) {
274-
// Do not analyze common block names. The analyzer will flag an error
275-
// on those.
276-
return;
277-
}
278-
if (auto *symbol{GetObjectSymbol(object)}) {
279-
// Eliminate certain kinds of symbols before running the analyzer to
280-
// avoid confusing error messages. The analyzer assumes that the context
281-
// of the object use is an expression, and some diagnostics are tailored
282-
// to that.
283-
if (symbol->has<DerivedTypeDetails>() || symbol->has<MiscDetails>()) {
284-
// Type names, construct names, etc.
285-
return;
286-
}
287-
if (auto *typeSpec{symbol->GetType()}) {
288-
if (typeSpec->category() == DeclTypeSpec::Category::Character) {
289-
// Don't pass character objects to the analyzer, it can emit somewhat
290-
// cryptic errors (e.g. "'obj' is not an array"). Substrings are
291-
// checked elsewhere in OmpStructureChecker.
292-
return;
293-
}
294-
}
295-
}
296-
evaluate::ExpressionAnalyzer ea{context_};
297-
auto restore{ea.AllowWholeAssumedSizeArray(allowAssumedSizeArrays)};
298-
common::visit([&](auto &&s) { ea.Analyze(s); }, object.u);
299-
}
300-
301-
void OmpStructureChecker::AnalyzeObjects(
302-
const parser::OmpObjectList &objects, bool allowAssumedSizeArrays) {
303-
for (const parser::OmpObject &object : objects.v) {
304-
AnalyzeObject(object, allowAssumedSizeArrays);
305-
}
306-
}
307-
308271
bool OmpStructureChecker::IsCloselyNestedRegion(const OmpDirectiveSet &set) {
309272
// Definition of close nesting:
310273
//
@@ -2734,9 +2697,8 @@ void OmpStructureChecker::Leave(const parser::OmpClauseList &) {
27342697
void OmpStructureChecker::Enter(const parser::OmpClause &x) {
27352698
SetContextClause(x);
27362699

2737-
llvm::omp::Clause id{x.Id()};
27382700
// The visitors for these clauses do their own checks.
2739-
switch (id) {
2701+
switch (x.Id()) {
27402702
case llvm::omp::Clause::OMPC_copyprivate:
27412703
case llvm::omp::Clause::OMPC_enter:
27422704
case llvm::omp::Clause::OMPC_lastprivate:
@@ -2750,7 +2712,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause &x) {
27502712
// Named constants are OK to be used within 'shared' and 'firstprivate'
27512713
// clauses. The check for this happens a few lines below.
27522714
bool SharedOrFirstprivate = false;
2753-
switch (id) {
2715+
switch (x.Id()) {
27542716
case llvm::omp::Clause::OMPC_shared:
27552717
case llvm::omp::Clause::OMPC_firstprivate:
27562718
SharedOrFirstprivate = true;
@@ -2759,20 +2721,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause &x) {
27592721
break;
27602722
}
27612723

2762-
auto allowsAssumedSizeArrays{[](llvm::omp::Clause c) {
2763-
// These clauses allow assumed-size-arrays as list items.
2764-
switch (c) {
2765-
case llvm::omp::Clause::OMPC_map:
2766-
case llvm::omp::Clause::OMPC_shared:
2767-
case llvm::omp::Clause::OMPC_use_device_addr:
2768-
return true;
2769-
default:
2770-
return false;
2771-
}
2772-
}};
2773-
27742724
if (const parser::OmpObjectList *objList{GetOmpObjectList(x)}) {
2775-
AnalyzeObjects(*objList, allowsAssumedSizeArrays(id));
27762725
SymbolSourceMap symbols;
27772726
GetSymbolsInObjectList(*objList, symbols);
27782727
for (const auto &[symbol, source] : symbols) {

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ class OmpStructureChecker
167167
void CheckVariableListItem(const SymbolSourceMap &symbols);
168168
void CheckDirectiveSpelling(
169169
parser::CharBlock spelling, llvm::omp::Directive id);
170-
void AnalyzeObject(
171-
const parser::OmpObject &object, bool allowAssumedSizeArrays = false);
172-
void AnalyzeObjects(const parser::OmpObjectList &objects,
173-
bool allowAssumedSizeArrays = false);
174170
void CheckMultipleOccurrence(semantics::UnorderedSymbolSet &listVars,
175171
const std::list<parser::Name> &nameList, const parser::CharBlock &item,
176172
const std::string &clauseName);

flang/test/Lower/OpenMP/Todo/omp-do-simd-linear.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
44
! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
55
subroutine testDoSimdLinear(int_array)
6-
integer :: int_array(:)
6+
integer :: int_array(*)
77
!CHECK: not yet implemented: Unhandled clause LINEAR in SIMD construct
88
!$omp do simd linear(int_array)
99
do index_ = 1, 10

flang/test/Semantics/OpenMP/cray-pointer-usage.f90

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ subroutine test_cray_pointer_usage
44
integer :: i
55
real(8) :: var(*), pointee(2)
66
pointer(ivar, var)
7-
real(8) :: var2(10)
8-
pointer(ivar2, var2)
9-
! ERROR: Whole assumed-size array 'var' may not appear here without subscripts
107
! ERROR: Cray Pointee 'var' may not appear in LINEAR clause
118
! ERROR: The list item 'var' specified without the REF 'linear-modifier' must be of INTEGER type
129
! ERROR: The list item `var` must be a dummy argument
@@ -20,9 +17,9 @@ subroutine test_cray_pointer_usage
2017
print *, var(1)
2118
!$omp end parallel
2219

23-
! ERROR: Cray Pointee 'var2' may not appear in PRIVATE clause, use Cray Pointer 'ivar2' instead
24-
!$omp parallel num_threads(2) default(none) private(var2)
25-
print *, var2(1)
20+
! ERROR: Cray Pointee 'var' may not appear in PRIVATE clause, use Cray Pointer 'ivar' instead
21+
!$omp parallel num_threads(2) default(none) private(var)
22+
print *, var(1)
2623
!$omp end parallel
2724

2825
! ERROR: Cray Pointee 'var' may not appear in SHARED clause, use Cray Pointer 'ivar' instead

flang/test/Semantics/OpenMP/declare-mapper02.f90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
end type t1
77

88
!ERROR: ABSTRACT derived type may not be used here
9-
!ERROR: Reference to object with abstract derived type 't1' must be polymorphic
109
!$omp declare mapper(mm : t1::x) map(x, x%y)
1110
end

flang/test/Semantics/OpenMP/depend01.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ program omp_depend
2020
!ERROR: 'a' in DEPEND clause must have a positive stride
2121
!ERROR: 'b' in DEPEND clause must have a positive stride
2222
!ERROR: 'b' in DEPEND clause is a zero size array section
23-
!$omp task shared(x) depend(in: a(10:5:-1)) depend(in: b(5:10:-1, 2))
23+
!$omp task shared(x) depend(in: a(10:5:-1)) depend(in: b(5:10:-1))
2424
print *, a(5:10), b
2525
!$omp end task
2626

flang/test/Semantics/OpenMP/depend07.f90

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)