]> granicus.if.org Git - clang/commitdiff
Handle binary or in constant expressions.
authorAnders Carlsson <andersca@mac.com>
Tue, 29 Jan 2008 01:33:32 +0000 (01:33 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 29 Jan 2008 01:33:32 +0000 (01:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46482 91177308-0d34-0410-b5e6-96231b3b80d8

CodeGen/CGExprConstant.cpp
test/CodeGen/globalinit.c

index faf2096d28b2012e627a0258e17f69934e1afc07..3b1c62bb16da2db056f3a2155ca797ba7180c6bc 100644 (file)
@@ -236,6 +236,14 @@ public:
     return EmitLValue(E->getSubExpr());
   }
   
+  // Binary operators
+  llvm::Constant *VisitBinOr(const BinaryOperator *E) {
+    llvm::Constant *LHS = Visit(E->getLHS());
+    llvm::Constant *RHS = Visit(E->getRHS());
+    
+    return llvm::ConstantExpr::getOr(LHS, RHS);
+  }
+
   // Utility methods
   const llvm::Type *ConvertType(QualType T) {
     return CGM.getTypes().ConvertType(T);
index f868feb24a0ee32bcd0805375044231f49496693..e880b9a9174fccb86e42ab5a822c5777f7e777e2 100644 (file)
@@ -36,8 +36,12 @@ void booltest2() {
 static int a = { 1 };
 static int b = { 1, 2 };
 
+// References to enums.
 enum {
        EnumA, EnumB
 };
 
 int c[] = { EnumA, EnumB };
+
+// Binary operators
+int d[] = { EnumA | EnumB };