aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/CGDecl.cpp2
-rw-r--r--test/CodeGen/init.c11
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index ddc68d68c5..bb2705ff60 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -109,7 +109,7 @@ CodeGenFunction::GenerateStaticBlockVarDecl(const VarDecl &D,
assert(0 && "Unknown context for block var decl");
llvm::GlobalValue *GV =
- new llvm::GlobalVariable(Init->getType(), false,
+ new llvm::GlobalVariable(Init->getType(), Ty.isConstant(getContext()),
Linkage,
Init, ContextName + Separator +D.getNameAsString(),
&CGM.getModule(), 0, Ty.getAddressSpace());
diff --git a/test/CodeGen/init.c b/test/CodeGen/init.c
index fa39ba6f5a..b53b81edb8 100644
--- a/test/CodeGen/init.c
+++ b/test/CodeGen/init.c
@@ -1,4 +1,5 @@
-// RUN: clang -emit-llvm %s -o -
+// RUN: clang -triple i386-unknown-unknown -emit-llvm %s -o %t &&
+
void f1() {
// Scalars in braces.
int a = { 1 };
@@ -20,3 +21,11 @@ void f3() {
struct S a[1] = { { foo } };
}
+// Constants
+// RUN: grep '@g3 = constant i32 10' %t &&
+// RUN: grep '@f4.g4 = internal constant i32 12' %t
+const int g3 = 10;
+int f4() {
+ static const int g4 = 12;
+ return g4;
+}