[clang] [OpenMP 5.2] Deprecate old syntax of linear clause (PR #70152)

Fazlay Rabbi via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 24 18:40:05 PDT 2023


https://github.com/mdfazlay created https://github.com/llvm/llvm-project/pull/70152

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

>From c470a9bb86f31ec7de01d4efad72ff785dc4124e Mon Sep 17 00:00:00 2001
From: Fazlay Rabbi <fazlay.rabbi at intel.com>
Date: Tue, 24 Oct 2023 18:36:53 -0700
Subject: [PATCH] [OpenMP 5.2] Deprecate old syntax of linear clause

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
---
 clang/include/clang/Basic/DiagnosticParseKinds.td | 2 ++
 clang/lib/Parse/ParseOpenMP.cpp                   | 4 ++++
 clang/test/OpenMP/for_linear_messages.cpp         | 2 ++
 3 files changed, 8 insertions(+)

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



More information about the cfe-commits mailing list