[clang] 09dc454 - [OpenCL] Enables .rgba vector extension in C++ for OpenCL 2021
Justas Janickas via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 14 05:06:14 PDT 2021
Author: Justas Janickas
Date: 2021-09-14T13:05:42+01:00
New Revision: 09dc454b00b8ed0a19f766f760fa19e86a0b9059
URL: https://github.com/llvm/llvm-project/commit/09dc454b00b8ed0a19f766f760fa19e86a0b9059
DIFF: https://github.com/llvm/llvm-project/commit/09dc454b00b8ed0a19f766f760fa19e86a0b9059.diff
LOG: [OpenCL] Enables .rgba vector extension in C++ for OpenCL 2021
`.rgba` vector extension setting in C++ for OpenCL 2021 is now
performed analogously to OpenCL C 3.0. Test case added.
Differential Revision: https://reviews.llvm.org/D109370
Added:
Modified:
clang/lib/Sema/SemaExprMember.cpp
clang/test/SemaOpenCL/ext_vectors.cl
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp
index 92b7464cd0bbf..0f0dd8a42cfca 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -340,7 +340,8 @@ CheckExtVectorComponent(Sema &S, QualType baseType, ExprValueKind &VK,
// Emit a warning if an rgba selector is used earlier than OpenCL C 3.0.
if (HasRGBA || (*compStr && IsRGBA(*compStr))) {
- if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 300) {
+ if (S.getLangOpts().OpenCL &&
+ S.getLangOpts().getOpenCLCompatibleVersion() < 300) {
const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
<< StringRef(DiagBegin, 1) << SourceRange(CompLoc);
diff --git a/clang/test/SemaOpenCL/ext_vectors.cl b/clang/test/SemaOpenCL/ext_vectors.cl
index 7404f037d93f5..ce5b333bd8aab 100644
--- a/clang/test/SemaOpenCL/ext_vectors.cl
+++ b/clang/test/SemaOpenCL/ext_vectors.cl
@@ -2,6 +2,7 @@
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021
typedef float float4 __attribute__((ext_vector_type(4)));
@@ -9,13 +10,13 @@ void test_ext_vector_accessors(float4 V) {
V = V.wzyx;
V = V.abgr;
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || (defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
// expected-warning at -2 {{vector component name 'a' is a feature from OpenCL version 3.0 onwards}}
#endif
V = V.xyzr;
// expected-error at -1 {{illegal vector component name 'r'}}
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || (defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
// expected-warning at -3 {{vector component name 'r' is a feature from OpenCL version 3.0 onwards}}
#endif
}
More information about the cfe-commits
mailing list