Skip to content

[OpenMP 5.2] Deprecate old syntax of linear clause #70152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2023

Conversation

mdfazlay
Copy link
Contributor

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

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:openmp OpenMP related changes to Clang labels Oct 25, 2023
@mdfazlay mdfazlay requested a review from mikerice1969 October 25, 2023 01:40
@mdfazlay
Copy link
Contributor Author

@alexey-bataev, I'll add more tests as soon as we finalize the proper error message.

@llvmbot
Copy link
Member

llvmbot commented Oct 25, 2023

@llvm/pr-subscribers-clang

Author: Fazlay Rabbi (mdfazlay)

Changes

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 --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

Copy link
Member

@alexey-bataev alexey-bataev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@mdfazlay mdfazlay force-pushed the deprecate-old-syntax-of-linear-clause branch 5 times, most recently from 5d36f0e to f13a552 Compare October 25, 2023 18:45
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
@mdfazlay mdfazlay force-pushed the deprecate-old-syntax-of-linear-clause branch from f13a552 to afec5a9 Compare October 25, 2023 19:09
@mdfazlay mdfazlay merged commit 9237ce4 into llvm:main Oct 25, 2023
@mdfazlay mdfazlay deleted the deprecate-old-syntax-of-linear-clause branch October 25, 2023 22:36
zahiraam pushed a commit to zahiraam/llvm-project that referenced this pull request Oct 26, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:openmp OpenMP related changes to Clang clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants