]> granicus.if.org Git - clang/commitdiff
Type Type::isRealFloatingType() that vectors are not floating-point
authorDouglas Gregor <dgregor@apple.com>
Tue, 22 Jun 2010 23:07:26 +0000 (23:07 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 22 Jun 2010 23:07:26 +0000 (23:07 +0000)
types, updating callers of both isFloatingType() and
isRealFloatingType() accordingly. Caught at least one issue where we
allowed one to declare a vector of vectors (!), along with cleaning up
the standard-conversion logic for C++.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106595 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Type.cpp
lib/Analysis/PrintfFormatString.cpp
lib/Checker/CheckSecuritySyntaxOnly.cpp
lib/CodeGen/CGObjCMac.cpp
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaOverload.cpp
lib/Sema/SemaStmt.cpp
test/Sema/ext_vector_casts.c

index 11fd42d62acb3cb5c1a3430a55695b6464ce5f47..a8ead6d46ba1ad01c99e7d9f29864ec4f4599e92 100644 (file)
@@ -576,8 +576,6 @@ bool Type::hasFloatingRepresentation() const {
 bool Type::isRealFloatingType() const {
   if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->isFloatingPoint();
-  if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
-    return VT->getElementType()->isRealFloatingType();
   return false;
 }
 
index 8ad1d21312c3cd11e582713c31dfabd818c1170e..558d38af0c6e94672d846df8f9dcf210d85ad35b 100644 (file)
@@ -757,7 +757,7 @@ bool FormatSpecifier::fixType(QualType QT) {
     HasPlusPrefix = 0;
   }
   // Test for Floating type first as LongDouble can pass isUnsignedIntegerType
-  else if (QT->isFloatingType()) {
+  else if (QT->isRealFloatingType()) {
     CS.setKind(ConversionSpecifier::fArg);
   }
   else if (QT->isPointerType()) {
index 74e12b18a81a0290432749e1c7f936615ecff9be..af85c2faee3a67ad8882f660ffdbaac41271f772 100644 (file)
@@ -191,8 +191,8 @@ void WalkAST::CheckLoopConditionForFloat(const ForStmt *FS) {
   const DeclRefExpr *drRHS = dyn_cast<DeclRefExpr>(B->getRHS()->IgnoreParens());
 
   // Does at least one of the variables have a floating point type?
-  drLHS = drLHS && drLHS->getType()->isFloatingType() ? drLHS : NULL;
-  drRHS = drRHS && drRHS->getType()->isFloatingType() ? drRHS : NULL;
+  drLHS = drLHS && drLHS->getType()->isRealFloatingType() ? drLHS : NULL;
+  drRHS = drRHS && drRHS->getType()->isRealFloatingType() ? drRHS : NULL;
 
   if (!drLHS && !drRHS)
     return;
index fb3bec5ad8c6221d3bdcda3f14a18b5ec0c9e691..f73cfa4af644f68b05eab62edd1defa348388437 100644 (file)
@@ -1646,7 +1646,7 @@ CGObjCCommonMac::EmitLegacyMessageSend(CodeGen::CodeGenFunction &CGF,
   if (CGM.ReturnTypeUsesSret(FnInfo)) {
     Fn = (ObjCABI == 2) ?  ObjCTypes.getSendStretFn2(IsSuper)
       : ObjCTypes.getSendStretFn(IsSuper);
-  } else if (ResultType->isFloatingType()) {
+  } else if (ResultType->isRealFloatingType()) {
     if (ObjCABI == 2) {
       if (const BuiltinType *BT = ResultType->getAs<BuiltinType>()) {
         BuiltinType::Kind k = BT->getKind();
@@ -5200,7 +5200,7 @@ CodeGen::RValue CGObjCNonFragileABIMac::EmitMessageSend(
         Fn = ObjCTypes.getMessageSendStretFixupFn();
         Name += "objc_msgSend_stret_fixup";
       }
-  } else if (!IsSuper && ResultType->isFloatingType()) {
+  } else if (!IsSuper && ResultType->isRealFloatingType()) {
     if (ResultType->isSpecificBuiltinType(BuiltinType::LongDouble)) {
       Fn = ObjCTypes.getMessageSendFpretFixupFn();
       Name += "objc_msgSend_fpret_fixup";
index 07b0c26403aaa38ff1b230534278ccbb7f82359f..0e61f1d23a8898750823670b034356200a659cfa 100644 (file)
@@ -1799,7 +1799,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
     break;
 
   case ICK_Floating_Integral:
-    if (ToType->isFloatingType())
+    if (ToType->isRealFloatingType())
       ImpCastExprToType(From, ToType, CastExpr::CK_IntegralToFloating);
     else
       ImpCastExprToType(From, ToType, CastExpr::CK_FloatingToIntegral);
index b4133e8b4ac7a2a4a33a59a4b0f717d53de7c15c..61d42f083c61f80643b2df13c237e48f4238f4f5 100644 (file)
@@ -1015,14 +1015,14 @@ Sema::IsStandardConversion(Expr* From, QualType ToType,
     // Complex-real conversions (C99 6.3.1.7)
     SCS.Second = ICK_Complex_Real;
     FromType = ToType.getUnqualifiedType();
-  } else if (FromType->isFloatingType() && ToType->isFloatingType()) {
+  } else if (FromType->isRealFloatingType() && ToType->isRealFloatingType()) {
     // Floating point conversions (C++ 4.8).
     SCS.Second = ICK_Floating_Conversion;
     FromType = ToType.getUnqualifiedType();
-  } else if ((FromType->isFloatingType() && 
+  } else if ((FromType->isRealFloatingType() && 
               ToType->isIntegralType(Context) && !ToType->isBooleanType()) ||
              (FromType->isIntegralOrEnumerationType() &&
-              ToType->isFloatingType())) {
+              ToType->isRealFloatingType())) {
     // Floating-integral conversions (C++ 4.9).
     SCS.Second = ICK_Floating_Integral;
     FromType = ToType.getUnqualifiedType();
index 735b069b42538c4d3f104c3b42fb7efa2605eaf2..738fc55823b3d69ba884b2ecaed3d80705f4430f 100644 (file)
@@ -1516,14 +1516,14 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
     
     if (InTy->isIntegerType() || InTy->isPointerType())
       InputDomain = AD_Int;
-    else if (InTy->isFloatingType())
+    else if (InTy->isRealFloatingType())
       InputDomain = AD_FP;
     else
       InputDomain = AD_Other;
 
     if (OutTy->isIntegerType() || OutTy->isPointerType())
       OutputDomain = AD_Int;
-    else if (OutTy->isFloatingType())
+    else if (OutTy->isRealFloatingType())
       OutputDomain = AD_FP;
     else
       OutputDomain = AD_Other;
index d2976238c0e5efc9305cb8d72f847de349b8fe14..be09903e00f7839a40697f0436d898d9a2554abe 100644 (file)
@@ -43,3 +43,5 @@ static void test() {
     ivec4 |= ivec4;
     ivec4 += ptr; // expected-error {{can't convert between vector values of different size ('int4' and 'int *')}}
 }
+
+typedef __attribute__(( ext_vector_type(2) )) float2 vecfloat2; // expected-error{{invalid vector type 'float2'}}