[clang] Add error note when if clause is used on teams before 5.2. (PR #65686)

via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 7 15:19:44 PDT 2023


https://github.com/shraiysh created https://github.com/llvm/llvm-project/pull/65686:

None

>From cdcacbd3f8b86fffa0f00d8890d8b3cc3bd170bb Mon Sep 17 00:00:00 2001
From: Shraiysh Vaishay <shraiysh.vaishay at amd.com>
Date: Thu, 7 Sep 2023 16:30:36 -0500
Subject: [PATCH] Add error note when if clause is used on teams before 5.2.

---
 clang/test/OpenMP/teams_default_messages.cpp | 10 ++++++++--
 llvm/include/llvm/Frontend/OpenMP/OMP.td     |  2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/clang/test/OpenMP/teams_default_messages.cpp b/clang/test/OpenMP/teams_default_messages.cpp
index 6afc5576d83412e..9131a088adb4a64 100644
--- a/clang/test/OpenMP/teams_default_messages.cpp
+++ b/clang/test/OpenMP/teams_default_messages.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -fopenmp -DOMP51 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -fopenmp -DOMP51 -o - %s -Wuninitialized
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -DOMP51 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -fopenmp-simd -DOMP51 -o - %s -Wuninitialized
 
 // RUN: %clang_cc1 -verify -fopenmp-version=50 -fopenmp -o - %s -Wuninitialized
 
@@ -42,6 +42,9 @@ int main(int argc, char **argv) {
   #pragma omp parallel default(shared)
   ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+  #pragma omp teams if(x) // expected-error {{unexpected OpenMP clause 'if' in directive '#pragma omp teams'}}
+  foo();
+
 #ifdef OMP51
 #pragma omp target
 #pragma omp teams default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
@@ -55,6 +58,9 @@ int main(int argc, char **argv) {
     ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
     ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
   }
+#pragma omp teams if(x) // expected-error {{unexpected OpenMP clause 'if' in directive '#pragma omp teams'}}
+  foo();
+
 #endif
   return 0;
 }
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td
index b6639b67a5c5276..1aaddcaf3969dcb 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -672,7 +672,7 @@ def OMP_Teams : Directive<"teams"> {
   ];
   let allowedOnceClauses = [
     VersionedClause<OMPC_Default>,
-    VersionedClause<OMPC_If>,
+    VersionedClause<OMPC_If, 52>,
     VersionedClause<OMPC_NumTeams>,
     VersionedClause<OMPC_ThreadLimit>
   ];



More information about the cfe-commits mailing list