Skip to content

Commit 5f8b83e

Browse files
authored
[flang][OpenMP] Deprecation message for DESTROY with no argument (#114988)
[5.2:625:17] The syntax of the DESTROY clause on the DEPOBJ construct with no argument was deprecated.
1 parent 76f993b commit 5f8b83e

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

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

+13-5
Original file line numberDiff line numberDiff line change
@@ -2687,11 +2687,19 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Destroy &x) {
26872687
llvm::omp::Directive dir{GetContext().directive};
26882688
unsigned version{context_.langOptions().OpenMPVersion};
26892689
if (dir == llvm::omp::Directive::OMPD_depobj) {
2690-
if (version < 52) {
2691-
context_.Say(GetContext().clauseSource,
2692-
"The object parameter in DESTROY clause in DEPOPJ construct "
2693-
"was introduced in %s"_port_en_US,
2694-
ThisVersion(52));
2690+
unsigned argSince{52}, noargDeprecatedIn{52};
2691+
if (x.v) {
2692+
if (version < argSince) {
2693+
context_.Say(GetContext().clauseSource,
2694+
"The object parameter in DESTROY clause on DEPOPJ construct is not allowed in %s, %s"_warn_en_US,
2695+
ThisVersion(version), TryVersion(argSince));
2696+
}
2697+
} else {
2698+
if (version >= noargDeprecatedIn) {
2699+
context_.Say(GetContext().clauseSource,
2700+
"The DESTROY clause without argument on DEPOBJ construct is deprecated in %s"_warn_en_US,
2701+
ThisVersion(noargDeprecatedIn));
2702+
}
26952703
}
26962704
}
26972705
}

flang/test/Semantics/OpenMP/depobj-construct-v50.f90

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ subroutine f02
2323
subroutine f03
2424
integer :: obj, jbo
2525
!ERROR: The DESTROY clause must refer to the same object as the DEPOBJ construct
26-
!PORTABILITY: The object parameter in DESTROY clause in DEPOPJ construct was introduced in OpenMP v5.2
26+
!WARNING: The object parameter in DESTROY clause on DEPOPJ construct is not allowed in OpenMP v5.0, try -fopenmp-version=52
2727
!$omp depobj(obj) destroy(jbo)
2828
end

flang/test/Semantics/OpenMP/depobj-construct-v52.f90

+6
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ subroutine f03
1313
!ERROR: The DESTROY clause must refer to the same object as the DEPOBJ construct
1414
!$omp depobj(obj) destroy(jbo)
1515
end
16+
17+
subroutine f06
18+
integer :: obj
19+
!WARNING: The DESTROY clause without argument on DEPOBJ construct is deprecated in OpenMP v5.2
20+
!$omp depobj(obj) destroy
21+
end

0 commit comments

Comments
 (0)