summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/Sema.h4
-rw-r--r--clang/lib/Sema/SemaExpr.cpp17
2 files changed, 16 insertions, 5 deletions
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h
index 6e3a5526864..45f08bc8df5 100644
--- a/clang/lib/Sema/Sema.h
+++ b/clang/lib/Sema/Sema.h
@@ -1584,6 +1584,10 @@ public:
/// c/v/r qualifiers, which we accept as an extension.
CompatiblePointerDiscardsQualifiers,
+ /// IncompatibleVectors - The assignment is between two vector types that
+ /// have the same size, which we accept as an extension.
+ IncompatibleVectors,
+
/// IntToBlockPointer - The assignment converts an int to a block
/// pointer. We disallow this.
IntToBlockPointer,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 129967a14b6..ddd5349c156 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2448,7 +2448,7 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
if (getLangOptions().LaxVectorConversions &&
lhsType->isVectorType() && rhsType->isVectorType()) {
if (Context.getTypeSize(lhsType) == Context.getTypeSize(rhsType))
- return Compatible;
+ return IncompatibleVectors;
}
return Incompatible;
}
@@ -2599,13 +2599,17 @@ inline QualType Sema::CheckVectorOperands(SourceLocation Loc, Expr *&lex,
// Handle the case of a vector & extvector type of the same size and element
// type. It would be nice if we only had one vector type someday.
- if (getLangOptions().LaxVectorConversions)
- if (const VectorType *LV = lhsType->getAsVectorType())
+ if (getLangOptions().LaxVectorConversions) {
+ // FIXME: Should we warn here?
+ if (const VectorType *LV = lhsType->getAsVectorType()) {
if (const VectorType *RV = rhsType->getAsVectorType())
if (LV->getElementType() == RV->getElementType() &&
- LV->getNumElements() == RV->getNumElements())
+ LV->getNumElements() == RV->getNumElements()) {
return lhsType->isExtVectorType() ? lhsType : rhsType;
-
+ }
+ }
+ }
+
// If the lhs is an extended vector and the rhs is a scalar of the same type
// or a literal, promote the rhs to the vector type.
if (const ExtVectorType *V = lhsType->getAsExtVectorType()) {
@@ -4359,6 +4363,9 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
// it can give a more specific diagnostic.
DiagKind = diag::warn_incompatible_qualified_id;
break;
+ case IncompatibleVectors:
+ DiagKind = diag::warn_incompatible_vectors;
+ break;
case Incompatible:
DiagKind = diag::err_typecheck_convert_incompatible;
isInvalid = true;
OpenPOWER on IntegriCloud