Emit the globals, metadata, etc. associated with static variables even when
they're unreachable. This matters because (if they're POD, or if this is C)
the scope containing the variable might be reachable even if the variable
isn't. Fixes PR7044.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103052 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGen/staticinit.c b/test/CodeGen/staticinit.c
index cd1f059..8c5cdd0 100644
--- a/test/CodeGen/staticinit.c
+++ b/test/CodeGen/staticinit.c
@@ -29,3 +29,13 @@
// RUN: grep "f1.l0 = internal global i32 ptrtoint (i32 ()\* @f1 to i32)" %t
int f1(void) { static int l0 = (unsigned) f1; }
+// PR7044
+char *f2(char key) {
+ switch (key) {
+ static char _msg[40];
+ case '\014':
+ return _msg;
+ }
+
+ return 0;
+}