Author: Sven van Haastregt Date: 2021-04-12T09:30:06+01:00 New Revision: 731bf28a6092286dde6972803b35c026e32bd6b1
URL: https://github.com/llvm/llvm-project/commit/731bf28a6092286dde6972803b35c026e32bd6b1 DIFF: https://github.com/llvm/llvm-project/commit/731bf28a6092286dde6972803b35c026e32bd6b1.diff LOG: [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 Added: Modified: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Sema/SemaExprMember.cpp clang/test/SemaOpenCL/ext_vectors.cl Removed: ################################################################################ diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 5c27902da2502..af7eea06f6f5b 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 0663c0d277259..d8b66639db8cd 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 3b2dd6d719d68..f8af230078f1a 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 } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits