Vector types are not arithmetic types, either. Note that we now ban
__real myvec and __imag myvec, since they aren't all that useful (it's
just an identity function) but we might want to use them in more
restricted cases in the future (e.g., "__real mycomplexvec" could
extract the real parts of a vector of complex numbers).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106601 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index af4b7eb..5a7aa89 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -596,7 +596,7 @@
     // GCC allows forward declaration of enum types (forbid by C99 6.7.2.3p2).
     // If a body isn't seen by the time we get here, return false.
     return ET->getDecl()->isDefinition();
-  return isa<ComplexType>(CanonicalType) || isa<VectorType>(CanonicalType);
+  return isa<ComplexType>(CanonicalType);
 }
 
 bool Type::isScalarType() const {
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index eb66d9d..e5c8e97 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -4626,7 +4626,7 @@
   if (lhsType->isExtVectorType()) {
     if (rhsType->isExtVectorType())
       return lhsType == rhsType ? Compatible : Incompatible;
-    if (!rhsType->isVectorType() && rhsType->isArithmeticType())
+    if (rhsType->isArithmeticType())
       return Compatible;
   }
 
@@ -6511,7 +6511,8 @@
     resultType = Input->getType();
     if (resultType->isDependentType())
       break;
-    if (resultType->isArithmeticType()) // C99 6.5.3.3p1
+    if (resultType->isArithmeticType() || // C99 6.5.3.3p1
+        resultType->isVectorType()) 
       break;
     else if (getLangOptions().CPlusPlus && // C++ [expr.unary.op]p6-7
              resultType->isEnumeralType())
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 61d42f0..317e8cd 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -845,7 +845,7 @@
       return false;
    
     // Vector splat from any arithmetic type to a vector.
-    if (!FromType->isVectorType() && FromType->isArithmeticType()) {
+    if (FromType->isArithmeticType()) {
       ICK = ICK_Vector_Splat;
       return true;
     }
@@ -1041,8 +1041,7 @@
               FromType->isAnyPointerType() ||
               FromType->isBlockPointerType() ||
               FromType->isMemberPointerType() ||
-              FromType->isNullPtrType()) &&
-             /*FIXME*/!FromType->isVectorType()) {
+              FromType->isNullPtrType())) {
     // Boolean conversions (C++ 4.12).
     SCS.Second = ICK_Boolean_Conversion;
     FromType = Context.BoolTy;
diff --git a/test/Sema/ext_vector_casts.c b/test/Sema/ext_vector_casts.c
index 7b7b0ca..143ce04 100644
--- a/test/Sema/ext_vector_casts.c
+++ b/test/Sema/ext_vector_casts.c
@@ -48,4 +48,5 @@
 
 void inc(float2 f2) {
   f2++; // expected-error{{cannot increment value of type 'float2'}}
+  __real f2; // expected-error{{invalid type 'float2' to __real operator}}
 }
diff --git a/test/Sema/init.c b/test/Sema/init.c
index c2c29ad..ac274a4 100644
--- a/test/Sema/init.c
+++ b/test/Sema/init.c
@@ -118,8 +118,6 @@
 typedef int32_t ivector4 __attribute((vector_size(16)));
 ivector4 vtest1 = 1 ? (ivector4){1} : (ivector4){1};
 ivector4 vtest2 = __builtin_choose_expr(1, (ivector4){1}, (ivector4){1});
-ivector4 vtest3 = __real__ (ivector4){1};
-ivector4 vtest4 = __imag__ (ivector4){1};
 
 uintptr_t ptrasintadd1 = (uintptr_t)&a - 4;
 uintptr_t ptrasintadd2 = (uintptr_t)&a + 4;