aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CodeGen/CGExprConstant.cpp2
-rw-r--r--test/CodeGen/globalinit.c12
-rw-r--r--test/CodeGen/init.c4
3 files changed, 13 insertions, 5 deletions
diff --git a/CodeGen/CGExprConstant.cpp b/CodeGen/CGExprConstant.cpp
index da2fef66f0..faf2096d28 100644
--- a/CodeGen/CGExprConstant.cpp
+++ b/CodeGen/CGExprConstant.cpp
@@ -186,6 +186,8 @@ public:
const ValueDecl *Decl = E->getDecl();
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(Decl))
return CGM.GetAddrOfFunctionDecl(FD, false);
+ if (const EnumConstantDecl *EC = dyn_cast<EnumConstantDecl>(Decl))
+ return llvm::ConstantInt::get(EC->getInitVal());
assert(0 && "Unsupported decl ref type!");
return 0;
}
diff --git a/test/CodeGen/globalinit.c b/test/CodeGen/globalinit.c
index 13a9e930bd..f868feb24a 100644
--- a/test/CodeGen/globalinit.c
+++ b/test/CodeGen/globalinit.c
@@ -32,6 +32,12 @@ void booltest2() {
static _Bool booltest3 = 4;
}
-// Braces in a scalar
-int a = { 1 };
-int b = { 1, 2 };
+// Scalars in braces.
+static int a = { 1 };
+static int b = { 1, 2 };
+
+enum {
+ EnumA, EnumB
+};
+
+int c[] = { EnumA, EnumB };
diff --git a/test/CodeGen/init.c b/test/CodeGen/init.c
index 77a85fa75c..24f887422d 100644
--- a/test/CodeGen/init.c
+++ b/test/CodeGen/init.c
@@ -1,7 +1,7 @@
// RUN: clang -emit-llvm %s
void f1()
{
- // Braces in a scalar
+ // Scalars in braces.
int a = { 1 };
int b = { 1, 2 };
-} \ No newline at end of file
+}