Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -triple i386-pc-linux-gnu -emit-llvm -o %t %s |
| 2 | // RUN: grep "g.b = internal global i8. getelementptr" %t |
Devang Patel | e40daa4 | 2007-10-26 17:50:58 +0000 | [diff] [blame] | 3 | |
Oliver Hunt | 2824723 | 2007-12-02 00:11:25 +0000 | [diff] [blame] | 4 | struct AStruct { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 5 | int i; |
| 6 | char *s; |
| 7 | double d; |
Oliver Hunt | 2824723 | 2007-12-02 00:11:25 +0000 | [diff] [blame] | 8 | }; |
| 9 | |
Devang Patel | e40daa4 | 2007-10-26 17:50:58 +0000 | [diff] [blame] | 10 | void f() { |
| 11 | static int i = 42; |
Oliver Hunt | 2824723 | 2007-12-02 00:11:25 +0000 | [diff] [blame] | 12 | 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 Patel | e40daa4 | 2007-10-26 17:50:58 +0000 | [diff] [blame] | 16 | } |
Lauro Ramos Venancio | 8137335 | 2008-02-26 21:41:45 +0000 | [diff] [blame] | 17 | |
| 18 | void g() { |
| 19 | static char a[10]; |
| 20 | static char *b = a; |
| 21 | } |
Anders Carlsson | e8a32b8 | 2008-11-24 05:23:59 +0000 | [diff] [blame] | 22 | |
| 23 | struct s { void *p; }; |
| 24 | |
| 25 | void foo(void) { |
| 26 | static struct s var = {((void*)&((char*)0)[0])}; |
| 27 | } |
Daniel Dunbar | d60f2fb | 2009-02-17 18:43:32 +0000 | [diff] [blame] | 28 | |
| 29 | // RUN: grep "f1.l0 = internal global i32 ptrtoint (i32 ()\* @f1 to i32)" %t |
| 30 | int f1(void) { static int l0 = (unsigned) f1; } |
| 31 | |