[PATCH] D38868: [OpenCL] Restrict swizzle length check to OpenCL mode

Bruno Cardoso Lopes via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 17 10:55:10 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL316016: [OpenCL] Restrict swizzle length check to OpenCL mode (authored by bruno).

Changed prior to commit:
  https://reviews.llvm.org/D38868?vs=118966&id=119351#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38868

Files:
  cfe/trunk/lib/Sema/SemaExprMember.cpp
  cfe/trunk/test/Sema/vector_swizzle_length.c
  cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl


Index: cfe/trunk/test/Sema/vector_swizzle_length.c
===================================================================
--- cfe/trunk/test/Sema/vector_swizzle_length.c
+++ cfe/trunk/test/Sema/vector_swizzle_length.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x c %s -verify -pedantic -fsyntax-only
+// expected-no-diagnostics
+
+typedef float float8 __attribute__((ext_vector_type(8)));
+
+void foo() {
+    float8 f2 = (float8){0, 0, 0, 0, 0, 0, 0, 0};
+    (void)f2.s01234;
+    (void)f2.xyzxy;
+}
Index: cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl
===================================================================
--- cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl
+++ cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 -x cl %s -verify -pedantic -fsyntax-only
 
 typedef float float8 __attribute__((ext_vector_type(8)));
 
Index: cfe/trunk/lib/Sema/SemaExprMember.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExprMember.cpp
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp
@@ -384,7 +384,9 @@
     }
   }
 
-  if (!HalvingSwizzle) {
+  // OpenCL mode requires swizzle length to be in accordance with accepted
+  // sizes. Clang however supports arbitrary lengths for other languages.
+  if (S.getLangOpts().OpenCL && !HalvingSwizzle) {
     unsigned SwizzleLength = CompName->getLength();
 
     if (HexSwizzle)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38868.119351.patch
Type: text/x-patch
Size: 1461 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171017/f6884425/attachment.bin>


More information about the cfe-commits mailing list