]> granicus.if.org Git - clang/commitdiff
Vector types are not arithmetic types, either. Note that we now ban
authorDouglas Gregor <dgregor@apple.com>
Tue, 22 Jun 2010 23:41:02 +0000 (23:41 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 22 Jun 2010 23:41:02 +0000 (23:41 +0000)
__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

lib/AST/Type.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaOverload.cpp
test/Sema/ext_vector_casts.c
test/Sema/init.c

index af4b7eb3a643995ac9da3da71eff753585ba16cf..5a7aa89d6dfe86ecd81fd696435770493adb3397 100644 (file)
@@ -596,7 +596,7 @@ bool Type::isArithmeticType() const {
     // 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 {
index eb66d9d6c01a9205f592c056e5766166eb678bc3..e5c8e973c531bea24e41ecae7642b883b9558c7f 100644 (file)
@@ -4626,7 +4626,7 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
   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 @@ Action::OwningExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
     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())
index 61d42f083c61f80643b2df13c237e48f4238f4f5..317e8cd6d385e9b4e78e5c531a6ab60d4f389f87 100644 (file)
@@ -845,7 +845,7 @@ static bool IsVectorConversion(ASTContext &Context, QualType FromType,
       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 @@ Sema::IsStandardConversion(Expr* From, QualType ToType,
               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;
index 7b7b0caf0aaca865e0152e823c0c8f215b37376c..143ce04e216c536e16596852c386589bac7458f5 100644 (file)
@@ -48,4 +48,5 @@ typedef __attribute__(( ext_vector_type(2) )) float2 vecfloat2; // expected-erro
 
 void inc(float2 f2) {
   f2++; // expected-error{{cannot increment value of type 'float2'}}
+  __real f2; // expected-error{{invalid type 'float2' to __real operator}}
 }
index c2c29ad9b04b6e0ec69e3c7afe0110422a0d87a9..ac274a4ce2276f5a335c7d4c9877fea1d7e33974 100644 (file)
@@ -118,8 +118,6 @@ int* ptest1 = __builtin_choose_expr(1, (int*)0, (int*)0);
 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;