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

via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 7 16:51:42 PDT 2023


Author: Shraiysh
Date: 2023-09-07T18:51:38-05:00
New Revision: d211ad311e4b6449c73e1617c0bdf927857e9279

URL: https://github.com/llvm/llvm-project/commit/d211ad311e4b6449c73e1617c0bdf927857e9279
DIFF: https://github.com/llvm/llvm-project/commit/d211ad311e4b6449c73e1617c0bdf927857e9279.diff

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

`if` clause is valid with openmp >= 5.2. It is not supported yet.

Added: 
    

Modified: 
    clang/test/OpenMP/teams_default_messages.cpp
    llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 
    


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