blob: 8c5cdd05642d2333a086b6875a54af2370600b29 [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o %t %s
Daniel Dunbar8b576972009-11-08 01:45:36 +00002// RUN: grep "g.b = internal global i8. getelementptr" %t
Devang Patelffdb07c2007-10-26 17:50:58 +00003
Oliver Huntaefc8fd2007-12-02 00:11:25 +00004struct AStruct {
Mike Stump11289f42009-09-09 15:08:12 +00005 int i;
6 char *s;
7 double d;
Oliver Huntaefc8fd2007-12-02 00:11:25 +00008};
9
Devang Patelffdb07c2007-10-26 17:50:58 +000010void f() {
11 static int i = 42;
Oliver Huntaefc8fd2007-12-02 00:11:25 +000012 static int is[] = { 1, 2, 3, 4 };
13 static char* str = "forty-two";
14 static char* strs[] = { "one", "two", "three", "four" };
15 static struct AStruct myStruct = { 1, "two", 3.0 };
Devang Patelffdb07c2007-10-26 17:50:58 +000016}
Lauro Ramos Venancio01a72ff2008-02-26 21:41:45 +000017
18void g() {
19 static char a[10];
20 static char *b = a;
21}
Anders Carlssona7c5eb72008-11-24 05:23:59 +000022
23struct s { void *p; };
24
25void foo(void) {
26 static struct s var = {((void*)&((char*)0)[0])};
27}
Daniel Dunbar38ad1e62009-02-17 18:43:32 +000028
29// RUN: grep "f1.l0 = internal global i32 ptrtoint (i32 ()\* @f1 to i32)" %t
30int f1(void) { static int l0 = (unsigned) f1; }
31
John McCall4a39ab82010-05-04 20:45:42 +000032// PR7044
33char *f2(char key) {
34 switch (key) {
35 static char _msg[40];
36 case '\014':
37 return _msg;
38 }
39
40 return 0;
41}