On 05/09/2013, at 11:10 , "Song, Ruiling" <[email protected]> wrote:
> This is a patch to allow increment decrement operators on integer vectors in
> OpenCL. Version 2 add a unit test.
> Please help review. Thanks!
Would it be better to avoid the duplicate of the error diagnostic? Something
like:
--- lib/Sema/SemaExpr.cpp (revision 190019)
+++ lib/Sema/SemaExpr.cpp (working copy)
@@ -8401,9 +8401,19 @@
} else if (S.getLangOpts().AltiVec && ResType->isVectorType()) {
// OK! ( C/C++ Language Extensions for CBEA(Version 2.6) 10.3 )
} else {
- S.Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
- << ResType << int(IsInc) << Op->getSourceRange();
- return QualType();
+ bool bad = true;
+ if(S.getLangOpts().OpenCL && ResType->isVectorType()) {
+ // OpenCL V1.2 6.3 says dec/inc ops operate on integer vector types.
+ QualType ElemTy = ResType->getAs<VectorType>()->getElementType();
+ if(ElemTy->isIntegerType()) {
+ bad = false;
+ }
+ }
+ if (bad) {
+ S.Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
+ << ResType << int(IsInc) << Op->getSourceRange();
+ return QualType();
+ }
}
// At this point, we know we have a real, complex or pointer type.
// Now make sure the operand is a modifiable lvalue.
It adds a boolean, I can't see an easy way to avoid that, but avoids the
duplicated code of the diagnostic and return value.
Peter.
--
Keyboard Maestro 6.2 now out - control Mail, reveal a file, format AppleScripts
and more.
Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
<http://www.stairways.com/> <http://download.keyboardmaestro.com/>
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits