[clang] [OpenMP 5.2] Deprecate old syntax of linear clause (PR #70152)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 24 18:42:22 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Fazlay Rabbi (mdfazlay)
<details>
<summary>Changes</summary>
The syntax of the linear clause that specifies its argument and linear-modifier as linear-modifier(list) was deprecated since OpenMP 5.2 and the step modifier was added for specifying the linear step.
Reference: OpenMP 5.2 Spec, Page 627, Line 15
---
Full diff: https://github.com/llvm/llvm-project/pull/70152.diff
3 Files Affected:
- (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+2)
- (modified) clang/lib/Parse/ParseOpenMP.cpp (+4)
- (modified) clang/test/OpenMP/for_linear_messages.cpp (+2)
``````````diff
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index d6652e6a610c1be..0621a61c2edb6a4 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1350,6 +1350,8 @@ def warn_omp_extra_tokens_at_eol : Warning<
InGroup<ExtraTokens>;
def err_omp_multiple_step_or_linear_modifier : Error<
"multiple %select{'step size'|'linear modifier'}0 found in linear clause">;
+def err_omp_deprecate_old_syntax : Error<
+ "old syntax '%0' on '%1' clause was deprecated, use new syntax '%2'">;
def warn_pragma_expected_colon_r_paren : Warning<
"missing ':' or ')' after %0 - ignoring">, InGroup<IgnoredPragmas>;
def err_omp_unknown_directive : Error<
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 4f3b8a28ee47ef3..3e7d8274aeefc52 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -4573,6 +4573,10 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
Data.ExtraModifierLoc = ConsumeToken();
LinearT.consumeOpen();
NeedRParenForLinear = true;
+ if (getLangOpts().OpenMP >= 52)
+ Diag(Data.ExtraModifierLoc, diag::err_omp_deprecate_old_syntax)
+ << "linear-modifier(list)" << getOpenMPClauseName(Kind)
+ << "linear(list: [linear-modifier,] step(step-size))";
}
} else if (Kind == OMPC_lastprivate) {
// Try to parse modifier if any.
diff --git a/clang/test/OpenMP/for_linear_messages.cpp b/clang/test/OpenMP/for_linear_messages.cpp
index 03c5c763d7b5c1d..d8d3391c0c27150 100644
--- a/clang/test/OpenMP/for_linear_messages.cpp
+++ b/clang/test/OpenMP/for_linear_messages.cpp
@@ -215,6 +215,8 @@ int main(int argc, char **argv) {
int i;
#pragma omp for linear(i)
for (int k = 0; k < argc; ++k) ++k;
+ #pragma omp for linear(val(i)) // omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}}
+ for (int k = 0; k < argc; ++k) ++k;
#ifdef OMP52
#pragma omp for linear(i : step(4))
#else
``````````
</details>
https://github.com/llvm/llvm-project/pull/70152
More information about the cfe-commits
mailing list