[PATCH] D99969: [OpenCL] Accept .rgba in OpenCL 3.0
Sven van Haastregt via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 6 09:41:44 PDT 2021
svenvh created this revision.
svenvh added reviewers: Anastasia, azabaznov.
svenvh added a project: clang.
Herald added subscribers: ldrumm, yaxunl.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.
The .rgba vector component accessors are supported in OpenCL C 3.0.
Previously, the diagnostic would check `OpenCLVersion` for version 2.2
(value 220) and report those accessors are an OpenCL 2.2 feature.
However, there is no "OpenCL C version 2.2", so change the check and
diagnostic text to 3.0 only.
A spurious `OpenCLVersion` argument was passed into the diagnostic;
remove that.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D99969
Files:
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExprMember.cpp
clang/test/SemaOpenCL/ext_vectors.cl
Index: clang/test/SemaOpenCL/ext_vectors.cl
===================================================================
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -1,11 +1,20 @@
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
typedef float float4 __attribute__((ext_vector_type(4)));
void test_ext_vector_accessors(float4 V) {
V = V.wzyx;
- V = V.abgr; // expected-warning {{vector component name 'a' is an OpenCL version 2.2 feature}}
- V = V.xyzr; // expected-warning {{vector component name 'r' is an OpenCL version 2.2 feature}} \
- // expected-error {{illegal vector component name 'r'}}
+
+ V = V.abgr;
+#if (__OPENCL_C_VERSION__ < 300)
+ // expected-warning at -2 {{vector component name 'a' is an OpenCL C version 3.0 feature}}
+#endif
+
+ V = V.xyzr;
+ // expected-error at -1 {{illegal vector component name 'r'}}
+#if (__OPENCL_C_VERSION__ < 300)
+ // expected-warning at -3 {{vector component name 'r' is an OpenCL C version 3.0 feature}}
+#endif
}
Index: clang/lib/Sema/SemaExprMember.cpp
===================================================================
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -338,13 +338,12 @@
compStr++;
} while (*compStr && (Idx = vecType->getPointAccessorIdx(*compStr)) != -1);
- // Emit a warning if an rgba selector is used earlier than OpenCL 2.2
+ // 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 < 220) {
+ if (S.getLangOpts().OpenCLVersion < 300) {
const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
- << StringRef(DiagBegin, 1)
- << S.getLangOpts().OpenCLVersion << SourceRange(CompLoc);
+ << StringRef(DiagBegin, 1) << SourceRange(CompLoc);
}
}
} else {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9996,9 +9996,9 @@
def err_opencl_builtin_expected_type : Error<
"illegal call to %0, expected %1 argument type">;
-// OpenCL v2.2 s2.1.2.3 - Vector Component Access
+// OpenCL v3.0 s6.3.7 - Vector Components
def ext_opencl_ext_vector_type_rgba_selector: ExtWarn<
- "vector component name '%0' is an OpenCL version 2.2 feature">,
+ "vector component name '%0' is an OpenCL C version 3.0 feature">,
InGroup<OpenCLUnsupportedRGBA>;
def err_openclcxx_placement_new : Error<
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99969.335557.patch
Type: text/x-patch
Size: 2883 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210406/aeb92cbd/attachment.bin>
More information about the cfe-commits
mailing list