[PATCH] D51296: [OpenCL] Traverse vector types for ocl extensions support
Viktoria Maximova via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 30 02:26:39 PDT 2018
vmaksimo updated this revision to Diff 163287.
vmaksimo retitled this revision from "[Sema] Traverse vector types for ocl extensions support" to "[OpenCL] Traverse vector types for ocl extensions support".
vmaksimo edited the summary of this revision.
Repository:
rC Clang
https://reviews.llvm.org/D51296
Files:
lib/Sema/Sema.cpp
test/SemaOpenCL/extensions.cl
Index: test/SemaOpenCL/extensions.cl
===================================================================
--- test/SemaOpenCL/extensions.cl
+++ test/SemaOpenCL/extensions.cl
@@ -70,6 +70,13 @@
// expected-error at -2{{use of type 'double' requires cl_khr_fp64 extension to be enabled}}
#endif
+ typedef double double4 __attribute__((ext_vector_type(4)));
+ double4 d4 = {0.0f, 2.0f, 3.0f, 1.0f};
+#ifdef NOFP64
+// expected-error at -3 {{use of type 'double' requires cl_khr_fp64 extension to be enabled}}
+// expected-error at -3 {{use of type 'double4' (vector of 4 'double' values) requires cl_khr_fp64 extension to be enabled}}
+#endif
+
(void) 1.0;
#ifdef NOFP64
Index: lib/Sema/Sema.cpp
===================================================================
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -1852,6 +1853,14 @@
if (auto TagT = dyn_cast<TagType>(QT.getCanonicalType().getTypePtr()))
Decl = TagT->getDecl();
auto Loc = DS.getTypeSpecTypeLoc();
+
+ // Check extensions for vector types.
+ // e.g. double4 is not allowed when cl_khr_fp64 is absent.
+ if (QT->isExtVectorType()) {
+ auto TypePtr = QT->castAs<ExtVectorType>()->getElementType().getTypePtr();
+ return checkOpenCLDisabledTypeOrDecl(TypePtr, Loc, QT, OpenCLTypeExtMap);
+ }
+
if (checkOpenCLDisabledTypeOrDecl(Decl, Loc, QT, OpenCLDeclExtMap))
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51296.163287.patch
Type: text/x-patch
Size: 1366 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180830/fb2bd3fd/attachment.bin>
More information about the cfe-commits
mailing list