Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o %t %s |
Daniel Dunbar | 8b57697 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 2 | // RUN: grep "g.b = internal global i8. getelementptr" %t |
Devang Patel | ffdb07c | 2007-10-26 17:50:58 +0000 | [diff] [blame] | 3 | |
Oliver Hunt | aefc8fd | 2007-12-02 00:11:25 +0000 | [diff] [blame] | 4 | struct AStruct { |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 5 | int i; |
| 6 | char *s; |
| 7 | double d; |
Oliver Hunt | aefc8fd | 2007-12-02 00:11:25 +0000 | [diff] [blame] | 8 | }; |
| 9 | |
Devang Patel | ffdb07c | 2007-10-26 17:50:58 +0000 | [diff] [blame] | 10 | void f() { |
| 11 | static int i = 42; |
Oliver Hunt | aefc8fd | 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 | ffdb07c | 2007-10-26 17:50:58 +0000 | [diff] [blame] | 16 | } |
Lauro Ramos Venancio | 01a72ff | 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 | a7c5eb7 | 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 | 38ad1e6 | 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 | |
John McCall | 4a39ab8 | 2010-05-04 20:45:42 +0000 | [diff] [blame] | 32 | // PR7044 |
| 33 | char *f2(char key) { |
| 34 | switch (key) { |
| 35 | static char _msg[40]; |
| 36 | case '\014': |
| 37 | return _msg; |
| 38 | } |
| 39 | |
| 40 | return 0; |
| 41 | } |