Pinging a proposed patch for fixing 15775 in SemaExpr.cpp, and adding
test cases.  Feedback would be appreciated.  This is an issue
affecting OpenCL language conformance.

--John
Index: test/SemaOpenCL/vector_ops.cl
===================================================================
--- test/SemaOpenCL/vector_ops.cl	(revision 0)
+++ test/SemaOpenCL/vector_ops.cl	(revision 0)
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -verify %s
+
+typedef unsigned int uint4 __attribute((ext_vector_type(4)));
+typedef int int4 __attribute((ext_vector_type(4)));
+typedef short short4 __attribute((ext_vector_type(4)));
+typedef float float4 __attribute((ext_vector_type(4)));
+
+void vector_increments() {
+  uint4 u = (uint4)(1);
+  int4 i = (int4)(1);
+  short4 s = (short4)(2);
+  float4 f = (float4)(2.0f);
+
+  u++; // fine
+  --u; // fine
+  i++; // fine
+  --i; // fine
+  s++; // fine
+  --s; // fine
+  f++; // expected-error{{cannot increment value of type 'float4'}}
+  --f; // expected-error{{cannot decrement value of type 'float4'}}
+}
+
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp	(revision 180265)
+++ lib/Sema/SemaExpr.cpp	(working copy)
@@ -8143,6 +8143,15 @@
                                           IsInc, IsPrefix);
   } else if (S.getLangOpts().AltiVec && ResType->isVectorType()) {
     // OK! ( C/C++ Language Extensions for CBEA(Version 2.6) 10.3 )
+  } else if (ResType->isExtVectorType()) {
+    // Only integral ext vector types are OK
+    // ( OpenCL Language Specification (Version 1.1) 6.3.c )
+    QualType EltType = ResType->getAs<ExtVectorType>()->getElementType();
+    if (!EltType->isIntegralType(S.getASTContext())) {
+      S.Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
+        << ResType << int(IsInc) << Op->getSourceRange();
+      return QualType();
+    }
   } else {
     S.Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
       << ResType << int(IsInc) << Op->getSourceRange();
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to