Author: grosser Date: Wed Sep 21 13:28:29 2011 New Revision: 140270 URL: http://llvm.org/viewvc/llvm-project?rev=140270&view=rev Log: In the OpenCL mode, the AltiVec mode must be off and checks must be strict
OpenCL is different from AltiVec in the way it supports vector literals. OpenCL is strict with regards to semantic checks. For example, implicit conversions and explicit casts between vectors of different types are disallowed. Fixes PR10975. Submitted by: Anton Lokhmotov <[email protected]> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/SemaOpenCL/vector_literals_invalid.cl Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=140270&r1=140269&r2=140270&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Sep 21 13:28:29 2011 @@ -1492,9 +1492,9 @@ // OpenCL has some additional defaults. if (LangStd == LangStandard::lang_opencl) { Opts.OpenCL = 1; - Opts.AltiVec = 1; + Opts.AltiVec = 0; Opts.CXXOperatorNames = 1; - Opts.LaxVectorConversions = 1; + Opts.LaxVectorConversions = 0; Opts.DefaultFPContract = 1; } Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=140270&r1=140269&r2=140270&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Sep 21 13:28:29 2011 @@ -4248,7 +4248,8 @@ // i.e. all the elements are integer constants. ParenExpr *PE = dyn_cast<ParenExpr>(CastExpr); ParenListExpr *PLE = dyn_cast<ParenListExpr>(CastExpr); - if (getLangOptions().AltiVec && castType->isVectorType() && (PE || PLE)) { + if ((getLangOptions().AltiVec || getLangOptions().OpenCL) + && castType->isVectorType() && (PE || PLE)) { if (PLE && PLE->getNumExprs() == 0) { Diag(PLE->getExprLoc(), diag::err_altivec_empty_initializer); return ExprError(); Modified: cfe/trunk/test/SemaOpenCL/vector_literals_invalid.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/vector_literals_invalid.cl?rev=140270&r1=140269&r2=140270&view=diff ============================================================================== --- cfe/trunk/test/SemaOpenCL/vector_literals_invalid.cl (original) +++ cfe/trunk/test/SemaOpenCL/vector_literals_invalid.cl Wed Sep 21 13:28:29 2011 @@ -8,6 +8,6 @@ { int4 a = (int4)(1,2,3); // expected-error{{too few elements}} int4 b = (int4)(1,2,3,4,5); // expected-error{{excess elements in vector}} - ((float4)(1.0f))++; // expected-error{{expression is not assignable}} + ((float4)(1.0f))++; // expected-error{{cannot increment value of type 'float4'}} int8 d = (int8)(a,(float4)(1)); // expected-error{{initializing 'int' with an expression of incompatible type 'float4'}} } _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
