diff options
author | Sven van Haastregt <sven.vanhaastregt@arm.com> | 2021-04-12 09:30:06 +0100 |
---|---|---|
committer | Sven van Haastregt <sven.vanhaastregt@arm.com> | 2021-04-12 09:30:06 +0100 |
commit | 731bf28a6092286dde6972803b35c026e32bd6b1 (patch) | |
tree | f01c3b30e91ed0f6aef2dad47b5efd14a20663e6 | |
parent | [AArch64] Adds memory operands for indexed loads. (diff) | |
download | llvm-project-731bf28a6092286dde6972803b35c026e32bd6b1.tar.gz llvm-project-731bf28a6092286dde6972803b35c026e32bd6b1.tar.bz2 llvm-project-731bf28a6092286dde6972803b35c026e32bd6b1.zip |
[OpenCL] Accept .rgba in OpenCL 3.0
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.
Differential Revision: https://reviews.llvm.org/D99969
-rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprMember.cpp | 7 | ||||
-rw-r--r-- | clang/test/SemaOpenCL/ext_vectors.cl | 15 |
3 files changed, 17 insertions, 9 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 5c27902da250..af7eea06f6f5 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -10005,9 +10005,9 @@ def err_opencl_enqueue_kernel_blocks_no_args : Error< 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< diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp index 0663c0d27725..d8b66639db8c 100644 --- a/clang/lib/Sema/SemaExprMember.cpp +++ b/clang/lib/Sema/SemaExprMember.cpp @@ -338,13 +338,12 @@ CheckExtVectorComponent(Sema &S, QualType baseType, ExprValueKind &VK, 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().OpenCL && 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 { diff --git a/clang/test/SemaOpenCL/ext_vectors.cl b/clang/test/SemaOpenCL/ext_vectors.cl index 3b2dd6d719d6..f8af230078f1 100644 --- a/clang/test/SemaOpenCL/ext_vectors.cl +++ b/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@-2 {{vector component name 'a' is an OpenCL C version 3.0 feature}} +#endif + + V = V.xyzr; + // expected-error@-1 {{illegal vector component name 'r'}} +#if (__OPENCL_C_VERSION__ < 300) + // expected-warning@-3 {{vector component name 'r' is an OpenCL C version 3.0 feature}} +#endif } |