]> granicus.if.org Git - clang/commitdiff
fix test/CodeGen/statements.c on 32-bit hosts.
authorChris Lattner <sabre@nondot.org>
Tue, 13 Oct 2009 22:12:09 +0000 (22:12 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 13 Oct 2009 22:12:09 +0000 (22:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84039 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Expr.cpp
lib/CodeGen/CGExprConstant.cpp

index 8516d41df6cfb1d720ecbc27d16ff2b22e856d00..0e4a29f916fa356b93aab372a6f2f6d3fe8f70cc 100644 (file)
@@ -1281,6 +1281,13 @@ bool Expr::isConstantInitializer(ASTContext &Ctx) const {
     // cast-to-union extension.
     if (getType()->isRecordType())
       return cast<CastExpr>(this)->getSubExpr()->isConstantInitializer(Ctx);
+      
+    // Integer->integer casts can be handled here, which is important for
+    // things like (int)(&&x-&&y).  Scary but true.
+    if (getType()->isIntegerType() &&
+        cast<CastExpr>(this)->getSubExpr()->getType()->isIntegerType())
+      return cast<CastExpr>(this)->getSubExpr()->isConstantInitializer(Ctx);
+      
     break;
   }
   return isEvaluatable(Ctx);
index 119b6f31e4ae3155406be82178cc2e40f1305bc6..7f540c3c068855848f30d815e9e27a08d68c274c 100644 (file)
@@ -548,7 +548,18 @@ public:
       // Explicit and implicit no-op casts
       QualType Ty = E->getType(), SubTy = E->getSubExpr()->getType();
       if (CGM.getContext().hasSameUnqualifiedType(Ty, SubTy))
-          return Visit(E->getSubExpr());
+        return Visit(E->getSubExpr());
+
+      // Handle integer->integer casts for address-of-label differences.
+      if (Ty->isIntegerType() && SubTy->isIntegerType() &&
+          CGF) {
+        llvm::Value *Src = Visit(E->getSubExpr());
+        if (Src == 0) return 0;
+        
+        // Use EmitScalarConversion to perform the conversion.
+        return cast<llvm::Constant>(CGF->EmitScalarConversion(Src, SubTy, Ty));
+      }
+      
       return 0;
     }
     }