blob: fa3e736d31fe8069ee9be6c974511fb77062ad6f [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -arch i386 -emit-llvm -o %t %s &&
Daniel Dunbard60f2fb2009-02-17 18:43:32 +00002// RUN: grep "g.b = internal global i8. getelementptr" %t &&
Devang Patele40daa42007-10-26 17:50:58 +00003
Oliver Hunt28247232007-12-02 00:11:25 +00004struct AStruct {
5 int i;
6 char *s;
7 double d;
8};
9
Devang Patele40daa42007-10-26 17:50:58 +000010void f() {
11 static int i = 42;
Oliver Hunt28247232007-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 Patele40daa42007-10-26 17:50:58 +000016}
Lauro Ramos Venancio81373352008-02-26 21:41:45 +000017
18void g() {
19 static char a[10];
20 static char *b = a;
21}
Anders Carlssone8a32b82008-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 Dunbard60f2fb2009-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