diff options
author | Anders Carlsson <andersca@mac.com> | 2008-01-29 01:33:32 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2008-01-29 01:33:32 +0000 |
commit | ce6237edf61ce3e5b8686f303513412c43e69058 (patch) | |
tree | 9b7a7a19506a3d6fde0cae3217f93af96adf8d73 | |
parent | a3881fc62ac1ddbf9c236fffd47b637fb4745bbd (diff) |
Handle binary or in constant expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46482 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | CodeGen/CGExprConstant.cpp | 8 | ||||
-rw-r--r-- | test/CodeGen/globalinit.c | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/CodeGen/CGExprConstant.cpp b/CodeGen/CGExprConstant.cpp index faf2096d28..3b1c62bb16 100644 --- a/CodeGen/CGExprConstant.cpp +++ b/CodeGen/CGExprConstant.cpp @@ -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); diff --git a/test/CodeGen/globalinit.c b/test/CodeGen/globalinit.c index f868feb24a..e880b9a917 100644 --- a/test/CodeGen/globalinit.c +++ b/test/CodeGen/globalinit.c @@ -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 }; |