[PATCH] D114102: [OpenMP] Add version macro support for 5.1 and 5.2
Mike Rice via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 17 10:51:34 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG69f35f896912: [OpenMP] Add version macro support for 5.1 and 5.2 (authored by mikerice).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114102/new/
https://reviews.llvm.org/D114102
Files:
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/OpenMP/declare_variant_clauses_messages.cpp
clang/test/OpenMP/driver.c
Index: clang/test/OpenMP/driver.c
===================================================================
--- clang/test/OpenMP/driver.c
+++ clang/test/OpenMP/driver.c
@@ -33,6 +33,12 @@
// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=50 | FileCheck --check-prefix=CHECK-50-VERSION %s
// CHECK-50-VERSION: #define _OPENMP 201811
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=51 | FileCheck --check-prefix=CHECK-51-VERSION %s
+// CHECK-51-VERSION: #define _OPENMP 202011
+
+// RUN: %clang %s -c -E -dM -fopenmp=libomp -fopenmp-version=52 | FileCheck --check-prefix=CHECK-52-VERSION %s
+// CHECK-52-VERSION: #define _OPENMP 202111
+
// RUN: %clang %s -c -E -dM -fopenmp-version=1 | FileCheck --check-prefix=CHECK-VERSION %s
// RUN: %clang %s -c -E -dM -fopenmp-version=31 | FileCheck --check-prefix=CHECK-VERSION %s
// RUN: %clang %s -c -E -dM -fopenmp-version=40 | FileCheck --check-prefix=CHECK-VERSION %s
Index: clang/test/OpenMP/declare_variant_clauses_messages.cpp
===================================================================
--- clang/test/OpenMP/declare_variant_clauses_messages.cpp
+++ clang/test/OpenMP/declare_variant_clauses_messages.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -verify -triple x86_64-unknown-linux -fopenmp -fopenmp-version=51 -DOMP51 -std=c++11 -o - %s
-// RUN: %clang_cc1 -verify -triple x86_64-unknown-linux -fopenmp -fopenmp-version=51 -DOMP51 -std=c++11 \
+// RUN: %clang_cc1 -verify -triple x86_64-unknown-linux -fopenmp -fopenmp-version=51 -std=c++11 -o - %s
+// RUN: %clang_cc1 -verify -triple x86_64-unknown-linux -fopenmp -fopenmp-version=51 -std=c++11 \
// RUN: -DNO_INTEROP_T_DEF -o - %s
-// RUN: %clang_cc1 -verify -triple x86_64-unknown-linux -fopenmp -fopenmp-version=50 -DOMP50 -std=c++11 -o - %s
-// RUN: %clang_cc1 -verify -triple x86_64-unknown-linux -fopenmp -fopenmp-version=51 -DOMP51 -DC -x c -o - %s
+// RUN: %clang_cc1 -verify -triple x86_64-unknown-linux -fopenmp -fopenmp-version=50 -std=c++11 -o - %s
+// RUN: %clang_cc1 -verify -triple x86_64-unknown-linux -fopenmp -fopenmp-version=51 -DC -x c -o - %s
#ifdef NO_INTEROP_T_DEF
void foo_v1(float *, void *);
@@ -15,7 +15,7 @@
int Other;
-#ifdef OMP51
+#if _OPENMP >= 202011 // At least OpenMP 5.1
#ifdef __cplusplus
class A {
public:
@@ -83,14 +83,14 @@
append_args(interop(target),interop(target))
void templatebar(const int &t) {}
#endif // __cplusplus
-#endif // OMP51
+#endif // _OPENMP >= 202011
void foo_v1(float *AAA, float *BBB, int *I) { return; }
void foo_v2(float *AAA, float *BBB, int *I) { return; }
void foo_v3(float *AAA, float *BBB, int *I) { return; }
void foo_v4(float *AAA, float *BBB, int *I, omp_interop_t IOp) { return; }
-#ifdef OMP51
+#if _OPENMP >= 202011 // At least OpenMP 5.1
void vararg_foo(const char *fmt, omp_interop_t it, ...);
// expected-error at +3 {{'append_args' is not allowed with varargs functions}}
#pragma omp declare variant(vararg_foo) match(construct={dispatch}) \
@@ -184,15 +184,15 @@
// expected-error at +1 {{variant in '#pragma omp declare variant' with type 'void (float *, float *, int *, omp_interop_t)' (aka 'void (float *, float *, int *, void *)') is incompatible with type 'void (float *, float *, int *)'}}
#pragma omp declare variant(foo_v4) match(construct={dispatch})
-#endif // OMP51
-#ifdef OMP50
+#endif // _OPENMP >= 202011
+#if _OPENMP < 202011 // OpenMP 5.0 or lower
// expected-error at +2 {{expected 'match' clause on 'omp declare variant' directive}}
#pragma omp declare variant(foo_v1) \
adjust_args(need_device_ptr:AAA) match(device={arch(arm)})
// expected-error at +2 {{expected 'match' clause on 'omp declare variant' directive}}
#pragma omp declare variant(foo_v1) \
append_args(interop(target)) match(device={arch(arm)})
-#endif // OMP50
+#endif // _OPENMP < 202011
void foo(float *AAA, float *BBB, int *I) { return; }
Index: clang/lib/Frontend/InitPreprocessor.cpp
===================================================================
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -1152,6 +1152,12 @@
case 45:
Builder.defineMacro("_OPENMP", "201511");
break;
+ case 51:
+ Builder.defineMacro("_OPENMP", "202011");
+ break;
+ case 52:
+ Builder.defineMacro("_OPENMP", "202111");
+ break;
default:
// Default version is OpenMP 5.0
Builder.defineMacro("_OPENMP", "201811");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114102.387994.patch
Type: text/x-patch
Size: 4513 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211117/d5824cc0/attachment-0001.bin>
More information about the cfe-commits
mailing list