summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2011-09-21 18:28:29 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2011-09-21 18:28:29 +0000
commit0a3a22fe665fc86119cf94690c09d13c9a8b4818 (patch)
treea8b496c9a837c2b3d259f2e81251006cfacd3452
parent37a7151b1fb990f2f09c51757d661d1f957e4e44 (diff)
downloadbcm5719-llvm-0a3a22fe665fc86119cf94690c09d13c9a8b4818.tar.gz
bcm5719-llvm-0a3a22fe665fc86119cf94690c09d13c9a8b4818.zip
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 <Anton.lokhmotov@gmail.com> llvm-svn: 140270
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp4
-rw-r--r--clang/lib/Sema/SemaExpr.cpp3
-rw-r--r--clang/test/SemaOpenCL/vector_literals_invalid.cl2
3 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index a8d98b26089..7cb707b9661 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1492,9 +1492,9 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
// 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;
}
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 1d23f4f3b2a..58b62583044 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -4248,7 +4248,8 @@ Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
// 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();
diff --git a/clang/test/SemaOpenCL/vector_literals_invalid.cl b/clang/test/SemaOpenCL/vector_literals_invalid.cl
index 957680f44ff..e4e23cd85f0 100644
--- a/clang/test/SemaOpenCL/vector_literals_invalid.cl
+++ b/clang/test/SemaOpenCL/vector_literals_invalid.cl
@@ -8,6 +8,6 @@ void vector_literals_invalid()
{
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'}}
}
OpenPOWER on IntegriCloud