blob: cd1f059e570af386d3f976cf5a7cae3a20862bcf [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o %t %s
Daniel Dunbar4fcfde42009-11-08 01:45:36 +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 {
Mike Stump1eb44332009-09-09 15:08:12 +00005 int i;
6 char *s;
7 double d;
Oliver Hunt28247232007-12-02 00:11:25 +00008};
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